From 39e180aad49d6bc1d11c765297a65a9531ec4f11 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Sun, 8 Mar 2026 23:50:31 +0000 Subject: [PATCH 01/53] v1.8.3 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 53adb84..a7ee35a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.2 +1.8.3 From 8abe0775a5820bab86de7f48bf56293847f06397 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 02:12:02 +0100 Subject: [PATCH 02/53] feat: Discord-style glass morphism UI redesign + nightly CI/CD - App shell: gradient title, glass admin modal, avatar, admin login/logout - All plugin empty states: floating icon animations, updated typography - Soundboard: orange accent theme replacing blurple default - Global styles: glass morphism variables, Discord-dark color palette - CI/CD: nightly deploy (stops main, starts nightly on port 8085) + manual restore-main job Co-Authored-By: Claude Opus 4.6 --- .gitlab-ci.yml | 90 +++++++ web/src/App.tsx | 94 ++++++- web/src/plugins/game-library/game-library.css | 24 +- web/src/plugins/lolstats/lolstats.css | 24 +- web/src/plugins/soundboard/soundboard.css | 128 +++++++--- web/src/plugins/streaming/streaming.css | 25 +- .../plugins/watch-together/watch-together.css | 25 +- web/src/styles.css | 240 +++++++++++++++++- 8 files changed, 556 insertions(+), 94 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9000ddf..5bfaed3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -171,6 +171,96 @@ deploy: "$DEPLOY_IMAGE" - docker ps --filter name="$CONTAINER_NAME" --format "ID={{.ID}} Status={{.Status}} Image={{.Image}}" +deploy-nightly: + stage: deploy + image: docker:latest + needs: [docker-build] + rules: + - if: $CI_COMMIT_BRANCH == "nightly" + variables: + DEPLOY_IMAGE: "$INTERNAL_REGISTRY/root/gaming-hub:nightly" + CONTAINER_NAME: "gaming-hub-nightly" + script: + - echo "[Nightly Deploy] Logging into registry..." + - echo "$CI_REGISTRY_PASSWORD" | docker login "$INTERNAL_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin + - echo "[Nightly Deploy] Pulling $DEPLOY_IMAGE..." + - docker pull "$DEPLOY_IMAGE" + - echo "[Nightly Deploy] Stopping main container..." + - docker stop gaming-hub || true + - docker rm gaming-hub || true + - echo "[Nightly Deploy] Stopping old nightly container..." + - docker stop "$CONTAINER_NAME" || true + - docker rm "$CONTAINER_NAME" || true + - echo "[Nightly Deploy] Starting $CONTAINER_NAME..." + - | + docker run -d \ + --name "$CONTAINER_NAME" \ + --network pangolin \ + --restart unless-stopped \ + --label "channel=nightly" \ + -p 8085:8080 \ + -e TZ=Europe/Berlin \ + -e NODE_ENV=production \ + -e PORT=8080 \ + -e DATA_DIR=/data \ + -e SOUNDS_DIR=/data/sounds \ + -e "NODE_OPTIONS=--dns-result-order=ipv4first" \ + -e ADMIN_PWD="$GAMING_HUB_ADMIN_PWD" \ + -e PCM_CACHE_MAX_MB=2048 \ + -e DISCORD_TOKEN_JUKEBOX="$GAMING_HUB_DISCORD_JUKEBOX" \ + -e DISCORD_TOKEN_RADIO="$GAMING_HUB_DISCORD_RADIO" \ + -e DISCORD_TOKEN_NOTIFICATIONS="$GAMING_HUB_DISCORD_NOTIFICATIONS" \ + -e PUBLIC_URL="$GAMING_HUB_PUBLIC_URL" \ + -e STEAM_API_KEY="$STEAM_API_KEY" \ + -v /mnt/cache/appdata/gaming-hub/data:/data:rw \ + -v /mnt/cache/appdata/dockge/container/jukebox/sounds/:/data/sounds:rw \ + "$DEPLOY_IMAGE" + - docker ps --filter name="$CONTAINER_NAME" --format "ID={{.ID}} Status={{.Status}} Image={{.Image}}" + +restore-main: + stage: deploy + image: docker:latest + needs: [docker-build] + rules: + - if: $CI_COMMIT_BRANCH == "nightly" + when: manual + allow_failure: true + variables: + DEPLOY_IMAGE: "$INTERNAL_REGISTRY/root/gaming-hub:latest" + CONTAINER_NAME: "gaming-hub" + script: + - echo "[Restore Main] Logging into registry..." + - echo "$CI_REGISTRY_PASSWORD" | docker login "$INTERNAL_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin + - echo "[Restore Main] Stopping nightly container..." + - docker stop gaming-hub-nightly || true + - docker rm gaming-hub-nightly || true + - echo "[Restore Main] Pulling $DEPLOY_IMAGE..." + - docker pull "$DEPLOY_IMAGE" + - echo "[Restore Main] Starting $CONTAINER_NAME..." + - | + docker run -d \ + --name "$CONTAINER_NAME" \ + --network pangolin \ + --restart unless-stopped \ + -p 8085:8080 \ + -e TZ=Europe/Berlin \ + -e NODE_ENV=production \ + -e PORT=8080 \ + -e DATA_DIR=/data \ + -e SOUNDS_DIR=/data/sounds \ + -e "NODE_OPTIONS=--dns-result-order=ipv4first" \ + -e ADMIN_PWD="$GAMING_HUB_ADMIN_PWD" \ + -e PCM_CACHE_MAX_MB=2048 \ + -e DISCORD_TOKEN_JUKEBOX="$GAMING_HUB_DISCORD_JUKEBOX" \ + -e DISCORD_TOKEN_RADIO="$GAMING_HUB_DISCORD_RADIO" \ + -e DISCORD_TOKEN_NOTIFICATIONS="$GAMING_HUB_DISCORD_NOTIFICATIONS" \ + -e PUBLIC_URL="$GAMING_HUB_PUBLIC_URL" \ + -e STEAM_API_KEY="$STEAM_API_KEY" \ + -v /mnt/cache/appdata/gaming-hub/data:/data:rw \ + -v /mnt/cache/appdata/dockge/container/jukebox/sounds/:/data/sounds:rw \ + "$DEPLOY_IMAGE" + - docker ps --filter name="$CONTAINER_NAME" --format "ID={{.ID}} Status={{.Status}} Image={{.Image}}" + bump-version: stage: bump-version image: diff --git a/web/src/App.tsx b/web/src/App.tsx index eeed0b4..fb12660 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -40,6 +40,12 @@ export default function App() { const [showVersionModal, setShowVersionModal] = useState(false); const [pluginData, setPluginData] = useState>({}); + // Admin state + const [adminLoggedIn, setAdminLoggedIn] = useState(false); + const [showAdminModal, setShowAdminModal] = useState(false); + const [adminPassword, setAdminPassword] = useState(''); + const [adminError, setAdminError] = useState(''); + // Electron auto-update state const isElectron = !!(window as any).electronAPI?.isElectron; const electronVersion = isElectron ? (window as any).electronAPI.version : null; @@ -130,13 +136,43 @@ export default function App() { const version = (import.meta as any).env?.VITE_APP_VERSION ?? 'dev'; - // Close version modal on Escape + // Close modals on Escape useEffect(() => { - if (!showVersionModal) return; - const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') setShowVersionModal(false); }; + if (!showVersionModal && !showAdminModal) return; + const handler = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + setShowVersionModal(false); + setShowAdminModal(false); + } + }; window.addEventListener('keydown', handler); return () => window.removeEventListener('keydown', handler); - }, [showVersionModal]); + }, [showVersionModal, showAdminModal]); + + // Admin login handler + const handleAdminLogin = () => { + if (!adminPassword) return; + fetch('/api/admin/login', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ password: adminPassword }), + }) + .then(r => { + if (r.ok) { + setAdminLoggedIn(true); + setAdminPassword(''); + setAdminError(''); + } else { + setAdminError('Falsches Passwort'); + } + }) + .catch(() => setAdminError('Verbindungsfehler')); + }; + + const handleAdminLogout = () => { + setAdminLoggedIn(false); + setShowAdminModal(false); + }; // Tab icon mapping @@ -198,7 +234,6 @@ export default function App() { { - // Status vom Main-Prozess synchronisieren bevor Modal öffnet if (isElectron) { const api = (window as any).electronAPI; const s = api.getUpdateStatus?.(); @@ -212,6 +247,15 @@ export default function App() { > v{version} + +
DK
@@ -307,6 +351,46 @@ export default function App() { )} + {showAdminModal && ( +
setShowAdminModal(false)}> +
e.stopPropagation()}> + {adminLoggedIn ? ( + <> +
Admin Panel
+
+
A
+
+ Administrator + Eingeloggt +
+
+ + + ) : ( + <> +
{'\u{1F511}'} Admin Login
+
Passwort eingeben um Einstellungen freizuschalten
+ {adminError &&
{adminError}
} + setAdminPassword(e.target.value)} + onKeyDown={e => { if (e.key === 'Enter') handleAdminLogin(); }} + autoFocus + /> + + + )} +
+
+ )} +
{plugins.length === 0 ? (
diff --git a/web/src/plugins/game-library/game-library.css b/web/src/plugins/game-library/game-library.css index 372c8f0..2ed46b4 100644 --- a/web/src/plugins/game-library/game-library.css +++ b/web/src/plugins/game-library/game-library.css @@ -472,24 +472,30 @@ /* ── Empty state ── */ .gl-empty { - text-align: center; - padding: 60px 20px; + flex: 1; display: flex; flex-direction: column; + align-items: center; justify-content: center; gap: 16px; + padding: 40px; height: 100%; } .gl-empty-icon { - font-size: 48px; - margin-bottom: 16px; + font-size: 64px; line-height: 1; + filter: drop-shadow(0 0 20px rgba(230,126,34,0.5)); + animation: gl-empty-float 3s ease-in-out infinite; +} + +@keyframes gl-empty-float { + 0%, 100% { transform: translateY(0); } + 50% { transform: translateY(-8px); } } .gl-empty h3 { - color: var(--text-normal); - margin: 0 0 8px; + font-size: 26px; font-weight: 700; color: #f2f3f5; + letter-spacing: -0.5px; margin: 0; } .gl-empty p { - color: var(--text-faint); - margin: 0; - font-size: 14px; + font-size: 15px; color: #80848e; + text-align: center; max-width: 360px; line-height: 1.5; margin: 0; } /* ── Common game playtime chips ── */ diff --git a/web/src/plugins/lolstats/lolstats.css b/web/src/plugins/lolstats/lolstats.css index 59503c4..f4b552d 100644 --- a/web/src/plugins/lolstats/lolstats.css +++ b/web/src/plugins/lolstats/lolstats.css @@ -456,22 +456,26 @@ } .lol-empty { - text-align: center; - padding: 60px 20px; - color: var(--text-faint); + flex: 1; display: flex; flex-direction: column; + align-items: center; justify-content: center; gap: 16px; + padding: 40px; height: 100%; } .lol-empty-icon { - font-size: 48px; - margin-bottom: 12px; + font-size: 64px; line-height: 1; + filter: drop-shadow(0 0 20px rgba(230,126,34,0.5)); + animation: lol-float 3s ease-in-out infinite; +} +@keyframes lol-float { + 0%, 100% { transform: translateY(0); } + 50% { transform: translateY(-8px); } } .lol-empty h3 { - margin: 0 0 8px; - color: var(--text-muted); - font-size: 16px; + font-size: 26px; font-weight: 700; color: #f2f3f5; + letter-spacing: -0.5px; margin: 0; } .lol-empty p { - margin: 0; - font-size: 13px; + font-size: 15px; color: #80848e; + text-align: center; max-width: 360px; line-height: 1.5; margin: 0; } /* ── Load more ── */ diff --git a/web/src/plugins/soundboard/soundboard.css b/web/src/plugins/soundboard/soundboard.css index be47e1a..1c69e0a 100644 --- a/web/src/plugins/soundboard/soundboard.css +++ b/web/src/plugins/soundboard/soundboard.css @@ -3,7 +3,7 @@ /* Soundboard Plugin — ported from Jukebox styles */ /* ──────────────────────────────────────────── - Theme Variables — Default (Discord Blurple) + Theme Variables — Default (Orange Accent) ──────────────────────────────────────────── */ .sb-app { --bg-deep: #1a1b1e; @@ -18,10 +18,10 @@ --text-muted: #949ba4; --text-faint: #6d6f78; - --accent: #5865f2; - --accent-rgb: 88, 101, 242; - --accent-hover: #4752c4; - --accent-glow: rgba(88, 101, 242, .45); + --accent: #e67e22; + --accent-rgb: 230, 126, 34; + --accent-hover: #d35400; + --accent-glow: rgba(230, 126, 34, .45); --green: #23a55a; --red: #f23f42; @@ -91,6 +91,18 @@ --accent-glow: rgba(52, 152, 219, .4); } +/* ── Theme: Cherry ── */ +.sb-app[data-theme="cherry"] { + --bg-deep: #1a0f14; + --bg-primary: #221419; + --bg-secondary: #2f1c22; + --bg-tertiary: #3d242c; + --accent: #e74c3c; + --accent-rgb: 231, 76, 60; + --accent-hover: #c0392b; + --accent-glow: rgba(231, 76, 60, .4); +} + /* ──────────────────────────────────────────── App Layout ──────────────────────────────────────────── */ @@ -310,6 +322,33 @@ margin-left: 2px; } +/* ── Disconnect Button ── */ +.disconnect-btn { + display: flex; + align-items: center; + gap: 5px; + padding: 4px 10px; + border-radius: 20px; + background: rgba(242, 63, 66, .1); + border: 1px solid rgba(242, 63, 66, .2); + backdrop-filter: blur(8px); + color: var(--red); + font-size: 12px; + font-weight: 600; + cursor: pointer; + transition: all var(--transition); +} + +.disconnect-btn:hover { + background: rgba(242, 63, 66, .2); + border-color: rgba(242, 63, 66, .4); + box-shadow: 0 0 12px rgba(242, 63, 66, .15); +} + +.disconnect-btn:active { + transform: scale(0.97); +} + /* ── Connection Details Modal ── */ .conn-modal-overlay { position: fixed; @@ -340,9 +379,10 @@ align-items: center; gap: 8px; padding: 14px 16px; - border-bottom: 1px solid var(--border); - font-weight: 700; + border-bottom: 1px solid rgba(255,255,255,.06); font-size: 14px; + font-weight: 700; + color: var(--text-normal); } .conn-modal-close { margin-left: auto; @@ -438,7 +478,9 @@ gap: 6px; padding: 6px 14px; border-radius: 20px; - background: var(--bg-tertiary); + background: rgba(255, 255, 255, .05); + border: 1px solid rgba(255, 255, 255, .08); + backdrop-filter: blur(8px); color: var(--text-muted); font-family: var(--font); font-size: 13px; @@ -449,13 +491,16 @@ } .cat-tab:hover { - background: var(--bg-modifier-selected); + background: rgba(255, 255, 255, .1); + border-color: rgba(255, 255, 255, .15); color: var(--text-normal); } .cat-tab.active { background: var(--accent); color: var(--white); + border-color: var(--accent); + box-shadow: 0 2px 12px rgba(var(--accent-rgb), .35); } .tab-count { @@ -489,9 +534,9 @@ width: 100%; height: 32px; padding: 0 28px 0 32px; - border: 1px solid rgba(255, 255, 255, .06); + border: 1px solid rgba(255, 255, 255, .08); border-radius: 20px; - background: var(--bg-secondary); + background: var(--bg-deep); color: var(--text-normal); font-family: var(--font); font-size: 13px; @@ -572,8 +617,8 @@ height: 24px; padding: 0 10px; border-radius: 14px; - border: 1px solid rgba(var(--accent-rgb, 88, 101, 242), .45); - background: rgba(var(--accent-rgb, 88, 101, 242), .12); + border: 1px solid rgba(var(--accent-rgb), .45); + background: rgba(var(--accent-rgb), .12); color: var(--accent); font-size: 11px; font-weight: 700; @@ -639,7 +684,7 @@ } .tb-btn.random { - border-color: rgba(88, 101, 242, .3); + border-color: rgba(230, 126, 34, .3); color: var(--accent); } @@ -834,7 +879,7 @@ gap: 4px; padding: 3px 8px; border-radius: 999px; - background: rgba(var(--accent-rgb, 88, 101, 242), .15); + background: rgba(var(--accent-rgb), .15); color: var(--accent); font-size: 11px; font-weight: 600; @@ -875,8 +920,9 @@ font-size: 12px; font-weight: 600; color: var(--text-muted); - background: var(--bg-secondary); - border: 1px solid rgba(255, 255, 255, .06); + background: rgba(255, 255, 255, .05); + border: 1px solid rgba(255, 255, 255, .08); + backdrop-filter: blur(8px); white-space: nowrap; cursor: pointer; transition: all var(--transition); @@ -884,13 +930,16 @@ } .cat-chip:hover { - border-color: rgba(255, 255, 255, .12); + border-color: rgba(255, 255, 255, .15); color: var(--text-normal); - background: var(--bg-tertiary); + background: rgba(255, 255, 255, .1); } .cat-chip.active { - background: rgba(88, 101, 242, .1); + background: var(--accent); + color: var(--white); + border-color: var(--accent); + box-shadow: 0 2px 12px rgba(var(--accent-rgb), .35); } .cat-dot { @@ -924,7 +973,7 @@ } /* ──────────────────────────────────────────── - Sound Card + Sound Card — Glass Morphism ──────────────────────────────────────────── */ .sound-card { position: relative; @@ -934,11 +983,13 @@ justify-content: center; gap: 3px; padding: 12px 6px 8px; - background: var(--bg-secondary); + background: rgba(255, 255, 255, .05); + border: 1px solid rgba(255, 255, 255, .08); + backdrop-filter: blur(8px); + -webkit-backdrop-filter: blur(8px); border-radius: var(--radius-lg); cursor: pointer; transition: all var(--transition); - border: 2px solid transparent; user-select: none; overflow: hidden; aspect-ratio: 1; @@ -953,15 +1004,14 @@ border-radius: inherit; opacity: 0; transition: opacity var(--transition); - background: radial-gradient(ellipse at center, var(--accent-glow) 0%, transparent 70%); + background: radial-gradient(circle at 50% 0%, rgba(var(--accent-rgb), .12), transparent 70%); pointer-events: none; } .sound-card:hover { - background: var(--bg-tertiary); - transform: translateY(-3px); - box-shadow: var(--shadow-med), 0 0 20px var(--accent-glow); - border-color: rgba(88, 101, 242, .2); + transform: scale(1.05); + border-color: rgba(var(--accent-rgb), .35); + box-shadow: 0 4px 20px rgba(var(--accent-rgb), .15); } .sound-card:hover::before { @@ -969,7 +1019,7 @@ } .sound-card:active { - transform: translateY(0); + transform: scale(0.97); transition-duration: 50ms; } @@ -992,7 +1042,7 @@ .ripple { position: absolute; border-radius: 50%; - background: rgba(88, 101, 242, .3); + background: rgba(var(--accent-rgb), .3); transform: scale(0); animation: ripple-expand 500ms ease-out forwards; pointer-events: none; @@ -1171,8 +1221,8 @@ gap: 6px; padding: 4px 12px; border-radius: 20px; - background: rgba(var(--accent-rgb, 88, 101, 242), .12); - border: 1px solid rgba(var(--accent-rgb, 88, 101, 242), .2); + background: rgba(var(--accent-rgb), .12); + border: 1px solid rgba(var(--accent-rgb), .2); font-size: 12px; color: var(--text-muted); max-width: none; @@ -1251,23 +1301,26 @@ .vol-slider::-webkit-slider-thumb { -webkit-appearance: none; - width: 12px; - height: 12px; + width: 14px; + height: 14px; border-radius: 50%; background: var(--accent); + box-shadow: 0 0 8px rgba(var(--accent-rgb), .5); cursor: pointer; - transition: transform var(--transition); + transition: transform var(--transition), box-shadow var(--transition); } .vol-slider::-webkit-slider-thumb:hover { transform: scale(1.3); + box-shadow: 0 0 14px rgba(var(--accent-rgb), .7); } .vol-slider::-moz-range-thumb { - width: 12px; - height: 12px; + width: 14px; + height: 14px; border-radius: 50%; background: var(--accent); + box-shadow: 0 0 8px rgba(var(--accent-rgb), .5); border: none; cursor: pointer; } @@ -2042,7 +2095,6 @@ z-index: 300; animation: fade-in 150ms ease; } -@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } } .dl-modal { width: 420px; max-width: 92vw; diff --git a/web/src/plugins/streaming/streaming.css b/web/src/plugins/streaming/streaming.css index 9d43c2e..6f8cffa 100644 --- a/web/src/plugins/streaming/streaming.css +++ b/web/src/plugins/streaming/streaming.css @@ -356,23 +356,26 @@ /* ── Empty state ── */ .stream-empty { - text-align: center; - padding: 60px 20px; - color: var(--text-muted); + flex: 1; display: flex; flex-direction: column; + align-items: center; justify-content: center; gap: 16px; + padding: 40px; height: 100%; } .stream-empty-icon { - font-size: 48px; - margin-bottom: 12px; - opacity: 0.4; + font-size: 64px; line-height: 1; + filter: drop-shadow(0 0 20px rgba(230,126,34,0.5)); + animation: stream-float 3s ease-in-out infinite; +} +@keyframes stream-float { + 0%, 100% { transform: translateY(0); } + 50% { transform: translateY(-8px); } } .stream-empty h3 { - font-size: 18px; - font-weight: 600; - color: var(--text-normal); - margin-bottom: 6px; + font-size: 26px; font-weight: 700; color: #f2f3f5; + letter-spacing: -0.5px; margin: 0; } .stream-empty p { - font-size: 14px; + font-size: 15px; color: #80848e; + text-align: center; max-width: 360px; line-height: 1.5; margin: 0; } /* ── Error ── */ diff --git a/web/src/plugins/watch-together/watch-together.css b/web/src/plugins/watch-together/watch-together.css index 1873674..c24e283 100644 --- a/web/src/plugins/watch-together/watch-together.css +++ b/web/src/plugins/watch-together/watch-together.css @@ -161,23 +161,26 @@ /* ── Empty state ── */ .wt-empty { - text-align: center; - padding: 60px 20px; - color: var(--text-muted); + flex: 1; display: flex; flex-direction: column; + align-items: center; justify-content: center; gap: 16px; + padding: 40px; height: 100%; } .wt-empty-icon { - font-size: 48px; - margin-bottom: 12px; - opacity: 0.4; + font-size: 64px; line-height: 1; + filter: drop-shadow(0 0 20px rgba(230,126,34,0.5)); + animation: wt-float 3s ease-in-out infinite; +} +@keyframes wt-float { + 0%, 100% { transform: translateY(0); } + 50% { transform: translateY(-8px); } } .wt-empty h3 { - font-size: 18px; - font-weight: 600; - color: var(--text-normal); - margin-bottom: 6px; + font-size: 26px; font-weight: 700; color: #f2f3f5; + letter-spacing: -0.5px; margin: 0; } .wt-empty p { - font-size: 14px; + font-size: 15px; color: #80848e; + text-align: center; max-width: 360px; line-height: 1.5; margin: 0; } /* ── Error ── */ diff --git a/web/src/styles.css b/web/src/styles.css index 656b9d5..50e7604 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -4,19 +4,27 @@ --bg-primary: #1e1f22; --bg-secondary: #2b2d31; --bg-tertiary: #313338; - --text-normal: #dbdee1; - --text-muted: #949ba4; - --text-faint: #6d6f78; + --bg-light: #3a3c41; + --bg-lighter: #43464d; + --text-normal: #f2f3f5; + --text-muted: #b5bac1; + --text-faint: #80848e; --accent: #e67e22; --accent-rgb: 230, 126, 34; --accent-hover: #d35400; - --success: #57d28f; + --accent-glow: rgba(230, 126, 34, 0.5); + --accent-dim: rgba(230, 126, 34, 0.35); + --accent-subtle: rgba(230, 126, 34, 0.12); + --glass-bg: rgba(255, 255, 255, 0.05); + --glass-border: rgba(255, 255, 255, 0.08); + --glass-bg-hover: rgba(255, 255, 255, 0.09); + --success: #23a559; --danger: #ed4245; --warning: #fee75c; --border: rgba(255, 255, 255, 0.06); --radius: 8px; --radius-lg: 12px; - --transition: 150ms ease; + --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); --font: 'Segoe UI', system-ui, -apple-system, sans-serif; --header-height: 56px; } @@ -78,14 +86,18 @@ html, body { .hub-logo { font-size: 24px; line-height: 1; + filter: drop-shadow(0 0 6px var(--accent-glow)); } .hub-title { font-size: 18px; font-weight: 700; - color: var(--text-normal); letter-spacing: -0.02em; white-space: nowrap; + background: linear-gradient(135deg, var(--accent), #f39c12); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; } /* ── Connection Status Dot ── */ @@ -155,8 +167,8 @@ html, body { } .hub-tab.active { - color: var(--accent); - background: rgba(var(--accent-rgb), 0.1); + color: var(--text-normal); + background: var(--accent-subtle); } .hub-tab.active::after { @@ -165,10 +177,11 @@ html, body { bottom: -1px; left: 50%; transform: translateX(-50%); - width: calc(100% - 16px); + width: 70%; height: 2px; background: var(--accent); - border-radius: 1px; + border-radius: 2px; + box-shadow: 0 0 8px var(--accent-glow), 0 0 16px rgba(230,126,34,0.2); } .hub-tab-icon { @@ -616,6 +629,213 @@ html, body { color: var(--text-normal); } +/* ── Admin Button ── */ +.hub-admin-btn { + background: var(--glass-bg); + border: 1px solid var(--glass-border); + color: var(--text-muted); + font-size: 16px; + width: 36px; + height: 36px; + border-radius: 50%; + cursor: pointer; + transition: all var(--transition); + display: flex; + align-items: center; + justify-content: center; + position: relative; +} + +.hub-admin-btn:hover { + background: var(--glass-bg-hover); + border-color: var(--accent-dim); + box-shadow: 0 0 12px rgba(230,126,34,0.15); +} + +.hub-admin-btn.logged-in { + border-color: var(--success); +} + +.hub-admin-green-dot { + position: absolute; + top: 1px; + right: 1px; + width: 8px; + height: 8px; + background: var(--success); + border-radius: 50%; + border: 2px solid var(--bg-primary); +} + +/* ── Avatar ── */ +.hub-avatar { + width: 34px; + height: 34px; + border-radius: 50%; + background: linear-gradient(135deg, var(--accent), #f39c12); + display: flex; + align-items: center; + justify-content: center; + font-size: 14px; + font-weight: 700; + color: #fff; + box-shadow: 0 0 0 2px var(--bg-primary); +} + +/* ── Admin Modal ── */ +.hub-admin-overlay { + position: fixed; + inset: 0; + background: rgba(0,0,0,0.7); + backdrop-filter: blur(6px); + -webkit-backdrop-filter: blur(6px); + z-index: 1000; + display: flex; + align-items: center; + justify-content: center; + animation: hub-modal-fade-in 0.2s ease; +} + +@keyframes hub-modal-fade-in { + from { opacity: 0; } + to { opacity: 1; } +} + +.hub-admin-modal { + background: var(--bg-secondary); + border: 1px solid var(--glass-border); + border-radius: var(--radius-lg); + padding: 32px; + width: 360px; + max-width: 90vw; + box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 40px rgba(230,126,34,0.08); + animation: hub-modal-slide-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); +} + +@keyframes hub-modal-slide-in { + from { opacity: 0; transform: scale(0.95) translateY(10px); } + to { opacity: 1; transform: scale(1) translateY(0); } +} + +.hub-admin-modal-title { + font-size: 20px; + font-weight: 700; + margin-bottom: 6px; + display: flex; + align-items: center; + gap: 8px; +} + +.hub-admin-modal-subtitle { + font-size: 13px; + color: var(--text-faint); + margin-bottom: 24px; +} + +.hub-admin-modal-error { + font-size: 13px; + color: var(--danger); + margin-bottom: 12px; + padding: 8px 12px; + background: rgba(237, 66, 69, 0.1); + border-radius: var(--radius); +} + +.hub-admin-modal-input { + width: 100%; + background: var(--bg-deep); + border: 1px solid var(--glass-border); + border-radius: var(--radius); + color: var(--text-normal); + font-family: var(--font); + font-size: 14px; + padding: 10px 14px; + outline: none; + transition: border-color var(--transition), box-shadow var(--transition); + margin-bottom: 16px; +} + +.hub-admin-modal-input:focus { + border-color: var(--accent); + box-shadow: 0 0 0 3px rgba(230,126,34,0.12); +} + +.hub-admin-modal-login { + width: 100%; + background: var(--accent); + border: none; + border-radius: var(--radius); + color: #fff; + font-family: var(--font); + font-size: 14px; + font-weight: 600; + padding: 10px; + cursor: pointer; + transition: all var(--transition); + box-shadow: 0 2px 10px var(--accent-dim); +} + +.hub-admin-modal-login:hover { + background: var(--accent-hover); + box-shadow: 0 4px 16px var(--accent-glow); +} + +.hub-admin-modal-info { + display: flex; + align-items: center; + gap: 12px; + margin-bottom: 20px; +} + +.hub-admin-modal-avatar { + width: 44px; + height: 44px; + border-radius: 50%; + background: linear-gradient(135deg, var(--accent), #f39c12); + display: flex; + align-items: center; + justify-content: center; + font-size: 20px; + font-weight: 700; + color: #fff; + box-shadow: 0 0 12px var(--accent-dim); +} + +.hub-admin-modal-text { + display: flex; + flex-direction: column; + gap: 2px; +} + +.hub-admin-modal-name { + font-weight: 600; + font-size: 15px; +} + +.hub-admin-modal-role { + font-size: 12px; + color: var(--success); + font-weight: 500; +} + +.hub-admin-modal-logout { + width: 100%; + background: rgba(237,66,69,0.12); + border: 1px solid rgba(237,66,69,0.25); + border-radius: var(--radius); + color: var(--danger); + font-family: var(--font); + font-size: 14px; + font-weight: 500; + padding: 10px; + cursor: pointer; + transition: all var(--transition); +} + +.hub-admin-modal-logout:hover { + background: rgba(237,66,69,0.2); +} + /* ── Focus Styles ── */ :focus-visible { outline: 2px solid var(--accent); From b3080fb763ee632fd99e64ea756e4b2757a08952 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 11:11:34 +0100 Subject: [PATCH 03/53] =?UTF-8?q?Refactor:=20Zentralisiertes=20Admin-Login?= =?UTF-8?q?=20f=C3=BCr=20alle=20Tabs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Admin-Auth aus Soundboard-Plugin in core/auth.ts extrahiert. Ein Login-Button im Header gilt jetzt für die gesamte Webseite. Cookie-basiert (HMAC-SHA256, 7 Tage) — überlebt Page-Reload. Co-Authored-By: Claude Opus 4.6 --- server/src/core/auth.ts | 61 +++++++++++++++++++ server/src/core/middleware.ts | 20 +------ server/src/index.ts | 12 +++- server/src/plugins/soundboard/index.ts | 51 +--------------- web/src/App.tsx | 27 +++++++-- web/src/plugins/soundboard/SoundboardTab.tsx | 63 +------------------- 6 files changed, 101 insertions(+), 133 deletions(-) create mode 100644 server/src/core/auth.ts diff --git a/server/src/core/auth.ts b/server/src/core/auth.ts new file mode 100644 index 0000000..4373913 --- /dev/null +++ b/server/src/core/auth.ts @@ -0,0 +1,61 @@ +import crypto from 'node:crypto'; +import type { Request, Response, NextFunction } from 'express'; + +const COOKIE_NAME = 'admin_token'; +const TOKEN_TTL_MS = 7 * 24 * 3600 * 1000; // 7 days + +type AdminPayload = { iat: number; exp: number }; + +function b64url(input: Buffer | string): string { + return Buffer.from(input).toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_'); +} + +export function signAdminToken(adminPwd: string): string { + const payload: AdminPayload = { iat: Date.now(), exp: Date.now() + TOKEN_TTL_MS }; + const body = b64url(JSON.stringify(payload)); + const sig = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); + return `${body}.${sig}`; +} + +export function verifyAdminToken(adminPwd: string, token: string | undefined): boolean { + if (!token || !adminPwd) return false; + const [body, sig] = token.split('.'); + if (!body || !sig) return false; + const expected = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); + if (expected !== sig) return false; + try { + const payload = JSON.parse(Buffer.from(body, 'base64').toString('utf8')) as AdminPayload; + return typeof payload.exp === 'number' && Date.now() < payload.exp; + } catch { return false; } +} + +export function readCookie(req: Request, key: string): string | undefined { + const c = req.headers.cookie; + if (!c) return undefined; + for (const part of c.split(';')) { + const [k, v] = part.trim().split('='); + if (k === key) return decodeURIComponent(v || ''); + } + return undefined; +} + +export function setAdminCookie(res: Response, token: string): void { + res.setHeader('Set-Cookie', `${COOKIE_NAME}=${encodeURIComponent(token)}; HttpOnly; Path=/; Max-Age=${7 * 24 * 3600}; SameSite=Lax`); +} + +export function clearAdminCookie(res: Response): void { + res.setHeader('Set-Cookie', `${COOKIE_NAME}=; HttpOnly; Path=/; Max-Age=0; SameSite=Lax`); +} + +export function requireAdmin(adminPwd: string) { + return (req: Request, res: Response, next: NextFunction): void => { + if (!adminPwd) { res.status(503).json({ error: 'ADMIN_PWD not configured' }); return; } + if (!verifyAdminToken(adminPwd, readCookie(req, COOKIE_NAME))) { + res.status(401).json({ error: 'Nicht eingeloggt' }); + return; + } + next(); + }; +} + +export { COOKIE_NAME }; diff --git a/server/src/core/middleware.ts b/server/src/core/middleware.ts index fc29a4b..7c5e7cd 100644 --- a/server/src/core/middleware.ts +++ b/server/src/core/middleware.ts @@ -1,24 +1,8 @@ import { Request, Response, NextFunction } from 'express'; import type { PluginContext } from './plugin.js'; -/** - * Admin authentication middleware. - * Checks `x-admin-password` header against ADMIN_PWD env var. - */ -export function adminAuth(ctx: PluginContext) { - return (req: Request, res: Response, next: NextFunction): void => { - if (!ctx.adminPwd) { - res.status(503).json({ error: 'ADMIN_PWD not configured' }); - return; - } - const pwd = req.headers['x-admin-password'] as string | undefined; - if (pwd !== ctx.adminPwd) { - res.status(401).json({ error: 'Unauthorized' }); - return; - } - next(); - }; -} +// Re-export centralised admin auth +export { requireAdmin } from './auth.js'; /** * Guild filter middleware. diff --git a/server/src/index.ts b/server/src/index.ts index 6c322c2..9ccfa47 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -8,6 +8,7 @@ import { createClient } from './core/discord.js'; import { addSSEClient, removeSSEClient, sseBroadcast, getSSEClientCount } from './core/sse.js'; import { loadState, getFullState, getStateDiag } from './core/persistence.js'; import { getPlugins, registerPlugin, getPluginCtx, type PluginContext } from './core/plugin.js'; +import { signAdminToken, verifyAdminToken, readCookie, setAdminCookie, clearAdminCookie, COOKIE_NAME } from './core/auth.js'; import radioPlugin from './plugins/radio/index.js'; import soundboardPlugin from './plugins/soundboard/index.js'; import lolstatsPlugin from './plugins/lolstats/index.js'; @@ -93,16 +94,25 @@ app.get('/api/health', (_req, res) => { }); }); -// ── Admin Login ── +// ── Admin Auth (centralised) ── app.post('/api/admin/login', (req, res) => { if (!ADMIN_PWD) { res.status(503).json({ error: 'ADMIN_PWD not configured' }); return; } const { password } = req.body ?? {}; if (password === ADMIN_PWD) { + const token = signAdminToken(ADMIN_PWD); + setAdminCookie(res, token); res.json({ ok: true }); } else { res.status(401).json({ error: 'Invalid password' }); } }); +app.post('/api/admin/logout', (_req, res) => { + clearAdminCookie(res); + res.json({ ok: true }); +}); +app.get('/api/admin/status', (req, res) => { + res.json({ authenticated: verifyAdminToken(ADMIN_PWD, readCookie(req, COOKIE_NAME)) }); +}); // ── API: List plugins ── app.get('/api/plugins', (_req, res) => { diff --git a/server/src/plugins/soundboard/index.ts b/server/src/plugins/soundboard/index.ts index d53238e..777b195 100644 --- a/server/src/plugins/soundboard/index.ts +++ b/server/src/plugins/soundboard/index.ts @@ -17,6 +17,7 @@ import nacl from 'tweetnacl'; import { ChannelType, Events, type VoiceBasedChannel, type VoiceState, type Message } from 'discord.js'; import type { Plugin, PluginContext } from '../../core/plugin.js'; import { sseBroadcast } from '../../core/sse.js'; +import { requireAdmin as requireAdminFactory } from '../../core/auth.js'; // ── Config (env) ── const SOUNDS_DIR = process.env.SOUNDS_DIR ?? '/data/sounds'; @@ -583,33 +584,6 @@ async function playFilePath(guildId: string, channelId: string, filePath: string if (relativeKey) incrementPlaysFor(relativeKey); } -// ── Admin Auth (JWT-like with HMAC) ── -type AdminPayload = { iat: number; exp: number }; -function b64url(input: Buffer | string): string { - return Buffer.from(input).toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_'); -} -function signAdminToken(adminPwd: string, payload: AdminPayload): string { - const body = b64url(JSON.stringify(payload)); - const sig = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); - return `${body}.${sig}`; -} -function verifyAdminToken(adminPwd: string, token: string | undefined): boolean { - if (!token || !adminPwd) return false; - const [body, sig] = token.split('.'); - if (!body || !sig) return false; - const expected = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); - if (expected !== sig) return false; - try { - const payload = JSON.parse(Buffer.from(body, 'base64').toString('utf8')) as AdminPayload; - return typeof payload.exp === 'number' && Date.now() < payload.exp; - } catch { return false; } -} -function readCookie(req: express.Request, key: string): string | undefined { - const c = req.headers.cookie; - if (!c) return undefined; - for (const part of c.split(';')) { const [k, v] = part.trim().split('='); if (k === key) return decodeURIComponent(v || ''); } - return undefined; -} // ── Party Mode ── function schedulePartyPlayback(guildId: string, channelId: string) { @@ -775,28 +749,7 @@ const soundboardPlugin: Plugin = { }, registerRoutes(app: express.Application, ctx: PluginContext) { - const requireAdmin = (req: express.Request, res: express.Response, next: () => void) => { - if (!ctx.adminPwd) { res.status(503).json({ error: 'Admin nicht konfiguriert' }); return; } - if (!verifyAdminToken(ctx.adminPwd, readCookie(req, 'admin'))) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } - next(); - }; - - // ── Admin Auth ── - app.post('/api/soundboard/admin/login', (req, res) => { - if (!ctx.adminPwd) { res.status(503).json({ error: 'Admin nicht konfiguriert' }); return; } - const { password } = req.body ?? {}; - if (!password || password !== ctx.adminPwd) { res.status(401).json({ error: 'Falsches Passwort' }); return; } - const token = signAdminToken(ctx.adminPwd, { iat: Date.now(), exp: Date.now() + 7 * 24 * 3600 * 1000 }); - res.setHeader('Set-Cookie', `admin=${encodeURIComponent(token)}; HttpOnly; Path=/; Max-Age=${7 * 24 * 3600}; SameSite=Lax`); - res.json({ ok: true }); - }); - app.post('/api/soundboard/admin/logout', (_req, res) => { - res.setHeader('Set-Cookie', 'admin=; HttpOnly; Path=/; Max-Age=0; SameSite=Lax'); - res.json({ ok: true }); - }); - app.get('/api/soundboard/admin/status', (req, res) => { - res.json({ authenticated: verifyAdminToken(ctx.adminPwd, readCookie(req, 'admin')) }); - }); + const requireAdmin = requireAdminFactory(ctx.adminPwd); // ── Sounds ── app.get('/api/soundboard/sounds', (req, res) => { diff --git a/web/src/App.tsx b/web/src/App.tsx index fb12660..e87ee2b 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -13,7 +13,7 @@ interface PluginInfo { } // Plugin tab components -const tabComponents: Record> = { +const tabComponents: Record> = { radio: RadioTab, soundboard: SoundboardTab, lolstats: LolstatsTab, @@ -22,7 +22,7 @@ const tabComponents: Record> = { 'game-library': GameLibraryTab, }; -export function registerTab(pluginName: string, component: React.FC<{ data: any }>) { +export function registerTab(pluginName: string, component: React.FC<{ data: any; isAdmin?: boolean }>) { tabComponents[pluginName] = component; } @@ -149,12 +149,21 @@ export default function App() { return () => window.removeEventListener('keydown', handler); }, [showVersionModal, showAdminModal]); + // Check admin status on mount (cookie-based, survives reload) + useEffect(() => { + fetch('/api/admin/status', { credentials: 'include' }) + .then(r => r.ok ? r.json() : null) + .then(d => { if (d?.authenticated) setAdminLoggedIn(true); }) + .catch(() => {}); + }, []); + // Admin login handler const handleAdminLogin = () => { if (!adminPassword) return; fetch('/api/admin/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, + credentials: 'include', body: JSON.stringify({ password: adminPassword }), }) .then(r => { @@ -162,6 +171,7 @@ export default function App() { setAdminLoggedIn(true); setAdminPassword(''); setAdminError(''); + setShowAdminModal(false); } else { setAdminError('Falsches Passwort'); } @@ -170,8 +180,15 @@ export default function App() { }; const handleAdminLogout = () => { - setAdminLoggedIn(false); - setShowAdminModal(false); + fetch('/api/admin/logout', { method: 'POST', credentials: 'include' }) + .then(() => { + setAdminLoggedIn(false); + setShowAdminModal(false); + }) + .catch(() => { + setAdminLoggedIn(false); + setShowAdminModal(false); + }); }; @@ -414,7 +431,7 @@ export default function App() { : { display: 'none' } } > - +
); }) diff --git a/web/src/plugins/soundboard/SoundboardTab.tsx b/web/src/plugins/soundboard/SoundboardTab.tsx index 064951b..dbe0103 100644 --- a/web/src/plugins/soundboard/SoundboardTab.tsx +++ b/web/src/plugins/soundboard/SoundboardTab.tsx @@ -186,24 +186,6 @@ async function apiGetVolume(guildId: string): Promise { return typeof data?.volume === 'number' ? data.volume : 1; } -async function apiAdminStatus(): Promise { - const res = await fetch(`${API_BASE}/admin/status`, { credentials: 'include' }); - if (!res.ok) return false; - const data = await res.json(); - return !!data?.authenticated; -} - -async function apiAdminLogin(password: string): Promise { - const res = await fetch(`${API_BASE}/admin/login`, { - method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', - body: JSON.stringify({ password }) - }); - return res.ok; -} - -async function apiAdminLogout(): Promise { - await fetch(`${API_BASE}/admin/logout`, { method: 'POST', credentials: 'include' }); -} async function apiAdminDelete(paths: string[]): Promise { const res = await fetch(`${API_BASE}/admin/sounds/delete`, { @@ -324,13 +306,14 @@ interface VoiceStats { interface SoundboardTabProps { data: any; + isAdmin?: boolean; } /* ══════════════════════════════════════════════════════════════════ COMPONENT ══════════════════════════════════════════════════════════════════ */ -export default function SoundboardTab({ data }: SoundboardTabProps) { +export default function SoundboardTab({ data, isAdmin: isAdminProp = false }: SoundboardTabProps) { /* ── Data ── */ const [sounds, setSounds] = useState([]); const [total, setTotal] = useState(0); @@ -378,9 +361,8 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { const volDebounceRef = useRef>(undefined); /* ── Admin ── */ - const [isAdmin, setIsAdmin] = useState(false); + const isAdmin = isAdminProp; const [showAdmin, setShowAdmin] = useState(false); - const [adminPwd, setAdminPwd] = useState(''); const [adminSounds, setAdminSounds] = useState([]); const [adminLoading, setAdminLoading] = useState(false); const [adminQuery, setAdminQuery] = useState(''); @@ -521,7 +503,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { setSelected(match ? `${g}:${serverCid}` : `${ch[0].guildId}:${ch[0].channelId}`); } } catch (e: any) { notify(e?.message || 'Channel-Fehler', 'error'); } - try { setIsAdmin(await apiAdminStatus()); } catch { } try { const c = await fetchCategories(); setCategories(c.categories || []); } catch { } })(); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -879,27 +860,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { } } - async function handleAdminLogin() { - try { - const ok = await apiAdminLogin(adminPwd); - if (ok) { - setIsAdmin(true); - setAdminPwd(''); - notify('Admin eingeloggt'); - } - else notify('Falsches Passwort', 'error'); - } catch { notify('Login fehlgeschlagen', 'error'); } - } - - async function handleAdminLogout() { - try { - await apiAdminLogout(); - setIsAdmin(false); - setAdminSelection({}); - cancelRename(); - notify('Ausgeloggt'); - } catch { } - } /* ── Computed ── */ const displaySounds = useMemo(() => { @@ -1447,21 +1407,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { close - {!isAdmin ? ( -
-
- - setAdminPwd(e.target.value)} - onKeyDown={e => e.key === 'Enter' && handleAdminLogin()} - placeholder="Admin-Passwort..." - /> -
- -
- ) : (

Eingeloggt als Admin

@@ -1473,7 +1418,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { > Aktualisieren -
@@ -1585,7 +1529,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { )} - )} )} From f27093b87a5091b1b954473f2737c16ba0017d1c Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 11:22:07 +0100 Subject: [PATCH 04/53] Refactor: Admin-Login aus allen Plugins entfernt Duplizierte Auth-Logik aus Notifications, Game Library und Streaming Plugins komplett entfernt (-251 Zeilen). Alle Plugins nutzen jetzt die zentrale Auth aus core/auth.ts via isAdmin Prop. Admin-Buttons (Settings-Zahnrad) erscheinen nur noch wenn global eingeloggt. Kein separater Login pro Tab mehr noetig. Co-Authored-By: Claude Opus 4.6 --- server/src/plugins/game-library/index.ts | 61 +--------------- server/src/plugins/notifications/index.ts | 64 +---------------- .../plugins/game-library/GameLibraryTab.tsx | 70 ++----------------- web/src/plugins/soundboard/SoundboardTab.tsx | 16 +++-- web/src/plugins/streaming/StreamingTab.tsx | 68 +++--------------- 5 files changed, 28 insertions(+), 251 deletions(-) diff --git a/server/src/plugins/game-library/index.ts b/server/src/plugins/game-library/index.ts index f48d0bd..461d787 100644 --- a/server/src/plugins/game-library/index.ts +++ b/server/src/plugins/game-library/index.ts @@ -1,6 +1,7 @@ import type express from 'express'; import type { Plugin, PluginContext } from '../../core/plugin.js'; import { sseBroadcast } from '../../core/sse.js'; +import { requireAdmin as requireAdminFactory } from '../../core/auth.js'; import fs from 'node:fs'; import path from 'node:path'; import crypto from 'node:crypto'; @@ -58,34 +59,6 @@ const STEAM_API_KEY = process.env.STEAM_API_KEY || '2481D43449821AA4FF66502A9166 // ── Admin auth helpers (same system as soundboard) ── -function readCookie(req: express.Request, name: string): string | undefined { - const raw = req.headers.cookie || ''; - const match = raw.match(new RegExp(`(?:^|;\\s*)${name}=([^;]*)`)); - return match ? decodeURIComponent(match[1]) : undefined; -} - -function b64url(str: string): string { - return Buffer.from(str).toString('base64url'); -} - -function verifyAdminToken(adminPwd: string, token: string | undefined): boolean { - if (!token || !adminPwd) return false; - const [body, sig] = token.split('.'); - if (!body || !sig) return false; - const expected = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); - if (expected !== sig) return false; - try { - const payload = JSON.parse(Buffer.from(body, 'base64').toString('utf8')) as { iat: number; exp: number }; - return typeof payload.exp === 'number' && Date.now() < payload.exp; - } catch { return false; } -} - -function signAdminToken(adminPwd: string): string { - const payload = { iat: Date.now(), exp: Date.now() + 7 * 24 * 3600_000 }; - const body = b64url(JSON.stringify(payload)); - const sig = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); - return `${body}.${sig}`; -} // ── Data Persistence ── @@ -893,37 +866,7 @@ const gameLibraryPlugin: Plugin = { // Admin endpoints (same auth as soundboard) // ═══════════════════════════════════════════════════════════════════ - const requireAdmin = (req: express.Request, res: express.Response, next: () => void) => { - if (!ctx.adminPwd) { res.status(503).json({ error: 'Admin nicht konfiguriert' }); return; } - if (!verifyAdminToken(ctx.adminPwd, readCookie(req, 'admin'))) { - res.status(401).json({ error: 'Nicht eingeloggt' }); - return; - } - next(); - }; - - // ── GET /api/game-library/admin/status ── - app.get('/api/game-library/admin/status', (req, res) => { - if (!ctx.adminPwd) { res.json({ admin: false, configured: false }); return; } - const valid = verifyAdminToken(ctx.adminPwd, readCookie(req, 'admin')); - res.json({ admin: valid, configured: true }); - }); - - // ── POST /api/game-library/admin/login ── - app.post('/api/game-library/admin/login', (req, res) => { - const password = String(req.body?.password || ''); - if (!ctx.adminPwd) { res.status(503).json({ error: 'Admin nicht konfiguriert' }); return; } - if (password !== ctx.adminPwd) { res.status(401).json({ error: 'Falsches Passwort' }); return; } - const token = signAdminToken(ctx.adminPwd); - res.setHeader('Set-Cookie', `admin=${token}; HttpOnly; Path=/; Max-Age=${7 * 24 * 3600}; SameSite=Lax`); - res.json({ ok: true }); - }); - - // ── POST /api/game-library/admin/logout ── - app.post('/api/game-library/admin/logout', (_req, res) => { - res.setHeader('Set-Cookie', 'admin=; HttpOnly; Path=/; Max-Age=0; SameSite=Lax'); - res.json({ ok: true }); - }); + const requireAdmin = requireAdminFactory(ctx.adminPwd); // ── GET /api/game-library/admin/profiles ── Alle Profile mit Details app.get('/api/game-library/admin/profiles', requireAdmin, (_req, res) => { diff --git a/server/src/plugins/notifications/index.ts b/server/src/plugins/notifications/index.ts index 98afae8..f04c8c6 100644 --- a/server/src/plugins/notifications/index.ts +++ b/server/src/plugins/notifications/index.ts @@ -1,8 +1,8 @@ import type express from 'express'; -import crypto from 'node:crypto'; import { Client, EmbedBuilder, TextChannel, ChannelType } from 'discord.js'; import type { Plugin, PluginContext } from '../../core/plugin.js'; import { getState, setState } from '../../core/persistence.js'; +import { requireAdmin as requireAdminFactory } from '../../core/auth.js'; const NB = '[Notifications]'; @@ -26,40 +26,6 @@ let _client: Client | null = null; let _ctx: PluginContext | null = null; let _publicUrl = ''; -// ── Admin Auth (JWT-like with HMAC) ── - -type AdminPayload = { iat: number; exp: number }; - -function readCookie(req: express.Request, name: string): string | undefined { - const header = req.headers.cookie; - if (!header) return undefined; - const match = header.split(';').map(s => s.trim()).find(s => s.startsWith(`${name}=`)); - return match?.split('=').slice(1).join('='); -} - -function b64url(str: string): string { - return Buffer.from(str).toString('base64url'); -} - -function verifyAdminToken(adminPwd: string, token: string | undefined): boolean { - if (!adminPwd || !token) return false; - const parts = token.split('.'); - if (parts.length !== 2) return false; - const [body, sig] = parts; - const expected = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); - if (expected !== sig) return false; - try { - const payload = JSON.parse(Buffer.from(body, 'base64url').toString('utf8')) as AdminPayload; - return typeof payload.exp === 'number' && Date.now() < payload.exp; - } catch { return false; } -} - -function signAdminToken(adminPwd: string): string { - const payload: AdminPayload = { iat: Date.now(), exp: Date.now() + 7 * 24 * 3600_000 }; - const body = b64url(JSON.stringify(payload)); - const sig = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); - return `${body}.${sig}`; -} // ── Exported notification functions (called by other plugins) ── @@ -159,33 +125,7 @@ const notificationsPlugin: Plugin = { }, registerRoutes(app, ctx) { - const requireAdmin = (req: express.Request, res: express.Response, next: () => void): void => { - if (!ctx.adminPwd) { res.status(503).json({ error: 'Admin nicht konfiguriert' }); return; } - if (!verifyAdminToken(ctx.adminPwd, readCookie(req, 'admin'))) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } - next(); - }; - - // Admin status - app.get('/api/notifications/admin/status', (req, res) => { - if (!ctx.adminPwd) { res.json({ admin: false }); return; } - res.json({ admin: verifyAdminToken(ctx.adminPwd, readCookie(req, 'admin')) }); - }); - - // Admin login - app.post('/api/notifications/admin/login', (req, res) => { - if (!ctx.adminPwd) { res.status(503).json({ error: 'Admin nicht konfiguriert' }); return; } - const { password } = req.body ?? {}; - if (password !== ctx.adminPwd) { res.status(401).json({ error: 'Falsches Passwort' }); return; } - const token = signAdminToken(ctx.adminPwd); - res.setHeader('Set-Cookie', `admin=${token}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${7 * 86400}`); - res.json({ ok: true }); - }); - - // Admin logout - app.post('/api/notifications/admin/logout', (_req, res) => { - res.setHeader('Set-Cookie', 'admin=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0'); - res.json({ ok: true }); - }); + const requireAdmin = requireAdminFactory(ctx.adminPwd); // List available text channels (requires admin) app.get('/api/notifications/channels', requireAdmin, async (_req, res) => { diff --git a/web/src/plugins/game-library/GameLibraryTab.tsx b/web/src/plugins/game-library/GameLibraryTab.tsx index 2f30c4d..28fb090 100644 --- a/web/src/plugins/game-library/GameLibraryTab.tsx +++ b/web/src/plugins/game-library/GameLibraryTab.tsx @@ -89,7 +89,7 @@ function formatDate(iso: string): string { COMPONENT ══════════════════════════════════════════════════════════════════ */ -export default function GameLibraryTab({ data }: { data: any }) { +export default function GameLibraryTab({ data, isAdmin: isAdminProp = false }: { data: any; isAdmin?: boolean }) { // ── State ── const [profiles, setProfiles] = useState([]); const [mode, setMode] = useState<'overview' | 'user' | 'common'>('overview'); @@ -111,11 +111,9 @@ export default function GameLibraryTab({ data }: { data: any }) { // ── Admin state ── const [showAdmin, setShowAdmin] = useState(false); - const [isAdmin, setIsAdmin] = useState(false); - const [adminPwd, setAdminPwd] = useState(''); + const isAdmin = isAdminProp; const [adminProfiles, setAdminProfiles] = useState([]); const [adminLoading, setAdminLoading] = useState(false); - const [adminError, setAdminError] = useState(''); // ── SSE data sync ── useEffect(() => { @@ -133,42 +131,6 @@ export default function GameLibraryTab({ data }: { data: any }) { } catch { /* silent */ } }, []); - // ── Admin: check login status on mount ── - useEffect(() => { - fetch('/api/game-library/admin/status', { credentials: 'include' }) - .then(r => r.json()) - .then(d => setIsAdmin(d.admin === true)) - .catch(() => {}); - }, []); - - // ── Admin: login ── - const adminLogin = useCallback(async () => { - setAdminError(''); - try { - const resp = await fetch('/api/game-library/admin/login', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ password: adminPwd }), - credentials: 'include', - }); - if (resp.ok) { - setIsAdmin(true); - setAdminPwd(''); - } else { - const d = await resp.json(); - setAdminError(d.error || 'Fehler'); - } - } catch { - setAdminError('Verbindung fehlgeschlagen'); - } - }, [adminPwd]); - - // ── Admin: logout ── - const adminLogout = useCallback(async () => { - await fetch('/api/game-library/admin/logout', { method: 'POST', credentials: 'include' }); - setIsAdmin(false); - setShowAdmin(false); - }, []); // ── Admin: load profiles ── const loadAdminProfiles = useCallback(async () => { @@ -552,9 +514,11 @@ export default function GameLibraryTab({ data }: { data: any }) { )}
- + {isAdmin && ( + + )}
{/* ── Profile Chips ── */} @@ -990,29 +954,10 @@ export default function GameLibraryTab({ data }: { data: any }) { - {!isAdmin ? ( -
-

Admin-Passwort eingeben:

-
- setAdminPwd(e.target.value)} - onKeyDown={e => { if (e.key === 'Enter') adminLogin(); }} - autoFocus - /> - -
- {adminError &&

{adminError}

} -
- ) : (
✅ Eingeloggt als Admin -
{adminLoading ? ( @@ -1044,7 +989,6 @@ export default function GameLibraryTab({ data }: { data: any }) {
)} - )} )} diff --git a/web/src/plugins/soundboard/SoundboardTab.tsx b/web/src/plugins/soundboard/SoundboardTab.tsx index dbe0103..a1140b2 100644 --- a/web/src/plugins/soundboard/SoundboardTab.tsx +++ b/web/src/plugins/soundboard/SoundboardTab.tsx @@ -1000,13 +1000,15 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp = false }: So )} )} - + {isAdmin && ( + + )} diff --git a/web/src/plugins/streaming/StreamingTab.tsx b/web/src/plugins/streaming/StreamingTab.tsx index cd85e68..46506db 100644 --- a/web/src/plugins/streaming/StreamingTab.tsx +++ b/web/src/plugins/streaming/StreamingTab.tsx @@ -56,7 +56,7 @@ const QUALITY_PRESETS = [ // ── Component ── -export default function StreamingTab({ data }: { data: any }) { +export default function StreamingTab({ data, isAdmin: isAdminProp = false }: { data: any; isAdmin?: boolean }) { // ── State ── const [streams, setStreams] = useState([]); const [userName, setUserName] = useState(() => localStorage.getItem('streaming_name') || ''); @@ -75,9 +75,7 @@ export default function StreamingTab({ data }: { data: any }) { // ── Admin / Notification Config ── const [showAdmin, setShowAdmin] = useState(false); - const [isAdmin, setIsAdmin] = useState(false); - const [adminPwd, setAdminPwd] = useState(''); - const [adminError, setAdminError] = useState(''); + const isAdmin = isAdminProp; const [availableChannels, setAvailableChannels] = useState>([]); const [notifyConfig, setNotifyConfig] = useState>([]); const [configLoading, setConfigLoading] = useState(false); @@ -138,12 +136,8 @@ export default function StreamingTab({ data }: { data: any }) { return () => document.removeEventListener('click', handler); }, [openMenu]); - // Check admin status on mount + // Load notification bot status on mount useEffect(() => { - fetch('/api/notifications/admin/status', { credentials: 'include' }) - .then(r => r.json()) - .then(d => setIsAdmin(d.admin === true)) - .catch(() => {}); fetch('/api/notifications/status') .then(r => r.json()) .then(d => setNotifyStatus(d)) @@ -610,34 +604,6 @@ export default function StreamingTab({ data }: { data: any }) { setOpenMenu(null); }, [buildStreamLink]); - // ── Admin functions ── - const adminLogin = useCallback(async () => { - setAdminError(''); - try { - const resp = await fetch('/api/notifications/admin/login', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ password: adminPwd }), - credentials: 'include', - }); - if (resp.ok) { - setIsAdmin(true); - setAdminPwd(''); - loadNotifyConfig(); - } else { - const d = await resp.json(); - setAdminError(d.error || 'Fehler'); - } - } catch { - setAdminError('Verbindung fehlgeschlagen'); - } - }, [adminPwd]); - - const adminLogout = useCallback(async () => { - await fetch('/api/notifications/admin/logout', { method: 'POST', credentials: 'include' }); - setIsAdmin(false); - setShowAdmin(false); - }, []); const loadNotifyConfig = useCallback(async () => { setConfigLoading(true); @@ -796,9 +762,11 @@ export default function StreamingTab({ data }: { data: any }) { {starting ? 'Starte...' : '\u{1F5A5}\uFE0F Stream starten'} )} - + {isAdmin && ( + + )} {streams.length === 0 && !isBroadcasting ? ( @@ -912,24 +880,6 @@ export default function StreamingTab({ data }: { data: any }) { - {!isAdmin ? ( -
-

Admin-Passwort eingeben:

-
- setAdminPwd(e.target.value)} - onKeyDown={e => { if (e.key === 'Enter') adminLogin(); }} - autoFocus - /> - -
- {adminError &&

{adminError}

} -
- ) : (
@@ -937,7 +887,6 @@ export default function StreamingTab({ data }: { data: any }) { ? <>{'\u2705'} Bot online: {notifyStatus.botTag} : <>{'\u26A0\uFE0F'} Bot offline — DISCORD_TOKEN_NOTIFICATIONS setzen} -
{configLoading ? ( @@ -993,7 +942,6 @@ export default function StreamingTab({ data }: { data: any }) { )}
- )} )} From 10fcde125d028a0c80023eb8e7fed6944c2db16b Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 11:42:48 +0100 Subject: [PATCH 05/53] Streaming: 30fps Presets entfernt, Dropdown breiter Qualitaetsstufen: 720p60, 1080p60, 2K60, 4K60, 4K165 Ultra. Dropdown von 120px auf 160px verbreitert damit Text nicht abgeschnitten wird. Co-Authored-By: Claude Opus 4.6 --- web/src/plugins/streaming/StreamingTab.tsx | 13 ++++++------- web/src/plugins/streaming/streaming.css | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/web/src/plugins/streaming/StreamingTab.tsx b/web/src/plugins/streaming/StreamingTab.tsx index 46506db..4ac264a 100644 --- a/web/src/plugins/streaming/StreamingTab.tsx +++ b/web/src/plugins/streaming/StreamingTab.tsx @@ -46,11 +46,10 @@ function formatElapsed(startedAt: string): string { // ── Quality Presets ── const QUALITY_PRESETS = [ - { label: '720p30', width: 1280, height: 720, fps: 30, bitrate: 2_500_000 }, - { label: '1080p30', width: 1920, height: 1080, fps: 30, bitrate: 5_000_000 }, - { label: '1080p60', width: 1920, height: 1080, fps: 60, bitrate: 8_000_000 }, - { label: '1440p60', width: 2560, height: 1440, fps: 60, bitrate: 14_000_000 }, - { label: '4K60', width: 3840, height: 2160, fps: 60, bitrate: 25_000_000 }, + { label: '720p60', width: 1280, height: 720, fps: 60, bitrate: 4_000_000 }, + { label: '1080p60', width: 1920, height: 1080, fps: 60, bitrate: 8_000_000 }, + { label: '2K60', width: 2560, height: 1440, fps: 60, bitrate: 14_000_000 }, + { label: '4K60', width: 3840, height: 2160, fps: 60, bitrate: 25_000_000 }, { label: '4K165 Ultra', width: 3840, height: 2160, fps: 165, bitrate: 50_000_000 }, ] as const; @@ -62,7 +61,7 @@ export default function StreamingTab({ data, isAdmin: isAdminProp = false }: { d const [userName, setUserName] = useState(() => localStorage.getItem('streaming_name') || ''); const [streamTitle, setStreamTitle] = useState('Screen Share'); const [streamPassword, setStreamPassword] = useState(''); - const [qualityIdx, setQualityIdx] = useState(2); // Default: 1080p60 + const [qualityIdx, setQualityIdx] = useState(1); // Default: 1080p60 const [error, setError] = useState(null); const [joinModal, setJoinModal] = useState(null); const [myStreamId, setMyStreamId] = useState(null); @@ -98,7 +97,7 @@ export default function StreamingTab({ data, isAdmin: isAdminProp = false }: { d // Refs that mirror state (avoid stale closures in WS handler) const isBroadcastingRef = useRef(false); const viewingRef = useRef(null); - const qualityRef = useRef(QUALITY_PRESETS[2]); + const qualityRef = useRef(QUALITY_PRESETS[1]); useEffect(() => { isBroadcastingRef.current = isBroadcasting; }, [isBroadcasting]); useEffect(() => { viewingRef.current = viewing; }, [viewing]); useEffect(() => { qualityRef.current = QUALITY_PRESETS[qualityIdx]; }, [qualityIdx]); diff --git a/web/src/plugins/streaming/streaming.css b/web/src/plugins/streaming/streaming.css index 6f8cffa..8f57bdd 100644 --- a/web/src/plugins/streaming/streaming.css +++ b/web/src/plugins/streaming/streaming.css @@ -412,7 +412,7 @@ } .stream-select-quality { - width: 120px; + width: 160px; padding: 10px 14px; border: 1px solid var(--bg-tertiary); border-radius: var(--radius); From 3127d31355ecfaa27cb83598d17ae29f532897b1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 11:46:20 +0100 Subject: [PATCH 06/53] Streaming: Presets zeigen jetzt Bitrate statt Aufloesung Aufloesung ist immer nativ (Monitor des Broadcasters), die Presets steuern nur Bitrate und FPS. Labels entsprechend angepasst: Niedrig (4 Mbit) bis Max (50 Mbit/165Hz). Dropdown auf 200px. Co-Authored-By: Claude Opus 4.6 --- web/src/plugins/streaming/StreamingTab.tsx | 12 ++++++------ web/src/plugins/streaming/streaming.css | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/src/plugins/streaming/StreamingTab.tsx b/web/src/plugins/streaming/StreamingTab.tsx index 4ac264a..d23a342 100644 --- a/web/src/plugins/streaming/StreamingTab.tsx +++ b/web/src/plugins/streaming/StreamingTab.tsx @@ -46,11 +46,11 @@ function formatElapsed(startedAt: string): string { // ── Quality Presets ── const QUALITY_PRESETS = [ - { label: '720p60', width: 1280, height: 720, fps: 60, bitrate: 4_000_000 }, - { label: '1080p60', width: 1920, height: 1080, fps: 60, bitrate: 8_000_000 }, - { label: '2K60', width: 2560, height: 1440, fps: 60, bitrate: 14_000_000 }, - { label: '4K60', width: 3840, height: 2160, fps: 60, bitrate: 25_000_000 }, - { label: '4K165 Ultra', width: 3840, height: 2160, fps: 165, bitrate: 50_000_000 }, + { label: 'Niedrig (4 Mbit)', fps: 60, bitrate: 4_000_000 }, + { label: 'Mittel (8 Mbit)', fps: 60, bitrate: 8_000_000 }, + { label: 'Hoch (14 Mbit)', fps: 60, bitrate: 14_000_000 }, + { label: 'Ultra (25 Mbit)', fps: 60, bitrate: 25_000_000 }, + { label: 'Max (50 Mbit/165Hz)', fps: 165, bitrate: 50_000_000 }, ] as const; // ── Component ── @@ -415,7 +415,7 @@ export default function StreamingTab({ data, isAdmin: isAdminProp = false }: { d try { const q = qualityRef.current; const stream = await navigator.mediaDevices.getDisplayMedia({ - video: { frameRate: { ideal: q.fps }, width: { ideal: q.width }, height: { ideal: q.height } }, + video: { frameRate: { ideal: q.fps } }, audio: true, }); localStreamRef.current = stream; diff --git a/web/src/plugins/streaming/streaming.css b/web/src/plugins/streaming/streaming.css index 8f57bdd..319bdae 100644 --- a/web/src/plugins/streaming/streaming.css +++ b/web/src/plugins/streaming/streaming.css @@ -412,7 +412,7 @@ } .stream-select-quality { - width: 160px; + width: 200px; padding: 10px 14px; border: 1px solid var(--bg-tertiary); border-radius: var(--radius); From 041557c8858a2913920f3870602e7f5578b396ef Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 11:52:42 +0100 Subject: [PATCH 07/53] UI: Avatar entfernt, Streaming-Topbar mit Labels - DK-Avatar aus Header entfernt (kein Zweck) - Streaming-Felder haben jetzt Ueberschriften: Name, Titel, Passwort, Qualitaet - Passwort-Feld von 140px auf 180px verbreitert - Topbar aligned an Feldunterkante (flex-end) Co-Authored-By: Claude Opus 4.6 --- web/src/App.tsx | 1 - web/src/plugins/streaming/StreamingTab.tsx | 77 ++++++++++++---------- web/src/plugins/streaming/streaming.css | 24 ++++++- 3 files changed, 65 insertions(+), 37 deletions(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index e87ee2b..9c2f9ae 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -272,7 +272,6 @@ export default function App() { {'\u{1F511}'} {adminLoggedIn && } -
DK
diff --git a/web/src/plugins/streaming/StreamingTab.tsx b/web/src/plugins/streaming/StreamingTab.tsx index d23a342..b34762f 100644 --- a/web/src/plugins/streaming/StreamingTab.tsx +++ b/web/src/plugins/streaming/StreamingTab.tsx @@ -719,39 +719,50 @@ export default function StreamingTab({ data, isAdmin: isAdminProp = false }: { d )}
- setUserName(e.target.value)} - disabled={isBroadcasting} - /> - setStreamTitle(e.target.value)} - disabled={isBroadcasting} - /> - setStreamPassword(e.target.value)} - disabled={isBroadcasting} - /> - + + + + {isBroadcasting ? ( ))} -
- {!(window as any).electronAPI && ( - - {'\u2B07\uFE0F'} - Desktop App - - )} + {/* Accent Theme Picker */} +
+ {accentSwatches.map(swatch => ( +
+ + {/* Sidebar Footer: User + Connection + Settings + Admin */} +
+
+ D + {connected && } +
+
+ User + + {connected ? 'Verbunden' : 'Getrennt'} + +
- { if (isElectron) { const api = (window as any).electronAPI; @@ -260,22 +321,50 @@ export default function App() { } setShowVersionModal(true); }} - title="Versionsinformationen" + title="Einstellungen & Version" > - v{version} - -
- + + {/* ===== MAIN CONTENT ===== */} +
+
+ {plugins.length === 0 ? ( +
+ {'\u{1F4E6}'} +

Keine Plugins geladen

+

Plugins werden im Server konfiguriert.

+
+ ) : ( + /* Render ALL tabs, hide inactive ones to preserve state. + Active tab gets full dimensions; hidden tabs stay in DOM but invisible. */ + plugins.map(p => { + const Comp = tabComponents[p.name]; + if (!Comp) return null; + const isActive = activeTab === p.name; + return ( +
+ +
+ ); + }) + )} +
+
+ {/* ===== VERSION MODAL ===== */} {showVersionModal && (
setShowVersionModal(false)}>
e.stopPropagation()}> @@ -321,13 +410,13 @@ export default function App() { {updateStatus === 'checking' && (
- Suche nach Updates… + Suche nach Updates...
)} {updateStatus === 'downloading' && (
- Update wird heruntergeladen… + Update wird heruntergeladen...
)} {updateStatus === 'ready' && ( @@ -367,6 +456,7 @@ export default function App() {
)} + {/* ===== ADMIN MODAL ===== */} {showAdminModal && (
setShowAdminModal(false)}>
e.stopPropagation()}> @@ -406,36 +496,6 @@ export default function App() {
)} - -
- {plugins.length === 0 ? ( -
- {'\u{1F4E6}'} -

Keine Plugins geladen

-

Plugins werden im Server konfiguriert.

-
- ) : ( - /* Render ALL tabs, hide inactive ones to preserve state. - Active tab gets full dimensions; hidden tabs stay in DOM but invisible. */ - plugins.map(p => { - const Comp = tabComponents[p.name]; - if (!Comp) return null; - const isActive = activeTab === p.name; - return ( -
- -
- ); - }) - )} -
); } diff --git a/web/src/plugins/soundboard/SoundboardTab.tsx b/web/src/plugins/soundboard/SoundboardTab.tsx index a1140b2..434f0f2 100644 --- a/web/src/plugins/soundboard/SoundboardTab.tsx +++ b/web/src/plugins/soundboard/SoundboardTab.tsx @@ -267,14 +267,6 @@ function apiUploadFileWithName( CONSTANTS ══════════════════════════════════════════════════════════════════ */ -const THEMES = [ - { id: 'default', color: '#5865f2', label: 'Discord' }, - { id: 'purple', color: '#9b59b6', label: 'Midnight' }, - { id: 'forest', color: '#2ecc71', label: 'Forest' }, - { id: 'sunset', color: '#e67e22', label: 'Sunset' }, - { id: 'ocean', color: '#3498db', label: 'Ocean' }, -]; - const CAT_PALETTE = [ '#3b82f6', '#f59e0b', '#8b5cf6', '#ec4899', '#14b8a6', '#f97316', '#06b6d4', '#ef4444', '#a855f7', '#84cc16', @@ -508,7 +500,7 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp = false }: So // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - /* ── Theme (persist only, data-theme is set on .sb-app div) ── */ + /* ── Theme (persist — global theming now handled by app-shell) ── */ useEffect(() => { localStorage.setItem('jb-theme', theme); }, [theme]); @@ -928,78 +920,60 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp = false }: So RENDER ════════════════════════════════════════════ */ return ( -
+
{chaosMode &&
} - {/* ═══ TOPBAR ═══ */} -
-
-
- music_note -
- Soundboard + {/* ═══ CONTENT HEADER ═══ */} +
+
+ Soundboard + {totalSoundsDisplay} +
- {/* Channel Dropdown */} -
e.stopPropagation()}> - - {channelOpen && ( -
- {Object.entries(channelsByGuild).map(([guild, chs]) => ( - -
{guild}
- {chs.map(ch => ( -
handleChannelSelect(ch)} - > - volume_up - {ch.channelName}{ch.members ? ` (${ch.members})` : ''} -
- ))} -
- ))} - {channels.length === 0 && ( -
- Keine Channels verfuegbar -
- )} -
- )} -
+ )}
-
-
{clockMain}{clockSec}
-
- -
+
+ {/* Now Playing indicator */} {lastPlayed && (
- Last Played: {lastPlayed} + Now: {lastPlayed}
)} + + {/* Connection status */} {selected && ( -
setShowConnModal(true)} style={{cursor:'pointer'}} title="Verbindungsdetails"> - +
setShowConnModal(true)} + style={{ cursor: 'pointer' }} + title="Verbindungsdetails" + > + Verbunden {voiceStats?.voicePing != null && ( - {voiceStats.voicePing}ms + {voiceStats.voicePing}ms )}
)} + + {/* Admin button */} {isAdmin && ( )} + + {/* Playback controls */} +
+ + + +
-
+
{/* ═══ TOOLBAR ═══ */}
-
- - - -
+ {/* Filter tabs */} + + + -
- search - setQuery(e.target.value)} - /> - {query && ( - - )} -
+
+ {/* URL import */}
{getUrlType(importUrl) === 'youtube' ? 'smart_display' @@ -1085,113 +1065,120 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp = false }: So
-
- -
- { - const newVol = volume > 0 ? 0 : 0.5; - setVolume(newVol); - if (guildId) apiSetVolumeLive(guildId, newVol).catch(() => {}); - }} - > - {volume === 0 ? 'volume_off' : volume < 0.5 ? 'volume_down' : 'volume_up'} - - { - const v = parseFloat(e.target.value); - setVolume(v); - if (guildId) { - if (volDebounceRef.current) clearTimeout(volDebounceRef.current); - volDebounceRef.current = setTimeout(() => { - apiSetVolumeLive(guildId, v).catch(() => {}); - }, 120); - } - }} - style={{ '--vol': `${Math.round(volume * 100)}%` } as React.CSSProperties} - /> - {Math.round(volume * 100)}% -
- - - - - - - -
- grid_view - setCardSize(parseInt(e.target.value))} - /> -
- -
- {THEMES.map(t => ( -
setTheme(t.id)} +
+ {/* Volume */} +
+ { + const newVol = volume > 0 ? 0 : 0.5; + setVolume(newVol); + if (guildId) apiSetVolumeLive(guildId, newVol).catch(() => {}); + }} + style={{ cursor: 'pointer' }} + > + {volume === 0 ? 'volume_off' : volume < 0.5 ? 'volume_down' : 'volume_up'} + + { + const v = parseFloat(e.target.value); + setVolume(v); + if (guildId) { + if (volDebounceRef.current) clearTimeout(volDebounceRef.current); + volDebounceRef.current = setTimeout(() => { + apiSetVolumeLive(guildId, v).catch(() => {}); + }, 120); + } + }} + style={{ '--vol': `${Math.round(volume * 100)}%` } as React.CSSProperties} /> - ))} -
-
- -
-
- library_music -
- Sounds gesamt - {totalSoundsDisplay} + {Math.round(volume * 100)}%
-
-
- leaderboard -
- Most Played -
- {analyticsTop.length === 0 ? ( - Noch keine Plays - ) : ( - analyticsTop.map((item, idx) => ( - - {idx + 1}. {item.name} ({item.count}) - - )) - )} -
+ {/* Channel selector */} +
e.stopPropagation()}> + + {channelOpen && ( +
+ {Object.entries(channelsByGuild).map(([guild, chs]) => ( + +
{guild}
+ {chs.map(ch => ( +
handleChannelSelect(ch)} + > + volume_up + {ch.channelName}{ch.members ? ` (${ch.members})` : ''} +
+ ))} +
+ ))} + {channels.length === 0 && ( +
+ Keine Channels verfuegbar +
+ )} +
+ )} +
+ + {/* Card size slider */} +
+ grid_view + setCardSize(parseInt(e.target.value))} + />
+ {/* ═══ MOST PLAYED / ANALYTICS ═══ */} + {analyticsTop.length > 0 && ( +
+
+ leaderboard + Most Played +
+
+ {analyticsTop.map((item, idx) => ( +
{ + const found = sounds.find(s => (s.relativePath ?? s.fileName) === item.relativePath); + if (found) handlePlay(found); + }} + > + {idx + 1} + {item.name} + {item.count} +
+ ))} +
+
+ )} + {/* ═══ FOLDER CHIPS ═══ */} {activeTab === 'all' && visibleFolders.length > 0 && (
@@ -1214,8 +1201,8 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp = false }: So
)} - {/* ═══ MAIN ═══ */} -
+ {/* ═══ SOUND GRID ═══ */} +
{displaySounds.length === 0 ? (
{activeTab === 'favorites' ? '\u2B50' : '\uD83D\uDD07'}
@@ -1232,66 +1219,88 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp = false }: So : 'Hier gibt\'s noch nichts zu hoeren.'}
- ) : ( -
- {displaySounds.map((s, idx) => { - const key = s.relativePath ?? s.fileName; - const isFav = !!favs[key]; - const isPlaying = lastPlayed === s.name; - const isNew = s.isRecent || s.badges?.includes('new'); - const initial = s.name.charAt(0).toUpperCase(); - const showInitial = firstOfInitial.has(idx); - const folderColor = s.folder ? (folderColorMap[s.folder] || 'var(--accent)') : 'var(--accent)'; + ) : (() => { + // Group sounds by initial letter for category headers + const groups: { letter: string; sounds: { sound: Sound; globalIdx: number }[] }[] = []; + let currentLetter = ''; + displaySounds.forEach((s, idx) => { + const ch = s.name.charAt(0).toUpperCase(); + const letter = /[A-Z]/.test(ch) ? ch : '#'; + if (letter !== currentLetter) { + currentLetter = letter; + groups.push({ letter, sounds: [] }); + } + groups[groups.length - 1].sounds.push({ sound: s, globalIdx: idx }); + }); - return ( -
{ - const card = e.currentTarget; - const rect = card.getBoundingClientRect(); - const ripple = document.createElement('div'); - ripple.className = 'ripple'; - const sz = Math.max(rect.width, rect.height); - ripple.style.width = ripple.style.height = sz + 'px'; - ripple.style.left = (e.clientX - rect.left - sz / 2) + 'px'; - ripple.style.top = (e.clientY - rect.top - sz / 2) + 'px'; - card.appendChild(ripple); - setTimeout(() => ripple.remove(), 500); - handlePlay(s); - }} - onContextMenu={e => { - e.preventDefault(); - e.stopPropagation(); - setCtxMenu({ - x: Math.min(e.clientX, window.innerWidth - 170), - y: Math.min(e.clientY, window.innerHeight - 140), - sound: s, - }); - }} - title={`${s.name}${s.folder ? ` (${s.folder})` : ''}`} - > - {isNew && NEU} - { e.stopPropagation(); toggleFav(key); }} - > - {isFav ? 'star' : 'star_border'} - - {showInitial && {initial}} - {s.name} - {s.folder && {s.folder}} -
-
-
-
-
- ); - })} -
- )} -
+ return groups.map(group => ( + +
+ {group.letter} + {group.sounds.length} Sound{group.sounds.length !== 1 ? 's' : ''} + +
+
+ {group.sounds.map(({ sound: s, globalIdx: idx }) => { + const key = s.relativePath ?? s.fileName; + const isFav = !!favs[key]; + const isPlaying = lastPlayed === s.name; + const isNew = s.isRecent || s.badges?.includes('new'); + const initial = s.name.charAt(0).toUpperCase(); + const showInitial = firstOfInitial.has(idx); + const folderColor = s.folder ? (folderColorMap[s.folder] || 'var(--accent)') : 'var(--accent)'; + + return ( +
{ + const card = e.currentTarget; + const rect = card.getBoundingClientRect(); + const ripple = document.createElement('div'); + ripple.className = 'ripple'; + const sz = Math.max(rect.width, rect.height); + ripple.style.width = ripple.style.height = sz + 'px'; + ripple.style.left = (e.clientX - rect.left - sz / 2) + 'px'; + ripple.style.top = (e.clientY - rect.top - sz / 2) + 'px'; + card.appendChild(ripple); + setTimeout(() => ripple.remove(), 500); + handlePlay(s); + }} + onContextMenu={e => { + e.preventDefault(); + e.stopPropagation(); + setCtxMenu({ + x: Math.min(e.clientX, window.innerWidth - 170), + y: Math.min(e.clientY, window.innerHeight - 140), + sound: s, + }); + }} + title={`${s.name}${s.folder ? ` (${s.folder})` : ''}`} + > + {isNew && NEU} + { e.stopPropagation(); toggleFav(key); }} + > + {isFav ? 'star' : 'star_border'} + + {showInitial && {initial}} + {s.name} + {s.folder && {s.folder}} +
+
+
+
+
+ ); + })} +
+ + )); + })()} +
{/* ═══ CONTEXT MENU ═══ */} {ctxMenu && ( @@ -1658,7 +1667,7 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp = false }: So {dropPhase === 'naming' && (
diff --git a/web/src/plugins/streaming/StreamingTab.tsx b/web/src/plugins/streaming/StreamingTab.tsx index bf6fc3b..13ca85d 100644 --- a/web/src/plugins/streaming/StreamingTab.tsx +++ b/web/src/plugins/streaming/StreamingTab.tsx @@ -753,39 +753,50 @@ export default function StreamingTab({ data }: { data: any }) { )}
- setUserName(e.target.value)} - disabled={isBroadcasting} - /> - setStreamTitle(e.target.value)} - disabled={isBroadcasting} - /> - setStreamPassword(e.target.value)} - disabled={isBroadcasting} - /> - + + + + {isBroadcasting ? (
From bccfee3de29b72c02fd5e71ae5d884a2714f3a15 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Mon, 9 Mar 2026 20:47:59 +0000 Subject: [PATCH 19/53] v1.8.4 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a7ee35a..bfa363e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.3 +1.8.4 From e9931d82af1104b0b4ebebdd147d763b0ef9f101 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 21:59:12 +0100 Subject: [PATCH 20/53] =?UTF-8?q?Refactor:=20Zentralisiertes=20Admin-Login?= =?UTF-8?q?=20im=20Top-Men=C3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Admin-Login aus 3 Plugins (Soundboard, Streaming, Game Library) entfernt - Zentraler 🔒/🔓 Button im Header mit Login-Modal - isAdmin wird als Prop an alle Plugins weitergegeben - Settings-Buttons (Gear-Icons) nur sichtbar wenn eingeloggt - Alle Plugins nutzen weiterhin den shared admin-Cookie für Operationen - Login/Logout-Formulare und Buttons aus Plugin-Panels entfernt Co-Authored-By: Claude Opus 4.6 --- web/dist/assets/index-BGKtt2gT.js | 4830 +++++++++++++++++ web/dist/assets/index-Be3HasqO.js | 4830 ----------------- web/dist/assets/index-DEfJ3Ric.css | 1 - web/dist/assets/index-TtdZJHkE.css | 1 + web/dist/index.html | 4 +- web/src/App.tsx | 89 +- .../plugins/game-library/GameLibraryTab.tsx | 135 +- web/src/plugins/soundboard/SoundboardTab.tsx | 81 +- web/src/plugins/streaming/StreamingTab.tsx | 71 +- web/src/styles.css | 98 + 10 files changed, 5077 insertions(+), 5063 deletions(-) create mode 100644 web/dist/assets/index-BGKtt2gT.js delete mode 100644 web/dist/assets/index-Be3HasqO.js delete mode 100644 web/dist/assets/index-DEfJ3Ric.css create mode 100644 web/dist/assets/index-TtdZJHkE.css diff --git a/web/dist/assets/index-BGKtt2gT.js b/web/dist/assets/index-BGKtt2gT.js new file mode 100644 index 0000000..9881ac1 --- /dev/null +++ b/web/dist/assets/index-BGKtt2gT.js @@ -0,0 +1,4830 @@ +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function E7(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var $b={exports:{}},Xp={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var I8;function CF(){if(I8)return Xp;I8=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,r,s){var a=null;if(s!==void 0&&(a=""+s),r.key!==void 0&&(a=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:i,type:n,key:a,ref:r!==void 0?r:null,props:s}}return Xp.Fragment=e,Xp.jsx=t,Xp.jsxs=t,Xp}var F8;function NF(){return F8||(F8=1,$b.exports=CF()),$b.exports}var P=NF(),Xb={exports:{}},Yp={},Yb={exports:{}},Qb={};/** + * @license React + * scheduler.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var k8;function RF(){return k8||(k8=1,(function(i){function e(K,ae){var Ae=K.length;K.push(ae);e:for(;0>>1,Se=K[be];if(0>>1;ber(qe,Ae))Cer(ke,qe)?(K[be]=ke,K[Ce]=Ae,be=Ce):(K[be]=qe,K[Ee]=Ae,be=Ee);else if(Cer(ke,Ae))K[be]=ke,K[Ce]=Ae,be=Ce;else break e}}return ae}function r(K,ae){var Ae=K.sortIndex-ae.sortIndex;return Ae!==0?Ae:K.id-ae.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;i.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();i.unstable_now=function(){return a.now()-l}}var u=[],h=[],m=1,v=null,x=3,S=!1,w=!1,N=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function I(K){for(var ae=t(h);ae!==null;){if(ae.callback===null)n(h);else if(ae.startTime<=K)n(h),ae.sortIndex=ae.expirationTime,e(u,ae);else break;ae=t(h)}}function j(K){if(N=!1,I(K),!w)if(t(u)!==null)w=!0,z||(z=!0,te());else{var ae=t(h);ae!==null&&Q(j,ae.startTime-K)}}var z=!1,G=-1,W=5,q=-1;function V(){return C?!0:!(i.unstable_now()-qK&&V());){var be=v.callback;if(typeof be=="function"){v.callback=null,x=v.priorityLevel;var Se=be(v.expirationTime<=K);if(K=i.unstable_now(),typeof Se=="function"){v.callback=Se,I(K),ae=!0;break t}v===t(u)&&n(u),I(K)}else n(u);v=t(u)}if(v!==null)ae=!0;else{var se=t(h);se!==null&&Q(j,se.startTime-K),ae=!1}}break e}finally{v=null,x=Ae,S=!1}ae=void 0}}finally{ae?te():z=!1}}}var te;if(typeof U=="function")te=function(){U(Y)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,le=ne.port2;ne.port1.onmessage=Y,te=function(){le.postMessage(null)}}else te=function(){E(Y,0)};function Q(K,ae){G=E(function(){K(i.unstable_now())},ae)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(K){K.callback=null},i.unstable_forceFrameRate=function(K){0>K||125be?(K.sortIndex=Ae,e(h,K),t(u)===null&&K===t(h)&&(N?(O(G),G=-1):N=!0,Q(j,Ae-be))):(K.sortIndex=Se,e(u,K),w||S||(w=!0,z||(z=!0,te()))),K},i.unstable_shouldYield=V,i.unstable_wrapCallback=function(K){var ae=x;return function(){var Ae=x;x=ae;try{return K.apply(this,arguments)}finally{x=Ae}}}})(Qb)),Qb}var z8;function DF(){return z8||(z8=1,Yb.exports=RF()),Yb.exports}var Kb={exports:{}},ii={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var G8;function PF(){if(G8)return ii;G8=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(se){return se===null||typeof se!="object"?null:(se=x&&se[x]||se["@@iterator"],typeof se=="function"?se:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,C={};function E(se,Ee,qe){this.props=se,this.context=Ee,this.refs=C,this.updater=qe||w}E.prototype.isReactComponent={},E.prototype.setState=function(se,Ee){if(typeof se!="object"&&typeof se!="function"&&se!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,se,Ee,"setState")},E.prototype.forceUpdate=function(se){this.updater.enqueueForceUpdate(this,se,"forceUpdate")};function O(){}O.prototype=E.prototype;function U(se,Ee,qe){this.props=se,this.context=Ee,this.refs=C,this.updater=qe||w}var I=U.prototype=new O;I.constructor=U,N(I,E.prototype),I.isPureReactComponent=!0;var j=Array.isArray;function z(){}var G={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function q(se,Ee,qe){var Ce=qe.ref;return{$$typeof:i,type:se,key:Ee,ref:Ce!==void 0?Ce:null,props:qe}}function V(se,Ee){return q(se.type,Ee,se.props)}function Y(se){return typeof se=="object"&&se!==null&&se.$$typeof===i}function te(se){var Ee={"=":"=0",":":"=2"};return"$"+se.replace(/[=:]/g,function(qe){return Ee[qe]})}var ne=/\/+/g;function le(se,Ee){return typeof se=="object"&&se!==null&&se.key!=null?te(""+se.key):Ee.toString(36)}function Q(se){switch(se.status){case"fulfilled":return se.value;case"rejected":throw se.reason;default:switch(typeof se.status=="string"?se.then(z,z):(se.status="pending",se.then(function(Ee){se.status==="pending"&&(se.status="fulfilled",se.value=Ee)},function(Ee){se.status==="pending"&&(se.status="rejected",se.reason=Ee)})),se.status){case"fulfilled":return se.value;case"rejected":throw se.reason}}throw se}function K(se,Ee,qe,Ce,ke){var Qe=typeof se;(Qe==="undefined"||Qe==="boolean")&&(se=null);var et=!1;if(se===null)et=!0;else switch(Qe){case"bigint":case"string":case"number":et=!0;break;case"object":switch(se.$$typeof){case i:case e:et=!0;break;case m:return et=se._init,K(et(se._payload),Ee,qe,Ce,ke)}}if(et)return ke=ke(se),et=Ce===""?"."+le(se,0):Ce,j(ke)?(qe="",et!=null&&(qe=et.replace(ne,"$&/")+"/"),K(ke,Ee,qe,"",function(Gt){return Gt})):ke!=null&&(Y(ke)&&(ke=V(ke,qe+(ke.key==null||se&&se.key===ke.key?"":(""+ke.key).replace(ne,"$&/")+"/")+et)),Ee.push(ke)),1;et=0;var Pt=Ce===""?".":Ce+":";if(j(se))for(var Nt=0;Nt"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Zb.exports=LF(),Zb.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var H8;function BF(){if(H8)return Yp;H8=1;var i=DF(),e=xw(),t=UF();function n(o){var c="https://react.dev/errors/"+o;if(1Se||(o.current=be[Se],be[Se]=null,Se--)}function qe(o,c){Se++,be[Se]=o.current,o.current=c}var Ce=se(null),ke=se(null),Qe=se(null),et=se(null);function Pt(o,c){switch(qe(Qe,c),qe(ke,o),qe(Ce,null),c.nodeType){case 9:case 11:o=(o=c.documentElement)&&(o=o.namespaceURI)?a8(o):0;break;default:if(o=c.tagName,c=c.namespaceURI)c=a8(c),o=o8(c,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}Ee(Ce),qe(Ce,o)}function Nt(){Ee(Ce),Ee(ke),Ee(Qe)}function Gt(o){o.memoizedState!==null&&qe(et,o);var c=Ce.current,g=o8(c,o.type);c!==g&&(qe(ke,o),qe(Ce,g))}function Tt(o){ke.current===o&&(Ee(Ce),Ee(ke)),et.current===o&&(Ee(et),jp._currentValue=Ae)}var Ge,dt;function he(o){if(Ge===void 0)try{throw Error()}catch(g){var c=g.stack.trim().match(/\n( *(at )?)/);Ge=c&&c[1]||"",dt=-1)":-1D||Me[b]!==rt[D]){var _t=` +`+Me[b].replace(" at new "," at ");return o.displayName&&_t.includes("")&&(_t=_t.replace("",o.displayName)),_t}while(1<=b&&0<=D);break}}}finally{en=!1,Error.prepareStackTrace=g}return(g=o?o.displayName||o.name:"")?he(g):""}function qt(o,c){switch(o.tag){case 26:case 27:case 5:return he(o.type);case 16:return he("Lazy");case 13:return o.child!==c&&c!==null?he("Suspense Fallback"):he("Suspense");case 19:return he("SuspenseList");case 0:case 15:return wt(o.type,!1);case 11:return wt(o.type.render,!1);case 1:return wt(o.type,!0);case 31:return he("Activity");default:return""}}function Lt(o){try{var c="",g=null;do c+=qt(o,g),g=o,o=o.return;while(o);return c}catch(b){return` +Error generating stack: `+b.message+` +`+b.stack}}var hn=Object.prototype.hasOwnProperty,ut=i.unstable_scheduleCallback,fe=i.unstable_cancelCallback,k=i.unstable_shouldYield,_e=i.unstable_requestPaint,Be=i.unstable_now,Oe=i.unstable_getCurrentPriorityLevel,je=i.unstable_ImmediatePriority,Bt=i.unstable_UserBlockingPriority,yt=i.unstable_NormalPriority,Xt=i.unstable_LowPriority,ln=i.unstable_IdlePriority,mt=i.log,Wt=i.unstable_setDisableYieldValue,Yt=null,$t=null;function It(o){if(typeof mt=="function"&&Wt(o),$t&&typeof $t.setStrictMode=="function")try{$t.setStrictMode(Yt,o)}catch{}}var Te=Math.clz32?Math.clz32:ce,nt=Math.log,At=Math.LN2;function ce(o){return o>>>=0,o===0?32:31-(nt(o)/At|0)|0}var xt=256,Ze=262144,lt=4194304;function bt(o){var c=o&42;if(c!==0)return c;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function Kt(o,c,g){var b=o.pendingLanes;if(b===0)return 0;var D=0,L=o.suspendedLanes,X=o.pingedLanes;o=o.warmLanes;var oe=b&134217727;return oe!==0?(b=oe&~L,b!==0?D=bt(b):(X&=oe,X!==0?D=bt(X):g||(g=oe&~o,g!==0&&(D=bt(g))))):(oe=b&~L,oe!==0?D=bt(oe):X!==0?D=bt(X):g||(g=b&~o,g!==0&&(D=bt(g)))),D===0?0:c!==0&&c!==D&&(c&L)===0&&(L=D&-D,g=c&-c,L>=g||L===32&&(g&4194048)!==0)?c:D}function un(o,c){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&c)===0}function Ye(o,c){switch(o){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function St(){var o=lt;return lt<<=1,(lt&62914560)===0&&(lt=4194304),o}function ye(o){for(var c=[],g=0;31>g;g++)c.push(o);return c}function pt(o,c){o.pendingLanes|=c,c!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function Zt(o,c,g,b,D,L){var X=o.pendingLanes;o.pendingLanes=g,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=g,o.entangledLanes&=g,o.errorRecoveryDisabledLanes&=g,o.shellSuspendCounter=0;var oe=o.entanglements,Me=o.expirationTimes,rt=o.hiddenUpdates;for(g=X&~g;0"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var qr=/[\n"\\]/g;function Er(o){return o.replace(qr,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Ni(o,c,g,b,D,L,X,oe){o.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?o.type=X:o.removeAttribute("type"),c!=null?X==="number"?(c===0&&o.value===""||o.value!=c)&&(o.value=""+Vn(c)):o.value!==""+Vn(c)&&(o.value=""+Vn(c)):X!=="submit"&&X!=="reset"||o.removeAttribute("value"),c!=null?_i(o,X,Vn(c)):g!=null?_i(o,X,Vn(g)):b!=null&&o.removeAttribute("value"),D==null&&L!=null&&(o.defaultChecked=!!L),D!=null&&(o.checked=D&&typeof D!="function"&&typeof D!="symbol"),oe!=null&&typeof oe!="function"&&typeof oe!="symbol"&&typeof oe!="boolean"?o.name=""+Vn(oe):o.removeAttribute("name")}function Yi(o,c,g,b,D,L,X,oe){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(o.type=L),c!=null||g!=null){if(!(L!=="submit"&&L!=="reset"||c!=null)){pi(o);return}g=g!=null?""+Vn(g):"",c=c!=null?""+Vn(c):g,oe||c===o.value||(o.value=c),o.defaultValue=c}b=b??D,b=typeof b!="function"&&typeof b!="symbol"&&!!b,o.checked=oe?o.checked:!!b,o.defaultChecked=!!b,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(o.name=X),pi(o)}function _i(o,c,g){c==="number"&&Gr(o.ownerDocument)===o||o.defaultValue===""+g||(o.defaultValue=""+g)}function pr(o,c,g,b){if(o=o.options,c){c={};for(var D=0;D"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ed=!1;if(dl)try{var sf={};Object.defineProperty(sf,"passive",{get:function(){Ed=!0}}),window.addEventListener("test",sf,sf),window.removeEventListener("test",sf,sf)}catch{Ed=!1}var qo=null,af=null,Cd=null;function ip(){if(Cd)return Cd;var o,c=af,g=c.length,b,D="value"in qo?qo.value:qo.textContent,L=D.length;for(o=0;o=cf),ju=" ",g1=!1;function Pd(o,c){switch(o){case"keyup":return xx.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lp(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var nh=!1;function v1(o,c){switch(o){case"compositionend":return lp(c);case"keypress":return c.which!==32?null:(g1=!0,ju);case"textInput":return o=c.data,o===ju&&g1?null:o;default:return null}}function bx(o,c){if(nh)return o==="compositionend"||!Vu&&Pd(o,c)?(o=ip(),Cd=af=qo=null,nh=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:g,offset:c-o};o=b}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=Bd(g)}}function Xu(o,c){return o&&c?o===c?!0:o&&o.nodeType===3?!1:c&&c.nodeType===3?Xu(o,c.parentNode):"contains"in o?o.contains(c):o.compareDocumentPosition?!!(o.compareDocumentPosition(c)&16):!1:!1}function jl(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var c=Gr(o.document);c instanceof o.HTMLIFrameElement;){try{var g=typeof c.contentWindow.location.href=="string"}catch{g=!1}if(g)o=c.contentWindow;else break;c=Gr(o.document)}return c}function Hl(o){var c=o&&o.nodeName&&o.nodeName.toLowerCase();return c&&(c==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||c==="textarea"||o.contentEditable==="true")}var wx=dl&&"documentMode"in document&&11>=document.documentMode,Yu=null,dp=null,Qu=null,Ap=!1;function T1(o,c,g){var b=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;Ap||Yu==null||Yu!==Gr(b)||(b=Yu,"selectionStart"in b&&Hl(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Qu&&Ps(Qu,b)||(Qu=b,b=s2(dp,"onSelect"),0>=X,D-=X,Oa=1<<32-Te(c)+D|g<di?(wi=Sn,Sn=null):wi=Sn.sibling;var Ui=st(We,Sn,it[di],Dt);if(Ui===null){Sn===null&&(Sn=wi);break}o&&Sn&&Ui.alternate===null&&c(We,Sn),Ue=L(Ui,Ue,di),Li===null?Dn=Ui:Li.sibling=Ui,Li=Ui,Sn=wi}if(di===it.length)return g(We,Sn),xi&&Ho(We,di),Dn;if(Sn===null){for(;didi?(wi=Sn,Sn=null):wi=Sn.sibling;var yh=st(We,Sn,Ui.value,Dt);if(yh===null){Sn===null&&(Sn=wi);break}o&&Sn&&yh.alternate===null&&c(We,Sn),Ue=L(yh,Ue,di),Li===null?Dn=yh:Li.sibling=yh,Li=yh,Sn=wi}if(Ui.done)return g(We,Sn),xi&&Ho(We,di),Dn;if(Sn===null){for(;!Ui.done;di++,Ui=it.next())Ui=Ot(We,Ui.value,Dt),Ui!==null&&(Ue=L(Ui,Ue,di),Li===null?Dn=Ui:Li.sibling=Ui,Li=Ui);return xi&&Ho(We,di),Dn}for(Sn=b(Sn);!Ui.done;di++,Ui=it.next())Ui=ct(Sn,We,di,Ui.value,Dt),Ui!==null&&(o&&Ui.alternate!==null&&Sn.delete(Ui.key===null?di:Ui.key),Ue=L(Ui,Ue,di),Li===null?Dn=Ui:Li.sibling=Ui,Li=Ui);return o&&Sn.forEach(function(EF){return c(We,EF)}),xi&&Ho(We,di),Dn}function ir(We,Ue,it,Dt){if(typeof it=="object"&&it!==null&&it.type===N&&it.key===null&&(it=it.props.children),typeof it=="object"&&it!==null){switch(it.$$typeof){case S:e:{for(var Dn=it.key;Ue!==null;){if(Ue.key===Dn){if(Dn=it.type,Dn===N){if(Ue.tag===7){g(We,Ue.sibling),Dt=D(Ue,it.props.children),Dt.return=We,We=Dt;break e}}else if(Ue.elementType===Dn||typeof Dn=="object"&&Dn!==null&&Dn.$$typeof===W&&d(Dn)===Ue.type){g(We,Ue.sibling),Dt=D(Ue,it.props),B(Dt,it),Dt.return=We,We=Dt;break e}g(We,Ue);break}else c(We,Ue);Ue=Ue.sibling}it.type===N?(Dt=tc(it.props.children,We.mode,Dt,it.key),Dt.return=We,We=Dt):(Dt=zd(it.type,it.key,it.props,null,We.mode,Dt),B(Dt,it),Dt.return=We,We=Dt)}return X(We);case w:e:{for(Dn=it.key;Ue!==null;){if(Ue.key===Dn)if(Ue.tag===4&&Ue.stateNode.containerInfo===it.containerInfo&&Ue.stateNode.implementation===it.implementation){g(We,Ue.sibling),Dt=D(Ue,it.children||[]),Dt.return=We,We=Dt;break e}else{g(We,Ue);break}else c(We,Ue);Ue=Ue.sibling}Dt=jo(it,We.mode,Dt),Dt.return=We,We=Dt}return X(We);case W:return it=d(it),ir(We,Ue,it,Dt)}if(Q(it))return vn(We,Ue,it,Dt);if(te(it)){if(Dn=te(it),typeof Dn!="function")throw Error(n(150));return it=Dn.call(it),Gn(We,Ue,it,Dt)}if(typeof it.then=="function")return ir(We,Ue,R(it),Dt);if(it.$$typeof===U)return ir(We,Ue,$d(We,it),Dt);F(We,it)}return typeof it=="string"&&it!==""||typeof it=="number"||typeof it=="bigint"?(it=""+it,Ue!==null&&Ue.tag===6?(g(We,Ue.sibling),Dt=D(Ue,it),Dt.return=We,We=Dt):(g(We,Ue),Dt=_p(it,We.mode,Dt),Dt.return=We,We=Dt),X(We)):g(We,Ue)}return function(We,Ue,it,Dt){try{M=0;var Dn=ir(We,Ue,it,Dt);return T=null,Dn}catch(Sn){if(Sn===xl||Sn===vo)throw Sn;var Li=ia(29,Sn,null,We.mode);return Li.lanes=Dt,Li.return=We,Li}finally{}}}var re=H(!0),me=H(!1),pe=!1;function ge(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ne(o,c){o=o.updateQueue,c.updateQueue===o&&(c.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function Ie(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function Je(o,c,g){var b=o.updateQueue;if(b===null)return null;if(b=b.shared,(Fi&2)!==0){var D=b.pending;return D===null?c.next=c:(c.next=D.next,D.next=c),b.pending=c,c=kd(o),E1(o,null,g),c}return Fd(o,b,c,g),kd(o)}function He(o,c,g){if(c=c.updateQueue,c!==null&&(c=c.shared,(g&4194048)!==0)){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,at(o,g)}}function Ve(o,c){var g=o.updateQueue,b=o.alternate;if(b!==null&&(b=b.updateQueue,g===b)){var D=null,L=null;if(g=g.firstBaseUpdate,g!==null){do{var X={lane:g.lane,tag:g.tag,payload:g.payload,callback:null,next:null};L===null?D=L=X:L=L.next=X,g=g.next}while(g!==null);L===null?D=L=c:L=L.next=c}else D=L=c;g={baseState:b.baseState,firstBaseUpdate:D,lastBaseUpdate:L,shared:b.shared,callbacks:b.callbacks},o.updateQueue=g;return}o=g.lastBaseUpdate,o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=c}var Re=!1;function jt(){if(Re){var o=vr;if(o!==null)throw o}}function pn(o,c,g,b){Re=!1;var D=o.updateQueue;pe=!1;var L=D.firstBaseUpdate,X=D.lastBaseUpdate,oe=D.shared.pending;if(oe!==null){D.shared.pending=null;var Me=oe,rt=Me.next;Me.next=null,X===null?L=rt:X.next=rt,X=Me;var _t=o.alternate;_t!==null&&(_t=_t.updateQueue,oe=_t.lastBaseUpdate,oe!==X&&(oe===null?_t.firstBaseUpdate=rt:oe.next=rt,_t.lastBaseUpdate=Me))}if(L!==null){var Ot=D.baseState;X=0,_t=rt=Me=null,oe=L;do{var st=oe.lane&-536870913,ct=st!==oe.lane;if(ct?(Ti&st)===st:(b&st)===st){st!==0&&st===ah&&(Re=!0),_t!==null&&(_t=_t.next={lane:0,tag:oe.tag,payload:oe.payload,callback:null,next:null});e:{var vn=o,Gn=oe;st=c;var ir=g;switch(Gn.tag){case 1:if(vn=Gn.payload,typeof vn=="function"){Ot=vn.call(ir,Ot,st);break e}Ot=vn;break e;case 3:vn.flags=vn.flags&-65537|128;case 0:if(vn=Gn.payload,st=typeof vn=="function"?vn.call(ir,Ot,st):vn,st==null)break e;Ot=v({},Ot,st);break e;case 2:pe=!0}}st=oe.callback,st!==null&&(o.flags|=64,ct&&(o.flags|=8192),ct=D.callbacks,ct===null?D.callbacks=[st]:ct.push(st))}else ct={lane:st,tag:oe.tag,payload:oe.payload,callback:oe.callback,next:null},_t===null?(rt=_t=ct,Me=Ot):_t=_t.next=ct,X|=st;if(oe=oe.next,oe===null){if(oe=D.shared.pending,oe===null)break;ct=oe,oe=ct.next,ct.next=null,D.lastBaseUpdate=ct,D.shared.pending=null}}while(!0);_t===null&&(Me=Ot),D.baseState=Me,D.firstBaseUpdate=rt,D.lastBaseUpdate=_t,L===null&&(D.shared.lanes=0),ch|=X,o.lanes=X,o.memoizedState=Ot}}function cn(o,c){if(typeof o!="function")throw Error(n(191,o));o.call(c)}function jn(o,c){var g=o.callbacks;if(g!==null)for(o.callbacks=null,o=0;oL?L:8;var X=K.T,oe={};K.T=oe,Hx(o,!1,c,g);try{var Me=D(),rt=K.S;if(rt!==null&&rt(oe,Me),Me!==null&&typeof Me=="object"&&typeof Me.then=="function"){var _t=D1(Me,b);Ep(o,c,_t,bo(o))}else Ep(o,c,b,bo(o))}catch(Ot){Ep(o,c,{then:function(){},status:"rejected",reason:Ot},bo())}finally{ae.p=L,X!==null&&oe.types!==null&&(X.types=oe.types),K.T=X}}function bI(){}function Vx(o,c,g,b){if(o.tag!==5)throw Error(n(476));var D=P4(o).queue;D4(o,D,c,Ae,g===null?bI:function(){return L4(o),g(b)})}function P4(o){var c=o.memoizedState;if(c!==null)return c;c={memoizedState:Ae,baseState:Ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cc,lastRenderedState:Ae},next:null};var g={};return c.next={memoizedState:g,baseState:g,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cc,lastRenderedState:g},next:null},o.memoizedState=c,o=o.alternate,o!==null&&(o.memoizedState=c),c}function L4(o){var c=P4(o);c.next===null&&(c=o.alternate.memoizedState),Ep(o,c.next.queue,{},bo())}function jx(){return bs(jp)}function U4(){return is().memoizedState}function B4(){return is().memoizedState}function SI(o){for(var c=o.return;c!==null;){switch(c.tag){case 24:case 3:var g=bo();o=Ie(g);var b=Je(c,o,g);b!==null&&(Va(b,c,g),He(b,c,g)),c={cache:Hr()},o.payload=c;return}c=c.return}}function TI(o,c,g){var b=bo();g={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},z1(o)?I4(c,g):(g=vp(o,c,g,b),g!==null&&(Va(g,o,b),F4(g,c,b)))}function O4(o,c,g){var b=bo();Ep(o,c,g,b)}function Ep(o,c,g,b){var D={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null};if(z1(o))I4(c,D);else{var L=o.alternate;if(o.lanes===0&&(L===null||L.lanes===0)&&(L=c.lastRenderedReducer,L!==null))try{var X=c.lastRenderedState,oe=L(X,g);if(D.hasEagerState=!0,D.eagerState=oe,ya(oe,X))return Fd(o,c,D,0),hr===null&&Id(),!1}catch{}finally{}if(g=vp(o,c,D,b),g!==null)return Va(g,o,b),F4(g,c,b),!0}return!1}function Hx(o,c,g,b){if(b={lane:2,revertLane:Sb(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},z1(o)){if(c)throw Error(n(479))}else c=vp(o,g,b,2),c!==null&&Va(c,o,2)}function z1(o){var c=o.alternate;return o===ui||c!==null&&c===ui}function I4(o,c){Xd=L1=!0;var g=o.pending;g===null?c.next=c:(c.next=g.next,g.next=c),o.pending=c}function F4(o,c,g){if((g&4194048)!==0){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,at(o,g)}}var Cp={readContext:bs,use:O1,useCallback:Wr,useContext:Wr,useEffect:Wr,useImperativeHandle:Wr,useLayoutEffect:Wr,useInsertionEffect:Wr,useMemo:Wr,useReducer:Wr,useRef:Wr,useState:Wr,useDebugValue:Wr,useDeferredValue:Wr,useTransition:Wr,useSyncExternalStore:Wr,useId:Wr,useHostTransitionStatus:Wr,useFormState:Wr,useActionState:Wr,useOptimistic:Wr,useMemoCache:Wr,useCacheRefresh:Wr};Cp.useEffectEvent=Wr;var k4={readContext:bs,use:O1,useCallback:function(o,c){return Sa().memoizedState=[o,c===void 0?null:c],o},useContext:bs,useEffect:b4,useImperativeHandle:function(o,c,g){g=g!=null?g.concat([o]):null,F1(4194308,4,M4.bind(null,c,o),g)},useLayoutEffect:function(o,c){return F1(4194308,4,o,c)},useInsertionEffect:function(o,c){F1(4,2,o,c)},useMemo:function(o,c){var g=Sa();c=c===void 0?null:c;var b=o();if(_f){It(!0);try{o()}finally{It(!1)}}return g.memoizedState=[b,c],b},useReducer:function(o,c,g){var b=Sa();if(g!==void 0){var D=g(c);if(_f){It(!0);try{g(c)}finally{It(!1)}}}else D=c;return b.memoizedState=b.baseState=D,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:D},b.queue=o,o=o.dispatch=TI.bind(null,ui,o),[b.memoizedState,o]},useRef:function(o){var c=Sa();return o={current:o},c.memoizedState=o},useState:function(o){o=Fx(o);var c=o.queue,g=O4.bind(null,ui,c);return c.dispatch=g,[o.memoizedState,g]},useDebugValue:Gx,useDeferredValue:function(o,c){var g=Sa();return qx(g,o,c)},useTransition:function(){var o=Fx(!1);return o=D4.bind(null,ui,o.queue,!0,!1),Sa().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,c,g){var b=ui,D=Sa();if(xi){if(g===void 0)throw Error(n(407));g=g()}else{if(g=c(),hr===null)throw Error(n(349));(Ti&127)!==0||a4(b,c,g)}D.memoizedState=g;var L={value:g,getSnapshot:c};return D.queue=L,b4(l4.bind(null,b,L,o),[o]),b.flags|=2048,Qd(9,{destroy:void 0},o4.bind(null,b,L,g,c),null),g},useId:function(){var o=Sa(),c=hr.identifierPrefix;if(xi){var g=Ia,b=Oa;g=(b&~(1<<32-Te(b)-1)).toString(32)+g,c="_"+c+"R_"+g,g=U1++,0<\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof b.is=="string"?X.createElement("select",{is:b.is}):X.createElement("select"),b.multiple?L.multiple=!0:b.size&&(L.size=b.size);break;default:L=typeof b.is=="string"?X.createElement(D,{is:b.is}):X.createElement(D)}}L[zn]=c,L[An]=b;e:for(X=c.child;X!==null;){if(X.tag===5||X.tag===6)L.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===c)break e;for(;X.sibling===null;){if(X.return===null||X.return===c)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}c.stateNode=L;e:switch(Vs(L,D,b),D){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&fc(c)}}return _r(c),sb(c,c.type,o===null?null:o.memoizedProps,c.pendingProps,g),null;case 6:if(o&&c.stateNode!=null)o.memoizedProps!==b&&fc(c);else{if(typeof b!="string"&&c.stateNode===null)throw Error(n(166));if(o=Qe.current,cr(c)){if(o=c.stateNode,g=c.memoizedProps,b=null,D=xs,D!==null)switch(D.tag){case 27:case 5:b=D.memoizedProps}o[zn]=c,o=!!(o.nodeValue===g||b!==null&&b.suppressHydrationWarning===!0||r8(o.nodeValue,g)),o||Xl(c,!0)}else o=a2(o).createTextNode(b),o[zn]=c,c.stateNode=o}return _r(c),null;case 31:if(g=c.memoizedState,o===null||o.memoizedState!==null){if(b=cr(c),g!==null){if(o===null){if(!b)throw Error(n(318));if(o=c.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(557));o[zn]=c}else ic(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;_r(c),o=!1}else g=Tp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=g),o=!0;if(!o)return c.flags&256?(_o(c),c):(_o(c),null);if((c.flags&128)!==0)throw Error(n(558))}return _r(c),null;case 13:if(b=c.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(D=cr(c),b!==null&&b.dehydrated!==null){if(o===null){if(!D)throw Error(n(318));if(D=c.memoizedState,D=D!==null?D.dehydrated:null,!D)throw Error(n(317));D[zn]=c}else ic(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;_r(c),D=!1}else D=Tp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=D),D=!0;if(!D)return c.flags&256?(_o(c),c):(_o(c),null)}return _o(c),(c.flags&128)!==0?(c.lanes=g,c):(g=b!==null,o=o!==null&&o.memoizedState!==null,g&&(b=c.child,D=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(D=b.alternate.memoizedState.cachePool.pool),L=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(L=b.memoizedState.cachePool.pool),L!==D&&(b.flags|=2048)),g!==o&&g&&(c.child.flags|=8192),H1(c,c.updateQueue),_r(c),null);case 4:return Nt(),o===null&&Eb(c.stateNode.containerInfo),_r(c),null;case 10:return Wo(c.type),_r(c),null;case 19:if(Ee(ns),b=c.memoizedState,b===null)return _r(c),null;if(D=(c.flags&128)!==0,L=b.rendering,L===null)if(D)Rp(b,!1);else{if($r!==0||o!==null&&(o.flags&128)!==0)for(o=c.child;o!==null;){if(L=P1(o),L!==null){for(c.flags|=128,Rp(b,!1),o=L.updateQueue,c.updateQueue=o,H1(c,o),c.subtreeFlags=0,o=g,g=c.child;g!==null;)C1(g,o),g=g.sibling;return qe(ns,ns.current&1|2),xi&&Ho(c,b.treeForkCount),c.child}o=o.sibling}b.tail!==null&&Be()>Q1&&(c.flags|=128,D=!0,Rp(b,!1),c.lanes=4194304)}else{if(!D)if(o=P1(L),o!==null){if(c.flags|=128,D=!0,o=o.updateQueue,c.updateQueue=o,H1(c,o),Rp(b,!0),b.tail===null&&b.tailMode==="hidden"&&!L.alternate&&!xi)return _r(c),null}else 2*Be()-b.renderingStartTime>Q1&&g!==536870912&&(c.flags|=128,D=!0,Rp(b,!1),c.lanes=4194304);b.isBackwards?(L.sibling=c.child,c.child=L):(o=b.last,o!==null?o.sibling=L:c.child=L,b.last=L)}return b.tail!==null?(o=b.tail,b.rendering=o,b.tail=o.sibling,b.renderingStartTime=Be(),o.sibling=null,g=ns.current,qe(ns,D?g&1|2:g&1),xi&&Ho(c,b.treeForkCount),o):(_r(c),null);case 22:case 23:return _o(c),Ht(),b=c.memoizedState!==null,o!==null?o.memoizedState!==null!==b&&(c.flags|=8192):b&&(c.flags|=8192),b?(g&536870912)!==0&&(c.flags&128)===0&&(_r(c),c.subtreeFlags&6&&(c.flags|=8192)):_r(c),g=c.updateQueue,g!==null&&H1(c,g.retryQueue),g=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),b=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(b=c.memoizedState.cachePool.pool),b!==g&&(c.flags|=2048),o!==null&&Ee(zt),null;case 24:return g=null,o!==null&&(g=o.memoizedState.cache),c.memoizedState.cache!==g&&(c.flags|=2048),Wo(rn),_r(c),null;case 25:return null;case 30:return null}throw Error(n(156,c.tag))}function NI(o,c){switch(yp(c),c.tag){case 1:return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 3:return Wo(rn),Nt(),o=c.flags,(o&65536)!==0&&(o&128)===0?(c.flags=o&-65537|128,c):null;case 26:case 27:case 5:return Tt(c),null;case 31:if(c.memoizedState!==null){if(_o(c),c.alternate===null)throw Error(n(340));ic()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 13:if(_o(c),o=c.memoizedState,o!==null&&o.dehydrated!==null){if(c.alternate===null)throw Error(n(340));ic()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 19:return Ee(ns),null;case 4:return Nt(),null;case 10:return Wo(c.type),null;case 22:case 23:return _o(c),Ht(),o!==null&&Ee(zt),o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 24:return Wo(rn),null;case 25:return null;default:return null}}function uC(o,c){switch(yp(c),c.tag){case 3:Wo(rn),Nt();break;case 26:case 27:case 5:Tt(c);break;case 4:Nt();break;case 31:c.memoizedState!==null&&_o(c);break;case 13:_o(c);break;case 19:Ee(ns);break;case 10:Wo(c.type);break;case 22:case 23:_o(c),Ht(),o!==null&&Ee(zt);break;case 24:Wo(rn)}}function Dp(o,c){try{var g=c.updateQueue,b=g!==null?g.lastEffect:null;if(b!==null){var D=b.next;g=D;do{if((g.tag&o)===o){b=void 0;var L=g.create,X=g.inst;b=L(),X.destroy=b}g=g.next}while(g!==D)}}catch(oe){Ki(c,c.return,oe)}}function lh(o,c,g){try{var b=c.updateQueue,D=b!==null?b.lastEffect:null;if(D!==null){var L=D.next;b=L;do{if((b.tag&o)===o){var X=b.inst,oe=X.destroy;if(oe!==void 0){X.destroy=void 0,D=c;var Me=g,rt=oe;try{rt()}catch(_t){Ki(D,Me,_t)}}}b=b.next}while(b!==L)}}catch(_t){Ki(c,c.return,_t)}}function cC(o){var c=o.updateQueue;if(c!==null){var g=o.stateNode;try{jn(c,g)}catch(b){Ki(o,o.return,b)}}}function hC(o,c,g){g.props=yf(o.type,o.memoizedProps),g.state=o.memoizedState;try{g.componentWillUnmount()}catch(b){Ki(o,c,b)}}function Pp(o,c){try{var g=o.ref;if(g!==null){switch(o.tag){case 26:case 27:case 5:var b=o.stateNode;break;case 30:b=o.stateNode;break;default:b=o.stateNode}typeof g=="function"?o.refCleanup=g(b):g.current=b}}catch(D){Ki(o,c,D)}}function Ql(o,c){var g=o.ref,b=o.refCleanup;if(g!==null)if(typeof b=="function")try{b()}catch(D){Ki(o,c,D)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof g=="function")try{g(null)}catch(D){Ki(o,c,D)}else g.current=null}function fC(o){var c=o.type,g=o.memoizedProps,b=o.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":g.autoFocus&&b.focus();break e;case"img":g.src?b.src=g.src:g.srcSet&&(b.srcset=g.srcSet)}}catch(D){Ki(o,o.return,D)}}function ab(o,c,g){try{var b=o.stateNode;KI(b,o.type,g,c),b[An]=c}catch(D){Ki(o,o.return,D)}}function dC(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&ph(o.type)||o.tag===4}function ob(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||dC(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&ph(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function lb(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?(g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g).insertBefore(o,c):(c=g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g,c.appendChild(o),g=g._reactRootContainer,g!=null||c.onclick!==null||(c.onclick=er));else if(b!==4&&(b===27&&ph(o.type)&&(g=o.stateNode,c=null),o=o.child,o!==null))for(lb(o,c,g),o=o.sibling;o!==null;)lb(o,c,g),o=o.sibling}function W1(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?g.insertBefore(o,c):g.appendChild(o);else if(b!==4&&(b===27&&ph(o.type)&&(g=o.stateNode),o=o.child,o!==null))for(W1(o,c,g),o=o.sibling;o!==null;)W1(o,c,g),o=o.sibling}function AC(o){var c=o.stateNode,g=o.memoizedProps;try{for(var b=o.type,D=c.attributes;D.length;)c.removeAttributeNode(D[0]);Vs(c,b,g),c[zn]=o,c[An]=g}catch(L){Ki(o,o.return,L)}}var dc=!1,ds=!1,ub=!1,pC=typeof WeakSet=="function"?WeakSet:Set,Bs=null;function RI(o,c){if(o=o.containerInfo,Rb=d2,o=jl(o),Hl(o)){if("selectionStart"in o)var g={start:o.selectionStart,end:o.selectionEnd};else e:{g=(g=o.ownerDocument)&&g.defaultView||window;var b=g.getSelection&&g.getSelection();if(b&&b.rangeCount!==0){g=b.anchorNode;var D=b.anchorOffset,L=b.focusNode;b=b.focusOffset;try{g.nodeType,L.nodeType}catch{g=null;break e}var X=0,oe=-1,Me=-1,rt=0,_t=0,Ot=o,st=null;t:for(;;){for(var ct;Ot!==g||D!==0&&Ot.nodeType!==3||(oe=X+D),Ot!==L||b!==0&&Ot.nodeType!==3||(Me=X+b),Ot.nodeType===3&&(X+=Ot.nodeValue.length),(ct=Ot.firstChild)!==null;)st=Ot,Ot=ct;for(;;){if(Ot===o)break t;if(st===g&&++rt===D&&(oe=X),st===L&&++_t===b&&(Me=X),(ct=Ot.nextSibling)!==null)break;Ot=st,st=Ot.parentNode}Ot=ct}g=oe===-1||Me===-1?null:{start:oe,end:Me}}else g=null}g=g||{start:0,end:0}}else g=null;for(Db={focusedElem:o,selectionRange:g},d2=!1,Bs=c;Bs!==null;)if(c=Bs,o=c.child,(c.subtreeFlags&1028)!==0&&o!==null)o.return=c,Bs=o;else for(;Bs!==null;){switch(c=Bs,L=c.alternate,o=c.flags,c.tag){case 0:if((o&4)!==0&&(o=c.updateQueue,o=o!==null?o.events:null,o!==null))for(g=0;g title"))),Vs(L,b,g),L[zn]=o,ze(L),b=L;break e;case"link":var X=x8("link","href",D).get(b+(g.href||""));if(X){for(var oe=0;oeir&&(X=ir,ir=Gn,Gn=X);var We=Od(oe,Gn),Ue=Od(oe,ir);if(We&&Ue&&(ct.rangeCount!==1||ct.anchorNode!==We.node||ct.anchorOffset!==We.offset||ct.focusNode!==Ue.node||ct.focusOffset!==Ue.offset)){var it=Ot.createRange();it.setStart(We.node,We.offset),ct.removeAllRanges(),Gn>ir?(ct.addRange(it),ct.extend(Ue.node,Ue.offset)):(it.setEnd(Ue.node,Ue.offset),ct.addRange(it))}}}}for(Ot=[],ct=oe;ct=ct.parentNode;)ct.nodeType===1&&Ot.push({element:ct,left:ct.scrollLeft,top:ct.scrollTop});for(typeof oe.focus=="function"&&oe.focus(),oe=0;oeg?32:g,K.T=null,g=mb,mb=null;var L=fh,X=vc;if(Ss=0,tA=fh=null,vc=0,(Fi&6)!==0)throw Error(n(331));var oe=Fi;if(Fi|=4,MC(L.current),SC(L,L.current,X,g),Fi=oe,Fp(0,!1),$t&&typeof $t.onPostCommitFiberRoot=="function")try{$t.onPostCommitFiberRoot(Yt,L)}catch{}return!0}finally{ae.p=D,K.T=b,jC(o,c)}}function WC(o,c,g){c=Ua(g,c),c=Yx(o.stateNode,c,2),o=Je(o,c,2),o!==null&&(pt(o,2),Kl(o))}function Ki(o,c,g){if(o.tag===3)WC(o,o,g);else for(;c!==null;){if(c.tag===3){WC(c,o,g);break}else if(c.tag===1){var b=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(hh===null||!hh.has(b))){o=Ua(g,o),g=$4(2),b=Je(c,g,2),b!==null&&(X4(g,b,c,o),pt(b,2),Kl(b));break}}c=c.return}}function yb(o,c,g){var b=o.pingCache;if(b===null){b=o.pingCache=new LI;var D=new Set;b.set(c,D)}else D=b.get(c),D===void 0&&(D=new Set,b.set(c,D));D.has(g)||(fb=!0,D.add(g),o=FI.bind(null,o,c,g),c.then(o,o))}function FI(o,c,g){var b=o.pingCache;b!==null&&b.delete(c),o.pingedLanes|=o.suspendedLanes&g,o.warmLanes&=~g,hr===o&&(Ti&g)===g&&($r===4||$r===3&&(Ti&62914560)===Ti&&300>Be()-Y1?(Fi&2)===0&&nA(o,0):db|=g,eA===Ti&&(eA=0)),Kl(o)}function $C(o,c){c===0&&(c=St()),o=Ju(o,c),o!==null&&(pt(o,c),Kl(o))}function kI(o){var c=o.memoizedState,g=0;c!==null&&(g=c.retryLane),$C(o,g)}function zI(o,c){var g=0;switch(o.tag){case 31:case 13:var b=o.stateNode,D=o.memoizedState;D!==null&&(g=D.retryLane);break;case 19:b=o.stateNode;break;case 22:b=o.stateNode._retryCache;break;default:throw Error(n(314))}b!==null&&b.delete(c),$C(o,g)}function GI(o,c){return ut(o,c)}var n2=null,rA=null,xb=!1,i2=!1,bb=!1,Ah=0;function Kl(o){o!==rA&&o.next===null&&(rA===null?n2=rA=o:rA=rA.next=o),i2=!0,xb||(xb=!0,VI())}function Fp(o,c){if(!bb&&i2){bb=!0;do for(var g=!1,b=n2;b!==null;){if(o!==0){var D=b.pendingLanes;if(D===0)var L=0;else{var X=b.suspendedLanes,oe=b.pingedLanes;L=(1<<31-Te(42|o)+1)-1,L&=D&~(X&~oe),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(g=!0,KC(b,L))}else L=Ti,L=Kt(b,b===hr?L:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(L&3)===0||un(b,L)||(g=!0,KC(b,L));b=b.next}while(g);bb=!1}}function qI(){XC()}function XC(){i2=xb=!1;var o=0;Ah!==0&&JI()&&(o=Ah);for(var c=Be(),g=null,b=n2;b!==null;){var D=b.next,L=YC(b,c);L===0?(b.next=null,g===null?n2=D:g.next=D,D===null&&(rA=g)):(g=b,(o!==0||(L&3)!==0)&&(i2=!0)),b=D}Ss!==0&&Ss!==5||Fp(o),Ah!==0&&(Ah=0)}function YC(o,c){for(var g=o.suspendedLanes,b=o.pingedLanes,D=o.expirationTimes,L=o.pendingLanes&-62914561;0oe)break;var _t=Me.transferSize,Ot=Me.initiatorType;_t&&s8(Ot)&&(Me=Me.responseEnd,X+=_t*(Me"u"?null:document;function g8(o,c,g){var b=sA;if(b&&typeof c=="string"&&c){var D=Er(c);D='link[rel="'+o+'"][href="'+D+'"]',typeof g=="string"&&(D+='[crossorigin="'+g+'"]'),m8.has(D)||(m8.add(D),o={rel:o,crossOrigin:g,href:c},b.querySelector(D)===null&&(c=b.createElement("link"),Vs(c,"link",o),ze(c),b.head.appendChild(c)))}}function lF(o){_c.D(o),g8("dns-prefetch",o,null)}function uF(o,c){_c.C(o,c),g8("preconnect",o,c)}function cF(o,c,g){_c.L(o,c,g);var b=sA;if(b&&o&&c){var D='link[rel="preload"][as="'+Er(c)+'"]';c==="image"&&g&&g.imageSrcSet?(D+='[imagesrcset="'+Er(g.imageSrcSet)+'"]',typeof g.imageSizes=="string"&&(D+='[imagesizes="'+Er(g.imageSizes)+'"]')):D+='[href="'+Er(o)+'"]';var L=D;switch(c){case"style":L=aA(o);break;case"script":L=oA(o)}Qo.has(L)||(o=v({rel:"preload",href:c==="image"&&g&&g.imageSrcSet?void 0:o,as:c},g),Qo.set(L,o),b.querySelector(D)!==null||c==="style"&&b.querySelector(qp(L))||c==="script"&&b.querySelector(Vp(L))||(c=b.createElement("link"),Vs(c,"link",o),ze(c),b.head.appendChild(c)))}}function hF(o,c){_c.m(o,c);var g=sA;if(g&&o){var b=c&&typeof c.as=="string"?c.as:"script",D='link[rel="modulepreload"][as="'+Er(b)+'"][href="'+Er(o)+'"]',L=D;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=oA(o)}if(!Qo.has(L)&&(o=v({rel:"modulepreload",href:o},c),Qo.set(L,o),g.querySelector(D)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(g.querySelector(Vp(L)))return}b=g.createElement("link"),Vs(b,"link",o),ze(b),g.head.appendChild(b)}}}function fF(o,c,g){_c.S(o,c,g);var b=sA;if(b&&o){var D=Ke(b).hoistableStyles,L=aA(o);c=c||"default";var X=D.get(L);if(!X){var oe={loading:0,preload:null};if(X=b.querySelector(qp(L)))oe.loading=5;else{o=v({rel:"stylesheet",href:o,"data-precedence":c},g),(g=Qo.get(L))&&Fb(o,g);var Me=X=b.createElement("link");ze(Me),Vs(Me,"link",o),Me._p=new Promise(function(rt,_t){Me.onload=rt,Me.onerror=_t}),Me.addEventListener("load",function(){oe.loading|=1}),Me.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,l2(X,c,b)}X={type:"stylesheet",instance:X,count:1,state:oe},D.set(L,X)}}}function dF(o,c){_c.X(o,c);var g=sA;if(g&&o){var b=Ke(g).hoistableScripts,D=oA(o),L=b.get(D);L||(L=g.querySelector(Vp(D)),L||(o=v({src:o,async:!0},c),(c=Qo.get(D))&&kb(o,c),L=g.createElement("script"),ze(L),Vs(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function AF(o,c){_c.M(o,c);var g=sA;if(g&&o){var b=Ke(g).hoistableScripts,D=oA(o),L=b.get(D);L||(L=g.querySelector(Vp(D)),L||(o=v({src:o,async:!0,type:"module"},c),(c=Qo.get(D))&&kb(o,c),L=g.createElement("script"),ze(L),Vs(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function v8(o,c,g,b){var D=(D=Qe.current)?o2(D):null;if(!D)throw Error(n(446));switch(o){case"meta":case"title":return null;case"style":return typeof g.precedence=="string"&&typeof g.href=="string"?(c=aA(g.href),g=Ke(D).hoistableStyles,b=g.get(c),b||(b={type:"style",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(g.rel==="stylesheet"&&typeof g.href=="string"&&typeof g.precedence=="string"){o=aA(g.href);var L=Ke(D).hoistableStyles,X=L.get(o);if(X||(D=D.ownerDocument||D,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(o,X),(L=D.querySelector(qp(o)))&&!L._p&&(X.instance=L,X.state.loading=5),Qo.has(o)||(g={rel:"preload",as:"style",href:g.href,crossOrigin:g.crossOrigin,integrity:g.integrity,media:g.media,hrefLang:g.hrefLang,referrerPolicy:g.referrerPolicy},Qo.set(o,g),L||pF(D,o,g,X.state))),c&&b===null)throw Error(n(528,""));return X}if(c&&b!==null)throw Error(n(529,""));return null;case"script":return c=g.async,g=g.src,typeof g=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=oA(g),g=Ke(D).hoistableScripts,b=g.get(c),b||(b={type:"script",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,o))}}function aA(o){return'href="'+Er(o)+'"'}function qp(o){return'link[rel="stylesheet"]['+o+"]"}function _8(o){return v({},o,{"data-precedence":o.precedence,precedence:null})}function pF(o,c,g,b){o.querySelector('link[rel="preload"][as="style"]['+c+"]")?b.loading=1:(c=o.createElement("link"),b.preload=c,c.addEventListener("load",function(){return b.loading|=1}),c.addEventListener("error",function(){return b.loading|=2}),Vs(c,"link",g),ze(c),o.head.appendChild(c))}function oA(o){return'[src="'+Er(o)+'"]'}function Vp(o){return"script[async]"+o}function y8(o,c,g){if(c.count++,c.instance===null)switch(c.type){case"style":var b=o.querySelector('style[data-href~="'+Er(g.href)+'"]');if(b)return c.instance=b,ze(b),b;var D=v({},g,{"data-href":g.href,"data-precedence":g.precedence,href:null,precedence:null});return b=(o.ownerDocument||o).createElement("style"),ze(b),Vs(b,"style",D),l2(b,g.precedence,o),c.instance=b;case"stylesheet":D=aA(g.href);var L=o.querySelector(qp(D));if(L)return c.state.loading|=4,c.instance=L,ze(L),L;b=_8(g),(D=Qo.get(D))&&Fb(b,D),L=(o.ownerDocument||o).createElement("link"),ze(L);var X=L;return X._p=new Promise(function(oe,Me){X.onload=oe,X.onerror=Me}),Vs(L,"link",b),c.state.loading|=4,l2(L,g.precedence,o),c.instance=L;case"script":return L=oA(g.src),(D=o.querySelector(Vp(L)))?(c.instance=D,ze(D),D):(b=g,(D=Qo.get(L))&&(b=v({},g),kb(b,D)),o=o.ownerDocument||o,D=o.createElement("script"),ze(D),Vs(D,"link",b),o.head.appendChild(D),c.instance=D);case"void":return null;default:throw Error(n(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(b=c.instance,c.state.loading|=4,l2(b,g.precedence,o));return c.instance}function l2(o,c,g){for(var b=g.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),D=b.length?b[b.length-1]:null,L=D,X=0;X title"):null)}function mF(o,c,g){if(g===1||c.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;switch(c.rel){case"stylesheet":return o=c.disabled,typeof c.precedence=="string"&&o==null;default:return!0}case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function S8(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function gF(o,c,g,b){if(g.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(g.state.loading&4)===0){if(g.instance===null){var D=aA(b.href),L=c.querySelector(qp(D));if(L){c=L._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(o.count++,o=c2.bind(o),c.then(o,o)),g.state.loading|=4,g.instance=L,ze(L);return}L=c.ownerDocument||c,b=_8(b),(D=Qo.get(D))&&Fb(b,D),L=L.createElement("link"),ze(L);var X=L;X._p=new Promise(function(oe,Me){X.onload=oe,X.onerror=Me}),Vs(L,"link",b),g.instance=L}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(g,c),(c=g.state.preload)&&(g.state.loading&3)===0&&(o.count++,g=c2.bind(o),c.addEventListener("load",g),c.addEventListener("error",g))}}var zb=0;function vF(o,c){return o.stylesheets&&o.count===0&&f2(o,o.stylesheets),0zb?50:800)+c);return o.unsuspend=g,function(){o.unsuspend=null,clearTimeout(b),clearTimeout(D)}}:null}function c2(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)f2(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var h2=null;function f2(o,c){o.stylesheets=null,o.unsuspend!==null&&(o.count++,h2=new Map,c.forEach(_F,o),h2=null,c2.call(o))}function _F(o,c){if(!(c.state.loading&4)){var g=h2.get(o);if(g)var b=g.get(null);else{g=new Map,h2.set(o,g);for(var D=o.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Xb.exports=BF(),Xb.exports}var IF=OF(),ie=xw();const FF=E7(ie);/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */const W0="172",il={ROTATE:0,DOLLY:1,PAN:2},jA={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},C7=0,HS=1,N7=2,kF=0,bw=1,zF=2,No=3,zl=0,gr=1,gs=2,no=0,io=1,u0=2,c0=3,h0=4,Sw=5,Bo=100,Tw=101,ww=102,R7=103,D7=104,Mw=200,Ew=201,Cw=202,Nw=203,jm=204,Hm=205,Rw=206,Dw=207,Pw=208,Lw=209,Uw=210,GF=211,qF=212,VF=213,jF=214,Wm=0,$m=1,Xm=2,Hh=3,Ym=4,Qm=5,Km=6,Zm=7,Bg=0,P7=1,L7=2,ro=0,U7=1,B7=2,O7=3,I7=4,HF=5,F7=6,k7=7,Bw=300,sl=301,al=302,Wh=303,$h=304,ld=306,ud=1e3,lu=1001,cd=1002,br=1003,s_=1004,uu=1005,Ms=1006,n0=1007,Ya=1008,WF=1008,Aa=1009,Jf=1010,ed=1011,Bl=1012,ks=1013,Ir=1014,ss=1015,Qs=1016,dy=1017,Ay=1018,xu=1020,py=35902,Ow=1021,Og=1022,Xs=1023,Iw=1024,Fw=1025,Au=1026,bu=1027,Ig=1028,$0=1029,hd=1030,X0=1031,$F=1032,Y0=1033,td=33776,Gh=33777,qh=33778,Vh=33779,Jm=35840,eg=35841,tg=35842,ng=35843,ig=36196,f0=37492,d0=37496,A0=37808,p0=37809,m0=37810,g0=37811,v0=37812,_0=37813,y0=37814,x0=37815,b0=37816,S0=37817,T0=37818,w0=37819,M0=37820,E0=37821,nd=36492,WS=36494,$S=36495,kw=36283,rg=36284,sg=36285,ag=36286,XF=0,YF=1,$8=2,QF=3200,KF=3201,kc=0,z7=1,Oo="",Nn="srgb",Io="srgb-linear",a_="linear",Hi="srgb",ZF=0,If=7680,JF=7681,ek=7682,tk=7683,nk=34055,ik=34056,rk=5386,sk=512,ak=513,ok=514,lk=515,uk=516,ck=517,hk=518,XS=519,zw=512,my=513,Gw=514,gy=515,qw=516,Vw=517,jw=518,Hw=519,o_=35044,HA=35048,X8="300 es",Qa=2e3,Su=2001;class Xc{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s>8&255]+oa[i>>16&255]+oa[i>>24&255]+"-"+oa[e&255]+oa[e>>8&255]+"-"+oa[e>>16&15|64]+oa[e>>24&255]+"-"+oa[t&63|128]+oa[t>>8&255]+"-"+oa[t>>16&255]+oa[t>>24&255]+oa[n&255]+oa[n>>8&255]+oa[n>>16&255]+oa[n>>24&255]).toLowerCase()}function ai(i,e,t){return Math.max(e,Math.min(t,i))}function Ww(i,e){return(i%e+e)%e}function fk(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function dk(i,e,t){return i!==e?(t-i)/(e-i):0}function Rm(i,e,t){return(1-t)*i+t*e}function Ak(i,e,t,n){return Rm(i,e,1-Math.exp(-t*n))}function pk(i,e=1){return e-Math.abs(Ww(i,e*2)-e)}function mk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function gk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function vk(i,e){return i+Math.floor(Math.random()*(e-i+1))}function _k(i,e){return i+Math.random()*(e-i)}function yk(i){return i*(.5-Math.random())}function xk(i){i!==void 0&&(Y8=i);let e=Y8+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function bk(i){return i*Nm}function Sk(i){return i*C0}function Tk(i){return(i&i-1)===0&&i!==0}function wk(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Mk(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ek(i,e,t,n,r){const s=Math.cos,a=Math.sin,l=s(t/2),u=a(t/2),h=s((e+n)/2),m=a((e+n)/2),v=s((e-n)/2),x=a((e-n)/2),S=s((n-e)/2),w=a((n-e)/2);switch(r){case"XYX":i.set(l*m,u*v,u*x,l*h);break;case"YZY":i.set(u*x,l*m,u*v,l*h);break;case"ZXZ":i.set(u*v,u*x,l*m,l*h);break;case"XZX":i.set(l*m,u*w,u*S,l*h);break;case"YXY":i.set(u*S,l*m,u*w,l*h);break;case"ZYZ":i.set(u*w,u*S,l*m,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Da(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function ci(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const N0={DEG2RAD:Nm,RAD2DEG:C0,generateUUID:pu,clamp:ai,euclideanModulo:Ww,mapLinear:fk,inverseLerp:dk,lerp:Rm,damp:Ak,pingpong:pk,smoothstep:mk,smootherstep:gk,randInt:vk,randFloat:_k,randFloatSpread:yk,seededRandom:xk,degToRad:bk,radToDeg:Sk,isPowerOfTwo:Tk,ceilPowerOfTwo:wk,floorPowerOfTwo:Mk,setQuaternionFromProperEuler:Ek,normalize:ci,denormalize:Da};class Et{constructor(e=0,t=0){Et.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ai(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ai(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qn{constructor(e,t,n,r,s,a,l,u,h){Qn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h)}set(e,t,n,r,s,a,l,u,h){const m=this.elements;return m[0]=e,m[1]=r,m[2]=l,m[3]=t,m[4]=s,m[5]=u,m[6]=n,m[7]=a,m[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[3],u=n[6],h=n[1],m=n[4],v=n[7],x=n[2],S=n[5],w=n[8],N=r[0],C=r[3],E=r[6],O=r[1],U=r[4],I=r[7],j=r[2],z=r[5],G=r[8];return s[0]=a*N+l*O+u*j,s[3]=a*C+l*U+u*z,s[6]=a*E+l*I+u*G,s[1]=h*N+m*O+v*j,s[4]=h*C+m*U+v*z,s[7]=h*E+m*I+v*G,s[2]=x*N+S*O+w*j,s[5]=x*C+S*U+w*z,s[8]=x*E+S*I+w*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8];return t*a*m-t*l*h-n*s*m+n*l*u+r*s*h-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=m*a-l*h,x=l*u-m*s,S=h*s-a*u,w=t*v+n*x+r*S;if(w===0)return this.set(0,0,0,0,0,0,0,0,0);const N=1/w;return e[0]=v*N,e[1]=(r*h-m*n)*N,e[2]=(l*n-r*a)*N,e[3]=x*N,e[4]=(m*t-r*u)*N,e[5]=(r*s-l*t)*N,e[6]=S*N,e[7]=(n*u-h*t)*N,e[8]=(a*t-n*s)*N,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,l){const u=Math.cos(s),h=Math.sin(s);return this.set(n*u,n*h,-n*(u*a+h*l)+a+e,-r*h,r*u,-r*(-h*a+u*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(Jb.makeScale(e,t)),this}rotate(e){return this.premultiply(Jb.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jb.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Jb=new Qn;function G7(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function og(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function q7(){const i=og("canvas");return i.style.display="block",i}const Q8={};function qf(i){i in Q8||(Q8[i]=!0,console.warn(i))}function Ck(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function Nk(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Rk(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const K8=new Qn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Z8=new Qn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Dk(){const i={enabled:!0,workingColorSpace:Io,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Hi&&(r.r=Uc(r.r),r.g=Uc(r.g),r.b=Uc(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Hi&&(r.r=i0(r.r),r.g=i0(r.g),r.b=i0(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Oo?a_:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Io]:{primaries:e,whitePoint:n,transfer:a_,toXYZ:K8,fromXYZ:Z8,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Nn},outputColorSpaceConfig:{drawingBufferColorSpace:Nn}},[Nn]:{primaries:e,whitePoint:n,transfer:Hi,toXYZ:K8,fromXYZ:Z8,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Nn}}}),i}const hi=Dk();function Uc(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function i0(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let uA;class Pk{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{uA===void 0&&(uA=og("canvas")),uA.width=e.width,uA.height=e.height;const n=uA.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=uA}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=og("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Bw)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ud:e.x=e.x-Math.floor(e.x);break;case lu:e.x=e.x<0?0:1;break;case cd:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ud:e.y=e.y-Math.floor(e.y);break;case lu:e.y=e.y<0?0:1;break;case cd:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Es.DEFAULT_IMAGE=null;Es.DEFAULT_MAPPING=Bw;Es.DEFAULT_ANISOTROPY=1;class qn{constructor(e=0,t=0,n=0,r=1){qn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const u=e.elements,h=u[0],m=u[4],v=u[8],x=u[1],S=u[5],w=u[9],N=u[2],C=u[6],E=u[10];if(Math.abs(m-x)<.01&&Math.abs(v-N)<.01&&Math.abs(w-C)<.01){if(Math.abs(m+x)<.1&&Math.abs(v+N)<.1&&Math.abs(w+C)<.1&&Math.abs(h+S+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const U=(h+1)/2,I=(S+1)/2,j=(E+1)/2,z=(m+x)/4,G=(v+N)/4,W=(w+C)/4;return U>I&&U>j?U<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(U),r=z/n,s=G/n):I>j?I<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(I),n=z/r,s=W/r):j<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(j),n=G/s,r=W/s),this.set(n,r,s,t),this}let O=Math.sqrt((C-w)*(C-w)+(v-N)*(v-N)+(x-m)*(x-m));return Math.abs(O)<.001&&(O=1),this.x=(C-w)/O,this.y=(v-N)/O,this.z=(x-m)/O,this.w=Math.acos((h+S+E-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this.z=ai(this.z,e.z,t.z),this.w=ai(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this.z=ai(this.z,e,t),this.w=ai(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ai(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Zh extends Xc{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new qn(0,0,e,t),this.scissorTest=!1,this.viewport=new qn(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ms,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new Es(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let l=0;l=0?1:-1,U=1-E*E;if(U>Number.EPSILON){const j=Math.sqrt(U),z=Math.atan2(j,E*O);C=Math.sin(C*z)/j,l=Math.sin(l*z)/j}const I=l*O;if(u=u*C+x*I,h=h*C+S*I,m=m*C+w*I,v=v*C+N*I,C===1-l){const j=1/Math.sqrt(u*u+h*h+m*m+v*v);u*=j,h*=j,m*=j,v*=j}}e[t]=u,e[t+1]=h,e[t+2]=m,e[t+3]=v}static multiplyQuaternionsFlat(e,t,n,r,s,a){const l=n[r],u=n[r+1],h=n[r+2],m=n[r+3],v=s[a],x=s[a+1],S=s[a+2],w=s[a+3];return e[t]=l*w+m*v+u*S-h*x,e[t+1]=u*w+m*x+h*v-l*S,e[t+2]=h*w+m*S+l*x-u*v,e[t+3]=m*w-l*v-u*x-h*S,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,l=Math.cos,u=Math.sin,h=l(n/2),m=l(r/2),v=l(s/2),x=u(n/2),S=u(r/2),w=u(s/2);switch(a){case"XYZ":this._x=x*m*v+h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v-x*S*w;break;case"YXZ":this._x=x*m*v+h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v+x*S*w;break;case"ZXY":this._x=x*m*v-h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v-x*S*w;break;case"ZYX":this._x=x*m*v-h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v+x*S*w;break;case"YZX":this._x=x*m*v+h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v-x*S*w;break;case"XZY":this._x=x*m*v-h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v+x*S*w;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],l=t[5],u=t[9],h=t[2],m=t[6],v=t[10],x=n+l+v;if(x>0){const S=.5/Math.sqrt(x+1);this._w=.25/S,this._x=(m-u)*S,this._y=(s-h)*S,this._z=(a-r)*S}else if(n>l&&n>v){const S=2*Math.sqrt(1+n-l-v);this._w=(m-u)/S,this._x=.25*S,this._y=(r+a)/S,this._z=(s+h)/S}else if(l>v){const S=2*Math.sqrt(1+l-n-v);this._w=(s-h)/S,this._x=(r+a)/S,this._y=.25*S,this._z=(u+m)/S}else{const S=2*Math.sqrt(1+v-n-l);this._w=(a-r)/S,this._x=(s+h)/S,this._y=(u+m)/S,this._z=.25*S}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ai(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,l=t._x,u=t._y,h=t._z,m=t._w;return this._x=n*m+a*l+r*h-s*u,this._y=r*m+a*u+s*l-n*h,this._z=s*m+a*h+n*u-r*l,this._w=a*m-n*l-r*u-s*h,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let l=a*e._w+n*e._x+r*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const u=1-l*l;if(u<=Number.EPSILON){const S=1-t;return this._w=S*a+t*this._w,this._x=S*n+t*this._x,this._y=S*r+t*this._y,this._z=S*s+t*this._z,this.normalize(),this}const h=Math.sqrt(u),m=Math.atan2(h,l),v=Math.sin((1-t)*m)/h,x=Math.sin(t*m)/h;return this._w=a*v+this._w*x,this._x=n*v+this._x*x,this._y=r*v+this._y*x,this._z=s*v+this._z*x,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class de{constructor(e=0,t=0,n=0){de.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(J8.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(J8.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,l=e.z,u=e.w,h=2*(a*r-l*n),m=2*(l*t-s*r),v=2*(s*n-a*t);return this.x=t+u*h+a*v-l*m,this.y=n+u*m+l*h-s*v,this.z=r+u*v+s*m-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this.z=ai(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this.z=ai(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ai(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,l=t.y,u=t.z;return this.x=r*u-s*l,this.y=s*a-n*u,this.z=n*l-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return t3.copy(this).projectOnVector(e),this.sub(t3)}reflect(e){return this.sub(t3.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ai(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const t3=new de,J8=new Tu;class Yc{constructor(e=new de(1/0,1/0,1/0),t=new de(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ml),Ml.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Qp),x2.subVectors(this.max,Qp),cA.subVectors(e.a,Qp),hA.subVectors(e.b,Qp),fA.subVectors(e.c,Qp),xh.subVectors(hA,cA),bh.subVectors(fA,hA),Sf.subVectors(cA,fA);let t=[0,-xh.z,xh.y,0,-bh.z,bh.y,0,-Sf.z,Sf.y,xh.z,0,-xh.x,bh.z,0,-bh.x,Sf.z,0,-Sf.x,-xh.y,xh.x,0,-bh.y,bh.x,0,-Sf.y,Sf.x,0];return!n3(t,cA,hA,fA,x2)||(t=[1,0,0,0,1,0,0,0,1],!n3(t,cA,hA,fA,x2))?!1:(b2.crossVectors(xh,bh),t=[b2.x,b2.y,b2.z],n3(t,cA,hA,fA,x2))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ml).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ml).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(yc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),yc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),yc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),yc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),yc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),yc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),yc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),yc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(yc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const yc=[new de,new de,new de,new de,new de,new de,new de,new de],Ml=new de,y2=new Yc,cA=new de,hA=new de,fA=new de,xh=new de,bh=new de,Sf=new de,Qp=new de,x2=new de,b2=new de,Tf=new de;function n3(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Tf.fromArray(i,s);const l=r.x*Math.abs(Tf.x)+r.y*Math.abs(Tf.y)+r.z*Math.abs(Tf.z),u=e.dot(Tf),h=t.dot(Tf),m=n.dot(Tf);if(Math.max(-Math.max(u,h,m),Math.min(u,h,m))>l)return!1}return!0}const Ok=new Yc,Kp=new de,i3=new de;class gd{constructor(e=new de,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ok.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Kp.subVectors(e,this.center);const t=Kp.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Kp,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(i3.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Kp.copy(e.center).add(i3)),this.expandByPoint(Kp.copy(e.center).sub(i3))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const xc=new de,r3=new de,S2=new de,Sh=new de,s3=new de,T2=new de,a3=new de;class Fg{constructor(e=new de,t=new de(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,xc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=xc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(xc.copy(this.origin).addScaledVector(this.direction,t),xc.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){r3.copy(e).add(t).multiplyScalar(.5),S2.copy(t).sub(e).normalize(),Sh.copy(this.origin).sub(r3);const s=e.distanceTo(t)*.5,a=-this.direction.dot(S2),l=Sh.dot(this.direction),u=-Sh.dot(S2),h=Sh.lengthSq(),m=Math.abs(1-a*a);let v,x,S,w;if(m>0)if(v=a*u-l,x=a*l-u,w=s*m,v>=0)if(x>=-w)if(x<=w){const N=1/m;v*=N,x*=N,S=v*(v+a*x+2*l)+x*(a*v+x+2*u)+h}else x=s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x=-s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x<=-w?(v=Math.max(0,-(-a*s+l)),x=v>0?-s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h):x<=w?(v=0,x=Math.min(Math.max(-s,-u),s),S=x*(x+2*u)+h):(v=Math.max(0,-(a*s+l)),x=v>0?s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h);else x=a>0?-s:s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,v),r&&r.copy(r3).addScaledVector(S2,x),S}intersectSphere(e,t){xc.subVectors(e.center,this.origin);const n=xc.dot(this.direction),r=xc.dot(xc)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),l=n-a,u=n+a;return u<0?null:l<0?this.at(u,t):this.at(l,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,l,u;const h=1/this.direction.x,m=1/this.direction.y,v=1/this.direction.z,x=this.origin;return h>=0?(n=(e.min.x-x.x)*h,r=(e.max.x-x.x)*h):(n=(e.max.x-x.x)*h,r=(e.min.x-x.x)*h),m>=0?(s=(e.min.y-x.y)*m,a=(e.max.y-x.y)*m):(s=(e.max.y-x.y)*m,a=(e.min.y-x.y)*m),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a=0?(l=(e.min.z-x.z)*v,u=(e.max.z-x.z)*v):(l=(e.max.z-x.z)*v,u=(e.min.z-x.z)*v),n>u||l>r)||((l>n||n!==n)&&(n=l),(u=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,xc)!==null}intersectTriangle(e,t,n,r,s){s3.subVectors(t,e),T2.subVectors(n,e),a3.crossVectors(s3,T2);let a=this.direction.dot(a3),l;if(a>0){if(r)return null;l=1}else if(a<0)l=-1,a=-a;else return null;Sh.subVectors(this.origin,e);const u=l*this.direction.dot(T2.crossVectors(Sh,T2));if(u<0)return null;const h=l*this.direction.dot(s3.cross(Sh));if(h<0||u+h>a)return null;const m=-l*Sh.dot(a3);return m<0?null:this.at(m/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Xn{constructor(e,t,n,r,s,a,l,u,h,m,v,x,S,w,N,C){Xn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h,m,v,x,S,w,N,C)}set(e,t,n,r,s,a,l,u,h,m,v,x,S,w,N,C){const E=this.elements;return E[0]=e,E[4]=t,E[8]=n,E[12]=r,E[1]=s,E[5]=a,E[9]=l,E[13]=u,E[2]=h,E[6]=m,E[10]=v,E[14]=x,E[3]=S,E[7]=w,E[11]=N,E[15]=C,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Xn().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/dA.setFromMatrixColumn(e,0).length(),s=1/dA.setFromMatrixColumn(e,1).length(),a=1/dA.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),l=Math.sin(n),u=Math.cos(r),h=Math.sin(r),m=Math.cos(s),v=Math.sin(s);if(e.order==="XYZ"){const x=a*m,S=a*v,w=l*m,N=l*v;t[0]=u*m,t[4]=-u*v,t[8]=h,t[1]=S+w*h,t[5]=x-N*h,t[9]=-l*u,t[2]=N-x*h,t[6]=w+S*h,t[10]=a*u}else if(e.order==="YXZ"){const x=u*m,S=u*v,w=h*m,N=h*v;t[0]=x+N*l,t[4]=w*l-S,t[8]=a*h,t[1]=a*v,t[5]=a*m,t[9]=-l,t[2]=S*l-w,t[6]=N+x*l,t[10]=a*u}else if(e.order==="ZXY"){const x=u*m,S=u*v,w=h*m,N=h*v;t[0]=x-N*l,t[4]=-a*v,t[8]=w+S*l,t[1]=S+w*l,t[5]=a*m,t[9]=N-x*l,t[2]=-a*h,t[6]=l,t[10]=a*u}else if(e.order==="ZYX"){const x=a*m,S=a*v,w=l*m,N=l*v;t[0]=u*m,t[4]=w*h-S,t[8]=x*h+N,t[1]=u*v,t[5]=N*h+x,t[9]=S*h-w,t[2]=-h,t[6]=l*u,t[10]=a*u}else if(e.order==="YZX"){const x=a*u,S=a*h,w=l*u,N=l*h;t[0]=u*m,t[4]=N-x*v,t[8]=w*v+S,t[1]=v,t[5]=a*m,t[9]=-l*m,t[2]=-h*m,t[6]=S*v+w,t[10]=x-N*v}else if(e.order==="XZY"){const x=a*u,S=a*h,w=l*u,N=l*h;t[0]=u*m,t[4]=-v,t[8]=h*m,t[1]=x*v+N,t[5]=a*m,t[9]=S*v-w,t[2]=w*v-S,t[6]=l*m,t[10]=N*v+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ik,e,Fk)}lookAt(e,t,n){const r=this.elements;return So.subVectors(e,t),So.lengthSq()===0&&(So.z=1),So.normalize(),Th.crossVectors(n,So),Th.lengthSq()===0&&(Math.abs(n.z)===1?So.x+=1e-4:So.z+=1e-4,So.normalize(),Th.crossVectors(n,So)),Th.normalize(),w2.crossVectors(So,Th),r[0]=Th.x,r[4]=w2.x,r[8]=So.x,r[1]=Th.y,r[5]=w2.y,r[9]=So.y,r[2]=Th.z,r[6]=w2.z,r[10]=So.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[4],u=n[8],h=n[12],m=n[1],v=n[5],x=n[9],S=n[13],w=n[2],N=n[6],C=n[10],E=n[14],O=n[3],U=n[7],I=n[11],j=n[15],z=r[0],G=r[4],W=r[8],q=r[12],V=r[1],Y=r[5],te=r[9],ne=r[13],le=r[2],Q=r[6],K=r[10],ae=r[14],Ae=r[3],be=r[7],Se=r[11],se=r[15];return s[0]=a*z+l*V+u*le+h*Ae,s[4]=a*G+l*Y+u*Q+h*be,s[8]=a*W+l*te+u*K+h*Se,s[12]=a*q+l*ne+u*ae+h*se,s[1]=m*z+v*V+x*le+S*Ae,s[5]=m*G+v*Y+x*Q+S*be,s[9]=m*W+v*te+x*K+S*Se,s[13]=m*q+v*ne+x*ae+S*se,s[2]=w*z+N*V+C*le+E*Ae,s[6]=w*G+N*Y+C*Q+E*be,s[10]=w*W+N*te+C*K+E*Se,s[14]=w*q+N*ne+C*ae+E*se,s[3]=O*z+U*V+I*le+j*Ae,s[7]=O*G+U*Y+I*Q+j*be,s[11]=O*W+U*te+I*K+j*Se,s[15]=O*q+U*ne+I*ae+j*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],l=e[5],u=e[9],h=e[13],m=e[2],v=e[6],x=e[10],S=e[14],w=e[3],N=e[7],C=e[11],E=e[15];return w*(+s*u*v-r*h*v-s*l*x+n*h*x+r*l*S-n*u*S)+N*(+t*u*S-t*h*x+s*a*x-r*a*S+r*h*m-s*u*m)+C*(+t*h*v-t*l*S-s*a*v+n*a*S+s*l*m-n*h*m)+E*(-r*l*m-t*u*v+t*l*x+r*a*v-n*a*x+n*u*m)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=e[9],x=e[10],S=e[11],w=e[12],N=e[13],C=e[14],E=e[15],O=v*C*h-N*x*h+N*u*S-l*C*S-v*u*E+l*x*E,U=w*x*h-m*C*h-w*u*S+a*C*S+m*u*E-a*x*E,I=m*N*h-w*v*h+w*l*S-a*N*S-m*l*E+a*v*E,j=w*v*u-m*N*u-w*l*x+a*N*x+m*l*C-a*v*C,z=t*O+n*U+r*I+s*j;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const G=1/z;return e[0]=O*G,e[1]=(N*x*s-v*C*s-N*r*S+n*C*S+v*r*E-n*x*E)*G,e[2]=(l*C*s-N*u*s+N*r*h-n*C*h-l*r*E+n*u*E)*G,e[3]=(v*u*s-l*x*s-v*r*h+n*x*h+l*r*S-n*u*S)*G,e[4]=U*G,e[5]=(m*C*s-w*x*s+w*r*S-t*C*S-m*r*E+t*x*E)*G,e[6]=(w*u*s-a*C*s-w*r*h+t*C*h+a*r*E-t*u*E)*G,e[7]=(a*x*s-m*u*s+m*r*h-t*x*h-a*r*S+t*u*S)*G,e[8]=I*G,e[9]=(w*v*s-m*N*s-w*n*S+t*N*S+m*n*E-t*v*E)*G,e[10]=(a*N*s-w*l*s+w*n*h-t*N*h-a*n*E+t*l*E)*G,e[11]=(m*l*s-a*v*s-m*n*h+t*v*h+a*n*S-t*l*S)*G,e[12]=j*G,e[13]=(m*N*r-w*v*r+w*n*x-t*N*x-m*n*C+t*v*C)*G,e[14]=(w*l*r-a*N*r-w*n*u+t*N*u+a*n*C-t*l*C)*G,e[15]=(a*v*r-m*l*r+m*n*u-t*v*u-a*n*x+t*l*x)*G,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,l=e.y,u=e.z,h=s*a,m=s*l;return this.set(h*a+n,h*l-r*u,h*u+r*l,0,h*l+r*u,m*l+n,m*u-r*a,0,h*u-r*l,m*u+r*a,s*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,l=t._z,u=t._w,h=s+s,m=a+a,v=l+l,x=s*h,S=s*m,w=s*v,N=a*m,C=a*v,E=l*v,O=u*h,U=u*m,I=u*v,j=n.x,z=n.y,G=n.z;return r[0]=(1-(N+E))*j,r[1]=(S+I)*j,r[2]=(w-U)*j,r[3]=0,r[4]=(S-I)*z,r[5]=(1-(x+E))*z,r[6]=(C+O)*z,r[7]=0,r[8]=(w+U)*G,r[9]=(C-O)*G,r[10]=(1-(x+N))*G,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=dA.set(r[0],r[1],r[2]).length();const a=dA.set(r[4],r[5],r[6]).length(),l=dA.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],El.copy(this);const h=1/s,m=1/a,v=1/l;return El.elements[0]*=h,El.elements[1]*=h,El.elements[2]*=h,El.elements[4]*=m,El.elements[5]*=m,El.elements[6]*=m,El.elements[8]*=v,El.elements[9]*=v,El.elements[10]*=v,t.setFromRotationMatrix(El),n.x=s,n.y=a,n.z=l,this}makePerspective(e,t,n,r,s,a,l=Qa){const u=this.elements,h=2*s/(t-e),m=2*s/(n-r),v=(t+e)/(t-e),x=(n+r)/(n-r);let S,w;if(l===Qa)S=-(a+s)/(a-s),w=-2*a*s/(a-s);else if(l===Su)S=-a/(a-s),w=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=h,u[4]=0,u[8]=v,u[12]=0,u[1]=0,u[5]=m,u[9]=x,u[13]=0,u[2]=0,u[6]=0,u[10]=S,u[14]=w,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,s,a,l=Qa){const u=this.elements,h=1/(t-e),m=1/(n-r),v=1/(a-s),x=(t+e)*h,S=(n+r)*m;let w,N;if(l===Qa)w=(a+s)*v,N=-2*v;else if(l===Su)w=s*v,N=-1*v;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=2*h,u[4]=0,u[8]=0,u[12]=-x,u[1]=0,u[5]=2*m,u[9]=0,u[13]=-S,u[2]=0,u[6]=0,u[10]=N,u[14]=-w,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const dA=new de,El=new Xn,Ik=new de(0,0,0),Fk=new de(1,1,1),Th=new de,w2=new de,So=new de,eN=new Xn,tN=new Tu;class ma{constructor(e=0,t=0,n=0,r=ma.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],l=r[8],u=r[1],h=r[5],m=r[9],v=r[2],x=r[6],S=r[10];switch(t){case"XYZ":this._y=Math.asin(ai(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-m,S),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(x,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ai(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(l,S),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-v,s),this._z=0);break;case"ZXY":this._x=Math.asin(ai(x,-1,1)),Math.abs(x)<.9999999?(this._y=Math.atan2(-v,S),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-ai(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(x,S),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(ai(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-m,h),this._y=Math.atan2(-v,s)):(this._x=0,this._y=Math.atan2(l,S));break;case"XZY":this._z=Math.asin(-ai(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(x,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-m,S),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return eN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(eN,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return tN.setFromEuler(this),this.setFromQuaternion(tN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ma.DEFAULT_ORDER="XYZ";class Xw{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(l,u){return l[u.uuid]===void 0&&(l[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const u=l.shapes;if(Array.isArray(u))for(let h=0,m=u.length;h0){r.children=[];for(let l=0;l0){r.animations=[];for(let l=0;l0&&(n.geometries=l),u.length>0&&(n.materials=u),h.length>0&&(n.textures=h),m.length>0&&(n.images=m),v.length>0&&(n.shapes=v),x.length>0&&(n.skeletons=x),S.length>0&&(n.animations=S),w.length>0&&(n.nodes=w)}return n.object=r,n;function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Cl.subVectors(r,t),Sc.subVectors(n,t),l3.subVectors(e,t);const a=Cl.dot(Cl),l=Cl.dot(Sc),u=Cl.dot(l3),h=Sc.dot(Sc),m=Sc.dot(l3),v=a*h-l*l;if(v===0)return s.set(0,0,0),null;const x=1/v,S=(h*u-l*m)*x,w=(a*m-l*u)*x;return s.set(1-S-w,w,S)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Tc)===null?!1:Tc.x>=0&&Tc.y>=0&&Tc.x+Tc.y<=1}static getInterpolation(e,t,n,r,s,a,l,u){return this.getBarycoord(e,t,n,r,Tc)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(s,Tc.x),u.addScaledVector(a,Tc.y),u.addScaledVector(l,Tc.z),u)}static getInterpolatedAttribute(e,t,n,r,s,a){return f3.setScalar(0),d3.setScalar(0),A3.setScalar(0),f3.fromBufferAttribute(e,t),d3.fromBufferAttribute(e,n),A3.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(f3,s.x),a.addScaledVector(d3,s.y),a.addScaledVector(A3,s.z),a}static isFrontFacing(e,t,n,r){return Cl.subVectors(n,t),Sc.subVectors(e,t),Cl.cross(Sc).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Cl.subVectors(this.c,this.b),Sc.subVectors(this.a,this.b),Cl.cross(Sc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ll.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ll.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Ll.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Ll.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ll.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,l;mA.subVectors(r,n),gA.subVectors(s,n),u3.subVectors(e,n);const u=mA.dot(u3),h=gA.dot(u3);if(u<=0&&h<=0)return t.copy(n);c3.subVectors(e,r);const m=mA.dot(c3),v=gA.dot(c3);if(m>=0&&v<=m)return t.copy(r);const x=u*v-m*h;if(x<=0&&u>=0&&m<=0)return a=u/(u-m),t.copy(n).addScaledVector(mA,a);h3.subVectors(e,s);const S=mA.dot(h3),w=gA.dot(h3);if(w>=0&&S<=w)return t.copy(s);const N=S*h-u*w;if(N<=0&&h>=0&&w<=0)return l=h/(h-w),t.copy(n).addScaledVector(gA,l);const C=m*w-S*v;if(C<=0&&v-m>=0&&S-w>=0)return oN.subVectors(s,r),l=(v-m)/(v-m+(S-w)),t.copy(r).addScaledVector(oN,l);const E=1/(C+N+x);return a=N*E,l=x*E,t.copy(n).addScaledVector(mA,a).addScaledVector(gA,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const j7={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},wh={h:0,s:0,l:0},E2={h:0,s:0,l:0};function p3(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let mn=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Nn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,hi.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=hi.workingColorSpace){return this.r=e,this.g=t,this.b=n,hi.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=hi.workingColorSpace){if(e=Ww(e,1),t=ai(t,0,1),n=ai(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=p3(a,s,e+1/3),this.g=p3(a,s,e),this.b=p3(a,s,e-1/3)}return hi.toWorkingColorSpace(this,r),this}setStyle(e,t=Nn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],l=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Nn){const n=j7[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Uc(e.r),this.g=Uc(e.g),this.b=Uc(e.b),this}copyLinearToSRGB(e){return this.r=i0(e.r),this.g=i0(e.g),this.b=i0(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nn){return hi.fromWorkingColorSpace(la.copy(this),e),Math.round(ai(la.r*255,0,255))*65536+Math.round(ai(la.g*255,0,255))*256+Math.round(ai(la.b*255,0,255))}getHexString(e=Nn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=hi.workingColorSpace){hi.fromWorkingColorSpace(la.copy(this),t);const n=la.r,r=la.g,s=la.b,a=Math.max(n,r,s),l=Math.min(n,r,s);let u,h;const m=(l+a)/2;if(l===a)u=0,h=0;else{const v=a-l;switch(h=m<=.5?v/(a+l):v/(2-a-l),a){case n:u=(r-s)/v+(r0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==io&&(n.blending=this.blending),this.side!==zl&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==jm&&(n.blendSrc=this.blendSrc),this.blendDst!==Hm&&(n.blendDst=this.blendDst),this.blendEquation!==Bo&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Hh&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==XS&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==If&&(n.stencilFail=this.stencilFail),this.stencilZFail!==If&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==If&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const l in s){const u=s[l];delete u.metadata,a.push(u)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class vd extends ga{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new mn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ma,this.combine=Bg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Rc=jk();function jk(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const h=u-127;h<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):h<-14?(n[u]=1024>>-h-14,n[u|256]=1024>>-h-14|32768,r[u]=-h-1,r[u|256]=-h-1):h<=15?(n[u]=h+15<<10,n[u|256]=h+15<<10|32768,r[u]=13,r[u|256]=13):h<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),l=new Uint32Array(64);for(let u=1;u<1024;++u){let h=u<<13,m=0;for(;(h&8388608)===0;)h<<=1,m-=8388608;h&=-8388609,m+=947912704,s[u]=h|m}for(let u=1024;u<2048;++u)s[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(l[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:l}}function To(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=ai(i,-65504,65504),Rc.floatView[0]=i;const e=Rc.uint32View[0],t=e>>23&511;return Rc.baseTable[t]+((e&8388607)>>Rc.shiftTable[t])}function C2(i){const e=i>>10;return Rc.uint32View[0]=Rc.mantissaTable[Rc.offsetTable[e]+(i&1023)]+Rc.exponentTable[e],Rc.floatView[0]}const As=new de,N2=new Et;class Lr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=o_,this.updateRanges=[],this.gpuType=ss,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;rt.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yc);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new de(-1/0,-1/0,-1/0),new de(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const h in u)u[h]!==void 0&&(e[h]=u[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const h=n[u];e.data.attributes[u]=h.toJSON(e.data)}const r={};let s=!1;for(const u in this.morphAttributes){const h=this.morphAttributes[u],m=[];for(let v=0,x=h.length;v0&&(r[u]=m,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const h in r){const m=r[h];this.setAttribute(h,m.clone(t))}const s=e.morphAttributes;for(const h in s){const m=[],v=s[h];for(let x=0,S=v.length;x0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s(e.far-e.near)**2))&&(lN.copy(s).invert(),wf.copy(e.ray).applyMatrix4(lN),!(n.boundingBox!==null&&wf.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,wf)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,l=s.index,u=s.attributes.position,h=s.attributes.uv,m=s.attributes.uv1,v=s.attributes.normal,x=s.groups,S=s.drawRange;if(l!==null)if(Array.isArray(a))for(let w=0,N=x.length;wt.far?null:{distance:h,point:B2.clone(),object:i}}function O2(i,e,t,n,r,s,a,l,u,h){i.getVertexPosition(l,D2),i.getVertexPosition(u,P2),i.getVertexPosition(h,L2);const m=Wk(i,e,t,n,D2,P2,L2,cN);if(m){const v=new de;Ll.getBarycoord(cN,D2,P2,L2,v),r&&(m.uv=Ll.getInterpolatedAttribute(r,l,u,h,v,new Et)),s&&(m.uv1=Ll.getInterpolatedAttribute(s,l,u,h,v,new Et)),a&&(m.normal=Ll.getInterpolatedAttribute(a,l,u,h,v,new de),m.normal.dot(n.direction)>0&&m.normal.multiplyScalar(-1));const x={a:l,b:u,c:h,normal:new de,materialIndex:0};Ll.getNormal(D2,P2,L2,x.normal),m.face=x,m.barycoord=v}return m}class Jh extends Ji{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const u=[],h=[],m=[],v=[];let x=0,S=0;w("z","y","x",-1,-1,n,t,e,a,s,0),w("z","y","x",1,-1,n,t,-e,a,s,1),w("x","z","y",1,1,e,n,t,r,a,2),w("x","z","y",1,-1,e,n,-t,r,a,3),w("x","y","z",1,-1,e,t,n,r,s,4),w("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(u),this.setAttribute("position",new Ci(h,3)),this.setAttribute("normal",new Ci(m,3)),this.setAttribute("uv",new Ci(v,2));function w(N,C,E,O,U,I,j,z,G,W,q){const V=I/G,Y=j/W,te=I/2,ne=j/2,le=z/2,Q=G+1,K=W+1;let ae=0,Ae=0;const be=new de;for(let Se=0;Se0?1:-1,m.push(be.x,be.y,be.z),v.push(Ee/G),v.push(1-Se/W),ae+=1}}for(let Se=0;Se0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class _y extends Tr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xn,this.projectionMatrix=new Xn,this.projectionMatrixInverse=new Xn,this.coordinateSystem=Qa}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Mh=new de,hN=new Et,fN=new Et;class Ea extends _y{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=C0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Nm*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return C0*2*Math.atan(Math.tan(Nm*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Mh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Mh.x,Mh.y).multiplyScalar(-e/Mh.z),Mh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Mh.x,Mh.y).multiplyScalar(-e/Mh.z)}getViewSize(e,t){return this.getViewBounds(e,hN,fN),t.subVectors(fN,hN)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Nm*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,h=a.fullHeight;s+=a.offsetX*r/u,t-=a.offsetY*n/h,r*=a.width/u,n*=a.height/h}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const _A=-90,yA=1;class $7 extends Tr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ea(_A,yA,e,t);r.layers=this.layers,this.add(r);const s=new Ea(_A,yA,e,t);s.layers=this.layers,this.add(s);const a=new Ea(_A,yA,e,t);a.layers=this.layers,this.add(a);const l=new Ea(_A,yA,e,t);l.layers=this.layers,this.add(l);const u=new Ea(_A,yA,e,t);u.layers=this.layers,this.add(u);const h=new Ea(_A,yA,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,l,u]=t;for(const h of t)this.remove(h);if(e===Qa)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===Su)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,l,u,h,m]=this.children,v=e.getRenderTarget(),x=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),w=e.xr.enabled;e.xr.enabled=!1;const N=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,l),e.setRenderTarget(n,3,r),e.render(t,u),e.setRenderTarget(n,4,r),e.render(t,h),n.texture.generateMipmaps=N,e.setRenderTarget(n,5,r),e.render(t,m),e.setRenderTarget(v,x,S),e.xr.enabled=w,n.texture.needsPMREMUpdate=!0}}class yy extends Es{constructor(e,t,n,r,s,a,l,u,h,m){e=e!==void 0?e:[],t=t!==void 0?t:sl,super(e,t,n,r,s,a,l,u,h,m),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class X7 extends Xh{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new yy(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Ms}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new Jh(5,5,5),s=new so({name:"CubemapFromEquirect",uniforms:R0(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:gr,blending:no});s.uniforms.tEquirect.value=t;const a=new qi(r,s),l=t.minFilter;return t.minFilter===Ya&&(t.minFilter=Ms),new $7(1,10,this).update(e,a),t.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Kw extends Tr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ma,this.environmentIntensity=1,this.environmentRotation=new ma,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Zw{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=o_,this.updateRanges=[],this.version=0,this.uuid=pu()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Jk.getNormalMatrix(e),r=this.coplanarPoint(v3).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Mf=new gd,I2=new de;class zg{constructor(e=new iu,t=new iu,n=new iu,r=new iu,s=new iu,a=new iu){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(s),l[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Qa){const n=this.planes,r=e.elements,s=r[0],a=r[1],l=r[2],u=r[3],h=r[4],m=r[5],v=r[6],x=r[7],S=r[8],w=r[9],N=r[10],C=r[11],E=r[12],O=r[13],U=r[14],I=r[15];if(n[0].setComponents(u-s,x-h,C-S,I-E).normalize(),n[1].setComponents(u+s,x+h,C+S,I+E).normalize(),n[2].setComponents(u+a,x+m,C+w,I+O).normalize(),n[3].setComponents(u-a,x-m,C-w,I-O).normalize(),n[4].setComponents(u-l,x-v,C-N,I-U).normalize(),t===Qa)n[5].setComponents(u+l,x+v,C+N,I+U).normalize();else if(t===Su)n[5].setComponents(l,v,N,U).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Mf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Mf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Mf)}intersectsSprite(e){return Mf.center.set(0,0,0),Mf.radius=.7071067811865476,Mf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mf)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,I2.y=r.normal.y>0?e.max.y:e.min.y,I2.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(I2)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Q0 extends ga{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new mn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const l_=new de,u_=new de,dN=new Xn,em=new Fg,F2=new gd,_3=new de,AN=new de;class xy extends Tr{constructor(e=new Ji,t=new Q0){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sn)return;_3.applyMatrix4(i.matrixWorld);const u=e.ray.origin.distanceTo(_3);if(!(ue.far))return{distance:u,point:AN.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const pN=new de,mN=new de;class Y7 extends xy{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}let Ka=class extends Tr{constructor(){super(),this.isGroup=!0,this.type="Group"}};class Q7 extends Es{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=br,this.minFilter=br,this.generateMipmaps=!1,this.needsUpdate=!0}}class Qc extends Es{constructor(e,t,n,r,s,a,l,u,h,m=Au){if(m!==Au&&m!==bu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&m===Au&&(n=Ir),n===void 0&&m===bu&&(n=xu),super(null,r,s,a,l,u,m,n,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:br,this.minFilter=u!==void 0?u:br,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class ql{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let l=0,u=s-1,h;for(;l<=u;)if(r=Math.floor(l+(u-l)/2),h=n[r]-a,h<0)l=r+1;else if(h>0)u=r-1;else{u=r;break}if(r=u,n[r]===a)return r/(s-1);const m=n[r],x=n[r+1]-m,S=(a-m)/x;return(r+S)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),l=this.getPoint(s),u=t||(a.isVector2?new Et:new de);return u.copy(l).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new de,r=[],s=[],a=[],l=new de,u=new Xn;for(let S=0;S<=e;S++){const w=S/e;r[S]=this.getTangentAt(w,new de)}s[0]=new de,a[0]=new de;let h=Number.MAX_VALUE;const m=Math.abs(r[0].x),v=Math.abs(r[0].y),x=Math.abs(r[0].z);m<=h&&(h=m,n.set(1,0,0)),v<=h&&(h=v,n.set(0,1,0)),x<=h&&n.set(0,0,1),l.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],l),a[0].crossVectors(r[0],s[0]);for(let S=1;S<=e;S++){if(s[S]=s[S-1].clone(),a[S]=a[S-1].clone(),l.crossVectors(r[S-1],r[S]),l.length()>Number.EPSILON){l.normalize();const w=Math.acos(ai(r[S-1].dot(r[S]),-1,1));s[S].applyMatrix4(u.makeRotationAxis(l,w))}a[S].crossVectors(r[S],s[S])}if(t===!0){let S=Math.acos(ai(s[0].dot(s[e]),-1,1));S/=e,r[0].dot(l.crossVectors(s[0],s[e]))>0&&(S=-S);for(let w=1;w<=e;w++)s[w].applyMatrix4(u.makeRotationAxis(r[w],S*w)),a[w].crossVectors(r[w],s[w])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class eM extends ql{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,l=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=l,this.aRotation=u}getPoint(e,t=new Et){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(l)/s)+1)*s:u===0&&l===s-1&&(l=s-2,u=1);let h,m;this.closed||l>0?h=r[(l-1)%s]:(q2.subVectors(r[0],r[1]).add(r[0]),h=q2);const v=r[l%s],x=r[(l+1)%s];if(this.closed||l+2r.length-2?r.length-1:a+1],v=r[a>r.length-3?r.length-1:a+2];return n.set(_N(l,u.x,h.x,m.x,v.x),_N(l,u.y,h.y,m.y,v.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[s]-n,l=this.curves[s],u=l.getLength(),h=u===0?0:1-a/u;return l.getPointAt(h,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const v=h.getPoint(0);v.equals(this.currentPoint)||this.lineTo(v.x,v.y)}this.curves.push(h);const m=h.getPoint(1);return this.currentPoint.copy(m),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class by extends Ji{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],l=[],u=[],h=new de,m=new Et;a.push(0,0,0),l.push(0,0,1),u.push(.5,.5);for(let v=0,x=3;v<=t;v++,x+=3){const S=n+v/t*r;h.x=e*Math.cos(S),h.y=e*Math.sin(S),a.push(h.x,h.y,h.z),l.push(0,0,1),m.x=(a[x]/e+1)/2,m.y=(a[x+1]/e+1)/2,u.push(m.x,m.y)}for(let v=1;v<=t;v++)s.push(v,v+1,0);this.setIndex(s),this.setAttribute("position",new Ci(a,3)),this.setAttribute("normal",new Ci(l,3)),this.setAttribute("uv",new Ci(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new by(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class nM extends Ji{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:l,thetaLength:u};const h=this;r=Math.floor(r),s=Math.floor(s);const m=[],v=[],x=[],S=[];let w=0;const N=[],C=n/2;let E=0;O(),a===!1&&(e>0&&U(!0),t>0&&U(!1)),this.setIndex(m),this.setAttribute("position",new Ci(v,3)),this.setAttribute("normal",new Ci(x,3)),this.setAttribute("uv",new Ci(S,2));function O(){const I=new de,j=new de;let z=0;const G=(t-e)/n;for(let W=0;W<=s;W++){const q=[],V=W/s,Y=V*(t-e)+e;for(let te=0;te<=r;te++){const ne=te/r,le=ne*u+l,Q=Math.sin(le),K=Math.cos(le);j.x=Y*Q,j.y=-V*n+C,j.z=Y*K,v.push(j.x,j.y,j.z),I.set(Q,G,K).normalize(),x.push(I.x,I.y,I.z),S.push(ne,1-V),q.push(w++)}N.push(q)}for(let W=0;W0||q!==0)&&(m.push(V,Y,ne),z+=3),(t>0||q!==s-1)&&(m.push(Y,te,ne),z+=3)}h.addGroup(E,z,0),E+=z}function U(I){const j=w,z=new Et,G=new de;let W=0;const q=I===!0?e:t,V=I===!0?1:-1;for(let te=1;te<=r;te++)v.push(0,C*V,0),x.push(0,V,0),S.push(.5,.5),w++;const Y=w;for(let te=0;te<=r;te++){const le=te/r*u+l,Q=Math.cos(le),K=Math.sin(le);G.x=q*K,G.y=C*V,G.z=q*Q,v.push(G.x,G.y,G.z),x.push(0,V,0),z.x=Q*.5+.5,z.y=K*.5*V+.5,S.push(z.x,z.y),w++}for(let te=0;te80*t){l=h=i[0],u=m=i[1];for(let w=t;wh&&(h=v),x>m&&(m=x);S=Math.max(h-l,m-u),S=S!==0?32767/S:0}return lg(s,a,t,l,u,S,0),a}};function iD(i,e,t,n,r){let s,a;if(r===Cz(i,e,t,n)>0)for(s=e;s=e;s-=n)a=yN(s,i[s],i[s+1],a);return a&&Sy(a,a.next)&&(cg(a),a=a.next),a}function fd(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Sy(t,t.next)||Fr(t.prev,t,t.next)===0)){if(cg(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function lg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&bz(i,n,r,s);let l=i,u,h;for(;i.prev!==i.next;){if(u=i.prev,h=i.next,s?Az(i,n,r,s):dz(i)){e.push(u.i/t|0),e.push(i.i/t|0),e.push(h.i/t|0),cg(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=pz(fd(i),e,t),lg(i,e,t,n,r,s,2)):a===2&&mz(i,e,t,n,r,s):lg(fd(i),e,t,n,r,s,1);break}}}function dz(i){const e=i.prev,t=i,n=i.next;if(Fr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=rs?r>a?r:a:s>a?s:a,S=l>u?l>h?l:h:u>h?u:h;let w=n.next;for(;w!==e;){if(w.x>=m&&w.x<=x&&w.y>=v&&w.y<=S&&WA(r,l,s,u,a,h,w.x,w.y)&&Fr(w.prev,w,w.next)>=0)return!1;w=w.next}return!0}function Az(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Fr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=lu?l>h?l:h:u>h?u:h,C=m>v?m>x?m:x:v>x?v:x,E=KS(S,w,e,t,n),O=KS(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=w&&U.y<=C&&U!==r&&U!==a&&WA(l,m,u,v,h,x,U.x,U.y)&&Fr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=w&&I.y<=C&&I!==r&&I!==a&&WA(l,m,u,v,h,x,I.x,I.y)&&Fr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=w&&U.y<=C&&U!==r&&U!==a&&WA(l,m,u,v,h,x,U.x,U.y)&&Fr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=w&&I.y<=C&&I!==r&&I!==a&&WA(l,m,u,v,h,x,I.x,I.y)&&Fr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function pz(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!Sy(r,s)&&rD(r,n,n.next,s)&&ug(r,s)&&ug(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),cg(n),cg(n.next),n=i=s),n=n.next}while(n!==i);return fd(n)}function mz(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&wz(a,l)){let u=sD(a,l);a=fd(a,a.next),u=fd(u,u.next),lg(a,e,t,n,r,s,0),lg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function gz(i,e,t,n){const r=[];let s,a,l,u,h;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const x=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=s&&x>n&&(n=x,r=t.x=t.x&&t.x>=u&&s!==t.x&&WA(ar.x||t.x===r.x&&xz(r,t)))&&(r=t,m=v)),t=t.next;while(t!==l);return r}function xz(i,e){return Fr(i.prev,i,e.prev)<0&&Fr(e.next,i,i.next)<0}function bz(i,e,t,n){let r=i;do r.z===0&&(r.z=KS(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Sz(r)}function Sz(i){let e,t,n,r,s,a,l,u,h=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,l=0,e=0;e0||u>0&&n;)l!==0&&(u===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,l--):(r=n,n=n.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,h*=2}while(a>1);return i}function KS(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function Tz(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function wz(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Mz(i,e)&&(ug(i,e)&&ug(e,i)&&Ez(i,e)&&(Fr(i.prev,i,e.prev)||Fr(i,e.prev,e))||Sy(i,e)&&Fr(i.prev,i,i.next)>0&&Fr(e.prev,e,e.next)>0)}function Fr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Sy(i,e){return i.x===e.x&&i.y===e.y}function rD(i,e,t,n){const r=j2(Fr(i,e,t)),s=j2(Fr(i,e,n)),a=j2(Fr(t,n,i)),l=j2(Fr(t,n,e));return!!(r!==s&&a!==l||r===0&&V2(i,t,e)||s===0&&V2(i,n,e)||a===0&&V2(t,i,n)||l===0&&V2(t,e,n))}function V2(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function j2(i){return i>0?1:i<0?-1:0}function Mz(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&rD(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ug(i,e){return Fr(i.prev,i,i.next)<0?Fr(i,e,i.next)>=0&&Fr(i,i.prev,e)>=0:Fr(i,e,i.prev)<0||Fr(i,i.next,e)<0}function Ez(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function sD(i,e){const t=new ZS(i.i,i.x,i.y),n=new ZS(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function yN(i,e,t,n){const r=new ZS(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function cg(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ZS(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Cz(i,e,t,n){let r=0;for(let s=e,a=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function bN(i,e){for(let t=0;tNumber.EPSILON){const Be=Math.sqrt(k),Oe=Math.sqrt(ut*ut+fe*fe),je=dt.x-hn/Be,Bt=dt.y+Lt/Be,yt=he.x-fe/Oe,Xt=he.y+ut/Oe,ln=((yt-je)*fe-(Xt-Bt)*ut)/(Lt*fe-hn*ut);en=je+Lt*ln-Ge.x,wt=Bt+hn*ln-Ge.y;const mt=en*en+wt*wt;if(mt<=2)return new Et(en,wt);qt=Math.sqrt(mt/2)}else{let Be=!1;Lt>Number.EPSILON?ut>Number.EPSILON&&(Be=!0):Lt<-Number.EPSILON?ut<-Number.EPSILON&&(Be=!0):Math.sign(hn)===Math.sign(fe)&&(Be=!0),Be?(en=-hn,wt=Lt,qt=Math.sqrt(k)):(en=Lt,wt=hn,qt=Math.sqrt(k/2))}return new Et(en/qt,wt/qt)}const be=[];for(let Ge=0,dt=le.length,he=dt-1,en=Ge+1;Ge=0;Ge--){const dt=Ge/C,he=S*Math.cos(dt*Math.PI/2),en=w*Math.sin(dt*Math.PI/2)+N;for(let wt=0,qt=le.length;wt=0;){const en=he;let wt=he-1;wt<0&&(wt=Ge.length-1);for(let qt=0,Lt=m+C*2;qt0)&&S.push(U,I,z),(E!==n-1||u0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class oD extends ga{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new mn(16777215),this.specular=new mn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ma,this.combine=Bg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Uz extends ga{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new mn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Bz extends ga{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Kc extends ga{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new mn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ma,this.combine=Bg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Oz extends ga{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=QF,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Iz extends ga{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Fz extends ga{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new mn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class kz extends Q0{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const TN={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class zz{constructor(e,t,n){const r=this;let s=!1,a=0,l=0,u;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(m){l++,s===!1&&r.onStart!==void 0&&r.onStart(m,a,l),s=!0},this.itemEnd=function(m){a++,r.onProgress!==void 0&&r.onProgress(m,a,l),a===l&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(m){r.onError!==void 0&&r.onError(m)},this.resolveURL=function(m){return u?u(m):m},this.setURLModifier=function(m){return u=m,this},this.addHandler=function(m,v){return h.push(m,v),this},this.removeHandler=function(m){const v=h.indexOf(m);return v!==-1&&h.splice(v,2),this},this.getHandler=function(m){for(let v=0,x=h.length;vNumber.EPSILON){if(V<0&&(G=O[z],q=-q,W=O[j],V=-V),E.yW.y)continue;if(E.y===G.y){if(E.x===G.x)return!0}else{const Y=V*(E.x-G.x)-q*(E.y-G.y);if(Y===0)return!0;if(Y<0)continue;I=!I}}else{if(E.y!==G.y)continue;if(W.x<=E.x&&E.x<=G.x||G.x<=E.x&&E.x<=W.x)return!0}}return I}const r=r0.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,l,u;const h=[];if(s.length===1)return l=s[0],u=new Gv,u.curves=l.curves,h.push(u),h;let m=!r(s[0].getPoints());m=e?!m:m;const v=[],x=[];let S=[],w=0,N;x[w]=void 0,S[w]=[];for(let E=0,O=s.length;E1){let E=!1,O=0;for(let U=0,I=x.length;U0&&E===!1&&(S=v)}let C;for(let E=0,O=x.length;ES.start-w.start);let x=0;for(let S=1;S 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,yG=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,xG=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,bG=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,SG=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,TG=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,wG=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec3 vColor; +#endif`,MG=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif +#ifdef USE_BATCHING_COLOR + vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); + vColor.xyz *= batchingColor.xyz; +#endif`,EG=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,CG=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,NG=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,RG=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,DG=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,PG=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,LG=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,UG="gl_FragColor = linearToOutputTexel( gl_FragColor );",BG=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,OG=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,IG=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,FG=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,kG=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,zG=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,GG=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,qG=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,VG=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,jG=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,HG=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,WG=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,$G=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,XG=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,YG=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,QG=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,KG=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,ZG=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,JG=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,eq=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,tq=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,nq=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,iq=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,rq=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,sq=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,aq=`#if defined( USE_LOGDEPTHBUF ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,oq=`#if defined( USE_LOGDEPTHBUF ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,lq=`#ifdef USE_LOGDEPTHBUF + varying float vFragDepth; + varying float vIsPerspective; +#endif`,uq=`#ifdef USE_LOGDEPTHBUF + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,cq=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,hq=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,fq=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,dq=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,Aq=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,pq=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,mq=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,gq=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,vq=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,_q=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,yq=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,xq=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,bq=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,Sq=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,Tq=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,wq=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,Mq=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,Eq=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,Cq=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,Nq=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,Rq=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,Dq=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Pq=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,Lq=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,Uq=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,Bq=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Oq=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,Iq=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,Fq=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,kq=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + + float lightToPositionLength = length( lightToPosition ); + if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { + float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + shadow = ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } +#endif`,zq=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,Gq=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,qq=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,Vq=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,jq=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,Hq=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,Wq=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,$q=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,Xq=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Yq=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Qq=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,Kq=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Zq=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Jq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,eV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,tV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,nV=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const iV=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,rV=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,sV=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,aV=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,oV=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,lV=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,uV=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,cV=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,hV=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,fV=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,dV=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,AV=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,pV=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,mV=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,gV=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,vV=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,_V=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,yV=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,xV=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,bV=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,SV=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,TV=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,wV=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,MV=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,EV=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,CV=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,NV=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,RV=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,DV=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,PV=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,LV=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,UV=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,BV=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,OV=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,ni={alphahash_fragment:rG,alphahash_pars_fragment:sG,alphamap_fragment:aG,alphamap_pars_fragment:oG,alphatest_fragment:lG,alphatest_pars_fragment:uG,aomap_fragment:cG,aomap_pars_fragment:hG,batching_pars_vertex:fG,batching_vertex:dG,begin_vertex:AG,beginnormal_vertex:pG,bsdfs:mG,iridescence_fragment:gG,bumpmap_pars_fragment:vG,clipping_planes_fragment:_G,clipping_planes_pars_fragment:yG,clipping_planes_pars_vertex:xG,clipping_planes_vertex:bG,color_fragment:SG,color_pars_fragment:TG,color_pars_vertex:wG,color_vertex:MG,common:EG,cube_uv_reflection_fragment:CG,defaultnormal_vertex:NG,displacementmap_pars_vertex:RG,displacementmap_vertex:DG,emissivemap_fragment:PG,emissivemap_pars_fragment:LG,colorspace_fragment:UG,colorspace_pars_fragment:BG,envmap_fragment:OG,envmap_common_pars_fragment:IG,envmap_pars_fragment:FG,envmap_pars_vertex:kG,envmap_physical_pars_fragment:QG,envmap_vertex:zG,fog_vertex:GG,fog_pars_vertex:qG,fog_fragment:VG,fog_pars_fragment:jG,gradientmap_pars_fragment:HG,lightmap_pars_fragment:WG,lights_lambert_fragment:$G,lights_lambert_pars_fragment:XG,lights_pars_begin:YG,lights_toon_fragment:KG,lights_toon_pars_fragment:ZG,lights_phong_fragment:JG,lights_phong_pars_fragment:eq,lights_physical_fragment:tq,lights_physical_pars_fragment:nq,lights_fragment_begin:iq,lights_fragment_maps:rq,lights_fragment_end:sq,logdepthbuf_fragment:aq,logdepthbuf_pars_fragment:oq,logdepthbuf_pars_vertex:lq,logdepthbuf_vertex:uq,map_fragment:cq,map_pars_fragment:hq,map_particle_fragment:fq,map_particle_pars_fragment:dq,metalnessmap_fragment:Aq,metalnessmap_pars_fragment:pq,morphinstance_vertex:mq,morphcolor_vertex:gq,morphnormal_vertex:vq,morphtarget_pars_vertex:_q,morphtarget_vertex:yq,normal_fragment_begin:xq,normal_fragment_maps:bq,normal_pars_fragment:Sq,normal_pars_vertex:Tq,normal_vertex:wq,normalmap_pars_fragment:Mq,clearcoat_normal_fragment_begin:Eq,clearcoat_normal_fragment_maps:Cq,clearcoat_pars_fragment:Nq,iridescence_pars_fragment:Rq,opaque_fragment:Dq,packing:Pq,premultiplied_alpha_fragment:Lq,project_vertex:Uq,dithering_fragment:Bq,dithering_pars_fragment:Oq,roughnessmap_fragment:Iq,roughnessmap_pars_fragment:Fq,shadowmap_pars_fragment:kq,shadowmap_pars_vertex:zq,shadowmap_vertex:Gq,shadowmask_pars_fragment:qq,skinbase_vertex:Vq,skinning_pars_vertex:jq,skinning_vertex:Hq,skinnormal_vertex:Wq,specularmap_fragment:$q,specularmap_pars_fragment:Xq,tonemapping_fragment:Yq,tonemapping_pars_fragment:Qq,transmission_fragment:Kq,transmission_pars_fragment:Zq,uv_pars_fragment:Jq,uv_pars_vertex:eV,uv_vertex:tV,worldpos_vertex:nV,background_vert:iV,background_frag:rV,backgroundCube_vert:sV,backgroundCube_frag:aV,cube_vert:oV,cube_frag:lV,depth_vert:uV,depth_frag:cV,distanceRGBA_vert:hV,distanceRGBA_frag:fV,equirect_vert:dV,equirect_frag:AV,linedashed_vert:pV,linedashed_frag:mV,meshbasic_vert:gV,meshbasic_frag:vV,meshlambert_vert:_V,meshlambert_frag:yV,meshmatcap_vert:xV,meshmatcap_frag:bV,meshnormal_vert:SV,meshnormal_frag:TV,meshphong_vert:wV,meshphong_frag:MV,meshphysical_vert:EV,meshphysical_frag:CV,meshtoon_vert:NV,meshtoon_frag:RV,points_vert:DV,points_frag:PV,shadow_vert:LV,shadow_frag:UV,sprite_vert:BV,sprite_frag:OV},sn={common:{diffuse:{value:new mn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Qn},alphaMap:{value:null},alphaMapTransform:{value:new Qn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Qn}},envmap:{envMap:{value:null},envMapRotation:{value:new Qn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Qn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Qn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Qn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Qn},normalScale:{value:new Et(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Qn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Qn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Qn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Qn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new mn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new mn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Qn},alphaTest:{value:0},uvTransform:{value:new Qn}},sprite:{diffuse:{value:new mn(16777215)},opacity:{value:1},center:{value:new Et(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Qn},alphaMap:{value:null},alphaMapTransform:{value:new Qn},alphaTest:{value:0}}},$a={basic:{uniforms:Ma([sn.common,sn.specularmap,sn.envmap,sn.aomap,sn.lightmap,sn.fog]),vertexShader:ni.meshbasic_vert,fragmentShader:ni.meshbasic_frag},lambert:{uniforms:Ma([sn.common,sn.specularmap,sn.envmap,sn.aomap,sn.lightmap,sn.emissivemap,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.fog,sn.lights,{emissive:{value:new mn(0)}}]),vertexShader:ni.meshlambert_vert,fragmentShader:ni.meshlambert_frag},phong:{uniforms:Ma([sn.common,sn.specularmap,sn.envmap,sn.aomap,sn.lightmap,sn.emissivemap,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.fog,sn.lights,{emissive:{value:new mn(0)},specular:{value:new mn(1118481)},shininess:{value:30}}]),vertexShader:ni.meshphong_vert,fragmentShader:ni.meshphong_frag},standard:{uniforms:Ma([sn.common,sn.envmap,sn.aomap,sn.lightmap,sn.emissivemap,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.roughnessmap,sn.metalnessmap,sn.fog,sn.lights,{emissive:{value:new mn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ni.meshphysical_vert,fragmentShader:ni.meshphysical_frag},toon:{uniforms:Ma([sn.common,sn.aomap,sn.lightmap,sn.emissivemap,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.gradientmap,sn.fog,sn.lights,{emissive:{value:new mn(0)}}]),vertexShader:ni.meshtoon_vert,fragmentShader:ni.meshtoon_frag},matcap:{uniforms:Ma([sn.common,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.fog,{matcap:{value:null}}]),vertexShader:ni.meshmatcap_vert,fragmentShader:ni.meshmatcap_frag},points:{uniforms:Ma([sn.points,sn.fog]),vertexShader:ni.points_vert,fragmentShader:ni.points_frag},dashed:{uniforms:Ma([sn.common,sn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ni.linedashed_vert,fragmentShader:ni.linedashed_frag},depth:{uniforms:Ma([sn.common,sn.displacementmap]),vertexShader:ni.depth_vert,fragmentShader:ni.depth_frag},normal:{uniforms:Ma([sn.common,sn.bumpmap,sn.normalmap,sn.displacementmap,{opacity:{value:1}}]),vertexShader:ni.meshnormal_vert,fragmentShader:ni.meshnormal_frag},sprite:{uniforms:Ma([sn.sprite,sn.fog]),vertexShader:ni.sprite_vert,fragmentShader:ni.sprite_frag},background:{uniforms:{uvTransform:{value:new Qn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ni.background_vert,fragmentShader:ni.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Qn}},vertexShader:ni.backgroundCube_vert,fragmentShader:ni.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ni.cube_vert,fragmentShader:ni.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ni.equirect_vert,fragmentShader:ni.equirect_frag},distanceRGBA:{uniforms:Ma([sn.common,sn.displacementmap,{referencePosition:{value:new de},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ni.distanceRGBA_vert,fragmentShader:ni.distanceRGBA_frag},shadow:{uniforms:Ma([sn.lights,sn.fog,{color:{value:new mn(0)},opacity:{value:1}}]),vertexShader:ni.shadow_vert,fragmentShader:ni.shadow_frag}};$a.physical={uniforms:Ma([$a.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Qn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Qn},clearcoatNormalScale:{value:new Et(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Qn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Qn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Qn},sheen:{value:0},sheenColor:{value:new mn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Qn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Qn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Qn},transmissionSamplerSize:{value:new Et},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Qn},attenuationDistance:{value:0},attenuationColor:{value:new mn(0)},specularColor:{value:new mn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Qn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Qn},anisotropyVector:{value:new Et},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Qn}}]),vertexShader:ni.meshphysical_vert,fragmentShader:ni.meshphysical_frag};const W2={r:0,b:0,g:0},Ef=new ma,IV=new Xn;function FV(i,e,t,n,r,s,a){const l=new mn(0);let u=s===!0?0:1,h,m,v=null,x=0,S=null;function w(U){let I=U.isScene===!0?U.background:null;return I&&I.isTexture&&(I=(U.backgroundBlurriness>0?t:e).get(I)),I}function N(U){let I=!1;const j=w(U);j===null?E(l,u):j&&j.isColor&&(E(j,1),I=!0);const z=i.xr.getEnvironmentBlendMode();z==="additive"?n.buffers.color.setClear(0,0,0,1,a):z==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function C(U,I){const j=w(I);j&&(j.isCubeTexture||j.mapping===ld)?(m===void 0&&(m=new qi(new Jh(1,1,1),new so({name:"BackgroundCubeMaterial",uniforms:R0($a.backgroundCube.uniforms),vertexShader:$a.backgroundCube.vertexShader,fragmentShader:$a.backgroundCube.fragmentShader,side:gr,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(z,G,W){this.matrixWorld.copyPosition(W.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(m)),Ef.copy(I.backgroundRotation),Ef.x*=-1,Ef.y*=-1,Ef.z*=-1,j.isCubeTexture&&j.isRenderTargetTexture===!1&&(Ef.y*=-1,Ef.z*=-1),m.material.uniforms.envMap.value=j,m.material.uniforms.flipEnvMap.value=j.isCubeTexture&&j.isRenderTargetTexture===!1?-1:1,m.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,m.material.uniforms.backgroundRotation.value.setFromMatrix4(IV.makeRotationFromEuler(Ef)),m.material.toneMapped=hi.getTransfer(j.colorSpace)!==Hi,(v!==j||x!==j.version||S!==i.toneMapping)&&(m.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),m.layers.enableAll(),U.unshift(m,m.geometry,m.material,0,0,null)):j&&j.isTexture&&(h===void 0&&(h=new qi(new Ty(2,2),new so({name:"BackgroundMaterial",uniforms:R0($a.background.uniforms),vertexShader:$a.background.vertexShader,fragmentShader:$a.background.fragmentShader,side:zl,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=j,h.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,h.material.toneMapped=hi.getTransfer(j.colorSpace)!==Hi,j.matrixAutoUpdate===!0&&j.updateMatrix(),h.material.uniforms.uvTransform.value.copy(j.matrix),(v!==j||x!==j.version||S!==i.toneMapping)&&(h.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),h.layers.enableAll(),U.unshift(h,h.geometry,h.material,0,0,null))}function E(U,I){U.getRGB(W2,W7(i)),n.buffers.color.setClear(W2.r,W2.g,W2.b,I,a)}function O(){m!==void 0&&(m.geometry.dispose(),m.material.dispose()),h!==void 0&&(h.geometry.dispose(),h.material.dispose())}return{getClearColor:function(){return l},setClearColor:function(U,I=1){l.set(U),u=I,E(l,u)},getClearAlpha:function(){return u},setClearAlpha:function(U){u=U,E(l,u)},render:N,addToRenderList:C,dispose:O}}function kV(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=x(null);let s=r,a=!1;function l(V,Y,te,ne,le){let Q=!1;const K=v(ne,te,Y);s!==K&&(s=K,h(s.object)),Q=S(V,ne,te,le),Q&&w(V,ne,te,le),le!==null&&e.update(le,i.ELEMENT_ARRAY_BUFFER),(Q||a)&&(a=!1,I(V,Y,te,ne),le!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(le).buffer))}function u(){return i.createVertexArray()}function h(V){return i.bindVertexArray(V)}function m(V){return i.deleteVertexArray(V)}function v(V,Y,te){const ne=te.wireframe===!0;let le=n[V.id];le===void 0&&(le={},n[V.id]=le);let Q=le[Y.id];Q===void 0&&(Q={},le[Y.id]=Q);let K=Q[ne];return K===void 0&&(K=x(u()),Q[ne]=K),K}function x(V){const Y=[],te=[],ne=[];for(let le=0;le=0){const Se=le[Ae];let se=Q[Ae];if(se===void 0&&(Ae==="instanceMatrix"&&V.instanceMatrix&&(se=V.instanceMatrix),Ae==="instanceColor"&&V.instanceColor&&(se=V.instanceColor)),Se===void 0||Se.attribute!==se||se&&Se.data!==se.data)return!0;K++}return s.attributesNum!==K||s.index!==ne}function w(V,Y,te,ne){const le={},Q=Y.attributes;let K=0;const ae=te.getAttributes();for(const Ae in ae)if(ae[Ae].location>=0){let Se=Q[Ae];Se===void 0&&(Ae==="instanceMatrix"&&V.instanceMatrix&&(Se=V.instanceMatrix),Ae==="instanceColor"&&V.instanceColor&&(Se=V.instanceColor));const se={};se.attribute=Se,Se&&Se.data&&(se.data=Se.data),le[Ae]=se,K++}s.attributes=le,s.attributesNum=K,s.index=ne}function N(){const V=s.newAttributes;for(let Y=0,te=V.length;Y=0){let be=le[ae];if(be===void 0&&(ae==="instanceMatrix"&&V.instanceMatrix&&(be=V.instanceMatrix),ae==="instanceColor"&&V.instanceColor&&(be=V.instanceColor)),be!==void 0){const Se=be.normalized,se=be.itemSize,Ee=e.get(be);if(Ee===void 0)continue;const qe=Ee.buffer,Ce=Ee.type,ke=Ee.bytesPerElement,Qe=Ce===i.INT||Ce===i.UNSIGNED_INT||be.gpuType===ks;if(be.isInterleavedBufferAttribute){const et=be.data,Pt=et.stride,Nt=be.offset;if(et.isInstancedInterleavedBuffer){for(let Gt=0;Gt0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";G="mediump"}return G==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const m=u(h);m!==h&&(console.warn("THREE.WebGLRenderer:",h,"not supported, using",m,"instead."),h=m);const v=t.logarithmicDepthBuffer===!0,x=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),S=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),w=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),N=i.getParameter(i.MAX_TEXTURE_SIZE),C=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),E=i.getParameter(i.MAX_VERTEX_ATTRIBS),O=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),U=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),j=w>0,z=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:l,precision:h,logarithmicDepthBuffer:v,reverseDepthBuffer:x,maxTextures:S,maxVertexTextures:w,maxTextureSize:N,maxCubemapSize:C,maxAttributes:E,maxVertexUniforms:O,maxVaryings:U,maxFragmentUniforms:I,vertexTextures:j,maxSamples:z}}function qV(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new iu,l=new Qn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(v,x){const S=v.length!==0||x||n!==0||r;return r=x,n=v.length,S},this.beginShadows=function(){s=!0,m(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(v,x){t=m(v,x,0)},this.setState=function(v,x,S){const w=v.clippingPlanes,N=v.clipIntersection,C=v.clipShadows,E=i.get(v);if(!r||w===null||w.length===0||s&&!C)s?m(null):h();else{const O=s?0:n,U=O*4;let I=E.clippingState||null;u.value=I,I=m(w,x,U,S);for(let j=0;j!==U;++j)I[j]=t[j];E.clippingState=I,this.numIntersection=N?this.numPlanes:0,this.numPlanes+=O}};function h(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function m(v,x,S,w){const N=v!==null?v.length:0;let C=null;if(N!==0){if(C=u.value,w!==!0||C===null){const E=S+N*4,O=x.matrixWorldInverse;l.getNormalMatrix(O),(C===null||C.length0){const h=new X7(u.height);return h.fromEquirectangularTexture(i,a),e.set(a,h),a.addEventListener("dispose",r),t(h.texture,a.mapping)}else return null}}return a}function r(a){const l=a.target;l.removeEventListener("dispose",r);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const $A=4,UN=[.125,.215,.35,.446,.526,.582],Vf=20,w3=new Gg,BN=new mn;let M3=null,E3=0,C3=0,N3=!1;const Ff=(1+Math.sqrt(5))/2,xA=1/Ff,ON=[new de(-Ff,xA,0),new de(Ff,xA,0),new de(-xA,0,Ff),new de(xA,0,Ff),new de(0,Ff,-xA),new de(0,Ff,xA),new de(-1,1,-1),new de(1,1,-1),new de(-1,1,1),new de(1,1,1)];let IN=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){M3=this._renderer.getRenderTarget(),E3=this._renderer.getActiveCubeFace(),C3=this._renderer.getActiveMipmapLevel(),N3=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zN(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=kN(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?U:0,U,U),m.setRenderTarget(r),N&&m.render(w,l),m.render(e,l)}w.geometry.dispose(),w.material.dispose(),m.toneMapping=x,m.autoClear=v,e.background=C}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===sl||e.mapping===al;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=zN()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=kN());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new qi(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const u=this._cubeSize;$2(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,w3)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sVf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Vf}`);const E=[];let O=0;for(let G=0;GU-$A?r-U+$A:0),z=4*(this._cubeSize-I);$2(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,w3)}};function jV(i){const e=[],t=[],n=[];let r=i;const s=i-$A+1+UN.length;for(let a=0;ai-$A?u=UN[a-i+$A-1]:a===0&&(u=0),n.push(u);const h=1/(l-2),m=-h,v=1+h,x=[m,m,v,m,v,v,m,m,v,v,m,v],S=6,w=6,N=3,C=2,E=1,O=new Float32Array(N*w*S),U=new Float32Array(C*w*S),I=new Float32Array(E*w*S);for(let z=0;z2?0:-1,q=[G,W,0,G+2/3,W,0,G+2/3,W+1,0,G,W,0,G+2/3,W+1,0,G,W+1,0];O.set(q,N*w*z),U.set(x,C*w*z);const V=[z,z,z,z,z,z];I.set(V,E*w*z)}const j=new Ji;j.setAttribute("position",new Lr(O,N)),j.setAttribute("uv",new Lr(U,C)),j.setAttribute("faceIndex",new Lr(I,E)),e.push(j),r>$A&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function FN(i,e,t){const n=new Xh(i,e,t);return n.texture.mapping=ld,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function $2(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function HV(i,e,t){const n=new Float32Array(Vf),r=new de(0,1,0);return new so({name:"SphericalGaussianBlur",defines:{n:Vf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:uM(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:no,depthTest:!1,depthWrite:!1})}function kN(){return new so({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uM(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:no,depthTest:!1,depthWrite:!1})}function zN(){return new so({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uM(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:no,depthTest:!1,depthWrite:!1})}function uM(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function WV(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const u=l.mapping,h=u===Wh||u===$h,m=u===sl||u===al;if(h||m){let v=e.get(l);const x=v!==void 0?v.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==x)return t===null&&(t=new IN(i)),v=h?t.fromEquirectangular(l,v):t.fromCubemap(l,v),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),v.texture;if(v!==void 0)return v.texture;{const S=l.image;return h&&S&&S.height>0||m&&S&&r(S)?(t===null&&(t=new IN(i)),v=h?t.fromEquirectangular(l):t.fromCubemap(l),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),l.addEventListener("dispose",s),v.texture):null}}}return l}function r(l){let u=0;const h=6;for(let m=0;me.maxTextureSize&&(z=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const G=new Float32Array(j*z*4*v),W=new $w(G,j,z,v);W.type=ss,W.needsUpdate=!0;const q=I*4;for(let Y=0;Y0)return i;const r=e*t;let s=qN[r];if(s===void 0&&(s=new Float32Array(r),qN[r]=s),e!==0){n.toArray(s,0);for(let a=1,l=0;a!==e;++a)l+=t,i[a].toArray(s,l)}return s}function Cs(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t":" "} ${l}: ${t[a]}`)}return n.join(` +`)}const YN=new Qn;function Wj(i){hi._getMatrix(YN,hi.workingColorSpace,i);const e=`mat3( ${YN.elements.map(t=>t.toFixed(4))} )`;switch(hi.getTransfer(i)){case a_:return[e,"LinearTransferOETF"];case Hi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function QN(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+` + +`+r+` + +`+Hj(i.getShaderSource(e),a)}else return r}function $j(i,e){const t=Wj(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}function Xj(i,e){let t;switch(e){case U7:t="Linear";break;case B7:t="Reinhard";break;case O7:t="Cineon";break;case I7:t="ACESFilmic";break;case F7:t="AgX";break;case k7:t="Neutral";break;case HF:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const X2=new de;function Yj(){hi.getLuminanceCoefficients(X2);const i=X2.x.toFixed(4),e=X2.y.toFixed(4),t=X2.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Qj(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(xm).join(` +`)}function Kj(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` +`)}function Zj(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function eT(i){return i.replace(Jj,tH)}const eH=new Map;function tH(i,e){let t=ni[e];if(t===void 0){const n=eH.get(e);if(n!==void 0)t=ni[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return eT(t)}const nH=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function JN(i){return i.replace(nH,iH)}function iH(i,e,t,n){let r="";for(let s=parseInt(e);s0&&(C+=` +`),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w].filter(xm).join(` +`),E.length>0&&(E+=` +`)):(C=[e5(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+m:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(xm).join(` +`),E=[e5(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+m:"",t.envMap?"#define "+v:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ro?"#define TONE_MAPPING":"",t.toneMapping!==ro?ni.tonemapping_pars_fragment:"",t.toneMapping!==ro?Xj("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ni.colorspace_pars_fragment,$j("linearToOutputTexel",t.outputColorSpace),Yj(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(xm).join(` +`)),a=eT(a),a=KN(a,t),a=ZN(a,t),l=eT(l),l=KN(l,t),l=ZN(l,t),a=JN(a),l=JN(l),t.isRawShaderMaterial!==!0&&(O=`#version 300 es +`,C=[S,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+C,E=["#define varying in",t.glslVersion===X8?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===X8?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+E);const U=O+C+a,I=O+E+l,j=XN(r,r.VERTEX_SHADER,U),z=XN(r,r.FRAGMENT_SHADER,I);r.attachShader(N,j),r.attachShader(N,z),t.index0AttributeName!==void 0?r.bindAttribLocation(N,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(N,0,"position"),r.linkProgram(N);function G(Y){if(i.debug.checkShaderErrors){const te=r.getProgramInfoLog(N).trim(),ne=r.getShaderInfoLog(j).trim(),le=r.getShaderInfoLog(z).trim();let Q=!0,K=!0;if(r.getProgramParameter(N,r.LINK_STATUS)===!1)if(Q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,N,j,z);else{const ae=QN(r,j,"vertex"),Ae=QN(r,z,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(N,r.VALIDATE_STATUS)+` + +Material Name: `+Y.name+` +Material Type: `+Y.type+` + +Program Info Log: `+te+` +`+ae+` +`+Ae)}else te!==""?console.warn("THREE.WebGLProgram: Program Info Log:",te):(ne===""||le==="")&&(K=!1);K&&(Y.diagnostics={runnable:Q,programLog:te,vertexShader:{log:ne,prefix:C},fragmentShader:{log:le,prefix:E}})}r.deleteShader(j),r.deleteShader(z),W=new qv(r,N),q=Zj(r,N)}let W;this.getUniforms=function(){return W===void 0&&G(this),W};let q;this.getAttributes=function(){return q===void 0&&G(this),q};let V=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return V===!1&&(V=r.getProgramParameter(N,Vj)),V},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(N),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=jj++,this.cacheKey=e,this.usedTimes=1,this.program=N,this.vertexShader=j,this.fragmentShader=z,this}let cH=0;class hH{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new fH(e),t.set(e,n)),n}}class fH{constructor(e){this.id=cH++,this.code=e,this.usedTimes=0}}function dH(i,e,t,n,r,s,a){const l=new Xw,u=new hH,h=new Set,m=[],v=r.logarithmicDepthBuffer,x=r.vertexTextures;let S=r.precision;const w={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function N(q){return h.add(q),q===0?"uv":`uv${q}`}function C(q,V,Y,te,ne){const le=te.fog,Q=ne.geometry,K=q.isMeshStandardMaterial?te.environment:null,ae=(q.isMeshStandardMaterial?t:e).get(q.envMap||K),Ae=ae&&ae.mapping===ld?ae.image.height:null,be=w[q.type];q.precision!==null&&(S=r.getMaxPrecision(q.precision),S!==q.precision&&console.warn("THREE.WebGLProgram.getParameters:",q.precision,"not supported, using",S,"instead."));const Se=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,se=Se!==void 0?Se.length:0;let Ee=0;Q.morphAttributes.position!==void 0&&(Ee=1),Q.morphAttributes.normal!==void 0&&(Ee=2),Q.morphAttributes.color!==void 0&&(Ee=3);let qe,Ce,ke,Qe;if(be){const ye=$a[be];qe=ye.vertexShader,Ce=ye.fragmentShader}else qe=q.vertexShader,Ce=q.fragmentShader,u.update(q),ke=u.getVertexShaderID(q),Qe=u.getFragmentShaderID(q);const et=i.getRenderTarget(),Pt=i.state.buffers.depth.getReversed(),Nt=ne.isInstancedMesh===!0,Gt=ne.isBatchedMesh===!0,Tt=!!q.map,Ge=!!q.matcap,dt=!!ae,he=!!q.aoMap,en=!!q.lightMap,wt=!!q.bumpMap,qt=!!q.normalMap,Lt=!!q.displacementMap,hn=!!q.emissiveMap,ut=!!q.metalnessMap,fe=!!q.roughnessMap,k=q.anisotropy>0,_e=q.clearcoat>0,Be=q.dispersion>0,Oe=q.iridescence>0,je=q.sheen>0,Bt=q.transmission>0,yt=k&&!!q.anisotropyMap,Xt=_e&&!!q.clearcoatMap,ln=_e&&!!q.clearcoatNormalMap,mt=_e&&!!q.clearcoatRoughnessMap,Wt=Oe&&!!q.iridescenceMap,Yt=Oe&&!!q.iridescenceThicknessMap,$t=je&&!!q.sheenColorMap,It=je&&!!q.sheenRoughnessMap,Te=!!q.specularMap,nt=!!q.specularColorMap,At=!!q.specularIntensityMap,ce=Bt&&!!q.transmissionMap,xt=Bt&&!!q.thicknessMap,Ze=!!q.gradientMap,lt=!!q.alphaMap,bt=q.alphaTest>0,Kt=!!q.alphaHash,un=!!q.extensions;let Ye=ro;q.toneMapped&&(et===null||et.isXRRenderTarget===!0)&&(Ye=i.toneMapping);const St={shaderID:be,shaderType:q.type,shaderName:q.name,vertexShader:qe,fragmentShader:Ce,defines:q.defines,customVertexShaderID:ke,customFragmentShaderID:Qe,isRawShaderMaterial:q.isRawShaderMaterial===!0,glslVersion:q.glslVersion,precision:S,batching:Gt,batchingColor:Gt&&ne._colorsTexture!==null,instancing:Nt,instancingColor:Nt&&ne.instanceColor!==null,instancingMorph:Nt&&ne.morphTexture!==null,supportsVertexTextures:x,outputColorSpace:et===null?i.outputColorSpace:et.isXRRenderTarget===!0?et.texture.colorSpace:Io,alphaToCoverage:!!q.alphaToCoverage,map:Tt,matcap:Ge,envMap:dt,envMapMode:dt&&ae.mapping,envMapCubeUVHeight:Ae,aoMap:he,lightMap:en,bumpMap:wt,normalMap:qt,displacementMap:x&&Lt,emissiveMap:hn,normalMapObjectSpace:qt&&q.normalMapType===z7,normalMapTangentSpace:qt&&q.normalMapType===kc,metalnessMap:ut,roughnessMap:fe,anisotropy:k,anisotropyMap:yt,clearcoat:_e,clearcoatMap:Xt,clearcoatNormalMap:ln,clearcoatRoughnessMap:mt,dispersion:Be,iridescence:Oe,iridescenceMap:Wt,iridescenceThicknessMap:Yt,sheen:je,sheenColorMap:$t,sheenRoughnessMap:It,specularMap:Te,specularColorMap:nt,specularIntensityMap:At,transmission:Bt,transmissionMap:ce,thicknessMap:xt,gradientMap:Ze,opaque:q.transparent===!1&&q.blending===io&&q.alphaToCoverage===!1,alphaMap:lt,alphaTest:bt,alphaHash:Kt,combine:q.combine,mapUv:Tt&&N(q.map.channel),aoMapUv:he&&N(q.aoMap.channel),lightMapUv:en&&N(q.lightMap.channel),bumpMapUv:wt&&N(q.bumpMap.channel),normalMapUv:qt&&N(q.normalMap.channel),displacementMapUv:Lt&&N(q.displacementMap.channel),emissiveMapUv:hn&&N(q.emissiveMap.channel),metalnessMapUv:ut&&N(q.metalnessMap.channel),roughnessMapUv:fe&&N(q.roughnessMap.channel),anisotropyMapUv:yt&&N(q.anisotropyMap.channel),clearcoatMapUv:Xt&&N(q.clearcoatMap.channel),clearcoatNormalMapUv:ln&&N(q.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:mt&&N(q.clearcoatRoughnessMap.channel),iridescenceMapUv:Wt&&N(q.iridescenceMap.channel),iridescenceThicknessMapUv:Yt&&N(q.iridescenceThicknessMap.channel),sheenColorMapUv:$t&&N(q.sheenColorMap.channel),sheenRoughnessMapUv:It&&N(q.sheenRoughnessMap.channel),specularMapUv:Te&&N(q.specularMap.channel),specularColorMapUv:nt&&N(q.specularColorMap.channel),specularIntensityMapUv:At&&N(q.specularIntensityMap.channel),transmissionMapUv:ce&&N(q.transmissionMap.channel),thicknessMapUv:xt&&N(q.thicknessMap.channel),alphaMapUv:lt&&N(q.alphaMap.channel),vertexTangents:!!Q.attributes.tangent&&(qt||k),vertexColors:q.vertexColors,vertexAlphas:q.vertexColors===!0&&!!Q.attributes.color&&Q.attributes.color.itemSize===4,pointsUvs:ne.isPoints===!0&&!!Q.attributes.uv&&(Tt||lt),fog:!!le,useFog:q.fog===!0,fogExp2:!!le&&le.isFogExp2,flatShading:q.flatShading===!0,sizeAttenuation:q.sizeAttenuation===!0,logarithmicDepthBuffer:v,reverseDepthBuffer:Pt,skinning:ne.isSkinnedMesh===!0,morphTargets:Q.morphAttributes.position!==void 0,morphNormals:Q.morphAttributes.normal!==void 0,morphColors:Q.morphAttributes.color!==void 0,morphTargetsCount:se,morphTextureStride:Ee,numDirLights:V.directional.length,numPointLights:V.point.length,numSpotLights:V.spot.length,numSpotLightMaps:V.spotLightMap.length,numRectAreaLights:V.rectArea.length,numHemiLights:V.hemi.length,numDirLightShadows:V.directionalShadowMap.length,numPointLightShadows:V.pointShadowMap.length,numSpotLightShadows:V.spotShadowMap.length,numSpotLightShadowsWithMaps:V.numSpotLightShadowsWithMaps,numLightProbes:V.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:q.dithering,shadowMapEnabled:i.shadowMap.enabled&&Y.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ye,decodeVideoTexture:Tt&&q.map.isVideoTexture===!0&&hi.getTransfer(q.map.colorSpace)===Hi,decodeVideoTextureEmissive:hn&&q.emissiveMap.isVideoTexture===!0&&hi.getTransfer(q.emissiveMap.colorSpace)===Hi,premultipliedAlpha:q.premultipliedAlpha,doubleSided:q.side===gs,flipSided:q.side===gr,useDepthPacking:q.depthPacking>=0,depthPacking:q.depthPacking||0,index0AttributeName:q.index0AttributeName,extensionClipCullDistance:un&&q.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(un&&q.extensions.multiDraw===!0||Gt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:q.customProgramCacheKey()};return St.vertexUv1s=h.has(1),St.vertexUv2s=h.has(2),St.vertexUv3s=h.has(3),h.clear(),St}function E(q){const V=[];if(q.shaderID?V.push(q.shaderID):(V.push(q.customVertexShaderID),V.push(q.customFragmentShaderID)),q.defines!==void 0)for(const Y in q.defines)V.push(Y),V.push(q.defines[Y]);return q.isRawShaderMaterial===!1&&(O(V,q),U(V,q),V.push(i.outputColorSpace)),V.push(q.customProgramCacheKey),V.join()}function O(q,V){q.push(V.precision),q.push(V.outputColorSpace),q.push(V.envMapMode),q.push(V.envMapCubeUVHeight),q.push(V.mapUv),q.push(V.alphaMapUv),q.push(V.lightMapUv),q.push(V.aoMapUv),q.push(V.bumpMapUv),q.push(V.normalMapUv),q.push(V.displacementMapUv),q.push(V.emissiveMapUv),q.push(V.metalnessMapUv),q.push(V.roughnessMapUv),q.push(V.anisotropyMapUv),q.push(V.clearcoatMapUv),q.push(V.clearcoatNormalMapUv),q.push(V.clearcoatRoughnessMapUv),q.push(V.iridescenceMapUv),q.push(V.iridescenceThicknessMapUv),q.push(V.sheenColorMapUv),q.push(V.sheenRoughnessMapUv),q.push(V.specularMapUv),q.push(V.specularColorMapUv),q.push(V.specularIntensityMapUv),q.push(V.transmissionMapUv),q.push(V.thicknessMapUv),q.push(V.combine),q.push(V.fogExp2),q.push(V.sizeAttenuation),q.push(V.morphTargetsCount),q.push(V.morphAttributeCount),q.push(V.numDirLights),q.push(V.numPointLights),q.push(V.numSpotLights),q.push(V.numSpotLightMaps),q.push(V.numHemiLights),q.push(V.numRectAreaLights),q.push(V.numDirLightShadows),q.push(V.numPointLightShadows),q.push(V.numSpotLightShadows),q.push(V.numSpotLightShadowsWithMaps),q.push(V.numLightProbes),q.push(V.shadowMapType),q.push(V.toneMapping),q.push(V.numClippingPlanes),q.push(V.numClipIntersection),q.push(V.depthPacking)}function U(q,V){l.disableAll(),V.supportsVertexTextures&&l.enable(0),V.instancing&&l.enable(1),V.instancingColor&&l.enable(2),V.instancingMorph&&l.enable(3),V.matcap&&l.enable(4),V.envMap&&l.enable(5),V.normalMapObjectSpace&&l.enable(6),V.normalMapTangentSpace&&l.enable(7),V.clearcoat&&l.enable(8),V.iridescence&&l.enable(9),V.alphaTest&&l.enable(10),V.vertexColors&&l.enable(11),V.vertexAlphas&&l.enable(12),V.vertexUv1s&&l.enable(13),V.vertexUv2s&&l.enable(14),V.vertexUv3s&&l.enable(15),V.vertexTangents&&l.enable(16),V.anisotropy&&l.enable(17),V.alphaHash&&l.enable(18),V.batching&&l.enable(19),V.dispersion&&l.enable(20),V.batchingColor&&l.enable(21),q.push(l.mask),l.disableAll(),V.fog&&l.enable(0),V.useFog&&l.enable(1),V.flatShading&&l.enable(2),V.logarithmicDepthBuffer&&l.enable(3),V.reverseDepthBuffer&&l.enable(4),V.skinning&&l.enable(5),V.morphTargets&&l.enable(6),V.morphNormals&&l.enable(7),V.morphColors&&l.enable(8),V.premultipliedAlpha&&l.enable(9),V.shadowMapEnabled&&l.enable(10),V.doubleSided&&l.enable(11),V.flipSided&&l.enable(12),V.useDepthPacking&&l.enable(13),V.dithering&&l.enable(14),V.transmission&&l.enable(15),V.sheen&&l.enable(16),V.opaque&&l.enable(17),V.pointsUvs&&l.enable(18),V.decodeVideoTexture&&l.enable(19),V.decodeVideoTextureEmissive&&l.enable(20),V.alphaToCoverage&&l.enable(21),q.push(l.mask)}function I(q){const V=w[q.type];let Y;if(V){const te=$a[V];Y=vy.clone(te.uniforms)}else Y=q.uniforms;return Y}function j(q,V){let Y;for(let te=0,ne=m.length;te0?n.push(E):S.transparent===!0?r.push(E):t.push(E)}function u(v,x,S,w,N,C){const E=a(v,x,S,w,N,C);S.transmission>0?n.unshift(E):S.transparent===!0?r.unshift(E):t.unshift(E)}function h(v,x){t.length>1&&t.sort(v||pH),n.length>1&&n.sort(x||t5),r.length>1&&r.sort(x||t5)}function m(){for(let v=e,x=i.length;v=s.length?(a=new n5,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function gH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new de,color:new mn};break;case"SpotLight":t={position:new de,direction:new de,color:new mn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new de,color:new mn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new de,skyColor:new mn,groundColor:new mn};break;case"RectAreaLight":t={color:new mn,position:new de,halfWidth:new de,halfHeight:new de};break}return i[e.id]=t,t}}}function vH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let _H=0;function yH(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function xH(i){const e=new gH,t=vH(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)n.probe.push(new de);const r=new de,s=new Xn,a=new Xn;function l(h){let m=0,v=0,x=0;for(let q=0;q<9;q++)n.probe[q].set(0,0,0);let S=0,w=0,N=0,C=0,E=0,O=0,U=0,I=0,j=0,z=0,G=0;h.sort(yH);for(let q=0,V=h.length;q0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=sn.LTC_FLOAT_1,n.rectAreaLTC2=sn.LTC_FLOAT_2):(n.rectAreaLTC1=sn.LTC_HALF_1,n.rectAreaLTC2=sn.LTC_HALF_2)),n.ambient[0]=m,n.ambient[1]=v,n.ambient[2]=x;const W=n.hash;(W.directionalLength!==S||W.pointLength!==w||W.spotLength!==N||W.rectAreaLength!==C||W.hemiLength!==E||W.numDirectionalShadows!==O||W.numPointShadows!==U||W.numSpotShadows!==I||W.numSpotMaps!==j||W.numLightProbes!==G)&&(n.directional.length=S,n.spot.length=N,n.rectArea.length=C,n.point.length=w,n.hemi.length=E,n.directionalShadow.length=O,n.directionalShadowMap.length=O,n.pointShadow.length=U,n.pointShadowMap.length=U,n.spotShadow.length=I,n.spotShadowMap.length=I,n.directionalShadowMatrix.length=O,n.pointShadowMatrix.length=U,n.spotLightMatrix.length=I+j-z,n.spotLightMap.length=j,n.numSpotLightShadowsWithMaps=z,n.numLightProbes=G,W.directionalLength=S,W.pointLength=w,W.spotLength=N,W.rectAreaLength=C,W.hemiLength=E,W.numDirectionalShadows=O,W.numPointShadows=U,W.numSpotShadows=I,W.numSpotMaps=j,W.numLightProbes=G,n.version=_H++)}function u(h,m){let v=0,x=0,S=0,w=0,N=0;const C=m.matrixWorldInverse;for(let E=0,O=h.length;E=a.length?(l=new i5(i),a.push(l)):l=a[s],l}function n(){e=new WeakMap}return{get:t,dispose:n}}const SH=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,TH=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function wH(i,e,t){let n=new zg;const r=new Et,s=new Et,a=new qn,l=new Oz({depthPacking:KF}),u=new Iz,h={},m=t.maxTextureSize,v={[zl]:gr,[gr]:zl,[gs]:gs},x=new so({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Et},radius:{value:4}},vertexShader:SH,fragmentShader:TH}),S=x.clone();S.defines.HORIZONTAL_PASS=1;const w=new Ji;w.setAttribute("position",new Lr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const N=new qi(w,x),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bw;let E=this.type;this.render=function(z,G,W){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||z.length===0)return;const q=i.getRenderTarget(),V=i.getActiveCubeFace(),Y=i.getActiveMipmapLevel(),te=i.state;te.setBlending(no),te.buffers.color.setClear(1,1,1,1),te.buffers.depth.setTest(!0),te.setScissorTest(!1);const ne=E!==No&&this.type===No,le=E===No&&this.type!==No;for(let Q=0,K=z.length;Qm||r.y>m)&&(r.x>m&&(s.x=Math.floor(m/be.x),r.x=s.x*be.x,Ae.mapSize.x=s.x),r.y>m&&(s.y=Math.floor(m/be.y),r.y=s.y*be.y,Ae.mapSize.y=s.y)),Ae.map===null||ne===!0||le===!0){const se=this.type!==No?{minFilter:br,magFilter:br}:{};Ae.map!==null&&Ae.map.dispose(),Ae.map=new Xh(r.x,r.y,se),Ae.map.texture.name=ae.name+".shadowMap",Ae.camera.updateProjectionMatrix()}i.setRenderTarget(Ae.map),i.clear();const Se=Ae.getViewportCount();for(let se=0;se0||G.map&&G.alphaTest>0){const te=V.uuid,ne=G.uuid;let le=h[te];le===void 0&&(le={},h[te]=le);let Q=le[ne];Q===void 0&&(Q=V.clone(),le[ne]=Q,G.addEventListener("dispose",j)),V=Q}if(V.visible=G.visible,V.wireframe=G.wireframe,q===No?V.side=G.shadowSide!==null?G.shadowSide:G.side:V.side=G.shadowSide!==null?G.shadowSide:v[G.side],V.alphaMap=G.alphaMap,V.alphaTest=G.alphaTest,V.map=G.map,V.clipShadows=G.clipShadows,V.clippingPlanes=G.clippingPlanes,V.clipIntersection=G.clipIntersection,V.displacementMap=G.displacementMap,V.displacementScale=G.displacementScale,V.displacementBias=G.displacementBias,V.wireframeLinewidth=G.wireframeLinewidth,V.linewidth=G.linewidth,W.isPointLight===!0&&V.isMeshDistanceMaterial===!0){const te=i.properties.get(V);te.light=W}return V}function I(z,G,W,q,V){if(z.visible===!1)return;if(z.layers.test(G.layers)&&(z.isMesh||z.isLine||z.isPoints)&&(z.castShadow||z.receiveShadow&&V===No)&&(!z.frustumCulled||n.intersectsObject(z))){z.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,z.matrixWorld);const ne=e.update(z),le=z.material;if(Array.isArray(le)){const Q=ne.groups;for(let K=0,ae=Q.length;K=1):Ae.indexOf("OpenGL ES")!==-1&&(ae=parseFloat(/^OpenGL ES (\d)/.exec(Ae)[1]),K=ae>=2);let be=null,Se={};const se=i.getParameter(i.SCISSOR_BOX),Ee=i.getParameter(i.VIEWPORT),qe=new qn().fromArray(se),Ce=new qn().fromArray(Ee);function ke(ce,xt,Ze,lt){const bt=new Uint8Array(4),Kt=i.createTexture();i.bindTexture(ce,Kt),i.texParameteri(ce,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(ce,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let un=0;un"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new Et,m=new WeakMap;let v;const x=new WeakMap;let S=!1;try{S=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function w(fe,k){return S?new OffscreenCanvas(fe,k):og("canvas")}function N(fe,k,_e){let Be=1;const Oe=ut(fe);if((Oe.width>_e||Oe.height>_e)&&(Be=_e/Math.max(Oe.width,Oe.height)),Be<1)if(typeof HTMLImageElement<"u"&&fe instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&fe instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&fe instanceof ImageBitmap||typeof VideoFrame<"u"&&fe instanceof VideoFrame){const je=Math.floor(Be*Oe.width),Bt=Math.floor(Be*Oe.height);v===void 0&&(v=w(je,Bt));const yt=k?w(je,Bt):v;return yt.width=je,yt.height=Bt,yt.getContext("2d").drawImage(fe,0,0,je,Bt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Oe.width+"x"+Oe.height+") to ("+je+"x"+Bt+")."),yt}else return"data"in fe&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Oe.width+"x"+Oe.height+")."),fe;return fe}function C(fe){return fe.generateMipmaps}function E(fe){i.generateMipmap(fe)}function O(fe){return fe.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:fe.isWebGL3DRenderTarget?i.TEXTURE_3D:fe.isWebGLArrayRenderTarget||fe.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function U(fe,k,_e,Be,Oe=!1){if(fe!==null){if(i[fe]!==void 0)return i[fe];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+fe+"'")}let je=k;if(k===i.RED&&(_e===i.FLOAT&&(je=i.R32F),_e===i.HALF_FLOAT&&(je=i.R16F),_e===i.UNSIGNED_BYTE&&(je=i.R8)),k===i.RED_INTEGER&&(_e===i.UNSIGNED_BYTE&&(je=i.R8UI),_e===i.UNSIGNED_SHORT&&(je=i.R16UI),_e===i.UNSIGNED_INT&&(je=i.R32UI),_e===i.BYTE&&(je=i.R8I),_e===i.SHORT&&(je=i.R16I),_e===i.INT&&(je=i.R32I)),k===i.RG&&(_e===i.FLOAT&&(je=i.RG32F),_e===i.HALF_FLOAT&&(je=i.RG16F),_e===i.UNSIGNED_BYTE&&(je=i.RG8)),k===i.RG_INTEGER&&(_e===i.UNSIGNED_BYTE&&(je=i.RG8UI),_e===i.UNSIGNED_SHORT&&(je=i.RG16UI),_e===i.UNSIGNED_INT&&(je=i.RG32UI),_e===i.BYTE&&(je=i.RG8I),_e===i.SHORT&&(je=i.RG16I),_e===i.INT&&(je=i.RG32I)),k===i.RGB_INTEGER&&(_e===i.UNSIGNED_BYTE&&(je=i.RGB8UI),_e===i.UNSIGNED_SHORT&&(je=i.RGB16UI),_e===i.UNSIGNED_INT&&(je=i.RGB32UI),_e===i.BYTE&&(je=i.RGB8I),_e===i.SHORT&&(je=i.RGB16I),_e===i.INT&&(je=i.RGB32I)),k===i.RGBA_INTEGER&&(_e===i.UNSIGNED_BYTE&&(je=i.RGBA8UI),_e===i.UNSIGNED_SHORT&&(je=i.RGBA16UI),_e===i.UNSIGNED_INT&&(je=i.RGBA32UI),_e===i.BYTE&&(je=i.RGBA8I),_e===i.SHORT&&(je=i.RGBA16I),_e===i.INT&&(je=i.RGBA32I)),k===i.RGB&&_e===i.UNSIGNED_INT_5_9_9_9_REV&&(je=i.RGB9_E5),k===i.RGBA){const Bt=Oe?a_:hi.getTransfer(Be);_e===i.FLOAT&&(je=i.RGBA32F),_e===i.HALF_FLOAT&&(je=i.RGBA16F),_e===i.UNSIGNED_BYTE&&(je=Bt===Hi?i.SRGB8_ALPHA8:i.RGBA8),_e===i.UNSIGNED_SHORT_4_4_4_4&&(je=i.RGBA4),_e===i.UNSIGNED_SHORT_5_5_5_1&&(je=i.RGB5_A1)}return(je===i.R16F||je===i.R32F||je===i.RG16F||je===i.RG32F||je===i.RGBA16F||je===i.RGBA32F)&&e.get("EXT_color_buffer_float"),je}function I(fe,k){let _e;return fe?k===null||k===Ir||k===xu?_e=i.DEPTH24_STENCIL8:k===ss?_e=i.DEPTH32F_STENCIL8:k===Bl&&(_e=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):k===null||k===Ir||k===xu?_e=i.DEPTH_COMPONENT24:k===ss?_e=i.DEPTH_COMPONENT32F:k===Bl&&(_e=i.DEPTH_COMPONENT16),_e}function j(fe,k){return C(fe)===!0||fe.isFramebufferTexture&&fe.minFilter!==br&&fe.minFilter!==Ms?Math.log2(Math.max(k.width,k.height))+1:fe.mipmaps!==void 0&&fe.mipmaps.length>0?fe.mipmaps.length:fe.isCompressedTexture&&Array.isArray(fe.image)?k.mipmaps.length:1}function z(fe){const k=fe.target;k.removeEventListener("dispose",z),W(k),k.isVideoTexture&&m.delete(k)}function G(fe){const k=fe.target;k.removeEventListener("dispose",G),V(k)}function W(fe){const k=n.get(fe);if(k.__webglInit===void 0)return;const _e=fe.source,Be=x.get(_e);if(Be){const Oe=Be[k.__cacheKey];Oe.usedTimes--,Oe.usedTimes===0&&q(fe),Object.keys(Be).length===0&&x.delete(_e)}n.remove(fe)}function q(fe){const k=n.get(fe);i.deleteTexture(k.__webglTexture);const _e=fe.source,Be=x.get(_e);delete Be[k.__cacheKey],a.memory.textures--}function V(fe){const k=n.get(fe);if(fe.depthTexture&&(fe.depthTexture.dispose(),n.remove(fe.depthTexture)),fe.isWebGLCubeRenderTarget)for(let Be=0;Be<6;Be++){if(Array.isArray(k.__webglFramebuffer[Be]))for(let Oe=0;Oe=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+fe+" texture units while this GPU supports only "+r.maxTextures),Y+=1,fe}function le(fe){const k=[];return k.push(fe.wrapS),k.push(fe.wrapT),k.push(fe.wrapR||0),k.push(fe.magFilter),k.push(fe.minFilter),k.push(fe.anisotropy),k.push(fe.internalFormat),k.push(fe.format),k.push(fe.type),k.push(fe.generateMipmaps),k.push(fe.premultiplyAlpha),k.push(fe.flipY),k.push(fe.unpackAlignment),k.push(fe.colorSpace),k.join()}function Q(fe,k){const _e=n.get(fe);if(fe.isVideoTexture&&Lt(fe),fe.isRenderTargetTexture===!1&&fe.version>0&&_e.__version!==fe.version){const Be=fe.image;if(Be===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Be.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(_e,fe,k);return}}t.bindTexture(i.TEXTURE_2D,_e.__webglTexture,i.TEXTURE0+k)}function K(fe,k){const _e=n.get(fe);if(fe.version>0&&_e.__version!==fe.version){Ce(_e,fe,k);return}t.bindTexture(i.TEXTURE_2D_ARRAY,_e.__webglTexture,i.TEXTURE0+k)}function ae(fe,k){const _e=n.get(fe);if(fe.version>0&&_e.__version!==fe.version){Ce(_e,fe,k);return}t.bindTexture(i.TEXTURE_3D,_e.__webglTexture,i.TEXTURE0+k)}function Ae(fe,k){const _e=n.get(fe);if(fe.version>0&&_e.__version!==fe.version){ke(_e,fe,k);return}t.bindTexture(i.TEXTURE_CUBE_MAP,_e.__webglTexture,i.TEXTURE0+k)}const be={[ud]:i.REPEAT,[lu]:i.CLAMP_TO_EDGE,[cd]:i.MIRRORED_REPEAT},Se={[br]:i.NEAREST,[s_]:i.NEAREST_MIPMAP_NEAREST,[uu]:i.NEAREST_MIPMAP_LINEAR,[Ms]:i.LINEAR,[n0]:i.LINEAR_MIPMAP_NEAREST,[Ya]:i.LINEAR_MIPMAP_LINEAR},se={[zw]:i.NEVER,[Hw]:i.ALWAYS,[my]:i.LESS,[gy]:i.LEQUAL,[Gw]:i.EQUAL,[jw]:i.GEQUAL,[qw]:i.GREATER,[Vw]:i.NOTEQUAL};function Ee(fe,k){if(k.type===ss&&e.has("OES_texture_float_linear")===!1&&(k.magFilter===Ms||k.magFilter===n0||k.magFilter===uu||k.magFilter===Ya||k.minFilter===Ms||k.minFilter===n0||k.minFilter===uu||k.minFilter===Ya)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(fe,i.TEXTURE_WRAP_S,be[k.wrapS]),i.texParameteri(fe,i.TEXTURE_WRAP_T,be[k.wrapT]),(fe===i.TEXTURE_3D||fe===i.TEXTURE_2D_ARRAY)&&i.texParameteri(fe,i.TEXTURE_WRAP_R,be[k.wrapR]),i.texParameteri(fe,i.TEXTURE_MAG_FILTER,Se[k.magFilter]),i.texParameteri(fe,i.TEXTURE_MIN_FILTER,Se[k.minFilter]),k.compareFunction&&(i.texParameteri(fe,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(fe,i.TEXTURE_COMPARE_FUNC,se[k.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(k.magFilter===br||k.minFilter!==uu&&k.minFilter!==Ya||k.type===ss&&e.has("OES_texture_float_linear")===!1)return;if(k.anisotropy>1||n.get(k).__currentAnisotropy){const _e=e.get("EXT_texture_filter_anisotropic");i.texParameterf(fe,_e.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),n.get(k).__currentAnisotropy=k.anisotropy}}}function qe(fe,k){let _e=!1;fe.__webglInit===void 0&&(fe.__webglInit=!0,k.addEventListener("dispose",z));const Be=k.source;let Oe=x.get(Be);Oe===void 0&&(Oe={},x.set(Be,Oe));const je=le(k);if(je!==fe.__cacheKey){Oe[je]===void 0&&(Oe[je]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,_e=!0),Oe[je].usedTimes++;const Bt=Oe[fe.__cacheKey];Bt!==void 0&&(Oe[fe.__cacheKey].usedTimes--,Bt.usedTimes===0&&q(k)),fe.__cacheKey=je,fe.__webglTexture=Oe[je].texture}return _e}function Ce(fe,k,_e){let Be=i.TEXTURE_2D;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(Be=i.TEXTURE_2D_ARRAY),k.isData3DTexture&&(Be=i.TEXTURE_3D);const Oe=qe(fe,k),je=k.source;t.bindTexture(Be,fe.__webglTexture,i.TEXTURE0+_e);const Bt=n.get(je);if(je.version!==Bt.__version||Oe===!0){t.activeTexture(i.TEXTURE0+_e);const yt=hi.getPrimaries(hi.workingColorSpace),Xt=k.colorSpace===Oo?null:hi.getPrimaries(k.colorSpace),ln=k.colorSpace===Oo||yt===Xt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,k.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,k.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ln);let mt=N(k.image,!1,r.maxTextureSize);mt=hn(k,mt);const Wt=s.convert(k.format,k.colorSpace),Yt=s.convert(k.type);let $t=U(k.internalFormat,Wt,Yt,k.colorSpace,k.isVideoTexture);Ee(Be,k);let It;const Te=k.mipmaps,nt=k.isVideoTexture!==!0,At=Bt.__version===void 0||Oe===!0,ce=je.dataReady,xt=j(k,mt);if(k.isDepthTexture)$t=I(k.format===bu,k.type),At&&(nt?t.texStorage2D(i.TEXTURE_2D,1,$t,mt.width,mt.height):t.texImage2D(i.TEXTURE_2D,0,$t,mt.width,mt.height,0,Wt,Yt,null));else if(k.isDataTexture)if(Te.length>0){nt&&At&&t.texStorage2D(i.TEXTURE_2D,xt,$t,Te[0].width,Te[0].height);for(let Ze=0,lt=Te.length;Ze0){const bt=LN(It.width,It.height,k.format,k.type);for(const Kt of k.layerUpdates){const un=It.data.subarray(Kt*bt/It.data.BYTES_PER_ELEMENT,(Kt+1)*bt/It.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Ze,0,0,Kt,It.width,It.height,1,Wt,un)}k.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Ze,0,0,0,It.width,It.height,mt.depth,Wt,It.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Ze,$t,It.width,It.height,mt.depth,0,It.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else nt?ce&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Ze,0,0,0,It.width,It.height,mt.depth,Wt,Yt,It.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Ze,$t,It.width,It.height,mt.depth,0,Wt,Yt,It.data)}else{nt&&At&&t.texStorage2D(i.TEXTURE_2D,xt,$t,Te[0].width,Te[0].height);for(let Ze=0,lt=Te.length;Ze0){const Ze=LN(mt.width,mt.height,k.format,k.type);for(const lt of k.layerUpdates){const bt=mt.data.subarray(lt*Ze/mt.data.BYTES_PER_ELEMENT,(lt+1)*Ze/mt.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,lt,mt.width,mt.height,1,Wt,Yt,bt)}k.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,mt.width,mt.height,mt.depth,Wt,Yt,mt.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,$t,mt.width,mt.height,mt.depth,0,Wt,Yt,mt.data);else if(k.isData3DTexture)nt?(At&&t.texStorage3D(i.TEXTURE_3D,xt,$t,mt.width,mt.height,mt.depth),ce&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,mt.width,mt.height,mt.depth,Wt,Yt,mt.data)):t.texImage3D(i.TEXTURE_3D,0,$t,mt.width,mt.height,mt.depth,0,Wt,Yt,mt.data);else if(k.isFramebufferTexture){if(At)if(nt)t.texStorage2D(i.TEXTURE_2D,xt,$t,mt.width,mt.height);else{let Ze=mt.width,lt=mt.height;for(let bt=0;bt>=1,lt>>=1}}else if(Te.length>0){if(nt&&At){const Ze=ut(Te[0]);t.texStorage2D(i.TEXTURE_2D,xt,$t,Ze.width,Ze.height)}for(let Ze=0,lt=Te.length;Ze0&&xt++;const lt=ut(Wt[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,xt,Te,lt.width,lt.height)}for(let lt=0;lt<6;lt++)if(mt){nt?ce&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,0,0,Wt[lt].width,Wt[lt].height,$t,It,Wt[lt].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,Te,Wt[lt].width,Wt[lt].height,0,$t,It,Wt[lt].data);for(let bt=0;bt>je),Yt=Math.max(1,k.height>>je);Oe===i.TEXTURE_3D||Oe===i.TEXTURE_2D_ARRAY?t.texImage3D(Oe,je,Xt,Wt,Yt,k.depth,0,Bt,yt,null):t.texImage2D(Oe,je,Xt,Wt,Yt,0,Bt,yt,null)}t.bindFramebuffer(i.FRAMEBUFFER,fe),qt(k)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Be,Oe,mt.__webglTexture,0,wt(k)):(Oe===i.TEXTURE_2D||Oe>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Oe<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Be,Oe,mt.__webglTexture,je),t.bindFramebuffer(i.FRAMEBUFFER,null)}function et(fe,k,_e){if(i.bindRenderbuffer(i.RENDERBUFFER,fe),k.depthBuffer){const Be=k.depthTexture,Oe=Be&&Be.isDepthTexture?Be.type:null,je=I(k.stencilBuffer,Oe),Bt=k.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,yt=wt(k);qt(k)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,yt,je,k.width,k.height):_e?i.renderbufferStorageMultisample(i.RENDERBUFFER,yt,je,k.width,k.height):i.renderbufferStorage(i.RENDERBUFFER,je,k.width,k.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Bt,i.RENDERBUFFER,fe)}else{const Be=k.textures;for(let Oe=0;Oe{delete k.__boundDepthTexture,delete k.__depthDisposeCallback,Be.removeEventListener("dispose",Oe)};Be.addEventListener("dispose",Oe),k.__depthDisposeCallback=Oe}k.__boundDepthTexture=Be}if(fe.depthTexture&&!k.__autoAllocateDepthBuffer){if(_e)throw new Error("target.depthTexture not supported in Cube render targets");Pt(k.__webglFramebuffer,fe)}else if(_e){k.__webglDepthbuffer=[];for(let Be=0;Be<6;Be++)if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer[Be]),k.__webglDepthbuffer[Be]===void 0)k.__webglDepthbuffer[Be]=i.createRenderbuffer(),et(k.__webglDepthbuffer[Be],fe,!1);else{const Oe=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,je=k.__webglDepthbuffer[Be];i.bindRenderbuffer(i.RENDERBUFFER,je),i.framebufferRenderbuffer(i.FRAMEBUFFER,Oe,i.RENDERBUFFER,je)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer),k.__webglDepthbuffer===void 0)k.__webglDepthbuffer=i.createRenderbuffer(),et(k.__webglDepthbuffer,fe,!1);else{const Be=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Oe=k.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Oe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Be,i.RENDERBUFFER,Oe)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Gt(fe,k,_e){const Be=n.get(fe);k!==void 0&&Qe(Be.__webglFramebuffer,fe,fe.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),_e!==void 0&&Nt(fe)}function Tt(fe){const k=fe.texture,_e=n.get(fe),Be=n.get(k);fe.addEventListener("dispose",G);const Oe=fe.textures,je=fe.isWebGLCubeRenderTarget===!0,Bt=Oe.length>1;if(Bt||(Be.__webglTexture===void 0&&(Be.__webglTexture=i.createTexture()),Be.__version=k.version,a.memory.textures++),je){_e.__webglFramebuffer=[];for(let yt=0;yt<6;yt++)if(k.mipmaps&&k.mipmaps.length>0){_e.__webglFramebuffer[yt]=[];for(let Xt=0;Xt0){_e.__webglFramebuffer=[];for(let yt=0;yt0&&qt(fe)===!1){_e.__webglMultisampledFramebuffer=i.createFramebuffer(),_e.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer);for(let yt=0;yt0)for(let Xt=0;Xt0)for(let Xt=0;Xt0){if(qt(fe)===!1){const k=fe.textures,_e=fe.width,Be=fe.height;let Oe=i.COLOR_BUFFER_BIT;const je=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Bt=n.get(fe),yt=k.length>1;if(yt)for(let Xt=0;Xt0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function Lt(fe){const k=a.render.frame;m.get(fe)!==k&&(m.set(fe,k),fe.update())}function hn(fe,k){const _e=fe.colorSpace,Be=fe.format,Oe=fe.type;return fe.isCompressedTexture===!0||fe.isVideoTexture===!0||_e!==Io&&_e!==Oo&&(hi.getTransfer(_e)===Hi?(Be!==Xs||Oe!==Aa)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",_e)),k}function ut(fe){return typeof HTMLImageElement<"u"&&fe instanceof HTMLImageElement?(h.width=fe.naturalWidth||fe.width,h.height=fe.naturalHeight||fe.height):typeof VideoFrame<"u"&&fe instanceof VideoFrame?(h.width=fe.displayWidth,h.height=fe.displayHeight):(h.width=fe.width,h.height=fe.height),h}this.allocateTextureUnit=ne,this.resetTextureUnits=te,this.setTexture2D=Q,this.setTexture2DArray=K,this.setTexture3D=ae,this.setTextureCube=Ae,this.rebindTextures=Gt,this.setupRenderTarget=Tt,this.updateRenderTargetMipmap=Ge,this.updateMultisampleRenderTarget=en,this.setupDepthRenderbuffer=Nt,this.setupFrameBufferTexture=Qe,this.useMultisampledRTT=qt}function NH(i,e){function t(n,r=Oo){let s;const a=hi.getTransfer(r);if(n===Aa)return i.UNSIGNED_BYTE;if(n===dy)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ay)return i.UNSIGNED_SHORT_5_5_5_1;if(n===py)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Jf)return i.BYTE;if(n===ed)return i.SHORT;if(n===Bl)return i.UNSIGNED_SHORT;if(n===ks)return i.INT;if(n===Ir)return i.UNSIGNED_INT;if(n===ss)return i.FLOAT;if(n===Qs)return i.HALF_FLOAT;if(n===Ow)return i.ALPHA;if(n===Og)return i.RGB;if(n===Xs)return i.RGBA;if(n===Iw)return i.LUMINANCE;if(n===Fw)return i.LUMINANCE_ALPHA;if(n===Au)return i.DEPTH_COMPONENT;if(n===bu)return i.DEPTH_STENCIL;if(n===Ig)return i.RED;if(n===$0)return i.RED_INTEGER;if(n===hd)return i.RG;if(n===X0)return i.RG_INTEGER;if(n===Y0)return i.RGBA_INTEGER;if(n===td||n===Gh||n===qh||n===Vh)if(a===Hi)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===td)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Gh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===qh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Vh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===td)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Gh)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===qh)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Vh)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Jm||n===eg||n===tg||n===ng)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Jm)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===eg)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===tg)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ng)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ig||n===f0||n===d0)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ig||n===f0)return a===Hi?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===d0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===A0||n===p0||n===m0||n===g0||n===v0||n===_0||n===y0||n===x0||n===b0||n===S0||n===T0||n===w0||n===M0||n===E0)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===A0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===p0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===m0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===g0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===v0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===_0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===y0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===x0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===b0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===S0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===T0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===w0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===M0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===E0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===nd||n===WS||n===$S)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===nd)return a===Hi?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===WS)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===$S)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===kw||n===rg||n===sg||n===ag)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===nd)return s.COMPRESSED_RED_RGTC1_EXT;if(n===rg)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===sg)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ag)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===xu?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const RH={type:"move"};class D3{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ka,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ka,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new de,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new de),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ka,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new de,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new de),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const l=this._targetRay,u=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const N of e.hand.values()){const C=t.getJointPose(N,n),E=this._getHandJoint(h,N);C!==null&&(E.matrix.fromArray(C.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=C.radius),E.visible=C!==null}const m=h.joints["index-finger-tip"],v=h.joints["thumb-tip"],x=m.position.distanceTo(v.position),S=.02,w=.005;h.inputState.pinching&&x>S+w?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&x<=S-w&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(RH)))}return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=s!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Ka;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const DH=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,PH=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class LH{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new Es,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new so({vertexShader:DH,fragmentShader:PH,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new qi(new Ty(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class UH extends Xc{constructor(e,t){super();const n=this;let r=null,s=1,a=null,l="local-floor",u=1,h=null,m=null,v=null,x=null,S=null,w=null;const N=new LH,C=t.getContextAttributes();let E=null,O=null;const U=[],I=[],j=new Et;let z=null;const G=new Ea;G.viewport=new qn;const W=new Ea;W.viewport=new qn;const q=[G,W],V=new Zz;let Y=null,te=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ce){let ke=U[Ce];return ke===void 0&&(ke=new D3,U[Ce]=ke),ke.getTargetRaySpace()},this.getControllerGrip=function(Ce){let ke=U[Ce];return ke===void 0&&(ke=new D3,U[Ce]=ke),ke.getGripSpace()},this.getHand=function(Ce){let ke=U[Ce];return ke===void 0&&(ke=new D3,U[Ce]=ke),ke.getHandSpace()};function ne(Ce){const ke=I.indexOf(Ce.inputSource);if(ke===-1)return;const Qe=U[ke];Qe!==void 0&&(Qe.update(Ce.inputSource,Ce.frame,h||a),Qe.dispatchEvent({type:Ce.type,data:Ce.inputSource}))}function le(){r.removeEventListener("select",ne),r.removeEventListener("selectstart",ne),r.removeEventListener("selectend",ne),r.removeEventListener("squeeze",ne),r.removeEventListener("squeezestart",ne),r.removeEventListener("squeezeend",ne),r.removeEventListener("end",le),r.removeEventListener("inputsourceschange",Q);for(let Ce=0;Ce=0&&(I[et]=null,U[et].disconnect(Qe))}for(let ke=0;ke=I.length){I.push(Qe),et=Nt;break}else if(I[Nt]===null){I[Nt]=Qe,et=Nt;break}if(et===-1)break}const Pt=U[et];Pt&&Pt.connect(Qe)}}const K=new de,ae=new de;function Ae(Ce,ke,Qe){K.setFromMatrixPosition(ke.matrixWorld),ae.setFromMatrixPosition(Qe.matrixWorld);const et=K.distanceTo(ae),Pt=ke.projectionMatrix.elements,Nt=Qe.projectionMatrix.elements,Gt=Pt[14]/(Pt[10]-1),Tt=Pt[14]/(Pt[10]+1),Ge=(Pt[9]+1)/Pt[5],dt=(Pt[9]-1)/Pt[5],he=(Pt[8]-1)/Pt[0],en=(Nt[8]+1)/Nt[0],wt=Gt*he,qt=Gt*en,Lt=et/(-he+en),hn=Lt*-he;if(ke.matrixWorld.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.translateX(hn),Ce.translateZ(Lt),Ce.matrixWorld.compose(Ce.position,Ce.quaternion,Ce.scale),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert(),Pt[10]===-1)Ce.projectionMatrix.copy(ke.projectionMatrix),Ce.projectionMatrixInverse.copy(ke.projectionMatrixInverse);else{const ut=Gt+Lt,fe=Tt+Lt,k=wt-hn,_e=qt+(et-hn),Be=Ge*Tt/fe*ut,Oe=dt*Tt/fe*ut;Ce.projectionMatrix.makePerspective(k,_e,Be,Oe,ut,fe),Ce.projectionMatrixInverse.copy(Ce.projectionMatrix).invert()}}function be(Ce,ke){ke===null?Ce.matrixWorld.copy(Ce.matrix):Ce.matrixWorld.multiplyMatrices(ke.matrixWorld,Ce.matrix),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert()}this.updateCamera=function(Ce){if(r===null)return;let ke=Ce.near,Qe=Ce.far;N.texture!==null&&(N.depthNear>0&&(ke=N.depthNear),N.depthFar>0&&(Qe=N.depthFar)),V.near=W.near=G.near=ke,V.far=W.far=G.far=Qe,(Y!==V.near||te!==V.far)&&(r.updateRenderState({depthNear:V.near,depthFar:V.far}),Y=V.near,te=V.far),G.layers.mask=Ce.layers.mask|2,W.layers.mask=Ce.layers.mask|4,V.layers.mask=G.layers.mask|W.layers.mask;const et=Ce.parent,Pt=V.cameras;be(V,et);for(let Nt=0;Nt0&&(C.alphaTest.value=E.alphaTest);const O=e.get(E),U=O.envMap,I=O.envMapRotation;U&&(C.envMap.value=U,Cf.copy(I),Cf.x*=-1,Cf.y*=-1,Cf.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(Cf.y*=-1,Cf.z*=-1),C.envMapRotation.value.setFromMatrix4(BH.makeRotationFromEuler(Cf)),C.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,C.reflectivity.value=E.reflectivity,C.ior.value=E.ior,C.refractionRatio.value=E.refractionRatio),E.lightMap&&(C.lightMap.value=E.lightMap,C.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,C.lightMapTransform)),E.aoMap&&(C.aoMap.value=E.aoMap,C.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,C.aoMapTransform))}function a(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform))}function l(C,E){C.dashSize.value=E.dashSize,C.totalSize.value=E.dashSize+E.gapSize,C.scale.value=E.scale}function u(C,E,O,U){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.size.value=E.size*O,C.scale.value=U*.5,E.map&&(C.map.value=E.map,t(E.map,C.uvTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function h(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.rotation.value=E.rotation,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function m(C,E){C.specular.value.copy(E.specular),C.shininess.value=Math.max(E.shininess,1e-4)}function v(C,E){E.gradientMap&&(C.gradientMap.value=E.gradientMap)}function x(C,E){C.metalness.value=E.metalness,E.metalnessMap&&(C.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,C.metalnessMapTransform)),C.roughness.value=E.roughness,E.roughnessMap&&(C.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,C.roughnessMapTransform)),E.envMap&&(C.envMapIntensity.value=E.envMapIntensity)}function S(C,E,O){C.ior.value=E.ior,E.sheen>0&&(C.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),C.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(C.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,C.sheenColorMapTransform)),E.sheenRoughnessMap&&(C.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,C.sheenRoughnessMapTransform))),E.clearcoat>0&&(C.clearcoat.value=E.clearcoat,C.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(C.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,C.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(C.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,C.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(C.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,C.clearcoatNormalMapTransform),C.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===gr&&C.clearcoatNormalScale.value.negate())),E.dispersion>0&&(C.dispersion.value=E.dispersion),E.iridescence>0&&(C.iridescence.value=E.iridescence,C.iridescenceIOR.value=E.iridescenceIOR,C.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],C.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(C.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,C.iridescenceMapTransform)),E.iridescenceThicknessMap&&(C.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,C.iridescenceThicknessMapTransform))),E.transmission>0&&(C.transmission.value=E.transmission,C.transmissionSamplerMap.value=O.texture,C.transmissionSamplerSize.value.set(O.width,O.height),E.transmissionMap&&(C.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,C.transmissionMapTransform)),C.thickness.value=E.thickness,E.thicknessMap&&(C.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,C.thicknessMapTransform)),C.attenuationDistance.value=E.attenuationDistance,C.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(C.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(C.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,C.anisotropyMapTransform))),C.specularIntensity.value=E.specularIntensity,C.specularColor.value.copy(E.specularColor),E.specularColorMap&&(C.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,C.specularColorMapTransform)),E.specularIntensityMap&&(C.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,C.specularIntensityMapTransform))}function w(C,E){E.matcap&&(C.matcap.value=E.matcap)}function N(C,E){const O=e.get(E).light;C.referencePosition.value.setFromMatrixPosition(O.matrixWorld),C.nearDistance.value=O.shadow.camera.near,C.farDistance.value=O.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function IH(i,e,t,n){let r={},s={},a=[];const l=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(O,U){const I=U.program;n.uniformBlockBinding(O,I)}function h(O,U){let I=r[O.id];I===void 0&&(w(O),I=m(O),r[O.id]=I,O.addEventListener("dispose",C));const j=U.program;n.updateUBOMapping(O,j);const z=e.render.frame;s[O.id]!==z&&(x(O),s[O.id]=z)}function m(O){const U=v();O.__bindingPointIndex=U;const I=i.createBuffer(),j=O.__size,z=O.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,j,z),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,U,I),I}function v(){for(let O=0;O0&&(I+=j-z),O.__size=I,O.__cache={},this}function N(O){const U={boundary:0,storage:0};return typeof O=="number"||typeof O=="boolean"?(U.boundary=4,U.storage=4):O.isVector2?(U.boundary=8,U.storage=8):O.isVector3||O.isColor?(U.boundary=16,U.storage=12):O.isVector4?(U.boundary=16,U.storage=16):O.isMatrix3?(U.boundary=48,U.storage=48):O.isMatrix4?(U.boundary=64,U.storage=64):O.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",O),U}function C(O){const U=O.target;U.removeEventListener("dispose",C);const I=a.indexOf(U.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[U.id]),delete r[U.id],delete s[U.id]}function E(){for(const O in r)i.deleteBuffer(r[O]);a=[],r={},s={}}return{bind:u,update:h,dispose:E}}class FH{constructor(e={}){const{canvas:t=q7(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:l=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:h=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:v=!1,reverseDepthBuffer:x=!1}=e;this.isWebGLRenderer=!0;let S;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");S=n.getContextAttributes().alpha}else S=a;const w=new Uint32Array(4),N=new Int32Array(4);let C=null,E=null;const O=[],U=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Nn,this.toneMapping=ro,this.toneMappingExposure=1;const I=this;let j=!1,z=0,G=0,W=null,q=-1,V=null;const Y=new qn,te=new qn;let ne=null;const le=new mn(0);let Q=0,K=t.width,ae=t.height,Ae=1,be=null,Se=null;const se=new qn(0,0,K,ae),Ee=new qn(0,0,K,ae);let qe=!1;const Ce=new zg;let ke=!1,Qe=!1;this.transmissionResolutionScale=1;const et=new Xn,Pt=new Xn,Nt=new de,Gt=new qn,Tt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ge=!1;function dt(){return W===null?Ae:1}let he=n;function en(ue,Fe){return t.getContext(ue,Fe)}try{const ue={alpha:!0,depth:r,stencil:s,antialias:l,premultipliedAlpha:u,preserveDrawingBuffer:h,powerPreference:m,failIfMajorPerformanceCaveat:v};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${W0}`),t.addEventListener("webglcontextlost",lt,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",Kt,!1),he===null){const Fe="webgl2";if(he=en(Fe,ue),he===null)throw en(Fe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ue){throw console.error("THREE.WebGLRenderer: "+ue.message),ue}let wt,qt,Lt,hn,ut,fe,k,_e,Be,Oe,je,Bt,yt,Xt,ln,mt,Wt,Yt,$t,It,Te,nt,At,ce;function xt(){wt=new $V(he),wt.init(),nt=new NH(he,wt),qt=new GV(he,wt,e,nt),Lt=new EH(he,wt),qt.reverseDepthBuffer&&x&&Lt.buffers.depth.setReversed(!0),hn=new QV(he),ut=new AH,fe=new CH(he,wt,Lt,ut,qt,nt,hn),k=new VV(I),_e=new WV(I),Be=new iG(he),At=new kV(he,Be),Oe=new XV(he,Be,hn,At),je=new ZV(he,Oe,Be,hn),$t=new KV(he,qt,fe),mt=new qV(ut),Bt=new dH(I,k,_e,wt,qt,At,mt),yt=new OH(I,ut),Xt=new mH,ln=new bH(wt),Yt=new FV(I,k,_e,Lt,je,S,u),Wt=new wH(I,je,qt),ce=new IH(he,hn,qt,Lt),It=new zV(he,wt,hn),Te=new YV(he,wt,hn),hn.programs=Bt.programs,I.capabilities=qt,I.extensions=wt,I.properties=ut,I.renderLists=Xt,I.shadowMap=Wt,I.state=Lt,I.info=hn}xt();const Ze=new UH(I,he);this.xr=Ze,this.getContext=function(){return he},this.getContextAttributes=function(){return he.getContextAttributes()},this.forceContextLoss=function(){const ue=wt.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=wt.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return Ae},this.setPixelRatio=function(ue){ue!==void 0&&(Ae=ue,this.setSize(K,ae,!1))},this.getSize=function(ue){return ue.set(K,ae)},this.setSize=function(ue,Fe,tt=!0){if(Ze.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=ue,ae=Fe,t.width=Math.floor(ue*Ae),t.height=Math.floor(Fe*Ae),tt===!0&&(t.style.width=ue+"px",t.style.height=Fe+"px"),this.setViewport(0,0,ue,Fe)},this.getDrawingBufferSize=function(ue){return ue.set(K*Ae,ae*Ae).floor()},this.setDrawingBufferSize=function(ue,Fe,tt){K=ue,ae=Fe,Ae=tt,t.width=Math.floor(ue*tt),t.height=Math.floor(Fe*tt),this.setViewport(0,0,ue,Fe)},this.getCurrentViewport=function(ue){return ue.copy(Y)},this.getViewport=function(ue){return ue.copy(se)},this.setViewport=function(ue,Fe,tt,Ke){ue.isVector4?se.set(ue.x,ue.y,ue.z,ue.w):se.set(ue,Fe,tt,Ke),Lt.viewport(Y.copy(se).multiplyScalar(Ae).round())},this.getScissor=function(ue){return ue.copy(Ee)},this.setScissor=function(ue,Fe,tt,Ke){ue.isVector4?Ee.set(ue.x,ue.y,ue.z,ue.w):Ee.set(ue,Fe,tt,Ke),Lt.scissor(te.copy(Ee).multiplyScalar(Ae).round())},this.getScissorTest=function(){return qe},this.setScissorTest=function(ue){Lt.setScissorTest(qe=ue)},this.setOpaqueSort=function(ue){be=ue},this.setTransparentSort=function(ue){Se=ue},this.getClearColor=function(ue){return ue.copy(Yt.getClearColor())},this.setClearColor=function(){Yt.setClearColor.apply(Yt,arguments)},this.getClearAlpha=function(){return Yt.getClearAlpha()},this.setClearAlpha=function(){Yt.setClearAlpha.apply(Yt,arguments)},this.clear=function(ue=!0,Fe=!0,tt=!0){let Ke=0;if(ue){let ze=!1;if(W!==null){const Qt=W.texture.format;ze=Qt===Y0||Qt===X0||Qt===$0}if(ze){const Qt=W.texture.type,tn=Qt===Aa||Qt===Ir||Qt===Bl||Qt===xu||Qt===dy||Qt===Ay,Mt=Yt.getClearColor(),ee=Yt.getClearAlpha(),Vt=Mt.r,Fn=Mt.g,Tn=Mt.b;tn?(w[0]=Vt,w[1]=Fn,w[2]=Tn,w[3]=ee,he.clearBufferuiv(he.COLOR,0,w)):(N[0]=Vt,N[1]=Fn,N[2]=Tn,N[3]=ee,he.clearBufferiv(he.COLOR,0,N))}else Ke|=he.COLOR_BUFFER_BIT}Fe&&(Ke|=he.DEPTH_BUFFER_BIT),tt&&(Ke|=he.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),he.clear(Ke)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",lt,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",Kt,!1),Yt.dispose(),Xt.dispose(),ln.dispose(),ut.dispose(),k.dispose(),_e.dispose(),je.dispose(),At.dispose(),ce.dispose(),Bt.dispose(),Ze.dispose(),Ze.removeEventListener("sessionstart",Pe),Ze.removeEventListener("sessionend",at),ht.stop()};function lt(ue){ue.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),j=!0}function bt(){console.log("THREE.WebGLRenderer: Context Restored."),j=!1;const ue=hn.autoReset,Fe=Wt.enabled,tt=Wt.autoUpdate,Ke=Wt.needsUpdate,ze=Wt.type;xt(),hn.autoReset=ue,Wt.enabled=Fe,Wt.autoUpdate=tt,Wt.needsUpdate=Ke,Wt.type=ze}function Kt(ue){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function un(ue){const Fe=ue.target;Fe.removeEventListener("dispose",un),Ye(Fe)}function Ye(ue){St(ue),ut.remove(ue)}function St(ue){const Fe=ut.get(ue).programs;Fe!==void 0&&(Fe.forEach(function(tt){Bt.releaseProgram(tt)}),ue.isShaderMaterial&&Bt.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,Fe,tt,Ke,ze,Qt){Fe===null&&(Fe=Tt);const tn=ze.isMesh&&ze.matrixWorld.determinant()<0,Mt=zr(ue,Fe,tt,Ke,ze);Lt.setMaterial(Ke,tn);let ee=tt.index,Vt=1;if(Ke.wireframe===!0){if(ee=Oe.getWireframeAttribute(tt),ee===void 0)return;Vt=2}const Fn=tt.drawRange,Tn=tt.attributes.position;let oi=Fn.start*Vt,Ai=(Fn.start+Fn.count)*Vt;Qt!==null&&(oi=Math.max(oi,Qt.start*Vt),Ai=Math.min(Ai,(Qt.start+Qt.count)*Vt)),ee!==null?(oi=Math.max(oi,0),Ai=Math.min(Ai,ee.count)):Tn!=null&&(oi=Math.max(oi,0),Ai=Math.min(Ai,Tn.count));const Ii=Ai-oi;if(Ii<0||Ii===1/0)return;At.setup(ze,Ke,Mt,tt,ee);let Z,Vn=It;if(ee!==null&&(Z=Be.get(ee),Vn=Te,Vn.setIndex(Z)),ze.isMesh)Ke.wireframe===!0?(Lt.setLineWidth(Ke.wireframeLinewidth*dt()),Vn.setMode(he.LINES)):Vn.setMode(he.TRIANGLES);else if(ze.isLine){let bn=Ke.linewidth;bn===void 0&&(bn=1),Lt.setLineWidth(bn*dt()),ze.isLineSegments?Vn.setMode(he.LINES):ze.isLineLoop?Vn.setMode(he.LINE_LOOP):Vn.setMode(he.LINE_STRIP)}else ze.isPoints?Vn.setMode(he.POINTS):ze.isSprite&&Vn.setMode(he.TRIANGLES);if(ze.isBatchedMesh)if(ze._multiDrawInstances!==null)Vn.renderMultiDrawInstances(ze._multiDrawStarts,ze._multiDrawCounts,ze._multiDrawCount,ze._multiDrawInstances);else if(wt.get("WEBGL_multi_draw"))Vn.renderMultiDraw(ze._multiDrawStarts,ze._multiDrawCounts,ze._multiDrawCount);else{const bn=ze._multiDrawStarts,Mr=ze._multiDrawCounts,pi=ze._multiDrawCount,Ds=ee?Be.get(ee).bytesPerElement:1,Gr=ut.get(Ke).currentProgram.getUniforms();for(let qr=0;qr{function Qt(){if(Ke.forEach(function(tn){ut.get(tn).currentProgram.isReady()&&Ke.delete(tn)}),Ke.size===0){ze(ue);return}setTimeout(Qt,10)}wt.get("KHR_parallel_shader_compile")!==null?Qt():setTimeout(Qt,10)})};let pt=null;function Zt(ue){pt&&pt(ue)}function Pe(){ht.stop()}function at(){ht.start()}const ht=new fD;ht.setAnimationLoop(Zt),typeof self<"u"&&ht.setContext(self),this.setAnimationLoop=function(ue){pt=ue,Ze.setAnimationLoop(ue),ue===null?ht.stop():ht.start()},Ze.addEventListener("sessionstart",Pe),Ze.addEventListener("sessionend",at),this.render=function(ue,Fe){if(Fe!==void 0&&Fe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(j===!0)return;if(ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),Fe.parent===null&&Fe.matrixWorldAutoUpdate===!0&&Fe.updateMatrixWorld(),Ze.enabled===!0&&Ze.isPresenting===!0&&(Ze.cameraAutoUpdate===!0&&Ze.updateCamera(Fe),Fe=Ze.getCamera()),ue.isScene===!0&&ue.onBeforeRender(I,ue,Fe,W),E=ln.get(ue,U.length),E.init(Fe),U.push(E),Pt.multiplyMatrices(Fe.projectionMatrix,Fe.matrixWorldInverse),Ce.setFromProjectionMatrix(Pt),Qe=this.localClippingEnabled,ke=mt.init(this.clippingPlanes,Qe),C=Xt.get(ue,O.length),C.init(),O.push(C),Ze.enabled===!0&&Ze.isPresenting===!0){const Qt=I.xr.getDepthSensingMesh();Qt!==null&&ot(Qt,Fe,-1/0,I.sortObjects)}ot(ue,Fe,0,I.sortObjects),C.finish(),I.sortObjects===!0&&C.sort(be,Se),Ge=Ze.enabled===!1||Ze.isPresenting===!1||Ze.hasDepthSensing()===!1,Ge&&Yt.addToRenderList(C,ue),this.info.render.frame++,ke===!0&&mt.beginShadows();const tt=E.state.shadowsArray;Wt.render(tt,ue,Fe),ke===!0&&mt.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ke=C.opaque,ze=C.transmissive;if(E.setupLights(),Fe.isArrayCamera){const Qt=Fe.cameras;if(ze.length>0)for(let tn=0,Mt=Qt.length;tn0&&J(Ke,ze,ue,Fe),Ge&&Yt.render(ue),f(C,ue,Fe);W!==null&&G===0&&(fe.updateMultisampleRenderTarget(W),fe.updateRenderTargetMipmap(W)),ue.isScene===!0&&ue.onAfterRender(I,ue,Fe),At.resetDefaultState(),q=-1,V=null,U.pop(),U.length>0?(E=U[U.length-1],ke===!0&&mt.setGlobalState(I.clippingPlanes,E.state.camera)):E=null,O.pop(),O.length>0?C=O[O.length-1]:C=null};function ot(ue,Fe,tt,Ke){if(ue.visible===!1)return;if(ue.layers.test(Fe.layers)){if(ue.isGroup)tt=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(Fe);else if(ue.isLight)E.pushLight(ue),ue.castShadow&&E.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||Ce.intersectsSprite(ue)){Ke&&Gt.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(Pt);const tn=je.update(ue),Mt=ue.material;Mt.visible&&C.push(ue,tn,Mt,tt,Gt.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||Ce.intersectsObject(ue))){const tn=je.update(ue),Mt=ue.material;if(Ke&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),Gt.copy(ue.boundingSphere.center)):(tn.boundingSphere===null&&tn.computeBoundingSphere(),Gt.copy(tn.boundingSphere.center)),Gt.applyMatrix4(ue.matrixWorld).applyMatrix4(Pt)),Array.isArray(Mt)){const ee=tn.groups;for(let Vt=0,Fn=ee.length;Vt0&&_n(ze,Fe,tt),Qt.length>0&&_n(Qt,Fe,tt),tn.length>0&&_n(tn,Fe,tt),Lt.buffers.depth.setTest(!0),Lt.buffers.depth.setMask(!0),Lt.buffers.color.setMask(!0),Lt.setPolygonOffset(!1)}function J(ue,Fe,tt,Ke){if((tt.isScene===!0?tt.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[Ke.id]===void 0&&(E.state.transmissionRenderTarget[Ke.id]=new Xh(1,1,{generateMipmaps:!0,type:wt.has("EXT_color_buffer_half_float")||wt.has("EXT_color_buffer_float")?Qs:Aa,minFilter:Ya,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:hi.workingColorSpace}));const Qt=E.state.transmissionRenderTarget[Ke.id],tn=Ke.viewport||Y;Qt.setSize(tn.z*I.transmissionResolutionScale,tn.w*I.transmissionResolutionScale);const Mt=I.getRenderTarget();I.setRenderTarget(Qt),I.getClearColor(le),Q=I.getClearAlpha(),Q<1&&I.setClearColor(16777215,.5),I.clear(),Ge&&Yt.render(tt);const ee=I.toneMapping;I.toneMapping=ro;const Vt=Ke.viewport;if(Ke.viewport!==void 0&&(Ke.viewport=void 0),E.setupLightsView(Ke),ke===!0&&mt.setGlobalState(I.clippingPlanes,Ke),_n(ue,tt,Ke),fe.updateMultisampleRenderTarget(Qt),fe.updateRenderTargetMipmap(Qt),wt.has("WEBGL_multisampled_render_to_texture")===!1){let Fn=!1;for(let Tn=0,oi=Fe.length;Tn0),Tn=!!tt.morphAttributes.position,oi=!!tt.morphAttributes.normal,Ai=!!tt.morphAttributes.color;let Ii=ro;Ke.toneMapped&&(W===null||W.isXRRenderTarget===!0)&&(Ii=I.toneMapping);const Z=tt.morphAttributes.position||tt.morphAttributes.normal||tt.morphAttributes.color,Vn=Z!==void 0?Z.length:0,bn=ut.get(Ke),Mr=E.state.lights;if(ke===!0&&(Qe===!0||ue!==V)){const pr=ue===V&&Ke.id===q;mt.setState(Ke,ue,pr)}let pi=!1;Ke.version===bn.__version?(bn.needsLights&&bn.lightsStateVersion!==Mr.state.version||bn.outputColorSpace!==Mt||ze.isBatchedMesh&&bn.batching===!1||!ze.isBatchedMesh&&bn.batching===!0||ze.isBatchedMesh&&bn.batchingColor===!0&&ze.colorTexture===null||ze.isBatchedMesh&&bn.batchingColor===!1&&ze.colorTexture!==null||ze.isInstancedMesh&&bn.instancing===!1||!ze.isInstancedMesh&&bn.instancing===!0||ze.isSkinnedMesh&&bn.skinning===!1||!ze.isSkinnedMesh&&bn.skinning===!0||ze.isInstancedMesh&&bn.instancingColor===!0&&ze.instanceColor===null||ze.isInstancedMesh&&bn.instancingColor===!1&&ze.instanceColor!==null||ze.isInstancedMesh&&bn.instancingMorph===!0&&ze.morphTexture===null||ze.isInstancedMesh&&bn.instancingMorph===!1&&ze.morphTexture!==null||bn.envMap!==ee||Ke.fog===!0&&bn.fog!==Qt||bn.numClippingPlanes!==void 0&&(bn.numClippingPlanes!==mt.numPlanes||bn.numIntersection!==mt.numIntersection)||bn.vertexAlphas!==Vt||bn.vertexTangents!==Fn||bn.morphTargets!==Tn||bn.morphNormals!==oi||bn.morphColors!==Ai||bn.toneMapping!==Ii||bn.morphTargetsCount!==Vn)&&(pi=!0):(pi=!0,bn.__version=Ke.version);let Ds=bn.currentProgram;pi===!0&&(Ds=zn(Ke,Fe,ze));let Gr=!1,qr=!1,Er=!1;const Ni=Ds.getUniforms(),Yi=bn.uniforms;if(Lt.useProgram(Ds.program)&&(Gr=!0,qr=!0,Er=!0),Ke.id!==q&&(q=Ke.id,qr=!0),Gr||V!==ue){Lt.buffers.depth.getReversed()?(et.copy(ue.projectionMatrix),Nk(et),Rk(et),Ni.setValue(he,"projectionMatrix",et)):Ni.setValue(he,"projectionMatrix",ue.projectionMatrix),Ni.setValue(he,"viewMatrix",ue.matrixWorldInverse);const Vr=Ni.map.cameraPosition;Vr!==void 0&&Vr.setValue(he,Nt.setFromMatrixPosition(ue.matrixWorld)),qt.logarithmicDepthBuffer&&Ni.setValue(he,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(Ke.isMeshPhongMaterial||Ke.isMeshToonMaterial||Ke.isMeshLambertMaterial||Ke.isMeshBasicMaterial||Ke.isMeshStandardMaterial||Ke.isShaderMaterial)&&Ni.setValue(he,"isOrthographic",ue.isOrthographicCamera===!0),V!==ue&&(V=ue,qr=!0,Er=!0)}if(ze.isSkinnedMesh){Ni.setOptional(he,ze,"bindMatrix"),Ni.setOptional(he,ze,"bindMatrixInverse");const pr=ze.skeleton;pr&&(pr.boneTexture===null&&pr.computeBoneTexture(),Ni.setValue(he,"boneTexture",pr.boneTexture,fe))}ze.isBatchedMesh&&(Ni.setOptional(he,ze,"batchingTexture"),Ni.setValue(he,"batchingTexture",ze._matricesTexture,fe),Ni.setOptional(he,ze,"batchingIdTexture"),Ni.setValue(he,"batchingIdTexture",ze._indirectTexture,fe),Ni.setOptional(he,ze,"batchingColorTexture"),ze._colorsTexture!==null&&Ni.setValue(he,"batchingColorTexture",ze._colorsTexture,fe));const _i=tt.morphAttributes;if((_i.position!==void 0||_i.normal!==void 0||_i.color!==void 0)&&$t.update(ze,tt,Ds),(qr||bn.receiveShadow!==ze.receiveShadow)&&(bn.receiveShadow=ze.receiveShadow,Ni.setValue(he,"receiveShadow",ze.receiveShadow)),Ke.isMeshGouraudMaterial&&Ke.envMap!==null&&(Yi.envMap.value=ee,Yi.flipEnvMap.value=ee.isCubeTexture&&ee.isRenderTargetTexture===!1?-1:1),Ke.isMeshStandardMaterial&&Ke.envMap===null&&Fe.environment!==null&&(Yi.envMapIntensity.value=Fe.environmentIntensity),qr&&(Ni.setValue(he,"toneMappingExposure",I.toneMappingExposure),bn.needsLights&&on(Yi,Er),Qt&&Ke.fog===!0&&yt.refreshFogUniforms(Yi,Qt),yt.refreshMaterialUniforms(Yi,Ke,Ae,ae,E.state.transmissionRenderTarget[ue.id]),qv.upload(he,An(bn),Yi,fe)),Ke.isShaderMaterial&&Ke.uniformsNeedUpdate===!0&&(qv.upload(he,An(bn),Yi,fe),Ke.uniformsNeedUpdate=!1),Ke.isSpriteMaterial&&Ni.setValue(he,"center",ze.center),Ni.setValue(he,"modelViewMatrix",ze.modelViewMatrix),Ni.setValue(he,"normalMatrix",ze.normalMatrix),Ni.setValue(he,"modelMatrix",ze.matrixWorld),Ke.isShaderMaterial||Ke.isRawShaderMaterial){const pr=Ke.uniformsGroups;for(let Vr=0,hl=pr.length;Vr0&&fe.useMultisampledRTT(ue)===!1?ze=ut.get(ue).__webglMultisampledFramebuffer:Array.isArray(Fn)?ze=Fn[tt]:ze=Fn,Y.copy(ue.viewport),te.copy(ue.scissor),ne=ue.scissorTest}else Y.copy(se).multiplyScalar(Ae).floor(),te.copy(Ee).multiplyScalar(Ae).floor(),ne=qe;if(tt!==0&&(ze=Ar),Lt.bindFramebuffer(he.FRAMEBUFFER,ze)&&Ke&&Lt.drawBuffers(ue,ze),Lt.viewport(Y),Lt.scissor(te),Lt.setScissorTest(ne),Qt){const ee=ut.get(ue.texture);he.framebufferTexture2D(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,he.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,ee.__webglTexture,tt)}else if(tn){const ee=ut.get(ue.texture),Vt=Fe;he.framebufferTextureLayer(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,ee.__webglTexture,tt,Vt)}else if(ue!==null&&tt!==0){const ee=ut.get(ue.texture);he.framebufferTexture2D(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,he.TEXTURE_2D,ee.__webglTexture,tt)}q=-1},this.readRenderTargetPixels=function(ue,Fe,tt,Ke,ze,Qt,tn){if(!(ue&&ue.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Mt=ut.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&tn!==void 0&&(Mt=Mt[tn]),Mt){Lt.bindFramebuffer(he.FRAMEBUFFER,Mt);try{const ee=ue.texture,Vt=ee.format,Fn=ee.type;if(!qt.textureFormatReadable(Vt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!qt.textureTypeReadable(Fn)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Fe>=0&&Fe<=ue.width-Ke&&tt>=0&&tt<=ue.height-ze&&he.readPixels(Fe,tt,Ke,ze,nt.convert(Vt),nt.convert(Fn),Qt)}finally{const ee=W!==null?ut.get(W).__webglFramebuffer:null;Lt.bindFramebuffer(he.FRAMEBUFFER,ee)}}},this.readRenderTargetPixelsAsync=async function(ue,Fe,tt,Ke,ze,Qt,tn){if(!(ue&&ue.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Mt=ut.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&tn!==void 0&&(Mt=Mt[tn]),Mt){const ee=ue.texture,Vt=ee.format,Fn=ee.type;if(!qt.textureFormatReadable(Vt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qt.textureTypeReadable(Fn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(Fe>=0&&Fe<=ue.width-Ke&&tt>=0&&tt<=ue.height-ze){Lt.bindFramebuffer(he.FRAMEBUFFER,Mt);const Tn=he.createBuffer();he.bindBuffer(he.PIXEL_PACK_BUFFER,Tn),he.bufferData(he.PIXEL_PACK_BUFFER,Qt.byteLength,he.STREAM_READ),he.readPixels(Fe,tt,Ke,ze,nt.convert(Vt),nt.convert(Fn),0);const oi=W!==null?ut.get(W).__webglFramebuffer:null;Lt.bindFramebuffer(he.FRAMEBUFFER,oi);const Ai=he.fenceSync(he.SYNC_GPU_COMMANDS_COMPLETE,0);return he.flush(),await Ck(he,Ai,4),he.bindBuffer(he.PIXEL_PACK_BUFFER,Tn),he.getBufferSubData(he.PIXEL_PACK_BUFFER,0,Qt),he.deleteBuffer(Tn),he.deleteSync(Ai),Qt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(ue,Fe=null,tt=0){ue.isTexture!==!0&&(qf("WebGLRenderer: copyFramebufferToTexture function signature has changed."),Fe=arguments[0]||null,ue=arguments[1]);const Ke=Math.pow(2,-tt),ze=Math.floor(ue.image.width*Ke),Qt=Math.floor(ue.image.height*Ke),tn=Fe!==null?Fe.x:0,Mt=Fe!==null?Fe.y:0;fe.setTexture2D(ue,0),he.copyTexSubImage2D(he.TEXTURE_2D,tt,0,0,tn,Mt,ze,Qt),Lt.unbindTexture()};const ji=he.createFramebuffer(),Ao=he.createFramebuffer();this.copyTextureToTexture=function(ue,Fe,tt=null,Ke=null,ze=0,Qt=null){ue.isTexture!==!0&&(qf("WebGLRenderer: copyTextureToTexture function signature has changed."),Ke=arguments[0]||null,ue=arguments[1],Fe=arguments[2],Qt=arguments[3]||0,tt=null),Qt===null&&(ze!==0?(qf("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Qt=ze,ze=0):Qt=0);let tn,Mt,ee,Vt,Fn,Tn,oi,Ai,Ii;const Z=ue.isCompressedTexture?ue.mipmaps[Qt]:ue.image;if(tt!==null)tn=tt.max.x-tt.min.x,Mt=tt.max.y-tt.min.y,ee=tt.isBox3?tt.max.z-tt.min.z:1,Vt=tt.min.x,Fn=tt.min.y,Tn=tt.isBox3?tt.min.z:0;else{const _i=Math.pow(2,-ze);tn=Math.floor(Z.width*_i),Mt=Math.floor(Z.height*_i),ue.isDataArrayTexture?ee=Z.depth:ue.isData3DTexture?ee=Math.floor(Z.depth*_i):ee=1,Vt=0,Fn=0,Tn=0}Ke!==null?(oi=Ke.x,Ai=Ke.y,Ii=Ke.z):(oi=0,Ai=0,Ii=0);const Vn=nt.convert(Fe.format),bn=nt.convert(Fe.type);let Mr;Fe.isData3DTexture?(fe.setTexture3D(Fe,0),Mr=he.TEXTURE_3D):Fe.isDataArrayTexture||Fe.isCompressedArrayTexture?(fe.setTexture2DArray(Fe,0),Mr=he.TEXTURE_2D_ARRAY):(fe.setTexture2D(Fe,0),Mr=he.TEXTURE_2D),he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,Fe.flipY),he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Fe.premultiplyAlpha),he.pixelStorei(he.UNPACK_ALIGNMENT,Fe.unpackAlignment);const pi=he.getParameter(he.UNPACK_ROW_LENGTH),Ds=he.getParameter(he.UNPACK_IMAGE_HEIGHT),Gr=he.getParameter(he.UNPACK_SKIP_PIXELS),qr=he.getParameter(he.UNPACK_SKIP_ROWS),Er=he.getParameter(he.UNPACK_SKIP_IMAGES);he.pixelStorei(he.UNPACK_ROW_LENGTH,Z.width),he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,Z.height),he.pixelStorei(he.UNPACK_SKIP_PIXELS,Vt),he.pixelStorei(he.UNPACK_SKIP_ROWS,Fn),he.pixelStorei(he.UNPACK_SKIP_IMAGES,Tn);const Ni=ue.isDataArrayTexture||ue.isData3DTexture,Yi=Fe.isDataArrayTexture||Fe.isData3DTexture;if(ue.isDepthTexture){const _i=ut.get(ue),pr=ut.get(Fe),Vr=ut.get(_i.__renderTarget),hl=ut.get(pr.__renderTarget);Lt.bindFramebuffer(he.READ_FRAMEBUFFER,Vr.__webglFramebuffer),Lt.bindFramebuffer(he.DRAW_FRAMEBUFFER,hl.__webglFramebuffer);for(let ts=0;ts=-1&&bA.z<=1&&w.layers.test(C.layers)===!0,O=w.element;O.style.display=E===!0?"":"none",E===!0&&(w.onBeforeRender(t,N,C),O.style.transform="translate("+-100*w.center.x+"%,"+-100*w.center.y+"%)translate("+(bA.x*s+s)+"px,"+(-bA.y*a+a)+"px)",O.parentNode!==u&&u.appendChild(O),w.onAfterRender(t,N,C));const U={distanceToCameraSquared:v(C,w)};l.objects.set(w,U)}for(let E=0,O=w.children.length;E=e||G<0||v&&W>=s}function E(){var z=P3();if(C(z))return O(z);l=setTimeout(E,N(z))}function O(z){return l=void 0,x&&n?S(z):(n=r=void 0,a)}function U(){l!==void 0&&clearTimeout(l),h=0,n=u=r=l=void 0}function I(){return l===void 0?a:O(P3())}function j(){var z=P3(),G=C(z);if(n=arguments,r=this,u=z,G){if(l===void 0)return w(u);if(v)return clearTimeout(l),l=setTimeout(E,e),S(u)}return l===void 0&&(l=setTimeout(E,e)),a}return j.cancel=U,j.flush=I,j}function h5(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),bm=function(){return performance.now()},My=(function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=bm()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(i[t],i[t-1],t-n):s(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},_D=(function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i})(),iT=new My,va=(function(){function i(e,t){t===void 0&&(t=iT),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=vs.Linear.None,this._interpolationFunction=nT.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=_D.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=bm()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,s){for(var a in n){var l=e[a],u=Array.isArray(l),h=u?"array":typeof l,m=!u&&Array.isArray(n[a]);if(!(h==="undefined"||h==="function")){if(m){var v=n[a];if(v.length===0)continue;for(var x=[l],S=0,w=v.length;S"u"||s)&&(t[a]=l),u||(t[a]*=1),m?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=bm()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=bm()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;ea)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,eh)return 1;var C=Math.trunc(l/u),E=l-C*u,O=Math.min(E/n._duration,1);return O===0&&l===n._duration?1:O},v=m(),x=this._easingFunction(v);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,x),this._onUpdateCallback&&this._onUpdateCallback(this._object,v),this._duration===0||l>=this._duration)if(this._repeat>0){var S=Math.min(Math.trunc((l-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=S);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*S,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var w=0,N=this._chainedTweens.length;w=(w=(u+v)/2))?u=w:v=w,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C,s=a,!(a=a[G=z<<2|j<<1|I]))return s[G]=l,i;if(E=+i._x.call(null,a.data),O=+i._y.call(null,a.data),U=+i._z.call(null,a.data),e===E&&t===O&&n===U)return l.next=a,s?s[G]=l:i._root=l,i;do s=s?s[G]=new Array(8):i._root=new Array(8),(I=e>=(w=(u+v)/2))?u=w:v=w,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C;while((G=z<<2|j<<1|I)===(W=(U>=C)<<2|(O>=N)<<1|E>=w));return s[W]=a,s[G]=l,i}function bW(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),n=new Float64Array(e),r=new Float64Array(e);let s=1/0,a=1/0,l=1/0,u=-1/0,h=-1/0,m=-1/0;for(let v=0,x,S,w,N;vu&&(u=S),wh&&(h=w),Nm&&(m=N));if(s>u||a>h||l>m)return this;this.cover(s,a,l).cover(u,h,m);for(let v=0;vi||i>=a||r>e||e>=l||s>t||t>=u;)switch(x=(tw||(h=U.y0)>N||(m=U.z0)>C||(v=U.x1)=G)<<2|(e>=z)<<1|i>=j)&&(U=E[E.length-1],E[E.length-1]=E[E.length-1-I],E[E.length-1-I]=U)}else{var W=i-+this._x.call(null,O.data),q=e-+this._y.call(null,O.data),V=t-+this._z.call(null,O.data),Y=W*W+q*q+V*V;if(YMath.sqrt((i-n)**2+(e-r)**2+(t-s)**2);function CW(i,e,t,n){const r=[],s=i-n,a=e-n,l=t-n,u=i+n,h=e+n,m=t+n;return this.visit((v,x,S,w,N,C,E)=>{if(!v.length)do{const O=v.data;EW(i,e,t,this._x(O),this._y(O),this._z(O))<=n&&r.push(O)}while(v=v.next);return x>u||S>h||w>m||N=(N=(a+h)/2))?a=N:h=N,(U=S>=(C=(l+m)/2))?l=C:m=C,(I=w>=(E=(u+v)/2))?u=E:v=E,e=t,!(t=t[j=I<<2|U<<1|O]))return this;if(!t.length)break;(e[j+1&7]||e[j+2&7]||e[j+3&7]||e[j+4&7]||e[j+5&7]||e[j+6&7]||e[j+7&7])&&(n=e,z=j)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[j]=s:delete e[j],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[z]=t:this._root=t),this):(this._root=s,this)}function RW(i){for(var e=0,t=i.length;ee?1:i>=e?0:NaN}function GW(i,e){return i==null||e==null?NaN:ei?1:e>=i?0:NaN}function bD(i){let e,t,n;i.length!==2?(e=Vv,t=(l,u)=>Vv(i(l),u),n=(l,u)=>i(l)-u):(e=i===Vv||i===GW?i:qW,t=i,n=i);function r(l,u,h=0,m=l.length){if(h>>1;t(l[v],u)<0?h=v+1:m=v}while(h>>1;t(l[v],u)<=0?h=v+1:m=v}while(hh&&n(l[v-1],u)>-n(l[v],u)?v-1:v}return{left:r,center:a,right:s}}function qW(){return 0}function VW(i){return i===null?NaN:+i}const jW=bD(Vv),SD=jW.right;bD(VW).center;function d_(i,e){let t,n;if(e===void 0)for(const r of i)r!=null&&(t===void 0?r>=r&&(t=n=r):(t>r&&(t=r),n=s&&(t=n=s):(t>s&&(t=s),n0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,s=r-(a-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(r=s*2,n=a+r,r==n-a&&(a=n))}return a}}const HW=Math.sqrt(50),WW=Math.sqrt(10),$W=Math.sqrt(2);function A_(i,e,t){const n=(e-i)/Math.max(0,t),r=Math.floor(Math.log10(n)),s=n/Math.pow(10,r),a=s>=HW?10:s>=WW?5:s>=$W?2:1;let l,u,h;return r<0?(h=Math.pow(10,-r)/a,l=Math.round(i*h),u=Math.round(e*h),l/he&&--u,h=-h):(h=Math.pow(10,r)*a,l=Math.round(i/h),u=Math.round(e/h),l*he&&--u),u0))return[];if(i===e)return[i];const n=e=r))return[];const l=s-r+1,u=new Array(l);if(n)if(a<0)for(let h=0;h=n)&&(t=n);return t}function KW(i,e){let t=0,n=0;if(e===void 0)for(let r of i)r!=null&&(r=+r)>=r&&(++t,n+=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*ZW(i){for(const e of i)yield*e}function hg(i){return Array.from(ZW(i))}function XA(i,e,t){i=+i,e=+e,t=(r=arguments.length)<2?(e=i,i=0,1):r<3?1:+t;for(var n=-1,r=Math.max(0,Math.ceil((e-i)/t))|0,s=new Array(r);++n>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?Y2(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?Y2(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=t$.exec(i))?new Za(e[1],e[2],e[3],1):(e=n$.exec(i))?new Za(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=i$.exec(i))?Y2(e[1],e[2],e[3],e[4]):(e=r$.exec(i))?Y2(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=s$.exec(i))?_5(e[1],e[2]/100,e[3]/100,1):(e=a$.exec(i))?_5(e[1],e[2]/100,e[3]/100,e[4]):d5.hasOwnProperty(i)?m5(d5[i]):i==="transparent"?new Za(NaN,NaN,NaN,0):null}function m5(i){return new Za(i>>16&255,i>>8&255,i&255,1)}function Y2(i,e,t,n){return n<=0&&(i=e=t=NaN),new Za(i,e,t,n)}function u$(i){return i instanceof qg||(i=dd(i)),i?(i=i.rgb(),new Za(i.r,i.g,i.b,i.opacity)):new Za}function sT(i,e,t,n){return arguments.length===1?u$(i):new Za(i,e,t,n??1)}function Za(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}hM(Za,sT,wD(qg,{brighter(i){return i=i==null?p_:Math.pow(p_,i),new Za(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?fg:Math.pow(fg,i),new Za(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new Za(id(this.r),id(this.g),id(this.b),m_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:g5,formatHex:g5,formatHex8:c$,formatRgb:v5,toString:v5}));function g5(){return`#${Yf(this.r)}${Yf(this.g)}${Yf(this.b)}`}function c$(){return`#${Yf(this.r)}${Yf(this.g)}${Yf(this.b)}${Yf((isNaN(this.opacity)?1:this.opacity)*255)}`}function v5(){const i=m_(this.opacity);return`${i===1?"rgb(":"rgba("}${id(this.r)}, ${id(this.g)}, ${id(this.b)}${i===1?")":`, ${i})`}`}function m_(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function id(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function Yf(i){return i=id(i),(i<16?"0":"")+i.toString(16)}function _5(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new Ul(i,e,t,n)}function MD(i){if(i instanceof Ul)return new Ul(i.h,i.s,i.l,i.opacity);if(i instanceof qg||(i=dd(i)),!i)return new Ul;if(i instanceof Ul)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,r=Math.min(e,t,n),s=Math.max(e,t,n),a=NaN,l=s-r,u=(s+r)/2;return l?(e===s?a=(t-n)/l+(t0&&u<1?0:a,new Ul(a,l,u,i.opacity)}function h$(i,e,t,n){return arguments.length===1?MD(i):new Ul(i,e,t,n??1)}function Ul(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}hM(Ul,h$,wD(qg,{brighter(i){return i=i==null?p_:Math.pow(p_,i),new Ul(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?fg:Math.pow(fg,i),new Ul(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,r=2*t-n;return new Za(L3(i>=240?i-240:i+120,r,n),L3(i,r,n),L3(i<120?i+240:i-120,r,n),this.opacity)},clamp(){return new Ul(y5(this.h),Q2(this.s),Q2(this.l),m_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=m_(this.opacity);return`${i===1?"hsl(":"hsla("}${y5(this.h)}, ${Q2(this.s)*100}%, ${Q2(this.l)*100}%${i===1?")":`, ${i})`}`}}));function y5(i){return i=(i||0)%360,i<0?i+360:i}function Q2(i){return Math.max(0,Math.min(1,i||0))}function L3(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const fM=i=>()=>i;function f$(i,e){return function(t){return i+t*e}}function d$(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function A$(i){return(i=+i)==1?ED:function(e,t){return t-e?d$(e,t,i):fM(isNaN(e)?t:e)}}function ED(i,e){var t=e-i;return t?f$(i,t):fM(isNaN(i)?e:i)}const x5=(function i(e){var t=A$(e);function n(r,s){var a=t((r=sT(r)).r,(s=sT(s)).r),l=t(r.g,s.g),u=t(r.b,s.b),h=ED(r.opacity,s.opacity);return function(m){return r.r=a(m),r.g=l(m),r.b=u(m),r.opacity=h(m),r+""}}return n.gamma=i,n})(1);function CD(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),r;return function(s){for(r=0;rt&&(s=e.slice(t,s),l[a]?l[a]+=s:l[++a]=s),(n=n[0])===(r=r[0])?l[a]?l[a]+=r:l[++a]=r:(l[++a]=null,u.push({i:a,x:Ag(n,r)})),t=U3.lastIndex;return te&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function w$(i,e,t){var n=i[0],r=i[1],s=e[0],a=e[1];return r2?M$:w$,u=h=null,v}function v(x){return x==null||isNaN(x=+x)?s:(u||(u=l(i.map(n),e,t)))(n(a(x)))}return v.invert=function(x){return a(r((h||(h=l(e,i.map(n),Ag)))(x)))},v.domain=function(x){return arguments.length?(i=Array.from(x,S$),m()):i.slice()},v.range=function(x){return arguments.length?(e=Array.from(x),m()):e.slice()},v.rangeRound=function(x){return e=Array.from(x),t=x$,m()},v.clamp=function(x){return arguments.length?(a=x?!0:YA,m()):a!==YA},v.interpolate=function(x){return arguments.length?(t=x,m()):t},v.unknown=function(x){return arguments.length?(s=x,v):s},function(x,S){return n=x,r=S,m()}}function N$(){return C$()(YA,YA)}function R$(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function g_(i,e){if(!isFinite(i)||i===0)return null;var t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"),n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function D0(i){return i=g_(Math.abs(i)),i?i[1]:NaN}function D$(i,e){return function(t,n){for(var r=t.length,s=[],a=0,l=i[0],u=0;r>0&&l>0&&(u+l+1>n&&(l=Math.max(1,n-u)),s.push(t.substring(r-=l,r+l)),!((u+=l+1)>n));)l=i[a=(a+1)%i.length];return s.reverse().join(e)}}function P$(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var L$=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function v_(i){if(!(e=L$.exec(i)))throw new Error("invalid format: "+i);var e;return new AM({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}v_.prototype=AM.prototype;function AM(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}AM.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function U$(i){e:for(var e=i.length,t=1,n=-1,r;t0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(r+1):i}var __;function B$(i,e){var t=g_(i,e);if(!t)return __=void 0,i.toPrecision(e);var n=t[0],r=t[1],s=r-(__=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+g_(i,Math.max(0,e+s-1))[0]}function S5(i,e){var t=g_(i,e);if(!t)return i+"";var n=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}const T5={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:R$,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>S5(i*100,e),r:S5,s:B$,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function w5(i){return i}var M5=Array.prototype.map,E5=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function O$(i){var e=i.grouping===void 0||i.thousands===void 0?w5:D$(M5.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",r=i.decimal===void 0?".":i.decimal+"",s=i.numerals===void 0?w5:P$(M5.call(i.numerals,String)),a=i.percent===void 0?"%":i.percent+"",l=i.minus===void 0?"−":i.minus+"",u=i.nan===void 0?"NaN":i.nan+"";function h(v,x){v=v_(v);var S=v.fill,w=v.align,N=v.sign,C=v.symbol,E=v.zero,O=v.width,U=v.comma,I=v.precision,j=v.trim,z=v.type;z==="n"?(U=!0,z="g"):T5[z]||(I===void 0&&(I=12),j=!0,z="g"),(E||S==="0"&&w==="=")&&(E=!0,S="0",w="=");var G=(x&&x.prefix!==void 0?x.prefix:"")+(C==="$"?t:C==="#"&&/[boxX]/.test(z)?"0"+z.toLowerCase():""),W=(C==="$"?n:/[%p]/.test(z)?a:"")+(x&&x.suffix!==void 0?x.suffix:""),q=T5[z],V=/[defgprs%]/.test(z);I=I===void 0?6:/[gprs]/.test(z)?Math.max(1,Math.min(21,I)):Math.max(0,Math.min(20,I));function Y(te){var ne=G,le=W,Q,K,ae;if(z==="c")le=q(te)+le,te="";else{te=+te;var Ae=te<0||1/te<0;if(te=isNaN(te)?u:q(Math.abs(te),I),j&&(te=U$(te)),Ae&&+te==0&&N!=="+"&&(Ae=!1),ne=(Ae?N==="("?N:l:N==="-"||N==="("?"":N)+ne,le=(z==="s"&&!isNaN(te)&&__!==void 0?E5[8+__/3]:"")+le+(Ae&&N==="("?")":""),V){for(Q=-1,K=te.length;++Qae||ae>57){le=(ae===46?r+te.slice(Q+1):te.slice(Q))+le,te=te.slice(0,Q);break}}}U&&!E&&(te=e(te,1/0));var be=ne.length+te.length+le.length,Se=be>1)+ne+te+le+Se.slice(be);break;default:te=Se+ne+te+le;break}return s(te)}return Y.toString=function(){return v+""},Y}function m(v,x){var S=Math.max(-8,Math.min(8,Math.floor(D0(x)/3)))*3,w=Math.pow(10,-S),N=h((v=v_(v),v.type="f",v),{suffix:E5[8+S/3]});return function(C){return N(w*C)}}return{format:h,formatPrefix:m}}var K2,DD,PD;I$({thousands:",",grouping:[3],currency:["$",""]});function I$(i){return K2=O$(i),DD=K2.format,PD=K2.formatPrefix,K2}function F$(i){return Math.max(0,-D0(Math.abs(i)))}function k$(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(D0(e)/3)))*3-D0(Math.abs(i)))}function z$(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,D0(e)-D0(i))+1}function G$(i,e,t,n){var r=YW(i,e,t),s;switch(n=v_(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(s=k$(r,a))&&(n.precision=s),PD(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=z$(r,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=F$(r))&&(n.precision=s-(n.type==="%")*2);break}}return DD(n)}function LD(i){var e=i.domain;return i.ticks=function(t){var n=e();return XW(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var r=e();return G$(r[0],r[r.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),r=0,s=n.length-1,a=n[r],l=n[s],u,h,m=10;for(l0;){if(h=rT(a,l,t),h===u)return n[r]=a,n[s]=l,e(n);if(h>0)a=Math.floor(a/h)*h,l=Math.ceil(l/h)*h;else if(h<0)a=Math.ceil(a*h)/h,l=Math.floor(l*h)/h;else break;u=h}return i},i}function zc(){var i=N$();return i.copy=function(){return E$(i,zc())},TD.apply(i,arguments),LD(i)}function UD(){var i=0,e=1,t=1,n=[.5],r=[0,1],s;function a(u){return u!=null&&u<=u?r[SD(n,u,0,t)]:s}function l(){var u=-1;for(n=new Array(t);++u=t?[n[t-1],e]:[n[h-1],n[h]]},a.unknown=function(u){return arguments.length&&(s=u),a},a.thresholds=function(){return n.slice()},a.copy=function(){return UD().domain([i,e]).range(r).unknown(s)},TD.apply(LD(a),arguments)}var vi=1e-6,y_=1e-12,Pi=Math.PI,Ja=Pi/2,x_=Pi/4,Fo=Pi*2,Qr=180/Pi,Kn=Pi/180,ar=Math.abs,pM=Math.atan,ol=Math.atan2,ri=Math.cos,Z2=Math.ceil,q$=Math.exp,lT=Math.hypot,V$=Math.log,Yn=Math.sin,j$=Math.sign||function(i){return i>0?1:i<0?-1:0},Gc=Math.sqrt,H$=Math.tan;function W$(i){return i>1?0:i<-1?Pi:Math.acos(i)}function qc(i){return i>1?Ja:i<-1?-Ja:Math.asin(i)}function C5(i){return(i=Yn(i/2))*i}function fa(){}function b_(i,e){i&&R5.hasOwnProperty(i.type)&&R5[i.type](i,e)}var N5={Feature:function(i,e){b_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n=0?1:-1,r=n*t,s=ri(e),a=Yn(e),l=fT*a,u=hT*s+l*ri(r),h=l*n*Yn(r);S_.add(ol(h,u)),cT=i,hT=s,fT=a}function T_(i){return[ol(i[1],i[0]),qc(i[2])]}function Ad(i){var e=i[0],t=i[1],n=ri(t);return[n*ri(e),n*Yn(e),Yn(t)]}function J2(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function P0(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function B3(i,e){i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}function ev(i,e){return[i[0]*e,i[1]*e,i[2]*e]}function w_(i){var e=Gc(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);i[0]/=e,i[1]/=e,i[2]/=e}var Or,Xa,Xr,Lo,kf,FD,kD,a0,Lm,Uh,jc,Ec={point:dT,lineStart:L5,lineEnd:U5,polygonStart:function(){Ec.point=GD,Ec.lineStart=Q$,Ec.lineEnd=K$,Lm=new Bc,Vc.polygonStart()},polygonEnd:function(){Vc.polygonEnd(),Ec.point=dT,Ec.lineStart=L5,Ec.lineEnd=U5,S_<0?(Or=-(Xr=180),Xa=-(Lo=90)):Lm>vi?Lo=90:Lm<-vi&&(Xa=-90),jc[0]=Or,jc[1]=Xr},sphere:function(){Or=-(Xr=180),Xa=-(Lo=90)}};function dT(i,e){Uh.push(jc=[Or=i,Xr=i]),eLo&&(Lo=e)}function zD(i,e){var t=Ad([i*Kn,e*Kn]);if(a0){var n=P0(a0,t),r=[n[1],-n[0],0],s=P0(r,n);w_(s),s=T_(s);var a=i-kf,l=a>0?1:-1,u=s[0]*Qr*l,h,m=ar(a)>180;m^(l*kfLo&&(Lo=h)):(u=(u+360)%360-180,m^(l*kfLo&&(Lo=e))),m?iRo(Or,Xr)&&(Xr=i):Ro(i,Xr)>Ro(Or,Xr)&&(Or=i):Xr>=Or?(iXr&&(Xr=i)):i>kf?Ro(Or,i)>Ro(Or,Xr)&&(Xr=i):Ro(i,Xr)>Ro(Or,Xr)&&(Or=i)}else Uh.push(jc=[Or=i,Xr=i]);eLo&&(Lo=e),a0=t,kf=i}function L5(){Ec.point=zD}function U5(){jc[0]=Or,jc[1]=Xr,Ec.point=dT,a0=null}function GD(i,e){if(a0){var t=i-kf;Lm.add(ar(t)>180?t+(t>0?360:-360):t)}else FD=i,kD=e;Vc.point(i,e),zD(i,e)}function Q$(){Vc.lineStart()}function K$(){GD(FD,kD),Vc.lineEnd(),ar(Lm)>vi&&(Or=-(Xr=180)),jc[0]=Or,jc[1]=Xr,a0=null}function Ro(i,e){return(e-=i)<0?e+360:e}function Z$(i,e){return i[0]-e[0]}function B5(i,e){return i[0]<=i[1]?i[0]<=e&&e<=i[1]:eRo(n[0],n[1])&&(n[1]=r[1]),Ro(r[0],n[1])>Ro(n[0],n[1])&&(n[0]=r[0])):s.push(n=r);for(a=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=r,++e)r=s[e],(l=Ro(n[1],r[0]))>a&&(a=l,Or=r[0],Xr=n[1])}return Uh=jc=null,Or===1/0||Xa===1/0?[[NaN,NaN],[NaN,NaN]]:[[Or,Xa],[Xr,Lo]]}var Sm,M_,E_,C_,N_,R_,D_,P_,AT,pT,mT,VD,jD,Ca,Na,Ra,Ol={sphere:fa,point:mM,lineStart:O5,lineEnd:I5,polygonStart:function(){Ol.lineStart=tX,Ol.lineEnd=nX},polygonEnd:function(){Ol.lineStart=O5,Ol.lineEnd=I5}};function mM(i,e){i*=Kn,e*=Kn;var t=ri(e);Vg(t*ri(i),t*Yn(i),Yn(e))}function Vg(i,e,t){++Sm,E_+=(i-E_)/Sm,C_+=(e-C_)/Sm,N_+=(t-N_)/Sm}function O5(){Ol.point=J$}function J$(i,e){i*=Kn,e*=Kn;var t=ri(e);Ca=t*ri(i),Na=t*Yn(i),Ra=Yn(e),Ol.point=eX,Vg(Ca,Na,Ra)}function eX(i,e){i*=Kn,e*=Kn;var t=ri(e),n=t*ri(i),r=t*Yn(i),s=Yn(e),a=ol(Gc((a=Na*s-Ra*r)*a+(a=Ra*n-Ca*s)*a+(a=Ca*r-Na*n)*a),Ca*n+Na*r+Ra*s);M_+=a,R_+=a*(Ca+(Ca=n)),D_+=a*(Na+(Na=r)),P_+=a*(Ra+(Ra=s)),Vg(Ca,Na,Ra)}function I5(){Ol.point=mM}function tX(){Ol.point=iX}function nX(){HD(VD,jD),Ol.point=mM}function iX(i,e){VD=i,jD=e,i*=Kn,e*=Kn,Ol.point=HD;var t=ri(e);Ca=t*ri(i),Na=t*Yn(i),Ra=Yn(e),Vg(Ca,Na,Ra)}function HD(i,e){i*=Kn,e*=Kn;var t=ri(e),n=t*ri(i),r=t*Yn(i),s=Yn(e),a=Na*s-Ra*r,l=Ra*n-Ca*s,u=Ca*r-Na*n,h=lT(a,l,u),m=qc(h),v=h&&-m/h;AT.add(v*a),pT.add(v*l),mT.add(v*u),M_+=m,R_+=m*(Ca+(Ca=n)),D_+=m*(Na+(Na=r)),P_+=m*(Ra+(Ra=s)),Vg(Ca,Na,Ra)}function F5(i){Sm=M_=E_=C_=N_=R_=D_=P_=0,AT=new Bc,pT=new Bc,mT=new Bc,Ey(i,Ol);var e=+AT,t=+pT,n=+mT,r=lT(e,t,n);return rPi&&(i-=Math.round(i/Fo)*Fo),[i,e]}vT.invert=vT;function WD(i,e,t){return(i%=Fo)?e||t?gT(z5(i),G5(e,t)):z5(i):e||t?G5(e,t):vT}function k5(i){return function(e,t){return e+=i,ar(e)>Pi&&(e-=Math.round(e/Fo)*Fo),[e,t]}}function z5(i){var e=k5(i);return e.invert=k5(-i),e}function G5(i,e){var t=ri(i),n=Yn(i),r=ri(e),s=Yn(e);function a(l,u){var h=ri(u),m=ri(l)*h,v=Yn(l)*h,x=Yn(u),S=x*t+m*n;return[ol(v*r-S*s,m*t-x*n),qc(S*r+v*s)]}return a.invert=function(l,u){var h=ri(u),m=ri(l)*h,v=Yn(l)*h,x=Yn(u),S=x*r-v*s;return[ol(v*r+x*s,m*t+S*n),qc(S*t-m*n)]},a}function rX(i){i=WD(i[0]*Kn,i[1]*Kn,i.length>2?i[2]*Kn:0);function e(t){return t=i(t[0]*Kn,t[1]*Kn),t[0]*=Qr,t[1]*=Qr,t}return e.invert=function(t){return t=i.invert(t[0]*Kn,t[1]*Kn),t[0]*=Qr,t[1]*=Qr,t},e}function sX(i,e,t,n,r,s){if(t){var a=ri(e),l=Yn(e),u=n*t;r==null?(r=e+n*Fo,s=e-u/2):(r=q5(a,r),s=q5(a,s),(n>0?rs)&&(r+=n*Fo));for(var h,m=r;n>0?m>s:m1&&i.push(i.pop().concat(i.shift()))},result:function(){var t=i;return i=[],e=null,t}}}function jv(i,e){return ar(i[0]-e[0])=0;--l)r.point((v=m[l])[0],v[1]);else n(x.x,x.p.x,-1,r);x=x.p}x=x.o,m=x.z,S=!S}while(!x.v);r.lineEnd()}}}function V5(i){if(e=i.length){for(var e,t=0,n=i[0],r;++t=0?1:-1,V=q*W,Y=V>Pi,te=C*z;if(u.add(ol(te*q*Yn(V),E*G+te*ri(V))),a+=Y?W+q*Fo:W,Y^w>=t^I>=t){var ne=P0(Ad(S),Ad(U));w_(ne);var le=P0(s,ne);w_(le);var Q=(Y^W>=0?-1:1)*qc(le[2]);(n>Q||n===Q&&(ne[0]||ne[1]))&&(l+=Y^W>=0?1:-1)}}return(a<-vi||a0){for(u||(r.polygonStart(),u=!0),r.lineStart(),z=0;z1&&I&2&&j.push(j.pop().concat(j.shift())),m.push(j.filter(aX))}}return x}}function aX(i){return i.length>1}function oX(i,e){return((i=i.x)[0]<0?i[1]-Ja-vi:Ja-i[1])-((e=e.x)[0]<0?e[1]-Ja-vi:Ja-e[1])}const j5=QD(function(){return!0},lX,cX,[-Pi,-Ja]);function lX(i){var e=NaN,t=NaN,n=NaN,r;return{lineStart:function(){i.lineStart(),r=1},point:function(s,a){var l=s>0?Pi:-Pi,u=ar(s-e);ar(u-Pi)0?Ja:-Ja),i.point(n,t),i.lineEnd(),i.lineStart(),i.point(l,t),i.point(s,t),r=0):n!==l&&u>=Pi&&(ar(e-n)vi?pM((Yn(e)*(s=ri(n))*Yn(t)-Yn(n)*(r=ri(e))*Yn(i))/(r*s*a)):(e+n)/2}function cX(i,e,t,n){var r;if(i==null)r=t*Ja,n.point(-Pi,r),n.point(0,r),n.point(Pi,r),n.point(Pi,0),n.point(Pi,-r),n.point(0,-r),n.point(-Pi,-r),n.point(-Pi,0),n.point(-Pi,r);else if(ar(i[0]-e[0])>vi){var s=i[0]0,r=ar(e)>vi;function s(m,v,x,S){sX(S,i,t,x,m,v)}function a(m,v){return ri(m)*ri(v)>e}function l(m){var v,x,S,w,N;return{lineStart:function(){w=S=!1,N=1},point:function(C,E){var O=[C,E],U,I=a(C,E),j=n?I?0:h(C,E):I?h(C+(C<0?Pi:-Pi),E):0;if(!v&&(w=S=I)&&m.lineStart(),I!==S&&(U=u(v,O),(!U||jv(v,U)||jv(O,U))&&(O[2]=1)),I!==S)N=0,I?(m.lineStart(),U=u(O,v),m.point(U[0],U[1])):(U=u(v,O),m.point(U[0],U[1],2),m.lineEnd()),v=U;else if(r&&v&&n^I){var z;!(j&x)&&(z=u(O,v,!0))&&(N=0,n?(m.lineStart(),m.point(z[0][0],z[0][1]),m.point(z[1][0],z[1][1]),m.lineEnd()):(m.point(z[1][0],z[1][1]),m.lineEnd(),m.lineStart(),m.point(z[0][0],z[0][1],3)))}I&&(!v||!jv(v,O))&&m.point(O[0],O[1]),v=O,S=I,x=j},lineEnd:function(){S&&m.lineEnd(),v=null},clean:function(){return N|(w&&S)<<1}}}function u(m,v,x){var S=Ad(m),w=Ad(v),N=[1,0,0],C=P0(S,w),E=J2(C,C),O=C[0],U=E-O*O;if(!U)return!x&&m;var I=e*E/U,j=-e*O/U,z=P0(N,C),G=ev(N,I),W=ev(C,j);B3(G,W);var q=z,V=J2(G,q),Y=J2(q,q),te=V*V-Y*(J2(G,G)-1);if(!(te<0)){var ne=Gc(te),le=ev(q,(-V-ne)/Y);if(B3(le,G),le=T_(le),!x)return le;var Q=m[0],K=v[0],ae=m[1],Ae=v[1],be;K0^le[1]<(ar(le[0]-Q)Pi^(Q<=le[0]&&le[0]<=K)){var qe=ev(q,(-V+ne)/Y);return B3(qe,G),[le,T_(qe)]}}}function h(m,v){var x=n?i:Pi-i,S=0;return m<-x?S|=1:m>x&&(S|=2),v<-x?S|=4:v>x&&(S|=8),S}return QD(a,l,s,n?[0,-i]:[-Pi,i-Pi])}function fX(i,e,t,n,r,s){var a=i[0],l=i[1],u=e[0],h=e[1],m=0,v=1,x=u-a,S=h-l,w;if(w=t-a,!(!x&&w>0)){if(w/=x,x<0){if(w0){if(w>v)return;w>m&&(m=w)}if(w=r-a,!(!x&&w<0)){if(w/=x,x<0){if(w>v)return;w>m&&(m=w)}else if(x>0){if(w0)){if(w/=S,S<0){if(w0){if(w>v)return;w>m&&(m=w)}if(w=s-l,!(!S&&w<0)){if(w/=S,S<0){if(w>v)return;w>m&&(m=w)}else if(S>0){if(w0&&(i[0]=a+m*x,i[1]=l+m*S),v<1&&(e[0]=a+v*x,e[1]=l+v*S),!0}}}}}var Tm=1e9,nv=-Tm;function dX(i,e,t,n){function r(h,m){return i<=h&&h<=t&&e<=m&&m<=n}function s(h,m,v,x){var S=0,w=0;if(h==null||(S=a(h,v))!==(w=a(m,v))||u(h,m)<0^v>0)do x.point(S===0||S===3?i:t,S>1?n:e);while((S=(S+v+4)%4)!==w);else x.point(m[0],m[1])}function a(h,m){return ar(h[0]-i)0?0:3:ar(h[0]-t)0?2:1:ar(h[1]-e)0?1:0:m>0?3:2}function l(h,m){return u(h.x,m.x)}function u(h,m){var v=a(h,1),x=a(m,1);return v!==x?v-x:v===0?m[1]-h[1]:v===1?h[0]-m[0]:v===2?h[1]-m[1]:m[0]-h[0]}return function(h){var m=h,v=$D(),x,S,w,N,C,E,O,U,I,j,z,G={point:W,lineStart:te,lineEnd:ne,polygonStart:V,polygonEnd:Y};function W(Q,K){r(Q,K)&&m.point(Q,K)}function q(){for(var Q=0,K=0,ae=S.length;Kn&&(Ce-Ee)*(n-qe)>(ke-qe)*(i-Ee)&&++Q:ke<=n&&(Ce-Ee)*(n-qe)<(ke-qe)*(i-Ee)&&--Q;return Q}function V(){m=v,x=[],S=[],z=!0}function Y(){var Q=q(),K=z&&Q,ae=(x=hg(x)).length;(K||ae)&&(h.polygonStart(),K&&(h.lineStart(),s(null,null,1,h),h.lineEnd()),ae&&XD(x,l,Q,s,h),h.polygonEnd()),m=h,x=S=w=null}function te(){G.point=le,S&&S.push(w=[]),j=!0,I=!1,O=U=NaN}function ne(){x&&(le(N,C),E&&I&&v.rejoin(),x.push(v.result())),G.point=W,I&&m.lineEnd()}function le(Q,K){var ae=r(Q,K);if(S&&w.push([Q,K]),j)N=Q,C=K,E=ae,j=!1,ae&&(m.lineStart(),m.point(Q,K));else if(ae&&I)m.point(Q,K);else{var Ae=[O=Math.max(nv,Math.min(Tm,O)),U=Math.max(nv,Math.min(Tm,U))],be=[Q=Math.max(nv,Math.min(Tm,Q)),K=Math.max(nv,Math.min(Tm,K))];fX(Ae,be,i,e,t,n)?(I||(m.lineStart(),m.point(Ae[0],Ae[1])),m.point(be[0],be[1]),ae||m.lineEnd(),z=!1):ae&&(m.lineStart(),m.point(Q,K),z=!1)}O=Q,U=K,I=ae}return G}}var _T,yT,Hv,Wv,L0={sphere:fa,point:fa,lineStart:AX,lineEnd:fa,polygonStart:fa,polygonEnd:fa};function AX(){L0.point=mX,L0.lineEnd=pX}function pX(){L0.point=L0.lineEnd=fa}function mX(i,e){i*=Kn,e*=Kn,yT=i,Hv=Yn(e),Wv=ri(e),L0.point=gX}function gX(i,e){i*=Kn,e*=Kn;var t=Yn(e),n=ri(e),r=ar(i-yT),s=ri(r),a=Yn(r),l=n*a,u=Wv*t-Hv*n*s,h=Hv*t+Wv*n*s;_T.add(ol(Gc(l*l+u*u),h)),yT=i,Hv=t,Wv=n}function vX(i){return _T=new Bc,Ey(i,L0),+_T}var xT=[null,null],_X={type:"LineString",coordinates:xT};function Yh(i,e){return xT[0]=i,xT[1]=e,vX(_X)}var H5={Feature:function(i,e){return L_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n0&&(r=Yh(i[s],i[s-1]),r>0&&t<=r&&n<=r&&(t+n-r)*(1-Math.pow((t-n)/r,2))vi}).map(x)).concat(XA(Z2(s/h)*h,r,h).filter(function(U){return ar(U%v)>vi}).map(S))}return E.lines=function(){return O().map(function(U){return{type:"LineString",coordinates:U}})},E.outline=function(){return{type:"Polygon",coordinates:[w(n).concat(N(a).slice(1),w(t).reverse().slice(1),N(l).reverse().slice(1))]}},E.extent=function(U){return arguments.length?E.extentMajor(U).extentMinor(U):E.extentMinor()},E.extentMajor=function(U){return arguments.length?(n=+U[0][0],t=+U[1][0],l=+U[0][1],a=+U[1][1],n>t&&(U=n,n=t,t=U),l>a&&(U=l,l=a,a=U),E.precision(C)):[[n,l],[t,a]]},E.extentMinor=function(U){return arguments.length?(e=+U[0][0],i=+U[1][0],s=+U[0][1],r=+U[1][1],e>i&&(U=e,e=i,i=U),s>r&&(U=s,s=r,r=U),E.precision(C)):[[e,s],[i,r]]},E.step=function(U){return arguments.length?E.stepMajor(U).stepMinor(U):E.stepMinor()},E.stepMajor=function(U){return arguments.length?(m=+U[0],v=+U[1],E):[m,v]},E.stepMinor=function(U){return arguments.length?(u=+U[0],h=+U[1],E):[u,h]},E.precision=function(U){return arguments.length?(C=+U,x=Q5(s,r,90),S=K5(e,i,C),w=Q5(l,a,90),N=K5(n,t,C),E):C},E.extentMajor([[-180,-90+vi],[180,90-vi]]).extentMinor([[-180,-80-vi],[180,80+vi]])}function SX(){return bX()()}function gM(i,e){var t=i[0]*Kn,n=i[1]*Kn,r=e[0]*Kn,s=e[1]*Kn,a=ri(n),l=Yn(n),u=ri(s),h=Yn(s),m=a*ri(t),v=a*Yn(t),x=u*ri(r),S=u*Yn(r),w=2*qc(Gc(C5(s-n)+a*u*C5(r-t))),N=Yn(w),C=w?function(E){var O=Yn(E*=w)/N,U=Yn(w-E)/N,I=U*m+O*x,j=U*v+O*S,z=U*l+O*h;return[ol(j,I)*Qr,ol(z,Gc(I*I+j*j))*Qr]}:function(){return[t*Qr,n*Qr]};return C.distance=w,C}const Z5=i=>i;var U0=1/0,U_=U0,pg=-U0,B_=pg,J5={point:TX,lineStart:fa,lineEnd:fa,polygonStart:fa,polygonEnd:fa,result:function(){var i=[[U0,U_],[pg,B_]];return pg=B_=-(U_=U0=1/0),i}};function TX(i,e){ipg&&(pg=i),eB_&&(B_=e)}function vM(i){return function(e){var t=new bT;for(var n in i)t[n]=i[n];return t.stream=e,t}}function bT(){}bT.prototype={constructor:bT,point:function(i,e){this.stream.point(i,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function _M(i,e,t){var n=i.clipExtent&&i.clipExtent();return i.scale(150).translate([0,0]),n!=null&&i.clipExtent(null),Ey(t,i.stream(J5)),e(J5.result()),n!=null&&i.clipExtent(n),i}function ZD(i,e,t){return _M(i,function(n){var r=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(r/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),l=+e[0][0]+(r-a*(n[1][0]+n[0][0]))/2,u=+e[0][1]+(s-a*(n[1][1]+n[0][1]))/2;i.scale(150*a).translate([l,u])},t)}function wX(i,e,t){return ZD(i,[[0,0],e],t)}function MX(i,e,t){return _M(i,function(n){var r=+e,s=r/(n[1][0]-n[0][0]),a=(r-s*(n[1][0]+n[0][0]))/2,l=-s*n[0][1];i.scale(150*s).translate([a,l])},t)}function EX(i,e,t){return _M(i,function(n){var r=+e,s=r/(n[1][1]-n[0][1]),a=-s*n[0][0],l=(r-s*(n[1][1]+n[0][1]))/2;i.scale(150*s).translate([a,l])},t)}var eR=16,CX=ri(30*Kn);function tR(i,e){return+e?RX(i,e):NX(i)}function NX(i){return vM({point:function(e,t){e=i(e,t),this.stream.point(e[0],e[1])}})}function RX(i,e){function t(n,r,s,a,l,u,h,m,v,x,S,w,N,C){var E=h-n,O=m-r,U=E*E+O*O;if(U>4*e&&N--){var I=a+x,j=l+S,z=u+w,G=Gc(I*I+j*j+z*z),W=qc(z/=G),q=ar(ar(z)-1)e||ar((E*ne+O*le)/U-.5)>.3||a*x+l*S+u*w2?Q[2]%360*Kn:0,ne()):[l*Qr,u*Qr,h*Qr]},Y.angle=function(Q){return arguments.length?(v=Q%360*Kn,ne()):v*Qr},Y.reflectX=function(Q){return arguments.length?(x=Q?-1:1,ne()):x<0},Y.reflectY=function(Q){return arguments.length?(S=Q?-1:1,ne()):S<0},Y.precision=function(Q){return arguments.length?(z=tR(G,j=Q*Q),le()):Gc(j)},Y.fitExtent=function(Q,K){return ZD(Y,Q,K)},Y.fitSize=function(Q,K){return wX(Y,Q,K)},Y.fitWidth=function(Q,K){return MX(Y,Q,K)},Y.fitHeight=function(Q,K){return EX(Y,Q,K)};function ne(){var Q=nR(t,0,0,x,S,v).apply(null,e(s,a)),K=nR(t,n-Q[0],r-Q[1],x,S,v);return m=WD(l,u,h),G=gT(e,K),W=gT(m,G),z=tR(G,j),le()}function le(){return q=V=null,Y}return function(){return e=i.apply(this,arguments),Y.invert=e.invert&&te,ne()}}function OX(i){return function(e,t){var n=Gc(e*e+t*t),r=i(n),s=Yn(r),a=ri(r);return[ol(e*s,n*a),qc(n&&t*s/n)]}}function yM(i,e){return[i,V$(H$((Ja+e)/2))]}yM.invert=function(i,e){return[i,2*pM(q$(e))-Ja]};function JD(i,e){var t=ri(e),n=1+ri(i)*t;return[t*Yn(i)/n,Yn(e)/n]}JD.invert=OX(function(i){return 2*pM(i)});function IX(){return UX(JD).scale(250).clipAngle(142)}function ST(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=zc().domain([1,0]).range([t,n]).clamp(!0),s=zc().domain([I3(t),I3(n)]).range([1,0]).clamp(!0),a=function(v){return s(I3(r(v)))},l=e.array,u=0,h=l.length;u2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,l=[],u=Math.pow(2,e),h=360/u,m=180/u,v=s===void 0?u-1:s,x=a===void 0?u-1:a,S=n,w=Math.min(u-1,v);S<=w;S++)for(var N=r,C=Math.min(u-1,x);N<=C;N++){var E=N,O=m;if(t){E=N===0?N:rR(N/u)*u;var U=N+1===u?N+1:rR((N+1)/u)*u;O=(U-E)*180/u}var I=-180+(S+.5)*h,j=90-(E*180/u+O/2),z=O;l.push({x:S,y:N,lng:I,lat:j,latLen:z})}return l},tY=6,nY=7,iY=3,rY=90,ru=new WeakMap,Oh=new WeakMap,F3=new WeakMap,iv=new WeakMap,Zo=new WeakMap,I_=new WeakMap,o0=new WeakMap,Rf=new WeakMap,rv=new WeakSet,sY=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.tileUrl,a=r.minLevel,l=a===void 0?0:a,u=r.maxLevel,h=u===void 0?17:u,m=r.mercatorProjection,v=m===void 0?!0:m;return qX(this,e),n=GX(this,e),VX(n,rv),Eh(n,ru,void 0),Eh(n,Oh,void 0),Eh(n,F3,void 0),Eh(n,iv,void 0),Eh(n,Zo,{}),Eh(n,I_,void 0),Eh(n,o0,void 0),Eh(n,Rf,void 0),SA(n,"minLevel",void 0),SA(n,"maxLevel",void 0),SA(n,"thresholds",nP(new Array(30)).map(function(x,S){return 8/Math.pow(2,S)})),SA(n,"curvatureResolution",5),SA(n,"tileMargin",0),SA(n,"clearTiles",function(){Object.values(mi(Zo,n)).forEach(function(x){x.forEach(function(S){S.obj&&(n.remove(S.obj),iR(S.obj),delete S.obj)})}),Ch(Zo,n,{})}),Ch(ru,n,t),n.tileUrl=s,Ch(Oh,n,v),n.minLevel=l,n.maxLevel=h,n.level=0,n.add(Ch(Rf,n,new qi(new Bu(mi(ru,n)*.99,180,90),new vd({color:0})))),mi(Rf,n).visible=!1,mi(Rf,n).material.polygonOffset=!0,mi(Rf,n).material.polygonOffsetUnits=3,mi(Rf,n).material.polygonOffsetFactor=1,n}return WX(e,i),HX(e,[{key:"tileUrl",get:function(){return mi(F3,this)},set:function(n){Ch(F3,this,n),this.updatePov(mi(o0,this))}},{key:"level",get:function(){return mi(iv,this)},set:function(n){var r,s=this;mi(Zo,this)[n]||Um(rv,this,aY).call(this,n);var a=mi(iv,this);if(Ch(iv,this,n),!(n===a||a===void 0)){if(mi(Rf,this).visible=n>0,mi(Zo,this)[n].forEach(function(u){return u.obj&&(u.obj.material.depthWrite=!0)}),an)for(var l=n+1;l<=a;l++)mi(Zo,this)[l]&&mi(Zo,this)[l].forEach(function(u){u.obj&&(s.remove(u.obj),iR(u.obj),delete u.obj)});Um(rv,this,aR).call(this)}}},{key:"updatePov",value:function(n){var r=this;if(!(!n||!(n instanceof _y))){Ch(o0,this,n);var s;if(Ch(I_,this,function(m){if(!m.hullPnts){var v=360/Math.pow(2,r.level),x=m.lng,S=m.lat,w=m.latLen,N=x-v/2,C=x+v/2,E=S-w/2,O=S+w/2;m.hullPnts=[[S,x],[E,N],[O,N],[E,C],[O,C]].map(function(U){var I=$v(U,2),j=I[0],z=I[1];return oP(j,z,mi(ru,r))}).map(function(U){var I=U.x,j=U.y,z=U.z;return new de(I,j,z)})}return s||(s=new zg,n.updateMatrix(),n.updateMatrixWorld(),s.setFromProjectionMatrix(new Xn().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse))),m.hullPnts.some(function(U){return s.containsPoint(U.clone().applyMatrix4(r.matrixWorld))})}),this.tileUrl){var a=n.position.clone(),l=a.distanceTo(this.getWorldPosition(new de)),u=(l-mi(ru,this))/mi(ru,this),h=this.thresholds.findIndex(function(m){return m&&m<=u});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,h<0?this.thresholds.length:h)),Um(rv,this,aR).call(this)}}}}])})(Ka);function aY(i){var e=this;if(i>nY){mi(Zo,this)[i]=[];return}var t=mi(Zo,this)[i]=wT(i,mi(Oh,this));t.forEach(function(n){return n.centroid=oP(n.lat,n.lng,mi(ru,e))}),t.octree=xD().x(function(n){return n.centroid.x}).y(function(n){return n.centroid.y}).z(function(n){return n.centroid.z}).addAll(t)}function aR(){var i=this;if(!(!this.tileUrl||this.level===void 0||!mi(Zo,this).hasOwnProperty(this.level))&&!(!mi(I_,this)&&this.level>tY)){var e=mi(Zo,this)[this.level];if(mi(o0,this)){var t=this.worldToLocal(mi(o0,this).position.clone());if(e.octree){var n,r=this.worldToLocal(mi(o0,this).position.clone()),s=(r.length()-mi(ru,this))*iY;e=(n=e.octree).findAllWithinRadius.apply(n,nP(r).concat([s]))}else{var a=JX(t),l=(a.r/mi(ru,this)-1)*rY,u=l/Math.cos(Nf(a.lat)),h=[a.lng-u,a.lng+u],m=[a.lat+l,a.lat-l],v=sR(this.level,mi(Oh,this),h[0],m[0]),x=$v(v,2),S=x[0],w=x[1],N=sR(this.level,mi(Oh,this),h[1],m[1]),C=$v(N,2),E=C[0],O=C[1];!e.record&&(e.record={});var U=e.record;if(!U.hasOwnProperty("".concat(Math.round((S+E)/2),"_").concat(Math.round((w+O)/2))))e=wT(this.level,mi(Oh,this),S,w,E,O).map(function(W){var q="".concat(W.x,"_").concat(W.y);return U.hasOwnProperty(q)?U[q]:(U[q]=W,e.push(W),W)});else{for(var I=[],j=S;j<=E;j++)for(var z=w;z<=O;z++){var G="".concat(j,"_").concat(z);U.hasOwnProperty(G)||(U[G]=wT(this.level,mi(Oh,this),j,z,j,z)[0],e.push(U[G])),I.push(U[G])}e=I}}}e.filter(function(W){return!W.obj}).filter(mi(I_,this)||function(){return!0}).forEach(function(W){var q=W.x,V=W.y,Y=W.lng,te=W.lat,ne=W.latLen,le=360/Math.pow(2,i.level);if(!W.obj){var Q=le*(1-i.tileMargin),K=ne*(1-i.tileMargin),ae=Nf(Y),Ae=Nf(-te),be=new qi(new Bu(mi(ru,i),Math.ceil(Q/i.curvatureResolution),Math.ceil(K/i.curvatureResolution),Nf(90-Q/2)+ae,Nf(Q),Nf(90-K/2)+Ae,Nf(K)),new Kc);if(mi(Oh,i)){var Se=[te+ne/2,te-ne/2].map(function(Ce){return .5-Ce/180}),se=$v(Se,2),Ee=se[0],qe=se[1];eY(be.geometry.attributes.uv,Ee,qe)}W.obj=be}W.loading||(W.loading=!0,new aM().load(i.tileUrl(q,V,i.level),function(Ce){var ke=W.obj;ke&&(Ce.colorSpace=Nn,ke.material.map=Ce,ke.material.color=null,ke.material.needsUpdate=!0,i.add(ke)),W.loading=!1}))})}}function oY(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=uP(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let l,u,h;if(n&&(s=fY(i,e,s,t)),i.length>80*t){l=i[0],u=i[1];let m=l,v=u;for(let x=t;xm&&(m=S),w>v&&(v=w)}h=Math.max(m-l,v-u),h=h!==0?32767/h:0}return mg(s,a,t,l,u,h,0),a}function uP(i,e,t,n,r){let s;if(r===SY(i,e,t,n)>0)for(let a=e;a=e;a-=n)s=oR(a/n|0,i[a],i[a+1],s);return s&&B0(s,s.next)&&(vg(s),s=s.next),s}function pd(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(B0(t,t.next)||kr(t.prev,t,t.next)===0)){if(vg(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function mg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&gY(i,n,r,s);let l=i;for(;i.prev!==i.next;){const u=i.prev,h=i.next;if(s?uY(i,n,r,s):lY(i)){e.push(u.i,i.i,h.i),vg(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=cY(pd(i),e),mg(i,e,t,n,r,s,2)):a===2&&hY(i,e,t,n,r,s):mg(pd(i),e,t,n,r,s,1);break}}}function lY(i){const e=i.prev,t=i,n=i.next;if(kr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=Math.min(r,s,a),v=Math.min(l,u,h),x=Math.max(r,s,a),S=Math.max(l,u,h);let w=n.next;for(;w!==e;){if(w.x>=m&&w.x<=x&&w.y>=v&&w.y<=S&&wm(r,l,s,u,a,h,w.x,w.y)&&kr(w.prev,w,w.next)>=0)return!1;w=w.next}return!0}function uY(i,e,t,n){const r=i.prev,s=i,a=i.next;if(kr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=Math.min(l,u,h),w=Math.min(m,v,x),N=Math.max(l,u,h),C=Math.max(m,v,x),E=MT(S,w,e,t,n),O=MT(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=w&&U.y<=C&&U!==r&&U!==a&&wm(l,m,u,v,h,x,U.x,U.y)&&kr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=w&&I.y<=C&&I!==r&&I!==a&&wm(l,m,u,v,h,x,I.x,I.y)&&kr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=w&&U.y<=C&&U!==r&&U!==a&&wm(l,m,u,v,h,x,U.x,U.y)&&kr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=w&&I.y<=C&&I!==r&&I!==a&&wm(l,m,u,v,h,x,I.x,I.y)&&kr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function cY(i,e){let t=i;do{const n=t.prev,r=t.next.next;!B0(n,r)&&hP(n,t,t.next,r)&&gg(n,r)&&gg(r,n)&&(e.push(n.i,t.i,r.i),vg(t),vg(t.next),t=i=r),t=t.next}while(t!==i);return pd(t)}function hY(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&yY(a,l)){let u=fP(a,l);a=pd(a,a.next),u=pd(u,u.next),mg(a,e,t,n,r,s,0),mg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function fY(i,e,t,n){const r=[];for(let s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const v=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=n&&v>s&&(s=v,a=t.x=t.x&&t.x>=u&&n!==t.x&&cP(ra.x||t.x===a.x&&mY(a,t)))&&(a=t,m=v)}t=t.next}while(t!==l);return a}function mY(i,e){return kr(i.prev,i,e.prev)<0&&kr(e.next,i,i.next)<0}function gY(i,e,t,n){let r=i;do r.z===0&&(r.z=MT(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,vY(r)}function vY(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,l=0;for(let h=0;h0||u>0&&a;)l!==0&&(u===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,l--):(r=a,a=a.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function MT(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function _Y(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function wm(i,e,t,n,r,s,a,l){return!(i===a&&e===l)&&cP(i,e,t,n,r,s,a,l)}function yY(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!xY(i,e)&&(gg(i,e)&&gg(e,i)&&bY(i,e)&&(kr(i.prev,i,e.prev)||kr(i,e.prev,e))||B0(i,e)&&kr(i.prev,i,i.next)>0&&kr(e.prev,e,e.next)>0)}function kr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function B0(i,e){return i.x===e.x&&i.y===e.y}function hP(i,e,t,n){const r=av(kr(i,e,t)),s=av(kr(i,e,n)),a=av(kr(t,n,i)),l=av(kr(t,n,e));return!!(r!==s&&a!==l||r===0&&sv(i,t,e)||s===0&&sv(i,n,e)||a===0&&sv(t,i,n)||l===0&&sv(t,e,n))}function sv(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function av(i){return i>0?1:i<0?-1:0}function xY(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&hP(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function gg(i,e){return kr(i.prev,i,i.next)<0?kr(i,e,i.next)>=0&&kr(i,i.prev,e)>=0:kr(i,e,i.prev)<0||kr(i,i.next,e)<0}function bY(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function fP(i,e){const t=ET(i.i,i.x,i.y),n=ET(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function oR(i,e,t,n){const r=ET(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function vg(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ET(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function SY(i,e,t,n){let r=0;for(let s=e,a=t-n;si.length)&&(e=i.length);for(var t=0,n=Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,l=!1;return{s:function(){t=t.call(i)},n:function(){var u=t.next();return a=u.done,u},e:function(u){l=!0,s=u},f:function(){try{a||t.return==null||t.return()}finally{if(l)throw s}}}}function k_(i){return k_=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},k_(i)}function DY(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&NT(i,e)}function dP(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dP=function(){return!!i})()}function PY(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function LY(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,a,l=[],u=!0,h=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=s.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(m){h=!0,r=m}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function UY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BY(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function OY(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return MY(i)}function NT(i,e){return NT=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},NT(i,e)}function im(i,e){return TY(i)||LY(i,e)||xM(i,e)||UY()}function IY(i){return wY(i)||PY(i)||xM(i)||BY()}function xM(i,e){if(i){if(typeof i=="string")return CT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?CT(i,e):void 0}}var lR=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(s){if(r){var a=Yh(s,r)*180/Math.PI;if(a>t)for(var l=gM(r,s),u=r.length>2||s.length>2?Ag(r[2]||0,s[2]||0):null,h=u?function(x){return[].concat(IY(l(x)),[u(x)])}:l,m=1/Math.ceil(a/t),v=m;v<1;)n.push(h(v)),v+=m}n.push(r=s)}),n},RT=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:Ji,Float32BufferAttribute:Ci},FY=new RT.BufferGeometry().setAttribute?"setAttribute":"addAttribute",AP=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;CY(this,e),n=EY(this,e),n.type="GeoJsonGeometry",n.parameters={geoJson:t,radius:r,resolution:s};var a=({Point:m,MultiPoint:v,LineString:x,MultiLineString:S,Polygon:w,MultiPolygon:N}[t.type]||function(){return[]})(t.coordinates,r),l=[],u=[],h=0;a.forEach(function(C){var E=l.length;rm({indices:l,vertices:u},C),n.addGroup(E,l.length-E,h++)}),l.length&&n.setIndex(l),u.length&&n[FY]("position",new RT.Float32BufferAttribute(u,3));function m(C,E){var O=k3(C[1],C[0],E+(C[2]||0)),U=[];return[{vertices:O,indices:U}]}function v(C,E){var O={vertices:[],indices:[]};return C.map(function(U){return m(U,E)}).forEach(function(U){var I=im(U,1),j=I[0];rm(O,j)}),[O]}function x(C,E){for(var O=lR(C,s).map(function(W){var q=im(W,3),V=q[0],Y=q[1],te=q[2],ne=te===void 0?0:te;return k3(Y,V,E+ne)}),U=F_([O]),I=U.vertices,j=Math.round(I.length/3),z=[],G=1;G2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function kY(i,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!i.hasAttribute("position")||!i.hasAttribute("normal")||!i.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(a){if(a.normalized||a.isInterleavedBufferAttribute){const l=new Float32Array(a.count*a.itemSize);for(let u=0,h=0;u2&&(l[h++]=a.getZ(u));return l}return a.array instanceof Float32Array?a.array:new Float32Array(a.array)}const r=i.index?i.toNonIndexed():i,s=e.generateTangents(n(r.attributes.position),n(r.attributes.normal),n(r.attributes.uv));if(t)for(let a=3;a=2&&a.setY(l,i.getY(l)),n>=3&&a.setZ(l,i.getZ(l)),n>=4&&a.setW(l,i.getW(l));return a}function VY(i){const e=i.attributes,t=i.morphTargets,n=new Map;for(const r in e){const s=e[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,z_(s)),e[r]=n.get(s))}for(const r in t){const s=t[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,z_(s)),t[r]=n.get(s))}}function jY(i){let e=0;for(const n in i.attributes){const r=i.getAttribute(n);e+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const t=i.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function HY(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=i.getIndex(),r=i.getAttribute("position"),s=n?n.count:r.count;let a=0;const l=Object.keys(i.attributes),u={},h={},m=[],v=["getX","getY","getZ","getW"],x=["setX","setY","setZ","setW"];for(let O=0,U=l.length;O{const q=new G.array.constructor(G.count*G.itemSize);h[I][W]=new G.constructor(q,G.itemSize,G.normalized)}))}const S=e*.5,w=Math.log10(1/e),N=Math.pow(10,w),C=S*N;for(let O=0;Oa.materialIndex!==l.materialIndex?a.materialIndex-l.materialIndex:a.start-l.start),i.getIndex()===null){const a=i.getAttribute("position"),l=[];for(let u=0;ut&&u.add(Y)}u.normalize(),w.setXYZ(E+j,u.x,u.y,u.z)}}return m.setAttribute("normal",w),m}const bM=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:kY,computeMorphedAttributes:$Y,deepCloneAttribute:GY,deinterleaveAttribute:z_,deinterleaveGeometry:VY,estimateBytesUsed:jY,interleaveAttributes:qY,mergeAttributes:DT,mergeGeometries:zY,mergeGroups:XY,mergeVertices:HY,toCreasedNormals:YY,toTrianglesDrawMode:WY},Symbol.toStringTag,{value:"Module"}));var kt=(function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}});function G_(i){"@babel/helpers - typeof";return G_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},G_(i)}var QY=/^\s+/,KY=/\s+$/;function Rn(i,e){if(i=i||"",e=e||{},i instanceof Rn)return i;if(!(this instanceof Rn))return new Rn(i,e);var t=ZY(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}Rn.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,r,s,a,l;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),n<=.03928?a=n/12.92:a=Math.pow((n+.055)/1.055,2.4),r<=.03928?l=r/12.92:l=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*a+.0722*l},setAlpha:function(e){return this._a=pP(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=hR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=hR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=cR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=cR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return fR(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return nQ(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Dr(this._r,255)*100)+"%",g:Math.round(Dr(this._g,255)*100)+"%",b:Math.round(Dr(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Dr(this._r,255)*100)+"%, "+Math.round(Dr(this._g,255)*100)+"%, "+Math.round(Dr(this._b,255)*100)+"%)":"rgba("+Math.round(Dr(this._r,255)*100)+"%, "+Math.round(Dr(this._g,255)*100)+"%, "+Math.round(Dr(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:AQ[fR(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+dR(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=Rn(e);n="#"+dR(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return Rn(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(aQ,arguments)},brighten:function(){return this._applyModification(oQ,arguments)},darken:function(){return this._applyModification(lQ,arguments)},desaturate:function(){return this._applyModification(iQ,arguments)},saturate:function(){return this._applyModification(rQ,arguments)},greyscale:function(){return this._applyModification(sQ,arguments)},spin:function(){return this._applyModification(uQ,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(fQ,arguments)},complement:function(){return this._applyCombination(cQ,arguments)},monochromatic:function(){return this._applyCombination(dQ,arguments)},splitcomplement:function(){return this._applyCombination(hQ,arguments)},triad:function(){return this._applyCombination(AR,[3])},tetrad:function(){return this._applyCombination(AR,[4])}};Rn.fromRatio=function(i,e){if(G_(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=Mm(i[n]));i=t}return Rn(i,e)};function ZY(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,s=null,a=!1,l=!1;return typeof i=="string"&&(i=vQ(i)),G_(i)=="object"&&(wc(i.r)&&wc(i.g)&&wc(i.b)?(e=JY(i.r,i.g,i.b),a=!0,l=String(i.r).substr(-1)==="%"?"prgb":"rgb"):wc(i.h)&&wc(i.s)&&wc(i.v)?(n=Mm(i.s),r=Mm(i.v),e=tQ(i.h,n,r),a=!0,l="hsv"):wc(i.h)&&wc(i.s)&&wc(i.l)&&(n=Mm(i.s),s=Mm(i.l),e=eQ(i.h,n,s),a=!0,l="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=pP(t),{ok:a,format:i.format||l,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function JY(i,e,t){return{r:Dr(i,255)*255,g:Dr(e,255)*255,b:Dr(t,255)*255}}function cR(i,e,t){i=Dr(i,255),e=Dr(e,255),t=Dr(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=(n+r)/2;if(n==r)s=a=0;else{var u=n-r;switch(a=l>.5?u/(2-n-r):u/(n+r),n){case i:s=(e-t)/u+(e1&&(v-=1),v<1/6?h+(m-h)*6*v:v<1/2?m:v<2/3?h+(m-h)*(2/3-v)*6:h}if(e===0)n=r=s=t;else{var l=t<.5?t*(1+e):t+e-t*e,u=2*t-l;n=a(u,l,i+1/3),r=a(u,l,i),s=a(u,l,i-1/3)}return{r:n*255,g:r*255,b:s*255}}function hR(i,e,t){i=Dr(i,255),e=Dr(e,255),t=Dr(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=n,u=n-r;if(a=n===0?0:u/n,n==r)s=0;else{switch(n){case i:s=(e-t)/u+(e>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(Rn(n));return s}function dQ(i,e){e=e||6;for(var t=Rn(i).toHsv(),n=t.h,r=t.s,s=t.v,a=[],l=1/e;e--;)a.push(Rn({h:n,s:r,v:s})),s=(s+l)%1;return a}Rn.mix=function(i,e,t){t=t===0?0:t||50;var n=Rn(i).toRgb(),r=Rn(e).toRgb(),s=t/100,a={r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a};return Rn(a)};Rn.readability=function(i,e){var t=Rn(i),n=Rn(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)};Rn.isReadable=function(i,e,t){var n=Rn.readability(i,e),r,s;switch(s=!1,r=_Q(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=n>=4.5;break;case"AAlarge":s=n>=3;break;case"AAAsmall":s=n>=7;break}return s};Rn.mostReadable=function(i,e,t){var n=null,r=0,s,a,l,u;t=t||{},a=t.includeFallbackColors,l=t.level,u=t.size;for(var h=0;hr&&(r=s,n=Rn(e[h]));return Rn.isReadable(i,n,{level:l,size:u})||!a?n:(t.includeFallbackColors=!1,Rn.mostReadable(i,["#fff","#000"],t))};var PT=Rn.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},AQ=Rn.hexNames=pQ(PT);function pQ(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function pP(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function Dr(i,e){mQ(i)&&(i="100%");var t=gQ(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function Cy(i){return Math.min(1,Math.max(0,i))}function Eo(i){return parseInt(i,16)}function mQ(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function gQ(i){return typeof i=="string"&&i.indexOf("%")!=-1}function Il(i){return i.length==1?"0"+i:""+i}function Mm(i){return i<=1&&(i=i*100+"%"),i}function mP(i){return Math.round(parseFloat(i)*255).toString(16)}function pR(i){return Eo(i)/255}var Pl=(function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function wc(i){return!!Pl.CSS_UNIT.exec(i)}function vQ(i){i=i.replace(QY,"").replace(KY,"").toLowerCase();var e=!1;if(PT[i])i=PT[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=Pl.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=Pl.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=Pl.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=Pl.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=Pl.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=Pl.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=Pl.hex8.exec(i))?{r:Eo(t[1]),g:Eo(t[2]),b:Eo(t[3]),a:pR(t[4]),format:e?"name":"hex8"}:(t=Pl.hex6.exec(i))?{r:Eo(t[1]),g:Eo(t[2]),b:Eo(t[3]),format:e?"name":"hex"}:(t=Pl.hex4.exec(i))?{r:Eo(t[1]+""+t[1]),g:Eo(t[2]+""+t[2]),b:Eo(t[3]+""+t[3]),a:pR(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=Pl.hex3.exec(i))?{r:Eo(t[1]+""+t[1]),g:Eo(t[2]+""+t[2]),b:Eo(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function _Q(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function LT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},l.prototype.update=function(u,h){h===void 0&&(h=!0),this._currentTick++,this._currentTime+=u,this._tickDeltaTime=u,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),h&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},l.prototype.getTimer=function(){return Date.now()},l})();Object.defineProperty(n,"__esModule",{value:!0}),n.default=a},function(t,n,r){(function(s,a){t.exports=a()})(this,function(){return(function(s){function a(u){if(l[u])return l[u].exports;var h=l[u]={exports:{},id:u,loaded:!1};return s[u].call(h.exports,h,h.exports,a),h.loaded=!0,h.exports}var l={};return a.m=s,a.c=l,a.p="",a(0)})([function(s,a){var l=(function(){function u(){this.functions=[]}return u.prototype.add=function(h){return this.functions.indexOf(h)===-1&&(this.functions.push(h),!0)},u.prototype.remove=function(h){var m=this.functions.indexOf(h);return m>-1&&(this.functions.splice(m,1),!0)},u.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},u.prototype.dispatch=function(){for(var h=[],m=0;mh==m>-h?(s=h,h=e[++v]):(s=m,m=n[++x]);let S=0;if(vh==m>-h?(a=h+s,l=s-(a-h),h=e[++v]):(a=m+s,l=s-(a-m),m=n[++x]),s=a,l!==0&&(r[S++]=l);vh==m>-h?(a=s+h,u=a-s,l=s-(a-u)+(h-u),h=e[++v]):(a=s+m,u=a-s,l=s-(a-u)+(m-u),m=n[++x]),s=a,l!==0&&(r[S++]=l);for(;v=le||-ne>=le||(v=i-q,l=i-(q+v)+(v-r),v=t-V,h=t-(V+v)+(v-r),v=e-Y,u=e-(Y+v)+(v-s),v=n-te,m=n-(te+v)+(v-s),l===0&&u===0&&h===0&&m===0)||(le=qQ*a+FQ*Math.abs(ne),ne+=q*m+te*l-(Y*h+V*u),ne>=le||-ne>=le))return ne;I=l*te,x=ca*l,S=x-(x-l),w=l-S,x=ca*te,N=x-(x-te),C=te-N,j=w*C-(I-S*N-w*N-S*C),z=u*V,x=ca*u,S=x-(x-u),w=u-S,x=ca*V,N=x-(x-V),C=V-N,G=w*C-(z-S*N-w*N-S*C),E=j-G,v=j-E,wa[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,wa[1]=U-(E+v)+(v-z),W=O+E,v=W-O,wa[2]=O-(W-v)+(E-v),wa[3]=W;const Q=V3(4,EA,4,wa,gR);I=q*m,x=ca*q,S=x-(x-q),w=q-S,x=ca*m,N=x-(x-m),C=m-N,j=w*C-(I-S*N-w*N-S*C),z=Y*h,x=ca*Y,S=x-(x-Y),w=Y-S,x=ca*h,N=x-(x-h),C=h-N,G=w*C-(z-S*N-w*N-S*C),E=j-G,v=j-E,wa[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,wa[1]=U-(E+v)+(v-z),W=O+E,v=W-O,wa[2]=O-(W-v)+(E-v),wa[3]=W;const K=V3(Q,gR,4,wa,vR);I=l*m,x=ca*l,S=x-(x-l),w=l-S,x=ca*m,N=x-(x-m),C=m-N,j=w*C-(I-S*N-w*N-S*C),z=u*h,x=ca*u,S=x-(x-u),w=u-S,x=ca*h,N=x-(x-h),C=h-N,G=w*C-(z-S*N-w*N-S*C),E=j-G,v=j-E,wa[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,wa[1]=U-(E+v)+(v-z),W=O+E,v=W-O,wa[2]=O-(W-v)+(E-v),wa[3]=W;const ae=V3(K,vR,4,wa,_R);return _R[ae-1]}function Em(i,e,t,n,r,s){const a=(e-s)*(t-r),l=(i-r)*(n-s),u=a-l,h=Math.abs(a+l);return Math.abs(u)>=zQ*h?u:-VQ(i,e,t,n,r,s,h)}const yR=Math.pow(2,-52),lv=new Uint32Array(512);class _g{static from(e,t=XQ,n=YQ){const r=e.length,s=new Float64Array(r*2);for(let a=0;a>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:s}=this,a=e.length>>1;let l=1/0,u=1/0,h=-1/0,m=-1/0;for(let q=0;qh&&(h=V),Y>m&&(m=Y),this._ids[q]=q}const v=(l+h)/2,x=(u+m)/2;let S,w,N;for(let q=0,V=1/0;q0&&(w=q,V=Y)}let O=e[2*w],U=e[2*w+1],I=1/0;for(let q=0;qte&&(q[V++]=ne,te=le)}this.hull=q.subarray(0,V),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Em(C,E,O,U,j,z)<0){const q=w,V=O,Y=U;w=N,O=j,U=z,N=q,j=V,z=Y}const G=$Q(C,E,O,U,j,z);this._cx=G.x,this._cy=G.y;for(let q=0;q0&&Math.abs(ne-V)<=yR&&Math.abs(le-Y)<=yR||(V=ne,Y=le,te===S||te===w||te===N))continue;let Q=0;for(let Se=0,se=this._hashKey(ne,le);Se=0;)if(K=ae,K===Q){K=-1;break}if(K===-1)continue;let Ae=this._addTriangle(K,te,n[K],-1,-1,r[K]);r[te]=this._legalize(Ae+2),r[K]=Ae,W++;let be=n[K];for(;ae=n[be],Em(ne,le,e[2*be],e[2*be+1],e[2*ae],e[2*ae+1])<0;)Ae=this._addTriangle(be,te,ae,r[te],-1,r[be]),r[te]=this._legalize(Ae+2),n[be]=be,W--,be=ae;if(K===Q)for(;ae=t[K],Em(ne,le,e[2*ae],e[2*ae+1],e[2*K],e[2*K+1])<0;)Ae=this._addTriangle(ae,te,K,-1,r[K],r[ae]),this._legalize(Ae+2),r[ae]=Ae,n[K]=K,W--,K=ae;this._hullStart=t[te]=K,n[K]=t[be]=te,n[te]=be,s[this._hashKey(ne,le)]=te,s[this._hashKey(e[2*K],e[2*K+1])]=K}this.hull=new Uint32Array(W);for(let q=0,V=this._hullStart;q0?3-t:1+t)/4}function j3(i,e,t,n){const r=i-t,s=e-n;return r*r+s*s}function HQ(i,e,t,n,r,s,a,l){const u=i-a,h=e-l,m=t-a,v=n-l,x=r-a,S=s-l,w=u*u+h*h,N=m*m+v*v,C=x*x+S*S;return u*(v*C-N*S)-h*(m*C-N*x)+w*(m*S-v*x)<0}function WQ(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=(h*m-l*v)*x,w=(a*v-u*m)*x;return S*S+w*w}function $Q(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=i+(h*m-l*v)*x,w=e+(a*v-u*m)*x;return{x:S,y:w}}function QA(i,e,t,n){if(n-t<=20)for(let r=t+1;r<=n;r++){const s=i[r],a=e[s];let l=r-1;for(;l>=t&&e[i[l]]>a;)i[l+1]=i[l--];i[l+1]=s}else{const r=t+n>>1;let s=t+1,a=n;am(i,r,s),e[i[t]]>e[i[n]]&&am(i,t,n),e[i[s]]>e[i[n]]&&am(i,s,n),e[i[t]]>e[i[s]]&&am(i,t,s);const l=i[s],u=e[l];for(;;){do s++;while(e[i[s]]u);if(a=a-t?(QA(i,e,s,n),QA(i,e,t,a-1)):(QA(i,e,t,a-1),QA(i,e,s,n))}}function am(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function XQ(i){return i[0]}function YQ(i){return i[1]}function QQ(i,e){var t,n,r=0,s,a,l,u,h,m,v,x=i[0],S=i[1],w=e.length;for(t=0;t=0||a<=0&&u>=0)return 0}else if(h>=0&&l<=0||h<=0&&l>=0){if(s=Em(a,u,l,h,0,0),s===0)return 0;(s>0&&h>0&&l<=0||s<0&&h<=0&&l>0)&&r++}m=v,l=h,a=u}}return r%2!==0}function KQ(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return[...i.geometry.coordinates];if(i.type==="Point")return[...i.coordinates]}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return[...i];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ZQ(i){return i.type==="Feature"?i.geometry:i}function JQ(i,e,t={}){if(!i)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=KQ(i),r=ZQ(e),s=r.type,a=e.bbox;let l=r.coordinates;if(a&&eK(n,a)===!1)return!1;s==="Polygon"&&(l=[l]);let u=!1;for(var h=0;h=i[0]&&e[3]>=i[1]}var tK=JQ;const xR=1e-6;class Qf{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const r=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${r},${s}`:(Math.abs(this._x1-r)>xR||Math.abs(this._y1-s)>xR)&&(this._+="L"+r+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=s}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class UT{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class nK{constructor(e,[t,n,r,s]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this;let s,a;const l=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let N=0,C=0,E=n.length,O,U;N1;)s-=2;for(let a=2;a0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function oK(i,e,t){return[i+Math.sin(i+e)*t,e+Math.cos(i-e)*t]}class SM{static from(e,t=rK,n=sK,r){return new SM("length"in e?lK(e,t,n,r):Float64Array.from(uK(e,t,n,r)))}constructor(e){this._delaunator=new _g(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&aK(e)){this.collinear=Int32Array.from({length:t.length/2},(x,S)=>S).sort((x,S)=>t[2*x]-t[2*S]||t[2*x+1]-t[2*S+1]);const u=this.collinear[0],h=this.collinear[this.collinear.length-1],m=[t[2*u],t[2*u+1],t[2*h],t[2*h+1]],v=1e-8*Math.hypot(m[3]-m[1],m[2]-m[0]);for(let x=0,S=t.length/2;x0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new nK(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:s,triangles:a,collinear:l}=this;if(l){const v=l.indexOf(e);v>0&&(yield l[v-1]),v=0&&s!==n&&s!==r;)n=s;return s}_step(e,t,n){const{inedges:r,hull:s,_hullIndex:a,halfedges:l,triangles:u,points:h}=this;if(r[e]===-1||!h.length)return(e+1)%(h.length>>1);let m=e,v=CA(t-h[e*2],2)+CA(n-h[e*2+1],2);const x=r[e];let S=x;do{let w=u[S];const N=CA(t-h[w*2],2)+CA(n-h[w*2+1],2);if(N0?1:i<0?-1:0},_P=Math.sqrt;function AK(i){return i>1?bR:i<-1?-bR:Math.asin(i)}function yP(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function Do(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function q_(i,e){return[i[0]+e[0],i[1]+e[1],i[2]+e[2]]}function V_(i){var e=_P(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);return[i[0]/e,i[1]/e,i[2]/e]}function wM(i){return[cK(i[1],i[0])*SR,AK(hK(-1,fK(1,i[2])))*SR]}function gu(i){const e=i[0]*TR,t=i[1]*TR,n=wR(t);return[n*wR(e),n*MR(e),MR(t)]}function MM(i){return i=i.map(e=>gu(e)),yP(i[0],Do(i[2],i[1]))}function pK(i){const e=gK(i),t=_K(e),n=vK(t,i),r=xK(t,i.length),s=mK(r,i),a=yK(t,i),{polygons:l,centers:u}=bK(a,t,i),h=SK(l),m=wK(t,i),v=TK(n,t);return{delaunay:e,edges:n,triangles:t,centers:u,neighbors:r,polygons:l,mesh:h,hull:m,urquhart:v,find:s}}function mK(i,e){function t(n,r){let s=n[0]-r[0],a=n[1]-r[1],l=n[2]-r[2];return s*s+a*a+l*l}return function(r,s,a){a===void 0&&(a=0);let l,u,h=a;const m=gu([r,s]);do l=a,a=null,u=t(m,gu(e[l])),i[l].forEach(v=>{let x=t(m,gu(e[v]));if(x1e32?r.push(v):S>s&&(s=S)}const a=1e6*_P(s);r.forEach(v=>i[v]=[a,0]),i.push([0,a]),i.push([-a,0]),i.push([0,-a]);const l=SM.from(i);l.projection=n;const{triangles:u,halfedges:h,inedges:m}=l;for(let v=0,x=h.length;vi.length-3-1&&(u[v]=e);return l}function vK(i,e){const t=new Set;return e.length===2?[[0,1]]:(i.forEach(n=>{if(n[0]!==n[1]&&!(MM(n.map(r=>e[r]))<0))for(let r=0,s;r<3;r++)s=(r+1)%3,t.add(d_([n[r],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function _K(i){const{triangles:e}=i;if(!e)return[];const t=[];for(let n=0,r=e.length/3;n{const n=t.map(s=>e[s]).map(gu),r=q_(q_(Do(n[1],n[0]),Do(n[2],n[1])),Do(n[0],n[2]));return wM(V_(r))})}function xK(i,e){const t=[];return i.forEach(n=>{for(let r=0;r<3;r++){const s=n[r],a=n[(r+1)%3];t[s]=t[s]||[],t[s].push(a)}}),i.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function bK(i,e,t){const n=[],r=i.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:r};if(t.length===2){const l=gu(t[0]),u=gu(t[1]),h=V_(q_(l,u)),m=V_(Do(l,u)),v=Do(h,m),x=[h,Do(h,v),Do(Do(h,v),v),Do(Do(Do(h,v),v),v)].map(wM).map(a);return n.push(x),n.push(x.slice().reverse()),{polygons:n,centers:r}}}e.forEach((l,u)=>{for(let h=0;h<3;h++){const m=l[h],v=l[(h+1)%3],x=l[(h+2)%3];n[m]=n[m]||[],n[m].push([v,x,u,[m,v,x]])}});const s=n.map(l=>{const u=[l[0][2]];let h=l[0][1];for(let m=1;m2)return u;if(u.length==2){const m=ER(t[l[0][3][0]],t[l[0][3][1]],r[u[0]]),v=ER(t[l[0][3][2]],t[l[0][3][0]],r[u[0]]),x=a(m),S=a(v);return[u[0],S,u[1],x]}});function a(l){let u=-1;return r.slice(e.length,1/0).forEach((h,m)=>{h[0]===l[0]&&h[1]===l[1]&&(u=m+e.length)}),u<0&&(u=r.length,r.push(l)),u}return{polygons:s,centers:r}}function ER(i,e,t){i=gu(i),e=gu(e),t=gu(t);const n=dK(yP(Do(e,i),t));return wM(V_(q_(i,e)).map(r=>n*r))}function SK(i){const e=[];return i.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let r of t)r>n&&e.push([n,r]),n=r}),e}function TK(i,e){return function(t){const n=new Map,r=new Map;return i.forEach((s,a)=>{const l=s.join("-");n.set(l,t[a]),r.set(l,!0)}),e.forEach(s=>{let a=0,l=-1;for(let u=0;u<3;u++){let h=d_([s[u],s[(u+1)%3]]).join("-");n.get(h)>a&&(a=n.get(h),l=h)}r.set(l,!1)}),i.map(s=>r.get(s.join("-")))}}function wK(i,e){const t=new Set,n=[];i.map(l=>{if(!(MM(l.map(u=>e[u>e.length?0:u]))>1e-12))for(let u=0;u<3;u++){let h=[l[u],l[(u+1)%3]],m=`${h[0]}-${h[1]}`;t.has(m)?t.delete(m):t.add(`${h[1]}-${h[0]}`)}});const r=new Map;let s;if(t.forEach(l=>{l=l.split("-").map(Number),r.set(l[0],l[1]),s=l[0]}),s===void 0)return n;let a=s;do{n.push(a);let l=r.get(a);r.set(a,-1),a=l}while(a>-1&&a!==s);return n}function MK(i){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(r=>[e._vx(r),e._vy(r),r]).filter(r=>isFinite(r[0]+r[1]));e.points=n.map(r=>[r[0],r[1]]),e.valid=n.map(r=>r[2]),e.delaunay=pK(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return F5(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return F5(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((r,s)=>n.features.push({type:"Feature",geometry:r?{type:"Polygon",coordinates:[[...r,r[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,r)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[r],n)).filter(n=>MM(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>Yh(e.points[s[0]],e.points[s[1]])),r=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[a],urquhart:!!r[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:r}=e.delaunay,s=[];for(const a of r)if(a)for(let l=a.length,u=a[l-1],h=a[0],m=0;mu&&s.push([n[u],n[h]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,r){if(e._found=e.delaunay.find(t,n,e._found),!r||Yh([t,n],e.points[e._found])r[s]),r[n[0]]]]}},i?e(i):e}function BT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,n=t===void 0?1/0:t,r=zK(i,n),s=hg(r),a=GK(i,n),l=[].concat(H3(s),H3(a)),u={type:"Polygon",coordinates:i},h=qD(u),m=su(h,2),v=su(m[0],2),x=v[0],S=v[1],w=su(m[1],2),N=w[0],C=w[1],E=x>N||C>=89||S<=-89,O=[];if(E){var U=MK(l).triangles(),I=new Map(l.map(function(ae,Ae){var be=su(ae,2),Se=be[0],se=be[1];return["".concat(Se,"-").concat(se),Ae]}));U.features.forEach(function(ae){var Ae,be=ae.geometry.coordinates[0].slice(0,3).reverse(),Se=[];if(be.forEach(function(Ee){var qe=su(Ee,2),Ce=qe[0],ke=qe[1],Qe="".concat(Ce,"-").concat(ke);I.has(Qe)&&Se.push(I.get(Qe))}),Se.length===3){if(Se.some(function(Ee){return Eee)for(var l=gM(r,s),u=1/Math.ceil(a/e),h=u;h<1;)n.push(l(h)),h+=u}n.push(r=s)}),n})}function GK(i,e){var t={type:"Polygon",coordinates:i},n=qD(t),r=su(n,2),s=su(r[0],2),a=s[0],l=s[1],u=su(r[1],2),h=u[0],m=u[1];if(Math.min(Math.abs(h-a),Math.abs(m-l))h||m>=89||l<=-89;return qK(e,{minLng:a,maxLng:h,minLat:l,maxLat:m}).filter(function(x){return IT(x,t,v)})}function qK(i){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,n=e.maxLng,r=e.minLat,s=e.maxLat,a=Math.round(Math.pow(360/i,2)/Math.PI),l=(1+Math.sqrt(5))/2,u=function(E){return E/l*360%360-180},h=function(E){return Math.acos(2*E/a-1)/Math.PI*180-90},m=function(E){return a*(Math.cos((E+90)*Math.PI/180)+1)/2},v=[s!==void 0?Math.ceil(m(s)):0,r!==void 0?Math.floor(m(r)):a-1],x=t===void 0&&n===void 0?function(){return!0}:t===void 0?function(C){return C<=n}:n===void 0?function(C){return C>=t}:n>=t?function(C){return C>=t&&C<=n}:function(C){return C>=t||C<=n},S=[],w=v[0];w<=v[1];w++){var N=u(w);x(N)&&S.push([N,h(w)])}return S}function IT(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?xX(e,i):tK(i,e)}var Yv=window.THREE?window.THREE:{BufferGeometry:Ji,Float32BufferAttribute:Ci},CR=new Yv.BufferGeometry().setAttribute?"setAttribute":"addAttribute",EM=(function(i){function e(t,n,r,s,a,l,u){var h;DK(this,e),h=RK(this,e),h.type="ConicPolygonGeometry",h.parameters={polygonGeoJson:t,bottomHeight:n,topHeight:r,closedBottom:s,closedTop:a,includeSides:l,curvatureResolution:u},n=n||0,r=r||1,s=s!==void 0?s:!0,a=a!==void 0?a:!0,l=l!==void 0?l:!0,u=u||5;var m=kK(t,{resolution:u}),v=m.contour,x=m.triangles,S=hg(x.uvs),w=[],N=[],C=[],E=0,O=function(G){var W=Math.round(w.length/3),q=C.length;w=w.concat(G.vertices),N=N.concat(G.uvs),C=C.concat(W?G.indices.map(function(V){return V+W}):G.indices),h.addGroup(q,C.length-q,E++)};l&&O(I()),s&&O(j(n,!1)),a&&O(j(r,!0)),h.setIndex(C),h[CR]("position",new Yv.Float32BufferAttribute(w,3)),h[CR]("uv",new Yv.Float32BufferAttribute(N,2)),h.computeVertexNormals();function U(z,G){var W=typeof G=="function"?G:function(){return G},q=z.map(function(V){return V.map(function(Y){var te=su(Y,2),ne=te[0],le=te[1];return VK(le,ne,W(ne,le))})});return F_(q)}function I(){for(var z=U(v,n),G=z.vertices,W=z.holes,q=U(v,r),V=q.vertices,Y=hg([V,G]),te=Math.round(V.length/3),ne=new Set(W),le=0,Q=[],K=0;K=0;Se--)for(var se=0;se1&&arguments[1]!==void 0?arguments[1]:!0;return{indices:G?x.indices:x.indices.slice().reverse(),vertices:U([x.points],z).vertices,uvs:S}}return h}return LK(e,i),PK(e)})(Yv.BufferGeometry);function VK(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function FT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(l){return{keyAccessor:l,isProp:!(l instanceof Function)}}),s=i.reduce(function(l,u){var h=l,m=u;return r.forEach(function(v,x){var S=v.keyAccessor,w=v.isProp,N;if(w){var C=m,E=C[S],O=QK(C,[S].map(tZ));N=E,m=O}else N=S(m,x);x+11&&arguments[1]!==void 0?arguments[1]:1;h===r.length?Object.keys(u).forEach(function(m){return u[m]=t(u[m])}):Object.values(u).forEach(function(m){return l(m,h+1)})})(s);var a=s;return n&&(a=[],(function l(u){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];h.length===r.length?a.push({keys:h,vals:u}):Object.entries(u).forEach(function(m){var v=ZK(m,2),x=v[0],S=v[1];return l(S,[].concat(JK(h),[x]))})})(s),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a}),Mi=(function(i){i=i||{};var e=typeof i<"u"?i:{},t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r="";function s(Pe){return e.locateFile?e.locateFile(Pe,r):r+Pe}var a;typeof document<"u"&&document.currentScript&&(r=document.currentScript.src),r.indexOf("blob:")!==0?r=r.substr(0,r.lastIndexOf("/")+1):r="",a=function(at,ht,ot){var f=new XMLHttpRequest;f.open("GET",at,!0),f.responseType="arraybuffer",f.onload=function(){if(f.status==200||f.status==0&&f.response){ht(f.response);return}var _n=Te(at);if(_n){ht(_n.buffer);return}ot()},f.onerror=ot,f.send(null)};var l=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&e.arguments;var h=0,m=function(Pe){h=Pe},v=function(){return h},x=8;function S(Pe,at,ht,ot){switch(ht=ht||"i8",ht.charAt(ht.length-1)==="*"&&(ht="i32"),ht){case"i1":te[Pe>>0]=at;break;case"i8":te[Pe>>0]=at;break;case"i16":le[Pe>>1]=at;break;case"i32":Q[Pe>>2]=at;break;case"i64":Oe=[at>>>0,(Be=at,+dt(Be)>=1?Be>0?(wt(+en(Be/4294967296),4294967295)|0)>>>0:~~+he((Be-+(~~Be>>>0))/4294967296)>>>0:0)],Q[Pe>>2]=Oe[0],Q[Pe+4>>2]=Oe[1];break;case"float":K[Pe>>2]=at;break;case"double":ae[Pe>>3]=at;break;default:Zt("invalid type for setValue: "+ht)}}function w(Pe,at,ht){switch(at=at||"i8",at.charAt(at.length-1)==="*"&&(at="i32"),at){case"i1":return te[Pe>>0];case"i8":return te[Pe>>0];case"i16":return le[Pe>>1];case"i32":return Q[Pe>>2];case"i64":return Q[Pe>>2];case"float":return K[Pe>>2];case"double":return ae[Pe>>3];default:Zt("invalid type for getValue: "+at)}return null}var N=!1;function C(Pe,at){Pe||Zt("Assertion failed: "+at)}function E(Pe){var at=e["_"+Pe];return C(at,"Cannot call unknown function "+Pe+", make sure it is exported"),at}function O(Pe,at,ht,ot,f){var J={string:function(xn){var Ar=0;if(xn!=null&&xn!==0){var ji=(xn.length<<2)+1;Ar=Ze(ji),W(xn,Ar,ji)}return Ar},array:function(xn){var Ar=Ze(xn.length);return q(xn,Ar),Ar}};function _n(xn){return at==="string"?z(xn):at==="boolean"?!!xn:xn}var fn=E(Pe),zn=[],An=0;if(ot)for(var yn=0;yn=ot);)++f;if(f-at>16&&Pe.subarray&&I)return I.decode(Pe.subarray(at,f));for(var J="";at>10,56320|An&1023)}}return J}function z(Pe,at){return Pe?j(ne,Pe,at):""}function G(Pe,at,ht,ot){if(!(ot>0))return 0;for(var f=ht,J=ht+ot-1,_n=0;_n=55296&&fn<=57343){var zn=Pe.charCodeAt(++_n);fn=65536+((fn&1023)<<10)|zn&1023}if(fn<=127){if(ht>=J)break;at[ht++]=fn}else if(fn<=2047){if(ht+1>=J)break;at[ht++]=192|fn>>6,at[ht++]=128|fn&63}else if(fn<=65535){if(ht+2>=J)break;at[ht++]=224|fn>>12,at[ht++]=128|fn>>6&63,at[ht++]=128|fn&63}else{if(ht+3>=J)break;at[ht++]=240|fn>>18,at[ht++]=128|fn>>12&63,at[ht++]=128|fn>>6&63,at[ht++]=128|fn&63}}return at[ht]=0,ht-f}function W(Pe,at,ht){return G(Pe,ne,at,ht)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function q(Pe,at){te.set(Pe,at)}function V(Pe,at){return Pe%at>0&&(Pe+=at-Pe%at),Pe}var Y,te,ne,le,Q,K,ae;function Ae(Pe){Y=Pe,e.HEAP8=te=new Int8Array(Pe),e.HEAP16=le=new Int16Array(Pe),e.HEAP32=Q=new Int32Array(Pe),e.HEAPU8=ne=new Uint8Array(Pe),e.HEAPU16=new Uint16Array(Pe),e.HEAPU32=new Uint32Array(Pe),e.HEAPF32=K=new Float32Array(Pe),e.HEAPF64=ae=new Float64Array(Pe)}var be=5271536,Se=28624,se=e.TOTAL_MEMORY||33554432;e.buffer?Y=e.buffer:Y=new ArrayBuffer(se),se=Y.byteLength,Ae(Y),Q[Se>>2]=be;function Ee(Pe){for(;Pe.length>0;){var at=Pe.shift();if(typeof at=="function"){at();continue}var ht=at.func;typeof ht=="number"?at.arg===void 0?e.dynCall_v(ht):e.dynCall_vi(ht,at.arg):ht(at.arg===void 0?null:at.arg)}}var qe=[],Ce=[],ke=[],Qe=[];function et(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Tt(e.preRun.shift());Ee(qe)}function Pt(){Ee(Ce)}function Nt(){Ee(ke)}function Gt(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Ge(e.postRun.shift());Ee(Qe)}function Tt(Pe){qe.unshift(Pe)}function Ge(Pe){Qe.unshift(Pe)}var dt=Math.abs,he=Math.ceil,en=Math.floor,wt=Math.min,qt=0,Lt=null;function hn(Pe){qt++,e.monitorRunDependencies&&e.monitorRunDependencies(qt)}function ut(Pe){if(qt--,e.monitorRunDependencies&&e.monitorRunDependencies(qt),qt==0&&Lt){var at=Lt;Lt=null,at()}}e.preloadedImages={},e.preloadedAudios={};var fe=null,k="data:application/octet-stream;base64,";function _e(Pe){return String.prototype.startsWith?Pe.startsWith(k):Pe.indexOf(k)===0}var Be,Oe;fe="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var je=28640;function Bt(Pe,at,ht,ot){Zt("Assertion failed: "+z(Pe)+", at: "+[at?z(at):"unknown filename",ht,ot?z(ot):"unknown function"])}function yt(){return te.length}function Xt(Pe,at,ht){ne.set(ne.subarray(at,at+ht),Pe)}function ln(Pe){return e.___errno_location&&(Q[e.___errno_location()>>2]=Pe),Pe}function mt(Pe){Zt("OOM")}function Wt(Pe){try{var at=new ArrayBuffer(Pe);return at.byteLength!=Pe?void 0:(new Int8Array(at).set(te),xt(at),Ae(at),1)}catch{}}function Yt(Pe){var at=yt(),ht=16777216,ot=2147483648-ht;if(Pe>ot)return!1;for(var f=16777216,J=Math.max(at,f);J>4,f=(fn&15)<<4|zn>>2,J=(zn&3)<<6|An,ht=ht+String.fromCharCode(ot),zn!==64&&(ht=ht+String.fromCharCode(f)),An!==64&&(ht=ht+String.fromCharCode(J));while(yn13780509?(d=Zu(15,d)|0,d|0):(p=((A|0)<0)<<31>>31,y=vr(A|0,p|0,3,0)|0,_=ee()|0,p=rn(A|0,p|0,1,0)|0,p=vr(y|0,_|0,p|0,ee()|0)|0,p=rn(p|0,ee()|0,1,0)|0,A=ee()|0,f[d>>2]=p,f[d+4>>2]=A,d=0,d|0)}function qr(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,Er(A,d,p,_,0)|0}function Er(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0;if(B=Z,Z=Z+16|0,M=B,!(Ni(A,d,p,_,y)|0))return _=0,Z=B,_|0;do if((p|0)>=0){if((p|0)>13780509){if(T=Zu(15,M)|0,T|0)break;R=M,M=f[R>>2]|0,R=f[R+4>>2]|0}else T=((p|0)<0)<<31>>31,F=vr(p|0,T|0,3,0)|0,R=ee()|0,T=rn(p|0,T|0,1,0)|0,T=vr(F|0,R|0,T|0,ee()|0)|0,T=rn(T|0,ee()|0,1,0)|0,R=ee()|0,f[M>>2]=T,f[M+4>>2]=R,M=T;if(vo(_|0,0,M<<3|0)|0,y|0){vo(y|0,0,M<<2|0)|0,T=Yi(A,d,p,_,y,M,R,0)|0;break}T=sa(M,4)|0,T?(F=Yi(A,d,p,_,T,M,R,0)|0,wn(T),T=F):T=13}else T=2;while(!1);return F=T,Z=B,F|0}function Ni(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0;if(Ne=Z,Z=Z+16|0,pe=Ne,ge=Ne+8|0,me=pe,f[me>>2]=A,f[me+4>>2]=d,(p|0)<0)return ge=2,Z=Ne,ge|0;if(T=_,f[T>>2]=A,f[T+4>>2]=d,T=(y|0)!=0,T&&(f[y>>2]=0),Ri(A,d)|0)return ge=9,Z=Ne,ge|0;f[ge>>2]=0;e:do if((p|0)>=1)if(T)for(H=1,F=0,re=0,me=1,T=A;;){if(!(F|re)){if(T=_i(T,d,4,ge,pe)|0,T|0)break e;if(d=pe,T=f[d>>2]|0,d=f[d+4>>2]|0,Ri(T,d)|0){T=9;break e}}if(T=_i(T,d,f[26800+(re<<2)>>2]|0,ge,pe)|0,T|0)break e;if(d=pe,T=f[d>>2]|0,d=f[d+4>>2]|0,A=_+(H<<3)|0,f[A>>2]=T,f[A+4>>2]=d,f[y+(H<<2)>>2]=me,A=F+1|0,M=(A|0)==(me|0),R=re+1|0,B=(R|0)==6,Ri(T,d)|0){T=9;break e}if(me=me+(B&M&1)|0,(me|0)>(p|0)){T=0;break}else H=H+1|0,F=M?0:A,re=M?B?0:R:re}else for(H=1,F=0,re=0,me=1,T=A;;){if(!(F|re)){if(T=_i(T,d,4,ge,pe)|0,T|0)break e;if(d=pe,T=f[d>>2]|0,d=f[d+4>>2]|0,Ri(T,d)|0){T=9;break e}}if(T=_i(T,d,f[26800+(re<<2)>>2]|0,ge,pe)|0,T|0)break e;if(d=pe,T=f[d>>2]|0,d=f[d+4>>2]|0,A=_+(H<<3)|0,f[A>>2]=T,f[A+4>>2]=d,A=F+1|0,M=(A|0)==(me|0),R=re+1|0,B=(R|0)==6,Ri(T,d)|0){T=9;break e}if(me=me+(B&M&1)|0,(me|0)>(p|0)){T=0;break}else H=H+1|0,F=M?0:A,re=M?B?0:R:re}else T=0;while(!1);return ge=T,Z=Ne,ge|0}function Yi(A,d,p,_,y,T,M,R){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0,R=R|0;var B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0;if(Ne=Z,Z=Z+16|0,pe=Ne+8|0,ge=Ne,B=lc(A|0,d|0,T|0,M|0)|0,H=ee()|0,re=_+(B<<3)|0,Ie=re,Je=f[Ie>>2]|0,Ie=f[Ie+4>>2]|0,F=(Je|0)==(A|0)&(Ie|0)==(d|0),!((Je|0)==0&(Ie|0)==0|F))do B=rn(B|0,H|0,1,0)|0,B=oh(B|0,ee()|0,T|0,M|0)|0,H=ee()|0,re=_+(B<<3)|0,Je=re,Ie=f[Je>>2]|0,Je=f[Je+4>>2]|0,F=(Ie|0)==(A|0)&(Je|0)==(d|0);while(!((Ie|0)==0&(Je|0)==0|F));if(B=y+(B<<2)|0,F&&(f[B>>2]|0)<=(R|0)||(Je=re,f[Je>>2]=A,f[Je+4>>2]=d,f[B>>2]=R,(R|0)>=(p|0)))return Je=0,Z=Ne,Je|0;switch(F=R+1|0,f[pe>>2]=0,B=_i(A,d,2,pe,ge)|0,B|0){case 9:{me=9;break}case 0:{B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B||(me=9);break}}e:do if((me|0)==9){switch(f[pe>>2]=0,B=_i(A,d,3,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}switch(f[pe>>2]=0,B=_i(A,d,1,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}switch(f[pe>>2]=0,B=_i(A,d,5,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}switch(f[pe>>2]=0,B=_i(A,d,4,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}switch(f[pe>>2]=0,B=_i(A,d,6,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}return Je=0,Z=Ne,Je|0}while(!1);return Je=B,Z=Ne,Je|0}function _i(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0;if(p>>>0>6)return y=1,y|0;if(re=(f[_>>2]|0)%6|0,f[_>>2]=re,(re|0)>0){T=0;do p=qu(p)|0,T=T+1|0;while((T|0)<(f[_>>2]|0))}if(re=Ut(A|0,d|0,45)|0,ee()|0,H=re&127,H>>>0>121)return y=5,y|0;B=ta(A,d)|0,T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15;e:do if(!T)F=8;else{for(;;){if(M=(15-T|0)*3|0,R=Ut(A|0,d|0,M|0)|0,ee()|0,R=R&7,(R|0)==7){d=5;break}if(ge=(Ps(T)|0)==0,T=T+-1|0,me=zt(7,0,M|0)|0,d=d&~(ee()|0),pe=zt(f[(ge?432:16)+(R*28|0)+(p<<2)>>2]|0,0,M|0)|0,M=ee()|0,p=f[(ge?640:224)+(R*28|0)+(p<<2)>>2]|0,A=pe|A&~me,d=M|d,!p){p=0;break e}if(!T){F=8;break e}}return d|0}while(!1);(F|0)==8&&(ge=f[848+(H*28|0)+(p<<2)>>2]|0,pe=zt(ge|0,0,45)|0,A=pe|A,d=ee()|0|d&-1040385,p=f[4272+(H*28|0)+(p<<2)>>2]|0,(ge&127|0)==127&&(ge=zt(f[848+(H*28|0)+20>>2]|0,0,45)|0,d=ee()|0|d&-1040385,p=f[4272+(H*28|0)+20>>2]|0,A=$u(ge|A,d)|0,d=ee()|0,f[_>>2]=(f[_>>2]|0)+1)),R=Ut(A|0,d|0,45)|0,ee()|0,R=R&127;e:do if($n(R)|0){t:do if((ta(A,d)|0)==1){if((H|0)!=(R|0))if(yi(R,f[7696+(H*28|0)>>2]|0)|0){A=fp(A,d)|0,M=1,d=ee()|0;break}else Vt(27795,26864,533,26872);switch(B|0){case 3:{A=$u(A,d)|0,d=ee()|0,f[_>>2]=(f[_>>2]|0)+1,M=0;break t}case 5:{A=fp(A,d)|0,d=ee()|0,f[_>>2]=(f[_>>2]|0)+5,M=0;break t}case 0:return ge=9,ge|0;default:return ge=1,ge|0}}else M=0;while(!1);if((p|0)>0){T=0;do A=hp(A,d)|0,d=ee()|0,T=T+1|0;while((T|0)!=(p|0))}if((H|0)!=(R|0)){if(!(or(R)|0)){if((M|0)!=0|(ta(A,d)|0)!=5)break;f[_>>2]=(f[_>>2]|0)+1;break}switch(re&127){case 8:case 118:break e}(ta(A,d)|0)!=3&&(f[_>>2]=(f[_>>2]|0)+1)}}else if((p|0)>0){T=0;do A=$u(A,d)|0,d=ee()|0,T=T+1|0;while((T|0)!=(p|0))}while(!1);return f[_>>2]=((f[_>>2]|0)+p|0)%6|0,ge=y,f[ge>>2]=A,f[ge+4>>2]=d,ge=0,ge|0}function pr(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,Vr(A,d,p,_)|0?(vo(_|0,0,p*48|0)|0,_=hl(A,d,p,_)|0,_|0):(_=0,_|0)}function Vr(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0;if(ge=Z,Z=Z+16|0,me=ge,pe=ge+8|0,re=me,f[re>>2]=A,f[re+4>>2]=d,(p|0)<0)return pe=2,Z=ge,pe|0;if(!p)return pe=_,f[pe>>2]=A,f[pe+4>>2]=d,pe=0,Z=ge,pe|0;f[pe>>2]=0;e:do if(Ri(A,d)|0)A=9;else{y=0,re=A;do{if(A=_i(re,d,4,pe,me)|0,A|0)break e;if(d=me,re=f[d>>2]|0,d=f[d+4>>2]|0,y=y+1|0,Ri(re,d)|0){A=9;break e}}while((y|0)<(p|0));H=_,f[H>>2]=re,f[H+4>>2]=d,H=p+-1|0,F=0,A=1;do{if(y=26800+(F<<2)|0,(F|0)==5)for(M=f[y>>2]|0,T=0,y=A;;){if(A=me,A=_i(f[A>>2]|0,f[A+4>>2]|0,M,pe,me)|0,A|0)break e;if((T|0)!=(H|0))if(B=me,R=f[B>>2]|0,B=f[B+4>>2]|0,A=_+(y<<3)|0,f[A>>2]=R,f[A+4>>2]=B,!(Ri(R,B)|0))A=y+1|0;else{A=9;break e}else A=y;if(T=T+1|0,(T|0)>=(p|0))break;y=A}else for(M=me,B=f[y>>2]|0,R=0,y=A,T=f[M>>2]|0,M=f[M+4>>2]|0;;){if(A=_i(T,M,B,pe,me)|0,A|0)break e;if(M=me,T=f[M>>2]|0,M=f[M+4>>2]|0,A=_+(y<<3)|0,f[A>>2]=T,f[A+4>>2]=M,A=y+1|0,Ri(T,M)|0){A=9;break e}if(R=R+1|0,(R|0)>=(p|0))break;y=A}F=F+1|0}while(F>>>0<6);A=me,A=(re|0)==(f[A>>2]|0)&&(d|0)==(f[A+4>>2]|0)?0:9}while(!1);return pe=A,Z=ge,pe|0}function hl(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;if(re=Z,Z=Z+16|0,M=re,!p)return f[_>>2]=A,f[_+4>>2]=d,_=0,Z=re,_|0;do if((p|0)>=0){if((p|0)>13780509){if(y=Zu(15,M)|0,y|0)break;T=M,y=f[T>>2]|0,T=f[T+4>>2]|0}else y=((p|0)<0)<<31>>31,H=vr(p|0,y|0,3,0)|0,T=ee()|0,y=rn(p|0,y|0,1,0)|0,y=vr(H|0,T|0,y|0,ee()|0)|0,y=rn(y|0,ee()|0,1,0)|0,T=ee()|0,H=M,f[H>>2]=y,f[H+4>>2]=T;if(F=sa(y,8)|0,!F)y=13;else{if(H=sa(y,4)|0,!H){wn(F),y=13;break}if(y=Yi(A,d,p,F,H,y,T,0)|0,y|0){wn(F),wn(H);break}if(d=f[M>>2]|0,M=f[M+4>>2]|0,(M|0)>0|(M|0)==0&d>>>0>0){y=0,R=0,B=0;do A=F+(R<<3)|0,T=f[A>>2]|0,A=f[A+4>>2]|0,!((T|0)==0&(A|0)==0)&&(f[H+(R<<2)>>2]|0)==(p|0)&&(me=_+(y<<3)|0,f[me>>2]=T,f[me+4>>2]=A,y=y+1|0),R=rn(R|0,B|0,1,0)|0,B=ee()|0;while((B|0)<(M|0)|(B|0)==(M|0)&R>>>0>>0)}wn(F),wn(H),y=0}}else y=2;while(!1);return me=y,Z=re,me|0}function ts(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;for(R=Z,Z=Z+16|0,T=R,M=R+8|0,y=(Ri(A,d)|0)==0,y=y?1:2;;){if(f[M>>2]=0,F=(_i(A,d,y,M,T)|0)==0,B=T,F&((f[B>>2]|0)==(p|0)?(f[B+4>>2]|0)==(_|0):0)){A=4;break}if(y=y+1|0,y>>>0>=7){y=7,A=4;break}}return(A|0)==4?(Z=R,y|0):0}function Md(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;if(R=Z,Z=Z+48|0,y=R+16|0,T=R+8|0,M=R,p=Ba(p)|0,p|0)return M=p,Z=R,M|0;if(F=A,B=f[F+4>>2]|0,p=T,f[p>>2]=f[F>>2],f[p+4>>2]=B,ba(T,y),p=lf(y,d,M)|0,!p){if(d=f[T>>2]|0,T=f[A+8>>2]|0,(T|0)>0){y=f[A+12>>2]|0,p=0;do d=(f[y+(p<<3)>>2]|0)+d|0,p=p+1|0;while((p|0)<(T|0))}p=M,y=f[p>>2]|0,p=f[p+4>>2]|0,T=((d|0)<0)<<31>>31,(p|0)<(T|0)|(p|0)==(T|0)&y>>>0>>0?(p=M,f[p>>2]=d,f[p+4>>2]=T,p=T):d=y,B=rn(d|0,p|0,12,0)|0,F=ee()|0,p=M,f[p>>2]=B,f[p+4>>2]=F,p=_,f[p>>2]=B,f[p+4>>2]=F,p=0}return F=p,Z=R,F|0}function xe(A,d,p,_,y,T,M){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0;var R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0,Cn=0,li=0,Ln=0,Di=0,Us=0,Sl=0;if(li=Z,Z=Z+64|0,Pn=li+48|0,gn=li+32|0,Ht=li+24|0,jt=li+8|0,pn=li,B=f[A>>2]|0,(B|0)<=0)return Cn=0,Z=li,Cn|0;for(cn=A+4|0,jn=Pn+8|0,Bn=gn+8|0,ei=jt+8|0,R=0,Ve=0;;){F=f[cn>>2]|0,He=F+(Ve<<4)|0,f[Pn>>2]=f[He>>2],f[Pn+4>>2]=f[He+4>>2],f[Pn+8>>2]=f[He+8>>2],f[Pn+12>>2]=f[He+12>>2],(Ve|0)==(B+-1|0)?(f[gn>>2]=f[F>>2],f[gn+4>>2]=f[F+4>>2],f[gn+8>>2]=f[F+8>>2],f[gn+12>>2]=f[F+12>>2]):(He=F+(Ve+1<<4)|0,f[gn>>2]=f[He>>2],f[gn+4>>2]=f[He+4>>2],f[gn+8>>2]=f[He+8>>2],f[gn+12>>2]=f[He+12>>2]),B=o1(Pn,gn,_,Ht)|0;e:do if(B)F=0,R=B;else if(B=Ht,F=f[B>>2]|0,B=f[B+4>>2]|0,(B|0)>0|(B|0)==0&F>>>0>0){Je=0,He=0;t:for(;;){if(Di=1/(+(F>>>0)+4294967296*+(B|0)),Sl=+J[Pn>>3],B=Hr(F|0,B|0,Je|0,He|0)|0,Us=+(B>>>0)+4294967296*+(ee()|0),Ln=+(Je>>>0)+4294967296*+(He|0),J[jt>>3]=Di*(Sl*Us)+Di*(+J[gn>>3]*Ln),J[ei>>3]=Di*(+J[jn>>3]*Us)+Di*(+J[Bn>>3]*Ln),B=Bd(jt,_,pn)|0,B|0){R=B;break}Ie=pn,Ne=f[Ie>>2]|0,Ie=f[Ie+4>>2]|0,me=lc(Ne|0,Ie|0,d|0,p|0)|0,H=ee()|0,B=M+(me<<3)|0,re=B,F=f[re>>2]|0,re=f[re+4>>2]|0;n:do if((F|0)==0&(re|0)==0)Re=B,Cn=16;else for(pe=0,ge=0;;){if((pe|0)>(p|0)|(pe|0)==(p|0)&ge>>>0>d>>>0){R=1;break t}if((F|0)==(Ne|0)&(re|0)==(Ie|0))break n;if(B=rn(me|0,H|0,1,0)|0,me=oh(B|0,ee()|0,d|0,p|0)|0,H=ee()|0,ge=rn(ge|0,pe|0,1,0)|0,pe=ee()|0,B=M+(me<<3)|0,re=B,F=f[re>>2]|0,re=f[re+4>>2]|0,(F|0)==0&(re|0)==0){Re=B,Cn=16;break}}while(!1);if((Cn|0)==16&&(Cn=0,!((Ne|0)==0&(Ie|0)==0))&&(ge=Re,f[ge>>2]=Ne,f[ge+4>>2]=Ie,ge=T+(f[y>>2]<<3)|0,f[ge>>2]=Ne,f[ge+4>>2]=Ie,ge=y,ge=rn(f[ge>>2]|0,f[ge+4>>2]|0,1,0)|0,Ne=ee()|0,Ie=y,f[Ie>>2]=ge,f[Ie+4>>2]=Ne),Je=rn(Je|0,He|0,1,0)|0,He=ee()|0,B=Ht,F=f[B>>2]|0,B=f[B+4>>2]|0,!((B|0)>(He|0)|(B|0)==(He|0)&F>>>0>Je>>>0)){F=1;break e}}F=0}else F=1;while(!1);if(Ve=Ve+1|0,!F){Cn=21;break}if(B=f[A>>2]|0,(Ve|0)>=(B|0)){R=0,Cn=21;break}}return(Cn|0)==21?(Z=li,R|0):0}function Rt(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0,Cn=0,li=0,Ln=0,Di=0,Us=0;if(Us=Z,Z=Z+112|0,Cn=Us+80|0,B=Us+72|0,li=Us,Ln=Us+56|0,y=Ba(p)|0,y|0)return Di=y,Z=Us,Di|0;if(F=A+8|0,Di=$o((f[F>>2]<<5)+32|0)|0,!Di)return Di=13,Z=Us,Di|0;if(Oa(A,Di),y=Ba(p)|0,!y){if(gn=A,Ht=f[gn+4>>2]|0,y=B,f[y>>2]=f[gn>>2],f[y+4>>2]=Ht,ba(B,Cn),y=lf(Cn,d,li)|0,y)gn=0,Ht=0;else{if(y=f[B>>2]|0,T=f[F>>2]|0,(T|0)>0){M=f[A+12>>2]|0,p=0;do y=(f[M+(p<<3)>>2]|0)+y|0,p=p+1|0;while((p|0)!=(T|0));p=y}else p=y;y=li,T=f[y>>2]|0,y=f[y+4>>2]|0,M=((p|0)<0)<<31>>31,(y|0)<(M|0)|(y|0)==(M|0)&T>>>0

>>0?(y=li,f[y>>2]=p,f[y+4>>2]=M,y=M):p=T,gn=rn(p|0,y|0,12,0)|0,Ht=ee()|0,y=li,f[y>>2]=gn,f[y+4>>2]=Ht,y=0}if(!y){if(p=sa(gn,8)|0,!p)return wn(Di),Di=13,Z=Us,Di|0;if(R=sa(gn,8)|0,!R)return wn(Di),wn(p),Di=13,Z=Us,Di|0;ei=Cn,f[ei>>2]=0,f[ei+4>>2]=0,ei=A,Pn=f[ei+4>>2]|0,y=B,f[y>>2]=f[ei>>2],f[y+4>>2]=Pn,y=xe(B,gn,Ht,d,Cn,p,R)|0;e:do if(y)wn(p),wn(R),wn(Di);else{t:do if((f[F>>2]|0)>0){for(M=A+12|0,T=0;y=xe((f[M>>2]|0)+(T<<3)|0,gn,Ht,d,Cn,p,R)|0,T=T+1|0,!(y|0);)if((T|0)>=(f[F>>2]|0))break t;wn(p),wn(R),wn(Di);break e}while(!1);(Ht|0)>0|(Ht|0)==0&gn>>>0>0&&vo(R|0,0,gn<<3|0)|0,Pn=Cn,ei=f[Pn+4>>2]|0;t:do if((ei|0)>0|(ei|0)==0&(f[Pn>>2]|0)>>>0>0){cn=p,jn=R,Bn=p,ei=R,Pn=p,y=p,Re=p,jt=R,pn=R,p=R;n:for(;;){for(Ie=0,Je=0,He=0,Ve=0,T=0,M=0;;){R=li,B=R+56|0;do f[R>>2]=0,R=R+4|0;while((R|0)<(B|0));if(d=cn+(Ie<<3)|0,F=f[d>>2]|0,d=f[d+4>>2]|0,Ni(F,d,1,li,0)|0){R=li,B=R+56|0;do f[R>>2]=0,R=R+4|0;while((R|0)<(B|0));R=sa(7,4)|0,R|0&&(Yi(F,d,1,li,R,7,0,0)|0,wn(R))}for(Ne=0;;){ge=li+(Ne<<3)|0,pe=f[ge>>2]|0,ge=f[ge+4>>2]|0;i:do if((pe|0)==0&(ge|0)==0)R=T,B=M;else{if(H=lc(pe|0,ge|0,gn|0,Ht|0)|0,F=ee()|0,R=_+(H<<3)|0,d=R,B=f[d>>2]|0,d=f[d+4>>2]|0,!((B|0)==0&(d|0)==0)){re=0,me=0;do{if((re|0)>(Ht|0)|(re|0)==(Ht|0)&me>>>0>gn>>>0)break n;if((B|0)==(pe|0)&(d|0)==(ge|0)){R=T,B=M;break i}R=rn(H|0,F|0,1,0)|0,H=oh(R|0,ee()|0,gn|0,Ht|0)|0,F=ee()|0,me=rn(me|0,re|0,1,0)|0,re=ee()|0,R=_+(H<<3)|0,d=R,B=f[d>>2]|0,d=f[d+4>>2]|0}while(!((B|0)==0&(d|0)==0))}if((pe|0)==0&(ge|0)==0){R=T,B=M;break}jl(pe,ge,Ln)|0,Ia(A,Di,Ln)|0&&(me=rn(T|0,M|0,1,0)|0,M=ee()|0,re=R,f[re>>2]=pe,f[re+4>>2]=ge,T=jn+(T<<3)|0,f[T>>2]=pe,f[T+4>>2]=ge,T=me),R=T,B=M}while(!1);if(Ne=Ne+1|0,Ne>>>0>=7)break;T=R,M=B}if(Ie=rn(Ie|0,Je|0,1,0)|0,Je=ee()|0,He=rn(He|0,Ve|0,1,0)|0,Ve=ee()|0,M=Cn,T=f[M>>2]|0,M=f[M+4>>2]|0,(Ve|0)<(M|0)|(Ve|0)==(M|0)&He>>>0>>0)T=R,M=B;else break}if((M|0)>0|(M|0)==0&T>>>0>0){T=0,M=0;do Ve=cn+(T<<3)|0,f[Ve>>2]=0,f[Ve+4>>2]=0,T=rn(T|0,M|0,1,0)|0,M=ee()|0,Ve=Cn,He=f[Ve+4>>2]|0;while((M|0)<(He|0)|((M|0)==(He|0)?T>>>0<(f[Ve>>2]|0)>>>0:0))}if(Ve=Cn,f[Ve>>2]=R,f[Ve+4>>2]=B,(B|0)>0|(B|0)==0&R>>>0>0)Ne=p,Ie=pn,Je=Pn,He=jt,Ve=jn,p=Re,pn=y,jt=Bn,Re=Ne,y=Ie,Pn=ei,ei=Je,Bn=He,jn=cn,cn=Ve;else break t}wn(Bn),wn(ei),wn(Di),y=1;break e}else y=R;while(!1);wn(Di),wn(p),wn(y),y=0}while(!1);return Di=y,Z=Us,Di|0}}return wn(Di),Di=y,Z=Us,Di|0}function nn(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(H=Z,Z=Z+176|0,B=H,(d|0)<1)return Wo(p,0,0),F=0,Z=H,F|0;for(R=A,R=Ut(f[R>>2]|0,f[R+4>>2]|0,52)|0,ee()|0,Wo(p,(d|0)>6?d:6,R&15),R=0;_=A+(R<<3)|0,_=Hl(f[_>>2]|0,f[_+4>>2]|0,B)|0,!(_|0);){if(_=f[B>>2]|0,(_|0)>0){M=0;do T=B+8+(M<<4)|0,M=M+1|0,_=B+8+(((M|0)%(_|0)|0)<<4)|0,y=ac(p,_,T)|0,y?sc(p,y)|0:Wd(p,T,_)|0,_=f[B>>2]|0;while((M|0)<(_|0))}if(R=R+1|0,(R|0)>=(d|0)){_=0,F=13;break}}return(F|0)==13?(Z=H,_|0):(jd(p),F=_,Z=H,F|0)}function fi(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;if(T=Z,Z=Z+32|0,_=T,y=T+16|0,A=nn(A,d,y)|0,A|0)return p=A,Z=T,p|0;if(f[p>>2]=0,f[p+4>>2]=0,f[p+8>>2]=0,A=Hd(y)|0,A|0)do{d=E1(p)|0;do kd(d,A)|0,M=A+16|0,f[_>>2]=f[M>>2],f[_+4>>2]=f[M+4>>2],f[_+8>>2]=f[M+8>>2],f[_+12>>2]=f[M+12>>2],sc(y,A)|0,A=bs(y,_)|0;while((A|0)!=0);A=Hd(y)|0}while((A|0)!=0);return jd(y),A=Nx(p)|0,A?(ec(p),M=A,Z=T,M|0):(M=0,Z=T,M|0)}function $n(A){return A=A|0,A>>>0>121?(A=0,A|0):(A=f[7696+(A*28|0)+16>>2]|0,A|0)}function or(A){return A=A|0,(A|0)==4|(A|0)==117|0}function er(A){return A=A|0,f[11120+((f[A>>2]|0)*216|0)+((f[A+4>>2]|0)*72|0)+((f[A+8>>2]|0)*24|0)+(f[A+12>>2]<<3)>>2]|0}function po(A){return A=A|0,f[11120+((f[A>>2]|0)*216|0)+((f[A+4>>2]|0)*72|0)+((f[A+8>>2]|0)*24|0)+(f[A+12>>2]<<3)+4>>2]|0}function Cr(A,d){A=A|0,d=d|0,A=7696+(A*28|0)|0,f[d>>2]=f[A>>2],f[d+4>>2]=f[A+4>>2],f[d+8>>2]=f[A+8>>2],f[d+12>>2]=f[A+12>>2]}function lr(A,d){A=A|0,d=d|0;var p=0,_=0;if(d>>>0>20)return d=-1,d|0;do if((f[11120+(d*216|0)>>2]|0)!=(A|0))if((f[11120+(d*216|0)+8>>2]|0)!=(A|0))if((f[11120+(d*216|0)+16>>2]|0)!=(A|0))if((f[11120+(d*216|0)+24>>2]|0)!=(A|0))if((f[11120+(d*216|0)+32>>2]|0)!=(A|0))if((f[11120+(d*216|0)+40>>2]|0)!=(A|0))if((f[11120+(d*216|0)+48>>2]|0)!=(A|0))if((f[11120+(d*216|0)+56>>2]|0)!=(A|0))if((f[11120+(d*216|0)+64>>2]|0)!=(A|0))if((f[11120+(d*216|0)+72>>2]|0)!=(A|0))if((f[11120+(d*216|0)+80>>2]|0)!=(A|0))if((f[11120+(d*216|0)+88>>2]|0)!=(A|0))if((f[11120+(d*216|0)+96>>2]|0)!=(A|0))if((f[11120+(d*216|0)+104>>2]|0)!=(A|0))if((f[11120+(d*216|0)+112>>2]|0)!=(A|0))if((f[11120+(d*216|0)+120>>2]|0)!=(A|0))if((f[11120+(d*216|0)+128>>2]|0)!=(A|0))if((f[11120+(d*216|0)+136>>2]|0)==(A|0))A=2,p=1,_=2;else{if((f[11120+(d*216|0)+144>>2]|0)==(A|0)){A=0,p=2,_=0;break}if((f[11120+(d*216|0)+152>>2]|0)==(A|0)){A=0,p=2,_=1;break}if((f[11120+(d*216|0)+160>>2]|0)==(A|0)){A=0,p=2,_=2;break}if((f[11120+(d*216|0)+168>>2]|0)==(A|0)){A=1,p=2,_=0;break}if((f[11120+(d*216|0)+176>>2]|0)==(A|0)){A=1,p=2,_=1;break}if((f[11120+(d*216|0)+184>>2]|0)==(A|0)){A=1,p=2,_=2;break}if((f[11120+(d*216|0)+192>>2]|0)==(A|0)){A=2,p=2,_=0;break}if((f[11120+(d*216|0)+200>>2]|0)==(A|0)){A=2,p=2,_=1;break}if((f[11120+(d*216|0)+208>>2]|0)==(A|0)){A=2,p=2,_=2;break}else A=-1;return A|0}else A=2,p=1,_=1;else A=2,p=1,_=0;else A=1,p=1,_=2;else A=1,p=1,_=1;else A=1,p=1,_=0;else A=0,p=1,_=2;else A=0,p=1,_=1;else A=0,p=1,_=0;else A=2,p=0,_=2;else A=2,p=0,_=1;else A=2,p=0,_=0;else A=1,p=0,_=2;else A=1,p=0,_=1;else A=1,p=0,_=0;else A=0,p=0,_=2;else A=0,p=0,_=1;else A=0,p=0,_=0;while(!1);return d=f[11120+(d*216|0)+(p*72|0)+(A*24|0)+(_<<3)+4>>2]|0,d|0}function yi(A,d){return A=A|0,d=d|0,(f[7696+(A*28|0)+20>>2]|0)==(d|0)?(d=1,d|0):(d=(f[7696+(A*28|0)+24>>2]|0)==(d|0),d|0)}function Iu(A,d){return A=A|0,d=d|0,f[848+(A*28|0)+(d<<2)>>2]|0}function zo(A,d){return A=A|0,d=d|0,(f[848+(A*28|0)>>2]|0)==(d|0)?(d=0,d|0):(f[848+(A*28|0)+4>>2]|0)==(d|0)?(d=1,d|0):(f[848+(A*28|0)+8>>2]|0)==(d|0)?(d=2,d|0):(f[848+(A*28|0)+12>>2]|0)==(d|0)?(d=3,d|0):(f[848+(A*28|0)+16>>2]|0)==(d|0)?(d=4,d|0):(f[848+(A*28|0)+20>>2]|0)==(d|0)?(d=5,d|0):((f[848+(A*28|0)+24>>2]|0)==(d|0)?6:7)|0}function Go(){return 122}function fl(A){A=A|0;var d=0,p=0,_=0;d=0;do zt(d|0,0,45)|0,_=ee()|0|134225919,p=A+(d<<3)|0,f[p>>2]=-1,f[p+4>>2]=_,d=d+1|0;while((d|0)!=122);return 0}function dl(A){A=A|0;var d=0,p=0,_=0;return _=+J[A+16>>3],p=+J[A+24>>3],d=_-p,+(_>3]<+J[A+24>>3]|0}function sf(A){return A=A|0,+(+J[A>>3]-+J[A+8>>3])}function qo(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;return p=+J[d>>3],!(p>=+J[A+8>>3])||!(p<=+J[A>>3])?(d=0,d|0):(_=+J[A+16>>3],p=+J[A+24>>3],y=+J[d+8>>3],d=y>=p,A=y<=_&1,_>3]<+J[d+8>>3]||+J[A+8>>3]>+J[d>>3]?(_=0,_|0):(T=+J[A+16>>3],p=A+24|0,H=+J[p>>3],M=T>3],y=d+24|0,B=+J[y>>3],R=F>3],d)||(H=+na(+J[p>>3],A),H>+na(+J[_>>3],d))?(R=0,R|0):(R=1,R|0))}function Cd(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0;T=+J[A+16>>3],B=+J[A+24>>3],A=T>3],M=+J[d+24>>3],y=R>2]=A?y|d?1:2:0,f[_>>2]=y?A?1:d?2:1:0}function ip(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;return+J[A>>3]<+J[d>>3]||+J[A+8>>3]>+J[d+8>>3]?(_=0,_|0):(_=A+16|0,B=+J[_>>3],T=+J[A+24>>3],M=B>3],y=d+24|0,F=+J[y>>3],R=H>3],d)?(H=+na(+J[_>>3],A),R=H>=+na(+J[p>>3],d),R|0):(R=0,R|0))}function of(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0;y=Z,Z=Z+176|0,_=y,f[_>>2]=4,R=+J[d>>3],J[_+8>>3]=R,T=+J[d+16>>3],J[_+16>>3]=T,J[_+24>>3]=R,R=+J[d+24>>3],J[_+32>>3]=R,M=+J[d+8>>3],J[_+40>>3]=M,J[_+48>>3]=R,J[_+56>>3]=M,J[_+64>>3]=T,d=_+72|0,p=d+96|0;do f[d>>2]=0,d=d+4|0;while((d|0)<(p|0));Yl(A|0,_|0,168)|0,Z=y}function lf(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0;ge=Z,Z=Z+288|0,H=ge+264|0,re=ge+96|0,F=ge,R=F,B=R+96|0;do f[R>>2]=0,R=R+4|0;while((R|0)<(B|0));return d=Qu(d,F)|0,d|0?(pe=d,Z=ge,pe|0):(B=F,F=f[B>>2]|0,B=f[B+4>>2]|0,jl(F,B,H)|0,Hl(F,B,re)|0,M=+rh(H,re+8|0),J[H>>3]=+J[A>>3],B=H+8|0,J[B>>3]=+J[A+16>>3],J[re>>3]=+J[A+8>>3],F=re+8|0,J[F>>3]=+J[A+24>>3],y=+rh(H,re),Ie=+J[B>>3]-+J[F>>3],T=+An(+Ie),Ne=+J[H>>3]-+J[re>>3],_=+An(+Ne),!(Ie==0|Ne==0)&&(Ie=+mf(+T,+_),Ie=+tt(+(y*y/+gf(+(Ie/+gf(+T,+_)),3)/(M*(M*2.59807621135)*.8))),J[_n>>3]=Ie,me=~~Ie>>>0,pe=+An(Ie)>=1?Ie>0?~~+ze(+zn(Ie/4294967296),4294967295)>>>0:~~+tt((Ie-+(~~Ie>>>0))/4294967296)>>>0:0,(f[_n+4>>2]&2146435072|0)!=2146435072)?(re=(me|0)==0&(pe|0)==0,d=p,f[d>>2]=re?1:me,f[d+4>>2]=re?0:pe,d=0):d=1,pe=d,Z=ge,pe|0)}function o1(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0;F=Z,Z=Z+288|0,M=F+264|0,R=F+96|0,B=F,y=B,T=y+96|0;do f[y>>2]=0,y=y+4|0;while((y|0)<(T|0));return p=Qu(p,B)|0,p|0?(_=p,Z=F,_|0):(p=B,y=f[p>>2]|0,p=f[p+4>>2]|0,jl(y,p,M)|0,Hl(y,p,R)|0,H=+rh(M,R+8|0),H=+tt(+(+rh(A,d)/(H*2))),J[_n>>3]=H,p=~~H>>>0,y=+An(H)>=1?H>0?~~+ze(+zn(H/4294967296),4294967295)>>>0:~~+tt((H-+(~~H>>>0))/4294967296)>>>0:0,(f[_n+4>>2]&2146435072|0)==2146435072?(_=1,Z=F,_|0):(B=(p|0)==0&(y|0)==0,f[_>>2]=B?1:p,f[_+4>>2]=B?0:y,_=0,Z=F,_|0))}function ea(A,d){A=A|0,d=+d;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;T=A+16|0,M=+J[T>>3],p=A+24|0,y=+J[p>>3],_=M-y,_=M>3],R=A+8|0,B=+J[R>>3],H=F-B,_=(_*d-_)*.5,d=(H*d-H)*.5,F=F+d,J[A>>3]=F>1.5707963267948966?1.5707963267948966:F,d=B-d,J[R>>3]=d<-1.5707963267948966?-1.5707963267948966:d,d=M+_,d=d>3.141592653589793?d+-6.283185307179586:d,J[T>>3]=d<-3.141592653589793?d+6.283185307179586:d,d=y-_,d=d>3.141592653589793?d+-6.283185307179586:d,J[p>>3]=d<-3.141592653589793?d+6.283185307179586:d}function Fu(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0,f[A>>2]=d,f[A+4>>2]=p,f[A+8>>2]=_}function Nd(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;re=d+8|0,f[re>>2]=0,B=+J[A>>3],M=+An(+B),F=+J[A+8>>3],R=+An(+F)*1.1547005383792515,M=M+R*.5,p=~~M,A=~~R,M=M-+(p|0),R=R-+(A|0);do if(M<.5)if(M<.3333333333333333)if(f[d>>2]=p,R<(M+1)*.5){f[d+4>>2]=A;break}else{A=A+1|0,f[d+4>>2]=A;break}else if(me=1-M,A=(!(R>2]=A,me<=R&R>2]=p;break}else{f[d>>2]=p;break}else{if(!(M<.6666666666666666))if(p=p+1|0,f[d>>2]=p,R>2]=A;break}else{A=A+1|0,f[d+4>>2]=A;break}if(R<1-M){if(f[d+4>>2]=A,M*2+-1>2]=p;break}}else A=A+1|0,f[d+4>>2]=A;p=p+1|0,f[d>>2]=p}while(!1);do if(B<0)if(A&1){H=(A+1|0)/2|0,H=Hr(p|0,((p|0)<0)<<31>>31|0,H|0,((H|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-((+(H>>>0)+4294967296*+(ee()|0))*2+1)),f[d>>2]=p;break}else{H=(A|0)/2|0,H=Hr(p|0,((p|0)<0)<<31>>31|0,H|0,((H|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-(+(H>>>0)+4294967296*+(ee()|0))*2),f[d>>2]=p;break}while(!1);H=d+4|0,F<0&&(p=p-((A<<1|1|0)/2|0)|0,f[d>>2]=p,A=0-A|0,f[H>>2]=A),_=A-p|0,(p|0)<0?(y=0-p|0,f[H>>2]=_,f[re>>2]=y,f[d>>2]=0,A=_,p=0):y=0,(A|0)<0&&(p=p-A|0,f[d>>2]=p,y=y-A|0,f[re>>2]=y,f[H>>2]=0,A=0),T=p-y|0,_=A-y|0,(y|0)<0&&(f[d>>2]=T,f[H>>2]=_,f[re>>2]=0,A=_,p=T,y=0),_=(A|0)<(p|0)?A:p,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(f[d>>2]=p-_,f[H>>2]=A-_,f[re>>2]=y-_)}function jr(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0;d=f[A>>2]|0,M=A+4|0,p=f[M>>2]|0,(d|0)<0&&(p=p-d|0,f[M>>2]=p,T=A+8|0,f[T>>2]=(f[T>>2]|0)-d,f[A>>2]=0,d=0),(p|0)<0?(d=d-p|0,f[A>>2]=d,T=A+8|0,y=(f[T>>2]|0)-p|0,f[T>>2]=y,f[M>>2]=0,p=0):(y=A+8|0,T=y,y=f[y>>2]|0),(y|0)<0&&(d=d-y|0,f[A>>2]=d,p=p-y|0,f[M>>2]=p,f[T>>2]=0,y=0),_=(p|0)<(d|0)?p:d,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(f[A>>2]=d-_,f[M>>2]=p-_,f[T>>2]=y-_)}function ku(A,d){A=A|0,d=d|0;var p=0,_=0;_=f[A+8>>2]|0,p=+((f[A+4>>2]|0)-_|0),J[d>>3]=+((f[A>>2]|0)-_|0)-p*.5,J[d+8>>3]=p*.8660254037844386}function ys(A,d,p){A=A|0,d=d|0,p=p|0,f[p>>2]=(f[d>>2]|0)+(f[A>>2]|0),f[p+4>>2]=(f[d+4>>2]|0)+(f[A+4>>2]|0),f[p+8>>2]=(f[d+8>>2]|0)+(f[A+8>>2]|0)}function uf(A,d,p){A=A|0,d=d|0,p=p|0,f[p>>2]=(f[A>>2]|0)-(f[d>>2]|0),f[p+4>>2]=(f[A+4>>2]|0)-(f[d+4>>2]|0),f[p+8>>2]=(f[A+8>>2]|0)-(f[d+8>>2]|0)}function eh(A,d){A=A|0,d=d|0;var p=0,_=0;p=Ke(f[A>>2]|0,d)|0,f[A>>2]=p,p=A+4|0,_=Ke(f[p>>2]|0,d)|0,f[p>>2]=_,A=A+8|0,d=Ke(f[A>>2]|0,d)|0,f[A>>2]=d}function zu(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;M=f[A>>2]|0,R=(M|0)<0,_=(f[A+4>>2]|0)-(R?M:0)|0,T=(_|0)<0,y=(T?0-_|0:0)+((f[A+8>>2]|0)-(R?M:0))|0,p=(y|0)<0,A=p?0:y,d=(T?0:_)-(p?y:0)|0,y=(R?0:M)-(T?_:0)-(p?y:0)|0,p=(d|0)<(y|0)?d:y,p=(A|0)<(p|0)?A:p,_=(p|0)>0,A=A-(_?p:0)|0,d=d-(_?p:0)|0;e:do switch(y-(_?p:0)|0){case 0:switch(d|0){case 0:return R=(A|0)==0?0:(A|0)==1?1:7,R|0;case 1:return R=(A|0)==0?2:(A|0)==1?3:7,R|0;default:break e}case 1:switch(d|0){case 0:return R=(A|0)==0?4:(A|0)==1?5:7,R|0;case 1:{if(!A)A=6;else break e;return A|0}default:break e}}while(!1);return R=7,R|0}function l1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0;if(B=A+8|0,M=f[B>>2]|0,R=(f[A>>2]|0)-M|0,F=A+4|0,M=(f[F>>2]|0)-M|0,R>>>0>715827881|M>>>0>715827881){if(_=(R|0)>0,y=2147483647-R|0,T=-2147483648-R|0,(_?(y|0)<(R|0):(T|0)>(R|0))||(p=R<<1,_?(2147483647-p|0)<(R|0):(-2147483648-p|0)>(R|0))||((M|0)>0?(2147483647-M|0)<(M|0):(-2147483648-M|0)>(M|0))||(d=R*3|0,p=M<<1,(_?(y|0)<(p|0):(T|0)>(p|0))||((R|0)>-1?(d|-2147483648|0)>=(M|0):(d^-2147483648|0)<(M|0))))return F=1,F|0}else p=M<<1,d=R*3|0;return _=yl(+(d-M|0)*.14285714285714285)|0,f[A>>2]=_,y=yl(+(p+R|0)*.14285714285714285)|0,f[F>>2]=y,f[B>>2]=0,p=(y|0)<(_|0),d=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((d|0)>0?(2147483647-d|0)<(p|0):(-2147483648-d|0)>(p|0)))&&Vt(27795,26892,354,26903),((d|0)>-1?(d|-2147483648|0)>=(p|0):(d^-2147483648|0)<(p|0))&&Vt(27795,26892,354,26903)),d=y-_|0,(_|0)<0?(p=0-_|0,f[F>>2]=d,f[B>>2]=p,f[A>>2]=0,_=0):(d=y,p=0),(d|0)<0&&(_=_-d|0,f[A>>2]=_,p=p-d|0,f[B>>2]=p,f[F>>2]=0,d=0),T=_-p|0,y=d-p|0,(p|0)<0?(f[A>>2]=T,f[F>>2]=y,f[B>>2]=0,d=y,y=T,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(F=0,F|0):(f[A>>2]=y-_,f[F>>2]=d-_,f[B>>2]=p-_,F=0,F|0)}function cx(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(M=A+8|0,y=f[M>>2]|0,T=(f[A>>2]|0)-y|0,R=A+4|0,y=(f[R>>2]|0)-y|0,T>>>0>715827881|y>>>0>715827881){if(p=(T|0)>0,(p?(2147483647-T|0)<(T|0):(-2147483648-T|0)>(T|0))||(d=T<<1,_=(y|0)>0,_?(2147483647-y|0)<(y|0):(-2147483648-y|0)>(y|0)))return R=1,R|0;if(B=y<<1,(_?(2147483647-B|0)<(y|0):(-2147483648-B|0)>(y|0))||(p?(2147483647-d|0)<(y|0):(-2147483648-d|0)>(y|0))||(p=y*3|0,(y|0)>-1?(p|-2147483648|0)>=(T|0):(p^-2147483648|0)<(T|0)))return B=1,B|0}else p=y*3|0,d=T<<1;return _=yl(+(d+y|0)*.14285714285714285)|0,f[A>>2]=_,y=yl(+(p-T|0)*.14285714285714285)|0,f[R>>2]=y,f[M>>2]=0,p=(y|0)<(_|0),d=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((d|0)>0?(2147483647-d|0)<(p|0):(-2147483648-d|0)>(p|0)))&&Vt(27795,26892,402,26917),((d|0)>-1?(d|-2147483648|0)>=(p|0):(d^-2147483648|0)<(p|0))&&Vt(27795,26892,402,26917)),d=y-_|0,(_|0)<0?(p=0-_|0,f[R>>2]=d,f[M>>2]=p,f[A>>2]=0,_=0):(d=y,p=0),(d|0)<0&&(_=_-d|0,f[A>>2]=_,p=p-d|0,f[M>>2]=p,f[R>>2]=0,d=0),T=_-p|0,y=d-p|0,(p|0)<0?(f[A>>2]=T,f[R>>2]=y,f[M>>2]=0,d=y,y=T,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(B=0,B|0):(f[A>>2]=y-_,f[R>>2]=d-_,f[M>>2]=p-_,B=0,B|0)}function hx(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;M=A+8|0,p=f[M>>2]|0,d=(f[A>>2]|0)-p|0,R=A+4|0,p=(f[R>>2]|0)-p|0,_=yl(+((d*3|0)-p|0)*.14285714285714285)|0,f[A>>2]=_,d=yl(+((p<<1)+d|0)*.14285714285714285)|0,f[R>>2]=d,f[M>>2]=0,p=d-_|0,(_|0)<0?(T=0-_|0,f[R>>2]=p,f[M>>2]=T,f[A>>2]=0,d=p,_=0,p=T):p=0,(d|0)<0&&(_=_-d|0,f[A>>2]=_,p=p-d|0,f[M>>2]=p,f[R>>2]=0,d=0),T=_-p|0,y=d-p|0,(p|0)<0?(f[A>>2]=T,f[R>>2]=y,f[M>>2]=0,d=y,y=T,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(f[A>>2]=y-_,f[R>>2]=d-_,f[M>>2]=p-_)}function u1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;M=A+8|0,p=f[M>>2]|0,d=(f[A>>2]|0)-p|0,R=A+4|0,p=(f[R>>2]|0)-p|0,_=yl(+((d<<1)+p|0)*.14285714285714285)|0,f[A>>2]=_,d=yl(+((p*3|0)-d|0)*.14285714285714285)|0,f[R>>2]=d,f[M>>2]=0,p=d-_|0,(_|0)<0?(T=0-_|0,f[R>>2]=p,f[M>>2]=T,f[A>>2]=0,d=p,_=0,p=T):p=0,(d|0)<0&&(_=_-d|0,f[A>>2]=_,p=p-d|0,f[M>>2]=p,f[R>>2]=0,d=0),T=_-p|0,y=d-p|0,(p|0)<0?(f[A>>2]=T,f[R>>2]=y,f[M>>2]=0,d=y,y=T,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(f[A>>2]=y-_,f[R>>2]=d-_,f[M>>2]=p-_)}function th(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;d=f[A>>2]|0,M=A+4|0,p=f[M>>2]|0,R=A+8|0,_=f[R>>2]|0,y=p+(d*3|0)|0,f[A>>2]=y,p=_+(p*3|0)|0,f[M>>2]=p,d=(_*3|0)+d|0,f[R>>2]=d,_=p-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=_,f[R>>2]=d,f[A>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=y,f[R>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[M>>2]=y-p,f[R>>2]=d-p)}function Gu(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;y=f[A>>2]|0,M=A+4|0,d=f[M>>2]|0,R=A+8|0,p=f[R>>2]|0,_=(d*3|0)+y|0,y=p+(y*3|0)|0,f[A>>2]=y,f[M>>2]=_,d=(p*3|0)+d|0,f[R>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=p,f[R>>2]=d,f[A>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,f[A>>2]=y,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=y-d|0,_=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=_,f[R>>2]=0,y=T,d=0):_=p,p=(_|0)<(y|0)?_:y,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=y-p,f[M>>2]=_-p,f[R>>2]=d-p)}function c1(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0;(d+-1|0)>>>0>=6||(y=(f[15440+(d*12|0)>>2]|0)+(f[A>>2]|0)|0,f[A>>2]=y,R=A+4|0,_=(f[15440+(d*12|0)+4>>2]|0)+(f[R>>2]|0)|0,f[R>>2]=_,M=A+8|0,d=(f[15440+(d*12|0)+8>>2]|0)+(f[M>>2]|0)|0,f[M>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[R>>2]=p,f[M>>2]=d,f[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[M>>2]=d,f[R>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[R>>2]=y,f[M>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[R>>2]=y-p,f[M>>2]=d-p))}function h1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;y=f[A>>2]|0,M=A+4|0,d=f[M>>2]|0,R=A+8|0,p=f[R>>2]|0,_=d+y|0,y=p+y|0,f[A>>2]=y,f[M>>2]=_,d=p+d|0,f[R>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=p,f[R>>2]=d,f[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=y,f[R>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[M>>2]=y-p,f[R>>2]=d-p)}function Rd(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;d=f[A>>2]|0,M=A+4|0,_=f[M>>2]|0,R=A+8|0,p=f[R>>2]|0,y=_+d|0,f[A>>2]=y,_=p+_|0,f[M>>2]=_,d=p+d|0,f[R>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=p,f[R>>2]=d,f[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=y,f[R>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[M>>2]=y-p,f[R>>2]=d-p)}function qu(A){switch(A=A|0,A|0){case 1:{A=5;break}case 5:{A=4;break}case 4:{A=6;break}case 6:{A=2;break}case 2:{A=3;break}case 3:{A=1;break}}return A|0}function Al(A){switch(A=A|0,A|0){case 1:{A=3;break}case 3:{A=2;break}case 2:{A=6;break}case 6:{A=4;break}case 4:{A=5;break}case 5:{A=1;break}}return A|0}function f1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;d=f[A>>2]|0,M=A+4|0,p=f[M>>2]|0,R=A+8|0,_=f[R>>2]|0,y=p+(d<<1)|0,f[A>>2]=y,p=_+(p<<1)|0,f[M>>2]=p,d=(_<<1)+d|0,f[R>>2]=d,_=p-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=_,f[R>>2]=d,f[A>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=y,f[R>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[M>>2]=y-p,f[R>>2]=d-p)}function d1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;y=f[A>>2]|0,M=A+4|0,d=f[M>>2]|0,R=A+8|0,p=f[R>>2]|0,_=(d<<1)+y|0,y=p+(y<<1)|0,f[A>>2]=y,f[M>>2]=_,d=(p<<1)+d|0,f[R>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=p,f[R>>2]=d,f[A>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,f[A>>2]=y,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=y-d|0,_=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=_,f[R>>2]=0,y=T,d=0):_=p,p=(_|0)<(y|0)?_:y,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=y-p,f[M>>2]=_-p,f[R>>2]=d-p)}function rp(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0;return M=(f[A>>2]|0)-(f[d>>2]|0)|0,R=(M|0)<0,_=(f[A+4>>2]|0)-(f[d+4>>2]|0)-(R?M:0)|0,T=(_|0)<0,y=(R?0-M|0:0)+(f[A+8>>2]|0)-(f[d+8>>2]|0)+(T?0-_|0:0)|0,A=(y|0)<0,d=A?0:y,p=(T?0:_)-(A?y:0)|0,y=(R?0:M)-(T?_:0)-(A?y:0)|0,A=(p|0)<(y|0)?p:y,A=(d|0)<(A|0)?d:A,_=(A|0)>0,d=d-(_?A:0)|0,p=p-(_?A:0)|0,A=y-(_?A:0)|0,A=(A|0)>-1?A:0-A|0,p=(p|0)>-1?p:0-p|0,d=(d|0)>-1?d:0-d|0,d=(p|0)>(d|0)?p:d,((A|0)>(d|0)?A:d)|0}function fx(A,d){A=A|0,d=d|0;var p=0;p=f[A+8>>2]|0,f[d>>2]=(f[A>>2]|0)-p,f[d+4>>2]=(f[A+4>>2]|0)-p}function sp(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0;return _=f[A>>2]|0,f[d>>2]=_,y=f[A+4>>2]|0,M=d+4|0,f[M>>2]=y,R=d+8|0,f[R>>2]=0,p=(y|0)<(_|0),A=p?_:y,p=p?y:_,(p|0)<0&&((p|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(p|0):(-2147483648-A|0)>(p|0))||((A|0)>-1?(A|-2147483648|0)>=(p|0):(A^-2147483648|0)<(p|0)))?(d=1,d|0):(A=y-_|0,(_|0)<0?(p=0-_|0,f[M>>2]=A,f[R>>2]=p,f[d>>2]=0,_=0):(A=y,p=0),(A|0)<0&&(_=_-A|0,f[d>>2]=_,p=p-A|0,f[R>>2]=p,f[M>>2]=0,A=0),T=_-p|0,y=A-p|0,(p|0)<0?(f[d>>2]=T,f[M>>2]=y,f[R>>2]=0,A=y,y=T,p=0):y=_,_=(A|0)<(y|0)?A:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(d=0,d|0):(f[d>>2]=y-_,f[M>>2]=A-_,f[R>>2]=p-_,d=0,d|0))}function A1(A){A=A|0;var d=0,p=0,_=0,y=0;d=A+8|0,y=f[d>>2]|0,p=y-(f[A>>2]|0)|0,f[A>>2]=p,_=A+4|0,A=(f[_>>2]|0)-y|0,f[_>>2]=A,f[d>>2]=0-(A+p)}function dx(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;p=f[A>>2]|0,d=0-p|0,f[A>>2]=d,M=A+8|0,f[M>>2]=0,R=A+4|0,_=f[R>>2]|0,y=_+p|0,(p|0)>0?(f[R>>2]=y,f[M>>2]=p,f[A>>2]=0,d=0,_=y):p=0,(_|0)<0?(T=d-_|0,f[A>>2]=T,p=p-_|0,f[M>>2]=p,f[R>>2]=0,y=T-p|0,d=0-p|0,(p|0)<0?(f[A>>2]=y,f[R>>2]=d,f[M>>2]=0,_=d,p=0):(_=0,y=T)):y=d,d=(_|0)<(y|0)?_:y,d=(p|0)<(d|0)?p:d,!((d|0)<=0)&&(f[A>>2]=y-d,f[R>>2]=_-d,f[M>>2]=p-d)}function Ax(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0;if(re=Z,Z=Z+64|0,H=re,R=re+56|0,!(!0&(d&2013265920|0)==134217728&(!0&(_&2013265920|0)==134217728)))return y=5,Z=re,y|0;if((A|0)==(p|0)&(d|0)==(_|0))return f[y>>2]=0,y=0,Z=re,y|0;if(M=Ut(A|0,d|0,52)|0,ee()|0,M=M&15,F=Ut(p|0,_|0,52)|0,ee()|0,(M|0)!=(F&15|0))return y=12,Z=re,y|0;if(T=M+-1|0,M>>>0>1){Wu(A,d,T,H)|0,Wu(p,_,T,R)|0,F=H,B=f[F>>2]|0,F=f[F+4>>2]|0;e:do if((B|0)==(f[R>>2]|0)&&(F|0)==(f[R+4>>2]|0)){M=(M^15)*3|0,T=Ut(A|0,d|0,M|0)|0,ee()|0,T=T&7,M=Ut(p|0,_|0,M|0)|0,ee()|0,M=M&7;do if((T|0)==0|(M|0)==0)f[y>>2]=1,T=0;else if((T|0)==7)T=5;else{if((T|0)==1|(M|0)==1&&Ri(B,F)|0){T=5;break}if((f[15536+(T<<2)>>2]|0)!=(M|0)&&(f[15568+(T<<2)>>2]|0)!=(M|0))break e;f[y>>2]=1,T=0}while(!1);return y=T,Z=re,y|0}while(!1)}T=H,M=T+56|0;do f[T>>2]=0,T=T+4|0;while((T|0)<(M|0));return qr(A,d,1,H)|0,d=H,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0))&&(d=H+8|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))&&(d=H+16|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))&&(d=H+24|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))&&(d=H+32|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))&&(d=H+40|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))?(T=H+48|0,T=((f[T>>2]|0)==(p|0)?(f[T+4>>2]|0)==(_|0):0)&1):T=1,f[y>>2]=T,y=0,Z=re,y|0}function p1(A,d,p,_,y){return A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,p=ts(A,d,p,_)|0,(p|0)==7?(y=11,y|0):(_=zt(p|0,0,56)|0,d=d&-2130706433|(ee()|0)|268435456,f[y>>2]=A|_,f[y+4>>2]=d,y=0,y|0)}function px(A,d,p){return A=A|0,d=d|0,p=p|0,!0&(d&2013265920|0)==268435456?(f[p>>2]=A,f[p+4>>2]=d&-2130706433|134217728,p=0,p|0):(p=6,p|0)}function mx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;return y=Z,Z=Z+16|0,_=y,f[_>>2]=0,!0&(d&2013265920|0)==268435456?(T=Ut(A|0,d|0,56)|0,ee()|0,_=_i(A,d&-2130706433|134217728,T&7,_,p)|0,Z=y,_|0):(_=6,Z=y,_|0)}function m1(A,d){A=A|0,d=d|0;var p=0;switch(p=Ut(A|0,d|0,56)|0,ee()|0,p&7){case 0:case 7:return p=0,p|0}return p=d&-2130706433|134217728,!(!0&(d&2013265920|0)==268435456)||!0&(d&117440512|0)==16777216&(Ri(A,p)|0)!=0?(p=0,p|0):(p=Ld(A,p)|0,p|0)}function gx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;return y=Z,Z=Z+16|0,_=y,!0&(d&2013265920|0)==268435456?(T=d&-2130706433|134217728,M=p,f[M>>2]=A,f[M+4>>2]=T,f[_>>2]=0,d=Ut(A|0,d|0,56)|0,ee()|0,_=_i(A,T,d&7,_,p+8|0)|0,Z=y,_|0):(_=6,Z=y,_|0)}function vx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;return y=(Ri(A,d)|0)==0,d=d&-2130706433,_=p,f[_>>2]=y?A:0,f[_+4>>2]=y?d|285212672:0,_=p+8|0,f[_>>2]=A,f[_+4>>2]=d|301989888,_=p+16|0,f[_>>2]=A,f[_+4>>2]=d|318767104,_=p+24|0,f[_>>2]=A,f[_+4>>2]=d|335544320,_=p+32|0,f[_>>2]=A,f[_+4>>2]=d|352321536,p=p+40|0,f[p>>2]=A,f[p+4>>2]=d|369098752,0}function Dd(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;return M=Z,Z=Z+16|0,y=M,T=d&-2130706433|134217728,!0&(d&2013265920|0)==268435456?(_=Ut(A|0,d|0,56)|0,ee()|0,_=Tp(A,T,_&7)|0,(_|0)==-1?(f[p>>2]=0,T=6,Z=M,T|0):(Xu(A,T,y)|0&&Vt(27795,26932,282,26947),d=Ut(A|0,d|0,52)|0,ee()|0,d=d&15,Ri(A,T)|0?ap(y,d,_,2,p):Pd(y,d,_,2,p),T=0,Z=M,T|0)):(T=6,Z=M,T|0)}function _x(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;_=Z,Z=Z+16|0,y=_,yx(A,d,p,y),Nd(y,p+4|0),Z=_}function yx(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0;if(R=Z,Z=Z+16|0,B=R,xx(A,p,B),T=+ji(+(1-+J[B>>3]*.5)),T<1e-16){f[_>>2]=0,f[_+4>>2]=0,f[_+8>>2]=0,f[_+12>>2]=0,Z=R;return}if(B=f[p>>2]|0,y=+J[15920+(B*24|0)>>3],y=+ih(y-+ih(+Ex(15600+(B<<4)|0,A))),Ps(d)|0?M=+ih(y+-.3334731722518321):M=y,y=+Ar(+T)*2.618033988749896,(d|0)>0){A=0;do y=y*2.6457513110645907,A=A+1|0;while((A|0)!=(d|0))}T=+on(+M)*y,J[_>>3]=T,M=+xn(+M)*y,J[_+8>>3]=M,Z=R}function xx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if(T=Z,Z=Z+32|0,y=T,ic(A,y),f[d>>2]=0,J[p>>3]=5,_=+cr(16400,y),_<+J[p>>3]&&(f[d>>2]=0,J[p>>3]=_),_=+cr(16424,y),_<+J[p>>3]&&(f[d>>2]=1,J[p>>3]=_),_=+cr(16448,y),_<+J[p>>3]&&(f[d>>2]=2,J[p>>3]=_),_=+cr(16472,y),_<+J[p>>3]&&(f[d>>2]=3,J[p>>3]=_),_=+cr(16496,y),_<+J[p>>3]&&(f[d>>2]=4,J[p>>3]=_),_=+cr(16520,y),_<+J[p>>3]&&(f[d>>2]=5,J[p>>3]=_),_=+cr(16544,y),_<+J[p>>3]&&(f[d>>2]=6,J[p>>3]=_),_=+cr(16568,y),_<+J[p>>3]&&(f[d>>2]=7,J[p>>3]=_),_=+cr(16592,y),_<+J[p>>3]&&(f[d>>2]=8,J[p>>3]=_),_=+cr(16616,y),_<+J[p>>3]&&(f[d>>2]=9,J[p>>3]=_),_=+cr(16640,y),_<+J[p>>3]&&(f[d>>2]=10,J[p>>3]=_),_=+cr(16664,y),_<+J[p>>3]&&(f[d>>2]=11,J[p>>3]=_),_=+cr(16688,y),_<+J[p>>3]&&(f[d>>2]=12,J[p>>3]=_),_=+cr(16712,y),_<+J[p>>3]&&(f[d>>2]=13,J[p>>3]=_),_=+cr(16736,y),_<+J[p>>3]&&(f[d>>2]=14,J[p>>3]=_),_=+cr(16760,y),_<+J[p>>3]&&(f[d>>2]=15,J[p>>3]=_),_=+cr(16784,y),_<+J[p>>3]&&(f[d>>2]=16,J[p>>3]=_),_=+cr(16808,y),_<+J[p>>3]&&(f[d>>2]=17,J[p>>3]=_),_=+cr(16832,y),_<+J[p>>3]&&(f[d>>2]=18,J[p>>3]=_),_=+cr(16856,y),!(_<+J[p>>3])){Z=T;return}f[d>>2]=19,J[p>>3]=_,Z=T}function Vu(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0;if(T=+Xl(A),T<1e-16){d=15600+(d<<4)|0,f[y>>2]=f[d>>2],f[y+4>>2]=f[d+4>>2],f[y+8>>2]=f[d+8>>2],f[y+12>>2]=f[d+12>>2];return}if(M=+Fe(+ +J[A+8>>3],+ +J[A>>3]),(p|0)>0){A=0;do T=T*.37796447300922725,A=A+1|0;while((A|0)!=(p|0))}R=T*.3333333333333333,_?(p=(Ps(p)|0)==0,T=+ue(+((p?R:R*.37796447300922725)*.381966011250105))):(T=+ue(+(T*.381966011250105)),Ps(p)|0&&(M=+ih(M+.3334731722518321))),Cx(15600+(d<<4)|0,+ih(+J[15920+(d*24|0)>>3]-M),T,y)}function cf(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;_=Z,Z=Z+16|0,y=_,ku(A+4|0,y),Vu(y,f[A>>2]|0,d,0,p),Z=_}function ap(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0,Cn=0,li=0,Ln=0;if(Cn=Z,Z=Z+272|0,T=Cn+256|0,He=Cn+240|0,Pn=Cn,gn=Cn+224|0,Ht=Cn+208|0,Ve=Cn+176|0,Re=Cn+160|0,jt=Cn+192|0,pn=Cn+144|0,cn=Cn+128|0,jn=Cn+112|0,Bn=Cn+96|0,ei=Cn+80|0,f[T>>2]=d,f[He>>2]=f[A>>2],f[He+4>>2]=f[A+4>>2],f[He+8>>2]=f[A+8>>2],f[He+12>>2]=f[A+12>>2],op(He,T,Pn),f[y>>2]=0,He=_+p+((_|0)==5&1)|0,(He|0)<=(p|0)){Z=Cn;return}B=f[T>>2]|0,F=gn+4|0,H=Ve+4|0,re=p+5|0,me=16880+(B<<2)|0,pe=16960+(B<<2)|0,ge=cn+8|0,Ne=jn+8|0,Ie=Bn+8|0,Je=Ht+4|0,R=p;e:for(;;){M=Pn+(((R|0)%5|0)<<4)|0,f[Ht>>2]=f[M>>2],f[Ht+4>>2]=f[M+4>>2],f[Ht+8>>2]=f[M+8>>2],f[Ht+12>>2]=f[M+12>>2];do;while((ju(Ht,B,0,1)|0)==2);if((R|0)>(p|0)&(Ps(d)|0)!=0){if(f[Ve>>2]=f[Ht>>2],f[Ve+4>>2]=f[Ht+4>>2],f[Ve+8>>2]=f[Ht+8>>2],f[Ve+12>>2]=f[Ht+12>>2],ku(F,Re),_=f[Ve>>2]|0,T=f[17040+(_*80|0)+(f[gn>>2]<<2)>>2]|0,f[Ve>>2]=f[18640+(_*80|0)+(T*20|0)>>2],M=f[18640+(_*80|0)+(T*20|0)+16>>2]|0,(M|0)>0){A=0;do h1(H),A=A+1|0;while((A|0)<(M|0))}switch(M=18640+(_*80|0)+(T*20|0)+4|0,f[jt>>2]=f[M>>2],f[jt+4>>2]=f[M+4>>2],f[jt+8>>2]=f[M+8>>2],eh(jt,(f[me>>2]|0)*3|0),ys(H,jt,H),jr(H),ku(H,pn),li=+(f[pe>>2]|0),J[cn>>3]=li*3,J[ge>>3]=0,Ln=li*-1.5,J[jn>>3]=Ln,J[Ne>>3]=li*2.598076211353316,J[Bn>>3]=Ln,J[Ie>>3]=li*-2.598076211353316,f[17040+((f[Ve>>2]|0)*80|0)+(f[Ht>>2]<<2)>>2]|0){case 1:{A=jn,_=cn;break}case 3:{A=Bn,_=jn;break}case 2:{A=cn,_=Bn;break}default:{A=12;break e}}bp(Re,pn,_,A,ei),Vu(ei,f[Ve>>2]|0,B,1,y+8+(f[y>>2]<<4)|0),f[y>>2]=(f[y>>2]|0)+1}if((R|0)<(re|0)&&(ku(Je,Ve),Vu(Ve,f[Ht>>2]|0,B,1,y+8+(f[y>>2]<<4)|0),f[y>>2]=(f[y>>2]|0)+1),f[gn>>2]=f[Ht>>2],f[gn+4>>2]=f[Ht+4>>2],f[gn+8>>2]=f[Ht+8>>2],f[gn+12>>2]=f[Ht+12>>2],R=R+1|0,(R|0)>=(He|0)){A=3;break}}if((A|0)==3){Z=Cn;return}else(A|0)==12&&Vt(26970,27017,572,27027)}function op(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0;B=Z,Z=Z+128|0,_=B+64|0,y=B,T=_,M=20240,R=T+60|0;do f[T>>2]=f[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(R|0));T=y,M=20304,R=T+60|0;do f[T>>2]=f[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(R|0));R=(Ps(f[d>>2]|0)|0)==0,_=R?_:y,y=A+4|0,f1(y),d1(y),Ps(f[d>>2]|0)|0&&(Gu(y),f[d>>2]=(f[d>>2]|0)+1),f[p>>2]=f[A>>2],d=p+4|0,ys(y,_,d),jr(d),f[p+16>>2]=f[A>>2],d=p+20|0,ys(y,_+12|0,d),jr(d),f[p+32>>2]=f[A>>2],d=p+36|0,ys(y,_+24|0,d),jr(d),f[p+48>>2]=f[A>>2],d=p+52|0,ys(y,_+36|0,d),jr(d),f[p+64>>2]=f[A>>2],p=p+68|0,ys(y,_+48|0,p),jr(p),Z=B}function ju(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0;if(ge=Z,Z=Z+32|0,me=ge+12|0,R=ge,pe=A+4|0,re=f[16960+(d<<2)>>2]|0,H=(_|0)!=0,re=H?re*3|0:re,y=f[pe>>2]|0,F=A+8|0,M=f[F>>2]|0,H){if(T=A+12|0,_=f[T>>2]|0,y=M+y+_|0,(y|0)==(re|0))return pe=1,Z=ge,pe|0;B=T}else B=A+12|0,_=f[B>>2]|0,y=M+y+_|0;if((y|0)<=(re|0))return pe=0,Z=ge,pe|0;do if((_|0)>0){if(_=f[A>>2]|0,(M|0)>0){T=18640+(_*80|0)+60|0,_=A;break}_=18640+(_*80|0)+40|0,p?(Fu(me,re,0,0),uf(pe,me,R),Rd(R),ys(R,me,pe),T=_,_=A):(T=_,_=A)}else T=18640+((f[A>>2]|0)*80|0)+20|0,_=A;while(!1);if(f[_>>2]=f[T>>2],y=T+16|0,(f[y>>2]|0)>0){_=0;do h1(pe),_=_+1|0;while((_|0)<(f[y>>2]|0))}return A=T+4|0,f[me>>2]=f[A>>2],f[me+4>>2]=f[A+4>>2],f[me+8>>2]=f[A+8>>2],d=f[16880+(d<<2)>>2]|0,eh(me,H?d*3|0:d),ys(pe,me,pe),jr(pe),H?_=((f[F>>2]|0)+(f[pe>>2]|0)+(f[B>>2]|0)|0)==(re|0)?1:2:_=2,pe=_,Z=ge,pe|0}function g1(A,d){A=A|0,d=d|0;var p=0;do p=ju(A,d,0,1)|0;while((p|0)==2);return p|0}function Pd(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0;if(Bn=Z,Z=Z+240|0,T=Bn+224|0,jt=Bn+208|0,pn=Bn,cn=Bn+192|0,jn=Bn+176|0,Ie=Bn+160|0,Je=Bn+144|0,He=Bn+128|0,Ve=Bn+112|0,Re=Bn+96|0,f[T>>2]=d,f[jt>>2]=f[A>>2],f[jt+4>>2]=f[A+4>>2],f[jt+8>>2]=f[A+8>>2],f[jt+12>>2]=f[A+12>>2],lp(jt,T,pn),f[y>>2]=0,Ne=_+p+((_|0)==6&1)|0,(Ne|0)<=(p|0)){Z=Bn;return}B=f[T>>2]|0,F=p+6|0,H=16960+(B<<2)|0,re=Je+8|0,me=He+8|0,pe=Ve+8|0,ge=cn+4|0,M=0,R=p,_=-1;e:for(;;){if(T=(R|0)%6|0,A=pn+(T<<4)|0,f[cn>>2]=f[A>>2],f[cn+4>>2]=f[A+4>>2],f[cn+8>>2]=f[A+8>>2],f[cn+12>>2]=f[A+12>>2],A=M,M=ju(cn,B,0,1)|0,(R|0)>(p|0)&(Ps(d)|0)!=0&&(A|0)!=1&&(f[cn>>2]|0)!=(_|0)){switch(ku(pn+(((T+5|0)%6|0)<<4)+4|0,jn),ku(pn+(T<<4)+4|0,Ie),ei=+(f[H>>2]|0),J[Je>>3]=ei*3,J[re>>3]=0,Pn=ei*-1.5,J[He>>3]=Pn,J[me>>3]=ei*2.598076211353316,J[Ve>>3]=Pn,J[pe>>3]=ei*-2.598076211353316,T=f[jt>>2]|0,f[17040+(T*80|0)+(((_|0)==(T|0)?f[cn>>2]|0:_)<<2)>>2]|0){case 1:{A=He,_=Je;break}case 3:{A=Ve,_=He;break}case 2:{A=Je,_=Ve;break}default:{A=8;break e}}bp(jn,Ie,_,A,Re),!(Sp(jn,Re)|0)&&!(Sp(Ie,Re)|0)&&(Vu(Re,f[jt>>2]|0,B,1,y+8+(f[y>>2]<<4)|0),f[y>>2]=(f[y>>2]|0)+1)}if((R|0)<(F|0)&&(ku(ge,jn),Vu(jn,f[cn>>2]|0,B,1,y+8+(f[y>>2]<<4)|0),f[y>>2]=(f[y>>2]|0)+1),R=R+1|0,(R|0)>=(Ne|0)){A=3;break}else _=f[cn>>2]|0}if((A|0)==3){Z=Bn;return}else(A|0)==8&&Vt(27054,27017,737,27099)}function lp(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0;B=Z,Z=Z+160|0,_=B+80|0,y=B,T=_,M=20368,R=T+72|0;do f[T>>2]=f[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(R|0));T=y,M=20448,R=T+72|0;do f[T>>2]=f[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(R|0));R=(Ps(f[d>>2]|0)|0)==0,_=R?_:y,y=A+4|0,f1(y),d1(y),Ps(f[d>>2]|0)|0&&(Gu(y),f[d>>2]=(f[d>>2]|0)+1),f[p>>2]=f[A>>2],d=p+4|0,ys(y,_,d),jr(d),f[p+16>>2]=f[A>>2],d=p+20|0,ys(y,_+12|0,d),jr(d),f[p+32>>2]=f[A>>2],d=p+36|0,ys(y,_+24|0,d),jr(d),f[p+48>>2]=f[A>>2],d=p+52|0,ys(y,_+36|0,d),jr(d),f[p+64>>2]=f[A>>2],d=p+68|0,ys(y,_+48|0,d),jr(d),f[p+80>>2]=f[A>>2],p=p+84|0,ys(y,_+60|0,p),jr(p),Z=B}function nh(A,d){return A=A|0,d=d|0,d=Ut(A|0,d|0,52)|0,ee()|0,d&15|0}function v1(A,d){return A=A|0,d=d|0,d=Ut(A|0,d|0,45)|0,ee()|0,d&127|0}function bx(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,(p+-1|0)>>>0>14?(_=4,_|0):(p=Ut(A|0,d|0,(15-p|0)*3|0)|0,ee()|0,f[_>>2]=p&7,_=0,_|0)}function Sx(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;if(A>>>0>15)return _=4,_|0;if(d>>>0>121)return _=17,_|0;M=zt(A|0,0,52)|0,y=ee()|0,R=zt(d|0,0,45)|0,y=y|(ee()|0)|134225919;e:do if((A|0)>=1){for(R=1,M=(ot[20528+d>>0]|0)!=0,T=-1;;){if(d=f[p+(R+-1<<2)>>2]|0,d>>>0>6){y=18,d=10;break}if(!((d|0)==0|M^1))if((d|0)==1){y=19,d=10;break}else M=0;if(F=(15-R|0)*3|0,B=zt(7,0,F|0)|0,y=y&~(ee()|0),d=zt(d|0,((d|0)<0)<<31>>31|0,F|0)|0,T=d|T&~B,y=ee()|0|y,(R|0)<(A|0))R=R+1|0;else break e}if((d|0)==10)return y|0}else T=-1;while(!1);return F=_,f[F>>2]=T,f[F+4>>2]=y,F=0,F|0}function Ld(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;return!(!0&(d&-16777216|0)==134217728)||(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,p=Ut(A|0,d|0,45)|0,ee()|0,p=p&127,p>>>0>121)?(A=0,A|0):(M=(_^15)*3|0,y=Ut(A|0,d|0,M|0)|0,M=zt(y|0,ee()|0,M|0)|0,y=ee()|0,T=Hr(-1227133514,-1171,M|0,y|0)|0,!((M&613566756&T|0)==0&(y&4681&(ee()|0)|0)==0)||(M=(_*3|0)+19|0,T=zt(~A|0,~d|0,M|0)|0,M=Ut(T|0,ee()|0,M|0)|0,!((_|0)==15|(M|0)==0&(ee()|0)==0))?(M=0,M|0):!(ot[20528+p>>0]|0)||(d=d&8191,(A|0)==0&(d|0)==0)?(M=1,M|0):(M=pf(A|0,d|0)|0,ee()|0,((63-M|0)%3|0|0)!=0|0))}function _1(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;return!0&(d&-16777216|0)==134217728&&(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,p=Ut(A|0,d|0,45)|0,ee()|0,p=p&127,p>>>0<=121)&&(M=(_^15)*3|0,y=Ut(A|0,d|0,M|0)|0,M=zt(y|0,ee()|0,M|0)|0,y=ee()|0,T=Hr(-1227133514,-1171,M|0,y|0)|0,(M&613566756&T|0)==0&(y&4681&(ee()|0)|0)==0)&&(M=(_*3|0)+19|0,T=zt(~A|0,~d|0,M|0)|0,M=Ut(T|0,ee()|0,M|0)|0,(_|0)==15|(M|0)==0&(ee()|0)==0)&&(!(ot[20528+p>>0]|0)||(p=d&8191,(A|0)==0&(p|0)==0)||(M=pf(A|0,p|0)|0,ee()|0,(63-M|0)%3|0|0))||m1(A,d)|0?(M=1,M|0):(M=(_l(A,d)|0)!=0&1,M|0)}function Hu(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0;if(y=zt(d|0,0,52)|0,T=ee()|0,p=zt(p|0,0,45)|0,p=T|(ee()|0)|134225919,(d|0)<1){T=-1,_=p,d=A,f[d>>2]=T,A=A+4|0,f[A>>2]=_;return}for(T=1,y=-1;M=(15-T|0)*3|0,R=zt(7,0,M|0)|0,p=p&~(ee()|0),M=zt(_|0,0,M|0)|0,y=y&~R|M,p=p|(ee()|0),(T|0)!=(d|0);)T=T+1|0;R=A,M=R,f[M>>2]=y,R=R+4|0,f[R>>2]=p}function Wu(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0;if(T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,p>>>0>15)return _=4,_|0;if((T|0)<(p|0))return _=12,_|0;if((T|0)==(p|0))return f[_>>2]=A,f[_+4>>2]=d,_=0,_|0;if(y=zt(p|0,0,52)|0,y=y|A,A=ee()|0|d&-15728641,(T|0)>(p|0))do d=zt(7,0,(14-p|0)*3|0)|0,p=p+1|0,y=d|y,A=ee()|0|A;while((p|0)<(T|0));return f[_>>2]=y,f[_+4>>2]=A,_=0,_|0}function hf(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0;if(T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,!((p|0)<16&(T|0)<=(p|0)))return _=4,_|0;y=p-T|0,p=Ut(A|0,d|0,45)|0,ee()|0;e:do if(!($n(p&127)|0))p=jo(7,0,y,((y|0)<0)<<31>>31)|0,y=ee()|0;else{t:do if(T|0){for(p=1;M=zt(7,0,(15-p|0)*3|0)|0,!!((M&A|0)==0&((ee()|0)&d|0)==0);)if(p>>>0>>0)p=p+1|0;else break t;p=jo(7,0,y,((y|0)<0)<<31>>31)|0,y=ee()|0;break e}while(!1);p=jo(7,0,y,((y|0)<0)<<31>>31)|0,p=vr(p|0,ee()|0,5,0)|0,p=rn(p|0,ee()|0,-5,-1)|0,p=Xo(p|0,ee()|0,6,0)|0,p=rn(p|0,ee()|0,1,0)|0,y=ee()|0}while(!1);return M=_,f[M>>2]=p,f[M+4>>2]=y,M=0,M|0}function Ri(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;if(y=Ut(A|0,d|0,45)|0,ee()|0,!($n(y&127)|0))return y=0,y|0;y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15;e:do if(!y)p=0;else for(_=1;;){if(p=Ut(A|0,d|0,(15-_|0)*3|0)|0,ee()|0,p=p&7,p|0)break e;if(_>>>0>>0)_=_+1|0;else{p=0;break}}while(!1);return y=(p|0)==0&1,y|0}function y1(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0;if(M=Z,Z=Z+16|0,T=M,pl(T,A,d,p),d=T,A=f[d>>2]|0,d=f[d+4>>2]|0,(A|0)==0&(d|0)==0)return Z=M,0;y=0,p=0;do R=_+(y<<3)|0,f[R>>2]=A,f[R+4>>2]=d,y=rn(y|0,p|0,1,0)|0,p=ee()|0,ff(T),R=T,A=f[R>>2]|0,d=f[R+4>>2]|0;while(!((A|0)==0&(d|0)==0));return Z=M,0}function up(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,(_|0)<(p|0)?(p=d,_=A,Mt(p|0),_|0):(p=zt(-1,-1,((_-p|0)*3|0)+3|0)|0,_=zt(~p|0,~(ee()|0)|0,(15-_|0)*3|0)|0,p=~(ee()|0)&d,_=~_&A,Mt(p|0),_|0)}function Ud(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0;return y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,(p|0)<16&(y|0)<=(p|0)?((y|0)<(p|0)&&(y=zt(-1,-1,((p+-1-y|0)*3|0)+3|0)|0,y=zt(~y|0,~(ee()|0)|0,(15-p|0)*3|0)|0,d=~(ee()|0)&d,A=~y&A),y=zt(p|0,0,52)|0,p=d&-15728641|(ee()|0),f[_>>2]=A|y,f[_+4>>2]=p,_=0,_|0):(_=4,_|0)}function cp(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0;if((p|0)==0&(_|0)==0)return Ht=0,Ht|0;if(y=A,T=f[y>>2]|0,y=f[y+4>>2]|0,!0&(y&15728640|0)==0){if(!((_|0)>0|(_|0)==0&p>>>0>0)||(Ht=d,f[Ht>>2]=T,f[Ht+4>>2]=y,(p|0)==1&(_|0)==0))return Ht=0,Ht|0;y=1,T=0;do Pn=A+(y<<3)|0,gn=f[Pn+4>>2]|0,Ht=d+(y<<3)|0,f[Ht>>2]=f[Pn>>2],f[Ht+4>>2]=gn,y=rn(y|0,T|0,1,0)|0,T=ee()|0;while((T|0)<(_|0)|(T|0)==(_|0)&y>>>0

>>0);return y=0,y|0}if(ei=p<<3,gn=$o(ei)|0,!gn)return Ht=13,Ht|0;if(Yl(gn|0,A|0,ei|0)|0,Pn=sa(p,8)|0,!Pn)return wn(gn),Ht=13,Ht|0;e:for(;;){y=gn,F=f[y>>2]|0,y=f[y+4>>2]|0,jn=Ut(F|0,y|0,52)|0,ee()|0,jn=jn&15,Bn=jn+-1|0,cn=(jn|0)!=0,pn=(_|0)>0|(_|0)==0&p>>>0>0;t:do if(cn&pn){if(He=zt(Bn|0,0,52)|0,Ve=ee()|0,Bn>>>0>15){if(!((F|0)==0&(y|0)==0)){Ht=16;break e}for(T=0,A=0;;){if(T=rn(T|0,A|0,1,0)|0,A=ee()|0,!((A|0)<(_|0)|(A|0)==(_|0)&T>>>0

>>0))break t;if(M=gn+(T<<3)|0,jt=f[M>>2]|0,M=f[M+4>>2]|0,!((jt|0)==0&(M|0)==0)){y=M,Ht=16;break e}}}for(R=F,A=y,T=0,M=0;;){if(!((R|0)==0&(A|0)==0)){if(!(!0&(A&117440512|0)==0)){Ht=21;break e}if(H=Ut(R|0,A|0,52)|0,ee()|0,H=H&15,(H|0)<(Bn|0)){y=12,Ht=27;break e}if((H|0)!=(Bn|0)&&(R=R|He,A=A&-15728641|Ve,H>>>0>=jn>>>0)){B=Bn;do jt=zt(7,0,(14-B|0)*3|0)|0,B=B+1|0,R=jt|R,A=ee()|0|A;while(B>>>0>>0)}if(me=lc(R|0,A|0,p|0,_|0)|0,pe=ee()|0,B=Pn+(me<<3)|0,H=B,re=f[H>>2]|0,H=f[H+4>>2]|0,!((re|0)==0&(H|0)==0)){Ie=0,Je=0;do{if((Ie|0)>(_|0)|(Ie|0)==(_|0)&Je>>>0>p>>>0){Ht=31;break e}if((re|0)==(R|0)&(H&-117440513|0)==(A|0)){ge=Ut(re|0,H|0,56)|0,ee()|0,ge=ge&7,Ne=ge+1|0,jt=Ut(re|0,H|0,45)|0,ee()|0;n:do if(!($n(jt&127)|0))H=7;else{if(re=Ut(re|0,H|0,52)|0,ee()|0,re=re&15,!re){H=6;break}for(H=1;;){if(jt=zt(7,0,(15-H|0)*3|0)|0,!((jt&R|0)==0&((ee()|0)&A|0)==0)){H=7;break n}if(H>>>0>>0)H=H+1|0;else{H=6;break}}}while(!1);if((ge+2|0)>>>0>H>>>0){Ht=41;break e}jt=zt(Ne|0,0,56)|0,A=ee()|0|A&-117440513,Re=B,f[Re>>2]=0,f[Re+4>>2]=0,R=jt|R}else me=rn(me|0,pe|0,1,0)|0,me=oh(me|0,ee()|0,p|0,_|0)|0,pe=ee()|0;Je=rn(Je|0,Ie|0,1,0)|0,Ie=ee()|0,B=Pn+(me<<3)|0,H=B,re=f[H>>2]|0,H=f[H+4>>2]|0}while(!((re|0)==0&(H|0)==0))}jt=B,f[jt>>2]=R,f[jt+4>>2]=A}if(T=rn(T|0,M|0,1,0)|0,M=ee()|0,!((M|0)<(_|0)|(M|0)==(_|0)&T>>>0

>>0))break t;A=gn+(T<<3)|0,R=f[A>>2]|0,A=f[A+4>>2]|0}}while(!1);if(jt=rn(p|0,_|0,5,0)|0,Re=ee()|0,Re>>>0<0|(Re|0)==0&jt>>>0<11){Ht=85;break}if(jt=Xo(p|0,_|0,6,0)|0,ee()|0,jt=sa(jt,8)|0,!jt){Ht=48;break}do if(pn){for(Ne=0,A=0,ge=0,Ie=0;;){if(H=Pn+(Ne<<3)|0,M=H,T=f[M>>2]|0,M=f[M+4>>2]|0,(T|0)==0&(M|0)==0)Re=ge;else{re=Ut(T|0,M|0,56)|0,ee()|0,re=re&7,R=re+1|0,me=M&-117440513,Re=Ut(T|0,M|0,45)|0,ee()|0;t:do if($n(Re&127)|0){if(pe=Ut(T|0,M|0,52)|0,ee()|0,pe=pe&15,pe|0)for(B=1;;){if(Re=zt(7,0,(15-B|0)*3|0)|0,!((T&Re|0)==0&(me&(ee()|0)|0)==0))break t;if(B>>>0>>0)B=B+1|0;else break}M=zt(R|0,0,56)|0,T=M|T,M=ee()|0|me,R=H,f[R>>2]=T,f[R+4>>2]=M,R=re+2|0}while(!1);(R|0)==7?(Re=jt+(A<<3)|0,f[Re>>2]=T,f[Re+4>>2]=M&-117440513,A=rn(A|0,ge|0,1,0)|0,Re=ee()|0):Re=ge}if(Ne=rn(Ne|0,Ie|0,1,0)|0,Ie=ee()|0,(Ie|0)<(_|0)|(Ie|0)==(_|0)&Ne>>>0

>>0)ge=Re;else break}if(pn){if(Je=Bn>>>0>15,He=zt(Bn|0,0,52)|0,Ve=ee()|0,!cn){for(T=0,B=0,R=0,M=0;(F|0)==0&(y|0)==0||(Bn=d+(T<<3)|0,f[Bn>>2]=F,f[Bn+4>>2]=y,T=rn(T|0,B|0,1,0)|0,B=ee()|0),R=rn(R|0,M|0,1,0)|0,M=ee()|0,!!((M|0)<(_|0)|(M|0)==(_|0)&R>>>0

>>0);)y=gn+(R<<3)|0,F=f[y>>2]|0,y=f[y+4>>2]|0;y=Re;break}for(T=0,B=0,M=0,R=0;;){do if(!((F|0)==0&(y|0)==0)){if(pe=Ut(F|0,y|0,52)|0,ee()|0,pe=pe&15,Je|(pe|0)<(Bn|0)){Ht=80;break e}if((pe|0)!=(Bn|0)){if(H=F|He,re=y&-15728641|Ve,pe>>>0>=jn>>>0){me=Bn;do cn=zt(7,0,(14-me|0)*3|0)|0,me=me+1|0,H=cn|H,re=ee()|0|re;while(me>>>0>>0)}}else H=F,re=y;ge=lc(H|0,re|0,p|0,_|0)|0,me=0,pe=0,Ie=ee()|0;do{if((me|0)>(_|0)|(me|0)==(_|0)&pe>>>0>p>>>0){Ht=81;break e}if(cn=Pn+(ge<<3)|0,Ne=f[cn+4>>2]|0,(Ne&-117440513|0)==(re|0)&&(f[cn>>2]|0)==(H|0)){Ht=65;break}cn=rn(ge|0,Ie|0,1,0)|0,ge=oh(cn|0,ee()|0,p|0,_|0)|0,Ie=ee()|0,pe=rn(pe|0,me|0,1,0)|0,me=ee()|0,cn=Pn+(ge<<3)|0}while(!((f[cn>>2]|0)==(H|0)&&(f[cn+4>>2]|0)==(re|0)));if((Ht|0)==65&&(Ht=0,!0&(Ne&117440512|0)==100663296))break;cn=d+(T<<3)|0,f[cn>>2]=F,f[cn+4>>2]=y,T=rn(T|0,B|0,1,0)|0,B=ee()|0}while(!1);if(M=rn(M|0,R|0,1,0)|0,R=ee()|0,!((R|0)<(_|0)|(R|0)==(_|0)&M>>>0

>>0))break;y=gn+(M<<3)|0,F=f[y>>2]|0,y=f[y+4>>2]|0}y=Re}else T=0,y=Re}else T=0,A=0,y=0;while(!1);if(vo(Pn|0,0,ei|0)|0,Yl(gn|0,jt|0,A<<3|0)|0,wn(jt),(A|0)==0&(y|0)==0){Ht=89;break}else d=d+(T<<3)|0,_=y,p=A}if((Ht|0)==16)!0&(y&117440512|0)==0?(y=4,Ht=27):Ht=21;else if((Ht|0)==31)Vt(27795,27122,620,27132);else{if((Ht|0)==41)return wn(gn),wn(Pn),Ht=10,Ht|0;if((Ht|0)==48)return wn(gn),wn(Pn),Ht=13,Ht|0;(Ht|0)==80?Vt(27795,27122,711,27132):(Ht|0)==81?Vt(27795,27122,723,27132):(Ht|0)==85&&(Yl(d|0,gn|0,p<<3|0)|0,Ht=89)}return(Ht|0)==21?(wn(gn),wn(Pn),Ht=5,Ht|0):(Ht|0)==27?(wn(gn),wn(Pn),Ht=y,Ht|0):(Ht|0)==89?(wn(gn),wn(Pn),Ht=0,Ht|0):0}function x1(A,d,p,_,y,T,M){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0;var R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0;if(Ne=Z,Z=Z+16|0,ge=Ne,!((p|0)>0|(p|0)==0&d>>>0>0))return ge=0,Z=Ne,ge|0;if((M|0)>=16)return ge=12,Z=Ne,ge|0;me=0,pe=0,re=0,R=0;e:for(;;){if(F=A+(me<<3)|0,B=f[F>>2]|0,F=f[F+4>>2]|0,H=Ut(B|0,F|0,52)|0,ee()|0,(H&15|0)>(M|0)){R=12,B=11;break}if(pl(ge,B,F,M),H=ge,F=f[H>>2]|0,H=f[H+4>>2]|0,(F|0)==0&(H|0)==0)B=re;else{B=re;do{if(!((R|0)<(T|0)|(R|0)==(T|0)&B>>>0>>0)){B=10;break e}re=_+(B<<3)|0,f[re>>2]=F,f[re+4>>2]=H,B=rn(B|0,R|0,1,0)|0,R=ee()|0,ff(ge),re=ge,F=f[re>>2]|0,H=f[re+4>>2]|0}while(!((F|0)==0&(H|0)==0))}if(me=rn(me|0,pe|0,1,0)|0,pe=ee()|0,(pe|0)<(p|0)|(pe|0)==(p|0)&me>>>0>>0)re=B;else{R=0,B=11;break}}return(B|0)==10?(ge=14,Z=Ne,ge|0):(B|0)==11?(Z=Ne,R|0):0}function b1(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;me=Z,Z=Z+16|0,re=me;e:do if((p|0)>0|(p|0)==0&d>>>0>0){for(F=0,M=0,T=0,H=0;;){if(B=A+(F<<3)|0,R=f[B>>2]|0,B=f[B+4>>2]|0,!((R|0)==0&(B|0)==0)&&(B=(hf(R,B,_,re)|0)==0,R=re,M=rn(f[R>>2]|0,f[R+4>>2]|0,M|0,T|0)|0,T=ee()|0,!B)){T=12;break}if(F=rn(F|0,H|0,1,0)|0,H=ee()|0,!((H|0)<(p|0)|(H|0)==(p|0)&F>>>0>>0))break e}return Z=me,T|0}else M=0,T=0;while(!1);return f[y>>2]=M,f[y+4>>2]=T,y=0,Z=me,y|0}function S1(A,d){return A=A|0,d=d|0,d=Ut(A|0,d|0,52)|0,ee()|0,d&1|0}function ta(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;if(y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,!y)return y=0,y|0;for(_=1;;){if(p=Ut(A|0,d|0,(15-_|0)*3|0)|0,ee()|0,p=p&7,p|0){_=5;break}if(_>>>0>>0)_=_+1|0;else{p=0,_=5;break}}return(_|0)==5?p|0:0}function hp(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(B=Ut(A|0,d|0,52)|0,ee()|0,B=B&15,!B)return R=d,B=A,Mt(R|0),B|0;for(R=1,p=0;;){T=(15-R|0)*3|0,_=zt(7,0,T|0)|0,y=ee()|0,M=Ut(A|0,d|0,T|0)|0,ee()|0,T=zt(qu(M&7)|0,0,T|0)|0,M=ee()|0,A=T|A&~_,d=M|d&~y;e:do if(!p)if((T&_|0)==0&(M&y|0)==0)p=0;else if(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ut(A|0,d|0,(15-p|0)*3|0)|0,ee()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(M=(15-p|0)*3|0,y=Ut(A|0,d|0,M|0)|0,ee()|0,T=zt(7,0,M|0)|0,d=d&~(ee()|0),M=zt(qu(y&7)|0,0,M|0)|0,A=A&~T|M,d=d|(ee()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return Mt(d|0),A|0}function $u(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;if(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,!_)return p=d,_=A,Mt(p|0),_|0;for(p=1;T=(15-p|0)*3|0,M=Ut(A|0,d|0,T|0)|0,ee()|0,y=zt(7,0,T|0)|0,d=d&~(ee()|0),T=zt(qu(M&7)|0,0,T|0)|0,A=T|A&~y,d=ee()|0|d,p>>>0<_>>>0;)p=p+1|0;return Mt(d|0),A|0}function Tx(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(B=Ut(A|0,d|0,52)|0,ee()|0,B=B&15,!B)return R=d,B=A,Mt(R|0),B|0;for(R=1,p=0;;){T=(15-R|0)*3|0,_=zt(7,0,T|0)|0,y=ee()|0,M=Ut(A|0,d|0,T|0)|0,ee()|0,T=zt(Al(M&7)|0,0,T|0)|0,M=ee()|0,A=T|A&~_,d=M|d&~y;e:do if(!p)if((T&_|0)==0&(M&y|0)==0)p=0;else if(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ut(A|0,d|0,(15-p|0)*3|0)|0,ee()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(y=(15-p|0)*3|0,T=zt(7,0,y|0)|0,M=d&~(ee()|0),d=Ut(A|0,d|0,y|0)|0,ee()|0,d=zt(Al(d&7)|0,0,y|0)|0,A=A&~T|d,d=M|(ee()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return Mt(d|0),A|0}function fp(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;if(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,!_)return p=d,_=A,Mt(p|0),_|0;for(p=1;M=(15-p|0)*3|0,T=zt(7,0,M|0)|0,y=d&~(ee()|0),d=Ut(A|0,d|0,M|0)|0,ee()|0,d=zt(Al(d&7)|0,0,M|0)|0,A=d|A&~T,d=ee()|0|y,p>>>0<_>>>0;)p=p+1|0;return Mt(d|0),A|0}function ya(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(B=Z,Z=Z+64|0,R=B+40|0,_=B+24|0,y=B+12|0,T=B,zt(d|0,0,52)|0,p=ee()|0|134225919,!d)return(f[A+4>>2]|0)>2||(f[A+8>>2]|0)>2||(f[A+12>>2]|0)>2?(M=0,R=0,Mt(M|0),Z=B,R|0):(zt(er(A)|0,0,45)|0,M=ee()|0|p,R=-1,Mt(M|0),Z=B,R|0);if(f[R>>2]=f[A>>2],f[R+4>>2]=f[A+4>>2],f[R+8>>2]=f[A+8>>2],f[R+12>>2]=f[A+12>>2],M=R+4|0,(d|0)>0)for(A=-1;f[_>>2]=f[M>>2],f[_+4>>2]=f[M+4>>2],f[_+8>>2]=f[M+8>>2],d&1?(hx(M),f[y>>2]=f[M>>2],f[y+4>>2]=f[M+4>>2],f[y+8>>2]=f[M+8>>2],th(y)):(u1(M),f[y>>2]=f[M>>2],f[y+4>>2]=f[M+4>>2],f[y+8>>2]=f[M+8>>2],Gu(y)),uf(_,y,T),jr(T),H=(15-d|0)*3|0,F=zt(7,0,H|0)|0,p=p&~(ee()|0),H=zt(zu(T)|0,0,H|0)|0,A=H|A&~F,p=ee()|0|p,(d|0)>1;)d=d+-1|0;else A=-1;e:do if((f[M>>2]|0)<=2&&(f[R+8>>2]|0)<=2&&(f[R+12>>2]|0)<=2){if(_=er(R)|0,d=zt(_|0,0,45)|0,d=d|A,A=ee()|0|p&-1040385,T=po(R)|0,!($n(_)|0)){if((T|0)<=0)break;for(y=0;;){if(_=Ut(d|0,A|0,52)|0,ee()|0,_=_&15,_)for(p=1;H=(15-p|0)*3|0,R=Ut(d|0,A|0,H|0)|0,ee()|0,F=zt(7,0,H|0)|0,A=A&~(ee()|0),H=zt(qu(R&7)|0,0,H|0)|0,d=d&~F|H,A=A|(ee()|0),p>>>0<_>>>0;)p=p+1|0;if(y=y+1|0,(y|0)==(T|0))break e}}y=Ut(d|0,A|0,52)|0,ee()|0,y=y&15;t:do if(y){p=1;n:for(;;){switch(H=Ut(d|0,A|0,(15-p|0)*3|0)|0,ee()|0,H&7){case 1:break n;case 0:break;default:break t}if(p>>>0>>0)p=p+1|0;else break t}if(yi(_,f[R>>2]|0)|0)for(p=1;R=(15-p|0)*3|0,F=zt(7,0,R|0)|0,H=A&~(ee()|0),A=Ut(d|0,A|0,R|0)|0,ee()|0,A=zt(Al(A&7)|0,0,R|0)|0,d=d&~F|A,A=H|(ee()|0),p>>>0>>0;)p=p+1|0;else for(p=1;H=(15-p|0)*3|0,R=Ut(d|0,A|0,H|0)|0,ee()|0,F=zt(7,0,H|0)|0,A=A&~(ee()|0),H=zt(qu(R&7)|0,0,H|0)|0,d=d&~F|H,A=A|(ee()|0),p>>>0>>0;)p=p+1|0}while(!1);if((T|0)>0){p=0;do d=hp(d,A)|0,A=ee()|0,p=p+1|0;while((p|0)!=(T|0))}}else d=0,A=0;while(!1);return F=A,H=d,Mt(F|0),Z=B,H|0}function Ps(A){return A=A|0,(A|0)%2|0|0}function Bd(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;return y=Z,Z=Z+16|0,_=y,d>>>0>15?(_=4,Z=y,_|0):(f[A+4>>2]&2146435072|0)==2146435072||(f[A+8+4>>2]&2146435072|0)==2146435072?(_=3,Z=y,_|0):(_x(A,d,_),d=ya(_,d)|0,_=ee()|0,f[p>>2]=d,f[p+4>>2]=_,(d|0)==0&(_|0)==0&&Vt(27795,27122,1050,27145),_=0,Z=y,_|0)}function Od(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;if(y=p+4|0,T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,M=Ut(A|0,d|0,45)|0,ee()|0,_=(T|0)==0,$n(M&127)|0){if(_)return M=1,M|0;_=1}else{if(_)return M=0,M|0;(f[y>>2]|0)==0&&(f[p+8>>2]|0)==0?_=(f[p+12>>2]|0)!=0&1:_=1}for(p=1;p&1?th(y):Gu(y),M=Ut(A|0,d|0,(15-p|0)*3|0)|0,ee()|0,c1(y,M&7),p>>>0>>0;)p=p+1|0;return _|0}function Xu(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(H=Z,Z=Z+16|0,B=H,F=Ut(A|0,d|0,45)|0,ee()|0,F=F&127,F>>>0>121)return f[p>>2]=0,f[p+4>>2]=0,f[p+8>>2]=0,f[p+12>>2]=0,F=5,Z=H,F|0;e:do if(($n(F)|0)!=0&&(T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,(T|0)!=0)){_=1;t:for(;;){switch(R=Ut(A|0,d|0,(15-_|0)*3|0)|0,ee()|0,R&7){case 5:break t;case 0:break;default:{_=d;break e}}if(_>>>0>>0)_=_+1|0;else{_=d;break e}}for(y=1,_=d;d=(15-y|0)*3|0,M=zt(7,0,d|0)|0,R=_&~(ee()|0),_=Ut(A|0,_|0,d|0)|0,ee()|0,_=zt(Al(_&7)|0,0,d|0)|0,A=A&~M|_,_=R|(ee()|0),y>>>0>>0;)y=y+1|0}else _=d;while(!1);if(R=7696+(F*28|0)|0,f[p>>2]=f[R>>2],f[p+4>>2]=f[R+4>>2],f[p+8>>2]=f[R+8>>2],f[p+12>>2]=f[R+12>>2],!(Od(A,_,p)|0))return F=0,Z=H,F|0;if(M=p+4|0,f[B>>2]=f[M>>2],f[B+4>>2]=f[M+4>>2],f[B+8>>2]=f[M+8>>2],T=Ut(A|0,_|0,52)|0,ee()|0,R=T&15,T&1?(Gu(M),T=R+1|0):T=R,!($n(F)|0))_=0;else{e:do if(!R)_=0;else for(d=1;;){if(y=Ut(A|0,_|0,(15-d|0)*3|0)|0,ee()|0,y=y&7,y|0){_=y;break e}if(d>>>0>>0)d=d+1|0;else{_=0;break}}while(!1);_=(_|0)==4&1}if(!(ju(p,T,_,0)|0))(T|0)!=(R|0)&&(f[M>>2]=f[B>>2],f[M+4>>2]=f[B+4>>2],f[M+8>>2]=f[B+8>>2]);else{if($n(F)|0)do;while((ju(p,T,0,0)|0)!=0);(T|0)!=(R|0)&&u1(M)}return F=0,Z=H,F|0}function jl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;return T=Z,Z=Z+16|0,_=T,y=Xu(A,d,_)|0,y|0?(Z=T,y|0):(y=Ut(A|0,d|0,52)|0,ee()|0,cf(_,y&15,p),y=0,Z=T,y|0)}function Hl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0;if(M=Z,Z=Z+16|0,T=M,_=Xu(A,d,T)|0,_|0)return T=_,Z=M,T|0;_=Ut(A|0,d|0,45)|0,ee()|0,_=($n(_&127)|0)==0,y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15;e:do if(!_){if(y|0)for(_=1;;){if(R=zt(7,0,(15-_|0)*3|0)|0,!((R&A|0)==0&((ee()|0)&d|0)==0))break e;if(_>>>0>>0)_=_+1|0;else break}return ap(T,y,0,5,p),R=0,Z=M,R|0}while(!1);return Pd(T,y,0,6,p),R=0,Z=M,R|0}function wx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if(y=Ut(A|0,d|0,45)|0,ee()|0,!($n(y&127)|0))return y=2,f[p>>2]=y,0;if(y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,!y)return y=5,f[p>>2]=y,0;for(_=1;;){if(T=zt(7,0,(15-_|0)*3|0)|0,!((T&A|0)==0&((ee()|0)&d|0)==0)){_=2,A=6;break}if(_>>>0>>0)_=_+1|0;else{_=5,A=6;break}}return(A|0)==6&&(f[p>>2]=_),0}function Yu(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0;re=Z,Z=Z+128|0,F=re+112|0,T=re+96|0,H=re,y=Ut(A|0,d|0,52)|0,ee()|0,R=y&15,f[F>>2]=R,M=Ut(A|0,d|0,45)|0,ee()|0,M=M&127;e:do if($n(M)|0){if(R|0)for(_=1;;){if(B=zt(7,0,(15-_|0)*3|0)|0,!((B&A|0)==0&((ee()|0)&d|0)==0)){y=0;break e}if(_>>>0>>0)_=_+1|0;else break}if(y&1)y=1;else return B=zt(R+1|0,0,52)|0,H=ee()|0|d&-15728641,F=zt(7,0,(14-R|0)*3|0)|0,H=Yu((B|A)&~F,H&~(ee()|0),p)|0,Z=re,H|0}else y=0;while(!1);if(_=Xu(A,d,T)|0,!_){y?(op(T,F,H),B=5):(lp(T,F,H),B=6);e:do if($n(M)|0)if(!R)A=5;else for(_=1;;){if(M=zt(7,0,(15-_|0)*3|0)|0,!((M&A|0)==0&((ee()|0)&d|0)==0)){A=2;break e}if(_>>>0>>0)_=_+1|0;else{A=5;break}}else A=2;while(!1);vo(p|0,-1,A<<2|0)|0;e:do if(y)for(T=0;;){if(M=H+(T<<4)|0,g1(M,f[F>>2]|0)|0,M=f[M>>2]|0,R=f[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=A>>>0){_=1;break e}_=p+(y<<2)|0,R=f[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(f[_>>2]=M,T=T+1|0,T>>>0>=B>>>0){_=0;break}}else for(T=0;;){if(M=H+(T<<4)|0,ju(M,f[F>>2]|0,0,1)|0,M=f[M>>2]|0,R=f[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=A>>>0){_=1;break e}_=p+(y<<2)|0,R=f[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(f[_>>2]=M,T=T+1|0,T>>>0>=B>>>0){_=0;break}}while(!1)}return H=_,Z=re,H|0}function dp(){return 12}function Qu(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(A>>>0>15)return R=4,R|0;if(zt(A|0,0,52)|0,R=ee()|0|134225919,!A){p=0,_=0;do $n(_)|0&&(zt(_|0,0,45)|0,M=R|(ee()|0),A=d+(p<<3)|0,f[A>>2]=-1,f[A+4>>2]=M,p=p+1|0),_=_+1|0;while((_|0)!=122);return p=0,p|0}p=0,M=0;do{if($n(M)|0){for(zt(M|0,0,45)|0,_=1,y=-1,T=R|(ee()|0);B=zt(7,0,(15-_|0)*3|0)|0,y=y&~B,T=T&~(ee()|0),(_|0)!=(A|0);)_=_+1|0;B=d+(p<<3)|0,f[B>>2]=y,f[B+4>>2]=T,p=p+1|0}M=M+1|0}while((M|0)!=122);return p=0,p|0}function Ap(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0;if(He=Z,Z=Z+16|0,Ie=He,Je=Ut(A|0,d|0,52)|0,ee()|0,Je=Je&15,p>>>0>15)return Je=4,Z=He,Je|0;if((Je|0)<(p|0))return Je=12,Z=He,Je|0;if((Je|0)!=(p|0))if(T=zt(p|0,0,52)|0,T=T|A,R=ee()|0|d&-15728641,(Je|0)>(p|0)){B=p;do Ne=zt(7,0,(14-B|0)*3|0)|0,B=B+1|0,T=Ne|T,R=ee()|0|R;while((B|0)<(Je|0));Ne=T}else Ne=T;else Ne=A,R=d;ge=Ut(Ne|0,R|0,45)|0,ee()|0;e:do if($n(ge&127)|0){if(B=Ut(Ne|0,R|0,52)|0,ee()|0,B=B&15,B|0)for(T=1;;){if(ge=zt(7,0,(15-T|0)*3|0)|0,!((ge&Ne|0)==0&((ee()|0)&R|0)==0)){F=33;break e}if(T>>>0>>0)T=T+1|0;else break}if(ge=_,f[ge>>2]=0,f[ge+4>>2]=0,(Je|0)>(p|0)){for(ge=d&-15728641,pe=Je;;){if(me=pe,pe=pe+-1|0,pe>>>0>15|(Je|0)<(pe|0)){F=19;break}if((Je|0)!=(pe|0))if(T=zt(pe|0,0,52)|0,T=T|A,B=ee()|0|ge,(Je|0)<(me|0))re=T;else{F=pe;do re=zt(7,0,(14-F|0)*3|0)|0,F=F+1|0,T=re|T,B=ee()|0|B;while((F|0)<(Je|0));re=T}else re=A,B=d;if(H=Ut(re|0,B|0,45)|0,ee()|0,!($n(H&127)|0))T=0;else{H=Ut(re|0,B|0,52)|0,ee()|0,H=H&15;t:do if(!H)T=0;else for(F=1;;){if(T=Ut(re|0,B|0,(15-F|0)*3|0)|0,ee()|0,T=T&7,T|0)break t;if(F>>>0>>0)F=F+1|0;else{T=0;break}}while(!1);T=(T|0)==0&1}if(B=Ut(A|0,d|0,(15-me|0)*3|0)|0,ee()|0,B=B&7,(B|0)==7){y=5,F=42;break}if(T=(T|0)!=0,(B|0)==1&T){y=5,F=42;break}if(re=B+(((B|0)!=0&T)<<31>>31)|0,re|0&&(F=Je-me|0,F=jo(7,0,F,((F|0)<0)<<31>>31)|0,H=ee()|0,T?(T=vr(F|0,H|0,5,0)|0,T=rn(T|0,ee()|0,-5,-1)|0,T=Xo(T|0,ee()|0,6,0)|0,T=rn(T|0,ee()|0,1,0)|0,B=ee()|0):(T=F,B=H),me=re+-1|0,me=vr(F|0,H|0,me|0,((me|0)<0)<<31>>31|0)|0,me=rn(T|0,B|0,me|0,ee()|0)|0,re=ee()|0,H=_,H=rn(me|0,re|0,f[H>>2]|0,f[H+4>>2]|0)|0,re=ee()|0,me=_,f[me>>2]=H,f[me+4>>2]=re),(pe|0)<=(p|0)){F=37;break}}if((F|0)==19)Vt(27795,27122,1367,27158);else if((F|0)==37){M=_,y=f[M+4>>2]|0,M=f[M>>2]|0;break}else if((F|0)==42)return Z=He,y|0}else y=0,M=0}else F=33;while(!1);e:do if((F|0)==33)if(ge=_,f[ge>>2]=0,f[ge+4>>2]=0,(Je|0)>(p|0)){for(T=Je;;){if(y=Ut(A|0,d|0,(15-T|0)*3|0)|0,ee()|0,y=y&7,(y|0)==7){y=5;break}if(M=Je-T|0,M=jo(7,0,M,((M|0)<0)<<31>>31)|0,y=vr(M|0,ee()|0,y|0,0)|0,M=ee()|0,ge=_,M=rn(f[ge>>2]|0,f[ge+4>>2]|0,y|0,M|0)|0,y=ee()|0,ge=_,f[ge>>2]=M,f[ge+4>>2]=y,T=T+-1|0,(T|0)<=(p|0))break e}return Z=He,y|0}else y=0,M=0;while(!1);return hf(Ne,R,Je,Ie)|0&&Vt(27795,27122,1327,27173),Je=Ie,Ie=f[Je+4>>2]|0,((y|0)>-1|(y|0)==-1&M>>>0>4294967295)&((Ie|0)>(y|0)|((Ie|0)==(y|0)?(f[Je>>2]|0)>>>0>M>>>0:0))?(Je=0,Z=He,Je|0):(Vt(27795,27122,1407,27158),0)}function T1(A,d,p,_,y,T){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0;if(re=Z,Z=Z+16|0,M=re,y>>>0>15)return T=4,Z=re,T|0;if(R=Ut(p|0,_|0,52)|0,ee()|0,R=R&15,(R|0)>(y|0))return T=12,Z=re,T|0;if(hf(p,_,y,M)|0&&Vt(27795,27122,1327,27173),H=M,F=f[H+4>>2]|0,!(((d|0)>-1|(d|0)==-1&A>>>0>4294967295)&((F|0)>(d|0)|((F|0)==(d|0)?(f[H>>2]|0)>>>0>A>>>0:0))))return T=2,Z=re,T|0;H=y-R|0,y=zt(y|0,0,52)|0,B=ee()|0|_&-15728641,F=T,f[F>>2]=y|p,f[F+4>>2]=B,F=Ut(p|0,_|0,45)|0,ee()|0;e:do if($n(F&127)|0){if(R|0)for(M=1;;){if(F=zt(7,0,(15-M|0)*3|0)|0,!((F&p|0)==0&((ee()|0)&_|0)==0))break e;if(M>>>0>>0)M=M+1|0;else break}if((H|0)<1)return T=0,Z=re,T|0;for(F=R^15,_=-1,B=1,M=1;;){R=H-B|0,R=jo(7,0,R,((R|0)<0)<<31>>31)|0,p=ee()|0;do if(M)if(M=vr(R|0,p|0,5,0)|0,M=rn(M|0,ee()|0,-5,-1)|0,M=Xo(M|0,ee()|0,6,0)|0,y=ee()|0,(d|0)>(y|0)|(d|0)==(y|0)&A>>>0>M>>>0){d=rn(A|0,d|0,-1,-1)|0,d=Hr(d|0,ee()|0,M|0,y|0)|0,M=ee()|0,me=T,ge=f[me>>2]|0,me=f[me+4>>2]|0,Ne=(F+_|0)*3|0,pe=zt(7,0,Ne|0)|0,me=me&~(ee()|0),_=Xo(d|0,M|0,R|0,p|0)|0,A=ee()|0,y=rn(_|0,A|0,2,0)|0,Ne=zt(y|0,ee()|0,Ne|0)|0,me=ee()|0|me,y=T,f[y>>2]=Ne|ge&~pe,f[y+4>>2]=me,A=vr(_|0,A|0,R|0,p|0)|0,A=Hr(d|0,M|0,A|0,ee()|0)|0,M=0,d=ee()|0;break}else{Ne=T,pe=f[Ne>>2]|0,Ne=f[Ne+4>>2]|0,ge=zt(7,0,(F+_|0)*3|0)|0,Ne=Ne&~(ee()|0),M=T,f[M>>2]=pe&~ge,f[M+4>>2]=Ne,M=1;break}else pe=T,y=f[pe>>2]|0,pe=f[pe+4>>2]|0,_=(F+_|0)*3|0,me=zt(7,0,_|0)|0,pe=pe&~(ee()|0),Ne=Xo(A|0,d|0,R|0,p|0)|0,M=ee()|0,_=zt(Ne|0,M|0,_|0)|0,pe=ee()|0|pe,ge=T,f[ge>>2]=_|y&~me,f[ge+4>>2]=pe,M=vr(Ne|0,M|0,R|0,p|0)|0,A=Hr(A|0,d|0,M|0,ee()|0)|0,M=0,d=ee()|0;while(!1);if((H|0)>(B|0))_=~B,B=B+1|0;else{d=0;break}}return Z=re,d|0}while(!1);if((H|0)<1)return Ne=0,Z=re,Ne|0;for(y=R^15,M=1;;)if(ge=H-M|0,ge=jo(7,0,ge,((ge|0)<0)<<31>>31)|0,Ne=ee()|0,B=T,p=f[B>>2]|0,B=f[B+4>>2]|0,R=(y-M|0)*3|0,_=zt(7,0,R|0)|0,B=B&~(ee()|0),me=Xo(A|0,d|0,ge|0,Ne|0)|0,pe=ee()|0,R=zt(me|0,pe|0,R|0)|0,B=ee()|0|B,F=T,f[F>>2]=R|p&~_,f[F+4>>2]=B,Ne=vr(me|0,pe|0,ge|0,Ne|0)|0,A=Hr(A|0,d|0,Ne|0,ee()|0)|0,d=ee()|0,(H|0)<=(M|0)){d=0;break}else M=M+1|0;return Z=re,d|0}function pl(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0;y=Ut(d|0,p|0,52)|0,ee()|0,y=y&15,(d|0)==0&(p|0)==0|((_|0)>15|(y|0)>(_|0))?(T=-1,d=-1,p=0,y=0):(d=up(d,p,y+1|0,_)|0,M=(ee()|0)&-15728641,p=zt(_|0,0,52)|0,p=d|p,M=M|(ee()|0),d=(Ri(p,M)|0)==0,T=y,d=d?-1:_,y=M),M=A,f[M>>2]=p,f[M+4>>2]=y,f[A+8>>2]=T,f[A+12>>2]=d}function Ku(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0;if(y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,T=_+8|0,f[T>>2]=y,(A|0)==0&(d|0)==0|((p|0)>15|(y|0)>(p|0))){p=_,f[p>>2]=0,f[p+4>>2]=0,f[T>>2]=-1,f[_+12>>2]=-1;return}if(A=up(A,d,y+1|0,p)|0,T=(ee()|0)&-15728641,y=zt(p|0,0,52)|0,y=A|y,T=T|(ee()|0),A=_,f[A>>2]=y,f[A+4>>2]=T,A=_+12|0,Ri(y,T)|0){f[A>>2]=p;return}else{f[A>>2]=-1;return}}function ff(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0;if(p=A,d=f[p>>2]|0,p=f[p+4>>2]|0,!((d|0)==0&(p|0)==0)&&(_=Ut(d|0,p|0,52)|0,ee()|0,_=_&15,R=zt(1,0,(_^15)*3|0)|0,d=rn(R|0,ee()|0,d|0,p|0)|0,p=ee()|0,R=A,f[R>>2]=d,f[R+4>>2]=p,R=A+8|0,M=f[R>>2]|0,!((_|0)<(M|0)))){for(B=A+12|0,T=_;;){if((T|0)==(M|0)){_=5;break}if(F=(T|0)==(f[B>>2]|0),y=(15-T|0)*3|0,_=Ut(d|0,p|0,y|0)|0,ee()|0,_=_&7,F&((_|0)==1&!0)){_=7;break}if(!((_|0)==7&!0)){_=10;break}if(F=zt(1,0,y|0)|0,d=rn(d|0,p|0,F|0,ee()|0)|0,p=ee()|0,F=A,f[F>>2]=d,f[F+4>>2]=p,(T|0)>(M|0))T=T+-1|0;else{_=10;break}}if((_|0)==5){F=A,f[F>>2]=0,f[F+4>>2]=0,f[R>>2]=-1,f[B>>2]=-1;return}else if((_|0)==7){M=zt(1,0,y|0)|0,M=rn(d|0,p|0,M|0,ee()|0)|0,R=ee()|0,F=A,f[F>>2]=M,f[F+4>>2]=R,f[B>>2]=T+-1;return}else if((_|0)==10)return}}function ih(A){A=+A;var d=0;return d=A<0?A+6.283185307179586:A,+(A>=6.283185307179586?d+-6.283185307179586:d)}function La(A,d){return A=A|0,d=d|0,+An(+(+J[A>>3]-+J[d>>3]))<17453292519943298e-27?(d=+An(+(+J[A+8>>3]-+J[d+8>>3]))<17453292519943298e-27,d|0):(d=0,d|0)}function na(A,d){switch(A=+A,d=d|0,d|0){case 1:{A=A<0?A+6.283185307179586:A;break}case 2:{A=A>0?A+-6.283185307179586:A;break}}return+A}function w1(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return y=+J[d>>3],_=+J[A>>3],T=+xn(+((y-_)*.5)),p=+xn(+((+J[d+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+on(+y)*+on(+_)*p),+(+Fe(+ +yn(+p),+ +yn(+(1-p)))*2)}function rh(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return y=+J[d>>3],_=+J[A>>3],T=+xn(+((y-_)*.5)),p=+xn(+((+J[d+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+on(+y)*+on(+_)*p),+(+Fe(+ +yn(+p),+ +yn(+(1-p)))*2*6371.007180918475)}function Mx(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return y=+J[d>>3],_=+J[A>>3],T=+xn(+((y-_)*.5)),p=+xn(+((+J[d+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+on(+y)*+on(+_)*p),+(+Fe(+ +yn(+p),+ +yn(+(1-p)))*2*6371.007180918475*1e3)}function Ex(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;return T=+J[d>>3],_=+on(+T),y=+J[d+8>>3]-+J[A+8>>3],M=_*+xn(+y),p=+J[A>>3],+ +Fe(+M,+(+xn(+T)*+on(+p)-+on(+y)*(_*+xn(+p))))}function Cx(A,d,p,_){A=A|0,d=+d,p=+p,_=_|0;var y=0,T=0,M=0,R=0;if(p<1e-16){f[_>>2]=f[A>>2],f[_+4>>2]=f[A+4>>2],f[_+8>>2]=f[A+8>>2],f[_+12>>2]=f[A+12>>2];return}T=d<0?d+6.283185307179586:d,T=d>=6.283185307179586?T+-6.283185307179586:T;do if(T<1e-16)d=+J[A>>3]+p,J[_>>3]=d,y=_;else{if(y=+An(+(T+-3.141592653589793))<1e-16,d=+J[A>>3],y){d=d-p,J[_>>3]=d,y=_;break}if(M=+on(+p),p=+xn(+p),d=M*+xn(+d)+ +on(+T)*(p*+on(+d)),d=d>1?1:d,d=+Ao(+(d<-1?-1:d)),J[_>>3]=d,+An(+(d+-1.5707963267948966))<1e-16){J[_>>3]=1.5707963267948966,J[_+8>>3]=0;return}if(+An(+(d+1.5707963267948966))<1e-16){J[_>>3]=-1.5707963267948966,J[_+8>>3]=0;return}if(R=1/+on(+d),T=p*+xn(+T)*R,p=+J[A>>3],d=R*((M-+xn(+d)*+xn(+p))/+on(+p)),M=T>1?1:T,d=d>1?1:d,d=+J[A+8>>3]+ +Fe(+(M<-1?-1:M),+(d<-1?-1:d)),d>3.141592653589793)do d=d+-6.283185307179586;while(d>3.141592653589793);if(d<-3.141592653589793)do d=d+6.283185307179586;while(d<-3.141592653589793);J[_+8>>3]=d;return}while(!1);if(+An(+(d+-1.5707963267948966))<1e-16){J[y>>3]=1.5707963267948966,J[_+8>>3]=0;return}if(+An(+(d+1.5707963267948966))<1e-16){J[y>>3]=-1.5707963267948966,J[_+8>>3]=0;return}if(d=+J[A+8>>3],d>3.141592653589793)do d=d+-6.283185307179586;while(d>3.141592653589793);if(d<-3.141592653589793)do d=d+6.283185307179586;while(d<-3.141592653589793);J[_+8>>3]=d}function pp(A,d){return A=A|0,d=d|0,A>>>0>15?(d=4,d|0):(J[d>>3]=+J[20656+(A<<3)>>3],d=0,d|0)}function M1(A,d){return A=A|0,d=d|0,A>>>0>15?(d=4,d|0):(J[d>>3]=+J[20784+(A<<3)>>3],d=0,d|0)}function mp(A,d){return A=A|0,d=d|0,A>>>0>15?(d=4,d|0):(J[d>>3]=+J[20912+(A<<3)>>3],d=0,d|0)}function mo(A,d){return A=A|0,d=d|0,A>>>0>15?(d=4,d|0):(J[d>>3]=+J[21040+(A<<3)>>3],d=0,d|0)}function Zu(A,d){A=A|0,d=d|0;var p=0;return A>>>0>15?(d=4,d|0):(p=jo(7,0,A,((A|0)<0)<<31>>31)|0,p=vr(p|0,ee()|0,120,0)|0,A=ee()|0,f[d>>2]=p|2,f[d+4>>2]=A,d=0,d|0)}function xa(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;return me=+J[d>>3],H=+J[A>>3],B=+xn(+((me-H)*.5)),T=+J[d+8>>3],F=+J[A+8>>3],M=+xn(+((T-F)*.5)),R=+on(+H),re=+on(+me),M=B*B+M*(re*R*M),M=+Fe(+ +yn(+M),+ +yn(+(1-M)))*2,B=+J[p>>3],me=+xn(+((B-me)*.5)),_=+J[p+8>>3],T=+xn(+((_-T)*.5)),y=+on(+B),T=me*me+T*(re*y*T),T=+Fe(+ +yn(+T),+ +yn(+(1-T)))*2,B=+xn(+((H-B)*.5)),_=+xn(+((F-_)*.5)),_=B*B+_*(R*y*_),_=+Fe(+ +yn(+_),+ +yn(+(1-_)))*2,y=(M+T+_)*.5,+(+ue(+ +yn(+(+Ar(+(y*.5))*+Ar(+((y-M)*.5))*+Ar(+((y-T)*.5))*+Ar(+((y-_)*.5)))))*4)}function Wl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0;if(R=Z,Z=Z+192|0,T=R+168|0,M=R,y=jl(A,d,T)|0,y|0)return p=y,Z=R,p|0;if(Hl(A,d,M)|0&&Vt(27795,27190,415,27199),d=f[M>>2]|0,(d|0)>0){if(_=+xa(M+8|0,M+8+(((d|0)!=1&1)<<4)|0,T)+0,(d|0)!=1){A=1;do y=A,A=A+1|0,_=_+ +xa(M+8+(y<<4)|0,M+8+(((A|0)%(d|0)|0)<<4)|0,T);while((A|0)<(d|0))}}else _=0;return J[p>>3]=_,p=0,Z=R,p|0}function gp(A,d,p){return A=A|0,d=d|0,p=p|0,A=Wl(A,d,p)|0,A|0||(J[p>>3]=+J[p>>3]*6371.007180918475*6371.007180918475),A|0}function Id(A,d,p){return A=A|0,d=d|0,p=p|0,A=Wl(A,d,p)|0,A|0||(J[p>>3]=+J[p>>3]*6371.007180918475*6371.007180918475*1e3*1e3),A|0}function Fd(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(R=Z,Z=Z+176|0,M=R,A=Dd(A,d,M)|0,A|0)return M=A,Z=R,M|0;if(J[p>>3]=0,A=f[M>>2]|0,(A|0)<=1)return M=0,Z=R,M|0;d=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,F=_,_=+J[M+8+(A<<4)>>3],H=+xn(+((_-F)*.5)),B=y,y=+J[M+8+(A<<4)+8>>3],B=+xn(+((y-B)*.5)),B=H*H+B*(+on(+_)*+on(+F)*B),T=T+ +Fe(+ +yn(+B),+ +yn(+(1-B)))*2;while((A|0)<(d|0));return J[p>>3]=T,M=0,Z=R,M|0}function vp(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(R=Z,Z=Z+176|0,M=R,A=Dd(A,d,M)|0,A|0)return M=A,T=+J[p>>3],T=T*6371.007180918475,J[p>>3]=T,Z=R,M|0;if(J[p>>3]=0,A=f[M>>2]|0,(A|0)<=1)return M=0,T=0,T=T*6371.007180918475,J[p>>3]=T,Z=R,M|0;d=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,F=_,_=+J[M+8+(A<<4)>>3],H=+xn(+((_-F)*.5)),B=y,y=+J[M+8+(A<<4)+8>>3],B=+xn(+((y-B)*.5)),B=H*H+B*(+on(+F)*+on(+_)*B),T=T+ +Fe(+ +yn(+B),+ +yn(+(1-B)))*2;while((A|0)!=(d|0));return J[p>>3]=T,M=0,H=T,H=H*6371.007180918475,J[p>>3]=H,Z=R,M|0}function Ju(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(R=Z,Z=Z+176|0,M=R,A=Dd(A,d,M)|0,A|0)return M=A,T=+J[p>>3],T=T*6371.007180918475,T=T*1e3,J[p>>3]=T,Z=R,M|0;if(J[p>>3]=0,A=f[M>>2]|0,(A|0)<=1)return M=0,T=0,T=T*6371.007180918475,T=T*1e3,J[p>>3]=T,Z=R,M|0;d=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,F=_,_=+J[M+8+(A<<4)>>3],H=+xn(+((_-F)*.5)),B=y,y=+J[M+8+(A<<4)+8>>3],B=+xn(+((y-B)*.5)),B=H*H+B*(+on(+F)*+on(+_)*B),T=T+ +Fe(+ +yn(+B),+ +yn(+(1-B)))*2;while((A|0)!=(d|0));return J[p>>3]=T,M=0,H=T,H=H*6371.007180918475,H=H*1e3,J[p>>3]=H,Z=R,M|0}function E1(A){A=A|0;var d=0,p=0,_=0;return d=sa(1,12)|0,d||Vt(27280,27235,49,27293),p=A+4|0,_=f[p>>2]|0,_|0?(_=_+8|0,f[_>>2]=d,f[p>>2]=d,d|0):(f[A>>2]|0&&Vt(27310,27235,61,27333),_=A,f[_>>2]=d,f[p>>2]=d,d|0)}function kd(A,d){A=A|0,d=d|0;var p=0,_=0;return _=$o(24)|0,_||Vt(27347,27235,78,27361),f[_>>2]=f[d>>2],f[_+4>>2]=f[d+4>>2],f[_+8>>2]=f[d+8>>2],f[_+12>>2]=f[d+12>>2],f[_+16>>2]=0,d=A+4|0,p=f[d>>2]|0,p|0?(f[p+16>>2]=_,f[d>>2]=_,_|0):(f[A>>2]|0&&Vt(27376,27235,82,27361),f[A>>2]=_,f[d>>2]=_,_|0)}function ec(A){A=A|0;var d=0,p=0,_=0,y=0;if(A)for(_=1;;){if(d=f[A>>2]|0,d|0)do{if(p=f[d>>2]|0,p|0)do y=p,p=f[p+16>>2]|0,wn(y);while((p|0)!=0);y=d,d=f[d+8>>2]|0,wn(y)}while((d|0)!=0);if(d=A,A=f[A+8>>2]|0,_||wn(d),A)_=0;else break}}function Nx(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0,Cn=0,li=0,Ln=0;if(y=A+8|0,f[y>>2]|0)return Ln=1,Ln|0;if(_=f[A>>2]|0,!_)return Ln=0,Ln|0;d=_,p=0;do p=p+1|0,d=f[d+8>>2]|0;while((d|0)!=0);if(p>>>0<2)return Ln=0,Ln|0;Cn=$o(p<<2)|0,Cn||Vt(27396,27235,317,27415),Ht=$o(p<<5)|0,Ht||Vt(27437,27235,321,27415),f[A>>2]=0,pn=A+4|0,f[pn>>2]=0,f[y>>2]=0,p=0,gn=0,jt=0,re=0;e:for(;;){if(H=f[_>>2]|0,H){T=0,M=H;do{if(B=+J[M+8>>3],d=M,M=f[M+16>>2]|0,F=(M|0)==0,y=F?H:M,R=+J[y+8>>3],+An(+(B-R))>3.141592653589793){Ln=14;break}T=T+(R-B)*(+J[d>>3]+ +J[y>>3])}while(!F);if((Ln|0)==14){Ln=0,T=0,d=H;do Re=+J[d+8>>3],Pn=d+16|0,ei=f[Pn>>2]|0,ei=(ei|0)==0?H:ei,Ve=+J[ei+8>>3],T=T+(+J[d>>3]+ +J[ei>>3])*((Ve<0?Ve+6.283185307179586:Ve)-(Re<0?Re+6.283185307179586:Re)),d=f[((d|0)==0?_:Pn)>>2]|0;while((d|0)!=0)}T>0?(f[Cn+(gn<<2)>>2]=_,gn=gn+1|0,y=jt,d=re):Ln=19}else Ln=19;if((Ln|0)==19){Ln=0;do if(p){if(d=p+8|0,f[d>>2]|0){Ln=21;break e}if(p=sa(1,12)|0,!p){Ln=23;break e}f[d>>2]=p,y=p+4|0,M=p,d=re}else if(re){y=pn,M=re+8|0,d=_,p=A;break}else if(f[A>>2]|0){Ln=27;break e}else{y=pn,M=A,d=_,p=A;break}while(!1);if(f[M>>2]=_,f[y>>2]=_,M=Ht+(jt<<5)|0,F=f[_>>2]|0,F){for(H=Ht+(jt<<5)+8|0,J[H>>3]=17976931348623157e292,re=Ht+(jt<<5)+24|0,J[re>>3]=17976931348623157e292,J[M>>3]=-17976931348623157e292,me=Ht+(jt<<5)+16|0,J[me>>3]=-17976931348623157e292,Je=17976931348623157e292,He=-17976931348623157e292,y=0,pe=F,B=17976931348623157e292,Ne=17976931348623157e292,Ie=-17976931348623157e292,R=-17976931348623157e292;T=+J[pe>>3],Re=+J[pe+8>>3],pe=f[pe+16>>2]|0,ge=(pe|0)==0,Ve=+J[(ge?F:pe)+8>>3],T>3]=T,B=T),Re>3]=Re,Ne=Re),T>Ie?J[M>>3]=T:T=Ie,Re>R&&(J[me>>3]=Re,R=Re),Je=Re>0&ReHe?Re:He,y=y|+An(+(Re-Ve))>3.141592653589793,!ge;)Ie=T;y&&(J[me>>3]=He,J[re>>3]=Je)}else f[M>>2]=0,f[M+4>>2]=0,f[M+8>>2]=0,f[M+12>>2]=0,f[M+16>>2]=0,f[M+20>>2]=0,f[M+24>>2]=0,f[M+28>>2]=0;y=jt+1|0}if(Pn=_+8|0,_=f[Pn>>2]|0,f[Pn>>2]=0,_)jt=y,re=d;else{Ln=45;break}}if((Ln|0)==21)Vt(27213,27235,35,27247);else if((Ln|0)==23)Vt(27267,27235,37,27247);else if((Ln|0)==27)Vt(27310,27235,61,27333);else if((Ln|0)==45){e:do if((gn|0)>0){for(Pn=(y|0)==0,Bn=y<<2,ei=(A|0)==0,jn=0,d=0;;){if(cn=f[Cn+(jn<<2)>>2]|0,Pn)Ln=73;else{if(jt=$o(Bn)|0,!jt){Ln=50;break}if(pn=$o(Bn)|0,!pn){Ln=52;break}t:do if(ei)p=0;else{for(y=0,p=0,M=A;_=Ht+(y<<5)|0,ia(f[M>>2]|0,_,f[cn>>2]|0)|0?(f[jt+(p<<2)>>2]=M,f[pn+(p<<2)>>2]=_,ge=p+1|0):ge=p,M=f[M+8>>2]|0,M;)y=y+1|0,p=ge;if((ge|0)>0)if(_=f[jt>>2]|0,(ge|0)==1)p=_;else for(me=0,pe=-1,p=_,re=_;;){for(F=f[re>>2]|0,_=0,M=0;y=f[f[jt+(M<<2)>>2]>>2]|0,(y|0)==(F|0)?H=_:H=_+((ia(y,f[pn+(M<<2)>>2]|0,f[F>>2]|0)|0)&1)|0,M=M+1|0,(M|0)!=(ge|0);)_=H;if(y=(H|0)>(pe|0),p=y?re:p,_=me+1|0,(_|0)==(ge|0))break t;me=_,pe=y?H:pe,re=f[jt+(_<<2)>>2]|0}else p=0}while(!1);if(wn(jt),wn(pn),p){if(y=p+4|0,_=f[y>>2]|0,_)p=_+8|0;else if(f[p>>2]|0){Ln=70;break}f[p>>2]=cn,f[y>>2]=cn}else Ln=73}if((Ln|0)==73){if(Ln=0,d=f[cn>>2]|0,d|0)do pn=d,d=f[d+16>>2]|0,wn(pn);while((d|0)!=0);wn(cn),d=1}if(jn=jn+1|0,(jn|0)>=(gn|0)){li=d;break e}}(Ln|0)==50?Vt(27452,27235,249,27471):(Ln|0)==52?Vt(27490,27235,252,27471):(Ln|0)==70&&Vt(27310,27235,61,27333)}else li=0;while(!1);return wn(Cn),wn(Ht),Ln=li,Ln|0}return 0}function ia(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(!(qo(d,p)|0)||(d=Ed(d)|0,_=+J[p>>3],y=+J[p+8>>3],y=d&y<0?y+6.283185307179586:y,A=f[A>>2]|0,!A))return A=0,A|0;if(d){d=0,F=y,p=A;e:for(;;){for(;M=+J[p>>3],y=+J[p+8>>3],p=p+16|0,H=f[p>>2]|0,H=(H|0)==0?A:H,T=+J[H>>3],R=+J[H+8>>3],M>T?(B=M,M=R):(B=T,T=M,M=y,y=R),_=_==T|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=f[p>>2]|0,!p){p=22;break e}if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,F=R==F|M==F?F+-2220446049250313e-31:F,B=R+(M-R)*((_-T)/(B-T)),(B<0?B+6.283185307179586:B)>F&&(d=d^1),p=f[p>>2]|0,!p){p=22;break}}if((p|0)==22)return d|0}else{d=0,F=y,p=A;e:for(;;){for(;M=+J[p>>3],y=+J[p+8>>3],p=p+16|0,H=f[p>>2]|0,H=(H|0)==0?A:H,T=+J[H>>3],R=+J[H+8>>3],M>T?(B=M,M=R):(B=T,T=M,M=y,y=R),_=_==T|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=f[p>>2]|0,!p){p=22;break e}if(F=M==F|y==F?F+-2220446049250313e-31:F,M+(y-M)*((_-T)/(B-T))>F&&(d=d^1),p=f[p>>2]|0,!p){p=22;break}}if((p|0)==22)return d|0}return 0}function go(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0;if(He=Z,Z=Z+32|0,Je=He+16|0,Ie=He,T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,pe=Ut(p|0,_|0,52)|0,ee()|0,(T|0)!=(pe&15|0))return Je=12,Z=He,Je|0;if(F=Ut(A|0,d|0,45)|0,ee()|0,F=F&127,H=Ut(p|0,_|0,45)|0,ee()|0,H=H&127,F>>>0>121|H>>>0>121)return Je=5,Z=He,Je|0;if(pe=(F|0)!=(H|0),pe){if(R=zo(F,H)|0,(R|0)==7)return Je=1,Z=He,Je|0;B=zo(H,F)|0,(B|0)==7?Vt(27514,27538,161,27548):(ge=R,M=B)}else ge=0,M=0;re=$n(F)|0,me=$n(H)|0,f[Je>>2]=0,f[Je+4>>2]=0,f[Je+8>>2]=0,f[Je+12>>2]=0;do if(ge){if(H=f[4272+(F*28|0)+(ge<<2)>>2]|0,R=(H|0)>0,me)if(R){F=0,B=p,R=_;do B=Tx(B,R)|0,R=ee()|0,M=Al(M)|0,(M|0)==1&&(M=Al(1)|0),F=F+1|0;while((F|0)!=(H|0));H=M,F=B,B=R}else H=M,F=p,B=_;else if(R){F=0,B=p,R=_;do B=fp(B,R)|0,R=ee()|0,M=Al(M)|0,F=F+1|0;while((F|0)!=(H|0));H=M,F=B,B=R}else H=M,F=p,B=_;if(Od(F,B,Je)|0,pe||Vt(27563,27538,191,27548),R=(re|0)!=0,M=(me|0)!=0,R&M&&Vt(27590,27538,192,27548),R){if(M=ta(A,d)|0,(M|0)==7){T=5;break}if(ot[22e3+(M*7|0)+ge>>0]|0){T=1;break}B=f[21168+(M*28|0)+(ge<<2)>>2]|0,F=B}else if(M){if(M=ta(F,B)|0,(M|0)==7){T=5;break}if(ot[22e3+(M*7|0)+H>>0]|0){T=1;break}F=0,B=f[21168+(H*28|0)+(M<<2)>>2]|0}else F=0,B=0;if((F|B|0)<0)T=5;else{if((B|0)>0){R=Je+4|0,M=0;do Rd(R),M=M+1|0;while((M|0)!=(B|0))}if(f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ie+8>>2]=0,c1(Ie,ge),T|0)for(;Ps(T)|0?th(Ie):Gu(Ie),(T|0)>1;)T=T+-1|0;if((F|0)>0){T=0;do Rd(Ie),T=T+1|0;while((T|0)!=(F|0))}Ne=Je+4|0,ys(Ne,Ie,Ne),jr(Ne),Ne=51}}else if(Od(p,_,Je)|0,(re|0)!=0&(me|0)!=0)if((H|0)!=(F|0)&&Vt(27621,27538,261,27548),M=ta(A,d)|0,T=ta(p,_)|0,(M|0)==7|(T|0)==7)T=5;else if(ot[22e3+(M*7|0)+T>>0]|0)T=1;else if(M=f[21168+(M*28|0)+(T<<2)>>2]|0,(M|0)>0){R=Je+4|0,T=0;do Rd(R),T=T+1|0;while((T|0)!=(M|0));Ne=51}else Ne=51;else Ne=51;while(!1);return(Ne|0)==51&&(T=Je+4|0,f[y>>2]=f[T>>2],f[y+4>>2]=f[T+4>>2],f[y+8>>2]=f[T+8>>2],T=0),Je=T,Z=He,Je|0}function Vo(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0;if(Ne=Z,Z=Z+48|0,F=Ne+36|0,M=Ne+24|0,R=Ne+12|0,B=Ne,y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,me=Ut(A|0,d|0,45)|0,ee()|0,me=me&127,me>>>0>121)return _=5,Z=Ne,_|0;if(H=$n(me)|0,zt(y|0,0,52)|0,Ie=ee()|0|134225919,T=_,f[T>>2]=-1,f[T+4>>2]=Ie,!y)return y=zu(p)|0,(y|0)==7||(y=Iu(me,y)|0,(y|0)==127)?(Ie=1,Z=Ne,Ie|0):(pe=zt(y|0,0,45)|0,ge=ee()|0,me=_,ge=f[me+4>>2]&-1040385|ge,Ie=_,f[Ie>>2]=f[me>>2]|pe,f[Ie+4>>2]=ge,Ie=0,Z=Ne,Ie|0);for(f[F>>2]=f[p>>2],f[F+4>>2]=f[p+4>>2],f[F+8>>2]=f[p+8>>2],p=y;;){if(T=p,p=p+-1|0,f[M>>2]=f[F>>2],f[M+4>>2]=f[F+4>>2],f[M+8>>2]=f[F+8>>2],Ps(T)|0){if(y=l1(F)|0,y|0){p=13;break}f[R>>2]=f[F>>2],f[R+4>>2]=f[F+4>>2],f[R+8>>2]=f[F+8>>2],th(R)}else{if(y=cx(F)|0,y|0){p=13;break}f[R>>2]=f[F>>2],f[R+4>>2]=f[F+4>>2],f[R+8>>2]=f[F+8>>2],Gu(R)}if(uf(M,R,B),jr(B),y=_,He=f[y>>2]|0,y=f[y+4>>2]|0,Ve=(15-T|0)*3|0,Je=zt(7,0,Ve|0)|0,y=y&~(ee()|0),Ve=zt(zu(B)|0,0,Ve|0)|0,y=ee()|0|y,Ie=_,f[Ie>>2]=Ve|He&~Je,f[Ie+4>>2]=y,(T|0)<=1){p=14;break}}e:do if((p|0)!=13&&(p|0)==14)if((f[F>>2]|0)<=1&&(f[F+4>>2]|0)<=1&&(f[F+8>>2]|0)<=1){p=zu(F)|0,y=Iu(me,p)|0,(y|0)==127?B=0:B=$n(y)|0;t:do if(p){if(H){if(y=ta(A,d)|0,(y|0)==7){y=5;break e}if(T=f[21376+(y*28|0)+(p<<2)>>2]|0,(T|0)>0){y=p,p=0;do y=qu(y)|0,p=p+1|0;while((p|0)!=(T|0))}else y=p;if((y|0)==1){y=9;break e}p=Iu(me,y)|0,(p|0)==127&&Vt(27648,27538,411,27678),$n(p)|0?Vt(27693,27538,412,27678):(ge=p,pe=T,re=y)}else ge=y,pe=0,re=p;if(R=f[4272+(me*28|0)+(re<<2)>>2]|0,(R|0)<=-1&&Vt(27724,27538,419,27678),!B){if((pe|0)<0){y=5;break e}if(pe|0){T=_,y=0,p=f[T>>2]|0,T=f[T+4>>2]|0;do p=$u(p,T)|0,T=ee()|0,Ve=_,f[Ve>>2]=p,f[Ve+4>>2]=T,y=y+1|0;while((y|0)<(pe|0))}if((R|0)<=0){y=ge,p=58;break}for(T=_,y=0,p=f[T>>2]|0,T=f[T+4>>2]|0;;)if(p=$u(p,T)|0,T=ee()|0,Ve=_,f[Ve>>2]=p,f[Ve+4>>2]=T,y=y+1|0,(y|0)==(R|0)){y=ge,p=58;break t}}if(M=zo(ge,me)|0,(M|0)==7&&Vt(27514,27538,428,27678),y=_,p=f[y>>2]|0,y=f[y+4>>2]|0,(R|0)>0){T=0;do p=$u(p,y)|0,y=ee()|0,Ve=_,f[Ve>>2]=p,f[Ve+4>>2]=y,T=T+1|0;while((T|0)!=(R|0))}if(y=ta(p,y)|0,(y|0)==7&&Vt(27795,27538,440,27678),p=or(ge)|0,p=f[(p?21792:21584)+(M*28|0)+(y<<2)>>2]|0,(p|0)<0&&Vt(27795,27538,454,27678),!p)y=ge,p=58;else{M=_,y=0,T=f[M>>2]|0,M=f[M+4>>2]|0;do T=hp(T,M)|0,M=ee()|0,Ve=_,f[Ve>>2]=T,f[Ve+4>>2]=M,y=y+1|0;while((y|0)<(p|0));y=ge,p=58}}else if((H|0)!=0&(B|0)!=0){if(p=ta(A,d)|0,T=_,T=ta(f[T>>2]|0,f[T+4>>2]|0)|0,(p|0)==7|(T|0)==7){y=5;break e}if(T=f[21376+(p*28|0)+(T<<2)>>2]|0,(T|0)<0){y=5;break e}if(!T)p=59;else{R=_,p=0,M=f[R>>2]|0,R=f[R+4>>2]|0;do M=$u(M,R)|0,R=ee()|0,Ve=_,f[Ve>>2]=M,f[Ve+4>>2]=R,p=p+1|0;while((p|0)<(T|0));p=58}}else p=58;while(!1);if((p|0)==58&&B&&(p=59),(p|0)==59&&(Ve=_,(ta(f[Ve>>2]|0,f[Ve+4>>2]|0)|0)==1)){y=9;break}Ve=_,Je=f[Ve>>2]|0,Ve=f[Ve+4>>2]&-1040385,He=zt(y|0,0,45)|0,Ve=Ve|(ee()|0),y=_,f[y>>2]=Je|He,f[y+4>>2]=Ve,y=0}else y=1;while(!1);return Ve=y,Z=Ne,Ve|0}function C1(A,d,p,_,y,T){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,R=0;return R=Z,Z=Z+16|0,M=R,y?A=15:(A=go(A,d,p,_,M)|0,A||(fx(M,T),A=0)),Z=R,A|0}function zd(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0;return M=Z,Z=Z+16|0,T=M,_?p=15:(p=sp(p,T)|0,p||(p=Vo(A,d,T,y)|0)),Z=M,p|0}function tc(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0;return B=Z,Z=Z+32|0,M=B+12|0,R=B,T=go(A,d,A,d,M)|0,T|0?(R=T,Z=B,R|0):(A=go(A,d,p,_,R)|0,A|0?(R=A,Z=B,R|0):(M=rp(M,R)|0,R=y,f[R>>2]=M,f[R+4>>2]=((M|0)<0)<<31>>31,R=0,Z=B,R|0))}function _p(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0;return B=Z,Z=Z+32|0,M=B+12|0,R=B,T=go(A,d,A,d,M)|0,!T&&(T=go(A,d,p,_,R)|0,!T)?(_=rp(M,R)|0,_=rn(_|0,((_|0)<0)<<31>>31|0,1,0)|0,M=ee()|0,R=y,f[R>>2]=_,f[R+4>>2]=M,R=0,Z=B,R|0):(R=T,Z=B,R|0)}function N1(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0;if(cn=Z,Z=Z+48|0,jt=cn+24|0,M=cn+12|0,pn=cn,T=go(A,d,A,d,jt)|0,!T&&(T=go(A,d,p,_,M)|0,!T)){Ve=rp(jt,M)|0,Re=((Ve|0)<0)<<31>>31,f[jt>>2]=0,f[jt+4>>2]=0,f[jt+8>>2]=0,f[M>>2]=0,f[M+4>>2]=0,f[M+8>>2]=0,go(A,d,A,d,jt)|0&&Vt(27795,27538,692,27747),go(A,d,p,_,M)|0&&Vt(27795,27538,697,27747),A1(jt),A1(M),H=(Ve|0)==0?0:1/+(Ve|0),p=f[jt>>2]|0,Ne=H*+((f[M>>2]|0)-p|0),Ie=jt+4|0,_=f[Ie>>2]|0,Je=H*+((f[M+4>>2]|0)-_|0),He=jt+8|0,T=f[He>>2]|0,H=H*+((f[M+8>>2]|0)-T|0),f[pn>>2]=p,re=pn+4|0,f[re>>2]=_,me=pn+8|0,f[me>>2]=T;e:do if((Ve|0)<0)T=0;else for(pe=0,ge=0;;){B=+(ge>>>0)+4294967296*+(pe|0),jn=Ne*B+ +(p|0),R=Je*B+ +(_|0),B=H*B+ +(T|0),p=~~+xl(+jn),M=~~+xl(+R),T=~~+xl(+B),jn=+An(+(+(p|0)-jn)),R=+An(+(+(M|0)-R)),B=+An(+(+(T|0)-B));do if(jn>R&jn>B)p=0-(M+T)|0,_=M;else if(F=0-p|0,R>B){_=F-T|0;break}else{_=M,T=F-M|0;break}while(!1);if(f[pn>>2]=p,f[re>>2]=_,f[me>>2]=T,dx(pn),T=Vo(A,d,pn,y+(ge<<3)|0)|0,T|0)break e;if(!((pe|0)<(Re|0)|(pe|0)==(Re|0)&ge>>>0>>0)){T=0;break e}p=rn(ge|0,pe|0,1,0)|0,_=ee()|0,pe=_,ge=p,p=f[jt>>2]|0,_=f[Ie>>2]|0,T=f[He>>2]|0}while(!1);return pn=T,Z=cn,pn|0}return pn=T,Z=cn,pn|0}function jo(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0;if((p|0)==0&(_|0)==0)return y=0,T=1,Mt(y|0),T|0;T=A,y=d,A=1,d=0;do M=(p&1|0)==0&!0,A=vr((M?1:T)|0,(M?0:y)|0,A|0,d|0)|0,d=ee()|0,p=D1(p|0,_|0,1)|0,_=ee()|0,T=vr(T|0,y|0,T|0,y|0)|0,y=ee()|0;while(!((p|0)==0&(_|0)==0));return Mt(d|0),A|0}function Gd(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0;R=Z,Z=Z+16|0,T=R,M=Ut(A|0,d|0,52)|0,ee()|0,M=M&15;do if(M){if(y=jl(A,d,T)|0,!y){F=+J[T>>3],B=1/+on(+F),H=+J[25968+(M<<3)>>3],J[p>>3]=F+H,J[p+8>>3]=F-H,F=+J[T+8>>3],B=H*B,J[p+16>>3]=B+F,J[p+24>>3]=F-B;break}return M=y,Z=R,M|0}else{if(y=Ut(A|0,d|0,45)|0,ee()|0,y=y&127,y>>>0>121)return M=5,Z=R,M|0;T=22064+(y<<5)|0,f[p>>2]=f[T>>2],f[p+4>>2]=f[T+4>>2],f[p+8>>2]=f[T+8>>2],f[p+12>>2]=f[T+12>>2],f[p+16>>2]=f[T+16>>2],f[p+20>>2]=f[T+20>>2],f[p+24>>2]=f[T+24>>2],f[p+28>>2]=f[T+28>>2];break}while(!1);return ea(p,_?1.4:1.1),_=26096+(M<<3)|0,(f[_>>2]|0)==(A|0)&&(f[_+4>>2]|0)==(d|0)&&(J[p>>3]=1.5707963267948966),M=26224+(M<<3)|0,(f[M>>2]|0)==(A|0)&&(f[M+4>>2]|0)==(d|0)&&(J[p+8>>3]=-1.5707963267948966),+J[p>>3]!=1.5707963267948966&&+J[p+8>>3]!=-1.5707963267948966?(M=0,Z=R,M|0):(J[p+16>>3]=3.141592653589793,J[p+24>>3]=-3.141592653589793,M=0,Z=R,M|0)}function Ua(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0;F=Z,Z=Z+48|0,M=F+32|0,T=F+40|0,R=F,Hu(M,0,0,0),B=f[M>>2]|0,M=f[M+4>>2]|0;do if(p>>>0<=15){if(y=Ba(_)|0,y|0){_=R,f[_>>2]=0,f[_+4>>2]=0,f[R+8>>2]=y,f[R+12>>2]=-1,_=R+16|0,B=R+29|0,f[_>>2]=0,f[_+4>>2]=0,f[_+8>>2]=0,ot[_+12>>0]=0,ot[B>>0]=ot[T>>0]|0,ot[B+1>>0]=ot[T+1>>0]|0,ot[B+2>>0]=ot[T+2>>0]|0;break}if(y=sa((f[d+8>>2]|0)+1|0,32)|0,y){Oa(d,y),H=R,f[H>>2]=B,f[H+4>>2]=M,f[R+8>>2]=0,f[R+12>>2]=p,f[R+16>>2]=_,f[R+20>>2]=d,f[R+24>>2]=y,ot[R+28>>0]=0,B=R+29|0,ot[B>>0]=ot[T>>0]|0,ot[B+1>>0]=ot[T+1>>0]|0,ot[B+2>>0]=ot[T+2>>0]|0;break}else{_=R,f[_>>2]=0,f[_+4>>2]=0,f[R+8>>2]=13,f[R+12>>2]=-1,_=R+16|0,B=R+29|0,f[_>>2]=0,f[_+4>>2]=0,f[_+8>>2]=0,ot[_+12>>0]=0,ot[B>>0]=ot[T>>0]|0,ot[B+1>>0]=ot[T+1>>0]|0,ot[B+2>>0]=ot[T+2>>0]|0;break}}else B=R,f[B>>2]=0,f[B+4>>2]=0,f[R+8>>2]=4,f[R+12>>2]=-1,B=R+16|0,H=R+29|0,f[B>>2]=0,f[B+4>>2]=0,f[B+8>>2]=0,ot[B+12>>0]=0,ot[H>>0]=ot[T>>0]|0,ot[H+1>>0]=ot[T+1>>0]|0,ot[H+2>>0]=ot[T+2>>0]|0;while(!1);ml(R),f[A>>2]=f[R>>2],f[A+4>>2]=f[R+4>>2],f[A+8>>2]=f[R+8>>2],f[A+12>>2]=f[R+12>>2],f[A+16>>2]=f[R+16>>2],f[A+20>>2]=f[R+20>>2],f[A+24>>2]=f[R+24>>2],f[A+28>>2]=f[R+28>>2],Z=F}function ml(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0;if(Re=Z,Z=Z+336|0,pe=Re+168|0,ge=Re,_=A,p=f[_>>2]|0,_=f[_+4>>2]|0,(p|0)==0&(_|0)==0){Z=Re;return}if(d=A+28|0,ot[d>>0]|0?(p=nc(p,_)|0,_=ee()|0):ot[d>>0]=1,Ve=A+20|0,!(f[f[Ve>>2]>>2]|0)){d=A+24|0,p=f[d>>2]|0,p|0&&wn(p),He=A,f[He>>2]=0,f[He+4>>2]=0,f[A+8>>2]=0,f[Ve>>2]=0,f[A+12>>2]=-1,f[A+16>>2]=0,f[d>>2]=0,Z=Re;return}He=A+16|0,d=f[He>>2]|0,y=d&15;e:do if((p|0)==0&(_|0)==0)Je=A+24|0;else{Ne=A+12|0,re=(y|0)==3,H=d&255,B=(y|1|0)==3,me=A+24|0,F=(y+-1|0)>>>0<3,M=(y|2|0)==3,R=ge+8|0;t:for(;;){if(T=Ut(p|0,_|0,52)|0,ee()|0,T=T&15,(T|0)==(f[Ne>>2]|0)){switch(H&15){case 0:case 2:case 3:{if(y=jl(p,_,pe)|0,y|0){Ie=15;break t}if(Ia(f[Ve>>2]|0,f[me>>2]|0,pe)|0){Ie=19;break t}break}}if(B&&(y=f[(f[Ve>>2]|0)+4>>2]|0,f[pe>>2]=f[y>>2],f[pe+4>>2]=f[y+4>>2],f[pe+8>>2]=f[y+8>>2],f[pe+12>>2]=f[y+12>>2],qo(26832,pe)|0)){if(Bd(f[(f[Ve>>2]|0)+4>>2]|0,T,ge)|0){Ie=25;break}if(y=ge,(f[y>>2]|0)==(p|0)&&(f[y+4>>2]|0)==(_|0)){Ie=29;break}}if(F){if(y=Hl(p,_,pe)|0,y|0){Ie=32;break}if(Gd(p,_,ge,0)|0){Ie=36;break}if(M&&Ho(f[Ve>>2]|0,f[me>>2]|0,pe,ge)|0){Ie=42;break}if(B&&Vd(f[Ve>>2]|0,f[me>>2]|0,pe,ge)|0){Ie=42;break}}if(re){if(d=Gd(p,_,pe,1)|0,y=f[me>>2]|0,d|0){Ie=45;break}if(af(y,pe)|0){if(of(ge,pe),ip(pe,f[me>>2]|0)|0){Ie=53;break}if(Ia(f[Ve>>2]|0,f[me>>2]|0,R)|0){Ie=53;break}if(Vd(f[Ve>>2]|0,f[me>>2]|0,ge,pe)|0){Ie=53;break}}}}do if((T|0)<(f[Ne>>2]|0)){if(d=Gd(p,_,pe,1)|0,y=f[me>>2]|0,d|0){Ie=58;break t}if(!(af(y,pe)|0)){Ie=73;break}if(ip(f[me>>2]|0,pe)|0&&(of(ge,pe),Ho(f[Ve>>2]|0,f[me>>2]|0,ge,pe)|0)){Ie=65;break t}if(p=Ud(p,_,T+1|0,ge)|0,p|0){Ie=67;break t}_=ge,p=f[_>>2]|0,_=f[_+4>>2]|0}else Ie=73;while(!1);if((Ie|0)==73&&(Ie=0,p=nc(p,_)|0,_=ee()|0),(p|0)==0&(_|0)==0){Je=me;break e}}switch(Ie|0){case 15:{d=f[me>>2]|0,d|0&&wn(d),Ie=A,f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=y,Ie=20;break}case 19:{f[A>>2]=p,f[A+4>>2]=_,Ie=20;break}case 25:{Vt(27795,27761,470,27772);break}case 29:{f[A>>2]=p,f[A+4>>2]=_,Z=Re;return}case 32:{d=f[me>>2]|0,d|0&&wn(d),Je=A,f[Je>>2]=0,f[Je+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=y,Z=Re;return}case 36:{Vt(27795,27761,493,27772);break}case 42:{f[A>>2]=p,f[A+4>>2]=_,Z=Re;return}case 45:{y|0&&wn(y),Ie=A,f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=d,Ie=55;break}case 53:{f[A>>2]=p,f[A+4>>2]=_,Ie=55;break}case 58:{y|0&&wn(y),Ie=A,f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=d,Ie=71;break}case 65:{f[A>>2]=p,f[A+4>>2]=_,Ie=71;break}case 67:{d=f[me>>2]|0,d|0&&wn(d),Je=A,f[Je>>2]=0,f[Je+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=p,Z=Re;return}}if((Ie|0)==20){Z=Re;return}else if((Ie|0)==55){Z=Re;return}else if((Ie|0)==71){Z=Re;return}}while(!1);d=f[Je>>2]|0,d|0&&wn(d),Ie=A,f[Ie>>2]=0,f[Ie+4>>2]=0,f[A+8>>2]=0,f[Ve>>2]=0,f[A+12>>2]=-1,f[He>>2]=0,f[Je>>2]=0,Z=Re}function nc(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0;re=Z,Z=Z+16|0,H=re,_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,p=Ut(A|0,d|0,45)|0,ee()|0;do if(_){for(;p=zt(_+4095|0,0,52)|0,y=ee()|0|d&-15728641,T=(15-_|0)*3|0,M=zt(7,0,T|0)|0,R=ee()|0,p=p|A|M,y=y|R,B=Ut(A|0,d|0,T|0)|0,ee()|0,B=B&7,_=_+-1|0,!(B>>>0<6);)if(_)d=y,A=p;else{F=4;break}if((F|0)==4){p=Ut(p|0,y|0,45)|0,ee()|0;break}return H=(B|0)==0&(Ri(p,y)|0)!=0,H=zt((H?2:1)+B|0,0,T|0)|0,F=ee()|0|d&~R,H=H|A&~M,Mt(F|0),Z=re,H|0}while(!1);return p=p&127,p>>>0>120?(F=0,H=0,Mt(F|0),Z=re,H|0):(Hu(H,0,p+1|0,0),F=f[H+4>>2]|0,H=f[H>>2]|0,Mt(F|0),Z=re,H|0)}function qd(A,d,p,_,y,T){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0;Ie=Z,Z=Z+160|0,re=Ie+80|0,R=Ie+64|0,me=Ie+112|0,Ne=Ie,Ua(re,A,d,p),F=re,pl(R,f[F>>2]|0,f[F+4>>2]|0,d),F=R,B=f[F>>2]|0,F=f[F+4>>2]|0,M=f[re+8>>2]|0,pe=me+4|0,f[pe>>2]=f[re>>2],f[pe+4>>2]=f[re+4>>2],f[pe+8>>2]=f[re+8>>2],f[pe+12>>2]=f[re+12>>2],f[pe+16>>2]=f[re+16>>2],f[pe+20>>2]=f[re+20>>2],f[pe+24>>2]=f[re+24>>2],f[pe+28>>2]=f[re+28>>2],pe=Ne,f[pe>>2]=B,f[pe+4>>2]=F,pe=Ne+8|0,f[pe>>2]=M,A=Ne+12|0,d=me,p=A+36|0;do f[A>>2]=f[d>>2],A=A+4|0,d=d+4|0;while((A|0)<(p|0));if(me=Ne+48|0,f[me>>2]=f[R>>2],f[me+4>>2]=f[R+4>>2],f[me+8>>2]=f[R+8>>2],f[me+12>>2]=f[R+12>>2],(B|0)==0&(F|0)==0)return Ne=M,Z=Ie,Ne|0;p=Ne+16|0,H=Ne+24|0,re=Ne+28|0,M=0,R=0,d=B,A=F;do{if(!((M|0)<(y|0)|(M|0)==(y|0)&R>>>0<_>>>0)){ge=4;break}if(F=R,R=rn(R|0,M|0,1,0)|0,M=ee()|0,F=T+(F<<3)|0,f[F>>2]=d,f[F+4>>2]=A,ff(me),A=me,d=f[A>>2]|0,A=f[A+4>>2]|0,(d|0)==0&(A|0)==0){if(ml(p),d=p,A=f[d>>2]|0,d=f[d+4>>2]|0,(A|0)==0&(d|0)==0){ge=10;break}Ku(A,d,f[re>>2]|0,me),A=me,d=f[A>>2]|0,A=f[A+4>>2]|0}F=Ne,f[F>>2]=d,f[F+4>>2]=A}while(!((d|0)==0&(A|0)==0));return(ge|0)==4?(A=Ne+40|0,d=f[A>>2]|0,d|0&&wn(d),ge=Ne+16|0,f[ge>>2]=0,f[ge+4>>2]=0,f[H>>2]=0,f[Ne+36>>2]=0,f[re>>2]=-1,f[Ne+32>>2]=0,f[A>>2]=0,Ku(0,0,0,me),f[Ne>>2]=0,f[Ne+4>>2]=0,f[pe>>2]=0,Ne=14,Z=Ie,Ne|0):((ge|0)==10&&(f[Ne>>2]=0,f[Ne+4>>2]=0,f[pe>>2]=f[H>>2]),Ne=f[pe>>2]|0,Z=Ie,Ne|0)}function df(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0;if(re=Z,Z=Z+48|0,B=re+32|0,R=re+40|0,F=re,!(f[A>>2]|0))return H=_,f[H>>2]=0,f[H+4>>2]=0,H=0,Z=re,H|0;Hu(B,0,0,0),M=B,y=f[M>>2]|0,M=f[M+4>>2]|0;do if(d>>>0>15)H=F,f[H>>2]=0,f[H+4>>2]=0,f[F+8>>2]=4,f[F+12>>2]=-1,H=F+16|0,p=F+29|0,f[H>>2]=0,f[H+4>>2]=0,f[H+8>>2]=0,ot[H+12>>0]=0,ot[p>>0]=ot[R>>0]|0,ot[p+1>>0]=ot[R+1>>0]|0,ot[p+2>>0]=ot[R+2>>0]|0,p=4,H=9;else{if(p=Ba(p)|0,p|0){B=F,f[B>>2]=0,f[B+4>>2]=0,f[F+8>>2]=p,f[F+12>>2]=-1,B=F+16|0,H=F+29|0,f[B>>2]=0,f[B+4>>2]=0,f[B+8>>2]=0,ot[B+12>>0]=0,ot[H>>0]=ot[R>>0]|0,ot[H+1>>0]=ot[R+1>>0]|0,ot[H+2>>0]=ot[R+2>>0]|0,H=9;break}if(p=sa((f[A+8>>2]|0)+1|0,32)|0,!p){H=F,f[H>>2]=0,f[H+4>>2]=0,f[F+8>>2]=13,f[F+12>>2]=-1,H=F+16|0,p=F+29|0,f[H>>2]=0,f[H+4>>2]=0,f[H+8>>2]=0,ot[H+12>>0]=0,ot[p>>0]=ot[R>>0]|0,ot[p+1>>0]=ot[R+1>>0]|0,ot[p+2>>0]=ot[R+2>>0]|0,p=13,H=9;break}Oa(A,p),pe=F,f[pe>>2]=y,f[pe+4>>2]=M,M=F+8|0,f[M>>2]=0,f[F+12>>2]=d,f[F+20>>2]=A,f[F+24>>2]=p,ot[F+28>>0]=0,y=F+29|0,ot[y>>0]=ot[R>>0]|0,ot[y+1>>0]=ot[R+1>>0]|0,ot[y+2>>0]=ot[R+2>>0]|0,f[F+16>>2]=3,me=+sf(p),me=me*+dl(p),T=+An(+ +J[p>>3]),T=me/+on(+ +gf(+T,+ +An(+ +J[p+8>>3])))*6371.007180918475*6371.007180918475,y=F+12|0,p=f[y>>2]|0;e:do if((p|0)>0)do{if(pp(p+-1|0,B)|0,!(T/+J[B>>3]>10))break e;pe=f[y>>2]|0,p=pe+-1|0,f[y>>2]=p}while((pe|0)>1);while(!1);if(ml(F),y=_,f[y>>2]=0,f[y+4>>2]=0,y=F,p=f[y>>2]|0,y=f[y+4>>2]|0,!((p|0)==0&(y|0)==0))do hf(p,y,d,B)|0,R=B,A=_,R=rn(f[A>>2]|0,f[A+4>>2]|0,f[R>>2]|0,f[R+4>>2]|0)|0,A=ee()|0,pe=_,f[pe>>2]=R,f[pe+4>>2]=A,ml(F),pe=F,p=f[pe>>2]|0,y=f[pe+4>>2]|0;while(!((p|0)==0&(y|0)==0));p=f[M>>2]|0}while(!1);return pe=p,Z=re,pe|0}function Ls(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;if(!(qo(d,p)|0)||(d=Ed(d)|0,_=+J[p>>3],y=+J[p+8>>3],y=d&y<0?y+6.283185307179586:y,me=f[A>>2]|0,(me|0)<=0))return me=0,me|0;if(re=f[A+4>>2]|0,d){d=0,H=y,p=-1,A=0;e:for(;;){for(F=A;M=+J[re+(F<<4)>>3],y=+J[re+(F<<4)+8>>3],A=(p+2|0)%(me|0)|0,T=+J[re+(A<<4)>>3],R=+J[re+(A<<4)+8>>3],M>T?(B=M,M=R):(B=T,T=M,M=y,y=R),_=_==T|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(me|0)){p=22;break e}else A=F,F=p,p=A;if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,H=R==H|M==H?H+-2220446049250313e-31:H,B=R+(M-R)*((_-T)/(B-T)),(B<0?B+6.283185307179586:B)>H&&(d=d^1),A=F+1|0,(A|0)>=(me|0)){p=22;break}else p=F}if((p|0)==22)return d|0}else{d=0,H=y,p=-1,A=0;e:for(;;){for(F=A;M=+J[re+(F<<4)>>3],y=+J[re+(F<<4)+8>>3],A=(p+2|0)%(me|0)|0,T=+J[re+(A<<4)>>3],R=+J[re+(A<<4)+8>>3],M>T?(B=M,M=R):(B=T,T=M,M=y,y=R),_=_==T|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(me|0)){p=22;break e}else A=F,F=p,p=A;if(H=M==H|y==H?H+-2220446049250313e-31:H,M+(y-M)*((_-T)/(B-T))>H&&(d=d^1),A=F+1|0,(A|0)>=(me|0)){p=22;break}else p=F}if((p|0)==22)return d|0}return 0}function ba(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0;if(ge=f[A>>2]|0,!ge){f[d>>2]=0,f[d+4>>2]=0,f[d+8>>2]=0,f[d+12>>2]=0,f[d+16>>2]=0,f[d+20>>2]=0,f[d+24>>2]=0,f[d+28>>2]=0;return}if(Ne=d+8|0,J[Ne>>3]=17976931348623157e292,Ie=d+24|0,J[Ie>>3]=17976931348623157e292,J[d>>3]=-17976931348623157e292,Je=d+16|0,J[Je>>3]=-17976931348623157e292,!((ge|0)<=0)){for(me=f[A+4>>2]|0,F=17976931348623157e292,H=-17976931348623157e292,re=0,A=-1,T=17976931348623157e292,M=17976931348623157e292,B=-17976931348623157e292,_=-17976931348623157e292,pe=0;p=+J[me+(pe<<4)>>3],R=+J[me+(pe<<4)+8>>3],A=A+2|0,y=+J[me+(((A|0)==(ge|0)?0:A)<<4)+8>>3],p>3]=p,T=p),R>3]=R,M=R),p>B?J[d>>3]=p:p=B,R>_&&(J[Je>>3]=R,_=R),F=R>0&RH?R:H,re=re|+An(+(R-y))>3.141592653589793,A=pe+1|0,(A|0)!=(ge|0);)He=pe,B=p,pe=A,A=He;re&&(J[Je>>3]=H,J[Ie>>3]=F)}}function Ba(A){return A=A|0,(A>>>0<4?0:15)|0}function Oa(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0;if(ge=f[A>>2]|0,ge){if(Ne=d+8|0,J[Ne>>3]=17976931348623157e292,Ie=d+24|0,J[Ie>>3]=17976931348623157e292,J[d>>3]=-17976931348623157e292,Je=d+16|0,J[Je>>3]=-17976931348623157e292,(ge|0)>0){for(y=f[A+4>>2]|0,me=17976931348623157e292,pe=-17976931348623157e292,_=0,p=-1,B=17976931348623157e292,F=17976931348623157e292,re=-17976931348623157e292,M=-17976931348623157e292,He=0;T=+J[y+(He<<4)>>3],H=+J[y+(He<<4)+8>>3],pn=p+2|0,R=+J[y+(((pn|0)==(ge|0)?0:pn)<<4)+8>>3],T>3]=T,B=T),H>3]=H,F=H),T>re?J[d>>3]=T:T=re,H>M&&(J[Je>>3]=H,M=H),me=H>0&Hpe?H:pe,_=_|+An(+(H-R))>3.141592653589793,p=He+1|0,(p|0)!=(ge|0);)pn=He,re=T,He=p,p=pn;_&&(J[Je>>3]=pe,J[Ie>>3]=me)}}else f[d>>2]=0,f[d+4>>2]=0,f[d+8>>2]=0,f[d+12>>2]=0,f[d+16>>2]=0,f[d+20>>2]=0,f[d+24>>2]=0,f[d+28>>2]=0;if(pn=A+8|0,p=f[pn>>2]|0,!((p|0)<=0)){jt=A+12|0,Re=0;do if(y=f[jt>>2]|0,_=Re,Re=Re+1|0,Ie=d+(Re<<5)|0,Je=f[y+(_<<3)>>2]|0,Je){if(He=d+(Re<<5)+8|0,J[He>>3]=17976931348623157e292,A=d+(Re<<5)+24|0,J[A>>3]=17976931348623157e292,J[Ie>>3]=-17976931348623157e292,Ve=d+(Re<<5)+16|0,J[Ve>>3]=-17976931348623157e292,(Je|0)>0){for(ge=f[y+(_<<3)+4>>2]|0,me=17976931348623157e292,pe=-17976931348623157e292,y=0,_=-1,Ne=0,B=17976931348623157e292,F=17976931348623157e292,H=-17976931348623157e292,M=-17976931348623157e292;T=+J[ge+(Ne<<4)>>3],re=+J[ge+(Ne<<4)+8>>3],_=_+2|0,R=+J[ge+(((_|0)==(Je|0)?0:_)<<4)+8>>3],T>3]=T,B=T),re>3]=re,F=re),T>H?J[Ie>>3]=T:T=H,re>M&&(J[Ve>>3]=re,M=re),me=re>0&repe?re:pe,y=y|+An(+(re-R))>3.141592653589793,_=Ne+1|0,(_|0)!=(Je|0);)cn=Ne,Ne=_,H=T,_=cn;y&&(J[Ve>>3]=pe,J[A>>3]=me)}}else f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ie+8>>2]=0,f[Ie+12>>2]=0,f[Ie+16>>2]=0,f[Ie+20>>2]=0,f[Ie+24>>2]=0,f[Ie+28>>2]=0,p=f[pn>>2]|0;while((Re|0)<(p|0))}}function Ia(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if(!(Ls(A,d,p)|0))return y=0,y|0;if(y=A+8|0,(f[y>>2]|0)<=0)return y=1,y|0;for(_=A+12|0,A=0;;){if(T=A,A=A+1|0,Ls((f[_>>2]|0)+(T<<3)|0,d+(A<<5)|0,p)|0){A=0,_=6;break}if((A|0)>=(f[y>>2]|0)){A=1,_=6;break}}return(_|0)==6?A|0:0}function Ho(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(F=Z,Z=Z+16|0,R=F,M=p+8|0,!(Ls(A,d,M)|0))return B=0,Z=F,B|0;B=A+8|0;e:do if((f[B>>2]|0)>0){for(T=A+12|0,y=0;;){if(H=y,y=y+1|0,Ls((f[T>>2]|0)+(H<<3)|0,d+(y<<5)|0,M)|0){y=0;break}if((y|0)>=(f[B>>2]|0))break e}return Z=F,y|0}while(!1);if(Af(A,d,p,_)|0)return H=0,Z=F,H|0;f[R>>2]=f[p>>2],f[R+4>>2]=M,y=f[B>>2]|0;e:do if((y|0)>0)for(A=A+12|0,M=0,T=y;;){if(y=f[A>>2]|0,(f[y+(M<<3)>>2]|0)>0){if(Ls(R,_,f[y+(M<<3)+4>>2]|0)|0){y=0;break e}if(y=M+1|0,Af((f[A>>2]|0)+(M<<3)|0,d+(y<<5)|0,p,_)|0){y=0;break e}T=f[B>>2]|0}else y=M+1|0;if((y|0)<(T|0))M=y;else{y=1;break}}else y=1;while(!1);return H=y,Z=F,H|0}function Af(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0;if(pn=Z,Z=Z+176|0,He=pn+172|0,y=pn+168|0,Ve=pn,!(af(d,_)|0))return A=0,Z=pn,A|0;if(Cd(d,_,He,y),Yl(Ve|0,p|0,168)|0,(f[p>>2]|0)>0){d=0;do cn=Ve+8+(d<<4)+8|0,Je=+na(+J[cn>>3],f[y>>2]|0),J[cn>>3]=Je,d=d+1|0;while((d|0)<(f[p>>2]|0))}Ne=+J[_>>3],Ie=+J[_+8>>3],Je=+na(+J[_+16>>3],f[y>>2]|0),pe=+na(+J[_+24>>3],f[y>>2]|0);e:do if((f[A>>2]|0)>0){if(_=A+4|0,y=f[Ve>>2]|0,(y|0)<=0){for(d=0;;)if(d=d+1|0,(d|0)>=(f[A>>2]|0)){d=0;break e}}for(p=0;;){if(d=f[_>>2]|0,me=+J[d+(p<<4)>>3],ge=+na(+J[d+(p<<4)+8>>3],f[He>>2]|0),d=f[_>>2]|0,p=p+1|0,cn=(p|0)%(f[A>>2]|0)|0,T=+J[d+(cn<<4)>>3],M=+na(+J[d+(cn<<4)+8>>3],f[He>>2]|0),!(me>=Ne)|!(T>=Ne)&&!(me<=Ie)|!(T<=Ie)&&!(ge<=pe)|!(M<=pe)&&!(ge>=Je)|!(M>=Je)){re=T-me,F=M-ge,d=0;do if(jn=d,d=d+1|0,cn=(d|0)==(y|0)?0:d,T=+J[Ve+8+(jn<<4)+8>>3],M=+J[Ve+8+(cn<<4)+8>>3]-T,R=+J[Ve+8+(jn<<4)>>3],B=+J[Ve+8+(cn<<4)>>3]-R,H=re*M-F*B,H!=0&&(Re=ge-T,jt=me-R,B=(Re*B-M*jt)/H,!(B<0|B>1))&&(H=(re*Re-F*jt)/H,H>=0&H<=1)){d=1;break e}while((d|0)<(y|0))}if((p|0)>=(f[A>>2]|0)){d=0;break}}}else d=0;while(!1);return jn=d,Z=pn,jn|0}function Vd(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0;if(Af(A,d,p,_)|0)return T=1,T|0;if(T=A+8|0,(f[T>>2]|0)<=0)return T=0,T|0;for(y=A+12|0,A=0;;){if(M=A,A=A+1|0,Af((f[y>>2]|0)+(M<<3)|0,d+(A<<5)|0,p,_)|0){A=1,y=6;break}if((A|0)>=(f[T>>2]|0)){A=0,y=6;break}}return(y|0)==6?A|0:0}function yp(){return 8}function R1(){return 16}function xs(){return 168}function ur(){return 8}function xi(){return 16}function $l(){return 12}function Fa(){return 8}function xp(A){return A=A|0,+(+((f[A>>2]|0)>>>0)+4294967296*+(f[A+4>>2]|0))}function Xl(A){A=A|0;var d=0,p=0;return p=+J[A>>3],d=+J[A+8>>3],+ +yn(+(p*p+d*d))}function bp(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;F=+J[A>>3],B=+J[d>>3]-F,R=+J[A+8>>3],M=+J[d+8>>3]-R,re=+J[p>>3],T=+J[_>>3]-re,me=+J[p+8>>3],H=+J[_+8>>3]-me,T=(T*(R-me)-(F-re)*H)/(B*H-M*T),J[y>>3]=F+B*T,J[y+8>>3]=R+M*T}function Sp(A,d){return A=A|0,d=d|0,+An(+(+J[A>>3]-+J[d>>3]))<11920928955078125e-23?(d=+An(+(+J[A+8>>3]-+J[d+8>>3]))<11920928955078125e-23,d|0):(d=0,d|0)}function cr(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;return y=+J[A>>3]-+J[d>>3],_=+J[A+8>>3]-+J[d+8>>3],p=+J[A+16>>3]-+J[d+16>>3],+(y*y+_*_+p*p)}function ic(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;p=+J[A>>3],_=+on(+p),p=+xn(+p),J[d+16>>3]=p,p=+J[A+8>>3],y=_*+on(+p),J[d>>3]=y,p=_*+xn(+p),J[d+8>>3]=p}function Tp(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if(T=Z,Z=Z+16|0,y=T,_=Ri(A,d)|0,(p+-1|0)>>>0>5||(_=(_|0)!=0,(p|0)==1&_))return y=-1,Z=T,y|0;do if(gl(A,d,y)|0)_=-1;else if(_){_=((f[26352+(p<<2)>>2]|0)+5-(f[y>>2]|0)|0)%5|0;break}else{_=((f[26384+(p<<2)>>2]|0)+6-(f[y>>2]|0)|0)%6|0;break}while(!1);return y=_,Z=T,y|0}function gl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(H=Z,Z=Z+32|0,R=H+16|0,B=H,_=Xu(A,d,R)|0,_|0)return p=_,Z=H,p|0;T=v1(A,d)|0,F=ta(A,d)|0,Cr(T,B),_=lr(T,f[R>>2]|0)|0;do if($n(T)|0){do switch(T|0){case 4:{y=0;break}case 14:{y=1;break}case 24:{y=2;break}case 38:{y=3;break}case 49:{y=4;break}case 58:{y=5;break}case 63:{y=6;break}case 72:{y=7;break}case 83:{y=8;break}case 97:{y=9;break}case 107:{y=10;break}case 117:{y=11;break}default:Vt(27795,27797,75,27806)}while(!1);if(M=f[26416+(y*24|0)+8>>2]|0,d=f[26416+(y*24|0)+16>>2]|0,A=f[R>>2]|0,(A|0)!=(f[B>>2]|0)&&(B=or(T)|0,A=f[R>>2]|0,B|(A|0)==(d|0)&&(_=(_+1|0)%6|0)),(F|0)==3&(A|0)==(d|0)){_=(_+5|0)%6|0;break}(F|0)==5&(A|0)==(M|0)&&(_=(_+1|0)%6|0)}while(!1);return f[p>>2]=_,p=0,Z=H,p|0}function ra(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0;if(Ve=Z,Z=Z+32|0,He=Ve+24|0,Ie=Ve+20|0,ge=Ve+8|0,pe=Ve+16|0,me=Ve,B=(Ri(A,d)|0)==0,B=B?6:5,H=Ut(A|0,d|0,52)|0,ee()|0,H=H&15,B>>>0<=p>>>0)return _=2,Z=Ve,_|0;re=(H|0)==0,!re&&(Ne=zt(7,0,(H^15)*3|0)|0,(Ne&A|0)==0&((ee()|0)&d|0)==0)?y=p:T=4;e:do if((T|0)==4){if(y=(Ri(A,d)|0)!=0,((y?4:5)|0)<(p|0)||gl(A,d,He)|0||(T=(f[He>>2]|0)+p|0,y?y=26704+(((T|0)%5|0)<<2)|0:y=26736+(((T|0)%6|0)<<2)|0,Ne=f[y>>2]|0,(Ne|0)==7))return _=1,Z=Ve,_|0;f[Ie>>2]=0,y=_i(A,d,Ne,Ie,ge)|0;do if(!y){if(R=ge,F=f[R>>2]|0,R=f[R+4>>2]|0,M=R>>>0>>0|(R|0)==(d|0)&F>>>0>>0,T=M?F:A,M=M?R:d,!re&&(re=zt(7,0,(H^15)*3|0)|0,(F&re|0)==0&(R&(ee()|0)|0)==0))y=p;else{if(R=(p+-1+B|0)%(B|0)|0,y=Ri(A,d)|0,(R|0)<0&&Vt(27795,27797,248,27822),B=(y|0)!=0,((B?4:5)|0)<(R|0)&&Vt(27795,27797,248,27822),gl(A,d,He)|0&&Vt(27795,27797,248,27822),y=(f[He>>2]|0)+R|0,B?y=26704+(((y|0)%5|0)<<2)|0:y=26736+(((y|0)%6|0)<<2)|0,R=f[y>>2]|0,(R|0)==7&&Vt(27795,27797,248,27822),f[pe>>2]=0,y=_i(A,d,R,pe,me)|0,y|0)break;F=me,B=f[F>>2]|0,F=f[F+4>>2]|0;do if(F>>>0>>0|(F|0)==(M|0)&B>>>0>>0){if(Ri(B,F)|0?T=ts(B,F,A,d)|0:T=f[26800+((((f[pe>>2]|0)+(f[26768+(R<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=Ri(B,F)|0,(T+-1|0)>>>0>5){y=-1,T=B,M=F;break}if(y=(y|0)!=0,(T|0)==1&y){y=-1,T=B,M=F;break}do if(gl(B,F,He)|0)y=-1;else if(y){y=((f[26352+(T<<2)>>2]|0)+5-(f[He>>2]|0)|0)%5|0;break}else{y=((f[26384+(T<<2)>>2]|0)+6-(f[He>>2]|0)|0)%6|0;break}while(!1);T=B,M=F}else y=p;while(!1);R=ge,F=f[R>>2]|0,R=f[R+4>>2]|0}if((T|0)==(F|0)&(M|0)==(R|0)){if(B=(Ri(F,R)|0)!=0,B?A=ts(F,R,A,d)|0:A=f[26800+((((f[Ie>>2]|0)+(f[26768+(Ne<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=Ri(F,R)|0,(A+-1|0)>>>0<=5&&(Je=(y|0)!=0,!((A|0)==1&Je)))do if(gl(F,R,He)|0)y=-1;else if(Je){y=((f[26352+(A<<2)>>2]|0)+5-(f[He>>2]|0)|0)%5|0;break}else{y=((f[26384+(A<<2)>>2]|0)+6-(f[He>>2]|0)|0)%6|0;break}while(!1);else y=-1;y=y+1|0,y=(y|0)==6|B&(y|0)==5?0:y}d=M,A=T;break e}while(!1);return _=y,Z=Ve,_|0}while(!1);return Je=zt(y|0,0,56)|0,He=ee()|0|d&-2130706433|536870912,f[_>>2]=Je|A,f[_+4>>2]=He,_=0,Z=Ve,_|0}function rc(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;return T=(Ri(A,d)|0)==0,_=ra(A,d,0,p)|0,y=(_|0)==0,T?!y||(_=ra(A,d,1,p+8|0)|0,_|0)||(_=ra(A,d,2,p+16|0)|0,_|0)||(_=ra(A,d,3,p+24|0)|0,_|0)||(_=ra(A,d,4,p+32|0)|0,_)?(T=_,T|0):ra(A,d,5,p+40|0)|0:!y||(_=ra(A,d,1,p+8|0)|0,_|0)||(_=ra(A,d,2,p+16|0)|0,_|0)||(_=ra(A,d,3,p+24|0)|0,_|0)||(_=ra(A,d,4,p+32|0)|0,_|0)?(T=_,T|0):(T=p+40|0,f[T>>2]=0,f[T+4>>2]=0,T=0,T|0)}function vl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0;return B=Z,Z=Z+192|0,y=B,T=B+168|0,M=Ut(A|0,d|0,56)|0,ee()|0,M=M&7,R=d&-2130706433|134217728,_=Xu(A,R,T)|0,_|0?(R=_,Z=B,R|0):(d=Ut(A|0,d|0,52)|0,ee()|0,d=d&15,Ri(A,R)|0?ap(T,d,M,1,y):Pd(T,d,M,1,y),R=y+8|0,f[p>>2]=f[R>>2],f[p+4>>2]=f[R+4>>2],f[p+8>>2]=f[R+8>>2],f[p+12>>2]=f[R+12>>2],R=0,Z=B,R|0)}function _l(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return y=Z,Z=Z+16|0,p=y,!(!0&(d&2013265920|0)==536870912)||(_=d&-2130706433|134217728,!(Ld(A,_)|0))?(_=0,Z=y,_|0):(T=Ut(A|0,d|0,56)|0,ee()|0,T=(ra(A,_,T&7,p)|0)==0,_=p,_=T&((f[_>>2]|0)==(A|0)?(f[_+4>>2]|0)==(d|0):0)&1,Z=y,_|0)}function Wo(A,d,p){A=A|0,d=d|0,p=p|0;var _=0;(d|0)>0?(_=sa(d,4)|0,f[A>>2]=_,_||Vt(27835,27858,40,27872)):f[A>>2]=0,f[A+4>>2]=d,f[A+8>>2]=0,f[A+12>>2]=p}function jd(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;y=A+4|0,T=A+12|0,M=A+8|0;e:for(;;){for(p=f[y>>2]|0,d=0;;){if((d|0)>=(p|0))break e;if(_=f[A>>2]|0,R=f[_+(d<<2)>>2]|0,!R)d=d+1|0;else break}d=_+(~~(+An(+(+zr(10,+ +(15-(f[T>>2]|0)|0))*(+J[R>>3]+ +J[R+8>>3])))%+(p|0))>>>0<<2)|0,p=f[d>>2]|0;t:do if(p|0){if(_=R+32|0,(p|0)==(R|0))f[d>>2]=f[_>>2];else{if(p=p+32|0,d=f[p>>2]|0,!d)break;for(;(d|0)!=(R|0);)if(p=d+32|0,d=f[p>>2]|0,!d)break t;f[p>>2]=f[_>>2]}wn(R),f[M>>2]=(f[M>>2]|0)+-1}while(!1)}wn(f[A>>2]|0)}function Hd(A){A=A|0;var d=0,p=0,_=0;for(_=f[A+4>>2]|0,p=0;;){if((p|0)>=(_|0)){d=0,p=4;break}if(d=f[(f[A>>2]|0)+(p<<2)>>2]|0,!d)p=p+1|0;else{p=4;break}}return(p|0)==4?d|0:0}function sc(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;if(p=~~(+An(+(+zr(10,+ +(15-(f[A+12>>2]|0)|0))*(+J[d>>3]+ +J[d+8>>3])))%+(f[A+4>>2]|0))>>>0,p=(f[A>>2]|0)+(p<<2)|0,_=f[p>>2]|0,!_)return T=1,T|0;T=d+32|0;do if((_|0)!=(d|0)){if(p=f[_+32>>2]|0,!p)return T=1,T|0;for(y=p;;){if((y|0)==(d|0)){y=8;break}if(p=f[y+32>>2]|0,p)_=y,y=p;else{p=1,y=10;break}}if((y|0)==8){f[_+32>>2]=f[T>>2];break}else if((y|0)==10)return p|0}else f[p>>2]=f[T>>2];while(!1);return wn(d),T=A+8|0,f[T>>2]=(f[T>>2]|0)+-1,T=0,T|0}function Wd(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;T=$o(40)|0,T||Vt(27888,27858,98,27901),f[T>>2]=f[d>>2],f[T+4>>2]=f[d+4>>2],f[T+8>>2]=f[d+8>>2],f[T+12>>2]=f[d+12>>2],y=T+16|0,f[y>>2]=f[p>>2],f[y+4>>2]=f[p+4>>2],f[y+8>>2]=f[p+8>>2],f[y+12>>2]=f[p+12>>2],f[T+32>>2]=0,y=~~(+An(+(+zr(10,+ +(15-(f[A+12>>2]|0)|0))*(+J[d>>3]+ +J[d+8>>3])))%+(f[A+4>>2]|0))>>>0,y=(f[A>>2]|0)+(y<<2)|0,_=f[y>>2]|0;do if(!_)f[y>>2]=T;else{for(;!(La(_,d)|0&&La(_+16|0,p)|0);)if(y=f[_+32>>2]|0,_=(y|0)==0?_:y,!(f[_+32>>2]|0)){M=10;break}if((M|0)==10){f[_+32>>2]=T;break}return wn(T),M=_,M|0}while(!1);return M=A+8|0,f[M>>2]=(f[M>>2]|0)+1,M=T,M|0}function ac(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;if(y=~~(+An(+(+zr(10,+ +(15-(f[A+12>>2]|0)|0))*(+J[d>>3]+ +J[d+8>>3])))%+(f[A+4>>2]|0))>>>0,y=f[(f[A>>2]|0)+(y<<2)>>2]|0,!y)return p=0,p|0;if(!p){for(A=y;;){if(La(A,d)|0){_=10;break}if(A=f[A+32>>2]|0,!A){A=0,_=10;break}}if((_|0)==10)return A|0}for(A=y;;){if(La(A,d)|0&&La(A+16|0,p)|0){_=10;break}if(A=f[A+32>>2]|0,!A){A=0,_=10;break}}return(_|0)==10?A|0:0}function bs(A,d){A=A|0,d=d|0;var p=0;if(p=~~(+An(+(+zr(10,+ +(15-(f[A+12>>2]|0)|0))*(+J[d>>3]+ +J[d+8>>3])))%+(f[A+4>>2]|0))>>>0,A=f[(f[A>>2]|0)+(p<<2)>>2]|0,!A)return p=0,p|0;for(;;){if(La(A,d)|0){d=5;break}if(A=f[A+32>>2]|0,!A){A=0,d=5;break}}return(d|0)==5?A|0:0}function $d(){return 27920}function yl(A){return A=+A,~~+vf(+A)|0}function $o(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0;jt=Z,Z=Z+16|0,me=jt;do if(A>>>0<245){if(F=A>>>0<11?16:A+11&-8,A=F>>>3,re=f[6981]|0,p=re>>>A,p&3|0)return d=(p&1^1)+A|0,A=27964+(d<<1<<2)|0,p=A+8|0,_=f[p>>2]|0,y=_+8|0,T=f[y>>2]|0,(T|0)==(A|0)?f[6981]=re&~(1<>2]=A,f[p>>2]=T),Re=d<<3,f[_+4>>2]=Re|3,Re=_+Re+4|0,f[Re>>2]=f[Re>>2]|1,Re=y,Z=jt,Re|0;if(H=f[6983]|0,F>>>0>H>>>0){if(p|0)return d=2<>>12&16,d=d>>>R,p=d>>>5&8,d=d>>>p,T=d>>>2&4,d=d>>>T,A=d>>>1&2,d=d>>>A,_=d>>>1&1,_=(p|R|T|A|_)+(d>>>_)|0,d=27964+(_<<1<<2)|0,A=d+8|0,T=f[A>>2]|0,R=T+8|0,p=f[R>>2]|0,(p|0)==(d|0)?(A=re&~(1<<_),f[6981]=A):(f[p+12>>2]=d,f[A>>2]=p,A=re),Re=_<<3,M=Re-F|0,f[T+4>>2]=F|3,y=T+F|0,f[y+4>>2]=M|1,f[T+Re>>2]=M,H|0&&(_=f[6986]|0,d=H>>>3,p=27964+(d<<1<<2)|0,d=1<>2]|0):(f[6981]=A|d,d=p,A=p+8|0),f[A>>2]=_,f[d+12>>2]=_,f[_+8>>2]=d,f[_+12>>2]=p),f[6983]=M,f[6986]=y,Re=R,Z=jt,Re|0;if(T=f[6982]|0,T){for(p=(T&0-T)+-1|0,y=p>>>12&16,p=p>>>y,_=p>>>5&8,p=p>>>_,M=p>>>2&4,p=p>>>M,R=p>>>1&2,p=p>>>R,B=p>>>1&1,B=f[28228+((_|y|M|R|B)+(p>>>B)<<2)>>2]|0,p=B,R=B,B=(f[B+4>>2]&-8)-F|0;A=f[p+16>>2]|0,!(!A&&(A=f[p+20>>2]|0,!A));)M=(f[A+4>>2]&-8)-F|0,y=M>>>0>>0,p=A,R=y?A:R,B=y?M:B;if(M=R+F|0,M>>>0>R>>>0){y=f[R+24>>2]|0,d=f[R+12>>2]|0;do if((d|0)==(R|0)){if(A=R+20|0,d=f[A>>2]|0,!d&&(A=R+16|0,d=f[A>>2]|0,!d)){p=0;break}for(;;)if(_=d+20|0,p=f[_>>2]|0,p)d=p,A=_;else if(_=d+16|0,p=f[_>>2]|0,p)d=p,A=_;else break;f[A>>2]=0,p=d}else p=f[R+8>>2]|0,f[p+12>>2]=d,f[d+8>>2]=p,p=d;while(!1);do if(y|0){if(d=f[R+28>>2]|0,A=28228+(d<<2)|0,(R|0)==(f[A>>2]|0)){if(f[A>>2]=p,!p){f[6982]=T&~(1<>2]|0)==(R|0)?Re:y+20|0)>>2]=p,!p)break;f[p+24>>2]=y,d=f[R+16>>2]|0,d|0&&(f[p+16>>2]=d,f[d+24>>2]=p),d=f[R+20>>2]|0,d|0&&(f[p+20>>2]=d,f[d+24>>2]=p)}while(!1);return B>>>0<16?(Re=B+F|0,f[R+4>>2]=Re|3,Re=R+Re+4|0,f[Re>>2]=f[Re>>2]|1):(f[R+4>>2]=F|3,f[M+4>>2]=B|1,f[M+B>>2]=B,H|0&&(_=f[6986]|0,d=H>>>3,p=27964+(d<<1<<2)|0,d=1<>2]|0):(f[6981]=d|re,d=p,A=p+8|0),f[A>>2]=_,f[d+12>>2]=_,f[_+8>>2]=d,f[_+12>>2]=p),f[6983]=B,f[6986]=M),Re=R+8|0,Z=jt,Re|0}else re=F}else re=F}else re=F}else if(A>>>0<=4294967231)if(A=A+11|0,F=A&-8,_=f[6982]|0,_){y=0-F|0,A=A>>>8,A?F>>>0>16777215?B=31:(re=(A+1048320|0)>>>16&8,Ne=A<>>16&4,Ne=Ne<>>16&2,B=14-(R|re|B)+(Ne<>>15)|0,B=F>>>(B+7|0)&1|B<<1):B=0,p=f[28228+(B<<2)>>2]|0;e:do if(!p)p=0,A=0,Ne=61;else for(A=0,R=F<<((B|0)==31?0:25-(B>>>1)|0),T=0;;){if(M=(f[p+4>>2]&-8)-F|0,M>>>0>>0)if(M)A=p,y=M;else{A=p,y=0,Ne=65;break e}if(Ne=f[p+20>>2]|0,p=f[p+16+(R>>>31<<2)>>2]|0,T=(Ne|0)==0|(Ne|0)==(p|0)?T:Ne,p)R=R<<1;else{p=T,Ne=61;break}}while(!1);if((Ne|0)==61){if((p|0)==0&(A|0)==0){if(A=2<>>12&16,re=re>>>M,T=re>>>5&8,re=re>>>T,R=re>>>2&4,re=re>>>R,B=re>>>1&2,re=re>>>B,p=re>>>1&1,A=0,p=f[28228+((T|M|R|B|p)+(re>>>p)<<2)>>2]|0}p?Ne=65:(R=A,M=y)}if((Ne|0)==65)for(T=p;;)if(re=(f[T+4>>2]&-8)-F|0,p=re>>>0>>0,y=p?re:y,A=p?T:A,p=f[T+16>>2]|0,p||(p=f[T+20>>2]|0),p)T=p;else{R=A,M=y;break}if((R|0)!=0&&M>>>0<((f[6983]|0)-F|0)>>>0&&(H=R+F|0,H>>>0>R>>>0)){T=f[R+24>>2]|0,d=f[R+12>>2]|0;do if((d|0)==(R|0)){if(A=R+20|0,d=f[A>>2]|0,!d&&(A=R+16|0,d=f[A>>2]|0,!d)){d=0;break}for(;;)if(y=d+20|0,p=f[y>>2]|0,p)d=p,A=y;else if(y=d+16|0,p=f[y>>2]|0,p)d=p,A=y;else break;f[A>>2]=0}else Re=f[R+8>>2]|0,f[Re+12>>2]=d,f[d+8>>2]=Re;while(!1);do if(T){if(A=f[R+28>>2]|0,p=28228+(A<<2)|0,(R|0)==(f[p>>2]|0)){if(f[p>>2]=d,!d){_=_&~(1<>2]|0)==(R|0)?Re:T+20|0)>>2]=d,!d)break;f[d+24>>2]=T,A=f[R+16>>2]|0,A|0&&(f[d+16>>2]=A,f[A+24>>2]=d),A=f[R+20>>2]|0,A&&(f[d+20>>2]=A,f[A+24>>2]=d)}while(!1);e:do if(M>>>0<16)Re=M+F|0,f[R+4>>2]=Re|3,Re=R+Re+4|0,f[Re>>2]=f[Re>>2]|1;else{if(f[R+4>>2]=F|3,f[H+4>>2]=M|1,f[H+M>>2]=M,d=M>>>3,M>>>0<256){p=27964+(d<<1<<2)|0,A=f[6981]|0,d=1<>2]|0):(f[6981]=A|d,d=p,A=p+8|0),f[A>>2]=H,f[d+12>>2]=H,f[H+8>>2]=d,f[H+12>>2]=p;break}if(d=M>>>8,d?M>>>0>16777215?p=31:(Ve=(d+1048320|0)>>>16&8,Re=d<>>16&4,Re=Re<>>16&2,p=14-(He|Ve|p)+(Re<

>>15)|0,p=M>>>(p+7|0)&1|p<<1):p=0,d=28228+(p<<2)|0,f[H+28>>2]=p,A=H+16|0,f[A+4>>2]=0,f[A>>2]=0,A=1<>2]=H,f[H+24>>2]=d,f[H+12>>2]=H,f[H+8>>2]=H;break}d=f[d>>2]|0;t:do if((f[d+4>>2]&-8|0)!=(M|0)){for(_=M<<((p|0)==31?0:25-(p>>>1)|0);p=d+16+(_>>>31<<2)|0,A=f[p>>2]|0,!!A;)if((f[A+4>>2]&-8|0)==(M|0)){d=A;break t}else _=_<<1,d=A;f[p>>2]=H,f[H+24>>2]=d,f[H+12>>2]=H,f[H+8>>2]=H;break e}while(!1);Ve=d+8|0,Re=f[Ve>>2]|0,f[Re+12>>2]=H,f[Ve>>2]=H,f[H+8>>2]=Re,f[H+12>>2]=d,f[H+24>>2]=0}while(!1);return Re=R+8|0,Z=jt,Re|0}else re=F}else re=F;else re=-1;while(!1);if(p=f[6983]|0,p>>>0>=re>>>0)return d=p-re|0,A=f[6986]|0,d>>>0>15?(Re=A+re|0,f[6986]=Re,f[6983]=d,f[Re+4>>2]=d|1,f[A+p>>2]=d,f[A+4>>2]=re|3):(f[6983]=0,f[6986]=0,f[A+4>>2]=p|3,Re=A+p+4|0,f[Re>>2]=f[Re>>2]|1),Re=A+8|0,Z=jt,Re|0;if(M=f[6984]|0,M>>>0>re>>>0)return He=M-re|0,f[6984]=He,Re=f[6987]|0,Ve=Re+re|0,f[6987]=Ve,f[Ve+4>>2]=He|1,f[Re+4>>2]=re|3,Re=Re+8|0,Z=jt,Re|0;if(f[7099]|0?A=f[7101]|0:(f[7101]=4096,f[7100]=4096,f[7102]=-1,f[7103]=-1,f[7104]=0,f[7092]=0,f[7099]=me&-16^1431655768,A=4096),R=re+48|0,B=re+47|0,T=A+B|0,y=0-A|0,F=T&y,F>>>0<=re>>>0||(A=f[7091]|0,A|0&&(H=f[7089]|0,me=H+F|0,me>>>0<=H>>>0|me>>>0>A>>>0)))return Re=0,Z=jt,Re|0;e:do if(f[7092]&4)d=0,Ne=143;else{p=f[6987]|0;t:do if(p){for(_=28372;me=f[_>>2]|0,!(me>>>0<=p>>>0&&(me+(f[_+4>>2]|0)|0)>>>0>p>>>0);)if(A=f[_+8>>2]|0,A)_=A;else{Ne=128;break t}if(d=T-M&y,d>>>0<2147483647)if(A=bl(d|0)|0,(A|0)==((f[_>>2]|0)+(f[_+4>>2]|0)|0)){if((A|0)!=-1){M=d,T=A,Ne=145;break e}}else _=A,Ne=136;else d=0}else Ne=128;while(!1);do if((Ne|0)==128)if(p=bl(0)|0,(p|0)!=-1&&(d=p,pe=f[7100]|0,ge=pe+-1|0,d=((ge&d|0)==0?0:(ge+d&0-pe)-d|0)+F|0,pe=f[7089]|0,ge=d+pe|0,d>>>0>re>>>0&d>>>0<2147483647)){if(me=f[7091]|0,me|0&&ge>>>0<=pe>>>0|ge>>>0>me>>>0){d=0;break}if(A=bl(d|0)|0,(A|0)==(p|0)){M=d,T=p,Ne=145;break e}else _=A,Ne=136}else d=0;while(!1);do if((Ne|0)==136){if(p=0-d|0,!(R>>>0>d>>>0&(d>>>0<2147483647&(_|0)!=-1)))if((_|0)==-1){d=0;break}else{M=d,T=_,Ne=145;break e}if(A=f[7101]|0,A=B-d+A&0-A,A>>>0>=2147483647){M=d,T=_,Ne=145;break e}if((bl(A|0)|0)==-1){bl(p|0)|0,d=0;break}else{M=A+d|0,T=_,Ne=145;break e}}while(!1);f[7092]=f[7092]|4,Ne=143}while(!1);if((Ne|0)==143&&F>>>0<2147483647&&(He=bl(F|0)|0,ge=bl(0)|0,Ie=ge-He|0,Je=Ie>>>0>(re+40|0)>>>0,!((He|0)==-1|Je^1|He>>>0>>0&((He|0)!=-1&(ge|0)!=-1)^1))&&(M=Je?Ie:d,T=He,Ne=145),(Ne|0)==145){d=(f[7089]|0)+M|0,f[7089]=d,d>>>0>(f[7090]|0)>>>0&&(f[7090]=d),B=f[6987]|0;e:do if(B){for(d=28372;;){if(A=f[d>>2]|0,p=f[d+4>>2]|0,(T|0)==(A+p|0)){Ne=154;break}if(_=f[d+8>>2]|0,_)d=_;else break}if((Ne|0)==154&&(Ve=d+4|0,(f[d+12>>2]&8|0)==0)&&T>>>0>B>>>0&A>>>0<=B>>>0){f[Ve>>2]=p+M,Re=(f[6984]|0)+M|0,He=B+8|0,He=(He&7|0)==0?0:0-He&7,Ve=B+He|0,He=Re-He|0,f[6987]=Ve,f[6984]=He,f[Ve+4>>2]=He|1,f[B+Re+4>>2]=40,f[6988]=f[7103];break}for(T>>>0<(f[6985]|0)>>>0&&(f[6985]=T),p=T+M|0,d=28372;;){if((f[d>>2]|0)==(p|0)){Ne=162;break}if(A=f[d+8>>2]|0,A)d=A;else break}if((Ne|0)==162&&(f[d+12>>2]&8|0)==0){f[d>>2]=T,H=d+4|0,f[H>>2]=(f[H>>2]|0)+M,H=T+8|0,H=T+((H&7|0)==0?0:0-H&7)|0,d=p+8|0,d=p+((d&7|0)==0?0:0-d&7)|0,F=H+re|0,R=d-H-re|0,f[H+4>>2]=re|3;t:do if((B|0)==(d|0))Re=(f[6984]|0)+R|0,f[6984]=Re,f[6987]=F,f[F+4>>2]=Re|1;else{if((f[6986]|0)==(d|0)){Re=(f[6983]|0)+R|0,f[6983]=Re,f[6986]=F,f[F+4>>2]=Re|1,f[F+Re>>2]=Re;break}if(A=f[d+4>>2]|0,(A&3|0)==1){M=A&-8,_=A>>>3;n:do if(A>>>0<256)if(A=f[d+8>>2]|0,p=f[d+12>>2]|0,(p|0)==(A|0)){f[6981]=f[6981]&~(1<<_);break}else{f[A+12>>2]=p,f[p+8>>2]=A;break}else{T=f[d+24>>2]|0,A=f[d+12>>2]|0;do if((A|0)==(d|0)){if(p=d+16|0,_=p+4|0,A=f[_>>2]|0,A)p=_;else if(A=f[p>>2]|0,!A){A=0;break}for(;;)if(y=A+20|0,_=f[y>>2]|0,_)A=_,p=y;else if(y=A+16|0,_=f[y>>2]|0,_)A=_,p=y;else break;f[p>>2]=0}else Re=f[d+8>>2]|0,f[Re+12>>2]=A,f[A+8>>2]=Re;while(!1);if(!T)break;p=f[d+28>>2]|0,_=28228+(p<<2)|0;do if((f[_>>2]|0)!=(d|0)){if(Re=T+16|0,f[((f[Re>>2]|0)==(d|0)?Re:T+20|0)>>2]=A,!A)break n}else{if(f[_>>2]=A,A|0)break;f[6982]=f[6982]&~(1<>2]=T,p=d+16|0,_=f[p>>2]|0,_|0&&(f[A+16>>2]=_,f[_+24>>2]=A),p=f[p+4>>2]|0,!p)break;f[A+20>>2]=p,f[p+24>>2]=A}while(!1);d=d+M|0,y=M+R|0}else y=R;if(d=d+4|0,f[d>>2]=f[d>>2]&-2,f[F+4>>2]=y|1,f[F+y>>2]=y,d=y>>>3,y>>>0<256){p=27964+(d<<1<<2)|0,A=f[6981]|0,d=1<>2]|0):(f[6981]=A|d,d=p,A=p+8|0),f[A>>2]=F,f[d+12>>2]=F,f[F+8>>2]=d,f[F+12>>2]=p;break}d=y>>>8;do if(!d)_=0;else{if(y>>>0>16777215){_=31;break}Ve=(d+1048320|0)>>>16&8,Re=d<>>16&4,Re=Re<>>16&2,_=14-(He|Ve|_)+(Re<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1}while(!1);if(d=28228+(_<<2)|0,f[F+28>>2]=_,A=F+16|0,f[A+4>>2]=0,f[A>>2]=0,A=f[6982]|0,p=1<<_,!(A&p)){f[6982]=A|p,f[d>>2]=F,f[F+24>>2]=d,f[F+12>>2]=F,f[F+8>>2]=F;break}d=f[d>>2]|0;n:do if((f[d+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=d+16+(_>>>31<<2)|0,A=f[p>>2]|0,!!A;)if((f[A+4>>2]&-8|0)==(y|0)){d=A;break n}else _=_<<1,d=A;f[p>>2]=F,f[F+24>>2]=d,f[F+12>>2]=F,f[F+8>>2]=F;break t}while(!1);Ve=d+8|0,Re=f[Ve>>2]|0,f[Re+12>>2]=F,f[Ve>>2]=F,f[F+8>>2]=Re,f[F+12>>2]=d,f[F+24>>2]=0}while(!1);return Re=H+8|0,Z=jt,Re|0}for(d=28372;A=f[d>>2]|0,!(A>>>0<=B>>>0&&(Re=A+(f[d+4>>2]|0)|0,Re>>>0>B>>>0));)d=f[d+8>>2]|0;y=Re+-47|0,A=y+8|0,A=y+((A&7|0)==0?0:0-A&7)|0,y=B+16|0,A=A>>>0>>0?B:A,d=A+8|0,p=M+-40|0,He=T+8|0,He=(He&7|0)==0?0:0-He&7,Ve=T+He|0,He=p-He|0,f[6987]=Ve,f[6984]=He,f[Ve+4>>2]=He|1,f[T+p+4>>2]=40,f[6988]=f[7103],p=A+4|0,f[p>>2]=27,f[d>>2]=f[7093],f[d+4>>2]=f[7094],f[d+8>>2]=f[7095],f[d+12>>2]=f[7096],f[7093]=T,f[7094]=M,f[7096]=0,f[7095]=d,d=A+24|0;do Ve=d,d=d+4|0,f[d>>2]=7;while((Ve+8|0)>>>0>>0);if((A|0)!=(B|0)){if(T=A-B|0,f[p>>2]=f[p>>2]&-2,f[B+4>>2]=T|1,f[A>>2]=T,d=T>>>3,T>>>0<256){p=27964+(d<<1<<2)|0,A=f[6981]|0,d=1<>2]|0):(f[6981]=A|d,d=p,A=p+8|0),f[A>>2]=B,f[d+12>>2]=B,f[B+8>>2]=d,f[B+12>>2]=p;break}if(d=T>>>8,d?T>>>0>16777215?_=31:(Ve=(d+1048320|0)>>>16&8,Re=d<>>16&4,Re=Re<>>16&2,_=14-(He|Ve|_)+(Re<<_>>>15)|0,_=T>>>(_+7|0)&1|_<<1):_=0,p=28228+(_<<2)|0,f[B+28>>2]=_,f[B+20>>2]=0,f[y>>2]=0,d=f[6982]|0,A=1<<_,!(d&A)){f[6982]=d|A,f[p>>2]=B,f[B+24>>2]=p,f[B+12>>2]=B,f[B+8>>2]=B;break}d=f[p>>2]|0;t:do if((f[d+4>>2]&-8|0)!=(T|0)){for(_=T<<((_|0)==31?0:25-(_>>>1)|0);p=d+16+(_>>>31<<2)|0,A=f[p>>2]|0,!!A;)if((f[A+4>>2]&-8|0)==(T|0)){d=A;break t}else _=_<<1,d=A;f[p>>2]=B,f[B+24>>2]=d,f[B+12>>2]=B,f[B+8>>2]=B;break e}while(!1);Ve=d+8|0,Re=f[Ve>>2]|0,f[Re+12>>2]=B,f[Ve>>2]=B,f[B+8>>2]=Re,f[B+12>>2]=d,f[B+24>>2]=0}}else Re=f[6985]|0,(Re|0)==0|T>>>0>>0&&(f[6985]=T),f[7093]=T,f[7094]=M,f[7096]=0,f[6990]=f[7099],f[6989]=-1,f[6994]=27964,f[6993]=27964,f[6996]=27972,f[6995]=27972,f[6998]=27980,f[6997]=27980,f[7e3]=27988,f[6999]=27988,f[7002]=27996,f[7001]=27996,f[7004]=28004,f[7003]=28004,f[7006]=28012,f[7005]=28012,f[7008]=28020,f[7007]=28020,f[7010]=28028,f[7009]=28028,f[7012]=28036,f[7011]=28036,f[7014]=28044,f[7013]=28044,f[7016]=28052,f[7015]=28052,f[7018]=28060,f[7017]=28060,f[7020]=28068,f[7019]=28068,f[7022]=28076,f[7021]=28076,f[7024]=28084,f[7023]=28084,f[7026]=28092,f[7025]=28092,f[7028]=28100,f[7027]=28100,f[7030]=28108,f[7029]=28108,f[7032]=28116,f[7031]=28116,f[7034]=28124,f[7033]=28124,f[7036]=28132,f[7035]=28132,f[7038]=28140,f[7037]=28140,f[7040]=28148,f[7039]=28148,f[7042]=28156,f[7041]=28156,f[7044]=28164,f[7043]=28164,f[7046]=28172,f[7045]=28172,f[7048]=28180,f[7047]=28180,f[7050]=28188,f[7049]=28188,f[7052]=28196,f[7051]=28196,f[7054]=28204,f[7053]=28204,f[7056]=28212,f[7055]=28212,Re=M+-40|0,He=T+8|0,He=(He&7|0)==0?0:0-He&7,Ve=T+He|0,He=Re-He|0,f[6987]=Ve,f[6984]=He,f[Ve+4>>2]=He|1,f[T+Re+4>>2]=40,f[6988]=f[7103];while(!1);if(d=f[6984]|0,d>>>0>re>>>0)return He=d-re|0,f[6984]=He,Re=f[6987]|0,Ve=Re+re|0,f[6987]=Ve,f[Ve+4>>2]=He|1,f[Re+4>>2]=re|3,Re=Re+8|0,Z=jt,Re|0}return Re=$d()|0,f[Re>>2]=12,Re=0,Z=jt,Re|0}function wn(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(A){p=A+-8|0,y=f[6985]|0,A=f[A+-4>>2]|0,d=A&-8,B=p+d|0;do if(A&1)R=p,M=p;else{if(_=f[p>>2]|0,!(A&3)||(M=p+(0-_)|0,T=_+d|0,M>>>0>>0))return;if((f[6986]|0)==(M|0)){if(A=B+4|0,d=f[A>>2]|0,(d&3|0)!=3){R=M,d=T;break}f[6983]=T,f[A>>2]=d&-2,f[M+4>>2]=T|1,f[M+T>>2]=T;return}if(p=_>>>3,_>>>0<256)if(A=f[M+8>>2]|0,d=f[M+12>>2]|0,(d|0)==(A|0)){f[6981]=f[6981]&~(1<>2]=d,f[d+8>>2]=A,R=M,d=T;break}y=f[M+24>>2]|0,A=f[M+12>>2]|0;do if((A|0)==(M|0)){if(d=M+16|0,p=d+4|0,A=f[p>>2]|0,A)d=p;else if(A=f[d>>2]|0,!A){A=0;break}for(;;)if(_=A+20|0,p=f[_>>2]|0,p)A=p,d=_;else if(_=A+16|0,p=f[_>>2]|0,p)A=p,d=_;else break;f[d>>2]=0}else R=f[M+8>>2]|0,f[R+12>>2]=A,f[A+8>>2]=R;while(!1);if(y){if(d=f[M+28>>2]|0,p=28228+(d<<2)|0,(f[p>>2]|0)==(M|0)){if(f[p>>2]=A,!A){f[6982]=f[6982]&~(1<>2]|0)==(M|0)?R:y+20|0)>>2]=A,!A){R=M,d=T;break}f[A+24>>2]=y,d=M+16|0,p=f[d>>2]|0,p|0&&(f[A+16>>2]=p,f[p+24>>2]=A),d=f[d+4>>2]|0,d?(f[A+20>>2]=d,f[d+24>>2]=A,R=M,d=T):(R=M,d=T)}else R=M,d=T}while(!1);if(!(M>>>0>=B>>>0)&&(A=B+4|0,_=f[A>>2]|0,!!(_&1))){if(_&2)f[A>>2]=_&-2,f[R+4>>2]=d|1,f[M+d>>2]=d,y=d;else{if((f[6987]|0)==(B|0)){if(B=(f[6984]|0)+d|0,f[6984]=B,f[6987]=R,f[R+4>>2]=B|1,(R|0)!=(f[6986]|0))return;f[6986]=0,f[6983]=0;return}if((f[6986]|0)==(B|0)){B=(f[6983]|0)+d|0,f[6983]=B,f[6986]=M,f[R+4>>2]=B|1,f[M+B>>2]=B;return}y=(_&-8)+d|0,p=_>>>3;do if(_>>>0<256)if(d=f[B+8>>2]|0,A=f[B+12>>2]|0,(A|0)==(d|0)){f[6981]=f[6981]&~(1<>2]=A,f[A+8>>2]=d;break}else{T=f[B+24>>2]|0,A=f[B+12>>2]|0;do if((A|0)==(B|0)){if(d=B+16|0,p=d+4|0,A=f[p>>2]|0,A)d=p;else if(A=f[d>>2]|0,!A){p=0;break}for(;;)if(_=A+20|0,p=f[_>>2]|0,p)A=p,d=_;else if(_=A+16|0,p=f[_>>2]|0,p)A=p,d=_;else break;f[d>>2]=0,p=A}else p=f[B+8>>2]|0,f[p+12>>2]=A,f[A+8>>2]=p,p=A;while(!1);if(T|0){if(A=f[B+28>>2]|0,d=28228+(A<<2)|0,(f[d>>2]|0)==(B|0)){if(f[d>>2]=p,!p){f[6982]=f[6982]&~(1<>2]|0)==(B|0)?_:T+20|0)>>2]=p,!p)break;f[p+24>>2]=T,A=B+16|0,d=f[A>>2]|0,d|0&&(f[p+16>>2]=d,f[d+24>>2]=p),A=f[A+4>>2]|0,A|0&&(f[p+20>>2]=A,f[A+24>>2]=p)}}while(!1);if(f[R+4>>2]=y|1,f[M+y>>2]=y,(R|0)==(f[6986]|0)){f[6983]=y;return}}if(A=y>>>3,y>>>0<256){p=27964+(A<<1<<2)|0,d=f[6981]|0,A=1<>2]|0):(f[6981]=d|A,A=p,d=p+8|0),f[d>>2]=R,f[A+12>>2]=R,f[R+8>>2]=A,f[R+12>>2]=p;return}A=y>>>8,A?y>>>0>16777215?_=31:(M=(A+1048320|0)>>>16&8,B=A<>>16&4,B=B<>>16&2,_=14-(T|M|_)+(B<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1):_=0,A=28228+(_<<2)|0,f[R+28>>2]=_,f[R+20>>2]=0,f[R+16>>2]=0,d=f[6982]|0,p=1<<_;e:do if(!(d&p))f[6982]=d|p,f[A>>2]=R,f[R+24>>2]=A,f[R+12>>2]=R,f[R+8>>2]=R;else{A=f[A>>2]|0;t:do if((f[A+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=A+16+(_>>>31<<2)|0,d=f[p>>2]|0,!!d;)if((f[d+4>>2]&-8|0)==(y|0)){A=d;break t}else _=_<<1,A=d;f[p>>2]=R,f[R+24>>2]=A,f[R+12>>2]=R,f[R+8>>2]=R;break e}while(!1);M=A+8|0,B=f[M>>2]|0,f[B+12>>2]=R,f[M>>2]=R,f[R+8>>2]=B,f[R+12>>2]=A,f[R+24>>2]=0}while(!1);if(B=(f[6989]|0)+-1|0,f[6989]=B,!(B|0)){for(A=28380;A=f[A>>2]|0,A;)A=A+8|0;f[6989]=-1}}}}function sa(A,d){A=A|0,d=d|0;var p=0;return A?(p=Ke(d,A)|0,(d|A)>>>0>65535&&(p=((p>>>0)/(A>>>0)|0|0)==(d|0)?p:-1)):p=0,A=$o(p)|0,!A||!(f[A+-4>>2]&3)||vo(A|0,0,p|0)|0,A|0}function rn(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,p=A+p>>>0,Mt(d+_+(p>>>0>>0|0)>>>0|0),p|0|0}function Hr(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,_=d-_-(p>>>0>A>>>0|0)>>>0,Mt(_|0),A-p>>>0|0|0}function sh(A){return A=A|0,(A?31-(tn(A^A-1)|0)|0:32)|0}function oc(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0;if(H=A,B=d,F=B,M=p,me=_,R=me,!F)return T=(y|0)!=0,R?T?(f[y>>2]=A|0,f[y+4>>2]=d&0,me=0,y=0,Mt(me|0),y|0):(me=0,y=0,Mt(me|0),y|0):(T&&(f[y>>2]=(H>>>0)%(M>>>0),f[y+4>>2]=0),me=0,y=(H>>>0)/(M>>>0)>>>0,Mt(me|0),y|0);T=(R|0)==0;do if(M){if(!T){if(T=(tn(R|0)|0)-(tn(F|0)|0)|0,T>>>0<=31){re=T+1|0,R=31-T|0,d=T-31>>31,M=re,A=H>>>(re>>>0)&d|F<>>(re>>>0)&d,T=0,R=H<>2]=A|0,f[y+4>>2]=B|d&0,me=0,y=0,Mt(me|0),y|0):(me=0,y=0,Mt(me|0),y|0)}if(T=M-1|0,T&M|0){R=(tn(M|0)|0)+33-(tn(F|0)|0)|0,ge=64-R|0,re=32-R|0,B=re>>31,pe=R-32|0,d=pe>>31,M=R,A=re-1>>31&F>>>(pe>>>0)|(F<>>(R>>>0))&d,d=d&F>>>(R>>>0),T=H<>>(pe>>>0))&B|H<>31;break}return y|0&&(f[y>>2]=T&H,f[y+4>>2]=0),(M|0)==1?(pe=B|d&0,ge=A|0|0,Mt(pe|0),ge|0):(ge=sh(M|0)|0,pe=F>>>(ge>>>0)|0,ge=F<<32-ge|H>>>(ge>>>0)|0,Mt(pe|0),ge|0)}else{if(T)return y|0&&(f[y>>2]=(F>>>0)%(M>>>0),f[y+4>>2]=0),pe=0,ge=(F>>>0)/(M>>>0)>>>0,Mt(pe|0),ge|0;if(!H)return y|0&&(f[y>>2]=0,f[y+4>>2]=(F>>>0)%(R>>>0)),pe=0,ge=(F>>>0)/(R>>>0)>>>0,Mt(pe|0),ge|0;if(T=R-1|0,!(T&R))return y|0&&(f[y>>2]=A|0,f[y+4>>2]=T&F|d&0),pe=0,ge=F>>>((sh(R|0)|0)>>>0),Mt(pe|0),ge|0;if(T=(tn(R|0)|0)-(tn(F|0)|0)|0,T>>>0<=30){d=T+1|0,R=31-T|0,M=d,A=F<>>(d>>>0),d=F>>>(d>>>0),T=0,R=H<>2]=A|0,f[y+4>>2]=B|d&0,pe=0,ge=0,Mt(pe|0),ge|0):(pe=0,ge=0,Mt(pe|0),ge|0)}while(!1);if(!M)F=R,B=0,R=0;else{re=p|0|0,H=me|_&0,F=rn(re|0,H|0,-1,-1)|0,p=ee()|0,B=R,R=0;do _=B,B=T>>>31|B<<1,T=R|T<<1,_=A<<1|_>>>31|0,me=A>>>31|d<<1|0,Hr(F|0,p|0,_|0,me|0)|0,ge=ee()|0,pe=ge>>31|((ge|0)<0?-1:0)<<1,R=pe&1,A=Hr(_|0,me|0,pe&re|0,(((ge|0)<0?-1:0)>>31|((ge|0)<0?-1:0)<<1)&H|0)|0,d=ee()|0,M=M-1|0;while((M|0)!=0);F=B,B=0}return M=0,y|0&&(f[y>>2]=A,f[y+4>>2]=d),pe=(T|0)>>>31|(F|M)<<1|(M<<1|T>>>31)&0|B,ge=(T<<1|0)&-2|R,Mt(pe|0),ge|0}function Xo(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;return F=d>>31|((d|0)<0?-1:0)<<1,B=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1,T=_>>31|((_|0)<0?-1:0)<<1,y=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,R=Hr(F^A|0,B^d|0,F|0,B|0)|0,M=ee()|0,A=T^F,d=y^B,Hr((oc(R,M,Hr(T^p|0,y^_|0,T|0,y|0)|0,ee()|0,0)|0)^A|0,(ee()|0)^d|0,A|0,d|0)|0}function ah(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return T=A&65535,y=d&65535,p=Ke(y,T)|0,_=A>>>16,A=(p>>>16)+(Ke(y,_)|0)|0,y=d>>>16,d=Ke(y,T)|0,Mt((A>>>16)+(Ke(y,_)|0)+(((A&65535)+d|0)>>>16)|0),A+d<<16|p&65535|0|0}function vr(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0;return y=A,T=p,p=ah(y,T)|0,A=ee()|0,Mt((Ke(d,T)|0)+(Ke(_,y)|0)+A|A&0|0),p|0|0|0}function oh(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;return y=Z,Z=Z+16|0,R=y|0,M=d>>31|((d|0)<0?-1:0)<<1,T=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1,F=_>>31|((_|0)<0?-1:0)<<1,B=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,A=Hr(M^A|0,T^d|0,M|0,T|0)|0,d=ee()|0,oc(A,d,Hr(F^p|0,B^_|0,F|0,B|0)|0,ee()|0,R)|0,_=Hr(f[R>>2]^M|0,f[R+4>>2]^T|0,M|0,T|0)|0,p=ee()|0,Z=y,Mt(p|0),_|0}function lc(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0;return T=Z,Z=Z+16|0,y=T|0,oc(A,d,p,_,y)|0,Z=T,Mt(f[y+4>>2]|0),f[y>>2]|0|0}function D1(A,d,p){return A=A|0,d=d|0,p=p|0,(p|0)<32?(Mt(d>>p|0),A>>>p|(d&(1<>p-32|0)}function Ut(A,d,p){return A=A|0,d=d|0,p=p|0,(p|0)<32?(Mt(d>>>p|0),A>>>p|(d&(1<>>p-32|0)}function zt(A,d,p){return A=A|0,d=d|0,p=p|0,(p|0)<32?(Mt(d<>>32-p|0),A<=0?+zn(A+.5):+tt(A-.5)}function Yl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if((p|0)>=8192)return oi(A|0,d|0,p|0)|0,A|0;if(T=A|0,y=A+p|0,(A&3)==(d&3)){for(;A&3;){if(!p)return T|0;ot[A>>0]=ot[d>>0]|0,A=A+1|0,d=d+1|0,p=p-1|0}for(p=y&-4|0,_=p-64|0;(A|0)<=(_|0);)f[A>>2]=f[d>>2],f[A+4>>2]=f[d+4>>2],f[A+8>>2]=f[d+8>>2],f[A+12>>2]=f[d+12>>2],f[A+16>>2]=f[d+16>>2],f[A+20>>2]=f[d+20>>2],f[A+24>>2]=f[d+24>>2],f[A+28>>2]=f[d+28>>2],f[A+32>>2]=f[d+32>>2],f[A+36>>2]=f[d+36>>2],f[A+40>>2]=f[d+40>>2],f[A+44>>2]=f[d+44>>2],f[A+48>>2]=f[d+48>>2],f[A+52>>2]=f[d+52>>2],f[A+56>>2]=f[d+56>>2],f[A+60>>2]=f[d+60>>2],A=A+64|0,d=d+64|0;for(;(A|0)<(p|0);)f[A>>2]=f[d>>2],A=A+4|0,d=d+4|0}else for(p=y-4|0;(A|0)<(p|0);)ot[A>>0]=ot[d>>0]|0,ot[A+1>>0]=ot[d+1>>0]|0,ot[A+2>>0]=ot[d+2>>0]|0,ot[A+3>>0]=ot[d+3>>0]|0,A=A+4|0,d=d+4|0;for(;(A|0)<(y|0);)ot[A>>0]=ot[d>>0]|0,A=A+1|0,d=d+1|0;return T|0}function vo(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;if(T=A+p|0,d=d&255,(p|0)>=67){for(;A&3;)ot[A>>0]=d,A=A+1|0;for(_=T&-4|0,M=d|d<<8|d<<16|d<<24,y=_-64|0;(A|0)<=(y|0);)f[A>>2]=M,f[A+4>>2]=M,f[A+8>>2]=M,f[A+12>>2]=M,f[A+16>>2]=M,f[A+20>>2]=M,f[A+24>>2]=M,f[A+28>>2]=M,f[A+32>>2]=M,f[A+36>>2]=M,f[A+40>>2]=M,f[A+44>>2]=M,f[A+48>>2]=M,f[A+52>>2]=M,f[A+56>>2]=M,f[A+60>>2]=M,A=A+64|0;for(;(A|0)<(_|0);)f[A>>2]=M,A=A+4|0}for(;(A|0)<(T|0);)ot[A>>0]=d,A=A+1|0;return T-p|0}function vf(A){return A=+A,A>=0?+zn(A+.5):+tt(A-.5)}function bl(A){A=A|0;var d=0,p=0,_=0;return _=Tn()|0,p=f[fn>>2]|0,d=p+A|0,(A|0)>0&(d|0)<(p|0)|(d|0)<0?(Ii(d|0)|0,Fn(12),-1):(d|0)>(_|0)&&!(Ai(d|0)|0)?(Fn(12),-1):(f[fn>>2]=d,p|0)}return{___divdi3:Xo,___muldi3:vr,___remdi3:oh,___uremdi3:lc,_areNeighborCells:Ax,_bitshift64Ashr:D1,_bitshift64Lshr:Ut,_bitshift64Shl:zt,_calloc:sa,_cellAreaKm2:gp,_cellAreaM2:Id,_cellAreaRads2:Wl,_cellToBoundary:Hl,_cellToCenterChild:Ud,_cellToChildPos:Ap,_cellToChildren:y1,_cellToChildrenSize:hf,_cellToLatLng:jl,_cellToLocalIj:C1,_cellToParent:Wu,_cellToVertex:ra,_cellToVertexes:rc,_cellsToDirectedEdge:p1,_cellsToLinkedMultiPolygon:fi,_childPosToCell:T1,_compactCells:cp,_constructCell:Sx,_destroyLinkedMultiPolygon:ec,_directedEdgeToBoundary:Dd,_directedEdgeToCells:gx,_edgeLengthKm:vp,_edgeLengthM:Ju,_edgeLengthRads:Fd,_emscripten_replace_memory:Vn,_free:wn,_getBaseCellNumber:v1,_getDirectedEdgeDestination:mx,_getDirectedEdgeOrigin:px,_getHexagonAreaAvgKm2:pp,_getHexagonAreaAvgM2:M1,_getHexagonEdgeLengthAvgKm:mp,_getHexagonEdgeLengthAvgM:mo,_getIcosahedronFaces:Yu,_getIndexDigit:bx,_getNumCells:Zu,_getPentagons:Qu,_getRes0Cells:fl,_getResolution:nh,_greatCircleDistanceKm:rh,_greatCircleDistanceM:Mx,_greatCircleDistanceRads:w1,_gridDisk:qr,_gridDiskDistances:Er,_gridDistance:tc,_gridPathCells:N1,_gridPathCellsSize:_p,_gridRing:pr,_gridRingUnsafe:Vr,_i64Add:rn,_i64Subtract:Hr,_isPentagon:Ri,_isResClassIII:S1,_isValidCell:Ld,_isValidDirectedEdge:m1,_isValidIndex:_1,_isValidVertex:_l,_latLngToCell:Bd,_llvm_ctlz_i64:pf,_llvm_maxnum_f64:mf,_llvm_minnum_f64:gf,_llvm_round_f64:xl,_localIjToCell:zd,_malloc:$o,_maxFaceCount:wx,_maxGridDiskSize:Gr,_maxPolygonToCellsSize:Md,_maxPolygonToCellsSizeExperimental:df,_memcpy:Yl,_memset:vo,_originToDirectedEdges:vx,_pentagonCount:dp,_polygonToCells:Rt,_polygonToCellsExperimental:qd,_readInt64AsDoubleFromPointer:xp,_res0CellCount:Go,_round:vf,_sbrk:bl,_sizeOfCellBoundary:xs,_sizeOfCoordIJ:Fa,_sizeOfGeoLoop:ur,_sizeOfGeoPolygon:xi,_sizeOfH3Index:yp,_sizeOfLatLng:R1,_sizeOfLinkedGeoPolygon:$l,_uncompactCells:x1,_uncompactCellsSize:b1,_vertexToLatLng:vl,establishStackSpace:Ds,stackAlloc:bn,stackRestore:pi,stackSave:Mr}})(nt,At,Y);e.___divdi3=ce.___divdi3,e.___muldi3=ce.___muldi3,e.___remdi3=ce.___remdi3,e.___uremdi3=ce.___uremdi3,e._areNeighborCells=ce._areNeighborCells,e._bitshift64Ashr=ce._bitshift64Ashr,e._bitshift64Lshr=ce._bitshift64Lshr,e._bitshift64Shl=ce._bitshift64Shl,e._calloc=ce._calloc,e._cellAreaKm2=ce._cellAreaKm2,e._cellAreaM2=ce._cellAreaM2,e._cellAreaRads2=ce._cellAreaRads2,e._cellToBoundary=ce._cellToBoundary,e._cellToCenterChild=ce._cellToCenterChild,e._cellToChildPos=ce._cellToChildPos,e._cellToChildren=ce._cellToChildren,e._cellToChildrenSize=ce._cellToChildrenSize,e._cellToLatLng=ce._cellToLatLng,e._cellToLocalIj=ce._cellToLocalIj,e._cellToParent=ce._cellToParent,e._cellToVertex=ce._cellToVertex,e._cellToVertexes=ce._cellToVertexes,e._cellsToDirectedEdge=ce._cellsToDirectedEdge,e._cellsToLinkedMultiPolygon=ce._cellsToLinkedMultiPolygon,e._childPosToCell=ce._childPosToCell,e._compactCells=ce._compactCells,e._constructCell=ce._constructCell,e._destroyLinkedMultiPolygon=ce._destroyLinkedMultiPolygon,e._directedEdgeToBoundary=ce._directedEdgeToBoundary,e._directedEdgeToCells=ce._directedEdgeToCells,e._edgeLengthKm=ce._edgeLengthKm,e._edgeLengthM=ce._edgeLengthM,e._edgeLengthRads=ce._edgeLengthRads;var xt=e._emscripten_replace_memory=ce._emscripten_replace_memory;e._free=ce._free,e._getBaseCellNumber=ce._getBaseCellNumber,e._getDirectedEdgeDestination=ce._getDirectedEdgeDestination,e._getDirectedEdgeOrigin=ce._getDirectedEdgeOrigin,e._getHexagonAreaAvgKm2=ce._getHexagonAreaAvgKm2,e._getHexagonAreaAvgM2=ce._getHexagonAreaAvgM2,e._getHexagonEdgeLengthAvgKm=ce._getHexagonEdgeLengthAvgKm,e._getHexagonEdgeLengthAvgM=ce._getHexagonEdgeLengthAvgM,e._getIcosahedronFaces=ce._getIcosahedronFaces,e._getIndexDigit=ce._getIndexDigit,e._getNumCells=ce._getNumCells,e._getPentagons=ce._getPentagons,e._getRes0Cells=ce._getRes0Cells,e._getResolution=ce._getResolution,e._greatCircleDistanceKm=ce._greatCircleDistanceKm,e._greatCircleDistanceM=ce._greatCircleDistanceM,e._greatCircleDistanceRads=ce._greatCircleDistanceRads,e._gridDisk=ce._gridDisk,e._gridDiskDistances=ce._gridDiskDistances,e._gridDistance=ce._gridDistance,e._gridPathCells=ce._gridPathCells,e._gridPathCellsSize=ce._gridPathCellsSize,e._gridRing=ce._gridRing,e._gridRingUnsafe=ce._gridRingUnsafe,e._i64Add=ce._i64Add,e._i64Subtract=ce._i64Subtract,e._isPentagon=ce._isPentagon,e._isResClassIII=ce._isResClassIII,e._isValidCell=ce._isValidCell,e._isValidDirectedEdge=ce._isValidDirectedEdge,e._isValidIndex=ce._isValidIndex,e._isValidVertex=ce._isValidVertex,e._latLngToCell=ce._latLngToCell,e._llvm_ctlz_i64=ce._llvm_ctlz_i64,e._llvm_maxnum_f64=ce._llvm_maxnum_f64,e._llvm_minnum_f64=ce._llvm_minnum_f64,e._llvm_round_f64=ce._llvm_round_f64,e._localIjToCell=ce._localIjToCell,e._malloc=ce._malloc,e._maxFaceCount=ce._maxFaceCount,e._maxGridDiskSize=ce._maxGridDiskSize,e._maxPolygonToCellsSize=ce._maxPolygonToCellsSize,e._maxPolygonToCellsSizeExperimental=ce._maxPolygonToCellsSizeExperimental,e._memcpy=ce._memcpy,e._memset=ce._memset,e._originToDirectedEdges=ce._originToDirectedEdges,e._pentagonCount=ce._pentagonCount,e._polygonToCells=ce._polygonToCells,e._polygonToCellsExperimental=ce._polygonToCellsExperimental,e._readInt64AsDoubleFromPointer=ce._readInt64AsDoubleFromPointer,e._res0CellCount=ce._res0CellCount,e._round=ce._round,e._sbrk=ce._sbrk,e._sizeOfCellBoundary=ce._sizeOfCellBoundary,e._sizeOfCoordIJ=ce._sizeOfCoordIJ,e._sizeOfGeoLoop=ce._sizeOfGeoLoop,e._sizeOfGeoPolygon=ce._sizeOfGeoPolygon,e._sizeOfH3Index=ce._sizeOfH3Index,e._sizeOfLatLng=ce._sizeOfLatLng,e._sizeOfLinkedGeoPolygon=ce._sizeOfLinkedGeoPolygon,e._uncompactCells=ce._uncompactCells,e._uncompactCellsSize=ce._uncompactCellsSize,e._vertexToLatLng=ce._vertexToLatLng,e.establishStackSpace=ce.establishStackSpace;var Ze=e.stackAlloc=ce.stackAlloc,lt=e.stackRestore=ce.stackRestore,bt=e.stackSave=ce.stackSave;if(e.asm=ce,e.cwrap=U,e.setValue=S,e.getValue=w,fe){_e(fe)||(fe=s(fe));{hn();var Kt=function(Pe){Pe.byteLength&&(Pe=new Uint8Array(Pe)),ne.set(Pe,x),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,ut()},un=function(){a(fe,Kt,function(){throw"could not load memory initializer "+fe})},Ye=Te(fe);if(Ye)Kt(Ye.buffer);else if(e.memoryInitializerRequest){var St=function(){var Pe=e.memoryInitializerRequest,at=Pe.response;if(Pe.status!==200&&Pe.status!==0){var ht=Te(e.memoryInitializerRequestURL);if(ht)at=ht.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+Pe.status+", retrying "+fe),un();return}}Kt(at)};e.memoryInitializerRequest.response?setTimeout(St,0):e.memoryInitializerRequest.addEventListener("load",St)}else un()}}var ye;Lt=function Pe(){ye||pt(),ye||(Lt=Pe)};function pt(Pe){if(qt>0||(et(),qt>0))return;function at(){ye||(ye=!0,!N&&(Pt(),Nt(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Gt()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),at()},1)):at()}e.run=pt;function Zt(Pe){throw e.onAbort&&e.onAbort(Pe),Pe+="",l(Pe),u(Pe),N=!0,"abort("+Pe+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=Zt,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return pt(),i})(typeof Mi=="object"?Mi:{}),kn="number",On=kn,NA=kn,Hn=kn,Wn=kn,Is=kn,dn=kn,iZ=[["sizeOfH3Index",kn],["sizeOfLatLng",kn],["sizeOfCellBoundary",kn],["sizeOfGeoLoop",kn],["sizeOfGeoPolygon",kn],["sizeOfLinkedGeoPolygon",kn],["sizeOfCoordIJ",kn],["readInt64AsDoubleFromPointer",kn],["isValidCell",NA,[Hn,Wn]],["isValidIndex",NA,[Hn,Wn]],["latLngToCell",On,[kn,kn,Is,dn]],["cellToLatLng",On,[Hn,Wn,dn]],["cellToBoundary",On,[Hn,Wn,dn]],["maxGridDiskSize",On,[kn,dn]],["gridDisk",On,[Hn,Wn,kn,dn]],["gridDiskDistances",On,[Hn,Wn,kn,dn,dn]],["gridRing",On,[Hn,Wn,kn,dn]],["gridRingUnsafe",On,[Hn,Wn,kn,dn]],["maxPolygonToCellsSize",On,[dn,Is,kn,dn]],["polygonToCells",On,[dn,Is,kn,dn]],["maxPolygonToCellsSizeExperimental",On,[dn,Is,kn,dn]],["polygonToCellsExperimental",On,[dn,Is,kn,kn,kn,dn]],["cellsToLinkedMultiPolygon",On,[dn,kn,dn]],["destroyLinkedMultiPolygon",null,[dn]],["compactCells",On,[dn,dn,kn,kn]],["uncompactCells",On,[dn,kn,kn,dn,kn,Is]],["uncompactCellsSize",On,[dn,kn,kn,Is,dn]],["isPentagon",NA,[Hn,Wn]],["isResClassIII",NA,[Hn,Wn]],["getBaseCellNumber",kn,[Hn,Wn]],["getResolution",kn,[Hn,Wn]],["getIndexDigit",kn,[Hn,Wn,kn]],["constructCell",On,[kn,kn,dn,dn]],["maxFaceCount",On,[Hn,Wn,dn]],["getIcosahedronFaces",On,[Hn,Wn,dn]],["cellToParent",On,[Hn,Wn,Is,dn]],["cellToChildren",On,[Hn,Wn,Is,dn]],["cellToCenterChild",On,[Hn,Wn,Is,dn]],["cellToChildrenSize",On,[Hn,Wn,Is,dn]],["cellToChildPos",On,[Hn,Wn,Is,dn]],["childPosToCell",On,[kn,kn,Hn,Wn,Is,dn]],["areNeighborCells",On,[Hn,Wn,Hn,Wn,dn]],["cellsToDirectedEdge",On,[Hn,Wn,Hn,Wn,dn]],["getDirectedEdgeOrigin",On,[Hn,Wn,dn]],["getDirectedEdgeDestination",On,[Hn,Wn,dn]],["isValidDirectedEdge",NA,[Hn,Wn]],["directedEdgeToCells",On,[Hn,Wn,dn]],["originToDirectedEdges",On,[Hn,Wn,dn]],["directedEdgeToBoundary",On,[Hn,Wn,dn]],["gridDistance",On,[Hn,Wn,Hn,Wn,dn]],["gridPathCells",On,[Hn,Wn,Hn,Wn,dn]],["gridPathCellsSize",On,[Hn,Wn,Hn,Wn,dn]],["cellToLocalIj",On,[Hn,Wn,Hn,Wn,kn,dn]],["localIjToCell",On,[Hn,Wn,dn,kn,dn]],["getHexagonAreaAvgM2",On,[Is,dn]],["getHexagonAreaAvgKm2",On,[Is,dn]],["getHexagonEdgeLengthAvgM",On,[Is,dn]],["getHexagonEdgeLengthAvgKm",On,[Is,dn]],["greatCircleDistanceM",kn,[dn,dn]],["greatCircleDistanceKm",kn,[dn,dn]],["greatCircleDistanceRads",kn,[dn,dn]],["cellAreaM2",On,[Hn,Wn,dn]],["cellAreaKm2",On,[Hn,Wn,dn]],["cellAreaRads2",On,[Hn,Wn,dn]],["edgeLengthM",On,[Hn,Wn,dn]],["edgeLengthKm",On,[Hn,Wn,dn]],["edgeLengthRads",On,[Hn,Wn,dn]],["getNumCells",On,[Is,dn]],["getRes0Cells",On,[dn]],["res0CellCount",kn],["getPentagons",On,[kn,dn]],["pentagonCount",kn],["cellToVertex",On,[Hn,Wn,kn,dn]],["cellToVertexes",On,[Hn,Wn,dn]],["vertexToLatLng",On,[Hn,Wn,dn]],["isValidVertex",NA,[Hn,Wn]]],rZ=0,sZ=1,aZ=2,oZ=3,TP=4,lZ=5,uZ=6,cZ=7,hZ=8,fZ=9,dZ=10,AZ=11,pZ=12,mZ=13,gZ=14,vZ=15,_Z=16,yZ=17,xZ=18,bZ=19,us={};us[rZ]="Success";us[sZ]="The operation failed but a more specific error is not available";us[aZ]="Argument was outside of acceptable range";us[oZ]="Latitude or longitude arguments were outside of acceptable range";us[TP]="Resolution argument was outside of acceptable range";us[lZ]="Cell argument was not valid";us[uZ]="Directed edge argument was not valid";us[cZ]="Undirected edge argument was not valid";us[hZ]="Vertex argument was not valid";us[fZ]="Pentagon distortion was encountered";us[dZ]="Duplicate input";us[AZ]="Cell arguments were not neighbors";us[pZ]="Cell arguments had incompatible resolutions";us[mZ]="Memory allocation failed";us[gZ]="Bounds of provided memory were insufficient";us[vZ]="Mode or flags argument was not valid";us[_Z]="Index argument was not valid";us[yZ]="Base cell number was outside of acceptable range";us[xZ]="Child indexing digits invalid";us[bZ]="Child indexing digits refer to a deleted subsequence";var SZ=1e3,wP=1001,MP=1002,Ny={};Ny[SZ]="Unknown unit";Ny[wP]="Array length out of bounds";Ny[MP]="Got unexpected null value for H3 index";var TZ="Unknown error";function EP(i,e,t){var n=t&&"value"in t,r=new Error((i[e]||TZ)+" (code: "+e+(n?", value: "+t.value:"")+")");return r.code=e,r}function CP(i,e){var t=arguments.length===2?{value:e}:{};return EP(us,i,t)}function NP(i,e){var t=arguments.length===2?{value:e}:{};return EP(Ny,i,t)}function yg(i){if(i!==0)throw CP(i)}var ao={};iZ.forEach(function(e){ao[e[0]]=Mi.cwrap.apply(Mi,e)});var KA=16,xg=4,I0=8,wZ=8,H_=ao.sizeOfH3Index(),CM=ao.sizeOfLatLng(),MZ=ao.sizeOfCellBoundary(),EZ=ao.sizeOfGeoPolygon(),Bm=ao.sizeOfGeoLoop();ao.sizeOfLinkedGeoPolygon();ao.sizeOfCoordIJ();function CZ(i){if(typeof i!="number"||i<0||i>15||Math.floor(i)!==i)throw CP(TP,i);return i}function NZ(i){if(!i)throw NP(MP);return i}var RZ=Math.pow(2,32)-1;function DZ(i){if(i>RZ)throw NP(wP,i);return i}var PZ=/[^0-9a-fA-F]/;function RP(i){if(Array.isArray(i)&&i.length===2&&Number.isInteger(i[0])&&Number.isInteger(i[1]))return i;if(typeof i!="string"||PZ.test(i))return[0,0];var e=parseInt(i.substring(0,i.length-8),KA),t=parseInt(i.substring(i.length-8),KA);return[t,e]}function NR(i){if(i>=0)return i.toString(KA);i=i&2147483647;var e=DP(8,i.toString(KA)),t=(parseInt(e[0],KA)+8).toString(KA);return e=t+e.substring(1),e}function LZ(i,e){return NR(e)+DP(8,NR(i))}function DP(i,e){for(var t=i-e.length,n="",r=0;r0){l=Mi._calloc(t,Bm);for(var u=0;u0){for(var a=Mi.getValue(i+n,"i32"),l=0;l0){const{width:a,height:l}=e.context;t.bufferWidth=a,t.bufferHeight=l}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){const{object:t,material:n,geometry:r}=e,s=this.getRenderObjectData(e);if(s.worldMatrix.equals(t.matrixWorld)!==!0)return s.worldMatrix.copy(t.matrixWorld),!1;const a=s.material;for(const N in a){const C=a[N],E=n[N];if(C.equals!==void 0){if(C.equals(E)===!1)return C.copy(E),!1}else if(E.isTexture===!0){if(C.id!==E.id||C.version!==E.version)return C.id=E.id,C.version=E.version,!1}else if(C!==E)return a[N]=E,!1}if(a.transmission>0){const{width:N,height:C}=e.context;if(s.bufferWidth!==N||s.bufferHeight!==C)return s.bufferWidth=N,s.bufferHeight=C,!1}const l=s.geometry,u=r.attributes,h=l.attributes,m=Object.keys(h),v=Object.keys(u);if(m.length!==v.length)return s.geometry.attributes=this.getAttributesData(u),!1;for(const N of m){const C=h[N],E=u[N];if(E===void 0)return delete h[N],!1;if(C.version!==E.version)return C.version=E.version,!1}const x=r.index,S=l.indexVersion,w=x?x.version:null;if(S!==w)return l.indexVersion=w,!1;if(l.drawRange.start!==r.drawRange.start||l.drawRange.count!==r.drawRange.count)return l.drawRange.start=r.drawRange.start,l.drawRange.count=r.drawRange.count,!1;if(s.morphTargetInfluences){let N=!1;for(let C=0;C>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const OP=i=>bg(i),Ry=i=>bg(i),NM=(...i)=>bg(i);function IP(i,e=!1){const t=[];i.isNode===!0&&(t.push(i.id),i=i.getSelf());for(const{property:n,childNode:r}of $_(i))t.push(t,bg(n.slice(0,-4)),r.getCacheKey(e));return bg(t)}function*$_(i,e=!1){for(const t in i){if(t.startsWith("_")===!0)continue;const n=i[t];if(Array.isArray(n)===!0)for(let r=0;re.charCodeAt(0)).buffer}const kT={VERTEX:"vertex",FRAGMENT:"fragment"},Zn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},$Z={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},da={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},HP=["fragment","vertex"],zT=["setup","analyze","generate"],GT=[...HP,"compute"],yd=["x","y","z","w"];let XZ=0;class Un extends Xc{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Zn.NONE,this.updateBeforeType=Zn.NONE,this.updateAfterType=Zn.NONE,this.uuid=N0.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:XZ++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Zn.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Zn.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Zn.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of $_(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=NM(IP(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e){if(e.increaseUsage(this)===1){const n=e.getNodeProperties(this);for(const r of Object.values(n))r&&r.isNode===!0&&r.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){a.initialized=!0;const l=this.setup(e),u=l&&l.isNode===!0;for(const h of Object.values(a))h&&h.isNode===!0&&h.build(e);u&&l.build(e),a.outputNode=l}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const l=this.getNodeType(e),u=e.getDataFromNode(this);r=u.snippet,r===void 0?(r=this.generate(e)||"",u.snippet=r):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,l,t)}else r=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return $_(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(s)?[]:{}),n[r][s]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const s of e.inputNodes[n])r.push(t[s]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const s in e.inputNodes[n]){const a=e.inputNodes[n][s];r[s]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}if(r){const l=a(e.textures),u=a(e.images),h=a(e.nodes);l.length>0&&(s.textures=l),u.length>0&&(s.images=u),h.length>0&&(s.nodes=h)}return s}}class xd extends Un{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),n=this.indexNode.build(e,"uint");return`${t}[ ${n} ]`}}class WP extends Un{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),s=n.build(e,r);return e.format(s,r,t)}}class cs extends Un{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),l=e.getVarFromNode(this,null,r),u=e.getPropertyName(l);return e.addLineFlowCode(`${u} = ${a}`,this),s.snippet=a,s.propertyName=u,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class YZ extends cs{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=this.nodes,s=e.getComponentType(n),a=[];for(const u of r){let h=u.build(e);const m=e.getComponentType(u.getNodeType(e));m!==s&&(h=e.format(h,m,s)),a.push(h)}const l=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(l,n,t)}}const QZ=yd.join("");class qT extends Un{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(yd.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===QZ.slice(0,this.components.length)?s=e.format(u,a,t):s=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class KZ extends cs{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,s=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),l=e.getTypeFromLength(n.length,a),u=r.build(e,l),h=t.build(e,s),m=e.getTypeLength(s),v=[];for(let x=0;xi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),LR=i=>$P(i).split("").sort().join(""),XP={setup(i,e){const t=e.shift();return i(Hg(t),...e)},get(i,e,t){if(typeof e=="string"&&i[e]===void 0){if(i.isStackNode!==!0&&e==="assign")return(...n)=>(F0.assign(t,...n),t);if(ZA.has(e)){const n=ZA.get(e);return i.isStackNode?(...r)=>t.add(n(...r)):(...r)=>n(t,...r)}else{if(e==="self")return i;if(e.endsWith("Assign")&&ZA.has(e.slice(0,e.length-6))){const n=ZA.get(e.slice(0,e.length-6));return i.isStackNode?(...r)=>t.assign(r[0],n(...r)):(...r)=>t.assign(n(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=$P(e),Ct(new qT(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=LR(e.slice(3).toLowerCase()),n=>Ct(new KZ(i,e,n));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=LR(e.slice(4).toLowerCase()),()=>Ct(new ZZ(Ct(i),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),Ct(new qT(i,e));if(/^\d+$/.test(e)===!0)return Ct(new xd(t,new Vl(Number(e),"uint")))}}}return Reflect.get(i,e,t)},set(i,e,t,n){return typeof e=="string"&&i[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(i,e,t,n)}},W3=new WeakMap,UR=new WeakMap,JZ=function(i,e=null){const t=zh(i);if(t==="node"){let n=W3.get(i);return n===void 0&&(n=new Proxy(i,XP),W3.set(i,n),W3.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return Ct(VT(i,e));if(t==="shader")return Xe(i)}return i},eJ=function(i,e=null){for(const t in i)i[t]=Ct(i[t],e);return i},tJ=function(i,e=null){const t=i.length;for(let n=0;nCt(n!==null?Object.assign(s,n):s);return e===null?(...s)=>r(new i(...rd(s))):t!==null?(t=Ct(t),(...s)=>r(new i(e,...rd(s),t))):(...s)=>r(new i(e,...rd(s)))},iJ=function(i,...e){return Ct(new i(...rd(e)))};class rJ extends Un{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=UR.get(e.constructor);a===void 0&&(a=new WeakMap,UR.set(e.constructor,a));let l=a.get(t);l===void 0&&(l=Ct(e.buildFunctionNode(t)),a.set(t,l)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(l),s=Ct(l.call(n))}else{const a=t.jsFunc,l=n!==null?a(n,e):a(e);s=Ct(l)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class sJ extends Un{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Hg(e),Ct(new rJ(this,e))}setup(){return this.call()}}const aJ=[!1,!0],oJ=[0,1,2,3],lJ=[-1,-2],YP=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],DM=new Map;for(const i of aJ)DM.set(i,new Vl(i));const PM=new Map;for(const i of oJ)PM.set(i,new Vl(i,"uint"));const LM=new Map([...PM].map(i=>new Vl(i.value,"int")));for(const i of lJ)LM.set(i,new Vl(i,"int"));const Dy=new Map([...LM].map(i=>new Vl(i.value)));for(const i of YP)Dy.set(i,new Vl(i));for(const i of YP)Dy.set(-i,new Vl(-i));const Py={bool:DM,uint:PM,ints:LM,float:Dy},BR=new Map([...DM,...Dy]),VT=(i,e)=>BR.has(i)?BR.get(i):i.isNode===!0?i:new Vl(i,e),uJ=i=>{try{return i.getNodeType()}catch{return}},_s=function(i,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>typeof r!="object"))&&(t=[GP(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return Ct(e.get(t[0]));if(t.length===1){const r=VT(t[0],i);return uJ(r)===i?Ct(r):Ct(new WP(r,i))}const n=t.map(r=>VT(r));return Ct(new YZ(n,i))}},Sg=i=>typeof i=="object"&&i!==null?i.value:i,QP=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Om(i,e){return new Proxy(new sJ(i,e),XP)}const Ct=(i,e=null)=>JZ(i,e),Hg=(i,e=null)=>new eJ(i,e),rd=(i,e=null)=>new tJ(i,e),vt=(...i)=>new nJ(...i),Jt=(...i)=>new iJ(...i),Xe=(i,e)=>{const t=new Om(i,e),n=(...r)=>{let s;return Hg(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return n.shaderNode=t,n.setLayout=r=>(t.setLayout(r),n),n.once=()=>(t.once=!0,n),n},cJ=(...i)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),Xe(...i));gt("toGlobal",i=>(i.global=!0,i));const Tg=i=>{F0=i},UM=()=>F0,si=(...i)=>F0.If(...i);function KP(i){return F0&&F0.add(i),i}gt("append",KP);const ZP=new _s("color"),ve=new _s("float",Py.float),we=new _s("int",Py.ints),an=new _s("uint",Py.uint),Hc=new _s("bool",Py.bool),Ft=new _s("vec2"),ws=new _s("ivec2"),JP=new _s("uvec2"),eL=new _s("bvec2"),Le=new _s("vec3"),tL=new _s("ivec3"),Z0=new _s("uvec3"),BM=new _s("bvec3"),Mn=new _s("vec4"),nL=new _s("ivec4"),iL=new _s("uvec4"),rL=new _s("bvec4"),Ly=new _s("mat2"),_a=new _s("mat3"),sd=new _s("mat4"),hJ=(i="")=>Ct(new Vl(i,"string")),fJ=i=>Ct(new Vl(i,"ArrayBuffer"));gt("toColor",ZP);gt("toFloat",ve);gt("toInt",we);gt("toUint",an);gt("toBool",Hc);gt("toVec2",Ft);gt("toIVec2",ws);gt("toUVec2",JP);gt("toBVec2",eL);gt("toVec3",Le);gt("toIVec3",tL);gt("toUVec3",Z0);gt("toBVec3",BM);gt("toVec4",Mn);gt("toIVec4",nL);gt("toUVec4",iL);gt("toBVec4",rL);gt("toMat2",Ly);gt("toMat3",_a);gt("toMat4",sd);const sL=vt(xd),aL=(i,e)=>Ct(new WP(Ct(i),e)),dJ=(i,e)=>Ct(new qT(Ct(i),e));gt("element",sL);gt("convert",aL);class oL extends Un{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const lL=i=>new oL(i),OM=(i,e=0)=>new oL(i,!0,e),uL=OM("frame"),In=OM("render"),IM=lL("object");class Wg extends RM{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=IM}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(r=>{const s=e(r,n);s!==void 0&&(this.value=s)},t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),l=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(l);return e.context.label!==void 0&&delete e.context.label,e.format(u,n,t)}}const En=(i,e)=>{const t=QP(e||i),n=i&&i.isNode===!0?i.node&&i.node.value||i.value:i;return Ct(new Wg(n,t))};class Vi extends Un{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const cL=(i,e)=>Ct(new Vi(i,e)),wg=(i,e)=>Ct(new Vi(i,e,!0)),Oi=Jt(Vi,"vec4","DiffuseColor"),jT=Jt(Vi,"vec3","EmissiveColor"),au=Jt(Vi,"float","Roughness"),Mg=Jt(Vi,"float","Metalness"),X_=Jt(Vi,"float","Clearcoat"),Eg=Jt(Vi,"float","ClearcoatRoughness"),Kf=Jt(Vi,"vec3","Sheen"),Uy=Jt(Vi,"float","SheenRoughness"),By=Jt(Vi,"float","Iridescence"),FM=Jt(Vi,"float","IridescenceIOR"),kM=Jt(Vi,"float","IridescenceThickness"),Y_=Jt(Vi,"float","AlphaT"),Bh=Jt(Vi,"float","Anisotropy"),Im=Jt(Vi,"vec3","AnisotropyT"),ad=Jt(Vi,"vec3","AnisotropyB"),Ha=Jt(Vi,"color","SpecularColor"),Cg=Jt(Vi,"float","SpecularF90"),Q_=Jt(Vi,"float","Shininess"),Ng=Jt(Vi,"vec4","Output"),Qv=Jt(Vi,"float","dashSize"),HT=Jt(Vi,"float","gapSize"),AJ=Jt(Vi,"float","pointWidth"),Fm=Jt(Vi,"float","IOR"),K_=Jt(Vi,"float","Transmission"),zM=Jt(Vi,"float","Thickness"),GM=Jt(Vi,"float","AttenuationDistance"),qM=Jt(Vi,"color","AttenuationColor"),VM=Jt(Vi,"float","Dispersion");class pJ extends cs{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return yd.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:r}=this,s=this.needsSplitAssign(e),a=n.getNodeType(e),l=n.context({assign:!0}).build(e),u=r.build(e,a),h=r.getNodeType(e),m=e.getDataFromNode(this);let v;if(m.initialized===!0)t!=="void"&&(v=l);else if(s){const x=e.getVarFromNode(this,null,a),S=e.getPropertyName(x);e.addLineFlowCode(`${S} = ${u}`,this);const w=n.node.context({assign:!0}).build(e);for(let N=0;N{const m=h.type,v=m==="pointer";let x;return v?x="&"+u.build(e):x=u.build(e,m),x};if(Array.isArray(s))for(let u=0;u(e=e.length>1||e[0]&&e[0].isNode===!0?rd(e):Hg(e[0]),Ct(new mJ(Ct(i),e)));gt("call",fL);class Ur extends cs{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let s=new Ur(e,t,n);for(let a=0;a>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="=="||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="<"||n===">"||n==="<="||n===">="){const u=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(l));return u>1?`bvec${u}`:"bool"}else return a==="float"&&e.isMatrix(l)?l:e.isMatrix(a)&&e.isVector(l)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(l)?e.getVectorFromMatrix(l):e.getTypeLength(l)>e.getTypeLength(a)?l:a}generate(e,t){const n=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let l=null,u=null;a!=="void"?(l=r.getNodeType(e),u=typeof s<"u"?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="?e.isVector(l)?u=l:l!==u&&(l=u="float"):n===">>"||n==="<<"?(l=a,u=e.changeComponentType(u,"uint")):e.isMatrix(l)&&e.isVector(u)?u=e.getVectorFromMatrix(l):e.isVector(l)&&e.isMatrix(u)?l=e.getVectorFromMatrix(u):l=u=a):l=u=a;const h=r.build(e,l),m=typeof s<"u"?s.build(e,u):null,v=e.getTypeLength(t),x=e.getFunctionOperator(n);if(t!=="void")return n==="<"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} < ${m} )`,a,t):n==="<="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} <= ${m} )`,a,t):n===">"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} > ${m} )`,a,t):n===">="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} >= ${m} )`,a,t):n==="!"||n==="~"?e.format(`(${n}${h})`,l,t):x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`( ${h} ${n} ${m} )`,a,t);if(l!=="void")return x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`${h} ${n} ${m}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const ls=vt(Ur,"+"),Ei=vt(Ur,"-"),Jn=vt(Ur,"*"),Gl=vt(Ur,"/"),jM=vt(Ur,"%"),dL=vt(Ur,"=="),AL=vt(Ur,"!="),pL=vt(Ur,"<"),HM=vt(Ur,">"),mL=vt(Ur,"<="),gL=vt(Ur,">="),vL=vt(Ur,"&&"),_L=vt(Ur,"||"),yL=vt(Ur,"!"),xL=vt(Ur,"^^"),bL=vt(Ur,"&"),SL=vt(Ur,"~"),TL=vt(Ur,"|"),wL=vt(Ur,"^"),ML=vt(Ur,"<<"),EL=vt(Ur,">>");gt("add",ls);gt("sub",Ei);gt("mul",Jn);gt("div",Gl);gt("modInt",jM);gt("equal",dL);gt("notEqual",AL);gt("lessThan",pL);gt("greaterThan",HM);gt("lessThanEqual",mL);gt("greaterThanEqual",gL);gt("and",vL);gt("or",_L);gt("not",yL);gt("xor",xL);gt("bitAnd",bL);gt("bitNot",SL);gt("bitOr",TL);gt("bitXor",wL);gt("shiftLeft",ML);gt("shiftRight",EL);const CL=(...i)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),jM(...i));gt("remainder",CL);class $e extends cs{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),l=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>l?t:a>l?n:l>s?r:t}getNodeType(e){const t=this.method;return t===$e.LENGTH||t===$e.DISTANCE||t===$e.DOT?"float":t===$e.CROSS?"vec3":t===$e.ALL?"bool":t===$e.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===$e.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){let n=this.method;const r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,l=this.bNode,u=this.cNode,h=e.renderer.coordinateSystem;if(n===$e.TRANSFORM_DIRECTION){let m=a,v=l;e.isMatrix(m.getNodeType(e))?v=Mn(Le(v),0):m=Mn(Le(m),0);const x=Jn(m,v).xyz;return Wc(x).build(e,t)}else{if(n===$e.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(n===$e.ONE_MINUS)return Ei(1,a).build(e,t);if(n===$e.RECIPROCAL)return Gl(1,a).build(e,t);if(n===$e.DIFFERENCE)return dr(Ei(a,l)).build(e,t);{const m=[];return n===$e.CROSS||n===$e.MOD?m.push(a.build(e,r),l.build(e,r)):h===Qa&&n===$e.STEP?m.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),l.build(e,s)):h===Qa&&(n===$e.MIN||n===$e.MAX)||n===$e.MOD?m.push(a.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):n===$e.REFRACT?m.push(a.build(e,s),l.build(e,s),u.build(e,"float")):n===$e.MIX?m.push(a.build(e,s),l.build(e,s),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":s)):(h===Su&&n===$e.ATAN&&l!==null&&(n="atan2"),m.push(a.build(e,s)),l!==null&&m.push(l.build(e,s)),u!==null&&m.push(u.build(e,s))),e.format(`${e.getMethod(n,r)}( ${m.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}$e.ALL="all";$e.ANY="any";$e.RADIANS="radians";$e.DEGREES="degrees";$e.EXP="exp";$e.EXP2="exp2";$e.LOG="log";$e.LOG2="log2";$e.SQRT="sqrt";$e.INVERSE_SQRT="inversesqrt";$e.FLOOR="floor";$e.CEIL="ceil";$e.NORMALIZE="normalize";$e.FRACT="fract";$e.SIN="sin";$e.COS="cos";$e.TAN="tan";$e.ASIN="asin";$e.ACOS="acos";$e.ATAN="atan";$e.ABS="abs";$e.SIGN="sign";$e.LENGTH="length";$e.NEGATE="negate";$e.ONE_MINUS="oneMinus";$e.DFDX="dFdx";$e.DFDY="dFdy";$e.ROUND="round";$e.RECIPROCAL="reciprocal";$e.TRUNC="trunc";$e.FWIDTH="fwidth";$e.TRANSPOSE="transpose";$e.BITCAST="bitcast";$e.EQUALS="equals";$e.MIN="min";$e.MAX="max";$e.MOD="mod";$e.STEP="step";$e.REFLECT="reflect";$e.DISTANCE="distance";$e.DIFFERENCE="difference";$e.DOT="dot";$e.CROSS="cross";$e.POW="pow";$e.TRANSFORM_DIRECTION="transformDirection";$e.MIX="mix";$e.CLAMP="clamp";$e.REFRACT="refract";$e.SMOOTHSTEP="smoothstep";$e.FACEFORWARD="faceforward";const NL=ve(1e-6),gJ=ve(1e6),Z_=ve(Math.PI),vJ=ve(Math.PI*2),WM=vt($e,$e.ALL),RL=vt($e,$e.ANY),DL=vt($e,$e.RADIANS),PL=vt($e,$e.DEGREES),$M=vt($e,$e.EXP),k0=vt($e,$e.EXP2),Oy=vt($e,$e.LOG),vu=vt($e,$e.LOG2),Ou=vt($e,$e.SQRT),XM=vt($e,$e.INVERSE_SQRT),_u=vt($e,$e.FLOOR),Iy=vt($e,$e.CEIL),Wc=vt($e,$e.NORMALIZE),Zc=vt($e,$e.FRACT),Uo=vt($e,$e.SIN),Cc=vt($e,$e.COS),LL=vt($e,$e.TAN),UL=vt($e,$e.ASIN),BL=vt($e,$e.ACOS),YM=vt($e,$e.ATAN),dr=vt($e,$e.ABS),Rg=vt($e,$e.SIGN),Ic=vt($e,$e.LENGTH),OL=vt($e,$e.NEGATE),IL=vt($e,$e.ONE_MINUS),QM=vt($e,$e.DFDX),KM=vt($e,$e.DFDY),FL=vt($e,$e.ROUND),kL=vt($e,$e.RECIPROCAL),ZM=vt($e,$e.TRUNC),zL=vt($e,$e.FWIDTH),GL=vt($e,$e.TRANSPOSE),_J=vt($e,$e.BITCAST),qL=vt($e,$e.EQUALS),oo=vt($e,$e.MIN),Jr=vt($e,$e.MAX),JM=vt($e,$e.MOD),Fy=vt($e,$e.STEP),VL=vt($e,$e.REFLECT),jL=vt($e,$e.DISTANCE),HL=vt($e,$e.DIFFERENCE),ef=vt($e,$e.DOT),ky=vt($e,$e.CROSS),Fl=vt($e,$e.POW),eE=vt($e,$e.POW,2),WL=vt($e,$e.POW,3),$L=vt($e,$e.POW,4),XL=vt($e,$e.TRANSFORM_DIRECTION),YL=i=>Jn(Rg(i),Fl(dr(i),1/3)),QL=i=>ef(i,i),zi=vt($e,$e.MIX),Mu=(i,e=0,t=1)=>Ct(new $e($e.CLAMP,Ct(i),Ct(e),Ct(t))),KL=i=>Mu(i),tE=vt($e,$e.REFRACT),$c=vt($e,$e.SMOOTHSTEP),nE=vt($e,$e.FACEFORWARD),ZL=Xe(([i])=>{const n=43758.5453,r=ef(i.xy,Ft(12.9898,78.233)),s=JM(r,Z_);return Zc(Uo(s).mul(n))}),JL=(i,e,t)=>zi(e,t,i),e9=(i,e,t)=>$c(e,t,i),t9=(i,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),YM(i,e)),yJ=nE,xJ=XM;gt("all",WM);gt("any",RL);gt("equals",qL);gt("radians",DL);gt("degrees",PL);gt("exp",$M);gt("exp2",k0);gt("log",Oy);gt("log2",vu);gt("sqrt",Ou);gt("inverseSqrt",XM);gt("floor",_u);gt("ceil",Iy);gt("normalize",Wc);gt("fract",Zc);gt("sin",Uo);gt("cos",Cc);gt("tan",LL);gt("asin",UL);gt("acos",BL);gt("atan",YM);gt("abs",dr);gt("sign",Rg);gt("length",Ic);gt("lengthSq",QL);gt("negate",OL);gt("oneMinus",IL);gt("dFdx",QM);gt("dFdy",KM);gt("round",FL);gt("reciprocal",kL);gt("trunc",ZM);gt("fwidth",zL);gt("atan2",t9);gt("min",oo);gt("max",Jr);gt("mod",JM);gt("step",Fy);gt("reflect",VL);gt("distance",jL);gt("dot",ef);gt("cross",ky);gt("pow",Fl);gt("pow2",eE);gt("pow3",WL);gt("pow4",$L);gt("transformDirection",XL);gt("mix",JL);gt("clamp",Mu);gt("refract",tE);gt("smoothstep",e9);gt("faceForward",nE);gt("difference",HL);gt("saturate",KL);gt("cbrt",YL);gt("transpose",GL);gt("rand",ZL);class bJ extends Un{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:l}=e.getNodeProperties(this),u=t!=="void",h=u?cL(n).build(e):"";r.nodeProperty=h;const m=s.build(e,"bool");e.addFlowCode(` +${e.tab}if ( ${m} ) { + +`).addFlowTab();let v=a.build(e,n);if(v&&(u?v=h+" = "+v+";":v="return "+v+";"),e.removeFlowTab().addFlowCode(e.tab+" "+v+` + +`+e.tab+"}"),l!==null){e.addFlowCode(` else { + +`).addFlowTab();let x=l.build(e,n);x&&(u?x=h+" = "+x+";":x="return "+x+";"),e.removeFlowTab().addFlowCode(e.tab+" "+x+` + +`+e.tab+`} + +`)}else e.addFlowCode(` + +`);return e.format(h,n,t)}}const Ys=vt(bJ);gt("select",Ys);const n9=(...i)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ys(...i));gt("cond",n9);class i9 extends Un{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(n),r}}const zy=vt(i9),r9=(i,e)=>zy(i,{label:e});gt("context",zy);gt("label",r9);class Kv extends Un{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const s9=vt(Kv);gt("toVar",(...i)=>s9(...i).append());const a9=i=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),s9(i));gt("temp",a9);class SJ extends Un{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,s),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e),r=e.shaderStage==="fragment"&&t.reassignPosition===!0&&e.context.needsPositionReassign;if(t.propertyName===void 0||r){const s=this.getNodeType(e),a=e.getPropertyName(n,kT.VERTEX);e.flowNodeFromShaderStage(kT.VERTEX,this.node,s,a),t.propertyName=a,r?t.reassignPosition=!1:t.reassignPosition===void 0&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(n)}}const co=vt(SJ),o9=i=>co(i);gt("varying",co);gt("vertexStage",o9);const l9=Xe(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return zi(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),u9=Xe(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return zi(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),$g="WorkingColorSpace",iE="OutputColorSpace";class Xg extends cs{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===$g?hi.workingColorSpace:t===iE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return hi.enabled===!1||n===r||!n||!r||(hi.getTransfer(n)===Hi&&(s=Mn(l9(s.rgb),s.a)),hi.getPrimaries(n)!==hi.getPrimaries(r)&&(s=Mn(_a(hi._getMatrix(new Qn,n,r)).mul(s.rgb),s.a)),hi.getTransfer(r)===Hi&&(s=Mn(u9(s.rgb),s.a))),s}}const c9=i=>Ct(new Xg(Ct(i),$g,iE)),h9=i=>Ct(new Xg(Ct(i),iE,$g)),f9=(i,e)=>Ct(new Xg(Ct(i),$g,e)),rE=(i,e)=>Ct(new Xg(Ct(i),e,$g)),TJ=(i,e,t)=>Ct(new Xg(Ct(i),e,t));gt("toOutputColorSpace",c9);gt("toWorkingColorSpace",h9);gt("workingToColorSpace",f9);gt("colorSpaceToWorking",rE);let wJ=class extends xd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class d9 extends Un{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=Zn.OBJECT}setGroup(e){return this.group=e,this}element(e){return Ct(new wJ(this,Ct(e)))}setNodeType(e){const t=En(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rCt(new d9(i,e,t));class EJ extends d9{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(In)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const A9=(i,e,t=null)=>Ct(new EJ(i,e,t));class CJ extends cs{static get type(){return"ToneMappingNode"}constructor(e,t=m9,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return NM(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===ro)return t;let r=null;const s=e.renderer.library.getToneMappingFunction(n);return s!==null?r=Mn(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const p9=(i,e,t)=>Ct(new CJ(i,Ct(e),Ct(t))),m9=A9("toneMappingExposure","float");gt("toneMapping",(i,e,t)=>p9(e,t,i));class NJ extends RM{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=o_,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,l=n.isInterleavedBuffer===!0?n:new Zw(n,s),u=new cu(l,r,a);l.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=co(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Yg=(i,e=null,t=0,n=0)=>Ct(new NJ(i,e,t,n)),g9=(i,e=null,t=0,n=0)=>Yg(i,e,t,n).setUsage(HA),J_=(i,e=null,t=0,n=0)=>Yg(i,e,t,n).setInstanced(!0),WT=(i,e=null,t=0,n=0)=>g9(i,e,t,n).setInstanced(!0);gt("toAttribute",i=>Yg(i.value));class RJ extends Un{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Zn.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let r=1;rCt(new RJ(Ct(i),e,t));gt("compute",v9);class DJ extends Un{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(n),s}}const km=(i,e)=>Ct(new DJ(Ct(i),e));gt("cache",km);class PJ extends Un{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const _9=vt(PJ);gt("bypass",_9);class y9 extends Un{static get type(){return"RemapNode"}constructor(e,t,n,r=ve(0),s=ve(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:s,doClamp:a}=this;let l=e.sub(t).div(n.sub(t));return a===!0&&(l=l.clamp()),l.mul(s.sub(r)).add(r)}}const x9=vt(y9,null,null,{doClamp:!1}),b9=vt(y9);gt("remap",x9);gt("remapClamp",b9);class Zv extends Un{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,n,t)}}const Qh=vt(Zv),S9=i=>(i?Ys(i,Qh("discard")):Qh("discard")).append(),LJ=()=>Qh("return").append();gt("discard",S9);class UJ extends cs{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||ro,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Oo;return n!==ro&&(t=t.toneMapping(n)),r!==Oo&&r!==hi.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const T9=(i,e=null,t=null)=>Ct(new UJ(Ct(i),e,t));gt("renderOutput",T9);function BJ(i){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class w9 extends Un{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(s),l=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(l.name,a,n):co(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Eu=(i,e)=>Ct(new w9(i,e)),Br=(i=0)=>Eu("uv"+(i>0?i:""),"vec2");class OJ extends Un{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const jh=vt(OJ);class IJ extends Wg{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Zn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:s}=n;this.value=Math.log2(Math.max(r,s))}}}const M9=vt(IJ);class Cu extends Wg{static get type(){return"TextureNode"}constructor(e,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Zn.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Ir?"uvec4":this.value.type===ks?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Br(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=En(this.value.matrix)),this._matrixUniform.mul(Le(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Zn.RENDER:Zn.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(we(jh(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this)),r||(r=this.getDefaultUV()),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,n,r,s,a,l,u){const h=this.value;let m;return r?m=e.generateTextureLevel(h,t,n,r,a):s?m=e.generateTextureBias(h,t,n,s,a):u?m=e.generateTextureGrad(h,t,n,u,a):l?m=e.generateTextureCompare(h,t,n,l,a):this.sampler===!1?m=e.generateTextureLoad(h,t,n,a):m=e.generateTexture(h,t,n,a),m}generate(e,t){const n=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let l=a.propertyName;if(l===void 0){const{uvNode:m,levelNode:v,biasNode:x,compareNode:S,depthNode:w,gradNode:N}=r,C=this.generateUV(e,m),E=v?v.build(e,"float"):null,O=x?x.build(e,"float"):null,U=w?w.build(e,"int"):null,I=S?S.build(e,"float"):null,j=N?[N[0].build(e,"vec2"),N[1].build(e,"vec2")]:null,z=e.getVarFromNode(this);l=e.getPropertyName(z);const G=this.generateSnippet(e,s,C,E,O,U,I,j);e.addLineFlowCode(`${l} = ${G}`,this),a.snippet=G,a.propertyName=l}let u=l;const h=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=rE(Qh(u,h),n.colorSpace).setup(e).build(e,h)),e.format(u,h,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}blur(e){const t=this.clone();return t.biasNode=Ct(e).mul(M9(t)),t.referenceNode=this.getSelf(),Ct(t)}level(e){const t=this.clone();return t.levelNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}size(e){return jh(this,e)}bias(e){const t=this.clone();return t.biasNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}compare(e){const t=this.clone();return t.compareNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}grad(e,t){const n=this.clone();return n.gradNode=[Ct(e),Ct(t)],n.referenceNode=this.getSelf(),Ct(n)}depth(e){const t=this.clone();return t.depthNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const gi=vt(Cu),Yr=(...i)=>gi(...i).setSampler(!1),FJ=i=>(i.isNode===!0?i:gi(i)).convert("sampler"),Ih=En("float").label("cameraNear").setGroup(In).onRenderUpdate(({camera:i})=>i.near),Fh=En("float").label("cameraFar").setGroup(In).onRenderUpdate(({camera:i})=>i.far),bd=En("mat4").label("cameraProjectionMatrix").setGroup(In).onRenderUpdate(({camera:i})=>i.projectionMatrix),kJ=En("mat4").label("cameraProjectionMatrixInverse").setGroup(In).onRenderUpdate(({camera:i})=>i.projectionMatrixInverse),ho=En("mat4").label("cameraViewMatrix").setGroup(In).onRenderUpdate(({camera:i})=>i.matrixWorldInverse),zJ=En("mat4").label("cameraWorldMatrix").setGroup(In).onRenderUpdate(({camera:i})=>i.matrixWorld),GJ=En("mat3").label("cameraNormalMatrix").setGroup(In).onRenderUpdate(({camera:i})=>i.normalMatrix),E9=En(new de).label("cameraPosition").setGroup(In).onRenderUpdate(({camera:i},e)=>e.value.setFromMatrixPosition(i.matrixWorld));class Bi extends Un{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Zn.OBJECT,this._uniformNode=new Wg(null)}getNodeType(){const e=this.scope;if(e===Bi.WORLD_MATRIX)return"mat4";if(e===Bi.POSITION||e===Bi.VIEW_POSITION||e===Bi.DIRECTION||e===Bi.SCALE)return"vec3"}update(e){const t=this.object3d,n=this._uniformNode,r=this.scope;if(r===Bi.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===Bi.POSITION)n.value=n.value||new de,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===Bi.SCALE)n.value=n.value||new de,n.value.setFromMatrixScale(t.matrixWorld);else if(r===Bi.DIRECTION)n.value=n.value||new de,t.getWorldDirection(n.value);else if(r===Bi.VIEW_POSITION){const s=e.camera;n.value=n.value||new de,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===Bi.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===Bi.POSITION||t===Bi.VIEW_POSITION||t===Bi.DIRECTION||t===Bi.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Bi.WORLD_MATRIX="worldMatrix";Bi.POSITION="position";Bi.SCALE="scale";Bi.VIEW_POSITION="viewPosition";Bi.DIRECTION="direction";const qJ=vt(Bi,Bi.DIRECTION),VJ=vt(Bi,Bi.WORLD_MATRIX),C9=vt(Bi,Bi.POSITION),jJ=vt(Bi,Bi.SCALE),HJ=vt(Bi,Bi.VIEW_POSITION);class Nu extends Bi{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const WJ=Jt(Nu,Nu.DIRECTION),nl=Jt(Nu,Nu.WORLD_MATRIX),$J=Jt(Nu,Nu.POSITION),XJ=Jt(Nu,Nu.SCALE),YJ=Jt(Nu,Nu.VIEW_POSITION),N9=En(new Qn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),QJ=En(new Xn).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),J0=Xe(i=>i.renderer.nodes.modelViewMatrix||R9).once()().toVar("modelViewMatrix"),R9=ho.mul(nl),KJ=Xe(i=>(i.context.isHighPrecisionModelViewMatrix=!0,En("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),ZJ=Xe(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return En("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Gy=Eu("position","vec3"),Zr=Gy.varying("positionLocal"),ey=Gy.varying("positionPrevious"),Fc=nl.mul(Zr).xyz.varying("v_positionWorld").context({needsPositionReassign:!0}),sE=Zr.transformDirection(nl).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection").context({needsPositionReassign:!0}),as=Xe(i=>i.context.setupPositionView(),"vec3").once()().varying("v_positionView").context({needsPositionReassign:!0}),yr=as.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class JJ extends Un{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===Qa&&n.side===gr?"false":e.getFrontFacing()}}const D9=Jt(JJ),Qg=ve(D9).mul(2).sub(1),qy=Eu("normal","vec3"),lo=Xe(i=>i.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),Le(0,1,0)):qy,"vec3").once()().toVar("normalLocal"),P9=as.dFdx().cross(as.dFdy()).normalize().toVar("normalFlat"),ll=Xe(i=>{let e;return i.material.flatShading===!0?e=P9:e=co(aE(lo),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Vy=co(ll.transformDirection(ho),"v_normalWorld").normalize().toVar("normalWorld"),Kr=Xe(i=>i.context.setupNormal(),"vec3").once()().mul(Qg).toVar("transformedNormalView"),jy=Kr.transformDirection(ho).toVar("transformedNormalWorld"),JA=Xe(i=>i.context.setupClearcoatNormal(),"vec3").once()().mul(Qg).toVar("transformedClearcoatNormalView"),L9=Xe(([i,e=nl])=>{const t=_a(e),n=i.div(Le(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),aE=Xe(([i],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const n=N9.mul(i);return ho.transformDirection(n)}),U9=En(0).onReference(({material:i})=>i).onRenderUpdate(({material:i})=>i.refractionRatio),B9=yr.negate().reflect(Kr),O9=yr.negate().refract(Kr,U9),I9=B9.transformDirection(ho).toVar("reflectVector"),F9=O9.transformDirection(ho).toVar("reflectVector");class eee extends Cu{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===sl?I9:e.mapping===al?F9:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Le(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem===Su||!n.isRenderTargetTexture?Le(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const z0=vt(eee);class oE extends Wg{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const Kg=(i,e,t)=>Ct(new oE(i,e,t));class tee extends xd{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class k9 extends oE{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?zh(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Zn.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;rCt(new k9(i,e)),nee=(i,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),Ct(new k9(i,e)));class iee extends xd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class Hy extends Un{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Zn.OBJECT}element(e){return Ct(new iee(this,Ct(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=Kg(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Dc(null,e):e==="texture"?t=gi(null):e==="cubeTexture"?t=z0(null):t=En(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rCt(new Hy(i,e,t)),$T=(i,e,t,n)=>Ct(new Hy(i,e,n,t));class ree extends Hy{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const Pc=(i,e,t=null)=>Ct(new ree(i,e,t)),Wy=Xe(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),Eu("tangent","vec4")))(),Zg=Wy.xyz.toVar("tangentLocal"),Jg=J0.mul(Mn(Zg,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),z9=Jg.transformDirection(ho).varying("v_tangentWorld").normalize().toVar("tangentWorld"),lE=Jg.toVar("transformedTangentView"),see=lE.transformDirection(ho).normalize().toVar("transformedTangentWorld"),e1=i=>i.mul(Wy.w).xyz,aee=co(e1(qy.cross(Wy)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),oee=co(e1(lo.cross(Zg)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),G9=co(e1(ll.cross(Jg)),"v_bitangentView").normalize().toVar("bitangentView"),lee=co(e1(Vy.cross(z9)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),q9=e1(Kr.cross(lE)).normalize().toVar("transformedBitangentView"),uee=q9.transformDirection(ho).normalize().toVar("transformedBitangentWorld"),Zf=_a(Jg,G9,ll),V9=yr.mul(Zf),cee=(i,e)=>i.sub(V9.mul(e)),j9=(()=>{let i=ad.cross(yr);return i=i.cross(ad).normalize(),i=zi(i,Kr,Bh.mul(au.oneMinus()).oneMinus().pow2().pow2()).normalize(),i})(),hee=Xe(i=>{const{eye_pos:e,surf_norm:t,mapN:n,uv:r}=i,s=e.dFdx(),a=e.dFdy(),l=r.dFdx(),u=r.dFdy(),h=t,m=a.cross(h),v=h.cross(s),x=m.mul(l.x).add(v.mul(u.x)),S=m.mul(l.y).add(v.mul(u.y)),w=x.dot(x).max(S.dot(S)),N=Qg.mul(w.inverseSqrt());return ls(x.mul(n.x,N),S.mul(n.y,N),h.mul(n.z)).normalize()});class fee extends cs{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=kc}setup(e){const{normalMapType:t,scaleNode:n}=this;let r=this.node.mul(2).sub(1);n!==null&&(r=Le(r.xy.mul(n),r.z));let s=null;return t===z7?s=aE(r):t===kc&&(e.hasGeometryAttribute("tangent")===!0?s=Zf.mul(r).normalize():s=hee({eye_pos:as,surf_norm:ll,mapN:r,uv:Br()})),s}}const XT=vt(fee),dee=Xe(({textureNode:i,bumpScale:e})=>{const t=r=>i.cache().context({getUV:s=>r(s.uvNode||Br()),forceUVContext:!0}),n=ve(t(r=>r));return Ft(ve(t(r=>r.add(r.dFdx()))).sub(n),ve(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),Aee=Xe(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,l=s.cross(a),u=a.cross(r),h=r.dot(l).mul(Qg),m=h.sign().mul(n.x.mul(l).add(n.y.mul(u)));return h.abs().mul(t).sub(m).normalize()});class pee extends cs{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=dee({textureNode:this.textureNode,bumpScale:e});return Aee({surf_pos:as,surf_norm:ll,dHdxy:t})}}const H9=vt(pee),OR=new Map;class ft extends Un{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=OR.get(e);return n===void 0&&(n=Pc(e,t),OR.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let r=null;if(n===ft.COLOR){const s=t.color!==void 0?this.getColor(n):Le();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(n===ft.OPACITY){const s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(n===ft.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=ve(1);else if(n===ft.SPECULAR_INTENSITY){const s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s}else if(n===ft.SPECULAR_COLOR){const s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(n).rgb):r=s}else if(n===ft.ROUGHNESS){const s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).g):r=s}else if(n===ft.METALNESS){const s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(n).b):r=s}else if(n===ft.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(n)):r=a}else if(n===ft.NORMAL)t.normalMap?(r=XT(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=H9(this.getTexture("bump").r,this.getFloat("bumpScale")):r=ll;else if(n===ft.CLEARCOAT){const s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===ft.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===ft.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=XT(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=ll;else if(n===ft.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(n===ft.SHEEN_ROUGHNESS){const s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s,r=r.clamp(.07,1)}else if(n===ft.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(n);r=Ly(qA.x,qA.y,qA.y.negate(),qA.x).mul(s.rg.mul(2).sub(Ft(1)).normalize().mul(s.b))}else r=qA;else if(n===ft.IRIDESCENCE_THICKNESS){const s=$i("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=$i("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(n).g).add(a)}else r=s}else if(n===ft.TRANSMISSION){const s=this.getFloat(n);t.transmissionMap?r=s.mul(this.getTexture(n).r):r=s}else if(n===ft.THICKNESS){const s=this.getFloat(n);t.thicknessMap?r=s.mul(this.getTexture(n).g):r=s}else if(n===ft.IOR)r=this.getFloat(n);else if(n===ft.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===ft.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(n,s)}return r}}ft.ALPHA_TEST="alphaTest";ft.COLOR="color";ft.OPACITY="opacity";ft.SHININESS="shininess";ft.SPECULAR="specular";ft.SPECULAR_STRENGTH="specularStrength";ft.SPECULAR_INTENSITY="specularIntensity";ft.SPECULAR_COLOR="specularColor";ft.REFLECTIVITY="reflectivity";ft.ROUGHNESS="roughness";ft.METALNESS="metalness";ft.NORMAL="normal";ft.CLEARCOAT="clearcoat";ft.CLEARCOAT_ROUGHNESS="clearcoatRoughness";ft.CLEARCOAT_NORMAL="clearcoatNormal";ft.EMISSIVE="emissive";ft.ROTATION="rotation";ft.SHEEN="sheen";ft.SHEEN_ROUGHNESS="sheenRoughness";ft.ANISOTROPY="anisotropy";ft.IRIDESCENCE="iridescence";ft.IRIDESCENCE_IOR="iridescenceIOR";ft.IRIDESCENCE_THICKNESS="iridescenceThickness";ft.IOR="ior";ft.TRANSMISSION="transmission";ft.THICKNESS="thickness";ft.ATTENUATION_DISTANCE="attenuationDistance";ft.ATTENUATION_COLOR="attenuationColor";ft.LINE_SCALE="scale";ft.LINE_DASH_SIZE="dashSize";ft.LINE_GAP_SIZE="gapSize";ft.LINE_WIDTH="linewidth";ft.LINE_DASH_OFFSET="dashOffset";ft.POINT_WIDTH="pointWidth";ft.DISPERSION="dispersion";ft.LIGHT_MAP="light";ft.AO="ao";const W9=Jt(ft,ft.ALPHA_TEST),$9=Jt(ft,ft.COLOR),X9=Jt(ft,ft.SHININESS),Y9=Jt(ft,ft.EMISSIVE),uE=Jt(ft,ft.OPACITY),Q9=Jt(ft,ft.SPECULAR),YT=Jt(ft,ft.SPECULAR_INTENSITY),K9=Jt(ft,ft.SPECULAR_COLOR),zm=Jt(ft,ft.SPECULAR_STRENGTH),Jv=Jt(ft,ft.REFLECTIVITY),Z9=Jt(ft,ft.ROUGHNESS),J9=Jt(ft,ft.METALNESS),eU=Jt(ft,ft.NORMAL).context({getUV:null}),tU=Jt(ft,ft.CLEARCOAT),nU=Jt(ft,ft.CLEARCOAT_ROUGHNESS),iU=Jt(ft,ft.CLEARCOAT_NORMAL).context({getUV:null}),rU=Jt(ft,ft.ROTATION),sU=Jt(ft,ft.SHEEN),aU=Jt(ft,ft.SHEEN_ROUGHNESS),oU=Jt(ft,ft.ANISOTROPY),lU=Jt(ft,ft.IRIDESCENCE),uU=Jt(ft,ft.IRIDESCENCE_IOR),cU=Jt(ft,ft.IRIDESCENCE_THICKNESS),hU=Jt(ft,ft.TRANSMISSION),fU=Jt(ft,ft.THICKNESS),dU=Jt(ft,ft.IOR),AU=Jt(ft,ft.ATTENUATION_DISTANCE),pU=Jt(ft,ft.ATTENUATION_COLOR),mU=Jt(ft,ft.LINE_SCALE),gU=Jt(ft,ft.LINE_DASH_SIZE),vU=Jt(ft,ft.LINE_GAP_SIZE),mee=Jt(ft,ft.LINE_WIDTH),_U=Jt(ft,ft.LINE_DASH_OFFSET),gee=Jt(ft,ft.POINT_WIDTH),yU=Jt(ft,ft.DISPERSION),cE=Jt(ft,ft.LIGHT_MAP),xU=Jt(ft,ft.AO),qA=En(new Et).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),hE=Xe(i=>i.context.setupModelViewProjection(),"vec4").once()().varying("v_modelViewProjection");class xr extends Un{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===xr.VERTEX)r=e.getVertexIndex();else if(n===xr.INSTANCE)r=e.getInstanceIndex();else if(n===xr.DRAW)r=e.getDrawIndex();else if(n===xr.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===xr.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===xr.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=co(this).build(e,t),s}}xr.VERTEX="vertex";xr.INSTANCE="instance";xr.SUBGROUP="subgroup";xr.INVOCATION_LOCAL="invocationLocal";xr.INVOCATION_SUBGROUP="invocationSubgroup";xr.DRAW="draw";const bU=Jt(xr,xr.VERTEX),t1=Jt(xr,xr.INSTANCE),vee=Jt(xr,xr.SUBGROUP),_ee=Jt(xr,xr.INVOCATION_SUBGROUP),yee=Jt(xr,xr.INVOCATION_LOCAL),SU=Jt(xr,xr.DRAW);class TU extends Un{static get type(){return"InstanceNode"}constructor(e,t,n){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Zn.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:n,instanceColor:r}=this;let{instanceMatrixNode:s,instanceColorNode:a}=this;if(s===null){if(t<=1e3)s=Kg(n.array,"mat4",Math.max(t,1)).element(t1);else{const u=new h_(n.array,16,1);this.buffer=u;const h=n.usage===HA?WT:J_,m=[h(u,"vec4",16,0),h(u,"vec4",16,4),h(u,"vec4",16,8),h(u,"vec4",16,12)];s=sd(...m)}this.instanceMatrixNode=s}if(r&&a===null){const u=new kg(r.array,3),h=r.usage===HA?WT:J_;this.bufferColor=u,a=Le(h(u,"vec3",3,0)),this.instanceColorNode=a}const l=s.mul(Zr).xyz;if(Zr.assign(l),e.hasGeometryAttribute("normal")){const u=L9(lo,s);lo.assign(u)}this.instanceColorNode!==null&&wg("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==HA&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==HA&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const xee=vt(TU);class bee extends TU{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const wU=vt(bee);class See extends Un{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=t1:this.batchingIdNode=SU);const n=Xe(([w])=>{const N=jh(Yr(this.batchMesh._indirectTexture),0),C=we(w).modInt(we(N)),E=we(w).div(we(N));return Yr(this.batchMesh._indirectTexture,ws(C,E)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(we(this.batchingIdNode)),r=this.batchMesh._matricesTexture,s=jh(Yr(r),0),a=ve(n).mul(4).toInt().toVar(),l=a.modInt(s),u=a.div(we(s)),h=sd(Yr(r,ws(l,u)),Yr(r,ws(l.add(1),u)),Yr(r,ws(l.add(2),u)),Yr(r,ws(l.add(3),u))),m=this.batchMesh._colorsTexture;if(m!==null){const N=Xe(([C])=>{const E=jh(Yr(m),0).x,O=C,U=O.modInt(E),I=O.div(E);return Yr(m,ws(U,I)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);wg("vec3","vBatchColor").assign(N)}const v=_a(h);Zr.assign(h.mul(Zr));const x=lo.div(Le(v[0].dot(v[0]),v[1].dot(v[1]),v[2].dot(v[2]))),S=v.mul(x).xyz;lo.assign(S),e.hasGeometryAttribute("tangent")&&Zg.mulAssign(v)}}const MU=vt(See),IR=new WeakMap;class EU extends Un{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=Zn.OBJECT,this.skinIndexNode=Eu("skinIndex","uvec4"),this.skinWeightNode=Eu("skinWeight","vec4");let n,r,s;t?(n=$i("bindMatrix","mat4"),r=$i("bindMatrixInverse","mat4"),s=$T("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=En(e.bindMatrix,"mat4"),r=En(e.bindMatrixInverse,"mat4"),s=Kg(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=Zr){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w),v=s.mul(t),x=ls(l.mul(r.x).mul(v),u.mul(r.y).mul(v),h.mul(r.z).mul(v),m.mul(r.w).mul(v));return a.mul(x).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=lo){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w);let v=ls(r.x.mul(l),r.y.mul(u),r.z.mul(h),r.w.mul(m));return v=a.mul(v).mul(s),v.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=$T("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,ey)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||qP(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&ey.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(Zr.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();lo.assign(n),e.hasGeometryAttribute("tangent")&&Zg.assign(n)}}generate(e,t){if(t!=="void")return Zr.build(e,t)}update(e){const n=(this.useReference?e.object:this.skinnedMesh).skeleton;IR.get(n)!==e.frameId&&(IR.set(n,e.frameId),this.previousBoneMatricesNode!==null&&n.previousBoneMatrices.set(n.boneMatrices),n.update())}}const Tee=i=>Ct(new EU(i)),CU=i=>Ct(new EU(i,!0));class wee extends Un{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let s=0,a=this.params.length-1;sNumber(v)?w=">=":w="<"));const C={start:m,end:v},E=C.start,O=C.end;let U="",I="",j="";N||(S==="int"||S==="uint"?w.includes("<")?N="++":N="--":w.includes("<")?N="+= 1.":N="-= 1."),U+=e.getVar(S,x)+" = "+E,I+=x+" "+w+" "+O,j+=x+" "+N;const z=`for ( ${U}; ${I}; ${j} )`;e.addFlowCode((l===0?` +`:"")+e.tab+z+` { + +`).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(` +`+e.tab+s);for(let l=0,u=this.params.length-1;lCt(new wee(rd(i,"int"))).append(),Mee=()=>Qh("continue").append(),NU=()=>Qh("break").append(),Eee=(...i)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),Gi(...i)),$3=new WeakMap,Mo=new qn,FR=Xe(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const a=we(bU).mul(t).add(s),l=a.div(n),u=a.sub(l.mul(n));return Yr(i,ws(u,l)).depth(r).mul(e)});function Cee(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let a=$3.get(i);if(a===void 0||a.count!==s){let O=function(){C.dispose(),$3.delete(i),i.removeEventListener("dispose",O)};var l=O;a!==void 0&&a.texture.dispose();const u=i.morphAttributes.position||[],h=i.morphAttributes.normal||[],m=i.morphAttributes.color||[];let v=0;e===!0&&(v=1),t===!0&&(v=2),n===!0&&(v=3);let x=i.attributes.position.count*v,S=1;const w=4096;x>w&&(S=Math.ceil(x/w),x=w);const N=new Float32Array(x*S*4*s),C=new $w(N,x,S,s);C.type=ss,C.needsUpdate=!0;const E=v*4;for(let U=0;U{const x=ve(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?x.assign(Yr(this.mesh.morphTexture,ws(we(v).add(1),we(t1))).r):x.assign($i("morphTargetInfluences","float").element(v).toVar()),n===!0&&Zr.addAssign(FR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:we(0)})),r===!0&&lo.addAssign(FR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:we(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const RU=vt(Nee);class ep extends Un{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Ree extends ep{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Dee extends i9{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=Le().toVar("directDiffuse"),r=Le().toVar("directSpecular"),s=Le().toVar("indirectDiffuse"),a=Le().toVar("indirectSpecular"),l={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:Le().toVar("radiance"),irradiance:Le().toVar("irradiance"),iblIrradiance:Le().toVar("iblIrradiance"),ambientOcclusion:ve(1).toVar("ambientOcclusion"),reflectedLight:l,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const DU=vt(Dee);class Pee extends ep{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let om,lm;class ms extends Un{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ms.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Zn.NONE;return(this.scope===ms.SIZE||this.scope===ms.VIEWPORT)&&(e=Zn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ms.VIEWPORT?t!==null?lm.copy(t.viewport):(e.getViewport(lm),lm.multiplyScalar(e.getPixelRatio())):t!==null?(om.width=t.width,om.height=t.height):e.getDrawingBufferSize(om)}setup(){const e=this.scope;let t=null;return e===ms.SIZE?t=En(om||(om=new Et)):e===ms.VIEWPORT?t=En(lm||(lm=new qn)):t=Ft(n1.div(Dg)),t}generate(e){if(this.scope===ms.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(Dg).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}ms.COORDINATE="coordinate";ms.VIEWPORT="viewport";ms.SIZE="size";ms.UV="uv";const Ru=Jt(ms,ms.UV),Dg=Jt(ms,ms.SIZE),n1=Jt(ms,ms.COORDINATE),fE=Jt(ms,ms.VIEWPORT),PU=fE.zw,LU=n1.sub(fE.xy),Lee=LU.div(PU),Uee=Xe(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),Dg),"vec2").once()(),Bee=Xe(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),Ru),"vec2").once()(),Oee=Xe(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),Ru.flipY()),"vec2").once()(),um=new Et;class $y extends Cu{static get type(){return"ViewportTextureNode"}constructor(e=Ru,t=null,n=null){n===null&&(n=new Q7,n.minFilter=Ya),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Zn.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(um);const n=this.value;(n.image.width!==um.width||n.image.height!==um.height)&&(n.image.width=um.width,n.image.height=um.height,n.needsUpdate=!0);const r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Iee=vt($y),dE=vt($y,null,null,{generateMipmaps:!0});let X3=null;class Fee extends $y{static get type(){return"ViewportDepthTextureNode"}constructor(e=Ru,t=null){X3===null&&(X3=new Qc),super(e,t,X3)}}const AE=vt(Fee);class eo extends Un{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===eo.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===eo.DEPTH_BASE)n!==null&&(r=BU().assign(n));else if(t===eo.DEPTH)e.isPerspectiveCamera?r=UU(as.z,Ih,Fh):r=l0(as.z,Ih,Fh);else if(t===eo.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const s=pE(n,Ih,Fh);r=l0(s,Ih,Fh)}else r=n;else r=l0(as.z,Ih,Fh);return r}}eo.DEPTH_BASE="depthBase";eo.DEPTH="depth";eo.LINEAR_DEPTH="linearDepth";const l0=(i,e,t)=>i.add(e).div(e.sub(t)),kee=(i,e,t)=>e.sub(t).mul(i).sub(e),UU=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),pE=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),mE=(i,e,t)=>{e=e.max(1e-6).toVar();const n=vu(i.negate().div(e)),r=vu(t.div(e));return n.div(r)},zee=(i,e,t)=>{const n=i.mul(Oy(t.div(e)));return ve(Math.E).pow(n).mul(e).negate()},BU=vt(eo,eo.DEPTH_BASE),gE=Jt(eo,eo.DEPTH),ty=vt(eo,eo.LINEAR_DEPTH),Gee=ty(AE());gE.assign=i=>BU(i);class qee extends Un{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Vee=vt(qee);class rl extends Un{static get type(){return"ClippingNode"}constructor(e=rl.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===rl.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===rl.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return Xe(()=>{const n=ve().toVar("distanceToPlane"),r=ve().toVar("distanceToGradient"),s=ve(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=Dc(t);Gi(a,({i:h})=>{const m=u.element(h);n.assign(as.dot(m.xyz).negate().add(m.w)),r.assign(n.fwidth().div(2)),s.mulAssign($c(r.negate(),r,n))})}const l=e.length;if(l>0){const u=Dc(e),h=ve(1).toVar("intersectionClipOpacity");Gi(l,({i:m})=>{const v=u.element(m);n.assign(as.dot(v.xyz).negate().add(v.w)),r.assign(n.fwidth().div(2)),h.mulAssign($c(r.negate(),r,n).oneMinus())}),s.mulAssign(h.oneMinus())}Oi.a.mulAssign(s),Oi.a.equal(0).discard()})()}setupDefault(e,t){return Xe(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const s=Dc(t);Gi(n,({i:a})=>{const l=s.element(a);as.dot(l.xyz).greaterThan(l.w).discard()})}const r=e.length;if(r>0){const s=Dc(e),a=Hc(!0).toVar("clipped");Gi(r,({i:l})=>{const u=s.element(l);a.assign(as.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Xe(()=>{const r=Dc(e),s=Vee(t.getClipDistance());Gi(n,({i:a})=>{const l=r.element(a),u=as.dot(l.xyz).sub(l.w).negate();s.element(a).assign(u)})})()}}rl.ALPHA_TO_COVERAGE="alphaToCoverage";rl.DEFAULT="default";rl.HARDWARE="hardware";const jee=()=>Ct(new rl),Hee=()=>Ct(new rl(rl.ALPHA_TO_COVERAGE)),Wee=()=>Ct(new rl(rl.HARDWARE)),$ee=.05,kR=Xe(([i])=>Zc(Jn(1e4,Uo(Jn(17,i.x).add(Jn(.1,i.y)))).mul(ls(.1,dr(Uo(Jn(13,i.y).add(i.x))))))),zR=Xe(([i])=>kR(Ft(kR(i.xy),i.z))),Xee=Xe(([i])=>{const e=Jr(Ic(QM(i.xyz)),Ic(KM(i.xyz))),t=ve(1).div(ve($ee).mul(e)).toVar("pixScale"),n=Ft(k0(_u(vu(t))),k0(Iy(vu(t)))),r=Ft(zR(_u(n.x.mul(i.xyz))),zR(_u(n.y.mul(i.xyz)))),s=Zc(vu(t)),a=ls(Jn(s.oneMinus(),r.x),Jn(s,r.y)),l=oo(s,s.oneMinus()),u=Le(a.mul(a).div(Jn(2,l).mul(Ei(1,l))),a.sub(Jn(.5,l)).div(Ei(1,l)),Ei(1,Ei(1,a).mul(Ei(1,a)).div(Jn(2,l).mul(Ei(1,l))))),h=a.lessThan(l.oneMinus()).select(a.lessThan(l).select(u.x,u.y),u.z);return Mu(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class es extends ga{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+IP(this)}build(e){this.setup(e)}setupObserver(e){return new HZ(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const r=this.vertexNode||this.setupVertex(e);e.stack.outputNode=r,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let s;const a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);a!==null&&e.stack.add(a);const u=Mn(l,Oi.a).max(0);if(s=this.setupOutput(e,u),Ng.assign(s),this.outputNode!==null&&(s=this.outputNode),n!==null){const h=t.getMRT(),m=this.mrtNode;h!==null?(s=h,m!==null&&(s=h.merge(m))):m!==null&&(s=m)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=Mn(l)),s=this.setupOutput(e,l)}e.stack.outputNode=s,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=Hee():e.stack.add(jee())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Wee()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=mE(as.z,Ih,Fh):r=l0(as.z,Ih,Fh))}r!==null&&gE.assign(r).append()}setupPositionView(){return J0.mul(Zr).xyz}setupModelViewProjection(){return bd.mul(as)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),hE}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&RU(t).append(),t.isSkinnedMesh===!0&&CU(t).append(),this.displacementMap){const r=Pc("displacementMap","texture"),s=Pc("displacementScale","float"),a=Pc("displacementBias","float");Zr.addAssign(lo.normalize().mul(r.x.mul(s).add(a)))}return t.isBatchedMesh&&MU(t).append(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&wU(t).append(),this.positionNode!==null&&Zr.assign(this.positionNode.context({isPositionNodeInput:!0})),Zr}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?Mn(this.colorNode):$9;this.vertexColors===!0&&t.hasAttribute("color")&&(n=Mn(n.xyz.mul(Eu("color","vec3")),n.a)),e.instanceColor&&(n=wg("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=wg("vec3","vBatchColor").mul(n)),Oi.assign(n);const r=this.opacityNode?ve(this.opacityNode):uE;if(Oi.a.assign(Oi.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?ve(this.alphaTestNode):W9;Oi.a.lessThanEqual(s).discard()}this.alphaHash===!0&&Oi.a.lessThan(Xee(Zr)).discard(),this.transparent===!1&&this.blending===io&&this.alphaToCoverage===!1&&Oi.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Le(0):Oi.rgb}setupNormal(){return this.normalNode?Le(this.normalNode):eU}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Pc("envMap","cubeTexture"):Pc("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Pee(cE)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:xU;t.push(new Ree(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:s}=this,l=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(l&&l.getScope().hasLights){const h=this.setupLightingModel(e);u=DU(l,h,n,r)}else n!==null&&(u=Le(r!==null?zi(u,n,r):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(jT.assign(Le(s||Y9)),u=u.add(jT)),u}setupOutput(e,t){if(this.fog===!0){const n=e.fogNode;n&&(Ng.assign(t),t=Mn(n))}return t}setDefaultValues(e){for(const n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=ga.prototype.toJSON.call(this,e),r=$_(this);n.inputNodes={};for(const{property:a,childNode:l}of r)n.inputNodes[a]=l.toJSON(e).uuid;function s(a){const l=[];for(const u in a){const h=a[u];delete h.metadata,l.push(h)}return l}if(t){const a=s(e.textures),l=s(e.images),u=s(e.nodes);a.length>0&&(n.textures=a),l.length>0&&(n.images=l),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const Yee=new Q0;class Qee extends es{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Yee),this.setValues(e)}}const Kee=new kz;class Zee extends es{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Kee),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ve(this.offsetNode):_U,t=this.dashScaleNode?ve(this.dashScaleNode):mU,n=this.dashSizeNode?ve(this.dashSizeNode):gU,r=this.gapSizeNode?ve(this.gapSizeNode):vU;Qv.assign(n),HT.assign(r);const s=co(Eu("lineDistance").mul(t));(e?s.add(e):s).mod(Qv.add(HT)).greaterThan(Qv).discard()}}let Y3=null;class Jee extends $y{static get type(){return"ViewportSharedTextureNode"}constructor(e=Ru,t=null){Y3===null&&(Y3=new Q7),super(e,t,Y3)}updateReference(){return this}}const ete=vt(Jee),OU=i=>Ct(i).mul(.5).add(.5),tte=i=>Ct(i).mul(2).sub(1),nte=new Bz;class ite extends es{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(nte),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ve(this.opacityNode):uE;Oi.assign(Mn(OU(Kr),e))}}class rte extends cs{static get type(){return"EquirectUVNode"}constructor(e=sE){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Ft(t,n)}}const vE=vt(rte);class IU extends X7{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new Jh(5,5,5),a=vE(sE),l=new es;l.colorNode=gi(t,a,0),l.side=gr,l.blending=no;const u=new qi(s,l),h=new Kw;h.add(u),t.minFilter===Ya&&(t.minFilter=Ms);const m=new $7(1,10,this),v=e.getMRT();return e.setMRT(null),m.update(e,h),e.setMRT(v),t.minFilter=n,t.currentGenerateMipmaps=r,u.geometry.dispose(),u.material.dispose(),this}}const Gm=new WeakMap;class ste extends cs{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=z0();const t=new yy;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Zn.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:n[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===Wh||a===$h){if(Gm.has(s)){const l=Gm.get(s);GR(l,s.mapping),this._cubeTexture=l}else{const l=s.image;if(ate(l)){const u=new IU(l.height);u.fromEquirectangularTexture(t,s),GR(u.texture,s.mapping),this._cubeTexture=u.texture,Gm.set(s,u.texture),s.addEventListener("dispose",FU)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function ate(i){return i==null?!1:i.height>0}function FU(i){const e=i.target;e.removeEventListener("dispose",FU);const t=Gm.get(e);t!==void 0&&(Gm.delete(e),t.dispose())}function GR(i,e){e===Wh?i.mapping=sl:e===$h&&(i.mapping=al)}const kU=vt(ste);class _E extends ep{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=kU(this.envNode)}}class ote extends ep{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ve(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Xy{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class zU extends Xy{constructor(){super()}indirect(e,t,n){const r=e.ambientOcclusion,s=e.reflectedLight,a=n.context.irradianceLightMap;s.indirectDiffuse.assign(Mn(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(Mn(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Oi.rgb)}finish(e,t,n){const r=n.material,s=e.outgoingLight,a=n.context.environment;if(a)switch(r.combine){case Bg:s.rgb.assign(zi(s.rgb,s.rgb.mul(a.rgb),zm.mul(Jv)));break;case P7:s.rgb.assign(zi(s.rgb,a.rgb,zm.mul(Jv)));break;case L7:s.rgb.addAssign(a.rgb.mul(zm.mul(Jv)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const lte=new vd;class ute extends es{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lte),this.setValues(e)}setupNormal(){return ll}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _E(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ote(cE)),t}setupOutgoingLight(){return Oi.rgb}setupLightingModel(){return new zU}}const G0=Xe(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),md=Xe(i=>i.diffuseColor.mul(1/Math.PI)),cte=()=>ve(.25),hte=Xe(({dotNH:i})=>Q_.mul(ve(.5)).add(1).mul(ve(1/Math.PI)).mul(i.pow(Q_))),fte=Xe(({lightDirection:i})=>{const e=i.add(yr).normalize(),t=Kr.dot(e).clamp(),n=yr.dot(e).clamp(),r=G0({f0:Ha,f90:1,dotVH:n}),s=cte(),a=hte({dotNH:t});return r.mul(s).mul(a)});class GU extends zU{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=Kr.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(md({diffuseColor:Oi.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(fte({lightDirection:e})).mul(zm))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(md({diffuseColor:Oi}))),n.indirectDiffuse.mulAssign(e)}}const dte=new Kc;class Ate extends es{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(dte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _E(t):null}setupLightingModel(){return new GU(!1)}}const pte=new oD;class mte extends es{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(pte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _E(t):null}setupLightingModel(){return new GU}setupVariants(){const e=(this.shininessNode?ve(this.shininessNode):X9).max(1e-4);Q_.assign(e);const t=this.specularNode||Q9;Ha.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const qU=Xe(i=>{if(i.geometry.hasAttribute("normal")===!1)return ve(0);const e=ll.dFdx().abs().max(ll.dFdy().abs());return e.x.max(e.y).max(e.z)}),yE=Xe(i=>{const{roughness:e}=i,t=qU();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),VU=Xe(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Gl(.5,r.add(s).max(NL))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),gte=Xe(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:s,dotNV:a,dotNL:l})=>{const u=l.mul(Le(i.mul(t),e.mul(n),a).length()),h=a.mul(Le(i.mul(r),e.mul(s),l).length());return Gl(.5,u.add(h)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),jU=Xe(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),vte=ve(1/Math.PI),_te=Xe(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const s=i.mul(e),a=Le(e.mul(n),i.mul(r),s.mul(t)),l=a.dot(a),u=s.div(l);return vte.mul(s.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),QT=Xe(i=>{const{lightDirection:e,f0:t,f90:n,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:l}=i,u=i.normalView||Kr,h=r.pow2(),m=e.add(yr).normalize(),v=u.dot(e).clamp(),x=u.dot(yr).clamp(),S=u.dot(m).clamp(),w=yr.dot(m).clamp();let N=G0({f0:t,f90:n,dotVH:w}),C,E;if(Sg(a)&&(N=By.mix(N,s)),Sg(l)){const O=Im.dot(e),U=Im.dot(yr),I=Im.dot(m),j=ad.dot(e),z=ad.dot(yr),G=ad.dot(m);C=gte({alphaT:Y_,alphaB:h,dotTV:U,dotBV:z,dotTL:O,dotBL:j,dotNV:x,dotNL:v}),E=_te({alphaT:Y_,alphaB:h,dotNH:S,dotTH:I,dotBH:G})}else C=VU({alpha:h,dotNL:v,dotNV:x}),E=jU({alpha:h,dotNH:S});return N.mul(C).mul(E)}),xE=Xe(({roughness:i,dotNV:e})=>{const t=Mn(-1,-.0275,-.572,.022),n=Mn(1,.0425,1.04,-.04),r=i.mul(t).add(n),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return Ft(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),HU=Xe(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,s=xE({dotNV:e,roughness:r});return t.mul(s.x).add(n.mul(s.y))}),WU=Xe(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),s=n.mul(r,r).clamp(0,.9999);return i.sub(Le(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),yte=Xe(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=ve(1).div(t),s=e.pow2().oneMinus().max(.0078125);return ve(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),xte=Xe(({dotNV:i,dotNL:e})=>ve(1).div(ve(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),bte=Xe(({lightDirection:i})=>{const e=i.add(yr).normalize(),t=Kr.dot(i).clamp(),n=Kr.dot(yr).clamp(),r=Kr.dot(e).clamp(),s=yte({roughness:Uy,dotNH:r}),a=xte({dotNV:n,dotNL:t});return Kf.mul(s).mul(a)}),Ste=Xe(({N:i,V:e,roughness:t})=>{const s=.0078125,a=i.dot(e).saturate(),l=Ft(t,a.oneMinus().sqrt());return l.assign(l.mul(.984375).add(s)),l}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),Tte=Xe(({f:i})=>{const e=i.length();return Jr(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),uv=Xe(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=r.div(s),l=t.greaterThan(0).select(a,Jr(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return i.cross(e).mul(l)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),qR=Xe(({N:i,V:e,P:t,mInv:n,p0:r,p1:s,p2:a,p3:l})=>{const u=s.sub(r).toVar(),h=l.sub(r).toVar(),m=u.cross(h),v=Le().toVar();return si(m.dot(t.sub(r)).greaterThanEqual(0),()=>{const x=e.sub(i.mul(e.dot(i))).normalize(),S=i.cross(x).negate(),w=n.mul(_a(x,S,i).transpose()).toVar(),N=w.mul(r.sub(t)).normalize().toVar(),C=w.mul(s.sub(t)).normalize().toVar(),E=w.mul(a.sub(t)).normalize().toVar(),O=w.mul(l.sub(t)).normalize().toVar(),U=Le(0).toVar();U.addAssign(uv({v1:N,v2:C})),U.addAssign(uv({v1:C,v2:E})),U.addAssign(uv({v1:E,v2:O})),U.addAssign(uv({v1:O,v2:N})),v.assign(Le(Tte({f:U})))}),v}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Yy=1/6,$U=i=>Jn(Yy,Jn(i,Jn(i,i.negate().add(3)).sub(3)).add(1)),KT=i=>Jn(Yy,Jn(i,Jn(i,Jn(3,i).sub(6))).add(4)),XU=i=>Jn(Yy,Jn(i,Jn(i,Jn(-3,i).add(3)).add(3)).add(1)),ZT=i=>Jn(Yy,Fl(i,3)),VR=i=>$U(i).add(KT(i)),jR=i=>XU(i).add(ZT(i)),HR=i=>ls(-1,KT(i).div($U(i).add(KT(i)))),WR=i=>ls(1,ZT(i).div(XU(i).add(ZT(i)))),$R=(i,e,t)=>{const n=i.uvNode,r=Jn(n,e.zw).add(.5),s=_u(r),a=Zc(r),l=VR(a.x),u=jR(a.x),h=HR(a.x),m=WR(a.x),v=HR(a.y),x=WR(a.y),S=Ft(s.x.add(h),s.y.add(v)).sub(.5).mul(e.xy),w=Ft(s.x.add(m),s.y.add(v)).sub(.5).mul(e.xy),N=Ft(s.x.add(h),s.y.add(x)).sub(.5).mul(e.xy),C=Ft(s.x.add(m),s.y.add(x)).sub(.5).mul(e.xy),E=VR(a.y).mul(ls(l.mul(i.sample(S).level(t)),u.mul(i.sample(w).level(t)))),O=jR(a.y).mul(ls(l.mul(i.sample(N).level(t)),u.mul(i.sample(C).level(t))));return E.add(O)},YU=Xe(([i,e=ve(3)])=>{const t=Ft(i.size(we(e))),n=Ft(i.size(we(e.add(1)))),r=Gl(1,t),s=Gl(1,n),a=$R(i,Mn(r,t),_u(e)),l=$R(i,Mn(s,n),Iy(e));return Zc(e).mix(a,l)}),XR=Xe(([i,e,t,n,r])=>{const s=Le(tE(e.negate(),Wc(i),Gl(1,n))),a=Le(Ic(r[0].xyz),Ic(r[1].xyz),Ic(r[2].xyz));return Wc(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),wte=Xe(([i,e])=>i.mul(Mu(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Mte=dE(),Ete=dE(),YR=Xe(([i,e,t],{material:n})=>{const s=(n.side===gr?Mte:Ete).sample(i),a=vu(Dg.x).mul(wte(e,t));return YU(s,a)}),QR=Xe(([i,e,t])=>(si(t.notEqual(0),()=>{const n=Oy(e).negate().div(t);return $M(n.negate().mul(i))}),Le(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Cte=Xe(([i,e,t,n,r,s,a,l,u,h,m,v,x,S,w])=>{let N,C;if(w){N=Mn().toVar(),C=Le().toVar();const j=m.sub(1).mul(w.mul(.025)),z=Le(m.sub(j),m,m.add(j));Gi({start:0,end:3},({i:G})=>{const W=z.element(G),q=XR(i,e,v,W,l),V=a.add(q),Y=h.mul(u.mul(Mn(V,1))),te=Ft(Y.xy.div(Y.w)).toVar();te.addAssign(1),te.divAssign(2),te.assign(Ft(te.x,te.y.oneMinus()));const ne=YR(te,t,W);N.element(G).assign(ne.element(G)),N.a.addAssign(ne.a),C.element(G).assign(n.element(G).mul(QR(Ic(q),x,S).element(G)))}),N.a.divAssign(3)}else{const j=XR(i,e,v,m,l),z=a.add(j),G=h.mul(u.mul(Mn(z,1))),W=Ft(G.xy.div(G.w)).toVar();W.addAssign(1),W.divAssign(2),W.assign(Ft(W.x,W.y.oneMinus())),N=YR(W,t,m),C=n.mul(QR(Ic(j),x,S))}const E=C.rgb.mul(N.rgb),O=i.dot(e).clamp(),U=Le(HU({dotNV:O,specularColor:r,specularF90:s,roughness:t})),I=C.r.add(C.g,C.b).div(3);return Mn(U.oneMinus().mul(E),N.a.oneMinus().mul(I).oneMinus())}),Nte=_a(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Rte=i=>{const e=i.sqrt();return Le(1).add(e).div(Le(1).sub(e))},KR=(i,e)=>i.sub(e).div(i.add(e)).pow2(),Dte=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=Le(54856e-17,44201e-17,52481e-17),r=Le(1681e3,1795300,2208400),s=Le(43278e5,93046e5,66121e5),a=ve(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let l=n.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return l=Le(l.x.add(a),l.y,l.z).div(10685e-11),Nte.mul(l)},Pte=Xe(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const s=zi(i,e,$c(0,.03,n)),l=i.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();si(l.lessThan(0),()=>Le(1));const u=l.sqrt(),h=KR(s,i),m=G0({f0:h,f90:1,dotVH:t}),v=m.oneMinus(),x=s.lessThan(i).select(Math.PI,0),S=ve(Math.PI).sub(x),w=Rte(r.clamp(0,.9999)),N=KR(w,s.toVec3()),C=G0({f0:N,f90:1,dotVH:u}),E=Le(w.x.lessThan(s).select(Math.PI,0),w.y.lessThan(s).select(Math.PI,0),w.z.lessThan(s).select(Math.PI,0)),O=s.mul(n,u,2),U=Le(S).add(E),I=m.mul(C).clamp(1e-5,.9999),j=I.sqrt(),z=v.pow2().mul(C).div(Le(1).sub(I)),W=m.add(z).toVar(),q=z.sub(v).toVar();return Gi({start:1,end:2,condition:"<=",name:"m"},({m:V})=>{q.mulAssign(j);const Y=Dte(ve(V).mul(O),ve(V).mul(U)).mul(2);W.addAssign(q.mul(Y))}),W.max(Le(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Lte=Xe(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.pow2(),s=Ys(t.lessThan(.25),ve(-339.2).mul(r).add(ve(161.4).mul(t)).sub(25.9),ve(-8.48).mul(r).add(ve(14.3).mul(t)).sub(9.95)),a=Ys(t.lessThan(.25),ve(44).mul(r).sub(ve(23.7).mul(t)).add(3.26),ve(1.97).mul(r).sub(ve(3.27).mul(t)).add(.72));return Ys(t.lessThan(.25),0,ve(.1).mul(t).sub(.025)).add(s.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),Q3=Le(.04),K3=ve(1);class QU extends Xy{constructor(e=!1,t=!1,n=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Le().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Le().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Le().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=Le().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Le().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Kr.dot(yr).clamp();this.iridescenceFresnel=Pte({outsideIOR:ve(1),eta2:FM,cosTheta1:t,thinFilmThickness:kM,baseF0:Ha}),this.iridescenceF0=WU({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Fc,n=E9.sub(Fc).normalize(),r=jy;e.backdrop=Cte(r,n,au,Oi,Ha,Cg,t,nl,ho,bd,Fm,zM,qM,GM,this.dispersion?VM:null),e.backdropAlpha=K_,Oi.a.mulAssign(zi(1,e.backdrop.a,K_))}}computeMultiscattering(e,t,n){const r=Kr.dot(yr).clamp(),s=xE({roughness:au,dotNV:r}),l=(this.iridescenceF0?By.mix(Ha,this.iridescenceF0):Ha).mul(s.x).add(n.mul(s.y)),h=s.x.add(s.y).oneMinus(),m=Ha.add(Ha.oneMinus().mul(.047619)),v=l.mul(m).div(h.mul(m).oneMinus());e.addAssign(l),t.addAssign(v.mul(h))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=Kr.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(s.mul(bte({lightDirection:e}))),this.clearcoat===!0){const l=JA.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(l.mul(QT({lightDirection:e,f0:Q3,f90:K3,roughness:Eg,normalView:JA})))}n.directDiffuse.addAssign(s.mul(md({diffuseColor:Oi.rgb}))),n.directSpecular.addAssign(s.mul(QT({lightDirection:e,f0:Ha,f90:1,roughness:au,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:l}){const u=t.add(n).sub(r),h=t.sub(n).sub(r),m=t.sub(n).add(r),v=t.add(n).add(r),x=Kr,S=yr,w=as.toVar(),N=Ste({N:x,V:S,roughness:au}),C=a.sample(N).toVar(),E=l.sample(N).toVar(),O=_a(Le(C.x,0,C.y),Le(0,1,0),Le(C.z,0,C.w)).toVar(),U=Ha.mul(E.x).add(Ha.oneMinus().mul(E.y)).toVar();s.directSpecular.addAssign(e.mul(U).mul(qR({N:x,V:S,P:w,mInv:O,p0:u,p1:h,p2:m,p3:v}))),s.directDiffuse.addAssign(e.mul(Oi).mul(qR({N:x,V:S,P:w,mInv:_a(1,0,0,0,1,0,0,0,1),p0:u,p1:h,p2:m,p3:v})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(md({diffuseColor:Oi})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Kf,Lte({normal:Kr,viewDir:yr,roughness:Uy}))),this.clearcoat===!0){const h=JA.dot(yr).clamp(),m=HU({dotNV:h,specularColor:Q3,specularF90:K3,roughness:Eg});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const r=Le().toVar("singleScattering"),s=Le().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,Cg);const l=r.add(s),u=Oi.mul(l.r.max(l.g).max(l.b).oneMinus());n.indirectSpecular.addAssign(e.mul(r)),n.indirectSpecular.addAssign(s.mul(a)),n.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const r=Kr.dot(yr).clamp().add(e),s=au.mul(-16).oneMinus().negate().exp2(),a=e.sub(r.pow(s).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(a)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=JA.dot(yr).clamp(),r=G0({dotVH:n,f0:Q3,f90:K3}),s=t.mul(X_.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(X_));t.assign(s)}if(this.sheen===!0){const n=Kf.r.max(Kf.g).max(Kf.b).mul(.157).oneMinus(),r=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const ZR=ve(1),JT=ve(-2),cv=ve(.8),Z3=ve(-1),hv=ve(.4),J3=ve(2),fv=ve(.305),eS=ve(3),JR=ve(.21),Ute=ve(4),e6=ve(4),Bte=ve(16),Ote=Xe(([i])=>{const e=Le(dr(i)).toVar(),t=ve(-1).toVar();return si(e.x.greaterThan(e.z),()=>{si(e.x.greaterThan(e.y),()=>{t.assign(Ys(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ys(i.y.greaterThan(0),1,4))})}).Else(()=>{si(e.z.greaterThan(e.y),()=>{t.assign(Ys(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ys(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Ite=Xe(([i,e])=>{const t=Ft().toVar();return si(e.equal(0),()=>{t.assign(Ft(i.z,i.y).div(dr(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Ft(i.x.negate(),i.z.negate()).div(dr(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Ft(i.x.negate(),i.y).div(dr(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Ft(i.z.negate(),i.y).div(dr(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Ft(i.x.negate(),i.z).div(dr(i.y)))}).Else(()=>{t.assign(Ft(i.x,i.y).div(dr(i.z)))}),Jn(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Fte=Xe(([i])=>{const e=ve(0).toVar();return si(i.greaterThanEqual(cv),()=>{e.assign(ZR.sub(i).mul(Z3.sub(JT)).div(ZR.sub(cv)).add(JT))}).ElseIf(i.greaterThanEqual(hv),()=>{e.assign(cv.sub(i).mul(J3.sub(Z3)).div(cv.sub(hv)).add(Z3))}).ElseIf(i.greaterThanEqual(fv),()=>{e.assign(hv.sub(i).mul(eS.sub(J3)).div(hv.sub(fv)).add(J3))}).ElseIf(i.greaterThanEqual(JR),()=>{e.assign(fv.sub(i).mul(Ute.sub(eS)).div(fv.sub(JR)).add(eS))}).Else(()=>{e.assign(ve(-2).mul(vu(Jn(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),KU=Xe(([i,e])=>{const t=i.toVar();t.assign(Jn(2,t).sub(1));const n=Le(t,1).toVar();return si(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ZU=Xe(([i,e,t,n,r,s])=>{const a=ve(t),l=Le(e),u=Mu(Fte(a),JT,s),h=Zc(u),m=_u(u),v=Le(ew(i,l,m,n,r,s)).toVar();return si(h.notEqual(0),()=>{const x=Le(ew(i,l,m.add(1),n,r,s)).toVar();v.assign(zi(v,x,h))}),v}),ew=Xe(([i,e,t,n,r,s])=>{const a=ve(t).toVar(),l=Le(e),u=ve(Ote(l)).toVar(),h=ve(Jr(e6.sub(a),0)).toVar();a.assign(Jr(a,e6));const m=ve(k0(a)).toVar(),v=Ft(Ite(l,u).mul(m.sub(2)).add(1)).toVar();return si(u.greaterThan(2),()=>{v.y.addAssign(m),u.subAssign(3)}),v.x.addAssign(u.mul(m)),v.x.addAssign(h.mul(Jn(3,Bte))),v.y.addAssign(Jn(4,k0(s).sub(m))),v.x.mulAssign(n),v.y.mulAssign(r),i.sample(v).grad(Ft(),Ft())}),tS=Xe(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:l})=>{const u=Cc(n),h=t.mul(u).add(r.cross(t).mul(Uo(n))).add(r.mul(r.dot(t).mul(u.oneMinus())));return ew(i,h,e,s,a,l)}),JU=Xe(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:s,dTheta:a,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})=>{const x=Le(Ys(e,t,ky(t,n))).toVar();si(WM(x.equals(Le(0))),()=>{x.assign(Le(n.z,0,n.x.negate()))}),x.assign(Wc(x));const S=Le().toVar();return S.addAssign(r.element(we(0)).mul(tS({theta:0,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),Gi({start:we(1),end:i},({i:w})=>{si(w.greaterThanEqual(s),()=>{NU()});const N=ve(a.mul(ve(w))).toVar();S.addAssign(r.element(w).mul(tS({theta:N.mul(-1),axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),S.addAssign(r.element(w).mul(tS({theta:N,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})))}),Mn(S,1)});let ny=null;const t6=new WeakMap;function kte(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function zte(i){let e=t6.get(i);if((e!==void 0?e.pmremVersion:-1)!==i.pmremVersion){const n=i.image;if(i.isCubeTexture)if(qte(n))e=ny.fromCubemap(i,e);else return null;else if(Vte(n))e=ny.fromEquirectangular(i,e);else return null;e.pmremVersion=i.pmremVersion,t6.set(i,e)}return e.texture}class Gte extends cs{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new Es;r.isRenderTargetTexture=!0,this._texture=gi(r),this._width=En(0),this._height=En(0),this._maxMip=En(0),this.updateBeforeType=Zn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=kte(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(n.isPMREMTexture===!0?e=n:e=zte(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ny===null&&(ny=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===Qa&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=Le(t.x.negate(),t.yz)),t=Le(t.x,t.y.negate(),t.z);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ZU(this._texture,t,r,this._width,this._height,this._maxMip)}}function qte(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n0}const bE=vt(Gte),n6=new WeakMap;class jte extends ep{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const S=n.isTextureNode?n.value:t[n.property];let w=n6.get(S);w===void 0&&(w=bE(S),n6.set(S,w)),n=w}const s=t.envMap?$i("envMapIntensity","float",e.material):$i("environmentIntensity","float",e.scene),l=t.useAnisotropy===!0||t.anisotropy>0?j9:Kr,u=n.context(i6(au,l)).mul(s),h=n.context(Hte(jy)).mul(Math.PI).mul(s),m=km(u),v=km(h);e.context.radiance.addAssign(m),e.context.iblIrradiance.addAssign(v);const x=e.context.lightingModel.clearcoatRadiance;if(x){const S=n.context(i6(Eg,JA)).mul(s),w=km(S);x.addAssign(w)}}}const i6=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=yr.negate().reflect(e),t=i.mul(i).mix(t,e).normalize(),t=t.transformDirection(ho)),t),getTextureLevel:()=>i}},Hte=i=>({getUV:()=>i,getTextureLevel:()=>ve(1)}),Wte=new aD;class eB extends es{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Wte),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new jte(t):null}setupLightingModel(){return new QU}setupSpecular(){const e=zi(Le(.04),Oi.rgb,Mg);Ha.assign(e),Cg.assign(1)}setupVariants(){const e=this.metalnessNode?ve(this.metalnessNode):J9;Mg.assign(e);let t=this.roughnessNode?ve(this.roughnessNode):Z9;t=yE({roughness:t}),au.assign(t),this.setupSpecular(),Oi.assign(Mn(Oi.rgb.mul(e.oneMinus()),Oi.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const $te=new Lz;class Xte extends eB{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues($te),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?ve(this.iorNode):dU;Fm.assign(e),Ha.assign(zi(oo(eE(Fm.sub(1).div(Fm.add(1))).mul(K9),Le(1)).mul(YT),Oi.rgb,Mg)),Cg.assign(zi(YT,1,Mg))}setupLightingModel(){return new QU(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?ve(this.clearcoatNode):tU,n=this.clearcoatRoughnessNode?ve(this.clearcoatRoughnessNode):nU;X_.assign(t),Eg.assign(yE({roughness:n}))}if(this.useSheen){const t=this.sheenNode?Le(this.sheenNode):sU,n=this.sheenRoughnessNode?ve(this.sheenRoughnessNode):aU;Kf.assign(t),Uy.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?ve(this.iridescenceNode):lU,n=this.iridescenceIORNode?ve(this.iridescenceIORNode):uU,r=this.iridescenceThicknessNode?ve(this.iridescenceThicknessNode):cU;By.assign(t),FM.assign(n),kM.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?Ft(this.anisotropyNode):oU).toVar();Bh.assign(t.length()),si(Bh.equal(0),()=>{t.assign(Ft(1,0))}).Else(()=>{t.divAssign(Ft(Bh)),Bh.assign(Bh.saturate())}),Y_.assign(Bh.pow2().mix(au.pow2(),1)),Im.assign(Zf[0].mul(t.x).add(Zf[1].mul(t.y))),ad.assign(Zf[1].mul(t.x).sub(Zf[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?ve(this.transmissionNode):hU,n=this.thicknessNode?ve(this.thicknessNode):fU,r=this.attenuationDistanceNode?ve(this.attenuationDistanceNode):AU,s=this.attenuationColorNode?Le(this.attenuationColorNode):pU;if(K_.assign(t),zM.assign(n),GM.assign(r),qM.assign(s),this.useDispersion){const a=this.dispersionNode?ve(this.dispersionNode):yU;VM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Le(this.clearcoatNormalNode):iU}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const Yte=Xe(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=Ft(n.mul(.5).add(.5),0);if(t.material.gradientMap){const s=Pc("gradientMap","texture").context({getUV:()=>r});return Le(s.r)}else{const s=r.fwidth().mul(.5);return zi(Le(.7),Le(1),$c(ve(.7).sub(s.x),ve(.7).add(s.x),r.x))}});class Qte extends Xy{direct({lightDirection:e,lightColor:t,reflectedLight:n},r,s){const a=Yte({normal:qy,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(a.mul(md({diffuseColor:Oi.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(md({diffuseColor:Oi}))),n.indirectDiffuse.mulAssign(e)}}const Kte=new Uz;class Zte extends es{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Kte),this.setValues(e)}setupLightingModel(){return new Qte}}class Jte extends cs{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=Le(yr.z,0,yr.x.negate()).normalize(),t=yr.cross(e);return Ft(e.dot(Kr),t.dot(Kr)).mul(.495).add(.5)}}const tB=Jt(Jte),ene=new Fz;class tne extends es{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(ene),this.setValues(e)}setupVariants(e){const t=tB;let n;e.material.matcap?n=Pc("matcap","texture").context({getUV:()=>t}):n=Le(zi(.2,.8,t.y)),Oi.rgb.mulAssign(n.rgb)}}const nne=new Jw;class ine extends es{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.setDefaultValues(nne),this.setValues(e)}}class rne extends cs{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),a=t.sin();return Ly(s,a,a.negate(),s).mul(n)}else{const s=t,a=sd(Mn(1,0,0,0),Mn(0,Cc(s.x),Uo(s.x).negate(),0),Mn(0,Uo(s.x),Cc(s.x),0),Mn(0,0,0,1)),l=sd(Mn(Cc(s.y),0,Uo(s.y),0),Mn(0,1,0,0),Mn(Uo(s.y).negate(),0,Cc(s.y),0),Mn(0,0,0,1)),u=sd(Mn(Cc(s.z),Uo(s.z).negate(),0,0),Mn(Uo(s.z),Cc(s.z),0,0),Mn(0,0,1,0),Mn(0,0,0,1));return a.mul(l).mul(u).mul(Mn(n,1)).xyz}}}const SE=vt(rne),sne=new Qk;class ane extends es{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(sne),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:l}=this,u=J0.mul(Le(s||0));let h=Ft(nl[0].xyz.length(),nl[1].xyz.length());if(l!==null&&(h=h.mul(l)),r===!1)if(n.isPerspectiveCamera)h=h.mul(u.z.negate());else{const S=ve(2).div(bd.element(1).element(1));h=h.mul(S.mul(2))}let m=Gy.xy;if(t.center&&t.center.isVector2===!0){const S=MJ("center","vec2",t);m=m.sub(S.sub(.5))}m=m.mul(h);const v=ve(a||rU),x=SE(m,v);return Mn(u.xy.add(x),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class one extends Xy{constructor(){super(),this.shadowNode=ve(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Oi.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Oi.rgb)}}const lne=new Pz;class une extends es{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lne),this.setValues(e)}setupLightingModel(){return new one}}const cne=Xe(({texture:i,uv:e})=>{const n=Le().toVar();return si(e.x.lessThan(1e-4),()=>{n.assign(Le(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(Le(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(Le(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(Le(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(Le(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(Le(0,0,-1))}).Else(()=>{const s=i.sample(e.add(Le(-.01,0,0))).r.sub(i.sample(e.add(Le(.01,0,0))).r),a=i.sample(e.add(Le(0,-.01,0))).r.sub(i.sample(e.add(Le(0,.01,0))).r),l=i.sample(e.add(Le(0,0,-.01))).r.sub(i.sample(e.add(Le(0,0,.01))).r);n.assign(Le(s,a,l))}),n.normalize()});class hne extends Cu{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Le(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(we(jh(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return cne({texture:this,uv:e})}}const fne=vt(hne);class dne{constructor(e,t){this.nodes=e,this.info=t,this._context=self,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class Du{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const s of e){const a=s.node&&s.node.attribute?s.node.attribute:t.getAttribute(s.name);if(a===void 0)continue;n.push(a);const l=a.isInterleavedBufferAttribute?a.data:a;r.add(l)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:s}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),l=this.getIndex(),u=l!==null,h=n.isInstancedBufferGeometry?n.instanceCount:e.count>1?e.count:1;if(h===0)return null;if(a.instanceCount=h,e.isBatchedMesh===!0)return a;let m=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(m=2);let v=s.start*m,x=(s.start+s.count)*m;r!==null&&(v=Math.max(v,r.start*m),x=Math.min(x,(r.start+r.count)*m));const S=n.attributes.position;let w=1/0;u?w=l.count:S!=null&&(w=S.count),v=Math.max(v,0),x=Math.min(x,w);const N=x-v;return N<0||N===1/0?null:(a.vertexCount=N,a.firstVertex=v,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const r of pne(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const s=t[r];let a;if(s!==null){const l=typeof s;l==="number"?a=s!==0?"1":"0":l==="object"?(a="{",s.isTexture&&(a+=s.mapping),a+="}"):a=String(s)}else a=String(s);n+=a+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(n+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",OP(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const RA=[];class gne{constructor(e,t,n,r,s,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=s,this.info=a,this.chainMaps={}}get(e,t,n,r,s,a,l,u){const h=this.getChainMap(u);RA[0]=e,RA[1]=t,RA[2]=a,RA[3]=s;let m=h.get(RA);return m===void 0?(m=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,s,a,l,u),h.set(RA,m)):(m.updateClipping(l),m.needsGeometryUpdate&&m.setGeometry(e.geometry),(m.version!==t.version||m.needsUpdate)&&(m.initialCacheKey!==m.getCacheKey()?(m.dispose(),m=this.get(e,t,n,r,s,a,l,u)):m.version=t.version)),m}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Du)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,s,a,l,u,h,m,v){const x=this.getChainMap(v),S=new mne(e,t,n,r,s,a,l,u,h,m);return S.onDispose=()=>{this.pipelines.delete(S),this.bindings.delete(S),this.nodes.delete(S),x.delete(S.getChainArray())},S}}class tf{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const hu={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},kh=16,vne=211,_ne=212;class yne extends tf{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==void 0&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===hu.VERTEX?this.backend.createAttribute(e):t===hu.INDEX?this.backend.createIndexAttribute(e):t===hu.STORAGE?this.backend.createStorageAttribute(e):t===hu.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version=0;--e)if(i[e]>=65535)return!0;return!1}function nB(i){return i.index!==null?i.index.version:i.attributes.position.version}function r6(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const s=t.array;for(let a=0,l=s.length;a{this.info.memory.geometries--;const s=t.index,a=e.getAttributes();s!==null&&this.attributes.delete(s);for(const u of a)this.attributes.delete(u);const l=this.wireframes.get(t);l!==void 0&&this.attributes.delete(l),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,hu.STORAGE):this.updateAttribute(s,hu.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,hu.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,hu.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const s=this.wireframes;let a=s.get(t);a===void 0?(a=r6(t),s.set(t,a)):a.version!==nB(t)&&(this.attributes.delete(a),a=r6(t),s.set(t,a)),r=a}return r}}class Sne{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){this[e].timestampCalls===0&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class iB{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Tne extends iB{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class wne extends iB{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Mne=0;class nS{constructor(e,t,n,r=null,s=null){this.id=Mne++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=s,this.usedTimes=0}}class Ene extends tf{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let l=this.programs.compute.get(a.computeShader);l===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),l=new nS(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,l),n.createProgram(l));const u=this._getComputeCacheKey(e,l);let h=this.caches.get(u);h===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),h=this._getComputePipeline(e,l,u,t)),h.usedTimes++,l.usedTimes++,r.version=e.version,r.pipeline=h}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),l=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),u=new nS(a.vertexShader,"vertex",l),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let h=this.programs.fragment.get(a.fragmentShader);h===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),h=new nS(a.fragmentShader,"fragment",l),this.programs.fragment.set(a.fragmentShader,h),n.createProgram(h));const m=this._getRenderCacheKey(e,u,h);let v=this.caches.get(m);v===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),v=this._getRenderPipeline(e,u,h,m,t)):e.pipeline=v,v.usedTimes++,u.usedTimes++,h.usedTimes++,r.pipeline=v}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new wne(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,n,r,s){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new Tne(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,s)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Cne extends tf{constructor(e,t,n,r,s,a){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?hu.INDIRECT:hu.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,s=!0,a=0,l=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const h=this.textures.get(u.texture);u.needsBindingsUpdate(h.generation)&&(r=!0);const m=u.update(),v=u.texture;m&&this.textures.updateTexture(v);const x=n.get(v);if(x.externalTexture!==void 0||h.isDefaultTexture?s=!1:(a=a*10+v.id,l+=v.version),n.isWebGPUBackend===!0&&x.texture===void 0&&x.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,m,v,u.textureNode.value,r),this.textures.updateTexture(v),r=!0),v.isStorageTexture===!0){const S=this.get(v);u.store===!0?S.needsMipmap=!0:this.textures.needsMipmaps(v)&&S.needsMipmap===!0&&(this.backend.generateMipmaps(v),S.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,s?a:0,l)}}function Nne(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function s6(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function a6(i){return(i.transmission>0||i.transmissionNode)&&i.side===gs&&i.forceSinglePass===!1}class Rne{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,s,a,l){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:s,group:a,clippingContext:l},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=s,u.group=a,u.clippingContext=l),this.renderItemsIndex++,u}push(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(a6(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);n.transparent===!0||n.transmission>0?(a6(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Nne),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||s6),this.transparent.length>1&&this.transparent.sort(t||s6)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,h=l.height>>t;let m=e.depthTexture||s[t];const v=e.depthBuffer===!0||e.stencilBuffer===!0;let x=!1;m===void 0&&v&&(m=new Qc,m.format=e.stencilBuffer?bu:Au,m.type=e.stencilBuffer?xu:Ir,m.image.width=u,m.image.height=h,s[t]=m),(n.width!==l.width||l.height!==n.height)&&(x=!0,m&&(m.needsUpdate=!0,m.image.width=u,m.image.height=h)),n.width=l.width,n.height=l.height,n.textures=a,n.depthTexture=m||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(x=!0,m&&(m.needsUpdate=!0),n.sampleCount=r);const S={sampleCount:r};for(let w=0;w{e.removeEventListener("dispose",w);for(let N=0;N0){const m=e.image;if(m===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(m.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const v=[];for(const x of e.images)v.push(x);t.images=v}else t.image=m;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&s.generateMipmaps(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const h=()=>{e.removeEventListener("dispose",h),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",h)}n.version=e.version}getSize(e,t=Bne){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return this.isEnvironmentTexture(e)||e.isCompressedTexture===!0||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===Wh||t===$h||t===sl||t===al}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class TE extends mn{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class sB extends Vi{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const Ine=(i,e)=>Ct(new sB(i,e));class Fne extends Un{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new Om(t);return this._currentCond=Ys(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Om(t),r=Ys(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Om(e),this}build(e,...t){const n=UM();Tg(this);for(const r of this.nodes)r.build(e,"void");return Tg(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const e_=vt(Fne);class aB extends Un{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,n=[];for(let r=0;r{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),tw=(i,e)=>Fl(Jn(4,i.mul(Ei(1,i))),e),qne=(i,e)=>i.lessThan(.5)?tw(i.mul(2),e).div(2):Ei(1,tw(Jn(Ei(1,i),2),e).div(2)),Vne=(i,e,t)=>Fl(Gl(Fl(i,e),ls(Fl(i,e),Fl(Ei(1,i),t))),1/e),jne=(i,e)=>Uo(Z_.mul(e.mul(i).sub(1))).div(Z_.mul(e.mul(i).sub(1))),Nc=Xe(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Hne=Xe(([i])=>Le(Nc(i.z.add(Nc(i.y.mul(1)))),Nc(i.z.add(Nc(i.x.mul(1)))),Nc(i.y.add(Nc(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Wne=Xe(([i,e,t])=>{const n=Le(i).toVar(),r=ve(1.4).toVar(),s=ve(0).toVar(),a=Le(n).toVar();return Gi({start:ve(0),end:ve(3),type:"float",condition:"<="},()=>{const l=Le(Hne(a.mul(2))).toVar();n.addAssign(l.add(t.mul(ve(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const u=ve(Nc(n.z.add(Nc(n.x.add(Nc(n.y)))))).toVar();s.addAssign(u.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class $ne extends Un{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let r=null,s=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=u.inputs;if(t.length===h.length){let m=0;for(let v=0;vs&&(r=a,s=m)}}this._candidateFnCall=n=r(...t)}return n}}const Xne=vt($ne),Zs=i=>(...e)=>Xne(i,...e),Sd=En(0).setGroup(In).onRenderUpdate(i=>i.time),uB=En(0).setGroup(In).onRenderUpdate(i=>i.deltaTime),Yne=En(0,"uint").setGroup(In).onRenderUpdate(i=>i.frameId),Qne=(i=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),Sd.mul(i)),Kne=(i=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),Sd.mul(i)),Zne=(i=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),uB.mul(i)),Jne=(i=Sd)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),eie=(i=Sd)=>i.fract().round(),tie=(i=Sd)=>i.add(.5).fract().mul(2).sub(1).abs(),nie=(i=Sd)=>i.fract(),iie=Xe(([i,e,t=Ft(.5)])=>SE(i.sub(t),e).add(t)),rie=Xe(([i,e,t=Ft(.5)])=>{const n=i.sub(t),r=n.dot(n),a=r.mul(r).mul(e);return i.add(n.mul(a))}),sie=Xe(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=nl.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=nl;const r=ho.mul(n);return Sg(e)&&(r[0][0]=nl[0].length(),r[0][1]=0,r[0][2]=0),Sg(t)&&(r[1][0]=0,r[1][1]=nl[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,bd.mul(r).mul(Zr)}),aie=Xe(([i=null])=>{const e=ty();return ty(AE(i)).sub(e).lessThan(0).select(Ru,i)});class oie extends Un{static get type(){return"SpriteSheetUVNode"}constructor(e,t=Br(),n=ve(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:s}=n,a=e.mod(r.mul(s)).floor(),l=a.mod(r),u=s.sub(a.add(1).div(r).ceil()),h=n.reciprocal(),m=Ft(l,u);return t.add(m).mul(h)}}const lie=vt(oie);class uie extends Un{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,n=null,r=ve(1),s=Zr,a=lo){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:s,normalNode:a}=this;let l=a.abs().normalize();l=l.div(l.dot(Le(1)));const u=s.yz.mul(r),h=s.zx.mul(r),m=s.xy.mul(r),v=e.value,x=t!==null?t.value:v,S=n!==null?n.value:v,w=gi(v,u).mul(l.x),N=gi(x,h).mul(l.y),C=gi(S,m).mul(l.z);return ls(w,N,C)}}const cB=vt(uie),cie=(...i)=>cB(...i),DA=new iu,Df=new de,PA=new de,iS=new de,cm=new Xn,dv=new de(0,0,-1),Zl=new qn,hm=new de,Av=new de,fm=new qn,pv=new Et,iy=new Zh,hie=Ru.flipX();iy.depthTexture=new Qc(1,1);let rS=!1;class wE extends Cu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||iy.texture,hie),this._reflectorBaseNode=e.reflector||new fie(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Ct(new wE({defaultTexture:iy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}}class fie extends Un{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new Tr,resolution:r=1,generateMipmaps:s=!1,bounces:a=!0,depth:l=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=s,this.bounces=a,this.depth=l,this.updateBeforeType=a?Zn.RENDER:Zn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const n=this.resolution;t.getDrawingBufferSize(pv),e.setSize(Math.round(pv.width*n),Math.round(pv.height*n))}setup(e){return this._updateResolution(iy,e.renderer),super.setup(e)}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Zh(0,0,{type:Qs}),this.generateMipmaps===!0&&(t.texture.minFilter=WF,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Qc),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&rS)return!1;rS=!0;const{scene:t,camera:n,renderer:r,material:s}=e,{target:a}=this,l=this.getVirtualCamera(n),u=this.getRenderTarget(l);if(r.getDrawingBufferSize(pv),this._updateResolution(u,r),PA.setFromMatrixPosition(a.matrixWorld),iS.setFromMatrixPosition(n.matrixWorld),cm.extractRotation(a.matrixWorld),Df.set(0,0,1),Df.applyMatrix4(cm),hm.subVectors(PA,iS),hm.dot(Df)>0)return;hm.reflect(Df).negate(),hm.add(PA),cm.extractRotation(n.matrixWorld),dv.set(0,0,-1),dv.applyMatrix4(cm),dv.add(iS),Av.subVectors(PA,dv),Av.reflect(Df).negate(),Av.add(PA),l.coordinateSystem=n.coordinateSystem,l.position.copy(hm),l.up.set(0,1,0),l.up.applyMatrix4(cm),l.up.reflect(Df),l.lookAt(Av),l.near=n.near,l.far=n.far,l.updateMatrixWorld(),l.projectionMatrix.copy(n.projectionMatrix),DA.setFromNormalAndCoplanarPoint(Df,PA),DA.applyMatrix4(l.matrixWorldInverse),Zl.set(DA.normal.x,DA.normal.y,DA.normal.z,DA.constant);const h=l.projectionMatrix;fm.x=(Math.sign(Zl.x)+h.elements[8])/h.elements[0],fm.y=(Math.sign(Zl.y)+h.elements[9])/h.elements[5],fm.z=-1,fm.w=(1+h.elements[10])/h.elements[14],Zl.multiplyScalar(1/Zl.dot(fm));const m=0;h.elements[2]=Zl.x,h.elements[6]=Zl.y,h.elements[10]=r.coordinateSystem===Su?Zl.z-m:Zl.z+1-m,h.elements[14]=Zl.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),s.visible=!1;const v=r.getRenderTarget(),x=r.getMRT(),S=r.autoClear;r.setMRT(null),r.setRenderTarget(u),r.autoClear=!0,r.render(t,l),r.setMRT(x),r.setRenderTarget(v),r.autoClear=S,s.visible=!0,rS=!1}}const die=i=>Ct(new wE(i)),sS=new Gg(-1,1,1,-1,0,1);class Aie extends Ji{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Ci([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ci(t,2))}}const pie=new Aie;class ME extends qi{constructor(e=null){super(pie,e),this.camera=sS,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,sS)}render(e){e.render(this,sS)}}const mie=new Et;class gie extends Cu{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:Qs}){const s=new Zh(t,n,r);super(s.texture,Br()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new ME(new es),this.updateBeforeType=Zn.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const n=e.getSize(mie);this.setSize(n.width,n.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Cu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const hB=(i,...e)=>Ct(new gie(Ct(i),...e)),vie=(i,...e)=>i.isTextureNode?i:i.isPassNode?i.getTextureNode():hB(i,...e),VA=Xe(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===Su?(i=Ft(i.x,i.y.oneMinus()).mul(2).sub(1),r=Mn(Le(i,e),1)):r=Mn(Le(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const s=Mn(t.mul(r));return s.xyz.div(s.w)}),_ie=Xe(([i,e])=>{const t=e.mul(Mn(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Ft(n.x,n.y.oneMinus())}),yie=Xe(([i,e,t])=>{const n=jh(Yr(e)),r=ws(i.mul(n)).toVar(),s=Yr(e,r).toVar(),a=Yr(e,r.sub(ws(2,0))).toVar(),l=Yr(e,r.sub(ws(1,0))).toVar(),u=Yr(e,r.add(ws(1,0))).toVar(),h=Yr(e,r.add(ws(2,0))).toVar(),m=Yr(e,r.add(ws(0,2))).toVar(),v=Yr(e,r.add(ws(0,1))).toVar(),x=Yr(e,r.sub(ws(0,1))).toVar(),S=Yr(e,r.sub(ws(0,2))).toVar(),w=dr(Ei(ve(2).mul(l).sub(a),s)).toVar(),N=dr(Ei(ve(2).mul(u).sub(h),s)).toVar(),C=dr(Ei(ve(2).mul(v).sub(m),s)).toVar(),E=dr(Ei(ve(2).mul(x).sub(S),s)).toVar(),O=VA(i,s,t).toVar(),U=w.lessThan(N).select(O.sub(VA(i.sub(Ft(ve(1).div(n.x),0)),l,t)),O.negate().add(VA(i.add(Ft(ve(1).div(n.x),0)),u,t))),I=C.lessThan(E).select(O.sub(VA(i.add(Ft(0,ve(1).div(n.y))),v,t)),O.negate().add(VA(i.sub(Ft(0,ve(1).div(n.y))),x,t)));return Wc(ky(U,I))});class t_ extends kg{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class xie extends Lr{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}class bie extends xd{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}const Sie=vt(bie);class Tie extends oE{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t=FP(e.itemSize),n=e.count),super(e,t,n),this.isStorageBufferNode=!0,this.access=da.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Sie(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(da.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Yg(this.value),this._varying=co(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}generate(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const Qy=(i,e=null,t=0)=>Ct(new Tie(i,e,t)),wie=(i,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Qy(i,e,t).setPBO(!0)),Mie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new xie(i,t,n);return Qy(r,e,i)},Eie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new t_(i,t,n);return Qy(r,e,i)};class Cie extends w9{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new qn(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const Nie=i=>Ct(new Cie(i));class Rie extends Un{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Die=Jt(Rie),dm=new ma,aS=new Xn;class to extends Un{static get type(){return"SceneNode"}constructor(e=to.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let r;return t===to.BACKGROUND_BLURRINESS?r=$i("backgroundBlurriness","float",n):t===to.BACKGROUND_INTENSITY?r=$i("backgroundIntensity","float",n):t===to.BACKGROUND_ROTATION?r=En("mat4").label("backgroundRotation").setGroup(In).onRenderUpdate(()=>{const s=n.background;return s!==null&&s.isTexture&&s.mapping!==Bw?(dm.copy(n.backgroundRotation),dm.x*=-1,dm.y*=-1,dm.z*=-1,aS.makeRotationFromEuler(dm)):aS.identity(),aS}):console.error("THREE.SceneNode: Unknown scope:",t),r}}to.BACKGROUND_BLURRINESS="backgroundBlurriness";to.BACKGROUND_INTENSITY="backgroundIntensity";to.BACKGROUND_ROTATION="backgroundRotation";const fB=Jt(to,to.BACKGROUND_BLURRINESS),nw=Jt(to,to.BACKGROUND_INTENSITY),dB=Jt(to,to.BACKGROUND_ROTATION);class Pie extends Cu{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=da.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(da.READ_WRITE)}toReadOnly(){return this.setAccess(da.READ_ONLY)}toWriteOnly(){return this.setAccess(da.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:r}=t,s=super.generate(e,"property"),a=n.build(e,"uvec2"),l=r.build(e,"vec4"),u=e.generateTextureStore(e,s,a,l);e.addLineFlowCode(u,this)}}const AB=vt(Pie),Lie=(i,e,t)=>{const n=AB(i,e,t);return t!==null&&n.append(),n};class Uie extends Hy{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Bie=(i,e,t)=>Ct(new Uie(i,e,t)),o6=new WeakMap;class Oie extends cs{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Zn.OBJECT,this.updateAfterType=Zn.OBJECT,this.previousModelWorldMatrix=En(new Xn),this.previousProjectionMatrix=En(new Xn).setGroup(In),this.previousCameraViewMatrix=En(new Xn)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=l6(n);this.previousModelWorldMatrix.value.copy(r);const s=pB(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new Xn,s.previousCameraViewMatrix=new Xn,s.currentProjectionMatrix=new Xn,s.currentCameraViewMatrix=new Xn,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){l6(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?bd:En(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(J0).mul(Zr),r=this.previousProjectionMatrix.mul(t).mul(ey),s=n.xy.div(n.w),a=r.xy.div(r.w);return Ei(s,a)}}function pB(i){let e=o6.get(i);return e===void 0&&(e={},o6.set(i,e)),e}function l6(i,e=0){const t=pB(i);let n=t[e];return n===void 0&&(t[e]=n=new Xn),n}const Iie=Jt(Oie),mB=Xe(([i,e])=>oo(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),gB=Xe(([i,e])=>oo(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vB=Xe(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_B=Xe(([i,e])=>zi(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Fy(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Fie=Xe(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return Mn(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kie=(...i)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),mB(i)),zie=(...i)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),gB(i)),Gie=(...i)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),vB(i)),qie=(...i)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),_B(i)),Vie=Xe(([i])=>EE(i.rgb)),jie=Xe(([i,e=ve(1)])=>e.mix(EE(i.rgb),i.rgb)),Hie=Xe(([i,e=ve(1)])=>{const t=ls(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),r=n.sub(t).mul(e).mul(-3);return zi(i.rgb,n,r)}),Wie=Xe(([i,e=ve(1)])=>{const t=Le(.57735,.57735,.57735),n=e.cos();return Le(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(ef(t,i.rgb).mul(n.oneMinus())))))}),EE=(i,e=Le(hi.getLuminanceCoefficients(new de)))=>ef(i,e),$ie=Xe(([i,e=Le(1),t=Le(0),n=Le(1),r=ve(1),s=Le(hi.getLuminanceCoefficients(new de,Io))])=>{const a=i.rgb.dot(Le(s)),l=Jr(i.rgb.mul(e).add(t),0).toVar(),u=l.pow(n).toVar();return si(l.r.greaterThan(0),()=>{l.r.assign(u.r)}),si(l.g.greaterThan(0),()=>{l.g.assign(u.g)}),si(l.b.greaterThan(0),()=>{l.b.assign(u.b)}),l.assign(a.add(l.sub(a).mul(r))),Mn(l.rgb,i.a)});class Xie extends cs{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const Yie=vt(Xie),Qie=new Et;class yB extends Cu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class u6 extends yB{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Pu extends cs{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new Qc;s.isRenderTargetTexture=!0,s.name="depth";const a=new Zh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Qs,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=En(0),this._cameraFar=En(0),this._mrt=null,this.isPassNode=!0,this.updateBeforeType=Zn.FRAME}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=Ct(new u6(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=Ct(new u6(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=pE(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=l0(s,n,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.scope===Pu.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(Qie);this.setSize(s.width,s.height);const a=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const u in this._previousTextures)this.toggleTexture(u);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(a),t.setMRT(l)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Pu.COLOR="color";Pu.DEPTH="depth";const Kie=(i,e,t)=>Ct(new Pu(Pu.COLOR,i,e,t)),Zie=(i,e)=>Ct(new yB(i,e)),Jie=(i,e,t)=>Ct(new Pu(Pu.DEPTH,i,e,t));class ere extends Pu{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,s){super(Pu.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,l,u,h,m,v)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const x=this._getOutlineMaterial(u);t.renderObject(r,s,a,l,x,h,m,v)}t.renderObject(r,s,a,l,u,h,m,v)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new es;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=gr;const t=lo.negate(),n=bd.mul(J0),r=ve(1),s=n.mul(Mn(Zr,1)),a=n.mul(Mn(Zr.add(t),1)),l=Wc(s.sub(a));return e.vertexNode=s.add(l.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=Mn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const tre=(i,e,t=new mn(0,0,0),n=.003,r=1)=>Ct(new ere(i,e,Ct(t),Ct(n),Ct(r))),xB=Xe(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bB=Xe(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SB=Xe(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),nre=Xe(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),TB=Xe(([i,e])=>{const t=_a(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=_a(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=nre(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ire=_a(Le(1.6605,-.1246,-.0182),Le(-.5876,1.1329,-.1006),Le(-.0728,-.0083,1.1187)),rre=_a(Le(.6274,.0691,.0164),Le(.3293,.9195,.088),Le(.0433,.0113,.8956)),sre=Xe(([i])=>{const e=Le(i).toVar(),t=Le(e.mul(e)).toVar(),n=Le(t.mul(t)).toVar();return ve(15.5).mul(n.mul(t)).sub(Jn(40.14,n.mul(e))).add(Jn(31.96,n).sub(Jn(6.868,t.mul(e))).add(Jn(.4298,t).add(Jn(.1191,e).sub(.00232))))}),wB=Xe(([i,e])=>{const t=Le(i).toVar(),n=_a(Le(.856627153315983,.137318972929847,.11189821299995),Le(.0951212405381588,.761241990602591,.0767994186031903),Le(.0482516061458583,.101439036467562,.811302368396859)),r=_a(Le(1.1271005818144368,-.1413297634984383,-.14132976349843826),Le(-.11060664309660323,1.157823702216272,-.11060664309660294),Le(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=ve(-12.47393),a=ve(4.026069);return t.mulAssign(e),t.assign(rre.mul(t)),t.assign(n.mul(t)),t.assign(Jr(t,1e-10)),t.assign(vu(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(Mu(t,0,1)),t.assign(sre(t)),t.assign(r.mul(t)),t.assign(Fl(Jr(Le(0),t),Le(2.2))),t.assign(ire.mul(t)),t.assign(Mu(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MB=Xe(([i,e])=>{const t=ve(.76),n=ve(.15);i=i.mul(e);const r=oo(i.r,oo(i.g,i.b)),s=Ys(r.lessThan(.08),r.sub(Jn(6.25,r.mul(r))),.04);i.subAssign(s);const a=Jr(i.r,Jr(i.g,i.b));si(a.lessThan(t),()=>i);const l=Ei(1,t),u=Ei(1,l.mul(l).div(a.add(l.sub(t))));i.mulAssign(u.div(a));const h=Ei(1,Gl(1,n.mul(a.sub(u)).add(1)));return zi(i,Le(u),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class ps extends Un{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.includes=t,this.language=n}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ky=vt(ps),are=(i,e)=>Ky(i,e,"js"),ore=(i,e)=>Ky(i,e,"wgsl"),lre=(i,e)=>Ky(i,e,"glsl");class EB extends ps{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,s=n.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const l=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(l);return a.code=u+` +`,t==="property"?l:e.format(`${l}()`,s,t)}}const CB=(i,e=[],t="")=>{for(let s=0;sn.call(...s);return r.functionNode=n,r},ure=(i,e)=>CB(i,e,"glsl"),cre=(i,e)=>CB(i,e,"wgsl");class hre extends Un{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Xc,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ve()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=VP(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=jP(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const n_=vt(hre);class NB extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class fre{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const i_=new NB;class dre extends Un{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new NB,this._output=n_(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=n_(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=n_(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r.constructor.name==="AsyncFunction"?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(h,m)=>this.setOutput(h,m),n=new fre(this),r=i_.get("THREE"),s=i_.get("TSL"),a=this.getMethod(),l=[n,this._local,i_,e,t,r,s];this._object=a(...l);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const h of u.elements){const m=h.id||h.name;h.inputType&&(this.getParameter(m)===void 0&&this.setParameter(m,null),this.getParameter(m).inputType=h.inputType),h.outputType&&(this.getOutput(m)===void 0&&this.setOutput(m,null),this.getOutput(m).outputType=h.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ve()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),r="var "+n+`; var output = {}; +`,s=` +return { ...output, `+n+" };",a=r+this.codeNode.code+s;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[OP(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Ry(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Are=vt(dre);function RB(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||as.z).negate()}const CE=Xe(([i,e],t)=>{const n=RB(t);return $c(i,e,n)}),NE=Xe(([i],e)=>{const t=RB(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Pg=Xe(([i,e])=>Mn(e.toFloat().mix(Ng.rgb,i.toVec3()),Ng.a));function pre(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Pg(i,CE(e,t))}function mre(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Pg(i,NE(e))}let Pf=null,Lf=null;class gre extends Un{static get type(){return"RangeNode"}constructor(e=ve(),t=ve()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(zh(this.minNode.value)),n=e.getTypeLength(zh(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(zh(r)),l=e.getTypeLength(zh(s));Pf=Pf||new qn,Lf=Lf||new qn,Pf.setScalar(0),Lf.setScalar(0),a===1?Pf.setScalar(r):r.isColor?Pf.set(r.r,r.g,r.b,1):Pf.set(r.x,r.y,r.z||0,r.w||0),l===1?Lf.setScalar(s):s.isColor?Lf.set(s.r,s.g,s.b,1):Lf.set(s.x,s.y,s.z||0,s.w||0);const u=4,h=u*t.count,m=new Float32Array(h);for(let x=0;xCt(new _re(i,e)),yre=Zy("numWorkgroups","uvec3"),xre=Zy("workgroupId","uvec3"),bre=Zy("localId","uvec3"),Sre=Zy("subgroupSize","uint");class Tre extends Un{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier +`):e.addLineFlowCode(`${t}Barrier()`,this)}}const RE=vt(Tre),wre=()=>RE("workgroup").append(),Mre=()=>RE("storage").append(),Ere=()=>RE("texture").append();class Cre extends xd{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}class Nre extends Un{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Ct(new Cre(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const Rre=(i,e)=>Ct(new Nre("Workgroup",i,e));class zs extends cs{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,l=[];l.push(`&${s.build(e,r)}`),l.push(a.build(e,r));const u=`${e.getMethod(t,n)}( ${l.join(", ")} )`;if(this.storeNode!==null){const h=this.storeNode.build(e,r);e.addLineFlowCode(`${h} = ${u}`,this)}else e.addLineFlowCode(u,this)}}zs.ATOMIC_LOAD="atomicLoad";zs.ATOMIC_STORE="atomicStore";zs.ATOMIC_ADD="atomicAdd";zs.ATOMIC_SUB="atomicSub";zs.ATOMIC_MAX="atomicMax";zs.ATOMIC_MIN="atomicMin";zs.ATOMIC_AND="atomicAnd";zs.ATOMIC_OR="atomicOr";zs.ATOMIC_XOR="atomicXor";const Dre=vt(zs),Jc=(i,e,t,n=null)=>{const r=Dre(i,e,t,n);return r.append(),r},Pre=(i,e,t=null)=>Jc(zs.ATOMIC_STORE,i,e,t),Lre=(i,e,t=null)=>Jc(zs.ATOMIC_ADD,i,e,t),Ure=(i,e,t=null)=>Jc(zs.ATOMIC_SUB,i,e,t),Bre=(i,e,t=null)=>Jc(zs.ATOMIC_MAX,i,e,t),Ore=(i,e,t=null)=>Jc(zs.ATOMIC_MIN,i,e,t),Ire=(i,e,t=null)=>Jc(zs.ATOMIC_AND,i,e,t),Fre=(i,e,t=null)=>Jc(zs.ATOMIC_OR,i,e,t),kre=(i,e,t=null)=>Jc(zs.ATOMIC_XOR,i,e,t);let mv;function i1(i){mv=mv||new WeakMap;let e=mv.get(i);return e===void 0&&mv.set(i,e={}),e}function DE(i){const e=i1(i);return e.shadowMatrix||(e.shadowMatrix=En("mat4").setGroup(In).onRenderUpdate(()=>(i.castShadow!==!0&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function DB(i){const e=i1(i);if(e.projectionUV===void 0){const t=DE(i).mul(Fc);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function PE(i){const e=i1(i);return e.position||(e.position=En(new de).setGroup(In).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function PB(i){const e=i1(i);return e.targetPosition||(e.targetPosition=En(new de).setGroup(In).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function Jy(i){const e=i1(i);return e.viewPosition||(e.viewPosition=En(new de).setGroup(In).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new de,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const LE=i=>ho.transformDirection(PE(i).sub(PB(i))),zre=i=>i.sort((e,t)=>e.id-t.id),Gre=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},oS=new WeakMap;class UE extends Un{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Le().toVar("totalDiffuse"),this.totalSpecularNode=Le().toVar("totalSpecular"),this.outgoingLightNode=Le().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let n=0;n0}}const qre=(i=[])=>Ct(new UE).setLights(i);class Vre extends Un{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Zn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({material:e}){BE.assign(e.shadowPositionNode||Fc)}dispose(){this.updateBeforeType=Zn.NONE}}const BE=Le().toVar("shadowPositionWorld");function jre(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new mn),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function Hre(i,e){return e=jre(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function Wre(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function $re(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function Xre(i,e){return e=$re(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function Yre(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function Qre(i,e,t){return t=Hre(i,t),t=Xre(e,t),t}function Kre(i,e,t){Wre(i,t),Yre(e,t)}const c6=new WeakMap,Zre=Xe(([i,e,t])=>{let n=Fc.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),Jre=i=>{const e=i.shadow.camera,t=$i("near","float",e).setGroup(In),n=$i("far","float",e).setGroup(In),r=C9(i);return Zre(r,t,n)},ese=i=>{let e=c6.get(i);if(e===void 0){const t=i.isPointLight?Jre(i):null;e=new es,e.colorNode=Mn(0,0,0,1),e.depthNode=t,e.isShadowNodeMaterial=!0,e.name="ShadowMaterial",e.fog=!1,c6.set(i,e)}return e},LB=Xe(({depthTexture:i,shadowCoord:e})=>gi(i,e.xy).compare(e.z)),UB=Xe(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(N,C)=>gi(i,N).compare(C),r=$i("mapSize","vec2",t).setGroup(In),s=$i("radius","float",t).setGroup(In),a=Ft(1).div(r),l=a.x.negate().mul(s),u=a.y.negate().mul(s),h=a.x.mul(s),m=a.y.mul(s),v=l.div(2),x=u.div(2),S=h.div(2),w=m.div(2);return ls(n(e.xy.add(Ft(l,u)),e.z),n(e.xy.add(Ft(0,u)),e.z),n(e.xy.add(Ft(h,u)),e.z),n(e.xy.add(Ft(v,x)),e.z),n(e.xy.add(Ft(0,x)),e.z),n(e.xy.add(Ft(S,x)),e.z),n(e.xy.add(Ft(l,0)),e.z),n(e.xy.add(Ft(v,0)),e.z),n(e.xy,e.z),n(e.xy.add(Ft(S,0)),e.z),n(e.xy.add(Ft(h,0)),e.z),n(e.xy.add(Ft(v,w)),e.z),n(e.xy.add(Ft(0,w)),e.z),n(e.xy.add(Ft(S,w)),e.z),n(e.xy.add(Ft(l,m)),e.z),n(e.xy.add(Ft(0,m)),e.z),n(e.xy.add(Ft(h,m)),e.z)).mul(1/17)}),BB=Xe(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(m,v)=>gi(i,m).compare(v),r=$i("mapSize","vec2",t).setGroup(In),s=Ft(1).div(r),a=s.x,l=s.y,u=e.xy,h=Zc(u.mul(r).add(.5));return u.subAssign(h.mul(s)),ls(n(u,e.z),n(u.add(Ft(a,0)),e.z),n(u.add(Ft(0,l)),e.z),n(u.add(s),e.z),zi(n(u.add(Ft(a.negate(),0)),e.z),n(u.add(Ft(a.mul(2),0)),e.z),h.x),zi(n(u.add(Ft(a.negate(),l)),e.z),n(u.add(Ft(a.mul(2),l)),e.z),h.x),zi(n(u.add(Ft(0,l.negate())),e.z),n(u.add(Ft(0,l.mul(2))),e.z),h.y),zi(n(u.add(Ft(a,l.negate())),e.z),n(u.add(Ft(a,l.mul(2))),e.z),h.y),zi(zi(n(u.add(Ft(a.negate(),l.negate())),e.z),n(u.add(Ft(a.mul(2),l.negate())),e.z),h.x),zi(n(u.add(Ft(a.negate(),l.mul(2))),e.z),n(u.add(Ft(a.mul(2),l.mul(2))),e.z),h.x),h.y)).mul(1/9)}),OB=Xe(({depthTexture:i,shadowCoord:e})=>{const t=ve(1).toVar(),n=gi(i).sample(e.xy).rg,r=Fy(e.z,n.x);return si(r.notEqual(ve(1)),()=>{const s=e.z.sub(n.x),a=Jr(0,n.y.mul(n.y));let l=a.div(a.add(s.mul(s)));l=Mu(Ei(l,.3).div(.95-.3)),t.assign(Mu(Jr(r,l)))}),t}),tse=Xe(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=ve(0).toVar(),s=ve(0).toVar(),a=i.lessThanEqual(ve(1)).select(ve(0),ve(2).div(i.sub(1))),l=i.lessThanEqual(ve(1)).select(ve(0),ve(-1));Gi({start:we(0),end:we(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(ve(h).mul(a)),v=n.sample(ls(n1.xy,Ft(0,m).mul(e)).div(t)).x;r.addAssign(v),s.addAssign(v.mul(v))}),r.divAssign(i),s.divAssign(i);const u=Ou(s.sub(r.mul(r)));return Ft(r,u)}),nse=Xe(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=ve(0).toVar(),s=ve(0).toVar(),a=i.lessThanEqual(ve(1)).select(ve(0),ve(2).div(i.sub(1))),l=i.lessThanEqual(ve(1)).select(ve(0),ve(-1));Gi({start:we(0),end:we(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(ve(h).mul(a)),v=n.sample(ls(n1.xy,Ft(m,0).mul(e)).div(t));r.addAssign(v.x),s.addAssign(ls(v.y.mul(v.y),v.x.mul(v.x)))}),r.divAssign(i),s.divAssign(i);const u=Ou(s.sub(r.mul(r)));return Ft(r,u)}),ise=[LB,UB,BB,OB];let lS;const gv=new ME;class IB extends Vre{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s}){const a=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:n,shadowCoord:r,shadow:s});return a.select(l,ve(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,s=$i("bias","float",n).setGroup(In);let a=t,l;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),l=a.z,r.coordinateSystem===Su&&(l=l.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const h=$i("near","float",n.camera).setGroup(In),m=$i("far","float",n.camera).setGroup(In);l=mE(u.negate(),h,m)}return a=Le(a.x,a.y.oneMinus(),l.add(s)),a}getShadowFilterFn(e){return ise[e]}setupShadow(e){const{renderer:t}=e,{light:n,shadow:r}=this,s=t.shadowMap.type,a=new Qc(r.mapSize.width,r.mapSize.height);a.compareFunction=my;const l=e.createRenderTarget(r.mapSize.width,r.mapSize.height);if(l.depthTexture=a,r.camera.updateProjectionMatrix(),s===No){a.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:hd,type:Qs}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:hd,type:Qs});const E=gi(a),O=gi(this.vsmShadowMapVertical.texture),U=$i("blurSamples","float",r).setGroup(In),I=$i("radius","float",r).setGroup(In),j=$i("mapSize","vec2",r).setGroup(In);let z=this.vsmMaterialVertical||(this.vsmMaterialVertical=new es);z.fragmentNode=tse({samples:U,radius:I,size:j,shadowPass:E}).context(e.getSharedContext()),z.name="VSMVertical",z=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new es),z.fragmentNode=nse({samples:U,radius:I,size:j,shadowPass:O}).context(e.getSharedContext()),z.name="VSMHorizontal"}const u=$i("intensity","float",r).setGroup(In),h=$i("normalBias","float",r).setGroup(In),m=DE(n).mul(BE.add(jy.mul(h))),v=this.setupShadowCoord(e,m),x=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(x===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const S=s===No?this.vsmShadowMapHorizontal.texture:a,w=this.setupShadowFilter(e,{filterFn:x,shadowTexture:l.texture,depthTexture:S,shadowCoord:v,shadow:r}),N=gi(l.texture,v),C=zi(1,w.rgb.mix(N,1),u.mul(N.a)).toVar();return this.shadowMap=l,this.shadow.map=l,C}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Xe(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height),s.render(a,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:s,scene:a,camera:l}=e,u=s.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h,r.camera.layers.mask=l.layers.mask;const m=s.getRenderObjectFunction(),v=s.getMRT(),x=v?v.has("velocity"):!1;lS=Qre(s,a,lS),a.overrideMaterial=ese(n),s.setRenderObjectFunction((S,w,N,C,E,O,...U)=>{(S.castShadow===!0||S.receiveShadow&&u===No)&&(x&&(qP(S).useVelocity=!0),S.onBeforeShadow(s,S,l,r.camera,C,w.overrideMaterial,O),s.renderObject(S,w,N,C,E,O,...U),S.onAfterShadow(s,S,l,r.camera,C,w.overrideMaterial,O))}),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(m),n.isPointLight!==!0&&u===No&&this.vsmPass(s),Kre(s,a,lS)}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),gv.material=this.vsmMaterialVertical,gv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),gv.material=this.vsmMaterialHorizontal,gv.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const FB=(i,e)=>Ct(new IB(i,e));class Td extends ep{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new mn,this.colorNode=e&&e.colorNode||En(this.color).setGroup(In),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Zn.FRAME}customCacheKey(){return NM(this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return FB(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let s;r!==void 0?s=Ct(r):s=this.setupShadowNode(e),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const OE=Xe(i=>{const{lightDistance:e,cutoffDistance:t,decayExponent:n}=i,r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),rse=new mn,nu=Xe(([i,e])=>{const t=i.toVar(),n=dr(t),r=Gl(1,Jr(n.x,Jr(n.y,n.z)));n.mulAssign(r),t.mulAssign(r.mul(e.mul(2).oneMinus()));const s=Ft(t.xy).toVar(),l=e.mul(1.5).oneMinus();return si(n.z.greaterThanEqual(l),()=>{si(t.z.greaterThan(0),()=>{s.x.assign(Ei(4,t.x))})}).ElseIf(n.x.greaterThanEqual(l),()=>{const u=Rg(t.x);s.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(l),()=>{const u=Rg(t.y);s.x.assign(t.x.add(u.mul(2)).add(2)),s.y.assign(t.z.mul(u).sub(2))}),Ft(.125,.25).mul(s).add(Ft(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),sse=Xe(({depthTexture:i,bd3D:e,dp:t,texelSize:n})=>gi(i,nu(e,n.y)).compare(t)),ase=Xe(({depthTexture:i,bd3D:e,dp:t,texelSize:n,shadow:r})=>{const s=$i("radius","float",r).setGroup(In),a=Ft(-1,1).mul(s).mul(n.y);return gi(i,nu(e.add(a.xyy),n.y)).compare(t).add(gi(i,nu(e.add(a.yyy),n.y)).compare(t)).add(gi(i,nu(e.add(a.xyx),n.y)).compare(t)).add(gi(i,nu(e.add(a.yyx),n.y)).compare(t)).add(gi(i,nu(e,n.y)).compare(t)).add(gi(i,nu(e.add(a.xxy),n.y)).compare(t)).add(gi(i,nu(e.add(a.yxy),n.y)).compare(t)).add(gi(i,nu(e.add(a.xxx),n.y)).compare(t)).add(gi(i,nu(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),ose=Xe(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),s=r.length(),a=En("float").setGroup(In).onRenderUpdate(()=>n.camera.near),l=En("float").setGroup(In).onRenderUpdate(()=>n.camera.far),u=$i("bias","float",n).setGroup(In),h=En(n.mapSize).setGroup(In),m=ve(1).toVar();return si(s.sub(l).lessThanEqual(0).and(s.sub(a).greaterThanEqual(0)),()=>{const v=s.sub(a).div(l.sub(a)).toVar();v.addAssign(u);const x=r.normalize(),S=Ft(1).div(h.mul(Ft(4,2)));m.assign(i({depthTexture:e,bd3D:x,dp:v,texelSize:S,shadow:n}))}),m}),h6=new qn,LA=new Et,Am=new Et;class lse extends IB{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===kF?sse:ase}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a}){return ose({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e,l=t.getFrameExtents();Am.copy(t.mapSize),Am.multiply(l),n.setSize(Am.width,Am.height),LA.copy(t.mapSize);const u=s.autoClear,h=s.getClearColor(rse),m=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha),s.clear();const v=t.getViewportCount();for(let x=0;xCt(new lse(i,e)),kB=Xe(({color:i,lightViewPosition:e,cutoffDistance:t,decayExponent:n},r)=>{const s=r.context.lightingModel,a=e.sub(as),l=a.normalize(),u=a.length(),h=OE({lightDistance:u,cutoffDistance:t,decayExponent:n}),m=i.mul(h),v=r.context.reflectedLight;s.direct({lightDirection:l,lightColor:m,reflectedLight:v},r.stack,r)});class cse extends Td{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=En(0).setGroup(In),this.decayExponentNode=En(2).setGroup(In)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return use(this.light)}setup(e){super.setup(e),kB({color:this.colorNode,lightViewPosition:Jy(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const hse=Xe(([i=Br()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),qm=Xe(([i,e,t])=>{const n=ve(t).toVar(),r=ve(e).toVar(),s=Hc(i).toVar();return Ys(s,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ry=Xe(([i,e])=>{const t=Hc(e).toVar(),n=ve(i).toVar();return Ys(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),os=Xe(([i])=>{const e=ve(i).toVar();return we(_u(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),wr=Xe(([i,e])=>{const t=ve(i).toVar();return e.assign(os(t)),t.sub(ve(e))}),fse=Xe(([i,e,t,n,r,s])=>{const a=ve(s).toVar(),l=ve(r).toVar(),u=ve(n).toVar(),h=ve(t).toVar(),m=ve(e).toVar(),v=ve(i).toVar(),x=ve(Ei(1,l)).toVar();return Ei(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),dse=Xe(([i,e,t,n,r,s])=>{const a=ve(s).toVar(),l=ve(r).toVar(),u=Le(n).toVar(),h=Le(t).toVar(),m=Le(e).toVar(),v=Le(i).toVar(),x=ve(Ei(1,l)).toVar();return Ei(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),zB=Zs([fse,dse]),Ase=Xe(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=ve(m).toVar(),x=ve(h).toVar(),S=ve(u).toVar(),w=ve(l).toVar(),N=ve(a).toVar(),C=ve(s).toVar(),E=ve(r).toVar(),O=ve(n).toVar(),U=ve(t).toVar(),I=ve(e).toVar(),j=ve(i).toVar(),z=ve(Ei(1,S)).toVar(),G=ve(Ei(1,x)).toVar();return ve(Ei(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(w.mul(S))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),pse=Xe(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=ve(m).toVar(),x=ve(h).toVar(),S=ve(u).toVar(),w=Le(l).toVar(),N=Le(a).toVar(),C=Le(s).toVar(),E=Le(r).toVar(),O=Le(n).toVar(),U=Le(t).toVar(),I=Le(e).toVar(),j=Le(i).toVar(),z=ve(Ei(1,S)).toVar(),G=ve(Ei(1,x)).toVar();return ve(Ei(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(w.mul(S))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),GB=Zs([Ase,pse]),mse=Xe(([i,e,t])=>{const n=ve(t).toVar(),r=ve(e).toVar(),s=an(i).toVar(),a=an(s.bitAnd(an(7))).toVar(),l=ve(qm(a.lessThan(an(4)),r,n)).toVar(),u=ve(Jn(2,qm(a.lessThan(an(4)),n,r))).toVar();return ry(l,Hc(a.bitAnd(an(1)))).add(ry(u,Hc(a.bitAnd(an(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),gse=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=ve(e).toVar(),l=an(i).toVar(),u=an(l.bitAnd(an(15))).toVar(),h=ve(qm(u.lessThan(an(8)),a,s)).toVar(),m=ve(qm(u.lessThan(an(4)),s,qm(u.equal(an(12)).or(u.equal(an(14))),a,r))).toVar();return ry(h,Hc(u.bitAnd(an(1)))).add(ry(m,Hc(u.bitAnd(an(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Fs=Zs([mse,gse]),vse=Xe(([i,e,t])=>{const n=ve(t).toVar(),r=ve(e).toVar(),s=Z0(i).toVar();return Le(Fs(s.x,r,n),Fs(s.y,r,n),Fs(s.z,r,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),_se=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=ve(e).toVar(),l=Z0(i).toVar();return Le(Fs(l.x,a,s,r),Fs(l.y,a,s,r),Fs(l.z,a,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Jo=Zs([vse,_se]),yse=Xe(([i])=>{const e=ve(i).toVar();return Jn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),xse=Xe(([i])=>{const e=ve(i).toVar();return Jn(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bse=Xe(([i])=>{const e=Le(i).toVar();return Jn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),qB=Zs([yse,bse]),Sse=Xe(([i])=>{const e=Le(i).toVar();return Jn(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),VB=Zs([xse,Sse]),Po=Xe(([i,e])=>{const t=we(e).toVar(),n=an(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(we(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),jB=Xe(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(Po(t,we(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Po(i,we(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Po(e,we(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(Po(t,we(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Po(i,we(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Po(e,we(4))),e.addAssign(i)}),r1=Xe(([i,e,t])=>{const n=an(t).toVar(),r=an(e).toVar(),s=an(i).toVar();return n.bitXorAssign(r),n.subAssign(Po(r,we(14))),s.bitXorAssign(n),s.subAssign(Po(n,we(11))),r.bitXorAssign(s),r.subAssign(Po(s,we(25))),n.bitXorAssign(r),n.subAssign(Po(r,we(16))),s.bitXorAssign(n),s.subAssign(Po(n,we(4))),r.bitXorAssign(s),r.subAssign(Po(s,we(14))),n.bitXorAssign(r),n.subAssign(Po(r,we(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),pa=Xe(([i])=>{const e=an(i).toVar();return ve(e).div(ve(an(we(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),yu=Xe(([i])=>{const e=ve(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),Tse=Xe(([i])=>{const e=we(i).toVar(),t=an(an(1)).toVar(),n=an(an(we(3735928559)).add(t.shiftLeft(an(2))).add(an(13))).toVar();return r1(n.add(an(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),wse=Xe(([i,e])=>{const t=we(e).toVar(),n=we(i).toVar(),r=an(an(2)).toVar(),s=an().toVar(),a=an().toVar(),l=an().toVar();return s.assign(a.assign(l.assign(an(we(3735928559)).add(r.shiftLeft(an(2))).add(an(13))))),s.addAssign(an(n)),a.addAssign(an(t)),r1(s,a,l)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Mse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=we(e).toVar(),s=we(i).toVar(),a=an(an(3)).toVar(),l=an().toVar(),u=an().toVar(),h=an().toVar();return l.assign(u.assign(h.assign(an(we(3735928559)).add(a.shiftLeft(an(2))).add(an(13))))),l.addAssign(an(s)),u.addAssign(an(r)),h.addAssign(an(n)),r1(l,u,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Ese=Xe(([i,e,t,n])=>{const r=we(n).toVar(),s=we(t).toVar(),a=we(e).toVar(),l=we(i).toVar(),u=an(an(4)).toVar(),h=an().toVar(),m=an().toVar(),v=an().toVar();return h.assign(m.assign(v.assign(an(we(3735928559)).add(u.shiftLeft(an(2))).add(an(13))))),h.addAssign(an(l)),m.addAssign(an(a)),v.addAssign(an(s)),jB(h,m,v),h.addAssign(an(r)),r1(h,m,v)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Cse=Xe(([i,e,t,n,r])=>{const s=we(r).toVar(),a=we(n).toVar(),l=we(t).toVar(),u=we(e).toVar(),h=we(i).toVar(),m=an(an(5)).toVar(),v=an().toVar(),x=an().toVar(),S=an().toVar();return v.assign(x.assign(S.assign(an(we(3735928559)).add(m.shiftLeft(an(2))).add(an(13))))),v.addAssign(an(h)),x.addAssign(an(u)),S.addAssign(an(l)),jB(v,x,S),v.addAssign(an(a)),x.addAssign(an(s)),r1(v,x,S)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Xi=Zs([Tse,wse,Mse,Ese,Cse]),Nse=Xe(([i,e])=>{const t=we(e).toVar(),n=we(i).toVar(),r=an(Xi(n,t)).toVar(),s=Z0().toVar();return s.x.assign(r.bitAnd(we(255))),s.y.assign(r.shiftRight(we(8)).bitAnd(we(255))),s.z.assign(r.shiftRight(we(16)).bitAnd(we(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Rse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=we(e).toVar(),s=we(i).toVar(),a=an(Xi(s,r,n)).toVar(),l=Z0().toVar();return l.x.assign(a.bitAnd(we(255))),l.y.assign(a.shiftRight(we(8)).bitAnd(we(255))),l.z.assign(a.shiftRight(we(16)).bitAnd(we(255))),l}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),el=Zs([Nse,Rse]),Dse=Xe(([i])=>{const e=Ft(i).toVar(),t=we().toVar(),n=we().toVar(),r=ve(wr(e.x,t)).toVar(),s=ve(wr(e.y,n)).toVar(),a=ve(yu(r)).toVar(),l=ve(yu(s)).toVar(),u=ve(zB(Fs(Xi(t,n),r,s),Fs(Xi(t.add(we(1)),n),r.sub(1),s),Fs(Xi(t,n.add(we(1))),r,s.sub(1)),Fs(Xi(t.add(we(1)),n.add(we(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Pse=Xe(([i])=>{const e=Le(i).toVar(),t=we().toVar(),n=we().toVar(),r=we().toVar(),s=ve(wr(e.x,t)).toVar(),a=ve(wr(e.y,n)).toVar(),l=ve(wr(e.z,r)).toVar(),u=ve(yu(s)).toVar(),h=ve(yu(a)).toVar(),m=ve(yu(l)).toVar(),v=ve(GB(Fs(Xi(t,n,r),s,a,l),Fs(Xi(t.add(we(1)),n,r),s.sub(1),a,l),Fs(Xi(t,n.add(we(1)),r),s,a.sub(1),l),Fs(Xi(t.add(we(1)),n.add(we(1)),r),s.sub(1),a.sub(1),l),Fs(Xi(t,n,r.add(we(1))),s,a,l.sub(1)),Fs(Xi(t.add(we(1)),n,r.add(we(1))),s.sub(1),a,l.sub(1)),Fs(Xi(t,n.add(we(1)),r.add(we(1))),s,a.sub(1),l.sub(1)),Fs(Xi(t.add(we(1)),n.add(we(1)),r.add(we(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),IE=Zs([Dse,Pse]),Lse=Xe(([i])=>{const e=Ft(i).toVar(),t=we().toVar(),n=we().toVar(),r=ve(wr(e.x,t)).toVar(),s=ve(wr(e.y,n)).toVar(),a=ve(yu(r)).toVar(),l=ve(yu(s)).toVar(),u=Le(zB(Jo(el(t,n),r,s),Jo(el(t.add(we(1)),n),r.sub(1),s),Jo(el(t,n.add(we(1))),r,s.sub(1)),Jo(el(t.add(we(1)),n.add(we(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Use=Xe(([i])=>{const e=Le(i).toVar(),t=we().toVar(),n=we().toVar(),r=we().toVar(),s=ve(wr(e.x,t)).toVar(),a=ve(wr(e.y,n)).toVar(),l=ve(wr(e.z,r)).toVar(),u=ve(yu(s)).toVar(),h=ve(yu(a)).toVar(),m=ve(yu(l)).toVar(),v=Le(GB(Jo(el(t,n,r),s,a,l),Jo(el(t.add(we(1)),n,r),s.sub(1),a,l),Jo(el(t,n.add(we(1)),r),s,a.sub(1),l),Jo(el(t.add(we(1)),n.add(we(1)),r),s.sub(1),a.sub(1),l),Jo(el(t,n,r.add(we(1))),s,a,l.sub(1)),Jo(el(t.add(we(1)),n,r.add(we(1))),s.sub(1),a,l.sub(1)),Jo(el(t,n.add(we(1)),r.add(we(1))),s,a.sub(1),l.sub(1)),Jo(el(t.add(we(1)),n.add(we(1)),r.add(we(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),FE=Zs([Lse,Use]),Bse=Xe(([i])=>{const e=ve(i).toVar(),t=we(os(e)).toVar();return pa(Xi(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Ose=Xe(([i])=>{const e=Ft(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar();return pa(Xi(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Ise=Xe(([i])=>{const e=Le(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar(),r=we(os(e.z)).toVar();return pa(Xi(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Fse=Xe(([i])=>{const e=Mn(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar(),r=we(os(e.z)).toVar(),s=we(os(e.w)).toVar();return pa(Xi(t,n,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),kse=Zs([Bse,Ose,Ise,Fse]),zse=Xe(([i])=>{const e=ve(i).toVar(),t=we(os(e)).toVar();return Le(pa(Xi(t,we(0))),pa(Xi(t,we(1))),pa(Xi(t,we(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Gse=Xe(([i])=>{const e=Ft(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar();return Le(pa(Xi(t,n,we(0))),pa(Xi(t,n,we(1))),pa(Xi(t,n,we(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),qse=Xe(([i])=>{const e=Le(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar(),r=we(os(e.z)).toVar();return Le(pa(Xi(t,n,r,we(0))),pa(Xi(t,n,r,we(1))),pa(Xi(t,n,r,we(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Vse=Xe(([i])=>{const e=Mn(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar(),r=we(os(e.z)).toVar(),s=we(os(e.w)).toVar();return Le(pa(Xi(t,n,r,s,we(0))),pa(Xi(t,n,r,s,we(1))),pa(Xi(t,n,r,s,we(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),HB=Zs([zse,Gse,qse,Vse]),sy=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=we(e).toVar(),l=Le(i).toVar(),u=ve(0).toVar(),h=ve(1).toVar();return Gi(a,()=>{u.addAssign(h.mul(IE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),WB=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=we(e).toVar(),l=Le(i).toVar(),u=Le(0).toVar(),h=ve(1).toVar();return Gi(a,()=>{u.addAssign(h.mul(FE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),jse=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=we(e).toVar(),l=Le(i).toVar();return Ft(sy(l,a,s,r),sy(l.add(Le(we(19),we(193),we(17))),a,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Hse=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=we(e).toVar(),l=Le(i).toVar(),u=Le(WB(l,a,s,r)).toVar(),h=ve(sy(l.add(Le(we(19),we(193),we(17))),a,s,r)).toVar();return Mn(u,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Wse=Xe(([i,e,t,n,r,s,a])=>{const l=we(a).toVar(),u=ve(s).toVar(),h=we(r).toVar(),m=we(n).toVar(),v=we(t).toVar(),x=we(e).toVar(),S=Ft(i).toVar(),w=Le(HB(Ft(x.add(m),v.add(h)))).toVar(),N=Ft(w.x,w.y).toVar();N.subAssign(.5),N.mulAssign(u),N.addAssign(.5);const C=Ft(Ft(ve(x),ve(v)).add(N)).toVar(),E=Ft(C.sub(S)).toVar();return si(l.equal(we(2)),()=>dr(E.x).add(dr(E.y))),si(l.equal(we(3)),()=>Jr(dr(E.x),dr(E.y))),ef(E,E)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$se=Xe(([i,e,t,n,r,s,a,l,u])=>{const h=we(u).toVar(),m=ve(l).toVar(),v=we(a).toVar(),x=we(s).toVar(),S=we(r).toVar(),w=we(n).toVar(),N=we(t).toVar(),C=we(e).toVar(),E=Le(i).toVar(),O=Le(HB(Le(C.add(S),N.add(x),w.add(v)))).toVar();O.subAssign(.5),O.mulAssign(m),O.addAssign(.5);const U=Le(Le(ve(C),ve(N),ve(w)).add(O)).toVar(),I=Le(U.sub(E)).toVar();return si(h.equal(we(2)),()=>dr(I.x).add(dr(I.y)).add(dr(I.z))),si(h.equal(we(3)),()=>Jr(Jr(dr(I.x),dr(I.y)),dr(I.z))),ef(I,I)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),tp=Zs([Wse,$se]),Xse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Ft(i).toVar(),a=we().toVar(),l=we().toVar(),u=Ft(wr(s.x,a),wr(s.y,l)).toVar(),h=ve(1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:m})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:v})=>{const x=ve(tp(u,m,v,a,l,r,n)).toVar();h.assign(oo(h,x))})}),si(n.equal(we(0)),()=>{h.assign(Ou(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Yse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Ft(i).toVar(),a=we().toVar(),l=we().toVar(),u=Ft(wr(s.x,a),wr(s.y,l)).toVar(),h=Ft(1e6,1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:m})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:v})=>{const x=ve(tp(u,m,v,a,l,r,n)).toVar();si(x.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.y.assign(x)})})}),si(n.equal(we(0)),()=>{h.assign(Ou(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Qse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Ft(i).toVar(),a=we().toVar(),l=we().toVar(),u=Ft(wr(s.x,a),wr(s.y,l)).toVar(),h=Le(1e6,1e6,1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:m})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:v})=>{const x=ve(tp(u,m,v,a,l,r,n)).toVar();si(x.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(x)}).ElseIf(x.lessThan(h.z),()=>{h.z.assign(x)})})}),si(n.equal(we(0)),()=>{h.assign(Ou(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Kse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Le(i).toVar(),a=we().toVar(),l=we().toVar(),u=we().toVar(),h=Le(wr(s.x,a),wr(s.y,l),wr(s.z,u)).toVar(),m=ve(1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:v})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:x})=>{Gi({start:-1,end:we(1),name:"z",condition:"<="},({z:S})=>{const w=ve(tp(h,v,x,S,a,l,u,r,n)).toVar();m.assign(oo(m,w))})})}),si(n.equal(we(0)),()=>{m.assign(Ou(m))}),m}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Zse=Zs([Xse,Kse]),Jse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Le(i).toVar(),a=we().toVar(),l=we().toVar(),u=we().toVar(),h=Le(wr(s.x,a),wr(s.y,l),wr(s.z,u)).toVar(),m=Ft(1e6,1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:v})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:x})=>{Gi({start:-1,end:we(1),name:"z",condition:"<="},({z:S})=>{const w=ve(tp(h,v,x,S,a,l,u,r,n)).toVar();si(w.lessThan(m.x),()=>{m.y.assign(m.x),m.x.assign(w)}).ElseIf(w.lessThan(m.y),()=>{m.y.assign(w)})})})}),si(n.equal(we(0)),()=>{m.assign(Ou(m))}),m}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),eae=Zs([Yse,Jse]),tae=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Le(i).toVar(),a=we().toVar(),l=we().toVar(),u=we().toVar(),h=Le(wr(s.x,a),wr(s.y,l),wr(s.z,u)).toVar(),m=Le(1e6,1e6,1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:v})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:x})=>{Gi({start:-1,end:we(1),name:"z",condition:"<="},({z:S})=>{const w=ve(tp(h,v,x,S,a,l,u,r,n)).toVar();si(w.lessThan(m.x),()=>{m.z.assign(m.y),m.y.assign(m.x),m.x.assign(w)}).ElseIf(w.lessThan(m.y),()=>{m.z.assign(m.y),m.y.assign(w)}).ElseIf(w.lessThan(m.z),()=>{m.z.assign(w)})})})}),si(n.equal(we(0)),()=>{m.assign(Ou(m))}),m}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nae=Zs([Qse,tae]),iae=Xe(([i])=>{const e=i.y,t=i.z,n=Le().toVar();return si(e.lessThan(1e-4),()=>{n.assign(Le(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(_u(r)).mul(6).toVar();const s=we(ZM(r)),a=r.sub(ve(s)),l=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),h=t.mul(e.mul(a.oneMinus()).oneMinus());si(s.equal(we(0)),()=>{n.assign(Le(t,h,l))}).ElseIf(s.equal(we(1)),()=>{n.assign(Le(u,t,l))}).ElseIf(s.equal(we(2)),()=>{n.assign(Le(l,t,h))}).ElseIf(s.equal(we(3)),()=>{n.assign(Le(l,u,t))}).ElseIf(s.equal(we(4)),()=>{n.assign(Le(h,l,t))}).Else(()=>{n.assign(Le(t,l,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),rae=Xe(([i])=>{const e=Le(i).toVar(),t=ve(e.x).toVar(),n=ve(e.y).toVar(),r=ve(e.z).toVar(),s=ve(oo(t,oo(n,r))).toVar(),a=ve(Jr(t,Jr(n,r))).toVar(),l=ve(a.sub(s)).toVar(),u=ve().toVar(),h=ve().toVar(),m=ve().toVar();return m.assign(a),si(a.greaterThan(0),()=>{h.assign(l.div(a))}).Else(()=>{h.assign(0)}),si(h.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{si(t.greaterThanEqual(a),()=>{u.assign(n.sub(r).div(l))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(ls(2,r.sub(t).div(l)))}).Else(()=>{u.assign(ls(4,t.sub(n).div(l)))}),u.mulAssign(1/6),si(u.lessThan(0),()=>{u.addAssign(1)})}),Le(u,h,m)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),sae=Xe(([i])=>{const e=Le(i).toVar(),t=BM(HM(e,Le(.04045))).toVar(),n=Le(e.div(12.92)).toVar(),r=Le(Fl(Jr(e.add(Le(.055)),Le(0)).div(1.055),Le(2.4))).toVar();return zi(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),$B=(i,e)=>{i=ve(i),e=ve(e);const t=Ft(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return $c(i.sub(t),i.add(t),e)},XB=(i,e,t,n)=>zi(i,e,t[n].clamp()),aae=(i,e,t=Br())=>XB(i,e,t,"x"),oae=(i,e,t=Br())=>XB(i,e,t,"y"),YB=(i,e,t,n,r)=>zi(i,e,$B(t,n[r])),lae=(i,e,t,n=Br())=>YB(i,e,t,n,"x"),uae=(i,e,t,n=Br())=>YB(i,e,t,n,"y"),cae=(i=1,e=0,t=Br())=>t.mul(i).add(e),hae=(i,e=1)=>(i=ve(i),i.abs().pow(e).mul(i.sign())),fae=(i,e=1,t=.5)=>ve(i).sub(t).mul(e).add(t),dae=(i=Br(),e=1,t=0)=>IE(i.convert("vec2|vec3")).mul(e).add(t),Aae=(i=Br(),e=1,t=0)=>FE(i.convert("vec2|vec3")).mul(e).add(t),pae=(i=Br(),e=1,t=0)=>(i=i.convert("vec2|vec3"),Mn(FE(i),IE(i.add(Ft(19,73)))).mul(e).add(t)),mae=(i=Br(),e=1)=>Zse(i.convert("vec2|vec3"),e,we(1)),gae=(i=Br(),e=1)=>eae(i.convert("vec2|vec3"),e,we(1)),vae=(i=Br(),e=1)=>nae(i.convert("vec2|vec3"),e,we(1)),_ae=(i=Br())=>kse(i.convert("vec2|vec3")),yae=(i=Br(),e=3,t=2,n=.5,r=1)=>sy(i,we(e),t,n).mul(r),xae=(i=Br(),e=3,t=2,n=.5,r=1)=>jse(i,we(e),t,n).mul(r),bae=(i=Br(),e=3,t=2,n=.5,r=1)=>WB(i,we(e),t,n).mul(r),Sae=(i=Br(),e=3,t=2,n=.5,r=1)=>Hse(i,we(e),t,n).mul(r),Tae=Xe(([i,e,t])=>{const n=Wc(i).toVar("nDir"),r=Ei(ve(.5).mul(e.sub(t)),Fc).div(n).toVar("rbmax"),s=Ei(ve(-.5).mul(e.sub(t)),Fc).div(n).toVar("rbmin"),a=Le().toVar("rbminmax");a.x=n.x.greaterThan(ve(0)).select(r.x,s.x),a.y=n.y.greaterThan(ve(0)).select(r.y,s.y),a.z=n.z.greaterThan(ve(0)).select(r.z,s.z);const l=oo(oo(a.x,a.y),a.z).toVar("correction");return Fc.add(n.mul(l)).toVar("boxIntersection").sub(t)}),QB=Xe(([i,e])=>{const t=i.x,n=i.y,r=i.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(Jn(t,t).sub(Jn(n,n)))),s});var $=Object.freeze({__proto__:null,BRDF_GGX:QT,BRDF_Lambert:md,BasicShadowFilter:LB,Break:NU,Continue:Mee,DFGApprox:xE,D_GGX:jU,Discard:S9,EPSILON:NL,F_Schlick:G0,Fn:Xe,INFINITY:gJ,If:si,Loop:Gi,NodeAccess:da,NodeShaderStage:kT,NodeType:$Z,NodeUpdateType:Zn,PCFShadowFilter:UB,PCFSoftShadowFilter:BB,PI:Z_,PI2:vJ,Return:LJ,Schlick_to_F0:WU,ScriptableNodeResources:i_,ShaderNode:Om,TBNViewMatrix:Zf,VSMShadowFilter:OB,V_GGX_SmithCorrelated:VU,abs:dr,acesFilmicToneMapping:TB,acos:BL,add:ls,addMethodChaining:gt,addNodeElement:BJ,agxToneMapping:wB,all:WM,alphaT:Y_,and:vL,anisotropy:Bh,anisotropyB:ad,anisotropyT:Im,any:RL,append:KP,arrayBuffer:fJ,asin:UL,assign:hL,atan:YM,atan2:t9,atomicAdd:Lre,atomicAnd:Ire,atomicFunc:Jc,atomicMax:Bre,atomicMin:Ore,atomicOr:Fre,atomicStore:Pre,atomicSub:Ure,atomicXor:kre,attenuationColor:qM,attenuationDistance:GM,attribute:Eu,attributeArray:Mie,backgroundBlurriness:fB,backgroundIntensity:nw,backgroundRotation:dB,batch:MU,billboarding:sie,bitAnd:bL,bitNot:SL,bitOr:TL,bitXor:wL,bitangentGeometry:aee,bitangentLocal:oee,bitangentView:G9,bitangentWorld:lee,bitcast:_J,blendBurn:mB,blendColor:Fie,blendDodge:gB,blendOverlay:_B,blendScreen:vB,blur:JU,bool:Hc,buffer:Kg,bufferAttribute:Yg,bumpMap:H9,burn:kie,bvec2:eL,bvec3:BM,bvec4:rL,bypass:_9,cache:km,call:fL,cameraFar:Fh,cameraNear:Ih,cameraNormalMatrix:GJ,cameraPosition:E9,cameraProjectionMatrix:bd,cameraProjectionMatrixInverse:kJ,cameraViewMatrix:ho,cameraWorldMatrix:zJ,cbrt:YL,cdl:$ie,ceil:Iy,checker:hse,cineonToneMapping:SB,clamp:Mu,clearcoat:X_,clearcoatRoughness:Eg,code:Ky,color:ZP,colorSpaceToWorking:rE,colorToDirection:tte,compute:v9,cond:n9,context:zy,convert:aL,convertColorSpace:TJ,convertToTexture:vie,cos:Cc,cross:ky,cubeTexture:z0,dFdx:QM,dFdy:KM,dashSize:Qv,defaultBuildStages:zT,defaultShaderStages:HP,defined:Sg,degrees:PL,deltaTime:uB,densityFog:mre,densityFogFactor:NE,depth:gE,depthPass:Jie,difference:HL,diffuseColor:Oi,directPointLight:kB,directionToColor:OU,dispersion:VM,distance:jL,div:Gl,dodge:zie,dot:ef,drawIndex:SU,dynamicBufferAttribute:g9,element:sL,emissive:jT,equal:dL,equals:qL,equirectUV:vE,exp:$M,exp2:k0,expression:Qh,faceDirection:Qg,faceForward:nE,faceforward:yJ,float:ve,floor:_u,fog:Pg,fract:Zc,frameGroup:uL,frameId:Yne,frontFacing:D9,fwidth:zL,gain:qne,gapSize:HT,getConstNodeType:QP,getCurrentStack:UM,getDirection:KU,getDistanceAttenuation:OE,getGeometryRoughness:qU,getNormalFromDepth:yie,getParallaxCorrectNormal:Tae,getRoughness:yE,getScreenPosition:_ie,getShIrradianceAt:QB,getTextureIndex:oB,getViewPosition:VA,glsl:lre,glslFn:ure,grayscale:Vie,greaterThan:HM,greaterThanEqual:gL,hash:Gne,highpModelNormalViewMatrix:ZJ,highpModelViewMatrix:KJ,hue:Wie,instance:xee,instanceIndex:t1,instancedArray:Eie,instancedBufferAttribute:J_,instancedDynamicBufferAttribute:WT,instancedMesh:wU,int:we,inverseSqrt:XM,inversesqrt:xJ,invocationLocalIndex:yee,invocationSubgroupIndex:_ee,ior:Fm,iridescence:By,iridescenceIOR:FM,iridescenceThickness:kM,ivec2:ws,ivec3:tL,ivec4:nL,js:are,label:r9,length:Ic,lengthSq:QL,lessThan:pL,lessThanEqual:mL,lightPosition:PE,lightProjectionUV:DB,lightShadowMatrix:DE,lightTargetDirection:LE,lightTargetPosition:PB,lightViewPosition:Jy,lightingContext:DU,lights:qre,linearDepth:ty,linearToneMapping:xB,localId:bre,log:Oy,log2:vu,logarithmicDepthToViewZ:zee,loop:Eee,luminance:EE,mat2:Ly,mat3:_a,mat4:sd,matcapUV:tB,materialAO:xU,materialAlphaTest:W9,materialAnisotropy:oU,materialAnisotropyVector:qA,materialAttenuationColor:pU,materialAttenuationDistance:AU,materialClearcoat:tU,materialClearcoatNormal:iU,materialClearcoatRoughness:nU,materialColor:$9,materialDispersion:yU,materialEmissive:Y9,materialIOR:dU,materialIridescence:lU,materialIridescenceIOR:uU,materialIridescenceThickness:cU,materialLightMap:cE,materialLineDashOffset:_U,materialLineDashSize:gU,materialLineGapSize:vU,materialLineScale:mU,materialLineWidth:mee,materialMetalness:J9,materialNormal:eU,materialOpacity:uE,materialPointWidth:gee,materialReference:Pc,materialReflectivity:Jv,materialRefractionRatio:U9,materialRotation:rU,materialRoughness:Z9,materialSheen:sU,materialSheenRoughness:aU,materialShininess:X9,materialSpecular:Q9,materialSpecularColor:K9,materialSpecularIntensity:YT,materialSpecularStrength:zm,materialThickness:fU,materialTransmission:hU,max:Jr,maxMipLevel:M9,mediumpModelViewMatrix:R9,metalness:Mg,min:oo,mix:zi,mixElement:JL,mod:JM,modInt:jM,modelDirection:WJ,modelNormalMatrix:N9,modelPosition:$J,modelScale:XJ,modelViewMatrix:J0,modelViewPosition:YJ,modelViewProjection:hE,modelWorldMatrix:nl,modelWorldMatrixInverse:QJ,morphReference:RU,mrt:lB,mul:Jn,mx_aastep:$B,mx_cell_noise_float:_ae,mx_contrast:fae,mx_fractal_noise_float:yae,mx_fractal_noise_vec2:xae,mx_fractal_noise_vec3:bae,mx_fractal_noise_vec4:Sae,mx_hsvtorgb:iae,mx_noise_float:dae,mx_noise_vec3:Aae,mx_noise_vec4:pae,mx_ramplr:aae,mx_ramptb:oae,mx_rgbtohsv:rae,mx_safepower:hae,mx_splitlr:lae,mx_splittb:uae,mx_srgb_texture_to_lin_rec709:sae,mx_transform_uv:cae,mx_worley_noise_float:mae,mx_worley_noise_vec2:gae,mx_worley_noise_vec3:vae,negate:OL,neutralToneMapping:MB,nodeArray:rd,nodeImmutable:Jt,nodeObject:Ct,nodeObjects:Hg,nodeProxy:vt,normalFlat:P9,normalGeometry:qy,normalLocal:lo,normalMap:XT,normalView:ll,normalWorld:Vy,normalize:Wc,not:yL,notEqual:AL,numWorkgroups:yre,objectDirection:qJ,objectGroup:IM,objectPosition:C9,objectScale:jJ,objectViewPosition:HJ,objectWorldMatrix:VJ,oneMinus:IL,or:_L,orthographicDepthToViewZ:kee,oscSawtooth:nie,oscSine:Jne,oscSquare:eie,oscTriangle:tie,output:Ng,outputStruct:kne,overlay:qie,overloadingFn:Zs,parabola:tw,parallaxDirection:V9,parallaxUV:cee,parameter:Ine,pass:Kie,passTexture:Zie,pcurve:Vne,perspectiveDepthToViewZ:pE,pmremTexture:bE,pointUV:Die,pointWidth:AJ,positionGeometry:Gy,positionLocal:Zr,positionPrevious:ey,positionView:as,positionViewDirection:yr,positionWorld:Fc,positionWorldDirection:sE,posterize:Yie,pow:Fl,pow2:eE,pow3:WL,pow4:$L,property:cL,radians:DL,rand:ZL,range:vre,rangeFog:pre,rangeFogFactor:CE,reciprocal:kL,reference:$i,referenceBuffer:$T,reflect:VL,reflectVector:I9,reflectView:B9,reflector:die,refract:tE,refractVector:F9,refractView:O9,reinhardToneMapping:bB,remainder:CL,remap:x9,remapClamp:b9,renderGroup:In,renderOutput:T9,rendererReference:A9,rotate:SE,rotateUV:iie,roughness:au,round:FL,rtt:hB,sRGBTransferEOTF:l9,sRGBTransferOETF:u9,sampler:FJ,saturate:KL,saturation:jie,screen:Gie,screenCoordinate:n1,screenSize:Dg,screenUV:Ru,scriptable:Are,scriptableValue:n_,select:Ys,setCurrentStack:Tg,shaderStages:GT,shadow:FB,shadowPositionWorld:BE,sharedUniformGroup:OM,sheen:Kf,sheenRoughness:Uy,shiftLeft:ML,shiftRight:EL,shininess:Q_,sign:Rg,sin:Uo,sinc:jne,skinning:Tee,skinningReference:CU,smoothstep:$c,smoothstepElement:e9,specularColor:Ha,specularF90:Cg,spherizeUV:rie,split:dJ,spritesheetUV:lie,sqrt:Ou,stack:e_,step:Fy,storage:Qy,storageBarrier:Mre,storageObject:wie,storageTexture:AB,string:hJ,sub:Ei,subgroupIndex:vee,subgroupSize:Sre,tan:LL,tangentGeometry:Wy,tangentLocal:Zg,tangentView:Jg,tangentWorld:z9,temp:a9,texture:gi,texture3D:fne,textureBarrier:Ere,textureBicubic:YU,textureCubeUV:ZU,textureLoad:Yr,textureSize:jh,textureStore:Lie,thickness:zM,time:Sd,timerDelta:Zne,timerGlobal:Kne,timerLocal:Qne,toOutputColorSpace:c9,toWorkingColorSpace:h9,toneMapping:p9,toneMappingExposure:m9,toonOutlinePass:tre,transformDirection:XL,transformNormal:L9,transformNormalToView:aE,transformedBentNormalView:j9,transformedBitangentView:q9,transformedBitangentWorld:uee,transformedClearcoatNormalView:JA,transformedNormalView:Kr,transformedNormalWorld:jy,transformedTangentView:lE,transformedTangentWorld:see,transmission:K_,transpose:GL,triNoise3D:Wne,triplanarTexture:cie,triplanarTextures:cB,trunc:ZM,tslFn:cJ,uint:an,uniform:En,uniformArray:Dc,uniformGroup:lL,uniforms:nee,userData:Bie,uv:Br,uvec2:JP,uvec3:Z0,uvec4:iL,varying:co,varyingProperty:wg,vec2:Ft,vec3:Le,vec4:Mn,vectorComponents:yd,velocity:Iie,vertexColor:Nie,vertexIndex:bU,vertexStage:o9,vibrance:Hie,viewZToLogarithmicDepth:mE,viewZToOrthographicDepth:l0,viewZToPerspectiveDepth:UU,viewport:fE,viewportBottomLeft:Oee,viewportCoordinate:LU,viewportDepthTexture:AE,viewportLinearDepth:Gee,viewportMipTexture:dE,viewportResolution:Uee,viewportSafeUV:aie,viewportSharedTexture:ete,viewportSize:PU,viewportTexture:Iee,viewportTopLeft:Bee,viewportUV:Lee,wgsl:ore,wgslFn:cre,workgroupArray:Rre,workgroupBarrier:wre,workgroupId:xre,workingToColorSpace:f9,xor:xL});const Mc=new TE;class wae extends tf{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(s===null)r._clearColor.getRGB(Mc,Io),Mc.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(Mc,Io),Mc.a=1,a=!0;else if(s.isNode===!0){const l=this.get(e),u=s;Mc.copy(r._clearColor);let h=l.backgroundMesh;if(h===void 0){const v=zy(Mn(u).mul(nw),{getUV:()=>dB.mul(Vy),getTextureLevel:()=>fB});let x=hE;x=x.setZ(x.w);const S=new es;S.name="Background.material",S.side=gr,S.depthTest=!1,S.depthWrite=!1,S.fog=!1,S.lights=!1,S.vertexNode=x,S.colorNode=v,l.backgroundMeshNode=v,l.backgroundMesh=h=new qi(new Bu(1,32,32),S),h.frustumCulled=!1,h.name="Background.mesh",h.onBeforeRender=function(w,N,C){this.matrixWorld.copyPosition(C.matrixWorld)}}const m=u.getCacheKey();l.backgroundCacheKey!==m&&(l.backgroundMeshNode.node=Mn(u).mul(nw),l.backgroundMeshNode.needsUpdate=!0,h.material.needsUpdate=!0,l.backgroundCacheKey=m),t.unshift(h,h.geometry,h.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",s);if(r.autoClear===!0||a===!0){const l=n.clearColorValue;l.r=Mc.r,l.g=Mc.g,l.b=Mc.b,l.a=Mc.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(l.r*=l.a,l.g*=l.a,l.b*=l.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let Mae=0;class iw{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=Mae++}}class Eae{constructor(e,t,n,r,s,a,l,u,h,m=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=m,this.nodeAttributes=r,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=l,this.updateAfterNodes=u,this.monitor=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new iw(t.name,[],t.index,t);e.push(r);for(const s of t.bindings)r.bindings.push(s.clone())}else e.push(t);return e}}class f6{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class Cae{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class KB{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Nae extends KB{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Rae{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Dae=0;class uS{constructor(e=null){this.id=Dae++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Pae extends Un{static get type(){return"StructTypeNode"}constructor(e,t){super(),this.name=e,this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class wd{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class Lae extends wd{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Uae extends wd{constructor(e,t=new Et){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Bae extends wd{constructor(e,t=new de){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Oae extends wd{constructor(e,t=new qn){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Iae extends wd{constructor(e,t=new mn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Fae extends wd{constructor(e,t=new Qn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kae extends wd{constructor(e,t=new Xn){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class zae extends Lae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Gae extends Uae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qae extends Bae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vae extends Oae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jae extends Iae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Hae extends Fae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Wae extends kae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const e0=4,d6=[.125,.215,.35,.446,.526,.582],jf=20,cS=new Gg(-1,1,1,-1,0,1),$ae=new Ea(90,1),A6=new mn;let hS=null,fS=0,dS=0;const zf=(1+Math.sqrt(5))/2,UA=1/zf,p6=[new de(-zf,UA,0),new de(zf,UA,0),new de(-UA,0,zf),new de(UA,0,zf),new de(0,zf,-UA),new de(0,zf,UA),new de(-1,1,-1),new de(1,1,-1),new de(-1,1,1),new de(1,1,1)],Xae=[3,1,5,0,4,2],AS=KU(Br(),Eu("faceIndex")).normalize(),kE=Le(AS.x,AS.y,AS.z);class Yae{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,s=null){if(this._setSize(256),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const l=s||this._allocateTargets();return this.fromSceneAsync(e,t,n,r,l),l}hS=this._renderer.getRenderTarget(),fS=this._renderer.getActiveCubeFace(),dS=this._renderer.getActiveMipmapLevel();const a=s||this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,n,r,a),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}async fromSceneAsync(e,t=0,n=.1,r=100,s=null){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=g6(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=v6(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===sl||e.mapping===al?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?N:0,N,N),u.render(e,s)}u.autoClear=h,e.background=x}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===sl||e.mapping===al;r?this._cubemapMaterial===null&&(this._cubemapMaterial=g6(e)):this._equirectMaterial===null&&(this._equirectMaterial=v6(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const l=this._cubeSize;vv(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,cS)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sjf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${jf}`);const E=[];let O=0;for(let G=0;GU-e0?r-U+e0:0),z=4*(this._cubeSize-I);vv(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,cS)}}function Qae(i){const e=[],t=[],n=[],r=[];let s=i;const a=i-e0+1+d6.length;for(let l=0;li-e0?h=d6[l-i+e0-1]:l===0&&(h=0),n.push(h);const m=1/(u-2),v=-m,x=1+m,S=[v,v,x,v,x,x,v,v,x,x,v,x],w=6,N=6,C=3,E=2,O=1,U=new Float32Array(C*N*w),I=new Float32Array(E*N*w),j=new Float32Array(O*N*w);for(let G=0;G2?0:-1,V=[W,q,0,W+2/3,q,0,W+2/3,q+1,0,W,q,0,W+2/3,q+1,0,W,q+1,0],Y=Xae[G];U.set(V,C*N*Y),I.set(S,E*N*Y);const te=[Y,Y,Y,Y,Y,Y];j.set(te,O*N*Y)}const z=new Ji;z.setAttribute("position",new Lr(U,C)),z.setAttribute("uv",new Lr(I,E)),z.setAttribute("faceIndex",new Lr(j,O)),e.push(z),r.push(new qi(z,null)),s>e0&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:r}}function m6(i,e,t){const n=new Zh(i,e,t);return n.texture.mapping=ld,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function vv(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function zE(i){const e=new es;return e.depthTest=!1,e.depthWrite=!1,e.blending=no,e.name=`PMREM_${i}`,e}function Kae(i,e,t){const n=Dc(new Array(jf).fill(0)),r=En(new de(0,1,0)),s=En(0),a=ve(jf),l=En(0),u=En(1),h=gi(null),m=En(0),v=ve(1/e),x=ve(1/t),S=ve(i),w={n:a,latitudinal:l,weights:n,poleAxis:r,outputDirection:kE,dTheta:s,samples:u,envMap:h,mipInt:m,CUBEUV_TEXEL_WIDTH:v,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:S},N=zE("blur");return N.uniforms=w,N.fragmentNode=JU({...w,latitudinal:l.equal(1)}),N}function g6(i){const e=zE("cubemap");return e.fragmentNode=z0(i,kE),e}function v6(i){const e=zE("equirect");return e.fragmentNode=gi(i,vE(kE),0),e}const _6=new WeakMap,Zae=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),_v=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class ZB{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=e_(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new uS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=_6.get(this.renderer);return e===void 0&&(e=new Du,_6.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Zh(e,t,n)}createCubeRenderTarget(e,t){return new IU(e,t)}createPMREMGenerator(){return new Yae(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let s=!0;for(const l of t)r.push(l),s=s&&l.groupNode.shared!==!0;let a;return s?(a=n.get(r),a===void 0&&(a=new iw(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new iw(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of GT)for(const s in n[r]){const a=n[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${_v(t.r)}, ${_v(t.g)}, ${_v(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const s of n)if(s.name===e)return s;const r=new f6(e,t);return n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===ks)return"int";if(t===Ir)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const n=FP(e);return(t==="float"?"":t[0])+n}getTypeFromArray(e){return Zae.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof H7)&&s!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=e_(this.stack),this.stacks.push(UM()||this.stack),Tg(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Tg(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);return r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let r=n.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new f6("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e,n);let s=r.structType;if(s===void 0){const a=this.structs.index++;s=new Pae("StructType"+a,t),this.structs[n].push(s),r.structType=s}return s}getUniformFromNode(e,t,n=this.shaderStage,r=null){const s=this.getDataFromNode(e,n,this.globalCache);let a=s.uniform;if(a===void 0){const l=this.uniforms.index++;a=new Cae(r||"nodeUniform"+l,t,e),this.uniforms[n].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const l=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+l.length),a=new KB(t,n),l.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,l=a.length;t===null&&(t="nodeVarying"+l),s=new Nae(t,n),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[n]||(this.codes[n]=[]),l=a.length;s=new Rae("nodeCode"+l,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const l of n)this.addLineFlowCode(l)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; +`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){const t=new EB,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const l=Object.values(this);return{next:()=>({value:l[a],done:a++>=l.length})}}};for(const a of t.inputs)n[a.name]=new sB(a.type,a.name);e.layout=null;const r=e.call(n),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,s=this.cache,a=this.buildStage,l=this.stack,u={code:""};this.flow=u,this.vars={},this.cache=new uS,this.stack=e_();for(const h of zT)this.setBuildStage(h),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.cache=s,this.stack=l,this.setBuildStage(a),u}getFunctionOperator(){return null}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const s=this.shaderStage;this.setShaderStage(e);const a=this.flowChildNode(t,n);return r!==null&&(a.code+=`${this.tab+r} = ${a.result}; +`),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(s),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+` +`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new es),r.build(this)}else this.addFlow("compute",e);for(const r of zT){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of GT){this.setShaderStage(s);const a=this.flowNodes[s];for(const l of a)r==="generate"?this.flowNode(l):l.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new zae(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Gae(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new qae(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new Vae(e);if(t==="color")return new jae(e);if(t==="mat3")return new Hae(e);if(t==="mat4")return new Wae(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),s=this.getTypeLength(n);return r===16&&s===9?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&s===4?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:r>4||s>4||s===0?e:r===s?`${this.getType(n)}( ${e} )`:r>s?this.format(`${e}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(t)),n):s===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${W0} - Node System +`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class y6{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Zn.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(n,this.frameId)}else if(t===Zn.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(n,this.renderId)}else t===Zn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Zn.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(n,this.frameId)}else if(t===Zn.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(n,this.renderId)}else t===Zn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===Zn.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.frameId&&e.update(this)!==!1&&r.set(n,this.frameId)}else if(t===Zn.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.renderId&&e.update(this)!==!1&&r.set(n,this.renderId)}else t===Zn.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class GE{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}GE.isNodeFunctionInput=!0;class Jae extends Td{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,r=LE(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:s},e.stack,e)}}const pS=new Xn,yv=new Xn;let pm=null;class eoe extends Td{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=En(new de).setGroup(In),this.halfWidth=En(new de).setGroup(In),this.updateType=Zn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;yv.identity(),pS.copy(t.matrixWorld),pS.premultiply(n),yv.extractRotation(pS),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(yv),this.halfHeight.value.applyMatrix4(yv)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=gi(pm.LTC_FLOAT_1),n=gi(pm.LTC_FLOAT_2)):(t=gi(pm.LTC_HALF_1),n=gi(pm.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,l=Jy(s),u=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:l,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:u,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){pm=e}}class JB extends Td{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=En(0).setGroup(In),this.penumbraCosNode=En(0).setGroup(In),this.cutoffDistanceNode=En(0).setGroup(In),this.decayExponentNode=En(0).setGroup(In)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return $c(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,l=Jy(a).sub(as),u=l.normalize(),h=u.dot(LE(a)),m=this.getSpotAttenuation(h),v=l.length(),x=OE({lightDistance:v,cutoffDistance:r,decayExponent:s});let S=n.mul(m).mul(x);if(a.map){const N=DB(a),C=gi(a.map,N.xy).onRenderUpdate(()=>a.map);S=N.mul(2).sub(1).abs().lessThan(1).all().select(S.mul(C),S)}const w=e.context.reflectedLight;t.direct({lightDirection:u,lightColor:S,reflectedLight:w},e.stack,e)}}class toe extends JB{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);n=gi(t,Ft(r,0),0).r}else n=super.getSpotAttenuation(e);return n}}class noe extends Td{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class ioe extends Td{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=PE(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=En(new mn).setGroup(In)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,a=ll.dot(r).mul(.5).add(.5),l=zi(n,t,a);e.context.irradiance.addAssign(l)}}class roe extends Td{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new de);this.lightProbe=Dc(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=QB(Vy,this.lightProbe);e.context.irradiance.addAssign(t)}}class eO{parseFunction(){console.warn("Abstract function.")}}class qE{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn("Abstract function.")}}qE.isNodeFunction=!0;const soe=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,aoe=/[a-z_0-9]+/ig,x6="#pragma main",ooe=i=>{i=i.trim();const e=i.indexOf(x6),t=e!==-1?i.slice(e+x6.length):i,n=t.match(soe);if(n!==null&&n.length===5){const r=n[4],s=[];let a=null;for(;(a=aoe.exec(r))!==null;)s.push(a);const l=[];let u=0;for(;u0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Wh||n.mapping===$h||n.mapping===ld){if(e.backgroundBlurriness>0||n.mapping===ld)return bE(n);{let a;return n.isCubeTexture===!0?a=z0(n):a=gi(n),kU(a)}}else{if(n.isTexture===!0)return gi(n,Ru.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=s.get(t);return(a===void 0||r)&&(a=n(),s.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const s=$i("color","color",n).setGroup(In),a=$i("density","float",n).setGroup(In);return Pg(s,NE(a))}else if(n.isFog){const s=$i("color","color",n).setGroup(In),a=$i("near","float",n).setGroup(In),l=$i("far","float",n).setGroup(In);return Pg(s,CE(a,l))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return z0(n);if(n.isTexture===!0)return gi(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,s=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=s,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return b6.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=gi(e,Ru).renderOutput(t.toneMapping,t.currentColorSpace);return b6.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new y6,this.nodeBuilderCache=new Map,this.cacheLib={}}}const mS=new iu;class ay{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Qn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const r=e.length;for(let s=0;s{await this.compileAsync(v,x);const w=this._renderLists.get(v,x),N=this._renderContexts.get(v,x,this._renderTarget),C=v.overrideMaterial||S.material,E=this._objects.get(S,C,v,x,w.lightsNode,N,N.clippingContext),{fragmentShader:O,vertexShader:U}=E.getNodeBuilderState();return{fragmentShader:O,vertexShader:U}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),await n.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new coe(this,n),this._animation=new dne(this._nodes,this.info),this._attributes=new yne(n),this._background=new wae(this,this._nodes),this._geometries=new bne(this._attributes,this.info),this._textures=new One(this,n,this.info),this._pipelines=new Ene(n,this._nodes),this._bindings=new Cne(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new gne(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new Dne(this.lighting),this._bundles=new foe,this._renderContexts=new Une,this._animation.start(),this._initialized=!0,e()}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,s=r.renderId,a=this._currentRenderContext,l=this._currentRenderObjectFunction,u=this._compilationPromises,h=e.isScene===!0?e:S6;n===null&&(n=e);const m=this._renderTarget,v=this._renderContexts.get(n,t,m),x=this._activeMipmapLevel,S=[];this._currentRenderContext=v,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=S,r.renderId++,r.update(),v.depth=this.depth,v.stencil=this.stencil,v.clippingContext||(v.clippingContext=new ay),v.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,m);const w=this._renderLists.get(e,t);if(w.begin(),this._projectObject(e,t,0,w,v.clippingContext),n!==e&&n.traverseVisible(function(U){U.isLight&&U.layers.test(t.layers)&&w.pushLight(U)}),w.finish(),m!==null){this._textures.updateRenderTarget(m,x);const U=this._textures.get(m);v.textures=U.textures,v.depthTexture=U.depthTexture}else v.textures=null,v.depthTexture=null;this._background.update(h,w,v);const N=w.opaque,C=w.transparent,E=w.transparentDoublePass,O=w.lightsNode;this.opaque===!0&&N.length>0&&this._renderObjects(N,t,h,O),this.transparent===!0&&C.length>0&&this._renderTransparents(C,E,t,h,O),r.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=l,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(S)}async renderAsync(e,t){this._initialized===!1&&await this.init();const n=this._renderScene(e,t);await this.backend.resolveTimestampAsync(n,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: + +Message: ${e.message}`;e.reason&&(t+=` +Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:s,renderList:a}=e,l=this._currentRenderContext,u=this._bundles.get(r,s),h=this.backend.get(u);h.renderContexts===void 0&&(h.renderContexts=new Set);const m=r.version!==h.version,v=h.renderContexts.has(l)===!1||m;if(h.renderContexts.add(l),v){this.backend.beginBundle(l),(h.renderObjects===void 0||m)&&(h.renderObjects=[]),this._currentRenderBundle=u;const x=a.opaque;this.opaque===!0&&x.length>0&&this._renderObjects(x,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(l,u),h.version=r.version}else{const{renderObjects:x}=h;for(let S=0,w=x.length;S>=x,w.viewportValue.height>>=x,w.viewportValue.minDepth=U,w.viewportValue.maxDepth=I,w.viewport=w.viewportValue.equals(gS)===!1,w.scissorValue.copy(E).multiplyScalar(O).floor(),w.scissor=this._scissorTest&&w.scissorValue.equals(gS)===!1,w.scissorValue.width>>=x,w.scissorValue.height>>=x,w.clippingContext||(w.clippingContext=new ay),w.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,S),bv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),vS.setFromProjectionMatrix(bv,N);const j=this._renderLists.get(e,t);if(j.begin(),this._projectObject(e,t,0,j,w.clippingContext),j.finish(),this.sortObjects===!0&&j.sort(this._opaqueSort,this._transparentSort),S!==null){this._textures.updateRenderTarget(S,x);const Y=this._textures.get(S);w.textures=Y.textures,w.depthTexture=Y.depthTexture,w.width=Y.width,w.height=Y.height,w.renderTarget=S,w.depth=S.depthBuffer,w.stencil=S.stencilBuffer}else w.textures=null,w.depthTexture=null,w.width=this.domElement.width,w.height=this.domElement.height,w.depth=this.depth,w.stencil=this.stencil;w.width>>=x,w.height>>=x,w.activeCubeFace=v,w.activeMipmapLevel=x,w.occlusionQueryCount=j.occlusionQueryCount,this._background.update(h,j,w),this.backend.beginRender(w);const{bundles:z,lightsNode:G,transparentDoublePass:W,transparent:q,opaque:V}=j;if(z.length>0&&this._renderBundles(z,h,G),this.opaque===!0&&V.length>0&&this._renderObjects(V,t,h,G),this.transparent===!0&&q.length>0&&this._renderTransparents(q,W,t,h,G),this.backend.finishRender(w),s.renderId=a,this._currentRenderContext=l,this._currentRenderObjectFunction=u,r!==null){this.setRenderTarget(m,v,x);const Y=this._quad;this._nodes.hasOutputChange(S.texture)&&(Y.material.fragmentNode=this._nodes.getOutputNode(S.texture),Y.material.needsUpdate=!0),this._renderScene(Y,Y.camera,!1)}return h.onAfterRender(this,e,t,S),w}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,n=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){const s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,s=0,a=1){const l=this._viewport;e.isVector4?l.copy(e):l.set(e,t,n,r),l.minDepth=s,l.maxDepth=a}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);const r=this._renderTarget||this._getFrameBufferTarget();let s=null;if(r!==null){this._textures.updateRenderTarget(r);const a=this._textures.get(r);s=this._renderContexts.get(null,null,r),s.textures=a.textures,s.depthTexture=a.depthTexture,s.width=a.width,s.height=a.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer}if(this.backend.clear(e,t,n,s),r!==null&&this._renderTarget===null){const a=this._quad;this._nodes.hasOutputChange(r.texture)&&(a.material.fragmentNode=this._nodes.getOutputNode(r.texture),a.material.needsUpdate=!0),this._renderScene(a,a.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){this._initialized===!1&&await this.init(),this.clear(e,t,n)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this._renderTarget!==null?ro:this.toneMapping}get currentColorSpace(){return this._renderTarget!==null?Io:this.outputColorSpace}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(this.isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,n=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const r=this.backend,s=this._pipelines,a=this._bindings,l=this._nodes,u=Array.isArray(e)?e:[e];if(u[0]===void 0||u[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");r.beginCompute(e);for(const h of u){if(s.has(h)===!1){const x=()=>{h.removeEventListener("dispose",x),s.delete(h),a.delete(h),l.delete(h)};h.addEventListener("dispose",x);const S=h.onInitFunction;S!==null&&S.call(h,{renderer:this})}l.updateForCompute(h),a.updateForCompute(h);const m=a.getForCompute(h),v=s.getForCompute(h,m);r.compute(e,h,m,v)}r.finishCompute(e),t.renderId=n}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e),await this.backend.resolveTimestampAsync(e,"compute")}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Nh.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Nh.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Nh.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n!==null?r=n.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,r=null,s=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,s)}async readRenderTargetPixelsAsync(e,t,n,r,s,a=0,l=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,s,l)}_projectObject(e,t,n,r,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||vS.intersectsSprite(e)){this.sortObjects===!0&&Nh.setFromMatrixPosition(e.matrixWorld).applyMatrix4(bv);const{geometry:u,material:h}=e;h.visible&&r.push(e,u,h,n,Nh.z,null,s)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||vS.intersectsObject(e))){const{geometry:u,material:h}=e;if(this.sortObjects===!0&&(u.boundingSphere===null&&u.computeBoundingSphere(),Nh.copy(u.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(bv)),Array.isArray(h)){const m=u.groups;for(let v=0,x=m.length;v0){for(const{material:a}of t)a.side=gr;this._renderObjects(t,n,r,s,"backSide");for(const{material:a}of t)a.side=zl;this._renderObjects(e,n,r,s);for(const{material:a}of t)a.side=gs}else this._renderObjects(e,n,r,s)}_renderObjects(e,t,n,r,s=null){for(let a=0,l=e.length;a0,S.isShadowNodeMaterial&&(S.side=s.shadowSide===null?s.side:s.shadowSide,s.depthNode&&s.depthNode.isNode&&(x=S.depthNode,S.depthNode=s.depthNode),s.castShadowNode&&s.castShadowNode.isNode&&(v=S.colorNode,S.colorNode=s.castShadowNode)),s=S}s.transparent===!0&&s.side===gs&&s.forceSinglePass===!1?(s.side=gr,this._handleObjectFunction(e,s,t,n,l,a,u,"backSide"),s.side=zl,this._handleObjectFunction(e,s,t,n,l,a,u,h),s.side=gs):this._handleObjectFunction(e,s,t,n,l,a,u,h),m!==void 0&&(t.overrideMaterial.positionNode=m),x!==void 0&&(t.overrideMaterial.depthNode=x),v!==void 0&&(t.overrideMaterial.colorNode=v),e.onAfterRender(this,t,n,r,s,a)}_renderObjectDirect(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a;const m=this._nodes.needsRefresh(h);m&&(this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h)),this._pipelines.updateForRender(h),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(h),h.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(h,this.info),m&&this._nodes.updateAfter(h)}_createObjectPipeline(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a,this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h),this._pipelines.getForRender(h,this._compilationPromises),this._nodes.updateAfter(h)}get compile(){return this.compileAsync}}class VE{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function moe(i){return i+(kh-i%kh)%kh}class nO extends VE{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return moe(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class iO extends nO{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let goe=0;class rO extends iO{constructor(e,t){super("UniformBuffer_"+goe++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class voe extends iO{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=0;for(let t=0,n=this.uniforms.length;t0?x:"";l=`${m.name} { + ${v} ${a.name}[${S}]; +}; +`}else l=`${this.getVectorType(a.type)} ${this.getPropertyName(a,e)};`,u=!0;const h=a.node.precision;if(h!==null&&(l=woe[h]+" "+l),u){l=" "+l;const m=a.groupNode.name;(r[m]||(r[m]=[])).push(l)}else l="uniform "+l,n.push(l)}let s="";for(const a in r){const l=r[a];s+=this._getGLSLUniformStruct(e+"_"+a,l.join(` +`))+` +`}return s+=n.join(` +`),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==ks){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let r=0;for(const s of n)t+=`layout( location = ${r++} ) in ${s.type} ${s.name}; +`}return t}getStructMembers(e){const t=[],n=e.getMemberTypes();for(let r=0;rn*r,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:r,behavior:s}of n.values())t.push(`#extension ${r} : ${s}`);return t.join(` +`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=T6[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const r=this.renderer.backend.extensions;r.has(n)&&(r.get(n),t=!0)}T6[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n0&&(n+=` +`),n+=` // flow -> ${h} + `),n+=`${u.code} + `,l===s&&t!=="compute"&&(n+=`// result + `,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(l.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);let l=a.uniformGPU;if(l===void 0){const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture")l=new ex(s.name,s.node,u),m.push(l);else if(t==="cubeTexture")l=new aO(s.name,s.node,u),m.push(l);else if(t==="texture3D")l=new oO(s.name,s.node,u),m.push(l);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;const v=new rO(e,u);v.name=e.name,m.push(v),l=v}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new sO(n+"_"+h,u),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}}let _S=null,BA=null;class lO{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return _S=_S||new Et,this.renderer.getDrawingBufferSize(_S)}setScissorTest(){}getClearColor(){const e=this.renderer;return BA=BA||new TE,e.getClearColor(BA),BA.getRGB(BA,this.renderer.currentColorSpace),BA}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:q7(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${W0} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let Eoe=0;class Coe{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class Noe{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,a=e.usage||r.STATIC_DRAW,l=e.isInterleavedBufferAttribute?e.data:e,u=n.get(l);let h=u.bufferGPU;h===void 0&&(h=this._createBuffer(r,t,s,a),u.bufferGPU=h,u.bufferType=t,u.version=l.version);let m;if(s instanceof Float32Array)m=r.FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?m=r.HALF_FLOAT:m=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)m=r.SHORT;else if(s instanceof Uint32Array)m=r.UNSIGNED_INT;else if(s instanceof Int32Array)m=r.INT;else if(s instanceof Int8Array)m=r.BYTE;else if(s instanceof Uint8Array)m=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)m=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let v={bufferGPU:h,bufferType:t,type:m,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:m===r.INT||m===r.UNSIGNED_INT||e.gpuType===ks,id:Eoe++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const x=this._createBuffer(r,t,s,a);v=new Coe(v,x)}n.set(e,v)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,a=t.get(s),l=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(l,a.bufferGPU),u.length===0)n.bufferSubData(l,0,r);else{for(let h=0,m=u.length;h1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u{function s(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}}let E6=!1,Sv,xS,C6;class Poe{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},E6===!1&&(this._init(this.gl),E6=!0)}_init(e){Sv={[ud]:e.REPEAT,[lu]:e.CLAMP_TO_EDGE,[cd]:e.MIRRORED_REPEAT},xS={[br]:e.NEAREST,[s_]:e.NEAREST_MIPMAP_NEAREST,[uu]:e.NEAREST_MIPMAP_LINEAR,[Ms]:e.LINEAR,[n0]:e.LINEAR_MIPMAP_NEAREST,[Ya]:e.LINEAR_MIPMAP_LINEAR},C6={[zw]:e.NEVER,[Hw]:e.ALWAYS,[my]:e.LESS,[gy]:e.LEQUAL,[Gw]:e.EQUAL,[jw]:e.GEQUAL,[qw]:e.GREATER,[Vw]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===br||e===s_||e===uu?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,s=!1){const{gl:a,extensions:l}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;return t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB&&(n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=r===Nn&&s===!1?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5)),t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA&&(n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=r===Nn&&s===!1?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)),t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_INT&&(u=a.DEPTH24_STENCIL8),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&l.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:r,backend:s}=this;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),n.texParameteri(e,n.TEXTURE_WRAP_S,Sv[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,Sv[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&n.texParameteri(e,n.TEXTURE_WRAP_R,Sv[t.wrapR]),n.texParameteri(e,n.TEXTURE_MAG_FILTER,xS[t.magFilter]);const a=t.mipmaps!==void 0&&t.mipmaps.length>0,l=t.minFilter===Ms&&a?Ya:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,xS[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,C6[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===br||t.minFilter!==uu&&t.minFilter!==Ya||t.type===ss&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const u=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,s=this.getGLTextureType(e);let a=r[s];a===void 0&&(a=t.createTexture(),n.state.bindTexture(s,a),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=a),n.set(e,{textureGPU:a,glTextureType:s,isDefault:!0})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:s,width:a,height:l,depth:u}=t,h=r.utils.convert(e.format,e.colorSpace),m=r.utils.convert(e.type),v=this.getInternalFormat(e.internalFormat,h,m,e.colorSpace,e.isVideoTexture),x=n.createTexture(),S=this.getGLTextureType(e);r.state.bindTexture(S,x),this.setTextureParameters(S,e),e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,v,a,l,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,v,a,l,u):e.isVideoTexture||n.texStorage2D(S,s,v,a,l),r.set(e,{textureGPU:x,glTextureType:S,glFormat:h,glType:m,glInternalFormat:v})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:s,glTextureType:a,glFormat:l,glType:u}=r.get(t),{width:h,height:m}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,h,m,l,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:s}=t,{textureGPU:a,glTextureType:l,glFormat:u,glType:h,glInternalFormat:m}=this.backend.get(e);if(e.isRenderTargetTexture||a===void 0)return;const v=x=>x.isDataTexture?x.image.data:typeof HTMLImageElement<"u"&&x instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&x instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&x instanceof ImageBitmap||x instanceof OffscreenCanvas?x:x.data;if(this.backend.state.bindTexture(l,a),this.setTextureParameters(l,e),e.isCompressedTexture){const x=e.mipmaps,S=t.image;for(let w=0;w0,x=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(v){const S=l!==0||u!==0;let w,N;if(e.isDepthTexture===!0?(w=r.DEPTH_BUFFER_BIT,N=r.DEPTH_ATTACHMENT,t.stencil&&(w|=r.STENCIL_BUFFER_BIT)):(w=r.COLOR_BUFFER_BIT,N=r.COLOR_ATTACHMENT0),S){const C=this.backend.get(t.renderTarget),E=C.framebuffers[t.getCacheKey()],O=C.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,E),s.bindFramebuffer(r.READ_FRAMEBUFFER,O);const U=x-u-m;r.blitFramebuffer(l,U,l+h,U+m,l,U,l+h,U+m,w,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,E),s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,U,h,m),s.unbindTexture()}else{const C=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,C),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,N,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,h,m,0,0,h,m,w,r.NEAREST),r.deleteFramebuffer(C)}}else s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,x-m-u,h,m),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:n}=this,r=t.renderTarget,{samples:s,depthTexture:a,depthBuffer:l,stencilBuffer:u,width:h,height:m}=r;if(n.bindRenderbuffer(n.RENDERBUFFER,e),l&&!u){let v=n.DEPTH_COMPONENT24;s>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(v=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,s,v,h,m)):n.renderbufferStorage(n.RENDERBUFFER,v,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else l&&u&&(s>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,s,n.DEPTH24_STENCIL8,h,m):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,n,r,s,a){const{backend:l,gl:u}=this,{textureGPU:h,glFormat:m,glType:v}=this.backend.get(e),x=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,x);const S=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,S,h,0);const w=this._getTypedArrayType(v),N=this._getBytesPerTexel(v,m),E=r*s*N,O=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.bufferData(u.PIXEL_PACK_BUFFER,E,u.STREAM_READ),u.readPixels(t,n,r,s,m,v,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await l.utils._clientWaitAsync();const U=new w(E/w.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,U),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(x),U}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}}class Loe{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class Uoe{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const N6={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class Boe{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:r,object:s,type:a,info:l,index:u}=this;u!==0?n.drawElements(r,t,a,e):n.drawArrays(r,e,t),l.update(s,t,r,1)}renderInstances(e,t,n){const{gl:r,mode:s,type:a,index:l,object:u,info:h}=this;n!==0&&(l!==0?r.drawElementsInstanced(s,t,a,e,n):r.drawArraysInstanced(s,e,t,n),h.update(u,t,s,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:s,object:a,info:l}=this;if(n===0)return;const u=r.get("WEBGL_multi_draw");if(u===null)for(let h=0;h0)){const n=t.queryQueue.shift();this.initTimestampQuery(n)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const n=this.get(e);n.gpuQueries||(n.gpuQueries=[]);for(let r=0;r0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),s=r.previousContext,a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const l=e.textures;if(l!==null)for(let u=0;u0){const m=u.framebuffers[e.getCacheKey()],v=t.COLOR_BUFFER_BIT,x=u.msaaFrameBuffer,S=e.textures;n.bindFramebuffer(t.READ_FRAMEBUFFER,x),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,m);for(let w=0;w{let u=0;for(let h=0;h0&&s.add(r[h]),n[h]=null,a.deleteQuery(m),u++)}u1?E.renderInstances(I,O,U):E.render(I,O),u.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new Moe(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,s=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,r),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:s,vertexProgram:a}=r,l=n.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU;if(n.attachShader(l,u),n.attachShader(l,h),n.linkProgram(l),this.set(r,{programGPU:l,fragmentShader:u,vertexShader:h}),t!==null&&this.parallel){const m=new Promise(v=>{const x=this.parallel,S=()=>{n.getProgramParameter(l,x.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),v()):requestAnimationFrame(S)};S()});t.push(m);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(` +`),r=[],s=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let l=s;l":" "} ${u}: ${n[l]}`)}return r.join(` +`)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),s=e.getShaderInfoLog(t).trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const l=parseInt(a[1]);return n.toUpperCase()+` + +`+s+` + +`+this._handleSource(e.getShaderSource(t),l)}else return s}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,s=r.getProgramInfoLog(e).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,n,t);else{const a=this._getShaderErrors(r,n,"vertex"),l=this._getShaderErrors(r,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+` + +Program Info Log: `+s+` +`+a+` +`+l)}else s!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",s)}}_completeCompile(e,t){const{state:n,gl:r}=this,s=this.get(t),{programGPU:a,fragmentShader:l,vertexShader:u}=s;r.getProgramParameter(a,r.LINK_STATUS)===!1&&this._logProgramError(a,l,u),n.useProgram(a);const h=e.getBindings();this._setupBindings(h,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){const{state:n,gl:r}=this,s={stage:"fragment",code:`#version 300 es +precision highp float; +void main() {}`};this.createProgram(s);const{computeProgram:a}=e,l=r.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU,m=a.transforms,v=[],x=[];for(let C=0;CN6[r]===e),n=this.extensions;for(let r=0;r0){if(S===void 0){const E=[];S=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,S);const O=[],U=e.textures;for(let I=0;I, + @location( 0 ) vTex : vec2 +}; + +@vertex +fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { + + var Varys : VarysStruct; + + var pos = array< vec2, 4 >( + vec2( -1.0, 1.0 ), + vec2( 1.0, 1.0 ), + vec2( -1.0, -1.0 ), + vec2( 1.0, -1.0 ) + ); + + var tex = array< vec2, 4 >( + vec2( 0.0, 0.0 ), + vec2( 1.0, 0.0 ), + vec2( 0.0, 1.0 ), + vec2( 1.0, 1.0 ) + ); + + Varys.vTex = tex[ vertexIndex ]; + Varys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 ); + + return Varys; + +} +`,n=` +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img : texture_2d; + +@fragment +fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { + + return textureSample( img, imgSampler, vTex ); + +} +`,r=` +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img : texture_2d; + +@fragment +fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { + + return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); + +} +`;this.mipmapSampler=e.createSampler({minFilter:Hf.Linear}),this.flipYSampler=e.createSampler({minFilter:Hf.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:r})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:t0.TriangleStrip,stripIndexFormat:q0.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:t0.TriangleStrip,stripIndexFormat:q0.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const r=t.format,{width:s,height:a}=t.size,l=this.getTransferPipeline(r),u=this.getFlipYPipeline(r),h=this.device.createTexture({size:{width:s,height:a,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),m=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Wa.TwoD,baseArrayLayer:n}),v=h.createView({baseMipLevel:0,mipLevelCount:1,dimension:Wa.TwoD,baseArrayLayer:0}),x=this.device.createCommandEncoder({}),S=(w,N,C)=>{const E=w.getBindGroupLayout(0),O=this.device.createBindGroup({layout:E,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:N}]}),U=x.beginRenderPass({colorAttachments:[{view:C,loadOp:rs.Clear,storeOp:ha.Store,clearValue:[0,0,0,0]}]});U.setPipeline(w),U.setBindGroup(0,O),U.draw(4,1,0,0),U.end()};S(l,m,v),S(u,v,m),this.device.queue.submit([x.finish()]),h.destroy()}generateMipmaps(e,t,n=0){const r=this.get(e);r.useCount===void 0&&(r.useCount=0,r.layers=[]);const s=r.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,s),this.device.queue.submit([a.finish()]),r.useCount!==0&&(r.layers[n]=s),r.useCount++}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),s=r.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Wa.TwoD,baseArrayLayer:n});const l=[];for(let u=1;u1;for(let l=0;l]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,$oe=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,L6={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},Xoe=i=>{i=i.trim();const e=i.match(Woe);if(e!==null&&e.length===4){const t=e[2],n=[];let r=null;for(;(r=$oe.exec(t))!==null;)n.push({name:r[1],type:r[2]});const s=[];for(let m=0;m "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class Qoe extends eO{parseFunction(e){return new Yoe(e)}}const IA=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Koe={[da.READ_ONLY]:"read",[da.WRITE_ONLY]:"write",[da.READ_WRITE]:"read_write"},U6={[ud]:"repeat",[lu]:"clamp",[cd]:"mirror"},wv={vertex:IA?IA.VERTEX:1,fragment:IA?IA.FRAGMENT:2,compute:IA?IA.COMPUTE:4},B6={instance:!0,swizzleAssign:!1,storageBuffer:!0},Zoe={"^^":"tsl_xor"},Joe={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},O6={},tl={tsl_xor:new ps("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new ps("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new ps("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new ps("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new ps("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new ps("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new ps("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new ps("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new ps("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new ps("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new ps("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new ps("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new ps(` +fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { + + let res = vec2f( iRes ); + + let uvScaled = coord * res; + let uvWrapping = ( ( uvScaled % res ) + res ) % res; + + // https://www.shadertoy.com/view/WtyXRy + + let uv = uvWrapping - 0.5; + let iuv = floor( uv ); + let f = fract( uv ); + + let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); + let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); + let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); + let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); + + return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); + +} +`)},Cm={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(tl.pow_float=new ps("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),tl.pow_vec2=new ps("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[tl.pow_float]),tl.pow_vec3=new ps("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[tl.pow_float]),tl.pow_vec4=new ps("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[tl.pow_float]),Cm.pow_float="tsl_pow_float",Cm.pow_vec2="tsl_pow_vec2",Cm.pow_vec3="tsl_pow_vec3",Cm.pow_vec4="tsl_pow_vec4");let uO="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(uO+=`diagnostic( off, derivative_uniformity ); +`);class ele extends ZB{constructor(e,t){super(e,t,new Qoe),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Oo}_generateTextureSample(e,t,n,r,s=this.shaderStage){return s==="fragment"?r?`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n):this.generateTextureLod(e,t,n,r,"0")}_generateVideoSample(e,t,n=this.shaderStage){if(n==="fragment")return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${n} shader.`)}_generateTextureSampleLevel(e,t,n,r,s,a=this.shaderStage){return(a==="fragment"||a==="compute")&&this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r):this.generateTextureLod(e,t,n,s,r)}generateWrapFunction(e){const t=`tsl_coord_${U6[e.wrapS]}S_${U6[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=O6[t];if(n===void 0){const r=[],s=e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${s} ) -> ${s} { + + return ${s}( +`;const l=(u,h)=>{u===ud?(r.push(tl.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${h} )`):u===lu?(r.push(tl.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${h} )`):u===cd?(r.push(tl.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${h} )`):(a+=` coord.${h}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};l(e.wrapS,"x"),a+=`, +`,l(e.wrapT,"y"),e.isData3DTexture&&(a+=`, +`,l(e.wrapR,"z")),a+=` + ); + +} +`,O6[t]=n=new ps(a,r)}return n.build(this),t}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,l;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),h=u>1;e.isData3DTexture?l="vec3":l="vec2",h||e.isVideoTexture||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,s=new Kv(new Zv(`textureDimensions( ${a} )`,l)),r.dimensionsSnippet[n]=s,(e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new Kv(new Zv(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new Kv(new Zv("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,n,r="0u"){this._include("biquadraticTexture");const s=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,r);return`tsl_biquadraticTexture( ${t}, ${s}( ${n} ), ${a}, u32( ${r} ) )`}generateTextureLod(e,t,n,r,s="0u"){const a=this.generateWrapFunction(e),l=this.generateTextureDimension(e,t,s),u=e.isData3DTexture?"vec3":"vec2",h=`${u}(${a}(${n}) * ${u}(${l}))`;return this.generateTextureLoad(e,t,h,r,s)}generateTextureLoad(e,t,n,r,s="0u"){return e.isVideoTexture===!0||e.isStorageTexture===!0?`textureLoad( ${t}, ${n} )`:r?`textureLoad( ${t}, ${n}, ${r}, u32( ${s} ) )`:`textureLoad( ${t}, ${n}, u32( ${s} ) )`}generateTextureStore(e,t,n,r){return`textureStore( ${t}, ${n}, ${r} )`}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===ss||this.isSampleCompare(e)===!1&&e.minFilter===br&&e.magFilter===br||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,s=this.shaderStage){let a=null;return e.isVideoTexture===!0?a=this._generateVideoSample(t,n,s):this.isUnfilterable(e)?a=this.generateTextureLod(e,t,n,r,"0",s):a=this._generateTextureSample(e,t,n,r,s),a}generateTextureGrad(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,r,s,a=this.shaderStage){let l=null;return e.isVideoTexture===!0?l=this._generateVideoSample(t,n,a):l=this._generateTextureSampleLevel(e,t,n,r,s,a),l}generateTextureBias(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const n=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="storageTexture"||r==="texture3D"?n:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?`NodeBuffer_${e.id}.${n}`:e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=Zoe[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?da.READ_ONLY:e.access}getStorageAccess(e,t){return Koe[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let l;const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let v=null;const x=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?v=new ex(s.name,s.node,u,x):t==="cubeTexture"?v=new aO(s.name,s.node,u,x):t==="texture3D"&&(v=new oO(s.name,s.node,u,x)),v.store=e.isStorageTextureNode===!0,v.setVisibility(wv[n]),(n==="fragment"||n==="compute")&&this.isUnfilterable(e.value)===!1&&v.store===!1){const S=new Foe(`${s.name}_sampler`,s.node,u);S.setVisibility(wv[n]),m.push(S,v),l=[S,v]}else m.push(v),l=[v]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const v=t==="buffer"?rO:Goe,x=new v(e,u);x.setVisibility(wv[n]),m.push(x),l=x}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new sO(h,u),x.setVisibility(wv[n]),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}getBuiltin(e,t,n,r=this.shaderStage){const s=this.builtins[r]||(this.builtins[r]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const a of t.inputs)r.push(a.name+" : "+this.getType(a.type));let s=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} { +${n.vars} +${n.code} +`;return n.result&&(s+=` return ${n.result}; +`),s+=` +} +`,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==void 0)for(const r of n)t.push(`enable ${r};`);return t.join(` +`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==void 0)for(const{name:r,property:s,type:a}of n.values())t.push(`@builtin( ${r} ) ${s} : ${a}`);return t.join(`, + `)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:r,bufferType:s,bufferCount:a}of this.scopedArrays.values()){const l=this.getType(s);t.push(`var<${r}> ${n}: array< ${l}, ${a} >;`)}return t.join(` +`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","id","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const n=this.getBuiltins("attribute");n&&t.push(n);const r=this.getAttributesArray();for(let s=0,a=r.length;s`)}const r=this.getBuiltins("output");return r&&t.push(" "+r),t.join(`, +`)}getStructs(e){const t=[],n=this.structs[e];for(let r=0,s=n.length;r output : ${l}; + +`)}return t.join(` + +`)}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(` ${this.getVar(r.type,r.name)};`);return` +${t.join(` +`)} +`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4","vertex"),e==="vertex"||e==="fragment"){const s=this.varyings,a=this.vars[e];for(let l=0;l1&&(S="_multisampled"),v.isCubeTexture===!0)x="texture_cube";else if(v.isDataArrayTexture===!0||v.isCompressedArrayTexture===!0)x="texture_2d_array";else if(v.isDepthTexture===!0)x=`texture_depth${S}_2d`;else if(v.isVideoTexture===!0)x="texture_external";else if(v.isData3DTexture===!0)x="texture_3d";else if(u.node.isStorageTextureNode===!0){const N=sw(v),C=this.getStorageAccess(u.node,e);x=`texture_storage_2d<${N}, ${C}>`}else{const N=this.getComponentTypeFromTexture(v).charAt(0);x=`texture${S}_2d<${N}32>`}n.push(`@binding( ${m.binding++} ) @group( ${m.group} ) var ${u.name} : ${x};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const v=u.node,x=this.getType(v.bufferType),S=v.bufferCount,w=S>0&&u.type==="buffer"?", "+S:"",N=v.isAtomic?`atomic<${x}>`:`${x}`,C=` ${u.name} : array< ${N}${w} > +`,E=v.isStorageBufferNode?`storage, ${this.getStorageAccess(v,e)}`:"uniform";r.push(this._getWGSLStructBinding("NodeBuffer_"+v.id,C,E,m.binding++,m.group))}else{const v=this.getType(this.getVectorType(u.type)),x=u.groupNode.name;(a[x]||(a[x]={index:m.binding++,id:m.group,snippets:[]})).snippets.push(` ${u.name} : ${v}`)}}for(const u in a){const h=a[u];s.push(this._getWGSLStructBinding(u,h.snippets.join(`, +`),"uniform",h.index,h.id))}let l=n.join(` +`);return l+=r.join(` +`),l+=s.join(` +`),l}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code + +`;r+=this.flowCode[t];const s=this.flowNodes[t],a=s[s.length-1],l=a.outputNode,u=l!==void 0&&l.isOutputStructNode===!0;for(const h of s){const m=this.getFlowData(h),v=h.name;if(v&&(r.length>0&&(r+=` +`),r+=` // flow -> ${v} + `),r+=`${m.code} + `,h===a&&t!=="compute"){if(r+=`// result + + `,t==="vertex")r+=`varyings.Vertex = ${m.result};`;else if(t==="fragment")if(u)n.returnType=l.nodeType,r+=`return ${m.result};`;else{let x=" @location(0) color: vec4";const S=this.getBuiltins("output");S&&(x+=`, + `+S),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",x),n.structs+=` +var output : OutputStruct; + +`,r+=`output.color = ${m.result}; + + return output;`}}}n.flow=r}this.material!==null?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getType(e){return Joe[e]||e}isAvailable(e){let t=B6[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),B6[e]=t),t}_getWGSLMethod(e){return tl[e]!==void 0&&this._include(e),Cm[e]}_include(e){const t=tl[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} +// directives +${e.directives} + +// uniforms +${e.uniforms} + +// varyings +${e.varyings} +var varyings : VaryingsStruct; + +// codes +${e.codes} + +@vertex +fn main( ${e.attributes} ) -> VaryingsStruct { + + // vars + ${e.vars} + + // flow + ${e.flow} + + return varyings; + +} +`}_getWGSLFragmentCode(e){return`${this.getSignature()} +// global +${uO} + +// uniforms +${e.uniforms} + +// structs +${e.structs} + +// codes +${e.codes} + +@fragment +fn main( ${e.varyings} ) -> ${e.returnType} { + + // vars + ${e.vars} + + // flow + ${e.flow} + +} +`}_getWGSLComputeCode(e,t){return`${this.getSignature()} +// directives +${e.directives} + +// system +var instanceIndex : u32; + +// locals +${e.scopedArrays} + +// uniforms +${e.uniforms} + +// codes +${e.codes} + +@compute @workgroup_size( ${t} ) +fn main( ${e.attributes} ) { + + // system + instanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t}); + + // vars + ${e.vars} + + // flow + ${e.flow} + +} +`}_getWGSLStruct(e,t){return` +struct ${e} { +${t} +};`}_getWGSLStructBinding(e,t,n,r=0,s=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)} +@binding( ${r} ) @group( ${s} ) +var<${n}> ${e} : ${a};`}}class tle{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=De.Depth24PlusStencil8:e.depth&&(t=De.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,a=s.getRenderTarget();t=a?a.samples:s.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return t0.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return t0.LineList;if(e.isLine)return t0.LineStrip;if(e.isMesh)return t0.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?De.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const nle=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),ile=new Map([[H7,["float16"]]]),rle=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class sle{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let a=s.buffer;if(a===void 0){const l=r.device;let u=n.array;if(e.normalized===!1&&(u.constructor===Int16Array||u.constructor===Uint16Array)){const m=new Uint32Array(u.length);for(let v=0;v1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=OA.UnfilterableFloat)),a.texture.isDepthTexture)u.sampleType=OA.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const m=a.texture.type;m===ks?u.sampleType=OA.SInt:m===Ir?u.sampleType=OA.UInt:m===ss&&(this.backend.hasFeature("float32-filterable")?u.sampleType=OA.Float:u.sampleType=OA.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=Wa.Cube:a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=Wa.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=Wa.ThreeD),l.texture=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);r.push(l)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){const{backend:s,bindGroupLayoutCache:a}=this,l=s.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let h;n>0&&(l.groups===void 0&&(l.groups=[],l.versions=[]),l.versions[n]===r&&(h=l.groups[n])),h===void 0&&(h=this.createBindGroup(e,u),n>0&&(l.groups[n]=h,l.versions[n]=r)),l.group=h,l.layout=u}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,s=t.get(e).buffer;n.queue.writeBuffer(s,0,r,0)}createBindGroup(e,t){const n=this.backend,r=n.device;let s=0;const a=[];for(const l of e.bindings){if(l.isUniformBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.byteLength,m=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,v=r.createBuffer({label:"bindingBuffer_"+l.name,size:h,usage:m});u.buffer=v}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isStorageBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.attribute;u.buffer=n.get(h).buffer}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isSampler){const u=n.get(l.texture);a.push({binding:s,resource:u.sampler})}else if(l.isSampledTexture){const u=n.get(l.texture);let h;if(u.externalTexture!==void 0)h=r.importExternalTexture({source:u.externalTexture});else{const m=l.store?1:u.texture.mipLevelCount,v=`view-${u.texture.width}-${u.texture.height}-${m}`;if(h=u[v],h===void 0){const x=Ooe.All;let S;l.isSampledCubeTexture?S=Wa.Cube:l.isSampledTexture3D?S=Wa.ThreeD:l.texture.isDataArrayTexture||l.texture.isCompressedArrayTexture?S=Wa.TwoDArray:S=Wa.TwoD,h=u[v]=u.texture.createView({aspect:x,dimension:S,mipLevelCount:m})}}a.push({binding:s,resource:h})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}}class ole{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:s,pipeline:a}=e,{vertexProgram:l,fragmentProgram:u}=a,h=this.backend,m=h.device,v=h.utils,x=h.get(a),S=[];for(const ne of e.getBindings()){const le=h.get(ne);S.push(le.layout)}const w=h.attributeUtils.createShaderVertexBuffers(e);let N;r.transparent===!0&&r.blending!==no&&(N=this._getBlending(r));let C={};r.stencilWrite===!0&&(C={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const E=this._getColorWriteMask(r),O=[];if(e.context.textures!==null){const ne=e.context.textures;for(let le=0;le1},layout:m.createPipelineLayout({bindGroupLayouts:S})},V={},Y=e.context.depth,te=e.context.stencil;if((Y===!0||te===!0)&&(Y===!0&&(V.format=G,V.depthWriteEnabled=r.depthWrite,V.depthCompare=z),te===!0&&(V.stencilFront=C,V.stencilBack={},V.stencilReadMask=r.stencilFuncMask,V.stencilWriteMask=r.stencilWriteMask),q.depthStencil=V),t===null)x.pipeline=m.createRenderPipeline(q);else{const ne=new Promise(le=>{m.createRenderPipelineAsync(q).then(Q=>{x.pipeline=Q,le()})});t.push(ne)}}createBundleEncoder(e){const t=this.backend,{utils:n,device:r}=t,s=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormat(e),l=this._getSampleCount(e),u={label:"renderBundleEncoder",colorFormats:[a],depthStencilFormat:s,sampleCount:l};return r.createRenderBundleEncoder(u)}createComputePipeline(e,t){const n=this.backend,r=n.device,s=n.get(e.computeProgram).module,a=n.get(e),l=[];for(const u of t){const h=n.get(u);l.push(h.layout)}a.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:l})})}_getBlending(e){let t,n;const r=e.blending,s=e.blendSrc,a=e.blendDst,l=e.blendEquation;if(r===Sw){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,h=e.blendDstAlpha!==null?e.blendDstAlpha:a,m=e.blendEquationAlpha!==null?e.blendEquationAlpha:l;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(l)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(h),operation:this._getBlendOperation(m)}}else{const u=e.premultipliedAlpha,h=(m,v,x,S)=>{t={srcFactor:m,dstFactor:v,operation:Uf.Add},n={srcFactor:x,dstFactor:S,operation:Uf.Add}};if(u)switch(r){case io:h(ti.One,ti.OneMinusSrcAlpha,ti.One,ti.OneMinusSrcAlpha);break;case u0:h(ti.One,ti.One,ti.One,ti.One);break;case c0:h(ti.Zero,ti.OneMinusSrc,ti.Zero,ti.One);break;case h0:h(ti.Zero,ti.Src,ti.Zero,ti.SrcAlpha);break}else switch(r){case io:h(ti.SrcAlpha,ti.OneMinusSrcAlpha,ti.One,ti.OneMinusSrcAlpha);break;case u0:h(ti.SrcAlpha,ti.One,ti.SrcAlpha,ti.One);break;case c0:h(ti.Zero,ti.OneMinusSrc,ti.Zero,ti.One);break;case h0:h(ti.Zero,ti.Src,ti.Zero,ti.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case Mw:t=ti.Zero;break;case Ew:t=ti.One;break;case Cw:t=ti.Src;break;case Nw:t=ti.OneMinusSrc;break;case jm:t=ti.SrcAlpha;break;case Hm:t=ti.OneMinusSrcAlpha;break;case Pw:t=ti.Dst;break;case Lw:t=ti.OneMinusDstColor;break;case Rw:t=ti.DstAlpha;break;case Dw:t=ti.OneMinusDstAlpha;break;case Uw:t=ti.SrcAlphaSaturated;break;case vne:t=ti.Constant;break;case _ne:t=ti.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case sk:t=js.Never;break;case XS:t=js.Always;break;case ak:t=js.Less;break;case lk:t=js.LessEqual;break;case ok:t=js.Equal;break;case hk:t=js.GreaterEqual;break;case uk:t=js.Greater;break;case ck:t=js.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case If:t=Rh.Keep;break;case ZF:t=Rh.Zero;break;case JF:t=Rh.Replace;break;case rk:t=Rh.Invert;break;case ek:t=Rh.IncrementClamp;break;case tk:t=Rh.DecrementClamp;break;case nk:t=Rh.IncrementWrap;break;case ik:t=Rh.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Bo:t=Uf.Add;break;case Tw:t=Uf.Subtract;break;case ww:t=Uf.ReverseSubtract;break;case R7:t=Uf.Min;break;case D7:t=Uf.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},s=this.backend.utils;switch(r.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?q0.Uint16:q0.Uint32),n.side){case zl:r.frontFace=bS.CCW,r.cullMode=SS.Back;break;case gr:r.frontFace=bS.CCW,r.cullMode=SS.Front;break;case gs:r.frontFace=bS.CCW,r.cullMode=SS.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?D6.All:D6.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=js.Always;else{const n=e.depthFunc;switch(n){case Wm:t=js.Never;break;case $m:t=js.Always;break;case Xm:t=js.Less;break;case Hh:t=js.LessEqual;break;case Ym:t=js.Equal;break;case Qm:t=js.GreaterEqual;break;case Km:t=js.Greater;break;case Zm:t=js.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class lle extends lO{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.trackTimestamp=e.trackTimestamp===!0,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new tle(this),this.attributeUtils=new sle(this),this.bindingUtils=new ale(this),this.pipelineUtils=new ole(this),this.textureUtils=new Hoe(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===void 0){const a={powerPreference:t.powerPreference},l=typeof navigator<"u"?await navigator.gpu.requestAdapter(a):null;if(l===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const u=Object.values(rw),h=[];for(const v of u)l.features.has(v)&&h.push(v);const m={requiredFeatures:h,requiredLimits:t.requiredLimits};n=await l.requestDevice(m)}else n=t.device;n.lost.then(a=>{const l={api:"WebGPU",message:a.message||"Unknown reason",reason:a.reason||null,originalEvent:a};e.onDeviceLost(l)});const r=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=r;const s=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(rw.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s}),this.updateSize()}get coordinateSystem(){return Su}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let s=r.descriptors;if(s===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==n.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples||r.loadOp!==t.loadOp){s={},r.descriptors=s;const u=()=>{n.removeEventListener("dispose",u),this.delete(n)};n.addEventListener("dispose",u)}const a=e.getCacheKey();let l=s[a];if(l===void 0){const u=e.textures,h=[];let m;for(let v=0;v0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:rs.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=s;const l=a.depthStencilAttachment;if(e.textures!==null){const m=a.colorAttachments;for(let v=0;v0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),n>0){const r=n*8;let s=this.occludedResolveCache.get(r);s===void 0&&(s=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,s));const a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const r=e.textures;for(let s=0;sl?(h.x=Math.min(t.dispatchCount,l),h.y=Math.ceil(t.dispatchCount/l)):h.x=t.dispatchCount,s.dispatchWorkgroups(h.x,h.y,h.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:n,context:r,pipeline:s}=e,a=e.getBindings(),l=this.get(r),u=this.get(s).pipeline,h=l.currentSets,m=l.currentPass,v=e.getDrawParameters();if(v===null)return;h.pipeline!==u&&(m.setPipeline(u),h.pipeline=u);const x=h.bindingGroups;for(let C=0,E=a.length;C1?0:I;w===!0?m.drawIndexed(E[I],j,C[I]/S.array.BYTES_PER_ELEMENT,0,z):m.draw(E[I],j,C[I],z)}}else if(w===!0){const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndexedIndirect(I,0)}else m.drawIndexed(C,E,O,0,0);t.update(n,C,E)}else{const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndirect(I,0)}else m.draw(C,E,O,0);t.update(n,C,E)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,s=this.utils,a=s.getSampleCountRenderContext(e.context),l=s.getCurrentColorSpace(e.context),u=s.getCurrentColorFormat(e.context),h=s.getCurrentDepthStencilFormat(e.context),m=s.getPrimitiveTopology(n,r);let v=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==l||t.colorFormat!==u||t.depthStencilFormat!==h||t.primitiveTopology!==m||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=l,t.colorFormat=u,t.depthStencilFormat=h,t.primitiveTopology=m,t.clippingContextCacheKey=e.clippingContextCacheKey,v=!0),v}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,s=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(s),r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const n=this.get(e);if(!n.timeStampQuerySet){const r=e.isComputeNode?"compute":"render",s=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${r}_${e.id}`});Object.assign(t,{timestampWrites:{querySet:s,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}),n.timeStampQuerySet=s}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const n=this.get(e),r=2*BigInt64Array.BYTES_PER_ELEMENT;n.currentTimestampQueryBuffers===void 0&&(n.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:s,resultBuffer:a}=n.currentTimestampQueryBuffers;t.resolveQuerySet(n.timeStampQuerySet,0,2,s,0),a.mapState==="unmapped"&&t.copyBufferToBuffer(s,0,a,0,r)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const n=this.get(e);if(n.currentTimestampQueryBuffers===void 0)return;const{resultBuffer:r}=n.currentTimestampQueryBuffers;r.mapState==="unmapped"&&r.mapAsync(GPUMapMode.READ).then(()=>{const s=new BigUint64Array(r.getMappedRange()),a=Number(s[1]-s[0])/1e6;this.renderer.info.updateTimestamp(t,a),r.unmap()})}createNodeBuilder(e,t){return new ele(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),s=n.currentPass.finish();this.get(t).bundleGPU=s,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,s=0){let a=0,l=0,u=0,h=0,m=0,v=0,x=e.image.width,S=e.image.height;n!==null&&(h=n.x,m=n.y,v=n.z||0,x=n.width,S=n.height),r!==null&&(a=r.x,l=r.y,u=r.z||0);const w=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),N=this.get(e).texture,C=this.get(t).texture;w.copyTextureToTexture({texture:N,mipLevel:s,origin:{x:h,y:m,z:v}},{texture:C,mipLevel:s,origin:{x:a,y:l,z:u}},[x,S,1]),this.device.queue.submit([w.finish()])}copyFramebufferToTexture(e,t,n){const r=this.get(t);let s=null;t.renderTarget?e.isDepthTexture?s=this.get(t.depthTexture).texture:s=this.get(t.textures[0]).texture:e.isDepthTexture?s=this.textureUtils.getDepthBuffer(t.depth,t.stencil):s=this.context.getCurrentTexture();const a=this.get(e).texture;if(s.format!==a.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,a.format);return}let l;if(r.currentPass?(r.currentPass.end(),l=r.encoder):l=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),l.copyTextureToTexture({texture:s,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),r.currentPass){const{descriptor:u}=r;for(let h=0;h(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new R6(e)));const n=new t(e);super(n,e),this.library=new cle,this.isWebGPURenderer=!0}}/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */$.BRDF_GGX;$.BRDF_Lambert;$.BasicShadowFilter;$.Break;$.Continue;$.DFGApprox;$.D_GGX;$.Discard;$.EPSILON;$.F_Schlick;const hle=$.Fn;$.INFINITY;const fle=$.If,dle=$.Loop;$.NodeShaderStage;$.NodeType;$.NodeUpdateType;$.NodeAccess;$.PCFShadowFilter;$.PCFSoftShadowFilter;$.PI;$.PI2;$.Return;$.Schlick_to_F0;$.ScriptableNodeResources;$.ShaderNode;$.TBNViewMatrix;$.VSMShadowFilter;$.V_GGX_SmithCorrelated;$.abs;$.acesFilmicToneMapping;$.acos;$.add;$.addNodeElement;$.agxToneMapping;$.all;$.alphaT;$.and;$.anisotropy;$.anisotropyB;$.anisotropyT;$.any;$.append;$.arrayBuffer;const Ale=$.asin;$.assign;$.atan;$.atan2;$.atomicAdd;$.atomicAnd;$.atomicFunc;$.atomicMax;$.atomicMin;$.atomicOr;$.atomicStore;$.atomicSub;$.atomicXor;$.attenuationColor;$.attenuationDistance;$.attribute;$.attributeArray;$.backgroundBlurriness;$.backgroundIntensity;$.backgroundRotation;$.batch;$.billboarding;$.bitAnd;$.bitNot;$.bitOr;$.bitXor;$.bitangentGeometry;$.bitangentLocal;$.bitangentView;$.bitangentWorld;$.bitcast;$.blendBurn;$.blendColor;$.blendDodge;$.blendOverlay;$.blendScreen;$.blur;$.bool;$.buffer;$.bufferAttribute;$.bumpMap;$.burn;$.bvec2;$.bvec3;$.bvec4;$.bypass;$.cache;$.call;$.cameraFar;$.cameraNear;$.cameraNormalMatrix;$.cameraPosition;$.cameraProjectionMatrix;$.cameraProjectionMatrixInverse;$.cameraViewMatrix;$.cameraWorldMatrix;$.cbrt;$.cdl;$.ceil;$.checker;$.cineonToneMapping;$.clamp;$.clearcoat;$.clearcoatRoughness;$.code;$.color;$.colorSpaceToWorking;$.colorToDirection;$.compute;$.cond;$.context;$.convert;$.convertColorSpace;$.convertToTexture;const ple=$.cos;$.cross;$.cubeTexture;$.dFdx;$.dFdy;$.dashSize;$.defaultBuildStages;$.defaultShaderStages;$.defined;$.degrees;$.deltaTime;$.densityFog;$.densityFogFactor;$.depth;$.depthPass;$.difference;$.diffuseColor;$.directPointLight;$.directionToColor;$.dispersion;$.distance;$.div;$.dodge;$.dot;$.drawIndex;$.dynamicBufferAttribute;$.element;$.emissive;$.equal;$.equals;$.equirectUV;const mle=$.exp;$.exp2;$.expression;$.faceDirection;$.faceForward;$.faceforward;const gle=$.float;$.floor;$.fog;$.fract;$.frameGroup;$.frameId;$.frontFacing;$.fwidth;$.gain;$.gapSize;$.getConstNodeType;$.getCurrentStack;$.getDirection;$.getDistanceAttenuation;$.getGeometryRoughness;$.getNormalFromDepth;$.getParallaxCorrectNormal;$.getRoughness;$.getScreenPosition;$.getShIrradianceAt;$.getTextureIndex;$.getViewPosition;$.glsl;$.glslFn;$.grayscale;$.greaterThan;$.greaterThanEqual;$.hash;$.highpModelNormalViewMatrix;$.highpModelViewMatrix;$.hue;$.instance;const vle=$.instanceIndex;$.instancedArray;$.instancedBufferAttribute;$.instancedDynamicBufferAttribute;$.instancedMesh;$.int;$.inverseSqrt;$.inversesqrt;$.invocationLocalIndex;$.invocationSubgroupIndex;$.ior;$.iridescence;$.iridescenceIOR;$.iridescenceThickness;$.ivec2;$.ivec3;$.ivec4;$.js;$.label;$.length;$.lengthSq;$.lessThan;$.lessThanEqual;$.lightPosition;$.lightTargetDirection;$.lightTargetPosition;$.lightViewPosition;$.lightingContext;$.lights;$.linearDepth;$.linearToneMapping;$.localId;$.log;$.log2;$.logarithmicDepthToViewZ;$.loop;$.luminance;$.mediumpModelViewMatrix;$.mat2;$.mat3;$.mat4;$.matcapUV;$.materialAO;$.materialAlphaTest;$.materialAnisotropy;$.materialAnisotropyVector;$.materialAttenuationColor;$.materialAttenuationDistance;$.materialClearcoat;$.materialClearcoatNormal;$.materialClearcoatRoughness;$.materialColor;$.materialDispersion;$.materialEmissive;$.materialIOR;$.materialIridescence;$.materialIridescenceIOR;$.materialIridescenceThickness;$.materialLightMap;$.materialLineDashOffset;$.materialLineDashSize;$.materialLineGapSize;$.materialLineScale;$.materialLineWidth;$.materialMetalness;$.materialNormal;$.materialOpacity;$.materialPointWidth;$.materialReference;$.materialReflectivity;$.materialRefractionRatio;$.materialRotation;$.materialRoughness;$.materialSheen;$.materialSheenRoughness;$.materialShininess;$.materialSpecular;$.materialSpecularColor;$.materialSpecularIntensity;$.materialSpecularStrength;$.materialThickness;$.materialTransmission;$.max;$.maxMipLevel;$.metalness;$.min;$.mix;$.mixElement;$.mod;$.modInt;$.modelDirection;$.modelNormalMatrix;$.modelPosition;$.modelScale;$.modelViewMatrix;$.modelViewPosition;$.modelViewProjection;$.modelWorldMatrix;$.modelWorldMatrixInverse;$.morphReference;$.mrt;$.mul;$.mx_aastep;$.mx_cell_noise_float;$.mx_contrast;$.mx_fractal_noise_float;$.mx_fractal_noise_vec2;$.mx_fractal_noise_vec3;$.mx_fractal_noise_vec4;$.mx_hsvtorgb;$.mx_noise_float;$.mx_noise_vec3;$.mx_noise_vec4;$.mx_ramplr;$.mx_ramptb;$.mx_rgbtohsv;$.mx_safepower;$.mx_splitlr;$.mx_splittb;$.mx_srgb_texture_to_lin_rec709;$.mx_transform_uv;$.mx_worley_noise_float;$.mx_worley_noise_vec2;$.mx_worley_noise_vec3;const _le=$.negate;$.neutralToneMapping;$.nodeArray;$.nodeImmutable;$.nodeObject;$.nodeObjects;$.nodeProxy;$.normalFlat;$.normalGeometry;$.normalLocal;$.normalMap;$.normalView;$.normalWorld;$.normalize;$.not;$.notEqual;$.numWorkgroups;$.objectDirection;$.objectGroup;$.objectPosition;$.objectScale;$.objectViewPosition;$.objectWorldMatrix;$.oneMinus;$.or;$.orthographicDepthToViewZ;$.oscSawtooth;$.oscSine;$.oscSquare;$.oscTriangle;$.output;$.outputStruct;$.overlay;$.overloadingFn;$.parabola;$.parallaxDirection;$.parallaxUV;$.parameter;$.pass;$.passTexture;$.pcurve;$.perspectiveDepthToViewZ;$.pmremTexture;$.pointUV;$.pointWidth;$.positionGeometry;$.positionLocal;$.positionPrevious;$.positionView;$.positionViewDirection;$.positionWorld;$.positionWorldDirection;$.posterize;$.pow;$.pow2;$.pow3;$.pow4;$.property;$.radians;$.rand;$.range;$.rangeFog;$.rangeFogFactor;$.reciprocal;$.reference;$.referenceBuffer;$.reflect;$.reflectVector;$.reflectView;$.reflector;$.refract;$.refractVector;$.refractView;$.reinhardToneMapping;$.remainder;$.remap;$.remapClamp;$.renderGroup;$.renderOutput;$.rendererReference;$.rotate;$.rotateUV;$.roughness;$.round;$.rtt;$.sRGBTransferEOTF;$.sRGBTransferOETF;$.sampler;$.saturate;$.saturation;$.screen;$.screenCoordinate;$.screenSize;$.screenUV;$.scriptable;$.scriptableValue;$.select;$.setCurrentStack;$.shaderStages;$.shadow;$.shadowPositionWorld;$.sharedUniformGroup;$.sheen;$.sheenRoughness;$.shiftLeft;$.shiftRight;$.shininess;$.sign;const yle=$.sin;$.sinc;$.skinning;$.skinningReference;$.smoothstep;$.smoothstepElement;$.specularColor;$.specularF90;$.spherizeUV;$.split;$.spritesheetUV;const xle=$.sqrt;$.stack;$.step;const ble=$.storage;$.storageBarrier;$.storageObject;$.storageTexture;$.string;$.sub;$.subgroupIndex;$.subgroupSize;$.tan;$.tangentGeometry;$.tangentLocal;$.tangentView;$.tangentWorld;$.temp;$.texture;$.texture3D;$.textureBarrier;$.textureBicubic;$.textureCubeUV;$.textureLoad;$.textureSize;$.textureStore;$.thickness;$.threshold;$.time;$.timerDelta;$.timerGlobal;$.timerLocal;$.toOutputColorSpace;$.toWorkingColorSpace;$.toneMapping;$.toneMappingExposure;$.toonOutlinePass;$.transformDirection;$.transformNormal;$.transformNormalToView;$.transformedBentNormalView;$.transformedBitangentView;$.transformedBitangentWorld;$.transformedClearcoatNormalView;$.transformedNormalView;$.transformedNormalWorld;$.transformedTangentView;$.transformedTangentWorld;$.transmission;$.transpose;$.tri;$.tri3;$.triNoise3D;$.triplanarTexture;$.triplanarTextures;$.trunc;$.tslFn;$.uint;const Sle=$.uniform;$.uniformArray;$.uniformGroup;$.uniforms;$.userData;$.uv;$.uvec2;$.uvec3;$.uvec4;$.varying;$.varyingProperty;$.vec2;$.vec3;$.vec4;$.vectorComponents;$.velocity;$.vertexColor;$.vertexIndex;$.vibrance;$.viewZToLogarithmicDepth;$.viewZToOrthographicDepth;$.viewZToPerspectiveDepth;$.viewport;$.viewportBottomLeft;$.viewportCoordinate;$.viewportDepthTexture;$.viewportLinearDepth;$.viewportMipTexture;$.viewportResolution;$.viewportSafeUV;$.viewportSharedTexture;$.viewportSize;$.viewportTexture;$.viewportTopLeft;$.viewportUV;$.wgsl;$.wgslFn;$.workgroupArray;$.workgroupBarrier;$.workgroupId;$.workingToColorSpace;$.xor;const I6=new Yc,Mv=new de;class hO extends Kz{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Ci(e,3)),this.setAttribute("uv",new Ci(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new h_(t,6,1);return this.setAttribute("instanceStart",new cu(n,3,0)),this.setAttribute("instanceEnd",new cu(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new h_(t,6,1);return this.setAttribute("instanceColorStart",new cu(n,3,0)),this.setAttribute("instanceColorEnd",new cu(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Dz(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yc);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),I6.setFromBufferAttribute(t),this.boundingBox.union(I6))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new gd),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let s=0,a=e.count;s + #include + #include + #include + #include + + uniform float linewidth; + uniform vec2 resolution; + + attribute vec3 instanceStart; + attribute vec3 instanceEnd; + + attribute vec3 instanceColorStart; + attribute vec3 instanceColorEnd; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #ifdef USE_DASH + + uniform float dashScale; + attribute float instanceDistanceStart; + attribute float instanceDistanceEnd; + varying float vLineDistance; + + #endif + + void trimSegment( const in vec4 start, inout vec4 end ) { + + // trim end segment so it terminates between the camera plane and the near plane + + // conservative estimate of the near plane + float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column + float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column + float nearEstimate = - 0.5 * b / a; + + float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); + + end.xyz = mix( start.xyz, end.xyz, alpha ); + + } + + void main() { + + #ifdef USE_COLOR + + vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; + + #endif + + #ifdef USE_DASH + + vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; + vUv = uv; + + #endif + + float aspect = resolution.x / resolution.y; + + // camera space + vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); + vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); + + #ifdef WORLD_UNITS + + worldStart = start.xyz; + worldEnd = end.xyz; + + #else + + vUv = uv; + + #endif + + // special case for perspective projection, and segments that terminate either in, or behind, the camera plane + // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space + // but we need to perform ndc-space calculations in the shader, so we must address this issue directly + // perhaps there is a more elegant solution -- WestLangley + + bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column + + if ( perspective ) { + + if ( start.z < 0.0 && end.z >= 0.0 ) { + + trimSegment( start, end ); + + } else if ( end.z < 0.0 && start.z >= 0.0 ) { + + trimSegment( end, start ); + + } + + } + + // clip space + vec4 clipStart = projectionMatrix * start; + vec4 clipEnd = projectionMatrix * end; + + // ndc space + vec3 ndcStart = clipStart.xyz / clipStart.w; + vec3 ndcEnd = clipEnd.xyz / clipEnd.w; + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize( dir ); + + #ifdef WORLD_UNITS + + vec3 worldDir = normalize( end.xyz - start.xyz ); + vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); + vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); + vec3 worldFwd = cross( worldDir, worldUp ); + worldPos = position.y < 0.5 ? start: end; + + // height offset + float hw = linewidth * 0.5; + worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; + + // don't extend the line if we're rendering dashes because we + // won't be rendering the endcaps + #ifndef USE_DASH + + // cap extension + worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; + + // add width to the box + worldPos.xyz += worldFwd * hw; + + // endcaps + if ( position.y > 1.0 || position.y < 0.0 ) { + + worldPos.xyz -= worldFwd * 2.0 * hw; + + } + + #endif + + // project the worldpos + vec4 clip = projectionMatrix * worldPos; + + // shift the depth of the projected points so the line + // segments overlap neatly + vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; + clip.z = clipPose.z * clip.w; + + #else + + vec2 offset = vec2( dir.y, - dir.x ); + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if ( position.x < 0.0 ) offset *= - 1.0; + + // endcaps + if ( position.y < 0.0 ) { + + offset += - dir; + + } else if ( position.y > 1.0 ) { + + offset += dir; + + } + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... + offset /= resolution.y; + + // select end + vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; + + // back to clip space + offset *= clip.w; + + clip.xy += offset; + + #endif + + gl_Position = clip; + + vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation + + #include + #include + #include + + } + `,fragmentShader:` + uniform vec3 diffuse; + uniform float opacity; + uniform float linewidth; + + #ifdef USE_DASH + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + #endif + + varying float vLineDistance; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #include + #include + #include + #include + #include + + vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { + + float mua; + float mub; + + vec3 p13 = p1 - p3; + vec3 p43 = p4 - p3; + + vec3 p21 = p2 - p1; + + float d1343 = dot( p13, p43 ); + float d4321 = dot( p43, p21 ); + float d1321 = dot( p13, p21 ); + float d4343 = dot( p43, p43 ); + float d2121 = dot( p21, p21 ); + + float denom = d2121 * d4343 - d4321 * d4321; + + float numer = d1343 * d4321 - d1321 * d4343; + + mua = numer / denom; + mua = clamp( mua, 0.0, 1.0 ); + mub = ( d1343 + d4321 * ( mua ) ) / d4343; + mub = clamp( mub, 0.0, 1.0 ); + + return vec2( mua, mub ); + + } + + void main() { + + #include + + #ifdef USE_DASH + + if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps + + if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX + + #endif + + float alpha = opacity; + + #ifdef WORLD_UNITS + + // Find the closest points on the view ray and the line segment + vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; + vec3 lineDir = worldEnd - worldStart; + vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); + + vec3 p1 = worldStart + lineDir * params.x; + vec3 p2 = rayEnd * params.y; + vec3 delta = p1 - p2; + float len = length( delta ); + float norm = len / linewidth; + + #ifndef USE_DASH + + #ifdef USE_ALPHA_TO_COVERAGE + + float dnorm = fwidth( norm ); + alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); + + #else + + if ( norm > 0.5 ) { + + discard; + + } + + #endif + + #endif + + #else + + #ifdef USE_ALPHA_TO_COVERAGE + + // artifacts appear on some hardware if a derivative is taken within a conditional + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + float dlen = fwidth( len2 ); + + if ( abs( vUv.y ) > 1.0 ) { + + alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); + + } + + #else + + if ( abs( vUv.y ) > 1.0 ) { + + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + + if ( len2 > 1.0 ) discard; + + } + + #endif + + #endif + + vec4 diffuseColor = vec4( diffuse, alpha ); + + #include + #include + + gl_FragColor = vec4( diffuseColor.rgb, alpha ); + + #include + #include + #include + #include + + } + `};class jE extends so{constructor(e){super({type:"LineMaterial",uniforms:vy.clone($a.line.uniforms),vertexShader:$a.line.vertexShader,fragmentShader:$a.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const ES=new qn,F6=new de,k6=new de,Hs=new qn,Ws=new qn,Jl=new qn,CS=new de,NS=new Xn,$s=new eG,z6=new de,Ev=new Yc,Cv=new gd,eu=new qn;let ou,od;function G6(i,e,t){return eu.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),eu.multiplyScalar(1/eu.w),eu.x=od/t.width,eu.y=od/t.height,eu.applyMatrix4(i.projectionMatrixInverse),eu.multiplyScalar(1/eu.w),Math.abs(Math.max(eu.x,eu.y))}function Tle(i,e){const t=i.matrixWorld,n=i.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,r.count);for(let l=0,u=a;lv&&Ws.z>v)continue;if(Hs.z>v){const U=Hs.z-Ws.z,I=(Hs.z-v)/U;Hs.lerp(Ws,I)}else if(Ws.z>v){const U=Ws.z-Hs.z,I=(Ws.z-v)/U;Ws.lerp(Hs,I)}Hs.applyMatrix4(n),Ws.applyMatrix4(n),Hs.multiplyScalar(1/Hs.w),Ws.multiplyScalar(1/Ws.w),Hs.x*=s.x/2,Hs.y*=s.y/2,Ws.x*=s.x/2,Ws.y*=s.y/2,$s.start.copy(Hs),$s.start.z=0,$s.end.copy(Ws),$s.end.z=0;const N=$s.closestPointToPointParameter(CS,!0);$s.at(N,z6);const C=N0.lerp(Hs.z,Ws.z,N),E=C>=-1&&C<=1,O=CS.distanceTo(z6)i.length)&&(e=i.length);for(var t=0,n=Array(e);t3?(K=be===Q)&&(W=ae[(G=ae[4])?5:(G=3,3)],ae[4]=ae[5]=i):ae[0]<=Ae&&((K=le<2&&AeQ||Q>be)&&(ae[4]=le,ae[5]=Q,te.n=be,G=0))}if(K||le>1)return a;throw Y=!0,Q}return function(le,Q,K){if(q>1)throw TypeError("Generator is already running");for(Y&&Q===1&&ne(Q,K),G=Q,W=K;(e=G<2?i:W)||!Y;){z||(G?G<3?(G>1&&(te.n=-1),ne(G,W)):te.n=W:te.v=W);try{if(q=2,z){if(G||(le="next"),e=z[le]){if(!(e=e.call(z,W)))throw TypeError("iterator result is not an object");if(!e.done)return e;W=e.value,G<2&&(G=0)}else G===1&&(e=z.return)&&e.call(z),G<2&&(W=TypeError("The iterator does not provide a '"+le+"' method"),G=1);z=i}else if((e=(Y=te.n<0)?W:U.call(I,te))!==a)break}catch(ae){z=i,G=1,W=ae}finally{q=1}}return{value:e,done:Y}}})(S,N,C),!0),O}var a={};function l(){}function u(){}function h(){}e=Object.getPrototypeOf;var m=[][n]?e(e([][n]())):(Co(e={},n,function(){return this}),e),v=h.prototype=l.prototype=Object.create(m);function x(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,Co(S,r,"GeneratorFunction")),S.prototype=Object.create(v),S}return u.prototype=h,Co(v,"constructor",h),Co(h,"constructor",u),u.displayName="GeneratorFunction",Co(h,r,"GeneratorFunction"),Co(v),Co(v,r,"Generator"),Co(v,n,function(){return this}),Co(v,"toString",function(){return"[object Generator]"}),(lw=function(){return{w:s,m:x}})()}function Co(i,e,t,n){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}Co=function(s,a,l,u){function h(m,v){Co(s,m,function(x){return this._invoke(m,v,x)})}a?r?r(s,a,{value:l,enumerable:!u,configurable:!u,writable:!u}):s[a]=l:(h("next",0),h("throw",1),h("return",2))},Co(i,e,t,n)}function uw(i,e){return uw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},uw(i,e)}function Sr(i,e){return Dle(i)||Fle(i,e)||pO(i,e)||kle()}function jle(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=V0(i))!==null;);return i}function PS(i,e,t,n){var r=ow(V0(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function Zi(i){return Ple(i)||Ile(i)||pO(i)||zle()}function Hle(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function AO(i){var e=Hle(i,"string");return typeof e=="symbol"?e:e+""}function pO(i,e){if(i){if(typeof i=="string")return aw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?aw(i,e):void 0}}var mO=function(e){e instanceof Array?e.forEach(mO):(e.map&&e.map.dispose(),e.dispose())},$E=function(e){e.geometry&&e.geometry.dispose(),e.material&&mO(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach($E)},sr=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),$E(t)}};function Pa(i,e){var t=new e;return{linkProp:function(r){return{default:t[r](),onChange:function(a,l){l[i][r](a)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var a=s[i],l=arguments.length,u=new Array(l>1?l-1:0),h=1;h2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180,s=mr*(1+t),a=Math.sin(n);return{x:s*a*Math.cos(r),y:s*Math.cos(n),z:s*a*Math.sin(r)}}function gO(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),a=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),altitude:r/mr-1}}function Wf(i){return i*Math.PI/180}var Lg=window.THREE?window.THREE:{BackSide:gr,BufferAttribute:Lr,Color:mn,Mesh:qi,ShaderMaterial:so},Wle=` +uniform float hollowRadius; + +varying vec3 vVertexWorldPosition; +varying vec3 vVertexNormal; +varying float vCameraDistanceToObjCenter; +varying float vVertexAngularDistanceToHollowRadius; + +void main() { + vVertexNormal = normalize(normalMatrix * normal); + vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; + + vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); + vCameraDistanceToObjCenter = length(objCenterViewPosition); + + float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter); + float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition))); + vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle; + + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +}`,$le=` +uniform vec3 color; +uniform float coefficient; +uniform float power; +uniform float hollowRadius; + +varying vec3 vVertexNormal; +varying vec3 vVertexWorldPosition; +varying float vCameraDistanceToObjCenter; +varying float vVertexAngularDistanceToHollowRadius; + +void main() { + if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius + if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius + + vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition; + vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz; + viewCameraToVertex = normalize(viewCameraToVertex); + float intensity = pow( + coefficient + dot(vVertexNormal, viewCameraToVertex), + power + ); + gl_FragColor = vec4(color, intensity); +}`;function Xle(i,e,t,n){return new Lg.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:Wle,fragmentShader:$le,uniforms:{coefficient:{value:i},color:{value:new Lg.Color(e)},power:{value:t},hollowRadius:{value:n}}})}function Yle(i,e){for(var t=i.clone(),n=new Float32Array(i.attributes.position.count*3),r=0,s=n.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.color,a=s===void 0?"gold":s,l=r.size,u=l===void 0?2:l,h=r.coefficient,m=h===void 0?.5:h,v=r.power,x=v===void 0?1:v,S=r.hollowRadius,w=S===void 0?0:S,N=r.backside,C=N===void 0?!0:N;nx(this,e),n=tx(this,e);var E=Yle(t,u),O=Xle(m,a,x,w);return C&&(O.side=Lg.BackSide),n.geometry=E,n.material=O,n}return rx(e,i),ix(e)})(Lg.Mesh),tu=window.THREE?window.THREE:{Color:mn,Group:Ka,LineBasicMaterial:Q0,LineSegments:Y7,Mesh:qi,MeshPhongMaterial:oD,SphereGeometry:Bu,SRGBColorSpace:Nn,TextureLoader:aM},vO=Rs({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){sr(e.globeObj),sr(e.tileEngine),sr(e.graticulesObj)}},stateInit:function(){var e=new tu.MeshPhongMaterial({color:0}),t=new tu.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new sY(mr),r=new tu.Group;r.__globeObjType="globe",r.add(t),r.add(n);var s=new tu.LineSegments(new AP(SX(),mr,2),new tu.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:r,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){sr(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var r;(r=e.globeObj.geometry)===null||r===void 0||r.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new tu.SphereGeometry(mr,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new tu.TextureLoader().load(e.globeImageUrl,function(l){l.colorSpace=tu.SRGBColorSpace,n.map=l,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new tu.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new tu.TextureLoader().load(e.bumpImageUrl,function(l){n.bumpMap=l,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),sr(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new Qle(e.globeObj.geometry,{color:e.atmosphereColor,size:mr*e.atmosphereAltitude,hollowRadius:mr,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType="atmosphere",e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),Lu=function(e){return isNaN(e)?parseInt(Rn(e).toHex(),16):e},kl=function(e){return e&&isNaN(e)?dd(e).opacity:1},Kh=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,s=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var l=a.slice(1),u=Sr(l,4),h=u[0],m=u[1],v=u[2],x=u[3];r=new mn("rgb(".concat(+h,",").concat(+m,",").concat(+v,")")),s=Math.min(+x,1)}else r=new mn(e);n&&r.convertLinearToSRGB();var S=r.toArray();return t?[].concat(Zi(S),[s]):S};function Kle(i,e,t){return i.opacity=e,i.transparent=e<1,i.depthWrite=e>=1,i}var W6=window.THREE?window.THREE:{BufferAttribute:Lr};function Uu(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(e===1)return new W6.BufferAttribute(new t(i),e);for(var n=new W6.BufferAttribute(new t(i.length*e),e),r=0,s=i.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.dataBindAttr,a=s===void 0?"__data":s,l=r.objBindAttr,u=l===void 0?"__threeObj":l,h=r.removeDelay,m=h===void 0?0:h;return nx(this,e),n=tx(this,e),Gs(n,"scene",void 0),RS(n,LS,void 0),RS(n,Nv,void 0),RS(n,Rv,void 0),n.scene=t,DS(LS,n,a),DS(Nv,n,u),DS(Rv,n,m),n.onRemoveObj(function(){}),n}return rx(e,i),ix(e,[{key:"onCreateObj",value:function(n){var r=this;return PS(e,"onCreateObj",this)([function(s){var a=n(s);return s[gm(Nv,r)]=a,a[gm(LS,r)]=s,r.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return PS(e,"onRemoveObj",this)([function(s,a){var l=PS(e,"getData",r)([s]);n(s,a);var u=function(){r.scene.remove(s),sr(s),delete l[gm(Nv,r)]};gm(Rv,r)?setTimeout(u,gm(Rv,r)):u()}]),this}}])})(UQ),Nl=window.THREE?window.THREE:{BufferGeometry:Ji,CylinderGeometry:nM,Matrix4:Xn,Mesh:qi,MeshLambertMaterial:Kc,Object3D:Tr,Vector3:de},$6=Object.assign({},bM),X6=$6.BufferGeometryUtils||$6,_O=Rs({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var n=kt(e.pointLat),r=kt(e.pointLng),s=kt(e.pointAltitude),a=kt(e.pointRadius),l=kt(e.pointColor),u=new Nl.CylinderGeometry(1,1,1,e.pointResolution);u.applyMatrix4(new Nl.Matrix4().makeRotationX(Math.PI/2)),u.applyMatrix4(new Nl.Matrix4().makeTranslation(0,0,-.5));var h=2*Math.PI*mr/360,m={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&sr(e.scene),e.dataMapper.scene=e.pointsMerge?new Nl.Object3D:e.scene,e.dataMapper.onCreateObj(S).onUpdateObj(w).digest(e.pointsData),e.pointsMerge){var v=e.pointsData.length?(X6.mergeGeometries||X6.mergeBufferGeometries)(e.pointsData.map(function(N){var C=e.dataMapper.getObj(N),E=C.geometry.clone();C.updateMatrix(),E.applyMatrix4(C.matrix);var O=Kh(l(N));return E.setAttribute("color",Uu(Array(E.getAttribute("position").count).fill(O),4)),E})):new Nl.BufferGeometry,x=new Nl.Mesh(v,new Nl.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));x.__globeObjType="points",x.__data=e.pointsData,e.dataMapper.clear(),sr(e.scene),e.scene.add(x)}function S(){var N=new Nl.Mesh(u);return N.__globeObjType="point",N}function w(N,C){var E=function(W){var q=N.__currentTargetD=W,V=q.r,Y=q.alt,te=q.lat,ne=q.lng;Object.assign(N.position,ul(te,ne));var le=e.pointsMerge?new Nl.Vector3(0,0,0):e.scene.localToWorld(new Nl.Vector3(0,0,0));N.lookAt(le),N.scale.x=N.scale.y=Math.min(30,V)*h,N.scale.z=Math.max(Y*mr,.1)},O={alt:+s(C),r:+a(C),lat:+n(C),lng:+r(C)},U=N.__currentTargetD||Object.assign({},O,{alt:-.001});if(Object.keys(O).some(function(G){return U[G]!==O[G]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?E(O):e.tweenGroup.add(new va(U).to(O,e.pointsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(E).start())),!e.pointsMerge){var I=l(C),j=I?kl(I):0,z=!!j;N.visible=z,z&&(m.hasOwnProperty(I)||(m[I]=new Nl.MeshLambertMaterial({color:Lu(I),transparent:j<1,opacity:j})),N.material=m[I])}}}}),yO=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` + `.concat(ni.common,` + `).concat(ni.logdepthbuf_pars_vertex,` + + uniform float dashTranslate; + + attribute vec4 color; + varying vec4 vColor; + + attribute float relDistance; + varying float vRelDistance; + + void main() { + // pass through colors and distances + vColor = color; + vRelDistance = relDistance + dashTranslate; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + + `).concat(ni.logdepthbuf_vertex,` + } + `),fragmentShader:` + `.concat(ni.logdepthbuf_pars_fragment,` + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + varying vec4 vColor; + varying float vRelDistance; + + void main() { + // ignore pixels in the gap + if (vRelDistance < dashOffset) discard; + if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard; + + // set px color: [r, g, b, a], interpolated between vertices + gl_FragColor = vColor; + + `).concat(ni.logdepthbuf_fragment,` + } + `)}},cw=function(e){return e.uniforms.uSurfaceRadius={type:"float",value:0},e.vertexShader=(`attribute float surfaceRadius; +varying float vSurfaceRadius; +varying vec3 vPos; +`+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join(` +`)),e.fragmentShader=(`uniform float uSurfaceRadius; +varying float vSurfaceRadius; +varying vec3 vPos; +`+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;"].join(` +`)),e},Jle=function(e){return e.vertexShader=` + attribute float r; + + const float PI = 3.1415926535897932384626433832795; + float toRad(in float a) { + return a * PI / 180.0; + } + + vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r] + float phi = toRad(90.0 - c.x); + float theta = toRad(90.0 - c.y); + float r = c.z; + return vec3( // x,y,z + r * sin(phi) * cos(theta), + r * cos(phi), + r * sin(phi) * sin(theta) + ); + } + + vec2 Cartesian2Polar(in vec3 p) { + float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z); + float phi = acos(p.y / r); + float theta = atan(p.z, p.x); + return vec2( // lat,lng + 90.0 - phi * 180.0 / PI, + 90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0) + ); + } + `.concat(e.vertexShader.replace("}",` + vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r)); + gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); + } + `),` + `),e},XE=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},eue=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(r){return r};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(r){n(r),t(r.uniforms)}}},tue=["stroke"],Rl=window.THREE?window.THREE:{BufferGeometry:Ji,CubicBezierCurve3:Z7,Curve:ql,Group:Ka,Line:xy,Mesh:qi,NormalBlending:io,ShaderMaterial:so,TubeGeometry:rM,Vector3:de},nue=O0.default||O0,xO=Rs({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new nue,sharedMaterial:new Rl.ShaderMaterial(Wi(Wi({},yO()),{},{transparent:!0,blending:Rl.NormalBlending}))}},init:function(e,t){sr(e),t.scene=e,t.dataMapper=new fo(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var n=new Rl.Group;return n.__globeObjType="arc",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Sr(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r,u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l})})},update:function(e){var t=kt(e.arcStartLat),n=kt(e.arcStartLng),r=kt(e.arcStartAltitude),s=kt(e.arcEndLat),a=kt(e.arcEndLng),l=kt(e.arcEndAltitude),u=kt(e.arcAltitude),h=kt(e.arcAltitudeAutoScale),m=kt(e.arcStroke),v=kt(e.arcColor),x=kt(e.arcDashLength),S=kt(e.arcDashGap),w=kt(e.arcDashInitialGap),N=kt(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(U,I){var j=m(I),z=j!=null;if(!U.children.length||z!==(U.children[0].type==="Mesh")){sr(U);var G=z?new Rl.Mesh:new Rl.Line(new Rl.BufferGeometry);G.material=e.sharedMaterial.clone(),U.add(G)}var W=U.children[0];Object.assign(W.material.uniforms,{dashSize:{value:x(I)},gapSize:{value:S(I)},dashOffset:{value:w(I)}});var q=N(I);W.__dashAnimateStep=q>0?1e3/q:0;var V=E(v(I),e.arcCurveResolution,z?e.arcCircularResolution+1:1),Y=O(e.arcCurveResolution,z?e.arcCircularResolution+1:1,!0);W.geometry.setAttribute("color",V),W.geometry.setAttribute("relDistance",Y);var te=function(K){var ae=U.__currentTargetD=K,Ae=ae.stroke,be=Gle(ae,tue),Se=C(be);z?(W.geometry&&W.geometry.dispose(),W.geometry=new Rl.TubeGeometry(Se,e.arcCurveResolution,Ae/2,e.arcCircularResolution),W.geometry.setAttribute("color",V),W.geometry.setAttribute("relDistance",Y)):W.geometry.setFromPoints(Se.getPoints(e.arcCurveResolution))},ne={stroke:j,alt:u(I),altAutoScale:+h(I),startLat:+t(I),startLng:+n(I),startAlt:+r(I),endLat:+s(I),endLng:+a(I),endAlt:+l(I)},le=U.__currentTargetD||Object.assign({},ne,{altAutoScale:-.001});Object.keys(ne).some(function(Q){return le[Q]!==ne[Q]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?te(ne):e.tweenGroup.add(new va(le).to(ne,e.arcsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(te).start()))}).digest(e.arcsData);function C(U){var I=U.alt,j=U.altAutoScale,z=U.startLat,G=U.startLng,W=U.startAlt,q=U.endLat,V=U.endLng,Y=U.endAlt,te=function(Qe){var et=Sr(Qe,3),Pt=et[0],Nt=et[1],Gt=et[2],Tt=ul(Nt,Pt,Gt),Ge=Tt.x,dt=Tt.y,he=Tt.z;return new Rl.Vector3(Ge,dt,he)},ne=[G,z],le=[V,q],Q=I;if(Q==null&&(Q=Yh(ne,le)/2*j+Math.max(W,Y)),Q||W||Y){var K=gM(ne,le),ae=function(Qe,et){return et+(et-Qe)*(Qe2&&arguments[2]!==void 0?arguments[2]:1,z=I+1,G;if(U instanceof Array||U instanceof Function){var W=U instanceof Array?zc().domain(U.map(function(Q,K){return K/(U.length-1)})).range(U):U;G=function(K){return Kh(W(K),!0,!0)}}else{var q=Kh(U,!0,!0);G=function(){return q}}for(var V=[],Y=0,te=z;Y1&&arguments[1]!==void 0?arguments[1]:1,j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,z=U+1,G=[],W=0,q=z;W=W?j:z}),4)),I})):new Dh.BufferGeometry,w=new Dh.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:Dh.DoubleSide});w.onBeforeCompile=function(O){w.userData.shader=cw(O)};var N=new Dh.Mesh(S,w);N.__globeObjType="hexBinPoints",N.__data=v,e.dataMapper.clear(),sr(e.scene),e.scene.add(N)}function C(O){var U=new Dh.Mesh;U.__hexCenter=LP(O.h3Idx),U.__hexGeoJson=UP(O.h3Idx,!0).reverse();var I=U.__hexCenter[1];return U.__hexGeoJson.forEach(function(j){var z=j[0];Math.abs(I-z)>170&&(j[0]+=I>z?360:-360)}),U.__globeObjType="hexbin",U}function E(O,U){var I=function(ae,Ae,be){return ae-(ae-Ae)*be},j=Math.max(0,Math.min(1,+h(U))),z=Sr(O.__hexCenter,2),G=z[0],W=z[1],q=j===0?O.__hexGeoJson:O.__hexGeoJson.map(function(K){var ae=Sr(K,2),Ae=ae[0],be=ae[1];return[[Ae,W],[be,G]].map(function(Se){var se=Sr(Se,2),Ee=se[0],qe=se[1];return I(Ee,qe,j)})}),V=e.hexTopCurvatureResolution;O.geometry&&O.geometry.dispose(),O.geometry=new EM([q],0,mr,!1,!0,!0,V);var Y={alt:+a(U)},te=function(ae){var Ae=O.__currentTargetD=ae,be=Ae.alt;O.scale.x=O.scale.y=O.scale.z=1+be;var Se=mr/(be+1);O.geometry.setAttribute("surfaceRadius",Uu(Array(O.geometry.getAttribute("position").count).fill(Se),1))},ne=O.__currentTargetD||Object.assign({},Y,{alt:-.001});if(Object.keys(Y).some(function(K){return ne[K]!==Y[K]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?te(Y):e.tweenGroup.add(new va(ne).to(Y,e.hexTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(te).start())),!e.hexBinMerge){var le=u(U),Q=l(U);[le,Q].forEach(function(K){if(!x.hasOwnProperty(K)){var ae=kl(K);x[K]=XE(new Dh.MeshLambertMaterial({color:Lu(K),transparent:ae<1,opacity:ae,side:Dh.DoubleSide}),cw)}}),O.material=[le,Q].map(function(K){return x[K]})}}}}),SO=function(e){return e*e},Lc=function(e){return e*Math.PI/180};function iue(i,e){var t=Math.sqrt,n=Math.cos,r=function(m){return SO(Math.sin(m/2))},s=Lc(i[1]),a=Lc(e[1]),l=Lc(i[0]),u=Lc(e[0]);return 2*Math.asin(t(r(a-s)+n(s)*n(a)*r(u-l)))}var rue=Math.sqrt(2*Math.PI);function sue(i,e){return Math.exp(-SO(i/e)/2)/(e*rue)}var aue=function(e){var t=Sr(e,2),n=t[0],r=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},l=a.lngAccessor,u=l===void 0?function(C){return C[0]}:l,h=a.latAccessor,m=h===void 0?function(C){return C[1]}:h,v=a.weightAccessor,x=v===void 0?function(){return 1}:v,S=a.bandwidth,w=[n,r],N=S*Math.PI/180;return JW(s.map(function(C){var E=x(C);if(!E)return 0;var O=iue(w,[u(C),m(C)]);return sue(O,N)*E}))},oue=(function(){var i=Ule(lw().m(function e(t){var n,r,s,a,l,u,h,m,v,x,S,w,N,C,E,O,U,I,j,z,G,W,q,V,Y,te,ne,le,Q,K,ae,Ae,be,Se,se,Ee,qe,Ce,ke,Qe,et=arguments,Pt,Nt,Gt;return lw().w(function(Tt){for(;;)switch(Tt.n){case 0:if(r=et.length>1&&et[1]!==void 0?et[1]:[],s=et.length>2&&et[2]!==void 0?et[2]:{},a=s.lngAccessor,l=a===void 0?function(Ge){return Ge[0]}:a,u=s.latAccessor,h=u===void 0?function(Ge){return Ge[1]}:u,m=s.weightAccessor,v=m===void 0?function(){return 1}:m,x=s.bandwidth,(n=navigator)!==null&&n!==void 0&&n.gpu){Tt.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),Tt.a(2,t.map(function(Ge){return aue(Ge,r,{lngAccessor:l,latAccessor:h,weightAccessor:v,bandwidth:x})}));case 1:return S=4,w=hle,N=fle,C=Sle,E=ble,O=gle,U=vle,I=dle,j=xle,z=yle,G=ple,W=Ale,q=mle,V=_le,Y=E(new t_(new Float32Array(t.flat().map(Lc)),2),"vec2",t.length),te=E(new t_(new Float32Array(r.map(function(Ge){return[Lc(l(Ge)),Lc(h(Ge)),v(Ge)]}).flat()),3),"vec3",r.length),ne=new t_(t.length,1),le=E(ne,"float",t.length),Q=O(Math.PI),K=j(Q.mul(2)),ae=function(dt){return dt.mul(dt)},Ae=function(dt){return ae(z(dt.div(2)))},be=function(dt,he){var en=O(dt[1]),wt=O(he[1]),qt=O(dt[0]),Lt=O(he[0]);return O(2).mul(W(j(Ae(wt.sub(en)).add(G(en).mul(G(wt)).mul(Ae(Lt.sub(qt)))))))},Se=function(dt,he){return q(V(ae(dt.div(he)).div(2))).div(he.mul(K))},se=C(Lc(x)),Ee=C(Lc(x*S)),qe=C(r.length),Ce=w(function(){var Ge=Y.element(U),dt=le.element(U);dt.assign(0),I(qe,function(he){var en=he.i,wt=te.element(en),qt=wt.z;N(qt,function(){var Lt=be(wt.xy,Ge.xy);N(Lt&&Lt.lessThan(Ee),function(){dt.addAssign(Se(Lt,se).mul(qt))})})})}),ke=Ce().compute(t.length),Qe=new cO,Tt.n=2,Qe.computeAsync(ke);case 2:return Pt=Array,Nt=Float32Array,Tt.n=3,Qe.getArrayBufferAsync(ne);case 3:return Gt=Tt.v,Tt.a(2,Pt.from.call(Pt,new Nt(Gt)))}},e)}));return function(t){return i.apply(this,arguments)}})(),Dv=window.THREE?window.THREE:{Mesh:qi,MeshLambertMaterial:Kc,SphereGeometry:Bu},lue=3.5,uue=.1,K6=100,cue=function(e){var t=dd(VZ(e));return t.opacity=Math.cbrt(e),t.formatRgb()},TO=Rs({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return cue}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var s=new Dv.Mesh(new Dv.SphereGeometry(mr),XE(new Dv.MeshLambertMaterial({vertexColors:!0,transparent:!0}),Jle));return s.__globeObjType="heatmap",s})},update:function(e){var t=kt(e.heatmapPoints),n=kt(e.heatmapPointLat),r=kt(e.heatmapPointLng),s=kt(e.heatmapPointWeight),a=kt(e.heatmapBandwidth),l=kt(e.heatmapColorFn),u=kt(e.heatmapColorSaturation),h=kt(e.heatmapBaseAltitude),m=kt(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(v,x){var S=a(x),w=l(x),N=u(x),C=h(x),E=m(x),O=t(x).map(function(G){var W=n(G),q=r(G),V=ul(W,q),Y=V.x,te=V.y,ne=V.z;return{x:Y,y:te,z:ne,lat:W,lng:q,weight:s(G)}}),U=Math.max(uue,S/lue),I=Math.ceil(360/(U||-1));v.geometry.parameters.widthSegments!==I&&(v.geometry.dispose(),v.geometry=new Dv.SphereGeometry(mr,I,I/2));var j=Zle(v.geometry.getAttribute("position")),z=j.map(function(G){var W=Sr(G,3),q=W[0],V=W[1],Y=W[2],te=gO({x:q,y:V,z:Y}),ne=te.lng,le=te.lat;return[ne,le]});oue(z,O,{latAccessor:function(W){return W.lat},lngAccessor:function(W){return W.lng},weightAccessor:function(W){return W.weight},bandwidth:S}).then(function(G){var W=Zi(new Array(K6)).map(function(te,ne){return Kh(w(ne/(K6-1)))}),q=function(ne){var le=v.__currentTargetD=ne,Q=le.kdeVals,K=le.topAlt,ae=le.saturation,Ae=QW(Q.map(Math.abs))||1e-15,be=UD([0,Ae/ae],W);v.geometry.setAttribute("color",Uu(Q.map(function(se){return be(Math.abs(se))}),4));var Se=zc([0,Ae],[mr*(1+C),mr*(1+(K||C))]);v.geometry.setAttribute("r",Uu(Q.map(Se)))},V={kdeVals:G,topAlt:E,saturation:N},Y=v.__currentTargetD||Object.assign({},V,{kdeVals:G.map(function(){return 0}),topAlt:E&&C,saturation:.5});Y.kdeVals.length!==G.length&&(Y.kdeVals=G.slice()),Object.keys(V).some(function(te){return Y[te]!==V[te]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?q(V):e.tweenGroup.add(new va(Y).to(V,e.heatmapsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(q).start()))})}).digest(e.heatmapsData)}}),Ph=window.THREE?window.THREE:{DoubleSide:gs,Group:Ka,LineBasicMaterial:Q0,LineSegments:Y7,Mesh:qi,MeshBasicMaterial:vd},wO=Rs({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjPolygon"}).id(function(s){return s.id}).onCreateObj(function(){var s=new Ph.Group;return s.__defaultSideMaterial=XE(new Ph.MeshBasicMaterial({side:Ph.DoubleSide,depthWrite:!0}),cw),s.__defaultCapMaterial=new Ph.MeshBasicMaterial({side:Ph.DoubleSide,depthWrite:!0}),s.add(new Ph.Mesh(void 0,[s.__defaultSideMaterial,s.__defaultCapMaterial])),s.add(new Ph.LineSegments(void 0,new Ph.LineBasicMaterial)),s.__globeObjType="polygon",s})},update:function(e){var t=kt(e.polygonGeoJsonGeometry),n=kt(e.polygonAltitude),r=kt(e.polygonCapCurvatureResolution),s=kt(e.polygonCapColor),a=kt(e.polygonCapMaterial),l=kt(e.polygonSideColor),u=kt(e.polygonSideMaterial),h=kt(e.polygonStrokeColor),m=[];e.polygonsData.forEach(function(v){var x={data:v,capColor:s(v),capMaterial:a(v),sideColor:l(v),sideMaterial:u(v),strokeColor:h(v),altitude:+n(v),capCurvatureResolution:+r(v)},S=t(v),w=v.__id||"".concat(Math.round(Math.random()*1e9));v.__id=w,S.type==="Polygon"?m.push(Wi({id:"".concat(w,"_0"),coords:S.coordinates},x)):S.type==="MultiPolygon"?m.push.apply(m,Zi(S.coordinates.map(function(N,C){return Wi({id:"".concat(w,"_").concat(C),coords:N},x)}))):console.warn("Unsupported GeoJson geometry type: ".concat(S.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(v,x){var S=x.coords,w=x.capColor,N=x.capMaterial,C=x.sideColor,E=x.sideMaterial,O=x.strokeColor,U=x.altitude,I=x.capCurvatureResolution,j=Sr(v.children,2),z=j[0],G=j[1],W=!!O;G.visible=W;var q=!!(w||N),V=!!(C||E);hue(z.geometry.parameters||{},{polygonGeoJson:S,curvatureResolution:I,closedTop:q,includeSides:V})||(z.geometry&&z.geometry.dispose(),z.geometry=new EM(S,0,mr,!1,q,V,I)),W&&(!G.geometry.parameters||G.geometry.parameters.geoJson.coordinates!==S||G.geometry.parameters.resolution!==I)&&(G.geometry&&G.geometry.dispose(),G.geometry=new AP({type:"Polygon",coordinates:S},mr,I));var Y=V?0:-1,te=q?V?1:0:-1;if(Y>=0&&(z.material[Y]=E||v.__defaultSideMaterial),te>=0&&(z.material[te]=N||v.__defaultCapMaterial),[[!E&&C,Y],[!N&&w,te]].forEach(function(Ae){var be=Sr(Ae,2),Se=be[0],se=be[1];if(!(!Se||se<0)){var Ee=z.material[se],qe=kl(Se);Ee.color.set(Lu(Se)),Ee.transparent=qe<1,Ee.opacity=qe}}),W){var ne=G.material,le=kl(O);ne.color.set(Lu(O)),ne.transparent=le<1,ne.opacity=le}var Q={alt:U},K=function(be){var Se=v.__currentTargetD=be,se=Se.alt;z.scale.x=z.scale.y=z.scale.z=1+se,W&&(G.scale.x=G.scale.y=G.scale.z=1+se+1e-4),eue(v.__defaultSideMaterial,function(Ee){return Ee.uSurfaceRadius.value=mr/(se+1)})},ae=v.__currentTargetD||Object.assign({},Q,{alt:-.001});Object.keys(Q).some(function(Ae){return ae[Ae]!==Q[Ae]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||ae.alt===Q.alt?K(Q):e.tweenGroup.add(new va(ae).to(Q,e.polygonsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(K).start()))}).digest(m)}});function hue(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(n,r){return n===r}};return Object.entries(e).every(function(n){var r=Sr(n,2),s=r[0],a=r[1];return i.hasOwnProperty(s)&&t(s)(i[s],a)})}var FA=window.THREE?window.THREE:{BufferGeometry:Ji,DoubleSide:gs,Mesh:qi,MeshLambertMaterial:Kc,Vector3:de},Z6=Object.assign({},bM),J6=Z6.BufferGeometryUtils||Z6,MO=Rs({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var s=new FA.Mesh(void 0,new FA.MeshLambertMaterial({side:FA.DoubleSide}));return s.__globeObjType="hexPolygon",s})},update:function(e){var t=kt(e.hexPolygonGeoJsonGeometry),n=kt(e.hexPolygonColor),r=kt(e.hexPolygonAltitude),s=kt(e.hexPolygonResolution),a=kt(e.hexPolygonMargin),l=kt(e.hexPolygonUseDots),u=kt(e.hexPolygonCurvatureResolution),h=kt(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(m,v){var x=t(v),S=s(v),w=r(v),N=Math.max(0,Math.min(1,+a(v))),C=l(v),E=u(v),O=h(v),U=n(v),I=kl(U);m.material.color.set(Lu(U)),m.material.transparent=I<1,m.material.opacity=I;var j={alt:w,margin:N,curvatureResolution:E},z={geoJson:x,h3Res:S},G=m.__currentTargetD||Object.assign({},j,{alt:-.001}),W=m.__currentMemD||z;if(Object.keys(j).some(function(te){return G[te]!==j[te]})||Object.keys(z).some(function(te){return W[te]!==z[te]})){m.__currentMemD=z;var q=[];x.type==="Polygon"?DR(x.coordinates,S,!0).forEach(function(te){return q.push(te)}):x.type==="MultiPolygon"?x.coordinates.forEach(function(te){return DR(te,S,!0).forEach(function(ne){return q.push(ne)})}):console.warn("Unsupported GeoJson geometry type: ".concat(x.type,". Skipping geometry..."));var V=q.map(function(te){var ne=LP(te),le=UP(te,!0).reverse(),Q=ne[1];return le.forEach(function(K){var ae=K[0];Math.abs(Q-ae)>170&&(K[0]+=Q>ae?360:-360)}),{h3Idx:te,hexCenter:ne,hexGeoJson:le}}),Y=function(ne){var le=m.__currentTargetD=ne,Q=le.alt,K=le.margin,ae=le.curvatureResolution;m.geometry&&m.geometry.dispose(),m.geometry=V.length?(J6.mergeGeometries||J6.mergeBufferGeometries)(V.map(function(Ae){var be=Sr(Ae.hexCenter,2),Se=be[0],se=be[1];if(C){var Ee=ul(Se,se,Q),qe=ul(Ae.hexGeoJson[0][1],Ae.hexGeoJson[0][0],Q),Ce=.85*(1-K)*new FA.Vector3(Ee.x,Ee.y,Ee.z).distanceTo(new FA.Vector3(qe.x,qe.y,qe.z)),ke=new by(Ce,O);return ke.rotateX(Wf(-Se)),ke.rotateY(Wf(se)),ke.translate(Ee.x,Ee.y,Ee.z),ke}else{var Qe=function(Nt,Gt,Tt){return Nt-(Nt-Gt)*Tt},et=K===0?Ae.hexGeoJson:Ae.hexGeoJson.map(function(Pt){var Nt=Sr(Pt,2),Gt=Nt[0],Tt=Nt[1];return[[Gt,se],[Tt,Se]].map(function(Ge){var dt=Sr(Ge,2),he=dt[0],en=dt[1];return Qe(he,en,K)})});return new EM([et],mr,mr*(1+Q),!1,!0,!1,ae)}})):new FA.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?Y(j):e.tweenGroup.add(new va(G).to(j,e.hexPolygonsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(Y).start())}}).digest(e.hexPolygonsData)}}),fue=window.THREE?window.THREE:{Vector3:de};function due(i,e){var t=function(a,l){var u=a[a.length-1];return[].concat(Zi(a),Zi(Array(l-a.length).fill(u)))},n=Math.max(i.length,e.length),r=p$.apply(void 0,Zi([i,e].map(function(s){return s.map(function(a){var l=a.x,u=a.y,h=a.z;return[l,u,h]})}).map(function(s){return t(s,n)})));return function(s){return s===0?i:s===1?e:r(s).map(function(a){var l=Sr(a,3),u=l[0],h=l[1],m=l[2];return new fue.Vector3(u,h,m)})}}var Bf=window.THREE?window.THREE:{BufferGeometry:Ji,Color:mn,Group:Ka,Line:xy,NormalBlending:io,ShaderMaterial:so,Vector3:de},Aue=O0.default||O0,EO=Rs({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new Aue,sharedMaterial:new Bf.ShaderMaterial(Wi(Wi({},yO()),{},{transparent:!0,blending:Bf.NormalBlending}))}},init:function(e,t){sr(e),t.scene=e,t.dataMapper=new fo(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var n=new Bf.Group;return n.__globeObjType="path",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Sr(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r;if(a.type==="Line"){var u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l}else if(a.type==="Line2"){for(var h=a.material.dashOffset-l,m=a.material.dashSize+a.material.gapSize;h<=-m;)h+=m;a.material.dashOffset=h}})})},update:function(e){var t=kt(e.pathPoints),n=kt(e.pathPointLat),r=kt(e.pathPointLng),s=kt(e.pathPointAlt),a=kt(e.pathStroke),l=kt(e.pathColor),u=kt(e.pathDashLength),h=kt(e.pathDashGap),m=kt(e.pathDashInitialGap),v=kt(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(C,E){var O=a(E),U=O!=null;if(!C.children.length||U===(C.children[0].type==="Line")){sr(C);var I=U?new Ele(new fO,new jE):new Bf.Line(new Bf.BufferGeometry,e.sharedMaterial.clone());C.add(I)}var j=C.children[0],z=S(t(E),n,r,s,e.pathResolution),G=v(E);if(j.__dashAnimateStep=G>0?1e3/G:0,U){j.material.resolution=e.rendererSize;{var V=u(E),Y=h(E),te=m(E);j.material.dashed=Y>0,j.material.dashed?j.material.defines.USE_DASH="":delete j.material.defines.USE_DASH,j.material.dashed&&(j.material.dashScale=1/x(z),j.material.dashSize=V,j.material.gapSize=Y,j.material.dashOffset=-te)}{var ne=l(E);if(ne instanceof Array){var le=w(l(E),z.length-1,1,!1);j.geometry.setColors(le.array),j.material.vertexColors=!0}else{var Q=ne,K=kl(Q);j.material.color=new Bf.Color(Lu(Q)),j.material.transparent=K<1,j.material.opacity=K,j.material.vertexColors=!1}}j.material.needsUpdate=!0}else{Object.assign(j.material.uniforms,{dashSize:{value:u(E)},gapSize:{value:h(E)},dashOffset:{value:m(E)}});var W=w(l(E),z.length),q=N(z.length,1,!0);j.geometry.setAttribute("color",W),j.geometry.setAttribute("relDistance",q)}var ae=due(C.__currentTargetD&&C.__currentTargetD.points||[z[0]],z),Ae=function(Ee){var qe=C.__currentTargetD=Ee,Ce=qe.stroke,ke=qe.interpolK,Qe=C.__currentTargetD.points=ae(ke);if(U){var et;j.geometry.setPositions((et=[]).concat.apply(et,Zi(Qe.map(function(Pt){var Nt=Pt.x,Gt=Pt.y,Tt=Pt.z;return[Nt,Gt,Tt]})))),j.material.linewidth=Ce,j.material.dashed&&j.computeLineDistances()}else j.geometry.setFromPoints(Qe),j.geometry.computeBoundingSphere()},be={stroke:O,interpolK:1},Se=Object.assign({},C.__currentTargetD||be,{interpolK:0});Object.keys(be).some(function(se){return Se[se]!==be[se]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?Ae(be):e.tweenGroup.add(new va(Se).to(be,e.pathTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(Ae).start()))}).digest(e.pathsData);function x(C){var E=0,O;return C.forEach(function(U){O&&(E+=O.distanceTo(U)),O=U}),E}function S(C,E,O,U,I){var j=function(q,V,Y){for(var te=[],ne=1;ne<=Y;ne++)te.push(q+(V-q)*ne/(Y+1));return te},z=function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Y=[],te=null;return q.forEach(function(ne){if(te){for(;Math.abs(te[1]-ne[1])>180;)te[1]+=360*(te[1]V)for(var Q=Math.floor(le/V),K=j(te[0],ne[0],Q),ae=j(te[1],ne[1],Q),Ae=j(te[2],ne[2],Q),be=0,Se=K.length;be2&&arguments[2]!==void 0?arguments[2]:1,U=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,I=E+1,j;if(C instanceof Array||C instanceof Function){var z=C instanceof Array?zc().domain(C.map(function(ne,le){return le/(C.length-1)})).range(C):C;j=function(le){return Kh(z(le),U,!0)}}else{var G=Kh(C,U,!0);j=function(){return G}}for(var W=[],q=0,V=I;q1&&arguments[1]!==void 0?arguments[1]:1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,U=C+1,I=[],j=0,z=U;j0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;nx(this,e),t=tx(this,e),t.type="CircleLineGeometry",t.parameters={radius:n,segmentCount:r};for(var s=[],a=0;a<=r;a++){var l=(a/r-.25)*Math.PI*2;s.push({x:Math.cos(l)*n,y:Math.sin(l)*n,z:0})}return t.setFromPoints(s),t}return rx(e,i),ix(e)})(pue.BufferGeometry),zA=window.THREE?window.THREE:{Color:mn,Group:Ka,Line:xy,LineBasicMaterial:Q0,Vector3:de},gue=O0.default||O0,RO=Rs({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var s=new zA.Group;return s.__globeObjType="ring",s}),t.ticker=new gue,t.ticker.onTick.add(function(s){if(t.ringsData.length){var a=kt(t.ringColor),l=kt(t.ringAltitude),u=kt(t.ringMaxRadius),h=kt(t.ringPropagationSpeed),m=kt(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(v){var x=Sr(v,2),S=x[1];return S}).forEach(function(v){var x=Sr(v,2),S=x[0],w=x[1];if((w.__nextRingTime||0)<=s){var N=m(S)/1e3;w.__nextRingTime=s+(N<=0?1/0:N);var C=new zA.Line(new mue(1,t.ringResolution),new zA.LineBasicMaterial),E=a(S),O=E instanceof Array||E instanceof Function,U;O?E instanceof Array?(U=zc().domain(E.map(function(Y,te){return te/(E.length-1)})).range(E),C.material.transparent=E.some(function(Y){return kl(Y)<1})):(U=E,C.material.transparent=!0):(C.material.color=new zA.Color(Lu(E)),Kle(C.material,kl(E)));var I=mr*(1+l(S)),j=u(S),z=j*Math.PI/180,G=h(S),W=G<=0,q=function(te){var ne=te.t,le=(W?1-ne:ne)*z;if(C.scale.x=C.scale.y=I*Math.sin(le),C.position.z=I*(1-Math.cos(le)),O){var Q=U(ne);C.material.color=new zA.Color(Lu(Q)),C.material.transparent&&(C.material.opacity=kl(Q))}};if(G===0)q({t:0}),w.add(C);else{var V=Math.abs(j/G)*1e3;t.tweenGroup.add(new va({t:0}).to({t:1},V).onUpdate(q).onStart(function(){return w.add(C)}).onComplete(function(){w.remove(C),$E(C)}).start())}}})}})},update:function(e){var t=kt(e.ringLat),n=kt(e.ringLng),r=kt(e.ringAltitude),s=e.scene.localToWorld(new zA.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(a,l){var u=t(l),h=n(l),m=r(l);Object.assign(a.position,ul(u,h,m)),a.lookAt(s)}).digest(e.ringsData)}}),vue={0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},_ue="normal",yue=1189,xue=-100,bue="normal",Sue={yMin:-334,xMin:-111,yMax:1189,xMax:1672},Tue=1e3,wue={postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r +\r +Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r +\r +The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r +\r +The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r +\r +This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r +\r +The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r +\r +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},Mue=-334,Eue="Helvetiker",Cue=1522,Nue=50,Rue={glyphs:vue,cssFontWeight:_ue,ascender:yue,underlinePosition:xue,cssFontStyle:bue,boundingBox:Sue,resolution:Tue,original_font_information:wue,descender:Mue,familyName:Eue,lineHeight:Cue,underlineThickness:Nue},Dl=Wi(Wi({},window.THREE?window.THREE:{BoxGeometry:Jh,CircleGeometry:by,DoubleSide:gs,Group:Ka,Mesh:qi,MeshLambertMaterial:Kc,TextGeometry:q6,Vector3:de}),{},{Font:Cle,TextGeometry:q6}),DO=Rs({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:Rue,onChange:function(e,t){t.font=new Dl.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r;var s=new Dl.CircleGeometry(1,32);t.dataMapper=new fo(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var a=new Dl.MeshLambertMaterial;a.side=gs;var l=new Dl.Group;l.add(new Dl.Mesh(s,a));var u=new Dl.Mesh(void 0,a);l.add(u);var h=new Dl.Mesh;return h.visible=!1,u.add(h),l.__globeObjType="label",l})},update:function(e){var t=kt(e.labelLat),n=kt(e.labelLng),r=kt(e.labelAltitude),s=kt(e.labelText),a=kt(e.labelSize),l=kt(e.labelRotation),u=kt(e.labelColor),h=kt(e.labelIncludeDot),m=kt(e.labelDotRadius),v=kt(e.labelDotOrientation),x=new Set(["right","top","bottom"]),S=2*Math.PI*mr/360;e.dataMapper.onUpdateObj(function(w,N){var C=Sr(w.children,2),E=C[0],O=C[1],U=Sr(O.children,1),I=U[0],j=u(N),z=kl(j);O.material.color.set(Lu(j)),O.material.transparent=z<1,O.material.opacity=z;var G=h(N),W=v(N);!G||!x.has(W)&&(W="bottom");var q=G?+m(N)*S:1e-12;E.scale.x=E.scale.y=q;var V=+a(N)*S;if(O.geometry&&O.geometry.dispose(),O.geometry=new Dl.TextGeometry(s(N),{font:e.font,size:V,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),I.geometry&&I.geometry.dispose(),O.geometry.computeBoundingBox(),I.geometry=HE(Dl.BoxGeometry,Zi(new Dl.Vector3().subVectors(O.geometry.boundingBox.max,O.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),W!=="right"&&O.geometry.center(),G){var Y=q+V/2;W==="right"&&(O.position.x=Y),O.position.y={right:-V/2,top:Y+V/2,bottom:-Y-V/2}[W]}var te=function(K){var ae=w.__currentTargetD=K,Ae=ae.lat,be=ae.lng,Se=ae.alt,se=ae.rot,Ee=ae.scale;Object.assign(w.position,ul(Ae,be,Se)),w.lookAt(e.scene.localToWorld(new Dl.Vector3(0,0,0))),w.rotateY(Math.PI),w.rotateZ(-se*Math.PI/180),w.scale.x=w.scale.y=w.scale.z=Ee},ne={lat:+t(N),lng:+n(N),alt:+r(N),rot:+l(N),scale:1},le=w.__currentTargetD||Object.assign({},ne,{scale:1e-12});Object.keys(ne).some(function(Q){return le[Q]!==ne[Q]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?te(ne):e.tweenGroup.add(new va(le).to(ne,e.labelsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(te).start()))}).digest(e.labelsData)}}),Due=Wi(Wi({},window.THREE?window.THREE:{}),{},{CSS2DObject:kH}),PO=Rs({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){if(e.dataMapper){var n=t?[t]:e.dataMapper.entries().map(function(r){var s=Sr(r,2),a=s[1];return a}).filter(function(r){return r});n.forEach(function(r){var s=!e.isBehindGlobe||!e.isBehindGlobe(r.position);e.htmlElementVisibilityModifier?(r.visible=!0,e.htmlElementVisibilityModifier(r.element,s)):r.visible=s})}}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(s){var a=kt(t.htmlElement)(s),l=new Due.CSS2DObject(a);return l.__globeObjType="html",l})},update:function(e,t){var n=this,r=kt(e.htmlLat),s=kt(e.htmlLng),a=kt(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(l,u){var h=function(x){var S=l.__currentTargetD=x,w=S.alt,N=S.lat,C=S.lng;Object.assign(l.position,ul(N,C,w)),n.updateObjVisibility(l)},m={lat:+r(u),lng:+s(u),alt:+a(u)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!l.__currentTargetD?h(m):e.tweenGroup.add(new va(l.__currentTargetD).to(m,e.htmlTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(h).start())}).digest(e.htmlElementsData)}}),Lv=window.THREE?window.THREE:{Group:Ka,Mesh:qi,MeshLambertMaterial:Kc,SphereGeometry:Bu},LO=Rs({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new Lv.Mesh(new Lv.SphereGeometry(1,16,8),new Lv.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){sr(e),t.scene=e,t.dataMapper=new fo(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(n){var r=kt(t.objectThreeObject)(n);t.objectThreeObject===r&&(r=r.clone());var s=new Lv.Group;return s.add(r),s.__globeObjType="object",s})},update:function(e,t){var n=kt(e.objectLat),r=kt(e.objectLng),s=kt(e.objectAltitude),a=kt(e.objectFacesSurface),l=kt(e.objectRotation);t.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(u,h){var m=+n(h),v=+r(h),x=+s(h);Object.assign(u.position,ul(m,v,x)),a(h)?u.setRotationFromEuler(new ma(Wf(-m),Wf(v),0,"YXZ")):u.rotation.set(0,0,0);var S=u.children[0],w=l(h);w&&S.setRotationFromEuler(new ma(Wf(w.x||0),Wf(w.y||0),Wf(w.z||0)))}).digest(e.objectsData)}}),UO=Rs({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){sr(e),t.scene=e,t.dataMapper=new fo(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(n){var r=kt(t.customThreeObject)(n,mr);return r&&(t.customThreeObject===r&&(r=r.clone()),r.__globeObjType="custom"),r})},update:function(e,t){e.customThreeObjectUpdate||sr(e.scene);var n=kt(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(r,s){return n(r,s,mr)}).digest(e.customLayerData)}}),Uv=window.THREE?window.THREE:{Camera:_y,Group:Ka,Vector2:Et,Vector3:de},Pue=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],BO=Pa("globeLayer",vO),Lue=Object.assign.apply(Object,Zi(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(i){return Gs({},i,BO.linkProp(i))}))),Uue=Object.assign.apply(Object,Zi(["globeMaterial","globeTileEngineClearCache"].map(function(i){return Gs({},i,BO.linkMethod(i))}))),Bue=Pa("pointsLayer",_O),Oue=Object.assign.apply(Object,Zi(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(i){return Gs({},i,Bue.linkProp(i))}))),Iue=Pa("arcsLayer",xO),Fue=Object.assign.apply(Object,Zi(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(i){return Gs({},i,Iue.linkProp(i))}))),kue=Pa("hexBinLayer",bO),zue=Object.assign.apply(Object,Zi(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(i){return Gs({},i,kue.linkProp(i))}))),Gue=Pa("heatmapsLayer",TO),que=Object.assign.apply(Object,Zi(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(i){return Gs({},i,Gue.linkProp(i))}))),Vue=Pa("hexedPolygonsLayer",MO),jue=Object.assign.apply(Object,Zi(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(i){return Gs({},i,Vue.linkProp(i))}))),Hue=Pa("polygonsLayer",wO),Wue=Object.assign.apply(Object,Zi(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(i){return Gs({},i,Hue.linkProp(i))}))),$ue=Pa("pathsLayer",EO),Xue=Object.assign.apply(Object,Zi(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(i){return Gs({},i,$ue.linkProp(i))}))),Yue=Pa("tilesLayer",CO),Que=Object.assign.apply(Object,Zi(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(i){return Gs({},i,Yue.linkProp(i))}))),Kue=Pa("particlesLayer",NO),Zue=Object.assign.apply(Object,Zi(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(i){return Gs({},i,Kue.linkProp(i))}))),Jue=Pa("ringsLayer",RO),ece=Object.assign.apply(Object,Zi(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(i){return Gs({},i,Jue.linkProp(i))}))),tce=Pa("labelsLayer",DO),nce=Object.assign.apply(Object,Zi(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(i){return Gs({},i,tce.linkProp(i))}))),ice=Pa("htmlElementsLayer",PO),rce=Object.assign.apply(Object,Zi(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(i){return Gs({},i,ice.linkProp(i))}))),sce=Pa("objectsLayer",LO),ace=Object.assign.apply(Object,Zi(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(i){return Gs({},i,sce.linkProp(i))}))),oce=Pa("customLayer",UO),lce=Object.assign.apply(Object,Zi(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(i){return Gs({},i,oce.linkProp(i))}))),uce=Rs({props:Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new Uv.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},Lue),Oue),Fue),zue),que),Wue),jue),Xue),Que),Zue),ece),nce),rce),ace),lce),methods:Wi({getGlobeRadius:H6,getCoords:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=(function(r){function s(){var a;nx(this,s);for(var l=arguments.length,u=new Array(l),h=0;he7&&(this.dispatchEvent(US),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>e7||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(US),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=ki.NONE,this.keyState=ki.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(US),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Lh.copy(this._panEnd).sub(this._panStart),Lh.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Lh.x*=e,Lh.y*=t}Lh.multiplyScalar(this._eye.length()*this.panSpeed),Ov.copy(this._eye).cross(this.object.up).setLength(Lh.x),Ov.add(fce.copy(this.object.up).setLength(Lh.y)),this.object.position.add(Ov),this.target.add(Ov),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Lh.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Fv.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Fv.length();e?(this._eye.copy(this.object.position).sub(this.target),t7.copy(this._eye).normalize(),Iv.copy(this.object.up).normalize(),OS.crossVectors(Iv,t7).normalize(),Iv.setLength(this._moveCurr.y-this._movePrev.y),OS.setLength(this._moveCurr.x-this._movePrev.x),Fv.copy(Iv.add(OS)),BS.crossVectors(Fv,this._eye).normalize(),e*=this.rotateSpeed,GA.setFromAxisAngle(BS,e),this._eye.applyQuaternion(GA),this.object.up.applyQuaternion(GA),this._lastAxis.copy(BS),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),GA.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(GA),this.object.up.applyQuaternion(GA)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===ki.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=N0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=N0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Bv.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Bv}_getMouseOnCircle(e,t){return Bv.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Bv}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=ja),r<-Math.PI?r+=ja:r>Math.PI&&(r-=ja),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(Ts.setFromSpherical(this._spherical),Ts.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ts),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=Ts.length();a=this._clampDistance(l*this._scale);const u=l-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),s=!!u}else if(this.object.isOrthographicCamera){const l=new de(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=u!==this.object.zoom;const h=new de(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(l),this.object.updateMatrixWorld(),a=Ts.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(kv.origin.copy(this.object.position),kv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(kv.direction))IS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>IS||this._lastTargetPosition.distanceToSquared(this.target)>IS?(this.dispatchEvent(n7),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ja/60*this.autoRotateSpeed*e:ja/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ts.setFromMatrixColumn(t,0),Ts.multiplyScalar(-e),this._panOffset.add(Ts)}_panUp(e,t){this.screenSpacePanning===!0?Ts.setFromMatrixColumn(t,1):(Ts.setFromMatrixColumn(t,0),Ts.crossVectors(this.object.up,Ts)),Ts.multiplyScalar(e),this._panOffset.add(Ts)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;Ts.copy(r).sub(this.target);let s=Ts.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,l=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(ja*this._rotateDelta.x/t.clientHeight),this._rotateUp(ja*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(ja*this._rotateDelta.x/t.clientHeight),this._rotateUp(ja*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tr7||8*(1-this._lastQuaternion.dot(t.quaternion))>r7)&&(this.dispatchEvent(qce),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function jce(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function Hce(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function Wce(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function $ce(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function Xce(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function Yce(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Qce(i){this.enabled!==!1&&i.preventDefault()}const Kce={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + uniform float opacity; + + uniform sampler2D tDiffuse; + + varying vec2 vUv; + + void main() { + + vec4 texel = texture2D( tDiffuse, vUv ); + gl_FragColor = opacity * texel; + + + }`};class sx{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Zce=new Gg(-1,1,1,-1,0,1);class Jce extends Ji{constructor(){super(),this.setAttribute("position",new Ci([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ci([0,2,0,0,2,0],2))}}const ehe=new Jce;class the{constructor(e){this._mesh=new qi(ehe,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Zce)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class nhe extends sx{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof so?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=vy.clone(e.uniforms),this.material=new so({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new the(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class a7 extends sx{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,l;this.inverse?(a=0,l=1):(a=1,l=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),s.buffers.stencil.setClear(l),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class ihe extends sx{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class rhe{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new Et);this._width=n.width,this._height=n.height,t=new Xh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Qs}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new nhe(Kce),this.copyPass.material.blending=no,this.clock=new hD}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&r<1?(l=s,u=a):r>=1&&r<2?(l=a,u=s):r>=2&&r<3?(u=s,h=a):r>=3&&r<4?(u=a,h=s):r>=4&&r<5?(l=a,h=s):r>=5&&r<6&&(l=s,h=a);var m=t-s/2,v=l+m,x=u+m,S=h+m;return n(v,x,S)}var o7={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function hhe(i){if(typeof i!="string")return i;var e=i.toLowerCase();return o7[e]?"#"+o7[e]:i}var fhe=/^#[a-fA-F0-9]{6}$/,dhe=/^#[a-fA-F0-9]{8}$/,Ahe=/^#[a-fA-F0-9]{3}$/,phe=/^#[a-fA-F0-9]{4}$/,kS=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,mhe=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,ghe=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,vhe=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function j0(i){if(typeof i!="string")throw new fu(3);var e=hhe(i);if(e.match(fhe))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(dhe)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(Ahe))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(phe)){var n=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:n}}var r=kS.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var s=mhe.exec(e.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var a=ghe.exec(e);if(a){var l=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,h=parseInt(""+a[3],10)/100,m="rgb("+oy(l,u,h)+")",v=kS.exec(m);if(!v)throw new fu(4,e,m);return{red:parseInt(""+v[1],10),green:parseInt(""+v[2],10),blue:parseInt(""+v[3],10)}}var x=vhe.exec(e.substring(0,50));if(x){var S=parseInt(""+x[1],10),w=parseInt(""+x[2],10)/100,N=parseInt(""+x[3],10)/100,C="rgb("+oy(S,w,N)+")",E=kS.exec(C);if(!E)throw new fu(4,e,C);return{red:parseInt(""+E[1],10),green:parseInt(""+E[2],10),blue:parseInt(""+E[3],10),alpha:parseFloat(""+x[4])>1?parseFloat(""+x[4])/100:parseFloat(""+x[4])}}throw new fu(5)}function _he(i){var e=i.red/255,t=i.green/255,n=i.blue/255,r=Math.max(e,t,n),s=Math.min(e,t,n),a=(r+s)/2;if(r===s)return i.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:i.alpha}:{hue:0,saturation:0,lightness:a};var l,u=r-s,h=a>.5?u/(2-r-s):u/(r+s);switch(r){case e:l=(t-n)/u+(t=1?kO(i.hue,i.saturation,i.lightness):"rgba("+oy(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new fu(2)}function zO(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return dw("#"+Gf(i)+Gf(e)+Gf(t));if(typeof i=="object"&&e===void 0&&t===void 0)return dw("#"+Gf(i.red)+Gf(i.green)+Gf(i.blue));throw new fu(6)}function ax(i,e,t,n){if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?zO(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")";throw new fu(7)}var The=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},whe=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},Mhe=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Ehe=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function rf(i){if(typeof i!="object")throw new fu(8);if(whe(i))return ax(i);if(The(i))return zO(i);if(Ehe(i))return She(i);if(Mhe(i))return bhe(i);throw new fu(8)}function GO(i,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?i.apply(this,r):GO(i,e,r)}}function ko(i){return GO(i,i.length,[])}function Che(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{hue:t.hue+parseFloat(i)}))}ko(Che);function np(i,e,t){return Math.max(i,Math.min(e,t))}function Nhe(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{lightness:np(0,1,t.lightness-parseFloat(i))}))}ko(Nhe);function Rhe(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{saturation:np(0,1,t.saturation-parseFloat(i))}))}ko(Rhe);function Dhe(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{lightness:np(0,1,t.lightness+parseFloat(i))}))}ko(Dhe);function Phe(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=j0(e),r=uo({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),s=j0(t),a=uo({},s,{alpha:typeof s.alpha=="number"?s.alpha:1}),l=r.alpha-a.alpha,u=parseFloat(i)*2-1,h=u*l===-1?u:u+l,m=1+u*l,v=(h/m+1)/2,x=1-v,S={red:Math.floor(r.red*v+a.red*x),green:Math.floor(r.green*v+a.green*x),blue:Math.floor(r.blue*v+a.blue*x),alpha:r.alpha*parseFloat(i)+a.alpha*(1-parseFloat(i))};return ax(S)}var Lhe=ko(Phe),qO=Lhe;function Uhe(i,e){if(e==="transparent")return e;var t=j0(e),n=typeof t.alpha=="number"?t.alpha:1,r=uo({},t,{alpha:np(0,1,(n*100+parseFloat(i)*100)/100)});return ax(r)}var Bhe=ko(Uhe),Ohe=Bhe;function Ihe(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{saturation:np(0,1,t.saturation+parseFloat(i))}))}ko(Ihe);function Fhe(i,e){return e==="transparent"?e:rf(uo({},nf(e),{hue:parseFloat(i)}))}ko(Fhe);function khe(i,e){return e==="transparent"?e:rf(uo({},nf(e),{lightness:parseFloat(i)}))}ko(khe);function zhe(i,e){return e==="transparent"?e:rf(uo({},nf(e),{saturation:parseFloat(i)}))}ko(zhe);function Ghe(i,e){return e==="transparent"?e:qO(parseFloat(i),"rgb(0, 0, 0)",e)}ko(Ghe);function qhe(i,e){return e==="transparent"?e:qO(parseFloat(i),"rgb(255, 255, 255)",e)}ko(qhe);function Vhe(i,e){if(e==="transparent")return e;var t=j0(e),n=typeof t.alpha=="number"?t.alpha:1,r=uo({},t,{alpha:np(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return ax(r)}ko(Vhe);var Aw="http://www.w3.org/1999/xhtml";const l7={svg:"http://www.w3.org/2000/svg",xhtml:Aw,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function VO(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),l7.hasOwnProperty(e)?{space:l7[e],local:i}:i}function jhe(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===Aw&&e.documentElement.namespaceURI===Aw?e.createElement(i):e.createElementNS(t,i)}}function Hhe(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function jO(i){var e=VO(i);return(e.local?Hhe:jhe)(e)}function Whe(){}function HO(i){return i==null?Whe:function(){return this.querySelector(i)}}function $he(i){typeof i!="function"&&(i=HO(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r=U&&(U=O+1);!(j=C[U])&&++U=0;)(a=n[r])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function yfe(i){i||(i=xfe);function e(v,x){return v&&x?i(v.__data__,x.__data__):!v-!x}for(var t=this._groups,n=t.length,r=new Array(n),s=0;se?1:i>=e?0:NaN}function bfe(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function Sfe(){return Array.from(this)}function Tfe(){for(var i=this._groups,e=0,t=i.length;e1?this.each((e==null?Bfe:typeof e=="function"?Ife:Ofe)(i,e,t??"")):kfe(this.node(),i)}function kfe(i,e){return i.style.getPropertyValue(e)||XO(i).getComputedStyle(i,null).getPropertyValue(e)}function zfe(i){return function(){delete this[i]}}function Gfe(i,e){return function(){this[i]=e}}function qfe(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function Vfe(i,e){return arguments.length>1?this.each((e==null?zfe:typeof e=="function"?qfe:Gfe)(i,e)):this.node()[i]}function YO(i){return i.trim().split(/^|\s+/)}function ZE(i){return i.classList||new QO(i)}function QO(i){this._node=i,this._names=YO(i.getAttribute("class")||"")}QO.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function KO(i,e){for(var t=ZE(i),n=-1,r=e.length;++n=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function gde(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,r=e.length,s;t2&&(a.children=arguments.length>3?s1.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(s in i.defaultProps)a[s]===void 0&&(a[s]=i.defaultProps[s]);return Vm(i,a,n,r,null)}function Vm(i,e,t,n,r){var s={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++eI,__i:-1,__u:0};return r==null&&Pr.vnode!=null&&Pr.vnode(s),s}function lx(i){return i.children}function r_(i,e){this.props=i,this.context=e}function H0(i,e){if(e==null)return i.__?H0(i.__,i.__i+1):null;for(var t;ee&&$f.sort(iI),i=$f.shift(),e=$f.length,Dde(i);hy.__r=0}function aI(i,e,t,n,r,s,a,l,u,h,m){var v,x,S,w,N,C,E,O=n&&n.__k||cy,U=e.length;for(u=Pde(t,e,O,u,U),v=0;v0?a=i.__k[s]=Vm(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):i.__k[s]=a,u=s+x,a.__=i,a.__b=i.__b+1,l=null,(h=a.__i=Lde(a,t,u,v))!=-1&&(v--,(l=t[h])&&(l.__u|=2)),l==null||l.__v==null?(h==-1&&(r>m?x--:ru?x--:x++,a.__u|=4))):i.__k[s]=null;if(v)for(s=0;s(m?1:0)){for(r=t-1,s=t+1;r>=0||s=0?r--:s++])!=null&&(2&h.__u)==0&&l==h.key&&u==h.type)return a}return-1}function h7(i,e,t){e[0]=="-"?i.setProperty(e,t??""):i[e]=t==null?"":typeof t!="number"||Nde.test(e)?t:t+"px"}function zv(i,e,t,n,r){var s,a;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||h7(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||h7(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(rI,"$1")),a=e.toLowerCase(),e=a in i||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+s]=t,t?n?t.u=n.u:(t.u=JE,i.addEventListener(e,s?mw:pw,s)):i.removeEventListener(e,s?mw:pw,s);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function f7(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=JE++;else if(e.t0?i:ox(i)?i.map(uI):du({},i)}function Ude(i,e,t,n,r,s,a,l,u){var h,m,v,x,S,w,N,C=t.props||uy,E=e.props,O=e.type;if(O=="svg"?r="http://www.w3.org/2000/svg":O=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(h=0;h2&&(l.children=arguments.length>3?s1.call(arguments,2):t),Vm(i.type,l,n||i.key,r||i.ref,null)}s1=cy.slice,Pr={__e:function(i,e,t,n){for(var r,s,a;e=e.__;)if((r=e.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(i)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(i,n||{}),a=r.__d),a)return r.__E=r}catch(l){i=l}throw i}},eI=0,tI=function(i){return i!=null&&i.constructor===void 0},r_.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=du({},this.state),typeof i=="function"&&(i=i(du({},t),this.props)),i&&du(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),c7(this))},r_.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),c7(this))},r_.prototype.render=lx,$f=[],nI=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,iI=function(i,e){return i.__v.__b-e.__v.__b},hy.__r=0,rI=/(PointerCapture)$|Capture$/i,JE=0,pw=f7(!1),mw=f7(!0);function d7(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var Yde=`.float-tooltip-kap { + position: absolute; + width: max-content; /* prevent shrinking near right edge */ + max-width: max(50%, 150px); + padding: 3px 5px; + border-radius: 3px; + font: 12px sans-serif; + color: #eee; + background: rgba(0,0,0,0.6); + pointer-events: none; +} +`;Xde(Yde);var Qde=Rs({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.style,s=r===void 0?{}:r,a=!!e&&fy(e)==="object"&&!!e.node&&typeof e.node=="function",l=Mde(a?e.node():e);l.style("position")==="static"&&l.style("position","relative"),t.tooltipEl=l.append("div").attr("class","float-tooltip-kap"),Object.entries(s).forEach(function(h){var m=qde(h,2),v=m[0],x=m[1];return t.tooltipEl.style(v,x)}),t.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,l.on("mousemove.".concat(u),function(h){t.mouseInside=!0;var m=Cde(h),v=l.node(),x=v.offsetWidth,S=v.offsetHeight,w=[t.offsetX===null||t.offsetX===void 0?"-".concat(m[0]/x*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?S>130&&S-m[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",m[0]+"px").style("top",m[1]+"px").style("transform","translate(".concat(w.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseover.".concat(u),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseout.".concat(u),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):Wde(e.content)?(e.tooltipEl.text(""),$de(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function Kde(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var Zde=`.scene-nav-info { + position: absolute; + bottom: 5px; + width: 100%; + text-align: center; + color: slategrey; + opacity: 0.7; + font-size: 10px; + font-family: sans-serif; + pointer-events: none; + user-select: none; +} + +.scene-container canvas:focus { + outline: none; +}`;Kde(Zde);function _w(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,l){return e.hoverOrderComparator(a.object,l.object)});var s=r.find(function(a){return e.hoverFilter(a.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&kt(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var a=t,l=n||{x:0,y:0,z:0};if(!r)m(a),v(l);else{var u=Object.assign({},s.position),h=x();e.tweenGroup.add(new va(u).to(a,r).easing(vs.Quadratic.Out).onUpdate(m).start()),e.tweenGroup.add(new va(h).to(l,r/3).easing(vs.Quadratic.Out).onUpdate(v).start())}return this}return Object.assign({},s.position,{lookAt:x()});function m(S){var w=S.x,N=S.y,C=S.z;w!==void 0&&(s.position.x=w),N!==void 0&&(s.position.y=N),C!==void 0&&(s.position.z=C)}function v(S){var w=new Rr.Vector3(S.x,S.y,S.z);e.controls.enabled&&e.controls.target?e.controls.target=w:s.lookAt(w)}function x(){return Object.assign(new Rr.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var a=new Rr.Vector3(0,0,0),l=Math.max.apply(Math,Of(Object.entries(t).map(function(S){var w=aAe(S,2),N=w[0],C=w[1];return Math.max.apply(Math,Of(C.map(function(E){return Math.abs(a[N]-E)})))})))*2,u=(1-r*2/e.height)*s.fov,h=l/Math.atan(u*Math.PI/180),m=h/s.aspect,v=Math.max(h,m);if(v>0){var x=a.clone().sub(s.position).normalize().multiplyScalar(-v);this.cameraPosition(x,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new Rr.Box3(new Rr.Vector3(0,0,0),new Rr.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,Of(["x","y","z"].map(function(s){return tAe({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new Rr.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new Rr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new Rr.Raycaster;return a.setFromCamera(s,e.camera),Object.assign({},a.ray.at(r,new Rr.Vector3))},intersectingObjects:function(e,t,n){var r=new Rr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new Rr.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new Rr.Scene,camera:new Rr.PerspectiveCamera,clock:new Rr.Clock,tweenGroup:new My,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,a=n.useWebGPU,l=a===void 0?!1:a,u=n.rendererConfig,h=u===void 0?{}:u,m=n.extraRenderers,v=m===void 0?[]:m,x=n.waitForLoadComplete,S=x===void 0?!0:x;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new Qde(t.container),t.pointerPos=new Rr.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(w){return t.container.addEventListener(w,function(N){if(w==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&N.type==="pointermove"&&(N.pressure>0||t.isPointerPressed)&&(N.pointerType==="mouse"||N.movementX===void 0||[N.movementX,N.movementY].some(function(O){return Math.abs(O)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var C=E(t.container);t.pointerPos.x=N.pageX-C.left,t.pointerPos.y=N.pageY-C.top}function E(O){var U=O.getBoundingClientRect(),I=window.pageXOffset||document.documentElement.scrollLeft,j=window.pageYOffset||document.documentElement.scrollTop;return{top:U.top+j,left:U.left+I}}},{passive:!0})}),t.container.addEventListener("pointerup",function(w){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){w.button===0&&t.onClick(t.hoverObj||null,w,t.intersection),w.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,w,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(w){t.onRightClick&&w.preventDefault()}),t.renderer=new(l?cO:Rr.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},h)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=v,t.extraRenderers.forEach(function(w){w.domElement.style.position="absolute",w.domElement.style.top="0px",w.domElement.style.pointerEvents="none",t.container.appendChild(w.domElement)}),t.postProcessingComposer=new rhe(t.renderer),t.postProcessingComposer.addPass(new she(t.scene,t.camera)),t.controls=new{trackball:dce,orbit:Nce,fly:Vce}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Of(t.extraRenderers)).forEach(function(w){return w.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new Rr.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!S,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Of(e.extraRenderers)).forEach(function(S){return S.setSize(r,s)}),e.camera.aspect=r/s;var a=e.viewOffset.slice(0,2);a.some(function(S){return S})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(Of(a),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var l,u=e.width,h=e.height,m=e.viewOffset.slice(0,2);m.some(function(S){return S})?(l=e.camera).setViewOffset.apply(l,[u,h].concat(Of(m),[u,h])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new Rr.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var v=j0(e.backgroundColor).alpha;v===void 0&&(v=1),e.renderer.setClearColor(new Rr.Color(Ohe(1,e.backgroundColor)),v)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new Rr.TextureLoader().load(e.backgroundImageUrl,function(S){S.colorSpace=Rr.SRGBColorSpace,e.skysphere.material=new Rr.MeshBasicMaterial({map:S,side:Rr.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&x()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&x())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(S){return e.scene.remove(S)}),e.lights.forEach(function(S){return e.scene.add(S)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(S){return e.scene.remove(S)}),e.objects.forEach(function(S){return e.scene.add(S)}));function x(){e.loadComplete=e.scene.visible=!0}}});function uAe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var cAe=`.scene-container .clickable { + cursor: pointer; +}`;uAe(cAe);function yw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1?l-1:0),h=1;h1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=a();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(u){return s[u]=+s[u]}),!n)l(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new va(r).to(s,n).easing(vs.Cubic.InOut).onUpdate(l).start())}return this;function a(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(u){var h=u.lat,m=u.lng,v=u.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(h,m,v)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;slocalStorage.getItem("radio-theme")||"default"),[a,l]=ie.useState([]),[u,h]=ie.useState(null),[m,v]=ie.useState([]),[x,S]=ie.useState(!1),[w,N]=ie.useState({}),[C,E]=ie.useState([]),[O,U]=ie.useState(""),[I,j]=ie.useState(""),[z,G]=ie.useState(""),[W,q]=ie.useState([]),[V,Y]=ie.useState(!1),[te,ne]=ie.useState([]),[le,Q]=ie.useState(!1),[K,ae]=ie.useState(!1),[Ae,be]=ie.useState(.5),[Se,se]=ie.useState(null),[Ee,qe]=ie.useState(!1),[Ce,ke]=ie.useState(!1),Qe=ie.useRef(void 0),et=ie.useRef(void 0),Pt=ie.useRef(O);ie.useEffect(()=>{fetch("/api/radio/places").then(k=>k.json()).then(l).catch(console.error),fetch("/api/radio/guilds").then(k=>k.json()).then(k=>{if(E(k),k.length>0){U(k[0].id);const _e=k[0].voiceChannels.find(Be=>Be.members>0)??k[0].voiceChannels[0];_e&&j(_e.id)}}).catch(console.error),fetch("/api/radio/favorites").then(k=>k.json()).then(ne).catch(console.error)},[]),ie.useEffect(()=>{Pt.current=O},[O]),ie.useEffect(()=>{i!=null&&i.guildId&&"playing"in i&&i.type!=="radio_voicestats"?N(k=>{if(i.playing)return{...k,[i.guildId]:i.playing};const _e={...k};return delete _e[i.guildId],_e}):i!=null&&i.playing&&!(i!=null&&i.guildId)&&N(i.playing),i!=null&&i.favorites&&ne(i.favorites),i!=null&&i.volumes&&O&&i.volumes[O]!=null&&be(i.volumes[O]),(i==null?void 0:i.volume)!=null&&(i==null?void 0:i.guildId)===O&&be(i.volume),(i==null?void 0:i.type)==="radio_voicestats"&&i.guildId===Pt.current&&se({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})},[i,O]),ie.useEffect(()=>{if(localStorage.setItem("radio-theme",r),t.current&&e.current){const _e=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim();t.current.pointColor(()=>`rgba(${_e}, 0.85)`).atmosphereColor(`rgba(${_e}, 0.25)`)}},[r]);const Nt=ie.useRef(u);Nt.current=u;const Gt=ie.useRef(le);Gt.current=le;const Tt=ie.useCallback(()=>{var _e;const k=(_e=t.current)==null?void 0:_e.controls();k&&(k.autoRotate=!1),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{var Oe;if(Nt.current||Gt.current)return;const Be=(Oe=t.current)==null?void 0:Oe.controls();Be&&(Be.autoRotate=!0)},5e3)},[]);ie.useEffect(()=>{var _e;const k=(_e=t.current)==null?void 0:_e.controls();k&&(u||le?(k.autoRotate=!1,n.current&&clearTimeout(n.current)):k.autoRotate=!0)},[u,le]);const Ge=ie.useRef(void 0);Ge.current=k=>{h(k),Q(!1),S(!0),v([]),Tt(),t.current&&t.current.pointOfView({lat:k.geo[1],lng:k.geo[0],altitude:.4},800),fetch(`/api/radio/place/${k.id}/channels`).then(_e=>_e.json()).then(_e=>{v(_e),S(!1)}).catch(()=>S(!1))},ie.useEffect(()=>{const k=e.current;if(!k)return;k.clientWidth>0&&k.clientHeight>0&&ke(!0);const _e=new ResizeObserver(Be=>{for(const Oe of Be){const{width:je,height:Bt}=Oe.contentRect;je>0&&Bt>0&&ke(!0)}});return _e.observe(k),()=>_e.disconnect()},[]),ie.useEffect(()=>{if(!e.current||a.length===0)return;const k=e.current.clientWidth,_e=e.current.clientHeight;if(t.current){t.current.pointsData(a),k>0&&_e>0&&t.current.width(k).height(_e);return}if(k===0||_e===0)return;const Oe=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim()||"230, 126, 34",je=new TAe(e.current).backgroundColor("rgba(0,0,0,0)").atmosphereColor(`rgba(${Oe}, 0.25)`).atmosphereAltitude(.12).globeImageUrl("/nasa-blue-marble.jpg").pointsData(a).pointLat($t=>$t.geo[1]).pointLng($t=>$t.geo[0]).pointColor(()=>`rgba(${Oe}, 0.85)`).pointRadius($t=>Math.max(.12,Math.min(.45,.06+($t.size??1)*.005))).pointAltitude(.001).pointResolution(24).pointLabel($t=>`

`).onPointClick($t=>{var It;return(It=Ge.current)==null?void 0:It.call(Ge,$t)}).width(e.current.clientWidth).height(e.current.clientHeight);je.renderer().setPixelRatio(window.devicePixelRatio),je.pointOfView({lat:48,lng:10,altitude:GS});const Bt=je.controls();Bt&&(Bt.autoRotate=!0,Bt.autoRotateSpeed=.3);let yt=GS;const Xt=()=>{const It=je.pointOfView().altitude;if(Math.abs(It-yt)/yt<.05)return;yt=It;const Te=Math.sqrt(It/GS);je.pointRadius(nt=>Math.max(.12,Math.min(.45,.06+(nt.size??1)*.005))*Math.max(.15,Math.min(2.5,Te)))};Bt.addEventListener("change",Xt),t.current=je;const ln=e.current,mt=()=>Tt();ln.addEventListener("mousedown",mt),ln.addEventListener("touchstart",mt),ln.addEventListener("wheel",mt);const Wt=()=>{if(e.current&&t.current){const $t=e.current.clientWidth,It=e.current.clientHeight;$t>0&&It>0&&t.current.width($t).height(It)}};window.addEventListener("resize",Wt);const Yt=new ResizeObserver(()=>Wt());return Yt.observe(ln),()=>{Bt.removeEventListener("change",Xt),ln.removeEventListener("mousedown",mt),ln.removeEventListener("touchstart",mt),ln.removeEventListener("wheel",mt),window.removeEventListener("resize",Wt),Yt.disconnect()}},[a,Tt,Ce]);const dt=ie.useCallback(async(k,_e,Be,Oe)=>{if(!(!O||!I)){ae(!0);try{(await(await fetch("/api/radio/play",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,voiceChannelId:I,stationId:k,stationName:_e,placeName:Be??(u==null?void 0:u.title)??"",country:Oe??(u==null?void 0:u.country)??""})})).json()).ok&&(N(yt=>{var Xt,ln;return{...yt,[O]:{stationId:k,stationName:_e,placeName:Be??(u==null?void 0:u.title)??"",country:Oe??(u==null?void 0:u.country)??"",startedAt:new Date().toISOString(),channelName:((ln=(Xt=C.find(mt=>mt.id===O))==null?void 0:Xt.voiceChannels.find(mt=>mt.id===I))==null?void 0:ln.name)??""}}}),Tt())}catch(je){console.error(je)}ae(!1)}},[O,I,u,C]),he=ie.useCallback(async()=>{O&&(await fetch("/api/radio/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O})}),N(k=>{const _e={...k};return delete _e[O],_e}))},[O]),en=ie.useCallback(k=>{if(G(k),Qe.current&&clearTimeout(Qe.current),!k.trim()){q([]),Y(!1);return}Qe.current=setTimeout(async()=>{try{const Be=await(await fetch(`/api/radio/search?q=${encodeURIComponent(k)}`)).json();q(Be),Y(!0)}catch{q([])}},350)},[]),wt=ie.useCallback(k=>{var _e,Be,Oe;if(Y(!1),G(""),q([]),k.type==="channel"){const je=(_e=k.url.match(/\/listen\/[^/]+\/([^/]+)/))==null?void 0:_e[1];je&&dt(je,k.title,k.subtitle,"")}else if(k.type==="place"){const je=(Be=k.url.match(/\/visit\/[^/]+\/([^/]+)/))==null?void 0:Be[1],Bt=a.find(yt=>yt.id===je);Bt&&((Oe=Ge.current)==null||Oe.call(Ge,Bt))}},[a,dt]),qt=ie.useCallback(async(k,_e)=>{try{const Oe=await(await fetch("/api/radio/favorites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stationId:k,stationName:_e,placeName:(u==null?void 0:u.title)??"",country:(u==null?void 0:u.country)??"",placeId:(u==null?void 0:u.id)??""})})).json();Oe.favorites&&ne(Oe.favorites)}catch{}},[u]),Lt=ie.useCallback(k=>{be(k),O&&(et.current&&clearTimeout(et.current),et.current=setTimeout(()=>{fetch("/api/radio/volume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,volume:k})}).catch(console.error)},100))},[O]),hn=k=>te.some(_e=>_e.stationId===k),ut=O?w[O]:null,fe=C.find(k=>k.id===O);return P.jsxs("div",{className:"radio-container","data-theme":r,children:[P.jsxs("header",{className:"radio-topbar",children:[P.jsxs("div",{className:"radio-topbar-left",children:[P.jsx("span",{className:"radio-topbar-logo",children:"🌍"}),P.jsx("span",{className:"radio-topbar-title",children:"World Radio"}),C.length>1&&P.jsx("select",{className:"radio-sel",value:O,onChange:k=>{U(k.target.value);const _e=C.find(Oe=>Oe.id===k.target.value),Be=(_e==null?void 0:_e.voiceChannels.find(Oe=>Oe.members>0))??(_e==null?void 0:_e.voiceChannels[0]);j((Be==null?void 0:Be.id)??"")},children:C.map(k=>P.jsx("option",{value:k.id,children:k.name},k.id))}),P.jsxs("select",{className:"radio-sel",value:I,onChange:k=>j(k.target.value),children:[P.jsx("option",{value:"",children:"Voice Channel..."}),fe==null?void 0:fe.voiceChannels.map(k=>P.jsxs("option",{value:k.id,children:["🔊"," ",k.name,k.members>0?` (${k.members})`:""]},k.id))]})]}),ut&&P.jsxs("div",{className:"radio-topbar-np",children:[P.jsxs("div",{className:"radio-eq radio-eq-np",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),P.jsxs("div",{className:"radio-np-info",children:[P.jsx("span",{className:"radio-np-name",children:ut.stationName}),P.jsxs("span",{className:"radio-np-loc",children:[ut.placeName,ut.country?`, ${ut.country}`:""]})]})]}),P.jsxs("div",{className:"radio-topbar-right",children:[ut&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"radio-volume",children:[P.jsx("span",{className:"radio-volume-icon",children:Ae===0?"🔇":Ae<.4?"🔉":"🔊"}),P.jsx("input",{type:"range",className:"radio-volume-slider",min:0,max:1,step:.01,value:Ae,onChange:k=>Lt(Number(k.target.value))}),P.jsxs("span",{className:"radio-volume-val",children:[Math.round(Ae*100),"%"]})]}),P.jsxs("div",{className:"radio-conn",onClick:()=>qe(!0),title:"Verbindungsdetails",children:[P.jsx("span",{className:"radio-conn-dot"}),"Verbunden",(Se==null?void 0:Se.voicePing)!=null&&P.jsxs("span",{className:"radio-conn-ping",children:[Se.voicePing,"ms"]})]}),P.jsxs("button",{className:"radio-topbar-stop",onClick:he,children:["⏹"," Stop"]})]}),P.jsx("div",{className:"radio-theme-inline",children:wAe.map(k=>P.jsx("div",{className:`radio-theme-dot ${r===k.id?"active":""}`,style:{background:k.color},title:k.label,onClick:()=>s(k.id)},k.id))})]})]}),P.jsxs("div",{className:"radio-globe-wrap",children:[P.jsx("div",{className:"radio-globe",ref:e}),P.jsxs("div",{className:"radio-search",children:[P.jsxs("div",{className:"radio-search-wrap",children:[P.jsx("span",{className:"radio-search-icon",children:"🔍"}),P.jsx("input",{className:"radio-search-input",type:"text",placeholder:"Sender oder Stadt suchen...",value:z,onChange:k=>en(k.target.value),onFocus:()=>{W.length&&Y(!0)}}),z&&P.jsx("button",{className:"radio-search-clear",onClick:()=>{G(""),q([]),Y(!1)},children:"✕"})]}),V&&W.length>0&&P.jsx("div",{className:"radio-search-results",children:W.slice(0,12).map(k=>P.jsxs("button",{className:"radio-search-result",onClick:()=>wt(k),children:[P.jsx("span",{className:"radio-search-result-icon",children:k.type==="channel"?"📻":k.type==="place"?"📍":"🌍"}),P.jsxs("div",{className:"radio-search-result-text",children:[P.jsx("span",{className:"radio-search-result-title",children:k.title}),P.jsx("span",{className:"radio-search-result-sub",children:k.subtitle})]})]},k.id+k.url))})]}),!u&&!le&&P.jsxs("button",{className:"radio-fab",onClick:()=>{Q(!0),h(null)},title:"Favoriten",children:["⭐",te.length>0&&P.jsx("span",{className:"radio-fab-badge",children:te.length})]}),le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("h3",{children:["⭐"," Favoriten"]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>Q(!1),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:te.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Noch keine Favoriten"}):te.map(k=>P.jsxs("div",{className:`radio-station ${(ut==null?void 0:ut.stationId)===k.stationId?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.stationName}),P.jsxs("span",{className:"radio-station-loc",children:[k.placeName,", ",k.country]})]}),P.jsxs("div",{className:"radio-station-btns",children:[P.jsx("button",{className:"radio-btn-play",onClick:()=>dt(k.stationId,k.stationName,k.placeName,k.country),disabled:!I||K,children:"▶"}),P.jsx("button",{className:"radio-btn-fav active",onClick:()=>qt(k.stationId,k.stationName),children:"★"})]})]},k.stationId))})]}),u&&!le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("div",{children:[P.jsx("h3",{children:u.title}),P.jsx("span",{className:"radio-panel-sub",children:u.country})]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>h(null),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:x?P.jsxs("div",{className:"radio-panel-loading",children:[P.jsx("div",{className:"radio-spinner"}),"Sender werden geladen..."]}):m.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Keine Sender gefunden"}):m.map(k=>P.jsxs("div",{className:`radio-station ${(ut==null?void 0:ut.stationId)===k.id?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.title}),(ut==null?void 0:ut.stationId)===k.id&&P.jsxs("span",{className:"radio-station-live",children:[P.jsxs("span",{className:"radio-eq",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),"Live"]})]}),P.jsxs("div",{className:"radio-station-btns",children:[(ut==null?void 0:ut.stationId)===k.id?P.jsx("button",{className:"radio-btn-stop",onClick:he,children:"⏹"}):P.jsx("button",{className:"radio-btn-play",onClick:()=>dt(k.id,k.title),disabled:!I||K,children:"▶"}),P.jsx("button",{className:`radio-btn-fav ${hn(k.id)?"active":""}`,onClick:()=>qt(k.id,k.title),children:hn(k.id)?"★":"☆"})]})]},k.id))})]}),P.jsxs("div",{className:"radio-counter",children:["📻"," ",a.length.toLocaleString("de-DE")," Sender weltweit"]}),P.jsx("a",{className:"radio-attribution",href:"https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/",target:"_blank",rel:"noreferrer",children:"Imagery © NASA Blue Marble"})]}),Ee&&(()=>{const k=Se!=null&&Se.connectedSince?Math.floor((Date.now()-new Date(Se.connectedSince).getTime())/1e3):0,_e=Math.floor(k/3600),Be=Math.floor(k%3600/60),Oe=k%60,je=_e>0?`${_e}h ${String(Be).padStart(2,"0")}m ${String(Oe).padStart(2,"0")}s`:Be>0?`${Be}m ${String(Oe).padStart(2,"0")}s`:`${Oe}s`,Bt=yt=>yt==null?"var(--text-faint)":yt<80?"var(--success)":yt<150?"#f0a830":"#e04040";return P.jsx("div",{className:"radio-modal-overlay",onClick:()=>qe(!1),children:P.jsxs("div",{className:"radio-modal",onClick:yt=>yt.stopPropagation(),children:[P.jsxs("div",{className:"radio-modal-header",children:[P.jsx("span",{children:"📡"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"radio-modal-close",onClick:()=>qe(!1),children:"✕"})]}),P.jsxs("div",{className:"radio-modal-body",children:[P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Voice Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:Bt((Se==null?void 0:Se.voicePing)??null)}}),(Se==null?void 0:Se.voicePing)!=null?`${Se.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Gateway Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:Bt((Se==null?void 0:Se.gatewayPing)??null)}}),Se&&Se.gatewayPing>=0?`${Se.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Status"}),P.jsx("span",{className:"radio-modal-value",style:{color:(Se==null?void 0:Se.status)==="ready"?"var(--success)":"#f0a830"},children:(Se==null?void 0:Se.status)==="ready"?"Verbunden":(Se==null?void 0:Se.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Kanal"}),P.jsx("span",{className:"radio-modal-value",children:(Se==null?void 0:Se.channelName)||"---"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Verbunden seit"}),P.jsx("span",{className:"radio-modal-value",children:je||"---"})]})]})]})})})()]})}function EAe(i,e,t=365){const n=new Date(Date.now()+t*24*60*60*1e3).toUTCString();document.cookie=`${encodeURIComponent(i)}=${encodeURIComponent(e)}; expires=${n}; path=/; SameSite=Lax`}function CAe(i){const e=`${encodeURIComponent(i)}=`,t=document.cookie.split(";");for(const n of t){const r=n.trim();if(r.startsWith(e))return decodeURIComponent(r.slice(e.length))}return null}const Js="/api/soundboard";async function m7(i,e,t,n){const r=new URL(`${Js}/sounds`,window.location.origin);i&&r.searchParams.set("q",i),e!==void 0&&r.searchParams.set("folder",e),r.searchParams.set("fuzzy","0");const s=await fetch(r.toString());if(!s.ok)throw new Error("Fehler beim Laden der Sounds");return s.json()}async function NAe(){const i=await fetch(`${Js}/analytics`);if(!i.ok)throw new Error("Fehler beim Laden der Analytics");return i.json()}async function RAe(){const i=await fetch(`${Js}/categories`,{credentials:"include"});if(!i.ok)throw new Error("Fehler beim Laden der Kategorien");return i.json()}async function DAe(){const i=await fetch(`${Js}/channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channels");return i.json()}async function PAe(){const i=await fetch(`${Js}/selected-channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channel-Auswahl");const e=await i.json();return(e==null?void 0:e.selected)||{}}async function LAe(i,e){if(!(await fetch(`${Js}/selected-channel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Channel-Auswahl setzen fehlgeschlagen")}async function UAe(i,e,t,n,r){const s=await fetch(`${Js}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({soundName:i,guildId:e,channelId:t,volume:n,relativePath:r})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error((a==null?void 0:a.error)||"Play fehlgeschlagen")}}async function BAe(i,e,t,n,r){const s=await fetch(`${Js}/play-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,guildId:e,channelId:t,volume:n,filename:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error((a==null?void 0:a.error)||"Play-URL fehlgeschlagen");return a}async function OAe(i,e){const t=await fetch(`${Js}/download-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,filename:e})}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error((n==null?void 0:n.error)||"Download fehlgeschlagen");return n}async function IAe(i,e){if(!(await fetch(`${Js}/party/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Partymode Start fehlgeschlagen")}async function FAe(i){if(!(await fetch(`${Js}/party/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i})})).ok)throw new Error("Partymode Stop fehlgeschlagen")}async function g7(i,e){const t=await fetch(`${Js}/volume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,volume:e})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error((n==null?void 0:n.error)||"Volume aendern fehlgeschlagen")}}async function kAe(i){const e=new URL(`${Js}/volume`,window.location.origin);e.searchParams.set("guildId",i);const t=await fetch(e.toString());if(!t.ok)throw new Error("Fehler beim Laden der Lautstaerke");const n=await t.json();return typeof(n==null?void 0:n.volume)=="number"?n.volume:1}async function zAe(i){if(!(await fetch(`${Js}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}async function GAe(i,e){const t=await fetch(`${Js}/admin/sounds/rename`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({from:i,to:e})});if(!t.ok)throw new Error("Umbenennen fehlgeschlagen");const n=await t.json();return n==null?void 0:n.to}function qAe(i,e,t){return new Promise((n,r)=>{const s=new FormData;s.append("files",i),e&&s.append("customName",e);const a=new XMLHttpRequest;a.open("POST",`${Js}/upload`),a.upload.onprogress=l=>{l.lengthComputable&&t(Math.round(l.loaded/l.total*100))},a.onload=()=>{var l,u;if(a.status===200)try{const h=JSON.parse(a.responseText);n(((u=(l=h.files)==null?void 0:l[0])==null?void 0:u.name)??i.name)}catch{n(i.name)}else try{r(new Error(JSON.parse(a.responseText).error))}catch{r(new Error(`HTTP ${a.status}`))}},a.onerror=()=>r(new Error("Netzwerkfehler")),a.send(s)})}const VAe=[{id:"default",color:"#5865f2",label:"Discord"},{id:"purple",color:"#9b59b6",label:"Midnight"},{id:"forest",color:"#2ecc71",label:"Forest"},{id:"sunset",color:"#e67e22",label:"Sunset"},{id:"ocean",color:"#3498db",label:"Ocean"}],v7=["#3b82f6","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#06b6d4","#ef4444","#a855f7","#84cc16","#d946ef","#0ea5e9","#f43f5e","#10b981"];function jAe({data:i,isAdmin:e}){var hl,ts,Md;const[t,n]=ie.useState([]),[r,s]=ie.useState(0),[a,l]=ie.useState([]),[u,h]=ie.useState([]),[m,v]=ie.useState({totalSounds:0,totalPlays:0,mostPlayed:[]}),[x,S]=ie.useState("all"),[w,N]=ie.useState(""),[C,E]=ie.useState(""),[O,U]=ie.useState(""),[I,j]=ie.useState(!1),[z,G]=ie.useState(null),[W,q]=ie.useState([]),[V,Y]=ie.useState(""),te=ie.useRef(""),[ne,le]=ie.useState(!1),[Q,K]=ie.useState(1),[ae,Ae]=ie.useState(""),[be,Se]=ie.useState({}),[se,Ee]=ie.useState(()=>localStorage.getItem("jb-theme")||"default"),[qe,Ce]=ie.useState(()=>parseInt(localStorage.getItem("jb-card-size")||"110")),[ke,Qe]=ie.useState(!1),[et,Pt]=ie.useState([]),Nt=ie.useRef(!1),Gt=ie.useRef(void 0),Tt=e??!1,[Ge,dt]=ie.useState(!1),[he,en]=ie.useState([]),[wt,qt]=ie.useState(!1),[Lt,hn]=ie.useState(""),[ut,fe]=ie.useState({}),[k,_e]=ie.useState(""),[Be,Oe]=ie.useState(""),[je,Bt]=ie.useState(!1),[yt,Xt]=ie.useState([]),[ln,mt]=ie.useState(!1),Wt=ie.useRef(0);ie.useRef(void 0);const[Yt,$t]=ie.useState([]),[It,Te]=ie.useState(0),[nt,At]=ie.useState(""),[ce,xt]=ie.useState("naming"),[Ze,lt]=ie.useState(0),[bt,Kt]=ie.useState(null),[un,Ye]=ie.useState(!1),[St,ye]=ie.useState(null),[pt,Zt]=ie.useState(""),[Pe,at]=ie.useState(null),[ht,ot]=ie.useState(0);ie.useEffect(()=>{Nt.current=ke},[ke]),ie.useEffect(()=>{te.current=V},[V]),ie.useEffect(()=>{const xe=$n=>{var or;Array.from(((or=$n.dataTransfer)==null?void 0:or.items)??[]).some(er=>er.kind==="file")&&(Wt.current++,Bt(!0))},Rt=()=>{Wt.current=Math.max(0,Wt.current-1),Wt.current===0&&Bt(!1)},nn=$n=>$n.preventDefault(),fi=$n=>{var er;$n.preventDefault(),Wt.current=0,Bt(!1);const or=Array.from(((er=$n.dataTransfer)==null?void 0:er.files)??[]).filter(po=>/\.(mp3|wav)$/i.test(po.name));or.length&&Fe(or)};return window.addEventListener("dragenter",xe),window.addEventListener("dragleave",Rt),window.addEventListener("dragover",nn),window.addEventListener("drop",fi),()=>{window.removeEventListener("dragenter",xe),window.removeEventListener("dragleave",Rt),window.removeEventListener("dragover",nn),window.removeEventListener("drop",fi)}},[Tt]);const f=ie.useCallback((xe,Rt="info")=>{ye({msg:xe,type:Rt}),setTimeout(()=>ye(null),3e3)},[]),J=ie.useCallback(xe=>xe.relativePath??xe.fileName,[]),_n=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","music.youtube.com","instagram.com","www.instagram.com"],fn=ie.useCallback(xe=>{const Rt=xe.trim();return!Rt||/^https?:\/\//i.test(Rt)?Rt:"https://"+Rt},[]),zn=ie.useCallback(xe=>{try{const Rt=new URL(fn(xe)),nn=Rt.hostname.toLowerCase();return!!(Rt.pathname.toLowerCase().endsWith(".mp3")||_n.some(fi=>nn===fi||nn.endsWith("."+fi)))}catch{return!1}},[fn]),An=ie.useCallback(xe=>{try{const Rt=new URL(fn(xe)),nn=Rt.hostname.toLowerCase();return nn.includes("youtube")||nn==="youtu.be"?"youtube":nn.includes("instagram")?"instagram":Rt.pathname.toLowerCase().endsWith(".mp3")?"mp3":null}catch{return null}},[fn]),yn=V?V.split(":")[0]:"",zr=V?V.split(":")[1]:"",on=ie.useMemo(()=>W.find(xe=>`${xe.guildId}:${xe.channelId}`===V),[W,V]);ie.useEffect(()=>{const xe=()=>{const nn=new Date,fi=String(nn.getHours()).padStart(2,"0"),$n=String(nn.getMinutes()).padStart(2,"0"),or=String(nn.getSeconds()).padStart(2,"0");Zt(`${fi}:${$n}:${or}`)};xe();const Rt=setInterval(xe,1e3);return()=>clearInterval(Rt)},[]),ie.useEffect(()=>{(async()=>{try{const[xe,Rt]=await Promise.all([DAe(),PAe()]);if(q(xe),xe.length){const nn=xe[0].guildId,fi=Rt[nn],$n=fi&&xe.find(or=>or.guildId===nn&&or.channelId===fi);Y($n?`${nn}:${fi}`:`${xe[0].guildId}:${xe[0].channelId}`)}}catch(xe){f((xe==null?void 0:xe.message)||"Channel-Fehler","error")}try{const xe=await RAe();h(xe.categories||[])}catch{}})()},[]),ie.useEffect(()=>{localStorage.setItem("jb-theme",se)},[se]);const xn=ie.useRef(null);ie.useEffect(()=>{const xe=xn.current;if(!xe)return;xe.style.setProperty("--card-size",qe+"px");const Rt=qe/110;xe.style.setProperty("--card-emoji",Math.round(28*Rt)+"px"),xe.style.setProperty("--card-font",Math.max(9,Math.round(11*Rt))+"px"),localStorage.setItem("jb-card-size",String(qe))},[qe]),ie.useEffect(()=>{var xe,Rt,nn,fi,$n,or,er,po;if(i){if(i.soundboard){const Cr=i.soundboard;Array.isArray(Cr.party)&&Pt(Cr.party);try{const lr=Cr.selected||{},yi=(xe=te.current)==null?void 0:xe.split(":")[0];yi&&lr[yi]&&Y(`${yi}:${lr[yi]}`)}catch{}try{const lr=Cr.volumes||{},yi=(Rt=te.current)==null?void 0:Rt.split(":")[0];yi&&typeof lr[yi]=="number"&&K(lr[yi])}catch{}try{const lr=Cr.nowplaying||{},yi=(nn=te.current)==null?void 0:nn.split(":")[0];yi&&typeof lr[yi]=="string"&&Ae(lr[yi])}catch{}try{const lr=Cr.voicestats||{},yi=(fi=te.current)==null?void 0:fi.split(":")[0];yi&&lr[yi]&&Kt(lr[yi])}catch{}}if(i.type==="soundboard_party")Pt(Cr=>{const lr=new Set(Cr);return i.active?lr.add(i.guildId):lr.delete(i.guildId),Array.from(lr)});else if(i.type==="soundboard_channel"){const Cr=($n=te.current)==null?void 0:$n.split(":")[0];i.guildId===Cr&&Y(`${i.guildId}:${i.channelId}`)}else if(i.type==="soundboard_volume"){const Cr=(or=te.current)==null?void 0:or.split(":")[0];i.guildId===Cr&&typeof i.volume=="number"&&K(i.volume)}else if(i.type==="soundboard_nowplaying"){const Cr=(er=te.current)==null?void 0:er.split(":")[0];i.guildId===Cr&&Ae(i.name||"")}else if(i.type==="soundboard_voicestats"){const Cr=(po=te.current)==null?void 0:po.split(":")[0];i.guildId===Cr&&Kt({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})}}},[i]),ie.useEffect(()=>{Qe(yn?et.includes(yn):!1)},[V,et,yn]),ie.useEffect(()=>{(async()=>{try{let xe="__all__";x==="recent"?xe="__recent__":w&&(xe=w);const Rt=await m7(C,xe,void 0,!1);n(Rt.items),s(Rt.total),l(Rt.folders)}catch(xe){f((xe==null?void 0:xe.message)||"Sounds-Fehler","error")}})()},[x,w,C,ht,f]),ie.useEffect(()=>{Ar()},[ht]),ie.useEffect(()=>{const xe=CAe("favs");if(xe)try{Se(JSON.parse(xe))}catch{}},[]),ie.useEffect(()=>{try{EAe("favs",JSON.stringify(be))}catch{}},[be]),ie.useEffect(()=>{V&&(async()=>{try{const xe=await kAe(yn);K(xe)}catch{}})()},[V]),ie.useEffect(()=>{const xe=()=>{le(!1),at(null)};return document.addEventListener("click",xe),()=>document.removeEventListener("click",xe)},[]),ie.useEffect(()=>{Ge&&Tt&&Vt()},[Ge,Tt]);async function Ar(){try{const xe=await NAe();v(xe)}catch{}}async function ji(xe){if(!V)return f("Bitte einen Voice-Channel auswaehlen","error");try{await UAe(xe.name,yn,zr,Q,xe.relativePath),Ae(xe.name),Ar()}catch(Rt){f((Rt==null?void 0:Rt.message)||"Play fehlgeschlagen","error")}}function Ao(){var fi;const xe=fn(O);if(!xe)return f("Bitte einen Link eingeben","error");if(!zn(xe))return f("Nur YouTube, Instagram oder direkte MP3-Links","error");const Rt=An(xe);let nn="";if(Rt==="mp3")try{nn=((fi=new URL(xe).pathname.split("/").pop())==null?void 0:fi.replace(/\.mp3$/i,""))??""}catch{}G({url:xe,type:Rt,filename:nn,phase:"input"})}async function ue(){if(z){G(xe=>xe?{...xe,phase:"downloading"}:null);try{let xe;const Rt=z.filename.trim()||void 0;V&&yn&&zr?xe=(await BAe(z.url,yn,zr,Q,Rt)).saved:xe=(await OAe(z.url,Rt)).saved,G(nn=>nn?{...nn,phase:"done",savedName:xe}:null),U(""),ot(nn=>nn+1),Ar(),setTimeout(()=>G(null),2500)}catch(xe){G(Rt=>Rt?{...Rt,phase:"error",error:(xe==null?void 0:xe.message)||"Fehler"}:null)}}}async function Fe(xe){if(!Tt){f("Admin-Login erforderlich zum Hochladen","error");return}if(xe.length===0)return;$t(xe),Te(0);const Rt=xe[0].name.replace(/\.(mp3|wav)$/i,"");At(Rt),xt("naming"),lt(0)}async function tt(){if(Yt.length===0)return;const xe=Yt[It],Rt=nt.trim()||xe.name.replace(/\.(mp3|wav)$/i,"");xt("uploading"),lt(0);try{await qAe(xe,Rt,nn=>lt(nn)),xt("done"),setTimeout(()=>{const nn=It+1;if(nnfi+1),Ar(),f(`${Yt.length} Sound${Yt.length>1?"s":""} hochgeladen`,"info")},800)}catch(nn){f((nn==null?void 0:nn.message)||"Upload fehlgeschlagen","error"),$t([])}}function Ke(){const xe=It+1;if(xe0&&(ot(Rt=>Rt+1),Ar())}async function ze(){if(V){Ae("");try{await fetch(`${Js}/stop?guildId=${encodeURIComponent(yn)}`,{method:"POST"})}catch{}}}async function Qt(){if(!Z.length||!V)return;const xe=Z[Math.floor(Math.random()*Z.length)];ji(xe)}async function tn(){if(ke){await ze();try{await FAe(yn)}catch{}}else{if(!V)return f("Bitte einen Channel auswaehlen","error");try{await IAe(yn,zr)}catch{}}}async function Mt(xe){const Rt=`${xe.guildId}:${xe.channelId}`;Y(Rt),le(!1);try{await LAe(xe.guildId,xe.channelId)}catch{}}function ee(xe){Se(Rt=>({...Rt,[xe]:!Rt[xe]}))}async function Vt(){qt(!0);try{const xe=await m7("","__all__",void 0,!1);en(xe.items||[])}catch(xe){f((xe==null?void 0:xe.message)||"Admin-Sounds konnten nicht geladen werden","error")}finally{qt(!1)}}function Fn(xe){fe(Rt=>({...Rt,[xe]:!Rt[xe]}))}function Tn(xe){_e(J(xe)),Oe(xe.name)}function oi(){_e(""),Oe("")}async function Ai(){if(!k)return;const xe=Be.trim().replace(/\.(mp3|wav)$/i,"");if(!xe){f("Bitte einen gueltigen Namen eingeben","error");return}try{await GAe(k,xe),f("Sound umbenannt"),oi(),ot(Rt=>Rt+1),Ge&&await Vt()}catch(Rt){f((Rt==null?void 0:Rt.message)||"Umbenennen fehlgeschlagen","error")}}async function Ii(xe){if(xe.length!==0)try{await zAe(xe),f(xe.length===1?"Sound geloescht":`${xe.length} Sounds geloescht`),fe({}),oi(),ot(Rt=>Rt+1),Ge&&await Vt()}catch(Rt){f((Rt==null?void 0:Rt.message)||"Loeschen fehlgeschlagen","error")}}const Z=ie.useMemo(()=>x==="favorites"?t.filter(xe=>be[xe.relativePath??xe.fileName]):t,[t,x,be]),Vn=ie.useMemo(()=>Object.values(be).filter(Boolean).length,[be]),bn=ie.useMemo(()=>a.filter(xe=>!["__all__","__recent__","__top3__"].includes(xe.key)),[a]),Mr=ie.useMemo(()=>{const xe={};return bn.forEach((Rt,nn)=>{xe[Rt.key]=v7[nn%v7.length]}),xe},[bn]),pi=ie.useMemo(()=>{const xe=new Set,Rt=new Set;return Z.forEach((nn,fi)=>{const $n=nn.name.charAt(0).toUpperCase();xe.has($n)||(xe.add($n),Rt.add(fi))}),Rt},[Z]),Ds=ie.useMemo(()=>{const xe={};return W.forEach(Rt=>{xe[Rt.guildName]||(xe[Rt.guildName]=[]),xe[Rt.guildName].push(Rt)}),xe},[W]),Gr=ie.useMemo(()=>{const xe=Lt.trim().toLowerCase();return xe?he.filter(Rt=>{const nn=J(Rt).toLowerCase();return Rt.name.toLowerCase().includes(xe)||(Rt.folder||"").toLowerCase().includes(xe)||nn.includes(xe)}):he},[Lt,he,J]),qr=ie.useMemo(()=>Object.keys(ut).filter(xe=>ut[xe]),[ut]),Er=ie.useMemo(()=>Gr.filter(xe=>!!ut[J(xe)]).length,[Gr,ut,J]),Ni=Gr.length>0&&Er===Gr.length,Yi=m.mostPlayed.slice(0,10),_i=m.totalSounds||r,pr=pt.slice(0,5),Vr=pt.slice(5);return P.jsxs("div",{className:"sb-app","data-theme":se,ref:xn,children:[ke&&P.jsx("div",{className:"party-overlay active"}),P.jsxs("header",{className:"topbar",children:[P.jsxs("div",{className:"topbar-left",children:[P.jsx("div",{className:"sb-app-logo",children:P.jsx("span",{className:"material-icons",style:{fontSize:16,color:"white"},children:"music_note"})}),P.jsx("span",{className:"sb-app-title",children:"Soundboard"}),P.jsxs("div",{className:"channel-dropdown",onClick:xe=>xe.stopPropagation(),children:[P.jsxs("button",{className:`channel-btn ${ne?"open":""}`,onClick:()=>le(!ne),children:[P.jsx("span",{className:"material-icons cb-icon",children:"headset"}),V&&P.jsx("span",{className:"channel-status"}),P.jsx("span",{className:"channel-label",children:on?`${on.channelName}${on.members?` (${on.members})`:""}`:"Channel..."}),P.jsx("span",{className:"material-icons chevron",children:"expand_more"})]}),ne&&P.jsxs("div",{className:"channel-menu visible",children:[Object.entries(Ds).map(([xe,Rt])=>P.jsxs(FF.Fragment,{children:[P.jsx("div",{className:"channel-menu-header",children:xe}),Rt.map(nn=>P.jsxs("div",{className:`channel-option ${`${nn.guildId}:${nn.channelId}`===V?"active":""}`,onClick:()=>Mt(nn),children:[P.jsx("span",{className:"material-icons co-icon",children:"volume_up"}),nn.channelName,nn.members?` (${nn.members})`:""]},`${nn.guildId}:${nn.channelId}`))]},xe)),W.length===0&&P.jsx("div",{className:"channel-option",style:{color:"var(--text-faint)",cursor:"default"},children:"Keine Channels verfuegbar"})]})]})]}),P.jsx("div",{className:"clock-wrap",children:P.jsxs("div",{className:"clock",children:[pr,P.jsx("span",{className:"clock-seconds",children:Vr})]})}),P.jsxs("div",{className:"topbar-right",children:[ae&&P.jsxs("div",{className:"now-playing",children:[P.jsxs("div",{className:"np-waves active",children:[P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"})]}),P.jsx("span",{className:"np-label",children:"Last Played:"})," ",P.jsx("span",{className:"np-name",children:ae})]}),V&&P.jsxs("div",{className:"connection",onClick:()=>Ye(!0),style:{cursor:"pointer"},title:"Verbindungsdetails",children:[P.jsx("span",{className:"conn-dot"}),"Verbunden",(bt==null?void 0:bt.voicePing)!=null&&P.jsxs("span",{className:"conn-ping",children:[bt.voicePing,"ms"]})]}),Tt&&P.jsx("button",{className:"admin-btn-icon active",onClick:()=>dt(!0),title:"Admin",children:P.jsx("span",{className:"material-icons",children:"settings"})})]})]}),P.jsxs("div",{className:"toolbar",children:[P.jsxs("div",{className:"cat-tabs",children:[P.jsxs("button",{className:`cat-tab ${x==="all"?"active":""}`,onClick:()=>{S("all"),N("")},children:["Alle",P.jsx("span",{className:"tab-count",children:r})]}),P.jsx("button",{className:`cat-tab ${x==="recent"?"active":""}`,onClick:()=>{S("recent"),N("")},children:"Neu hinzugefuegt"}),P.jsxs("button",{className:`cat-tab ${x==="favorites"?"active":""}`,onClick:()=>{S("favorites"),N("")},children:["Favoriten",Vn>0&&P.jsx("span",{className:"tab-count",children:Vn})]})]}),P.jsxs("div",{className:"search-wrap",children:[P.jsx("span",{className:"material-icons search-icon",children:"search"}),P.jsx("input",{className:"search-input",type:"text",placeholder:"Suchen...",value:C,onChange:xe=>E(xe.target.value)}),C&&P.jsx("button",{className:"search-clear",onClick:()=>E(""),children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsxs("div",{className:"url-import-wrap",children:[P.jsx("span",{className:"material-icons url-import-icon",children:An(O)==="youtube"?"smart_display":An(O)==="instagram"?"photo_camera":"link"}),P.jsx("input",{className:"url-import-input",type:"text",placeholder:"YouTube / Instagram / MP3-Link...",value:O,onChange:xe=>U(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&Ao()}}),O&&P.jsx("span",{className:`url-import-tag ${zn(O)?"valid":"invalid"}`,children:An(O)==="youtube"?"YT":An(O)==="instagram"?"IG":An(O)==="mp3"?"MP3":"?"}),P.jsx("button",{className:"url-import-btn",onClick:()=>{Ao()},disabled:I||!!O&&!zn(O),title:"Sound herunterladen",children:I?"Laedt...":"Download"})]}),P.jsx("div",{className:"toolbar-spacer"}),P.jsxs("div",{className:"volume-control",children:[P.jsx("span",{className:"material-icons vol-icon",onClick:()=>{const xe=Q>0?0:.5;K(xe),yn&&g7(yn,xe).catch(()=>{})},children:Q===0?"volume_off":Q<.5?"volume_down":"volume_up"}),P.jsx("input",{type:"range",className:"vol-slider",min:0,max:1,step:.01,value:Q,onChange:xe=>{const Rt=parseFloat(xe.target.value);K(Rt),yn&&(Gt.current&&clearTimeout(Gt.current),Gt.current=setTimeout(()=>{g7(yn,Rt).catch(()=>{})},120))},style:{"--vol":`${Math.round(Q*100)}%`}}),P.jsxs("span",{className:"vol-pct",children:[Math.round(Q*100),"%"]})]}),P.jsxs("button",{className:"tb-btn random",onClick:Qt,title:"Zufaelliger Sound",children:[P.jsx("span",{className:"material-icons tb-icon",children:"shuffle"}),"Random"]}),P.jsxs("button",{className:`tb-btn party ${ke?"active":""}`,onClick:tn,title:"Party Mode",children:[P.jsx("span",{className:"material-icons tb-icon",children:ke?"celebration":"auto_awesome"}),ke?"Party!":"Party"]}),P.jsxs("button",{className:"tb-btn stop",onClick:ze,title:"Alle stoppen",children:[P.jsx("span",{className:"material-icons tb-icon",children:"stop"}),"Stop"]}),P.jsxs("div",{className:"size-control",title:"Button-Groesse",children:[P.jsx("span",{className:"material-icons sc-icon",children:"grid_view"}),P.jsx("input",{type:"range",className:"size-slider",min:80,max:160,value:qe,onChange:xe=>Ce(parseInt(xe.target.value))})]}),P.jsx("div",{className:"theme-selector",children:VAe.map(xe=>P.jsx("div",{className:`theme-dot ${se===xe.id?"active":""}`,style:{background:xe.color},title:xe.label,onClick:()=>Ee(xe.id)},xe.id))})]}),P.jsxs("div",{className:"analytics-strip",children:[P.jsxs("div",{className:"analytics-card",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"library_music"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Sounds gesamt"}),P.jsx("strong",{className:"analytics-value",children:_i})]})]}),P.jsxs("div",{className:"analytics-card analytics-wide",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"leaderboard"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Most Played"}),P.jsx("div",{className:"analytics-top-list",children:Yi.length===0?P.jsx("span",{className:"analytics-muted",children:"Noch keine Plays"}):Yi.map((xe,Rt)=>P.jsxs("span",{className:"analytics-chip",children:[Rt+1,". ",xe.name," (",xe.count,")"]},xe.relativePath))})]})]})]}),x==="all"&&bn.length>0&&P.jsx("div",{className:"category-strip",children:bn.map(xe=>{const Rt=Mr[xe.key]||"#888",nn=w===xe.key;return P.jsxs("button",{className:`cat-chip ${nn?"active":""}`,onClick:()=>N(nn?"":xe.key),style:nn?{borderColor:Rt,color:Rt}:void 0,children:[P.jsx("span",{className:"cat-dot",style:{background:Rt}}),xe.name.replace(/\s*\(\d+\)\s*$/,""),P.jsx("span",{className:"cat-count",children:xe.count})]},xe.key)})}),P.jsx("main",{className:"main",children:Z.length===0?P.jsxs("div",{className:"empty-state visible",children:[P.jsx("div",{className:"empty-emoji",children:x==="favorites"?"⭐":"🔇"}),P.jsx("div",{className:"empty-title",children:x==="favorites"?"Noch keine Favoriten":C?`Kein Sound fuer "${C}" gefunden`:"Keine Sounds vorhanden"}),P.jsx("div",{className:"empty-desc",children:x==="favorites"?"Klick den Stern auf einem Sound!":"Hier gibt's noch nichts zu hoeren."})]}):P.jsx("div",{className:"sound-grid",children:Z.map((xe,Rt)=>{var lr;const nn=xe.relativePath??xe.fileName,fi=!!be[nn],$n=ae===xe.name,or=xe.isRecent||((lr=xe.badges)==null?void 0:lr.includes("new")),er=xe.name.charAt(0).toUpperCase(),po=pi.has(Rt),Cr=xe.folder&&Mr[xe.folder]||"var(--accent)";return P.jsxs("div",{className:`sound-card ${$n?"playing":""} ${po?"has-initial":""}`,style:{animationDelay:`${Math.min(Rt*20,400)}ms`},onClick:yi=>{const Iu=yi.currentTarget,zo=Iu.getBoundingClientRect(),Go=document.createElement("div");Go.className="ripple";const fl=Math.max(zo.width,zo.height);Go.style.width=Go.style.height=fl+"px",Go.style.left=yi.clientX-zo.left-fl/2+"px",Go.style.top=yi.clientY-zo.top-fl/2+"px",Iu.appendChild(Go),setTimeout(()=>Go.remove(),500),ji(xe)},onContextMenu:yi=>{yi.preventDefault(),yi.stopPropagation(),at({x:Math.min(yi.clientX,window.innerWidth-170),y:Math.min(yi.clientY,window.innerHeight-140),sound:xe})},title:`${xe.name}${xe.folder?` (${xe.folder})`:""}`,children:[or&&P.jsx("span",{className:"new-badge",children:"NEU"}),P.jsx("span",{className:`fav-star ${fi?"active":""}`,onClick:yi=>{yi.stopPropagation(),ee(nn)},children:P.jsx("span",{className:"material-icons fav-icon",children:fi?"star":"star_border"})}),po&&P.jsx("span",{className:"sound-emoji",style:{color:Cr},children:er}),P.jsx("span",{className:"sound-name",children:xe.name}),xe.folder&&P.jsx("span",{className:"sound-duration",children:xe.folder}),P.jsxs("div",{className:"playing-indicator",children:[P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"})]})]},nn)})})}),Pe&&P.jsxs("div",{className:"ctx-menu visible",style:{left:Pe.x,top:Pe.y},onClick:xe=>xe.stopPropagation(),children:[P.jsxs("div",{className:"ctx-item",onClick:()=>{ji(Pe.sound),at(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"play_arrow"}),"Abspielen"]}),P.jsxs("div",{className:"ctx-item",onClick:()=>{ee(Pe.sound.relativePath??Pe.sound.fileName),at(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:be[Pe.sound.relativePath??Pe.sound.fileName]?"star":"star_border"}),"Favorit"]}),Tt&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"ctx-sep"}),P.jsxs("div",{className:"ctx-item danger",onClick:async()=>{const xe=Pe.sound.relativePath??Pe.sound.fileName;await Ii([xe]),at(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"delete"}),"Loeschen"]})]})]}),un&&(()=>{const xe=bt!=null&&bt.connectedSince?Math.floor((Date.now()-new Date(bt.connectedSince).getTime())/1e3):0,Rt=Math.floor(xe/3600),nn=Math.floor(xe%3600/60),fi=xe%60,$n=Rt>0?`${Rt}h ${String(nn).padStart(2,"0")}m ${String(fi).padStart(2,"0")}s`:nn>0?`${nn}m ${String(fi).padStart(2,"0")}s`:`${fi}s`,or=er=>er==null?"var(--muted)":er<80?"var(--green)":er<150?"#f0a830":"#e04040";return P.jsx("div",{className:"conn-modal-overlay",onClick:()=>Ye(!1),children:P.jsxs("div",{className:"conn-modal",onClick:er=>er.stopPropagation(),children:[P.jsxs("div",{className:"conn-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20,color:"var(--green)"},children:"cell_tower"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"conn-modal-close",onClick:()=>Ye(!1),children:P.jsx("span",{className:"material-icons",children:"close"})})]}),P.jsxs("div",{className:"conn-modal-body",children:[P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Voice Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:or((bt==null?void 0:bt.voicePing)??null)}}),(bt==null?void 0:bt.voicePing)!=null?`${bt.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Gateway Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:or((bt==null?void 0:bt.gatewayPing)??null)}}),bt&&bt.gatewayPing>=0?`${bt.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Status"}),P.jsx("span",{className:"conn-stat-value",style:{color:(bt==null?void 0:bt.status)==="ready"?"var(--green)":"#f0a830"},children:(bt==null?void 0:bt.status)==="ready"?"Verbunden":(bt==null?void 0:bt.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Kanal"}),P.jsx("span",{className:"conn-stat-value",children:(bt==null?void 0:bt.channelName)||"---"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Verbunden seit"}),P.jsx("span",{className:"conn-stat-value",children:$n||"---"})]})]})]})})})(),St&&P.jsxs("div",{className:`toast ${St.type}`,children:[P.jsx("span",{className:"material-icons toast-icon",children:St.type==="error"?"error_outline":"check_circle"}),St.msg]}),Ge&&P.jsx("div",{className:"admin-overlay",onClick:xe=>{xe.target===xe.currentTarget&&dt(!1)},children:P.jsxs("div",{className:"admin-panel",children:[P.jsxs("h3",{children:["Admin",P.jsx("button",{className:"admin-close",onClick:()=>dt(!1),children:P.jsx("span",{className:"material-icons",style:{fontSize:18},children:"close"})})]}),P.jsxs("div",{className:"admin-shell",children:[P.jsxs("div",{className:"admin-header-row",children:[P.jsx("p",{className:"admin-status",children:"Eingeloggt als Admin"}),P.jsx("div",{className:"admin-actions-inline",children:P.jsx("button",{className:"admin-btn-action outline",onClick:()=>{Vt()},disabled:wt,children:"Aktualisieren"})})]}),P.jsxs("div",{className:"admin-field admin-search-field",children:[P.jsx("label",{children:"Sounds verwalten"}),P.jsx("input",{type:"text",value:Lt,onChange:xe=>hn(xe.target.value),placeholder:"Nach Name, Ordner oder Pfad filtern..."})]}),P.jsxs("div",{className:"admin-bulk-row",children:[P.jsxs("label",{className:"admin-select-all",children:[P.jsx("input",{type:"checkbox",checked:Ni,onChange:xe=>{const Rt=xe.target.checked,nn={...ut};Gr.forEach(fi=>{nn[J(fi)]=Rt}),fe(nn)}}),P.jsxs("span",{children:["Alle sichtbaren auswaehlen (",Er,"/",Gr.length,")"]})]}),P.jsx("button",{className:"admin-btn-action danger",disabled:qr.length===0,onClick:async()=>{window.confirm(`Wirklich ${qr.length} Sound(s) loeschen?`)&&await Ii(qr)},children:"Ausgewaehlte loeschen"})]}),P.jsx("div",{className:"admin-list-wrap",children:wt?P.jsx("div",{className:"admin-empty",children:"Lade Sounds..."}):Gr.length===0?P.jsx("div",{className:"admin-empty",children:"Keine Sounds gefunden."}):P.jsx("div",{className:"admin-list",children:Gr.map(xe=>{const Rt=J(xe),nn=k===Rt;return P.jsxs("div",{className:"admin-item",children:[P.jsx("label",{className:"admin-item-check",children:P.jsx("input",{type:"checkbox",checked:!!ut[Rt],onChange:()=>Fn(Rt)})}),P.jsxs("div",{className:"admin-item-main",children:[P.jsx("div",{className:"admin-item-name",children:xe.name}),P.jsxs("div",{className:"admin-item-meta",children:[xe.folder?`Ordner: ${xe.folder}`:"Root"," · ",Rt]}),nn&&P.jsxs("div",{className:"admin-rename-row",children:[P.jsx("input",{value:Be,onChange:fi=>Oe(fi.target.value),onKeyDown:fi=>{fi.key==="Enter"&&Ai(),fi.key==="Escape"&&oi()},placeholder:"Neuer Name..."}),P.jsx("button",{className:"admin-btn-action primary",onClick:()=>{Ai()},children:"Speichern"}),P.jsx("button",{className:"admin-btn-action outline",onClick:oi,children:"Abbrechen"})]})]}),!nn&&P.jsxs("div",{className:"admin-item-actions",children:[P.jsx("button",{className:"admin-btn-action outline",onClick:()=>Tn(xe),children:"Umbenennen"}),P.jsx("button",{className:"admin-btn-action danger ghost",onClick:async()=>{window.confirm(`Sound "${xe.name}" loeschen?`)&&await Ii([Rt])},children:"Loeschen"})]})]},Rt)})})})]})]})}),je&&P.jsx("div",{className:"drop-overlay",children:P.jsxs("div",{className:"drop-zone",children:[P.jsx("span",{className:"material-icons drop-icon",children:"cloud_upload"}),P.jsx("div",{className:"drop-title",children:"MP3 & WAV hier ablegen"}),P.jsx("div",{className:"drop-sub",children:"Mehrere Dateien gleichzeitig moeglich"})]})}),ln&&yt.length>0&&P.jsxs("div",{className:"upload-queue",children:[P.jsxs("div",{className:"uq-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),P.jsx("span",{children:yt.every(xe=>xe.status==="done"||xe.status==="error")?`${yt.filter(xe=>xe.status==="done").length} von ${yt.length} hochgeladen`:`Lade hoch… (${yt.filter(xe=>xe.status==="done").length}/${yt.length})`}),P.jsx("button",{className:"uq-close",onClick:()=>{mt(!1),Xt([])},children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsx("div",{className:"uq-list",children:yt.map(xe=>P.jsxs("div",{className:`uq-item uq-${xe.status}`,children:[P.jsx("span",{className:"material-icons uq-file-icon",children:"audio_file"}),P.jsxs("div",{className:"uq-info",children:[P.jsx("div",{className:"uq-name",title:xe.savedName??xe.file.name,children:xe.savedName??xe.file.name}),P.jsxs("div",{className:"uq-size",children:[(xe.file.size/1024).toFixed(0)," KB"]})]}),(xe.status==="waiting"||xe.status==="uploading")&&P.jsx("div",{className:"uq-progress-wrap",children:P.jsx("div",{className:"uq-progress-bar",style:{width:`${xe.progress}%`}})}),P.jsx("span",{className:`material-icons uq-status-icon uq-status-${xe.status}`,children:xe.status==="done"?"check_circle":xe.status==="error"?"error":xe.status==="uploading"?"sync":"schedule"}),xe.status==="error"&&P.jsx("div",{className:"uq-error",children:xe.error})]},xe.id))})]}),Yt.length>0&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>ce==="naming"&&Ke(),children:P.jsxs("div",{className:"dl-modal",onClick:xe=>xe.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:"upload_file"}),P.jsxs("span",{children:[ce==="naming"?"Sound benennen":ce==="uploading"?"Wird hochgeladen...":"Gespeichert!",Yt.length>1&&` (${It+1}/${Yt.length})`]}),ce==="naming"&&P.jsx("button",{className:"dl-modal-close",onClick:Ke,children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:"dl-modal-tag mp3",children:"Datei"}),P.jsx("span",{className:"dl-modal-url-text",title:(hl=Yt[It])==null?void 0:hl.name,children:(ts=Yt[It])==null?void 0:ts.name}),P.jsxs("span",{style:{marginLeft:"auto",opacity:.5,fontSize:12},children:[((((Md=Yt[It])==null?void 0:Md.size)??0)/1024).toFixed(0)," KB"]})]}),ce==="naming"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:"Dateiname eingeben...",value:nt,onChange:xe=>At(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&tt()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]})]}),ce==="uploading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsxs("span",{children:["Upload: ",Ze,"%"]})]}),ce==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsx("span",{children:"Erfolgreich hochgeladen!"})]})]}),ce==="naming"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:Ke,children:Yt.length>1?"Überspringen":"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void tt(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),"Hochladen"]})]})]})}),z&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>z.phase!=="downloading"&&G(null),children:P.jsxs("div",{className:"dl-modal",onClick:xe=>xe.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:z.type==="youtube"?"smart_display":z.type==="instagram"?"photo_camera":"audio_file"}),P.jsx("span",{children:z.phase==="input"?"Sound herunterladen":z.phase==="downloading"?"Wird heruntergeladen...":z.phase==="done"?"Fertig!":"Fehler"}),z.phase!=="downloading"&&P.jsx("button",{className:"dl-modal-close",onClick:()=>G(null),children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:`dl-modal-tag ${z.type??""}`,children:z.type==="youtube"?"YouTube":z.type==="instagram"?"Instagram":"MP3"}),P.jsx("span",{className:"dl-modal-url-text",title:z.url,children:z.url.length>60?z.url.slice(0,57)+"...":z.url})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:z.type==="mp3"?"Dateiname...":"Wird automatisch erkannt...",value:z.filename,onChange:xe=>G(Rt=>Rt?{...Rt,filename:xe.target.value}:null),onKeyDown:xe=>{xe.key==="Enter"&&ue()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]}),P.jsx("span",{className:"dl-modal-hint",children:"Leer lassen = automatischer Name"})]}),z.phase==="downloading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsx("span",{children:z.type==="youtube"||z.type==="instagram"?"Audio wird extrahiert...":"MP3 wird heruntergeladen..."})]}),z.phase==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsxs("span",{children:["Gespeichert als ",P.jsx("b",{children:z.savedName})]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-error",children:[P.jsx("span",{className:"material-icons",style:{color:"#e74c3c"},children:"error"}),P.jsx("span",{children:z.error})]})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void ue(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"download"}),"Herunterladen"]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Schliessen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>G(xe=>xe?{...xe,phase:"input",error:void 0}:null),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"refresh"}),"Nochmal"]})]})]})})]})}const _7={IRON:"#6b6b6b",BRONZE:"#8c6239",SILVER:"#8c8c8c",GOLD:"#d4a017",PLATINUM:"#28b29e",EMERALD:"#1e9e5e",DIAMOND:"#576cce",MASTER:"#9d48e0",GRANDMASTER:"#e44c3e",CHALLENGER:"#f4c874"},HAe={SOLORANKED:"Ranked Solo",FLEXRANKED:"Ranked Flex",NORMAL:"Normal",ARAM:"ARAM",ARENA:"Arena",URF:"URF",BOT:"Co-op vs AI"},WAe="https://ddragon.leagueoflegends.com/cdn/15.5.1/img";function ym(i){return`${WAe}/champion/${i}.png`}function y7(i){const e=Math.floor((Date.now()-new Date(i).getTime())/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function $Ae(i){const e=Math.floor(i/60),t=i%60;return`${e}:${String(t).padStart(2,"0")}`}function x7(i,e,t){return e===0?"Perfect":((i+t)/e).toFixed(2)}function b7(i,e){const t=i+e;return t>0?Math.round(i/t*100):0}function XAe(i,e){if(!i)return"Unranked";const t=["","I","II","III","IV"];return`${i.charAt(0)}${i.slice(1).toLowerCase()}${e?" "+(t[e]??e):""}`}function YAe({data:i}){var Lt,hn,ut,fe;const[e,t]=ie.useState(""),[n,r]=ie.useState("EUW"),[s,a]=ie.useState([]),[l,u]=ie.useState(null),[h,m]=ie.useState([]),[v,x]=ie.useState(!1),[S,w]=ie.useState(null),[N,C]=ie.useState([]),[E,O]=ie.useState(null),[U,I]=ie.useState({}),[j,z]=ie.useState(!1),[G,W]=ie.useState(!1),[q,V]=ie.useState(null),[Y,te]=ie.useState("aram"),[ne,le]=ie.useState("EUW"),[Q,K]=ie.useState([]),[ae,Ae]=ie.useState(!1),[be,Se]=ie.useState(null),[se,Ee]=ie.useState([]),[qe,Ce]=ie.useState(""),[ke,Qe]=ie.useState(!1),et=ie.useRef(null),Pt=ie.useRef(null);ie.useEffect(()=>{fetch("/api/lolstats/regions").then(k=>k.json()).then(a).catch(()=>{}),fetch("/api/lolstats/recent").then(k=>k.json()).then(C).catch(()=>{}),fetch("/api/lolstats/modes").then(k=>k.json()).then(Ee).catch(()=>{})},[]),ie.useEffect(()=>{Y&&(Ae(!0),Se(null),Qe(!1),fetch(`/api/lolstats/tierlist?mode=${Y}®ion=${ne}`).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>K(k.champions??[])).catch(k=>Se(k.message)).finally(()=>Ae(!1)))},[Y,ne]),ie.useEffect(()=>{i&&(i.recentSearches&&C(i.recentSearches),i.regions&&!s.length&&a(i.regions))},[i]);const Nt=ie.useCallback(async(k,_e,Be)=>{W(!0);try{const Oe=`gameName=${encodeURIComponent(k)}&tagLine=${encodeURIComponent(_e)}®ion=${Be}`,je=await fetch(`/api/lolstats/renew?${Oe}`,{method:"POST"});if(je.ok){const Bt=await je.json();return Bt.last_updated_at&&V(Bt.last_updated_at),Bt.renewed??!1}}catch{}return W(!1),!1},[]),Gt=ie.useCallback(async(k,_e,Be,Oe=!1)=>{var Xt,ln;let je=k??"",Bt=_e??"";const yt=Be??n;if(!je){const mt=e.split("#");je=((Xt=mt[0])==null?void 0:Xt.trim())??"",Bt=((ln=mt[1])==null?void 0:ln.trim())??""}if(!je||!Bt){w("Bitte im Format Name#Tag eingeben");return}x(!0),w(null),u(null),m([]),O(null),I({}),Pt.current={gameName:je,tagLine:Bt,region:yt},Oe||Nt(je,Bt,yt).finally(()=>W(!1));try{const mt=`gameName=${encodeURIComponent(je)}&tagLine=${encodeURIComponent(Bt)}®ion=${yt}`,[Wt,Yt]=await Promise.all([fetch(`/api/lolstats/profile?${mt}`),fetch(`/api/lolstats/matches?${mt}&limit=10`)]);if(!Wt.ok){const It=await Wt.json();throw new Error(It.error??`Fehler ${Wt.status}`)}const $t=await Wt.json();if(u($t),$t.updated_at&&V($t.updated_at),Yt.ok){const It=await Yt.json();m(Array.isArray(It)?It:[])}}catch(mt){w(mt.message)}x(!1)},[e,n,Nt]),Tt=ie.useCallback(async()=>{const k=Pt.current;if(!(!k||G)){W(!0);try{await Nt(k.gameName,k.tagLine,k.region),await new Promise(_e=>setTimeout(_e,1500)),await Gt(k.gameName,k.tagLine,k.region,!0)}finally{W(!1)}}},[Nt,Gt,G]),Ge=ie.useCallback(async()=>{if(!(!l||j)){z(!0);try{const k=`gameName=${encodeURIComponent(l.game_name)}&tagLine=${encodeURIComponent(l.tagline)}®ion=${n}&limit=20`,_e=await fetch(`/api/lolstats/matches?${k}`);if(_e.ok){const Be=await _e.json();m(Array.isArray(Be)?Be:[])}}catch{}z(!1)}},[l,n,j]),dt=ie.useCallback(async k=>{var _e;if(E===k.id){O(null);return}if(O(k.id),!(((_e=k.participants)==null?void 0:_e.length)>=10||U[k.id]))try{const Be=`region=${n}&createdAt=${encodeURIComponent(k.created_at)}`,Oe=await fetch(`/api/lolstats/match/${encodeURIComponent(k.id)}?${Be}`);if(Oe.ok){const je=await Oe.json();I(Bt=>({...Bt,[k.id]:je}))}}catch{}},[E,U,n]),he=ie.useCallback(k=>{t(`${k.game_name}#${k.tag_line}`),r(k.region),Gt(k.game_name,k.tag_line,k.region)},[Gt]),en=ie.useCallback(k=>{var Be,Oe,je;if(!l)return((Be=k.participants)==null?void 0:Be[0])??null;const _e=l.game_name.toLowerCase();return((Oe=k.participants)==null?void 0:Oe.find(Bt=>{var yt,Xt;return((Xt=(yt=Bt.summoner)==null?void 0:yt.game_name)==null?void 0:Xt.toLowerCase())===_e}))??((je=k.participants)==null?void 0:je[0])??null},[l]),wt=k=>{var ln,mt,Wt;const _e=en(k);if(!_e)return null;const Be=((ln=_e.stats)==null?void 0:ln.result)==="WIN",Oe=x7(_e.stats.kill,_e.stats.death,_e.stats.assist),je=(_e.stats.minion_kill??0)+(_e.stats.neutral_minion_kill??0),Bt=k.game_length_second>0?(je/(k.game_length_second/60)).toFixed(1):"0",yt=E===k.id,Xt=U[k.id]??(((mt=k.participants)==null?void 0:mt.length)>=10?k:null);return P.jsxs("div",{children:[P.jsxs("div",{className:`lol-match ${Be?"win":"loss"}`,onClick:()=>dt(k),children:[P.jsx("div",{className:"lol-match-result",children:Be?"W":"L"}),P.jsxs("div",{className:"lol-match-champ",children:[P.jsx("img",{src:ym(_e.champion_name),alt:_e.champion_name,title:_e.champion_name}),P.jsx("span",{className:"lol-match-champ-level",children:_e.stats.champion_level})]}),P.jsxs("div",{className:"lol-match-kda",children:[P.jsxs("div",{className:"lol-match-kda-nums",children:[_e.stats.kill,"/",_e.stats.death,"/",_e.stats.assist]}),P.jsxs("div",{className:`lol-match-kda-ratio ${Oe==="Perfect"?"perfect":Number(Oe)>=4?"great":""}`,children:[Oe," KDA"]})]}),P.jsxs("div",{className:"lol-match-stats",children:[P.jsxs("span",{children:[je," CS (",Bt,"/m)"]}),P.jsxs("span",{children:[_e.stats.ward_place," wards"]})]}),P.jsx("div",{className:"lol-match-items",children:(_e.items_names??[]).slice(0,7).map((Yt,$t)=>Yt?P.jsx("img",{src:ym("Aatrox"),alt:Yt,title:Yt,style:{background:"var(--bg-deep)"},onError:It=>{It.target.style.display="none"}},$t):P.jsx("div",{className:"lol-match-item-empty"},$t))}),P.jsxs("div",{className:"lol-match-meta",children:[P.jsx("div",{className:"lol-match-duration",children:$Ae(k.game_length_second)}),P.jsx("div",{className:"lol-match-queue",children:HAe[k.game_type]??k.game_type}),P.jsxs("div",{className:"lol-match-ago",children:[y7(k.created_at)," ago"]})]})]}),yt&&Xt&&P.jsx("div",{className:"lol-match-detail",children:qt(Xt,(Wt=_e.summoner)==null?void 0:Wt.game_name)})]},k.id)},qt=(k,_e)=>{var yt,Xt,ln,mt,Wt;const Be=((yt=k.participants)==null?void 0:yt.filter(Yt=>Yt.team_key==="BLUE"))??[],Oe=((Xt=k.participants)==null?void 0:Xt.filter(Yt=>Yt.team_key==="RED"))??[],je=(Wt=(mt=(ln=k.teams)==null?void 0:ln.find(Yt=>Yt.key==="BLUE"))==null?void 0:mt.game_stat)==null?void 0:Wt.is_win,Bt=(Yt,$t,It)=>P.jsxs("div",{className:"lol-match-detail-team",children:[P.jsxs("div",{className:`lol-match-detail-team-header ${$t?"win":"loss"}`,children:[It," — ",$t?"Victory":"Defeat"]}),Yt.map((Te,nt)=>{var xt,Ze,lt,bt,Kt,un,Ye,St,ye,pt,Zt,Pe;const At=((Ze=(xt=Te.summoner)==null?void 0:xt.game_name)==null?void 0:Ze.toLowerCase())===(_e==null?void 0:_e.toLowerCase()),ce=(((lt=Te.stats)==null?void 0:lt.minion_kill)??0)+(((bt=Te.stats)==null?void 0:bt.neutral_minion_kill)??0);return P.jsxs("div",{className:`lol-detail-row ${At?"me":""}`,children:[P.jsx("img",{className:"lol-detail-champ",src:ym(Te.champion_name),alt:Te.champion_name}),P.jsx("span",{className:"lol-detail-name",title:`${(Kt=Te.summoner)==null?void 0:Kt.game_name}#${(un=Te.summoner)==null?void 0:un.tagline}`,children:((Ye=Te.summoner)==null?void 0:Ye.game_name)??Te.champion_name}),P.jsxs("span",{className:"lol-detail-kda",children:[(St=Te.stats)==null?void 0:St.kill,"/",(ye=Te.stats)==null?void 0:ye.death,"/",(pt=Te.stats)==null?void 0:pt.assist]}),P.jsxs("span",{className:"lol-detail-cs",children:[ce," CS"]}),P.jsxs("span",{className:"lol-detail-dmg",children:[((((Zt=Te.stats)==null?void 0:Zt.total_damage_dealt_to_champions)??0)/1e3).toFixed(1),"k"]}),P.jsxs("span",{className:"lol-detail-gold",children:[((((Pe=Te.stats)==null?void 0:Pe.gold_earned)??0)/1e3).toFixed(1),"k"]})]},nt)})]});return P.jsxs(P.Fragment,{children:[Bt(Be,je,"Blue Team"),Bt(Oe,je===void 0?void 0:!je,"Red Team")]})};return P.jsxs("div",{className:"lol-container",children:[P.jsxs("div",{className:"lol-search",children:[P.jsx("input",{ref:et,className:"lol-search-input",placeholder:"Summoner Name#Tag",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>k.key==="Enter"&&Gt()}),P.jsx("select",{className:"lol-search-region",value:n,onChange:k=>r(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("button",{className:"lol-search-btn",onClick:()=>Gt(),disabled:v,children:v?"...":"Search"})]}),N.length>0&&P.jsx("div",{className:"lol-recent",children:N.map((k,_e)=>P.jsxs("button",{className:"lol-recent-chip",onClick:()=>he(k),children:[k.profile_image_url&&P.jsx("img",{src:k.profile_image_url,alt:""}),k.game_name,"#",k.tag_line,k.tier&&P.jsx("span",{className:"lol-recent-tier",style:{color:_7[k.tier]},children:k.tier})]},_e))}),S&&P.jsx("div",{className:"lol-error",children:S}),v&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Profil..."]}),l&&!v&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-profile",children:[P.jsx("img",{className:"lol-profile-icon",src:l.profile_image_url,alt:""}),P.jsxs("div",{className:"lol-profile-info",children:[P.jsxs("h2",{children:[l.game_name,P.jsxs("span",{children:["#",l.tagline]})]}),P.jsxs("div",{className:"lol-profile-level",children:["Level ",l.level]}),((Lt=l.ladder_rank)==null?void 0:Lt.rank)&&P.jsxs("div",{className:"lol-profile-ladder",children:["Ladder Rank #",l.ladder_rank.rank.toLocaleString()," / ",(hn=l.ladder_rank.total)==null?void 0:hn.toLocaleString()]}),q&&P.jsxs("div",{className:"lol-profile-updated",children:["Updated ",y7(q)," ago"]})]}),P.jsxs("button",{className:`lol-update-btn ${G?"renewing":""}`,onClick:Tt,disabled:G,title:"Refresh data from Riot servers",children:[P.jsx("span",{className:"lol-update-icon",children:G?"⟳":"↻"}),G?"Updating...":"Update"]})]}),P.jsx("div",{className:"lol-ranked-row",children:(l.league_stats??[]).filter(k=>k.game_type==="SOLORANKED"||k.game_type==="FLEXRANKED").map(k=>{const _e=k.tier_info,Be=!!(_e!=null&&_e.tier),Oe=_7[(_e==null?void 0:_e.tier)??""]??"var(--text-normal)";return P.jsxs("div",{className:`lol-ranked-card ${Be?"has-rank":""}`,style:{"--tier-color":Oe},children:[P.jsx("div",{className:"lol-ranked-type",children:k.game_type==="SOLORANKED"?"Ranked Solo/Duo":"Ranked Flex"}),Be?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-ranked-tier",style:{color:Oe},children:[XAe(_e.tier,_e.division),P.jsxs("span",{className:"lol-ranked-lp",children:[_e.lp," LP"]})]}),P.jsxs("div",{className:"lol-ranked-record",children:[k.win,"W ",k.lose,"L",P.jsxs("span",{className:"lol-ranked-wr",children:["(",b7(k.win??0,k.lose??0),"%)"]}),k.is_hot_streak&&P.jsx("span",{className:"lol-ranked-streak",children:"🔥"})]})]}):P.jsx("div",{className:"lol-ranked-tier",children:"Unranked"})]},k.game_type)})}),((fe=(ut=l.most_champions)==null?void 0:ut.champion_stats)==null?void 0:fe.length)>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Top Champions"}),P.jsx("div",{className:"lol-champs",children:l.most_champions.champion_stats.slice(0,7).map(k=>{const _e=b7(k.win,k.lose),Be=k.play>0?x7(k.kill/k.play,k.death/k.play,k.assist/k.play):"0";return P.jsxs("div",{className:"lol-champ-card",children:[P.jsx("img",{className:"lol-champ-icon",src:ym(k.champion_name),alt:k.champion_name}),P.jsxs("div",{children:[P.jsx("div",{className:"lol-champ-name",children:k.champion_name}),P.jsxs("div",{className:"lol-champ-stats",children:[k.play," games · ",_e,"% WR"]}),P.jsxs("div",{className:"lol-champ-kda",children:[Be," KDA"]})]})]},k.champion_name)})})]}),h.length>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Match History"}),P.jsx("div",{className:"lol-matches",children:h.map(k=>wt(k))}),h.length<20&&P.jsx("button",{className:"lol-load-more",onClick:Ge,disabled:j,children:j?"Laden...":"Mehr laden"})]})]}),!l&&!v&&!S&&P.jsxs("div",{className:"lol-empty",children:[P.jsx("div",{className:"lol-empty-icon",children:"⚔️"}),P.jsx("h3",{children:"League of Legends Stats"}),P.jsx("p",{children:"Gib einen Summoner Name#Tag ein und wähle die Region"})]}),P.jsxs("div",{className:"lol-tier-section",children:[P.jsx("div",{className:"lol-section-title",children:"Champion Tier List"}),P.jsxs("div",{className:"lol-tier-controls",children:[P.jsx("div",{className:"lol-tier-modes",children:se.map(k=>P.jsx("button",{className:`lol-tier-mode-btn ${Y===k.key?"active":""}`,onClick:()=>te(k.key),children:k.label},k.key))}),P.jsx("select",{className:"lol-search-region",value:ne,onChange:k=>le(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("input",{className:"lol-tier-filter",placeholder:"Filter champion...",value:qe,onChange:k=>Ce(k.target.value)})]}),ae&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Tier List..."]}),be&&P.jsx("div",{className:"lol-error",children:be}),!ae&&!be&&Q.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-tier-table",children:[P.jsxs("div",{className:"lol-tier-header",children:[P.jsx("span",{className:"lol-tier-col-rank",children:"#"}),P.jsx("span",{className:"lol-tier-col-champ",children:"Champion"}),P.jsx("span",{className:"lol-tier-col-tier",children:"Tier"}),P.jsx("span",{className:"lol-tier-col-wr",children:Y==="arena"?"Win":"Win %"}),P.jsx("span",{className:"lol-tier-col-pr",children:"Pick %"}),Y!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:"Ban %"}),P.jsx("span",{className:"lol-tier-col-kda",children:Y==="arena"?"Avg Place":"KDA"})]}),Q.filter(k=>!qe||k.champion_name.toLowerCase().includes(qe.toLowerCase())).slice(0,ke?void 0:50).map(k=>{var Be,Oe;const _e=["OP","1","2","3","4","5"];return P.jsxs("div",{className:`lol-tier-row tier-${k.tier}`,children:[P.jsx("span",{className:"lol-tier-col-rank",children:k.rank}),P.jsxs("span",{className:"lol-tier-col-champ",children:[P.jsx("img",{src:ym(k.champion_name),alt:k.champion_name}),k.champion_name]}),P.jsx("span",{className:`lol-tier-col-tier tier-badge-${k.tier}`,children:_e[k.tier]??k.tier}),P.jsx("span",{className:"lol-tier-col-wr",children:k.win_rate!=null?`${(k.win_rate*100).toFixed(1)}%`:"-"}),P.jsxs("span",{className:"lol-tier-col-pr",children:[(k.pick_rate*100).toFixed(1),"%"]}),Y!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:k.ban_rate!=null?`${(k.ban_rate*100).toFixed(1)}%`:"-"}),P.jsx("span",{className:"lol-tier-col-kda",children:Y==="arena"?((Be=k.average_placement)==null?void 0:Be.toFixed(1))??"-":((Oe=k.kda)==null?void 0:Oe.toFixed(2))??"-"})]},k.champion_id)})]}),!ke&&Q.length>50&&P.jsxs("button",{className:"lol-load-more",onClick:()=>Qe(!0),children:["Alle ",Q.length," Champions anzeigen"]})]})]})]})}const S7={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function qS(i){const e=Math.max(0,Math.floor((Date.now()-new Date(i).getTime())/1e3)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}const VS=[{label:"Niedrig · 4 Mbit · 60fps",fps:60,bitrate:4e6},{label:"Mittel · 8 Mbit · 60fps",fps:60,bitrate:8e6},{label:"Hoch · 14 Mbit · 60fps",fps:60,bitrate:14e6},{label:"Ultra · 25 Mbit · 60fps",fps:60,bitrate:25e6},{label:"Max · 50 Mbit · 165fps",fps:165,bitrate:5e7}];function QAe({data:i,isAdmin:e}){var Ye,St;const[t,n]=ie.useState([]),[r,s]=ie.useState(()=>localStorage.getItem("streaming_name")||""),[a,l]=ie.useState("Screen Share"),[u,h]=ie.useState(""),[m,v]=ie.useState(1),[x,S]=ie.useState(null),[w,N]=ie.useState(null),[C,E]=ie.useState(null),[O,U]=ie.useState(!1),[I,j]=ie.useState(!1),[z,G]=ie.useState(null),[,W]=ie.useState(0),[q,V]=ie.useState(null),[Y,te]=ie.useState(null),[ne,le]=ie.useState(!1),Q=e??!1,[K,ae]=ie.useState([]),[Ae,be]=ie.useState([]),[Se,se]=ie.useState(!1),[Ee,qe]=ie.useState(!1),[Ce,ke]=ie.useState({online:!1,botTag:null}),Qe=ie.useRef(null),et=ie.useRef(""),Pt=ie.useRef(null),Nt=ie.useRef(null),Gt=ie.useRef(null),Tt=ie.useRef(new Map),Ge=ie.useRef(null),dt=ie.useRef(null),he=ie.useRef(new Map),en=ie.useRef(null),wt=ie.useRef(1e3),qt=ie.useRef(!1),Lt=ie.useRef(null),hn=ie.useRef(VS[1]);ie.useEffect(()=>{qt.current=O},[O]),ie.useEffect(()=>{Lt.current=z},[z]),ie.useEffect(()=>{hn.current=VS[m]},[m]),ie.useEffect(()=>{var ye,pt;(pt=(ye=window.electronAPI)==null?void 0:ye.setStreaming)==null||pt.call(ye,O||z!==null)},[O,z]),ie.useEffect(()=>{if(!(t.length>0||O))return;const pt=setInterval(()=>W(Zt=>Zt+1),1e3);return()=>clearInterval(pt)},[t.length,O]),ie.useEffect(()=>{i!=null&&i.streams&&n(i.streams)},[i]),ie.useEffect(()=>{r&&localStorage.setItem("streaming_name",r)},[r]),ie.useEffect(()=>{if(!q)return;const ye=()=>V(null);return document.addEventListener("click",ye),()=>document.removeEventListener("click",ye)},[q]),ie.useEffect(()=>{fetch("/api/notifications/status").then(ye=>ye.json()).then(ye=>ke(ye)).catch(()=>{})},[]);const ut=ie.useCallback(ye=>{var pt;((pt=Qe.current)==null?void 0:pt.readyState)===WebSocket.OPEN&&Qe.current.send(JSON.stringify(ye))},[]),fe=ie.useCallback((ye,pt,Zt)=>{if(ye.remoteDescription)ye.addIceCandidate(new RTCIceCandidate(Zt)).catch(()=>{});else{let Pe=he.current.get(pt);Pe||(Pe=[],he.current.set(pt,Pe)),Pe.push(Zt)}},[]),k=ie.useCallback((ye,pt)=>{const Zt=he.current.get(pt);if(Zt){for(const Pe of Zt)ye.addIceCandidate(new RTCIceCandidate(Pe)).catch(()=>{});he.current.delete(pt)}},[]),_e=ie.useCallback((ye,pt)=>{ye.srcObject=pt;const Zt=ye.play();Zt&&Zt.catch(()=>{ye.muted=!0,ye.play().catch(()=>{})})},[]),Be=ie.useCallback(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),Ge.current&&(Ge.current.close(),Ge.current=null),dt.current=null,Gt.current&&(Gt.current.srcObject=null)},[]),Oe=ie.useRef(()=>{});Oe.current=ye=>{var pt,Zt,Pe;switch(ye.type){case"welcome":et.current=ye.clientId,ye.streams&&n(ye.streams);break;case"broadcast_started":E(ye.streamId),U(!0),qt.current=!0,j(!1),(pt=window.electronAPI)!=null&&pt.showNotification&&window.electronAPI.showNotification("Stream gestartet","Dein Stream ist jetzt live!");break;case"stream_available":n(ht=>ht.some(ot=>ot.id===ye.streamId)?ht:[...ht,{id:ye.streamId,broadcasterName:ye.broadcasterName,title:ye.title,startedAt:new Date().toISOString(),viewerCount:0,hasPassword:!!ye.hasPassword}]);const at=`${ye.broadcasterName} streamt: ${ye.title}`;(Zt=window.electronAPI)!=null&&Zt.showNotification?window.electronAPI.showNotification("Neuer Stream",at):Notification.permission==="granted"&&new Notification("Neuer Stream",{body:at,icon:"/assets/icon.png"});break;case"stream_ended":n(ht=>ht.filter(ot=>ot.id!==ye.streamId)),((Pe=Lt.current)==null?void 0:Pe.streamId)===ye.streamId&&(Be(),G(null));break;case"viewer_joined":{const ht=ye.viewerId,ot=Tt.current.get(ht);ot&&(ot.close(),Tt.current.delete(ht)),he.current.delete(ht);const f=new RTCPeerConnection(S7);Tt.current.set(ht,f);const J=Pt.current;if(J)for(const fn of J.getTracks())f.addTrack(fn,J);f.onicecandidate=fn=>{fn.candidate&&ut({type:"ice_candidate",targetId:ht,candidate:fn.candidate.toJSON()})};const _n=f.getSenders().find(fn=>{var zn;return((zn=fn.track)==null?void 0:zn.kind)==="video"});if(_n){const fn=_n.getParameters();(!fn.encodings||fn.encodings.length===0)&&(fn.encodings=[{}]),fn.encodings[0].maxFramerate=hn.current.fps,fn.encodings[0].maxBitrate=hn.current.bitrate,_n.setParameters(fn).catch(()=>{})}f.createOffer().then(fn=>f.setLocalDescription(fn)).then(()=>ut({type:"offer",targetId:ht,sdp:f.localDescription})).catch(console.error);break}case"viewer_left":{const ht=Tt.current.get(ye.viewerId);ht&&(ht.close(),Tt.current.delete(ye.viewerId)),he.current.delete(ye.viewerId);break}case"offer":{const ht=ye.fromId;Ge.current&&(Ge.current.close(),Ge.current=null),he.current.delete(ht);const ot=new RTCPeerConnection(S7);Ge.current=ot,ot.ontrack=f=>{const J=f.streams[0];if(!J)return;dt.current=J;const _n=Gt.current;_n&&_e(_n,J),G(fn=>fn&&{...fn,phase:"connected"})},ot.onicecandidate=f=>{f.candidate&&ut({type:"ice_candidate",targetId:ht,candidate:f.candidate.toJSON()})},ot.oniceconnectionstatechange=()=>{(ot.iceConnectionState==="failed"||ot.iceConnectionState==="disconnected")&&G(f=>f&&{...f,phase:"error",error:"Verbindung verloren"})},ot.setRemoteDescription(new RTCSessionDescription(ye.sdp)).then(()=>(k(ot,ht),ot.createAnswer())).then(f=>ot.setLocalDescription(f)).then(()=>ut({type:"answer",targetId:ht,sdp:ot.localDescription})).catch(console.error);break}case"answer":{const ht=Tt.current.get(ye.fromId);ht&&ht.setRemoteDescription(new RTCSessionDescription(ye.sdp)).then(()=>k(ht,ye.fromId)).catch(console.error);break}case"ice_candidate":{if(!ye.candidate)break;const ht=Tt.current.get(ye.fromId);ht?fe(ht,ye.fromId,ye.candidate):Ge.current&&fe(Ge.current,ye.fromId,ye.candidate);break}case"error":ye.code==="WRONG_PASSWORD"?N(ht=>ht&&{...ht,error:ye.message}):S(ye.message),j(!1);break}};const je=ie.useCallback(()=>{if(Qe.current&&Qe.current.readyState===WebSocket.OPEN)return;const ye=location.protocol==="https:"?"wss":"ws",pt=new WebSocket(`${ye}://${location.host}/ws/streaming`);Qe.current=pt,pt.onopen=()=>{wt.current=1e3},pt.onmessage=Zt=>{let Pe;try{Pe=JSON.parse(Zt.data)}catch{return}Oe.current(Pe)},pt.onclose=()=>{Qe.current=null,en.current=setTimeout(()=>{wt.current=Math.min(wt.current*2,1e4),je()},wt.current)},pt.onerror=()=>{pt.close()}},[]);ie.useEffect(()=>(je(),()=>{en.current&&clearTimeout(en.current)}),[je]);const Bt=ie.useCallback(async()=>{var ye,pt;if(!r.trim()){S("Bitte gib einen Namen ein.");return}if(!((ye=navigator.mediaDevices)!=null&&ye.getDisplayMedia)){S("Dein Browser unterstützt keine Bildschirmfreigabe.");return}S(null),j(!0);try{const Zt=hn.current,Pe=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:Zt.fps}},audio:!0});Pt.current=Pe,Nt.current&&(Nt.current.srcObject=Pe),(pt=Pe.getVideoTracks()[0])==null||pt.addEventListener("ended",()=>{yt()}),je();const at=()=>{var ht;((ht=Qe.current)==null?void 0:ht.readyState)===WebSocket.OPEN?ut({type:"start_broadcast",name:r.trim(),title:a.trim()||"Screen Share",password:u.trim()||void 0}):setTimeout(at,100)};at()}catch(Zt){j(!1),Zt.name==="NotAllowedError"?S("Bildschirmfreigabe wurde abgelehnt."):S(`Fehler: ${Zt.message}`)}},[r,a,u,je,ut]),yt=ie.useCallback(()=>{var ye;ut({type:"stop_broadcast"}),(ye=Pt.current)==null||ye.getTracks().forEach(pt=>pt.stop()),Pt.current=null,Nt.current&&(Nt.current.srcObject=null);for(const pt of Tt.current.values())pt.close();Tt.current.clear(),U(!1),qt.current=!1,E(null),h("")},[ut]),Xt=ie.useCallback(ye=>{S(null),G({streamId:ye,phase:"connecting"}),je();const pt=()=>{var Zt;((Zt=Qe.current)==null?void 0:Zt.readyState)===WebSocket.OPEN?ut({type:"join_viewer",name:r.trim()||"Viewer",streamId:ye}):setTimeout(pt,100)};pt()},[r,je,ut]),ln=ie.useCallback(ye=>{ye.hasPassword?N({streamId:ye.id,streamTitle:ye.title,broadcasterName:ye.broadcasterName,password:"",error:null}):Xt(ye.id)},[Xt]),mt=ie.useCallback(()=>{if(!w)return;if(!w.password.trim()){N(Pe=>Pe&&{...Pe,error:"Passwort eingeben."});return}const{streamId:ye,password:pt}=w;N(null),S(null),G({streamId:ye,phase:"connecting"}),je();const Zt=()=>{var Pe;((Pe=Qe.current)==null?void 0:Pe.readyState)===WebSocket.OPEN?ut({type:"join_viewer",name:r.trim()||"Viewer",streamId:ye,password:pt.trim()}):setTimeout(Zt,100)};Zt()},[w,r,je,ut]),Wt=ie.useCallback(()=>{ut({type:"leave_viewer"}),Be(),G(null)},[Be,ut]);ie.useEffect(()=>{const ye=Zt=>{(qt.current||Lt.current)&&Zt.preventDefault()},pt=()=>{et.current&&navigator.sendBeacon("/api/streaming/disconnect",JSON.stringify({clientId:et.current}))};return window.addEventListener("beforeunload",ye),window.addEventListener("pagehide",pt),()=>{window.removeEventListener("beforeunload",ye),window.removeEventListener("pagehide",pt)}},[]);const Yt=ie.useRef(null),[$t,It]=ie.useState(!1),Te=ie.useCallback(()=>{const ye=Yt.current;ye&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):ye.requestFullscreen().catch(()=>{}))},[]);ie.useEffect(()=>{const ye=()=>It(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",ye),()=>document.removeEventListener("fullscreenchange",ye)},[]),ie.useEffect(()=>()=>{var ye;(ye=Pt.current)==null||ye.getTracks().forEach(pt=>pt.stop());for(const pt of Tt.current.values())pt.close();Ge.current&&Ge.current.close(),Qe.current&&Qe.current.close(),en.current&&clearTimeout(en.current)},[]),ie.useEffect(()=>{z&&dt.current&&Gt.current&&!Gt.current.srcObject&&_e(Gt.current,dt.current)},[z,_e]);const nt=ie.useRef(null);ie.useEffect(()=>{const pt=new URLSearchParams(location.search).get("viewStream");if(pt){nt.current=pt;const Zt=new URL(location.href);Zt.searchParams.delete("viewStream"),window.history.replaceState({},"",Zt.toString())}},[]),ie.useEffect(()=>{const ye=nt.current;if(!ye||t.length===0)return;const pt=t.find(Zt=>Zt.id===ye);pt&&(nt.current=null,ln(pt))},[t,ln]);const At=ie.useCallback(ye=>{const pt=new URL(location.href);return pt.searchParams.set("viewStream",ye),pt.hash="",pt.toString()},[]),ce=ie.useCallback(ye=>{navigator.clipboard.writeText(At(ye)).then(()=>{te(ye),setTimeout(()=>te(null),2e3)}).catch(()=>{})},[At]),xt=ie.useCallback(ye=>{window.open(At(ye),"_blank","noopener"),V(null)},[At]),Ze=ie.useCallback(async()=>{se(!0);try{const[ye,pt]=await Promise.all([fetch("/api/notifications/channels",{credentials:"include"}),fetch("/api/notifications/config",{credentials:"include"})]);if(ye.ok){const Zt=await ye.json();ae(Zt.channels||[])}if(pt.ok){const Zt=await pt.json();be(Zt.channels||[])}}catch{}finally{se(!1)}},[]),lt=ie.useCallback(()=>{le(!0),Q&&Ze()},[Q,Ze]),bt=ie.useCallback((ye,pt,Zt,Pe,at)=>{be(ht=>{const ot=ht.find(f=>f.channelId===ye);if(ot){const J=ot.events.includes(at)?ot.events.filter(_n=>_n!==at):[...ot.events,at];return J.length===0?ht.filter(_n=>_n.channelId!==ye):ht.map(_n=>_n.channelId===ye?{..._n,events:J}:_n)}else return[...ht,{channelId:ye,channelName:pt,guildId:Zt,guildName:Pe,events:[at]}]})},[]),Kt=ie.useCallback(async()=>{qe(!0);try{(await fetch("/api/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channels:Ae}),credentials:"include"})).ok}catch{}finally{qe(!1)}},[Ae]),un=ie.useCallback((ye,pt)=>{const Zt=Ae.find(Pe=>Pe.channelId===ye);return(Zt==null?void 0:Zt.events.includes(pt))??!1},[Ae]);if(z){const ye=t.find(pt=>pt.id===z.streamId);return P.jsxs("div",{className:"stream-viewer-overlay",ref:Yt,children:[P.jsxs("div",{className:"stream-viewer-header",children:[P.jsxs("div",{className:"stream-viewer-header-left",children:[P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("div",{children:[P.jsx("div",{className:"stream-viewer-title",children:(ye==null?void 0:ye.title)||"Stream"}),P.jsxs("div",{className:"stream-viewer-subtitle",children:[(ye==null?void 0:ye.broadcasterName)||"..."," ",ye?` · ${ye.viewerCount} Zuschauer`:""]})]})]}),P.jsxs("div",{className:"stream-viewer-header-right",children:[P.jsx("button",{className:"stream-viewer-fullscreen",onClick:Te,title:$t?"Vollbild verlassen":"Vollbild",children:$t?"✖":"⛶"}),P.jsx("button",{className:"stream-viewer-close",onClick:Wt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"stream-viewer-video",children:[z.phase==="connecting"?P.jsxs("div",{className:"stream-viewer-connecting",children:[P.jsx("div",{className:"stream-viewer-spinner"}),"Verbindung wird hergestellt..."]}):z.phase==="error"?P.jsxs("div",{className:"stream-viewer-connecting",children:[z.error||"Verbindungsfehler",P.jsx("button",{className:"stream-btn",onClick:Wt,children:"Zurück"})]}):null,P.jsx("video",{ref:Gt,autoPlay:!0,playsInline:!0,style:z.phase==="connected"?{}:{display:"none"}})]})]})}return P.jsxs("div",{className:"stream-container",children:[x&&P.jsxs("div",{className:"stream-error",children:[x,P.jsx("button",{className:"stream-error-dismiss",onClick:()=>S(null),children:"×"})]}),P.jsxs("div",{className:"stream-topbar",children:[P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Name"}),P.jsx("input",{className:"stream-input stream-input-name",placeholder:"Dein Name",value:r,onChange:ye=>s(ye.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field stream-field-grow",children:[P.jsx("span",{className:"stream-field-label",children:"Titel"}),P.jsx("input",{className:"stream-input stream-input-title",placeholder:"Stream-Titel",value:a,onChange:ye=>l(ye.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Passwort"}),P.jsx("input",{className:"stream-input stream-input-password",type:"password",placeholder:"optional",value:u,onChange:ye=>h(ye.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsxs("span",{className:"stream-field-label",children:["Qualit","ä","t"]}),P.jsx("select",{className:"stream-select-quality",value:m,onChange:ye=>v(Number(ye.target.value)),disabled:O,children:VS.map((ye,pt)=>P.jsx("option",{value:pt,children:ye.label},ye.label))})]}),O?P.jsxs("button",{className:"stream-btn stream-btn-stop",onClick:yt,children:["⏹"," Stream beenden"]}):P.jsx("button",{className:"stream-btn",onClick:Bt,disabled:I,children:I?"Starte...":"🖥️ Stream starten"}),Q&&P.jsx("button",{className:"stream-admin-btn",onClick:lt,title:"Notification Einstellungen",children:"⚙️"})]}),t.length===0&&!O?P.jsxs("div",{className:"stream-empty",children:[P.jsx("div",{className:"stream-empty-icon",children:"📺"}),P.jsx("h3",{children:"Keine aktiven Streams"}),P.jsx("p",{children:"Starte einen Stream, um deinen Bildschirm zu teilen."})]}):P.jsxs("div",{className:"stream-grid",children:[O&&P.jsxs("div",{className:"stream-tile own broadcasting",children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("video",{ref:Nt,autoPlay:!0,playsInline:!0,muted:!0}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",((Ye=t.find(ye=>ye.id===C))==null?void 0:Ye.viewerCount)??0]})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsxs("div",{className:"stream-tile-name",children:[r," (Du)"]}),P.jsx("div",{className:"stream-tile-title",children:a})]}),P.jsx("span",{className:"stream-tile-time",children:C&&((St=t.find(ye=>ye.id===C))!=null&&St.startedAt)?qS(t.find(ye=>ye.id===C).startedAt):"0:00"})]})]}),t.filter(ye=>ye.id!==C).map(ye=>P.jsxs("div",{className:"stream-tile",onClick:()=>ln(ye),children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("span",{className:"stream-tile-icon",children:"🖥️"}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",ye.viewerCount]}),ye.hasPassword&&P.jsx("span",{className:"stream-tile-lock",children:"🔒"})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsx("div",{className:"stream-tile-name",children:ye.broadcasterName}),P.jsx("div",{className:"stream-tile-title",children:ye.title})]}),P.jsx("span",{className:"stream-tile-time",children:qS(ye.startedAt)}),P.jsxs("div",{className:"stream-tile-menu-wrap",children:[P.jsx("button",{className:"stream-tile-menu",onClick:pt=>{pt.stopPropagation(),V(q===ye.id?null:ye.id)},children:"⋮"}),q===ye.id&&P.jsxs("div",{className:"stream-tile-dropdown",onClick:pt=>pt.stopPropagation(),children:[P.jsxs("div",{className:"stream-tile-dropdown-header",children:[P.jsx("div",{className:"stream-tile-dropdown-name",children:ye.broadcasterName}),P.jsx("div",{className:"stream-tile-dropdown-title",children:ye.title}),P.jsxs("div",{className:"stream-tile-dropdown-detail",children:["👥"," ",ye.viewerCount," Zuschauer · ",qS(ye.startedAt)]})]}),P.jsx("div",{className:"stream-tile-dropdown-divider"}),P.jsxs("button",{className:"stream-tile-dropdown-item",onClick:()=>xt(ye.id),children:["🗗"," In neuem Fenster öffnen"]}),P.jsx("button",{className:"stream-tile-dropdown-item",onClick:()=>{ce(ye.id),V(null)},children:Y===ye.id?"✅ Kopiert!":"🔗 Link teilen"})]})]})]})]},ye.id))]}),w&&P.jsx("div",{className:"stream-pw-overlay",onClick:()=>N(null),children:P.jsxs("div",{className:"stream-pw-modal",onClick:ye=>ye.stopPropagation(),children:[P.jsx("h3",{children:w.broadcasterName}),P.jsx("p",{children:w.streamTitle}),w.error&&P.jsx("div",{className:"stream-pw-modal-error",children:w.error}),P.jsx("input",{className:"stream-input",type:"password",placeholder:"Stream-Passwort",value:w.password,onChange:ye=>N(pt=>pt&&{...pt,password:ye.target.value,error:null}),onKeyDown:ye=>{ye.key==="Enter"&&mt()},autoFocus:!0}),P.jsxs("div",{className:"stream-pw-actions",children:[P.jsx("button",{className:"stream-pw-cancel",onClick:()=>N(null),children:"Abbrechen"}),P.jsx("button",{className:"stream-btn",onClick:mt,children:"Beitreten"})]})]})}),ne&&P.jsx("div",{className:"stream-admin-overlay",onClick:()=>le(!1),children:P.jsxs("div",{className:"stream-admin-panel",onClick:ye=>ye.stopPropagation(),children:[P.jsxs("div",{className:"stream-admin-header",children:[P.jsxs("h3",{children:["🔔"," Benachrichtigungen"]}),P.jsx("button",{className:"stream-admin-close",onClick:()=>le(!1),children:"✕"})]}),P.jsxs("div",{className:"stream-admin-content",children:[P.jsx("div",{className:"stream-admin-toolbar",children:P.jsx("span",{className:"stream-admin-status",children:Ce.online?P.jsxs(P.Fragment,{children:["✅"," Bot online: ",P.jsx("b",{children:Ce.botTag})]}):P.jsxs(P.Fragment,{children:["⚠️"," Bot offline — ",P.jsx("code",{children:"DISCORD_TOKEN_NOTIFICATIONS"})," setzen"]})})}),Se?P.jsxs("div",{className:"stream-admin-loading",children:["Lade Kan","ä","le..."]}):K.length===0?P.jsx("div",{className:"stream-admin-empty",children:Ce.online?"Keine Text-Kanäle gefunden. Bot hat möglicherweise keinen Zugriff.":"Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren."}):P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"stream-admin-hint",children:["W","ä","hle die Kan","ä","le, in die Benachrichtigungen gesendet werden sollen:"]}),P.jsx("div",{className:"stream-admin-channel-list",children:K.map(ye=>P.jsxs("div",{className:"stream-admin-channel",children:[P.jsxs("div",{className:"stream-admin-channel-info",children:[P.jsxs("span",{className:"stream-admin-channel-name",children:["#",ye.channelName]}),P.jsx("span",{className:"stream-admin-channel-guild",children:ye.guildName})]}),P.jsxs("div",{className:"stream-admin-channel-events",children:[P.jsxs("label",{className:`stream-admin-event-toggle${un(ye.channelId,"stream_start")?" active":""}`,children:[P.jsx("input",{type:"checkbox",checked:un(ye.channelId,"stream_start"),onChange:()=>bt(ye.channelId,ye.channelName,ye.guildId,ye.guildName,"stream_start")}),"🔴"," Stream Start"]}),P.jsxs("label",{className:`stream-admin-event-toggle${un(ye.channelId,"stream_end")?" active":""}`,children:[P.jsx("input",{type:"checkbox",checked:un(ye.channelId,"stream_end"),onChange:()=>bt(ye.channelId,ye.channelName,ye.guildId,ye.guildName,"stream_end")}),"⏹️"," Stream Ende"]})]})]},ye.channelId))}),P.jsx("div",{className:"stream-admin-actions",children:P.jsx("button",{className:"stream-btn stream-admin-save",onClick:Kt,disabled:Ee,children:Ee?"Speichern...":"💾 Speichern"})})]})]})]})})]})}function T7(i){const e=Math.floor(i),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function KAe(i){const e=i.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(e)return{type:"youtube",videoId:e[1]};const t=i.match(/(?:dailymotion\.com\/video\/|dai\.ly\/)([a-zA-Z0-9]+)/);return t?{type:"dailymotion",videoId:t[1]}:/\.(mp4|webm|ogg)(\?|$)/i.test(i)||i.startsWith("http")?{type:"direct",url:i}:null}function ZAe({data:i}){var un;const[e,t]=ie.useState([]),[n,r]=ie.useState(()=>localStorage.getItem("wt_name")||""),[s,a]=ie.useState(""),[l,u]=ie.useState(""),[h,m]=ie.useState(null),[v,x]=ie.useState(null),[S,w]=ie.useState(null),[N,C]=ie.useState(""),[E,O]=ie.useState(()=>{const Ye=localStorage.getItem("wt_volume");return Ye?parseFloat(Ye):1}),[U,I]=ie.useState(!1),[j,z]=ie.useState(0),[G,W]=ie.useState(0),[q,V]=ie.useState(null),[Y,te]=ie.useState(!1),[ne,le]=ie.useState([]),[Q,K]=ie.useState(""),[ae,Ae]=ie.useState(null),[be,Se]=ie.useState("synced"),[se,Ee]=ie.useState(!0),[qe,Ce]=ie.useState(()=>localStorage.getItem("wt_yt_quality")||"hd1080"),ke=ie.useRef(null),Qe=ie.useRef(""),et=ie.useRef(null),Pt=ie.useRef(1e3),Nt=ie.useRef(null),Gt=ie.useRef(null),Tt=ie.useRef(null),Ge=ie.useRef(null),dt=ie.useRef(null),he=ie.useRef(null),en=ie.useRef(!1),wt=ie.useRef(!1),qt=ie.useRef(null),Lt=ie.useRef(null),hn=ie.useRef(qe),ut=ie.useRef(null),fe=ie.useRef(!1),k=ie.useRef(0),_e=ie.useRef(0);ie.useEffect(()=>{Nt.current=h},[h]);const Be=h!=null&&Qe.current===h.hostId;ie.useEffect(()=>{hn.current=qe,localStorage.setItem("wt_yt_quality",qe),Tt.current&&typeof Tt.current.setPlaybackQuality=="function"&&Tt.current.setPlaybackQuality(qe)},[qe]),ie.useEffect(()=>{i!=null&&i.rooms&&t(i.rooms)},[i]),ie.useEffect(()=>{var Ye;(Ye=Lt.current)==null||Ye.scrollIntoView({behavior:"smooth"})},[ne]),ie.useEffect(()=>{const St=new URLSearchParams(window.location.search).get("wt");if(St&&n.trim()){const ye=setTimeout(()=>Wt(St),1500);return()=>clearTimeout(ye)}},[]),ie.useEffect(()=>{n&&localStorage.setItem("wt_name",n)},[n]),ie.useEffect(()=>{var Ye;localStorage.setItem("wt_volume",String(E)),Tt.current&&typeof Tt.current.setVolume=="function"&&Tt.current.setVolume(E*100),Ge.current&&(Ge.current.volume=E),(Ye=ut.current)!=null&&Ye.contentWindow&&he.current==="dailymotion"&&ut.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com")},[E]),ie.useEffect(()=>{if(window.YT){en.current=!0;return}const Ye=document.createElement("script");Ye.src="https://www.youtube.com/iframe_api",document.head.appendChild(Ye);const St=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{en.current=!0,St&&St()}},[]);const Oe=ie.useCallback(Ye=>{var St;((St=ke.current)==null?void 0:St.readyState)===WebSocket.OPEN&&ke.current.send(JSON.stringify(Ye))},[]),je=ie.useCallback(()=>he.current==="youtube"&&Tt.current&&typeof Tt.current.getCurrentTime=="function"?Tt.current.getCurrentTime():he.current==="direct"&&Ge.current?Ge.current.currentTime:he.current==="dailymotion"?k.current:null,[]);ie.useCallback(()=>he.current==="youtube"&&Tt.current&&typeof Tt.current.getDuration=="function"?Tt.current.getDuration()||0:he.current==="direct"&&Ge.current?Ge.current.duration||0:he.current==="dailymotion"?_e.current:0,[]);const Bt=ie.useCallback(()=>{if(Tt.current){try{Tt.current.destroy()}catch{}Tt.current=null}Ge.current&&(Ge.current.pause(),Ge.current.removeAttribute("src"),Ge.current.load()),ut.current&&(ut.current.src="",fe.current=!1,k.current=0,_e.current=0),he.current=null,qt.current&&(clearInterval(qt.current),qt.current=null)},[]),yt=ie.useCallback(Ye=>{Bt(),V(null);const St=KAe(Ye);if(St)if(St.type==="youtube"){if(he.current="youtube",!en.current||!dt.current)return;const ye=dt.current,pt=document.createElement("div");pt.id="wt-yt-player-"+Date.now(),ye.innerHTML="",ye.appendChild(pt),Tt.current=new window.YT.Player(pt.id,{videoId:St.videoId,playerVars:{autoplay:1,controls:0,modestbranding:1,rel:0},events:{onReady:Zt=>{Zt.target.setVolume(E*100),Zt.target.setPlaybackQuality(hn.current),z(Zt.target.getDuration()||0),qt.current=setInterval(()=>{Tt.current&&typeof Tt.current.getCurrentTime=="function"&&(W(Tt.current.getCurrentTime()),z(Tt.current.getDuration()||0))},500)},onStateChange:Zt=>{if(Zt.data===window.YT.PlayerState.ENDED){const Pe=Nt.current;Pe&&Qe.current===Pe.hostId&&Oe({type:"skip"})}},onError:Zt=>{const Pe=Zt.data;V(Pe===101||Pe===150?"Embedding deaktiviert — Video kann nur auf YouTube angesehen werden.":Pe===100?"Video nicht gefunden oder entfernt.":"Wiedergabefehler — Video wird übersprungen."),setTimeout(()=>{const at=Nt.current;at&&Qe.current===at.hostId&&Oe({type:"skip"})},3e3)}}})}else St.type==="dailymotion"?(he.current="dailymotion",ut.current&&(ut.current.src=`https://www.dailymotion.com/embed/video/${St.videoId}?api=postMessage&autoplay=1&controls=0&mute=0&queue-enable=0`)):(he.current="direct",Ge.current&&(Ge.current.src=St.url,Ge.current.volume=E,Ge.current.play().catch(()=>{})))},[Bt,E,Oe]);ie.useEffect(()=>{const Ye=Ge.current;if(!Ye)return;const St=()=>{const pt=Nt.current;pt&&Qe.current===pt.hostId&&Oe({type:"skip"})},ye=()=>{W(Ye.currentTime),z(Ye.duration||0)};return Ye.addEventListener("ended",St),Ye.addEventListener("timeupdate",ye),()=>{Ye.removeEventListener("ended",St),Ye.removeEventListener("timeupdate",ye)}},[Oe]),ie.useEffect(()=>{const Ye=St=>{var Pe;if(St.origin!=="https://www.dailymotion.com"||typeof St.data!="string")return;const ye=new URLSearchParams(St.data),pt=ye.get("method"),Zt=ye.get("value");if(pt==="timeupdate"&&Zt){const at=parseFloat(Zt);k.current=at,W(at)}else if(pt==="durationchange"&&Zt){const at=parseFloat(Zt);_e.current=at,z(at)}else if(pt==="ended"){const at=Nt.current;at&&Qe.current===at.hostId&&Oe({type:"skip"})}else pt==="apiready"&&(fe.current=!0,(Pe=ut.current)!=null&&Pe.contentWindow&&ut.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com"))};return window.addEventListener("message",Ye),()=>window.removeEventListener("message",Ye)},[Oe,E]);const Xt=ie.useRef(()=>{});Xt.current=Ye=>{var St,ye,pt,Zt,Pe,at,ht,ot,f,J,_n,fn,zn,An,yn,zr;switch(Ye.type){case"welcome":Qe.current=Ye.clientId,Ye.rooms&&t(Ye.rooms);break;case"room_created":{const on=Ye.room;m({id:on.id,name:on.name,hostId:on.hostId,members:on.members||[],currentVideo:on.currentVideo||null,playing:on.playing||!1,currentTime:on.currentTime||0,queue:on.queue||[]});break}case"room_joined":{const on=Ye.room;m({id:on.id,name:on.name,hostId:on.hostId,members:on.members||[],currentVideo:on.currentVideo||null,playing:on.playing||!1,currentTime:on.currentTime||0,queue:on.queue||[]}),(St=on.currentVideo)!=null&&St.url&&setTimeout(()=>yt(on.currentVideo.url),100);break}case"playback_state":{const on=Nt.current;if(!on)break;const xn=Ye.currentVideo,Ar=(ye=on.currentVideo)==null?void 0:ye.url;if(xn!=null&&xn.url&&xn.url!==Ar?yt(xn.url):!xn&&Ar&&Bt(),he.current==="youtube"&&Tt.current){const ji=(Zt=(pt=Tt.current).getPlayerState)==null?void 0:Zt.call(pt);Ye.playing&&ji!==((at=(Pe=window.YT)==null?void 0:Pe.PlayerState)==null?void 0:at.PLAYING)?(ot=(ht=Tt.current).playVideo)==null||ot.call(ht):!Ye.playing&&ji===((J=(f=window.YT)==null?void 0:f.PlayerState)==null?void 0:J.PLAYING)&&((fn=(_n=Tt.current).pauseVideo)==null||fn.call(_n))}else he.current==="direct"&&Ge.current?Ye.playing&&Ge.current.paused?Ge.current.play().catch(()=>{}):!Ye.playing&&!Ge.current.paused&&Ge.current.pause():he.current==="dailymotion"&&((zn=ut.current)!=null&&zn.contentWindow)&&(Ye.playing?ut.current.contentWindow.postMessage("play","https://www.dailymotion.com"):ut.current.contentWindow.postMessage("pause","https://www.dailymotion.com"));if(Ye.currentTime!==void 0&&!wt.current){const ji=je();ji!==null&&Math.abs(ji-Ye.currentTime)>2&&(he.current==="youtube"&&Tt.current?(yn=(An=Tt.current).seekTo)==null||yn.call(An,Ye.currentTime,!0):he.current==="direct"&&Ge.current?Ge.current.currentTime=Ye.currentTime:he.current==="dailymotion"&&((zr=ut.current)!=null&&zr.contentWindow)&&ut.current.contentWindow.postMessage(`seek?to=${Ye.currentTime}`,"https://www.dailymotion.com"))}if(Ye.currentTime!==void 0){const ji=je();if(ji!==null){const Ao=Math.abs(ji-Ye.currentTime);Ao<1.5?Se("synced"):Ao<5?Se("drifting"):Se("desynced")}}m(ji=>ji&&{...ji,currentVideo:xn||null,playing:Ye.playing,currentTime:Ye.currentTime??ji.currentTime});break}case"queue_updated":m(on=>on&&{...on,queue:Ye.queue});break;case"members_updated":m(on=>on&&{...on,members:Ye.members,hostId:Ye.hostId});break;case"vote_updated":Ae(Ye.votes);break;case"chat":le(on=>{const xn=[...on,{sender:Ye.sender,text:Ye.text,timestamp:Ye.timestamp}];return xn.length>100?xn.slice(-100):xn});break;case"chat_history":le(Ye.messages||[]);break;case"error":Ye.code==="WRONG_PASSWORD"?x(on=>on&&{...on,error:Ye.message}):w(Ye.message);break}};const ln=ie.useCallback(()=>{if(ke.current&&(ke.current.readyState===WebSocket.OPEN||ke.current.readyState===WebSocket.CONNECTING))return;const Ye=location.protocol==="https:"?"wss":"ws",St=new WebSocket(`${Ye}://${location.host}/ws/watch-together`);ke.current=St,St.onopen=()=>{Pt.current=1e3},St.onmessage=ye=>{let pt;try{pt=JSON.parse(ye.data)}catch{return}Xt.current(pt)},St.onclose=()=>{ke.current===St&&(ke.current=null),Nt.current&&(et.current=setTimeout(()=>{Pt.current=Math.min(Pt.current*2,1e4),ln()},Pt.current))},St.onerror=()=>{St.close()}},[]),mt=ie.useCallback(()=>{if(!n.trim()){w("Bitte gib einen Namen ein.");return}if(!s.trim()){w("Bitte gib einen Raumnamen ein.");return}w(null),ln();const Ye=Date.now(),St=()=>{var ye;((ye=ke.current)==null?void 0:ye.readyState)===WebSocket.OPEN?Oe({type:"create_room",name:s.trim(),userName:n.trim(),password:l.trim()||void 0}):Date.now()-Ye>1e4?w("Verbindung zum Server fehlgeschlagen."):setTimeout(St,100)};St()},[n,s,l,ln,Oe]),Wt=ie.useCallback((Ye,St)=>{if(!n.trim()){w("Bitte gib einen Namen ein.");return}w(null),ln();const ye=Date.now(),pt=()=>{var Zt;((Zt=ke.current)==null?void 0:Zt.readyState)===WebSocket.OPEN?Oe({type:"join_room",userName:n.trim(),roomId:Ye,password:(St==null?void 0:St.trim())||void 0}):Date.now()-ye>1e4?w("Verbindung zum Server fehlgeschlagen."):setTimeout(pt,100)};pt()},[n,ln,Oe]),Yt=ie.useCallback(()=>{Oe({type:"leave_room"}),Bt(),m(null),C(""),z(0),W(0),le([]),Ae(null),Se("synced")},[Oe,Bt]),$t=ie.useCallback(async()=>{const Ye=N.trim();if(!Ye)return;C(""),te(!0);let St="";try{const ye=await fetch(`/api/watch-together/video-info?url=${encodeURIComponent(Ye)}`);ye.ok&&(St=(await ye.json()).title||"")}catch{}Oe({type:"add_to_queue",url:Ye,title:St||void 0}),te(!1)},[N,Oe]),It=ie.useCallback(()=>{const Ye=Q.trim();Ye&&(K(""),Oe({type:"chat_message",text:Ye}))},[Q,Oe]);ie.useCallback(()=>{Oe({type:"vote_skip"})},[Oe]),ie.useCallback(()=>{Oe({type:"vote_pause"})},[Oe]);const Te=ie.useCallback(()=>{Oe({type:"clear_watched"})},[Oe]),nt=ie.useCallback(()=>{if(!h)return;const Ye=`${window.location.origin}${window.location.pathname}?wt=${h.id}`;navigator.clipboard.writeText(Ye).catch(()=>{})},[h]),At=ie.useCallback(Ye=>{Oe({type:"remove_from_queue",index:Ye})},[Oe]),ce=ie.useCallback(()=>{const Ye=Nt.current;Ye&&Oe({type:Ye.playing?"pause":"resume"})},[Oe]),xt=ie.useCallback(()=>{Oe({type:"skip"})},[Oe]),Ze=ie.useCallback(Ye=>{var St,ye,pt;wt.current=!0,Oe({type:"seek",time:Ye}),he.current==="youtube"&&Tt.current?(ye=(St=Tt.current).seekTo)==null||ye.call(St,Ye,!0):he.current==="direct"&&Ge.current?Ge.current.currentTime=Ye:he.current==="dailymotion"&&((pt=ut.current)!=null&&pt.contentWindow)&&ut.current.contentWindow.postMessage(`seek?to=${Ye}`,"https://www.dailymotion.com"),W(Ye),setTimeout(()=>{wt.current=!1},3e3)},[Oe]);ie.useEffect(()=>{if(!Be||!(h!=null&&h.playing))return;const Ye=setInterval(()=>{const St=je();St!==null&&Oe({type:"report_time",time:St})},2e3);return()=>clearInterval(Ye)},[Be,h==null?void 0:h.playing,Oe,je]);const lt=ie.useCallback(()=>{const Ye=Gt.current;Ye&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):Ye.requestFullscreen().catch(()=>{}))},[]);ie.useEffect(()=>{const Ye=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",Ye),()=>document.removeEventListener("fullscreenchange",Ye)},[]),ie.useEffect(()=>{const Ye=ye=>{Nt.current&&ye.preventDefault()},St=()=>{Qe.current&&navigator.sendBeacon("/api/watch-together/disconnect",JSON.stringify({clientId:Qe.current}))};return window.addEventListener("beforeunload",Ye),window.addEventListener("pagehide",St),()=>{window.removeEventListener("beforeunload",Ye),window.removeEventListener("pagehide",St)}},[]),ie.useEffect(()=>()=>{Bt(),ke.current&&ke.current.close(),et.current&&clearTimeout(et.current)},[Bt]);const bt=ie.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(ye=>ye&&{...ye,error:"Passwort eingeben."});return}const{roomId:Ye,password:St}=v;x(null),Wt(Ye,St)},[v,Wt]),Kt=ie.useCallback(Ye=>{Ye.hasPassword?x({roomId:Ye.id,roomName:Ye.name,password:"",error:null}):Wt(Ye.id)},[Wt]);if(h){const Ye=h.members.find(St=>St.id===h.hostId);return P.jsxs("div",{className:"wt-room-overlay",ref:Gt,children:[P.jsxs("div",{className:"wt-room-header",children:[P.jsxs("div",{className:"wt-room-header-left",children:[P.jsx("span",{className:"wt-room-name",children:h.name}),P.jsxs("span",{className:"wt-room-members",children:[h.members.length," Mitglieder"]}),Ye&&P.jsxs("span",{className:"wt-host-badge",children:["Host: ",Ye.name]})]}),P.jsxs("div",{className:"wt-room-header-right",children:[P.jsx("div",{className:`wt-sync-dot wt-sync-${be}`,title:be==="synced"?"Synchron":be==="drifting"?"Leichte Verzögerung":"Nicht synchron"}),P.jsx("button",{className:"wt-header-btn",onClick:nt,title:"Link kopieren",children:"Link"}),P.jsx("button",{className:"wt-header-btn",onClick:()=>Ee(St=>!St),title:se?"Chat ausblenden":"Chat einblenden",children:"Chat"}),P.jsx("button",{className:"wt-fullscreen-btn",onClick:lt,title:U?"Vollbild verlassen":"Vollbild",children:U?"✖":"⛶"}),P.jsx("button",{className:"wt-leave-btn",onClick:Yt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"wt-room-body",children:[P.jsxs("div",{className:"wt-player-section",children:[P.jsxs("div",{className:"wt-player-wrap",children:[P.jsx("div",{ref:dt,className:"wt-yt-container",style:he.current==="youtube"?{}:{display:"none"}}),P.jsx("video",{ref:Ge,className:"wt-video-element",style:he.current==="direct"?{}:{display:"none"},playsInline:!0}),P.jsx("iframe",{ref:ut,className:"wt-dm-container",style:he.current==="dailymotion"?{}:{display:"none"},allow:"autoplay; fullscreen",allowFullScreen:!0}),q&&P.jsxs("div",{className:"wt-player-error",children:[P.jsx("div",{className:"wt-error-icon",children:"⚠️"}),P.jsx("p",{children:q}),((un=h.currentVideo)==null?void 0:un.url)&&P.jsx("a",{className:"wt-yt-link",href:h.currentVideo.url,target:"_blank",rel:"noopener noreferrer",children:"Auf YouTube öffnen ↗"}),P.jsx("p",{className:"wt-skip-info",children:"Wird in 3 Sekunden übersprungen..."})]}),!h.currentVideo&&P.jsxs("div",{className:"wt-player-placeholder",children:[P.jsx("div",{className:"wt-placeholder-icon",children:"🎬"}),P.jsx("p",{children:"Fuege ein Video zur Warteschlange hinzu"})]})]}),P.jsxs("div",{className:"wt-controls",children:[P.jsx("button",{className:"wt-ctrl-btn",onClick:ce,disabled:!h.currentVideo,title:h.playing?"Pause":"Abspielen",children:h.playing?"⏸":"▶"}),P.jsxs("button",{className:"wt-ctrl-btn wt-next-btn",onClick:xt,disabled:!h.currentVideo&&h.queue.length===0,title:"Nächstes Video",children:["⏭"," Weiter"]}),P.jsx("input",{className:"wt-seek",type:"range",min:0,max:j||0,step:.5,value:G,onChange:St=>Ze(parseFloat(St.target.value)),disabled:!h.currentVideo}),P.jsxs("span",{className:"wt-time",children:[T7(G)," / ",T7(j)]}),P.jsxs("div",{className:"wt-volume",children:[P.jsx("span",{className:"wt-volume-icon",children:E===0?"🔇":E<.5?"🔉":"🔊"}),P.jsx("input",{className:"wt-volume-slider",type:"range",min:0,max:1,step:.01,value:E,onChange:St=>O(parseFloat(St.target.value))})]}),he.current==="youtube"&&P.jsxs("select",{className:"wt-quality-select",value:qe,onChange:St=>Ce(St.target.value),title:"Videoqualität",children:[P.jsx("option",{value:"highres",children:"4K+"}),P.jsx("option",{value:"hd2160",children:"2160p"}),P.jsx("option",{value:"hd1440",children:"1440p"}),P.jsx("option",{value:"hd1080",children:"1080p"}),P.jsx("option",{value:"hd720",children:"720p"}),P.jsx("option",{value:"large",children:"480p"}),P.jsx("option",{value:"medium",children:"360p"}),P.jsx("option",{value:"small",children:"240p"})]})]})]}),P.jsxs("div",{className:"wt-queue-panel",children:[P.jsxs("div",{className:"wt-queue-header",children:[P.jsxs("span",{children:["Warteschlange (",h.queue.length,")"]}),h.queue.some(St=>St.watched)&&P.jsx("button",{className:"wt-queue-clear-btn",onClick:Te,title:"Gesehene entfernen",children:"Gesehene entfernen"})]}),P.jsx("div",{className:"wt-queue-list",children:h.queue.length===0?P.jsx("div",{className:"wt-queue-empty",children:"Keine Videos in der Warteschlange"}):h.queue.map((St,ye)=>{var Zt,Pe;const pt=((Zt=h.currentVideo)==null?void 0:Zt.url)===St.url;return P.jsxs("div",{className:`wt-queue-item${pt?" playing":""}${St.watched&&!pt?" watched":""} clickable`,onClick:()=>Oe({type:"play_video",index:ye}),title:"Klicken zum Abspielen",children:[P.jsxs("div",{className:"wt-queue-item-info",children:[St.watched&&!pt&&P.jsx("span",{className:"wt-queue-item-check",children:"✓"}),St.url.match(/youtu/)&&P.jsx("img",{className:"wt-queue-thumb",src:`https://img.youtube.com/vi/${(Pe=St.url.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/))==null?void 0:Pe[1]}/default.jpg`,alt:""}),P.jsxs("div",{className:"wt-queue-item-text",children:[P.jsx("div",{className:"wt-queue-item-title",children:St.title||St.url}),P.jsx("div",{className:"wt-queue-item-by",children:St.addedBy})]})]}),Be&&P.jsx("button",{className:"wt-queue-item-remove",onClick:at=>{at.stopPropagation(),At(ye)},title:"Entfernen",children:"×"})]},ye)})}),P.jsxs("div",{className:"wt-queue-add",children:[P.jsx("input",{className:"wt-input wt-queue-input",placeholder:"Video-URL eingeben",value:N,onChange:St=>C(St.target.value),onKeyDown:St=>{St.key==="Enter"&&$t()}}),P.jsx("button",{className:"wt-btn wt-queue-add-btn",onClick:$t,disabled:Y,children:Y?"Laden...":"Hinzufuegen"})]})]}),se&&P.jsxs("div",{className:"wt-chat-panel",children:[P.jsx("div",{className:"wt-chat-header",children:"Chat"}),P.jsxs("div",{className:"wt-chat-messages",children:[ne.length===0?P.jsx("div",{className:"wt-chat-empty",children:"Noch keine Nachrichten"}):ne.map((St,ye)=>P.jsxs("div",{className:"wt-chat-msg",children:[P.jsx("span",{className:"wt-chat-sender",children:St.sender}),P.jsx("span",{className:"wt-chat-text",children:St.text})]},ye)),P.jsx("div",{ref:Lt})]}),P.jsxs("div",{className:"wt-chat-input-row",children:[P.jsx("input",{className:"wt-input wt-chat-input",placeholder:"Nachricht...",value:Q,onChange:St=>K(St.target.value),onKeyDown:St=>{St.key==="Enter"&&It()},maxLength:500}),P.jsx("button",{className:"wt-btn wt-chat-send-btn",onClick:It,children:"Senden"})]})]})]})]})}return P.jsxs("div",{className:"wt-container",children:[S&&P.jsxs("div",{className:"wt-error",children:[S,P.jsx("button",{className:"wt-error-dismiss",onClick:()=>w(null),children:"×"})]}),P.jsxs("div",{className:"wt-topbar",children:[P.jsx("input",{className:"wt-input wt-input-name",placeholder:"Dein Name",value:n,onChange:Ye=>r(Ye.target.value)}),P.jsx("input",{className:"wt-input wt-input-room",placeholder:"Raumname",value:s,onChange:Ye=>a(Ye.target.value)}),P.jsx("input",{className:"wt-input wt-input-password",type:"password",placeholder:"Passwort (optional)",value:l,onChange:Ye=>u(Ye.target.value)}),P.jsx("button",{className:"wt-btn",onClick:mt,children:"Raum erstellen"})]}),e.length===0?P.jsxs("div",{className:"wt-empty",children:[P.jsx("div",{className:"wt-empty-icon",children:"🎬"}),P.jsx("h3",{children:"Keine aktiven Raeume"}),P.jsx("p",{children:"Erstelle einen Raum, um gemeinsam Videos zu schauen."})]}):P.jsx("div",{className:"wt-grid",children:e.map(Ye=>P.jsxs("div",{className:"wt-tile",onClick:()=>Kt(Ye),children:[P.jsxs("div",{className:"wt-tile-preview",children:[P.jsx("span",{className:"wt-tile-icon",children:"🎬"}),P.jsxs("span",{className:"wt-tile-members",children:["👥"," ",Ye.memberCount]}),Ye.hasPassword&&P.jsx("span",{className:"wt-tile-lock",children:"🔒"}),Ye.playing&&P.jsx("span",{className:"wt-tile-playing",children:"▶"})]}),P.jsxs("div",{className:"wt-tile-info",children:[P.jsxs("div",{className:"wt-tile-meta",children:[P.jsx("div",{className:"wt-tile-name",children:Ye.name}),P.jsx("div",{className:"wt-tile-host",children:Ye.hostName})]}),Ye.memberNames&&Ye.memberNames.length>0&&P.jsxs("div",{className:"wt-tile-members-list",children:[Ye.memberNames.slice(0,5).join(", "),Ye.memberNames.length>5&&` +${Ye.memberNames.length-5}`]})]})]},Ye.id))}),v&&P.jsx("div",{className:"wt-modal-overlay",onClick:()=>x(null),children:P.jsxs("div",{className:"wt-modal",onClick:Ye=>Ye.stopPropagation(),children:[P.jsx("h3",{children:v.roomName}),P.jsx("p",{children:"Raum-Passwort"}),v.error&&P.jsx("div",{className:"wt-modal-error",children:v.error}),P.jsx("input",{className:"wt-input",type:"password",placeholder:"Passwort",value:v.password,onChange:Ye=>x(St=>St&&{...St,password:Ye.target.value,error:null}),onKeyDown:Ye=>{Ye.key==="Enter"&&bt()},autoFocus:!0}),P.jsxs("div",{className:"wt-modal-actions",children:[P.jsx("button",{className:"wt-modal-cancel",onClick:()=>x(null),children:"Abbrechen"}),P.jsx("button",{className:"wt-btn",onClick:bt,children:"Beitreten"})]})]})})]})}function jS(i,e){return`https://media.steampowered.com/steamcommunity/public/images/apps/${i}/${e}.jpg`}function w7(i){if(i==null||i===0)return"—";if(i<60)return`${i} Min`;const e=Math.floor(i/60),t=i%60;return t>0?`${e}h ${t}m`:`${e}h`}function JAe(i){try{return new Date(i).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function e0e({data:i,isAdmin:e}){const[t,n]=ie.useState([]),[r,s]=ie.useState("overview"),[a,l]=ie.useState(null),[u,h]=ie.useState(new Set),[m,v]=ie.useState(null),[x,S]=ie.useState(null),[w,N]=ie.useState(""),[C,E]=ie.useState(null),[O,U]=ie.useState(!1),[I,j]=ie.useState(null),[z,G]=ie.useState(new Set),[W,q]=ie.useState("playtime"),V=ie.useRef(null),Y=ie.useRef(null),[te,ne]=ie.useState(""),[le,Q]=ie.useState(!1),K=e??!1,[ae,Ae]=ie.useState([]),[be,Se]=ie.useState(!1);ie.useEffect(()=>{i!=null&&i.profiles&&n(i.profiles)},[i]);const se=ie.useCallback(async()=>{try{const Te=await fetch("/api/game-library/profiles");if(Te.ok){const nt=await Te.json();n(nt.profiles||[])}}catch{}},[]),Ee=ie.useCallback(async()=>{Se(!0);try{const Te=await fetch("/api/game-library/admin/profiles",{credentials:"include"});if(Te.ok){const nt=await Te.json();Ae(nt.profiles||[])}}catch{}finally{Se(!1)}},[]),qe=ie.useCallback(()=>{Q(!0),K&&Ee()},[K,Ee]),Ce=ie.useCallback(async(Te,nt)=>{if(confirm(`Profil "${nt}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`))try{(await fetch(`/api/game-library/admin/profile/${Te}`,{method:"DELETE",credentials:"include"})).ok&&(Ee(),se())}catch{}},[Ee,se]),ke=ie.useCallback(()=>{const Te=window.open("/api/game-library/steam/login","_blank","width=800,height=600"),nt=setInterval(()=>{Te&&Te.closed&&(clearInterval(nt),setTimeout(se,1e3))},500)},[se]),Qe=navigator.userAgent.includes("GamingHubDesktop"),[et,Pt]=ie.useState(!1),[Nt,Gt]=ie.useState(""),[Tt,Ge]=ie.useState("idle"),[dt,he]=ie.useState(""),en=ie.useCallback(()=>{const Te=a?`?linkTo=${a}`:"";if(Qe){const nt=window.open(`/api/game-library/gog/login${Te}`,"_blank","width=800,height=700"),At=setInterval(()=>{nt&&nt.closed&&(clearInterval(At),setTimeout(se,1e3))},500)}else window.open(`/api/game-library/gog/login${Te}`,"_blank","width=800,height=700"),Gt(""),Ge("idle"),he(""),Pt(!0)},[se,a,Qe]),wt=ie.useCallback(async()=>{let Te=Nt.trim();const nt=Te.match(/[?&]code=([^&]+)/);if(nt&&(Te=nt[1]),!!Te){Ge("loading"),he("Verbinde mit GOG...");try{const At=await fetch("/api/game-library/gog/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:Te,linkTo:a||""})}),ce=await At.json();At.ok&&ce.ok?(Ge("success"),he(`${ce.profileName}: ${ce.gameCount} Spiele geladen!`),se(),setTimeout(()=>Pt(!1),2e3)):(Ge("error"),he(ce.error||"Unbekannter Fehler"))}catch{Ge("error"),he("Verbindung fehlgeschlagen.")}}},[Nt,a,se]);ie.useEffect(()=>{const Te=()=>se();return window.addEventListener("gog-connected",Te),()=>window.removeEventListener("gog-connected",Te)},[se]),ie.useEffect(()=>{const Te=()=>se();return window.addEventListener("focus",Te),()=>window.removeEventListener("focus",Te)},[se]);const qt=ie.useCallback(async Te=>{var nt,At;s("user"),l(Te),v(null),ne(""),U(!0);try{const ce=await fetch(`/api/game-library/profile/${Te}/games`);if(ce.ok){const xt=await ce.json(),Ze=xt.games||xt;v(Ze);const lt=t.find(Kt=>Kt.id===Te),bt=(At=(nt=lt==null?void 0:lt.platforms)==null?void 0:nt.steam)==null?void 0:At.steamId;bt&&Ze.filter(un=>!un.igdb).length>0&&(j(Te),fetch(`/api/game-library/igdb/enrich/${bt}`).then(un=>un.ok?un.json():null).then(()=>fetch(`/api/game-library/profile/${Te}/games`)).then(un=>un.ok?un.json():null).then(un=>{un&&v(un.games||un)}).catch(()=>{}).finally(()=>j(null)))}}catch{}finally{U(!1)}},[t]),Lt=ie.useCallback(async(Te,nt)=>{var xt,Ze;nt&&nt.stopPropagation();const At=t.find(lt=>lt.id===Te),ce=(Ze=(xt=At==null?void 0:At.platforms)==null?void 0:xt.steam)==null?void 0:Ze.steamId;try{ce&&await fetch(`/api/game-library/user/${ce}?refresh=true`),await se(),r==="user"&&a===Te&&qt(Te)}catch{}},[se,r,a,qt,t]),hn=ie.useCallback(async Te=>{var ce,xt;const nt=t.find(Ze=>Ze.id===Te),At=(xt=(ce=nt==null?void 0:nt.platforms)==null?void 0:ce.steam)==null?void 0:xt.steamId;if(At){j(Te);try{(await fetch(`/api/game-library/igdb/enrich/${At}`)).ok&&r==="user"&&a===Te&&qt(Te)}catch{}finally{j(null)}}},[r,a,qt,t]),ut=ie.useCallback(Te=>{h(nt=>{const At=new Set(nt);return At.has(Te)?At.delete(Te):At.add(Te),At})},[]),fe=ie.useCallback(async()=>{if(!(u.size<2)){s("common"),S(null),U(!0);try{const Te=Array.from(u).join(","),nt=await fetch(`/api/game-library/common-games?users=${Te}`);if(nt.ok){const At=await nt.json();S(At.games||At)}else console.error("[GameLibrary] common-games error:",nt.status,await nt.text().catch(()=>"")),S([])}catch(Te){console.error("[GameLibrary] common-games fetch failed:",Te)}finally{U(!1)}}},[u]),k=ie.useCallback(Te=>{if(N(Te),V.current&&clearTimeout(V.current),Te.length<2){E(null);return}V.current=setTimeout(async()=>{try{const nt=await fetch(`/api/game-library/search?q=${encodeURIComponent(Te)}`);if(nt.ok){const At=await nt.json();E(At.results||At)}}catch{}},300)},[]),_e=ie.useCallback(Te=>{G(nt=>{const At=new Set(nt);return At.has(Te)?At.delete(Te):At.add(Te),At})},[]),Be=ie.useCallback(async(Te,nt)=>{if(confirm(`${nt==="steam"?"Steam":"GOG"}-Verknuepfung wirklich trennen?`))try{const At=await fetch(`/api/game-library/profile/${Te}/${nt}`,{method:"DELETE"});if(At.ok&&(se(),(await At.json()).ok)){const xt=t.find(lt=>lt.id===Te);(nt==="steam"?xt==null?void 0:xt.platforms.gog:xt==null?void 0:xt.platforms.steam)||Oe()}}catch{}},[se,t]);ie.useCallback(async Te=>{const nt=t.find(At=>At.id===Te);if(confirm(`Profil "${nt==null?void 0:nt.displayName}" wirklich komplett loeschen?`))try{(await fetch(`/api/game-library/profile/${Te}`,{method:"DELETE"})).ok&&(se(),Oe())}catch{}},[se,t]);const Oe=ie.useCallback(()=>{s("overview"),l(null),v(null),S(null),ne(""),G(new Set),q("playtime")},[]),je=Oe,Bt=ie.useCallback(Te=>t.find(nt=>nt.id===Te),[t]),yt=ie.useCallback(Te=>typeof Te.playtime_forever=="number"?Te.playtime_forever:Array.isArray(Te.owners)?Math.max(...Te.owners.map(nt=>nt.playtime_forever||0)):0,[]),Xt=ie.useCallback(Te=>[...Te].sort((nt,At)=>{var ce,xt;if(W==="rating"){const Ze=((ce=nt.igdb)==null?void 0:ce.rating)??-1;return(((xt=At.igdb)==null?void 0:xt.rating)??-1)-Ze}return W==="name"?nt.name.localeCompare(At.name):yt(At)-yt(nt)}),[W,yt]),ln=ie.useCallback(Te=>{var nt,At;return z.size===0?!0:(At=(nt=Te.igdb)==null?void 0:nt.genres)!=null&&At.length?Te.igdb.genres.some(ce=>z.has(ce)):!1},[z]),mt=ie.useCallback(Te=>{var At;const nt=new Map;for(const ce of Te)if((At=ce.igdb)!=null&&At.genres)for(const xt of ce.igdb.genres)nt.set(xt,(nt.get(xt)||0)+1);return[...nt.entries()].sort((ce,xt)=>xt[1]-ce[1]).map(([ce])=>ce)},[]),Wt=m?Xt(m.filter(Te=>!te||Te.name.toLowerCase().includes(te.toLowerCase())).filter(ln)):null,Yt=m?mt(m):[],$t=x?mt(x):[],It=x?Xt(x.filter(ln)):null;return P.jsxs("div",{className:"gl-container",children:[P.jsxs("div",{className:"gl-login-bar",children:[!a&&P.jsx("button",{className:"gl-connect-btn gl-steam-btn",onClick:ke,children:"🎮 Steam verbinden"}),P.jsx("div",{className:"gl-login-bar-spacer"}),K&&P.jsx("button",{className:"gl-admin-btn",onClick:qe,title:"Admin Panel",children:"⚙️"})]}),t.length>0&&P.jsx("div",{className:"gl-profile-chips",children:t.map(Te=>P.jsxs("div",{className:`gl-profile-chip${a===Te.id?" selected":""}`,onClick:()=>qt(Te.id),children:[P.jsx("img",{className:"gl-profile-chip-avatar",src:Te.avatarUrl,alt:Te.displayName}),P.jsxs("div",{className:"gl-profile-chip-info",children:[P.jsx("span",{className:"gl-profile-chip-name",children:Te.displayName}),P.jsxs("span",{className:"gl-profile-chip-platforms",children:[Te.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:`Steam: ${Te.platforms.steam.gameCount} Spiele`,children:"S"}),Te.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:`GOG: ${Te.platforms.gog.gameCount} Spiele`,children:"G"})]})]}),P.jsxs("span",{className:"gl-profile-chip-count",children:["(",Te.totalGames,")"]})]},Te.id))}),r==="overview"&&P.jsx(P.Fragment,{children:t.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"🎮"}),P.jsx("h3",{children:"Keine Konten verbunden"}),P.jsx("p",{children:"Klicke oben auf “Steam verbinden” oder “GOG verbinden”, um deine Spielebibliothek hinzuzufuegen."})]}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"gl-section-title",children:"Verbundene Spieler"}),P.jsx("div",{className:"gl-users-grid",children:t.map(Te=>P.jsxs("div",{className:"gl-user-card",onClick:()=>qt(Te.id),children:[P.jsx("img",{className:"gl-user-card-avatar",src:Te.avatarUrl,alt:Te.displayName}),P.jsx("span",{className:"gl-user-card-name",children:Te.displayName}),P.jsxs("div",{className:"gl-profile-card-platforms",children:[Te.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:"Steam",children:"S"}),Te.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:"GOG",children:"G"})]}),P.jsxs("span",{className:"gl-user-card-games",children:[Te.totalGames," Spiele"]}),P.jsxs("span",{className:"gl-user-card-updated",children:["Aktualisiert: ",JAe(Te.lastUpdated)]})]},Te.id))}),t.length>=2&&P.jsxs("div",{className:"gl-common-finder",children:[P.jsx("h3",{children:"Gemeinsame Spiele finden"}),P.jsx("div",{className:"gl-common-users",children:t.map(Te=>P.jsxs("label",{className:`gl-common-check${u.has(Te.id)?" checked":""}`,children:[P.jsx("input",{type:"checkbox",checked:u.has(Te.id),onChange:()=>ut(Te.id)}),P.jsx("img",{className:"gl-common-check-avatar",src:Te.avatarUrl,alt:Te.displayName}),Te.displayName,P.jsxs("span",{className:"gl-profile-chip-platforms",style:{marginLeft:4},children:[Te.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",children:"S"}),Te.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",children:"G"})]})]},Te.id))}),P.jsx("button",{className:"gl-common-find-btn",disabled:u.size<2,onClick:fe,children:"Finden"})]}),P.jsx("div",{className:"gl-search",children:P.jsx("input",{className:"gl-search-input",type:"text",placeholder:"Spiel suchen...",value:w,onChange:Te=>k(Te.target.value)})}),C&&C.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"gl-search-results-title",children:[C.length," Ergebnis",C.length!==1?"se":""]}),P.jsx("div",{className:"gl-game-list",children:C.map(Te=>P.jsxs("div",{className:"gl-game-item",children:[Te.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:jS(Te.appid,Te.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"}),P.jsx("span",{className:"gl-game-name",children:Te.name}),P.jsx("div",{className:"gl-game-owners",children:Te.owners.map(nt=>{const At=t.find(ce=>{var xt;return((xt=ce.platforms.steam)==null?void 0:xt.steamId)===nt.steamId});return At?P.jsx("img",{className:"gl-game-owner-avatar",src:At.avatarUrl,alt:nt.personaName,title:nt.personaName},nt.steamId):null})})]},Te.appid))})]}),C&&C.length===0&&P.jsx("p",{className:"gl-search-results-title",children:"Keine Ergebnisse gefunden."})]})}),r==="user"&&(()=>{const Te=a?Bt(a):null;return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:je,children:"← Zurueck"}),Te&&P.jsxs(P.Fragment,{children:[P.jsx("img",{className:"gl-detail-avatar",src:Te.avatarUrl,alt:Te.displayName}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsxs("div",{className:"gl-detail-name",children:[Te.displayName,P.jsxs("span",{className:"gl-game-count",children:[Te.totalGames," Spiele"]})]}),P.jsxs("div",{className:"gl-detail-sub",children:[Te.platforms.steam&&P.jsxs("span",{className:"gl-platform-detail steam",children:[P.jsx("span",{className:"gl-platform-badge steam",children:"Steam ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:nt=>{nt.stopPropagation(),Be(Te.id,"steam")},title:"Steam trennen",children:"✕"})]}),Te.platforms.gog?P.jsxs("span",{className:"gl-platform-detail gog",children:[P.jsx("span",{className:"gl-platform-badge gog",children:"GOG ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:nt=>{nt.stopPropagation(),Be(Te.id,"gog")},title:"GOG trennen",children:"✕"})]}):P.jsx("button",{className:"gl-link-gog-btn",onClick:en,children:"🟣 GOG verknuepfen"})]})]}),P.jsx("button",{className:"gl-refresh-btn",onClick:()=>Lt(Te.id),title:"Aktualisieren",children:"↻"}),Te.platforms.steam&&P.jsxs("button",{className:`gl-enrich-btn ${I===a?"enriching":""}`,onClick:()=>hn(a),disabled:I===a,title:I===a?"IGDB-Daten werden geladen...":"Mit IGDB-Daten anreichern (erneut)",children:[I===a?"⏳":"🌐"," IGDB"]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Bibliothek wird geladen..."}):Wt?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-filter-bar",children:[P.jsx("input",{ref:Y,className:"gl-search-input",type:"text",placeholder:"Bibliothek durchsuchen...",value:te,onChange:nt=>ne(nt.target.value)}),P.jsxs("select",{className:"gl-sort-select",value:W,onChange:nt=>q(nt.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})]}),Yt.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),Yt.map(nt=>P.jsx("button",{className:`gl-genre-chip${z.has(nt)?" active":""}`,onClick:()=>_e(nt),children:nt},nt))]}),P.jsxs("p",{className:"gl-filter-count",children:[Wt.length," Spiele"]}),Wt.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Spiele gefunden."}):P.jsx("div",{className:"gl-game-list",children:Wt.map((nt,At)=>{var ce,xt,Ze;return P.jsxs("div",{className:`gl-game-item ${nt.igdb?"enriched":""}`,children:[P.jsx("span",{className:`gl-game-platform-icon ${nt.platform||"steam"}`,children:nt.platform==="gog"?"G":"S"}),P.jsx("div",{className:"gl-game-visual",children:(ce=nt.igdb)!=null&&ce.coverUrl?P.jsx("img",{className:"gl-game-cover",src:nt.igdb.coverUrl,alt:""}):nt.img_icon_url&&nt.appid?P.jsx("img",{className:"gl-game-icon",src:jS(nt.appid,nt.img_icon_url),alt:""}):nt.image?P.jsx("img",{className:"gl-game-icon",src:nt.image,alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:nt.name}),((xt=nt.igdb)==null?void 0:xt.genres)&&nt.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:nt.igdb.genres.slice(0,3).map(lt=>P.jsx("span",{className:"gl-genre-tag",children:lt},lt))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Ze=nt.igdb)==null?void 0:Ze.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${nt.igdb.rating>=75?"high":nt.igdb.rating>=50?"mid":"low"}`,children:Math.round(nt.igdb.rating)}),P.jsx("span",{className:"gl-game-playtime",children:w7(nt.playtime_forever)})]})]},nt.appid??nt.gogId??At)})})]}):null]})})(),r==="common"&&(()=>{const Te=Array.from(u).map(At=>Bt(At)).filter(Boolean),nt=Te.map(At=>At.displayName).join(", ");return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:je,children:"← Zurueck"}),P.jsx("div",{className:"gl-detail-avatars",children:Te.map(At=>P.jsx("img",{src:At.avatarUrl,alt:At.displayName},At.id))}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsx("div",{className:"gl-detail-name",children:"Gemeinsame Spiele"}),P.jsxs("div",{className:"gl-detail-sub",children:["von ",nt]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Gemeinsame Spiele werden gesucht..."}):x?x.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"😔"}),P.jsx("h3",{children:"Keine gemeinsamen Spiele"}),P.jsx("p",{children:"Die ausgewaehlten Spieler besitzen leider keine gemeinsamen Spiele."})]}):P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"gl-filter-bar",children:P.jsxs("select",{className:"gl-sort-select",value:W,onChange:At=>q(At.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})}),$t.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),$t.map(At=>P.jsx("button",{className:`gl-genre-chip${z.has(At)?" active":""}`,onClick:()=>_e(At),children:At},At))]}),P.jsxs("p",{className:"gl-section-title",children:[It.length," gemeinsame",It.length!==1?" Spiele":"s Spiel",z.size>0?` (von ${x.length})`:""]}),P.jsx("div",{className:"gl-game-list",children:It.map(At=>{var ce,xt,Ze;return P.jsxs("div",{className:`gl-game-item ${At.igdb?"enriched":""}`,children:[P.jsx("div",{className:"gl-game-visual",children:(ce=At.igdb)!=null&&ce.coverUrl?P.jsx("img",{className:"gl-game-cover",src:At.igdb.coverUrl,alt:""}):At.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:jS(At.appid,At.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:At.name}),((xt=At.igdb)==null?void 0:xt.genres)&&At.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:At.igdb.genres.slice(0,3).map(lt=>P.jsx("span",{className:"gl-genre-tag",children:lt},lt))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Ze=At.igdb)==null?void 0:Ze.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${At.igdb.rating>=75?"high":At.igdb.rating>=50?"mid":"low"}`,children:Math.round(At.igdb.rating)}),P.jsx("div",{className:"gl-common-playtimes",children:At.owners.map(lt=>P.jsxs("span",{className:"gl-common-pt",children:[lt.personaName,": ",w7(lt.playtime_forever)]},lt.steamId))})]})]},At.appid)})})]}):null]})})(),le&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>Q(!1),children:P.jsxs("div",{className:"gl-admin-panel",onClick:Te=>Te.stopPropagation(),children:[P.jsxs("div",{className:"gl-admin-header",children:[P.jsx("h3",{children:"⚙️ Game Library Admin"}),P.jsx("button",{className:"gl-admin-close",onClick:()=>Q(!1),children:"✕"})]}),P.jsxs("div",{className:"gl-admin-content",children:[P.jsxs("div",{className:"gl-admin-toolbar",children:[P.jsx("span",{className:"gl-admin-status-text",children:"✅ Eingeloggt als Admin"}),P.jsx("button",{className:"gl-admin-refresh-btn",onClick:Ee,children:"↻ Aktualisieren"})]}),be?P.jsx("div",{className:"gl-loading",children:"Lade Profile..."}):ae.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Profile vorhanden."}):P.jsx("div",{className:"gl-admin-list",children:ae.map(Te=>P.jsxs("div",{className:"gl-admin-item",children:[P.jsx("img",{className:"gl-admin-item-avatar",src:Te.avatarUrl,alt:Te.displayName}),P.jsxs("div",{className:"gl-admin-item-info",children:[P.jsx("span",{className:"gl-admin-item-name",children:Te.displayName}),P.jsxs("span",{className:"gl-admin-item-details",children:[Te.steamName&&P.jsxs("span",{className:"gl-platform-badge steam",children:["Steam: ",Te.steamGames]}),Te.gogName&&P.jsxs("span",{className:"gl-platform-badge gog",children:["GOG: ",Te.gogGames]}),P.jsxs("span",{className:"gl-admin-item-total",children:[Te.totalGames," Spiele"]})]})]}),P.jsx("button",{className:"gl-admin-delete-btn",onClick:()=>Ce(Te.id,Te.displayName),title:"Profil loeschen",children:"🗑️ Entfernen"})]},Te.id))})]})]})}),et&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>Pt(!1),children:P.jsxs("div",{className:"gl-dialog",onClick:Te=>Te.stopPropagation(),children:[P.jsx("h3",{children:"🟣 GOG verbinden"}),P.jsxs("p",{className:"gl-dialog-hint",children:["Nach dem GOG-Login wirst du auf eine Seite weitergeleitet. Kopiere die ",P.jsx("strong",{children:"komplette URL"})," aus der Adressleiste und füge sie hier ein:"]}),P.jsx("input",{className:"gl-dialog-input",type:"text",placeholder:"https://embed.gog.com/on_login_success?code=...",value:Nt,onChange:Te=>Gt(Te.target.value),onKeyDown:Te=>{Te.key==="Enter"&&wt()},disabled:Tt==="loading"||Tt==="success",autoFocus:!0}),dt&&P.jsx("p",{className:`gl-dialog-status ${Tt}`,children:dt}),P.jsxs("div",{className:"gl-dialog-actions",children:[P.jsx("button",{onClick:()=>Pt(!1),className:"gl-dialog-cancel",children:"Abbrechen"}),P.jsx("button",{onClick:wt,className:"gl-dialog-submit",disabled:!Nt.trim()||Tt==="loading"||Tt==="success",children:Tt==="loading"?"Verbinde...":"Verbinden"})]})]})})]})}const M7={radio:MAe,soundboard:jAe,lolstats:YAe,streaming:QAe,"watch-together":ZAe,"game-library":e0e};function t0e(){var le;const[i,e]=ie.useState(!1),[t,n]=ie.useState([]),[r,s]=ie.useState(()=>localStorage.getItem("hub_activeTab")??""),a=Q=>{s(Q),localStorage.setItem("hub_activeTab",Q)},[l,u]=ie.useState(!1),[h,m]=ie.useState({}),[v,x]=ie.useState(!1),[S,w]=ie.useState(!1),[N,C]=ie.useState(""),[E,O]=ie.useState(""),U=!!((le=window.electronAPI)!=null&&le.isElectron),I=U?window.electronAPI.version:null,[j,z]=ie.useState("idle"),[G,W]=ie.useState(""),q=ie.useRef(null);ie.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]),ie.useEffect(()=>{fetch("/api/soundboard/admin/status",{credentials:"include"}).then(Q=>Q.json()).then(Q=>x(!!Q.authenticated)).catch(()=>{})},[]),ie.useEffect(()=>{if(!S)return;const Q=K=>{K.key==="Escape"&&w(!1)};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[S]);async function V(){O("");try{(await fetch("/api/soundboard/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:N}),credentials:"include"})).ok?(x(!0),C(""),w(!1)):O("Falsches Passwort")}catch{O("Verbindung fehlgeschlagen")}}async function Y(){await fetch("/api/soundboard/admin/logout",{method:"POST",credentials:"include"}),x(!1)}ie.useEffect(()=>{var ae;if(!U)return;const Q=window.electronAPI;Q.onUpdateAvailable(()=>z("downloading")),Q.onUpdateReady(()=>z("ready")),Q.onUpdateNotAvailable(()=>z("upToDate")),Q.onUpdateError(Ae=>{z("error"),W(Ae||"Unbekannter Fehler")});const K=(ae=Q.getUpdateStatus)==null?void 0:ae.call(Q);K==="downloading"?z("downloading"):K==="ready"?z("ready"):K==="checking"&&z("checking")},[U]),ie.useEffect(()=>{fetch("/api/plugins").then(Q=>Q.json()).then(Q=>{if(n(Q),new URLSearchParams(location.search).has("viewStream")&&Q.some(be=>be.name==="streaming")){a("streaming");return}const ae=localStorage.getItem("hub_activeTab"),Ae=Q.some(be=>be.name===ae);Q.length>0&&!Ae&&a(Q[0].name)}).catch(()=>{})},[]),ie.useEffect(()=>{let Q=null,K;function ae(){Q=new EventSource("/api/events"),q.current=Q,Q.onopen=()=>e(!0),Q.onmessage=Ae=>{try{const be=JSON.parse(Ae.data);be.type==="snapshot"?m(Se=>({...Se,...be})):be.plugin&&m(Se=>({...Se,[be.plugin]:{...Se[be.plugin]||{},...be}}))}catch{}},Q.onerror=()=>{e(!1),Q==null||Q.close(),K=setTimeout(ae,3e3)}}return ae(),()=>{Q==null||Q.close(),clearTimeout(K)}},[]);const te="1.0.0-dev";ie.useEffect(()=>{if(!l)return;const Q=K=>{K.key==="Escape"&&u(!1)};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[l]);const ne={radio:"🌍",soundboard:"🎵",lolstats:"⚔️",stats:"📊",events:"📅",games:"🎲",gamevote:"🎮",streaming:"📺","watch-together":"🎬","game-library":"🎮"};return P.jsxs("div",{className:"hub-app",children:[P.jsxs("header",{className:"hub-header",children:[P.jsxs("div",{className:"hub-header-left",children:[P.jsx("span",{className:"hub-logo",children:"🎮"}),P.jsx("span",{className:"hub-title",children:"Gaming Hub"}),P.jsx("span",{className:`hub-conn-dot ${i?"online":""}`})]}),P.jsx("nav",{className:"hub-tabs",children:t.filter(Q=>Q.name in M7).map(Q=>P.jsxs("button",{className:`hub-tab ${r===Q.name?"active":""}`,onClick:()=>a(Q.name),title:Q.description,children:[P.jsx("span",{className:"hub-tab-icon",children:ne[Q.name]??"📦"}),P.jsx("span",{className:"hub-tab-label",children:Q.name})]},Q.name))}),P.jsxs("div",{className:"hub-header-right",children:[!window.electronAPI&&P.jsxs("a",{className:"hub-download-btn",href:"/downloads/GamingHub-Setup.exe",download:!0,title:"Desktop App herunterladen",children:[P.jsx("span",{className:"hub-download-icon",children:"⬇️"}),P.jsx("span",{className:"hub-download-label",children:"Desktop App"})]}),P.jsx("button",{className:`hub-admin-btn ${v?"active":""}`,onClick:()=>v?Y():w(!0),title:v?"Admin abmelden":"Admin Login",children:v?"🔓":"🔒"}),P.jsx("button",{className:"hub-refresh-btn",onClick:()=>window.location.reload(),title:"Seite neu laden",children:"🔄"}),P.jsxs("span",{className:"hub-version hub-version-clickable",onClick:()=>{var Q;if(U){const K=window.electronAPI,ae=(Q=K.getUpdateStatus)==null?void 0:Q.call(K);ae==="downloading"?z("downloading"):ae==="ready"?z("ready"):ae==="checking"&&z("checking")}u(!0)},title:"Versionsinformationen",children:["v",te]})]})]}),l&&P.jsx("div",{className:"hub-version-overlay",onClick:()=>u(!1),children:P.jsxs("div",{className:"hub-version-modal",onClick:Q=>Q.stopPropagation(),children:[P.jsxs("div",{className:"hub-version-modal-header",children:[P.jsx("span",{children:"Versionsinformationen"}),P.jsx("button",{className:"hub-version-modal-close",onClick:()=>u(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-version-modal-body",children:[P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Hub-Version"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",te]})]}),U&&P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Desktop-App"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",I]})]}),P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Server"}),P.jsxs("span",{className:"hub-version-modal-value",children:[P.jsx("span",{className:`hub-version-modal-dot ${i?"online":""}`}),i?"Verbunden":"Getrennt"]})]}),U&&P.jsxs("div",{className:"hub-version-modal-update",children:[j==="idle"&&P.jsxs("button",{className:"hub-version-modal-update-btn",onClick:()=>{z("checking"),W(""),window.electronAPI.checkForUpdates()},children:["🔄"," Nach Updates suchen"]}),j==="checking"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Suche nach Updates…"]}),j==="downloading"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Update wird heruntergeladen…"]}),j==="ready"&&P.jsxs("button",{className:"hub-version-modal-update-btn ready",onClick:()=>window.electronAPI.installUpdate(),children:["✅"," Jetzt installieren & neu starten"]}),j==="upToDate"&&P.jsxs("div",{className:"hub-version-modal-update-status success",children:["✅"," App ist aktuell",P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>z("idle"),children:"Erneut prüfen"})]}),j==="error"&&P.jsxs("div",{className:"hub-version-modal-update-status error",children:["❌"," ",G,P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>z("idle"),children:"Erneut versuchen"})]})]})]})]})}),S&&P.jsx("div",{className:"hub-admin-overlay",onClick:()=>w(!1),children:P.jsxs("div",{className:"hub-admin-modal",onClick:Q=>Q.stopPropagation(),children:[P.jsxs("div",{className:"hub-admin-modal-header",children:[P.jsxs("span",{children:["🔒"," Admin Login"]}),P.jsx("button",{className:"hub-admin-modal-close",onClick:()=>w(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-admin-modal-body",children:[P.jsx("input",{type:"password",className:"hub-admin-input",placeholder:"Admin-Passwort...",value:N,onChange:Q=>C(Q.target.value),onKeyDown:Q=>Q.key==="Enter"&&V(),autoFocus:!0}),E&&P.jsx("p",{className:"hub-admin-error",children:E}),P.jsx("button",{className:"hub-admin-submit",onClick:V,children:"Login"})]})]})}),P.jsx("main",{className:"hub-content",children:t.length===0?P.jsxs("div",{className:"hub-empty",children:[P.jsx("span",{className:"hub-empty-icon",children:"📦"}),P.jsx("h2",{children:"Keine Plugins geladen"}),P.jsx("p",{children:"Plugins werden im Server konfiguriert."})]}):t.map(Q=>{const K=M7[Q.name];if(!K)return null;const ae=r===Q.name;return P.jsx("div",{className:`hub-tab-panel ${ae?"active":""}`,style:ae?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{display:"none"},children:P.jsx(K,{data:h[Q.name]||{},isAdmin:v})},Q.name)})})]})}IF.createRoot(document.getElementById("root")).render(P.jsx(t0e,{})); diff --git a/web/dist/assets/index-Be3HasqO.js b/web/dist/assets/index-Be3HasqO.js deleted file mode 100644 index 5f9dac8..0000000 --- a/web/dist/assets/index-Be3HasqO.js +++ /dev/null @@ -1,4830 +0,0 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function S7(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var $b={exports:{}},$p={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var BC;function TF(){if(BC)return $p;BC=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,r,s){var a=null;if(s!==void 0&&(a=""+s),r.key!==void 0&&(a=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:i,type:n,key:a,ref:r!==void 0?r:null,props:s}}return $p.Fragment=e,$p.jsx=t,$p.jsxs=t,$p}var OC;function wF(){return OC||(OC=1,$b.exports=TF()),$b.exports}var k=wF(),Xb={exports:{}},Xp={},Yb={exports:{}},Qb={};/** - * @license React - * scheduler.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var IC;function MF(){return IC||(IC=1,(function(i){function e(Q,ae){var de=Q.length;Q.push(ae);e:for(;0>>1,be=Q[Te];if(0>>1;Ter(We,de))Ner(ze,We)?(Q[Te]=ze,Q[Ne]=de,Te=Ne):(Q[Te]=We,Q[we]=de,Te=we);else if(Ner(ze,de))Q[Te]=ze,Q[Ne]=de,Te=Ne;else break e}}return ae}function r(Q,ae){var de=Q.sortIndex-ae.sortIndex;return de!==0?de:Q.id-ae.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;i.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();i.unstable_now=function(){return a.now()-l}}var u=[],h=[],m=1,v=null,x=3,S=!1,w=!1,R=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function O(Q){for(var ae=t(h);ae!==null;){if(ae.callback===null)n(h);else if(ae.startTime<=Q)n(h),ae.sortIndex=ae.expirationTime,e(u,ae);else break;ae=t(h)}}function G(Q){if(R=!1,O(Q),!w)if(t(u)!==null)w=!0,q||(q=!0,ee());else{var ae=t(h);ae!==null&&ne(G,ae.startTime-Q)}}var q=!1,z=-1,j=5,F=-1;function V(){return C?!0:!(i.unstable_now()-FQ&&V());){var Te=v.callback;if(typeof Te=="function"){v.callback=null,x=v.priorityLevel;var be=Te(v.expirationTime<=Q);if(Q=i.unstable_now(),typeof be=="function"){v.callback=be,O(Q),ae=!0;break t}v===t(u)&&n(u),O(Q)}else n(u);v=t(u)}if(v!==null)ae=!0;else{var ue=t(h);ue!==null&&ne(G,ue.startTime-Q),ae=!1}}break e}finally{v=null,x=de,S=!1}ae=void 0}}finally{ae?ee():q=!1}}}var ee;if(typeof L=="function")ee=function(){L(Y)};else if(typeof MessageChannel<"u"){var te=new MessageChannel,re=te.port2;te.port1.onmessage=Y,ee=function(){re.postMessage(null)}}else ee=function(){E(Y,0)};function ne(Q,ae){z=E(function(){Q(i.unstable_now())},ae)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(Q){Q.callback=null},i.unstable_forceFrameRate=function(Q){0>Q||125Te?(Q.sortIndex=de,e(h,Q),t(u)===null&&Q===t(h)&&(R?(B(z),z=-1):R=!0,ne(G,de-Te))):(Q.sortIndex=be,e(u,Q),w||S||(w=!0,q||(q=!0,ee()))),Q},i.unstable_shouldYield=V,i.unstable_wrapCallback=function(Q){var ae=x;return function(){var de=x;x=ae;try{return Q.apply(this,arguments)}finally{x=de}}}})(Qb)),Qb}var FC;function EF(){return FC||(FC=1,Yb.exports=MF()),Yb.exports}var Kb={exports:{}},Jn={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var kC;function CF(){if(kC)return Jn;kC=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(ue){return ue===null||typeof ue!="object"?null:(ue=x&&ue[x]||ue["@@iterator"],typeof ue=="function"?ue:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,C={};function E(ue,we,We){this.props=ue,this.context=we,this.refs=C,this.updater=We||w}E.prototype.isReactComponent={},E.prototype.setState=function(ue,we){if(typeof ue!="object"&&typeof ue!="function"&&ue!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,ue,we,"setState")},E.prototype.forceUpdate=function(ue){this.updater.enqueueForceUpdate(this,ue,"forceUpdate")};function B(){}B.prototype=E.prototype;function L(ue,we,We){this.props=ue,this.context=we,this.refs=C,this.updater=We||w}var O=L.prototype=new B;O.constructor=L,R(O,E.prototype),O.isPureReactComponent=!0;var G=Array.isArray;function q(){}var z={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function F(ue,we,We){var Ne=We.ref;return{$$typeof:i,type:ue,key:we,ref:Ne!==void 0?Ne:null,props:We}}function V(ue,we){return F(ue.type,we,ue.props)}function Y(ue){return typeof ue=="object"&&ue!==null&&ue.$$typeof===i}function ee(ue){var we={"=":"=0",":":"=2"};return"$"+ue.replace(/[=:]/g,function(We){return we[We]})}var te=/\/+/g;function re(ue,we){return typeof ue=="object"&&ue!==null&&ue.key!=null?ee(""+ue.key):we.toString(36)}function ne(ue){switch(ue.status){case"fulfilled":return ue.value;case"rejected":throw ue.reason;default:switch(typeof ue.status=="string"?ue.then(q,q):(ue.status="pending",ue.then(function(we){ue.status==="pending"&&(ue.status="fulfilled",ue.value=we)},function(we){ue.status==="pending"&&(ue.status="rejected",ue.reason=we)})),ue.status){case"fulfilled":return ue.value;case"rejected":throw ue.reason}}throw ue}function Q(ue,we,We,Ne,ze){var Se=typeof ue;(Se==="undefined"||Se==="boolean")&&(ue=null);var Ce=!1;if(ue===null)Ce=!0;else switch(Se){case"bigint":case"string":case"number":Ce=!0;break;case"object":switch(ue.$$typeof){case i:case e:Ce=!0;break;case m:return Ce=ue._init,Q(Ce(ue._payload),we,We,Ne,ze)}}if(Ce)return ze=ze(ue),Ce=Ne===""?"."+re(ue,0):Ne,G(ze)?(We="",Ce!=null&&(We=Ce.replace(te,"$&/")+"/"),Q(ze,we,We,"",function(wt){return wt})):ze!=null&&(Y(ze)&&(ze=V(ze,We+(ze.key==null||ue&&ue.key===ze.key?"":(""+ze.key).replace(te,"$&/")+"/")+Ce)),we.push(ze)),1;Ce=0;var dt=Ne===""?".":Ne+":";if(G(ue))for(var At=0;At"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Zb.exports=RF(),Zb.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var VC;function DF(){if(VC)return Xp;VC=1;var i=EF(),e=_w(),t=NF();function n(o){var c="https://react.dev/errors/"+o;if(1be||(o.current=Te[be],Te[be]=null,be--)}function We(o,c){be++,Te[be]=o.current,o.current=c}var Ne=ue(null),ze=ue(null),Se=ue(null),Ce=ue(null);function dt(o,c){switch(We(Se,c),We(ze,o),We(Ne,null),c.nodeType){case 9:case 11:o=(o=c.documentElement)&&(o=o.namespaceURI)?rC(o):0;break;default:if(o=c.tagName,c=c.namespaceURI)c=rC(c),o=sC(c,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}we(Ne),We(Ne,o)}function At(){we(Ne),we(ze),we(Se)}function wt(o){o.memoizedState!==null&&We(Ce,o);var c=Ne.current,g=sC(c,o.type);c!==g&&(We(ze,o),We(Ne,g))}function Ft(o){ze.current===o&&(we(Ne),we(ze)),Ce.current===o&&(we(Ce),Vp._currentValue=de)}var $e,rt;function ce(o){if($e===void 0)try{throw Error()}catch(g){var c=g.stack.trim().match(/\n( *(at )?)/);$e=c&&c[1]||"",rt=-1)":-1D||De[b]!==Je[D]){var ft=` -`+De[b].replace(" at new "," at ");return o.displayName&&ft.includes("")&&(ft=ft.replace("",o.displayName)),ft}while(1<=b&&0<=D);break}}}finally{Gt=!1,Error.prepareStackTrace=g}return(g=o?o.displayName||o.name:"")?ce(g):""}function Pt(o,c){switch(o.tag){case 26:case 27:case 5:return ce(o.type);case 16:return ce("Lazy");case 13:return o.child!==c&&c!==null?ce("Suspense Fallback"):ce("Suspense");case 19:return ce("SuspenseList");case 0:case 15:return ht(o.type,!1);case 11:return ht(o.type.render,!1);case 1:return ht(o.type,!0);case 31:return ce("Activity");default:return""}}function yt(o){try{var c="",g=null;do c+=Pt(o,g),g=o,o=o.return;while(o);return c}catch(b){return` -Error generating stack: `+b.message+` -`+b.stack}}var en=Object.prototype.hasOwnProperty,xt=i.unstable_scheduleCallback,fe=i.unstable_cancelCallback,X=i.unstable_shouldYield,le=i.unstable_requestPaint,Re=i.unstable_now,pe=i.unstable_getCurrentPriorityLevel,Me=i.unstable_ImmediatePriority,nt=i.unstable_UserBlockingPriority,lt=i.unstable_NormalPriority,Ot=i.unstable_LowPriority,jt=i.unstable_IdlePriority,pt=i.log,Yt=i.unstable_setDisableYieldValue,rn=null,$t=null;function kt(o){if(typeof pt=="function"&&Yt(o),$t&&typeof $t.setStrictMode=="function")try{$t.setStrictMode(rn,o)}catch{}}var Vt=Math.clz32?Math.clz32:me,Nn=Math.log,_i=Math.LN2;function me(o){return o>>>=0,o===0?32:31-(Nn(o)/_i|0)|0}var bt=256,tt=262144,St=4194304;function qt(o){var c=o&42;if(c!==0)return c;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function Ht(o,c,g){var b=o.pendingLanes;if(b===0)return 0;var D=0,P=o.suspendedLanes,$=o.pingedLanes;o=o.warmLanes;var se=b&134217727;return se!==0?(b=se&~P,b!==0?D=qt(b):($&=se,$!==0?D=qt($):g||(g=se&~o,g!==0&&(D=qt(g))))):(se=b&~P,se!==0?D=qt(se):$!==0?D=qt($):g||(g=b&~o,g!==0&&(D=qt(g)))),D===0?0:c!==0&&c!==D&&(c&P)===0&&(P=D&-D,g=c&-c,P>=g||P===32&&(g&4194048)!==0)?c:D}function xn(o,c){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&c)===0}function qi(o,c){switch(o){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function rr(){var o=St;return St<<=1,(St&62914560)===0&&(St=4194304),o}function pn(o){for(var c=[],g=0;31>g;g++)c.push(o);return c}function $i(o,c){o.pendingLanes|=c,c!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function Jr(o,c,g,b,D,P){var $=o.pendingLanes;o.pendingLanes=g,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=g,o.entangledLanes&=g,o.errorRecoveryDisabledLanes&=g,o.shellSuspendCounter=0;var se=o.entanglements,De=o.expirationTimes,Je=o.hiddenUpdates;for(g=$&~g;0"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var ye=/[\n"\\]/g;function ot(o){return o.replace(ye,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Nt(o,c,g,b,D,P,$,se){o.name="",$!=null&&typeof $!="function"&&typeof $!="symbol"&&typeof $!="boolean"?o.type=$:o.removeAttribute("type"),c!=null?$==="number"?(c===0&&o.value===""||o.value!=c)&&(o.value=""+Un(c)):o.value!==""+Un(c)&&(o.value=""+Un(c)):$!=="submit"&&$!=="reset"||o.removeAttribute("value"),c!=null?cn(o,$,Un(c)):g!=null?cn(o,$,Un(g)):b!=null&&o.removeAttribute("value"),D==null&&P!=null&&(o.defaultChecked=!!P),D!=null&&(o.checked=D&&typeof D!="function"&&typeof D!="symbol"),se!=null&&typeof se!="function"&&typeof se!="symbol"&&typeof se!="boolean"?o.name=""+Un(se):o.removeAttribute("name")}function Jt(o,c,g,b,D,P,$,se){if(P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"&&(o.type=P),c!=null||g!=null){if(!(P!=="submit"&&P!=="reset"||c!=null)){hi(o);return}g=g!=null?""+Un(g):"",c=c!=null?""+Un(c):g,se||c===o.value||(o.value=c),o.defaultValue=c}b=b??D,b=typeof b!="function"&&typeof b!="symbol"&&!!b,o.checked=se?o.checked:!!b,o.defaultChecked=!!b,$!=null&&typeof $!="function"&&typeof $!="symbol"&&typeof $!="boolean"&&(o.name=$),hi(o)}function cn(o,c,g){c==="number"&&fa(o.ownerDocument)===o||o.defaultValue===""+g||(o.defaultValue=""+g)}function Yn(o,c,g,b){if(o=o.options,c){c={};for(var D=0;D"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),TA=!1;if(il)try{var tf={};Object.defineProperty(tf,"passive",{get:function(){TA=!0}}),window.addEventListener("test",tf,tf),window.removeEventListener("test",tf,tf)}catch{TA=!1}var Lo=null,nf=null,wA=null;function np(){if(wA)return wA;var o,c=nf,g=c.length,b,D="value"in Lo?Lo.value:Lo.textContent,P=D.length;for(o=0;o=of),Ou=" ",m1=!1;function RA(o,c){switch(o){case"keyup":return xx.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function op(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Qc=!1;function g1(o,c){switch(o){case"compositionend":return op(c);case"keypress":return c.which!==32?null:(m1=!0,Ou);case"textInput":return o=c.data,o===Ou&&m1?null:o;default:return null}}function bx(o,c){if(Qc)return o==="compositionend"||!Bu&&RA(o,c)?(o=np(),wA=nf=Lo=null,Qc=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:g,offset:c-o};o=b}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=PA(g)}}function zu(o,c){return o&&c?o===c?!0:o&&o.nodeType===3?!1:c&&c.nodeType===3?zu(o,c.parentNode):"contains"in o?o.contains(c):o.compareDocumentPosition?!!(o.compareDocumentPosition(c)&16):!1:!1}function Ol(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var c=fa(o.document);c instanceof o.HTMLIFrameElement;){try{var g=typeof c.contentWindow.location.href=="string"}catch{g=!1}if(g)o=c.contentWindow;else break;c=fa(o.document)}return c}function Il(o){var c=o&&o.nodeName&&o.nodeName.toLowerCase();return c&&(c==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||c==="textarea"||o.contentEditable==="true")}var wx=il&&"documentMode"in document&&11>=document.documentMode,Gu=null,fp=null,qu=null,Ap=!1;function S1(o,c,g){var b=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;Ap||Gu==null||Gu!==fa(b)||(b=Gu,"selectionStart"in b&&Il(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),qu&&Ss(qu,b)||(qu=b,b=r2(fp,"onSelect"),0>=$,D-=$,Na=1<<32-Vt(c)+D|g<oi?(Si=hn,hn=null):Si=hn.sibling;var Pi=et(Ve,hn,Ke[oi],Tt);if(Pi===null){hn===null&&(hn=Si);break}o&&hn&&Pi.alternate===null&&c(Ve,hn),Oe=P(Pi,Oe,oi),Di===null?Sn=Pi:Di.sibling=Pi,Di=Pi,hn=Si}if(oi===Ke.length)return g(Ve,hn),mi&&Oo(Ve,oi),Sn;if(hn===null){for(;oioi?(Si=hn,hn=null):Si=hn.sibling;var dh=et(Ve,hn,Pi.value,Tt);if(dh===null){hn===null&&(hn=Si);break}o&&hn&&dh.alternate===null&&c(Ve,hn),Oe=P(dh,Oe,oi),Di===null?Sn=dh:Di.sibling=dh,Di=dh,hn=Si}if(Pi.done)return g(Ve,hn),mi&&Oo(Ve,oi),Sn;if(hn===null){for(;!Pi.done;oi++,Pi=Ke.next())Pi=Et(Ve,Pi.value,Tt),Pi!==null&&(Oe=P(Pi,Oe,oi),Di===null?Sn=Pi:Di.sibling=Pi,Di=Pi);return mi&&Oo(Ve,oi),Sn}for(hn=b(hn);!Pi.done;oi++,Pi=Ke.next())Pi=it(hn,Ve,oi,Pi.value,Tt),Pi!==null&&(o&&Pi.alternate!==null&&hn.delete(Pi.key===null?oi:Pi.key),Oe=P(Pi,Oe,oi),Di===null?Sn=Pi:Di.sibling=Pi,Di=Pi);return o&&hn.forEach(function(SF){return c(Ve,SF)}),mi&&Oo(Ve,oi),Sn}function er(Ve,Oe,Ke,Tt){if(typeof Ke=="object"&&Ke!==null&&Ke.type===R&&Ke.key===null&&(Ke=Ke.props.children),typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case S:e:{for(var Sn=Ke.key;Oe!==null;){if(Oe.key===Sn){if(Sn=Ke.type,Sn===R){if(Oe.tag===7){g(Ve,Oe.sibling),Tt=D(Oe,Ke.props.children),Tt.return=Ve,Ve=Tt;break e}}else if(Oe.elementType===Sn||typeof Sn=="object"&&Sn!==null&&Sn.$$typeof===j&&f(Sn)===Oe.type){g(Ve,Oe.sibling),Tt=D(Oe,Ke.props),U(Tt,Ke),Tt.return=Ve,Ve=Tt;break e}g(Ve,Oe);break}else c(Ve,Oe);Oe=Oe.sibling}Ke.type===R?(Tt=$u(Ke.props.children,Ve.mode,Tt,Ke.key),Tt.return=Ve,Ve=Tt):(Tt=IA(Ke.type,Ke.key,Ke.props,null,Ve.mode,Tt),U(Tt,Ke),Tt.return=Ve,Ve=Tt)}return $(Ve);case w:e:{for(Sn=Ke.key;Oe!==null;){if(Oe.key===Sn)if(Oe.tag===4&&Oe.stateNode.containerInfo===Ke.containerInfo&&Oe.stateNode.implementation===Ke.implementation){g(Ve,Oe.sibling),Tt=D(Oe,Ke.children||[]),Tt.return=Ve,Ve=Tt;break e}else{g(Ve,Oe);break}else c(Ve,Oe);Oe=Oe.sibling}Tt=Bo(Ke,Ve.mode,Tt),Tt.return=Ve,Ve=Tt}return $(Ve);case j:return Ke=f(Ke),er(Ve,Oe,Ke,Tt)}if(ne(Ke))return ln(Ve,Oe,Ke,Tt);if(ee(Ke)){if(Sn=ee(Ke),typeof Sn!="function")throw Error(n(150));return Ke=Sn.call(Ke),Pn(Ve,Oe,Ke,Tt)}if(typeof Ke.then=="function")return er(Ve,Oe,N(Ke),Tt);if(Ke.$$typeof===L)return er(Ve,Oe,HA(Ve,Ke),Tt);I(Ve,Ke)}return typeof Ke=="string"&&Ke!==""||typeof Ke=="number"||typeof Ke=="bigint"?(Ke=""+Ke,Oe!==null&&Oe.tag===6?(g(Ve,Oe.sibling),Tt=D(Oe,Ke),Tt.return=Ve,Ve=Tt):(g(Ve,Oe),Tt=vp(Ke,Ve.mode,Tt),Tt.return=Ve,Ve=Tt),$(Ve)):g(Ve,Oe)}return function(Ve,Oe,Ke,Tt){try{M=0;var Sn=er(Ve,Oe,Ke,Tt);return T=null,Sn}catch(hn){if(hn===hl||hn===uo)throw hn;var Di=Ys(29,hn,null,Ve.mode);return Di.lanes=Tt,Di.return=Ve,Di}finally{}}}var ie=H(!0),ge=H(!1),Ae=!1;function ve(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pe(o,c){o=o.updateQueue,c.updateQueue===o&&(c.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function Ie(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function Ye(o,c,g){var b=o.updateQueue;if(b===null)return null;if(b=b.shared,(Oi&2)!==0){var D=b.pending;return D===null?c.next=c:(c.next=D.next,D.next=c),b.pending=c,c=OA(o),M1(o,null,g),c}return BA(o,b,c,g),OA(o)}function qe(o,c,g){if(c=c.updateQueue,c!==null&&(c=c.shared,(g&4194048)!==0)){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,vt(o,g)}}function Ge(o,c){var g=o.updateQueue,b=o.alternate;if(b!==null&&(b=b.updateQueue,g===b)){var D=null,P=null;if(g=g.firstBaseUpdate,g!==null){do{var $={lane:g.lane,tag:g.tag,payload:g.payload,callback:null,next:null};P===null?D=P=$:P=P.next=$,g=g.next}while(g!==null);P===null?D=P=c:P=P.next=c}else D=P=c;g={baseState:b.baseState,firstBaseUpdate:D,lastBaseUpdate:P,shared:b.shared,callbacks:b.callbacks},o.updateQueue=g;return}o=g.lastBaseUpdate,o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=c}var Le=!1;function Lt(){if(Le){var o=fr;if(o!==null)throw o}}function sn(o,c,g,b){Le=!1;var D=o.updateQueue;Ae=!1;var P=D.firstBaseUpdate,$=D.lastBaseUpdate,se=D.shared.pending;if(se!==null){D.shared.pending=null;var De=se,Je=De.next;De.next=null,$===null?P=Je:$.next=Je,$=De;var ft=o.alternate;ft!==null&&(ft=ft.updateQueue,se=ft.lastBaseUpdate,se!==$&&(se===null?ft.firstBaseUpdate=Je:se.next=Je,ft.lastBaseUpdate=De))}if(P!==null){var Et=D.baseState;$=0,ft=Je=De=null,se=P;do{var et=se.lane&-536870913,it=et!==se.lane;if(it?(bi&et)===et:(b&et)===et){et!==0&&et===eh&&(Le=!0),ft!==null&&(ft=ft.next={lane:0,tag:se.tag,payload:se.payload,callback:null,next:null});e:{var ln=o,Pn=se;et=c;var er=g;switch(Pn.tag){case 1:if(ln=Pn.payload,typeof ln=="function"){Et=ln.call(er,Et,et);break e}Et=ln;break e;case 3:ln.flags=ln.flags&-65537|128;case 0:if(ln=Pn.payload,et=typeof ln=="function"?ln.call(er,Et,et):ln,et==null)break e;Et=v({},Et,et);break e;case 2:Ae=!0}}et=se.callback,et!==null&&(o.flags|=64,it&&(o.flags|=8192),it=D.callbacks,it===null?D.callbacks=[et]:it.push(et))}else it={lane:et,tag:se.tag,payload:se.payload,callback:se.callback,next:null},ft===null?(Je=ft=it,De=Et):ft=ft.next=it,$|=et;if(se=se.next,se===null){if(se=D.shared.pending,se===null)break;it=se,se=it.next,it.next=null,D.lastBaseUpdate=it,D.shared.pending=null}}while(!0);ft===null&&(De=Et),D.baseState=De,D.firstBaseUpdate=Je,D.lastBaseUpdate=ft,P===null&&(D.shared.lanes=0),rh|=$,o.lanes=$,o.memoizedState=Et}}function tn(o,c){if(typeof o!="function")throw Error(n(191,o));o.call(c)}function Bn(o,c){var g=o.callbacks;if(g!==null)for(o.callbacks=null,o=0;oP?P:8;var $=Q.T,se={};Q.T=se,jx(o,!1,c,g);try{var De=D(),Je=Q.S;if(Je!==null&&Je(se,De),De!==null&&typeof De=="object"&&typeof De.then=="function"){var ft=N1(De,b);Mp(o,c,ft,Ao(o))}else Mp(o,c,b,Ao(o))}catch(Et){Mp(o,c,{then:function(){},status:"rejected",reason:Et},Ao())}finally{ae.p=P,$!==null&&se.types!==null&&($.types=se.types),Q.T=$}}function vI(){}function Vx(o,c,g,b){if(o.tag!==5)throw Error(n(476));var D=N4(o).queue;R4(o,D,c,de,g===null?vI:function(){return D4(o),g(b)})}function N4(o){var c=o.memoizedState;if(c!==null)return c;c={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nc,lastRenderedState:de},next:null};var g={};return c.next={memoizedState:g,baseState:g,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nc,lastRenderedState:g},next:null},o.memoizedState=c,o=o.alternate,o!==null&&(o.memoizedState=c),c}function D4(o){var c=N4(o);c.next===null&&(c=o.alternate.memoizedState),Mp(o,c.next.queue,{},Ao())}function Hx(){return As(Vp)}function P4(){return jr().memoizedState}function L4(){return jr().memoizedState}function _I(o){for(var c=o.return;c!==null;){switch(c.tag){case 24:case 3:var g=Ao();o=Ie(g);var b=Ye(c,o,g);b!==null&&(Ia(b,c,g),qe(b,c,g)),c={cache:Ur()},o.payload=c;return}c=c.return}}function yI(o,c,g){var b=Ao();g={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},k1(o)?B4(c,g):(g=gp(o,c,g,b),g!==null&&(Ia(g,o,b),O4(g,c,b)))}function U4(o,c,g){var b=Ao();Mp(o,c,g,b)}function Mp(o,c,g,b){var D={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null};if(k1(o))B4(c,D);else{var P=o.alternate;if(o.lanes===0&&(P===null||P.lanes===0)&&(P=c.lastRenderedReducer,P!==null))try{var $=c.lastRenderedState,se=P($,g);if(D.hasEagerState=!0,D.eagerState=se,Aa(se,$))return BA(o,c,D,0),or===null&&UA(),!1}catch{}finally{}if(g=gp(o,c,D,b),g!==null)return Ia(g,o,b),O4(g,c,b),!0}return!1}function jx(o,c,g,b){if(b={lane:2,revertLane:Sb(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},k1(o)){if(c)throw Error(n(479))}else c=gp(o,g,b,2),c!==null&&Ia(c,o,2)}function k1(o){var c=o.alternate;return o===ri||c!==null&&c===ri}function B4(o,c){jA=P1=!0;var g=o.pending;g===null?c.next=c:(c.next=g.next,g.next=c),o.pending=c}function O4(o,c,g){if((g&4194048)!==0){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,vt(o,g)}}var Ep={readContext:As,use:B1,useCallback:Br,useContext:Br,useEffect:Br,useImperativeHandle:Br,useLayoutEffect:Br,useInsertionEffect:Br,useMemo:Br,useReducer:Br,useRef:Br,useState:Br,useDebugValue:Br,useDeferredValue:Br,useTransition:Br,useSyncExternalStore:Br,useId:Br,useHostTransitionStatus:Br,useFormState:Br,useActionState:Br,useOptimistic:Br,useMemoCache:Br,useCacheRefresh:Br};Ep.useEffectEvent=Br;var I4={readContext:As,use:B1,useCallback:function(o,c){return ma().memoizedState=[o,c===void 0?null:c],o},useContext:As,useEffect:y4,useImperativeHandle:function(o,c,g){g=g!=null?g.concat([o]):null,I1(4194308,4,T4.bind(null,c,o),g)},useLayoutEffect:function(o,c){return I1(4194308,4,o,c)},useInsertionEffect:function(o,c){I1(4,2,o,c)},useMemo:function(o,c){var g=ma();c=c===void 0?null:c;var b=o();if(mf){kt(!0);try{o()}finally{kt(!1)}}return g.memoizedState=[b,c],b},useReducer:function(o,c,g){var b=ma();if(g!==void 0){var D=g(c);if(mf){kt(!0);try{g(c)}finally{kt(!1)}}}else D=c;return b.memoizedState=b.baseState=D,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:D},b.queue=o,o=o.dispatch=yI.bind(null,ri,o),[b.memoizedState,o]},useRef:function(o){var c=ma();return o={current:o},c.memoizedState=o},useState:function(o){o=Fx(o);var c=o.queue,g=U4.bind(null,ri,c);return c.dispatch=g,[o.memoizedState,g]},useDebugValue:Gx,useDeferredValue:function(o,c){var g=ma();return qx(g,o,c)},useTransition:function(){var o=Fx(!1);return o=R4.bind(null,ri,o.queue,!0,!1),ma().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,c,g){var b=ri,D=ma();if(mi){if(g===void 0)throw Error(n(407));g=g()}else{if(g=c(),or===null)throw Error(n(349));(bi&127)!==0||r4(b,c,g)}D.memoizedState=g;var P={value:g,getSnapshot:c};return D.queue=P,y4(a4.bind(null,b,P,o),[o]),b.flags|=2048,$A(9,{destroy:void 0},s4.bind(null,b,P,g,c),null),g},useId:function(){var o=ma(),c=or.identifierPrefix;if(mi){var g=Da,b=Na;g=(b&~(1<<32-Vt(b)-1)).toString(32)+g,c="_"+c+"R_"+g,g=L1++,0<\/script>",P=P.removeChild(P.firstChild);break;case"select":P=typeof b.is=="string"?$.createElement("select",{is:b.is}):$.createElement("select"),b.multiple?P.multiple=!0:b.size&&(P.size=b.size);break;default:P=typeof b.is=="string"?$.createElement(D,{is:b.is}):$.createElement(D)}}P[Xn]=c,P[un]=b;e:for($=c.child;$!==null;){if($.tag===5||$.tag===6)P.appendChild($.stateNode);else if($.tag!==4&&$.tag!==27&&$.child!==null){$.child.return=$,$=$.child;continue}if($===c)break e;for(;$.sibling===null;){if($.return===null||$.return===c)break e;$=$.return}$.sibling.return=$.return,$=$.sibling}c.stateNode=P;e:switch(Us(P,D,b),D){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&rc(c)}}return Ar(c),sb(c,c.type,o===null?null:o.memoizedProps,c.pendingProps,g),null;case 6:if(o&&c.stateNode!=null)o.memoizedProps!==b&&rc(c);else{if(typeof b!="string"&&c.stateNode===null)throw Error(n(166));if(o=Se.current,ar(c)){if(o=c.stateNode,g=c.memoizedProps,b=null,D=fs,D!==null)switch(D.tag){case 27:case 5:b=D.memoizedProps}o[Xn]=c,o=!!(o.nodeValue===g||b!==null&&b.suppressHydrationWarning===!0||nC(o.nodeValue,g)),o||zl(c,!0)}else o=s2(o).createTextNode(b),o[Xn]=c,c.stateNode=o}return Ar(c),null;case 31:if(g=c.memoizedState,o===null||o.memoizedState!==null){if(b=ar(c),g!==null){if(o===null){if(!b)throw Error(n(318));if(o=c.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(557));o[Xn]=c}else Yu(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Ar(c),o=!1}else g=Sp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=g),o=!0;if(!o)return c.flags&256?(co(c),c):(co(c),null);if((c.flags&128)!==0)throw Error(n(558))}return Ar(c),null;case 13:if(b=c.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(D=ar(c),b!==null&&b.dehydrated!==null){if(o===null){if(!D)throw Error(n(318));if(D=c.memoizedState,D=D!==null?D.dehydrated:null,!D)throw Error(n(317));D[Xn]=c}else Yu(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Ar(c),D=!1}else D=Sp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=D),D=!0;if(!D)return c.flags&256?(co(c),c):(co(c),null)}return co(c),(c.flags&128)!==0?(c.lanes=g,c):(g=b!==null,o=o!==null&&o.memoizedState!==null,g&&(b=c.child,D=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(D=b.alternate.memoizedState.cachePool.pool),P=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(P=b.memoizedState.cachePool.pool),P!==D&&(b.flags|=2048)),g!==o&&g&&(c.child.flags|=8192),H1(c,c.updateQueue),Ar(c),null);case 4:return At(),o===null&&Eb(c.stateNode.containerInfo),Ar(c),null;case 10:return Io(c.type),Ar(c),null;case 19:if(we(Hr),b=c.memoizedState,b===null)return Ar(c),null;if(D=(c.flags&128)!==0,P=b.rendering,P===null)if(D)Rp(b,!1);else{if(Or!==0||o!==null&&(o.flags&128)!==0)for(o=c.child;o!==null;){if(P=D1(o),P!==null){for(c.flags|=128,Rp(b,!1),o=P.updateQueue,c.updateQueue=o,H1(c,o),c.subtreeFlags=0,o=g,g=c.child;g!==null;)E1(g,o),g=g.sibling;return We(Hr,Hr.current&1|2),mi&&Oo(c,b.treeForkCount),c.child}o=o.sibling}b.tail!==null&&Re()>Y1&&(c.flags|=128,D=!0,Rp(b,!1),c.lanes=4194304)}else{if(!D)if(o=D1(P),o!==null){if(c.flags|=128,D=!0,o=o.updateQueue,c.updateQueue=o,H1(c,o),Rp(b,!0),b.tail===null&&b.tailMode==="hidden"&&!P.alternate&&!mi)return Ar(c),null}else 2*Re()-b.renderingStartTime>Y1&&g!==536870912&&(c.flags|=128,D=!0,Rp(b,!1),c.lanes=4194304);b.isBackwards?(P.sibling=c.child,c.child=P):(o=b.last,o!==null?o.sibling=P:c.child=P,b.last=P)}return b.tail!==null?(o=b.tail,b.rendering=o,b.tail=o.sibling,b.renderingStartTime=Re(),o.sibling=null,g=Hr.current,We(Hr,D?g&1|2:g&1),mi&&Oo(c,b.treeForkCount),o):(Ar(c),null);case 22:case 23:return co(c),Ut(),b=c.memoizedState!==null,o!==null?o.memoizedState!==null!==b&&(c.flags|=8192):b&&(c.flags|=8192),b?(g&536870912)!==0&&(c.flags&128)===0&&(Ar(c),c.subtreeFlags&6&&(c.flags|=8192)):Ar(c),g=c.updateQueue,g!==null&&H1(c,g.retryQueue),g=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),b=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(b=c.memoizedState.cachePool.pool),b!==g&&(c.flags|=2048),o!==null&&we(Dt),null;case 24:return g=null,o!==null&&(g=o.memoizedState.cache),c.memoizedState.cache!==g&&(c.flags|=2048),Io(Qt),Ar(c),null;case 25:return null;case 30:return null}throw Error(n(156,c.tag))}function wI(o,c){switch(_p(c),c.tag){case 1:return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 3:return Io(Qt),At(),o=c.flags,(o&65536)!==0&&(o&128)===0?(c.flags=o&-65537|128,c):null;case 26:case 27:case 5:return Ft(c),null;case 31:if(c.memoizedState!==null){if(co(c),c.alternate===null)throw Error(n(340));Yu()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 13:if(co(c),o=c.memoizedState,o!==null&&o.dehydrated!==null){if(c.alternate===null)throw Error(n(340));Yu()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 19:return we(Hr),null;case 4:return At(),null;case 10:return Io(c.type),null;case 22:case 23:return co(c),Ut(),o!==null&&we(Dt),o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 24:return Io(Qt),null;case 25:return null;default:return null}}function o8(o,c){switch(_p(c),c.tag){case 3:Io(Qt),At();break;case 26:case 27:case 5:Ft(c);break;case 4:At();break;case 31:c.memoizedState!==null&&co(c);break;case 13:co(c);break;case 19:we(Hr);break;case 10:Io(c.type);break;case 22:case 23:co(c),Ut(),o!==null&&we(Dt);break;case 24:Io(Qt)}}function Np(o,c){try{var g=c.updateQueue,b=g!==null?g.lastEffect:null;if(b!==null){var D=b.next;g=D;do{if((g.tag&o)===o){b=void 0;var P=g.create,$=g.inst;b=P(),$.destroy=b}g=g.next}while(g!==D)}}catch(se){Yi(c,c.return,se)}}function nh(o,c,g){try{var b=c.updateQueue,D=b!==null?b.lastEffect:null;if(D!==null){var P=D.next;b=P;do{if((b.tag&o)===o){var $=b.inst,se=$.destroy;if(se!==void 0){$.destroy=void 0,D=c;var De=g,Je=se;try{Je()}catch(ft){Yi(D,De,ft)}}}b=b.next}while(b!==P)}}catch(ft){Yi(c,c.return,ft)}}function l8(o){var c=o.updateQueue;if(c!==null){var g=o.stateNode;try{Bn(c,g)}catch(b){Yi(o,o.return,b)}}}function u8(o,c,g){g.props=gf(o.type,o.memoizedProps),g.state=o.memoizedState;try{g.componentWillUnmount()}catch(b){Yi(o,c,b)}}function Dp(o,c){try{var g=o.ref;if(g!==null){switch(o.tag){case 26:case 27:case 5:var b=o.stateNode;break;case 30:b=o.stateNode;break;default:b=o.stateNode}typeof g=="function"?o.refCleanup=g(b):g.current=b}}catch(D){Yi(o,c,D)}}function ql(o,c){var g=o.ref,b=o.refCleanup;if(g!==null)if(typeof b=="function")try{b()}catch(D){Yi(o,c,D)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof g=="function")try{g(null)}catch(D){Yi(o,c,D)}else g.current=null}function c8(o){var c=o.type,g=o.memoizedProps,b=o.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":g.autoFocus&&b.focus();break e;case"img":g.src?b.src=g.src:g.srcSet&&(b.srcset=g.srcSet)}}catch(D){Yi(o,o.return,D)}}function ab(o,c,g){try{var b=o.stateNode;$I(b,o.type,g,c),b[un]=c}catch(D){Yi(o,o.return,D)}}function h8(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&uh(o.type)||o.tag===4}function ob(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||h8(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&uh(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function lb(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?(g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g).insertBefore(o,c):(c=g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g,c.appendChild(o),g=g._reactRootContainer,g!=null||c.onclick!==null||(c.onclick=Po));else if(b!==4&&(b===27&&uh(o.type)&&(g=o.stateNode,c=null),o=o.child,o!==null))for(lb(o,c,g),o=o.sibling;o!==null;)lb(o,c,g),o=o.sibling}function j1(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?g.insertBefore(o,c):g.appendChild(o);else if(b!==4&&(b===27&&uh(o.type)&&(g=o.stateNode),o=o.child,o!==null))for(j1(o,c,g),o=o.sibling;o!==null;)j1(o,c,g),o=o.sibling}function f8(o){var c=o.stateNode,g=o.memoizedProps;try{for(var b=o.type,D=c.attributes;D.length;)c.removeAttributeNode(D[0]);Us(c,b,g),c[Xn]=o,c[un]=g}catch(P){Yi(o,o.return,P)}}var sc=!1,ns=!1,ub=!1,A8=typeof WeakSet=="function"?WeakSet:Set,Ms=null;function MI(o,c){if(o=o.containerInfo,Nb=f2,o=Ol(o),Il(o)){if("selectionStart"in o)var g={start:o.selectionStart,end:o.selectionEnd};else e:{g=(g=o.ownerDocument)&&g.defaultView||window;var b=g.getSelection&&g.getSelection();if(b&&b.rangeCount!==0){g=b.anchorNode;var D=b.anchorOffset,P=b.focusNode;b=b.focusOffset;try{g.nodeType,P.nodeType}catch{g=null;break e}var $=0,se=-1,De=-1,Je=0,ft=0,Et=o,et=null;t:for(;;){for(var it;Et!==g||D!==0&&Et.nodeType!==3||(se=$+D),Et!==P||b!==0&&Et.nodeType!==3||(De=$+b),Et.nodeType===3&&($+=Et.nodeValue.length),(it=Et.firstChild)!==null;)et=Et,Et=it;for(;;){if(Et===o)break t;if(et===g&&++Je===D&&(se=$),et===P&&++ft===b&&(De=$),(it=Et.nextSibling)!==null)break;Et=et,et=Et.parentNode}Et=it}g=se===-1||De===-1?null:{start:se,end:De}}else g=null}g=g||{start:0,end:0}}else g=null;for(Db={focusedElem:o,selectionRange:g},f2=!1,Ms=c;Ms!==null;)if(c=Ms,o=c.child,(c.subtreeFlags&1028)!==0&&o!==null)o.return=c,Ms=o;else for(;Ms!==null;){switch(c=Ms,P=c.alternate,o=c.flags,c.tag){case 0:if((o&4)!==0&&(o=c.updateQueue,o=o!==null?o.events:null,o!==null))for(g=0;g title"))),Us(P,b,g),P[Xn]=o,ke(P),b=P;break e;case"link":var $=_C("link","href",D).get(b+(g.href||""));if($){for(var se=0;se<$.length;se++)if(P=$[se],P.getAttribute("href")===(g.href==null||g.href===""?null:g.href)&&P.getAttribute("rel")===(g.rel==null?null:g.rel)&&P.getAttribute("title")===(g.title==null?null:g.title)&&P.getAttribute("crossorigin")===(g.crossOrigin==null?null:g.crossOrigin)){$.splice(se,1);break t}}P=D.createElement(b),Us(P,b,g),D.head.appendChild(P);break;case"meta":if($=_C("meta","content",D).get(b+(g.content||""))){for(se=0;se<$.length;se++)if(P=$[se],P.getAttribute("content")===(g.content==null?null:""+g.content)&&P.getAttribute("name")===(g.name==null?null:g.name)&&P.getAttribute("property")===(g.property==null?null:g.property)&&P.getAttribute("http-equiv")===(g.httpEquiv==null?null:g.httpEquiv)&&P.getAttribute("charset")===(g.charSet==null?null:g.charSet)){$.splice(se,1);break t}}P=D.createElement(b),Us(P,b,g),D.head.appendChild(P);break;default:throw Error(n(468,b))}P[Xn]=o,ke(P),b=P}o.stateNode=b}else yC(D,o.type,o.stateNode);else o.stateNode=vC(D,b,o.memoizedProps);else P!==b?(P===null?g.stateNode!==null&&(g=g.stateNode,g.parentNode.removeChild(g)):P.count--,b===null?yC(D,o.type,o.stateNode):vC(D,b,o.memoizedProps)):b===null&&o.stateNode!==null&&ab(o,o.memoizedProps,g.memoizedProps)}break;case 27:Ua(c,o),Ba(o),b&512&&(ns||g===null||ql(g,g.return)),g!==null&&b&4&&ab(o,o.memoizedProps,g.memoizedProps);break;case 5:if(Ua(c,o),Ba(o),b&512&&(ns||g===null||ql(g,g.return)),o.flags&32){D=o.stateNode;try{pi(D,"")}catch(ln){Yi(o,o.return,ln)}}b&4&&o.stateNode!=null&&(D=o.memoizedProps,ab(o,D,g!==null?g.memoizedProps:D)),b&1024&&(ub=!0);break;case 6:if(Ua(c,o),Ba(o),b&4){if(o.stateNode===null)throw Error(n(162));b=o.memoizedProps,g=o.stateNode;try{g.nodeValue=b}catch(ln){Yi(o,o.return,ln)}}break;case 3:if(l2=null,D=dl,dl=a2(c.containerInfo),Ua(c,o),dl=D,Ba(o),b&4&&g!==null&&g.memoizedState.isDehydrated)try{sd(c.containerInfo)}catch(ln){Yi(o,o.return,ln)}ub&&(ub=!1,y8(o));break;case 4:b=dl,dl=a2(o.stateNode.containerInfo),Ua(c,o),Ba(o),dl=b;break;case 12:Ua(c,o),Ba(o);break;case 31:Ua(c,o),Ba(o),b&4&&(b=o.updateQueue,b!==null&&(o.updateQueue=null,W1(o,b)));break;case 13:Ua(c,o),Ba(o),o.child.flags&8192&&o.memoizedState!==null!=(g!==null&&g.memoizedState!==null)&&(X1=Re()),b&4&&(b=o.updateQueue,b!==null&&(o.updateQueue=null,W1(o,b)));break;case 22:D=o.memoizedState!==null;var De=g!==null&&g.memoizedState!==null,Je=sc,ft=ns;if(sc=Je||D,ns=ft||De,Ua(c,o),ns=ft,sc=Je,Ba(o),b&8192)e:for(c=o.stateNode,c._visibility=D?c._visibility&-2:c._visibility|1,D&&(g===null||De||sc||ns||vf(o)),g=null,c=o;;){if(c.tag===5||c.tag===26){if(g===null){De=g=c;try{if(P=De.stateNode,D)$=P.style,typeof $.setProperty=="function"?$.setProperty("display","none","important"):$.display="none";else{se=De.stateNode;var Et=De.memoizedProps.style,et=Et!=null&&Et.hasOwnProperty("display")?Et.display:null;se.style.display=et==null||typeof et=="boolean"?"":(""+et).trim()}}catch(ln){Yi(De,De.return,ln)}}}else if(c.tag===6){if(g===null){De=c;try{De.stateNode.nodeValue=D?"":De.memoizedProps}catch(ln){Yi(De,De.return,ln)}}}else if(c.tag===18){if(g===null){De=c;try{var it=De.stateNode;D?uC(it,!0):uC(De.stateNode,!1)}catch(ln){Yi(De,De.return,ln)}}}else if((c.tag!==22&&c.tag!==23||c.memoizedState===null||c===o)&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===o)break e;for(;c.sibling===null;){if(c.return===null||c.return===o)break e;g===c&&(g=null),c=c.return}g===c&&(g=null),c.sibling.return=c.return,c=c.sibling}b&4&&(b=o.updateQueue,b!==null&&(g=b.retryQueue,g!==null&&(b.retryQueue=null,W1(o,g))));break;case 19:Ua(c,o),Ba(o),b&4&&(b=o.updateQueue,b!==null&&(o.updateQueue=null,W1(o,b)));break;case 30:break;case 21:break;default:Ua(c,o),Ba(o)}}function Ba(o){var c=o.flags;if(c&2){try{for(var g,b=o.return;b!==null;){if(h8(b)){g=b;break}b=b.return}if(g==null)throw Error(n(160));switch(g.tag){case 27:var D=g.stateNode,P=ob(o);j1(o,P,D);break;case 5:var $=g.stateNode;g.flags&32&&(pi($,""),g.flags&=-33);var se=ob(o);j1(o,se,$);break;case 3:case 4:var De=g.stateNode.containerInfo,Je=ob(o);lb(o,Je,De);break;default:throw Error(n(161))}}catch(ft){Yi(o,o.return,ft)}o.flags&=-3}c&4096&&(o.flags&=-4097)}function y8(o){if(o.subtreeFlags&1024)for(o=o.child;o!==null;){var c=o;y8(c),c.tag===5&&c.flags&1024&&c.stateNode.reset(),o=o.sibling}}function oc(o,c){if(c.subtreeFlags&8772)for(c=c.child;c!==null;)d8(o,c.alternate,c),c=c.sibling}function vf(o){for(o=o.child;o!==null;){var c=o;switch(c.tag){case 0:case 11:case 14:case 15:nh(4,c,c.return),vf(c);break;case 1:ql(c,c.return);var g=c.stateNode;typeof g.componentWillUnmount=="function"&&u8(c,c.return,g),vf(c);break;case 27:zp(c.stateNode);case 26:case 5:ql(c,c.return),vf(c);break;case 22:c.memoizedState===null&&vf(c);break;case 30:vf(c);break;default:vf(c)}o=o.sibling}}function lc(o,c,g){for(g=g&&(c.subtreeFlags&8772)!==0,c=c.child;c!==null;){var b=c.alternate,D=o,P=c,$=P.flags;switch(P.tag){case 0:case 11:case 15:lc(D,P,g),Np(4,P);break;case 1:if(lc(D,P,g),b=P,D=b.stateNode,typeof D.componentDidMount=="function")try{D.componentDidMount()}catch(Je){Yi(b,b.return,Je)}if(b=P,D=b.updateQueue,D!==null){var se=b.stateNode;try{var De=D.shared.hiddenCallbacks;if(De!==null)for(D.shared.hiddenCallbacks=null,D=0;Der&&($=er,er=Pn,Pn=$);var Ve=LA(se,Pn),Oe=LA(se,er);if(Ve&&Oe&&(it.rangeCount!==1||it.anchorNode!==Ve.node||it.anchorOffset!==Ve.offset||it.focusNode!==Oe.node||it.focusOffset!==Oe.offset)){var Ke=Et.createRange();Ke.setStart(Ve.node,Ve.offset),it.removeAllRanges(),Pn>er?(it.addRange(Ke),it.extend(Oe.node,Oe.offset)):(Ke.setEnd(Oe.node,Oe.offset),it.addRange(Ke))}}}}for(Et=[],it=se;it=it.parentNode;)it.nodeType===1&&Et.push({element:it,left:it.scrollLeft,top:it.scrollTop});for(typeof se.focus=="function"&&se.focus(),se=0;seg?32:g,Q.T=null,g=mb,mb=null;var P=ah,$=cc;if(ds=0,ZA=ah=null,cc=0,(Oi&6)!==0)throw Error(n(331));var se=Oi;if(Oi|=4,T8(P.current),x8(P,P.current,$,g),Oi=se,Ip(0,!1),$t&&typeof $t.onPostCommitFiberRoot=="function")try{$t.onPostCommitFiberRoot(rn,P)}catch{}return!0}finally{ae.p=D,Q.T=b,q8(o,c)}}function H8(o,c,g){c=Ca(g,c),c=Yx(o.stateNode,c,2),o=Ye(o,c,2),o!==null&&($i(o,2),Vl(o))}function Yi(o,c,g){if(o.tag===3)H8(o,o,g);else for(;c!==null;){if(c.tag===3){H8(c,o,g);break}else if(c.tag===1){var b=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(sh===null||!sh.has(b))){o=Ca(g,o),g=j4(2),b=Ye(c,g,2),b!==null&&(W4(g,b,c,o),$i(b,2),Vl(b));break}}c=c.return}}function yb(o,c,g){var b=o.pingCache;if(b===null){b=o.pingCache=new RI;var D=new Set;b.set(c,D)}else D=b.get(c),D===void 0&&(D=new Set,b.set(c,D));D.has(g)||(fb=!0,D.add(g),o=UI.bind(null,o,c,g),c.then(o,o))}function UI(o,c,g){var b=o.pingCache;b!==null&&b.delete(c),o.pingedLanes|=o.suspendedLanes&g,o.warmLanes&=~g,or===o&&(bi&g)===g&&(Or===4||Or===3&&(bi&62914560)===bi&&300>Re()-X1?(Oi&2)===0&&JA(o,0):Ab|=g,KA===bi&&(KA=0)),Vl(o)}function j8(o,c){c===0&&(c=rr()),o=ju(o,c),o!==null&&($i(o,c),Vl(o))}function BI(o){var c=o.memoizedState,g=0;c!==null&&(g=c.retryLane),j8(o,g)}function OI(o,c){var g=0;switch(o.tag){case 31:case 13:var b=o.stateNode,D=o.memoizedState;D!==null&&(g=D.retryLane);break;case 19:b=o.stateNode;break;case 22:b=o.stateNode._retryCache;break;default:throw Error(n(314))}b!==null&&b.delete(c),j8(o,g)}function II(o,c){return xt(o,c)}var t2=null,td=null,xb=!1,n2=!1,bb=!1,lh=0;function Vl(o){o!==td&&o.next===null&&(td===null?t2=td=o:td=td.next=o),n2=!0,xb||(xb=!0,kI())}function Ip(o,c){if(!bb&&n2){bb=!0;do for(var g=!1,b=t2;b!==null;){if(o!==0){var D=b.pendingLanes;if(D===0)var P=0;else{var $=b.suspendedLanes,se=b.pingedLanes;P=(1<<31-Vt(42|o)+1)-1,P&=D&~($&~se),P=P&201326741?P&201326741|1:P?P|2:0}P!==0&&(g=!0,Y8(b,P))}else P=bi,P=Ht(b,b===or?P:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(P&3)===0||xn(b,P)||(g=!0,Y8(b,P));b=b.next}while(g);bb=!1}}function FI(){W8()}function W8(){n2=xb=!1;var o=0;lh!==0&&YI()&&(o=lh);for(var c=Re(),g=null,b=t2;b!==null;){var D=b.next,P=$8(b,c);P===0?(b.next=null,g===null?t2=D:g.next=D,D===null&&(td=g)):(g=b,(o!==0||(P&3)!==0)&&(n2=!0)),b=D}ds!==0&&ds!==5||Ip(o),lh!==0&&(lh=0)}function $8(o,c){for(var g=o.suspendedLanes,b=o.pingedLanes,D=o.expirationTimes,P=o.pendingLanes&-62914561;0se)break;var ft=De.transferSize,Et=De.initiatorType;ft&&iC(Et)&&(De=De.responseEnd,$+=ft*(De"u"?null:document;function pC(o,c,g){var b=nd;if(b&&typeof c=="string"&&c){var D=ot(c);D='link[rel="'+o+'"][href="'+D+'"]',typeof g=="string"&&(D+='[crossorigin="'+g+'"]'),dC.has(D)||(dC.add(D),o={rel:o,crossOrigin:g,href:c},b.querySelector(D)===null&&(c=b.createElement("link"),Us(c,"link",o),ke(c),b.head.appendChild(c)))}}function rF(o){hc.D(o),pC("dns-prefetch",o,null)}function sF(o,c){hc.C(o,c),pC("preconnect",o,c)}function aF(o,c,g){hc.L(o,c,g);var b=nd;if(b&&o&&c){var D='link[rel="preload"][as="'+ot(c)+'"]';c==="image"&&g&&g.imageSrcSet?(D+='[imagesrcset="'+ot(g.imageSrcSet)+'"]',typeof g.imageSizes=="string"&&(D+='[imagesizes="'+ot(g.imageSizes)+'"]')):D+='[href="'+ot(o)+'"]';var P=D;switch(c){case"style":P=id(o);break;case"script":P=rd(o)}Go.has(P)||(o=v({rel:"preload",href:c==="image"&&g&&g.imageSrcSet?void 0:o,as:c},g),Go.set(P,o),b.querySelector(D)!==null||c==="style"&&b.querySelector(Gp(P))||c==="script"&&b.querySelector(qp(P))||(c=b.createElement("link"),Us(c,"link",o),ke(c),b.head.appendChild(c)))}}function oF(o,c){hc.m(o,c);var g=nd;if(g&&o){var b=c&&typeof c.as=="string"?c.as:"script",D='link[rel="modulepreload"][as="'+ot(b)+'"][href="'+ot(o)+'"]',P=D;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":P=rd(o)}if(!Go.has(P)&&(o=v({rel:"modulepreload",href:o},c),Go.set(P,o),g.querySelector(D)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(g.querySelector(qp(P)))return}b=g.createElement("link"),Us(b,"link",o),ke(b),g.head.appendChild(b)}}}function lF(o,c,g){hc.S(o,c,g);var b=nd;if(b&&o){var D=Xe(b).hoistableStyles,P=id(o);c=c||"default";var $=D.get(P);if(!$){var se={loading:0,preload:null};if($=b.querySelector(Gp(P)))se.loading=5;else{o=v({rel:"stylesheet",href:o,"data-precedence":c},g),(g=Go.get(P))&&Fb(o,g);var De=$=b.createElement("link");ke(De),Us(De,"link",o),De._p=new Promise(function(Je,ft){De.onload=Je,De.onerror=ft}),De.addEventListener("load",function(){se.loading|=1}),De.addEventListener("error",function(){se.loading|=2}),se.loading|=4,o2($,c,b)}$={type:"stylesheet",instance:$,count:1,state:se},D.set(P,$)}}}function uF(o,c){hc.X(o,c);var g=nd;if(g&&o){var b=Xe(g).hoistableScripts,D=rd(o),P=b.get(D);P||(P=g.querySelector(qp(D)),P||(o=v({src:o,async:!0},c),(c=Go.get(D))&&kb(o,c),P=g.createElement("script"),ke(P),Us(P,"link",o),g.head.appendChild(P)),P={type:"script",instance:P,count:1,state:null},b.set(D,P))}}function cF(o,c){hc.M(o,c);var g=nd;if(g&&o){var b=Xe(g).hoistableScripts,D=rd(o),P=b.get(D);P||(P=g.querySelector(qp(D)),P||(o=v({src:o,async:!0,type:"module"},c),(c=Go.get(D))&&kb(o,c),P=g.createElement("script"),ke(P),Us(P,"link",o),g.head.appendChild(P)),P={type:"script",instance:P,count:1,state:null},b.set(D,P))}}function mC(o,c,g,b){var D=(D=Se.current)?a2(D):null;if(!D)throw Error(n(446));switch(o){case"meta":case"title":return null;case"style":return typeof g.precedence=="string"&&typeof g.href=="string"?(c=id(g.href),g=Xe(D).hoistableStyles,b=g.get(c),b||(b={type:"style",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(g.rel==="stylesheet"&&typeof g.href=="string"&&typeof g.precedence=="string"){o=id(g.href);var P=Xe(D).hoistableStyles,$=P.get(o);if($||(D=D.ownerDocument||D,$={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},P.set(o,$),(P=D.querySelector(Gp(o)))&&!P._p&&($.instance=P,$.state.loading=5),Go.has(o)||(g={rel:"preload",as:"style",href:g.href,crossOrigin:g.crossOrigin,integrity:g.integrity,media:g.media,hrefLang:g.hrefLang,referrerPolicy:g.referrerPolicy},Go.set(o,g),P||hF(D,o,g,$.state))),c&&b===null)throw Error(n(528,""));return $}if(c&&b!==null)throw Error(n(529,""));return null;case"script":return c=g.async,g=g.src,typeof g=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=rd(g),g=Xe(D).hoistableScripts,b=g.get(c),b||(b={type:"script",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,o))}}function id(o){return'href="'+ot(o)+'"'}function Gp(o){return'link[rel="stylesheet"]['+o+"]"}function gC(o){return v({},o,{"data-precedence":o.precedence,precedence:null})}function hF(o,c,g,b){o.querySelector('link[rel="preload"][as="style"]['+c+"]")?b.loading=1:(c=o.createElement("link"),b.preload=c,c.addEventListener("load",function(){return b.loading|=1}),c.addEventListener("error",function(){return b.loading|=2}),Us(c,"link",g),ke(c),o.head.appendChild(c))}function rd(o){return'[src="'+ot(o)+'"]'}function qp(o){return"script[async]"+o}function vC(o,c,g){if(c.count++,c.instance===null)switch(c.type){case"style":var b=o.querySelector('style[data-href~="'+ot(g.href)+'"]');if(b)return c.instance=b,ke(b),b;var D=v({},g,{"data-href":g.href,"data-precedence":g.precedence,href:null,precedence:null});return b=(o.ownerDocument||o).createElement("style"),ke(b),Us(b,"style",D),o2(b,g.precedence,o),c.instance=b;case"stylesheet":D=id(g.href);var P=o.querySelector(Gp(D));if(P)return c.state.loading|=4,c.instance=P,ke(P),P;b=gC(g),(D=Go.get(D))&&Fb(b,D),P=(o.ownerDocument||o).createElement("link"),ke(P);var $=P;return $._p=new Promise(function(se,De){$.onload=se,$.onerror=De}),Us(P,"link",b),c.state.loading|=4,o2(P,g.precedence,o),c.instance=P;case"script":return P=rd(g.src),(D=o.querySelector(qp(P)))?(c.instance=D,ke(D),D):(b=g,(D=Go.get(P))&&(b=v({},g),kb(b,D)),o=o.ownerDocument||o,D=o.createElement("script"),ke(D),Us(D,"link",b),o.head.appendChild(D),c.instance=D);case"void":return null;default:throw Error(n(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(b=c.instance,c.state.loading|=4,o2(b,g.precedence,o));return c.instance}function o2(o,c,g){for(var b=g.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),D=b.length?b[b.length-1]:null,P=D,$=0;$ title"):null)}function fF(o,c,g){if(g===1||c.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;switch(c.rel){case"stylesheet":return o=c.disabled,typeof c.precedence=="string"&&o==null;default:return!0}case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function xC(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function AF(o,c,g,b){if(g.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(g.state.loading&4)===0){if(g.instance===null){var D=id(b.href),P=c.querySelector(Gp(D));if(P){c=P._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(o.count++,o=u2.bind(o),c.then(o,o)),g.state.loading|=4,g.instance=P,ke(P);return}P=c.ownerDocument||c,b=gC(b),(D=Go.get(D))&&Fb(b,D),P=P.createElement("link"),ke(P);var $=P;$._p=new Promise(function(se,De){$.onload=se,$.onerror=De}),Us(P,"link",b),g.instance=P}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(g,c),(c=g.state.preload)&&(g.state.loading&3)===0&&(o.count++,g=u2.bind(o),c.addEventListener("load",g),c.addEventListener("error",g))}}var zb=0;function dF(o,c){return o.stylesheets&&o.count===0&&h2(o,o.stylesheets),0zb?50:800)+c);return o.unsuspend=g,function(){o.unsuspend=null,clearTimeout(b),clearTimeout(D)}}:null}function u2(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)h2(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var c2=null;function h2(o,c){o.stylesheets=null,o.unsuspend!==null&&(o.count++,c2=new Map,c.forEach(pF,o),c2=null,u2.call(o))}function pF(o,c){if(!(c.state.loading&4)){var g=c2.get(o);if(g)var b=g.get(null);else{g=new Map,c2.set(o,g);for(var D=o.querySelectorAll("link[data-precedence],style[data-precedence]"),P=0;P"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Xb.exports=DF(),Xb.exports}var LF=PF(),xe=_w();const UF=S7(xe);/** - * @license - * Copyright 2010-2024 Three.js Authors - * SPDX-License-Identifier: MIT - */const V0="172",Xo={ROTATE:0,DOLLY:1,PAN:2},Gd={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},T7=0,VS=1,w7=2,BF=0,yw=1,OF=2,xo=3,Nl=0,hr=1,as=2,Qa=0,Ka=1,a0=2,o0=3,l0=4,xw=5,Eo=100,bw=101,Sw=102,M7=103,E7=104,Tw=200,ww=201,Mw=202,Ew=203,qm=204,Vm=205,Cw=206,Rw=207,Nw=208,Dw=209,Pw=210,IF=211,FF=212,kF=213,zF=214,Hm=0,jm=1,Wm=2,kh=3,$m=4,Xm=5,Ym=6,Qm=7,Lg=0,C7=1,R7=2,Za=0,N7=1,D7=2,P7=3,L7=4,GF=5,U7=6,B7=7,Lw=300,Qo=301,Ko=302,zh=303,Gh=304,sA=306,aA=1e3,eu=1001,oA=1002,mr=1003,s_=1004,tu=1005,gs=1006,Jd=1007,Va=1008,qF=1008,aa=1009,Qf=1010,Kf=1011,wl=1012,Ns=1013,Rr=1014,$r=1015,Gs=1016,Ay=1017,dy=1018,Au=1020,py=35902,Uw=1021,Ug=1022,ks=1023,Bw=1024,Ow=1025,au=1026,du=1027,Bg=1028,H0=1029,lA=1030,j0=1031,VF=1032,W0=1033,Zf=33776,Bh=33777,Oh=33778,Ih=33779,Km=35840,Zm=35841,Jm=35842,eg=35843,tg=36196,u0=37492,c0=37496,h0=37808,f0=37809,A0=37810,d0=37811,p0=37812,m0=37813,g0=37814,v0=37815,_0=37816,y0=37817,x0=37818,b0=37819,S0=37820,T0=37821,Jf=36492,HS=36494,jS=36495,Iw=36283,ng=36284,ig=36285,rg=36286,HF=0,jF=1,jC=2,WF=3200,$F=3201,Dc=0,O7=1,Co="",_n="srgb",Ro="srgb-linear",a_="linear",Vi="srgb",XF=0,Uf=7680,YF=7681,QF=7682,KF=7683,ZF=34055,JF=34056,ek=5386,tk=512,nk=513,ik=514,rk=515,sk=516,ak=517,ok=518,WS=519,Fw=512,my=513,kw=514,gy=515,zw=516,Gw=517,qw=518,Vw=519,o_=35044,qd=35048,WC="300 es",Ha=2e3,pu=2001;class zc{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s>8&255]+Js[i>>16&255]+Js[i>>24&255]+"-"+Js[e&255]+Js[e>>8&255]+"-"+Js[e>>16&15|64]+Js[e>>24&255]+"-"+Js[t&63|128]+Js[t>>8&255]+"-"+Js[t>>16&255]+Js[t>>24&255]+Js[n&255]+Js[n>>8&255]+Js[n>>16&255]+Js[n>>24&255]).toLowerCase()}function ni(i,e,t){return Math.max(e,Math.min(t,i))}function Hw(i,e){return(i%e+e)%e}function lk(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function uk(i,e,t){return i!==e?(t-i)/(e-i):0}function Cm(i,e,t){return(1-t)*i+t*e}function ck(i,e,t,n){return Cm(i,e,1-Math.exp(-t*n))}function hk(i,e=1){return e-Math.abs(Hw(i,e*2)-e)}function fk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Ak(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function dk(i,e){return i+Math.floor(Math.random()*(e-i+1))}function pk(i,e){return i+Math.random()*(e-i)}function mk(i){return i*(.5-Math.random())}function gk(i){i!==void 0&&($C=i);let e=$C+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function vk(i){return i*Em}function _k(i){return i*w0}function yk(i){return(i&i-1)===0&&i!==0}function xk(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function bk(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Sk(i,e,t,n,r){const s=Math.cos,a=Math.sin,l=s(t/2),u=a(t/2),h=s((e+n)/2),m=a((e+n)/2),v=s((e-n)/2),x=a((e-n)/2),S=s((n-e)/2),w=a((n-e)/2);switch(r){case"XYX":i.set(l*m,u*v,u*x,l*h);break;case"YZY":i.set(u*x,l*m,u*v,l*h);break;case"ZXZ":i.set(u*v,u*x,l*m,l*h);break;case"XZX":i.set(l*m,u*w,u*S,l*h);break;case"YXY":i.set(u*S,l*m,u*w,l*h);break;case"ZYZ":i.set(u*w,u*S,l*m,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ta(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function si(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const M0={DEG2RAD:Em,RAD2DEG:w0,generateUUID:ou,clamp:ni,euclideanModulo:Hw,mapLinear:lk,inverseLerp:uk,lerp:Cm,damp:ck,pingpong:hk,smoothstep:fk,smootherstep:Ak,randInt:dk,randFloat:pk,randFloatSpread:mk,seededRandom:gk,degToRad:vk,radToDeg:_k,isPowerOfTwo:yk,ceilPowerOfTwo:xk,floorPowerOfTwo:bk,setQuaternionFromProperEuler:Sk,normalize:si,denormalize:Ta};class gt{constructor(e=0,t=0){gt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ni(this.x,e.x,t.x),this.y=ni(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ni(this.x,e,t),this.y=ni(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ni(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ni(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Vn{constructor(e,t,n,r,s,a,l,u,h){Vn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h)}set(e,t,n,r,s,a,l,u,h){const m=this.elements;return m[0]=e,m[1]=r,m[2]=l,m[3]=t,m[4]=s,m[5]=u,m[6]=n,m[7]=a,m[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[3],u=n[6],h=n[1],m=n[4],v=n[7],x=n[2],S=n[5],w=n[8],R=r[0],C=r[3],E=r[6],B=r[1],L=r[4],O=r[7],G=r[2],q=r[5],z=r[8];return s[0]=a*R+l*B+u*G,s[3]=a*C+l*L+u*q,s[6]=a*E+l*O+u*z,s[1]=h*R+m*B+v*G,s[4]=h*C+m*L+v*q,s[7]=h*E+m*O+v*z,s[2]=x*R+S*B+w*G,s[5]=x*C+S*L+w*q,s[8]=x*E+S*O+w*z,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8];return t*a*m-t*l*h-n*s*m+n*l*u+r*s*h-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=m*a-l*h,x=l*u-m*s,S=h*s-a*u,w=t*v+n*x+r*S;if(w===0)return this.set(0,0,0,0,0,0,0,0,0);const R=1/w;return e[0]=v*R,e[1]=(r*h-m*n)*R,e[2]=(l*n-r*a)*R,e[3]=x*R,e[4]=(m*t-r*u)*R,e[5]=(r*s-l*t)*R,e[6]=S*R,e[7]=(n*u-h*t)*R,e[8]=(a*t-n*s)*R,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,l){const u=Math.cos(s),h=Math.sin(s);return this.set(n*u,n*h,-n*(u*a+h*l)+a+e,-r*h,r*u,-r*(-h*a+u*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(Jb.makeScale(e,t)),this}rotate(e){return this.premultiply(Jb.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jb.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Jb=new Vn;function I7(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function sg(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function F7(){const i=sg("canvas");return i.style.display="block",i}const XC={};function kf(i){i in XC||(XC[i]=!0,console.warn(i))}function Tk(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function wk(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Mk(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const YC=new Vn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),QC=new Vn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Ek(){const i={enabled:!0,workingColorSpace:Ro,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Vi&&(r.r=Mc(r.r),r.g=Mc(r.g),r.b=Mc(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Vi&&(r.r=e0(r.r),r.g=e0(r.g),r.b=e0(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Co?a_:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Ro]:{primaries:e,whitePoint:n,transfer:a_,toXYZ:YC,fromXYZ:QC,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:_n},outputColorSpaceConfig:{drawingBufferColorSpace:_n}},[_n]:{primaries:e,whitePoint:n,transfer:Vi,toXYZ:YC,fromXYZ:QC,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:_n}}}),i}const ai=Ek();function Mc(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function e0(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ad;class Ck{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{ad===void 0&&(ad=sg("canvas")),ad.width=e.width,ad.height=e.height;const n=ad.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=ad}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=sg("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Lw)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case aA:e.x=e.x-Math.floor(e.x);break;case eu:e.x=e.x<0?0:1;break;case oA:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case aA:e.y=e.y-Math.floor(e.y);break;case eu:e.y=e.y<0?0:1;break;case oA:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}vs.DEFAULT_IMAGE=null;vs.DEFAULT_MAPPING=Lw;vs.DEFAULT_ANISOTROPY=1;class Ln{constructor(e=0,t=0,n=0,r=1){Ln.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const u=e.elements,h=u[0],m=u[4],v=u[8],x=u[1],S=u[5],w=u[9],R=u[2],C=u[6],E=u[10];if(Math.abs(m-x)<.01&&Math.abs(v-R)<.01&&Math.abs(w-C)<.01){if(Math.abs(m+x)<.1&&Math.abs(v+R)<.1&&Math.abs(w+C)<.1&&Math.abs(h+S+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const L=(h+1)/2,O=(S+1)/2,G=(E+1)/2,q=(m+x)/4,z=(v+R)/4,j=(w+C)/4;return L>O&&L>G?L<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(L),r=q/n,s=z/n):O>G?O<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(O),n=q/r,s=j/r):G<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(G),n=z/s,r=j/s),this.set(n,r,s,t),this}let B=Math.sqrt((C-w)*(C-w)+(v-R)*(v-R)+(x-m)*(x-m));return Math.abs(B)<.001&&(B=1),this.x=(C-w)/B,this.y=(v-R)/B,this.z=(x-m)/B,this.w=Math.acos((h+S+E-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ni(this.x,e.x,t.x),this.y=ni(this.y,e.y,t.y),this.z=ni(this.z,e.z,t.z),this.w=ni(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ni(this.x,e,t),this.y=ni(this.y,e,t),this.z=ni(this.z,e,t),this.w=ni(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ni(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Wh extends zc{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ln(0,0,e,t),this.scissorTest=!1,this.viewport=new Ln(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:gs,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new vs(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let l=0;l=0?1:-1,L=1-E*E;if(L>Number.EPSILON){const G=Math.sqrt(L),q=Math.atan2(G,E*B);C=Math.sin(C*q)/G,l=Math.sin(l*q)/G}const O=l*B;if(u=u*C+x*O,h=h*C+S*O,m=m*C+w*O,v=v*C+R*O,C===1-l){const G=1/Math.sqrt(u*u+h*h+m*m+v*v);u*=G,h*=G,m*=G,v*=G}}e[t]=u,e[t+1]=h,e[t+2]=m,e[t+3]=v}static multiplyQuaternionsFlat(e,t,n,r,s,a){const l=n[r],u=n[r+1],h=n[r+2],m=n[r+3],v=s[a],x=s[a+1],S=s[a+2],w=s[a+3];return e[t]=l*w+m*v+u*S-h*x,e[t+1]=u*w+m*x+h*v-l*S,e[t+2]=h*w+m*S+l*x-u*v,e[t+3]=m*w-l*v-u*x-h*S,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,l=Math.cos,u=Math.sin,h=l(n/2),m=l(r/2),v=l(s/2),x=u(n/2),S=u(r/2),w=u(s/2);switch(a){case"XYZ":this._x=x*m*v+h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v-x*S*w;break;case"YXZ":this._x=x*m*v+h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v+x*S*w;break;case"ZXY":this._x=x*m*v-h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v-x*S*w;break;case"ZYX":this._x=x*m*v-h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v+x*S*w;break;case"YZX":this._x=x*m*v+h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v-x*S*w;break;case"XZY":this._x=x*m*v-h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v+x*S*w;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],l=t[5],u=t[9],h=t[2],m=t[6],v=t[10],x=n+l+v;if(x>0){const S=.5/Math.sqrt(x+1);this._w=.25/S,this._x=(m-u)*S,this._y=(s-h)*S,this._z=(a-r)*S}else if(n>l&&n>v){const S=2*Math.sqrt(1+n-l-v);this._w=(m-u)/S,this._x=.25*S,this._y=(r+a)/S,this._z=(s+h)/S}else if(l>v){const S=2*Math.sqrt(1+l-n-v);this._w=(s-h)/S,this._x=(r+a)/S,this._y=.25*S,this._z=(u+m)/S}else{const S=2*Math.sqrt(1+v-n-l);this._w=(a-r)/S,this._x=(s+h)/S,this._y=(u+m)/S,this._z=.25*S}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ni(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,l=t._x,u=t._y,h=t._z,m=t._w;return this._x=n*m+a*l+r*h-s*u,this._y=r*m+a*u+s*l-n*h,this._z=s*m+a*h+n*u-r*l,this._w=a*m-n*l-r*u-s*h,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let l=a*e._w+n*e._x+r*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const u=1-l*l;if(u<=Number.EPSILON){const S=1-t;return this._w=S*a+t*this._w,this._x=S*n+t*this._x,this._y=S*r+t*this._y,this._z=S*s+t*this._z,this.normalize(),this}const h=Math.sqrt(u),m=Math.atan2(h,l),v=Math.sin((1-t)*m)/h,x=Math.sin(t*m)/h;return this._w=a*v+this._w*x,this._x=n*v+this._x*x,this._y=r*v+this._y*x,this._z=s*v+this._z*x,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class he{constructor(e=0,t=0,n=0){he.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(KC.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(KC.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,l=e.z,u=e.w,h=2*(a*r-l*n),m=2*(l*t-s*r),v=2*(s*n-a*t);return this.x=t+u*h+a*v-l*m,this.y=n+u*m+l*h-s*v,this.z=r+u*v+s*m-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ni(this.x,e.x,t.x),this.y=ni(this.y,e.y,t.y),this.z=ni(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ni(this.x,e,t),this.y=ni(this.y,e,t),this.z=ni(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ni(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,l=t.y,u=t.z;return this.x=r*u-s*l,this.y=s*a-n*u,this.z=n*l-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return t3.copy(this).projectOnVector(e),this.sub(t3)}reflect(e){return this.sub(t3.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ni(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const t3=new he,KC=new mu;class Gc{constructor(e=new he(1/0,1/0,1/0),t=new he(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ml),ml.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Yp),y2.subVectors(this.max,Yp),od.subVectors(e.a,Yp),ld.subVectors(e.b,Yp),ud.subVectors(e.c,Yp),ph.subVectors(ld,od),mh.subVectors(ud,ld),yf.subVectors(od,ud);let t=[0,-ph.z,ph.y,0,-mh.z,mh.y,0,-yf.z,yf.y,ph.z,0,-ph.x,mh.z,0,-mh.x,yf.z,0,-yf.x,-ph.y,ph.x,0,-mh.y,mh.x,0,-yf.y,yf.x,0];return!n3(t,od,ld,ud,y2)||(t=[1,0,0,0,1,0,0,0,1],!n3(t,od,ld,ud,y2))?!1:(x2.crossVectors(ph,mh),t=[x2.x,x2.y,x2.z],n3(t,od,ld,ud,y2))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ml).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ml).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(fc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const fc=[new he,new he,new he,new he,new he,new he,new he,new he],ml=new he,_2=new Gc,od=new he,ld=new he,ud=new he,ph=new he,mh=new he,yf=new he,Yp=new he,y2=new he,x2=new he,xf=new he;function n3(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){xf.fromArray(i,s);const l=r.x*Math.abs(xf.x)+r.y*Math.abs(xf.y)+r.z*Math.abs(xf.z),u=e.dot(xf),h=t.dot(xf),m=n.dot(xf);if(Math.max(-Math.max(u,h,m),Math.min(u,h,m))>l)return!1}return!0}const Pk=new Gc,Qp=new he,i3=new he;class dA{constructor(e=new he,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Pk.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Qp.subVectors(e,this.center);const t=Qp.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Qp,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(i3.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Qp.copy(e.center).add(i3)),this.expandByPoint(Qp.copy(e.center).sub(i3))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ac=new he,r3=new he,b2=new he,gh=new he,s3=new he,S2=new he,a3=new he;class Og{constructor(e=new he,t=new he(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ac)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ac.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ac.copy(this.origin).addScaledVector(this.direction,t),Ac.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){r3.copy(e).add(t).multiplyScalar(.5),b2.copy(t).sub(e).normalize(),gh.copy(this.origin).sub(r3);const s=e.distanceTo(t)*.5,a=-this.direction.dot(b2),l=gh.dot(this.direction),u=-gh.dot(b2),h=gh.lengthSq(),m=Math.abs(1-a*a);let v,x,S,w;if(m>0)if(v=a*u-l,x=a*l-u,w=s*m,v>=0)if(x>=-w)if(x<=w){const R=1/m;v*=R,x*=R,S=v*(v+a*x+2*l)+x*(a*v+x+2*u)+h}else x=s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x=-s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x<=-w?(v=Math.max(0,-(-a*s+l)),x=v>0?-s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h):x<=w?(v=0,x=Math.min(Math.max(-s,-u),s),S=x*(x+2*u)+h):(v=Math.max(0,-(a*s+l)),x=v>0?s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h);else x=a>0?-s:s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,v),r&&r.copy(r3).addScaledVector(b2,x),S}intersectSphere(e,t){Ac.subVectors(e.center,this.origin);const n=Ac.dot(this.direction),r=Ac.dot(Ac)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),l=n-a,u=n+a;return u<0?null:l<0?this.at(u,t):this.at(l,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,l,u;const h=1/this.direction.x,m=1/this.direction.y,v=1/this.direction.z,x=this.origin;return h>=0?(n=(e.min.x-x.x)*h,r=(e.max.x-x.x)*h):(n=(e.max.x-x.x)*h,r=(e.min.x-x.x)*h),m>=0?(s=(e.min.y-x.y)*m,a=(e.max.y-x.y)*m):(s=(e.max.y-x.y)*m,a=(e.min.y-x.y)*m),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a=0?(l=(e.min.z-x.z)*v,u=(e.max.z-x.z)*v):(l=(e.max.z-x.z)*v,u=(e.min.z-x.z)*v),n>u||l>r)||((l>n||n!==n)&&(n=l),(u=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Ac)!==null}intersectTriangle(e,t,n,r,s){s3.subVectors(t,e),S2.subVectors(n,e),a3.crossVectors(s3,S2);let a=this.direction.dot(a3),l;if(a>0){if(r)return null;l=1}else if(a<0)l=-1,a=-a;else return null;gh.subVectors(this.origin,e);const u=l*this.direction.dot(S2.crossVectors(gh,S2));if(u<0)return null;const h=l*this.direction.dot(s3.cross(gh));if(h<0||u+h>a)return null;const m=-l*gh.dot(a3);return m<0?null:this.at(m/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class kn{constructor(e,t,n,r,s,a,l,u,h,m,v,x,S,w,R,C){kn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h,m,v,x,S,w,R,C)}set(e,t,n,r,s,a,l,u,h,m,v,x,S,w,R,C){const E=this.elements;return E[0]=e,E[4]=t,E[8]=n,E[12]=r,E[1]=s,E[5]=a,E[9]=l,E[13]=u,E[2]=h,E[6]=m,E[10]=v,E[14]=x,E[3]=S,E[7]=w,E[11]=R,E[15]=C,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new kn().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/cd.setFromMatrixColumn(e,0).length(),s=1/cd.setFromMatrixColumn(e,1).length(),a=1/cd.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),l=Math.sin(n),u=Math.cos(r),h=Math.sin(r),m=Math.cos(s),v=Math.sin(s);if(e.order==="XYZ"){const x=a*m,S=a*v,w=l*m,R=l*v;t[0]=u*m,t[4]=-u*v,t[8]=h,t[1]=S+w*h,t[5]=x-R*h,t[9]=-l*u,t[2]=R-x*h,t[6]=w+S*h,t[10]=a*u}else if(e.order==="YXZ"){const x=u*m,S=u*v,w=h*m,R=h*v;t[0]=x+R*l,t[4]=w*l-S,t[8]=a*h,t[1]=a*v,t[5]=a*m,t[9]=-l,t[2]=S*l-w,t[6]=R+x*l,t[10]=a*u}else if(e.order==="ZXY"){const x=u*m,S=u*v,w=h*m,R=h*v;t[0]=x-R*l,t[4]=-a*v,t[8]=w+S*l,t[1]=S+w*l,t[5]=a*m,t[9]=R-x*l,t[2]=-a*h,t[6]=l,t[10]=a*u}else if(e.order==="ZYX"){const x=a*m,S=a*v,w=l*m,R=l*v;t[0]=u*m,t[4]=w*h-S,t[8]=x*h+R,t[1]=u*v,t[5]=R*h+x,t[9]=S*h-w,t[2]=-h,t[6]=l*u,t[10]=a*u}else if(e.order==="YZX"){const x=a*u,S=a*h,w=l*u,R=l*h;t[0]=u*m,t[4]=R-x*v,t[8]=w*v+S,t[1]=v,t[5]=a*m,t[9]=-l*m,t[2]=-h*m,t[6]=S*v+w,t[10]=x-R*v}else if(e.order==="XZY"){const x=a*u,S=a*h,w=l*u,R=l*h;t[0]=u*m,t[4]=-v,t[8]=h*m,t[1]=x*v+R,t[5]=a*m,t[9]=S*v-w,t[2]=w*v-S,t[6]=l*m,t[10]=R*v+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Lk,e,Uk)}lookAt(e,t,n){const r=this.elements;return po.subVectors(e,t),po.lengthSq()===0&&(po.z=1),po.normalize(),vh.crossVectors(n,po),vh.lengthSq()===0&&(Math.abs(n.z)===1?po.x+=1e-4:po.z+=1e-4,po.normalize(),vh.crossVectors(n,po)),vh.normalize(),T2.crossVectors(po,vh),r[0]=vh.x,r[4]=T2.x,r[8]=po.x,r[1]=vh.y,r[5]=T2.y,r[9]=po.y,r[2]=vh.z,r[6]=T2.z,r[10]=po.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[4],u=n[8],h=n[12],m=n[1],v=n[5],x=n[9],S=n[13],w=n[2],R=n[6],C=n[10],E=n[14],B=n[3],L=n[7],O=n[11],G=n[15],q=r[0],z=r[4],j=r[8],F=r[12],V=r[1],Y=r[5],ee=r[9],te=r[13],re=r[2],ne=r[6],Q=r[10],ae=r[14],de=r[3],Te=r[7],be=r[11],ue=r[15];return s[0]=a*q+l*V+u*re+h*de,s[4]=a*z+l*Y+u*ne+h*Te,s[8]=a*j+l*ee+u*Q+h*be,s[12]=a*F+l*te+u*ae+h*ue,s[1]=m*q+v*V+x*re+S*de,s[5]=m*z+v*Y+x*ne+S*Te,s[9]=m*j+v*ee+x*Q+S*be,s[13]=m*F+v*te+x*ae+S*ue,s[2]=w*q+R*V+C*re+E*de,s[6]=w*z+R*Y+C*ne+E*Te,s[10]=w*j+R*ee+C*Q+E*be,s[14]=w*F+R*te+C*ae+E*ue,s[3]=B*q+L*V+O*re+G*de,s[7]=B*z+L*Y+O*ne+G*Te,s[11]=B*j+L*ee+O*Q+G*be,s[15]=B*F+L*te+O*ae+G*ue,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],l=e[5],u=e[9],h=e[13],m=e[2],v=e[6],x=e[10],S=e[14],w=e[3],R=e[7],C=e[11],E=e[15];return w*(+s*u*v-r*h*v-s*l*x+n*h*x+r*l*S-n*u*S)+R*(+t*u*S-t*h*x+s*a*x-r*a*S+r*h*m-s*u*m)+C*(+t*h*v-t*l*S-s*a*v+n*a*S+s*l*m-n*h*m)+E*(-r*l*m-t*u*v+t*l*x+r*a*v-n*a*x+n*u*m)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=e[9],x=e[10],S=e[11],w=e[12],R=e[13],C=e[14],E=e[15],B=v*C*h-R*x*h+R*u*S-l*C*S-v*u*E+l*x*E,L=w*x*h-m*C*h-w*u*S+a*C*S+m*u*E-a*x*E,O=m*R*h-w*v*h+w*l*S-a*R*S-m*l*E+a*v*E,G=w*v*u-m*R*u-w*l*x+a*R*x+m*l*C-a*v*C,q=t*B+n*L+r*O+s*G;if(q===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const z=1/q;return e[0]=B*z,e[1]=(R*x*s-v*C*s-R*r*S+n*C*S+v*r*E-n*x*E)*z,e[2]=(l*C*s-R*u*s+R*r*h-n*C*h-l*r*E+n*u*E)*z,e[3]=(v*u*s-l*x*s-v*r*h+n*x*h+l*r*S-n*u*S)*z,e[4]=L*z,e[5]=(m*C*s-w*x*s+w*r*S-t*C*S-m*r*E+t*x*E)*z,e[6]=(w*u*s-a*C*s-w*r*h+t*C*h+a*r*E-t*u*E)*z,e[7]=(a*x*s-m*u*s+m*r*h-t*x*h-a*r*S+t*u*S)*z,e[8]=O*z,e[9]=(w*v*s-m*R*s-w*n*S+t*R*S+m*n*E-t*v*E)*z,e[10]=(a*R*s-w*l*s+w*n*h-t*R*h-a*n*E+t*l*E)*z,e[11]=(m*l*s-a*v*s-m*n*h+t*v*h+a*n*S-t*l*S)*z,e[12]=G*z,e[13]=(m*R*r-w*v*r+w*n*x-t*R*x-m*n*C+t*v*C)*z,e[14]=(w*l*r-a*R*r-w*n*u+t*R*u+a*n*C-t*l*C)*z,e[15]=(a*v*r-m*l*r+m*n*u-t*v*u-a*n*x+t*l*x)*z,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,l=e.y,u=e.z,h=s*a,m=s*l;return this.set(h*a+n,h*l-r*u,h*u+r*l,0,h*l+r*u,m*l+n,m*u-r*a,0,h*u-r*l,m*u+r*a,s*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,l=t._z,u=t._w,h=s+s,m=a+a,v=l+l,x=s*h,S=s*m,w=s*v,R=a*m,C=a*v,E=l*v,B=u*h,L=u*m,O=u*v,G=n.x,q=n.y,z=n.z;return r[0]=(1-(R+E))*G,r[1]=(S+O)*G,r[2]=(w-L)*G,r[3]=0,r[4]=(S-O)*q,r[5]=(1-(x+E))*q,r[6]=(C+B)*q,r[7]=0,r[8]=(w+L)*z,r[9]=(C-B)*z,r[10]=(1-(x+R))*z,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=cd.set(r[0],r[1],r[2]).length();const a=cd.set(r[4],r[5],r[6]).length(),l=cd.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],gl.copy(this);const h=1/s,m=1/a,v=1/l;return gl.elements[0]*=h,gl.elements[1]*=h,gl.elements[2]*=h,gl.elements[4]*=m,gl.elements[5]*=m,gl.elements[6]*=m,gl.elements[8]*=v,gl.elements[9]*=v,gl.elements[10]*=v,t.setFromRotationMatrix(gl),n.x=s,n.y=a,n.z=l,this}makePerspective(e,t,n,r,s,a,l=Ha){const u=this.elements,h=2*s/(t-e),m=2*s/(n-r),v=(t+e)/(t-e),x=(n+r)/(n-r);let S,w;if(l===Ha)S=-(a+s)/(a-s),w=-2*a*s/(a-s);else if(l===pu)S=-a/(a-s),w=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=h,u[4]=0,u[8]=v,u[12]=0,u[1]=0,u[5]=m,u[9]=x,u[13]=0,u[2]=0,u[6]=0,u[10]=S,u[14]=w,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,s,a,l=Ha){const u=this.elements,h=1/(t-e),m=1/(n-r),v=1/(a-s),x=(t+e)*h,S=(n+r)*m;let w,R;if(l===Ha)w=(a+s)*v,R=-2*v;else if(l===pu)w=s*v,R=-1*v;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=2*h,u[4]=0,u[8]=0,u[12]=-x,u[1]=0,u[5]=2*m,u[9]=0,u[13]=-S,u[2]=0,u[6]=0,u[10]=R,u[14]=-w,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const cd=new he,gl=new kn,Lk=new he(0,0,0),Uk=new he(1,1,1),vh=new he,T2=new he,po=new he,ZC=new kn,JC=new mu;class la{constructor(e=0,t=0,n=0,r=la.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],l=r[8],u=r[1],h=r[5],m=r[9],v=r[2],x=r[6],S=r[10];switch(t){case"XYZ":this._y=Math.asin(ni(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-m,S),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(x,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ni(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(l,S),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-v,s),this._z=0);break;case"ZXY":this._x=Math.asin(ni(x,-1,1)),Math.abs(x)<.9999999?(this._y=Math.atan2(-v,S),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-ni(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(x,S),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(ni(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-m,h),this._y=Math.atan2(-v,s)):(this._x=0,this._y=Math.atan2(l,S));break;case"XZY":this._z=Math.asin(-ni(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(x,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-m,S),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ZC.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ZC,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return JC.setFromEuler(this),this.setFromQuaternion(JC,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}la.DEFAULT_ORDER="XYZ";class Ww{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(l,u){return l[u.uuid]===void 0&&(l[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const u=l.shapes;if(Array.isArray(u))for(let h=0,m=u.length;h0){r.children=[];for(let l=0;l0){r.animations=[];for(let l=0;l0&&(n.geometries=l),u.length>0&&(n.materials=u),h.length>0&&(n.textures=h),m.length>0&&(n.images=m),v.length>0&&(n.shapes=v),x.length>0&&(n.skeletons=x),S.length>0&&(n.animations=S),w.length>0&&(n.nodes=w)}return n.object=r,n;function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){vl.subVectors(r,t),pc.subVectors(n,t),l3.subVectors(e,t);const a=vl.dot(vl),l=vl.dot(pc),u=vl.dot(l3),h=pc.dot(pc),m=pc.dot(l3),v=a*h-l*l;if(v===0)return s.set(0,0,0),null;const x=1/v,S=(h*u-l*m)*x,w=(a*m-l*u)*x;return s.set(1-S-w,w,S)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,mc)===null?!1:mc.x>=0&&mc.y>=0&&mc.x+mc.y<=1}static getInterpolation(e,t,n,r,s,a,l,u){return this.getBarycoord(e,t,n,r,mc)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(s,mc.x),u.addScaledVector(a,mc.y),u.addScaledVector(l,mc.z),u)}static getInterpolatedAttribute(e,t,n,r,s,a){return f3.setScalar(0),A3.setScalar(0),d3.setScalar(0),f3.fromBufferAttribute(e,t),A3.fromBufferAttribute(e,n),d3.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(f3,s.x),a.addScaledVector(A3,s.y),a.addScaledVector(d3,s.z),a}static isFrontFacing(e,t,n,r){return vl.subVectors(n,t),pc.subVectors(e,t),vl.cross(pc).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return vl.subVectors(this.c,this.b),pc.subVectors(this.a,this.b),vl.cross(pc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sl.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Sl.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Sl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,l;Ad.subVectors(r,n),dd.subVectors(s,n),u3.subVectors(e,n);const u=Ad.dot(u3),h=dd.dot(u3);if(u<=0&&h<=0)return t.copy(n);c3.subVectors(e,r);const m=Ad.dot(c3),v=dd.dot(c3);if(m>=0&&v<=m)return t.copy(r);const x=u*v-m*h;if(x<=0&&u>=0&&m<=0)return a=u/(u-m),t.copy(n).addScaledVector(Ad,a);h3.subVectors(e,s);const S=Ad.dot(h3),w=dd.dot(h3);if(w>=0&&S<=w)return t.copy(s);const R=S*h-u*w;if(R<=0&&h>=0&&w<=0)return l=h/(h-w),t.copy(n).addScaledVector(dd,l);const C=m*w-S*v;if(C<=0&&v-m>=0&&S-w>=0)return s5.subVectors(s,r),l=(v-m)/(v-m+(S-w)),t.copy(r).addScaledVector(s5,l);const E=1/(C+R+x);return a=R*E,l=x*E,t.copy(n).addScaledVector(Ad,a).addScaledVector(dd,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const z7={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},_h={h:0,s:0,l:0},M2={h:0,s:0,l:0};function p3(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let an=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=_n){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ai.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=ai.workingColorSpace){return this.r=e,this.g=t,this.b=n,ai.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=ai.workingColorSpace){if(e=Hw(e,1),t=ni(t,0,1),n=ni(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=p3(a,s,e+1/3),this.g=p3(a,s,e),this.b=p3(a,s,e-1/3)}return ai.toWorkingColorSpace(this,r),this}setStyle(e,t=_n){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],l=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=_n){const n=z7[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Mc(e.r),this.g=Mc(e.g),this.b=Mc(e.b),this}copyLinearToSRGB(e){return this.r=e0(e.r),this.g=e0(e.g),this.b=e0(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_n){return ai.fromWorkingColorSpace(ea.copy(this),e),Math.round(ni(ea.r*255,0,255))*65536+Math.round(ni(ea.g*255,0,255))*256+Math.round(ni(ea.b*255,0,255))}getHexString(e=_n){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ai.workingColorSpace){ai.fromWorkingColorSpace(ea.copy(this),t);const n=ea.r,r=ea.g,s=ea.b,a=Math.max(n,r,s),l=Math.min(n,r,s);let u,h;const m=(l+a)/2;if(l===a)u=0,h=0;else{const v=a-l;switch(h=m<=.5?v/(a+l):v/(2-a-l),a){case n:u=(r-s)/v+(r0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ka&&(n.blending=this.blending),this.side!==Nl&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==qm&&(n.blendSrc=this.blendSrc),this.blendDst!==Vm&&(n.blendDst=this.blendDst),this.blendEquation!==Eo&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==kh&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==WS&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Uf&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Uf&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Uf&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const l in s){const u=s[l];delete u.metadata,a.push(u)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class pA extends ua{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new an(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new la,this.combine=Lg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const bc=zk();function zk(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const h=u-127;h<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):h<-14?(n[u]=1024>>-h-14,n[u|256]=1024>>-h-14|32768,r[u]=-h-1,r[u|256]=-h-1):h<=15?(n[u]=h+15<<10,n[u|256]=h+15<<10|32768,r[u]=13,r[u|256]=13):h<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),l=new Uint32Array(64);for(let u=1;u<1024;++u){let h=u<<13,m=0;for(;(h&8388608)===0;)h<<=1,m-=8388608;h&=-8388609,m+=947912704,s[u]=h|m}for(let u=1024;u<2048;++u)s[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(l[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:l}}function mo(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=ni(i,-65504,65504),bc.floatView[0]=i;const e=bc.uint32View[0],t=e>>23&511;return bc.baseTable[t]+((e&8388607)>>bc.shiftTable[t])}function E2(i){const e=i>>10;return bc.uint32View[0]=bc.mantissaTable[bc.offsetTable[e]+(i&1023)]+bc.exponentTable[e],bc.floatView[0]}const is=new he,C2=new gt;class wr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=o_,this.updateRanges=[],this.gpuType=$r,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;rt.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gc);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new he(-1/0,-1/0,-1/0),new he(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const h in u)u[h]!==void 0&&(e[h]=u[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const h=n[u];e.data.attributes[u]=h.toJSON(e.data)}const r={};let s=!1;for(const u in this.morphAttributes){const h=this.morphAttributes[u],m=[];for(let v=0,x=h.length;v0&&(r[u]=m,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const h in r){const m=r[h];this.setAttribute(h,m.clone(t))}const s=e.morphAttributes;for(const h in s){const m=[],v=s[h];for(let x=0,S=v.length;x0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s(e.far-e.near)**2))&&(a5.copy(s).invert(),bf.copy(e.ray).applyMatrix4(a5),!(n.boundingBox!==null&&bf.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,bf)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,l=s.index,u=s.attributes.position,h=s.attributes.uv,m=s.attributes.uv1,v=s.attributes.normal,x=s.groups,S=s.drawRange;if(l!==null)if(Array.isArray(a))for(let w=0,R=x.length;wt.far?null:{distance:h,point:U2.clone(),object:i}}function B2(i,e,t,n,r,s,a,l,u,h){i.getVertexPosition(l,N2),i.getVertexPosition(u,D2),i.getVertexPosition(h,P2);const m=qk(i,e,t,n,N2,D2,P2,l5);if(m){const v=new he;Sl.getBarycoord(l5,N2,D2,P2,v),r&&(m.uv=Sl.getInterpolatedAttribute(r,l,u,h,v,new gt)),s&&(m.uv1=Sl.getInterpolatedAttribute(s,l,u,h,v,new gt)),a&&(m.normal=Sl.getInterpolatedAttribute(a,l,u,h,v,new he),m.normal.dot(n.direction)>0&&m.normal.multiplyScalar(-1));const x={a:l,b:u,c:h,normal:new he,materialIndex:0};Sl.getNormal(N2,D2,P2,x.normal),m.face=x,m.barycoord=v}return m}class $h extends Ki{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const u=[],h=[],m=[],v=[];let x=0,S=0;w("z","y","x",-1,-1,n,t,e,a,s,0),w("z","y","x",1,-1,n,t,-e,a,s,1),w("x","z","y",1,1,e,n,t,r,a,2),w("x","z","y",1,-1,e,n,-t,r,a,3),w("x","y","z",1,-1,e,t,n,r,s,4),w("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(u),this.setAttribute("position",new Mi(h,3)),this.setAttribute("normal",new Mi(m,3)),this.setAttribute("uv",new Mi(v,2));function w(R,C,E,B,L,O,G,q,z,j,F){const V=O/z,Y=G/j,ee=O/2,te=G/2,re=q/2,ne=z+1,Q=j+1;let ae=0,de=0;const Te=new he;for(let be=0;be0?1:-1,m.push(Te.x,Te.y,Te.z),v.push(we/z),v.push(1-be/j),ae+=1}}for(let be=0;be0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class _y extends vr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new kn,this.projectionMatrix=new kn,this.projectionMatrixInverse=new kn,this.coordinateSystem=Ha}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const yh=new he,u5=new gt,c5=new gt;class ya extends _y{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=w0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Em*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return w0*2*Math.atan(Math.tan(Em*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){yh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(yh.x,yh.y).multiplyScalar(-e/yh.z),yh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(yh.x,yh.y).multiplyScalar(-e/yh.z)}getViewSize(e,t){return this.getViewBounds(e,u5,c5),t.subVectors(c5,u5)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Em*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,h=a.fullHeight;s+=a.offsetX*r/u,t-=a.offsetY*n/h,r*=a.width/u,n*=a.height/h}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const md=-90,gd=1;class V7 extends vr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new ya(md,gd,e,t);r.layers=this.layers,this.add(r);const s=new ya(md,gd,e,t);s.layers=this.layers,this.add(s);const a=new ya(md,gd,e,t);a.layers=this.layers,this.add(a);const l=new ya(md,gd,e,t);l.layers=this.layers,this.add(l);const u=new ya(md,gd,e,t);u.layers=this.layers,this.add(u);const h=new ya(md,gd,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,l,u]=t;for(const h of t)this.remove(h);if(e===Ha)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===pu)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,l,u,h,m]=this.children,v=e.getRenderTarget(),x=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),w=e.xr.enabled;e.xr.enabled=!1;const R=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,l),e.setRenderTarget(n,3,r),e.render(t,u),e.setRenderTarget(n,4,r),e.render(t,h),n.texture.generateMipmaps=R,e.setRenderTarget(n,5,r),e.render(t,m),e.setRenderTarget(v,x,S),e.xr.enabled=w,n.texture.needsPMREMUpdate=!0}}class yy extends vs{constructor(e,t,n,r,s,a,l,u,h,m){e=e!==void 0?e:[],t=t!==void 0?t:Qo,super(e,t,n,r,s,a,l,u,h,m),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class H7 extends qh{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new yy(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:gs}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` - - varying vec3 vWorldDirection; - - vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); - - } - - void main() { - - vWorldDirection = transformDirection( position, modelMatrix ); - - #include - #include - - } - `,fragmentShader:` - - uniform sampler2D tEquirect; - - varying vec3 vWorldDirection; - - #include - - void main() { - - vec3 direction = normalize( vWorldDirection ); - - vec2 sampleUV = equirectUv( direction ); - - gl_FragColor = texture2D( tEquirect, sampleUV ); - - } - `},r=new $h(5,5,5),s=new Ja({name:"CubemapFromEquirect",uniforms:E0(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:hr,blending:Qa});s.uniforms.tEquirect.value=t;const a=new zi(r,s),l=t.minFilter;return t.minFilter===Va&&(t.minFilter=gs),new V7(1,10,this).update(e,a),t.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Yw extends vr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new la,this.environmentIntensity=1,this.environmentRotation=new la,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Qw{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=o_,this.updateRanges=[],this.version=0,this.uuid=ou()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Yk.getNormalMatrix(e),r=this.coplanarPoint(v3).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Sf=new dA,O2=new he;class Fg{constructor(e=new Yl,t=new Yl,n=new Yl,r=new Yl,s=new Yl,a=new Yl){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(s),l[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ha){const n=this.planes,r=e.elements,s=r[0],a=r[1],l=r[2],u=r[3],h=r[4],m=r[5],v=r[6],x=r[7],S=r[8],w=r[9],R=r[10],C=r[11],E=r[12],B=r[13],L=r[14],O=r[15];if(n[0].setComponents(u-s,x-h,C-S,O-E).normalize(),n[1].setComponents(u+s,x+h,C+S,O+E).normalize(),n[2].setComponents(u+a,x+m,C+w,O+B).normalize(),n[3].setComponents(u-a,x-m,C-w,O-B).normalize(),n[4].setComponents(u-l,x-v,C-R,O-L).normalize(),t===Ha)n[5].setComponents(u+l,x+v,C+R,O+L).normalize();else if(t===pu)n[5].setComponents(l,v,R,L).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Sf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Sf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Sf)}intersectsSprite(e){return Sf.center.set(0,0,0),Sf.radius=.7071067811865476,Sf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Sf)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,O2.y=r.normal.y>0?e.max.y:e.min.y,O2.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(O2)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class $0 extends ua{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new an(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const l_=new he,u_=new he,h5=new kn,Jp=new Og,I2=new dA,_3=new he,f5=new he;class xy extends vr{constructor(e=new Ki,t=new $0){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sn)return;_3.applyMatrix4(i.matrixWorld);const u=e.ray.origin.distanceTo(_3);if(!(ue.far))return{distance:u,point:f5.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const A5=new he,d5=new he;class j7 extends xy{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}let ja=class extends vr{constructor(){super(),this.isGroup=!0,this.type="Group"}};class W7 extends vs{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=mr,this.minFilter=mr,this.generateMipmaps=!1,this.needsUpdate=!0}}class qc extends vs{constructor(e,t,n,r,s,a,l,u,h,m=au){if(m!==au&&m!==du)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&m===au&&(n=Rr),n===void 0&&m===du&&(n=Au),super(null,r,s,a,l,u,m,n,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:mr,this.minFilter=u!==void 0?u:mr,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Pl{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let l=0,u=s-1,h;for(;l<=u;)if(r=Math.floor(l+(u-l)/2),h=n[r]-a,h<0)l=r+1;else if(h>0)u=r-1;else{u=r;break}if(r=u,n[r]===a)return r/(s-1);const m=n[r],x=n[r+1]-m,S=(a-m)/x;return(r+S)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),l=this.getPoint(s),u=t||(a.isVector2?new gt:new he);return u.copy(l).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new he,r=[],s=[],a=[],l=new he,u=new kn;for(let S=0;S<=e;S++){const w=S/e;r[S]=this.getTangentAt(w,new he)}s[0]=new he,a[0]=new he;let h=Number.MAX_VALUE;const m=Math.abs(r[0].x),v=Math.abs(r[0].y),x=Math.abs(r[0].z);m<=h&&(h=m,n.set(1,0,0)),v<=h&&(h=v,n.set(0,1,0)),x<=h&&n.set(0,0,1),l.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],l),a[0].crossVectors(r[0],s[0]);for(let S=1;S<=e;S++){if(s[S]=s[S-1].clone(),a[S]=a[S-1].clone(),l.crossVectors(r[S-1],r[S]),l.length()>Number.EPSILON){l.normalize();const w=Math.acos(ni(r[S-1].dot(r[S]),-1,1));s[S].applyMatrix4(u.makeRotationAxis(l,w))}a[S].crossVectors(r[S],s[S])}if(t===!0){let S=Math.acos(ni(s[0].dot(s[e]),-1,1));S/=e,r[0].dot(l.crossVectors(s[0],s[e]))>0&&(S=-S);for(let w=1;w<=e;w++)s[w].applyMatrix4(u.makeRotationAxis(r[w],S*w)),a[w].crossVectors(r[w],s[w])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Zw extends Pl{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,l=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=l,this.aRotation=u}getPoint(e,t=new gt){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(l)/s)+1)*s:u===0&&l===s-1&&(l=s-2,u=1);let h,m;this.closed||l>0?h=r[(l-1)%s]:(G2.subVectors(r[0],r[1]).add(r[0]),h=G2);const v=r[l%s],x=r[(l+1)%s];if(this.closed||l+2r.length-2?r.length-1:a+1],v=r[a>r.length-3?r.length-1:a+2];return n.set(g5(l,u.x,h.x,m.x,v.x),g5(l,u.y,h.y,m.y,v.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[s]-n,l=this.curves[s],u=l.getLength(),h=u===0?0:1-a/u;return l.getPointAt(h,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const v=h.getPoint(0);v.equals(this.currentPoint)||this.lineTo(v.x,v.y)}this.curves.push(h);const m=h.getPoint(1);return this.currentPoint.copy(m),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class by extends Ki{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],l=[],u=[],h=new he,m=new gt;a.push(0,0,0),l.push(0,0,1),u.push(.5,.5);for(let v=0,x=3;v<=t;v++,x+=3){const S=n+v/t*r;h.x=e*Math.cos(S),h.y=e*Math.sin(S),a.push(h.x,h.y,h.z),l.push(0,0,1),m.x=(a[x]/e+1)/2,m.y=(a[x+1]/e+1)/2,u.push(m.x,m.y)}for(let v=1;v<=t;v++)s.push(v,v+1,0);this.setIndex(s),this.setAttribute("position",new Mi(a,3)),this.setAttribute("normal",new Mi(l,3)),this.setAttribute("uv",new Mi(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new by(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class eM extends Ki{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:l,thetaLength:u};const h=this;r=Math.floor(r),s=Math.floor(s);const m=[],v=[],x=[],S=[];let w=0;const R=[],C=n/2;let E=0;B(),a===!1&&(e>0&&L(!0),t>0&&L(!1)),this.setIndex(m),this.setAttribute("position",new Mi(v,3)),this.setAttribute("normal",new Mi(x,3)),this.setAttribute("uv",new Mi(S,2));function B(){const O=new he,G=new he;let q=0;const z=(t-e)/n;for(let j=0;j<=s;j++){const F=[],V=j/s,Y=V*(t-e)+e;for(let ee=0;ee<=r;ee++){const te=ee/r,re=te*u+l,ne=Math.sin(re),Q=Math.cos(re);G.x=Y*ne,G.y=-V*n+C,G.z=Y*Q,v.push(G.x,G.y,G.z),O.set(ne,z,Q).normalize(),x.push(O.x,O.y,O.z),S.push(te,1-V),F.push(w++)}R.push(F)}for(let j=0;j0||F!==0)&&(m.push(V,Y,te),q+=3),(t>0||F!==s-1)&&(m.push(Y,ee,te),q+=3)}h.addGroup(E,q,0),E+=q}function L(O){const G=w,q=new gt,z=new he;let j=0;const F=O===!0?e:t,V=O===!0?1:-1;for(let ee=1;ee<=r;ee++)v.push(0,C*V,0),x.push(0,V,0),S.push(.5,.5),w++;const Y=w;for(let ee=0;ee<=r;ee++){const re=ee/r*u+l,ne=Math.cos(re),Q=Math.sin(re);z.x=F*Q,z.y=C*V,z.z=F*ne,v.push(z.x,z.y,z.z),x.push(0,V,0),q.x=ne*.5+.5,q.y=Q*.5*V+.5,S.push(q.x,q.y),w++}for(let ee=0;ee80*t){l=h=i[0],u=m=i[1];for(let w=t;wh&&(h=v),x>m&&(m=x);S=Math.max(h-l,m-u),S=S!==0?32767/S:0}return ag(s,a,t,l,u,S,0),a}};function J7(i,e,t,n,r){let s,a;if(r===Tz(i,e,t,n)>0)for(s=e;s=e;s-=n)a=v5(s,i[s],i[s+1],a);return a&&Sy(a,a.next)&&(lg(a),a=a.next),a}function uA(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Sy(t,t.next)||Nr(t.prev,t,t.next)===0)){if(lg(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ag(i,e,t,n,r,s,a){if(!i)return;!a&&s&&vz(i,n,r,s);let l=i,u,h;for(;i.prev!==i.next;){if(u=i.prev,h=i.next,s?cz(i,n,r,s):uz(i)){e.push(u.i/t|0),e.push(i.i/t|0),e.push(h.i/t|0),lg(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=hz(uA(i),e,t),ag(i,e,t,n,r,s,2)):a===2&&fz(i,e,t,n,r,s):ag(uA(i),e,t,n,r,s,1);break}}}function uz(i){const e=i.prev,t=i,n=i.next;if(Nr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=rs?r>a?r:a:s>a?s:a,S=l>u?l>h?l:h:u>h?u:h;let w=n.next;for(;w!==e;){if(w.x>=m&&w.x<=x&&w.y>=v&&w.y<=S&&Vd(r,l,s,u,a,h,w.x,w.y)&&Nr(w.prev,w,w.next)>=0)return!1;w=w.next}return!0}function cz(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Nr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=lu?l>h?l:h:u>h?u:h,C=m>v?m>x?m:x:v>x?v:x,E=YS(S,w,e,t,n),B=YS(R,C,e,t,n);let L=i.prevZ,O=i.nextZ;for(;L&&L.z>=E&&O&&O.z<=B;){if(L.x>=S&&L.x<=R&&L.y>=w&&L.y<=C&&L!==r&&L!==a&&Vd(l,m,u,v,h,x,L.x,L.y)&&Nr(L.prev,L,L.next)>=0||(L=L.prevZ,O.x>=S&&O.x<=R&&O.y>=w&&O.y<=C&&O!==r&&O!==a&&Vd(l,m,u,v,h,x,O.x,O.y)&&Nr(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;L&&L.z>=E;){if(L.x>=S&&L.x<=R&&L.y>=w&&L.y<=C&&L!==r&&L!==a&&Vd(l,m,u,v,h,x,L.x,L.y)&&Nr(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;O&&O.z<=B;){if(O.x>=S&&O.x<=R&&O.y>=w&&O.y<=C&&O!==r&&O!==a&&Vd(l,m,u,v,h,x,O.x,O.y)&&Nr(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function hz(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!Sy(r,s)&&eD(r,n,n.next,s)&&og(r,s)&&og(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),lg(n),lg(n.next),n=i=s),n=n.next}while(n!==i);return uA(n)}function fz(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&xz(a,l)){let u=tD(a,l);a=uA(a,a.next),u=uA(u,u.next),ag(a,e,t,n,r,s,0),ag(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function Az(i,e,t,n){const r=[];let s,a,l,u,h;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const x=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=s&&x>n&&(n=x,r=t.x=t.x&&t.x>=u&&s!==t.x&&Vd(ar.x||t.x===r.x&&gz(r,t)))&&(r=t,m=v)),t=t.next;while(t!==l);return r}function gz(i,e){return Nr(i.prev,i,e.prev)<0&&Nr(e.next,i,i.next)<0}function vz(i,e,t,n){let r=i;do r.z===0&&(r.z=YS(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,_z(r)}function _z(i){let e,t,n,r,s,a,l,u,h=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,l=0,e=0;e0||u>0&&n;)l!==0&&(u===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,l--):(r=n,n=n.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,h*=2}while(a>1);return i}function YS(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function yz(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function xz(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!bz(i,e)&&(og(i,e)&&og(e,i)&&Sz(i,e)&&(Nr(i.prev,i,e.prev)||Nr(i,e.prev,e))||Sy(i,e)&&Nr(i.prev,i,i.next)>0&&Nr(e.prev,e,e.next)>0)}function Nr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Sy(i,e){return i.x===e.x&&i.y===e.y}function eD(i,e,t,n){const r=V2(Nr(i,e,t)),s=V2(Nr(i,e,n)),a=V2(Nr(t,n,i)),l=V2(Nr(t,n,e));return!!(r!==s&&a!==l||r===0&&q2(i,t,e)||s===0&&q2(i,n,e)||a===0&&q2(t,i,n)||l===0&&q2(t,e,n))}function q2(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function V2(i){return i>0?1:i<0?-1:0}function bz(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&eD(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function og(i,e){return Nr(i.prev,i,i.next)<0?Nr(i,e,i.next)>=0&&Nr(i,i.prev,e)>=0:Nr(i,e,i.prev)<0||Nr(i,i.next,e)<0}function Sz(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function tD(i,e){const t=new QS(i.i,i.x,i.y),n=new QS(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function v5(i,e,t,n){const r=new QS(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function lg(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function QS(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Tz(i,e,t,n){let r=0;for(let s=e,a=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function y5(i,e){for(let t=0;tNumber.EPSILON){const Re=Math.sqrt(X),pe=Math.sqrt(xt*xt+fe*fe),Me=rt.x-en/Re,nt=rt.y+yt/Re,lt=ce.x-fe/pe,Ot=ce.y+xt/pe,jt=((lt-Me)*fe-(Ot-nt)*xt)/(yt*fe-en*xt);Gt=Me+yt*jt-$e.x,ht=nt+en*jt-$e.y;const pt=Gt*Gt+ht*ht;if(pt<=2)return new gt(Gt,ht);Pt=Math.sqrt(pt/2)}else{let Re=!1;yt>Number.EPSILON?xt>Number.EPSILON&&(Re=!0):yt<-Number.EPSILON?xt<-Number.EPSILON&&(Re=!0):Math.sign(en)===Math.sign(fe)&&(Re=!0),Re?(Gt=-en,ht=yt,Pt=Math.sqrt(X)):(Gt=yt,ht=en,Pt=Math.sqrt(X/2))}return new gt(Gt/Pt,ht/Pt)}const Te=[];for(let $e=0,rt=re.length,ce=rt-1,Gt=$e+1;$e=0;$e--){const rt=$e/C,ce=S*Math.cos(rt*Math.PI/2),Gt=w*Math.sin(rt*Math.PI/2)+R;for(let ht=0,Pt=re.length;ht=0;){const Gt=ce;let ht=ce-1;ht<0&&(ht=$e.length-1);for(let Pt=0,yt=m+C*2;Pt0)&&S.push(L,O,q),(E!==n-1||u0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class iD extends ua{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new an(16777215),this.specular=new an(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new an(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Dc,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new la,this.combine=Lg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Nz extends ua{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new an(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new an(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Dc,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Dz extends ua{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Dc,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Vc extends ua{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new an(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new an(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Dc,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new la,this.combine=Lg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Pz extends ua{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=WF,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Lz extends ua{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Uz extends ua{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new an(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Dc,this.normalScale=new gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Bz extends $0{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const b5={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class Oz{constructor(e,t,n){const r=this;let s=!1,a=0,l=0,u;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(m){l++,s===!1&&r.onStart!==void 0&&r.onStart(m,a,l),s=!0},this.itemEnd=function(m){a++,r.onProgress!==void 0&&r.onProgress(m,a,l),a===l&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(m){r.onError!==void 0&&r.onError(m)},this.resolveURL=function(m){return u?u(m):m},this.setURLModifier=function(m){return u=m,this},this.addHandler=function(m,v){return h.push(m,v),this},this.removeHandler=function(m){const v=h.indexOf(m);return v!==-1&&h.splice(v,2),this},this.getHandler=function(m){for(let v=0,x=h.length;vNumber.EPSILON){if(V<0&&(z=B[q],F=-F,j=B[G],V=-V),E.yj.y)continue;if(E.y===z.y){if(E.x===z.x)return!0}else{const Y=V*(E.x-z.x)-F*(E.y-z.y);if(Y===0)return!0;if(Y<0)continue;O=!O}}else{if(E.y!==z.y)continue;if(j.x<=E.x&&E.x<=z.x||z.x<=E.x&&E.x<=j.x)return!0}}return O}const r=t0.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,l,u;const h=[];if(s.length===1)return l=s[0],u=new Gv,u.curves=l.curves,h.push(u),h;let m=!r(s[0].getPoints());m=e?!m:m;const v=[],x=[];let S=[],w=0,R;x[w]=void 0,S[w]=[];for(let E=0,B=s.length;E1){let E=!1,B=0;for(let L=0,O=x.length;L0&&E===!1&&(S=v)}let C;for(let E=0,B=x.length;ES.start-w.start);let x=0;for(let S=1;S 0 - vec4 plane; - #ifdef ALPHA_TO_COVERAGE - float distanceToPlane, distanceGradient; - float clipOpacity = 1.0; - #pragma unroll_loop_start - for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; - distanceGradient = fwidth( distanceToPlane ) / 2.0; - clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); - if ( clipOpacity == 0.0 ) discard; - } - #pragma unroll_loop_end - #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES - float unionClipOpacity = 1.0; - #pragma unroll_loop_start - for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; - distanceGradient = fwidth( distanceToPlane ) / 2.0; - unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); - } - #pragma unroll_loop_end - clipOpacity *= 1.0 - unionClipOpacity; - #endif - diffuseColor.a *= clipOpacity; - if ( diffuseColor.a == 0.0 ) discard; - #else - #pragma unroll_loop_start - for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; - } - #pragma unroll_loop_end - #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES - bool clipped = true; - #pragma unroll_loop_start - for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; - } - #pragma unroll_loop_end - if ( clipped ) discard; - #endif - #endif -#endif`,mG=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; - uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,gG=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; -#endif`,vG=`#if NUM_CLIPPING_PLANES > 0 - vClipPosition = - mvPosition.xyz; -#endif`,_G=`#if defined( USE_COLOR_ALPHA ) - diffuseColor *= vColor; -#elif defined( USE_COLOR ) - diffuseColor.rgb *= vColor; -#endif`,yG=`#if defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#elif defined( USE_COLOR ) - varying vec3 vColor; -#endif`,xG=`#if defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) - varying vec3 vColor; -#endif`,bG=`#if defined( USE_COLOR_ALPHA ) - vColor = vec4( 1.0 ); -#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) - vColor = vec3( 1.0 ); -#endif -#ifdef USE_COLOR - vColor *= color; -#endif -#ifdef USE_INSTANCING_COLOR - vColor.xyz *= instanceColor.xyz; -#endif -#ifdef USE_BATCHING_COLOR - vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); - vColor.xyz *= batchingColor.xyz; -#endif`,SG=`#define PI 3.141592653589793 -#define PI2 6.283185307179586 -#define PI_HALF 1.5707963267948966 -#define RECIPROCAL_PI 0.3183098861837907 -#define RECIPROCAL_PI2 0.15915494309189535 -#define EPSILON 1e-6 -#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -#define whiteComplement( a ) ( 1.0 - saturate( a ) ) -float pow2( const in float x ) { return x*x; } -vec3 pow2( const in vec3 x ) { return x*x; } -float pow3( const in float x ) { return x*x*x; } -float pow4( const in float x ) { float x2 = x*x; return x2*x2; } -float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } -float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } -highp float rand( const in vec2 uv ) { - const highp float a = 12.9898, b = 78.233, c = 43758.5453; - highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); - return fract( sin( sn ) * c ); -} -#ifdef HIGH_PRECISION - float precisionSafeLength( vec3 v ) { return length( v ); } -#else - float precisionSafeLength( vec3 v ) { - float maxComponent = max3( abs( v ) ); - return length( v / maxComponent ) * maxComponent; - } -#endif -struct IncidentLight { - vec3 color; - vec3 direction; - bool visible; -}; -struct ReflectedLight { - vec3 directDiffuse; - vec3 directSpecular; - vec3 indirectDiffuse; - vec3 indirectSpecular; -}; -#ifdef USE_ALPHAHASH - varying vec3 vPosition; -#endif -vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); -} -vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); -} -mat3 transposeMat3( const in mat3 m ) { - mat3 tmp; - tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); - tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); - tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); - return tmp; -} -bool isPerspectiveMatrix( mat4 m ) { - return m[ 2 ][ 3 ] == - 1.0; -} -vec2 equirectUv( in vec3 dir ) { - float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; - float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; - return vec2( u, v ); -} -vec3 BRDF_Lambert( const in vec3 diffuseColor ) { - return RECIPROCAL_PI * diffuseColor; -} -vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} -float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,TG=`#ifdef ENVMAP_TYPE_CUBE_UV - #define cubeUV_minMipLevel 4.0 - #define cubeUV_minTileSize 16.0 - float getFace( vec3 direction ) { - vec3 absDirection = abs( direction ); - float face = - 1.0; - if ( absDirection.x > absDirection.z ) { - if ( absDirection.x > absDirection.y ) - face = direction.x > 0.0 ? 0.0 : 3.0; - else - face = direction.y > 0.0 ? 1.0 : 4.0; - } else { - if ( absDirection.z > absDirection.y ) - face = direction.z > 0.0 ? 2.0 : 5.0; - else - face = direction.y > 0.0 ? 1.0 : 4.0; - } - return face; - } - vec2 getUV( vec3 direction, float face ) { - vec2 uv; - if ( face == 0.0 ) { - uv = vec2( direction.z, direction.y ) / abs( direction.x ); - } else if ( face == 1.0 ) { - uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); - } else if ( face == 2.0 ) { - uv = vec2( - direction.x, direction.y ) / abs( direction.z ); - } else if ( face == 3.0 ) { - uv = vec2( - direction.z, direction.y ) / abs( direction.x ); - } else if ( face == 4.0 ) { - uv = vec2( - direction.x, direction.z ) / abs( direction.y ); - } else { - uv = vec2( direction.x, direction.y ) / abs( direction.z ); - } - return 0.5 * ( uv + 1.0 ); - } - vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { - float face = getFace( direction ); - float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); - mipInt = max( mipInt, cubeUV_minMipLevel ); - float faceSize = exp2( mipInt ); - highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; - if ( face > 2.0 ) { - uv.y += faceSize; - face -= 3.0; - } - uv.x += face * faceSize; - uv.x += filterInt * 3.0 * cubeUV_minTileSize; - uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); - uv.x *= CUBEUV_TEXEL_WIDTH; - uv.y *= CUBEUV_TEXEL_HEIGHT; - #ifdef texture2DGradEXT - return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; - #else - return texture2D( envMap, uv ).rgb; - #endif - } - #define cubeUV_r0 1.0 - #define cubeUV_m0 - 2.0 - #define cubeUV_r1 0.8 - #define cubeUV_m1 - 1.0 - #define cubeUV_r4 0.4 - #define cubeUV_m4 2.0 - #define cubeUV_r5 0.305 - #define cubeUV_m5 3.0 - #define cubeUV_r6 0.21 - #define cubeUV_m6 4.0 - float roughnessToMip( float roughness ) { - float mip = 0.0; - if ( roughness >= cubeUV_r1 ) { - mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; - } else if ( roughness >= cubeUV_r4 ) { - mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; - } else if ( roughness >= cubeUV_r5 ) { - mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; - } else if ( roughness >= cubeUV_r6 ) { - mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; - } else { - mip = - 2.0 * log2( 1.16 * roughness ); } - return mip; - } - vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { - float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); - float mipF = fract( mip ); - float mipInt = floor( mip ); - vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); - if ( mipF == 0.0 ) { - return vec4( color0, 1.0 ); - } else { - vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); - return vec4( mix( color0, color1, mipF ), 1.0 ); - } - } -#endif`,wG=`vec3 transformedNormal = objectNormal; -#ifdef USE_TANGENT - vec3 transformedTangent = objectTangent; -#endif -#ifdef USE_BATCHING - mat3 bm = mat3( batchingMatrix ); - transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); - transformedNormal = bm * transformedNormal; - #ifdef USE_TANGENT - transformedTangent = bm * transformedTangent; - #endif -#endif -#ifdef USE_INSTANCING - mat3 im = mat3( instanceMatrix ); - transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); - transformedNormal = im * transformedNormal; - #ifdef USE_TANGENT - transformedTangent = im * transformedTangent; - #endif -#endif -transformedNormal = normalMatrix * transformedNormal; -#ifdef FLIP_SIDED - transformedNormal = - transformedNormal; -#endif -#ifdef USE_TANGENT - transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; - #ifdef FLIP_SIDED - transformedTangent = - transformedTangent; - #endif -#endif`,MG=`#ifdef USE_DISPLACEMENTMAP - uniform sampler2D displacementMap; - uniform float displacementScale; - uniform float displacementBias; -#endif`,EG=`#ifdef USE_DISPLACEMENTMAP - transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,CG=`#ifdef USE_EMISSIVEMAP - vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); - #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE - emissiveColor = sRGBTransferEOTF( emissiveColor ); - #endif - totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,RG=`#ifdef USE_EMISSIVEMAP - uniform sampler2D emissiveMap; -#endif`,NG="gl_FragColor = linearToOutputTexel( gl_FragColor );",DG=`vec4 LinearTransferOETF( in vec4 value ) { - return value; -} -vec4 sRGBTransferEOTF( in vec4 value ) { - return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); -} -vec4 sRGBTransferOETF( in vec4 value ) { - return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); -}`,PG=`#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vec3 cameraToFrag; - if ( isOrthographic ) { - cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToFrag = normalize( vWorldPosition - cameraPosition ); - } - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vec3 reflectVec = reflect( cameraToFrag, worldNormal ); - #else - vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); - #endif - #else - vec3 reflectVec = vReflect; - #endif - #ifdef ENVMAP_TYPE_CUBE - vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); - #else - vec4 envColor = vec4( 0.0 ); - #endif - #ifdef ENVMAP_BLENDING_MULTIPLY - outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_MIX ) - outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_ADD ) - outgoingLight += envColor.xyz * specularStrength * reflectivity; - #endif -#endif`,LG=`#ifdef USE_ENVMAP - uniform float envMapIntensity; - uniform float flipEnvMap; - uniform mat3 envMapRotation; - #ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; - #else - uniform sampler2D envMap; - #endif - -#endif`,UG=`#ifdef USE_ENVMAP - uniform float reflectivity; - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) - #define ENV_WORLDPOS - #endif - #ifdef ENV_WORLDPOS - varying vec3 vWorldPosition; - uniform float refractionRatio; - #else - varying vec3 vReflect; - #endif -#endif`,BG=`#ifdef USE_ENVMAP - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) - #define ENV_WORLDPOS - #endif - #ifdef ENV_WORLDPOS - - varying vec3 vWorldPosition; - #else - varying vec3 vReflect; - uniform float refractionRatio; - #endif -#endif`,OG=`#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vWorldPosition = worldPosition.xyz; - #else - vec3 cameraToVertex; - if ( isOrthographic ) { - cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); - } - vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vReflect = reflect( cameraToVertex, worldNormal ); - #else - vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); - #endif - #endif -#endif`,IG=`#ifdef USE_FOG - vFogDepth = - mvPosition.z; -#endif`,FG=`#ifdef USE_FOG - varying float vFogDepth; -#endif`,kG=`#ifdef USE_FOG - #ifdef FOG_EXP2 - float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); - #else - float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); - #endif - gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,zG=`#ifdef USE_FOG - uniform vec3 fogColor; - varying float vFogDepth; - #ifdef FOG_EXP2 - uniform float fogDensity; - #else - uniform float fogNear; - uniform float fogFar; - #endif -#endif`,GG=`#ifdef USE_GRADIENTMAP - uniform sampler2D gradientMap; -#endif -vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { - float dotNL = dot( normal, lightDirection ); - vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); - #ifdef USE_GRADIENTMAP - return vec3( texture2D( gradientMap, coord ).r ); - #else - vec2 fw = fwidth( coord ) * 0.5; - return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); - #endif -}`,qG=`#ifdef USE_LIGHTMAP - uniform sampler2D lightMap; - uniform float lightMapIntensity; -#endif`,VG=`LambertMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,HG=`varying vec3 vViewPosition; -struct LambertMaterial { - vec3 diffuseColor; - float specularStrength; -}; -void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,jG=`uniform bool receiveShadow; -uniform vec3 ambientLightColor; -#if defined( USE_LIGHT_PROBES ) - uniform vec3 lightProbe[ 9 ]; -#endif -vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { - float x = normal.x, y = normal.y, z = normal.z; - vec3 result = shCoefficients[ 0 ] * 0.886227; - result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; - result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; - result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; - result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; - result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; - result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); - result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; - result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); - return result; -} -vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); - return irradiance; -} -vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { - vec3 irradiance = ambientLightColor; - return irradiance; -} -float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { - float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); - if ( cutoffDistance > 0.0 ) { - distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); - } - return distanceFalloff; -} -float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { - return smoothstep( coneCosine, penumbraCosine, angleCosine ); -} -#if NUM_DIR_LIGHTS > 0 - struct DirectionalLight { - vec3 direction; - vec3 color; - }; - uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; - void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { - light.color = directionalLight.color; - light.direction = directionalLight.direction; - light.visible = true; - } -#endif -#if NUM_POINT_LIGHTS > 0 - struct PointLight { - vec3 position; - vec3 color; - float distance; - float decay; - }; - uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; - void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { - vec3 lVector = pointLight.position - geometryPosition; - light.direction = normalize( lVector ); - float lightDistance = length( lVector ); - light.color = pointLight.color; - light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } -#endif -#if NUM_SPOT_LIGHTS > 0 - struct SpotLight { - vec3 position; - vec3 direction; - vec3 color; - float distance; - float decay; - float coneCos; - float penumbraCos; - }; - uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; - void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { - vec3 lVector = spotLight.position - geometryPosition; - light.direction = normalize( lVector ); - float angleCos = dot( light.direction, spotLight.direction ); - float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); - if ( spotAttenuation > 0.0 ) { - float lightDistance = length( lVector ); - light.color = spotLight.color * spotAttenuation; - light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } else { - light.color = vec3( 0.0 ); - light.visible = false; - } - } -#endif -#if NUM_RECT_AREA_LIGHTS > 0 - struct RectAreaLight { - vec3 color; - vec3 position; - vec3 halfWidth; - vec3 halfHeight; - }; - uniform sampler2D ltc_1; uniform sampler2D ltc_2; - uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; -#endif -#if NUM_HEMI_LIGHTS > 0 - struct HemisphereLight { - vec3 direction; - vec3 skyColor; - vec3 groundColor; - }; - uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; - vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { - float dotNL = dot( normal, hemiLight.direction ); - float hemiDiffuseWeight = 0.5 * dotNL + 0.5; - vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); - return irradiance; - } -#endif`,WG=`#ifdef USE_ENVMAP - vec3 getIBLIrradiance( const in vec3 normal ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); - return PI * envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 reflectVec = reflect( - viewDir, normal ); - reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); - reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); - return envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - #ifdef USE_ANISOTROPY - vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 bentNormal = cross( bitangent, viewDir ); - bentNormal = normalize( cross( bentNormal, bitangent ) ); - bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); - return getIBLRadiance( viewDir, bentNormal, roughness ); - #else - return vec3( 0.0 ); - #endif - } - #endif -#endif`,$G=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,XG=`varying vec3 vViewPosition; -struct ToonMaterial { - vec3 diffuseColor; -}; -void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { - vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,YG=`BlinnPhongMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularColor = specular; -material.specularShininess = shininess; -material.specularStrength = specularStrength;`,QG=`varying vec3 vViewPosition; -struct BlinnPhongMaterial { - vec3 diffuseColor; - vec3 specularColor; - float specularShininess; - float specularStrength; -}; -void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); - reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; -} -void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,KG=`PhysicalMaterial material; -material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); -vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); -float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); -material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; -material.roughness = min( material.roughness, 1.0 ); -#ifdef IOR - material.ior = ior; - #ifdef USE_SPECULAR - float specularIntensityFactor = specularIntensity; - vec3 specularColorFactor = specularColor; - #ifdef USE_SPECULAR_COLORMAP - specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; - #endif - #ifdef USE_SPECULAR_INTENSITYMAP - specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; - #endif - material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); - #else - float specularIntensityFactor = 1.0; - vec3 specularColorFactor = vec3( 1.0 ); - material.specularF90 = 1.0; - #endif - material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); -#else - material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); - material.specularF90 = 1.0; -#endif -#ifdef USE_CLEARCOAT - material.clearcoat = clearcoat; - material.clearcoatRoughness = clearcoatRoughness; - material.clearcoatF0 = vec3( 0.04 ); - material.clearcoatF90 = 1.0; - #ifdef USE_CLEARCOATMAP - material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; - #endif - #ifdef USE_CLEARCOAT_ROUGHNESSMAP - material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; - #endif - material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); - material.clearcoatRoughness += geometryRoughness; - material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); -#endif -#ifdef USE_DISPERSION - material.dispersion = dispersion; -#endif -#ifdef USE_IRIDESCENCE - material.iridescence = iridescence; - material.iridescenceIOR = iridescenceIOR; - #ifdef USE_IRIDESCENCEMAP - material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; - #endif - #ifdef USE_IRIDESCENCE_THICKNESSMAP - material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; - #else - material.iridescenceThickness = iridescenceThicknessMaximum; - #endif -#endif -#ifdef USE_SHEEN - material.sheenColor = sheenColor; - #ifdef USE_SHEEN_COLORMAP - material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; - #endif - material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); - #ifdef USE_SHEEN_ROUGHNESSMAP - material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; - #endif -#endif -#ifdef USE_ANISOTROPY - #ifdef USE_ANISOTROPYMAP - mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); - vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; - vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; - #else - vec2 anisotropyV = anisotropyVector; - #endif - material.anisotropy = length( anisotropyV ); - if( material.anisotropy == 0.0 ) { - anisotropyV = vec2( 1.0, 0.0 ); - } else { - anisotropyV /= material.anisotropy; - material.anisotropy = saturate( material.anisotropy ); - } - material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); - material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; - material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,ZG=`struct PhysicalMaterial { - vec3 diffuseColor; - float roughness; - vec3 specularColor; - float specularF90; - float dispersion; - #ifdef USE_CLEARCOAT - float clearcoat; - float clearcoatRoughness; - vec3 clearcoatF0; - float clearcoatF90; - #endif - #ifdef USE_IRIDESCENCE - float iridescence; - float iridescenceIOR; - float iridescenceThickness; - vec3 iridescenceFresnel; - vec3 iridescenceF0; - #endif - #ifdef USE_SHEEN - vec3 sheenColor; - float sheenRoughness; - #endif - #ifdef IOR - float ior; - #endif - #ifdef USE_TRANSMISSION - float transmission; - float transmissionAlpha; - float thickness; - float attenuationDistance; - vec3 attenuationColor; - #endif - #ifdef USE_ANISOTROPY - float anisotropy; - float alphaT; - vec3 anisotropyT; - vec3 anisotropyB; - #endif -}; -vec3 clearcoatSpecularDirect = vec3( 0.0 ); -vec3 clearcoatSpecularIndirect = vec3( 0.0 ); -vec3 sheenSpecularDirect = vec3( 0.0 ); -vec3 sheenSpecularIndirect = vec3(0.0 ); -vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { - float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); - float x2 = x * x; - float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); - return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); -} -float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { - float a2 = pow2( alpha ); - float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); - float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); - return 0.5 / max( gv + gl, EPSILON ); -} -float D_GGX( const in float alpha, const in float dotNH ) { - float a2 = pow2( alpha ); - float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; - return RECIPROCAL_PI * a2 / pow2( denom ); -} -#ifdef USE_ANISOTROPY - float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { - float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); - float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); - float v = 0.5 / ( gv + gl ); - return saturate(v); - } - float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { - float a2 = alphaT * alphaB; - highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); - highp float v2 = dot( v, v ); - float w2 = a2 / v2; - return RECIPROCAL_PI * a2 * pow2 ( w2 ); - } -#endif -#ifdef USE_CLEARCOAT - vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { - vec3 f0 = material.clearcoatF0; - float f90 = material.clearcoatF90; - float roughness = material.clearcoatRoughness; - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - return F * ( V * D ); - } -#endif -vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { - vec3 f0 = material.specularColor; - float f90 = material.specularF90; - float roughness = material.roughness; - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - #ifdef USE_IRIDESCENCE - F = mix( F, material.iridescenceFresnel, material.iridescence ); - #endif - #ifdef USE_ANISOTROPY - float dotTL = dot( material.anisotropyT, lightDir ); - float dotTV = dot( material.anisotropyT, viewDir ); - float dotTH = dot( material.anisotropyT, halfDir ); - float dotBL = dot( material.anisotropyB, lightDir ); - float dotBV = dot( material.anisotropyB, viewDir ); - float dotBH = dot( material.anisotropyB, halfDir ); - float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); - float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); - #else - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - #endif - return F * ( V * D ); -} -vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { - const float LUT_SIZE = 64.0; - const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; - const float LUT_BIAS = 0.5 / LUT_SIZE; - float dotNV = saturate( dot( N, V ) ); - vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); - uv = uv * LUT_SCALE + LUT_BIAS; - return uv; -} -float LTC_ClippedSphereFormFactor( const in vec3 f ) { - float l = length( f ); - return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); -} -vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { - float x = dot( v1, v2 ); - float y = abs( x ); - float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; - float b = 3.4175940 + ( 4.1616724 + y ) * y; - float v = a / b; - float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; - return cross( v1, v2 ) * theta_sintheta; -} -vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { - vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; - vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; - vec3 lightNormal = cross( v1, v2 ); - if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); - vec3 T1, T2; - T1 = normalize( V - N * dot( V, N ) ); - T2 = - cross( N, T1 ); - mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); - vec3 coords[ 4 ]; - coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); - coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); - coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); - coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); - coords[ 0 ] = normalize( coords[ 0 ] ); - coords[ 1 ] = normalize( coords[ 1 ] ); - coords[ 2 ] = normalize( coords[ 2 ] ); - coords[ 3 ] = normalize( coords[ 3 ] ); - vec3 vectorFormFactor = vec3( 0.0 ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); - float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); - return vec3( result ); -} -#if defined( USE_SHEEN ) -float D_Charlie( float roughness, float dotNH ) { - float alpha = pow2( roughness ); - float invAlpha = 1.0 / alpha; - float cos2h = dotNH * dotNH; - float sin2h = max( 1.0 - cos2h, 0.0078125 ); - return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); -} -float V_Neubelt( float dotNV, float dotNL ) { - return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); -} -vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float D = D_Charlie( sheenRoughness, dotNH ); - float V = V_Neubelt( dotNV, dotNL ); - return sheenColor * ( D * V ); -} -#endif -float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - float r2 = roughness * roughness; - float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; - float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; - float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); - return saturate( DG * RECIPROCAL_PI ); -} -vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); - const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); - vec4 r = roughness * c0 + c1; - float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; - vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; - return fab; -} -vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { - vec2 fab = DFGApprox( normal, viewDir, roughness ); - return specularColor * fab.x + specularF90 * fab.y; -} -#ifdef USE_IRIDESCENCE -void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { -#else -void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { -#endif - vec2 fab = DFGApprox( normal, viewDir, roughness ); - #ifdef USE_IRIDESCENCE - vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); - #else - vec3 Fr = specularColor; - #endif - vec3 FssEss = Fr * fab.x + specularF90 * fab.y; - float Ess = fab.x + fab.y; - float Ems = 1.0 - Ess; - vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); - singleScatter += FssEss; - multiScatter += Fms * Ems; -} -#if NUM_RECT_AREA_LIGHTS > 0 - void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - vec3 normal = geometryNormal; - vec3 viewDir = geometryViewDir; - vec3 position = geometryPosition; - vec3 lightPos = rectAreaLight.position; - vec3 halfWidth = rectAreaLight.halfWidth; - vec3 halfHeight = rectAreaLight.halfHeight; - vec3 lightColor = rectAreaLight.color; - float roughness = material.roughness; - vec3 rectCoords[ 4 ]; - rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; - rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; - rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; - vec2 uv = LTC_Uv( normal, viewDir, roughness ); - vec4 t1 = texture2D( ltc_1, uv ); - vec4 t2 = texture2D( ltc_2, uv ); - mat3 mInv = mat3( - vec3( t1.x, 0, t1.y ), - vec3( 0, 1, 0 ), - vec3( t1.z, 0, t1.w ) - ); - vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); - reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); - reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); - } -#endif -void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - #ifdef USE_CLEARCOAT - float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); - vec3 ccIrradiance = dotNLcc * directLight.color; - clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); - #endif - #ifdef USE_SHEEN - sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); - #endif - reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { - #ifdef USE_CLEARCOAT - clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); - #endif - #ifdef USE_SHEEN - sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); - #endif - vec3 singleScattering = vec3( 0.0 ); - vec3 multiScattering = vec3( 0.0 ); - vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; - #ifdef USE_IRIDESCENCE - computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); - #else - computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); - #endif - vec3 totalScattering = singleScattering + multiScattering; - vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); - reflectedLight.indirectSpecular += radiance * singleScattering; - reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; - reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; -} -#define RE_Direct RE_Direct_Physical -#define RE_Direct_RectArea RE_Direct_RectArea_Physical -#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical -#define RE_IndirectSpecular RE_IndirectSpecular_Physical -float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { - return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,JG=` -vec3 geometryPosition = - vViewPosition; -vec3 geometryNormal = normal; -vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); -vec3 geometryClearcoatNormal = vec3( 0.0 ); -#ifdef USE_CLEARCOAT - geometryClearcoatNormal = clearcoatNormal; -#endif -#ifdef USE_IRIDESCENCE - float dotNVi = saturate( dot( normal, geometryViewDir ) ); - if ( material.iridescenceThickness == 0.0 ) { - material.iridescence = 0.0; - } else { - material.iridescence = saturate( material.iridescence ); - } - if ( material.iridescence > 0.0 ) { - material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); - material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); - } -#endif -IncidentLight directLight; -#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) - PointLight pointLight; - #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { - pointLight = pointLights[ i ]; - getPointLightInfo( pointLight, geometryPosition, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) - pointLightShadow = pointLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) - SpotLight spotLight; - vec4 spotColor; - vec3 spotLightCoord; - bool inSpotLightMap; - #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { - spotLight = spotLights[ i ]; - getSpotLightInfo( spotLight, geometryPosition, directLight ); - #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) - #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX - #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS - #else - #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) - #endif - #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) - spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; - inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); - spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); - directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; - #endif - #undef SPOT_LIGHT_MAP_INDEX - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - spotLightShadow = spotLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) - DirectionalLight directionalLight; - #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { - directionalLight = directionalLights[ i ]; - getDirectionalLightInfo( directionalLight, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) - directionalLightShadow = directionalLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) - RectAreaLight rectAreaLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { - rectAreaLight = rectAreaLights[ i ]; - RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if defined( RE_IndirectDiffuse ) - vec3 iblIrradiance = vec3( 0.0 ); - vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); - #if defined( USE_LIGHT_PROBES ) - irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); - #endif - #if ( NUM_HEMI_LIGHTS > 0 ) - #pragma unroll_loop_start - for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { - irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); - } - #pragma unroll_loop_end - #endif -#endif -#if defined( RE_IndirectSpecular ) - vec3 radiance = vec3( 0.0 ); - vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,eq=`#if defined( RE_IndirectDiffuse ) - #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); - vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; - irradiance += lightMapIrradiance; - #endif - #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) - iblIrradiance += getIBLIrradiance( geometryNormal ); - #endif -#endif -#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) - #ifdef USE_ANISOTROPY - radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); - #else - radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); - #endif - #ifdef USE_CLEARCOAT - clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); - #endif -#endif`,tq=`#if defined( RE_IndirectDiffuse ) - RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif -#if defined( RE_IndirectSpecular ) - RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,nq=`#if defined( USE_LOGDEPTHBUF ) - gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,iq=`#if defined( USE_LOGDEPTHBUF ) - uniform float logDepthBufFC; - varying float vFragDepth; - varying float vIsPerspective; -#endif`,rq=`#ifdef USE_LOGDEPTHBUF - varying float vFragDepth; - varying float vIsPerspective; -#endif`,sq=`#ifdef USE_LOGDEPTHBUF - vFragDepth = 1.0 + gl_Position.w; - vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,aq=`#ifdef USE_MAP - vec4 sampledDiffuseColor = texture2D( map, vMapUv ); - #ifdef DECODE_VIDEO_TEXTURE - sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); - #endif - diffuseColor *= sampledDiffuseColor; -#endif`,oq=`#ifdef USE_MAP - uniform sampler2D map; -#endif`,lq=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - #if defined( USE_POINTS_UV ) - vec2 uv = vUv; - #else - vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; - #endif -#endif -#ifdef USE_MAP - diffuseColor *= texture2D( map, uv ); -#endif -#ifdef USE_ALPHAMAP - diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,uq=`#if defined( USE_POINTS_UV ) - varying vec2 vUv; -#else - #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - uniform mat3 uvTransform; - #endif -#endif -#ifdef USE_MAP - uniform sampler2D map; -#endif -#ifdef USE_ALPHAMAP - uniform sampler2D alphaMap; -#endif`,cq=`float metalnessFactor = metalness; -#ifdef USE_METALNESSMAP - vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); - metalnessFactor *= texelMetalness.b; -#endif`,hq=`#ifdef USE_METALNESSMAP - uniform sampler2D metalnessMap; -#endif`,fq=`#ifdef USE_INSTANCING_MORPH - float morphTargetInfluences[ MORPHTARGETS_COUNT ]; - float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; - } -#endif`,Aq=`#if defined( USE_MORPHCOLORS ) - vColor *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - #if defined( USE_COLOR_ALPHA ) - if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; - #elif defined( USE_COLOR ) - if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; - #endif - } -#endif`,dq=`#ifdef USE_MORPHNORMALS - objectNormal *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; - } -#endif`,pq=`#ifdef USE_MORPHTARGETS - #ifndef USE_INSTANCING_MORPH - uniform float morphTargetBaseInfluence; - uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; - #endif - uniform sampler2DArray morphTargetsTexture; - uniform ivec2 morphTargetsTextureSize; - vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { - int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; - int y = texelIndex / morphTargetsTextureSize.x; - int x = texelIndex - y * morphTargetsTextureSize.x; - ivec3 morphUV = ivec3( x, y, morphTargetIndex ); - return texelFetch( morphTargetsTexture, morphUV, 0 ); - } -#endif`,mq=`#ifdef USE_MORPHTARGETS - transformed *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; - } -#endif`,gq=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; -#ifdef FLAT_SHADED - vec3 fdx = dFdx( vViewPosition ); - vec3 fdy = dFdy( vViewPosition ); - vec3 normal = normalize( cross( fdx, fdy ) ); -#else - vec3 normal = normalize( vNormal ); - #ifdef DOUBLE_SIDED - normal *= faceDirection; - #endif -#endif -#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) - #ifdef USE_TANGENT - mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); - #else - mat3 tbn = getTangentFrame( - vViewPosition, normal, - #if defined( USE_NORMALMAP ) - vNormalMapUv - #elif defined( USE_CLEARCOAT_NORMALMAP ) - vClearcoatNormalMapUv - #else - vUv - #endif - ); - #endif - #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) - tbn[0] *= faceDirection; - tbn[1] *= faceDirection; - #endif -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - #ifdef USE_TANGENT - mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); - #else - mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); - #endif - #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) - tbn2[0] *= faceDirection; - tbn2[1] *= faceDirection; - #endif -#endif -vec3 nonPerturbedNormal = normal;`,vq=`#ifdef USE_NORMALMAP_OBJECTSPACE - normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; - #ifdef FLIP_SIDED - normal = - normal; - #endif - #ifdef DOUBLE_SIDED - normal = normal * faceDirection; - #endif - normal = normalize( normalMatrix * normal ); -#elif defined( USE_NORMALMAP_TANGENTSPACE ) - vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; - mapN.xy *= normalScale; - normal = normalize( tbn * mapN ); -#elif defined( USE_BUMPMAP ) - normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,_q=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,yq=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,xq=`#ifndef FLAT_SHADED - vNormal = normalize( transformedNormal ); - #ifdef USE_TANGENT - vTangent = normalize( transformedTangent ); - vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); - #endif -#endif`,bq=`#ifdef USE_NORMALMAP - uniform sampler2D normalMap; - uniform vec2 normalScale; -#endif -#ifdef USE_NORMALMAP_OBJECTSPACE - uniform mat3 normalMatrix; -#endif -#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) - mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { - vec3 q0 = dFdx( eye_pos.xyz ); - vec3 q1 = dFdy( eye_pos.xyz ); - vec2 st0 = dFdx( uv.st ); - vec2 st1 = dFdy( uv.st ); - vec3 N = surf_norm; - vec3 q1perp = cross( q1, N ); - vec3 q0perp = cross( N, q0 ); - vec3 T = q1perp * st0.x + q0perp * st1.x; - vec3 B = q1perp * st0.y + q0perp * st1.y; - float det = max( dot( T, T ), dot( B, B ) ); - float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); - return mat3( T * scale, B * scale, N ); - } -#endif`,Sq=`#ifdef USE_CLEARCOAT - vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,Tq=`#ifdef USE_CLEARCOAT_NORMALMAP - vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; - clearcoatMapN.xy *= clearcoatNormalScale; - clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,wq=`#ifdef USE_CLEARCOATMAP - uniform sampler2D clearcoatMap; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - uniform sampler2D clearcoatNormalMap; - uniform vec2 clearcoatNormalScale; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - uniform sampler2D clearcoatRoughnessMap; -#endif`,Mq=`#ifdef USE_IRIDESCENCEMAP - uniform sampler2D iridescenceMap; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - uniform sampler2D iridescenceThicknessMap; -#endif`,Eq=`#ifdef OPAQUE -diffuseColor.a = 1.0; -#endif -#ifdef USE_TRANSMISSION -diffuseColor.a *= material.transmissionAlpha; -#endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Cq=`vec3 packNormalToRGB( const in vec3 normal ) { - return normalize( normal ) * 0.5 + 0.5; -} -vec3 unpackRGBToNormal( const in vec3 rgb ) { - return 2.0 * rgb.xyz - 1.0; -} -const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; -const float Inv255 = 1. / 255.; -const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); -const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); -const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); -const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); -vec4 packDepthToRGBA( const in float v ) { - if( v <= 0.0 ) - return vec4( 0., 0., 0., 0. ); - if( v >= 1.0 ) - return vec4( 1., 1., 1., 1. ); - float vuf; - float af = modf( v * PackFactors.a, vuf ); - float bf = modf( vuf * ShiftRight8, vuf ); - float gf = modf( vuf * ShiftRight8, vuf ); - return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); -} -vec3 packDepthToRGB( const in float v ) { - if( v <= 0.0 ) - return vec3( 0., 0., 0. ); - if( v >= 1.0 ) - return vec3( 1., 1., 1. ); - float vuf; - float bf = modf( v * PackFactors.b, vuf ); - float gf = modf( vuf * ShiftRight8, vuf ); - return vec3( vuf * Inv255, gf * PackUpscale, bf ); -} -vec2 packDepthToRG( const in float v ) { - if( v <= 0.0 ) - return vec2( 0., 0. ); - if( v >= 1.0 ) - return vec2( 1., 1. ); - float vuf; - float gf = modf( v * 256., vuf ); - return vec2( vuf * Inv255, gf ); -} -float unpackRGBAToDepth( const in vec4 v ) { - return dot( v, UnpackFactors4 ); -} -float unpackRGBToDepth( const in vec3 v ) { - return dot( v, UnpackFactors3 ); -} -float unpackRGToDepth( const in vec2 v ) { - return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; -} -vec4 pack2HalfToRGBA( const in vec2 v ) { - vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); - return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); -} -vec2 unpackRGBATo2Half( const in vec4 v ) { - return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); -} -float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { - return ( viewZ + near ) / ( near - far ); -} -float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { - return depth * ( near - far ) - near; -} -float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { - return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); -} -float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { - return ( near * far ) / ( ( far - near ) * depth - far ); -}`,Rq=`#ifdef PREMULTIPLIED_ALPHA - gl_FragColor.rgb *= gl_FragColor.a; -#endif`,Nq=`vec4 mvPosition = vec4( transformed, 1.0 ); -#ifdef USE_BATCHING - mvPosition = batchingMatrix * mvPosition; -#endif -#ifdef USE_INSTANCING - mvPosition = instanceMatrix * mvPosition; -#endif -mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,Dq=`#ifdef DITHERING - gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,Pq=`#ifdef DITHERING - vec3 dithering( vec3 color ) { - float grid_position = rand( gl_FragCoord.xy ); - vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); - dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); - return color + dither_shift_RGB; - } -#endif`,Lq=`float roughnessFactor = roughness; -#ifdef USE_ROUGHNESSMAP - vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); - roughnessFactor *= texelRoughness.g; -#endif`,Uq=`#ifdef USE_ROUGHNESSMAP - uniform sampler2D roughnessMap; -#endif`,Bq=`#if NUM_SPOT_LIGHT_COORDS > 0 - varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; -#endif -#if NUM_SPOT_LIGHT_MAPS > 0 - uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; -#endif -#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; - struct SpotLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif - float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { - return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); - } - vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { - return unpackRGBATo2Half( texture2D( shadow, uv ) ); - } - float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ - float occlusion = 1.0; - vec2 distribution = texture2DDistribution( shadow, uv ); - float hard_shadow = step( compare , distribution.x ); - if (hard_shadow != 1.0 ) { - float distance = compare - distribution.x ; - float variance = max( 0.00000, distribution.y * distribution.y ); - float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); - } - return occlusion; - } - float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { - float shadow = 1.0; - shadowCoord.xyz /= shadowCoord.w; - shadowCoord.z += shadowBias; - bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; - bool frustumTest = inFrustum && shadowCoord.z <= 1.0; - if ( frustumTest ) { - #if defined( SHADOWMAP_TYPE_PCF ) - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float dx0 = - texelSize.x * shadowRadius; - float dy0 = - texelSize.y * shadowRadius; - float dx1 = + texelSize.x * shadowRadius; - float dy1 = + texelSize.y * shadowRadius; - float dx2 = dx0 / 2.0; - float dy2 = dy0 / 2.0; - float dx3 = dx1 / 2.0; - float dy3 = dy1 / 2.0; - shadow = ( - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) - ) * ( 1.0 / 17.0 ); - #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float dx = texelSize.x; - float dy = texelSize.y; - vec2 uv = shadowCoord.xy; - vec2 f = fract( uv * shadowMapSize + 0.5 ); - uv -= f * texelSize; - shadow = ( - texture2DCompare( shadowMap, uv, shadowCoord.z ) + - texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + - texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), - f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), - f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), - f.y ) + - mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), - f.y ) + - mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), - f.x ), - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), - f.x ), - f.y ) - ) * ( 1.0 / 9.0 ); - #elif defined( SHADOWMAP_TYPE_VSM ) - shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); - #else - shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); - #endif - } - return mix( 1.0, shadow, shadowIntensity ); - } - vec2 cubeToUV( vec3 v, float texelSizeY ) { - vec3 absV = abs( v ); - float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); - absV *= scaleToCube; - v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); - vec2 planar = v.xy; - float almostATexel = 1.5 * texelSizeY; - float almostOne = 1.0 - almostATexel; - if ( absV.z >= almostOne ) { - if ( v.z > 0.0 ) - planar.x = 4.0 - v.x; - } else if ( absV.x >= almostOne ) { - float signX = sign( v.x ); - planar.x = v.z * signX + 2.0 * signX; - } else if ( absV.y >= almostOne ) { - float signY = sign( v.y ); - planar.x = v.x + 2.0 * signY + 2.0; - planar.y = v.z * signY - 2.0; - } - return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); - } - float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { - float shadow = 1.0; - vec3 lightToPosition = shadowCoord.xyz; - - float lightToPositionLength = length( lightToPosition ); - if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { - float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; - vec3 bd3D = normalize( lightToPosition ); - vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); - #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) - vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; - shadow = ( - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) - ) * ( 1.0 / 9.0 ); - #else - shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); - #endif - } - return mix( 1.0, shadow, shadowIntensity ); - } -#endif`,Oq=`#if NUM_SPOT_LIGHT_COORDS > 0 - uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; - varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; -#endif -#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - struct SpotLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif -#endif`,Iq=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) - vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - vec4 shadowWorldPosition; -#endif -#if defined( USE_SHADOWMAP ) - #if NUM_DIR_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); - vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); - vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif -#endif -#if NUM_SPOT_LIGHT_COORDS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { - shadowWorldPosition = worldPosition; - #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; - #endif - vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end -#endif`,Fq=`float getShadowMask() { - float shadow = 1.0; - #ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - directionalLight = directionalLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { - spotLight = spotLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - pointLight = pointLightShadows[ i ]; - shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; - } - #pragma unroll_loop_end - #endif - #endif - return shadow; -}`,kq=`#ifdef USE_SKINNING - mat4 boneMatX = getBoneMatrix( skinIndex.x ); - mat4 boneMatY = getBoneMatrix( skinIndex.y ); - mat4 boneMatZ = getBoneMatrix( skinIndex.z ); - mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,zq=`#ifdef USE_SKINNING - uniform mat4 bindMatrix; - uniform mat4 bindMatrixInverse; - uniform highp sampler2D boneTexture; - mat4 getBoneMatrix( const in float i ) { - int size = textureSize( boneTexture, 0 ).x; - int j = int( i ) * 4; - int x = j % size; - int y = j / size; - vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); - vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); - vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); - vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); - return mat4( v1, v2, v3, v4 ); - } -#endif`,Gq=`#ifdef USE_SKINNING - vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); - vec4 skinned = vec4( 0.0 ); - skinned += boneMatX * skinVertex * skinWeight.x; - skinned += boneMatY * skinVertex * skinWeight.y; - skinned += boneMatZ * skinVertex * skinWeight.z; - skinned += boneMatW * skinVertex * skinWeight.w; - transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,qq=`#ifdef USE_SKINNING - mat4 skinMatrix = mat4( 0.0 ); - skinMatrix += skinWeight.x * boneMatX; - skinMatrix += skinWeight.y * boneMatY; - skinMatrix += skinWeight.z * boneMatZ; - skinMatrix += skinWeight.w * boneMatW; - skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; - objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; - #ifdef USE_TANGENT - objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; - #endif -#endif`,Vq=`float specularStrength; -#ifdef USE_SPECULARMAP - vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); - specularStrength = texelSpecular.r; -#else - specularStrength = 1.0; -#endif`,Hq=`#ifdef USE_SPECULARMAP - uniform sampler2D specularMap; -#endif`,jq=`#if defined( TONE_MAPPING ) - gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,Wq=`#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -uniform float toneMappingExposure; -vec3 LinearToneMapping( vec3 color ) { - return saturate( toneMappingExposure * color ); -} -vec3 ReinhardToneMapping( vec3 color ) { - color *= toneMappingExposure; - return saturate( color / ( vec3( 1.0 ) + color ) ); -} -vec3 CineonToneMapping( vec3 color ) { - color *= toneMappingExposure; - color = max( vec3( 0.0 ), color - 0.004 ); - return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); -} -vec3 RRTAndODTFit( vec3 v ) { - vec3 a = v * ( v + 0.0245786 ) - 0.000090537; - vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; - return a / b; -} -vec3 ACESFilmicToneMapping( vec3 color ) { - const mat3 ACESInputMat = mat3( - vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), - vec3( 0.04823, 0.01566, 0.83777 ) - ); - const mat3 ACESOutputMat = mat3( - vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), - vec3( -0.07367, -0.00605, 1.07602 ) - ); - color *= toneMappingExposure / 0.6; - color = ACESInputMat * color; - color = RRTAndODTFit( color ); - color = ACESOutputMat * color; - return saturate( color ); -} -const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( - vec3( 1.6605, - 0.1246, - 0.0182 ), - vec3( - 0.5876, 1.1329, - 0.1006 ), - vec3( - 0.0728, - 0.0083, 1.1187 ) -); -const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( - vec3( 0.6274, 0.0691, 0.0164 ), - vec3( 0.3293, 0.9195, 0.0880 ), - vec3( 0.0433, 0.0113, 0.8956 ) -); -vec3 agxDefaultContrastApprox( vec3 x ) { - vec3 x2 = x * x; - vec3 x4 = x2 * x2; - return + 15.5 * x4 * x2 - - 40.14 * x4 * x - + 31.96 * x4 - - 6.868 * x2 * x - + 0.4298 * x2 - + 0.1191 * x - - 0.00232; -} -vec3 AgXToneMapping( vec3 color ) { - const mat3 AgXInsetMatrix = mat3( - vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), - vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), - vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) - ); - const mat3 AgXOutsetMatrix = mat3( - vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), - vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), - vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) - ); - const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; - color *= toneMappingExposure; - color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; - color = AgXInsetMatrix * color; - color = max( color, 1e-10 ); color = log2( color ); - color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); - color = clamp( color, 0.0, 1.0 ); - color = agxDefaultContrastApprox( color ); - color = AgXOutsetMatrix * color; - color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); - color = LINEAR_REC2020_TO_LINEAR_SRGB * color; - color = clamp( color, 0.0, 1.0 ); - return color; -} -vec3 NeutralToneMapping( vec3 color ) { - const float StartCompression = 0.8 - 0.04; - const float Desaturation = 0.15; - color *= toneMappingExposure; - float x = min( color.r, min( color.g, color.b ) ); - float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; - color -= offset; - float peak = max( color.r, max( color.g, color.b ) ); - if ( peak < StartCompression ) return color; - float d = 1. - StartCompression; - float newPeak = 1. - d * d / ( peak + d - StartCompression ); - color *= newPeak / peak; - float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); - return mix( color, vec3( newPeak ), g ); -} -vec3 CustomToneMapping( vec3 color ) { return color; }`,$q=`#ifdef USE_TRANSMISSION - material.transmission = transmission; - material.transmissionAlpha = 1.0; - material.thickness = thickness; - material.attenuationDistance = attenuationDistance; - material.attenuationColor = attenuationColor; - #ifdef USE_TRANSMISSIONMAP - material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; - #endif - #ifdef USE_THICKNESSMAP - material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; - #endif - vec3 pos = vWorldPosition; - vec3 v = normalize( cameraPosition - pos ); - vec3 n = inverseTransformDirection( normal, viewMatrix ); - vec4 transmitted = getIBLVolumeRefraction( - n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, - pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, - material.attenuationColor, material.attenuationDistance ); - material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); - totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,Xq=`#ifdef USE_TRANSMISSION - uniform float transmission; - uniform float thickness; - uniform float attenuationDistance; - uniform vec3 attenuationColor; - #ifdef USE_TRANSMISSIONMAP - uniform sampler2D transmissionMap; - #endif - #ifdef USE_THICKNESSMAP - uniform sampler2D thicknessMap; - #endif - uniform vec2 transmissionSamplerSize; - uniform sampler2D transmissionSamplerMap; - uniform mat4 modelMatrix; - uniform mat4 projectionMatrix; - varying vec3 vWorldPosition; - float w0( float a ) { - return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); - } - float w1( float a ) { - return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); - } - float w2( float a ){ - return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); - } - float w3( float a ) { - return ( 1.0 / 6.0 ) * ( a * a * a ); - } - float g0( float a ) { - return w0( a ) + w1( a ); - } - float g1( float a ) { - return w2( a ) + w3( a ); - } - float h0( float a ) { - return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); - } - float h1( float a ) { - return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); - } - vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { - uv = uv * texelSize.zw + 0.5; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - float g0x = g0( fuv.x ); - float g1x = g1( fuv.x ); - float h0x = h0( fuv.x ); - float h1x = h1( fuv.x ); - float h0y = h0( fuv.y ); - float h1y = h1( fuv.y ); - vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; - vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; - vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; - vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; - return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + - g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); - } - vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { - vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); - vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); - vec2 fLodSizeInv = 1.0 / fLodSize; - vec2 cLodSizeInv = 1.0 / cLodSize; - vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); - vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); - return mix( fSample, cSample, fract( lod ) ); - } - vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { - vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); - vec3 modelScale; - modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); - modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); - modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); - return normalize( refractionVector ) * thickness * modelScale; - } - float applyIorToRoughness( const in float roughness, const in float ior ) { - return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); - } - vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { - float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); - return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); - } - vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { - if ( isinf( attenuationDistance ) ) { - return vec3( 1.0 ); - } else { - vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; - vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; - } - } - vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, - const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, - const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, - const in vec3 attenuationColor, const in float attenuationDistance ) { - vec4 transmittedLight; - vec3 transmittance; - #ifdef USE_DISPERSION - float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; - vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); - for ( int i = 0; i < 3; i ++ ) { - vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); - vec3 refractedRayExit = position + transmissionRay; - vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); - vec2 refractionCoords = ndcPos.xy / ndcPos.w; - refractionCoords += 1.0; - refractionCoords /= 2.0; - vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); - transmittedLight[ i ] = transmissionSample[ i ]; - transmittedLight.a += transmissionSample.a; - transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; - } - transmittedLight.a /= 3.0; - #else - vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); - vec3 refractedRayExit = position + transmissionRay; - vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); - vec2 refractionCoords = ndcPos.xy / ndcPos.w; - refractionCoords += 1.0; - refractionCoords /= 2.0; - transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); - transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); - #endif - vec3 attenuatedColor = transmittance * transmittedLight.rgb; - vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); - float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; - return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); - } -#endif`,Yq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - varying vec2 vUv; -#endif -#ifdef USE_MAP - varying vec2 vMapUv; -#endif -#ifdef USE_ALPHAMAP - varying vec2 vAlphaMapUv; -#endif -#ifdef USE_LIGHTMAP - varying vec2 vLightMapUv; -#endif -#ifdef USE_AOMAP - varying vec2 vAoMapUv; -#endif -#ifdef USE_BUMPMAP - varying vec2 vBumpMapUv; -#endif -#ifdef USE_NORMALMAP - varying vec2 vNormalMapUv; -#endif -#ifdef USE_EMISSIVEMAP - varying vec2 vEmissiveMapUv; -#endif -#ifdef USE_METALNESSMAP - varying vec2 vMetalnessMapUv; -#endif -#ifdef USE_ROUGHNESSMAP - varying vec2 vRoughnessMapUv; -#endif -#ifdef USE_ANISOTROPYMAP - varying vec2 vAnisotropyMapUv; -#endif -#ifdef USE_CLEARCOATMAP - varying vec2 vClearcoatMapUv; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - varying vec2 vClearcoatNormalMapUv; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - varying vec2 vClearcoatRoughnessMapUv; -#endif -#ifdef USE_IRIDESCENCEMAP - varying vec2 vIridescenceMapUv; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - varying vec2 vIridescenceThicknessMapUv; -#endif -#ifdef USE_SHEEN_COLORMAP - varying vec2 vSheenColorMapUv; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - varying vec2 vSheenRoughnessMapUv; -#endif -#ifdef USE_SPECULARMAP - varying vec2 vSpecularMapUv; -#endif -#ifdef USE_SPECULAR_COLORMAP - varying vec2 vSpecularColorMapUv; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - varying vec2 vSpecularIntensityMapUv; -#endif -#ifdef USE_TRANSMISSIONMAP - uniform mat3 transmissionMapTransform; - varying vec2 vTransmissionMapUv; -#endif -#ifdef USE_THICKNESSMAP - uniform mat3 thicknessMapTransform; - varying vec2 vThicknessMapUv; -#endif`,Qq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - varying vec2 vUv; -#endif -#ifdef USE_MAP - uniform mat3 mapTransform; - varying vec2 vMapUv; -#endif -#ifdef USE_ALPHAMAP - uniform mat3 alphaMapTransform; - varying vec2 vAlphaMapUv; -#endif -#ifdef USE_LIGHTMAP - uniform mat3 lightMapTransform; - varying vec2 vLightMapUv; -#endif -#ifdef USE_AOMAP - uniform mat3 aoMapTransform; - varying vec2 vAoMapUv; -#endif -#ifdef USE_BUMPMAP - uniform mat3 bumpMapTransform; - varying vec2 vBumpMapUv; -#endif -#ifdef USE_NORMALMAP - uniform mat3 normalMapTransform; - varying vec2 vNormalMapUv; -#endif -#ifdef USE_DISPLACEMENTMAP - uniform mat3 displacementMapTransform; - varying vec2 vDisplacementMapUv; -#endif -#ifdef USE_EMISSIVEMAP - uniform mat3 emissiveMapTransform; - varying vec2 vEmissiveMapUv; -#endif -#ifdef USE_METALNESSMAP - uniform mat3 metalnessMapTransform; - varying vec2 vMetalnessMapUv; -#endif -#ifdef USE_ROUGHNESSMAP - uniform mat3 roughnessMapTransform; - varying vec2 vRoughnessMapUv; -#endif -#ifdef USE_ANISOTROPYMAP - uniform mat3 anisotropyMapTransform; - varying vec2 vAnisotropyMapUv; -#endif -#ifdef USE_CLEARCOATMAP - uniform mat3 clearcoatMapTransform; - varying vec2 vClearcoatMapUv; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - uniform mat3 clearcoatNormalMapTransform; - varying vec2 vClearcoatNormalMapUv; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - uniform mat3 clearcoatRoughnessMapTransform; - varying vec2 vClearcoatRoughnessMapUv; -#endif -#ifdef USE_SHEEN_COLORMAP - uniform mat3 sheenColorMapTransform; - varying vec2 vSheenColorMapUv; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - uniform mat3 sheenRoughnessMapTransform; - varying vec2 vSheenRoughnessMapUv; -#endif -#ifdef USE_IRIDESCENCEMAP - uniform mat3 iridescenceMapTransform; - varying vec2 vIridescenceMapUv; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - uniform mat3 iridescenceThicknessMapTransform; - varying vec2 vIridescenceThicknessMapUv; -#endif -#ifdef USE_SPECULARMAP - uniform mat3 specularMapTransform; - varying vec2 vSpecularMapUv; -#endif -#ifdef USE_SPECULAR_COLORMAP - uniform mat3 specularColorMapTransform; - varying vec2 vSpecularColorMapUv; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - uniform mat3 specularIntensityMapTransform; - varying vec2 vSpecularIntensityMapUv; -#endif -#ifdef USE_TRANSMISSIONMAP - uniform mat3 transmissionMapTransform; - varying vec2 vTransmissionMapUv; -#endif -#ifdef USE_THICKNESSMAP - uniform mat3 thicknessMapTransform; - varying vec2 vThicknessMapUv; -#endif`,Kq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - vUv = vec3( uv, 1 ).xy; -#endif -#ifdef USE_MAP - vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ALPHAMAP - vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_LIGHTMAP - vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_AOMAP - vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_BUMPMAP - vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_NORMALMAP - vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_DISPLACEMENTMAP - vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_EMISSIVEMAP - vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_METALNESSMAP - vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ROUGHNESSMAP - vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ANISOTROPYMAP - vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOATMAP - vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_IRIDESCENCEMAP - vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SHEEN_COLORMAP - vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULARMAP - vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULAR_COLORMAP - vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_TRANSMISSIONMAP - vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_THICKNESSMAP - vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,Zq=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 - vec4 worldPosition = vec4( transformed, 1.0 ); - #ifdef USE_BATCHING - worldPosition = batchingMatrix * worldPosition; - #endif - #ifdef USE_INSTANCING - worldPosition = instanceMatrix * worldPosition; - #endif - worldPosition = modelMatrix * worldPosition; -#endif`;const Jq=`varying vec2 vUv; -uniform mat3 uvTransform; -void main() { - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,eV=`uniform sampler2D t2D; -uniform float backgroundIntensity; -varying vec2 vUv; -void main() { - vec4 texColor = texture2D( t2D, vUv ); - #ifdef DECODE_VIDEO_TEXTURE - texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); - #endif - texColor.rgb *= backgroundIntensity; - gl_FragColor = texColor; - #include - #include -}`,tV=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`,nV=`#ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; -#elif defined( ENVMAP_TYPE_CUBE_UV ) - uniform sampler2D envMap; -#endif -uniform float flipEnvMap; -uniform float backgroundBlurriness; -uniform float backgroundIntensity; -uniform mat3 backgroundRotation; -varying vec3 vWorldDirection; -#include -void main() { - #ifdef ENVMAP_TYPE_CUBE - vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); - #elif defined( ENVMAP_TYPE_CUBE_UV ) - vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); - #else - vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - #endif - texColor.rgb *= backgroundIntensity; - gl_FragColor = texColor; - #include - #include -}`,iV=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`,rV=`uniform samplerCube tCube; -uniform float tFlip; -uniform float opacity; -varying vec3 vWorldDirection; -void main() { - vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); - gl_FragColor = texColor; - gl_FragColor.a *= opacity; - #include - #include -}`,sV=`#include -#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - #include - #include - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - vHighPrecisionZW = gl_Position.zw; -}`,aV=`#if DEPTH_PACKING == 3200 - uniform float opacity; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - vec4 diffuseColor = vec4( 1.0 ); - #include - #if DEPTH_PACKING == 3200 - diffuseColor.a = opacity; - #endif - #include - #include - #include - #include - #include - float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; - #if DEPTH_PACKING == 3200 - gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); - #elif DEPTH_PACKING == 3201 - gl_FragColor = packDepthToRGBA( fragCoordZ ); - #elif DEPTH_PACKING == 3202 - gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); - #elif DEPTH_PACKING == 3203 - gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); - #endif -}`,oV=`#define DISTANCE -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - vWorldPosition = worldPosition.xyz; -}`,lV=`#define DISTANCE -uniform vec3 referencePosition; -uniform float nearDistance; -uniform float farDistance; -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -#include -#include -void main () { - vec4 diffuseColor = vec4( 1.0 ); - #include - #include - #include - #include - #include - float dist = length( vWorldPosition - referencePosition ); - dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); - dist = saturate( dist ); - gl_FragColor = packDepthToRGBA( dist ); -}`,uV=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include -}`,cV=`uniform sampler2D tEquirect; -varying vec3 vWorldDirection; -#include -void main() { - vec3 direction = normalize( vWorldDirection ); - vec2 sampleUV = equirectUv( direction ); - gl_FragColor = texture2D( tEquirect, sampleUV ); - #include - #include -}`,hV=`uniform float scale; -attribute float lineDistance; -varying float vLineDistance; -#include -#include -#include -#include -#include -#include -#include -void main() { - vLineDistance = scale * lineDistance; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,fV=`uniform vec3 diffuse; -uniform float opacity; -uniform float dashSize; -uniform float totalSize; -varying float vLineDistance; -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - if ( mod( vLineDistance, totalSize ) > dashSize ) { - discard; - } - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include - #include -}`,AV=`#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) - #include - #include - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,dV=`uniform vec3 diffuse; -uniform float opacity; -#ifndef FLAT_SHADED - varying vec3 vNormal; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - #include - #include - #include - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); - reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; - #else - reflectedLight.indirectDiffuse += vec3( 1.0 ); - #endif - #include - reflectedLight.indirectDiffuse *= diffuseColor.rgb; - vec3 outgoingLight = reflectedLight.indirectDiffuse; - #include - #include - #include - #include - #include - #include - #include -}`,pV=`#define LAMBERT -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include - #include -}`,mV=`#define LAMBERT -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`,gV=`#define MATCAP -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; -}`,vV=`#define MATCAP -uniform vec3 diffuse; -uniform float opacity; -uniform sampler2D matcap; -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 viewDir = normalize( vViewPosition ); - vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); - vec3 y = cross( viewDir, x ); - vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; - #ifdef USE_MATCAP - vec4 matcapColor = texture2D( matcap, uv ); - #else - vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); - #endif - vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; - #include - #include - #include - #include - #include - #include -}`,_V=`#define NORMAL -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - vViewPosition = - mvPosition.xyz; -#endif -}`,yV=`#define NORMAL -uniform float opacity; -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); - #include - #include - #include - #include - gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); - #ifdef OPAQUE - gl_FragColor.a = 1.0; - #endif -}`,xV=`#define PHONG -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include - #include -}`,bV=`#define PHONG -uniform vec3 diffuse; -uniform vec3 emissive; -uniform vec3 specular; -uniform float shininess; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`,SV=`#define STANDARD -varying vec3 vViewPosition; -#ifdef USE_TRANSMISSION - varying vec3 vWorldPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include -#ifdef USE_TRANSMISSION - vWorldPosition = worldPosition.xyz; -#endif -}`,TV=`#define STANDARD -#ifdef PHYSICAL - #define IOR - #define USE_SPECULAR -#endif -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float roughness; -uniform float metalness; -uniform float opacity; -#ifdef IOR - uniform float ior; -#endif -#ifdef USE_SPECULAR - uniform float specularIntensity; - uniform vec3 specularColor; - #ifdef USE_SPECULAR_COLORMAP - uniform sampler2D specularColorMap; - #endif - #ifdef USE_SPECULAR_INTENSITYMAP - uniform sampler2D specularIntensityMap; - #endif -#endif -#ifdef USE_CLEARCOAT - uniform float clearcoat; - uniform float clearcoatRoughness; -#endif -#ifdef USE_DISPERSION - uniform float dispersion; -#endif -#ifdef USE_IRIDESCENCE - uniform float iridescence; - uniform float iridescenceIOR; - uniform float iridescenceThicknessMinimum; - uniform float iridescenceThicknessMaximum; -#endif -#ifdef USE_SHEEN - uniform vec3 sheenColor; - uniform float sheenRoughness; - #ifdef USE_SHEEN_COLORMAP - uniform sampler2D sheenColorMap; - #endif - #ifdef USE_SHEEN_ROUGHNESSMAP - uniform sampler2D sheenRoughnessMap; - #endif -#endif -#ifdef USE_ANISOTROPY - uniform vec2 anisotropyVector; - #ifdef USE_ANISOTROPYMAP - uniform sampler2D anisotropyMap; - #endif -#endif -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; - vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; - #include - vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; - #ifdef USE_SHEEN - float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); - outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; - #endif - #ifdef USE_CLEARCOAT - float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); - vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); - outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; - #endif - #include - #include - #include - #include - #include - #include -}`,wV=`#define TOON -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include -}`,MV=`#define TOON -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include -}`,EV=`uniform float size; -uniform float scale; -#include -#include -#include -#include -#include -#include -#ifdef USE_POINTS_UV - varying vec2 vUv; - uniform mat3 uvTransform; -#endif -void main() { - #ifdef USE_POINTS_UV - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - #endif - #include - #include - #include - #include - #include - #include - gl_PointSize = size; - #ifdef USE_SIZEATTENUATION - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); - #endif - #include - #include - #include - #include -}`,CV=`uniform vec3 diffuse; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include - #include -}`,RV=`#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,NV=`uniform vec3 color; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); - #include - #include - #include -}`,DV=`uniform float rotation; -uniform vec2 center; -#include -#include -#include -#include -#include -void main() { - #include - vec4 mvPosition = modelViewMatrix[ 3 ]; - vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); - #ifndef USE_SIZEATTENUATION - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) scale *= - mvPosition.z; - #endif - vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; - vec2 rotatedPosition; - rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; - rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; - mvPosition.xy += rotatedPosition; - gl_Position = projectionMatrix * mvPosition; - #include - #include - #include -}`,PV=`uniform vec3 diffuse; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include -}`,Zn={alphahash_fragment:eG,alphahash_pars_fragment:tG,alphamap_fragment:nG,alphamap_pars_fragment:iG,alphatest_fragment:rG,alphatest_pars_fragment:sG,aomap_fragment:aG,aomap_pars_fragment:oG,batching_pars_vertex:lG,batching_vertex:uG,begin_vertex:cG,beginnormal_vertex:hG,bsdfs:fG,iridescence_fragment:AG,bumpmap_pars_fragment:dG,clipping_planes_fragment:pG,clipping_planes_pars_fragment:mG,clipping_planes_pars_vertex:gG,clipping_planes_vertex:vG,color_fragment:_G,color_pars_fragment:yG,color_pars_vertex:xG,color_vertex:bG,common:SG,cube_uv_reflection_fragment:TG,defaultnormal_vertex:wG,displacementmap_pars_vertex:MG,displacementmap_vertex:EG,emissivemap_fragment:CG,emissivemap_pars_fragment:RG,colorspace_fragment:NG,colorspace_pars_fragment:DG,envmap_fragment:PG,envmap_common_pars_fragment:LG,envmap_pars_fragment:UG,envmap_pars_vertex:BG,envmap_physical_pars_fragment:WG,envmap_vertex:OG,fog_vertex:IG,fog_pars_vertex:FG,fog_fragment:kG,fog_pars_fragment:zG,gradientmap_pars_fragment:GG,lightmap_pars_fragment:qG,lights_lambert_fragment:VG,lights_lambert_pars_fragment:HG,lights_pars_begin:jG,lights_toon_fragment:$G,lights_toon_pars_fragment:XG,lights_phong_fragment:YG,lights_phong_pars_fragment:QG,lights_physical_fragment:KG,lights_physical_pars_fragment:ZG,lights_fragment_begin:JG,lights_fragment_maps:eq,lights_fragment_end:tq,logdepthbuf_fragment:nq,logdepthbuf_pars_fragment:iq,logdepthbuf_pars_vertex:rq,logdepthbuf_vertex:sq,map_fragment:aq,map_pars_fragment:oq,map_particle_fragment:lq,map_particle_pars_fragment:uq,metalnessmap_fragment:cq,metalnessmap_pars_fragment:hq,morphinstance_vertex:fq,morphcolor_vertex:Aq,morphnormal_vertex:dq,morphtarget_pars_vertex:pq,morphtarget_vertex:mq,normal_fragment_begin:gq,normal_fragment_maps:vq,normal_pars_fragment:_q,normal_pars_vertex:yq,normal_vertex:xq,normalmap_pars_fragment:bq,clearcoat_normal_fragment_begin:Sq,clearcoat_normal_fragment_maps:Tq,clearcoat_pars_fragment:wq,iridescence_pars_fragment:Mq,opaque_fragment:Eq,packing:Cq,premultiplied_alpha_fragment:Rq,project_vertex:Nq,dithering_fragment:Dq,dithering_pars_fragment:Pq,roughnessmap_fragment:Lq,roughnessmap_pars_fragment:Uq,shadowmap_pars_fragment:Bq,shadowmap_pars_vertex:Oq,shadowmap_vertex:Iq,shadowmask_pars_fragment:Fq,skinbase_vertex:kq,skinning_pars_vertex:zq,skinning_vertex:Gq,skinnormal_vertex:qq,specularmap_fragment:Vq,specularmap_pars_fragment:Hq,tonemapping_fragment:jq,tonemapping_pars_fragment:Wq,transmission_fragment:$q,transmission_pars_fragment:Xq,uv_pars_fragment:Yq,uv_pars_vertex:Qq,uv_vertex:Kq,worldpos_vertex:Zq,background_vert:Jq,background_frag:eV,backgroundCube_vert:tV,backgroundCube_frag:nV,cube_vert:iV,cube_frag:rV,depth_vert:sV,depth_frag:aV,distanceRGBA_vert:oV,distanceRGBA_frag:lV,equirect_vert:uV,equirect_frag:cV,linedashed_vert:hV,linedashed_frag:fV,meshbasic_vert:AV,meshbasic_frag:dV,meshlambert_vert:pV,meshlambert_frag:mV,meshmatcap_vert:gV,meshmatcap_frag:vV,meshnormal_vert:_V,meshnormal_frag:yV,meshphong_vert:xV,meshphong_frag:bV,meshphysical_vert:SV,meshphysical_frag:TV,meshtoon_vert:wV,meshtoon_frag:MV,points_vert:EV,points_frag:CV,shadow_vert:RV,shadow_frag:NV,sprite_vert:DV,sprite_frag:PV},Kt={common:{diffuse:{value:new an(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Vn},alphaMap:{value:null},alphaMapTransform:{value:new Vn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Vn}},envmap:{envMap:{value:null},envMapRotation:{value:new Vn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Vn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Vn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Vn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Vn},normalScale:{value:new gt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Vn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Vn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Vn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Vn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new an(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new an(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Vn},alphaTest:{value:0},uvTransform:{value:new Vn}},sprite:{diffuse:{value:new an(16777215)},opacity:{value:1},center:{value:new gt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Vn},alphaMap:{value:null},alphaMapTransform:{value:new Vn},alphaTest:{value:0}}},Ga={basic:{uniforms:_a([Kt.common,Kt.specularmap,Kt.envmap,Kt.aomap,Kt.lightmap,Kt.fog]),vertexShader:Zn.meshbasic_vert,fragmentShader:Zn.meshbasic_frag},lambert:{uniforms:_a([Kt.common,Kt.specularmap,Kt.envmap,Kt.aomap,Kt.lightmap,Kt.emissivemap,Kt.bumpmap,Kt.normalmap,Kt.displacementmap,Kt.fog,Kt.lights,{emissive:{value:new an(0)}}]),vertexShader:Zn.meshlambert_vert,fragmentShader:Zn.meshlambert_frag},phong:{uniforms:_a([Kt.common,Kt.specularmap,Kt.envmap,Kt.aomap,Kt.lightmap,Kt.emissivemap,Kt.bumpmap,Kt.normalmap,Kt.displacementmap,Kt.fog,Kt.lights,{emissive:{value:new an(0)},specular:{value:new an(1118481)},shininess:{value:30}}]),vertexShader:Zn.meshphong_vert,fragmentShader:Zn.meshphong_frag},standard:{uniforms:_a([Kt.common,Kt.envmap,Kt.aomap,Kt.lightmap,Kt.emissivemap,Kt.bumpmap,Kt.normalmap,Kt.displacementmap,Kt.roughnessmap,Kt.metalnessmap,Kt.fog,Kt.lights,{emissive:{value:new an(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag},toon:{uniforms:_a([Kt.common,Kt.aomap,Kt.lightmap,Kt.emissivemap,Kt.bumpmap,Kt.normalmap,Kt.displacementmap,Kt.gradientmap,Kt.fog,Kt.lights,{emissive:{value:new an(0)}}]),vertexShader:Zn.meshtoon_vert,fragmentShader:Zn.meshtoon_frag},matcap:{uniforms:_a([Kt.common,Kt.bumpmap,Kt.normalmap,Kt.displacementmap,Kt.fog,{matcap:{value:null}}]),vertexShader:Zn.meshmatcap_vert,fragmentShader:Zn.meshmatcap_frag},points:{uniforms:_a([Kt.points,Kt.fog]),vertexShader:Zn.points_vert,fragmentShader:Zn.points_frag},dashed:{uniforms:_a([Kt.common,Kt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Zn.linedashed_vert,fragmentShader:Zn.linedashed_frag},depth:{uniforms:_a([Kt.common,Kt.displacementmap]),vertexShader:Zn.depth_vert,fragmentShader:Zn.depth_frag},normal:{uniforms:_a([Kt.common,Kt.bumpmap,Kt.normalmap,Kt.displacementmap,{opacity:{value:1}}]),vertexShader:Zn.meshnormal_vert,fragmentShader:Zn.meshnormal_frag},sprite:{uniforms:_a([Kt.sprite,Kt.fog]),vertexShader:Zn.sprite_vert,fragmentShader:Zn.sprite_frag},background:{uniforms:{uvTransform:{value:new Vn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Zn.background_vert,fragmentShader:Zn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Vn}},vertexShader:Zn.backgroundCube_vert,fragmentShader:Zn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Zn.cube_vert,fragmentShader:Zn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Zn.equirect_vert,fragmentShader:Zn.equirect_frag},distanceRGBA:{uniforms:_a([Kt.common,Kt.displacementmap,{referencePosition:{value:new he},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Zn.distanceRGBA_vert,fragmentShader:Zn.distanceRGBA_frag},shadow:{uniforms:_a([Kt.lights,Kt.fog,{color:{value:new an(0)},opacity:{value:1}}]),vertexShader:Zn.shadow_vert,fragmentShader:Zn.shadow_frag}};Ga.physical={uniforms:_a([Ga.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Vn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Vn},clearcoatNormalScale:{value:new gt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Vn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Vn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Vn},sheen:{value:0},sheenColor:{value:new an(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Vn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Vn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Vn},transmissionSamplerSize:{value:new gt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Vn},attenuationDistance:{value:0},attenuationColor:{value:new an(0)},specularColor:{value:new an(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Vn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Vn},anisotropyVector:{value:new gt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Vn}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag};const j2={r:0,b:0,g:0},Tf=new la,LV=new kn;function UV(i,e,t,n,r,s,a){const l=new an(0);let u=s===!0?0:1,h,m,v=null,x=0,S=null;function w(L){let O=L.isScene===!0?L.background:null;return O&&O.isTexture&&(O=(L.backgroundBlurriness>0?t:e).get(O)),O}function R(L){let O=!1;const G=w(L);G===null?E(l,u):G&&G.isColor&&(E(G,1),O=!0);const q=i.xr.getEnvironmentBlendMode();q==="additive"?n.buffers.color.setClear(0,0,0,1,a):q==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||O)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function C(L,O){const G=w(O);G&&(G.isCubeTexture||G.mapping===sA)?(m===void 0&&(m=new zi(new $h(1,1,1),new Ja({name:"BackgroundCubeMaterial",uniforms:E0(Ga.backgroundCube.uniforms),vertexShader:Ga.backgroundCube.vertexShader,fragmentShader:Ga.backgroundCube.fragmentShader,side:hr,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(q,z,j){this.matrixWorld.copyPosition(j.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(m)),Tf.copy(O.backgroundRotation),Tf.x*=-1,Tf.y*=-1,Tf.z*=-1,G.isCubeTexture&&G.isRenderTargetTexture===!1&&(Tf.y*=-1,Tf.z*=-1),m.material.uniforms.envMap.value=G,m.material.uniforms.flipEnvMap.value=G.isCubeTexture&&G.isRenderTargetTexture===!1?-1:1,m.material.uniforms.backgroundBlurriness.value=O.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=O.backgroundIntensity,m.material.uniforms.backgroundRotation.value.setFromMatrix4(LV.makeRotationFromEuler(Tf)),m.material.toneMapped=ai.getTransfer(G.colorSpace)!==Vi,(v!==G||x!==G.version||S!==i.toneMapping)&&(m.material.needsUpdate=!0,v=G,x=G.version,S=i.toneMapping),m.layers.enableAll(),L.unshift(m,m.geometry,m.material,0,0,null)):G&&G.isTexture&&(h===void 0&&(h=new zi(new Ty(2,2),new Ja({name:"BackgroundMaterial",uniforms:E0(Ga.background.uniforms),vertexShader:Ga.background.vertexShader,fragmentShader:Ga.background.fragmentShader,side:Nl,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=G,h.material.uniforms.backgroundIntensity.value=O.backgroundIntensity,h.material.toneMapped=ai.getTransfer(G.colorSpace)!==Vi,G.matrixAutoUpdate===!0&&G.updateMatrix(),h.material.uniforms.uvTransform.value.copy(G.matrix),(v!==G||x!==G.version||S!==i.toneMapping)&&(h.material.needsUpdate=!0,v=G,x=G.version,S=i.toneMapping),h.layers.enableAll(),L.unshift(h,h.geometry,h.material,0,0,null))}function E(L,O){L.getRGB(j2,q7(i)),n.buffers.color.setClear(j2.r,j2.g,j2.b,O,a)}function B(){m!==void 0&&(m.geometry.dispose(),m.material.dispose()),h!==void 0&&(h.geometry.dispose(),h.material.dispose())}return{getClearColor:function(){return l},setClearColor:function(L,O=1){l.set(L),u=O,E(l,u)},getClearAlpha:function(){return u},setClearAlpha:function(L){u=L,E(l,u)},render:R,addToRenderList:C,dispose:B}}function BV(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=x(null);let s=r,a=!1;function l(V,Y,ee,te,re){let ne=!1;const Q=v(te,ee,Y);s!==Q&&(s=Q,h(s.object)),ne=S(V,te,ee,re),ne&&w(V,te,ee,re),re!==null&&e.update(re,i.ELEMENT_ARRAY_BUFFER),(ne||a)&&(a=!1,O(V,Y,ee,te),re!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(re).buffer))}function u(){return i.createVertexArray()}function h(V){return i.bindVertexArray(V)}function m(V){return i.deleteVertexArray(V)}function v(V,Y,ee){const te=ee.wireframe===!0;let re=n[V.id];re===void 0&&(re={},n[V.id]=re);let ne=re[Y.id];ne===void 0&&(ne={},re[Y.id]=ne);let Q=ne[te];return Q===void 0&&(Q=x(u()),ne[te]=Q),Q}function x(V){const Y=[],ee=[],te=[];for(let re=0;re=0){const be=re[de];let ue=ne[de];if(ue===void 0&&(de==="instanceMatrix"&&V.instanceMatrix&&(ue=V.instanceMatrix),de==="instanceColor"&&V.instanceColor&&(ue=V.instanceColor)),be===void 0||be.attribute!==ue||ue&&be.data!==ue.data)return!0;Q++}return s.attributesNum!==Q||s.index!==te}function w(V,Y,ee,te){const re={},ne=Y.attributes;let Q=0;const ae=ee.getAttributes();for(const de in ae)if(ae[de].location>=0){let be=ne[de];be===void 0&&(de==="instanceMatrix"&&V.instanceMatrix&&(be=V.instanceMatrix),de==="instanceColor"&&V.instanceColor&&(be=V.instanceColor));const ue={};ue.attribute=be,be&&be.data&&(ue.data=be.data),re[de]=ue,Q++}s.attributes=re,s.attributesNum=Q,s.index=te}function R(){const V=s.newAttributes;for(let Y=0,ee=V.length;Y=0){let Te=re[ae];if(Te===void 0&&(ae==="instanceMatrix"&&V.instanceMatrix&&(Te=V.instanceMatrix),ae==="instanceColor"&&V.instanceColor&&(Te=V.instanceColor)),Te!==void 0){const be=Te.normalized,ue=Te.itemSize,we=e.get(Te);if(we===void 0)continue;const We=we.buffer,Ne=we.type,ze=we.bytesPerElement,Se=Ne===i.INT||Ne===i.UNSIGNED_INT||Te.gpuType===Ns;if(Te.isInterleavedBufferAttribute){const Ce=Te.data,dt=Ce.stride,At=Te.offset;if(Ce.isInstancedInterleavedBuffer){for(let wt=0;wt0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";z="mediump"}return z==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const m=u(h);m!==h&&(console.warn("THREE.WebGLRenderer:",h,"not supported, using",m,"instead."),h=m);const v=t.logarithmicDepthBuffer===!0,x=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),S=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),w=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),R=i.getParameter(i.MAX_TEXTURE_SIZE),C=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),E=i.getParameter(i.MAX_VERTEX_ATTRIBS),B=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),L=i.getParameter(i.MAX_VARYING_VECTORS),O=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),G=w>0,q=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:l,precision:h,logarithmicDepthBuffer:v,reverseDepthBuffer:x,maxTextures:S,maxVertexTextures:w,maxTextureSize:R,maxCubemapSize:C,maxAttributes:E,maxVertexUniforms:B,maxVaryings:L,maxFragmentUniforms:O,vertexTextures:G,maxSamples:q}}function FV(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new Yl,l=new Vn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(v,x){const S=v.length!==0||x||n!==0||r;return r=x,n=v.length,S},this.beginShadows=function(){s=!0,m(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(v,x){t=m(v,x,0)},this.setState=function(v,x,S){const w=v.clippingPlanes,R=v.clipIntersection,C=v.clipShadows,E=i.get(v);if(!r||w===null||w.length===0||s&&!C)s?m(null):h();else{const B=s?0:n,L=B*4;let O=E.clippingState||null;u.value=O,O=m(w,x,L,S);for(let G=0;G!==L;++G)O[G]=t[G];E.clippingState=O,this.numIntersection=R?this.numPlanes:0,this.numPlanes+=B}};function h(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function m(v,x,S,w){const R=v!==null?v.length:0;let C=null;if(R!==0){if(C=u.value,w!==!0||C===null){const E=S+R*4,B=x.matrixWorldInverse;l.getNormalMatrix(B),(C===null||C.length0){const h=new H7(u.height);return h.fromEquirectangularTexture(i,a),e.set(a,h),a.addEventListener("dispose",r),t(h.texture,a.mapping)}else return null}}return a}function r(a){const l=a.target;l.removeEventListener("dispose",r);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const Hd=4,P5=[.125,.215,.35,.446,.526,.582],zf=20,w3=new kg,L5=new an;let M3=null,E3=0,C3=0,R3=!1;const Bf=(1+Math.sqrt(5))/2,vd=1/Bf,U5=[new he(-Bf,vd,0),new he(Bf,vd,0),new he(-vd,0,Bf),new he(vd,0,Bf),new he(0,Bf,-vd),new he(0,Bf,vd),new he(-1,1,-1),new he(1,1,-1),new he(-1,1,1),new he(1,1,1)];let B5=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){M3=this._renderer.getRenderTarget(),E3=this._renderer.getActiveCubeFace(),C3=this._renderer.getActiveMipmapLevel(),R3=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=F5(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=I5(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?L:0,L,L),m.setRenderTarget(r),R&&m.render(w,l),m.render(e,l)}w.geometry.dispose(),w.material.dispose(),m.toneMapping=x,m.autoClear=v,e.background=C}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Qo||e.mapping===Ko;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=F5()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=I5());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new zi(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const u=this._cubeSize;W2(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,w3)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;szf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${zf}`);const E=[];let B=0;for(let z=0;zL-Hd?r-L+Hd:0),q=4*(this._cubeSize-O);W2(t,G,q,3*O,2*O),u.setRenderTarget(t),u.render(v,w3)}};function zV(i){const e=[],t=[],n=[];let r=i;const s=i-Hd+1+P5.length;for(let a=0;ai-Hd?u=P5[a-i+Hd-1]:a===0&&(u=0),n.push(u);const h=1/(l-2),m=-h,v=1+h,x=[m,m,v,m,v,v,m,m,v,v,m,v],S=6,w=6,R=3,C=2,E=1,B=new Float32Array(R*w*S),L=new Float32Array(C*w*S),O=new Float32Array(E*w*S);for(let q=0;q2?0:-1,F=[z,j,0,z+2/3,j,0,z+2/3,j+1,0,z,j,0,z+2/3,j+1,0,z,j+1,0];B.set(F,R*w*q),L.set(x,C*w*q);const V=[q,q,q,q,q,q];O.set(V,E*w*q)}const G=new Ki;G.setAttribute("position",new wr(B,R)),G.setAttribute("uv",new wr(L,C)),G.setAttribute("faceIndex",new wr(O,E)),e.push(G),r>Hd&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function O5(i,e,t){const n=new qh(i,e,t);return n.texture.mapping=sA,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function W2(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function GV(i,e,t){const n=new Float32Array(zf),r=new he(0,1,0);return new Ja({name:"SphericalGaussianBlur",defines:{n:zf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:oM(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform int samples; - uniform float weights[ n ]; - uniform bool latitudinal; - uniform float dTheta; - uniform float mipInt; - uniform vec3 poleAxis; - - #define ENVMAP_TYPE_CUBE_UV - #include - - vec3 getSample( float theta, vec3 axis ) { - - float cosTheta = cos( theta ); - // Rodrigues' axis-angle rotation - vec3 sampleDirection = vOutputDirection * cosTheta - + cross( axis, vOutputDirection ) * sin( theta ) - + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); - - return bilinearCubeUV( envMap, sampleDirection, mipInt ); - - } - - void main() { - - vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); - - if ( all( equal( axis, vec3( 0.0 ) ) ) ) { - - axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); - - } - - axis = normalize( axis ); - - gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); - - for ( int i = 1; i < n; i++ ) { - - if ( i >= samples ) { - - break; - - } - - float theta = dTheta * float( i ); - gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); - gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); - - } - - } - `,blending:Qa,depthTest:!1,depthWrite:!1})}function I5(){return new Ja({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:oM(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - - #include - - void main() { - - vec3 outputDirection = normalize( vOutputDirection ); - vec2 uv = equirectUv( outputDirection ); - - gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); - - } - `,blending:Qa,depthTest:!1,depthWrite:!1})}function F5(){return new Ja({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:oM(),fragmentShader:` - - precision mediump float; - precision mediump int; - - uniform float flipEnvMap; - - varying vec3 vOutputDirection; - - uniform samplerCube envMap; - - void main() { - - gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); - - } - `,blending:Qa,depthTest:!1,depthWrite:!1})}function oM(){return` - - precision mediump float; - precision mediump int; - - attribute float faceIndex; - - varying vec3 vOutputDirection; - - // RH coordinate system; PMREM face-indexing convention - vec3 getDirection( vec2 uv, float face ) { - - uv = 2.0 * uv - 1.0; - - vec3 direction = vec3( uv, 1.0 ); - - if ( face == 0.0 ) { - - direction = direction.zyx; // ( 1, v, u ) pos x - - } else if ( face == 1.0 ) { - - direction = direction.xzy; - direction.xz *= -1.0; // ( -u, 1, -v ) pos y - - } else if ( face == 2.0 ) { - - direction.x *= -1.0; // ( -u, v, 1 ) pos z - - } else if ( face == 3.0 ) { - - direction = direction.zyx; - direction.xz *= -1.0; // ( -1, v, -u ) neg x - - } else if ( face == 4.0 ) { - - direction = direction.xzy; - direction.xy *= -1.0; // ( -u, -1, v ) neg y - - } else if ( face == 5.0 ) { - - direction.z *= -1.0; // ( u, v, -1 ) neg z - - } - - return direction; - - } - - void main() { - - vOutputDirection = getDirection( uv, faceIndex ); - gl_Position = vec4( position, 1.0 ); - - } - `}function qV(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const u=l.mapping,h=u===zh||u===Gh,m=u===Qo||u===Ko;if(h||m){let v=e.get(l);const x=v!==void 0?v.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==x)return t===null&&(t=new B5(i)),v=h?t.fromEquirectangular(l,v):t.fromCubemap(l,v),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),v.texture;if(v!==void 0)return v.texture;{const S=l.image;return h&&S&&S.height>0||m&&S&&r(S)?(t===null&&(t=new B5(i)),v=h?t.fromEquirectangular(l):t.fromCubemap(l),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),l.addEventListener("dispose",s),v.texture):null}}}return l}function r(l){let u=0;const h=6;for(let m=0;me.maxTextureSize&&(q=Math.ceil(G/e.maxTextureSize),G=e.maxTextureSize);const z=new Float32Array(G*q*4*v),j=new jw(z,G,q,v);j.type=$r,j.needsUpdate=!0;const F=O*4;for(let Y=0;Y0)return i;const r=e*t;let s=z5[r];if(s===void 0&&(s=new Float32Array(r),z5[r]=s),e!==0){n.toArray(s,0);for(let a=1,l=0;a!==e;++a)l+=t,i[a].toArray(s,l)}return s}function _s(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t":" "} ${l}: ${t[a]}`)}return n.join(` -`)}const $5=new Vn;function qH(i){ai._getMatrix($5,ai.workingColorSpace,i);const e=`mat3( ${$5.elements.map(t=>t.toFixed(4))} )`;switch(ai.getTransfer(i)){case a_:return[e,"LinearTransferOETF"];case Vi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function X5(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+` - -`+r+` - -`+GH(i.getShaderSource(e),a)}else return r}function VH(i,e){const t=qH(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` -`)}function HH(i,e){let t;switch(e){case N7:t="Linear";break;case D7:t="Reinhard";break;case P7:t="Cineon";break;case L7:t="ACESFilmic";break;case U7:t="AgX";break;case B7:t="Neutral";break;case GF:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const $2=new he;function jH(){ai.getLuminanceCoefficients($2);const i=$2.x.toFixed(4),e=$2.y.toFixed(4),t=$2.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` -`)}function WH(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(_m).join(` -`)}function $H(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` -`)}function XH(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function ZS(i){return i.replace(YH,KH)}const QH=new Map;function KH(i,e){let t=Zn[e];if(t===void 0){const n=QH.get(e);if(n!==void 0)t=Zn[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return ZS(t)}const ZH=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function K5(i){return i.replace(ZH,JH)}function JH(i,e,t,n){let r="";for(let s=parseInt(e);s0&&(C+=` -`),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w].filter(_m).join(` -`),E.length>0&&(E+=` -`)):(C=[Z5(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+m:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` -`].filter(_m).join(` -`),E=[Z5(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+m:"",t.envMap?"#define "+v:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Za?"#define TONE_MAPPING":"",t.toneMapping!==Za?Zn.tonemapping_pars_fragment:"",t.toneMapping!==Za?HH("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Zn.colorspace_pars_fragment,VH("linearToOutputTexel",t.outputColorSpace),jH(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` -`].filter(_m).join(` -`)),a=ZS(a),a=Y5(a,t),a=Q5(a,t),l=ZS(l),l=Y5(l,t),l=Q5(l,t),a=K5(a),l=K5(l),t.isRawShaderMaterial!==!0&&(B=`#version 300 es -`,C=[S,"#define attribute in","#define varying out","#define texture2D texture"].join(` -`)+` -`+C,E=["#define varying in",t.glslVersion===WC?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===WC?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` -`)+` -`+E);const L=B+C+a,O=B+E+l,G=W5(r,r.VERTEX_SHADER,L),q=W5(r,r.FRAGMENT_SHADER,O);r.attachShader(R,G),r.attachShader(R,q),t.index0AttributeName!==void 0?r.bindAttribLocation(R,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(R,0,"position"),r.linkProgram(R);function z(Y){if(i.debug.checkShaderErrors){const ee=r.getProgramInfoLog(R).trim(),te=r.getShaderInfoLog(G).trim(),re=r.getShaderInfoLog(q).trim();let ne=!0,Q=!0;if(r.getProgramParameter(R,r.LINK_STATUS)===!1)if(ne=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,R,G,q);else{const ae=X5(r,G,"vertex"),de=X5(r,q,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(R,r.VALIDATE_STATUS)+` - -Material Name: `+Y.name+` -Material Type: `+Y.type+` - -Program Info Log: `+ee+` -`+ae+` -`+de)}else ee!==""?console.warn("THREE.WebGLProgram: Program Info Log:",ee):(te===""||re==="")&&(Q=!1);Q&&(Y.diagnostics={runnable:ne,programLog:ee,vertexShader:{log:te,prefix:C},fragmentShader:{log:re,prefix:E}})}r.deleteShader(G),r.deleteShader(q),j=new qv(r,R),F=XH(r,R)}let j;this.getUniforms=function(){return j===void 0&&z(this),j};let F;this.getAttributes=function(){return F===void 0&&z(this),F};let V=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return V===!1&&(V=r.getProgramParameter(R,kH)),V},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(R),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=zH++,this.cacheKey=e,this.usedTimes=1,this.program=R,this.vertexShader=G,this.fragmentShader=q,this}let aj=0;class oj{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new lj(e),t.set(e,n)),n}}class lj{constructor(e){this.id=aj++,this.code=e,this.usedTimes=0}}function uj(i,e,t,n,r,s,a){const l=new Ww,u=new oj,h=new Set,m=[],v=r.logarithmicDepthBuffer,x=r.vertexTextures;let S=r.precision;const w={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function R(F){return h.add(F),F===0?"uv":`uv${F}`}function C(F,V,Y,ee,te){const re=ee.fog,ne=te.geometry,Q=F.isMeshStandardMaterial?ee.environment:null,ae=(F.isMeshStandardMaterial?t:e).get(F.envMap||Q),de=ae&&ae.mapping===sA?ae.image.height:null,Te=w[F.type];F.precision!==null&&(S=r.getMaxPrecision(F.precision),S!==F.precision&&console.warn("THREE.WebGLProgram.getParameters:",F.precision,"not supported, using",S,"instead."));const be=ne.morphAttributes.position||ne.morphAttributes.normal||ne.morphAttributes.color,ue=be!==void 0?be.length:0;let we=0;ne.morphAttributes.position!==void 0&&(we=1),ne.morphAttributes.normal!==void 0&&(we=2),ne.morphAttributes.color!==void 0&&(we=3);let We,Ne,ze,Se;if(Te){const pn=Ga[Te];We=pn.vertexShader,Ne=pn.fragmentShader}else We=F.vertexShader,Ne=F.fragmentShader,u.update(F),ze=u.getVertexShaderID(F),Se=u.getFragmentShaderID(F);const Ce=i.getRenderTarget(),dt=i.state.buffers.depth.getReversed(),At=te.isInstancedMesh===!0,wt=te.isBatchedMesh===!0,Ft=!!F.map,$e=!!F.matcap,rt=!!ae,ce=!!F.aoMap,Gt=!!F.lightMap,ht=!!F.bumpMap,Pt=!!F.normalMap,yt=!!F.displacementMap,en=!!F.emissiveMap,xt=!!F.metalnessMap,fe=!!F.roughnessMap,X=F.anisotropy>0,le=F.clearcoat>0,Re=F.dispersion>0,pe=F.iridescence>0,Me=F.sheen>0,nt=F.transmission>0,lt=X&&!!F.anisotropyMap,Ot=le&&!!F.clearcoatMap,jt=le&&!!F.clearcoatNormalMap,pt=le&&!!F.clearcoatRoughnessMap,Yt=pe&&!!F.iridescenceMap,rn=pe&&!!F.iridescenceThicknessMap,$t=Me&&!!F.sheenColorMap,kt=Me&&!!F.sheenRoughnessMap,Vt=!!F.specularMap,Nn=!!F.specularColorMap,_i=!!F.specularIntensityMap,me=nt&&!!F.transmissionMap,bt=nt&&!!F.thicknessMap,tt=!!F.gradientMap,St=!!F.alphaMap,qt=F.alphaTest>0,Ht=!!F.alphaHash,xn=!!F.extensions;let qi=Za;F.toneMapped&&(Ce===null||Ce.isXRRenderTarget===!0)&&(qi=i.toneMapping);const rr={shaderID:Te,shaderType:F.type,shaderName:F.name,vertexShader:We,fragmentShader:Ne,defines:F.defines,customVertexShaderID:ze,customFragmentShaderID:Se,isRawShaderMaterial:F.isRawShaderMaterial===!0,glslVersion:F.glslVersion,precision:S,batching:wt,batchingColor:wt&&te._colorsTexture!==null,instancing:At,instancingColor:At&&te.instanceColor!==null,instancingMorph:At&&te.morphTexture!==null,supportsVertexTextures:x,outputColorSpace:Ce===null?i.outputColorSpace:Ce.isXRRenderTarget===!0?Ce.texture.colorSpace:Ro,alphaToCoverage:!!F.alphaToCoverage,map:Ft,matcap:$e,envMap:rt,envMapMode:rt&&ae.mapping,envMapCubeUVHeight:de,aoMap:ce,lightMap:Gt,bumpMap:ht,normalMap:Pt,displacementMap:x&&yt,emissiveMap:en,normalMapObjectSpace:Pt&&F.normalMapType===O7,normalMapTangentSpace:Pt&&F.normalMapType===Dc,metalnessMap:xt,roughnessMap:fe,anisotropy:X,anisotropyMap:lt,clearcoat:le,clearcoatMap:Ot,clearcoatNormalMap:jt,clearcoatRoughnessMap:pt,dispersion:Re,iridescence:pe,iridescenceMap:Yt,iridescenceThicknessMap:rn,sheen:Me,sheenColorMap:$t,sheenRoughnessMap:kt,specularMap:Vt,specularColorMap:Nn,specularIntensityMap:_i,transmission:nt,transmissionMap:me,thicknessMap:bt,gradientMap:tt,opaque:F.transparent===!1&&F.blending===Ka&&F.alphaToCoverage===!1,alphaMap:St,alphaTest:qt,alphaHash:Ht,combine:F.combine,mapUv:Ft&&R(F.map.channel),aoMapUv:ce&&R(F.aoMap.channel),lightMapUv:Gt&&R(F.lightMap.channel),bumpMapUv:ht&&R(F.bumpMap.channel),normalMapUv:Pt&&R(F.normalMap.channel),displacementMapUv:yt&&R(F.displacementMap.channel),emissiveMapUv:en&&R(F.emissiveMap.channel),metalnessMapUv:xt&&R(F.metalnessMap.channel),roughnessMapUv:fe&&R(F.roughnessMap.channel),anisotropyMapUv:lt&&R(F.anisotropyMap.channel),clearcoatMapUv:Ot&&R(F.clearcoatMap.channel),clearcoatNormalMapUv:jt&&R(F.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:pt&&R(F.clearcoatRoughnessMap.channel),iridescenceMapUv:Yt&&R(F.iridescenceMap.channel),iridescenceThicknessMapUv:rn&&R(F.iridescenceThicknessMap.channel),sheenColorMapUv:$t&&R(F.sheenColorMap.channel),sheenRoughnessMapUv:kt&&R(F.sheenRoughnessMap.channel),specularMapUv:Vt&&R(F.specularMap.channel),specularColorMapUv:Nn&&R(F.specularColorMap.channel),specularIntensityMapUv:_i&&R(F.specularIntensityMap.channel),transmissionMapUv:me&&R(F.transmissionMap.channel),thicknessMapUv:bt&&R(F.thicknessMap.channel),alphaMapUv:St&&R(F.alphaMap.channel),vertexTangents:!!ne.attributes.tangent&&(Pt||X),vertexColors:F.vertexColors,vertexAlphas:F.vertexColors===!0&&!!ne.attributes.color&&ne.attributes.color.itemSize===4,pointsUvs:te.isPoints===!0&&!!ne.attributes.uv&&(Ft||St),fog:!!re,useFog:F.fog===!0,fogExp2:!!re&&re.isFogExp2,flatShading:F.flatShading===!0,sizeAttenuation:F.sizeAttenuation===!0,logarithmicDepthBuffer:v,reverseDepthBuffer:dt,skinning:te.isSkinnedMesh===!0,morphTargets:ne.morphAttributes.position!==void 0,morphNormals:ne.morphAttributes.normal!==void 0,morphColors:ne.morphAttributes.color!==void 0,morphTargetsCount:ue,morphTextureStride:we,numDirLights:V.directional.length,numPointLights:V.point.length,numSpotLights:V.spot.length,numSpotLightMaps:V.spotLightMap.length,numRectAreaLights:V.rectArea.length,numHemiLights:V.hemi.length,numDirLightShadows:V.directionalShadowMap.length,numPointLightShadows:V.pointShadowMap.length,numSpotLightShadows:V.spotShadowMap.length,numSpotLightShadowsWithMaps:V.numSpotLightShadowsWithMaps,numLightProbes:V.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:F.dithering,shadowMapEnabled:i.shadowMap.enabled&&Y.length>0,shadowMapType:i.shadowMap.type,toneMapping:qi,decodeVideoTexture:Ft&&F.map.isVideoTexture===!0&&ai.getTransfer(F.map.colorSpace)===Vi,decodeVideoTextureEmissive:en&&F.emissiveMap.isVideoTexture===!0&&ai.getTransfer(F.emissiveMap.colorSpace)===Vi,premultipliedAlpha:F.premultipliedAlpha,doubleSided:F.side===as,flipSided:F.side===hr,useDepthPacking:F.depthPacking>=0,depthPacking:F.depthPacking||0,index0AttributeName:F.index0AttributeName,extensionClipCullDistance:xn&&F.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(xn&&F.extensions.multiDraw===!0||wt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:F.customProgramCacheKey()};return rr.vertexUv1s=h.has(1),rr.vertexUv2s=h.has(2),rr.vertexUv3s=h.has(3),h.clear(),rr}function E(F){const V=[];if(F.shaderID?V.push(F.shaderID):(V.push(F.customVertexShaderID),V.push(F.customFragmentShaderID)),F.defines!==void 0)for(const Y in F.defines)V.push(Y),V.push(F.defines[Y]);return F.isRawShaderMaterial===!1&&(B(V,F),L(V,F),V.push(i.outputColorSpace)),V.push(F.customProgramCacheKey),V.join()}function B(F,V){F.push(V.precision),F.push(V.outputColorSpace),F.push(V.envMapMode),F.push(V.envMapCubeUVHeight),F.push(V.mapUv),F.push(V.alphaMapUv),F.push(V.lightMapUv),F.push(V.aoMapUv),F.push(V.bumpMapUv),F.push(V.normalMapUv),F.push(V.displacementMapUv),F.push(V.emissiveMapUv),F.push(V.metalnessMapUv),F.push(V.roughnessMapUv),F.push(V.anisotropyMapUv),F.push(V.clearcoatMapUv),F.push(V.clearcoatNormalMapUv),F.push(V.clearcoatRoughnessMapUv),F.push(V.iridescenceMapUv),F.push(V.iridescenceThicknessMapUv),F.push(V.sheenColorMapUv),F.push(V.sheenRoughnessMapUv),F.push(V.specularMapUv),F.push(V.specularColorMapUv),F.push(V.specularIntensityMapUv),F.push(V.transmissionMapUv),F.push(V.thicknessMapUv),F.push(V.combine),F.push(V.fogExp2),F.push(V.sizeAttenuation),F.push(V.morphTargetsCount),F.push(V.morphAttributeCount),F.push(V.numDirLights),F.push(V.numPointLights),F.push(V.numSpotLights),F.push(V.numSpotLightMaps),F.push(V.numHemiLights),F.push(V.numRectAreaLights),F.push(V.numDirLightShadows),F.push(V.numPointLightShadows),F.push(V.numSpotLightShadows),F.push(V.numSpotLightShadowsWithMaps),F.push(V.numLightProbes),F.push(V.shadowMapType),F.push(V.toneMapping),F.push(V.numClippingPlanes),F.push(V.numClipIntersection),F.push(V.depthPacking)}function L(F,V){l.disableAll(),V.supportsVertexTextures&&l.enable(0),V.instancing&&l.enable(1),V.instancingColor&&l.enable(2),V.instancingMorph&&l.enable(3),V.matcap&&l.enable(4),V.envMap&&l.enable(5),V.normalMapObjectSpace&&l.enable(6),V.normalMapTangentSpace&&l.enable(7),V.clearcoat&&l.enable(8),V.iridescence&&l.enable(9),V.alphaTest&&l.enable(10),V.vertexColors&&l.enable(11),V.vertexAlphas&&l.enable(12),V.vertexUv1s&&l.enable(13),V.vertexUv2s&&l.enable(14),V.vertexUv3s&&l.enable(15),V.vertexTangents&&l.enable(16),V.anisotropy&&l.enable(17),V.alphaHash&&l.enable(18),V.batching&&l.enable(19),V.dispersion&&l.enable(20),V.batchingColor&&l.enable(21),F.push(l.mask),l.disableAll(),V.fog&&l.enable(0),V.useFog&&l.enable(1),V.flatShading&&l.enable(2),V.logarithmicDepthBuffer&&l.enable(3),V.reverseDepthBuffer&&l.enable(4),V.skinning&&l.enable(5),V.morphTargets&&l.enable(6),V.morphNormals&&l.enable(7),V.morphColors&&l.enable(8),V.premultipliedAlpha&&l.enable(9),V.shadowMapEnabled&&l.enable(10),V.doubleSided&&l.enable(11),V.flipSided&&l.enable(12),V.useDepthPacking&&l.enable(13),V.dithering&&l.enable(14),V.transmission&&l.enable(15),V.sheen&&l.enable(16),V.opaque&&l.enable(17),V.pointsUvs&&l.enable(18),V.decodeVideoTexture&&l.enable(19),V.decodeVideoTextureEmissive&&l.enable(20),V.alphaToCoverage&&l.enable(21),F.push(l.mask)}function O(F){const V=w[F.type];let Y;if(V){const ee=Ga[V];Y=vy.clone(ee.uniforms)}else Y=F.uniforms;return Y}function G(F,V){let Y;for(let ee=0,te=m.length;ee0?n.push(E):S.transparent===!0?r.push(E):t.push(E)}function u(v,x,S,w,R,C){const E=a(v,x,S,w,R,C);S.transmission>0?n.unshift(E):S.transparent===!0?r.unshift(E):t.unshift(E)}function h(v,x){t.length>1&&t.sort(v||hj),n.length>1&&n.sort(x||J5),r.length>1&&r.sort(x||J5)}function m(){for(let v=e,x=i.length;v=s.length?(a=new eR,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Aj(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new he,color:new an};break;case"SpotLight":t={position:new he,direction:new he,color:new an,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new he,color:new an,distance:0,decay:0};break;case"HemisphereLight":t={direction:new he,skyColor:new an,groundColor:new an};break;case"RectAreaLight":t={color:new an,position:new he,halfWidth:new he,halfHeight:new he};break}return i[e.id]=t,t}}}function dj(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new gt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let pj=0;function mj(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function gj(i){const e=new Aj,t=dj(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)n.probe.push(new he);const r=new he,s=new kn,a=new kn;function l(h){let m=0,v=0,x=0;for(let F=0;F<9;F++)n.probe[F].set(0,0,0);let S=0,w=0,R=0,C=0,E=0,B=0,L=0,O=0,G=0,q=0,z=0;h.sort(mj);for(let F=0,V=h.length;F0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Kt.LTC_FLOAT_1,n.rectAreaLTC2=Kt.LTC_FLOAT_2):(n.rectAreaLTC1=Kt.LTC_HALF_1,n.rectAreaLTC2=Kt.LTC_HALF_2)),n.ambient[0]=m,n.ambient[1]=v,n.ambient[2]=x;const j=n.hash;(j.directionalLength!==S||j.pointLength!==w||j.spotLength!==R||j.rectAreaLength!==C||j.hemiLength!==E||j.numDirectionalShadows!==B||j.numPointShadows!==L||j.numSpotShadows!==O||j.numSpotMaps!==G||j.numLightProbes!==z)&&(n.directional.length=S,n.spot.length=R,n.rectArea.length=C,n.point.length=w,n.hemi.length=E,n.directionalShadow.length=B,n.directionalShadowMap.length=B,n.pointShadow.length=L,n.pointShadowMap.length=L,n.spotShadow.length=O,n.spotShadowMap.length=O,n.directionalShadowMatrix.length=B,n.pointShadowMatrix.length=L,n.spotLightMatrix.length=O+G-q,n.spotLightMap.length=G,n.numSpotLightShadowsWithMaps=q,n.numLightProbes=z,j.directionalLength=S,j.pointLength=w,j.spotLength=R,j.rectAreaLength=C,j.hemiLength=E,j.numDirectionalShadows=B,j.numPointShadows=L,j.numSpotShadows=O,j.numSpotMaps=G,j.numLightProbes=z,n.version=pj++)}function u(h,m){let v=0,x=0,S=0,w=0,R=0;const C=m.matrixWorldInverse;for(let E=0,B=h.length;E=a.length?(l=new tR(i),a.push(l)):l=a[s],l}function n(){e=new WeakMap}return{get:t,dispose:n}}const _j=`void main() { - gl_Position = vec4( position, 1.0 ); -}`,yj=`uniform sampler2D shadow_pass; -uniform vec2 resolution; -uniform float radius; -#include -void main() { - const float samples = float( VSM_SAMPLES ); - float mean = 0.0; - float squared_mean = 0.0; - float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); - float uvStart = samples <= 1.0 ? 0.0 : - 1.0; - for ( float i = 0.0; i < samples; i ++ ) { - float uvOffset = uvStart + i * uvStride; - #ifdef HORIZONTAL_PASS - vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); - mean += distribution.x; - squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; - #else - float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); - mean += depth; - squared_mean += depth * depth; - #endif - } - mean = mean / samples; - squared_mean = squared_mean / samples; - float std_dev = sqrt( squared_mean - mean * mean ); - gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function xj(i,e,t){let n=new Fg;const r=new gt,s=new gt,a=new Ln,l=new Pz({depthPacking:$F}),u=new Lz,h={},m=t.maxTextureSize,v={[Nl]:hr,[hr]:Nl,[as]:as},x=new Ja({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new gt},radius:{value:4}},vertexShader:_j,fragmentShader:yj}),S=x.clone();S.defines.HORIZONTAL_PASS=1;const w=new Ki;w.setAttribute("position",new wr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const R=new zi(w,x),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yw;let E=this.type;this.render=function(q,z,j){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||q.length===0)return;const F=i.getRenderTarget(),V=i.getActiveCubeFace(),Y=i.getActiveMipmapLevel(),ee=i.state;ee.setBlending(Qa),ee.buffers.color.setClear(1,1,1,1),ee.buffers.depth.setTest(!0),ee.setScissorTest(!1);const te=E!==xo&&this.type===xo,re=E===xo&&this.type!==xo;for(let ne=0,Q=q.length;nem||r.y>m)&&(r.x>m&&(s.x=Math.floor(m/Te.x),r.x=s.x*Te.x,de.mapSize.x=s.x),r.y>m&&(s.y=Math.floor(m/Te.y),r.y=s.y*Te.y,de.mapSize.y=s.y)),de.map===null||te===!0||re===!0){const ue=this.type!==xo?{minFilter:mr,magFilter:mr}:{};de.map!==null&&de.map.dispose(),de.map=new qh(r.x,r.y,ue),de.map.texture.name=ae.name+".shadowMap",de.camera.updateProjectionMatrix()}i.setRenderTarget(de.map),i.clear();const be=de.getViewportCount();for(let ue=0;ue0||z.map&&z.alphaTest>0){const ee=V.uuid,te=z.uuid;let re=h[ee];re===void 0&&(re={},h[ee]=re);let ne=re[te];ne===void 0&&(ne=V.clone(),re[te]=ne,z.addEventListener("dispose",G)),V=ne}if(V.visible=z.visible,V.wireframe=z.wireframe,F===xo?V.side=z.shadowSide!==null?z.shadowSide:z.side:V.side=z.shadowSide!==null?z.shadowSide:v[z.side],V.alphaMap=z.alphaMap,V.alphaTest=z.alphaTest,V.map=z.map,V.clipShadows=z.clipShadows,V.clippingPlanes=z.clippingPlanes,V.clipIntersection=z.clipIntersection,V.displacementMap=z.displacementMap,V.displacementScale=z.displacementScale,V.displacementBias=z.displacementBias,V.wireframeLinewidth=z.wireframeLinewidth,V.linewidth=z.linewidth,j.isPointLight===!0&&V.isMeshDistanceMaterial===!0){const ee=i.properties.get(V);ee.light=j}return V}function O(q,z,j,F,V){if(q.visible===!1)return;if(q.layers.test(z.layers)&&(q.isMesh||q.isLine||q.isPoints)&&(q.castShadow||q.receiveShadow&&V===xo)&&(!q.frustumCulled||n.intersectsObject(q))){q.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,q.matrixWorld);const te=e.update(q),re=q.material;if(Array.isArray(re)){const ne=te.groups;for(let Q=0,ae=ne.length;Q=1):de.indexOf("OpenGL ES")!==-1&&(ae=parseFloat(/^OpenGL ES (\d)/.exec(de)[1]),Q=ae>=2);let Te=null,be={};const ue=i.getParameter(i.SCISSOR_BOX),we=i.getParameter(i.VIEWPORT),We=new Ln().fromArray(ue),Ne=new Ln().fromArray(we);function ze(me,bt,tt,St){const qt=new Uint8Array(4),Ht=i.createTexture();i.bindTexture(me,Ht),i.texParameteri(me,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(me,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let xn=0;xn"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new gt,m=new WeakMap;let v;const x=new WeakMap;let S=!1;try{S=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function w(fe,X){return S?new OffscreenCanvas(fe,X):sg("canvas")}function R(fe,X,le){let Re=1;const pe=xt(fe);if((pe.width>le||pe.height>le)&&(Re=le/Math.max(pe.width,pe.height)),Re<1)if(typeof HTMLImageElement<"u"&&fe instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&fe instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&fe instanceof ImageBitmap||typeof VideoFrame<"u"&&fe instanceof VideoFrame){const Me=Math.floor(Re*pe.width),nt=Math.floor(Re*pe.height);v===void 0&&(v=w(Me,nt));const lt=X?w(Me,nt):v;return lt.width=Me,lt.height=nt,lt.getContext("2d").drawImage(fe,0,0,Me,nt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+pe.width+"x"+pe.height+") to ("+Me+"x"+nt+")."),lt}else return"data"in fe&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+pe.width+"x"+pe.height+")."),fe;return fe}function C(fe){return fe.generateMipmaps}function E(fe){i.generateMipmap(fe)}function B(fe){return fe.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:fe.isWebGL3DRenderTarget?i.TEXTURE_3D:fe.isWebGLArrayRenderTarget||fe.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function L(fe,X,le,Re,pe=!1){if(fe!==null){if(i[fe]!==void 0)return i[fe];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+fe+"'")}let Me=X;if(X===i.RED&&(le===i.FLOAT&&(Me=i.R32F),le===i.HALF_FLOAT&&(Me=i.R16F),le===i.UNSIGNED_BYTE&&(Me=i.R8)),X===i.RED_INTEGER&&(le===i.UNSIGNED_BYTE&&(Me=i.R8UI),le===i.UNSIGNED_SHORT&&(Me=i.R16UI),le===i.UNSIGNED_INT&&(Me=i.R32UI),le===i.BYTE&&(Me=i.R8I),le===i.SHORT&&(Me=i.R16I),le===i.INT&&(Me=i.R32I)),X===i.RG&&(le===i.FLOAT&&(Me=i.RG32F),le===i.HALF_FLOAT&&(Me=i.RG16F),le===i.UNSIGNED_BYTE&&(Me=i.RG8)),X===i.RG_INTEGER&&(le===i.UNSIGNED_BYTE&&(Me=i.RG8UI),le===i.UNSIGNED_SHORT&&(Me=i.RG16UI),le===i.UNSIGNED_INT&&(Me=i.RG32UI),le===i.BYTE&&(Me=i.RG8I),le===i.SHORT&&(Me=i.RG16I),le===i.INT&&(Me=i.RG32I)),X===i.RGB_INTEGER&&(le===i.UNSIGNED_BYTE&&(Me=i.RGB8UI),le===i.UNSIGNED_SHORT&&(Me=i.RGB16UI),le===i.UNSIGNED_INT&&(Me=i.RGB32UI),le===i.BYTE&&(Me=i.RGB8I),le===i.SHORT&&(Me=i.RGB16I),le===i.INT&&(Me=i.RGB32I)),X===i.RGBA_INTEGER&&(le===i.UNSIGNED_BYTE&&(Me=i.RGBA8UI),le===i.UNSIGNED_SHORT&&(Me=i.RGBA16UI),le===i.UNSIGNED_INT&&(Me=i.RGBA32UI),le===i.BYTE&&(Me=i.RGBA8I),le===i.SHORT&&(Me=i.RGBA16I),le===i.INT&&(Me=i.RGBA32I)),X===i.RGB&&le===i.UNSIGNED_INT_5_9_9_9_REV&&(Me=i.RGB9_E5),X===i.RGBA){const nt=pe?a_:ai.getTransfer(Re);le===i.FLOAT&&(Me=i.RGBA32F),le===i.HALF_FLOAT&&(Me=i.RGBA16F),le===i.UNSIGNED_BYTE&&(Me=nt===Vi?i.SRGB8_ALPHA8:i.RGBA8),le===i.UNSIGNED_SHORT_4_4_4_4&&(Me=i.RGBA4),le===i.UNSIGNED_SHORT_5_5_5_1&&(Me=i.RGB5_A1)}return(Me===i.R16F||Me===i.R32F||Me===i.RG16F||Me===i.RG32F||Me===i.RGBA16F||Me===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Me}function O(fe,X){let le;return fe?X===null||X===Rr||X===Au?le=i.DEPTH24_STENCIL8:X===$r?le=i.DEPTH32F_STENCIL8:X===wl&&(le=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):X===null||X===Rr||X===Au?le=i.DEPTH_COMPONENT24:X===$r?le=i.DEPTH_COMPONENT32F:X===wl&&(le=i.DEPTH_COMPONENT16),le}function G(fe,X){return C(fe)===!0||fe.isFramebufferTexture&&fe.minFilter!==mr&&fe.minFilter!==gs?Math.log2(Math.max(X.width,X.height))+1:fe.mipmaps!==void 0&&fe.mipmaps.length>0?fe.mipmaps.length:fe.isCompressedTexture&&Array.isArray(fe.image)?X.mipmaps.length:1}function q(fe){const X=fe.target;X.removeEventListener("dispose",q),j(X),X.isVideoTexture&&m.delete(X)}function z(fe){const X=fe.target;X.removeEventListener("dispose",z),V(X)}function j(fe){const X=n.get(fe);if(X.__webglInit===void 0)return;const le=fe.source,Re=x.get(le);if(Re){const pe=Re[X.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&F(fe),Object.keys(Re).length===0&&x.delete(le)}n.remove(fe)}function F(fe){const X=n.get(fe);i.deleteTexture(X.__webglTexture);const le=fe.source,Re=x.get(le);delete Re[X.__cacheKey],a.memory.textures--}function V(fe){const X=n.get(fe);if(fe.depthTexture&&(fe.depthTexture.dispose(),n.remove(fe.depthTexture)),fe.isWebGLCubeRenderTarget)for(let Re=0;Re<6;Re++){if(Array.isArray(X.__webglFramebuffer[Re]))for(let pe=0;pe=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+fe+" texture units while this GPU supports only "+r.maxTextures),Y+=1,fe}function re(fe){const X=[];return X.push(fe.wrapS),X.push(fe.wrapT),X.push(fe.wrapR||0),X.push(fe.magFilter),X.push(fe.minFilter),X.push(fe.anisotropy),X.push(fe.internalFormat),X.push(fe.format),X.push(fe.type),X.push(fe.generateMipmaps),X.push(fe.premultiplyAlpha),X.push(fe.flipY),X.push(fe.unpackAlignment),X.push(fe.colorSpace),X.join()}function ne(fe,X){const le=n.get(fe);if(fe.isVideoTexture&&yt(fe),fe.isRenderTargetTexture===!1&&fe.version>0&&le.__version!==fe.version){const Re=fe.image;if(Re===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Re.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ne(le,fe,X);return}}t.bindTexture(i.TEXTURE_2D,le.__webglTexture,i.TEXTURE0+X)}function Q(fe,X){const le=n.get(fe);if(fe.version>0&&le.__version!==fe.version){Ne(le,fe,X);return}t.bindTexture(i.TEXTURE_2D_ARRAY,le.__webglTexture,i.TEXTURE0+X)}function ae(fe,X){const le=n.get(fe);if(fe.version>0&&le.__version!==fe.version){Ne(le,fe,X);return}t.bindTexture(i.TEXTURE_3D,le.__webglTexture,i.TEXTURE0+X)}function de(fe,X){const le=n.get(fe);if(fe.version>0&&le.__version!==fe.version){ze(le,fe,X);return}t.bindTexture(i.TEXTURE_CUBE_MAP,le.__webglTexture,i.TEXTURE0+X)}const Te={[aA]:i.REPEAT,[eu]:i.CLAMP_TO_EDGE,[oA]:i.MIRRORED_REPEAT},be={[mr]:i.NEAREST,[s_]:i.NEAREST_MIPMAP_NEAREST,[tu]:i.NEAREST_MIPMAP_LINEAR,[gs]:i.LINEAR,[Jd]:i.LINEAR_MIPMAP_NEAREST,[Va]:i.LINEAR_MIPMAP_LINEAR},ue={[Fw]:i.NEVER,[Vw]:i.ALWAYS,[my]:i.LESS,[gy]:i.LEQUAL,[kw]:i.EQUAL,[qw]:i.GEQUAL,[zw]:i.GREATER,[Gw]:i.NOTEQUAL};function we(fe,X){if(X.type===$r&&e.has("OES_texture_float_linear")===!1&&(X.magFilter===gs||X.magFilter===Jd||X.magFilter===tu||X.magFilter===Va||X.minFilter===gs||X.minFilter===Jd||X.minFilter===tu||X.minFilter===Va)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(fe,i.TEXTURE_WRAP_S,Te[X.wrapS]),i.texParameteri(fe,i.TEXTURE_WRAP_T,Te[X.wrapT]),(fe===i.TEXTURE_3D||fe===i.TEXTURE_2D_ARRAY)&&i.texParameteri(fe,i.TEXTURE_WRAP_R,Te[X.wrapR]),i.texParameteri(fe,i.TEXTURE_MAG_FILTER,be[X.magFilter]),i.texParameteri(fe,i.TEXTURE_MIN_FILTER,be[X.minFilter]),X.compareFunction&&(i.texParameteri(fe,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(fe,i.TEXTURE_COMPARE_FUNC,ue[X.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(X.magFilter===mr||X.minFilter!==tu&&X.minFilter!==Va||X.type===$r&&e.has("OES_texture_float_linear")===!1)return;if(X.anisotropy>1||n.get(X).__currentAnisotropy){const le=e.get("EXT_texture_filter_anisotropic");i.texParameterf(fe,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(X.anisotropy,r.getMaxAnisotropy())),n.get(X).__currentAnisotropy=X.anisotropy}}}function We(fe,X){let le=!1;fe.__webglInit===void 0&&(fe.__webglInit=!0,X.addEventListener("dispose",q));const Re=X.source;let pe=x.get(Re);pe===void 0&&(pe={},x.set(Re,pe));const Me=re(X);if(Me!==fe.__cacheKey){pe[Me]===void 0&&(pe[Me]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,le=!0),pe[Me].usedTimes++;const nt=pe[fe.__cacheKey];nt!==void 0&&(pe[fe.__cacheKey].usedTimes--,nt.usedTimes===0&&F(X)),fe.__cacheKey=Me,fe.__webglTexture=pe[Me].texture}return le}function Ne(fe,X,le){let Re=i.TEXTURE_2D;(X.isDataArrayTexture||X.isCompressedArrayTexture)&&(Re=i.TEXTURE_2D_ARRAY),X.isData3DTexture&&(Re=i.TEXTURE_3D);const pe=We(fe,X),Me=X.source;t.bindTexture(Re,fe.__webglTexture,i.TEXTURE0+le);const nt=n.get(Me);if(Me.version!==nt.__version||pe===!0){t.activeTexture(i.TEXTURE0+le);const lt=ai.getPrimaries(ai.workingColorSpace),Ot=X.colorSpace===Co?null:ai.getPrimaries(X.colorSpace),jt=X.colorSpace===Co||lt===Ot?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,X.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,X.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,X.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,jt);let pt=R(X.image,!1,r.maxTextureSize);pt=en(X,pt);const Yt=s.convert(X.format,X.colorSpace),rn=s.convert(X.type);let $t=L(X.internalFormat,Yt,rn,X.colorSpace,X.isVideoTexture);we(Re,X);let kt;const Vt=X.mipmaps,Nn=X.isVideoTexture!==!0,_i=nt.__version===void 0||pe===!0,me=Me.dataReady,bt=G(X,pt);if(X.isDepthTexture)$t=O(X.format===du,X.type),_i&&(Nn?t.texStorage2D(i.TEXTURE_2D,1,$t,pt.width,pt.height):t.texImage2D(i.TEXTURE_2D,0,$t,pt.width,pt.height,0,Yt,rn,null));else if(X.isDataTexture)if(Vt.length>0){Nn&&_i&&t.texStorage2D(i.TEXTURE_2D,bt,$t,Vt[0].width,Vt[0].height);for(let tt=0,St=Vt.length;tt0){const qt=D5(kt.width,kt.height,X.format,X.type);for(const Ht of X.layerUpdates){const xn=kt.data.subarray(Ht*qt/kt.data.BYTES_PER_ELEMENT,(Ht+1)*qt/kt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,tt,0,0,Ht,kt.width,kt.height,1,Yt,xn)}X.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,tt,0,0,0,kt.width,kt.height,pt.depth,Yt,kt.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,tt,$t,kt.width,kt.height,pt.depth,0,kt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Nn?me&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,tt,0,0,0,kt.width,kt.height,pt.depth,Yt,rn,kt.data):t.texImage3D(i.TEXTURE_2D_ARRAY,tt,$t,kt.width,kt.height,pt.depth,0,Yt,rn,kt.data)}else{Nn&&_i&&t.texStorage2D(i.TEXTURE_2D,bt,$t,Vt[0].width,Vt[0].height);for(let tt=0,St=Vt.length;tt0){const tt=D5(pt.width,pt.height,X.format,X.type);for(const St of X.layerUpdates){const qt=pt.data.subarray(St*tt/pt.data.BYTES_PER_ELEMENT,(St+1)*tt/pt.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,St,pt.width,pt.height,1,Yt,rn,qt)}X.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,pt.width,pt.height,pt.depth,Yt,rn,pt.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,$t,pt.width,pt.height,pt.depth,0,Yt,rn,pt.data);else if(X.isData3DTexture)Nn?(_i&&t.texStorage3D(i.TEXTURE_3D,bt,$t,pt.width,pt.height,pt.depth),me&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,pt.width,pt.height,pt.depth,Yt,rn,pt.data)):t.texImage3D(i.TEXTURE_3D,0,$t,pt.width,pt.height,pt.depth,0,Yt,rn,pt.data);else if(X.isFramebufferTexture){if(_i)if(Nn)t.texStorage2D(i.TEXTURE_2D,bt,$t,pt.width,pt.height);else{let tt=pt.width,St=pt.height;for(let qt=0;qt>=1,St>>=1}}else if(Vt.length>0){if(Nn&&_i){const tt=xt(Vt[0]);t.texStorage2D(i.TEXTURE_2D,bt,$t,tt.width,tt.height)}for(let tt=0,St=Vt.length;tt0&&bt++;const St=xt(Yt[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,bt,Vt,St.width,St.height)}for(let St=0;St<6;St++)if(pt){Nn?me&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+St,0,0,0,Yt[St].width,Yt[St].height,$t,kt,Yt[St].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+St,0,Vt,Yt[St].width,Yt[St].height,0,$t,kt,Yt[St].data);for(let qt=0;qt>Me),rn=Math.max(1,X.height>>Me);pe===i.TEXTURE_3D||pe===i.TEXTURE_2D_ARRAY?t.texImage3D(pe,Me,Ot,Yt,rn,X.depth,0,nt,lt,null):t.texImage2D(pe,Me,Ot,Yt,rn,0,nt,lt,null)}t.bindFramebuffer(i.FRAMEBUFFER,fe),Pt(X)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Re,pe,pt.__webglTexture,0,ht(X)):(pe===i.TEXTURE_2D||pe>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&pe<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Re,pe,pt.__webglTexture,Me),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ce(fe,X,le){if(i.bindRenderbuffer(i.RENDERBUFFER,fe),X.depthBuffer){const Re=X.depthTexture,pe=Re&&Re.isDepthTexture?Re.type:null,Me=O(X.stencilBuffer,pe),nt=X.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,lt=ht(X);Pt(X)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,lt,Me,X.width,X.height):le?i.renderbufferStorageMultisample(i.RENDERBUFFER,lt,Me,X.width,X.height):i.renderbufferStorage(i.RENDERBUFFER,Me,X.width,X.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,nt,i.RENDERBUFFER,fe)}else{const Re=X.textures;for(let pe=0;pe{delete X.__boundDepthTexture,delete X.__depthDisposeCallback,Re.removeEventListener("dispose",pe)};Re.addEventListener("dispose",pe),X.__depthDisposeCallback=pe}X.__boundDepthTexture=Re}if(fe.depthTexture&&!X.__autoAllocateDepthBuffer){if(le)throw new Error("target.depthTexture not supported in Cube render targets");dt(X.__webglFramebuffer,fe)}else if(le){X.__webglDepthbuffer=[];for(let Re=0;Re<6;Re++)if(t.bindFramebuffer(i.FRAMEBUFFER,X.__webglFramebuffer[Re]),X.__webglDepthbuffer[Re]===void 0)X.__webglDepthbuffer[Re]=i.createRenderbuffer(),Ce(X.__webglDepthbuffer[Re],fe,!1);else{const pe=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Me=X.__webglDepthbuffer[Re];i.bindRenderbuffer(i.RENDERBUFFER,Me),i.framebufferRenderbuffer(i.FRAMEBUFFER,pe,i.RENDERBUFFER,Me)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,X.__webglFramebuffer),X.__webglDepthbuffer===void 0)X.__webglDepthbuffer=i.createRenderbuffer(),Ce(X.__webglDepthbuffer,fe,!1);else{const Re=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pe=X.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,pe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Re,i.RENDERBUFFER,pe)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function wt(fe,X,le){const Re=n.get(fe);X!==void 0&&Se(Re.__webglFramebuffer,fe,fe.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),le!==void 0&&At(fe)}function Ft(fe){const X=fe.texture,le=n.get(fe),Re=n.get(X);fe.addEventListener("dispose",z);const pe=fe.textures,Me=fe.isWebGLCubeRenderTarget===!0,nt=pe.length>1;if(nt||(Re.__webglTexture===void 0&&(Re.__webglTexture=i.createTexture()),Re.__version=X.version,a.memory.textures++),Me){le.__webglFramebuffer=[];for(let lt=0;lt<6;lt++)if(X.mipmaps&&X.mipmaps.length>0){le.__webglFramebuffer[lt]=[];for(let Ot=0;Ot0){le.__webglFramebuffer=[];for(let lt=0;lt0&&Pt(fe)===!1){le.__webglMultisampledFramebuffer=i.createFramebuffer(),le.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,le.__webglMultisampledFramebuffer);for(let lt=0;lt0)for(let Ot=0;Ot0)for(let Ot=0;Ot0){if(Pt(fe)===!1){const X=fe.textures,le=fe.width,Re=fe.height;let pe=i.COLOR_BUFFER_BIT;const Me=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,nt=n.get(fe),lt=X.length>1;if(lt)for(let Ot=0;Ot0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&X.__useRenderToTexture!==!1}function yt(fe){const X=a.render.frame;m.get(fe)!==X&&(m.set(fe,X),fe.update())}function en(fe,X){const le=fe.colorSpace,Re=fe.format,pe=fe.type;return fe.isCompressedTexture===!0||fe.isVideoTexture===!0||le!==Ro&&le!==Co&&(ai.getTransfer(le)===Vi?(Re!==ks||pe!==aa)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",le)),X}function xt(fe){return typeof HTMLImageElement<"u"&&fe instanceof HTMLImageElement?(h.width=fe.naturalWidth||fe.width,h.height=fe.naturalHeight||fe.height):typeof VideoFrame<"u"&&fe instanceof VideoFrame?(h.width=fe.displayWidth,h.height=fe.displayHeight):(h.width=fe.width,h.height=fe.height),h}this.allocateTextureUnit=te,this.resetTextureUnits=ee,this.setTexture2D=ne,this.setTexture2DArray=Q,this.setTexture3D=ae,this.setTextureCube=de,this.rebindTextures=wt,this.setupRenderTarget=Ft,this.updateRenderTargetMipmap=$e,this.updateMultisampleRenderTarget=Gt,this.setupDepthRenderbuffer=At,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=Pt}function wj(i,e){function t(n,r=Co){let s;const a=ai.getTransfer(r);if(n===aa)return i.UNSIGNED_BYTE;if(n===Ay)return i.UNSIGNED_SHORT_4_4_4_4;if(n===dy)return i.UNSIGNED_SHORT_5_5_5_1;if(n===py)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Qf)return i.BYTE;if(n===Kf)return i.SHORT;if(n===wl)return i.UNSIGNED_SHORT;if(n===Ns)return i.INT;if(n===Rr)return i.UNSIGNED_INT;if(n===$r)return i.FLOAT;if(n===Gs)return i.HALF_FLOAT;if(n===Uw)return i.ALPHA;if(n===Ug)return i.RGB;if(n===ks)return i.RGBA;if(n===Bw)return i.LUMINANCE;if(n===Ow)return i.LUMINANCE_ALPHA;if(n===au)return i.DEPTH_COMPONENT;if(n===du)return i.DEPTH_STENCIL;if(n===Bg)return i.RED;if(n===H0)return i.RED_INTEGER;if(n===lA)return i.RG;if(n===j0)return i.RG_INTEGER;if(n===W0)return i.RGBA_INTEGER;if(n===Zf||n===Bh||n===Oh||n===Ih)if(a===Vi)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Zf)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Bh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Oh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ih)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Zf)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Bh)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Oh)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ih)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Km||n===Zm||n===Jm||n===eg)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Km)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Zm)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Jm)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===eg)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===tg||n===u0||n===c0)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===tg||n===u0)return a===Vi?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===c0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===h0||n===f0||n===A0||n===d0||n===p0||n===m0||n===g0||n===v0||n===_0||n===y0||n===x0||n===b0||n===S0||n===T0)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===h0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===f0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===A0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===d0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===p0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===m0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===g0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===v0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===_0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===y0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===x0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===b0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===S0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===T0)return a===Vi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Jf||n===HS||n===jS)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Jf)return a===Vi?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===HS)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===jS)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Iw||n===ng||n===ig||n===rg)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Jf)return s.COMPRESSED_RED_RGTC1_EXT;if(n===ng)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ig)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===rg)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Au?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Mj={type:"move"};class D3{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ja,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ja,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new he,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new he),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ja,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new he,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new he),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const l=this._targetRay,u=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const R of e.hand.values()){const C=t.getJointPose(R,n),E=this._getHandJoint(h,R);C!==null&&(E.matrix.fromArray(C.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=C.radius),E.visible=C!==null}const m=h.joints["index-finger-tip"],v=h.joints["thumb-tip"],x=m.position.distanceTo(v.position),S=.02,w=.005;h.inputState.pinching&&x>S+w?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&x<=S-w&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(Mj)))}return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=s!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ja;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Ej=` -void main() { - - gl_Position = vec4( position, 1.0 ); - -}`,Cj=` -uniform sampler2DArray depthColor; -uniform float depthWidth; -uniform float depthHeight; - -void main() { - - vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); - - if ( coord.x >= 1.0 ) { - - gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; - - } else { - - gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; - - } - -}`;class Rj{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new vs,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Ja({vertexShader:Ej,fragmentShader:Cj,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new zi(new Ty(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Nj extends zc{constructor(e,t){super();const n=this;let r=null,s=1,a=null,l="local-floor",u=1,h=null,m=null,v=null,x=null,S=null,w=null;const R=new Rj,C=t.getContextAttributes();let E=null,B=null;const L=[],O=[],G=new gt;let q=null;const z=new ya;z.viewport=new Ln;const j=new ya;j.viewport=new Ln;const F=[z,j],V=new Xz;let Y=null,ee=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ne){let ze=L[Ne];return ze===void 0&&(ze=new D3,L[Ne]=ze),ze.getTargetRaySpace()},this.getControllerGrip=function(Ne){let ze=L[Ne];return ze===void 0&&(ze=new D3,L[Ne]=ze),ze.getGripSpace()},this.getHand=function(Ne){let ze=L[Ne];return ze===void 0&&(ze=new D3,L[Ne]=ze),ze.getHandSpace()};function te(Ne){const ze=O.indexOf(Ne.inputSource);if(ze===-1)return;const Se=L[ze];Se!==void 0&&(Se.update(Ne.inputSource,Ne.frame,h||a),Se.dispatchEvent({type:Ne.type,data:Ne.inputSource}))}function re(){r.removeEventListener("select",te),r.removeEventListener("selectstart",te),r.removeEventListener("selectend",te),r.removeEventListener("squeeze",te),r.removeEventListener("squeezestart",te),r.removeEventListener("squeezeend",te),r.removeEventListener("end",re),r.removeEventListener("inputsourceschange",ne);for(let Ne=0;Ne=0&&(O[Ce]=null,L[Ce].disconnect(Se))}for(let ze=0;ze=O.length){O.push(Se),Ce=At;break}else if(O[At]===null){O[At]=Se,Ce=At;break}if(Ce===-1)break}const dt=L[Ce];dt&&dt.connect(Se)}}const Q=new he,ae=new he;function de(Ne,ze,Se){Q.setFromMatrixPosition(ze.matrixWorld),ae.setFromMatrixPosition(Se.matrixWorld);const Ce=Q.distanceTo(ae),dt=ze.projectionMatrix.elements,At=Se.projectionMatrix.elements,wt=dt[14]/(dt[10]-1),Ft=dt[14]/(dt[10]+1),$e=(dt[9]+1)/dt[5],rt=(dt[9]-1)/dt[5],ce=(dt[8]-1)/dt[0],Gt=(At[8]+1)/At[0],ht=wt*ce,Pt=wt*Gt,yt=Ce/(-ce+Gt),en=yt*-ce;if(ze.matrixWorld.decompose(Ne.position,Ne.quaternion,Ne.scale),Ne.translateX(en),Ne.translateZ(yt),Ne.matrixWorld.compose(Ne.position,Ne.quaternion,Ne.scale),Ne.matrixWorldInverse.copy(Ne.matrixWorld).invert(),dt[10]===-1)Ne.projectionMatrix.copy(ze.projectionMatrix),Ne.projectionMatrixInverse.copy(ze.projectionMatrixInverse);else{const xt=wt+yt,fe=Ft+yt,X=ht-en,le=Pt+(Ce-en),Re=$e*Ft/fe*xt,pe=rt*Ft/fe*xt;Ne.projectionMatrix.makePerspective(X,le,Re,pe,xt,fe),Ne.projectionMatrixInverse.copy(Ne.projectionMatrix).invert()}}function Te(Ne,ze){ze===null?Ne.matrixWorld.copy(Ne.matrix):Ne.matrixWorld.multiplyMatrices(ze.matrixWorld,Ne.matrix),Ne.matrixWorldInverse.copy(Ne.matrixWorld).invert()}this.updateCamera=function(Ne){if(r===null)return;let ze=Ne.near,Se=Ne.far;R.texture!==null&&(R.depthNear>0&&(ze=R.depthNear),R.depthFar>0&&(Se=R.depthFar)),V.near=j.near=z.near=ze,V.far=j.far=z.far=Se,(Y!==V.near||ee!==V.far)&&(r.updateRenderState({depthNear:V.near,depthFar:V.far}),Y=V.near,ee=V.far),z.layers.mask=Ne.layers.mask|2,j.layers.mask=Ne.layers.mask|4,V.layers.mask=z.layers.mask|j.layers.mask;const Ce=Ne.parent,dt=V.cameras;Te(V,Ce);for(let At=0;At0&&(C.alphaTest.value=E.alphaTest);const B=e.get(E),L=B.envMap,O=B.envMapRotation;L&&(C.envMap.value=L,wf.copy(O),wf.x*=-1,wf.y*=-1,wf.z*=-1,L.isCubeTexture&&L.isRenderTargetTexture===!1&&(wf.y*=-1,wf.z*=-1),C.envMapRotation.value.setFromMatrix4(Dj.makeRotationFromEuler(wf)),C.flipEnvMap.value=L.isCubeTexture&&L.isRenderTargetTexture===!1?-1:1,C.reflectivity.value=E.reflectivity,C.ior.value=E.ior,C.refractionRatio.value=E.refractionRatio),E.lightMap&&(C.lightMap.value=E.lightMap,C.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,C.lightMapTransform)),E.aoMap&&(C.aoMap.value=E.aoMap,C.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,C.aoMapTransform))}function a(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform))}function l(C,E){C.dashSize.value=E.dashSize,C.totalSize.value=E.dashSize+E.gapSize,C.scale.value=E.scale}function u(C,E,B,L){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.size.value=E.size*B,C.scale.value=L*.5,E.map&&(C.map.value=E.map,t(E.map,C.uvTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function h(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.rotation.value=E.rotation,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function m(C,E){C.specular.value.copy(E.specular),C.shininess.value=Math.max(E.shininess,1e-4)}function v(C,E){E.gradientMap&&(C.gradientMap.value=E.gradientMap)}function x(C,E){C.metalness.value=E.metalness,E.metalnessMap&&(C.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,C.metalnessMapTransform)),C.roughness.value=E.roughness,E.roughnessMap&&(C.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,C.roughnessMapTransform)),E.envMap&&(C.envMapIntensity.value=E.envMapIntensity)}function S(C,E,B){C.ior.value=E.ior,E.sheen>0&&(C.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),C.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(C.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,C.sheenColorMapTransform)),E.sheenRoughnessMap&&(C.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,C.sheenRoughnessMapTransform))),E.clearcoat>0&&(C.clearcoat.value=E.clearcoat,C.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(C.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,C.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(C.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,C.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(C.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,C.clearcoatNormalMapTransform),C.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===hr&&C.clearcoatNormalScale.value.negate())),E.dispersion>0&&(C.dispersion.value=E.dispersion),E.iridescence>0&&(C.iridescence.value=E.iridescence,C.iridescenceIOR.value=E.iridescenceIOR,C.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],C.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(C.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,C.iridescenceMapTransform)),E.iridescenceThicknessMap&&(C.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,C.iridescenceThicknessMapTransform))),E.transmission>0&&(C.transmission.value=E.transmission,C.transmissionSamplerMap.value=B.texture,C.transmissionSamplerSize.value.set(B.width,B.height),E.transmissionMap&&(C.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,C.transmissionMapTransform)),C.thickness.value=E.thickness,E.thicknessMap&&(C.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,C.thicknessMapTransform)),C.attenuationDistance.value=E.attenuationDistance,C.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(C.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(C.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,C.anisotropyMapTransform))),C.specularIntensity.value=E.specularIntensity,C.specularColor.value.copy(E.specularColor),E.specularColorMap&&(C.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,C.specularColorMapTransform)),E.specularIntensityMap&&(C.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,C.specularIntensityMapTransform))}function w(C,E){E.matcap&&(C.matcap.value=E.matcap)}function R(C,E){const B=e.get(E).light;C.referencePosition.value.setFromMatrixPosition(B.matrixWorld),C.nearDistance.value=B.shadow.camera.near,C.farDistance.value=B.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Lj(i,e,t,n){let r={},s={},a=[];const l=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(B,L){const O=L.program;n.uniformBlockBinding(B,O)}function h(B,L){let O=r[B.id];O===void 0&&(w(B),O=m(B),r[B.id]=O,B.addEventListener("dispose",C));const G=L.program;n.updateUBOMapping(B,G);const q=e.render.frame;s[B.id]!==q&&(x(B),s[B.id]=q)}function m(B){const L=v();B.__bindingPointIndex=L;const O=i.createBuffer(),G=B.__size,q=B.usage;return i.bindBuffer(i.UNIFORM_BUFFER,O),i.bufferData(i.UNIFORM_BUFFER,G,q),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,L,O),O}function v(){for(let B=0;B0&&(O+=G-q),B.__size=O,B.__cache={},this}function R(B){const L={boundary:0,storage:0};return typeof B=="number"||typeof B=="boolean"?(L.boundary=4,L.storage=4):B.isVector2?(L.boundary=8,L.storage=8):B.isVector3||B.isColor?(L.boundary=16,L.storage=12):B.isVector4?(L.boundary=16,L.storage=16):B.isMatrix3?(L.boundary=48,L.storage=48):B.isMatrix4?(L.boundary=64,L.storage=64):B.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",B),L}function C(B){const L=B.target;L.removeEventListener("dispose",C);const O=a.indexOf(L.__bindingPointIndex);a.splice(O,1),i.deleteBuffer(r[L.id]),delete r[L.id],delete s[L.id]}function E(){for(const B in r)i.deleteBuffer(r[B]);a=[],r={},s={}}return{bind:u,update:h,dispose:E}}class Uj{constructor(e={}){const{canvas:t=F7(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:l=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:h=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:v=!1,reverseDepthBuffer:x=!1}=e;this.isWebGLRenderer=!0;let S;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");S=n.getContextAttributes().alpha}else S=a;const w=new Uint32Array(4),R=new Int32Array(4);let C=null,E=null;const B=[],L=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=_n,this.toneMapping=Za,this.toneMappingExposure=1;const O=this;let G=!1,q=0,z=0,j=null,F=-1,V=null;const Y=new Ln,ee=new Ln;let te=null;const re=new an(0);let ne=0,Q=t.width,ae=t.height,de=1,Te=null,be=null;const ue=new Ln(0,0,Q,ae),we=new Ln(0,0,Q,ae);let We=!1;const Ne=new Fg;let ze=!1,Se=!1;this.transmissionResolutionScale=1;const Ce=new kn,dt=new kn,At=new he,wt=new Ln,Ft={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let $e=!1;function rt(){return j===null?de:1}let ce=n;function Gt(oe,Fe){return t.getContext(oe,Fe)}try{const oe={alpha:!0,depth:r,stencil:s,antialias:l,premultipliedAlpha:u,preserveDrawingBuffer:h,powerPreference:m,failIfMajorPerformanceCaveat:v};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${V0}`),t.addEventListener("webglcontextlost",St,!1),t.addEventListener("webglcontextrestored",qt,!1),t.addEventListener("webglcontextcreationerror",Ht,!1),ce===null){const Fe="webgl2";if(ce=Gt(Fe,oe),ce===null)throw Gt(Fe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(oe){throw console.error("THREE.WebGLRenderer: "+oe.message),oe}let ht,Pt,yt,en,xt,fe,X,le,Re,pe,Me,nt,lt,Ot,jt,pt,Yt,rn,$t,kt,Vt,Nn,_i,me;function bt(){ht=new VV(ce),ht.init(),Nn=new wj(ce,ht),Pt=new IV(ce,ht,e,Nn),yt=new Sj(ce,ht),Pt.reverseDepthBuffer&&x&&yt.buffers.depth.setReversed(!0),en=new WV(ce),xt=new cj,fe=new Tj(ce,ht,yt,xt,Pt,Nn,en),X=new kV(O),le=new qV(O),Re=new Jz(ce),_i=new BV(ce,Re),pe=new HV(ce,Re,en,_i),Me=new XV(ce,pe,Re,en),$t=new $V(ce,Pt,fe),pt=new FV(xt),nt=new uj(O,X,le,ht,Pt,_i,pt),lt=new Pj(O,xt),Ot=new fj,jt=new vj(ht),rn=new UV(O,X,le,yt,Me,S,u),Yt=new xj(O,Me,Pt),me=new Lj(ce,en,Pt,yt),kt=new OV(ce,ht,en),Vt=new jV(ce,ht,en),en.programs=nt.programs,O.capabilities=Pt,O.extensions=ht,O.properties=xt,O.renderLists=Ot,O.shadowMap=Yt,O.state=yt,O.info=en}bt();const tt=new Nj(O,ce);this.xr=tt,this.getContext=function(){return ce},this.getContextAttributes=function(){return ce.getContextAttributes()},this.forceContextLoss=function(){const oe=ht.get("WEBGL_lose_context");oe&&oe.loseContext()},this.forceContextRestore=function(){const oe=ht.get("WEBGL_lose_context");oe&&oe.restoreContext()},this.getPixelRatio=function(){return de},this.setPixelRatio=function(oe){oe!==void 0&&(de=oe,this.setSize(Q,ae,!1))},this.getSize=function(oe){return oe.set(Q,ae)},this.setSize=function(oe,Fe,Qe=!0){if(tt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Q=oe,ae=Fe,t.width=Math.floor(oe*de),t.height=Math.floor(Fe*de),Qe===!0&&(t.style.width=oe+"px",t.style.height=Fe+"px"),this.setViewport(0,0,oe,Fe)},this.getDrawingBufferSize=function(oe){return oe.set(Q*de,ae*de).floor()},this.setDrawingBufferSize=function(oe,Fe,Qe){Q=oe,ae=Fe,de=Qe,t.width=Math.floor(oe*Qe),t.height=Math.floor(Fe*Qe),this.setViewport(0,0,oe,Fe)},this.getCurrentViewport=function(oe){return oe.copy(Y)},this.getViewport=function(oe){return oe.copy(ue)},this.setViewport=function(oe,Fe,Qe,Xe){oe.isVector4?ue.set(oe.x,oe.y,oe.z,oe.w):ue.set(oe,Fe,Qe,Xe),yt.viewport(Y.copy(ue).multiplyScalar(de).round())},this.getScissor=function(oe){return oe.copy(we)},this.setScissor=function(oe,Fe,Qe,Xe){oe.isVector4?we.set(oe.x,oe.y,oe.z,oe.w):we.set(oe,Fe,Qe,Xe),yt.scissor(ee.copy(we).multiplyScalar(de).round())},this.getScissorTest=function(){return We},this.setScissorTest=function(oe){yt.setScissorTest(We=oe)},this.setOpaqueSort=function(oe){Te=oe},this.setTransparentSort=function(oe){be=oe},this.getClearColor=function(oe){return oe.copy(rn.getClearColor())},this.setClearColor=function(){rn.setClearColor.apply(rn,arguments)},this.getClearAlpha=function(){return rn.getClearAlpha()},this.setClearAlpha=function(){rn.setClearAlpha.apply(rn,arguments)},this.clear=function(oe=!0,Fe=!0,Qe=!0){let Xe=0;if(oe){let ke=!1;if(j!==null){const It=j.texture.format;ke=It===W0||It===j0||It===H0}if(ke){const It=j.texture.type,Xt=It===aa||It===Rr||It===wl||It===Au||It===Ay||It===dy,mt=rn.getClearColor(),Z=rn.getClearAlpha(),Bt=mt.r,bn=mt.g,fn=mt.b;Xt?(w[0]=Bt,w[1]=bn,w[2]=fn,w[3]=Z,ce.clearBufferuiv(ce.COLOR,0,w)):(R[0]=Bt,R[1]=bn,R[2]=fn,R[3]=Z,ce.clearBufferiv(ce.COLOR,0,R))}else Xe|=ce.COLOR_BUFFER_BIT}Fe&&(Xe|=ce.DEPTH_BUFFER_BIT),Qe&&(Xe|=ce.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ce.clear(Xe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",St,!1),t.removeEventListener("webglcontextrestored",qt,!1),t.removeEventListener("webglcontextcreationerror",Ht,!1),rn.dispose(),Ot.dispose(),jt.dispose(),xt.dispose(),X.dispose(),le.dispose(),Me.dispose(),_i.dispose(),me.dispose(),nt.dispose(),tt.dispose(),tt.removeEventListener("sessionstart",Ze),tt.removeEventListener("sessionend",vt),zt.stop()};function St(oe){oe.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),G=!0}function qt(){console.log("THREE.WebGLRenderer: Context Restored."),G=!1;const oe=en.autoReset,Fe=Yt.enabled,Qe=Yt.autoUpdate,Xe=Yt.needsUpdate,ke=Yt.type;bt(),en.autoReset=oe,Yt.enabled=Fe,Yt.autoUpdate=Qe,Yt.needsUpdate=Xe,Yt.type=ke}function Ht(oe){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",oe.statusMessage)}function xn(oe){const Fe=oe.target;Fe.removeEventListener("dispose",xn),qi(Fe)}function qi(oe){rr(oe),xt.remove(oe)}function rr(oe){const Fe=xt.get(oe).programs;Fe!==void 0&&(Fe.forEach(function(Qe){nt.releaseProgram(Qe)}),oe.isShaderMaterial&&nt.releaseShaderCache(oe))}this.renderBufferDirect=function(oe,Fe,Qe,Xe,ke,It){Fe===null&&(Fe=Ft);const Xt=ke.isMesh&&ke.matrixWorld.determinant()<0,mt=Hs(oe,Fe,Qe,Xe,ke);yt.setMaterial(Xe,Xt);let Z=Qe.index,Bt=1;if(Xe.wireframe===!0){if(Z=pe.getWireframeAttribute(Qe),Z===void 0)return;Bt=2}const bn=Qe.drawRange,fn=Qe.attributes.position;let ui=bn.start*Bt,ci=(bn.start+bn.count)*Bt;It!==null&&(ui=Math.max(ui,It.start*Bt),ci=Math.min(ci,(It.start+It.count)*Bt)),Z!==null?(ui=Math.max(ui,0),ci=Math.min(ci,Z.count)):fn!=null&&(ui=Math.max(ui,0),ci=Math.min(ci,fn.count));const yi=ci-ui;if(yi<0||yi===1/0)return;_i.setup(ke,Xe,mt,Qe,Z);let K,Un=kt;if(Z!==null&&(K=Re.get(Z),Un=Vt,Un.setIndex(K)),ke.isMesh)Xe.wireframe===!0?(yt.setLineWidth(Xe.wireframeLinewidth*rt()),Un.setMode(ce.LINES)):Un.setMode(ce.TRIANGLES);else if(ke.isLine){let mn=Xe.linewidth;mn===void 0&&(mn=1),yt.setLineWidth(mn*rt()),ke.isLineSegments?Un.setMode(ce.LINES):ke.isLineLoop?Un.setMode(ce.LINE_LOOP):Un.setMode(ce.LINE_STRIP)}else ke.isPoints?Un.setMode(ce.POINTS):ke.isSprite&&Un.setMode(ce.TRIANGLES);if(ke.isBatchedMesh)if(ke._multiDrawInstances!==null)Un.renderMultiDrawInstances(ke._multiDrawStarts,ke._multiDrawCounts,ke._multiDrawCount,ke._multiDrawInstances);else if(ht.get("WEBGL_multi_draw"))Un.renderMultiDraw(ke._multiDrawStarts,ke._multiDrawCounts,ke._multiDrawCount);else{const mn=ke._multiDrawStarts,yr=ke._multiDrawCounts,hi=ke._multiDrawCount,bs=Z?Re.get(Z).bytesPerElement:1,fa=xt.get(Xe).currentProgram.getUniforms();for(let ye=0;ye{function It(){if(Xe.forEach(function(Xt){xt.get(Xt).currentProgram.isReady()&&Xe.delete(Xt)}),Xe.size===0){ke(oe);return}setTimeout(It,10)}ht.get("KHR_parallel_shader_compile")!==null?It():setTimeout(It,10)})};let $i=null;function Jr(oe){$i&&$i(oe)}function Ze(){zt.stop()}function vt(){zt.start()}const zt=new lD;zt.setAnimationLoop(Jr),typeof self<"u"&&zt.setContext(self),this.setAnimationLoop=function(oe){$i=oe,tt.setAnimationLoop(oe),oe===null?zt.stop():zt.start()},tt.addEventListener("sessionstart",Ze),tt.addEventListener("sessionend",vt),this.render=function(oe,Fe){if(Fe!==void 0&&Fe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;if(oe.matrixWorldAutoUpdate===!0&&oe.updateMatrixWorld(),Fe.parent===null&&Fe.matrixWorldAutoUpdate===!0&&Fe.updateMatrixWorld(),tt.enabled===!0&&tt.isPresenting===!0&&(tt.cameraAutoUpdate===!0&&tt.updateCamera(Fe),Fe=tt.getCamera()),oe.isScene===!0&&oe.onBeforeRender(O,oe,Fe,j),E=jt.get(oe,L.length),E.init(Fe),L.push(E),dt.multiplyMatrices(Fe.projectionMatrix,Fe.matrixWorldInverse),Ne.setFromProjectionMatrix(dt),Se=this.localClippingEnabled,ze=pt.init(this.clippingPlanes,Se),C=Ot.get(oe,B.length),C.init(),B.push(C),tt.enabled===!0&&tt.isPresenting===!0){const It=O.xr.getDepthSensingMesh();It!==null&&at(It,Fe,-1/0,O.sortObjects)}at(oe,Fe,0,O.sortObjects),C.finish(),O.sortObjects===!0&&C.sort(Te,be),$e=tt.enabled===!1||tt.isPresenting===!1||tt.hasDepthSensing()===!1,$e&&rn.addToRenderList(C,oe),this.info.render.frame++,ze===!0&&pt.beginShadows();const Qe=E.state.shadowsArray;Yt.render(Qe,oe,Fe),ze===!0&&pt.endShadows(),this.info.autoReset===!0&&this.info.reset();const Xe=C.opaque,ke=C.transmissive;if(E.setupLights(),Fe.isArrayCamera){const It=Fe.cameras;if(ke.length>0)for(let Xt=0,mt=It.length;Xt0&&J(Xe,ke,oe,Fe),$e&&rn.render(oe),d(C,oe,Fe);j!==null&&z===0&&(fe.updateMultisampleRenderTarget(j),fe.updateRenderTargetMipmap(j)),oe.isScene===!0&&oe.onAfterRender(O,oe,Fe),_i.resetDefaultState(),F=-1,V=null,L.pop(),L.length>0?(E=L[L.length-1],ze===!0&&pt.setGlobalState(O.clippingPlanes,E.state.camera)):E=null,B.pop(),B.length>0?C=B[B.length-1]:C=null};function at(oe,Fe,Qe,Xe){if(oe.visible===!1)return;if(oe.layers.test(Fe.layers)){if(oe.isGroup)Qe=oe.renderOrder;else if(oe.isLOD)oe.autoUpdate===!0&&oe.update(Fe);else if(oe.isLight)E.pushLight(oe),oe.castShadow&&E.pushShadow(oe);else if(oe.isSprite){if(!oe.frustumCulled||Ne.intersectsSprite(oe)){Xe&&wt.setFromMatrixPosition(oe.matrixWorld).applyMatrix4(dt);const Xt=Me.update(oe),mt=oe.material;mt.visible&&C.push(oe,Xt,mt,Qe,wt.z,null)}}else if((oe.isMesh||oe.isLine||oe.isPoints)&&(!oe.frustumCulled||Ne.intersectsObject(oe))){const Xt=Me.update(oe),mt=oe.material;if(Xe&&(oe.boundingSphere!==void 0?(oe.boundingSphere===null&&oe.computeBoundingSphere(),wt.copy(oe.boundingSphere.center)):(Xt.boundingSphere===null&&Xt.computeBoundingSphere(),wt.copy(Xt.boundingSphere.center)),wt.applyMatrix4(oe.matrixWorld).applyMatrix4(dt)),Array.isArray(mt)){const Z=Xt.groups;for(let Bt=0,bn=Z.length;Bt0&&$n(ke,Fe,Qe),It.length>0&&$n(It,Fe,Qe),Xt.length>0&&$n(Xt,Fe,Qe),yt.buffers.depth.setTest(!0),yt.buffers.depth.setMask(!0),yt.buffers.color.setMask(!0),yt.setPolygonOffset(!1)}function J(oe,Fe,Qe,Xe){if((Qe.isScene===!0?Qe.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[Xe.id]===void 0&&(E.state.transmissionRenderTarget[Xe.id]=new qh(1,1,{generateMipmaps:!0,type:ht.has("EXT_color_buffer_half_float")||ht.has("EXT_color_buffer_float")?Gs:aa,minFilter:Va,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ai.workingColorSpace}));const It=E.state.transmissionRenderTarget[Xe.id],Xt=Xe.viewport||Y;It.setSize(Xt.z*O.transmissionResolutionScale,Xt.w*O.transmissionResolutionScale);const mt=O.getRenderTarget();O.setRenderTarget(It),O.getClearColor(re),ne=O.getClearAlpha(),ne<1&&O.setClearColor(16777215,.5),O.clear(),$e&&rn.render(Qe);const Z=O.toneMapping;O.toneMapping=Za;const Bt=Xe.viewport;if(Xe.viewport!==void 0&&(Xe.viewport=void 0),E.setupLightsView(Xe),ze===!0&&pt.setGlobalState(O.clippingPlanes,Xe),$n(oe,Qe,Xe),fe.updateMultisampleRenderTarget(It),fe.updateRenderTargetMipmap(It),ht.has("WEBGL_multisampled_render_to_texture")===!1){let bn=!1;for(let fn=0,ui=Fe.length;fn0),fn=!!Qe.morphAttributes.position,ui=!!Qe.morphAttributes.normal,ci=!!Qe.morphAttributes.color;let yi=Za;Xe.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(yi=O.toneMapping);const K=Qe.morphAttributes.position||Qe.morphAttributes.normal||Qe.morphAttributes.color,Un=K!==void 0?K.length:0,mn=xt.get(Xe),yr=E.state.lights;if(ze===!0&&(Se===!0||oe!==V)){const Yn=oe===V&&Xe.id===F;pt.setState(Xe,oe,Yn)}let hi=!1;Xe.version===mn.__version?(mn.needsLights&&mn.lightsStateVersion!==yr.state.version||mn.outputColorSpace!==mt||ke.isBatchedMesh&&mn.batching===!1||!ke.isBatchedMesh&&mn.batching===!0||ke.isBatchedMesh&&mn.batchingColor===!0&&ke.colorTexture===null||ke.isBatchedMesh&&mn.batchingColor===!1&&ke.colorTexture!==null||ke.isInstancedMesh&&mn.instancing===!1||!ke.isInstancedMesh&&mn.instancing===!0||ke.isSkinnedMesh&&mn.skinning===!1||!ke.isSkinnedMesh&&mn.skinning===!0||ke.isInstancedMesh&&mn.instancingColor===!0&&ke.instanceColor===null||ke.isInstancedMesh&&mn.instancingColor===!1&&ke.instanceColor!==null||ke.isInstancedMesh&&mn.instancingMorph===!0&&ke.morphTexture===null||ke.isInstancedMesh&&mn.instancingMorph===!1&&ke.morphTexture!==null||mn.envMap!==Z||Xe.fog===!0&&mn.fog!==It||mn.numClippingPlanes!==void 0&&(mn.numClippingPlanes!==pt.numPlanes||mn.numIntersection!==pt.numIntersection)||mn.vertexAlphas!==Bt||mn.vertexTangents!==bn||mn.morphTargets!==fn||mn.morphNormals!==ui||mn.morphColors!==ci||mn.toneMapping!==yi||mn.morphTargetsCount!==Un)&&(hi=!0):(hi=!0,mn.__version=Xe.version);let bs=mn.currentProgram;hi===!0&&(bs=Xn(Xe,Fe,ke));let fa=!1,ye=!1,ot=!1;const Nt=bs.getUniforms(),Jt=mn.uniforms;if(yt.useProgram(bs.program)&&(fa=!0,ye=!0,ot=!0),Xe.id!==F&&(F=Xe.id,ye=!0),fa||V!==oe){yt.buffers.depth.getReversed()?(Ce.copy(oe.projectionMatrix),wk(Ce),Mk(Ce),Nt.setValue(ce,"projectionMatrix",Ce)):Nt.setValue(ce,"projectionMatrix",oe.projectionMatrix),Nt.setValue(ce,"viewMatrix",oe.matrixWorldInverse);const xi=Nt.map.cameraPosition;xi!==void 0&&xi.setValue(ce,At.setFromMatrixPosition(oe.matrixWorld)),Pt.logarithmicDepthBuffer&&Nt.setValue(ce,"logDepthBufFC",2/(Math.log(oe.far+1)/Math.LN2)),(Xe.isMeshPhongMaterial||Xe.isMeshToonMaterial||Xe.isMeshLambertMaterial||Xe.isMeshBasicMaterial||Xe.isMeshStandardMaterial||Xe.isShaderMaterial)&&Nt.setValue(ce,"isOrthographic",oe.isOrthographicCamera===!0),V!==oe&&(V=oe,ye=!0,ot=!0)}if(ke.isSkinnedMesh){Nt.setOptional(ce,ke,"bindMatrix"),Nt.setOptional(ce,ke,"bindMatrixInverse");const Yn=ke.skeleton;Yn&&(Yn.boneTexture===null&&Yn.computeBoneTexture(),Nt.setValue(ce,"boneTexture",Yn.boneTexture,fe))}ke.isBatchedMesh&&(Nt.setOptional(ce,ke,"batchingTexture"),Nt.setValue(ce,"batchingTexture",ke._matricesTexture,fe),Nt.setOptional(ce,ke,"batchingIdTexture"),Nt.setValue(ce,"batchingIdTexture",ke._indirectTexture,fe),Nt.setOptional(ce,ke,"batchingColorTexture"),ke._colorsTexture!==null&&Nt.setValue(ce,"batchingColorTexture",ke._colorsTexture,fe));const cn=Qe.morphAttributes;if((cn.position!==void 0||cn.normal!==void 0||cn.color!==void 0)&&$t.update(ke,Qe,bs),(ye||mn.receiveShadow!==ke.receiveShadow)&&(mn.receiveShadow=ke.receiveShadow,Nt.setValue(ce,"receiveShadow",ke.receiveShadow)),Xe.isMeshGouraudMaterial&&Xe.envMap!==null&&(Jt.envMap.value=Z,Jt.flipEnvMap.value=Z.isCubeTexture&&Z.isRenderTargetTexture===!1?-1:1),Xe.isMeshStandardMaterial&&Xe.envMap===null&&Fe.environment!==null&&(Jt.envMapIntensity.value=Fe.environmentIntensity),ye&&(Nt.setValue(ce,"toneMappingExposure",O.toneMappingExposure),mn.needsLights&&li(Jt,ot),It&&Xe.fog===!0&<.refreshFogUniforms(Jt,It),lt.refreshMaterialUniforms(Jt,Xe,de,ae,E.state.transmissionRenderTarget[oe.id]),qv.upload(ce,un(mn),Jt,fe)),Xe.isShaderMaterial&&Xe.uniformsNeedUpdate===!0&&(qv.upload(ce,un(mn),Jt,fe),Xe.uniformsNeedUpdate=!1),Xe.isSpriteMaterial&&Nt.setValue(ce,"center",ke.center),Nt.setValue(ce,"modelViewMatrix",ke.modelViewMatrix),Nt.setValue(ce,"normalMatrix",ke.normalMatrix),Nt.setValue(ce,"modelMatrix",ke.matrixWorld),Xe.isShaderMaterial||Xe.isRawShaderMaterial){const Yn=Xe.uniformsGroups;for(let xi=0,js=Yn.length;xi0&&fe.useMultisampledRTT(oe)===!1?ke=xt.get(oe).__webglMultisampledFramebuffer:Array.isArray(bn)?ke=bn[Qe]:ke=bn,Y.copy(oe.viewport),ee.copy(oe.scissor),te=oe.scissorTest}else Y.copy(ue).multiplyScalar(de).floor(),ee.copy(we).multiplyScalar(de).floor(),te=We;if(Qe!==0&&(ke=cs),yt.bindFramebuffer(ce.FRAMEBUFFER,ke)&&Xe&&yt.drawBuffers(oe,ke),yt.viewport(Y),yt.scissor(ee),yt.setScissorTest(te),It){const Z=xt.get(oe.texture);ce.framebufferTexture2D(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,ce.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,Z.__webglTexture,Qe)}else if(Xt){const Z=xt.get(oe.texture),Bt=Fe;ce.framebufferTextureLayer(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,Z.__webglTexture,Qe,Bt)}else if(oe!==null&&Qe!==0){const Z=xt.get(oe.texture);ce.framebufferTexture2D(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,ce.TEXTURE_2D,Z.__webglTexture,Qe)}F=-1},this.readRenderTargetPixels=function(oe,Fe,Qe,Xe,ke,It,Xt){if(!(oe&&oe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let mt=xt.get(oe).__webglFramebuffer;if(oe.isWebGLCubeRenderTarget&&Xt!==void 0&&(mt=mt[Xt]),mt){yt.bindFramebuffer(ce.FRAMEBUFFER,mt);try{const Z=oe.texture,Bt=Z.format,bn=Z.type;if(!Pt.textureFormatReadable(Bt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Pt.textureTypeReadable(bn)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Fe>=0&&Fe<=oe.width-Xe&&Qe>=0&&Qe<=oe.height-ke&&ce.readPixels(Fe,Qe,Xe,ke,Nn.convert(Bt),Nn.convert(bn),It)}finally{const Z=j!==null?xt.get(j).__webglFramebuffer:null;yt.bindFramebuffer(ce.FRAMEBUFFER,Z)}}},this.readRenderTargetPixelsAsync=async function(oe,Fe,Qe,Xe,ke,It,Xt){if(!(oe&&oe.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let mt=xt.get(oe).__webglFramebuffer;if(oe.isWebGLCubeRenderTarget&&Xt!==void 0&&(mt=mt[Xt]),mt){const Z=oe.texture,Bt=Z.format,bn=Z.type;if(!Pt.textureFormatReadable(Bt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Pt.textureTypeReadable(bn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(Fe>=0&&Fe<=oe.width-Xe&&Qe>=0&&Qe<=oe.height-ke){yt.bindFramebuffer(ce.FRAMEBUFFER,mt);const fn=ce.createBuffer();ce.bindBuffer(ce.PIXEL_PACK_BUFFER,fn),ce.bufferData(ce.PIXEL_PACK_BUFFER,It.byteLength,ce.STREAM_READ),ce.readPixels(Fe,Qe,Xe,ke,Nn.convert(Bt),Nn.convert(bn),0);const ui=j!==null?xt.get(j).__webglFramebuffer:null;yt.bindFramebuffer(ce.FRAMEBUFFER,ui);const ci=ce.fenceSync(ce.SYNC_GPU_COMMANDS_COMPLETE,0);return ce.flush(),await Tk(ce,ci,4),ce.bindBuffer(ce.PIXEL_PACK_BUFFER,fn),ce.getBufferSubData(ce.PIXEL_PACK_BUFFER,0,It),ce.deleteBuffer(fn),ce.deleteSync(ci),It}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(oe,Fe=null,Qe=0){oe.isTexture!==!0&&(kf("WebGLRenderer: copyFramebufferToTexture function signature has changed."),Fe=arguments[0]||null,oe=arguments[1]);const Xe=Math.pow(2,-Qe),ke=Math.floor(oe.image.width*Xe),It=Math.floor(oe.image.height*Xe),Xt=Fe!==null?Fe.x:0,mt=Fe!==null?Fe.y:0;fe.setTexture2D(oe,0),ce.copyTexSubImage2D(ce.TEXTURE_2D,Qe,0,0,Xt,mt,ke,It),yt.unbindTexture()};const Ma=ce.createFramebuffer(),Ul=ce.createFramebuffer();this.copyTextureToTexture=function(oe,Fe,Qe=null,Xe=null,ke=0,It=null){oe.isTexture!==!0&&(kf("WebGLRenderer: copyTextureToTexture function signature has changed."),Xe=arguments[0]||null,oe=arguments[1],Fe=arguments[2],It=arguments[3]||0,Qe=null),It===null&&(ke!==0?(kf("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),It=ke,ke=0):It=0);let Xt,mt,Z,Bt,bn,fn,ui,ci,yi;const K=oe.isCompressedTexture?oe.mipmaps[It]:oe.image;if(Qe!==null)Xt=Qe.max.x-Qe.min.x,mt=Qe.max.y-Qe.min.y,Z=Qe.isBox3?Qe.max.z-Qe.min.z:1,Bt=Qe.min.x,bn=Qe.min.y,fn=Qe.isBox3?Qe.min.z:0;else{const cn=Math.pow(2,-ke);Xt=Math.floor(K.width*cn),mt=Math.floor(K.height*cn),oe.isDataArrayTexture?Z=K.depth:oe.isData3DTexture?Z=Math.floor(K.depth*cn):Z=1,Bt=0,bn=0,fn=0}Xe!==null?(ui=Xe.x,ci=Xe.y,yi=Xe.z):(ui=0,ci=0,yi=0);const Un=Nn.convert(Fe.format),mn=Nn.convert(Fe.type);let yr;Fe.isData3DTexture?(fe.setTexture3D(Fe,0),yr=ce.TEXTURE_3D):Fe.isDataArrayTexture||Fe.isCompressedArrayTexture?(fe.setTexture2DArray(Fe,0),yr=ce.TEXTURE_2D_ARRAY):(fe.setTexture2D(Fe,0),yr=ce.TEXTURE_2D),ce.pixelStorei(ce.UNPACK_FLIP_Y_WEBGL,Fe.flipY),ce.pixelStorei(ce.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Fe.premultiplyAlpha),ce.pixelStorei(ce.UNPACK_ALIGNMENT,Fe.unpackAlignment);const hi=ce.getParameter(ce.UNPACK_ROW_LENGTH),bs=ce.getParameter(ce.UNPACK_IMAGE_HEIGHT),fa=ce.getParameter(ce.UNPACK_SKIP_PIXELS),ye=ce.getParameter(ce.UNPACK_SKIP_ROWS),ot=ce.getParameter(ce.UNPACK_SKIP_IMAGES);ce.pixelStorei(ce.UNPACK_ROW_LENGTH,K.width),ce.pixelStorei(ce.UNPACK_IMAGE_HEIGHT,K.height),ce.pixelStorei(ce.UNPACK_SKIP_PIXELS,Bt),ce.pixelStorei(ce.UNPACK_SKIP_ROWS,bn),ce.pixelStorei(ce.UNPACK_SKIP_IMAGES,fn);const Nt=oe.isDataArrayTexture||oe.isData3DTexture,Jt=Fe.isDataArrayTexture||Fe.isData3DTexture;if(oe.isDepthTexture){const cn=xt.get(oe),Yn=xt.get(Fe),xi=xt.get(cn.__renderTarget),js=xt.get(Yn.__renderTarget);yt.bindFramebuffer(ce.READ_FRAMEBUFFER,xi.__webglFramebuffer),yt.bindFramebuffer(ce.DRAW_FRAMEBUFFER,js.__webglFramebuffer);for(let pi=0;pi=-1&&_d.z<=1&&w.layers.test(C.layers)===!0,B=w.element;B.style.display=E===!0?"":"none",E===!0&&(w.onBeforeRender(t,R,C),B.style.transform="translate("+-100*w.center.x+"%,"+-100*w.center.y+"%)translate("+(_d.x*s+s)+"px,"+(-_d.y*a+a)+"px)",B.parentNode!==u&&u.appendChild(B),w.onAfterRender(t,R,C));const L={distanceToCameraSquared:v(C,w)};l.objects.set(w,L)}for(let E=0,B=w.children.length;E=e||z<0||v&&j>=s}function E(){var q=P3();if(C(q))return B(q);l=setTimeout(E,R(q))}function B(q){return l=void 0,x&&n?S(q):(n=r=void 0,a)}function L(){l!==void 0&&clearTimeout(l),h=0,n=u=r=l=void 0}function O(){return l===void 0?a:B(P3())}function G(){var q=P3(),z=C(q);if(n=arguments,r=this,u=q,z){if(l===void 0)return w(u);if(v)return clearTimeout(l),l=setTimeout(E,e),S(u)}return l===void 0&&(l=setTimeout(E,e)),a}return G.cancel=L,G.flush=O,G}function uR(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),ym=function(){return performance.now()},My=(function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=ym()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(i[t],i[t-1],t-n):s(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},pD=(function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i})(),tT=new My,ca=(function(){function i(e,t){t===void 0&&(t=tT),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=os.Linear.None,this._interpolationFunction=eT.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=pD.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=ym()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,s){for(var a in n){var l=e[a],u=Array.isArray(l),h=u?"array":typeof l,m=!u&&Array.isArray(n[a]);if(!(h==="undefined"||h==="function")){if(m){var v=n[a];if(v.length===0)continue;for(var x=[l],S=0,w=v.length;S"u"||s)&&(t[a]=l),u||(t[a]*=1),m?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=ym()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=ym()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;ea)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,eh)return 1;var C=Math.trunc(l/u),E=l-C*u,B=Math.min(E/n._duration,1);return B===0&&l===n._duration?1:B},v=m(),x=this._easingFunction(v);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,x),this._onUpdateCallback&&this._onUpdateCallback(this._object,v),this._duration===0||l>=this._duration)if(this._repeat>0){var S=Math.min(Math.trunc((l-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=S);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*S,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var w=0,R=this._chainedTweens.length;w=(w=(u+v)/2))?u=w:v=w,(G=t>=(R=(h+x)/2))?h=R:x=R,(q=n>=(C=(m+S)/2))?m=C:S=C,s=a,!(a=a[z=q<<2|G<<1|O]))return s[z]=l,i;if(E=+i._x.call(null,a.data),B=+i._y.call(null,a.data),L=+i._z.call(null,a.data),e===E&&t===B&&n===L)return l.next=a,s?s[z]=l:i._root=l,i;do s=s?s[z]=new Array(8):i._root=new Array(8),(O=e>=(w=(u+v)/2))?u=w:v=w,(G=t>=(R=(h+x)/2))?h=R:x=R,(q=n>=(C=(m+S)/2))?m=C:S=C;while((z=q<<2|G<<1|O)===(j=(L>=C)<<2|(B>=R)<<1|E>=w));return s[j]=a,s[z]=l,i}function vW(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),n=new Float64Array(e),r=new Float64Array(e);let s=1/0,a=1/0,l=1/0,u=-1/0,h=-1/0,m=-1/0;for(let v=0,x,S,w,R;vu&&(u=S),wh&&(h=w),Rm&&(m=R));if(s>u||a>h||l>m)return this;this.cover(s,a,l).cover(u,h,m);for(let v=0;vi||i>=a||r>e||e>=l||s>t||t>=u;)switch(x=(tw||(h=L.y0)>R||(m=L.z0)>C||(v=L.x1)=z)<<2|(e>=q)<<1|i>=G)&&(L=E[E.length-1],E[E.length-1]=E[E.length-1-O],E[E.length-1-O]=L)}else{var j=i-+this._x.call(null,B.data),F=e-+this._y.call(null,B.data),V=t-+this._z.call(null,B.data),Y=j*j+F*F+V*V;if(YMath.sqrt((i-n)**2+(e-r)**2+(t-s)**2);function TW(i,e,t,n){const r=[],s=i-n,a=e-n,l=t-n,u=i+n,h=e+n,m=t+n;return this.visit((v,x,S,w,R,C,E)=>{if(!v.length)do{const B=v.data;SW(i,e,t,this._x(B),this._y(B),this._z(B))<=n&&r.push(B)}while(v=v.next);return x>u||S>h||w>m||R=(R=(a+h)/2))?a=R:h=R,(L=S>=(C=(l+m)/2))?l=C:m=C,(O=w>=(E=(u+v)/2))?u=E:v=E,e=t,!(t=t[G=O<<2|L<<1|B]))return this;if(!t.length)break;(e[G+1&7]||e[G+2&7]||e[G+3&7]||e[G+4&7]||e[G+5&7]||e[G+6&7]||e[G+7&7])&&(n=e,q=G)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[G]=s:delete e[G],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[q]=t:this._root=t),this):(this._root=s,this)}function MW(i){for(var e=0,t=i.length;ee?1:i>=e?0:NaN}function IW(i,e){return i==null||e==null?NaN:ei?1:e>=i?0:NaN}function vD(i){let e,t,n;i.length!==2?(e=Vv,t=(l,u)=>Vv(i(l),u),n=(l,u)=>i(l)-u):(e=i===Vv||i===IW?i:FW,t=i,n=i);function r(l,u,h=0,m=l.length){if(h>>1;t(l[v],u)<0?h=v+1:m=v}while(h>>1;t(l[v],u)<=0?h=v+1:m=v}while(hh&&n(l[v-1],u)>-n(l[v],u)?v-1:v}return{left:r,center:a,right:s}}function FW(){return 0}function kW(i){return i===null?NaN:+i}const zW=vD(Vv),_D=zW.right;vD(kW).center;function A_(i,e){let t,n;if(e===void 0)for(const r of i)r!=null&&(t===void 0?r>=r&&(t=n=r):(t>r&&(t=r),n=s&&(t=n=s):(t>s&&(t=s),n0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,s=r-(a-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(r=s*2,n=a+r,r==n-a&&(a=n))}return a}}const GW=Math.sqrt(50),qW=Math.sqrt(10),VW=Math.sqrt(2);function d_(i,e,t){const n=(e-i)/Math.max(0,t),r=Math.floor(Math.log10(n)),s=n/Math.pow(10,r),a=s>=GW?10:s>=qW?5:s>=VW?2:1;let l,u,h;return r<0?(h=Math.pow(10,-r)/a,l=Math.round(i*h),u=Math.round(e*h),l/he&&--u,h=-h):(h=Math.pow(10,r)*a,l=Math.round(i/h),u=Math.round(e/h),l*he&&--u),u0))return[];if(i===e)return[i];const n=e=r))return[];const l=s-r+1,u=new Array(l);if(n)if(a<0)for(let h=0;h=n)&&(t=n);return t}function $W(i,e){let t=0,n=0;if(e===void 0)for(let r of i)r!=null&&(r=+r)>=r&&(++t,n+=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*XW(i){for(const e of i)yield*e}function ug(i){return Array.from(XW(i))}function jd(i,e,t){i=+i,e=+e,t=(r=arguments.length)<2?(e=i,i=0,1):r<3?1:+t;for(var n=-1,r=Math.max(0,Math.ceil((e-i)/t))|0,s=new Array(r);++n>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?X2(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?X2(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=KW.exec(i))?new Wa(e[1],e[2],e[3],1):(e=ZW.exec(i))?new Wa(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=JW.exec(i))?X2(e[1],e[2],e[3],e[4]):(e=e$.exec(i))?X2(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=t$.exec(i))?gR(e[1],e[2]/100,e[3]/100,1):(e=n$.exec(i))?gR(e[1],e[2]/100,e[3]/100,e[4]):hR.hasOwnProperty(i)?dR(hR[i]):i==="transparent"?new Wa(NaN,NaN,NaN,0):null}function dR(i){return new Wa(i>>16&255,i>>8&255,i&255,1)}function X2(i,e,t,n){return n<=0&&(i=e=t=NaN),new Wa(i,e,t,n)}function s$(i){return i instanceof zg||(i=cA(i)),i?(i=i.rgb(),new Wa(i.r,i.g,i.b,i.opacity)):new Wa}function iT(i,e,t,n){return arguments.length===1?s$(i):new Wa(i,e,t,n??1)}function Wa(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}uM(Wa,iT,xD(zg,{brighter(i){return i=i==null?p_:Math.pow(p_,i),new Wa(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?cg:Math.pow(cg,i),new Wa(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new Wa(eA(this.r),eA(this.g),eA(this.b),m_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:pR,formatHex:pR,formatHex8:a$,formatRgb:mR,toString:mR}));function pR(){return`#${Wf(this.r)}${Wf(this.g)}${Wf(this.b)}`}function a$(){return`#${Wf(this.r)}${Wf(this.g)}${Wf(this.b)}${Wf((isNaN(this.opacity)?1:this.opacity)*255)}`}function mR(){const i=m_(this.opacity);return`${i===1?"rgb(":"rgba("}${eA(this.r)}, ${eA(this.g)}, ${eA(this.b)}${i===1?")":`, ${i})`}`}function m_(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function eA(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function Wf(i){return i=eA(i),(i<16?"0":"")+i.toString(16)}function gR(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new Tl(i,e,t,n)}function bD(i){if(i instanceof Tl)return new Tl(i.h,i.s,i.l,i.opacity);if(i instanceof zg||(i=cA(i)),!i)return new Tl;if(i instanceof Tl)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,r=Math.min(e,t,n),s=Math.max(e,t,n),a=NaN,l=s-r,u=(s+r)/2;return l?(e===s?a=(t-n)/l+(t0&&u<1?0:a,new Tl(a,l,u,i.opacity)}function o$(i,e,t,n){return arguments.length===1?bD(i):new Tl(i,e,t,n??1)}function Tl(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}uM(Tl,o$,xD(zg,{brighter(i){return i=i==null?p_:Math.pow(p_,i),new Tl(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?cg:Math.pow(cg,i),new Tl(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,r=2*t-n;return new Wa(L3(i>=240?i-240:i+120,r,n),L3(i,r,n),L3(i<120?i+240:i-120,r,n),this.opacity)},clamp(){return new Tl(vR(this.h),Y2(this.s),Y2(this.l),m_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=m_(this.opacity);return`${i===1?"hsl(":"hsla("}${vR(this.h)}, ${Y2(this.s)*100}%, ${Y2(this.l)*100}%${i===1?")":`, ${i})`}`}}));function vR(i){return i=(i||0)%360,i<0?i+360:i}function Y2(i){return Math.max(0,Math.min(1,i||0))}function L3(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const cM=i=>()=>i;function l$(i,e){return function(t){return i+t*e}}function u$(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function c$(i){return(i=+i)==1?SD:function(e,t){return t-e?u$(e,t,i):cM(isNaN(e)?t:e)}}function SD(i,e){var t=e-i;return t?l$(i,t):cM(isNaN(i)?e:i)}const _R=(function i(e){var t=c$(e);function n(r,s){var a=t((r=iT(r)).r,(s=iT(s)).r),l=t(r.g,s.g),u=t(r.b,s.b),h=SD(r.opacity,s.opacity);return function(m){return r.r=a(m),r.g=l(m),r.b=u(m),r.opacity=h(m),r+""}}return n.gamma=i,n})(1);function TD(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),r;return function(s){for(r=0;rt&&(s=e.slice(t,s),l[a]?l[a]+=s:l[++a]=s),(n=n[0])===(r=r[0])?l[a]?l[a]+=r:l[++a]=r:(l[++a]=null,u.push({i:a,x:fg(n,r)})),t=U3.lastIndex;return te&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function x$(i,e,t){var n=i[0],r=i[1],s=e[0],a=e[1];return r2?b$:x$,u=h=null,v}function v(x){return x==null||isNaN(x=+x)?s:(u||(u=l(i.map(n),e,t)))(n(a(x)))}return v.invert=function(x){return a(r((h||(h=l(e,i.map(n),fg)))(x)))},v.domain=function(x){return arguments.length?(i=Array.from(x,_$),m()):i.slice()},v.range=function(x){return arguments.length?(e=Array.from(x),m()):e.slice()},v.rangeRound=function(x){return e=Array.from(x),t=g$,m()},v.clamp=function(x){return arguments.length?(a=x?!0:Wd,m()):a!==Wd},v.interpolate=function(x){return arguments.length?(t=x,m()):t},v.unknown=function(x){return arguments.length?(s=x,v):s},function(x,S){return n=x,r=S,m()}}function w$(){return T$()(Wd,Wd)}function M$(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function g_(i,e){if(!isFinite(i)||i===0)return null;var t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"),n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function C0(i){return i=g_(Math.abs(i)),i?i[1]:NaN}function E$(i,e){return function(t,n){for(var r=t.length,s=[],a=0,l=i[0],u=0;r>0&&l>0&&(u+l+1>n&&(l=Math.max(1,n-u)),s.push(t.substring(r-=l,r+l)),!((u+=l+1)>n));)l=i[a=(a+1)%i.length];return s.reverse().join(e)}}function C$(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var R$=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function v_(i){if(!(e=R$.exec(i)))throw new Error("invalid format: "+i);var e;return new fM({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}v_.prototype=fM.prototype;function fM(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}fM.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function N$(i){e:for(var e=i.length,t=1,n=-1,r;t0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(r+1):i}var __;function D$(i,e){var t=g_(i,e);if(!t)return __=void 0,i.toPrecision(e);var n=t[0],r=t[1],s=r-(__=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+g_(i,Math.max(0,e+s-1))[0]}function xR(i,e){var t=g_(i,e);if(!t)return i+"";var n=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}const bR={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:M$,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>xR(i*100,e),r:xR,s:D$,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function SR(i){return i}var TR=Array.prototype.map,wR=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function P$(i){var e=i.grouping===void 0||i.thousands===void 0?SR:E$(TR.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",r=i.decimal===void 0?".":i.decimal+"",s=i.numerals===void 0?SR:C$(TR.call(i.numerals,String)),a=i.percent===void 0?"%":i.percent+"",l=i.minus===void 0?"−":i.minus+"",u=i.nan===void 0?"NaN":i.nan+"";function h(v,x){v=v_(v);var S=v.fill,w=v.align,R=v.sign,C=v.symbol,E=v.zero,B=v.width,L=v.comma,O=v.precision,G=v.trim,q=v.type;q==="n"?(L=!0,q="g"):bR[q]||(O===void 0&&(O=12),G=!0,q="g"),(E||S==="0"&&w==="=")&&(E=!0,S="0",w="=");var z=(x&&x.prefix!==void 0?x.prefix:"")+(C==="$"?t:C==="#"&&/[boxX]/.test(q)?"0"+q.toLowerCase():""),j=(C==="$"?n:/[%p]/.test(q)?a:"")+(x&&x.suffix!==void 0?x.suffix:""),F=bR[q],V=/[defgprs%]/.test(q);O=O===void 0?6:/[gprs]/.test(q)?Math.max(1,Math.min(21,O)):Math.max(0,Math.min(20,O));function Y(ee){var te=z,re=j,ne,Q,ae;if(q==="c")re=F(ee)+re,ee="";else{ee=+ee;var de=ee<0||1/ee<0;if(ee=isNaN(ee)?u:F(Math.abs(ee),O),G&&(ee=N$(ee)),de&&+ee==0&&R!=="+"&&(de=!1),te=(de?R==="("?R:l:R==="-"||R==="("?"":R)+te,re=(q==="s"&&!isNaN(ee)&&__!==void 0?wR[8+__/3]:"")+re+(de&&R==="("?")":""),V){for(ne=-1,Q=ee.length;++neae||ae>57){re=(ae===46?r+ee.slice(ne+1):ee.slice(ne))+re,ee=ee.slice(0,ne);break}}}L&&!E&&(ee=e(ee,1/0));var Te=te.length+ee.length+re.length,be=Te>1)+te+ee+re+be.slice(Te);break;default:ee=be+te+ee+re;break}return s(ee)}return Y.toString=function(){return v+""},Y}function m(v,x){var S=Math.max(-8,Math.min(8,Math.floor(C0(x)/3)))*3,w=Math.pow(10,-S),R=h((v=v_(v),v.type="f",v),{suffix:wR[8+S/3]});return function(C){return R(w*C)}}return{format:h,formatPrefix:m}}var Q2,ED,CD;L$({thousands:",",grouping:[3],currency:["$",""]});function L$(i){return Q2=P$(i),ED=Q2.format,CD=Q2.formatPrefix,Q2}function U$(i){return Math.max(0,-C0(Math.abs(i)))}function B$(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(C0(e)/3)))*3-C0(Math.abs(i)))}function O$(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,C0(e)-C0(i))+1}function I$(i,e,t,n){var r=jW(i,e,t),s;switch(n=v_(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(s=B$(r,a))&&(n.precision=s),CD(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=O$(r,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=U$(r))&&(n.precision=s-(n.type==="%")*2);break}}return ED(n)}function RD(i){var e=i.domain;return i.ticks=function(t){var n=e();return HW(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var r=e();return I$(r[0],r[r.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),r=0,s=n.length-1,a=n[r],l=n[s],u,h,m=10;for(l0;){if(h=nT(a,l,t),h===u)return n[r]=a,n[s]=l,e(n);if(h>0)a=Math.floor(a/h)*h,l=Math.ceil(l/h)*h;else if(h<0)a=Math.ceil(a*h)/h,l=Math.floor(l*h)/h;else break;u=h}return i},i}function Pc(){var i=w$();return i.copy=function(){return S$(i,Pc())},yD.apply(i,arguments),RD(i)}function ND(){var i=0,e=1,t=1,n=[.5],r=[0,1],s;function a(u){return u!=null&&u<=u?r[_D(n,u,0,t)]:s}function l(){var u=-1;for(n=new Array(t);++u=t?[n[t-1],e]:[n[h-1],n[h]]},a.unknown=function(u){return arguments.length&&(s=u),a},a.thresholds=function(){return n.slice()},a.copy=function(){return ND().domain([i,e]).range(r).unknown(s)},yD.apply(RD(a),arguments)}var di=1e-6,y_=1e-12,Ni=Math.PI,$a=Ni/2,x_=Ni/4,No=Ni*2,kr=180/Ni,Hn=Ni/180,ir=Math.abs,AM=Math.atan,Zo=Math.atan2,ei=Math.cos,K2=Math.ceil,F$=Math.exp,aT=Math.hypot,k$=Math.log,zn=Math.sin,z$=Math.sign||function(i){return i>0?1:i<0?-1:0},Lc=Math.sqrt,G$=Math.tan;function q$(i){return i>1?0:i<-1?Ni:Math.acos(i)}function Uc(i){return i>1?$a:i<-1?-$a:Math.asin(i)}function MR(i){return(i=zn(i/2))*i}function ra(){}function b_(i,e){i&&CR.hasOwnProperty(i.type)&&CR[i.type](i,e)}var ER={Feature:function(i,e){b_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n=0?1:-1,r=n*t,s=ei(e),a=zn(e),l=cT*a,u=uT*s+l*ei(r),h=l*n*zn(r);S_.add(Zo(h,u)),lT=i,uT=s,cT=a}function T_(i){return[Zo(i[1],i[0]),Uc(i[2])]}function hA(i){var e=i[0],t=i[1],n=ei(t);return[n*ei(e),n*zn(e),zn(t)]}function Z2(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function R0(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function B3(i,e){i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}function J2(i,e){return[i[0]*e,i[1]*e,i[2]*e]}function w_(i){var e=Lc(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);i[0]/=e,i[1]/=e,i[2]/=e}var Cr,qa,Ir,wo,Of,UD,BD,i0,Dm,Ch,Oc,_c={point:hT,lineStart:DR,lineEnd:PR,polygonStart:function(){_c.point=ID,_c.lineStart=W$,_c.lineEnd=$$,Dm=new Ec,Bc.polygonStart()},polygonEnd:function(){Bc.polygonEnd(),_c.point=hT,_c.lineStart=DR,_c.lineEnd=PR,S_<0?(Cr=-(Ir=180),qa=-(wo=90)):Dm>di?wo=90:Dm<-di&&(qa=-90),Oc[0]=Cr,Oc[1]=Ir},sphere:function(){Cr=-(Ir=180),qa=-(wo=90)}};function hT(i,e){Ch.push(Oc=[Cr=i,Ir=i]),ewo&&(wo=e)}function OD(i,e){var t=hA([i*Hn,e*Hn]);if(i0){var n=R0(i0,t),r=[n[1],-n[0],0],s=R0(r,n);w_(s),s=T_(s);var a=i-Of,l=a>0?1:-1,u=s[0]*kr*l,h,m=ir(a)>180;m^(l*Ofwo&&(wo=h)):(u=(u+360)%360-180,m^(l*Ofwo&&(wo=e))),m?ibo(Cr,Ir)&&(Ir=i):bo(i,Ir)>bo(Cr,Ir)&&(Cr=i):Ir>=Cr?(iIr&&(Ir=i)):i>Of?bo(Cr,i)>bo(Cr,Ir)&&(Ir=i):bo(i,Ir)>bo(Cr,Ir)&&(Cr=i)}else Ch.push(Oc=[Cr=i,Ir=i]);ewo&&(wo=e),i0=t,Of=i}function DR(){_c.point=OD}function PR(){Oc[0]=Cr,Oc[1]=Ir,_c.point=hT,i0=null}function ID(i,e){if(i0){var t=i-Of;Dm.add(ir(t)>180?t+(t>0?360:-360):t)}else UD=i,BD=e;Bc.point(i,e),OD(i,e)}function W$(){Bc.lineStart()}function $$(){ID(UD,BD),Bc.lineEnd(),ir(Dm)>di&&(Cr=-(Ir=180)),Oc[0]=Cr,Oc[1]=Ir,i0=null}function bo(i,e){return(e-=i)<0?e+360:e}function X$(i,e){return i[0]-e[0]}function LR(i,e){return i[0]<=i[1]?i[0]<=e&&e<=i[1]:ebo(n[0],n[1])&&(n[1]=r[1]),bo(r[0],n[1])>bo(n[0],n[1])&&(n[0]=r[0])):s.push(n=r);for(a=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=r,++e)r=s[e],(l=bo(n[1],r[0]))>a&&(a=l,Cr=r[0],Ir=n[1])}return Ch=Oc=null,Cr===1/0||qa===1/0?[[NaN,NaN],[NaN,NaN]]:[[Cr,qa],[Ir,wo]]}var xm,M_,E_,C_,R_,N_,D_,P_,fT,AT,dT,kD,zD,xa,ba,Sa,Ml={sphere:ra,point:dM,lineStart:UR,lineEnd:BR,polygonStart:function(){Ml.lineStart=K$,Ml.lineEnd=Z$},polygonEnd:function(){Ml.lineStart=UR,Ml.lineEnd=BR}};function dM(i,e){i*=Hn,e*=Hn;var t=ei(e);Gg(t*ei(i),t*zn(i),zn(e))}function Gg(i,e,t){++xm,E_+=(i-E_)/xm,C_+=(e-C_)/xm,R_+=(t-R_)/xm}function UR(){Ml.point=Y$}function Y$(i,e){i*=Hn,e*=Hn;var t=ei(e);xa=t*ei(i),ba=t*zn(i),Sa=zn(e),Ml.point=Q$,Gg(xa,ba,Sa)}function Q$(i,e){i*=Hn,e*=Hn;var t=ei(e),n=t*ei(i),r=t*zn(i),s=zn(e),a=Zo(Lc((a=ba*s-Sa*r)*a+(a=Sa*n-xa*s)*a+(a=xa*r-ba*n)*a),xa*n+ba*r+Sa*s);M_+=a,N_+=a*(xa+(xa=n)),D_+=a*(ba+(ba=r)),P_+=a*(Sa+(Sa=s)),Gg(xa,ba,Sa)}function BR(){Ml.point=dM}function K$(){Ml.point=J$}function Z$(){GD(kD,zD),Ml.point=dM}function J$(i,e){kD=i,zD=e,i*=Hn,e*=Hn,Ml.point=GD;var t=ei(e);xa=t*ei(i),ba=t*zn(i),Sa=zn(e),Gg(xa,ba,Sa)}function GD(i,e){i*=Hn,e*=Hn;var t=ei(e),n=t*ei(i),r=t*zn(i),s=zn(e),a=ba*s-Sa*r,l=Sa*n-xa*s,u=xa*r-ba*n,h=aT(a,l,u),m=Uc(h),v=h&&-m/h;fT.add(v*a),AT.add(v*l),dT.add(v*u),M_+=m,N_+=m*(xa+(xa=n)),D_+=m*(ba+(ba=r)),P_+=m*(Sa+(Sa=s)),Gg(xa,ba,Sa)}function OR(i){xm=M_=E_=C_=R_=N_=D_=P_=0,fT=new Ec,AT=new Ec,dT=new Ec,Ey(i,Ml);var e=+fT,t=+AT,n=+dT,r=aT(e,t,n);return rNi&&(i-=Math.round(i/No)*No),[i,e]}mT.invert=mT;function qD(i,e,t){return(i%=No)?e||t?pT(FR(i),kR(e,t)):FR(i):e||t?kR(e,t):mT}function IR(i){return function(e,t){return e+=i,ir(e)>Ni&&(e-=Math.round(e/No)*No),[e,t]}}function FR(i){var e=IR(i);return e.invert=IR(-i),e}function kR(i,e){var t=ei(i),n=zn(i),r=ei(e),s=zn(e);function a(l,u){var h=ei(u),m=ei(l)*h,v=zn(l)*h,x=zn(u),S=x*t+m*n;return[Zo(v*r-S*s,m*t-x*n),Uc(S*r+v*s)]}return a.invert=function(l,u){var h=ei(u),m=ei(l)*h,v=zn(l)*h,x=zn(u),S=x*r-v*s;return[Zo(v*r+x*s,m*t+S*n),Uc(S*t-m*n)]},a}function eX(i){i=qD(i[0]*Hn,i[1]*Hn,i.length>2?i[2]*Hn:0);function e(t){return t=i(t[0]*Hn,t[1]*Hn),t[0]*=kr,t[1]*=kr,t}return e.invert=function(t){return t=i.invert(t[0]*Hn,t[1]*Hn),t[0]*=kr,t[1]*=kr,t},e}function tX(i,e,t,n,r,s){if(t){var a=ei(e),l=zn(e),u=n*t;r==null?(r=e+n*No,s=e-u/2):(r=zR(a,r),s=zR(a,s),(n>0?rs)&&(r+=n*No));for(var h,m=r;n>0?m>s:m1&&i.push(i.pop().concat(i.shift()))},result:function(){var t=i;return i=[],e=null,t}}}function Hv(i,e){return ir(i[0]-e[0])=0;--l)r.point((v=m[l])[0],v[1]);else n(x.x,x.p.x,-1,r);x=x.p}x=x.o,m=x.z,S=!S}while(!x.v);r.lineEnd()}}}function GR(i){if(e=i.length){for(var e,t=0,n=i[0],r;++t=0?1:-1,V=F*j,Y=V>Ni,ee=C*q;if(u.add(Zo(ee*F*zn(V),E*z+ee*ei(V))),a+=Y?j+F*No:j,Y^w>=t^O>=t){var te=R0(hA(S),hA(L));w_(te);var re=R0(s,te);w_(re);var ne=(Y^j>=0?-1:1)*Uc(re[2]);(n>ne||n===ne&&(te[0]||te[1]))&&(l+=Y^j>=0?1:-1)}}return(a<-di||a0){for(u||(r.polygonStart(),u=!0),r.lineStart(),q=0;q1&&O&2&&G.push(G.pop().concat(G.shift())),m.push(G.filter(nX))}}return x}}function nX(i){return i.length>1}function iX(i,e){return((i=i.x)[0]<0?i[1]-$a-di:$a-i[1])-((e=e.x)[0]<0?e[1]-$a-di:$a-e[1])}const qR=WD(function(){return!0},rX,aX,[-Ni,-$a]);function rX(i){var e=NaN,t=NaN,n=NaN,r;return{lineStart:function(){i.lineStart(),r=1},point:function(s,a){var l=s>0?Ni:-Ni,u=ir(s-e);ir(u-Ni)0?$a:-$a),i.point(n,t),i.lineEnd(),i.lineStart(),i.point(l,t),i.point(s,t),r=0):n!==l&&u>=Ni&&(ir(e-n)di?AM((zn(e)*(s=ei(n))*zn(t)-zn(n)*(r=ei(e))*zn(i))/(r*s*a)):(e+n)/2}function aX(i,e,t,n){var r;if(i==null)r=t*$a,n.point(-Ni,r),n.point(0,r),n.point(Ni,r),n.point(Ni,0),n.point(Ni,-r),n.point(0,-r),n.point(-Ni,-r),n.point(-Ni,0),n.point(-Ni,r);else if(ir(i[0]-e[0])>di){var s=i[0]0,r=ir(e)>di;function s(m,v,x,S){tX(S,i,t,x,m,v)}function a(m,v){return ei(m)*ei(v)>e}function l(m){var v,x,S,w,R;return{lineStart:function(){w=S=!1,R=1},point:function(C,E){var B=[C,E],L,O=a(C,E),G=n?O?0:h(C,E):O?h(C+(C<0?Ni:-Ni),E):0;if(!v&&(w=S=O)&&m.lineStart(),O!==S&&(L=u(v,B),(!L||Hv(v,L)||Hv(B,L))&&(B[2]=1)),O!==S)R=0,O?(m.lineStart(),L=u(B,v),m.point(L[0],L[1])):(L=u(v,B),m.point(L[0],L[1],2),m.lineEnd()),v=L;else if(r&&v&&n^O){var q;!(G&x)&&(q=u(B,v,!0))&&(R=0,n?(m.lineStart(),m.point(q[0][0],q[0][1]),m.point(q[1][0],q[1][1]),m.lineEnd()):(m.point(q[1][0],q[1][1]),m.lineEnd(),m.lineStart(),m.point(q[0][0],q[0][1],3)))}O&&(!v||!Hv(v,B))&&m.point(B[0],B[1]),v=B,S=O,x=G},lineEnd:function(){S&&m.lineEnd(),v=null},clean:function(){return R|(w&&S)<<1}}}function u(m,v,x){var S=hA(m),w=hA(v),R=[1,0,0],C=R0(S,w),E=Z2(C,C),B=C[0],L=E-B*B;if(!L)return!x&&m;var O=e*E/L,G=-e*B/L,q=R0(R,C),z=J2(R,O),j=J2(C,G);B3(z,j);var F=q,V=Z2(z,F),Y=Z2(F,F),ee=V*V-Y*(Z2(z,z)-1);if(!(ee<0)){var te=Lc(ee),re=J2(F,(-V-te)/Y);if(B3(re,z),re=T_(re),!x)return re;var ne=m[0],Q=v[0],ae=m[1],de=v[1],Te;Q0^re[1]<(ir(re[0]-ne)Ni^(ne<=re[0]&&re[0]<=Q)){var We=J2(F,(-V+te)/Y);return B3(We,z),[re,T_(We)]}}}function h(m,v){var x=n?i:Ni-i,S=0;return m<-x?S|=1:m>x&&(S|=2),v<-x?S|=4:v>x&&(S|=8),S}return WD(a,l,s,n?[0,-i]:[-Ni,i-Ni])}function lX(i,e,t,n,r,s){var a=i[0],l=i[1],u=e[0],h=e[1],m=0,v=1,x=u-a,S=h-l,w;if(w=t-a,!(!x&&w>0)){if(w/=x,x<0){if(w0){if(w>v)return;w>m&&(m=w)}if(w=r-a,!(!x&&w<0)){if(w/=x,x<0){if(w>v)return;w>m&&(m=w)}else if(x>0){if(w0)){if(w/=S,S<0){if(w0){if(w>v)return;w>m&&(m=w)}if(w=s-l,!(!S&&w<0)){if(w/=S,S<0){if(w>v)return;w>m&&(m=w)}else if(S>0){if(w0&&(i[0]=a+m*x,i[1]=l+m*S),v<1&&(e[0]=a+v*x,e[1]=l+v*S),!0}}}}}var bm=1e9,tv=-bm;function uX(i,e,t,n){function r(h,m){return i<=h&&h<=t&&e<=m&&m<=n}function s(h,m,v,x){var S=0,w=0;if(h==null||(S=a(h,v))!==(w=a(m,v))||u(h,m)<0^v>0)do x.point(S===0||S===3?i:t,S>1?n:e);while((S=(S+v+4)%4)!==w);else x.point(m[0],m[1])}function a(h,m){return ir(h[0]-i)0?0:3:ir(h[0]-t)0?2:1:ir(h[1]-e)0?1:0:m>0?3:2}function l(h,m){return u(h.x,m.x)}function u(h,m){var v=a(h,1),x=a(m,1);return v!==x?v-x:v===0?m[1]-h[1]:v===1?h[0]-m[0]:v===2?h[1]-m[1]:m[0]-h[0]}return function(h){var m=h,v=VD(),x,S,w,R,C,E,B,L,O,G,q,z={point:j,lineStart:ee,lineEnd:te,polygonStart:V,polygonEnd:Y};function j(ne,Q){r(ne,Q)&&m.point(ne,Q)}function F(){for(var ne=0,Q=0,ae=S.length;Qn&&(Ne-we)*(n-We)>(ze-We)*(i-we)&&++ne:ze<=n&&(Ne-we)*(n-We)<(ze-We)*(i-we)&&--ne;return ne}function V(){m=v,x=[],S=[],q=!0}function Y(){var ne=F(),Q=q&&ne,ae=(x=ug(x)).length;(Q||ae)&&(h.polygonStart(),Q&&(h.lineStart(),s(null,null,1,h),h.lineEnd()),ae&&HD(x,l,ne,s,h),h.polygonEnd()),m=h,x=S=w=null}function ee(){z.point=re,S&&S.push(w=[]),G=!0,O=!1,B=L=NaN}function te(){x&&(re(R,C),E&&O&&v.rejoin(),x.push(v.result())),z.point=j,O&&m.lineEnd()}function re(ne,Q){var ae=r(ne,Q);if(S&&w.push([ne,Q]),G)R=ne,C=Q,E=ae,G=!1,ae&&(m.lineStart(),m.point(ne,Q));else if(ae&&O)m.point(ne,Q);else{var de=[B=Math.max(tv,Math.min(bm,B)),L=Math.max(tv,Math.min(bm,L))],Te=[ne=Math.max(tv,Math.min(bm,ne)),Q=Math.max(tv,Math.min(bm,Q))];lX(de,Te,i,e,t,n)?(O||(m.lineStart(),m.point(de[0],de[1])),m.point(Te[0],Te[1]),ae||m.lineEnd(),q=!1):ae&&(m.lineStart(),m.point(ne,Q),q=!1)}B=ne,L=Q,O=ae}return z}}var gT,vT,jv,Wv,N0={sphere:ra,point:ra,lineStart:cX,lineEnd:ra,polygonStart:ra,polygonEnd:ra};function cX(){N0.point=fX,N0.lineEnd=hX}function hX(){N0.point=N0.lineEnd=ra}function fX(i,e){i*=Hn,e*=Hn,vT=i,jv=zn(e),Wv=ei(e),N0.point=AX}function AX(i,e){i*=Hn,e*=Hn;var t=zn(e),n=ei(e),r=ir(i-vT),s=ei(r),a=zn(r),l=n*a,u=Wv*t-jv*n*s,h=jv*t+Wv*n*s;gT.add(Zo(Lc(l*l+u*u),h)),vT=i,jv=t,Wv=n}function dX(i){return gT=new Ec,Ey(i,N0),+gT}var _T=[null,null],pX={type:"LineString",coordinates:_T};function Vh(i,e){return _T[0]=i,_T[1]=e,dX(pX)}var VR={Feature:function(i,e){return L_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n0&&(r=Vh(i[s],i[s-1]),r>0&&t<=r&&n<=r&&(t+n-r)*(1-Math.pow((t-n)/r,2))di}).map(x)).concat(jd(K2(s/h)*h,r,h).filter(function(L){return ir(L%v)>di}).map(S))}return E.lines=function(){return B().map(function(L){return{type:"LineString",coordinates:L}})},E.outline=function(){return{type:"Polygon",coordinates:[w(n).concat(R(a).slice(1),w(t).reverse().slice(1),R(l).reverse().slice(1))]}},E.extent=function(L){return arguments.length?E.extentMajor(L).extentMinor(L):E.extentMinor()},E.extentMajor=function(L){return arguments.length?(n=+L[0][0],t=+L[1][0],l=+L[0][1],a=+L[1][1],n>t&&(L=n,n=t,t=L),l>a&&(L=l,l=a,a=L),E.precision(C)):[[n,l],[t,a]]},E.extentMinor=function(L){return arguments.length?(e=+L[0][0],i=+L[1][0],s=+L[0][1],r=+L[1][1],e>i&&(L=e,e=i,i=L),s>r&&(L=s,s=r,r=L),E.precision(C)):[[e,s],[i,r]]},E.step=function(L){return arguments.length?E.stepMajor(L).stepMinor(L):E.stepMinor()},E.stepMajor=function(L){return arguments.length?(m=+L[0],v=+L[1],E):[m,v]},E.stepMinor=function(L){return arguments.length?(u=+L[0],h=+L[1],E):[u,h]},E.precision=function(L){return arguments.length?(C=+L,x=XR(s,r,90),S=YR(e,i,C),w=XR(l,a,90),R=YR(n,t,C),E):C},E.extentMajor([[-180,-90+di],[180,90-di]]).extentMinor([[-180,-80-di],[180,80+di]])}function _X(){return vX()()}function pM(i,e){var t=i[0]*Hn,n=i[1]*Hn,r=e[0]*Hn,s=e[1]*Hn,a=ei(n),l=zn(n),u=ei(s),h=zn(s),m=a*ei(t),v=a*zn(t),x=u*ei(r),S=u*zn(r),w=2*Uc(Lc(MR(s-n)+a*u*MR(r-t))),R=zn(w),C=w?function(E){var B=zn(E*=w)/R,L=zn(w-E)/R,O=L*m+B*x,G=L*v+B*S,q=L*l+B*h;return[Zo(G,O)*kr,Zo(q,Lc(O*O+G*G))*kr]}:function(){return[t*kr,n*kr]};return C.distance=w,C}const QR=i=>i;var D0=1/0,U_=D0,Ag=-D0,B_=Ag,KR={point:yX,lineStart:ra,lineEnd:ra,polygonStart:ra,polygonEnd:ra,result:function(){var i=[[D0,U_],[Ag,B_]];return Ag=B_=-(U_=D0=1/0),i}};function yX(i,e){iAg&&(Ag=i),eB_&&(B_=e)}function mM(i){return function(e){var t=new yT;for(var n in i)t[n]=i[n];return t.stream=e,t}}function yT(){}yT.prototype={constructor:yT,point:function(i,e){this.stream.point(i,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function gM(i,e,t){var n=i.clipExtent&&i.clipExtent();return i.scale(150).translate([0,0]),n!=null&&i.clipExtent(null),Ey(t,i.stream(KR)),e(KR.result()),n!=null&&i.clipExtent(n),i}function XD(i,e,t){return gM(i,function(n){var r=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(r/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),l=+e[0][0]+(r-a*(n[1][0]+n[0][0]))/2,u=+e[0][1]+(s-a*(n[1][1]+n[0][1]))/2;i.scale(150*a).translate([l,u])},t)}function xX(i,e,t){return XD(i,[[0,0],e],t)}function bX(i,e,t){return gM(i,function(n){var r=+e,s=r/(n[1][0]-n[0][0]),a=(r-s*(n[1][0]+n[0][0]))/2,l=-s*n[0][1];i.scale(150*s).translate([a,l])},t)}function SX(i,e,t){return gM(i,function(n){var r=+e,s=r/(n[1][1]-n[0][1]),a=-s*n[0][0],l=(r-s*(n[1][1]+n[0][1]))/2;i.scale(150*s).translate([a,l])},t)}var ZR=16,TX=ei(30*Hn);function JR(i,e){return+e?MX(i,e):wX(i)}function wX(i){return mM({point:function(e,t){e=i(e,t),this.stream.point(e[0],e[1])}})}function MX(i,e){function t(n,r,s,a,l,u,h,m,v,x,S,w,R,C){var E=h-n,B=m-r,L=E*E+B*B;if(L>4*e&&R--){var O=a+x,G=l+S,q=u+w,z=Lc(O*O+G*G+q*q),j=Uc(q/=z),F=ir(ir(q)-1)e||ir((E*te+B*re)/L-.5)>.3||a*x+l*S+u*w2?ne[2]%360*Hn:0,te()):[l*kr,u*kr,h*kr]},Y.angle=function(ne){return arguments.length?(v=ne%360*Hn,te()):v*kr},Y.reflectX=function(ne){return arguments.length?(x=ne?-1:1,te()):x<0},Y.reflectY=function(ne){return arguments.length?(S=ne?-1:1,te()):S<0},Y.precision=function(ne){return arguments.length?(q=JR(z,G=ne*ne),re()):Lc(G)},Y.fitExtent=function(ne,Q){return XD(Y,ne,Q)},Y.fitSize=function(ne,Q){return xX(Y,ne,Q)},Y.fitWidth=function(ne,Q){return bX(Y,ne,Q)},Y.fitHeight=function(ne,Q){return SX(Y,ne,Q)};function te(){var ne=e6(t,0,0,x,S,v).apply(null,e(s,a)),Q=e6(t,n-ne[0],r-ne[1],x,S,v);return m=qD(l,u,h),z=pT(e,Q),j=pT(m,z),q=JR(z,G),re()}function re(){return F=V=null,Y}return function(){return e=i.apply(this,arguments),Y.invert=e.invert&&ee,te()}}function PX(i){return function(e,t){var n=Lc(e*e+t*t),r=i(n),s=zn(r),a=ei(r);return[Zo(e*s,n*a),Uc(n&&t*s/n)]}}function vM(i,e){return[i,k$(G$(($a+e)/2))]}vM.invert=function(i,e){return[i,2*AM(F$(e))-$a]};function YD(i,e){var t=ei(e),n=1+ei(i)*t;return[t*zn(i)/n,zn(e)/n]}YD.invert=PX(function(i){return 2*AM(i)});function LX(){return NX(YD).scale(250).clipAngle(142)}function xT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=Pc().domain([1,0]).range([t,n]).clamp(!0),s=Pc().domain([I3(t),I3(n)]).range([1,0]).clamp(!0),a=function(v){return s(I3(r(v)))},l=e.array,u=0,h=l.length;u2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,l=[],u=Math.pow(2,e),h=360/u,m=180/u,v=s===void 0?u-1:s,x=a===void 0?u-1:a,S=n,w=Math.min(u-1,v);S<=w;S++)for(var R=r,C=Math.min(u-1,x);R<=C;R++){var E=R,B=m;if(t){E=R===0?R:n6(R/u)*u;var L=R+1===u?R+1:n6((R+1)/u)*u;B=(L-E)*180/u}var O=-180+(S+.5)*h,G=90-(E*180/u+B/2),q=B;l.push({x:S,y:R,lng:O,lat:G,latLen:q})}return l},KX=6,ZX=7,JX=3,eY=90,Ql=new WeakMap,Nh=new WeakMap,F3=new WeakMap,nv=new WeakMap,Vo=new WeakMap,I_=new WeakMap,r0=new WeakMap,Ef=new WeakMap,iv=new WeakSet,tY=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.tileUrl,a=r.minLevel,l=a===void 0?0:a,u=r.maxLevel,h=u===void 0?17:u,m=r.mercatorProjection,v=m===void 0?!0:m;return FX(this,e),n=IX(this,e),kX(n,iv),xh(n,Ql,void 0),xh(n,Nh,void 0),xh(n,F3,void 0),xh(n,nv,void 0),xh(n,Vo,{}),xh(n,I_,void 0),xh(n,r0,void 0),xh(n,Ef,void 0),yd(n,"minLevel",void 0),yd(n,"maxLevel",void 0),yd(n,"thresholds",ZD(new Array(30)).map(function(x,S){return 8/Math.pow(2,S)})),yd(n,"curvatureResolution",5),yd(n,"tileMargin",0),yd(n,"clearTiles",function(){Object.values(fi(Vo,n)).forEach(function(x){x.forEach(function(S){S.obj&&(n.remove(S.obj),t6(S.obj),delete S.obj)})}),bh(Vo,n,{})}),bh(Ql,n,t),n.tileUrl=s,bh(Nh,n,v),n.minLevel=l,n.maxLevel=h,n.level=0,n.add(bh(Ef,n,new zi(new Eu(fi(Ql,n)*.99,180,90),new pA({color:0})))),fi(Ef,n).visible=!1,fi(Ef,n).material.polygonOffset=!0,fi(Ef,n).material.polygonOffsetUnits=3,fi(Ef,n).material.polygonOffsetFactor=1,n}return qX(e,i),GX(e,[{key:"tileUrl",get:function(){return fi(F3,this)},set:function(n){bh(F3,this,n),this.updatePov(fi(r0,this))}},{key:"level",get:function(){return fi(nv,this)},set:function(n){var r,s=this;fi(Vo,this)[n]||Pm(iv,this,nY).call(this,n);var a=fi(nv,this);if(bh(nv,this,n),!(n===a||a===void 0)){if(fi(Ef,this).visible=n>0,fi(Vo,this)[n].forEach(function(u){return u.obj&&(u.obj.material.depthWrite=!0)}),an)for(var l=n+1;l<=a;l++)fi(Vo,this)[l]&&fi(Vo,this)[l].forEach(function(u){u.obj&&(s.remove(u.obj),t6(u.obj),delete u.obj)});Pm(iv,this,r6).call(this)}}},{key:"updatePov",value:function(n){var r=this;if(!(!n||!(n instanceof _y))){bh(r0,this,n);var s;if(bh(I_,this,function(m){if(!m.hullPnts){var v=360/Math.pow(2,r.level),x=m.lng,S=m.lat,w=m.latLen,R=x-v/2,C=x+v/2,E=S-w/2,B=S+w/2;m.hullPnts=[[S,x],[E,R],[B,R],[E,C],[B,C]].map(function(L){var O=$v(L,2),G=O[0],q=O[1];return iP(G,q,fi(Ql,r))}).map(function(L){var O=L.x,G=L.y,q=L.z;return new he(O,G,q)})}return s||(s=new Fg,n.updateMatrix(),n.updateMatrixWorld(),s.setFromProjectionMatrix(new kn().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse))),m.hullPnts.some(function(L){return s.containsPoint(L.clone().applyMatrix4(r.matrixWorld))})}),this.tileUrl){var a=n.position.clone(),l=a.distanceTo(this.getWorldPosition(new he)),u=(l-fi(Ql,this))/fi(Ql,this),h=this.thresholds.findIndex(function(m){return m&&m<=u});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,h<0?this.thresholds.length:h)),Pm(iv,this,r6).call(this)}}}}])})(ja);function nY(i){var e=this;if(i>ZX){fi(Vo,this)[i]=[];return}var t=fi(Vo,this)[i]=ST(i,fi(Nh,this));t.forEach(function(n){return n.centroid=iP(n.lat,n.lng,fi(Ql,e))}),t.octree=gD().x(function(n){return n.centroid.x}).y(function(n){return n.centroid.y}).z(function(n){return n.centroid.z}).addAll(t)}function r6(){var i=this;if(!(!this.tileUrl||this.level===void 0||!fi(Vo,this).hasOwnProperty(this.level))&&!(!fi(I_,this)&&this.level>KX)){var e=fi(Vo,this)[this.level];if(fi(r0,this)){var t=this.worldToLocal(fi(r0,this).position.clone());if(e.octree){var n,r=this.worldToLocal(fi(r0,this).position.clone()),s=(r.length()-fi(Ql,this))*JX;e=(n=e.octree).findAllWithinRadius.apply(n,ZD(r).concat([s]))}else{var a=YX(t),l=(a.r/fi(Ql,this)-1)*eY,u=l/Math.cos(Mf(a.lat)),h=[a.lng-u,a.lng+u],m=[a.lat+l,a.lat-l],v=i6(this.level,fi(Nh,this),h[0],m[0]),x=$v(v,2),S=x[0],w=x[1],R=i6(this.level,fi(Nh,this),h[1],m[1]),C=$v(R,2),E=C[0],B=C[1];!e.record&&(e.record={});var L=e.record;if(!L.hasOwnProperty("".concat(Math.round((S+E)/2),"_").concat(Math.round((w+B)/2))))e=ST(this.level,fi(Nh,this),S,w,E,B).map(function(j){var F="".concat(j.x,"_").concat(j.y);return L.hasOwnProperty(F)?L[F]:(L[F]=j,e.push(j),j)});else{for(var O=[],G=S;G<=E;G++)for(var q=w;q<=B;q++){var z="".concat(G,"_").concat(q);L.hasOwnProperty(z)||(L[z]=ST(this.level,fi(Nh,this),G,q,G,q)[0],e.push(L[z])),O.push(L[z])}e=O}}}e.filter(function(j){return!j.obj}).filter(fi(I_,this)||function(){return!0}).forEach(function(j){var F=j.x,V=j.y,Y=j.lng,ee=j.lat,te=j.latLen,re=360/Math.pow(2,i.level);if(!j.obj){var ne=re*(1-i.tileMargin),Q=te*(1-i.tileMargin),ae=Mf(Y),de=Mf(-ee),Te=new zi(new Eu(fi(Ql,i),Math.ceil(ne/i.curvatureResolution),Math.ceil(Q/i.curvatureResolution),Mf(90-ne/2)+ae,Mf(ne),Mf(90-Q/2)+de,Mf(Q)),new Vc);if(fi(Nh,i)){var be=[ee+te/2,ee-te/2].map(function(Ne){return .5-Ne/180}),ue=$v(be,2),we=ue[0],We=ue[1];QX(Te.geometry.attributes.uv,we,We)}j.obj=Te}j.loading||(j.loading=!0,new rM().load(i.tileUrl(F,V,i.level),function(Ne){var ze=j.obj;ze&&(Ne.colorSpace=_n,ze.material.map=Ne,ze.material.color=null,ze.material.needsUpdate=!0,i.add(ze)),j.loading=!1}))})}}function iY(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=sP(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let l,u,h;if(n&&(s=lY(i,e,s,t)),i.length>80*t){l=i[0],u=i[1];let m=l,v=u;for(let x=t;xm&&(m=S),w>v&&(v=w)}h=Math.max(m-l,v-u),h=h!==0?32767/h:0}return dg(s,a,t,l,u,h,0),a}function sP(i,e,t,n,r){let s;if(r===_Y(i,e,t,n)>0)for(let a=e;a=e;a-=n)s=s6(a/n|0,i[a],i[a+1],s);return s&&P0(s,s.next)&&(mg(s),s=s.next),s}function fA(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(P0(t,t.next)||Dr(t.prev,t,t.next)===0)){if(mg(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function dg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&AY(i,n,r,s);let l=i;for(;i.prev!==i.next;){const u=i.prev,h=i.next;if(s?sY(i,n,r,s):rY(i)){e.push(u.i,i.i,h.i),mg(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=aY(fA(i),e),dg(i,e,t,n,r,s,2)):a===2&&oY(i,e,t,n,r,s):dg(fA(i),e,t,n,r,s,1);break}}}function rY(i){const e=i.prev,t=i,n=i.next;if(Dr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=Math.min(r,s,a),v=Math.min(l,u,h),x=Math.max(r,s,a),S=Math.max(l,u,h);let w=n.next;for(;w!==e;){if(w.x>=m&&w.x<=x&&w.y>=v&&w.y<=S&&Sm(r,l,s,u,a,h,w.x,w.y)&&Dr(w.prev,w,w.next)>=0)return!1;w=w.next}return!0}function sY(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Dr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=Math.min(l,u,h),w=Math.min(m,v,x),R=Math.max(l,u,h),C=Math.max(m,v,x),E=TT(S,w,e,t,n),B=TT(R,C,e,t,n);let L=i.prevZ,O=i.nextZ;for(;L&&L.z>=E&&O&&O.z<=B;){if(L.x>=S&&L.x<=R&&L.y>=w&&L.y<=C&&L!==r&&L!==a&&Sm(l,m,u,v,h,x,L.x,L.y)&&Dr(L.prev,L,L.next)>=0||(L=L.prevZ,O.x>=S&&O.x<=R&&O.y>=w&&O.y<=C&&O!==r&&O!==a&&Sm(l,m,u,v,h,x,O.x,O.y)&&Dr(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;L&&L.z>=E;){if(L.x>=S&&L.x<=R&&L.y>=w&&L.y<=C&&L!==r&&L!==a&&Sm(l,m,u,v,h,x,L.x,L.y)&&Dr(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;O&&O.z<=B;){if(O.x>=S&&O.x<=R&&O.y>=w&&O.y<=C&&O!==r&&O!==a&&Sm(l,m,u,v,h,x,O.x,O.y)&&Dr(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function aY(i,e){let t=i;do{const n=t.prev,r=t.next.next;!P0(n,r)&&oP(n,t,t.next,r)&&pg(n,r)&&pg(r,n)&&(e.push(n.i,t.i,r.i),mg(t),mg(t.next),t=i=r),t=t.next}while(t!==i);return fA(t)}function oY(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&mY(a,l)){let u=lP(a,l);a=fA(a,a.next),u=fA(u,u.next),dg(a,e,t,n,r,s,0),dg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function lY(i,e,t,n){const r=[];for(let s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const v=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=n&&v>s&&(s=v,a=t.x=t.x&&t.x>=u&&n!==t.x&&aP(ra.x||t.x===a.x&&fY(a,t)))&&(a=t,m=v)}t=t.next}while(t!==l);return a}function fY(i,e){return Dr(i.prev,i,e.prev)<0&&Dr(e.next,i,i.next)<0}function AY(i,e,t,n){let r=i;do r.z===0&&(r.z=TT(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,dY(r)}function dY(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,l=0;for(let h=0;h0||u>0&&a;)l!==0&&(u===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,l--):(r=a,a=a.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function TT(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function pY(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function Sm(i,e,t,n,r,s,a,l){return!(i===a&&e===l)&&aP(i,e,t,n,r,s,a,l)}function mY(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!gY(i,e)&&(pg(i,e)&&pg(e,i)&&vY(i,e)&&(Dr(i.prev,i,e.prev)||Dr(i,e.prev,e))||P0(i,e)&&Dr(i.prev,i,i.next)>0&&Dr(e.prev,e,e.next)>0)}function Dr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function P0(i,e){return i.x===e.x&&i.y===e.y}function oP(i,e,t,n){const r=sv(Dr(i,e,t)),s=sv(Dr(i,e,n)),a=sv(Dr(t,n,i)),l=sv(Dr(t,n,e));return!!(r!==s&&a!==l||r===0&&rv(i,t,e)||s===0&&rv(i,n,e)||a===0&&rv(t,i,n)||l===0&&rv(t,e,n))}function rv(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function sv(i){return i>0?1:i<0?-1:0}function gY(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&oP(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function pg(i,e){return Dr(i.prev,i,i.next)<0?Dr(i,e,i.next)>=0&&Dr(i,i.prev,e)>=0:Dr(i,e,i.prev)<0||Dr(i,i.next,e)<0}function vY(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function lP(i,e){const t=wT(i.i,i.x,i.y),n=wT(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function s6(i,e,t,n){const r=wT(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function mg(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function wT(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function _Y(i,e,t,n){let r=0;for(let s=e,a=t-n;si.length)&&(e=i.length);for(var t=0,n=Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,l=!1;return{s:function(){t=t.call(i)},n:function(){var u=t.next();return a=u.done,u},e:function(u){l=!0,s=u},f:function(){try{a||t.return==null||t.return()}finally{if(l)throw s}}}}function k_(i){return k_=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},k_(i)}function EY(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&ET(i,e)}function uP(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(uP=function(){return!!i})()}function CY(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function RY(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,a,l=[],u=!0,h=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=s.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(m){h=!0,r=m}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function NY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function DY(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function PY(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return bY(i)}function ET(i,e){return ET=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},ET(i,e)}function nm(i,e){return yY(i)||RY(i,e)||_M(i,e)||NY()}function LY(i){return xY(i)||CY(i)||_M(i)||DY()}function _M(i,e){if(i){if(typeof i=="string")return MT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?MT(i,e):void 0}}var a6=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(s){if(r){var a=Vh(s,r)*180/Math.PI;if(a>t)for(var l=pM(r,s),u=r.length>2||s.length>2?fg(r[2]||0,s[2]||0):null,h=u?function(x){return[].concat(LY(l(x)),[u(x)])}:l,m=1/Math.ceil(a/t),v=m;v<1;)n.push(h(v)),v+=m}n.push(r=s)}),n},CT=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:Ki,Float32BufferAttribute:Mi},UY=new CT.BufferGeometry().setAttribute?"setAttribute":"addAttribute",cP=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;TY(this,e),n=SY(this,e),n.type="GeoJsonGeometry",n.parameters={geoJson:t,radius:r,resolution:s};var a=({Point:m,MultiPoint:v,LineString:x,MultiLineString:S,Polygon:w,MultiPolygon:R}[t.type]||function(){return[]})(t.coordinates,r),l=[],u=[],h=0;a.forEach(function(C){var E=l.length;im({indices:l,vertices:u},C),n.addGroup(E,l.length-E,h++)}),l.length&&n.setIndex(l),u.length&&n[UY]("position",new CT.Float32BufferAttribute(u,3));function m(C,E){var B=k3(C[1],C[0],E+(C[2]||0)),L=[];return[{vertices:B,indices:L}]}function v(C,E){var B={vertices:[],indices:[]};return C.map(function(L){return m(L,E)}).forEach(function(L){var O=nm(L,1),G=O[0];im(B,G)}),[B]}function x(C,E){for(var B=a6(C,s).map(function(j){var F=nm(j,3),V=F[0],Y=F[1],ee=F[2],te=ee===void 0?0:ee;return k3(Y,V,E+te)}),L=F_([B]),O=L.vertices,G=Math.round(O.length/3),q=[],z=1;z2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function BY(i,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!i.hasAttribute("position")||!i.hasAttribute("normal")||!i.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(a){if(a.normalized||a.isInterleavedBufferAttribute){const l=new Float32Array(a.count*a.itemSize);for(let u=0,h=0;u2&&(l[h++]=a.getZ(u));return l}return a.array instanceof Float32Array?a.array:new Float32Array(a.array)}const r=i.index?i.toNonIndexed():i,s=e.generateTangents(n(r.attributes.position),n(r.attributes.normal),n(r.attributes.uv));if(t)for(let a=3;a=2&&a.setY(l,i.getY(l)),n>=3&&a.setZ(l,i.getZ(l)),n>=4&&a.setW(l,i.getW(l));return a}function kY(i){const e=i.attributes,t=i.morphTargets,n=new Map;for(const r in e){const s=e[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,z_(s)),e[r]=n.get(s))}for(const r in t){const s=t[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,z_(s)),t[r]=n.get(s))}}function zY(i){let e=0;for(const n in i.attributes){const r=i.getAttribute(n);e+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const t=i.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function GY(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=i.getIndex(),r=i.getAttribute("position"),s=n?n.count:r.count;let a=0;const l=Object.keys(i.attributes),u={},h={},m=[],v=["getX","getY","getZ","getW"],x=["setX","setY","setZ","setW"];for(let B=0,L=l.length;B{const F=new z.array.constructor(z.count*z.itemSize);h[O][j]=new z.constructor(F,z.itemSize,z.normalized)}))}const S=e*.5,w=Math.log10(1/e),R=Math.pow(10,w),C=S*R;for(let B=0;Ba.materialIndex!==l.materialIndex?a.materialIndex-l.materialIndex:a.start-l.start),i.getIndex()===null){const a=i.getAttribute("position"),l=[];for(let u=0;ut&&u.add(Y)}u.normalize(),w.setXYZ(E+G,u.x,u.y,u.z)}}return m.setAttribute("normal",w),m}const yM=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:BY,computeMorphedAttributes:VY,deepCloneAttribute:IY,deinterleaveAttribute:z_,deinterleaveGeometry:kY,estimateBytesUsed:zY,interleaveAttributes:FY,mergeAttributes:RT,mergeGeometries:OY,mergeGroups:HY,mergeVertices:GY,toCreasedNormals:jY,toTrianglesDrawMode:qY},Symbol.toStringTag,{value:"Module"}));var Rt=(function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}});function G_(i){"@babel/helpers - typeof";return G_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},G_(i)}var WY=/^\s+/,$Y=/\s+$/;function yn(i,e){if(i=i||"",e=e||{},i instanceof yn)return i;if(!(this instanceof yn))return new yn(i,e);var t=XY(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}yn.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,r,s,a,l;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),n<=.03928?a=n/12.92:a=Math.pow((n+.055)/1.055,2.4),r<=.03928?l=r/12.92:l=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*a+.0722*l},setAlpha:function(e){return this._a=hP(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=u6(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=u6(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=l6(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=l6(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return c6(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return ZY(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Sr(this._r,255)*100)+"%",g:Math.round(Sr(this._g,255)*100)+"%",b:Math.round(Sr(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Sr(this._r,255)*100)+"%, "+Math.round(Sr(this._g,255)*100)+"%, "+Math.round(Sr(this._b,255)*100)+"%)":"rgba("+Math.round(Sr(this._r,255)*100)+"%, "+Math.round(Sr(this._g,255)*100)+"%, "+Math.round(Sr(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:cQ[c6(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+h6(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=yn(e);n="#"+h6(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return yn(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(nQ,arguments)},brighten:function(){return this._applyModification(iQ,arguments)},darken:function(){return this._applyModification(rQ,arguments)},desaturate:function(){return this._applyModification(JY,arguments)},saturate:function(){return this._applyModification(eQ,arguments)},greyscale:function(){return this._applyModification(tQ,arguments)},spin:function(){return this._applyModification(sQ,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(lQ,arguments)},complement:function(){return this._applyCombination(aQ,arguments)},monochromatic:function(){return this._applyCombination(uQ,arguments)},splitcomplement:function(){return this._applyCombination(oQ,arguments)},triad:function(){return this._applyCombination(f6,[3])},tetrad:function(){return this._applyCombination(f6,[4])}};yn.fromRatio=function(i,e){if(G_(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=Tm(i[n]));i=t}return yn(i,e)};function XY(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,s=null,a=!1,l=!1;return typeof i=="string"&&(i=dQ(i)),G_(i)=="object"&&(gc(i.r)&&gc(i.g)&&gc(i.b)?(e=YY(i.r,i.g,i.b),a=!0,l=String(i.r).substr(-1)==="%"?"prgb":"rgb"):gc(i.h)&&gc(i.s)&&gc(i.v)?(n=Tm(i.s),r=Tm(i.v),e=KY(i.h,n,r),a=!0,l="hsv"):gc(i.h)&&gc(i.s)&&gc(i.l)&&(n=Tm(i.s),s=Tm(i.l),e=QY(i.h,n,s),a=!0,l="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=hP(t),{ok:a,format:i.format||l,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function YY(i,e,t){return{r:Sr(i,255)*255,g:Sr(e,255)*255,b:Sr(t,255)*255}}function l6(i,e,t){i=Sr(i,255),e=Sr(e,255),t=Sr(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=(n+r)/2;if(n==r)s=a=0;else{var u=n-r;switch(a=l>.5?u/(2-n-r):u/(n+r),n){case i:s=(e-t)/u+(e1&&(v-=1),v<1/6?h+(m-h)*6*v:v<1/2?m:v<2/3?h+(m-h)*(2/3-v)*6:h}if(e===0)n=r=s=t;else{var l=t<.5?t*(1+e):t+e-t*e,u=2*t-l;n=a(u,l,i+1/3),r=a(u,l,i),s=a(u,l,i-1/3)}return{r:n*255,g:r*255,b:s*255}}function u6(i,e,t){i=Sr(i,255),e=Sr(e,255),t=Sr(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=n,u=n-r;if(a=n===0?0:u/n,n==r)s=0;else{switch(n){case i:s=(e-t)/u+(e>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(yn(n));return s}function uQ(i,e){e=e||6;for(var t=yn(i).toHsv(),n=t.h,r=t.s,s=t.v,a=[],l=1/e;e--;)a.push(yn({h:n,s:r,v:s})),s=(s+l)%1;return a}yn.mix=function(i,e,t){t=t===0?0:t||50;var n=yn(i).toRgb(),r=yn(e).toRgb(),s=t/100,a={r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a};return yn(a)};yn.readability=function(i,e){var t=yn(i),n=yn(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)};yn.isReadable=function(i,e,t){var n=yn.readability(i,e),r,s;switch(s=!1,r=pQ(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=n>=4.5;break;case"AAlarge":s=n>=3;break;case"AAAsmall":s=n>=7;break}return s};yn.mostReadable=function(i,e,t){var n=null,r=0,s,a,l,u;t=t||{},a=t.includeFallbackColors,l=t.level,u=t.size;for(var h=0;hr&&(r=s,n=yn(e[h]));return yn.isReadable(i,n,{level:l,size:u})||!a?n:(t.includeFallbackColors=!1,yn.mostReadable(i,["#fff","#000"],t))};var NT=yn.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},cQ=yn.hexNames=hQ(NT);function hQ(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function hP(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function Sr(i,e){fQ(i)&&(i="100%");var t=AQ(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function Cy(i){return Math.min(1,Math.max(0,i))}function _o(i){return parseInt(i,16)}function fQ(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function AQ(i){return typeof i=="string"&&i.indexOf("%")!=-1}function El(i){return i.length==1?"0"+i:""+i}function Tm(i){return i<=1&&(i=i*100+"%"),i}function fP(i){return Math.round(parseFloat(i)*255).toString(16)}function A6(i){return _o(i)/255}var bl=(function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function gc(i){return!!bl.CSS_UNIT.exec(i)}function dQ(i){i=i.replace(WY,"").replace($Y,"").toLowerCase();var e=!1;if(NT[i])i=NT[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=bl.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=bl.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=bl.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=bl.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=bl.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=bl.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=bl.hex8.exec(i))?{r:_o(t[1]),g:_o(t[2]),b:_o(t[3]),a:A6(t[4]),format:e?"name":"hex8"}:(t=bl.hex6.exec(i))?{r:_o(t[1]),g:_o(t[2]),b:_o(t[3]),format:e?"name":"hex"}:(t=bl.hex4.exec(i))?{r:_o(t[1]+""+t[1]),g:_o(t[2]+""+t[2]),b:_o(t[3]+""+t[3]),a:A6(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=bl.hex3.exec(i))?{r:_o(t[1]+""+t[1]),g:_o(t[2]+""+t[2]),b:_o(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function pQ(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function DT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},l.prototype.update=function(u,h){h===void 0&&(h=!0),this._currentTick++,this._currentTime+=u,this._tickDeltaTime=u,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),h&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},l.prototype.getTimer=function(){return Date.now()},l})();Object.defineProperty(n,"__esModule",{value:!0}),n.default=a},function(t,n,r){(function(s,a){t.exports=a()})(this,function(){return(function(s){function a(u){if(l[u])return l[u].exports;var h=l[u]={exports:{},id:u,loaded:!1};return s[u].call(h.exports,h,h.exports,a),h.loaded=!0,h.exports}var l={};return a.m=s,a.c=l,a.p="",a(0)})([function(s,a){var l=(function(){function u(){this.functions=[]}return u.prototype.add=function(h){return this.functions.indexOf(h)===-1&&(this.functions.push(h),!0)},u.prototype.remove=function(h){var m=this.functions.indexOf(h);return m>-1&&(this.functions.splice(m,1),!0)},u.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},u.prototype.dispatch=function(){for(var h=[],m=0;mh==m>-h?(s=h,h=e[++v]):(s=m,m=n[++x]);let S=0;if(vh==m>-h?(a=h+s,l=s-(a-h),h=e[++v]):(a=m+s,l=s-(a-m),m=n[++x]),s=a,l!==0&&(r[S++]=l);vh==m>-h?(a=s+h,u=a-s,l=s-(a-u)+(h-u),h=e[++v]):(a=s+m,u=a-s,l=s-(a-u)+(m-u),m=n[++x]),s=a,l!==0&&(r[S++]=l);for(;v=re||-te>=re||(v=i-F,l=i-(F+v)+(v-r),v=t-V,h=t-(V+v)+(v-r),v=e-Y,u=e-(Y+v)+(v-s),v=n-ee,m=n-(ee+v)+(v-s),l===0&&u===0&&h===0&&m===0)||(re=FQ*a+UQ*Math.abs(te),te+=F*m+ee*l-(Y*h+V*u),te>=re||-te>=re))return te;O=l*ee,x=na*l,S=x-(x-l),w=l-S,x=na*ee,R=x-(x-ee),C=ee-R,G=w*C-(O-S*R-w*R-S*C),q=u*V,x=na*u,S=x-(x-u),w=u-S,x=na*V,R=x-(x-V),C=V-R,z=w*C-(q-S*R-w*R-S*C),E=G-z,v=G-E,va[0]=G-(E+v)+(v-z),B=O+E,v=B-O,L=O-(B-v)+(E-v),E=L-q,v=L-E,va[1]=L-(E+v)+(v-q),j=B+E,v=j-B,va[2]=B-(j-v)+(E-v),va[3]=j;const ne=V3(4,Td,4,va,p6);O=F*m,x=na*F,S=x-(x-F),w=F-S,x=na*m,R=x-(x-m),C=m-R,G=w*C-(O-S*R-w*R-S*C),q=Y*h,x=na*Y,S=x-(x-Y),w=Y-S,x=na*h,R=x-(x-h),C=h-R,z=w*C-(q-S*R-w*R-S*C),E=G-z,v=G-E,va[0]=G-(E+v)+(v-z),B=O+E,v=B-O,L=O-(B-v)+(E-v),E=L-q,v=L-E,va[1]=L-(E+v)+(v-q),j=B+E,v=j-B,va[2]=B-(j-v)+(E-v),va[3]=j;const Q=V3(ne,p6,4,va,m6);O=l*m,x=na*l,S=x-(x-l),w=l-S,x=na*m,R=x-(x-m),C=m-R,G=w*C-(O-S*R-w*R-S*C),q=u*h,x=na*u,S=x-(x-u),w=u-S,x=na*h,R=x-(x-h),C=h-R,z=w*C-(q-S*R-w*R-S*C),E=G-z,v=G-E,va[0]=G-(E+v)+(v-z),B=O+E,v=B-O,L=O-(B-v)+(E-v),E=L-q,v=L-E,va[1]=L-(E+v)+(v-q),j=B+E,v=j-B,va[2]=B-(j-v)+(E-v),va[3]=j;const ae=V3(Q,m6,4,va,g6);return g6[ae-1]}function wm(i,e,t,n,r,s){const a=(e-s)*(t-r),l=(i-r)*(n-s),u=a-l,h=Math.abs(a+l);return Math.abs(u)>=OQ*h?u:-kQ(i,e,t,n,r,s,h)}const v6=Math.pow(2,-52),ov=new Uint32Array(512);class gg{static from(e,t=HQ,n=jQ){const r=e.length,s=new Float64Array(r*2);for(let a=0;a>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:s}=this,a=e.length>>1;let l=1/0,u=1/0,h=-1/0,m=-1/0;for(let F=0;Fh&&(h=V),Y>m&&(m=Y),this._ids[F]=F}const v=(l+h)/2,x=(u+m)/2;let S,w,R;for(let F=0,V=1/0;F0&&(w=F,V=Y)}let B=e[2*w],L=e[2*w+1],O=1/0;for(let F=0;Fee&&(F[V++]=te,ee=re)}this.hull=F.subarray(0,V),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(wm(C,E,B,L,G,q)<0){const F=w,V=B,Y=L;w=R,B=G,L=q,R=F,G=V,q=Y}const z=VQ(C,E,B,L,G,q);this._cx=z.x,this._cy=z.y;for(let F=0;F0&&Math.abs(te-V)<=v6&&Math.abs(re-Y)<=v6||(V=te,Y=re,ee===S||ee===w||ee===R))continue;let ne=0;for(let be=0,ue=this._hashKey(te,re);be=0;)if(Q=ae,Q===ne){Q=-1;break}if(Q===-1)continue;let de=this._addTriangle(Q,ee,n[Q],-1,-1,r[Q]);r[ee]=this._legalize(de+2),r[Q]=de,j++;let Te=n[Q];for(;ae=n[Te],wm(te,re,e[2*Te],e[2*Te+1],e[2*ae],e[2*ae+1])<0;)de=this._addTriangle(Te,ee,ae,r[ee],-1,r[Te]),r[ee]=this._legalize(de+2),n[Te]=Te,j--,Te=ae;if(Q===ne)for(;ae=t[Q],wm(te,re,e[2*ae],e[2*ae+1],e[2*Q],e[2*Q+1])<0;)de=this._addTriangle(ae,ee,Q,-1,r[Q],r[ae]),this._legalize(de+2),r[ae]=de,n[Q]=Q,j--,Q=ae;this._hullStart=t[ee]=Q,n[Q]=t[Te]=ee,n[ee]=Te,s[this._hashKey(te,re)]=ee,s[this._hashKey(e[2*Q],e[2*Q+1])]=Q}this.hull=new Uint32Array(j);for(let F=0,V=this._hullStart;F0?3-t:1+t)/4}function H3(i,e,t,n){const r=i-t,s=e-n;return r*r+s*s}function GQ(i,e,t,n,r,s,a,l){const u=i-a,h=e-l,m=t-a,v=n-l,x=r-a,S=s-l,w=u*u+h*h,R=m*m+v*v,C=x*x+S*S;return u*(v*C-R*S)-h*(m*C-R*x)+w*(m*S-v*x)<0}function qQ(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=(h*m-l*v)*x,w=(a*v-u*m)*x;return S*S+w*w}function VQ(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=i+(h*m-l*v)*x,w=e+(a*v-u*m)*x;return{x:S,y:w}}function $d(i,e,t,n){if(n-t<=20)for(let r=t+1;r<=n;r++){const s=i[r],a=e[s];let l=r-1;for(;l>=t&&e[i[l]]>a;)i[l+1]=i[l--];i[l+1]=s}else{const r=t+n>>1;let s=t+1,a=n;sm(i,r,s),e[i[t]]>e[i[n]]&&sm(i,t,n),e[i[s]]>e[i[n]]&&sm(i,s,n),e[i[t]]>e[i[s]]&&sm(i,t,s);const l=i[s],u=e[l];for(;;){do s++;while(e[i[s]]u);if(a=a-t?($d(i,e,s,n),$d(i,e,t,a-1)):($d(i,e,t,a-1),$d(i,e,s,n))}}function sm(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function HQ(i){return i[0]}function jQ(i){return i[1]}function WQ(i,e){var t,n,r=0,s,a,l,u,h,m,v,x=i[0],S=i[1],w=e.length;for(t=0;t=0||a<=0&&u>=0)return 0}else if(h>=0&&l<=0||h<=0&&l>=0){if(s=wm(a,u,l,h,0,0),s===0)return 0;(s>0&&h>0&&l<=0||s<0&&h<=0&&l>0)&&r++}m=v,l=h,a=u}}return r%2!==0}function $Q(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return[...i.geometry.coordinates];if(i.type==="Point")return[...i.coordinates]}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return[...i];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function XQ(i){return i.type==="Feature"?i.geometry:i}function YQ(i,e,t={}){if(!i)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=$Q(i),r=XQ(e),s=r.type,a=e.bbox;let l=r.coordinates;if(a&&QQ(n,a)===!1)return!1;s==="Polygon"&&(l=[l]);let u=!1;for(var h=0;h=i[0]&&e[3]>=i[1]}var KQ=YQ;const _6=1e-6;class $f{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const r=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${r},${s}`:(Math.abs(this._x1-r)>_6||Math.abs(this._y1-s)>_6)&&(this._+="L"+r+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=s}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class PT{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class ZQ{constructor(e,[t,n,r,s]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this;let s,a;const l=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let R=0,C=0,E=n.length,B,L;R1;)s-=2;for(let a=2;a0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function iK(i,e,t){return[i+Math.sin(i+e)*t,e+Math.cos(i-e)*t]}class xM{static from(e,t=eK,n=tK,r){return new xM("length"in e?rK(e,t,n,r):Float64Array.from(sK(e,t,n,r)))}constructor(e){this._delaunator=new gg(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&nK(e)){this.collinear=Int32Array.from({length:t.length/2},(x,S)=>S).sort((x,S)=>t[2*x]-t[2*S]||t[2*x+1]-t[2*S+1]);const u=this.collinear[0],h=this.collinear[this.collinear.length-1],m=[t[2*u],t[2*u+1],t[2*h],t[2*h+1]],v=1e-8*Math.hypot(m[3]-m[1],m[2]-m[0]);for(let x=0,S=t.length/2;x0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new ZQ(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:s,triangles:a,collinear:l}=this;if(l){const v=l.indexOf(e);v>0&&(yield l[v-1]),v=0&&s!==n&&s!==r;)n=s;return s}_step(e,t,n){const{inedges:r,hull:s,_hullIndex:a,halfedges:l,triangles:u,points:h}=this;if(r[e]===-1||!h.length)return(e+1)%(h.length>>1);let m=e,v=wd(t-h[e*2],2)+wd(n-h[e*2+1],2);const x=r[e];let S=x;do{let w=u[S];const R=wd(t-h[w*2],2)+wd(n-h[w*2+1],2);if(R0?1:i<0?-1:0},pP=Math.sqrt;function cK(i){return i>1?y6:i<-1?-y6:Math.asin(i)}function mP(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function So(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function q_(i,e){return[i[0]+e[0],i[1]+e[1],i[2]+e[2]]}function V_(i){var e=pP(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);return[i[0]/e,i[1]/e,i[2]/e]}function SM(i){return[aK(i[1],i[0])*x6,cK(oK(-1,lK(1,i[2])))*x6]}function uu(i){const e=i[0]*b6,t=i[1]*b6,n=S6(t);return[n*S6(e),n*T6(e),T6(t)]}function TM(i){return i=i.map(e=>uu(e)),mP(i[0],So(i[2],i[1]))}function hK(i){const e=AK(i),t=pK(e),n=dK(t,i),r=gK(t,i.length),s=fK(r,i),a=mK(t,i),{polygons:l,centers:u}=vK(a,t,i),h=_K(l),m=xK(t,i),v=yK(n,t);return{delaunay:e,edges:n,triangles:t,centers:u,neighbors:r,polygons:l,mesh:h,hull:m,urquhart:v,find:s}}function fK(i,e){function t(n,r){let s=n[0]-r[0],a=n[1]-r[1],l=n[2]-r[2];return s*s+a*a+l*l}return function(r,s,a){a===void 0&&(a=0);let l,u,h=a;const m=uu([r,s]);do l=a,a=null,u=t(m,uu(e[l])),i[l].forEach(v=>{let x=t(m,uu(e[v]));if(x1e32?r.push(v):S>s&&(s=S)}const a=1e6*pP(s);r.forEach(v=>i[v]=[a,0]),i.push([0,a]),i.push([-a,0]),i.push([0,-a]);const l=xM.from(i);l.projection=n;const{triangles:u,halfedges:h,inedges:m}=l;for(let v=0,x=h.length;vi.length-3-1&&(u[v]=e);return l}function dK(i,e){const t=new Set;return e.length===2?[[0,1]]:(i.forEach(n=>{if(n[0]!==n[1]&&!(TM(n.map(r=>e[r]))<0))for(let r=0,s;r<3;r++)s=(r+1)%3,t.add(A_([n[r],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function pK(i){const{triangles:e}=i;if(!e)return[];const t=[];for(let n=0,r=e.length/3;n{const n=t.map(s=>e[s]).map(uu),r=q_(q_(So(n[1],n[0]),So(n[2],n[1])),So(n[0],n[2]));return SM(V_(r))})}function gK(i,e){const t=[];return i.forEach(n=>{for(let r=0;r<3;r++){const s=n[r],a=n[(r+1)%3];t[s]=t[s]||[],t[s].push(a)}}),i.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function vK(i,e,t){const n=[],r=i.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:r};if(t.length===2){const l=uu(t[0]),u=uu(t[1]),h=V_(q_(l,u)),m=V_(So(l,u)),v=So(h,m),x=[h,So(h,v),So(So(h,v),v),So(So(So(h,v),v),v)].map(SM).map(a);return n.push(x),n.push(x.slice().reverse()),{polygons:n,centers:r}}}e.forEach((l,u)=>{for(let h=0;h<3;h++){const m=l[h],v=l[(h+1)%3],x=l[(h+2)%3];n[m]=n[m]||[],n[m].push([v,x,u,[m,v,x]])}});const s=n.map(l=>{const u=[l[0][2]];let h=l[0][1];for(let m=1;m2)return u;if(u.length==2){const m=w6(t[l[0][3][0]],t[l[0][3][1]],r[u[0]]),v=w6(t[l[0][3][2]],t[l[0][3][0]],r[u[0]]),x=a(m),S=a(v);return[u[0],S,u[1],x]}});function a(l){let u=-1;return r.slice(e.length,1/0).forEach((h,m)=>{h[0]===l[0]&&h[1]===l[1]&&(u=m+e.length)}),u<0&&(u=r.length,r.push(l)),u}return{polygons:s,centers:r}}function w6(i,e,t){i=uu(i),e=uu(e),t=uu(t);const n=uK(mP(So(e,i),t));return SM(V_(q_(i,e)).map(r=>n*r))}function _K(i){const e=[];return i.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let r of t)r>n&&e.push([n,r]),n=r}),e}function yK(i,e){return function(t){const n=new Map,r=new Map;return i.forEach((s,a)=>{const l=s.join("-");n.set(l,t[a]),r.set(l,!0)}),e.forEach(s=>{let a=0,l=-1;for(let u=0;u<3;u++){let h=A_([s[u],s[(u+1)%3]]).join("-");n.get(h)>a&&(a=n.get(h),l=h)}r.set(l,!1)}),i.map(s=>r.get(s.join("-")))}}function xK(i,e){const t=new Set,n=[];i.map(l=>{if(!(TM(l.map(u=>e[u>e.length?0:u]))>1e-12))for(let u=0;u<3;u++){let h=[l[u],l[(u+1)%3]],m=`${h[0]}-${h[1]}`;t.has(m)?t.delete(m):t.add(`${h[1]}-${h[0]}`)}});const r=new Map;let s;if(t.forEach(l=>{l=l.split("-").map(Number),r.set(l[0],l[1]),s=l[0]}),s===void 0)return n;let a=s;do{n.push(a);let l=r.get(a);r.set(a,-1),a=l}while(a>-1&&a!==s);return n}function bK(i){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(r=>[e._vx(r),e._vy(r),r]).filter(r=>isFinite(r[0]+r[1]));e.points=n.map(r=>[r[0],r[1]]),e.valid=n.map(r=>r[2]),e.delaunay=hK(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return OR(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return OR(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((r,s)=>n.features.push({type:"Feature",geometry:r?{type:"Polygon",coordinates:[[...r,r[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,r)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[r],n)).filter(n=>TM(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>Vh(e.points[s[0]],e.points[s[1]])),r=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[a],urquhart:!!r[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:r}=e.delaunay,s=[];for(const a of r)if(a)for(let l=a.length,u=a[l-1],h=a[0],m=0;mu&&s.push([n[u],n[h]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,r){if(e._found=e.delaunay.find(t,n,e._found),!r||Vh([t,n],e.points[e._found])r[s]),r[n[0]]]]}},i?e(i):e}function LT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,n=t===void 0?1/0:t,r=OK(i,n),s=ug(r),a=IK(i,n),l=[].concat(j3(s),j3(a)),u={type:"Polygon",coordinates:i},h=FD(u),m=Kl(h,2),v=Kl(m[0],2),x=v[0],S=v[1],w=Kl(m[1],2),R=w[0],C=w[1],E=x>R||C>=89||S<=-89,B=[];if(E){var L=bK(l).triangles(),O=new Map(l.map(function(ae,de){var Te=Kl(ae,2),be=Te[0],ue=Te[1];return["".concat(be,"-").concat(ue),de]}));L.features.forEach(function(ae){var de,Te=ae.geometry.coordinates[0].slice(0,3).reverse(),be=[];if(Te.forEach(function(we){var We=Kl(we,2),Ne=We[0],ze=We[1],Se="".concat(Ne,"-").concat(ze);O.has(Se)&&be.push(O.get(Se))}),be.length===3){if(be.some(function(we){return wee)for(var l=pM(r,s),u=1/Math.ceil(a/e),h=u;h<1;)n.push(l(h)),h+=u}n.push(r=s)}),n})}function IK(i,e){var t={type:"Polygon",coordinates:i},n=FD(t),r=Kl(n,2),s=Kl(r[0],2),a=s[0],l=s[1],u=Kl(r[1],2),h=u[0],m=u[1];if(Math.min(Math.abs(h-a),Math.abs(m-l))h||m>=89||l<=-89;return FK(e,{minLng:a,maxLng:h,minLat:l,maxLat:m}).filter(function(x){return BT(x,t,v)})}function FK(i){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,n=e.maxLng,r=e.minLat,s=e.maxLat,a=Math.round(Math.pow(360/i,2)/Math.PI),l=(1+Math.sqrt(5))/2,u=function(E){return E/l*360%360-180},h=function(E){return Math.acos(2*E/a-1)/Math.PI*180-90},m=function(E){return a*(Math.cos((E+90)*Math.PI/180)+1)/2},v=[s!==void 0?Math.ceil(m(s)):0,r!==void 0?Math.floor(m(r)):a-1],x=t===void 0&&n===void 0?function(){return!0}:t===void 0?function(C){return C<=n}:n===void 0?function(C){return C>=t}:n>=t?function(C){return C>=t&&C<=n}:function(C){return C>=t||C<=n},S=[],w=v[0];w<=v[1];w++){var R=u(w);x(R)&&S.push([R,h(w)])}return S}function BT(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?gX(e,i):KQ(i,e)}var Yv=window.THREE?window.THREE:{BufferGeometry:Ki,Float32BufferAttribute:Mi},M6=new Yv.BufferGeometry().setAttribute?"setAttribute":"addAttribute",wM=(function(i){function e(t,n,r,s,a,l,u){var h;EK(this,e),h=MK(this,e),h.type="ConicPolygonGeometry",h.parameters={polygonGeoJson:t,bottomHeight:n,topHeight:r,closedBottom:s,closedTop:a,includeSides:l,curvatureResolution:u},n=n||0,r=r||1,s=s!==void 0?s:!0,a=a!==void 0?a:!0,l=l!==void 0?l:!0,u=u||5;var m=BK(t,{resolution:u}),v=m.contour,x=m.triangles,S=ug(x.uvs),w=[],R=[],C=[],E=0,B=function(z){var j=Math.round(w.length/3),F=C.length;w=w.concat(z.vertices),R=R.concat(z.uvs),C=C.concat(j?z.indices.map(function(V){return V+j}):z.indices),h.addGroup(F,C.length-F,E++)};l&&B(O()),s&&B(G(n,!1)),a&&B(G(r,!0)),h.setIndex(C),h[M6]("position",new Yv.Float32BufferAttribute(w,3)),h[M6]("uv",new Yv.Float32BufferAttribute(R,2)),h.computeVertexNormals();function L(q,z){var j=typeof z=="function"?z:function(){return z},F=q.map(function(V){return V.map(function(Y){var ee=Kl(Y,2),te=ee[0],re=ee[1];return kK(re,te,j(te,re))})});return F_(F)}function O(){for(var q=L(v,n),z=q.vertices,j=q.holes,F=L(v,r),V=F.vertices,Y=ug([V,z]),ee=Math.round(V.length/3),te=new Set(j),re=0,ne=[],Q=0;Q=0;be--)for(var ue=0;ue1&&arguments[1]!==void 0?arguments[1]:!0;return{indices:z?x.indices:x.indices.slice().reverse(),vertices:L([x.points],q).vertices,uvs:S}}return h}return RK(e,i),CK(e)})(Yv.BufferGeometry);function kK(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function OT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(l){return{keyAccessor:l,isProp:!(l instanceof Function)}}),s=i.reduce(function(l,u){var h=l,m=u;return r.forEach(function(v,x){var S=v.keyAccessor,w=v.isProp,R;if(w){var C=m,E=C[S],B=WK(C,[S].map(KK));R=E,m=B}else R=S(m,x);x+11&&arguments[1]!==void 0?arguments[1]:1;h===r.length?Object.keys(u).forEach(function(m){return u[m]=t(u[m])}):Object.values(u).forEach(function(m){return l(m,h+1)})})(s);var a=s;return n&&(a=[],(function l(u){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];h.length===r.length?a.push({keys:h,vals:u}):Object.entries(u).forEach(function(m){var v=XK(m,2),x=v[0],S=v[1];return l(S,[].concat(YK(h),[x]))})})(s),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a}),Ti=(function(i){i=i||{};var e=typeof i<"u"?i:{},t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r="";function s(Ze){return e.locateFile?e.locateFile(Ze,r):r+Ze}var a;typeof document<"u"&&document.currentScript&&(r=document.currentScript.src),r.indexOf("blob:")!==0?r=r.substr(0,r.lastIndexOf("/")+1):r="",a=function(vt,zt,at){var d=new XMLHttpRequest;d.open("GET",vt,!0),d.responseType="arraybuffer",d.onload=function(){if(d.status==200||d.status==0&&d.response){zt(d.response);return}var $n=Vt(vt);if($n){zt($n.buffer);return}at()},d.onerror=at,d.send(null)};var l=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&e.arguments;var h=0,m=function(Ze){h=Ze},v=function(){return h},x=8;function S(Ze,vt,zt,at){switch(zt=zt||"i8",zt.charAt(zt.length-1)==="*"&&(zt="i32"),zt){case"i1":ee[Ze>>0]=vt;break;case"i8":ee[Ze>>0]=vt;break;case"i16":re[Ze>>1]=vt;break;case"i32":ne[Ze>>2]=vt;break;case"i64":pe=[vt>>>0,(Re=vt,+rt(Re)>=1?Re>0?(ht(+Gt(Re/4294967296),4294967295)|0)>>>0:~~+ce((Re-+(~~Re>>>0))/4294967296)>>>0:0)],ne[Ze>>2]=pe[0],ne[Ze+4>>2]=pe[1];break;case"float":Q[Ze>>2]=vt;break;case"double":ae[Ze>>3]=vt;break;default:Jr("invalid type for setValue: "+zt)}}function w(Ze,vt,zt){switch(vt=vt||"i8",vt.charAt(vt.length-1)==="*"&&(vt="i32"),vt){case"i1":return ee[Ze>>0];case"i8":return ee[Ze>>0];case"i16":return re[Ze>>1];case"i32":return ne[Ze>>2];case"i64":return ne[Ze>>2];case"float":return Q[Ze>>2];case"double":return ae[Ze>>3];default:Jr("invalid type for getValue: "+vt)}return null}var R=!1;function C(Ze,vt){Ze||Jr("Assertion failed: "+vt)}function E(Ze){var vt=e["_"+Ze];return C(vt,"Cannot call unknown function "+Ze+", make sure it is exported"),vt}function B(Ze,vt,zt,at,d){var J={string:function(Fn){var cs=0;if(Fn!=null&&Fn!==0){var Ma=(Fn.length<<2)+1;cs=tt(Ma),j(Fn,cs,Ma)}return cs},array:function(Fn){var cs=tt(Fn.length);return F(Fn,cs),cs}};function $n(Fn){return vt==="string"?q(Fn):vt==="boolean"?!!Fn:Fn}var Gn=E(Ze),Xn=[],un=0;if(at)for(var qn=0;qn=at);)++d;if(d-vt>16&&Ze.subarray&&O)return O.decode(Ze.subarray(vt,d));for(var J="";vt>10,56320|un&1023)}}return J}function q(Ze,vt){return Ze?G(te,Ze,vt):""}function z(Ze,vt,zt,at){if(!(at>0))return 0;for(var d=zt,J=zt+at-1,$n=0;$n=55296&&Gn<=57343){var Xn=Ze.charCodeAt(++$n);Gn=65536+((Gn&1023)<<10)|Xn&1023}if(Gn<=127){if(zt>=J)break;vt[zt++]=Gn}else if(Gn<=2047){if(zt+1>=J)break;vt[zt++]=192|Gn>>6,vt[zt++]=128|Gn&63}else if(Gn<=65535){if(zt+2>=J)break;vt[zt++]=224|Gn>>12,vt[zt++]=128|Gn>>6&63,vt[zt++]=128|Gn&63}else{if(zt+3>=J)break;vt[zt++]=240|Gn>>18,vt[zt++]=128|Gn>>12&63,vt[zt++]=128|Gn>>6&63,vt[zt++]=128|Gn&63}}return vt[zt]=0,zt-d}function j(Ze,vt,zt){return z(Ze,te,vt,zt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function F(Ze,vt){ee.set(Ze,vt)}function V(Ze,vt){return Ze%vt>0&&(Ze+=vt-Ze%vt),Ze}var Y,ee,te,re,ne,Q,ae;function de(Ze){Y=Ze,e.HEAP8=ee=new Int8Array(Ze),e.HEAP16=re=new Int16Array(Ze),e.HEAP32=ne=new Int32Array(Ze),e.HEAPU8=te=new Uint8Array(Ze),e.HEAPU16=new Uint16Array(Ze),e.HEAPU32=new Uint32Array(Ze),e.HEAPF32=Q=new Float32Array(Ze),e.HEAPF64=ae=new Float64Array(Ze)}var Te=5271536,be=28624,ue=e.TOTAL_MEMORY||33554432;e.buffer?Y=e.buffer:Y=new ArrayBuffer(ue),ue=Y.byteLength,de(Y),ne[be>>2]=Te;function we(Ze){for(;Ze.length>0;){var vt=Ze.shift();if(typeof vt=="function"){vt();continue}var zt=vt.func;typeof zt=="number"?vt.arg===void 0?e.dynCall_v(zt):e.dynCall_vi(zt,vt.arg):zt(vt.arg===void 0?null:vt.arg)}}var We=[],Ne=[],ze=[],Se=[];function Ce(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Ft(e.preRun.shift());we(We)}function dt(){we(Ne)}function At(){we(ze)}function wt(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)$e(e.postRun.shift());we(Se)}function Ft(Ze){We.unshift(Ze)}function $e(Ze){Se.unshift(Ze)}var rt=Math.abs,ce=Math.ceil,Gt=Math.floor,ht=Math.min,Pt=0,yt=null;function en(Ze){Pt++,e.monitorRunDependencies&&e.monitorRunDependencies(Pt)}function xt(Ze){if(Pt--,e.monitorRunDependencies&&e.monitorRunDependencies(Pt),Pt==0&&yt){var vt=yt;yt=null,vt()}}e.preloadedImages={},e.preloadedAudios={};var fe=null,X="data:application/octet-stream;base64,";function le(Ze){return String.prototype.startsWith?Ze.startsWith(X):Ze.indexOf(X)===0}var Re,pe;fe="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var Me=28640;function nt(Ze,vt,zt,at){Jr("Assertion failed: "+q(Ze)+", at: "+[vt?q(vt):"unknown filename",zt,at?q(at):"unknown function"])}function lt(){return ee.length}function Ot(Ze,vt,zt){te.set(te.subarray(vt,vt+zt),Ze)}function jt(Ze){return e.___errno_location&&(ne[e.___errno_location()>>2]=Ze),Ze}function pt(Ze){Jr("OOM")}function Yt(Ze){try{var vt=new ArrayBuffer(Ze);return vt.byteLength!=Ze?void 0:(new Int8Array(vt).set(ee),bt(vt),de(vt),1)}catch{}}function rn(Ze){var vt=lt(),zt=16777216,at=2147483648-zt;if(Ze>at)return!1;for(var d=16777216,J=Math.max(vt,d);J>4,d=(Gn&15)<<4|Xn>>2,J=(Xn&3)<<6|un,zt=zt+String.fromCharCode(at),Xn!==64&&(zt=zt+String.fromCharCode(d)),un!==64&&(zt=zt+String.fromCharCode(J));while(qn13780509?(f=Hu(15,f)|0,f|0):(p=((A|0)<0)<<31>>31,y=fr(A|0,p|0,3,0)|0,_=Z()|0,p=Qt(A|0,p|0,1,0)|0,p=fr(y|0,_|0,p|0,Z()|0)|0,p=Qt(p|0,Z()|0,1,0)|0,A=Z()|0,d[f>>2]=p,d[f+4>>2]=A,f=0,f|0)}function ye(A,f,p,_){return A=A|0,f=f|0,p=p|0,_=_|0,ot(A,f,p,_,0)|0}function ot(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0;if(U=K,K=K+16|0,M=U,!(Nt(A,f,p,_,y)|0))return _=0,K=U,_|0;do if((p|0)>=0){if((p|0)>13780509){if(T=Hu(15,M)|0,T|0)break;N=M,M=d[N>>2]|0,N=d[N+4>>2]|0}else T=((p|0)<0)<<31>>31,I=fr(p|0,T|0,3,0)|0,N=Z()|0,T=Qt(p|0,T|0,1,0)|0,T=fr(I|0,N|0,T|0,Z()|0)|0,T=Qt(T|0,Z()|0,1,0)|0,N=Z()|0,d[M>>2]=T,d[M+4>>2]=N,M=T;if(uo(_|0,0,M<<3|0)|0,y|0){uo(y|0,0,M<<2|0)|0,T=Jt(A,f,p,_,y,M,N,0)|0;break}T=Ks(M,4)|0,T?(I=Jt(A,f,p,_,T,M,N,0)|0,An(T),T=I):T=13}else T=2;while(!1);return I=T,K=U,I|0}function Nt(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0;if(Pe=K,K=K+16|0,Ae=Pe,ve=Pe+8|0,ge=Ae,d[ge>>2]=A,d[ge+4>>2]=f,(p|0)<0)return ve=2,K=Pe,ve|0;if(T=_,d[T>>2]=A,d[T+4>>2]=f,T=(y|0)!=0,T&&(d[y>>2]=0),Ci(A,f)|0)return ve=9,K=Pe,ve|0;d[ve>>2]=0;e:do if((p|0)>=1)if(T)for(H=1,I=0,ie=0,ge=1,T=A;;){if(!(I|ie)){if(T=cn(T,f,4,ve,Ae)|0,T|0)break e;if(f=Ae,T=d[f>>2]|0,f=d[f+4>>2]|0,Ci(T,f)|0){T=9;break e}}if(T=cn(T,f,d[26800+(ie<<2)>>2]|0,ve,Ae)|0,T|0)break e;if(f=Ae,T=d[f>>2]|0,f=d[f+4>>2]|0,A=_+(H<<3)|0,d[A>>2]=T,d[A+4>>2]=f,d[y+(H<<2)>>2]=ge,A=I+1|0,M=(A|0)==(ge|0),N=ie+1|0,U=(N|0)==6,Ci(T,f)|0){T=9;break e}if(ge=ge+(U&M&1)|0,(ge|0)>(p|0)){T=0;break}else H=H+1|0,I=M?0:A,ie=M?U?0:N:ie}else for(H=1,I=0,ie=0,ge=1,T=A;;){if(!(I|ie)){if(T=cn(T,f,4,ve,Ae)|0,T|0)break e;if(f=Ae,T=d[f>>2]|0,f=d[f+4>>2]|0,Ci(T,f)|0){T=9;break e}}if(T=cn(T,f,d[26800+(ie<<2)>>2]|0,ve,Ae)|0,T|0)break e;if(f=Ae,T=d[f>>2]|0,f=d[f+4>>2]|0,A=_+(H<<3)|0,d[A>>2]=T,d[A+4>>2]=f,A=I+1|0,M=(A|0)==(ge|0),N=ie+1|0,U=(N|0)==6,Ci(T,f)|0){T=9;break e}if(ge=ge+(U&M&1)|0,(ge|0)>(p|0)){T=0;break}else H=H+1|0,I=M?0:A,ie=M?U?0:N:ie}else T=0;while(!1);return ve=T,K=Pe,ve|0}function Jt(A,f,p,_,y,T,M,N){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0,N=N|0;var U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0;if(Pe=K,K=K+16|0,Ae=Pe+8|0,ve=Pe,U=ec(A|0,f|0,T|0,M|0)|0,H=Z()|0,ie=_+(U<<3)|0,Ie=ie,Ye=d[Ie>>2]|0,Ie=d[Ie+4>>2]|0,I=(Ye|0)==(A|0)&(Ie|0)==(f|0),!((Ye|0)==0&(Ie|0)==0|I))do U=Qt(U|0,H|0,1,0)|0,U=th(U|0,Z()|0,T|0,M|0)|0,H=Z()|0,ie=_+(U<<3)|0,Ye=ie,Ie=d[Ye>>2]|0,Ye=d[Ye+4>>2]|0,I=(Ie|0)==(A|0)&(Ye|0)==(f|0);while(!((Ie|0)==0&(Ye|0)==0|I));if(U=y+(U<<2)|0,I&&(d[U>>2]|0)<=(N|0)||(Ye=ie,d[Ye>>2]=A,d[Ye+4>>2]=f,d[U>>2]=N,(N|0)>=(p|0)))return Ye=0,K=Pe,Ye|0;switch(I=N+1|0,d[Ae>>2]=0,U=cn(A,f,2,Ae,ve)|0,U|0){case 9:{ge=9;break}case 0:{U=ve,U=Jt(d[U>>2]|0,d[U+4>>2]|0,p,_,y,T,M,I)|0,U||(ge=9);break}}e:do if((ge|0)==9){switch(d[Ae>>2]=0,U=cn(A,f,3,Ae,ve)|0,U|0){case 9:break;case 0:{if(U=ve,U=Jt(d[U>>2]|0,d[U+4>>2]|0,p,_,y,T,M,I)|0,U|0)break e;break}default:break e}switch(d[Ae>>2]=0,U=cn(A,f,1,Ae,ve)|0,U|0){case 9:break;case 0:{if(U=ve,U=Jt(d[U>>2]|0,d[U+4>>2]|0,p,_,y,T,M,I)|0,U|0)break e;break}default:break e}switch(d[Ae>>2]=0,U=cn(A,f,5,Ae,ve)|0,U|0){case 9:break;case 0:{if(U=ve,U=Jt(d[U>>2]|0,d[U+4>>2]|0,p,_,y,T,M,I)|0,U|0)break e;break}default:break e}switch(d[Ae>>2]=0,U=cn(A,f,4,Ae,ve)|0,U|0){case 9:break;case 0:{if(U=ve,U=Jt(d[U>>2]|0,d[U+4>>2]|0,p,_,y,T,M,I)|0,U|0)break e;break}default:break e}switch(d[Ae>>2]=0,U=cn(A,f,6,Ae,ve)|0,U|0){case 9:break;case 0:{if(U=ve,U=Jt(d[U>>2]|0,d[U+4>>2]|0,p,_,y,T,M,I)|0,U|0)break e;break}default:break e}return Ye=0,K=Pe,Ye|0}while(!1);return Ye=U,K=Pe,Ye|0}function cn(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0;if(p>>>0>6)return y=1,y|0;if(ie=(d[_>>2]|0)%6|0,d[_>>2]=ie,(ie|0)>0){T=0;do p=Uu(p)|0,T=T+1|0;while((T|0)<(d[_>>2]|0))}if(ie=Mt(A|0,f|0,45)|0,Z()|0,H=ie&127,H>>>0>121)return y=5,y|0;U=$s(A,f)|0,T=Mt(A|0,f|0,52)|0,Z()|0,T=T&15;e:do if(!T)I=8;else{for(;;){if(M=(15-T|0)*3|0,N=Mt(A|0,f|0,M|0)|0,Z()|0,N=N&7,(N|0)==7){f=5;break}if(ve=(Ss(T)|0)==0,T=T+-1|0,ge=Dt(7,0,M|0)|0,f=f&~(Z()|0),Ae=Dt(d[(ve?432:16)+(N*28|0)+(p<<2)>>2]|0,0,M|0)|0,M=Z()|0,p=d[(ve?640:224)+(N*28|0)+(p<<2)>>2]|0,A=Ae|A&~ge,f=M|f,!p){p=0;break e}if(!T){I=8;break e}}return f|0}while(!1);(I|0)==8&&(ve=d[848+(H*28|0)+(p<<2)>>2]|0,Ae=Dt(ve|0,0,45)|0,A=Ae|A,f=Z()|0|f&-1040385,p=d[4272+(H*28|0)+(p<<2)>>2]|0,(ve&127|0)==127&&(ve=Dt(d[848+(H*28|0)+20>>2]|0,0,45)|0,f=Z()|0|f&-1040385,p=d[4272+(H*28|0)+20>>2]|0,A=ku(ve|A,f)|0,f=Z()|0,d[_>>2]=(d[_>>2]|0)+1)),N=Mt(A|0,f|0,45)|0,Z()|0,N=N&127;e:do if(Bi(N)|0){t:do if(($s(A,f)|0)==1){if((H|0)!=(N|0))if(Ru(N,d[7696+(H*28|0)>>2]|0)|0){A=hp(A,f)|0,M=1,f=Z()|0;break}else Bt(27795,26864,533,26872);switch(U|0){case 3:{A=ku(A,f)|0,f=Z()|0,d[_>>2]=(d[_>>2]|0)+1,M=0;break t}case 5:{A=hp(A,f)|0,f=Z()|0,d[_>>2]=(d[_>>2]|0)+5,M=0;break t}case 0:return ve=9,ve|0;default:return ve=1,ve|0}}else M=0;while(!1);if((p|0)>0){T=0;do A=cp(A,f)|0,f=Z()|0,T=T+1|0;while((T|0)!=(p|0))}if((H|0)!=(N|0)){if(!(Wc(N)|0)){if((M|0)!=0|($s(A,f)|0)!=5)break;d[_>>2]=(d[_>>2]|0)+1;break}switch(ie&127){case 8:case 118:break e}($s(A,f)|0)!=3&&(d[_>>2]=(d[_>>2]|0)+1)}}else if((p|0)>0){T=0;do A=ku(A,f)|0,f=Z()|0,T=T+1|0;while((T|0)!=(p|0))}while(!1);return d[_>>2]=((d[_>>2]|0)+p|0)%6|0,ve=y,d[ve>>2]=A,d[ve+4>>2]=f,ve=0,ve|0}function Yn(A,f,p,_){return A=A|0,f=f|0,p=p|0,_=_|0,xi(A,f,p,_)|0?(uo(_|0,0,p*48|0)|0,_=js(A,f,p,_)|0,_|0):(_=0,_|0)}function xi(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0;if(ve=K,K=K+16|0,ge=ve,Ae=ve+8|0,ie=ge,d[ie>>2]=A,d[ie+4>>2]=f,(p|0)<0)return Ae=2,K=ve,Ae|0;if(!p)return Ae=_,d[Ae>>2]=A,d[Ae+4>>2]=f,Ae=0,K=ve,Ae|0;d[Ae>>2]=0;e:do if(Ci(A,f)|0)A=9;else{y=0,ie=A;do{if(A=cn(ie,f,4,Ae,ge)|0,A|0)break e;if(f=ge,ie=d[f>>2]|0,f=d[f+4>>2]|0,y=y+1|0,Ci(ie,f)|0){A=9;break e}}while((y|0)<(p|0));H=_,d[H>>2]=ie,d[H+4>>2]=f,H=p+-1|0,I=0,A=1;do{if(y=26800+(I<<2)|0,(I|0)==5)for(M=d[y>>2]|0,T=0,y=A;;){if(A=ge,A=cn(d[A>>2]|0,d[A+4>>2]|0,M,Ae,ge)|0,A|0)break e;if((T|0)!=(H|0))if(U=ge,N=d[U>>2]|0,U=d[U+4>>2]|0,A=_+(y<<3)|0,d[A>>2]=N,d[A+4>>2]=U,!(Ci(N,U)|0))A=y+1|0;else{A=9;break e}else A=y;if(T=T+1|0,(T|0)>=(p|0))break;y=A}else for(M=ge,U=d[y>>2]|0,N=0,y=A,T=d[M>>2]|0,M=d[M+4>>2]|0;;){if(A=cn(T,M,U,Ae,ge)|0,A|0)break e;if(M=ge,T=d[M>>2]|0,M=d[M+4>>2]|0,A=_+(y<<3)|0,d[A>>2]=T,d[A+4>>2]=M,A=y+1|0,Ci(T,M)|0){A=9;break e}if(N=N+1|0,(N|0)>=(p|0))break;y=A}I=I+1|0}while(I>>>0<6);A=ge,A=(ie|0)==(d[A>>2]|0)&&(f|0)==(d[A+4>>2]|0)?0:9}while(!1);return Ae=A,K=ve,Ae|0}function js(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0;if(ie=K,K=K+16|0,M=ie,!p)return d[_>>2]=A,d[_+4>>2]=f,_=0,K=ie,_|0;do if((p|0)>=0){if((p|0)>13780509){if(y=Hu(15,M)|0,y|0)break;T=M,y=d[T>>2]|0,T=d[T+4>>2]|0}else y=((p|0)<0)<<31>>31,H=fr(p|0,y|0,3,0)|0,T=Z()|0,y=Qt(p|0,y|0,1,0)|0,y=fr(H|0,T|0,y|0,Z()|0)|0,y=Qt(y|0,Z()|0,1,0)|0,T=Z()|0,H=M,d[H>>2]=y,d[H+4>>2]=T;if(I=Ks(y,8)|0,!I)y=13;else{if(H=Ks(y,4)|0,!H){An(I),y=13;break}if(y=Jt(A,f,p,I,H,y,T,0)|0,y|0){An(I),An(H);break}if(f=d[M>>2]|0,M=d[M+4>>2]|0,(M|0)>0|(M|0)==0&f>>>0>0){y=0,N=0,U=0;do A=I+(N<<3)|0,T=d[A>>2]|0,A=d[A+4>>2]|0,!((T|0)==0&(A|0)==0)&&(d[H+(N<<2)>>2]|0)==(p|0)&&(ge=_+(y<<3)|0,d[ge>>2]=T,d[ge+4>>2]=A,y=y+1|0),N=Qt(N|0,U|0,1,0)|0,U=Z()|0;while((U|0)<(M|0)|(U|0)==(M|0)&N>>>0>>0)}An(I),An(H),y=0}}else y=2;while(!1);return ge=y,K=ie,ge|0}function pi(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0;for(N=K,K=K+16|0,T=N,M=N+8|0,y=(Ci(A,f)|0)==0,y=y?1:2;;){if(d[M>>2]=0,I=(cn(A,f,y,M,T)|0)==0,U=T,I&((d[U>>2]|0)==(p|0)?(d[U+4>>2]|0)==(_|0):0)){A=4;break}if(y=y+1|0,y>>>0>=7){y=7,A=4;break}}return(A|0)==4?(K=N,y|0):0}function Pr(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0;if(N=K,K=K+48|0,y=N+16|0,T=N+8|0,M=N,p=Ra(p)|0,p|0)return M=p,K=N,M|0;if(I=A,U=d[I+4>>2]|0,p=T,d[p>>2]=d[I>>2],d[p+4>>2]=U,pa(T,y),p=sf(y,f,M)|0,!p){if(f=d[T>>2]|0,T=d[A+8>>2]|0,(T|0)>0){y=d[A+12>>2]|0,p=0;do f=(d[y+(p<<3)>>2]|0)+f|0,p=p+1|0;while((p|0)<(T|0))}p=M,y=d[p>>2]|0,p=d[p+4>>2]|0,T=((f|0)<0)<<31>>31,(p|0)<(T|0)|(p|0)==(T|0)&y>>>0>>0?(p=M,d[p>>2]=f,d[p+4>>2]=T,p=T):f=y,U=Qt(f|0,p|0,12,0)|0,I=Z()|0,p=M,d[p>>2]=U,d[p+4>>2]=I,p=_,d[p>>2]=U,d[p+4>>2]=I,p=0}return I=p,K=N,I|0}function Ei(A,f,p,_,y,T,M){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0;var N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0,Bn=0,En=0,Qn=0,Tn=0,on=0,Ut=0,vn=0,ii=0,wn=0,Ri=0,ws=0,Al=0;if(ii=K,K=K+64|0,Tn=ii+48|0,on=ii+32|0,Ut=ii+24|0,Lt=ii+8|0,sn=ii,U=d[A>>2]|0,(U|0)<=0)return vn=0,K=ii,vn|0;for(tn=A+4|0,Bn=Tn+8|0,En=on+8|0,Qn=Lt+8|0,N=0,Ge=0;;){I=d[tn>>2]|0,qe=I+(Ge<<4)|0,d[Tn>>2]=d[qe>>2],d[Tn+4>>2]=d[qe+4>>2],d[Tn+8>>2]=d[qe+8>>2],d[Tn+12>>2]=d[qe+12>>2],(Ge|0)==(U+-1|0)?(d[on>>2]=d[I>>2],d[on+4>>2]=d[I+4>>2],d[on+8>>2]=d[I+8>>2],d[on+12>>2]=d[I+12>>2]):(qe=I+(Ge+1<<4)|0,d[on>>2]=d[qe>>2],d[on+4>>2]=d[qe+4>>2],d[on+8>>2]=d[qe+8>>2],d[on+12>>2]=d[qe+12>>2]),U=a1(Tn,on,_,Ut)|0;e:do if(U)I=0,N=U;else if(U=Ut,I=d[U>>2]|0,U=d[U+4>>2]|0,(U|0)>0|(U|0)==0&I>>>0>0){Ye=0,qe=0;t:for(;;){if(Ri=1/(+(I>>>0)+4294967296*+(U|0)),Al=+J[Tn>>3],U=Ur(I|0,U|0,Ye|0,qe|0)|0,ws=+(U>>>0)+4294967296*+(Z()|0),wn=+(Ye>>>0)+4294967296*+(qe|0),J[Lt>>3]=Ri*(Al*ws)+Ri*(+J[on>>3]*wn),J[Qn>>3]=Ri*(+J[Bn>>3]*ws)+Ri*(+J[En>>3]*wn),U=PA(Lt,_,sn)|0,U|0){N=U;break}Ie=sn,Pe=d[Ie>>2]|0,Ie=d[Ie+4>>2]|0,ge=ec(Pe|0,Ie|0,f|0,p|0)|0,H=Z()|0,U=M+(ge<<3)|0,ie=U,I=d[ie>>2]|0,ie=d[ie+4>>2]|0;n:do if((I|0)==0&(ie|0)==0)Le=U,vn=16;else for(Ae=0,ve=0;;){if((Ae|0)>(p|0)|(Ae|0)==(p|0)&ve>>>0>f>>>0){N=1;break t}if((I|0)==(Pe|0)&(ie|0)==(Ie|0))break n;if(U=Qt(ge|0,H|0,1,0)|0,ge=th(U|0,Z()|0,f|0,p|0)|0,H=Z()|0,ve=Qt(ve|0,Ae|0,1,0)|0,Ae=Z()|0,U=M+(ge<<3)|0,ie=U,I=d[ie>>2]|0,ie=d[ie+4>>2]|0,(I|0)==0&(ie|0)==0){Le=U,vn=16;break}}while(!1);if((vn|0)==16&&(vn=0,!((Pe|0)==0&(Ie|0)==0))&&(ve=Le,d[ve>>2]=Pe,d[ve+4>>2]=Ie,ve=T+(d[y>>2]<<3)|0,d[ve>>2]=Pe,d[ve+4>>2]=Ie,ve=y,ve=Qt(d[ve>>2]|0,d[ve+4>>2]|0,1,0)|0,Pe=Z()|0,Ie=y,d[Ie>>2]=ve,d[Ie+4>>2]=Pe),Ye=Qt(Ye|0,qe|0,1,0)|0,qe=Z()|0,U=Ut,I=d[U>>2]|0,U=d[U+4>>2]|0,!((U|0)>(qe|0)|(U|0)==(qe|0)&I>>>0>Ye>>>0)){I=1;break e}}I=0}else I=1;while(!1);if(Ge=Ge+1|0,!I){vn=21;break}if(U=d[A>>2]|0,(Ge|0)>=(U|0)){N=0,vn=21;break}}return(vn|0)==21?(K=ii,N|0):0}function Zh(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0,Bn=0,En=0,Qn=0,Tn=0,on=0,Ut=0,vn=0,ii=0,wn=0,Ri=0,ws=0;if(ws=K,K=K+112|0,vn=ws+80|0,U=ws+72|0,ii=ws,wn=ws+56|0,y=Ra(p)|0,y|0)return Ri=y,K=ws,Ri|0;if(I=A+8|0,Ri=Fo((d[I>>2]<<5)+32|0)|0,!Ri)return Ri=13,K=ws,Ri|0;if(Na(A,Ri),y=Ra(p)|0,!y){if(on=A,Ut=d[on+4>>2]|0,y=U,d[y>>2]=d[on>>2],d[y+4>>2]=Ut,pa(U,vn),y=sf(vn,f,ii)|0,y)on=0,Ut=0;else{if(y=d[U>>2]|0,T=d[I>>2]|0,(T|0)>0){M=d[A+12>>2]|0,p=0;do y=(d[M+(p<<3)>>2]|0)+y|0,p=p+1|0;while((p|0)!=(T|0));p=y}else p=y;y=ii,T=d[y>>2]|0,y=d[y+4>>2]|0,M=((p|0)<0)<<31>>31,(y|0)<(M|0)|(y|0)==(M|0)&T>>>0

>>0?(y=ii,d[y>>2]=p,d[y+4>>2]=M,y=M):p=T,on=Qt(p|0,y|0,12,0)|0,Ut=Z()|0,y=ii,d[y>>2]=on,d[y+4>>2]=Ut,y=0}if(!y){if(p=Ks(on,8)|0,!p)return An(Ri),Ri=13,K=ws,Ri|0;if(N=Ks(on,8)|0,!N)return An(Ri),An(p),Ri=13,K=ws,Ri|0;Qn=vn,d[Qn>>2]=0,d[Qn+4>>2]=0,Qn=A,Tn=d[Qn+4>>2]|0,y=U,d[y>>2]=d[Qn>>2],d[y+4>>2]=Tn,y=Ei(U,on,Ut,f,vn,p,N)|0;e:do if(y)An(p),An(N),An(Ri);else{t:do if((d[I>>2]|0)>0){for(M=A+12|0,T=0;y=Ei((d[M>>2]|0)+(T<<3)|0,on,Ut,f,vn,p,N)|0,T=T+1|0,!(y|0);)if((T|0)>=(d[I>>2]|0))break t;An(p),An(N),An(Ri);break e}while(!1);(Ut|0)>0|(Ut|0)==0&on>>>0>0&&uo(N|0,0,on<<3|0)|0,Tn=vn,Qn=d[Tn+4>>2]|0;t:do if((Qn|0)>0|(Qn|0)==0&(d[Tn>>2]|0)>>>0>0){tn=p,Bn=N,En=p,Qn=N,Tn=p,y=p,Le=p,Lt=N,sn=N,p=N;n:for(;;){for(Ie=0,Ye=0,qe=0,Ge=0,T=0,M=0;;){N=ii,U=N+56|0;do d[N>>2]=0,N=N+4|0;while((N|0)<(U|0));if(f=tn+(Ie<<3)|0,I=d[f>>2]|0,f=d[f+4>>2]|0,Nt(I,f,1,ii,0)|0){N=ii,U=N+56|0;do d[N>>2]=0,N=N+4|0;while((N|0)<(U|0));N=Ks(7,4)|0,N|0&&(Jt(I,f,1,ii,N,7,0,0)|0,An(N))}for(Pe=0;;){ve=ii+(Pe<<3)|0,Ae=d[ve>>2]|0,ve=d[ve+4>>2]|0;i:do if((Ae|0)==0&(ve|0)==0)N=T,U=M;else{if(H=ec(Ae|0,ve|0,on|0,Ut|0)|0,I=Z()|0,N=_+(H<<3)|0,f=N,U=d[f>>2]|0,f=d[f+4>>2]|0,!((U|0)==0&(f|0)==0)){ie=0,ge=0;do{if((ie|0)>(Ut|0)|(ie|0)==(Ut|0)&ge>>>0>on>>>0)break n;if((U|0)==(Ae|0)&(f|0)==(ve|0)){N=T,U=M;break i}N=Qt(H|0,I|0,1,0)|0,H=th(N|0,Z()|0,on|0,Ut|0)|0,I=Z()|0,ge=Qt(ge|0,ie|0,1,0)|0,ie=Z()|0,N=_+(H<<3)|0,f=N,U=d[f>>2]|0,f=d[f+4>>2]|0}while(!((U|0)==0&(f|0)==0))}if((Ae|0)==0&(ve|0)==0){N=T,U=M;break}Ol(Ae,ve,wn)|0,Da(A,Ri,wn)|0&&(ge=Qt(T|0,M|0,1,0)|0,M=Z()|0,ie=N,d[ie>>2]=Ae,d[ie+4>>2]=ve,T=Bn+(T<<3)|0,d[T>>2]=Ae,d[T+4>>2]=ve,T=ge),N=T,U=M}while(!1);if(Pe=Pe+1|0,Pe>>>0>=7)break;T=N,M=U}if(Ie=Qt(Ie|0,Ye|0,1,0)|0,Ye=Z()|0,qe=Qt(qe|0,Ge|0,1,0)|0,Ge=Z()|0,M=vn,T=d[M>>2]|0,M=d[M+4>>2]|0,(Ge|0)<(M|0)|(Ge|0)==(M|0)&qe>>>0>>0)T=N,M=U;else break}if((M|0)>0|(M|0)==0&T>>>0>0){T=0,M=0;do Ge=tn+(T<<3)|0,d[Ge>>2]=0,d[Ge+4>>2]=0,T=Qt(T|0,M|0,1,0)|0,M=Z()|0,Ge=vn,qe=d[Ge+4>>2]|0;while((M|0)<(qe|0)|((M|0)==(qe|0)?T>>>0<(d[Ge>>2]|0)>>>0:0))}if(Ge=vn,d[Ge>>2]=N,d[Ge+4>>2]=U,(U|0)>0|(U|0)==0&N>>>0>0)Pe=p,Ie=sn,Ye=Tn,qe=Lt,Ge=Bn,p=Le,sn=y,Lt=En,Le=Pe,y=Ie,Tn=Qn,Qn=Ye,En=qe,Bn=tn,tn=Ge;else break t}An(En),An(Qn),An(Ri),y=1;break e}else y=N;while(!1);An(Ri),An(p),An(y),y=0}while(!1);return Ri=y,K=ws,Ri|0}}return An(Ri),Ri=y,K=ws,Ri|0}function Bl(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(H=K,K=K+176|0,U=H,(f|0)<1)return Io(p,0,0),I=0,K=H,I|0;for(N=A,N=Mt(d[N>>2]|0,d[N+4>>2]|0,52)|0,Z()|0,Io(p,(f|0)>6?f:6,N&15),N=0;_=A+(N<<3)|0,_=Il(d[_>>2]|0,d[_+4>>2]|0,U)|0,!(_|0);){if(_=d[U>>2]|0,(_|0)>0){M=0;do T=U+8+(M<<4)|0,M=M+1|0,_=U+8+(((M|0)%(_|0)|0)<<4)|0,y=Zu(p,_,T)|0,y?Ku(p,y)|0:VA(p,T,_)|0,_=d[U>>2]|0;while((M|0)<(_|0))}if(N=N+1|0,(N|0)>=(f|0)){_=0,I=13;break}}return(I|0)==13?(K=H,_|0):(GA(p),I=_,K=H,I|0)}function nl(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0;if(T=K,K=K+32|0,_=T,y=T+16|0,A=Bl(A,f,y)|0,A|0)return p=A,K=T,p|0;if(d[p>>2]=0,d[p+4>>2]=0,d[p+8>>2]=0,A=qA(y)|0,A|0)do{f=M1(p)|0;do OA(f,A)|0,M=A+16|0,d[_>>2]=d[M>>2],d[_+4>>2]=d[M+4>>2],d[_+8>>2]=d[M+8>>2],d[_+12>>2]=d[M+12>>2],Ku(y,A)|0,A=As(y,_)|0;while((A|0)!=0);A=qA(y)|0}while((A|0)!=0);return GA(y),A=Rx(p)|0,A?(Wu(p),M=A,K=T,M|0):(M=0,K=T,M|0)}function Bi(A){return A=A|0,A>>>0>121?(A=0,A|0):(A=d[7696+(A*28|0)+16>>2]|0,A|0)}function Wc(A){return A=A|0,(A|0)==4|(A|0)==117|0}function Po(A){return A=A|0,d[11120+((d[A>>2]|0)*216|0)+((d[A+4>>2]|0)*72|0)+((d[A+8>>2]|0)*24|0)+(d[A+12>>2]<<3)>>2]|0}function ep(A){return A=A|0,d[11120+((d[A>>2]|0)*216|0)+((d[A+4>>2]|0)*72|0)+((d[A+8>>2]|0)*24|0)+(d[A+12>>2]<<3)+4>>2]|0}function tp(A,f){A=A|0,f=f|0,A=7696+(A*28|0)|0,d[f>>2]=d[A>>2],d[f+4>>2]=d[A+4>>2],d[f+8>>2]=d[A+8>>2],d[f+12>>2]=d[A+12>>2]}function $c(A,f){A=A|0,f=f|0;var p=0,_=0;if(f>>>0>20)return f=-1,f|0;do if((d[11120+(f*216|0)>>2]|0)!=(A|0))if((d[11120+(f*216|0)+8>>2]|0)!=(A|0))if((d[11120+(f*216|0)+16>>2]|0)!=(A|0))if((d[11120+(f*216|0)+24>>2]|0)!=(A|0))if((d[11120+(f*216|0)+32>>2]|0)!=(A|0))if((d[11120+(f*216|0)+40>>2]|0)!=(A|0))if((d[11120+(f*216|0)+48>>2]|0)!=(A|0))if((d[11120+(f*216|0)+56>>2]|0)!=(A|0))if((d[11120+(f*216|0)+64>>2]|0)!=(A|0))if((d[11120+(f*216|0)+72>>2]|0)!=(A|0))if((d[11120+(f*216|0)+80>>2]|0)!=(A|0))if((d[11120+(f*216|0)+88>>2]|0)!=(A|0))if((d[11120+(f*216|0)+96>>2]|0)!=(A|0))if((d[11120+(f*216|0)+104>>2]|0)!=(A|0))if((d[11120+(f*216|0)+112>>2]|0)!=(A|0))if((d[11120+(f*216|0)+120>>2]|0)!=(A|0))if((d[11120+(f*216|0)+128>>2]|0)!=(A|0))if((d[11120+(f*216|0)+136>>2]|0)==(A|0))A=2,p=1,_=2;else{if((d[11120+(f*216|0)+144>>2]|0)==(A|0)){A=0,p=2,_=0;break}if((d[11120+(f*216|0)+152>>2]|0)==(A|0)){A=0,p=2,_=1;break}if((d[11120+(f*216|0)+160>>2]|0)==(A|0)){A=0,p=2,_=2;break}if((d[11120+(f*216|0)+168>>2]|0)==(A|0)){A=1,p=2,_=0;break}if((d[11120+(f*216|0)+176>>2]|0)==(A|0)){A=1,p=2,_=1;break}if((d[11120+(f*216|0)+184>>2]|0)==(A|0)){A=1,p=2,_=2;break}if((d[11120+(f*216|0)+192>>2]|0)==(A|0)){A=2,p=2,_=0;break}if((d[11120+(f*216|0)+200>>2]|0)==(A|0)){A=2,p=2,_=1;break}if((d[11120+(f*216|0)+208>>2]|0)==(A|0)){A=2,p=2,_=2;break}else A=-1;return A|0}else A=2,p=1,_=1;else A=2,p=1,_=0;else A=1,p=1,_=2;else A=1,p=1,_=1;else A=1,p=1,_=0;else A=0,p=1,_=2;else A=0,p=1,_=1;else A=0,p=1,_=0;else A=2,p=0,_=2;else A=2,p=0,_=1;else A=2,p=0,_=0;else A=1,p=0,_=2;else A=1,p=0,_=1;else A=1,p=0,_=0;else A=0,p=0,_=2;else A=0,p=0,_=1;else A=0,p=0,_=0;while(!1);return f=d[11120+(f*216|0)+(p*72|0)+(A*24|0)+(_<<3)+4>>2]|0,f|0}function Ru(A,f){return A=A|0,f=f|0,(d[7696+(A*28|0)+20>>2]|0)==(f|0)?(f=1,f|0):(f=(d[7696+(A*28|0)+24>>2]|0)==(f|0),f|0)}function SA(A,f){return A=A|0,f=f|0,d[848+(A*28|0)+(f<<2)>>2]|0}function Jh(A,f){return A=A|0,f=f|0,(d[848+(A*28|0)>>2]|0)==(f|0)?(f=0,f|0):(d[848+(A*28|0)+4>>2]|0)==(f|0)?(f=1,f|0):(d[848+(A*28|0)+8>>2]|0)==(f|0)?(f=2,f|0):(d[848+(A*28|0)+12>>2]|0)==(f|0)?(f=3,f|0):(d[848+(A*28|0)+16>>2]|0)==(f|0)?(f=4,f|0):(d[848+(A*28|0)+20>>2]|0)==(f|0)?(f=5,f|0):((d[848+(A*28|0)+24>>2]|0)==(f|0)?6:7)|0}function s1(){return 122}function ef(A){A=A|0;var f=0,p=0,_=0;f=0;do Dt(f|0,0,45)|0,_=Z()|0|134225919,p=A+(f<<3)|0,d[p>>2]=-1,d[p+4>>2]=_,f=f+1|0;while((f|0)!=122);return 0}function il(A){A=A|0;var f=0,p=0,_=0;return _=+J[A+16>>3],p=+J[A+24>>3],f=_-p,+(_>3]<+J[A+24>>3]|0}function tf(A){return A=A|0,+(+J[A>>3]-+J[A+8>>3])}function Lo(A,f){A=A|0,f=f|0;var p=0,_=0,y=0;return p=+J[f>>3],!(p>=+J[A+8>>3])||!(p<=+J[A>>3])?(f=0,f|0):(_=+J[A+16>>3],p=+J[A+24>>3],y=+J[f+8>>3],f=y>=p,A=y<=_&1,_>3]<+J[f+8>>3]||+J[A+8>>3]>+J[f>>3]?(_=0,_|0):(T=+J[A+16>>3],p=A+24|0,H=+J[p>>3],M=T>3],y=f+24|0,U=+J[y>>3],N=I>3],f)||(H=+Xs(+J[p>>3],A),H>+Xs(+J[_>>3],f))?(N=0,N|0):(N=1,N|0))}function wA(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0;T=+J[A+16>>3],U=+J[A+24>>3],A=T>3],M=+J[f+24>>3],y=N>2]=A?y|f?1:2:0,d[_>>2]=y?A?1:f?2:1:0}function np(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;return+J[A>>3]<+J[f>>3]||+J[A+8>>3]>+J[f+8>>3]?(_=0,_|0):(_=A+16|0,U=+J[_>>3],T=+J[A+24>>3],M=U>3],y=f+24|0,I=+J[y>>3],N=H>3],f)?(H=+Xs(+J[_>>3],A),N=H>=+Xs(+J[p>>3],f),N|0):(N=0,N|0))}function rf(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0;y=K,K=K+176|0,_=y,d[_>>2]=4,N=+J[f>>3],J[_+8>>3]=N,T=+J[f+16>>3],J[_+16>>3]=T,J[_+24>>3]=N,N=+J[f+24>>3],J[_+32>>3]=N,M=+J[f+8>>3],J[_+40>>3]=M,J[_+48>>3]=N,J[_+56>>3]=M,J[_+64>>3]=T,f=_+72|0,p=f+96|0;do d[f>>2]=0,f=f+4|0;while((f|0)<(p|0));Gl(A|0,_|0,168)|0,K=y}function sf(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0;ve=K,K=K+288|0,H=ve+264|0,ie=ve+96|0,I=ve,N=I,U=N+96|0;do d[N>>2]=0,N=N+4|0;while((N|0)<(U|0));return f=qu(f,I)|0,f|0?(Ae=f,K=ve,Ae|0):(U=I,I=d[U>>2]|0,U=d[U+4>>2]|0,Ol(I,U,H)|0,Il(I,U,ie)|0,M=+Zc(H,ie+8|0),J[H>>3]=+J[A>>3],U=H+8|0,J[U>>3]=+J[A+16>>3],J[ie>>3]=+J[A+8>>3],I=ie+8|0,J[I>>3]=+J[A+24>>3],y=+Zc(H,ie),Ie=+J[U>>3]-+J[I>>3],T=+un(+Ie),Pe=+J[H>>3]-+J[ie>>3],_=+un(+Pe),!(Ie==0|Pe==0)&&(Ie=+Af(+T,+_),Ie=+Qe(+(y*y/+df(+(Ie/+df(+T,+_)),3)/(M*(M*2.59807621135)*.8))),J[$n>>3]=Ie,ge=~~Ie>>>0,Ae=+un(Ie)>=1?Ie>0?~~+ke(+Xn(Ie/4294967296),4294967295)>>>0:~~+Qe((Ie-+(~~Ie>>>0))/4294967296)>>>0:0,(d[$n+4>>2]&2146435072|0)!=2146435072)?(ie=(ge|0)==0&(Ae|0)==0,f=p,d[f>>2]=ie?1:ge,d[f+4>>2]=ie?0:Ae,f=0):f=1,Ae=f,K=ve,Ae|0)}function a1(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0;I=K,K=K+288|0,M=I+264|0,N=I+96|0,U=I,y=U,T=y+96|0;do d[y>>2]=0,y=y+4|0;while((y|0)<(T|0));return p=qu(p,U)|0,p|0?(_=p,K=I,_|0):(p=U,y=d[p>>2]|0,p=d[p+4>>2]|0,Ol(y,p,M)|0,Il(y,p,N)|0,H=+Zc(M,N+8|0),H=+Qe(+(+Zc(A,f)/(H*2))),J[$n>>3]=H,p=~~H>>>0,y=+un(H)>=1?H>0?~~+ke(+Xn(H/4294967296),4294967295)>>>0:~~+Qe((H-+(~~H>>>0))/4294967296)>>>0:0,(d[$n+4>>2]&2146435072|0)==2146435072?(_=1,K=I,_|0):(U=(p|0)==0&(y|0)==0,d[_>>2]=U?1:p,d[_+4>>2]=U?0:y,_=0,K=I,_|0))}function Ws(A,f){A=A|0,f=+f;var p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;T=A+16|0,M=+J[T>>3],p=A+24|0,y=+J[p>>3],_=M-y,_=M>3],N=A+8|0,U=+J[N>>3],H=I-U,_=(_*f-_)*.5,f=(H*f-H)*.5,I=I+f,J[A>>3]=I>1.5707963267948966?1.5707963267948966:I,f=U-f,J[N>>3]=f<-1.5707963267948966?-1.5707963267948966:f,f=M+_,f=f>3.141592653589793?f+-6.283185307179586:f,J[T>>3]=f<-3.141592653589793?f+6.283185307179586:f,f=y-_,f=f>3.141592653589793?f+-6.283185307179586:f,J[p>>3]=f<-3.141592653589793?f+6.283185307179586:f}function Nu(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0,d[A>>2]=f,d[A+4>>2]=p,d[A+8>>2]=_}function MA(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0;ie=f+8|0,d[ie>>2]=0,U=+J[A>>3],M=+un(+U),I=+J[A+8>>3],N=+un(+I)*1.1547005383792515,M=M+N*.5,p=~~M,A=~~N,M=M-+(p|0),N=N-+(A|0);do if(M<.5)if(M<.3333333333333333)if(d[f>>2]=p,N<(M+1)*.5){d[f+4>>2]=A;break}else{A=A+1|0,d[f+4>>2]=A;break}else if(ge=1-M,A=(!(N>2]=A,ge<=N&N>2]=p;break}else{d[f>>2]=p;break}else{if(!(M<.6666666666666666))if(p=p+1|0,d[f>>2]=p,N>2]=A;break}else{A=A+1|0,d[f+4>>2]=A;break}if(N<1-M){if(d[f+4>>2]=A,M*2+-1>2]=p;break}}else A=A+1|0,d[f+4>>2]=A;p=p+1|0,d[f>>2]=p}while(!1);do if(U<0)if(A&1){H=(A+1|0)/2|0,H=Ur(p|0,((p|0)<0)<<31>>31|0,H|0,((H|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-((+(H>>>0)+4294967296*+(Z()|0))*2+1)),d[f>>2]=p;break}else{H=(A|0)/2|0,H=Ur(p|0,((p|0)<0)<<31>>31|0,H|0,((H|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-(+(H>>>0)+4294967296*+(Z()|0))*2),d[f>>2]=p;break}while(!1);H=f+4|0,I<0&&(p=p-((A<<1|1|0)/2|0)|0,d[f>>2]=p,A=0-A|0,d[H>>2]=A),_=A-p|0,(p|0)<0?(y=0-p|0,d[H>>2]=_,d[ie>>2]=y,d[f>>2]=0,A=_,p=0):y=0,(A|0)<0&&(p=p-A|0,d[f>>2]=p,y=y-A|0,d[ie>>2]=y,d[H>>2]=0,A=0),T=p-y|0,_=A-y|0,(y|0)<0&&(d[f>>2]=T,d[H>>2]=_,d[ie>>2]=0,A=_,p=T,y=0),_=(A|0)<(p|0)?A:p,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(d[f>>2]=p-_,d[H>>2]=A-_,d[ie>>2]=y-_)}function Lr(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0;f=d[A>>2]|0,M=A+4|0,p=d[M>>2]|0,(f|0)<0&&(p=p-f|0,d[M>>2]=p,T=A+8|0,d[T>>2]=(d[T>>2]|0)-f,d[A>>2]=0,f=0),(p|0)<0?(f=f-p|0,d[A>>2]=f,T=A+8|0,y=(d[T>>2]|0)-p|0,d[T>>2]=y,d[M>>2]=0,p=0):(y=A+8|0,T=y,y=d[y>>2]|0),(y|0)<0&&(f=f-y|0,d[A>>2]=f,p=p-y|0,d[M>>2]=p,d[T>>2]=0,y=0),_=(p|0)<(f|0)?p:f,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(d[A>>2]=f-_,d[M>>2]=p-_,d[T>>2]=y-_)}function Du(A,f){A=A|0,f=f|0;var p=0,_=0;_=d[A+8>>2]|0,p=+((d[A+4>>2]|0)-_|0),J[f>>3]=+((d[A>>2]|0)-_|0)-p*.5,J[f+8>>3]=p*.8660254037844386}function hs(A,f,p){A=A|0,f=f|0,p=p|0,d[p>>2]=(d[f>>2]|0)+(d[A>>2]|0),d[p+4>>2]=(d[f+4>>2]|0)+(d[A+4>>2]|0),d[p+8>>2]=(d[f+8>>2]|0)+(d[A+8>>2]|0)}function af(A,f,p){A=A|0,f=f|0,p=p|0,d[p>>2]=(d[A>>2]|0)-(d[f>>2]|0),d[p+4>>2]=(d[A+4>>2]|0)-(d[f+4>>2]|0),d[p+8>>2]=(d[A+8>>2]|0)-(d[f+8>>2]|0)}function Xc(A,f){A=A|0,f=f|0;var p=0,_=0;p=Xe(d[A>>2]|0,f)|0,d[A>>2]=p,p=A+4|0,_=Xe(d[p>>2]|0,f)|0,d[p>>2]=_,A=A+8|0,f=Xe(d[A>>2]|0,f)|0,d[A>>2]=f}function Pu(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;M=d[A>>2]|0,N=(M|0)<0,_=(d[A+4>>2]|0)-(N?M:0)|0,T=(_|0)<0,y=(T?0-_|0:0)+((d[A+8>>2]|0)-(N?M:0))|0,p=(y|0)<0,A=p?0:y,f=(T?0:_)-(p?y:0)|0,y=(N?0:M)-(T?_:0)-(p?y:0)|0,p=(f|0)<(y|0)?f:y,p=(A|0)<(p|0)?A:p,_=(p|0)>0,A=A-(_?p:0)|0,f=f-(_?p:0)|0;e:do switch(y-(_?p:0)|0){case 0:switch(f|0){case 0:return N=(A|0)==0?0:(A|0)==1?1:7,N|0;case 1:return N=(A|0)==0?2:(A|0)==1?3:7,N|0;default:break e}case 1:switch(f|0){case 0:return N=(A|0)==0?4:(A|0)==1?5:7,N|0;case 1:{if(!A)A=6;else break e;return A|0}default:break e}}while(!1);return N=7,N|0}function o1(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0;if(U=A+8|0,M=d[U>>2]|0,N=(d[A>>2]|0)-M|0,I=A+4|0,M=(d[I>>2]|0)-M|0,N>>>0>715827881|M>>>0>715827881){if(_=(N|0)>0,y=2147483647-N|0,T=-2147483648-N|0,(_?(y|0)<(N|0):(T|0)>(N|0))||(p=N<<1,_?(2147483647-p|0)<(N|0):(-2147483648-p|0)>(N|0))||((M|0)>0?(2147483647-M|0)<(M|0):(-2147483648-M|0)>(M|0))||(f=N*3|0,p=M<<1,(_?(y|0)<(p|0):(T|0)>(p|0))||((N|0)>-1?(f|-2147483648|0)>=(M|0):(f^-2147483648|0)<(M|0))))return I=1,I|0}else p=M<<1,f=N*3|0;return _=cl(+(f-M|0)*.14285714285714285)|0,d[A>>2]=_,y=cl(+(p+N|0)*.14285714285714285)|0,d[I>>2]=y,d[U>>2]=0,p=(y|0)<(_|0),f=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((f|0)>0?(2147483647-f|0)<(p|0):(-2147483648-f|0)>(p|0)))&&Bt(27795,26892,354,26903),((f|0)>-1?(f|-2147483648|0)>=(p|0):(f^-2147483648|0)<(p|0))&&Bt(27795,26892,354,26903)),f=y-_|0,(_|0)<0?(p=0-_|0,d[I>>2]=f,d[U>>2]=p,d[A>>2]=0,_=0):(f=y,p=0),(f|0)<0&&(_=_-f|0,d[A>>2]=_,p=p-f|0,d[U>>2]=p,d[I>>2]=0,f=0),T=_-p|0,y=f-p|0,(p|0)<0?(d[A>>2]=T,d[I>>2]=y,d[U>>2]=0,f=y,y=T,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(I=0,I|0):(d[A>>2]=y-_,d[I>>2]=f-_,d[U>>2]=p-_,I=0,I|0)}function cx(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0,U=0;if(M=A+8|0,y=d[M>>2]|0,T=(d[A>>2]|0)-y|0,N=A+4|0,y=(d[N>>2]|0)-y|0,T>>>0>715827881|y>>>0>715827881){if(p=(T|0)>0,(p?(2147483647-T|0)<(T|0):(-2147483648-T|0)>(T|0))||(f=T<<1,_=(y|0)>0,_?(2147483647-y|0)<(y|0):(-2147483648-y|0)>(y|0)))return N=1,N|0;if(U=y<<1,(_?(2147483647-U|0)<(y|0):(-2147483648-U|0)>(y|0))||(p?(2147483647-f|0)<(y|0):(-2147483648-f|0)>(y|0))||(p=y*3|0,(y|0)>-1?(p|-2147483648|0)>=(T|0):(p^-2147483648|0)<(T|0)))return U=1,U|0}else p=y*3|0,f=T<<1;return _=cl(+(f+y|0)*.14285714285714285)|0,d[A>>2]=_,y=cl(+(p-T|0)*.14285714285714285)|0,d[N>>2]=y,d[M>>2]=0,p=(y|0)<(_|0),f=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((f|0)>0?(2147483647-f|0)<(p|0):(-2147483648-f|0)>(p|0)))&&Bt(27795,26892,402,26917),((f|0)>-1?(f|-2147483648|0)>=(p|0):(f^-2147483648|0)<(p|0))&&Bt(27795,26892,402,26917)),f=y-_|0,(_|0)<0?(p=0-_|0,d[N>>2]=f,d[M>>2]=p,d[A>>2]=0,_=0):(f=y,p=0),(f|0)<0&&(_=_-f|0,d[A>>2]=_,p=p-f|0,d[M>>2]=p,d[N>>2]=0,f=0),T=_-p|0,y=f-p|0,(p|0)<0?(d[A>>2]=T,d[N>>2]=y,d[M>>2]=0,f=y,y=T,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(U=0,U|0):(d[A>>2]=y-_,d[N>>2]=f-_,d[M>>2]=p-_,U=0,U|0)}function hx(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;M=A+8|0,p=d[M>>2]|0,f=(d[A>>2]|0)-p|0,N=A+4|0,p=(d[N>>2]|0)-p|0,_=cl(+((f*3|0)-p|0)*.14285714285714285)|0,d[A>>2]=_,f=cl(+((p<<1)+f|0)*.14285714285714285)|0,d[N>>2]=f,d[M>>2]=0,p=f-_|0,(_|0)<0?(T=0-_|0,d[N>>2]=p,d[M>>2]=T,d[A>>2]=0,f=p,_=0,p=T):p=0,(f|0)<0&&(_=_-f|0,d[A>>2]=_,p=p-f|0,d[M>>2]=p,d[N>>2]=0,f=0),T=_-p|0,y=f-p|0,(p|0)<0?(d[A>>2]=T,d[N>>2]=y,d[M>>2]=0,f=y,y=T,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(d[A>>2]=y-_,d[N>>2]=f-_,d[M>>2]=p-_)}function l1(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;M=A+8|0,p=d[M>>2]|0,f=(d[A>>2]|0)-p|0,N=A+4|0,p=(d[N>>2]|0)-p|0,_=cl(+((f<<1)+p|0)*.14285714285714285)|0,d[A>>2]=_,f=cl(+((p*3|0)-f|0)*.14285714285714285)|0,d[N>>2]=f,d[M>>2]=0,p=f-_|0,(_|0)<0?(T=0-_|0,d[N>>2]=p,d[M>>2]=T,d[A>>2]=0,f=p,_=0,p=T):p=0,(f|0)<0&&(_=_-f|0,d[A>>2]=_,p=p-f|0,d[M>>2]=p,d[N>>2]=0,f=0),T=_-p|0,y=f-p|0,(p|0)<0?(d[A>>2]=T,d[N>>2]=y,d[M>>2]=0,f=y,y=T,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(d[A>>2]=y-_,d[N>>2]=f-_,d[M>>2]=p-_)}function Yc(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;f=d[A>>2]|0,M=A+4|0,p=d[M>>2]|0,N=A+8|0,_=d[N>>2]|0,y=p+(f*3|0)|0,d[A>>2]=y,p=_+(p*3|0)|0,d[M>>2]=p,f=(_*3|0)+f|0,d[N>>2]=f,_=p-y|0,(y|0)<0?(f=f-y|0,d[M>>2]=_,d[N>>2]=f,d[A>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,d[A>>2]=_,f=f-p|0,d[N>>2]=f,d[M>>2]=0,p=0),T=_-f|0,y=p-f|0,(f|0)<0?(d[A>>2]=T,d[M>>2]=y,d[N>>2]=0,_=T,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(d[A>>2]=_-p,d[M>>2]=y-p,d[N>>2]=f-p)}function Lu(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;y=d[A>>2]|0,M=A+4|0,f=d[M>>2]|0,N=A+8|0,p=d[N>>2]|0,_=(f*3|0)+y|0,y=p+(y*3|0)|0,d[A>>2]=y,d[M>>2]=_,f=(p*3|0)+f|0,d[N>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,d[M>>2]=p,d[N>>2]=f,d[A>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,d[A>>2]=y,f=f-p|0,d[N>>2]=f,d[M>>2]=0,p=0),T=y-f|0,_=p-f|0,(f|0)<0?(d[A>>2]=T,d[M>>2]=_,d[N>>2]=0,y=T,f=0):_=p,p=(_|0)<(y|0)?_:y,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(d[A>>2]=y-p,d[M>>2]=_-p,d[N>>2]=f-p)}function u1(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0;(f+-1|0)>>>0>=6||(y=(d[15440+(f*12|0)>>2]|0)+(d[A>>2]|0)|0,d[A>>2]=y,N=A+4|0,_=(d[15440+(f*12|0)+4>>2]|0)+(d[N>>2]|0)|0,d[N>>2]=_,M=A+8|0,f=(d[15440+(f*12|0)+8>>2]|0)+(d[M>>2]|0)|0,d[M>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,d[N>>2]=p,d[M>>2]=f,d[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,d[A>>2]=_,f=f-p|0,d[M>>2]=f,d[N>>2]=0,p=0),T=_-f|0,y=p-f|0,(f|0)<0?(d[A>>2]=T,d[N>>2]=y,d[M>>2]=0,_=T,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(d[A>>2]=_-p,d[N>>2]=y-p,d[M>>2]=f-p))}function c1(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;y=d[A>>2]|0,M=A+4|0,f=d[M>>2]|0,N=A+8|0,p=d[N>>2]|0,_=f+y|0,y=p+y|0,d[A>>2]=y,d[M>>2]=_,f=p+f|0,d[N>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,d[M>>2]=p,d[N>>2]=f,d[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,d[A>>2]=_,f=f-p|0,d[N>>2]=f,d[M>>2]=0,p=0),T=_-f|0,y=p-f|0,(f|0)<0?(d[A>>2]=T,d[M>>2]=y,d[N>>2]=0,_=T,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(d[A>>2]=_-p,d[M>>2]=y-p,d[N>>2]=f-p)}function EA(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;f=d[A>>2]|0,M=A+4|0,_=d[M>>2]|0,N=A+8|0,p=d[N>>2]|0,y=_+f|0,d[A>>2]=y,_=p+_|0,d[M>>2]=_,f=p+f|0,d[N>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,d[M>>2]=p,d[N>>2]=f,d[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,d[A>>2]=_,f=f-p|0,d[N>>2]=f,d[M>>2]=0,p=0),T=_-f|0,y=p-f|0,(f|0)<0?(d[A>>2]=T,d[M>>2]=y,d[N>>2]=0,_=T,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(d[A>>2]=_-p,d[M>>2]=y-p,d[N>>2]=f-p)}function Uu(A){switch(A=A|0,A|0){case 1:{A=5;break}case 5:{A=4;break}case 4:{A=6;break}case 6:{A=2;break}case 2:{A=3;break}case 3:{A=1;break}}return A|0}function rl(A){switch(A=A|0,A|0){case 1:{A=3;break}case 3:{A=2;break}case 2:{A=6;break}case 6:{A=4;break}case 4:{A=5;break}case 5:{A=1;break}}return A|0}function h1(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;f=d[A>>2]|0,M=A+4|0,p=d[M>>2]|0,N=A+8|0,_=d[N>>2]|0,y=p+(f<<1)|0,d[A>>2]=y,p=_+(p<<1)|0,d[M>>2]=p,f=(_<<1)+f|0,d[N>>2]=f,_=p-y|0,(y|0)<0?(f=f-y|0,d[M>>2]=_,d[N>>2]=f,d[A>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,d[A>>2]=_,f=f-p|0,d[N>>2]=f,d[M>>2]=0,p=0),T=_-f|0,y=p-f|0,(f|0)<0?(d[A>>2]=T,d[M>>2]=y,d[N>>2]=0,_=T,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(d[A>>2]=_-p,d[M>>2]=y-p,d[N>>2]=f-p)}function f1(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;y=d[A>>2]|0,M=A+4|0,f=d[M>>2]|0,N=A+8|0,p=d[N>>2]|0,_=(f<<1)+y|0,y=p+(y<<1)|0,d[A>>2]=y,d[M>>2]=_,f=(p<<1)+f|0,d[N>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,d[M>>2]=p,d[N>>2]=f,d[A>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,d[A>>2]=y,f=f-p|0,d[N>>2]=f,d[M>>2]=0,p=0),T=y-f|0,_=p-f|0,(f|0)<0?(d[A>>2]=T,d[M>>2]=_,d[N>>2]=0,y=T,f=0):_=p,p=(_|0)<(y|0)?_:y,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(d[A>>2]=y-p,d[M>>2]=_-p,d[N>>2]=f-p)}function ip(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0;return M=(d[A>>2]|0)-(d[f>>2]|0)|0,N=(M|0)<0,_=(d[A+4>>2]|0)-(d[f+4>>2]|0)-(N?M:0)|0,T=(_|0)<0,y=(N?0-M|0:0)+(d[A+8>>2]|0)-(d[f+8>>2]|0)+(T?0-_|0:0)|0,A=(y|0)<0,f=A?0:y,p=(T?0:_)-(A?y:0)|0,y=(N?0:M)-(T?_:0)-(A?y:0)|0,A=(p|0)<(y|0)?p:y,A=(f|0)<(A|0)?f:A,_=(A|0)>0,f=f-(_?A:0)|0,p=p-(_?A:0)|0,A=y-(_?A:0)|0,A=(A|0)>-1?A:0-A|0,p=(p|0)>-1?p:0-p|0,f=(f|0)>-1?f:0-f|0,f=(p|0)>(f|0)?p:f,((A|0)>(f|0)?A:f)|0}function fx(A,f){A=A|0,f=f|0;var p=0;p=d[A+8>>2]|0,d[f>>2]=(d[A>>2]|0)-p,d[f+4>>2]=(d[A+4>>2]|0)-p}function rp(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0;return _=d[A>>2]|0,d[f>>2]=_,y=d[A+4>>2]|0,M=f+4|0,d[M>>2]=y,N=f+8|0,d[N>>2]=0,p=(y|0)<(_|0),A=p?_:y,p=p?y:_,(p|0)<0&&((p|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(p|0):(-2147483648-A|0)>(p|0))||((A|0)>-1?(A|-2147483648|0)>=(p|0):(A^-2147483648|0)<(p|0)))?(f=1,f|0):(A=y-_|0,(_|0)<0?(p=0-_|0,d[M>>2]=A,d[N>>2]=p,d[f>>2]=0,_=0):(A=y,p=0),(A|0)<0&&(_=_-A|0,d[f>>2]=_,p=p-A|0,d[N>>2]=p,d[M>>2]=0,A=0),T=_-p|0,y=A-p|0,(p|0)<0?(d[f>>2]=T,d[M>>2]=y,d[N>>2]=0,A=y,y=T,p=0):y=_,_=(A|0)<(y|0)?A:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(f=0,f|0):(d[f>>2]=y-_,d[M>>2]=A-_,d[N>>2]=p-_,f=0,f|0))}function A1(A){A=A|0;var f=0,p=0,_=0,y=0;f=A+8|0,y=d[f>>2]|0,p=y-(d[A>>2]|0)|0,d[A>>2]=p,_=A+4|0,A=(d[_>>2]|0)-y|0,d[_>>2]=A,d[f>>2]=0-(A+p)}function Ax(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;p=d[A>>2]|0,f=0-p|0,d[A>>2]=f,M=A+8|0,d[M>>2]=0,N=A+4|0,_=d[N>>2]|0,y=_+p|0,(p|0)>0?(d[N>>2]=y,d[M>>2]=p,d[A>>2]=0,f=0,_=y):p=0,(_|0)<0?(T=f-_|0,d[A>>2]=T,p=p-_|0,d[M>>2]=p,d[N>>2]=0,y=T-p|0,f=0-p|0,(p|0)<0?(d[A>>2]=y,d[N>>2]=f,d[M>>2]=0,_=f,p=0):(_=0,y=T)):y=f,f=(_|0)<(y|0)?_:y,f=(p|0)<(f|0)?p:f,!((f|0)<=0)&&(d[A>>2]=y-f,d[N>>2]=_-f,d[M>>2]=p-f)}function dx(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0;if(ie=K,K=K+64|0,H=ie,N=ie+56|0,!(!0&(f&2013265920|0)==134217728&(!0&(_&2013265920|0)==134217728)))return y=5,K=ie,y|0;if((A|0)==(p|0)&(f|0)==(_|0))return d[y>>2]=0,y=0,K=ie,y|0;if(M=Mt(A|0,f|0,52)|0,Z()|0,M=M&15,I=Mt(p|0,_|0,52)|0,Z()|0,(M|0)!=(I&15|0))return y=12,K=ie,y|0;if(T=M+-1|0,M>>>0>1){Fu(A,f,T,H)|0,Fu(p,_,T,N)|0,I=H,U=d[I>>2]|0,I=d[I+4>>2]|0;e:do if((U|0)==(d[N>>2]|0)&&(I|0)==(d[N+4>>2]|0)){M=(M^15)*3|0,T=Mt(A|0,f|0,M|0)|0,Z()|0,T=T&7,M=Mt(p|0,_|0,M|0)|0,Z()|0,M=M&7;do if((T|0)==0|(M|0)==0)d[y>>2]=1,T=0;else if((T|0)==7)T=5;else{if((T|0)==1|(M|0)==1&&Ci(U,I)|0){T=5;break}if((d[15536+(T<<2)>>2]|0)!=(M|0)&&(d[15568+(T<<2)>>2]|0)!=(M|0))break e;d[y>>2]=1,T=0}while(!1);return y=T,K=ie,y|0}while(!1)}T=H,M=T+56|0;do d[T>>2]=0,T=T+4|0;while((T|0)<(M|0));return ye(A,f,1,H)|0,f=H,!((d[f>>2]|0)==(p|0)&&(d[f+4>>2]|0)==(_|0))&&(f=H+8|0,!((d[f>>2]|0)==(p|0)&&(d[f+4>>2]|0)==(_|0)))&&(f=H+16|0,!((d[f>>2]|0)==(p|0)&&(d[f+4>>2]|0)==(_|0)))&&(f=H+24|0,!((d[f>>2]|0)==(p|0)&&(d[f+4>>2]|0)==(_|0)))&&(f=H+32|0,!((d[f>>2]|0)==(p|0)&&(d[f+4>>2]|0)==(_|0)))&&(f=H+40|0,!((d[f>>2]|0)==(p|0)&&(d[f+4>>2]|0)==(_|0)))?(T=H+48|0,T=((d[T>>2]|0)==(p|0)?(d[T+4>>2]|0)==(_|0):0)&1):T=1,d[y>>2]=T,y=0,K=ie,y|0}function d1(A,f,p,_,y){return A=A|0,f=f|0,p=p|0,_=_|0,y=y|0,p=pi(A,f,p,_)|0,(p|0)==7?(y=11,y|0):(_=Dt(p|0,0,56)|0,f=f&-2130706433|(Z()|0)|268435456,d[y>>2]=A|_,d[y+4>>2]=f,y=0,y|0)}function px(A,f,p){return A=A|0,f=f|0,p=p|0,!0&(f&2013265920|0)==268435456?(d[p>>2]=A,d[p+4>>2]=f&-2130706433|134217728,p=0,p|0):(p=6,p|0)}function mx(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0;return y=K,K=K+16|0,_=y,d[_>>2]=0,!0&(f&2013265920|0)==268435456?(T=Mt(A|0,f|0,56)|0,Z()|0,_=cn(A,f&-2130706433|134217728,T&7,_,p)|0,K=y,_|0):(_=6,K=y,_|0)}function p1(A,f){A=A|0,f=f|0;var p=0;switch(p=Mt(A|0,f|0,56)|0,Z()|0,p&7){case 0:case 7:return p=0,p|0}return p=f&-2130706433|134217728,!(!0&(f&2013265920|0)==268435456)||!0&(f&117440512|0)==16777216&(Ci(A,p)|0)!=0?(p=0,p|0):(p=NA(A,p)|0,p|0)}function gx(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0;return y=K,K=K+16|0,_=y,!0&(f&2013265920|0)==268435456?(T=f&-2130706433|134217728,M=p,d[M>>2]=A,d[M+4>>2]=T,d[_>>2]=0,f=Mt(A|0,f|0,56)|0,Z()|0,_=cn(A,T,f&7,_,p+8|0)|0,K=y,_|0):(_=6,K=y,_|0)}function vx(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0;return y=(Ci(A,f)|0)==0,f=f&-2130706433,_=p,d[_>>2]=y?A:0,d[_+4>>2]=y?f|285212672:0,_=p+8|0,d[_>>2]=A,d[_+4>>2]=f|301989888,_=p+16|0,d[_>>2]=A,d[_+4>>2]=f|318767104,_=p+24|0,d[_>>2]=A,d[_+4>>2]=f|335544320,_=p+32|0,d[_>>2]=A,d[_+4>>2]=f|352321536,p=p+40|0,d[p>>2]=A,d[p+4>>2]=f|369098752,0}function CA(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0;return M=K,K=K+16|0,y=M,T=f&-2130706433|134217728,!0&(f&2013265920|0)==268435456?(_=Mt(A|0,f|0,56)|0,Z()|0,_=Sp(A,T,_&7)|0,(_|0)==-1?(d[p>>2]=0,T=6,K=M,T|0):(zu(A,T,y)|0&&Bt(27795,26932,282,26947),f=Mt(A|0,f|0,52)|0,Z()|0,f=f&15,Ci(A,T)|0?sp(y,f,_,2,p):RA(y,f,_,2,p),T=0,K=M,T|0)):(T=6,K=M,T|0)}function _x(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0;_=K,K=K+16|0,y=_,yx(A,f,p,y),MA(y,p+4|0),K=_}function yx(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0;if(N=K,K=K+16|0,U=N,xx(A,p,U),T=+Ma(+(1-+J[U>>3]*.5)),T<1e-16){d[_>>2]=0,d[_+4>>2]=0,d[_+8>>2]=0,d[_+12>>2]=0,K=N;return}if(U=d[p>>2]|0,y=+J[15920+(U*24|0)>>3],y=+Kc(y-+Kc(+Ex(15600+(U<<4)|0,A))),Ss(f)|0?M=+Kc(y+-.3334731722518321):M=y,y=+cs(+T)*2.618033988749896,(f|0)>0){A=0;do y=y*2.6457513110645907,A=A+1|0;while((A|0)!=(f|0))}T=+li(+M)*y,J[_>>3]=T,M=+Fn(+M)*y,J[_+8>>3]=M,K=N}function xx(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0;if(T=K,K=K+32|0,y=T,Yu(A,y),d[f>>2]=0,J[p>>3]=5,_=+ar(16400,y),_<+J[p>>3]&&(d[f>>2]=0,J[p>>3]=_),_=+ar(16424,y),_<+J[p>>3]&&(d[f>>2]=1,J[p>>3]=_),_=+ar(16448,y),_<+J[p>>3]&&(d[f>>2]=2,J[p>>3]=_),_=+ar(16472,y),_<+J[p>>3]&&(d[f>>2]=3,J[p>>3]=_),_=+ar(16496,y),_<+J[p>>3]&&(d[f>>2]=4,J[p>>3]=_),_=+ar(16520,y),_<+J[p>>3]&&(d[f>>2]=5,J[p>>3]=_),_=+ar(16544,y),_<+J[p>>3]&&(d[f>>2]=6,J[p>>3]=_),_=+ar(16568,y),_<+J[p>>3]&&(d[f>>2]=7,J[p>>3]=_),_=+ar(16592,y),_<+J[p>>3]&&(d[f>>2]=8,J[p>>3]=_),_=+ar(16616,y),_<+J[p>>3]&&(d[f>>2]=9,J[p>>3]=_),_=+ar(16640,y),_<+J[p>>3]&&(d[f>>2]=10,J[p>>3]=_),_=+ar(16664,y),_<+J[p>>3]&&(d[f>>2]=11,J[p>>3]=_),_=+ar(16688,y),_<+J[p>>3]&&(d[f>>2]=12,J[p>>3]=_),_=+ar(16712,y),_<+J[p>>3]&&(d[f>>2]=13,J[p>>3]=_),_=+ar(16736,y),_<+J[p>>3]&&(d[f>>2]=14,J[p>>3]=_),_=+ar(16760,y),_<+J[p>>3]&&(d[f>>2]=15,J[p>>3]=_),_=+ar(16784,y),_<+J[p>>3]&&(d[f>>2]=16,J[p>>3]=_),_=+ar(16808,y),_<+J[p>>3]&&(d[f>>2]=17,J[p>>3]=_),_=+ar(16832,y),_<+J[p>>3]&&(d[f>>2]=18,J[p>>3]=_),_=+ar(16856,y),!(_<+J[p>>3])){K=T;return}d[f>>2]=19,J[p>>3]=_,K=T}function Bu(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0;if(T=+zl(A),T<1e-16){f=15600+(f<<4)|0,d[y>>2]=d[f>>2],d[y+4>>2]=d[f+4>>2],d[y+8>>2]=d[f+8>>2],d[y+12>>2]=d[f+12>>2];return}if(M=+Fe(+ +J[A+8>>3],+ +J[A>>3]),(p|0)>0){A=0;do T=T*.37796447300922725,A=A+1|0;while((A|0)!=(p|0))}N=T*.3333333333333333,_?(p=(Ss(p)|0)==0,T=+oe(+((p?N:N*.37796447300922725)*.381966011250105))):(T=+oe(+(T*.381966011250105)),Ss(p)|0&&(M=+Kc(M+.3334731722518321))),Cx(15600+(f<<4)|0,+Kc(+J[15920+(f*24|0)>>3]-M),T,y)}function of(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0;_=K,K=K+16|0,y=_,Du(A+4|0,y),Bu(y,d[A>>2]|0,f,0,p),K=_}function sp(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0,Bn=0,En=0,Qn=0,Tn=0,on=0,Ut=0,vn=0,ii=0,wn=0;if(vn=K,K=K+272|0,T=vn+256|0,qe=vn+240|0,Tn=vn,on=vn+224|0,Ut=vn+208|0,Ge=vn+176|0,Le=vn+160|0,Lt=vn+192|0,sn=vn+144|0,tn=vn+128|0,Bn=vn+112|0,En=vn+96|0,Qn=vn+80|0,d[T>>2]=f,d[qe>>2]=d[A>>2],d[qe+4>>2]=d[A+4>>2],d[qe+8>>2]=d[A+8>>2],d[qe+12>>2]=d[A+12>>2],ap(qe,T,Tn),d[y>>2]=0,qe=_+p+((_|0)==5&1)|0,(qe|0)<=(p|0)){K=vn;return}U=d[T>>2]|0,I=on+4|0,H=Ge+4|0,ie=p+5|0,ge=16880+(U<<2)|0,Ae=16960+(U<<2)|0,ve=tn+8|0,Pe=Bn+8|0,Ie=En+8|0,Ye=Ut+4|0,N=p;e:for(;;){M=Tn+(((N|0)%5|0)<<4)|0,d[Ut>>2]=d[M>>2],d[Ut+4>>2]=d[M+4>>2],d[Ut+8>>2]=d[M+8>>2],d[Ut+12>>2]=d[M+12>>2];do;while((Ou(Ut,U,0,1)|0)==2);if((N|0)>(p|0)&(Ss(f)|0)!=0){if(d[Ge>>2]=d[Ut>>2],d[Ge+4>>2]=d[Ut+4>>2],d[Ge+8>>2]=d[Ut+8>>2],d[Ge+12>>2]=d[Ut+12>>2],Du(I,Le),_=d[Ge>>2]|0,T=d[17040+(_*80|0)+(d[on>>2]<<2)>>2]|0,d[Ge>>2]=d[18640+(_*80|0)+(T*20|0)>>2],M=d[18640+(_*80|0)+(T*20|0)+16>>2]|0,(M|0)>0){A=0;do c1(H),A=A+1|0;while((A|0)<(M|0))}switch(M=18640+(_*80|0)+(T*20|0)+4|0,d[Lt>>2]=d[M>>2],d[Lt+4>>2]=d[M+4>>2],d[Lt+8>>2]=d[M+8>>2],Xc(Lt,(d[ge>>2]|0)*3|0),hs(H,Lt,H),Lr(H),Du(H,sn),ii=+(d[Ae>>2]|0),J[tn>>3]=ii*3,J[ve>>3]=0,wn=ii*-1.5,J[Bn>>3]=wn,J[Pe>>3]=ii*2.598076211353316,J[En>>3]=wn,J[Ie>>3]=ii*-2.598076211353316,d[17040+((d[Ge>>2]|0)*80|0)+(d[Ut>>2]<<2)>>2]|0){case 1:{A=Bn,_=tn;break}case 3:{A=En,_=Bn;break}case 2:{A=tn,_=En;break}default:{A=12;break e}}xp(Le,sn,_,A,Qn),Bu(Qn,d[Ge>>2]|0,U,1,y+8+(d[y>>2]<<4)|0),d[y>>2]=(d[y>>2]|0)+1}if((N|0)<(ie|0)&&(Du(Ye,Ge),Bu(Ge,d[Ut>>2]|0,U,1,y+8+(d[y>>2]<<4)|0),d[y>>2]=(d[y>>2]|0)+1),d[on>>2]=d[Ut>>2],d[on+4>>2]=d[Ut+4>>2],d[on+8>>2]=d[Ut+8>>2],d[on+12>>2]=d[Ut+12>>2],N=N+1|0,(N|0)>=(qe|0)){A=3;break}}if((A|0)==3){K=vn;return}else(A|0)==12&&Bt(26970,27017,572,27027)}function ap(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0;U=K,K=K+128|0,_=U+64|0,y=U,T=_,M=20240,N=T+60|0;do d[T>>2]=d[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(N|0));T=y,M=20304,N=T+60|0;do d[T>>2]=d[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(N|0));N=(Ss(d[f>>2]|0)|0)==0,_=N?_:y,y=A+4|0,h1(y),f1(y),Ss(d[f>>2]|0)|0&&(Lu(y),d[f>>2]=(d[f>>2]|0)+1),d[p>>2]=d[A>>2],f=p+4|0,hs(y,_,f),Lr(f),d[p+16>>2]=d[A>>2],f=p+20|0,hs(y,_+12|0,f),Lr(f),d[p+32>>2]=d[A>>2],f=p+36|0,hs(y,_+24|0,f),Lr(f),d[p+48>>2]=d[A>>2],f=p+52|0,hs(y,_+36|0,f),Lr(f),d[p+64>>2]=d[A>>2],p=p+68|0,hs(y,_+48|0,p),Lr(p),K=U}function Ou(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0;if(ve=K,K=K+32|0,ge=ve+12|0,N=ve,Ae=A+4|0,ie=d[16960+(f<<2)>>2]|0,H=(_|0)!=0,ie=H?ie*3|0:ie,y=d[Ae>>2]|0,I=A+8|0,M=d[I>>2]|0,H){if(T=A+12|0,_=d[T>>2]|0,y=M+y+_|0,(y|0)==(ie|0))return Ae=1,K=ve,Ae|0;U=T}else U=A+12|0,_=d[U>>2]|0,y=M+y+_|0;if((y|0)<=(ie|0))return Ae=0,K=ve,Ae|0;do if((_|0)>0){if(_=d[A>>2]|0,(M|0)>0){T=18640+(_*80|0)+60|0,_=A;break}_=18640+(_*80|0)+40|0,p?(Nu(ge,ie,0,0),af(Ae,ge,N),EA(N),hs(N,ge,Ae),T=_,_=A):(T=_,_=A)}else T=18640+((d[A>>2]|0)*80|0)+20|0,_=A;while(!1);if(d[_>>2]=d[T>>2],y=T+16|0,(d[y>>2]|0)>0){_=0;do c1(Ae),_=_+1|0;while((_|0)<(d[y>>2]|0))}return A=T+4|0,d[ge>>2]=d[A>>2],d[ge+4>>2]=d[A+4>>2],d[ge+8>>2]=d[A+8>>2],f=d[16880+(f<<2)>>2]|0,Xc(ge,H?f*3|0:f),hs(Ae,ge,Ae),Lr(Ae),H?_=((d[I>>2]|0)+(d[Ae>>2]|0)+(d[U>>2]|0)|0)==(ie|0)?1:2:_=2,Ae=_,K=ve,Ae|0}function m1(A,f){A=A|0,f=f|0;var p=0;do p=Ou(A,f,0,1)|0;while((p|0)==2);return p|0}function RA(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0,Bn=0,En=0,Qn=0,Tn=0;if(En=K,K=K+240|0,T=En+224|0,Lt=En+208|0,sn=En,tn=En+192|0,Bn=En+176|0,Ie=En+160|0,Ye=En+144|0,qe=En+128|0,Ge=En+112|0,Le=En+96|0,d[T>>2]=f,d[Lt>>2]=d[A>>2],d[Lt+4>>2]=d[A+4>>2],d[Lt+8>>2]=d[A+8>>2],d[Lt+12>>2]=d[A+12>>2],op(Lt,T,sn),d[y>>2]=0,Pe=_+p+((_|0)==6&1)|0,(Pe|0)<=(p|0)){K=En;return}U=d[T>>2]|0,I=p+6|0,H=16960+(U<<2)|0,ie=Ye+8|0,ge=qe+8|0,Ae=Ge+8|0,ve=tn+4|0,M=0,N=p,_=-1;e:for(;;){if(T=(N|0)%6|0,A=sn+(T<<4)|0,d[tn>>2]=d[A>>2],d[tn+4>>2]=d[A+4>>2],d[tn+8>>2]=d[A+8>>2],d[tn+12>>2]=d[A+12>>2],A=M,M=Ou(tn,U,0,1)|0,(N|0)>(p|0)&(Ss(f)|0)!=0&&(A|0)!=1&&(d[tn>>2]|0)!=(_|0)){switch(Du(sn+(((T+5|0)%6|0)<<4)+4|0,Bn),Du(sn+(T<<4)+4|0,Ie),Qn=+(d[H>>2]|0),J[Ye>>3]=Qn*3,J[ie>>3]=0,Tn=Qn*-1.5,J[qe>>3]=Tn,J[ge>>3]=Qn*2.598076211353316,J[Ge>>3]=Tn,J[Ae>>3]=Qn*-2.598076211353316,T=d[Lt>>2]|0,d[17040+(T*80|0)+(((_|0)==(T|0)?d[tn>>2]|0:_)<<2)>>2]|0){case 1:{A=qe,_=Ye;break}case 3:{A=Ge,_=qe;break}case 2:{A=Ye,_=Ge;break}default:{A=8;break e}}xp(Bn,Ie,_,A,Le),!(bp(Bn,Le)|0)&&!(bp(Ie,Le)|0)&&(Bu(Le,d[Lt>>2]|0,U,1,y+8+(d[y>>2]<<4)|0),d[y>>2]=(d[y>>2]|0)+1)}if((N|0)<(I|0)&&(Du(ve,Bn),Bu(Bn,d[tn>>2]|0,U,1,y+8+(d[y>>2]<<4)|0),d[y>>2]=(d[y>>2]|0)+1),N=N+1|0,(N|0)>=(Pe|0)){A=3;break}else _=d[tn>>2]|0}if((A|0)==3){K=En;return}else(A|0)==8&&Bt(27054,27017,737,27099)}function op(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0;U=K,K=K+160|0,_=U+80|0,y=U,T=_,M=20368,N=T+72|0;do d[T>>2]=d[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(N|0));T=y,M=20448,N=T+72|0;do d[T>>2]=d[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(N|0));N=(Ss(d[f>>2]|0)|0)==0,_=N?_:y,y=A+4|0,h1(y),f1(y),Ss(d[f>>2]|0)|0&&(Lu(y),d[f>>2]=(d[f>>2]|0)+1),d[p>>2]=d[A>>2],f=p+4|0,hs(y,_,f),Lr(f),d[p+16>>2]=d[A>>2],f=p+20|0,hs(y,_+12|0,f),Lr(f),d[p+32>>2]=d[A>>2],f=p+36|0,hs(y,_+24|0,f),Lr(f),d[p+48>>2]=d[A>>2],f=p+52|0,hs(y,_+36|0,f),Lr(f),d[p+64>>2]=d[A>>2],f=p+68|0,hs(y,_+48|0,f),Lr(f),d[p+80>>2]=d[A>>2],p=p+84|0,hs(y,_+60|0,p),Lr(p),K=U}function Qc(A,f){return A=A|0,f=f|0,f=Mt(A|0,f|0,52)|0,Z()|0,f&15|0}function g1(A,f){return A=A|0,f=f|0,f=Mt(A|0,f|0,45)|0,Z()|0,f&127|0}function bx(A,f,p,_){return A=A|0,f=f|0,p=p|0,_=_|0,(p+-1|0)>>>0>14?(_=4,_|0):(p=Mt(A|0,f|0,(15-p|0)*3|0)|0,Z()|0,d[_>>2]=p&7,_=0,_|0)}function Sx(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0;if(A>>>0>15)return _=4,_|0;if(f>>>0>121)return _=17,_|0;M=Dt(A|0,0,52)|0,y=Z()|0,N=Dt(f|0,0,45)|0,y=y|(Z()|0)|134225919;e:do if((A|0)>=1){for(N=1,M=(at[20528+f>>0]|0)!=0,T=-1;;){if(f=d[p+(N+-1<<2)>>2]|0,f>>>0>6){y=18,f=10;break}if(!((f|0)==0|M^1))if((f|0)==1){y=19,f=10;break}else M=0;if(I=(15-N|0)*3|0,U=Dt(7,0,I|0)|0,y=y&~(Z()|0),f=Dt(f|0,((f|0)<0)<<31>>31|0,I|0)|0,T=f|T&~U,y=Z()|0|y,(N|0)<(A|0))N=N+1|0;else break e}if((f|0)==10)return y|0}else T=-1;while(!1);return I=_,d[I>>2]=T,d[I+4>>2]=y,I=0,I|0}function NA(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0;return!(!0&(f&-16777216|0)==134217728)||(_=Mt(A|0,f|0,52)|0,Z()|0,_=_&15,p=Mt(A|0,f|0,45)|0,Z()|0,p=p&127,p>>>0>121)?(A=0,A|0):(M=(_^15)*3|0,y=Mt(A|0,f|0,M|0)|0,M=Dt(y|0,Z()|0,M|0)|0,y=Z()|0,T=Ur(-1227133514,-1171,M|0,y|0)|0,!((M&613566756&T|0)==0&(y&4681&(Z()|0)|0)==0)||(M=(_*3|0)+19|0,T=Dt(~A|0,~f|0,M|0)|0,M=Mt(T|0,Z()|0,M|0)|0,!((_|0)==15|(M|0)==0&(Z()|0)==0))?(M=0,M|0):!(at[20528+p>>0]|0)||(f=f&8191,(A|0)==0&(f|0)==0)?(M=1,M|0):(M=ff(A|0,f|0)|0,Z()|0,((63-M|0)%3|0|0)!=0|0))}function v1(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0;return!0&(f&-16777216|0)==134217728&&(_=Mt(A|0,f|0,52)|0,Z()|0,_=_&15,p=Mt(A|0,f|0,45)|0,Z()|0,p=p&127,p>>>0<=121)&&(M=(_^15)*3|0,y=Mt(A|0,f|0,M|0)|0,M=Dt(y|0,Z()|0,M|0)|0,y=Z()|0,T=Ur(-1227133514,-1171,M|0,y|0)|0,(M&613566756&T|0)==0&(y&4681&(Z()|0)|0)==0)&&(M=(_*3|0)+19|0,T=Dt(~A|0,~f|0,M|0)|0,M=Mt(T|0,Z()|0,M|0)|0,(_|0)==15|(M|0)==0&(Z()|0)==0)&&(!(at[20528+p>>0]|0)||(p=f&8191,(A|0)==0&(p|0)==0)||(M=ff(A|0,p|0)|0,Z()|0,(63-M|0)%3|0|0))||p1(A,f)|0?(M=1,M|0):(M=(ul(A,f)|0)!=0&1,M|0)}function Iu(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0;if(y=Dt(f|0,0,52)|0,T=Z()|0,p=Dt(p|0,0,45)|0,p=T|(Z()|0)|134225919,(f|0)<1){T=-1,_=p,f=A,d[f>>2]=T,A=A+4|0,d[A>>2]=_;return}for(T=1,y=-1;M=(15-T|0)*3|0,N=Dt(7,0,M|0)|0,p=p&~(Z()|0),M=Dt(_|0,0,M|0)|0,y=y&~N|M,p=p|(Z()|0),(T|0)!=(f|0);)T=T+1|0;N=A,M=N,d[M>>2]=y,N=N+4|0,d[N>>2]=p}function Fu(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0;if(T=Mt(A|0,f|0,52)|0,Z()|0,T=T&15,p>>>0>15)return _=4,_|0;if((T|0)<(p|0))return _=12,_|0;if((T|0)==(p|0))return d[_>>2]=A,d[_+4>>2]=f,_=0,_|0;if(y=Dt(p|0,0,52)|0,y=y|A,A=Z()|0|f&-15728641,(T|0)>(p|0))do f=Dt(7,0,(14-p|0)*3|0)|0,p=p+1|0,y=f|y,A=Z()|0|A;while((p|0)<(T|0));return d[_>>2]=y,d[_+4>>2]=A,_=0,_|0}function lf(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0;if(T=Mt(A|0,f|0,52)|0,Z()|0,T=T&15,!((p|0)<16&(T|0)<=(p|0)))return _=4,_|0;y=p-T|0,p=Mt(A|0,f|0,45)|0,Z()|0;e:do if(!(Bi(p&127)|0))p=Bo(7,0,y,((y|0)<0)<<31>>31)|0,y=Z()|0;else{t:do if(T|0){for(p=1;M=Dt(7,0,(15-p|0)*3|0)|0,!!((M&A|0)==0&((Z()|0)&f|0)==0);)if(p>>>0>>0)p=p+1|0;else break t;p=Bo(7,0,y,((y|0)<0)<<31>>31)|0,y=Z()|0;break e}while(!1);p=Bo(7,0,y,((y|0)<0)<<31>>31)|0,p=fr(p|0,Z()|0,5,0)|0,p=Qt(p|0,Z()|0,-5,-1)|0,p=ko(p|0,Z()|0,6,0)|0,p=Qt(p|0,Z()|0,1,0)|0,y=Z()|0}while(!1);return M=_,d[M>>2]=p,d[M+4>>2]=y,M=0,M|0}function Ci(A,f){A=A|0,f=f|0;var p=0,_=0,y=0;if(y=Mt(A|0,f|0,45)|0,Z()|0,!(Bi(y&127)|0))return y=0,y|0;y=Mt(A|0,f|0,52)|0,Z()|0,y=y&15;e:do if(!y)p=0;else for(_=1;;){if(p=Mt(A|0,f|0,(15-_|0)*3|0)|0,Z()|0,p=p&7,p|0)break e;if(_>>>0>>0)_=_+1|0;else{p=0;break}}while(!1);return y=(p|0)==0&1,y|0}function _1(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0;if(M=K,K=K+16|0,T=M,sl(T,A,f,p),f=T,A=d[f>>2]|0,f=d[f+4>>2]|0,(A|0)==0&(f|0)==0)return K=M,0;y=0,p=0;do N=_+(y<<3)|0,d[N>>2]=A,d[N+4>>2]=f,y=Qt(y|0,p|0,1,0)|0,p=Z()|0,uf(T),N=T,A=d[N>>2]|0,f=d[N+4>>2]|0;while(!((A|0)==0&(f|0)==0));return K=M,0}function lp(A,f,p,_){return A=A|0,f=f|0,p=p|0,_=_|0,(_|0)<(p|0)?(p=f,_=A,mt(p|0),_|0):(p=Dt(-1,-1,((_-p|0)*3|0)+3|0)|0,_=Dt(~p|0,~(Z()|0)|0,(15-_|0)*3|0)|0,p=~(Z()|0)&f,_=~_&A,mt(p|0),_|0)}function DA(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0;return y=Mt(A|0,f|0,52)|0,Z()|0,y=y&15,(p|0)<16&(y|0)<=(p|0)?((y|0)<(p|0)&&(y=Dt(-1,-1,((p+-1-y|0)*3|0)+3|0)|0,y=Dt(~y|0,~(Z()|0)|0,(15-p|0)*3|0)|0,f=~(Z()|0)&f,A=~y&A),y=Dt(p|0,0,52)|0,p=f&-15728641|(Z()|0),d[_>>2]=A|y,d[_+4>>2]=p,_=0,_|0):(_=4,_|0)}function up(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0,Bn=0,En=0,Qn=0,Tn=0,on=0,Ut=0;if((p|0)==0&(_|0)==0)return Ut=0,Ut|0;if(y=A,T=d[y>>2]|0,y=d[y+4>>2]|0,!0&(y&15728640|0)==0){if(!((_|0)>0|(_|0)==0&p>>>0>0)||(Ut=f,d[Ut>>2]=T,d[Ut+4>>2]=y,(p|0)==1&(_|0)==0))return Ut=0,Ut|0;y=1,T=0;do Tn=A+(y<<3)|0,on=d[Tn+4>>2]|0,Ut=f+(y<<3)|0,d[Ut>>2]=d[Tn>>2],d[Ut+4>>2]=on,y=Qt(y|0,T|0,1,0)|0,T=Z()|0;while((T|0)<(_|0)|(T|0)==(_|0)&y>>>0

>>0);return y=0,y|0}if(Qn=p<<3,on=Fo(Qn)|0,!on)return Ut=13,Ut|0;if(Gl(on|0,A|0,Qn|0)|0,Tn=Ks(p,8)|0,!Tn)return An(on),Ut=13,Ut|0;e:for(;;){y=on,I=d[y>>2]|0,y=d[y+4>>2]|0,Bn=Mt(I|0,y|0,52)|0,Z()|0,Bn=Bn&15,En=Bn+-1|0,tn=(Bn|0)!=0,sn=(_|0)>0|(_|0)==0&p>>>0>0;t:do if(tn&sn){if(qe=Dt(En|0,0,52)|0,Ge=Z()|0,En>>>0>15){if(!((I|0)==0&(y|0)==0)){Ut=16;break e}for(T=0,A=0;;){if(T=Qt(T|0,A|0,1,0)|0,A=Z()|0,!((A|0)<(_|0)|(A|0)==(_|0)&T>>>0

>>0))break t;if(M=on+(T<<3)|0,Lt=d[M>>2]|0,M=d[M+4>>2]|0,!((Lt|0)==0&(M|0)==0)){y=M,Ut=16;break e}}}for(N=I,A=y,T=0,M=0;;){if(!((N|0)==0&(A|0)==0)){if(!(!0&(A&117440512|0)==0)){Ut=21;break e}if(H=Mt(N|0,A|0,52)|0,Z()|0,H=H&15,(H|0)<(En|0)){y=12,Ut=27;break e}if((H|0)!=(En|0)&&(N=N|qe,A=A&-15728641|Ge,H>>>0>=Bn>>>0)){U=En;do Lt=Dt(7,0,(14-U|0)*3|0)|0,U=U+1|0,N=Lt|N,A=Z()|0|A;while(U>>>0>>0)}if(ge=ec(N|0,A|0,p|0,_|0)|0,Ae=Z()|0,U=Tn+(ge<<3)|0,H=U,ie=d[H>>2]|0,H=d[H+4>>2]|0,!((ie|0)==0&(H|0)==0)){Ie=0,Ye=0;do{if((Ie|0)>(_|0)|(Ie|0)==(_|0)&Ye>>>0>p>>>0){Ut=31;break e}if((ie|0)==(N|0)&(H&-117440513|0)==(A|0)){ve=Mt(ie|0,H|0,56)|0,Z()|0,ve=ve&7,Pe=ve+1|0,Lt=Mt(ie|0,H|0,45)|0,Z()|0;n:do if(!(Bi(Lt&127)|0))H=7;else{if(ie=Mt(ie|0,H|0,52)|0,Z()|0,ie=ie&15,!ie){H=6;break}for(H=1;;){if(Lt=Dt(7,0,(15-H|0)*3|0)|0,!((Lt&N|0)==0&((Z()|0)&A|0)==0)){H=7;break n}if(H>>>0>>0)H=H+1|0;else{H=6;break}}}while(!1);if((ve+2|0)>>>0>H>>>0){Ut=41;break e}Lt=Dt(Pe|0,0,56)|0,A=Z()|0|A&-117440513,Le=U,d[Le>>2]=0,d[Le+4>>2]=0,N=Lt|N}else ge=Qt(ge|0,Ae|0,1,0)|0,ge=th(ge|0,Z()|0,p|0,_|0)|0,Ae=Z()|0;Ye=Qt(Ye|0,Ie|0,1,0)|0,Ie=Z()|0,U=Tn+(ge<<3)|0,H=U,ie=d[H>>2]|0,H=d[H+4>>2]|0}while(!((ie|0)==0&(H|0)==0))}Lt=U,d[Lt>>2]=N,d[Lt+4>>2]=A}if(T=Qt(T|0,M|0,1,0)|0,M=Z()|0,!((M|0)<(_|0)|(M|0)==(_|0)&T>>>0

>>0))break t;A=on+(T<<3)|0,N=d[A>>2]|0,A=d[A+4>>2]|0}}while(!1);if(Lt=Qt(p|0,_|0,5,0)|0,Le=Z()|0,Le>>>0<0|(Le|0)==0&Lt>>>0<11){Ut=85;break}if(Lt=ko(p|0,_|0,6,0)|0,Z()|0,Lt=Ks(Lt,8)|0,!Lt){Ut=48;break}do if(sn){for(Pe=0,A=0,ve=0,Ie=0;;){if(H=Tn+(Pe<<3)|0,M=H,T=d[M>>2]|0,M=d[M+4>>2]|0,(T|0)==0&(M|0)==0)Le=ve;else{ie=Mt(T|0,M|0,56)|0,Z()|0,ie=ie&7,N=ie+1|0,ge=M&-117440513,Le=Mt(T|0,M|0,45)|0,Z()|0;t:do if(Bi(Le&127)|0){if(Ae=Mt(T|0,M|0,52)|0,Z()|0,Ae=Ae&15,Ae|0)for(U=1;;){if(Le=Dt(7,0,(15-U|0)*3|0)|0,!((T&Le|0)==0&(ge&(Z()|0)|0)==0))break t;if(U>>>0>>0)U=U+1|0;else break}M=Dt(N|0,0,56)|0,T=M|T,M=Z()|0|ge,N=H,d[N>>2]=T,d[N+4>>2]=M,N=ie+2|0}while(!1);(N|0)==7?(Le=Lt+(A<<3)|0,d[Le>>2]=T,d[Le+4>>2]=M&-117440513,A=Qt(A|0,ve|0,1,0)|0,Le=Z()|0):Le=ve}if(Pe=Qt(Pe|0,Ie|0,1,0)|0,Ie=Z()|0,(Ie|0)<(_|0)|(Ie|0)==(_|0)&Pe>>>0

>>0)ve=Le;else break}if(sn){if(Ye=En>>>0>15,qe=Dt(En|0,0,52)|0,Ge=Z()|0,!tn){for(T=0,U=0,N=0,M=0;(I|0)==0&(y|0)==0||(En=f+(T<<3)|0,d[En>>2]=I,d[En+4>>2]=y,T=Qt(T|0,U|0,1,0)|0,U=Z()|0),N=Qt(N|0,M|0,1,0)|0,M=Z()|0,!!((M|0)<(_|0)|(M|0)==(_|0)&N>>>0

>>0);)y=on+(N<<3)|0,I=d[y>>2]|0,y=d[y+4>>2]|0;y=Le;break}for(T=0,U=0,M=0,N=0;;){do if(!((I|0)==0&(y|0)==0)){if(Ae=Mt(I|0,y|0,52)|0,Z()|0,Ae=Ae&15,Ye|(Ae|0)<(En|0)){Ut=80;break e}if((Ae|0)!=(En|0)){if(H=I|qe,ie=y&-15728641|Ge,Ae>>>0>=Bn>>>0){ge=En;do tn=Dt(7,0,(14-ge|0)*3|0)|0,ge=ge+1|0,H=tn|H,ie=Z()|0|ie;while(ge>>>0>>0)}}else H=I,ie=y;ve=ec(H|0,ie|0,p|0,_|0)|0,ge=0,Ae=0,Ie=Z()|0;do{if((ge|0)>(_|0)|(ge|0)==(_|0)&Ae>>>0>p>>>0){Ut=81;break e}if(tn=Tn+(ve<<3)|0,Pe=d[tn+4>>2]|0,(Pe&-117440513|0)==(ie|0)&&(d[tn>>2]|0)==(H|0)){Ut=65;break}tn=Qt(ve|0,Ie|0,1,0)|0,ve=th(tn|0,Z()|0,p|0,_|0)|0,Ie=Z()|0,Ae=Qt(Ae|0,ge|0,1,0)|0,ge=Z()|0,tn=Tn+(ve<<3)|0}while(!((d[tn>>2]|0)==(H|0)&&(d[tn+4>>2]|0)==(ie|0)));if((Ut|0)==65&&(Ut=0,!0&(Pe&117440512|0)==100663296))break;tn=f+(T<<3)|0,d[tn>>2]=I,d[tn+4>>2]=y,T=Qt(T|0,U|0,1,0)|0,U=Z()|0}while(!1);if(M=Qt(M|0,N|0,1,0)|0,N=Z()|0,!((N|0)<(_|0)|(N|0)==(_|0)&M>>>0

>>0))break;y=on+(M<<3)|0,I=d[y>>2]|0,y=d[y+4>>2]|0}y=Le}else T=0,y=Le}else T=0,A=0,y=0;while(!1);if(uo(Tn|0,0,Qn|0)|0,Gl(on|0,Lt|0,A<<3|0)|0,An(Lt),(A|0)==0&(y|0)==0){Ut=89;break}else f=f+(T<<3)|0,_=y,p=A}if((Ut|0)==16)!0&(y&117440512|0)==0?(y=4,Ut=27):Ut=21;else if((Ut|0)==31)Bt(27795,27122,620,27132);else{if((Ut|0)==41)return An(on),An(Tn),Ut=10,Ut|0;if((Ut|0)==48)return An(on),An(Tn),Ut=13,Ut|0;(Ut|0)==80?Bt(27795,27122,711,27132):(Ut|0)==81?Bt(27795,27122,723,27132):(Ut|0)==85&&(Gl(f|0,on|0,p<<3|0)|0,Ut=89)}return(Ut|0)==21?(An(on),An(Tn),Ut=5,Ut|0):(Ut|0)==27?(An(on),An(Tn),Ut=y,Ut|0):(Ut|0)==89?(An(on),An(Tn),Ut=0,Ut|0):0}function y1(A,f,p,_,y,T,M){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0;var N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0;if(Pe=K,K=K+16|0,ve=Pe,!((p|0)>0|(p|0)==0&f>>>0>0))return ve=0,K=Pe,ve|0;if((M|0)>=16)return ve=12,K=Pe,ve|0;ge=0,Ae=0,ie=0,N=0;e:for(;;){if(I=A+(ge<<3)|0,U=d[I>>2]|0,I=d[I+4>>2]|0,H=Mt(U|0,I|0,52)|0,Z()|0,(H&15|0)>(M|0)){N=12,U=11;break}if(sl(ve,U,I,M),H=ve,I=d[H>>2]|0,H=d[H+4>>2]|0,(I|0)==0&(H|0)==0)U=ie;else{U=ie;do{if(!((N|0)<(T|0)|(N|0)==(T|0)&U>>>0>>0)){U=10;break e}ie=_+(U<<3)|0,d[ie>>2]=I,d[ie+4>>2]=H,U=Qt(U|0,N|0,1,0)|0,N=Z()|0,uf(ve),ie=ve,I=d[ie>>2]|0,H=d[ie+4>>2]|0}while(!((I|0)==0&(H|0)==0))}if(ge=Qt(ge|0,Ae|0,1,0)|0,Ae=Z()|0,(Ae|0)<(p|0)|(Ae|0)==(p|0)&ge>>>0>>0)ie=U;else{N=0,U=11;break}}return(U|0)==10?(ve=14,K=Pe,ve|0):(U|0)==11?(K=Pe,N|0):0}function x1(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0;ge=K,K=K+16|0,ie=ge;e:do if((p|0)>0|(p|0)==0&f>>>0>0){for(I=0,M=0,T=0,H=0;;){if(U=A+(I<<3)|0,N=d[U>>2]|0,U=d[U+4>>2]|0,!((N|0)==0&(U|0)==0)&&(U=(lf(N,U,_,ie)|0)==0,N=ie,M=Qt(d[N>>2]|0,d[N+4>>2]|0,M|0,T|0)|0,T=Z()|0,!U)){T=12;break}if(I=Qt(I|0,H|0,1,0)|0,H=Z()|0,!((H|0)<(p|0)|(H|0)==(p|0)&I>>>0>>0))break e}return K=ge,T|0}else M=0,T=0;while(!1);return d[y>>2]=M,d[y+4>>2]=T,y=0,K=ge,y|0}function b1(A,f){return A=A|0,f=f|0,f=Mt(A|0,f|0,52)|0,Z()|0,f&1|0}function $s(A,f){A=A|0,f=f|0;var p=0,_=0,y=0;if(y=Mt(A|0,f|0,52)|0,Z()|0,y=y&15,!y)return y=0,y|0;for(_=1;;){if(p=Mt(A|0,f|0,(15-_|0)*3|0)|0,Z()|0,p=p&7,p|0){_=5;break}if(_>>>0>>0)_=_+1|0;else{p=0,_=5;break}}return(_|0)==5?p|0:0}function cp(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0;if(U=Mt(A|0,f|0,52)|0,Z()|0,U=U&15,!U)return N=f,U=A,mt(N|0),U|0;for(N=1,p=0;;){T=(15-N|0)*3|0,_=Dt(7,0,T|0)|0,y=Z()|0,M=Mt(A|0,f|0,T|0)|0,Z()|0,T=Dt(Uu(M&7)|0,0,T|0)|0,M=Z()|0,A=T|A&~_,f=M|f&~y;e:do if(!p)if((T&_|0)==0&(M&y|0)==0)p=0;else if(_=Mt(A|0,f|0,52)|0,Z()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Mt(A|0,f|0,(15-p|0)*3|0)|0,Z()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(M=(15-p|0)*3|0,y=Mt(A|0,f|0,M|0)|0,Z()|0,T=Dt(7,0,M|0)|0,f=f&~(Z()|0),M=Dt(Uu(y&7)|0,0,M|0)|0,A=A&~T|M,f=f|(Z()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(N>>>0>>0)N=N+1|0;else break}return mt(f|0),A|0}function ku(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0;if(_=Mt(A|0,f|0,52)|0,Z()|0,_=_&15,!_)return p=f,_=A,mt(p|0),_|0;for(p=1;T=(15-p|0)*3|0,M=Mt(A|0,f|0,T|0)|0,Z()|0,y=Dt(7,0,T|0)|0,f=f&~(Z()|0),T=Dt(Uu(M&7)|0,0,T|0)|0,A=T|A&~y,f=Z()|0|f,p>>>0<_>>>0;)p=p+1|0;return mt(f|0),A|0}function Tx(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0;if(U=Mt(A|0,f|0,52)|0,Z()|0,U=U&15,!U)return N=f,U=A,mt(N|0),U|0;for(N=1,p=0;;){T=(15-N|0)*3|0,_=Dt(7,0,T|0)|0,y=Z()|0,M=Mt(A|0,f|0,T|0)|0,Z()|0,T=Dt(rl(M&7)|0,0,T|0)|0,M=Z()|0,A=T|A&~_,f=M|f&~y;e:do if(!p)if((T&_|0)==0&(M&y|0)==0)p=0;else if(_=Mt(A|0,f|0,52)|0,Z()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Mt(A|0,f|0,(15-p|0)*3|0)|0,Z()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(y=(15-p|0)*3|0,T=Dt(7,0,y|0)|0,M=f&~(Z()|0),f=Mt(A|0,f|0,y|0)|0,Z()|0,f=Dt(rl(f&7)|0,0,y|0)|0,A=A&~T|f,f=M|(Z()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(N>>>0>>0)N=N+1|0;else break}return mt(f|0),A|0}function hp(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0;if(_=Mt(A|0,f|0,52)|0,Z()|0,_=_&15,!_)return p=f,_=A,mt(p|0),_|0;for(p=1;M=(15-p|0)*3|0,T=Dt(7,0,M|0)|0,y=f&~(Z()|0),f=Mt(A|0,f|0,M|0)|0,Z()|0,f=Dt(rl(f&7)|0,0,M|0)|0,A=f|A&~T,f=Z()|0|y,p>>>0<_>>>0;)p=p+1|0;return mt(f|0),A|0}function Aa(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(U=K,K=K+64|0,N=U+40|0,_=U+24|0,y=U+12|0,T=U,Dt(f|0,0,52)|0,p=Z()|0|134225919,!f)return(d[A+4>>2]|0)>2||(d[A+8>>2]|0)>2||(d[A+12>>2]|0)>2?(M=0,N=0,mt(M|0),K=U,N|0):(Dt(Po(A)|0,0,45)|0,M=Z()|0|p,N=-1,mt(M|0),K=U,N|0);if(d[N>>2]=d[A>>2],d[N+4>>2]=d[A+4>>2],d[N+8>>2]=d[A+8>>2],d[N+12>>2]=d[A+12>>2],M=N+4|0,(f|0)>0)for(A=-1;d[_>>2]=d[M>>2],d[_+4>>2]=d[M+4>>2],d[_+8>>2]=d[M+8>>2],f&1?(hx(M),d[y>>2]=d[M>>2],d[y+4>>2]=d[M+4>>2],d[y+8>>2]=d[M+8>>2],Yc(y)):(l1(M),d[y>>2]=d[M>>2],d[y+4>>2]=d[M+4>>2],d[y+8>>2]=d[M+8>>2],Lu(y)),af(_,y,T),Lr(T),H=(15-f|0)*3|0,I=Dt(7,0,H|0)|0,p=p&~(Z()|0),H=Dt(Pu(T)|0,0,H|0)|0,A=H|A&~I,p=Z()|0|p,(f|0)>1;)f=f+-1|0;else A=-1;e:do if((d[M>>2]|0)<=2&&(d[N+8>>2]|0)<=2&&(d[N+12>>2]|0)<=2){if(_=Po(N)|0,f=Dt(_|0,0,45)|0,f=f|A,A=Z()|0|p&-1040385,T=ep(N)|0,!(Bi(_)|0)){if((T|0)<=0)break;for(y=0;;){if(_=Mt(f|0,A|0,52)|0,Z()|0,_=_&15,_)for(p=1;H=(15-p|0)*3|0,N=Mt(f|0,A|0,H|0)|0,Z()|0,I=Dt(7,0,H|0)|0,A=A&~(Z()|0),H=Dt(Uu(N&7)|0,0,H|0)|0,f=f&~I|H,A=A|(Z()|0),p>>>0<_>>>0;)p=p+1|0;if(y=y+1|0,(y|0)==(T|0))break e}}y=Mt(f|0,A|0,52)|0,Z()|0,y=y&15;t:do if(y){p=1;n:for(;;){switch(H=Mt(f|0,A|0,(15-p|0)*3|0)|0,Z()|0,H&7){case 1:break n;case 0:break;default:break t}if(p>>>0>>0)p=p+1|0;else break t}if(Ru(_,d[N>>2]|0)|0)for(p=1;N=(15-p|0)*3|0,I=Dt(7,0,N|0)|0,H=A&~(Z()|0),A=Mt(f|0,A|0,N|0)|0,Z()|0,A=Dt(rl(A&7)|0,0,N|0)|0,f=f&~I|A,A=H|(Z()|0),p>>>0>>0;)p=p+1|0;else for(p=1;H=(15-p|0)*3|0,N=Mt(f|0,A|0,H|0)|0,Z()|0,I=Dt(7,0,H|0)|0,A=A&~(Z()|0),H=Dt(Uu(N&7)|0,0,H|0)|0,f=f&~I|H,A=A|(Z()|0),p>>>0>>0;)p=p+1|0}while(!1);if((T|0)>0){p=0;do f=cp(f,A)|0,A=Z()|0,p=p+1|0;while((p|0)!=(T|0))}}else f=0,A=0;while(!1);return I=A,H=f,mt(I|0),K=U,H|0}function Ss(A){return A=A|0,(A|0)%2|0|0}function PA(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0;return y=K,K=K+16|0,_=y,f>>>0>15?(_=4,K=y,_|0):(d[A+4>>2]&2146435072|0)==2146435072||(d[A+8+4>>2]&2146435072|0)==2146435072?(_=3,K=y,_|0):(_x(A,f,_),f=Aa(_,f)|0,_=Z()|0,d[p>>2]=f,d[p+4>>2]=_,(f|0)==0&(_|0)==0&&Bt(27795,27122,1050,27145),_=0,K=y,_|0)}function LA(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0;if(y=p+4|0,T=Mt(A|0,f|0,52)|0,Z()|0,T=T&15,M=Mt(A|0,f|0,45)|0,Z()|0,_=(T|0)==0,Bi(M&127)|0){if(_)return M=1,M|0;_=1}else{if(_)return M=0,M|0;(d[y>>2]|0)==0&&(d[p+8>>2]|0)==0?_=(d[p+12>>2]|0)!=0&1:_=1}for(p=1;p&1?Yc(y):Lu(y),M=Mt(A|0,f|0,(15-p|0)*3|0)|0,Z()|0,u1(y,M&7),p>>>0>>0;)p=p+1|0;return _|0}function zu(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(H=K,K=K+16|0,U=H,I=Mt(A|0,f|0,45)|0,Z()|0,I=I&127,I>>>0>121)return d[p>>2]=0,d[p+4>>2]=0,d[p+8>>2]=0,d[p+12>>2]=0,I=5,K=H,I|0;e:do if((Bi(I)|0)!=0&&(T=Mt(A|0,f|0,52)|0,Z()|0,T=T&15,(T|0)!=0)){_=1;t:for(;;){switch(N=Mt(A|0,f|0,(15-_|0)*3|0)|0,Z()|0,N&7){case 5:break t;case 0:break;default:{_=f;break e}}if(_>>>0>>0)_=_+1|0;else{_=f;break e}}for(y=1,_=f;f=(15-y|0)*3|0,M=Dt(7,0,f|0)|0,N=_&~(Z()|0),_=Mt(A|0,_|0,f|0)|0,Z()|0,_=Dt(rl(_&7)|0,0,f|0)|0,A=A&~M|_,_=N|(Z()|0),y>>>0>>0;)y=y+1|0}else _=f;while(!1);if(N=7696+(I*28|0)|0,d[p>>2]=d[N>>2],d[p+4>>2]=d[N+4>>2],d[p+8>>2]=d[N+8>>2],d[p+12>>2]=d[N+12>>2],!(LA(A,_,p)|0))return I=0,K=H,I|0;if(M=p+4|0,d[U>>2]=d[M>>2],d[U+4>>2]=d[M+4>>2],d[U+8>>2]=d[M+8>>2],T=Mt(A|0,_|0,52)|0,Z()|0,N=T&15,T&1?(Lu(M),T=N+1|0):T=N,!(Bi(I)|0))_=0;else{e:do if(!N)_=0;else for(f=1;;){if(y=Mt(A|0,_|0,(15-f|0)*3|0)|0,Z()|0,y=y&7,y|0){_=y;break e}if(f>>>0>>0)f=f+1|0;else{_=0;break}}while(!1);_=(_|0)==4&1}if(!(Ou(p,T,_,0)|0))(T|0)!=(N|0)&&(d[M>>2]=d[U>>2],d[M+4>>2]=d[U+4>>2],d[M+8>>2]=d[U+8>>2]);else{if(Bi(I)|0)do;while((Ou(p,T,0,0)|0)!=0);(T|0)!=(N|0)&&l1(M)}return I=0,K=H,I|0}function Ol(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0;return T=K,K=K+16|0,_=T,y=zu(A,f,_)|0,y|0?(K=T,y|0):(y=Mt(A|0,f|0,52)|0,Z()|0,of(_,y&15,p),y=0,K=T,y|0)}function Il(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0;if(M=K,K=K+16|0,T=M,_=zu(A,f,T)|0,_|0)return T=_,K=M,T|0;_=Mt(A|0,f|0,45)|0,Z()|0,_=(Bi(_&127)|0)==0,y=Mt(A|0,f|0,52)|0,Z()|0,y=y&15;e:do if(!_){if(y|0)for(_=1;;){if(N=Dt(7,0,(15-_|0)*3|0)|0,!((N&A|0)==0&((Z()|0)&f|0)==0))break e;if(_>>>0>>0)_=_+1|0;else break}return sp(T,y,0,5,p),N=0,K=M,N|0}while(!1);return RA(T,y,0,6,p),N=0,K=M,N|0}function wx(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0;if(y=Mt(A|0,f|0,45)|0,Z()|0,!(Bi(y&127)|0))return y=2,d[p>>2]=y,0;if(y=Mt(A|0,f|0,52)|0,Z()|0,y=y&15,!y)return y=5,d[p>>2]=y,0;for(_=1;;){if(T=Dt(7,0,(15-_|0)*3|0)|0,!((T&A|0)==0&((Z()|0)&f|0)==0)){_=2,A=6;break}if(_>>>0>>0)_=_+1|0;else{_=5,A=6;break}}return(A|0)==6&&(d[p>>2]=_),0}function Gu(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0;ie=K,K=K+128|0,I=ie+112|0,T=ie+96|0,H=ie,y=Mt(A|0,f|0,52)|0,Z()|0,N=y&15,d[I>>2]=N,M=Mt(A|0,f|0,45)|0,Z()|0,M=M&127;e:do if(Bi(M)|0){if(N|0)for(_=1;;){if(U=Dt(7,0,(15-_|0)*3|0)|0,!((U&A|0)==0&((Z()|0)&f|0)==0)){y=0;break e}if(_>>>0>>0)_=_+1|0;else break}if(y&1)y=1;else return U=Dt(N+1|0,0,52)|0,H=Z()|0|f&-15728641,I=Dt(7,0,(14-N|0)*3|0)|0,H=Gu((U|A)&~I,H&~(Z()|0),p)|0,K=ie,H|0}else y=0;while(!1);if(_=zu(A,f,T)|0,!_){y?(ap(T,I,H),U=5):(op(T,I,H),U=6);e:do if(Bi(M)|0)if(!N)A=5;else for(_=1;;){if(M=Dt(7,0,(15-_|0)*3|0)|0,!((M&A|0)==0&((Z()|0)&f|0)==0)){A=2;break e}if(_>>>0>>0)_=_+1|0;else{A=5;break}}else A=2;while(!1);uo(p|0,-1,A<<2|0)|0;e:do if(y)for(T=0;;){if(M=H+(T<<4)|0,m1(M,d[I>>2]|0)|0,M=d[M>>2]|0,N=d[p>>2]|0,(N|0)==-1|(N|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=A>>>0){_=1;break e}_=p+(y<<2)|0,N=d[_>>2]|0}while(!((N|0)==-1|(N|0)==(M|0)))}if(d[_>>2]=M,T=T+1|0,T>>>0>=U>>>0){_=0;break}}else for(T=0;;){if(M=H+(T<<4)|0,Ou(M,d[I>>2]|0,0,1)|0,M=d[M>>2]|0,N=d[p>>2]|0,(N|0)==-1|(N|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=A>>>0){_=1;break e}_=p+(y<<2)|0,N=d[_>>2]|0}while(!((N|0)==-1|(N|0)==(M|0)))}if(d[_>>2]=M,T=T+1|0,T>>>0>=U>>>0){_=0;break}}while(!1)}return H=_,K=ie,H|0}function fp(){return 12}function qu(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0;if(A>>>0>15)return N=4,N|0;if(Dt(A|0,0,52)|0,N=Z()|0|134225919,!A){p=0,_=0;do Bi(_)|0&&(Dt(_|0,0,45)|0,M=N|(Z()|0),A=f+(p<<3)|0,d[A>>2]=-1,d[A+4>>2]=M,p=p+1|0),_=_+1|0;while((_|0)!=122);return p=0,p|0}p=0,M=0;do{if(Bi(M)|0){for(Dt(M|0,0,45)|0,_=1,y=-1,T=N|(Z()|0);U=Dt(7,0,(15-_|0)*3|0)|0,y=y&~U,T=T&~(Z()|0),(_|0)!=(A|0);)_=_+1|0;U=f+(p<<3)|0,d[U>>2]=y,d[U+4>>2]=T,p=p+1|0}M=M+1|0}while((M|0)!=122);return p=0,p|0}function Ap(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0;if(qe=K,K=K+16|0,Ie=qe,Ye=Mt(A|0,f|0,52)|0,Z()|0,Ye=Ye&15,p>>>0>15)return Ye=4,K=qe,Ye|0;if((Ye|0)<(p|0))return Ye=12,K=qe,Ye|0;if((Ye|0)!=(p|0))if(T=Dt(p|0,0,52)|0,T=T|A,N=Z()|0|f&-15728641,(Ye|0)>(p|0)){U=p;do Pe=Dt(7,0,(14-U|0)*3|0)|0,U=U+1|0,T=Pe|T,N=Z()|0|N;while((U|0)<(Ye|0));Pe=T}else Pe=T;else Pe=A,N=f;ve=Mt(Pe|0,N|0,45)|0,Z()|0;e:do if(Bi(ve&127)|0){if(U=Mt(Pe|0,N|0,52)|0,Z()|0,U=U&15,U|0)for(T=1;;){if(ve=Dt(7,0,(15-T|0)*3|0)|0,!((ve&Pe|0)==0&((Z()|0)&N|0)==0)){I=33;break e}if(T>>>0>>0)T=T+1|0;else break}if(ve=_,d[ve>>2]=0,d[ve+4>>2]=0,(Ye|0)>(p|0)){for(ve=f&-15728641,Ae=Ye;;){if(ge=Ae,Ae=Ae+-1|0,Ae>>>0>15|(Ye|0)<(Ae|0)){I=19;break}if((Ye|0)!=(Ae|0))if(T=Dt(Ae|0,0,52)|0,T=T|A,U=Z()|0|ve,(Ye|0)<(ge|0))ie=T;else{I=Ae;do ie=Dt(7,0,(14-I|0)*3|0)|0,I=I+1|0,T=ie|T,U=Z()|0|U;while((I|0)<(Ye|0));ie=T}else ie=A,U=f;if(H=Mt(ie|0,U|0,45)|0,Z()|0,!(Bi(H&127)|0))T=0;else{H=Mt(ie|0,U|0,52)|0,Z()|0,H=H&15;t:do if(!H)T=0;else for(I=1;;){if(T=Mt(ie|0,U|0,(15-I|0)*3|0)|0,Z()|0,T=T&7,T|0)break t;if(I>>>0>>0)I=I+1|0;else{T=0;break}}while(!1);T=(T|0)==0&1}if(U=Mt(A|0,f|0,(15-ge|0)*3|0)|0,Z()|0,U=U&7,(U|0)==7){y=5,I=42;break}if(T=(T|0)!=0,(U|0)==1&T){y=5,I=42;break}if(ie=U+(((U|0)!=0&T)<<31>>31)|0,ie|0&&(I=Ye-ge|0,I=Bo(7,0,I,((I|0)<0)<<31>>31)|0,H=Z()|0,T?(T=fr(I|0,H|0,5,0)|0,T=Qt(T|0,Z()|0,-5,-1)|0,T=ko(T|0,Z()|0,6,0)|0,T=Qt(T|0,Z()|0,1,0)|0,U=Z()|0):(T=I,U=H),ge=ie+-1|0,ge=fr(I|0,H|0,ge|0,((ge|0)<0)<<31>>31|0)|0,ge=Qt(T|0,U|0,ge|0,Z()|0)|0,ie=Z()|0,H=_,H=Qt(ge|0,ie|0,d[H>>2]|0,d[H+4>>2]|0)|0,ie=Z()|0,ge=_,d[ge>>2]=H,d[ge+4>>2]=ie),(Ae|0)<=(p|0)){I=37;break}}if((I|0)==19)Bt(27795,27122,1367,27158);else if((I|0)==37){M=_,y=d[M+4>>2]|0,M=d[M>>2]|0;break}else if((I|0)==42)return K=qe,y|0}else y=0,M=0}else I=33;while(!1);e:do if((I|0)==33)if(ve=_,d[ve>>2]=0,d[ve+4>>2]=0,(Ye|0)>(p|0)){for(T=Ye;;){if(y=Mt(A|0,f|0,(15-T|0)*3|0)|0,Z()|0,y=y&7,(y|0)==7){y=5;break}if(M=Ye-T|0,M=Bo(7,0,M,((M|0)<0)<<31>>31)|0,y=fr(M|0,Z()|0,y|0,0)|0,M=Z()|0,ve=_,M=Qt(d[ve>>2]|0,d[ve+4>>2]|0,y|0,M|0)|0,y=Z()|0,ve=_,d[ve>>2]=M,d[ve+4>>2]=y,T=T+-1|0,(T|0)<=(p|0))break e}return K=qe,y|0}else y=0,M=0;while(!1);return lf(Pe,N,Ye,Ie)|0&&Bt(27795,27122,1327,27173),Ye=Ie,Ie=d[Ye+4>>2]|0,((y|0)>-1|(y|0)==-1&M>>>0>4294967295)&((Ie|0)>(y|0)|((Ie|0)==(y|0)?(d[Ye>>2]|0)>>>0>M>>>0:0))?(Ye=0,K=qe,Ye|0):(Bt(27795,27122,1407,27158),0)}function S1(A,f,p,_,y,T){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0;if(ie=K,K=K+16|0,M=ie,y>>>0>15)return T=4,K=ie,T|0;if(N=Mt(p|0,_|0,52)|0,Z()|0,N=N&15,(N|0)>(y|0))return T=12,K=ie,T|0;if(lf(p,_,y,M)|0&&Bt(27795,27122,1327,27173),H=M,I=d[H+4>>2]|0,!(((f|0)>-1|(f|0)==-1&A>>>0>4294967295)&((I|0)>(f|0)|((I|0)==(f|0)?(d[H>>2]|0)>>>0>A>>>0:0))))return T=2,K=ie,T|0;H=y-N|0,y=Dt(y|0,0,52)|0,U=Z()|0|_&-15728641,I=T,d[I>>2]=y|p,d[I+4>>2]=U,I=Mt(p|0,_|0,45)|0,Z()|0;e:do if(Bi(I&127)|0){if(N|0)for(M=1;;){if(I=Dt(7,0,(15-M|0)*3|0)|0,!((I&p|0)==0&((Z()|0)&_|0)==0))break e;if(M>>>0>>0)M=M+1|0;else break}if((H|0)<1)return T=0,K=ie,T|0;for(I=N^15,_=-1,U=1,M=1;;){N=H-U|0,N=Bo(7,0,N,((N|0)<0)<<31>>31)|0,p=Z()|0;do if(M)if(M=fr(N|0,p|0,5,0)|0,M=Qt(M|0,Z()|0,-5,-1)|0,M=ko(M|0,Z()|0,6,0)|0,y=Z()|0,(f|0)>(y|0)|(f|0)==(y|0)&A>>>0>M>>>0){f=Qt(A|0,f|0,-1,-1)|0,f=Ur(f|0,Z()|0,M|0,y|0)|0,M=Z()|0,ge=T,ve=d[ge>>2]|0,ge=d[ge+4>>2]|0,Pe=(I+_|0)*3|0,Ae=Dt(7,0,Pe|0)|0,ge=ge&~(Z()|0),_=ko(f|0,M|0,N|0,p|0)|0,A=Z()|0,y=Qt(_|0,A|0,2,0)|0,Pe=Dt(y|0,Z()|0,Pe|0)|0,ge=Z()|0|ge,y=T,d[y>>2]=Pe|ve&~Ae,d[y+4>>2]=ge,A=fr(_|0,A|0,N|0,p|0)|0,A=Ur(f|0,M|0,A|0,Z()|0)|0,M=0,f=Z()|0;break}else{Pe=T,Ae=d[Pe>>2]|0,Pe=d[Pe+4>>2]|0,ve=Dt(7,0,(I+_|0)*3|0)|0,Pe=Pe&~(Z()|0),M=T,d[M>>2]=Ae&~ve,d[M+4>>2]=Pe,M=1;break}else Ae=T,y=d[Ae>>2]|0,Ae=d[Ae+4>>2]|0,_=(I+_|0)*3|0,ge=Dt(7,0,_|0)|0,Ae=Ae&~(Z()|0),Pe=ko(A|0,f|0,N|0,p|0)|0,M=Z()|0,_=Dt(Pe|0,M|0,_|0)|0,Ae=Z()|0|Ae,ve=T,d[ve>>2]=_|y&~ge,d[ve+4>>2]=Ae,M=fr(Pe|0,M|0,N|0,p|0)|0,A=Ur(A|0,f|0,M|0,Z()|0)|0,M=0,f=Z()|0;while(!1);if((H|0)>(U|0))_=~U,U=U+1|0;else{f=0;break}}return K=ie,f|0}while(!1);if((H|0)<1)return Pe=0,K=ie,Pe|0;for(y=N^15,M=1;;)if(ve=H-M|0,ve=Bo(7,0,ve,((ve|0)<0)<<31>>31)|0,Pe=Z()|0,U=T,p=d[U>>2]|0,U=d[U+4>>2]|0,N=(y-M|0)*3|0,_=Dt(7,0,N|0)|0,U=U&~(Z()|0),ge=ko(A|0,f|0,ve|0,Pe|0)|0,Ae=Z()|0,N=Dt(ge|0,Ae|0,N|0)|0,U=Z()|0|U,I=T,d[I>>2]=N|p&~_,d[I+4>>2]=U,Pe=fr(ge|0,Ae|0,ve|0,Pe|0)|0,A=Ur(A|0,f|0,Pe|0,Z()|0)|0,f=Z()|0,(H|0)<=(M|0)){f=0;break}else M=M+1|0;return K=ie,f|0}function sl(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0;y=Mt(f|0,p|0,52)|0,Z()|0,y=y&15,(f|0)==0&(p|0)==0|((_|0)>15|(y|0)>(_|0))?(T=-1,f=-1,p=0,y=0):(f=lp(f,p,y+1|0,_)|0,M=(Z()|0)&-15728641,p=Dt(_|0,0,52)|0,p=f|p,M=M|(Z()|0),f=(Ci(p,M)|0)==0,T=y,f=f?-1:_,y=M),M=A,d[M>>2]=p,d[M+4>>2]=y,d[A+8>>2]=T,d[A+12>>2]=f}function Vu(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0;if(y=Mt(A|0,f|0,52)|0,Z()|0,y=y&15,T=_+8|0,d[T>>2]=y,(A|0)==0&(f|0)==0|((p|0)>15|(y|0)>(p|0))){p=_,d[p>>2]=0,d[p+4>>2]=0,d[T>>2]=-1,d[_+12>>2]=-1;return}if(A=lp(A,f,y+1|0,p)|0,T=(Z()|0)&-15728641,y=Dt(p|0,0,52)|0,y=A|y,T=T|(Z()|0),A=_,d[A>>2]=y,d[A+4>>2]=T,A=_+12|0,Ci(y,T)|0){d[A>>2]=p;return}else{d[A>>2]=-1;return}}function uf(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0;if(p=A,f=d[p>>2]|0,p=d[p+4>>2]|0,!((f|0)==0&(p|0)==0)&&(_=Mt(f|0,p|0,52)|0,Z()|0,_=_&15,N=Dt(1,0,(_^15)*3|0)|0,f=Qt(N|0,Z()|0,f|0,p|0)|0,p=Z()|0,N=A,d[N>>2]=f,d[N+4>>2]=p,N=A+8|0,M=d[N>>2]|0,!((_|0)<(M|0)))){for(U=A+12|0,T=_;;){if((T|0)==(M|0)){_=5;break}if(I=(T|0)==(d[U>>2]|0),y=(15-T|0)*3|0,_=Mt(f|0,p|0,y|0)|0,Z()|0,_=_&7,I&((_|0)==1&!0)){_=7;break}if(!((_|0)==7&!0)){_=10;break}if(I=Dt(1,0,y|0)|0,f=Qt(f|0,p|0,I|0,Z()|0)|0,p=Z()|0,I=A,d[I>>2]=f,d[I+4>>2]=p,(T|0)>(M|0))T=T+-1|0;else{_=10;break}}if((_|0)==5){I=A,d[I>>2]=0,d[I+4>>2]=0,d[N>>2]=-1,d[U>>2]=-1;return}else if((_|0)==7){M=Dt(1,0,y|0)|0,M=Qt(f|0,p|0,M|0,Z()|0)|0,N=Z()|0,I=A,d[I>>2]=M,d[I+4>>2]=N,d[U>>2]=T+-1;return}else if((_|0)==10)return}}function Kc(A){A=+A;var f=0;return f=A<0?A+6.283185307179586:A,+(A>=6.283185307179586?f+-6.283185307179586:f)}function Ea(A,f){return A=A|0,f=f|0,+un(+(+J[A>>3]-+J[f>>3]))<17453292519943298e-27?(f=+un(+(+J[A+8>>3]-+J[f+8>>3]))<17453292519943298e-27,f|0):(f=0,f|0)}function Xs(A,f){switch(A=+A,f=f|0,f|0){case 1:{A=A<0?A+6.283185307179586:A;break}case 2:{A=A>0?A+-6.283185307179586:A;break}}return+A}function T1(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0;return y=+J[f>>3],_=+J[A>>3],T=+Fn(+((y-_)*.5)),p=+Fn(+((+J[f+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+li(+y)*+li(+_)*p),+(+Fe(+ +qn(+p),+ +qn(+(1-p)))*2)}function Zc(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0;return y=+J[f>>3],_=+J[A>>3],T=+Fn(+((y-_)*.5)),p=+Fn(+((+J[f+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+li(+y)*+li(+_)*p),+(+Fe(+ +qn(+p),+ +qn(+(1-p)))*2*6371.007180918475)}function Mx(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0;return y=+J[f>>3],_=+J[A>>3],T=+Fn(+((y-_)*.5)),p=+Fn(+((+J[f+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+li(+y)*+li(+_)*p),+(+Fe(+ +qn(+p),+ +qn(+(1-p)))*2*6371.007180918475*1e3)}function Ex(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0;return T=+J[f>>3],_=+li(+T),y=+J[f+8>>3]-+J[A+8>>3],M=_*+Fn(+y),p=+J[A>>3],+ +Fe(+M,+(+Fn(+T)*+li(+p)-+li(+y)*(_*+Fn(+p))))}function Cx(A,f,p,_){A=A|0,f=+f,p=+p,_=_|0;var y=0,T=0,M=0,N=0;if(p<1e-16){d[_>>2]=d[A>>2],d[_+4>>2]=d[A+4>>2],d[_+8>>2]=d[A+8>>2],d[_+12>>2]=d[A+12>>2];return}T=f<0?f+6.283185307179586:f,T=f>=6.283185307179586?T+-6.283185307179586:T;do if(T<1e-16)f=+J[A>>3]+p,J[_>>3]=f,y=_;else{if(y=+un(+(T+-3.141592653589793))<1e-16,f=+J[A>>3],y){f=f-p,J[_>>3]=f,y=_;break}if(M=+li(+p),p=+Fn(+p),f=M*+Fn(+f)+ +li(+T)*(p*+li(+f)),f=f>1?1:f,f=+Ul(+(f<-1?-1:f)),J[_>>3]=f,+un(+(f+-1.5707963267948966))<1e-16){J[_>>3]=1.5707963267948966,J[_+8>>3]=0;return}if(+un(+(f+1.5707963267948966))<1e-16){J[_>>3]=-1.5707963267948966,J[_+8>>3]=0;return}if(N=1/+li(+f),T=p*+Fn(+T)*N,p=+J[A>>3],f=N*((M-+Fn(+f)*+Fn(+p))/+li(+p)),M=T>1?1:T,f=f>1?1:f,f=+J[A+8>>3]+ +Fe(+(M<-1?-1:M),+(f<-1?-1:f)),f>3.141592653589793)do f=f+-6.283185307179586;while(f>3.141592653589793);if(f<-3.141592653589793)do f=f+6.283185307179586;while(f<-3.141592653589793);J[_+8>>3]=f;return}while(!1);if(+un(+(f+-1.5707963267948966))<1e-16){J[y>>3]=1.5707963267948966,J[_+8>>3]=0;return}if(+un(+(f+1.5707963267948966))<1e-16){J[y>>3]=-1.5707963267948966,J[_+8>>3]=0;return}if(f=+J[A+8>>3],f>3.141592653589793)do f=f+-6.283185307179586;while(f>3.141592653589793);if(f<-3.141592653589793)do f=f+6.283185307179586;while(f<-3.141592653589793);J[_+8>>3]=f}function dp(A,f){return A=A|0,f=f|0,A>>>0>15?(f=4,f|0):(J[f>>3]=+J[20656+(A<<3)>>3],f=0,f|0)}function w1(A,f){return A=A|0,f=f|0,A>>>0>15?(f=4,f|0):(J[f>>3]=+J[20784+(A<<3)>>3],f=0,f|0)}function pp(A,f){return A=A|0,f=f|0,A>>>0>15?(f=4,f|0):(J[f>>3]=+J[20912+(A<<3)>>3],f=0,f|0)}function oo(A,f){return A=A|0,f=f|0,A>>>0>15?(f=4,f|0):(J[f>>3]=+J[21040+(A<<3)>>3],f=0,f|0)}function Hu(A,f){A=A|0,f=f|0;var p=0;return A>>>0>15?(f=4,f|0):(p=Bo(7,0,A,((A|0)<0)<<31>>31)|0,p=fr(p|0,Z()|0,120,0)|0,A=Z()|0,d[f>>2]=p|2,d[f+4>>2]=A,f=0,f|0)}function da(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0;return ge=+J[f>>3],H=+J[A>>3],U=+Fn(+((ge-H)*.5)),T=+J[f+8>>3],I=+J[A+8>>3],M=+Fn(+((T-I)*.5)),N=+li(+H),ie=+li(+ge),M=U*U+M*(ie*N*M),M=+Fe(+ +qn(+M),+ +qn(+(1-M)))*2,U=+J[p>>3],ge=+Fn(+((U-ge)*.5)),_=+J[p+8>>3],T=+Fn(+((_-T)*.5)),y=+li(+U),T=ge*ge+T*(ie*y*T),T=+Fe(+ +qn(+T),+ +qn(+(1-T)))*2,U=+Fn(+((H-U)*.5)),_=+Fn(+((I-_)*.5)),_=U*U+_*(N*y*_),_=+Fe(+ +qn(+_),+ +qn(+(1-_)))*2,y=(M+T+_)*.5,+(+oe(+ +qn(+(+cs(+(y*.5))*+cs(+((y-M)*.5))*+cs(+((y-T)*.5))*+cs(+((y-_)*.5)))))*4)}function Fl(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0;if(N=K,K=K+192|0,T=N+168|0,M=N,y=Ol(A,f,T)|0,y|0)return p=y,K=N,p|0;if(Il(A,f,M)|0&&Bt(27795,27190,415,27199),f=d[M>>2]|0,(f|0)>0){if(_=+da(M+8|0,M+8+(((f|0)!=1&1)<<4)|0,T)+0,(f|0)!=1){A=1;do y=A,A=A+1|0,_=_+ +da(M+8+(y<<4)|0,M+8+(((A|0)%(f|0)|0)<<4)|0,T);while((A|0)<(f|0))}}else _=0;return J[p>>3]=_,p=0,K=N,p|0}function mp(A,f,p){return A=A|0,f=f|0,p=p|0,A=Fl(A,f,p)|0,A|0||(J[p>>3]=+J[p>>3]*6371.007180918475*6371.007180918475),A|0}function UA(A,f,p){return A=A|0,f=f|0,p=p|0,A=Fl(A,f,p)|0,A|0||(J[p>>3]=+J[p>>3]*6371.007180918475*6371.007180918475*1e3*1e3),A|0}function BA(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(N=K,K=K+176|0,M=N,A=CA(A,f,M)|0,A|0)return M=A,K=N,M|0;if(J[p>>3]=0,A=d[M>>2]|0,(A|0)<=1)return M=0,K=N,M|0;f=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,I=_,_=+J[M+8+(A<<4)>>3],H=+Fn(+((_-I)*.5)),U=y,y=+J[M+8+(A<<4)+8>>3],U=+Fn(+((y-U)*.5)),U=H*H+U*(+li(+_)*+li(+I)*U),T=T+ +Fe(+ +qn(+U),+ +qn(+(1-U)))*2;while((A|0)<(f|0));return J[p>>3]=T,M=0,K=N,M|0}function gp(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(N=K,K=K+176|0,M=N,A=CA(A,f,M)|0,A|0)return M=A,T=+J[p>>3],T=T*6371.007180918475,J[p>>3]=T,K=N,M|0;if(J[p>>3]=0,A=d[M>>2]|0,(A|0)<=1)return M=0,T=0,T=T*6371.007180918475,J[p>>3]=T,K=N,M|0;f=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,I=_,_=+J[M+8+(A<<4)>>3],H=+Fn(+((_-I)*.5)),U=y,y=+J[M+8+(A<<4)+8>>3],U=+Fn(+((y-U)*.5)),U=H*H+U*(+li(+I)*+li(+_)*U),T=T+ +Fe(+ +qn(+U),+ +qn(+(1-U)))*2;while((A|0)!=(f|0));return J[p>>3]=T,M=0,H=T,H=H*6371.007180918475,J[p>>3]=H,K=N,M|0}function ju(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(N=K,K=K+176|0,M=N,A=CA(A,f,M)|0,A|0)return M=A,T=+J[p>>3],T=T*6371.007180918475,T=T*1e3,J[p>>3]=T,K=N,M|0;if(J[p>>3]=0,A=d[M>>2]|0,(A|0)<=1)return M=0,T=0,T=T*6371.007180918475,T=T*1e3,J[p>>3]=T,K=N,M|0;f=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,I=_,_=+J[M+8+(A<<4)>>3],H=+Fn(+((_-I)*.5)),U=y,y=+J[M+8+(A<<4)+8>>3],U=+Fn(+((y-U)*.5)),U=H*H+U*(+li(+I)*+li(+_)*U),T=T+ +Fe(+ +qn(+U),+ +qn(+(1-U)))*2;while((A|0)!=(f|0));return J[p>>3]=T,M=0,H=T,H=H*6371.007180918475,H=H*1e3,J[p>>3]=H,K=N,M|0}function M1(A){A=A|0;var f=0,p=0,_=0;return f=Ks(1,12)|0,f||Bt(27280,27235,49,27293),p=A+4|0,_=d[p>>2]|0,_|0?(_=_+8|0,d[_>>2]=f,d[p>>2]=f,f|0):(d[A>>2]|0&&Bt(27310,27235,61,27333),_=A,d[_>>2]=f,d[p>>2]=f,f|0)}function OA(A,f){A=A|0,f=f|0;var p=0,_=0;return _=Fo(24)|0,_||Bt(27347,27235,78,27361),d[_>>2]=d[f>>2],d[_+4>>2]=d[f+4>>2],d[_+8>>2]=d[f+8>>2],d[_+12>>2]=d[f+12>>2],d[_+16>>2]=0,f=A+4|0,p=d[f>>2]|0,p|0?(d[p+16>>2]=_,d[f>>2]=_,_|0):(d[A>>2]|0&&Bt(27376,27235,82,27361),d[A>>2]=_,d[f>>2]=_,_|0)}function Wu(A){A=A|0;var f=0,p=0,_=0,y=0;if(A)for(_=1;;){if(f=d[A>>2]|0,f|0)do{if(p=d[f>>2]|0,p|0)do y=p,p=d[p+16>>2]|0,An(y);while((p|0)!=0);y=f,f=d[f+8>>2]|0,An(y)}while((f|0)!=0);if(f=A,A=d[A+8>>2]|0,_||An(f),A)_=0;else break}}function Rx(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0,Bn=0,En=0,Qn=0,Tn=0,on=0,Ut=0,vn=0,ii=0,wn=0;if(y=A+8|0,d[y>>2]|0)return wn=1,wn|0;if(_=d[A>>2]|0,!_)return wn=0,wn|0;f=_,p=0;do p=p+1|0,f=d[f+8>>2]|0;while((f|0)!=0);if(p>>>0<2)return wn=0,wn|0;vn=Fo(p<<2)|0,vn||Bt(27396,27235,317,27415),Ut=Fo(p<<5)|0,Ut||Bt(27437,27235,321,27415),d[A>>2]=0,sn=A+4|0,d[sn>>2]=0,d[y>>2]=0,p=0,on=0,Lt=0,ie=0;e:for(;;){if(H=d[_>>2]|0,H){T=0,M=H;do{if(U=+J[M+8>>3],f=M,M=d[M+16>>2]|0,I=(M|0)==0,y=I?H:M,N=+J[y+8>>3],+un(+(U-N))>3.141592653589793){wn=14;break}T=T+(N-U)*(+J[f>>3]+ +J[y>>3])}while(!I);if((wn|0)==14){wn=0,T=0,f=H;do Le=+J[f+8>>3],Tn=f+16|0,Qn=d[Tn>>2]|0,Qn=(Qn|0)==0?H:Qn,Ge=+J[Qn+8>>3],T=T+(+J[f>>3]+ +J[Qn>>3])*((Ge<0?Ge+6.283185307179586:Ge)-(Le<0?Le+6.283185307179586:Le)),f=d[((f|0)==0?_:Tn)>>2]|0;while((f|0)!=0)}T>0?(d[vn+(on<<2)>>2]=_,on=on+1|0,y=Lt,f=ie):wn=19}else wn=19;if((wn|0)==19){wn=0;do if(p){if(f=p+8|0,d[f>>2]|0){wn=21;break e}if(p=Ks(1,12)|0,!p){wn=23;break e}d[f>>2]=p,y=p+4|0,M=p,f=ie}else if(ie){y=sn,M=ie+8|0,f=_,p=A;break}else if(d[A>>2]|0){wn=27;break e}else{y=sn,M=A,f=_,p=A;break}while(!1);if(d[M>>2]=_,d[y>>2]=_,M=Ut+(Lt<<5)|0,I=d[_>>2]|0,I){for(H=Ut+(Lt<<5)+8|0,J[H>>3]=17976931348623157e292,ie=Ut+(Lt<<5)+24|0,J[ie>>3]=17976931348623157e292,J[M>>3]=-17976931348623157e292,ge=Ut+(Lt<<5)+16|0,J[ge>>3]=-17976931348623157e292,Ye=17976931348623157e292,qe=-17976931348623157e292,y=0,Ae=I,U=17976931348623157e292,Pe=17976931348623157e292,Ie=-17976931348623157e292,N=-17976931348623157e292;T=+J[Ae>>3],Le=+J[Ae+8>>3],Ae=d[Ae+16>>2]|0,ve=(Ae|0)==0,Ge=+J[(ve?I:Ae)+8>>3],T>3]=T,U=T),Le>3]=Le,Pe=Le),T>Ie?J[M>>3]=T:T=Ie,Le>N&&(J[ge>>3]=Le,N=Le),Ye=Le>0&Leqe?Le:qe,y=y|+un(+(Le-Ge))>3.141592653589793,!ve;)Ie=T;y&&(J[ge>>3]=qe,J[ie>>3]=Ye)}else d[M>>2]=0,d[M+4>>2]=0,d[M+8>>2]=0,d[M+12>>2]=0,d[M+16>>2]=0,d[M+20>>2]=0,d[M+24>>2]=0,d[M+28>>2]=0;y=Lt+1|0}if(Tn=_+8|0,_=d[Tn>>2]|0,d[Tn>>2]=0,_)Lt=y,ie=f;else{wn=45;break}}if((wn|0)==21)Bt(27213,27235,35,27247);else if((wn|0)==23)Bt(27267,27235,37,27247);else if((wn|0)==27)Bt(27310,27235,61,27333);else if((wn|0)==45){e:do if((on|0)>0){for(Tn=(y|0)==0,En=y<<2,Qn=(A|0)==0,Bn=0,f=0;;){if(tn=d[vn+(Bn<<2)>>2]|0,Tn)wn=73;else{if(Lt=Fo(En)|0,!Lt){wn=50;break}if(sn=Fo(En)|0,!sn){wn=52;break}t:do if(Qn)p=0;else{for(y=0,p=0,M=A;_=Ut+(y<<5)|0,Ys(d[M>>2]|0,_,d[tn>>2]|0)|0?(d[Lt+(p<<2)>>2]=M,d[sn+(p<<2)>>2]=_,ve=p+1|0):ve=p,M=d[M+8>>2]|0,M;)y=y+1|0,p=ve;if((ve|0)>0)if(_=d[Lt>>2]|0,(ve|0)==1)p=_;else for(ge=0,Ae=-1,p=_,ie=_;;){for(I=d[ie>>2]|0,_=0,M=0;y=d[d[Lt+(M<<2)>>2]>>2]|0,(y|0)==(I|0)?H=_:H=_+((Ys(y,d[sn+(M<<2)>>2]|0,d[I>>2]|0)|0)&1)|0,M=M+1|0,(M|0)!=(ve|0);)_=H;if(y=(H|0)>(Ae|0),p=y?ie:p,_=ge+1|0,(_|0)==(ve|0))break t;ge=_,Ae=y?H:Ae,ie=d[Lt+(_<<2)>>2]|0}else p=0}while(!1);if(An(Lt),An(sn),p){if(y=p+4|0,_=d[y>>2]|0,_)p=_+8|0;else if(d[p>>2]|0){wn=70;break}d[p>>2]=tn,d[y>>2]=tn}else wn=73}if((wn|0)==73){if(wn=0,f=d[tn>>2]|0,f|0)do sn=f,f=d[f+16>>2]|0,An(sn);while((f|0)!=0);An(tn),f=1}if(Bn=Bn+1|0,(Bn|0)>=(on|0)){ii=f;break e}}(wn|0)==50?Bt(27452,27235,249,27471):(wn|0)==52?Bt(27490,27235,252,27471):(wn|0)==70&&Bt(27310,27235,61,27333)}else ii=0;while(!1);return An(vn),An(Ut),wn=ii,wn|0}return 0}function Ys(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(!(Lo(f,p)|0)||(f=TA(f)|0,_=+J[p>>3],y=+J[p+8>>3],y=f&y<0?y+6.283185307179586:y,A=d[A>>2]|0,!A))return A=0,A|0;if(f){f=0,I=y,p=A;e:for(;;){for(;M=+J[p>>3],y=+J[p+8>>3],p=p+16|0,H=d[p>>2]|0,H=(H|0)==0?A:H,T=+J[H>>3],N=+J[H+8>>3],M>T?(U=M,M=N):(U=T,T=M,M=y,y=N),_=_==T|_==U?_+2220446049250313e-31:_,!!(_U);)if(p=d[p>>2]|0,!p){p=22;break e}if(N=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,I=N==I|M==I?I+-2220446049250313e-31:I,U=N+(M-N)*((_-T)/(U-T)),(U<0?U+6.283185307179586:U)>I&&(f=f^1),p=d[p>>2]|0,!p){p=22;break}}if((p|0)==22)return f|0}else{f=0,I=y,p=A;e:for(;;){for(;M=+J[p>>3],y=+J[p+8>>3],p=p+16|0,H=d[p>>2]|0,H=(H|0)==0?A:H,T=+J[H>>3],N=+J[H+8>>3],M>T?(U=M,M=N):(U=T,T=M,M=y,y=N),_=_==T|_==U?_+2220446049250313e-31:_,!!(_U);)if(p=d[p>>2]|0,!p){p=22;break e}if(I=M==I|y==I?I+-2220446049250313e-31:I,M+(y-M)*((_-T)/(U-T))>I&&(f=f^1),p=d[p>>2]|0,!p){p=22;break}}if((p|0)==22)return f|0}return 0}function lo(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0;if(qe=K,K=K+32|0,Ye=qe+16|0,Ie=qe,T=Mt(A|0,f|0,52)|0,Z()|0,T=T&15,Ae=Mt(p|0,_|0,52)|0,Z()|0,(T|0)!=(Ae&15|0))return Ye=12,K=qe,Ye|0;if(I=Mt(A|0,f|0,45)|0,Z()|0,I=I&127,H=Mt(p|0,_|0,45)|0,Z()|0,H=H&127,I>>>0>121|H>>>0>121)return Ye=5,K=qe,Ye|0;if(Ae=(I|0)!=(H|0),Ae){if(N=Jh(I,H)|0,(N|0)==7)return Ye=1,K=qe,Ye|0;U=Jh(H,I)|0,(U|0)==7?Bt(27514,27538,161,27548):(ve=N,M=U)}else ve=0,M=0;ie=Bi(I)|0,ge=Bi(H)|0,d[Ye>>2]=0,d[Ye+4>>2]=0,d[Ye+8>>2]=0,d[Ye+12>>2]=0;do if(ve){if(H=d[4272+(I*28|0)+(ve<<2)>>2]|0,N=(H|0)>0,ge)if(N){I=0,U=p,N=_;do U=Tx(U,N)|0,N=Z()|0,M=rl(M)|0,(M|0)==1&&(M=rl(1)|0),I=I+1|0;while((I|0)!=(H|0));H=M,I=U,U=N}else H=M,I=p,U=_;else if(N){I=0,U=p,N=_;do U=hp(U,N)|0,N=Z()|0,M=rl(M)|0,I=I+1|0;while((I|0)!=(H|0));H=M,I=U,U=N}else H=M,I=p,U=_;if(LA(I,U,Ye)|0,Ae||Bt(27563,27538,191,27548),N=(ie|0)!=0,M=(ge|0)!=0,N&M&&Bt(27590,27538,192,27548),N){if(M=$s(A,f)|0,(M|0)==7){T=5;break}if(at[22e3+(M*7|0)+ve>>0]|0){T=1;break}U=d[21168+(M*28|0)+(ve<<2)>>2]|0,I=U}else if(M){if(M=$s(I,U)|0,(M|0)==7){T=5;break}if(at[22e3+(M*7|0)+H>>0]|0){T=1;break}I=0,U=d[21168+(H*28|0)+(M<<2)>>2]|0}else I=0,U=0;if((I|U|0)<0)T=5;else{if((U|0)>0){N=Ye+4|0,M=0;do EA(N),M=M+1|0;while((M|0)!=(U|0))}if(d[Ie>>2]=0,d[Ie+4>>2]=0,d[Ie+8>>2]=0,u1(Ie,ve),T|0)for(;Ss(T)|0?Yc(Ie):Lu(Ie),(T|0)>1;)T=T+-1|0;if((I|0)>0){T=0;do EA(Ie),T=T+1|0;while((T|0)!=(I|0))}Pe=Ye+4|0,hs(Pe,Ie,Pe),Lr(Pe),Pe=51}}else if(LA(p,_,Ye)|0,(ie|0)!=0&(ge|0)!=0)if((H|0)!=(I|0)&&Bt(27621,27538,261,27548),M=$s(A,f)|0,T=$s(p,_)|0,(M|0)==7|(T|0)==7)T=5;else if(at[22e3+(M*7|0)+T>>0]|0)T=1;else if(M=d[21168+(M*28|0)+(T<<2)>>2]|0,(M|0)>0){N=Ye+4|0,T=0;do EA(N),T=T+1|0;while((T|0)!=(M|0));Pe=51}else Pe=51;else Pe=51;while(!1);return(Pe|0)==51&&(T=Ye+4|0,d[y>>2]=d[T>>2],d[y+4>>2]=d[T+4>>2],d[y+8>>2]=d[T+8>>2],T=0),Ye=T,K=qe,Ye|0}function Uo(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0;if(Pe=K,K=K+48|0,I=Pe+36|0,M=Pe+24|0,N=Pe+12|0,U=Pe,y=Mt(A|0,f|0,52)|0,Z()|0,y=y&15,ge=Mt(A|0,f|0,45)|0,Z()|0,ge=ge&127,ge>>>0>121)return _=5,K=Pe,_|0;if(H=Bi(ge)|0,Dt(y|0,0,52)|0,Ie=Z()|0|134225919,T=_,d[T>>2]=-1,d[T+4>>2]=Ie,!y)return y=Pu(p)|0,(y|0)==7||(y=SA(ge,y)|0,(y|0)==127)?(Ie=1,K=Pe,Ie|0):(Ae=Dt(y|0,0,45)|0,ve=Z()|0,ge=_,ve=d[ge+4>>2]&-1040385|ve,Ie=_,d[Ie>>2]=d[ge>>2]|Ae,d[Ie+4>>2]=ve,Ie=0,K=Pe,Ie|0);for(d[I>>2]=d[p>>2],d[I+4>>2]=d[p+4>>2],d[I+8>>2]=d[p+8>>2],p=y;;){if(T=p,p=p+-1|0,d[M>>2]=d[I>>2],d[M+4>>2]=d[I+4>>2],d[M+8>>2]=d[I+8>>2],Ss(T)|0){if(y=o1(I)|0,y|0){p=13;break}d[N>>2]=d[I>>2],d[N+4>>2]=d[I+4>>2],d[N+8>>2]=d[I+8>>2],Yc(N)}else{if(y=cx(I)|0,y|0){p=13;break}d[N>>2]=d[I>>2],d[N+4>>2]=d[I+4>>2],d[N+8>>2]=d[I+8>>2],Lu(N)}if(af(M,N,U),Lr(U),y=_,qe=d[y>>2]|0,y=d[y+4>>2]|0,Ge=(15-T|0)*3|0,Ye=Dt(7,0,Ge|0)|0,y=y&~(Z()|0),Ge=Dt(Pu(U)|0,0,Ge|0)|0,y=Z()|0|y,Ie=_,d[Ie>>2]=Ge|qe&~Ye,d[Ie+4>>2]=y,(T|0)<=1){p=14;break}}e:do if((p|0)!=13&&(p|0)==14)if((d[I>>2]|0)<=1&&(d[I+4>>2]|0)<=1&&(d[I+8>>2]|0)<=1){p=Pu(I)|0,y=SA(ge,p)|0,(y|0)==127?U=0:U=Bi(y)|0;t:do if(p){if(H){if(y=$s(A,f)|0,(y|0)==7){y=5;break e}if(T=d[21376+(y*28|0)+(p<<2)>>2]|0,(T|0)>0){y=p,p=0;do y=Uu(y)|0,p=p+1|0;while((p|0)!=(T|0))}else y=p;if((y|0)==1){y=9;break e}p=SA(ge,y)|0,(p|0)==127&&Bt(27648,27538,411,27678),Bi(p)|0?Bt(27693,27538,412,27678):(ve=p,Ae=T,ie=y)}else ve=y,Ae=0,ie=p;if(N=d[4272+(ge*28|0)+(ie<<2)>>2]|0,(N|0)<=-1&&Bt(27724,27538,419,27678),!U){if((Ae|0)<0){y=5;break e}if(Ae|0){T=_,y=0,p=d[T>>2]|0,T=d[T+4>>2]|0;do p=ku(p,T)|0,T=Z()|0,Ge=_,d[Ge>>2]=p,d[Ge+4>>2]=T,y=y+1|0;while((y|0)<(Ae|0))}if((N|0)<=0){y=ve,p=58;break}for(T=_,y=0,p=d[T>>2]|0,T=d[T+4>>2]|0;;)if(p=ku(p,T)|0,T=Z()|0,Ge=_,d[Ge>>2]=p,d[Ge+4>>2]=T,y=y+1|0,(y|0)==(N|0)){y=ve,p=58;break t}}if(M=Jh(ve,ge)|0,(M|0)==7&&Bt(27514,27538,428,27678),y=_,p=d[y>>2]|0,y=d[y+4>>2]|0,(N|0)>0){T=0;do p=ku(p,y)|0,y=Z()|0,Ge=_,d[Ge>>2]=p,d[Ge+4>>2]=y,T=T+1|0;while((T|0)!=(N|0))}if(y=$s(p,y)|0,(y|0)==7&&Bt(27795,27538,440,27678),p=Wc(ve)|0,p=d[(p?21792:21584)+(M*28|0)+(y<<2)>>2]|0,(p|0)<0&&Bt(27795,27538,454,27678),!p)y=ve,p=58;else{M=_,y=0,T=d[M>>2]|0,M=d[M+4>>2]|0;do T=cp(T,M)|0,M=Z()|0,Ge=_,d[Ge>>2]=T,d[Ge+4>>2]=M,y=y+1|0;while((y|0)<(p|0));y=ve,p=58}}else if((H|0)!=0&(U|0)!=0){if(p=$s(A,f)|0,T=_,T=$s(d[T>>2]|0,d[T+4>>2]|0)|0,(p|0)==7|(T|0)==7){y=5;break e}if(T=d[21376+(p*28|0)+(T<<2)>>2]|0,(T|0)<0){y=5;break e}if(!T)p=59;else{N=_,p=0,M=d[N>>2]|0,N=d[N+4>>2]|0;do M=ku(M,N)|0,N=Z()|0,Ge=_,d[Ge>>2]=M,d[Ge+4>>2]=N,p=p+1|0;while((p|0)<(T|0));p=58}}else p=58;while(!1);if((p|0)==58&&U&&(p=59),(p|0)==59&&(Ge=_,($s(d[Ge>>2]|0,d[Ge+4>>2]|0)|0)==1)){y=9;break}Ge=_,Ye=d[Ge>>2]|0,Ge=d[Ge+4>>2]&-1040385,qe=Dt(y|0,0,45)|0,Ge=Ge|(Z()|0),y=_,d[y>>2]=Ye|qe,d[y+4>>2]=Ge,y=0}else y=1;while(!1);return Ge=y,K=Pe,Ge|0}function E1(A,f,p,_,y,T){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,N=0;return N=K,K=K+16|0,M=N,y?A=15:(A=lo(A,f,p,_,M)|0,A||(fx(M,T),A=0)),K=N,A|0}function IA(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0;return M=K,K=K+16|0,T=M,_?p=15:(p=rp(p,T)|0,p||(p=Uo(A,f,T,y)|0)),K=M,p|0}function $u(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0;return U=K,K=K+32|0,M=U+12|0,N=U,T=lo(A,f,A,f,M)|0,T|0?(N=T,K=U,N|0):(A=lo(A,f,p,_,N)|0,A|0?(N=A,K=U,N|0):(M=ip(M,N)|0,N=y,d[N>>2]=M,d[N+4>>2]=((M|0)<0)<<31>>31,N=0,K=U,N|0))}function vp(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0;return U=K,K=K+32|0,M=U+12|0,N=U,T=lo(A,f,A,f,M)|0,!T&&(T=lo(A,f,p,_,N)|0,!T)?(_=ip(M,N)|0,_=Qt(_|0,((_|0)<0)<<31>>31|0,1,0)|0,M=Z()|0,N=y,d[N>>2]=_,d[N+4>>2]=M,N=0,K=U,N|0):(N=T,K=U,N|0)}function C1(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0,Bn=0;if(tn=K,K=K+48|0,Lt=tn+24|0,M=tn+12|0,sn=tn,T=lo(A,f,A,f,Lt)|0,!T&&(T=lo(A,f,p,_,M)|0,!T)){Ge=ip(Lt,M)|0,Le=((Ge|0)<0)<<31>>31,d[Lt>>2]=0,d[Lt+4>>2]=0,d[Lt+8>>2]=0,d[M>>2]=0,d[M+4>>2]=0,d[M+8>>2]=0,lo(A,f,A,f,Lt)|0&&Bt(27795,27538,692,27747),lo(A,f,p,_,M)|0&&Bt(27795,27538,697,27747),A1(Lt),A1(M),H=(Ge|0)==0?0:1/+(Ge|0),p=d[Lt>>2]|0,Pe=H*+((d[M>>2]|0)-p|0),Ie=Lt+4|0,_=d[Ie>>2]|0,Ye=H*+((d[M+4>>2]|0)-_|0),qe=Lt+8|0,T=d[qe>>2]|0,H=H*+((d[M+8>>2]|0)-T|0),d[sn>>2]=p,ie=sn+4|0,d[ie>>2]=_,ge=sn+8|0,d[ge>>2]=T;e:do if((Ge|0)<0)T=0;else for(Ae=0,ve=0;;){U=+(ve>>>0)+4294967296*+(Ae|0),Bn=Pe*U+ +(p|0),N=Ye*U+ +(_|0),U=H*U+ +(T|0),p=~~+hl(+Bn),M=~~+hl(+N),T=~~+hl(+U),Bn=+un(+(+(p|0)-Bn)),N=+un(+(+(M|0)-N)),U=+un(+(+(T|0)-U));do if(Bn>N&Bn>U)p=0-(M+T)|0,_=M;else if(I=0-p|0,N>U){_=I-T|0;break}else{_=M,T=I-M|0;break}while(!1);if(d[sn>>2]=p,d[ie>>2]=_,d[ge>>2]=T,Ax(sn),T=Uo(A,f,sn,y+(ve<<3)|0)|0,T|0)break e;if(!((Ae|0)<(Le|0)|(Ae|0)==(Le|0)&ve>>>0>>0)){T=0;break e}p=Qt(ve|0,Ae|0,1,0)|0,_=Z()|0,Ae=_,ve=p,p=d[Lt>>2]|0,_=d[Ie>>2]|0,T=d[qe>>2]|0}while(!1);return sn=T,K=tn,sn|0}return sn=T,K=tn,sn|0}function Bo(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0;if((p|0)==0&(_|0)==0)return y=0,T=1,mt(y|0),T|0;T=A,y=f,A=1,f=0;do M=(p&1|0)==0&!0,A=fr((M?1:T)|0,(M?0:y)|0,A|0,f|0)|0,f=Z()|0,p=N1(p|0,_|0,1)|0,_=Z()|0,T=fr(T|0,y|0,T|0,y|0)|0,y=Z()|0;while(!((p|0)==0&(_|0)==0));return mt(f|0),A|0}function FA(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0;N=K,K=K+16|0,T=N,M=Mt(A|0,f|0,52)|0,Z()|0,M=M&15;do if(M){if(y=Ol(A,f,T)|0,!y){I=+J[T>>3],U=1/+li(+I),H=+J[25968+(M<<3)>>3],J[p>>3]=I+H,J[p+8>>3]=I-H,I=+J[T+8>>3],U=H*U,J[p+16>>3]=U+I,J[p+24>>3]=I-U;break}return M=y,K=N,M|0}else{if(y=Mt(A|0,f|0,45)|0,Z()|0,y=y&127,y>>>0>121)return M=5,K=N,M|0;T=22064+(y<<5)|0,d[p>>2]=d[T>>2],d[p+4>>2]=d[T+4>>2],d[p+8>>2]=d[T+8>>2],d[p+12>>2]=d[T+12>>2],d[p+16>>2]=d[T+16>>2],d[p+20>>2]=d[T+20>>2],d[p+24>>2]=d[T+24>>2],d[p+28>>2]=d[T+28>>2];break}while(!1);return Ws(p,_?1.4:1.1),_=26096+(M<<3)|0,(d[_>>2]|0)==(A|0)&&(d[_+4>>2]|0)==(f|0)&&(J[p>>3]=1.5707963267948966),M=26224+(M<<3)|0,(d[M>>2]|0)==(A|0)&&(d[M+4>>2]|0)==(f|0)&&(J[p+8>>3]=-1.5707963267948966),+J[p>>3]!=1.5707963267948966&&+J[p+8>>3]!=-1.5707963267948966?(M=0,K=N,M|0):(J[p+16>>3]=3.141592653589793,J[p+24>>3]=-3.141592653589793,M=0,K=N,M|0)}function Ca(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0;I=K,K=K+48|0,M=I+32|0,T=I+40|0,N=I,Iu(M,0,0,0),U=d[M>>2]|0,M=d[M+4>>2]|0;do if(p>>>0<=15){if(y=Ra(_)|0,y|0){_=N,d[_>>2]=0,d[_+4>>2]=0,d[N+8>>2]=y,d[N+12>>2]=-1,_=N+16|0,U=N+29|0,d[_>>2]=0,d[_+4>>2]=0,d[_+8>>2]=0,at[_+12>>0]=0,at[U>>0]=at[T>>0]|0,at[U+1>>0]=at[T+1>>0]|0,at[U+2>>0]=at[T+2>>0]|0;break}if(y=Ks((d[f+8>>2]|0)+1|0,32)|0,y){Na(f,y),H=N,d[H>>2]=U,d[H+4>>2]=M,d[N+8>>2]=0,d[N+12>>2]=p,d[N+16>>2]=_,d[N+20>>2]=f,d[N+24>>2]=y,at[N+28>>0]=0,U=N+29|0,at[U>>0]=at[T>>0]|0,at[U+1>>0]=at[T+1>>0]|0,at[U+2>>0]=at[T+2>>0]|0;break}else{_=N,d[_>>2]=0,d[_+4>>2]=0,d[N+8>>2]=13,d[N+12>>2]=-1,_=N+16|0,U=N+29|0,d[_>>2]=0,d[_+4>>2]=0,d[_+8>>2]=0,at[_+12>>0]=0,at[U>>0]=at[T>>0]|0,at[U+1>>0]=at[T+1>>0]|0,at[U+2>>0]=at[T+2>>0]|0;break}}else U=N,d[U>>2]=0,d[U+4>>2]=0,d[N+8>>2]=4,d[N+12>>2]=-1,U=N+16|0,H=N+29|0,d[U>>2]=0,d[U+4>>2]=0,d[U+8>>2]=0,at[U+12>>0]=0,at[H>>0]=at[T>>0]|0,at[H+1>>0]=at[T+1>>0]|0,at[H+2>>0]=at[T+2>>0]|0;while(!1);al(N),d[A>>2]=d[N>>2],d[A+4>>2]=d[N+4>>2],d[A+8>>2]=d[N+8>>2],d[A+12>>2]=d[N+12>>2],d[A+16>>2]=d[N+16>>2],d[A+20>>2]=d[N+20>>2],d[A+24>>2]=d[N+24>>2],d[A+28>>2]=d[N+28>>2],K=I}function al(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0;if(Le=K,K=K+336|0,Ae=Le+168|0,ve=Le,_=A,p=d[_>>2]|0,_=d[_+4>>2]|0,(p|0)==0&(_|0)==0){K=Le;return}if(f=A+28|0,at[f>>0]|0?(p=Xu(p,_)|0,_=Z()|0):at[f>>0]=1,Ge=A+20|0,!(d[d[Ge>>2]>>2]|0)){f=A+24|0,p=d[f>>2]|0,p|0&&An(p),qe=A,d[qe>>2]=0,d[qe+4>>2]=0,d[A+8>>2]=0,d[Ge>>2]=0,d[A+12>>2]=-1,d[A+16>>2]=0,d[f>>2]=0,K=Le;return}qe=A+16|0,f=d[qe>>2]|0,y=f&15;e:do if((p|0)==0&(_|0)==0)Ye=A+24|0;else{Pe=A+12|0,ie=(y|0)==3,H=f&255,U=(y|1|0)==3,ge=A+24|0,I=(y+-1|0)>>>0<3,M=(y|2|0)==3,N=ve+8|0;t:for(;;){if(T=Mt(p|0,_|0,52)|0,Z()|0,T=T&15,(T|0)==(d[Pe>>2]|0)){switch(H&15){case 0:case 2:case 3:{if(y=Ol(p,_,Ae)|0,y|0){Ie=15;break t}if(Da(d[Ge>>2]|0,d[ge>>2]|0,Ae)|0){Ie=19;break t}break}}if(U&&(y=d[(d[Ge>>2]|0)+4>>2]|0,d[Ae>>2]=d[y>>2],d[Ae+4>>2]=d[y+4>>2],d[Ae+8>>2]=d[y+8>>2],d[Ae+12>>2]=d[y+12>>2],Lo(26832,Ae)|0)){if(PA(d[(d[Ge>>2]|0)+4>>2]|0,T,ve)|0){Ie=25;break}if(y=ve,(d[y>>2]|0)==(p|0)&&(d[y+4>>2]|0)==(_|0)){Ie=29;break}}if(I){if(y=Il(p,_,Ae)|0,y|0){Ie=32;break}if(FA(p,_,ve,0)|0){Ie=36;break}if(M&&Oo(d[Ge>>2]|0,d[ge>>2]|0,Ae,ve)|0){Ie=42;break}if(U&&zA(d[Ge>>2]|0,d[ge>>2]|0,Ae,ve)|0){Ie=42;break}}if(ie){if(f=FA(p,_,Ae,1)|0,y=d[ge>>2]|0,f|0){Ie=45;break}if(nf(y,Ae)|0){if(rf(ve,Ae),np(Ae,d[ge>>2]|0)|0){Ie=53;break}if(Da(d[Ge>>2]|0,d[ge>>2]|0,N)|0){Ie=53;break}if(zA(d[Ge>>2]|0,d[ge>>2]|0,ve,Ae)|0){Ie=53;break}}}}do if((T|0)<(d[Pe>>2]|0)){if(f=FA(p,_,Ae,1)|0,y=d[ge>>2]|0,f|0){Ie=58;break t}if(!(nf(y,Ae)|0)){Ie=73;break}if(np(d[ge>>2]|0,Ae)|0&&(rf(ve,Ae),Oo(d[Ge>>2]|0,d[ge>>2]|0,ve,Ae)|0)){Ie=65;break t}if(p=DA(p,_,T+1|0,ve)|0,p|0){Ie=67;break t}_=ve,p=d[_>>2]|0,_=d[_+4>>2]|0}else Ie=73;while(!1);if((Ie|0)==73&&(Ie=0,p=Xu(p,_)|0,_=Z()|0),(p|0)==0&(_|0)==0){Ye=ge;break e}}switch(Ie|0){case 15:{f=d[ge>>2]|0,f|0&&An(f),Ie=A,d[Ie>>2]=0,d[Ie+4>>2]=0,d[Ge>>2]=0,d[Pe>>2]=-1,d[qe>>2]=0,d[ge>>2]=0,d[A+8>>2]=y,Ie=20;break}case 19:{d[A>>2]=p,d[A+4>>2]=_,Ie=20;break}case 25:{Bt(27795,27761,470,27772);break}case 29:{d[A>>2]=p,d[A+4>>2]=_,K=Le;return}case 32:{f=d[ge>>2]|0,f|0&&An(f),Ye=A,d[Ye>>2]=0,d[Ye+4>>2]=0,d[Ge>>2]=0,d[Pe>>2]=-1,d[qe>>2]=0,d[ge>>2]=0,d[A+8>>2]=y,K=Le;return}case 36:{Bt(27795,27761,493,27772);break}case 42:{d[A>>2]=p,d[A+4>>2]=_,K=Le;return}case 45:{y|0&&An(y),Ie=A,d[Ie>>2]=0,d[Ie+4>>2]=0,d[Ge>>2]=0,d[Pe>>2]=-1,d[qe>>2]=0,d[ge>>2]=0,d[A+8>>2]=f,Ie=55;break}case 53:{d[A>>2]=p,d[A+4>>2]=_,Ie=55;break}case 58:{y|0&&An(y),Ie=A,d[Ie>>2]=0,d[Ie+4>>2]=0,d[Ge>>2]=0,d[Pe>>2]=-1,d[qe>>2]=0,d[ge>>2]=0,d[A+8>>2]=f,Ie=71;break}case 65:{d[A>>2]=p,d[A+4>>2]=_,Ie=71;break}case 67:{f=d[ge>>2]|0,f|0&&An(f),Ye=A,d[Ye>>2]=0,d[Ye+4>>2]=0,d[Ge>>2]=0,d[Pe>>2]=-1,d[qe>>2]=0,d[ge>>2]=0,d[A+8>>2]=p,K=Le;return}}if((Ie|0)==20){K=Le;return}else if((Ie|0)==55){K=Le;return}else if((Ie|0)==71){K=Le;return}}while(!1);f=d[Ye>>2]|0,f|0&&An(f),Ie=A,d[Ie>>2]=0,d[Ie+4>>2]=0,d[A+8>>2]=0,d[Ge>>2]=0,d[A+12>>2]=-1,d[qe>>2]=0,d[Ye>>2]=0,K=Le}function Xu(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0;ie=K,K=K+16|0,H=ie,_=Mt(A|0,f|0,52)|0,Z()|0,_=_&15,p=Mt(A|0,f|0,45)|0,Z()|0;do if(_){for(;p=Dt(_+4095|0,0,52)|0,y=Z()|0|f&-15728641,T=(15-_|0)*3|0,M=Dt(7,0,T|0)|0,N=Z()|0,p=p|A|M,y=y|N,U=Mt(A|0,f|0,T|0)|0,Z()|0,U=U&7,_=_+-1|0,!(U>>>0<6);)if(_)f=y,A=p;else{I=4;break}if((I|0)==4){p=Mt(p|0,y|0,45)|0,Z()|0;break}return H=(U|0)==0&(Ci(p,y)|0)!=0,H=Dt((H?2:1)+U|0,0,T|0)|0,I=Z()|0|f&~N,H=H|A&~M,mt(I|0),K=ie,H|0}while(!1);return p=p&127,p>>>0>120?(I=0,H=0,mt(I|0),K=ie,H|0):(Iu(H,0,p+1|0,0),I=d[H+4>>2]|0,H=d[H>>2]|0,mt(I|0),K=ie,H|0)}function kA(A,f,p,_,y,T){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0;Ie=K,K=K+160|0,ie=Ie+80|0,N=Ie+64|0,ge=Ie+112|0,Pe=Ie,Ca(ie,A,f,p),I=ie,sl(N,d[I>>2]|0,d[I+4>>2]|0,f),I=N,U=d[I>>2]|0,I=d[I+4>>2]|0,M=d[ie+8>>2]|0,Ae=ge+4|0,d[Ae>>2]=d[ie>>2],d[Ae+4>>2]=d[ie+4>>2],d[Ae+8>>2]=d[ie+8>>2],d[Ae+12>>2]=d[ie+12>>2],d[Ae+16>>2]=d[ie+16>>2],d[Ae+20>>2]=d[ie+20>>2],d[Ae+24>>2]=d[ie+24>>2],d[Ae+28>>2]=d[ie+28>>2],Ae=Pe,d[Ae>>2]=U,d[Ae+4>>2]=I,Ae=Pe+8|0,d[Ae>>2]=M,A=Pe+12|0,f=ge,p=A+36|0;do d[A>>2]=d[f>>2],A=A+4|0,f=f+4|0;while((A|0)<(p|0));if(ge=Pe+48|0,d[ge>>2]=d[N>>2],d[ge+4>>2]=d[N+4>>2],d[ge+8>>2]=d[N+8>>2],d[ge+12>>2]=d[N+12>>2],(U|0)==0&(I|0)==0)return Pe=M,K=Ie,Pe|0;p=Pe+16|0,H=Pe+24|0,ie=Pe+28|0,M=0,N=0,f=U,A=I;do{if(!((M|0)<(y|0)|(M|0)==(y|0)&N>>>0<_>>>0)){ve=4;break}if(I=N,N=Qt(N|0,M|0,1,0)|0,M=Z()|0,I=T+(I<<3)|0,d[I>>2]=f,d[I+4>>2]=A,uf(ge),A=ge,f=d[A>>2]|0,A=d[A+4>>2]|0,(f|0)==0&(A|0)==0){if(al(p),f=p,A=d[f>>2]|0,f=d[f+4>>2]|0,(A|0)==0&(f|0)==0){ve=10;break}Vu(A,f,d[ie>>2]|0,ge),A=ge,f=d[A>>2]|0,A=d[A+4>>2]|0}I=Pe,d[I>>2]=f,d[I+4>>2]=A}while(!((f|0)==0&(A|0)==0));return(ve|0)==4?(A=Pe+40|0,f=d[A>>2]|0,f|0&&An(f),ve=Pe+16|0,d[ve>>2]=0,d[ve+4>>2]=0,d[H>>2]=0,d[Pe+36>>2]=0,d[ie>>2]=-1,d[Pe+32>>2]=0,d[A>>2]=0,Vu(0,0,0,ge),d[Pe>>2]=0,d[Pe+4>>2]=0,d[Ae>>2]=0,Pe=14,K=Ie,Pe|0):((ve|0)==10&&(d[Pe>>2]=0,d[Pe+4>>2]=0,d[Ae>>2]=d[H>>2]),Pe=d[Ae>>2]|0,K=Ie,Pe|0)}function cf(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0;if(ie=K,K=K+48|0,U=ie+32|0,N=ie+40|0,I=ie,!(d[A>>2]|0))return H=_,d[H>>2]=0,d[H+4>>2]=0,H=0,K=ie,H|0;Iu(U,0,0,0),M=U,y=d[M>>2]|0,M=d[M+4>>2]|0;do if(f>>>0>15)H=I,d[H>>2]=0,d[H+4>>2]=0,d[I+8>>2]=4,d[I+12>>2]=-1,H=I+16|0,p=I+29|0,d[H>>2]=0,d[H+4>>2]=0,d[H+8>>2]=0,at[H+12>>0]=0,at[p>>0]=at[N>>0]|0,at[p+1>>0]=at[N+1>>0]|0,at[p+2>>0]=at[N+2>>0]|0,p=4,H=9;else{if(p=Ra(p)|0,p|0){U=I,d[U>>2]=0,d[U+4>>2]=0,d[I+8>>2]=p,d[I+12>>2]=-1,U=I+16|0,H=I+29|0,d[U>>2]=0,d[U+4>>2]=0,d[U+8>>2]=0,at[U+12>>0]=0,at[H>>0]=at[N>>0]|0,at[H+1>>0]=at[N+1>>0]|0,at[H+2>>0]=at[N+2>>0]|0,H=9;break}if(p=Ks((d[A+8>>2]|0)+1|0,32)|0,!p){H=I,d[H>>2]=0,d[H+4>>2]=0,d[I+8>>2]=13,d[I+12>>2]=-1,H=I+16|0,p=I+29|0,d[H>>2]=0,d[H+4>>2]=0,d[H+8>>2]=0,at[H+12>>0]=0,at[p>>0]=at[N>>0]|0,at[p+1>>0]=at[N+1>>0]|0,at[p+2>>0]=at[N+2>>0]|0,p=13,H=9;break}Na(A,p),Ae=I,d[Ae>>2]=y,d[Ae+4>>2]=M,M=I+8|0,d[M>>2]=0,d[I+12>>2]=f,d[I+20>>2]=A,d[I+24>>2]=p,at[I+28>>0]=0,y=I+29|0,at[y>>0]=at[N>>0]|0,at[y+1>>0]=at[N+1>>0]|0,at[y+2>>0]=at[N+2>>0]|0,d[I+16>>2]=3,ge=+tf(p),ge=ge*+il(p),T=+un(+ +J[p>>3]),T=ge/+li(+ +df(+T,+ +un(+ +J[p+8>>3])))*6371.007180918475*6371.007180918475,y=I+12|0,p=d[y>>2]|0;e:do if((p|0)>0)do{if(dp(p+-1|0,U)|0,!(T/+J[U>>3]>10))break e;Ae=d[y>>2]|0,p=Ae+-1|0,d[y>>2]=p}while((Ae|0)>1);while(!1);if(al(I),y=_,d[y>>2]=0,d[y+4>>2]=0,y=I,p=d[y>>2]|0,y=d[y+4>>2]|0,!((p|0)==0&(y|0)==0))do lf(p,y,f,U)|0,N=U,A=_,N=Qt(d[A>>2]|0,d[A+4>>2]|0,d[N>>2]|0,d[N+4>>2]|0)|0,A=Z()|0,Ae=_,d[Ae>>2]=N,d[Ae+4>>2]=A,al(I),Ae=I,p=d[Ae>>2]|0,y=d[Ae+4>>2]|0;while(!((p|0)==0&(y|0)==0));p=d[M>>2]|0}while(!1);return Ae=p,K=ie,Ae|0}function Ts(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0;if(!(Lo(f,p)|0)||(f=TA(f)|0,_=+J[p>>3],y=+J[p+8>>3],y=f&y<0?y+6.283185307179586:y,ge=d[A>>2]|0,(ge|0)<=0))return ge=0,ge|0;if(ie=d[A+4>>2]|0,f){f=0,H=y,p=-1,A=0;e:for(;;){for(I=A;M=+J[ie+(I<<4)>>3],y=+J[ie+(I<<4)+8>>3],A=(p+2|0)%(ge|0)|0,T=+J[ie+(A<<4)>>3],N=+J[ie+(A<<4)+8>>3],M>T?(U=M,M=N):(U=T,T=M,M=y,y=N),_=_==T|_==U?_+2220446049250313e-31:_,!!(_U);)if(p=I+1|0,(p|0)>=(ge|0)){p=22;break e}else A=I,I=p,p=A;if(N=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,H=N==H|M==H?H+-2220446049250313e-31:H,U=N+(M-N)*((_-T)/(U-T)),(U<0?U+6.283185307179586:U)>H&&(f=f^1),A=I+1|0,(A|0)>=(ge|0)){p=22;break}else p=I}if((p|0)==22)return f|0}else{f=0,H=y,p=-1,A=0;e:for(;;){for(I=A;M=+J[ie+(I<<4)>>3],y=+J[ie+(I<<4)+8>>3],A=(p+2|0)%(ge|0)|0,T=+J[ie+(A<<4)>>3],N=+J[ie+(A<<4)+8>>3],M>T?(U=M,M=N):(U=T,T=M,M=y,y=N),_=_==T|_==U?_+2220446049250313e-31:_,!!(_U);)if(p=I+1|0,(p|0)>=(ge|0)){p=22;break e}else A=I,I=p,p=A;if(H=M==H|y==H?H+-2220446049250313e-31:H,M+(y-M)*((_-T)/(U-T))>H&&(f=f^1),A=I+1|0,(A|0)>=(ge|0)){p=22;break}else p=I}if((p|0)==22)return f|0}return 0}function pa(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0;if(ve=d[A>>2]|0,!ve){d[f>>2]=0,d[f+4>>2]=0,d[f+8>>2]=0,d[f+12>>2]=0,d[f+16>>2]=0,d[f+20>>2]=0,d[f+24>>2]=0,d[f+28>>2]=0;return}if(Pe=f+8|0,J[Pe>>3]=17976931348623157e292,Ie=f+24|0,J[Ie>>3]=17976931348623157e292,J[f>>3]=-17976931348623157e292,Ye=f+16|0,J[Ye>>3]=-17976931348623157e292,!((ve|0)<=0)){for(ge=d[A+4>>2]|0,I=17976931348623157e292,H=-17976931348623157e292,ie=0,A=-1,T=17976931348623157e292,M=17976931348623157e292,U=-17976931348623157e292,_=-17976931348623157e292,Ae=0;p=+J[ge+(Ae<<4)>>3],N=+J[ge+(Ae<<4)+8>>3],A=A+2|0,y=+J[ge+(((A|0)==(ve|0)?0:A)<<4)+8>>3],p>3]=p,T=p),N>3]=N,M=N),p>U?J[f>>3]=p:p=U,N>_&&(J[Ye>>3]=N,_=N),I=N>0&NH?N:H,ie=ie|+un(+(N-y))>3.141592653589793,A=Ae+1|0,(A|0)!=(ve|0);)qe=Ae,U=p,Ae=A,A=qe;ie&&(J[Ye>>3]=H,J[Ie>>3]=I)}}function Ra(A){return A=A|0,(A>>>0<4?0:15)|0}function Na(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0;if(ve=d[A>>2]|0,ve){if(Pe=f+8|0,J[Pe>>3]=17976931348623157e292,Ie=f+24|0,J[Ie>>3]=17976931348623157e292,J[f>>3]=-17976931348623157e292,Ye=f+16|0,J[Ye>>3]=-17976931348623157e292,(ve|0)>0){for(y=d[A+4>>2]|0,ge=17976931348623157e292,Ae=-17976931348623157e292,_=0,p=-1,U=17976931348623157e292,I=17976931348623157e292,ie=-17976931348623157e292,M=-17976931348623157e292,qe=0;T=+J[y+(qe<<4)>>3],H=+J[y+(qe<<4)+8>>3],sn=p+2|0,N=+J[y+(((sn|0)==(ve|0)?0:sn)<<4)+8>>3],T>3]=T,U=T),H>3]=H,I=H),T>ie?J[f>>3]=T:T=ie,H>M&&(J[Ye>>3]=H,M=H),ge=H>0&HAe?H:Ae,_=_|+un(+(H-N))>3.141592653589793,p=qe+1|0,(p|0)!=(ve|0);)sn=qe,ie=T,qe=p,p=sn;_&&(J[Ye>>3]=Ae,J[Ie>>3]=ge)}}else d[f>>2]=0,d[f+4>>2]=0,d[f+8>>2]=0,d[f+12>>2]=0,d[f+16>>2]=0,d[f+20>>2]=0,d[f+24>>2]=0,d[f+28>>2]=0;if(sn=A+8|0,p=d[sn>>2]|0,!((p|0)<=0)){Lt=A+12|0,Le=0;do if(y=d[Lt>>2]|0,_=Le,Le=Le+1|0,Ie=f+(Le<<5)|0,Ye=d[y+(_<<3)>>2]|0,Ye){if(qe=f+(Le<<5)+8|0,J[qe>>3]=17976931348623157e292,A=f+(Le<<5)+24|0,J[A>>3]=17976931348623157e292,J[Ie>>3]=-17976931348623157e292,Ge=f+(Le<<5)+16|0,J[Ge>>3]=-17976931348623157e292,(Ye|0)>0){for(ve=d[y+(_<<3)+4>>2]|0,ge=17976931348623157e292,Ae=-17976931348623157e292,y=0,_=-1,Pe=0,U=17976931348623157e292,I=17976931348623157e292,H=-17976931348623157e292,M=-17976931348623157e292;T=+J[ve+(Pe<<4)>>3],ie=+J[ve+(Pe<<4)+8>>3],_=_+2|0,N=+J[ve+(((_|0)==(Ye|0)?0:_)<<4)+8>>3],T>3]=T,U=T),ie>3]=ie,I=ie),T>H?J[Ie>>3]=T:T=H,ie>M&&(J[Ge>>3]=ie,M=ie),ge=ie>0&ieAe?ie:Ae,y=y|+un(+(ie-N))>3.141592653589793,_=Pe+1|0,(_|0)!=(Ye|0);)tn=Pe,Pe=_,H=T,_=tn;y&&(J[Ge>>3]=Ae,J[A>>3]=ge)}}else d[Ie>>2]=0,d[Ie+4>>2]=0,d[Ie+8>>2]=0,d[Ie+12>>2]=0,d[Ie+16>>2]=0,d[Ie+20>>2]=0,d[Ie+24>>2]=0,d[Ie+28>>2]=0,p=d[sn>>2]|0;while((Le|0)<(p|0))}}function Da(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0;if(!(Ts(A,f,p)|0))return y=0,y|0;if(y=A+8|0,(d[y>>2]|0)<=0)return y=1,y|0;for(_=A+12|0,A=0;;){if(T=A,A=A+1|0,Ts((d[_>>2]|0)+(T<<3)|0,f+(A<<5)|0,p)|0){A=0,_=6;break}if((A|0)>=(d[y>>2]|0)){A=1,_=6;break}}return(_|0)==6?A|0:0}function Oo(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(I=K,K=K+16|0,N=I,M=p+8|0,!(Ts(A,f,M)|0))return U=0,K=I,U|0;U=A+8|0;e:do if((d[U>>2]|0)>0){for(T=A+12|0,y=0;;){if(H=y,y=y+1|0,Ts((d[T>>2]|0)+(H<<3)|0,f+(y<<5)|0,M)|0){y=0;break}if((y|0)>=(d[U>>2]|0))break e}return K=I,y|0}while(!1);if(hf(A,f,p,_)|0)return H=0,K=I,H|0;d[N>>2]=d[p>>2],d[N+4>>2]=M,y=d[U>>2]|0;e:do if((y|0)>0)for(A=A+12|0,M=0,T=y;;){if(y=d[A>>2]|0,(d[y+(M<<3)>>2]|0)>0){if(Ts(N,_,d[y+(M<<3)+4>>2]|0)|0){y=0;break e}if(y=M+1|0,hf((d[A>>2]|0)+(M<<3)|0,f+(y<<5)|0,p,_)|0){y=0;break e}T=d[U>>2]|0}else y=M+1|0;if((y|0)<(T|0))M=y;else{y=1;break}}else y=1;while(!1);return H=y,K=I,H|0}function hf(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0,sn=0,tn=0,Bn=0;if(sn=K,K=K+176|0,qe=sn+172|0,y=sn+168|0,Ge=sn,!(nf(f,_)|0))return A=0,K=sn,A|0;if(wA(f,_,qe,y),Gl(Ge|0,p|0,168)|0,(d[p>>2]|0)>0){f=0;do tn=Ge+8+(f<<4)+8|0,Ye=+Xs(+J[tn>>3],d[y>>2]|0),J[tn>>3]=Ye,f=f+1|0;while((f|0)<(d[p>>2]|0))}Pe=+J[_>>3],Ie=+J[_+8>>3],Ye=+Xs(+J[_+16>>3],d[y>>2]|0),Ae=+Xs(+J[_+24>>3],d[y>>2]|0);e:do if((d[A>>2]|0)>0){if(_=A+4|0,y=d[Ge>>2]|0,(y|0)<=0){for(f=0;;)if(f=f+1|0,(f|0)>=(d[A>>2]|0)){f=0;break e}}for(p=0;;){if(f=d[_>>2]|0,ge=+J[f+(p<<4)>>3],ve=+Xs(+J[f+(p<<4)+8>>3],d[qe>>2]|0),f=d[_>>2]|0,p=p+1|0,tn=(p|0)%(d[A>>2]|0)|0,T=+J[f+(tn<<4)>>3],M=+Xs(+J[f+(tn<<4)+8>>3],d[qe>>2]|0),!(ge>=Pe)|!(T>=Pe)&&!(ge<=Ie)|!(T<=Ie)&&!(ve<=Ae)|!(M<=Ae)&&!(ve>=Ye)|!(M>=Ye)){ie=T-ge,I=M-ve,f=0;do if(Bn=f,f=f+1|0,tn=(f|0)==(y|0)?0:f,T=+J[Ge+8+(Bn<<4)+8>>3],M=+J[Ge+8+(tn<<4)+8>>3]-T,N=+J[Ge+8+(Bn<<4)>>3],U=+J[Ge+8+(tn<<4)>>3]-N,H=ie*M-I*U,H!=0&&(Le=ve-T,Lt=ge-N,U=(Le*U-M*Lt)/H,!(U<0|U>1))&&(H=(ie*Le-I*Lt)/H,H>=0&H<=1)){f=1;break e}while((f|0)<(y|0))}if((p|0)>=(d[A>>2]|0)){f=0;break}}}else f=0;while(!1);return Bn=f,K=sn,Bn|0}function zA(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0;if(hf(A,f,p,_)|0)return T=1,T|0;if(T=A+8|0,(d[T>>2]|0)<=0)return T=0,T|0;for(y=A+12|0,A=0;;){if(M=A,A=A+1|0,hf((d[y>>2]|0)+(M<<3)|0,f+(A<<5)|0,p,_)|0){A=1,y=6;break}if((A|0)>=(d[T>>2]|0)){A=0,y=6;break}}return(y|0)==6?A|0:0}function _p(){return 8}function R1(){return 16}function fs(){return 168}function sr(){return 8}function mi(){return 16}function kl(){return 12}function Pa(){return 8}function yp(A){return A=A|0,+(+((d[A>>2]|0)>>>0)+4294967296*+(d[A+4>>2]|0))}function zl(A){A=A|0;var f=0,p=0;return p=+J[A>>3],f=+J[A+8>>3],+ +qn(+(p*p+f*f))}function xp(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0;I=+J[A>>3],U=+J[f>>3]-I,N=+J[A+8>>3],M=+J[f+8>>3]-N,ie=+J[p>>3],T=+J[_>>3]-ie,ge=+J[p+8>>3],H=+J[_+8>>3]-ge,T=(T*(N-ge)-(I-ie)*H)/(U*H-M*T),J[y>>3]=I+U*T,J[y+8>>3]=N+M*T}function bp(A,f){return A=A|0,f=f|0,+un(+(+J[A>>3]-+J[f>>3]))<11920928955078125e-23?(f=+un(+(+J[A+8>>3]-+J[f+8>>3]))<11920928955078125e-23,f|0):(f=0,f|0)}function ar(A,f){A=A|0,f=f|0;var p=0,_=0,y=0;return y=+J[A>>3]-+J[f>>3],_=+J[A+8>>3]-+J[f+8>>3],p=+J[A+16>>3]-+J[f+16>>3],+(y*y+_*_+p*p)}function Yu(A,f){A=A|0,f=f|0;var p=0,_=0,y=0;p=+J[A>>3],_=+li(+p),p=+Fn(+p),J[f+16>>3]=p,p=+J[A+8>>3],y=_*+li(+p),J[f>>3]=y,p=_*+Fn(+p),J[f+8>>3]=p}function Sp(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0;if(T=K,K=K+16|0,y=T,_=Ci(A,f)|0,(p+-1|0)>>>0>5||(_=(_|0)!=0,(p|0)==1&_))return y=-1,K=T,y|0;do if(ol(A,f,y)|0)_=-1;else if(_){_=((d[26352+(p<<2)>>2]|0)+5-(d[y>>2]|0)|0)%5|0;break}else{_=((d[26384+(p<<2)>>2]|0)+6-(d[y>>2]|0)|0)%6|0;break}while(!1);return y=_,K=T,y|0}function ol(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0;if(H=K,K=K+32|0,N=H+16|0,U=H,_=zu(A,f,N)|0,_|0)return p=_,K=H,p|0;T=g1(A,f)|0,I=$s(A,f)|0,tp(T,U),_=$c(T,d[N>>2]|0)|0;do if(Bi(T)|0){do switch(T|0){case 4:{y=0;break}case 14:{y=1;break}case 24:{y=2;break}case 38:{y=3;break}case 49:{y=4;break}case 58:{y=5;break}case 63:{y=6;break}case 72:{y=7;break}case 83:{y=8;break}case 97:{y=9;break}case 107:{y=10;break}case 117:{y=11;break}default:Bt(27795,27797,75,27806)}while(!1);if(M=d[26416+(y*24|0)+8>>2]|0,f=d[26416+(y*24|0)+16>>2]|0,A=d[N>>2]|0,(A|0)!=(d[U>>2]|0)&&(U=Wc(T)|0,A=d[N>>2]|0,U|(A|0)==(f|0)&&(_=(_+1|0)%6|0)),(I|0)==3&(A|0)==(f|0)){_=(_+5|0)%6|0;break}(I|0)==5&(A|0)==(M|0)&&(_=(_+1|0)%6|0)}while(!1);return d[p>>2]=_,p=0,K=H,p|0}function Qs(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0;if(Ge=K,K=K+32|0,qe=Ge+24|0,Ie=Ge+20|0,ve=Ge+8|0,Ae=Ge+16|0,ge=Ge,U=(Ci(A,f)|0)==0,U=U?6:5,H=Mt(A|0,f|0,52)|0,Z()|0,H=H&15,U>>>0<=p>>>0)return _=2,K=Ge,_|0;ie=(H|0)==0,!ie&&(Pe=Dt(7,0,(H^15)*3|0)|0,(Pe&A|0)==0&((Z()|0)&f|0)==0)?y=p:T=4;e:do if((T|0)==4){if(y=(Ci(A,f)|0)!=0,((y?4:5)|0)<(p|0)||ol(A,f,qe)|0||(T=(d[qe>>2]|0)+p|0,y?y=26704+(((T|0)%5|0)<<2)|0:y=26736+(((T|0)%6|0)<<2)|0,Pe=d[y>>2]|0,(Pe|0)==7))return _=1,K=Ge,_|0;d[Ie>>2]=0,y=cn(A,f,Pe,Ie,ve)|0;do if(!y){if(N=ve,I=d[N>>2]|0,N=d[N+4>>2]|0,M=N>>>0>>0|(N|0)==(f|0)&I>>>0>>0,T=M?I:A,M=M?N:f,!ie&&(ie=Dt(7,0,(H^15)*3|0)|0,(I&ie|0)==0&(N&(Z()|0)|0)==0))y=p;else{if(N=(p+-1+U|0)%(U|0)|0,y=Ci(A,f)|0,(N|0)<0&&Bt(27795,27797,248,27822),U=(y|0)!=0,((U?4:5)|0)<(N|0)&&Bt(27795,27797,248,27822),ol(A,f,qe)|0&&Bt(27795,27797,248,27822),y=(d[qe>>2]|0)+N|0,U?y=26704+(((y|0)%5|0)<<2)|0:y=26736+(((y|0)%6|0)<<2)|0,N=d[y>>2]|0,(N|0)==7&&Bt(27795,27797,248,27822),d[Ae>>2]=0,y=cn(A,f,N,Ae,ge)|0,y|0)break;I=ge,U=d[I>>2]|0,I=d[I+4>>2]|0;do if(I>>>0>>0|(I|0)==(M|0)&U>>>0>>0){if(Ci(U,I)|0?T=pi(U,I,A,f)|0:T=d[26800+((((d[Ae>>2]|0)+(d[26768+(N<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=Ci(U,I)|0,(T+-1|0)>>>0>5){y=-1,T=U,M=I;break}if(y=(y|0)!=0,(T|0)==1&y){y=-1,T=U,M=I;break}do if(ol(U,I,qe)|0)y=-1;else if(y){y=((d[26352+(T<<2)>>2]|0)+5-(d[qe>>2]|0)|0)%5|0;break}else{y=((d[26384+(T<<2)>>2]|0)+6-(d[qe>>2]|0)|0)%6|0;break}while(!1);T=U,M=I}else y=p;while(!1);N=ve,I=d[N>>2]|0,N=d[N+4>>2]|0}if((T|0)==(I|0)&(M|0)==(N|0)){if(U=(Ci(I,N)|0)!=0,U?A=pi(I,N,A,f)|0:A=d[26800+((((d[Ie>>2]|0)+(d[26768+(Pe<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=Ci(I,N)|0,(A+-1|0)>>>0<=5&&(Ye=(y|0)!=0,!((A|0)==1&Ye)))do if(ol(I,N,qe)|0)y=-1;else if(Ye){y=((d[26352+(A<<2)>>2]|0)+5-(d[qe>>2]|0)|0)%5|0;break}else{y=((d[26384+(A<<2)>>2]|0)+6-(d[qe>>2]|0)|0)%6|0;break}while(!1);else y=-1;y=y+1|0,y=(y|0)==6|U&(y|0)==5?0:y}f=M,A=T;break e}while(!1);return _=y,K=Ge,_|0}while(!1);return Ye=Dt(y|0,0,56)|0,qe=Z()|0|f&-2130706433|536870912,d[_>>2]=Ye|A,d[_+4>>2]=qe,_=0,K=Ge,_|0}function Qu(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0;return T=(Ci(A,f)|0)==0,_=Qs(A,f,0,p)|0,y=(_|0)==0,T?!y||(_=Qs(A,f,1,p+8|0)|0,_|0)||(_=Qs(A,f,2,p+16|0)|0,_|0)||(_=Qs(A,f,3,p+24|0)|0,_|0)||(_=Qs(A,f,4,p+32|0)|0,_)?(T=_,T|0):Qs(A,f,5,p+40|0)|0:!y||(_=Qs(A,f,1,p+8|0)|0,_|0)||(_=Qs(A,f,2,p+16|0)|0,_|0)||(_=Qs(A,f,3,p+24|0)|0,_|0)||(_=Qs(A,f,4,p+32|0)|0,_|0)?(T=_,T|0):(T=p+40|0,d[T>>2]=0,d[T+4>>2]=0,T=0,T|0)}function ll(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0,N=0,U=0;return U=K,K=K+192|0,y=U,T=U+168|0,M=Mt(A|0,f|0,56)|0,Z()|0,M=M&7,N=f&-2130706433|134217728,_=zu(A,N,T)|0,_|0?(N=_,K=U,N|0):(f=Mt(A|0,f|0,52)|0,Z()|0,f=f&15,Ci(A,N)|0?sp(T,f,M,1,y):RA(T,f,M,1,y),N=y+8|0,d[p>>2]=d[N>>2],d[p+4>>2]=d[N+4>>2],d[p+8>>2]=d[N+8>>2],d[p+12>>2]=d[N+12>>2],N=0,K=U,N|0)}function ul(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0;return y=K,K=K+16|0,p=y,!(!0&(f&2013265920|0)==536870912)||(_=f&-2130706433|134217728,!(NA(A,_)|0))?(_=0,K=y,_|0):(T=Mt(A|0,f|0,56)|0,Z()|0,T=(Qs(A,_,T&7,p)|0)==0,_=p,_=T&((d[_>>2]|0)==(A|0)?(d[_+4>>2]|0)==(f|0):0)&1,K=y,_|0)}function Io(A,f,p){A=A|0,f=f|0,p=p|0;var _=0;(f|0)>0?(_=Ks(f,4)|0,d[A>>2]=_,_||Bt(27835,27858,40,27872)):d[A>>2]=0,d[A+4>>2]=f,d[A+8>>2]=0,d[A+12>>2]=p}function GA(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0;y=A+4|0,T=A+12|0,M=A+8|0;e:for(;;){for(p=d[y>>2]|0,f=0;;){if((f|0)>=(p|0))break e;if(_=d[A>>2]|0,N=d[_+(f<<2)>>2]|0,!N)f=f+1|0;else break}f=_+(~~(+un(+(+Hs(10,+ +(15-(d[T>>2]|0)|0))*(+J[N>>3]+ +J[N+8>>3])))%+(p|0))>>>0<<2)|0,p=d[f>>2]|0;t:do if(p|0){if(_=N+32|0,(p|0)==(N|0))d[f>>2]=d[_>>2];else{if(p=p+32|0,f=d[p>>2]|0,!f)break;for(;(f|0)!=(N|0);)if(p=f+32|0,f=d[p>>2]|0,!f)break t;d[p>>2]=d[_>>2]}An(N),d[M>>2]=(d[M>>2]|0)+-1}while(!1)}An(d[A>>2]|0)}function qA(A){A=A|0;var f=0,p=0,_=0;for(_=d[A+4>>2]|0,p=0;;){if((p|0)>=(_|0)){f=0,p=4;break}if(f=d[(d[A>>2]|0)+(p<<2)>>2]|0,!f)p=p+1|0;else{p=4;break}}return(p|0)==4?f|0:0}function Ku(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0;if(p=~~(+un(+(+Hs(10,+ +(15-(d[A+12>>2]|0)|0))*(+J[f>>3]+ +J[f+8>>3])))%+(d[A+4>>2]|0))>>>0,p=(d[A>>2]|0)+(p<<2)|0,_=d[p>>2]|0,!_)return T=1,T|0;T=f+32|0;do if((_|0)!=(f|0)){if(p=d[_+32>>2]|0,!p)return T=1,T|0;for(y=p;;){if((y|0)==(f|0)){y=8;break}if(p=d[y+32>>2]|0,p)_=y,y=p;else{p=1,y=10;break}}if((y|0)==8){d[_+32>>2]=d[T>>2];break}else if((y|0)==10)return p|0}else d[p>>2]=d[T>>2];while(!1);return An(f),T=A+8|0,d[T>>2]=(d[T>>2]|0)+-1,T=0,T|0}function VA(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0;T=Fo(40)|0,T||Bt(27888,27858,98,27901),d[T>>2]=d[f>>2],d[T+4>>2]=d[f+4>>2],d[T+8>>2]=d[f+8>>2],d[T+12>>2]=d[f+12>>2],y=T+16|0,d[y>>2]=d[p>>2],d[y+4>>2]=d[p+4>>2],d[y+8>>2]=d[p+8>>2],d[y+12>>2]=d[p+12>>2],d[T+32>>2]=0,y=~~(+un(+(+Hs(10,+ +(15-(d[A+12>>2]|0)|0))*(+J[f>>3]+ +J[f+8>>3])))%+(d[A+4>>2]|0))>>>0,y=(d[A>>2]|0)+(y<<2)|0,_=d[y>>2]|0;do if(!_)d[y>>2]=T;else{for(;!(Ea(_,f)|0&&Ea(_+16|0,p)|0);)if(y=d[_+32>>2]|0,_=(y|0)==0?_:y,!(d[_+32>>2]|0)){M=10;break}if((M|0)==10){d[_+32>>2]=T;break}return An(T),M=_,M|0}while(!1);return M=A+8|0,d[M>>2]=(d[M>>2]|0)+1,M=T,M|0}function Zu(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0;if(y=~~(+un(+(+Hs(10,+ +(15-(d[A+12>>2]|0)|0))*(+J[f>>3]+ +J[f+8>>3])))%+(d[A+4>>2]|0))>>>0,y=d[(d[A>>2]|0)+(y<<2)>>2]|0,!y)return p=0,p|0;if(!p){for(A=y;;){if(Ea(A,f)|0){_=10;break}if(A=d[A+32>>2]|0,!A){A=0,_=10;break}}if((_|0)==10)return A|0}for(A=y;;){if(Ea(A,f)|0&&Ea(A+16|0,p)|0){_=10;break}if(A=d[A+32>>2]|0,!A){A=0,_=10;break}}return(_|0)==10?A|0:0}function As(A,f){A=A|0,f=f|0;var p=0;if(p=~~(+un(+(+Hs(10,+ +(15-(d[A+12>>2]|0)|0))*(+J[f>>3]+ +J[f+8>>3])))%+(d[A+4>>2]|0))>>>0,A=d[(d[A>>2]|0)+(p<<2)>>2]|0,!A)return p=0,p|0;for(;;){if(Ea(A,f)|0){f=5;break}if(A=d[A+32>>2]|0,!A){A=0,f=5;break}}return(f|0)==5?A|0:0}function HA(){return 27920}function cl(A){return A=+A,~~+pf(+A)|0}function Fo(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0,Pe=0,Ie=0,Ye=0,qe=0,Ge=0,Le=0,Lt=0;Lt=K,K=K+16|0,ge=Lt;do if(A>>>0<245){if(I=A>>>0<11?16:A+11&-8,A=I>>>3,ie=d[6981]|0,p=ie>>>A,p&3|0)return f=(p&1^1)+A|0,A=27964+(f<<1<<2)|0,p=A+8|0,_=d[p>>2]|0,y=_+8|0,T=d[y>>2]|0,(T|0)==(A|0)?d[6981]=ie&~(1<>2]=A,d[p>>2]=T),Le=f<<3,d[_+4>>2]=Le|3,Le=_+Le+4|0,d[Le>>2]=d[Le>>2]|1,Le=y,K=Lt,Le|0;if(H=d[6983]|0,I>>>0>H>>>0){if(p|0)return f=2<>>12&16,f=f>>>N,p=f>>>5&8,f=f>>>p,T=f>>>2&4,f=f>>>T,A=f>>>1&2,f=f>>>A,_=f>>>1&1,_=(p|N|T|A|_)+(f>>>_)|0,f=27964+(_<<1<<2)|0,A=f+8|0,T=d[A>>2]|0,N=T+8|0,p=d[N>>2]|0,(p|0)==(f|0)?(A=ie&~(1<<_),d[6981]=A):(d[p+12>>2]=f,d[A>>2]=p,A=ie),Le=_<<3,M=Le-I|0,d[T+4>>2]=I|3,y=T+I|0,d[y+4>>2]=M|1,d[T+Le>>2]=M,H|0&&(_=d[6986]|0,f=H>>>3,p=27964+(f<<1<<2)|0,f=1<>2]|0):(d[6981]=A|f,f=p,A=p+8|0),d[A>>2]=_,d[f+12>>2]=_,d[_+8>>2]=f,d[_+12>>2]=p),d[6983]=M,d[6986]=y,Le=N,K=Lt,Le|0;if(T=d[6982]|0,T){for(p=(T&0-T)+-1|0,y=p>>>12&16,p=p>>>y,_=p>>>5&8,p=p>>>_,M=p>>>2&4,p=p>>>M,N=p>>>1&2,p=p>>>N,U=p>>>1&1,U=d[28228+((_|y|M|N|U)+(p>>>U)<<2)>>2]|0,p=U,N=U,U=(d[U+4>>2]&-8)-I|0;A=d[p+16>>2]|0,!(!A&&(A=d[p+20>>2]|0,!A));)M=(d[A+4>>2]&-8)-I|0,y=M>>>0>>0,p=A,N=y?A:N,U=y?M:U;if(M=N+I|0,M>>>0>N>>>0){y=d[N+24>>2]|0,f=d[N+12>>2]|0;do if((f|0)==(N|0)){if(A=N+20|0,f=d[A>>2]|0,!f&&(A=N+16|0,f=d[A>>2]|0,!f)){p=0;break}for(;;)if(_=f+20|0,p=d[_>>2]|0,p)f=p,A=_;else if(_=f+16|0,p=d[_>>2]|0,p)f=p,A=_;else break;d[A>>2]=0,p=f}else p=d[N+8>>2]|0,d[p+12>>2]=f,d[f+8>>2]=p,p=f;while(!1);do if(y|0){if(f=d[N+28>>2]|0,A=28228+(f<<2)|0,(N|0)==(d[A>>2]|0)){if(d[A>>2]=p,!p){d[6982]=T&~(1<>2]|0)==(N|0)?Le:y+20|0)>>2]=p,!p)break;d[p+24>>2]=y,f=d[N+16>>2]|0,f|0&&(d[p+16>>2]=f,d[f+24>>2]=p),f=d[N+20>>2]|0,f|0&&(d[p+20>>2]=f,d[f+24>>2]=p)}while(!1);return U>>>0<16?(Le=U+I|0,d[N+4>>2]=Le|3,Le=N+Le+4|0,d[Le>>2]=d[Le>>2]|1):(d[N+4>>2]=I|3,d[M+4>>2]=U|1,d[M+U>>2]=U,H|0&&(_=d[6986]|0,f=H>>>3,p=27964+(f<<1<<2)|0,f=1<>2]|0):(d[6981]=f|ie,f=p,A=p+8|0),d[A>>2]=_,d[f+12>>2]=_,d[_+8>>2]=f,d[_+12>>2]=p),d[6983]=U,d[6986]=M),Le=N+8|0,K=Lt,Le|0}else ie=I}else ie=I}else ie=I}else if(A>>>0<=4294967231)if(A=A+11|0,I=A&-8,_=d[6982]|0,_){y=0-I|0,A=A>>>8,A?I>>>0>16777215?U=31:(ie=(A+1048320|0)>>>16&8,Pe=A<>>16&4,Pe=Pe<>>16&2,U=14-(N|ie|U)+(Pe<>>15)|0,U=I>>>(U+7|0)&1|U<<1):U=0,p=d[28228+(U<<2)>>2]|0;e:do if(!p)p=0,A=0,Pe=61;else for(A=0,N=I<<((U|0)==31?0:25-(U>>>1)|0),T=0;;){if(M=(d[p+4>>2]&-8)-I|0,M>>>0>>0)if(M)A=p,y=M;else{A=p,y=0,Pe=65;break e}if(Pe=d[p+20>>2]|0,p=d[p+16+(N>>>31<<2)>>2]|0,T=(Pe|0)==0|(Pe|0)==(p|0)?T:Pe,p)N=N<<1;else{p=T,Pe=61;break}}while(!1);if((Pe|0)==61){if((p|0)==0&(A|0)==0){if(A=2<>>12&16,ie=ie>>>M,T=ie>>>5&8,ie=ie>>>T,N=ie>>>2&4,ie=ie>>>N,U=ie>>>1&2,ie=ie>>>U,p=ie>>>1&1,A=0,p=d[28228+((T|M|N|U|p)+(ie>>>p)<<2)>>2]|0}p?Pe=65:(N=A,M=y)}if((Pe|0)==65)for(T=p;;)if(ie=(d[T+4>>2]&-8)-I|0,p=ie>>>0>>0,y=p?ie:y,A=p?T:A,p=d[T+16>>2]|0,p||(p=d[T+20>>2]|0),p)T=p;else{N=A,M=y;break}if((N|0)!=0&&M>>>0<((d[6983]|0)-I|0)>>>0&&(H=N+I|0,H>>>0>N>>>0)){T=d[N+24>>2]|0,f=d[N+12>>2]|0;do if((f|0)==(N|0)){if(A=N+20|0,f=d[A>>2]|0,!f&&(A=N+16|0,f=d[A>>2]|0,!f)){f=0;break}for(;;)if(y=f+20|0,p=d[y>>2]|0,p)f=p,A=y;else if(y=f+16|0,p=d[y>>2]|0,p)f=p,A=y;else break;d[A>>2]=0}else Le=d[N+8>>2]|0,d[Le+12>>2]=f,d[f+8>>2]=Le;while(!1);do if(T){if(A=d[N+28>>2]|0,p=28228+(A<<2)|0,(N|0)==(d[p>>2]|0)){if(d[p>>2]=f,!f){_=_&~(1<>2]|0)==(N|0)?Le:T+20|0)>>2]=f,!f)break;d[f+24>>2]=T,A=d[N+16>>2]|0,A|0&&(d[f+16>>2]=A,d[A+24>>2]=f),A=d[N+20>>2]|0,A&&(d[f+20>>2]=A,d[A+24>>2]=f)}while(!1);e:do if(M>>>0<16)Le=M+I|0,d[N+4>>2]=Le|3,Le=N+Le+4|0,d[Le>>2]=d[Le>>2]|1;else{if(d[N+4>>2]=I|3,d[H+4>>2]=M|1,d[H+M>>2]=M,f=M>>>3,M>>>0<256){p=27964+(f<<1<<2)|0,A=d[6981]|0,f=1<>2]|0):(d[6981]=A|f,f=p,A=p+8|0),d[A>>2]=H,d[f+12>>2]=H,d[H+8>>2]=f,d[H+12>>2]=p;break}if(f=M>>>8,f?M>>>0>16777215?p=31:(Ge=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,p=14-(qe|Ge|p)+(Le<

>>15)|0,p=M>>>(p+7|0)&1|p<<1):p=0,f=28228+(p<<2)|0,d[H+28>>2]=p,A=H+16|0,d[A+4>>2]=0,d[A>>2]=0,A=1<>2]=H,d[H+24>>2]=f,d[H+12>>2]=H,d[H+8>>2]=H;break}f=d[f>>2]|0;t:do if((d[f+4>>2]&-8|0)!=(M|0)){for(_=M<<((p|0)==31?0:25-(p>>>1)|0);p=f+16+(_>>>31<<2)|0,A=d[p>>2]|0,!!A;)if((d[A+4>>2]&-8|0)==(M|0)){f=A;break t}else _=_<<1,f=A;d[p>>2]=H,d[H+24>>2]=f,d[H+12>>2]=H,d[H+8>>2]=H;break e}while(!1);Ge=f+8|0,Le=d[Ge>>2]|0,d[Le+12>>2]=H,d[Ge>>2]=H,d[H+8>>2]=Le,d[H+12>>2]=f,d[H+24>>2]=0}while(!1);return Le=N+8|0,K=Lt,Le|0}else ie=I}else ie=I;else ie=-1;while(!1);if(p=d[6983]|0,p>>>0>=ie>>>0)return f=p-ie|0,A=d[6986]|0,f>>>0>15?(Le=A+ie|0,d[6986]=Le,d[6983]=f,d[Le+4>>2]=f|1,d[A+p>>2]=f,d[A+4>>2]=ie|3):(d[6983]=0,d[6986]=0,d[A+4>>2]=p|3,Le=A+p+4|0,d[Le>>2]=d[Le>>2]|1),Le=A+8|0,K=Lt,Le|0;if(M=d[6984]|0,M>>>0>ie>>>0)return qe=M-ie|0,d[6984]=qe,Le=d[6987]|0,Ge=Le+ie|0,d[6987]=Ge,d[Ge+4>>2]=qe|1,d[Le+4>>2]=ie|3,Le=Le+8|0,K=Lt,Le|0;if(d[7099]|0?A=d[7101]|0:(d[7101]=4096,d[7100]=4096,d[7102]=-1,d[7103]=-1,d[7104]=0,d[7092]=0,d[7099]=ge&-16^1431655768,A=4096),N=ie+48|0,U=ie+47|0,T=A+U|0,y=0-A|0,I=T&y,I>>>0<=ie>>>0||(A=d[7091]|0,A|0&&(H=d[7089]|0,ge=H+I|0,ge>>>0<=H>>>0|ge>>>0>A>>>0)))return Le=0,K=Lt,Le|0;e:do if(d[7092]&4)f=0,Pe=143;else{p=d[6987]|0;t:do if(p){for(_=28372;ge=d[_>>2]|0,!(ge>>>0<=p>>>0&&(ge+(d[_+4>>2]|0)|0)>>>0>p>>>0);)if(A=d[_+8>>2]|0,A)_=A;else{Pe=128;break t}if(f=T-M&y,f>>>0<2147483647)if(A=fl(f|0)|0,(A|0)==((d[_>>2]|0)+(d[_+4>>2]|0)|0)){if((A|0)!=-1){M=f,T=A,Pe=145;break e}}else _=A,Pe=136;else f=0}else Pe=128;while(!1);do if((Pe|0)==128)if(p=fl(0)|0,(p|0)!=-1&&(f=p,Ae=d[7100]|0,ve=Ae+-1|0,f=((ve&f|0)==0?0:(ve+f&0-Ae)-f|0)+I|0,Ae=d[7089]|0,ve=f+Ae|0,f>>>0>ie>>>0&f>>>0<2147483647)){if(ge=d[7091]|0,ge|0&&ve>>>0<=Ae>>>0|ve>>>0>ge>>>0){f=0;break}if(A=fl(f|0)|0,(A|0)==(p|0)){M=f,T=p,Pe=145;break e}else _=A,Pe=136}else f=0;while(!1);do if((Pe|0)==136){if(p=0-f|0,!(N>>>0>f>>>0&(f>>>0<2147483647&(_|0)!=-1)))if((_|0)==-1){f=0;break}else{M=f,T=_,Pe=145;break e}if(A=d[7101]|0,A=U-f+A&0-A,A>>>0>=2147483647){M=f,T=_,Pe=145;break e}if((fl(A|0)|0)==-1){fl(p|0)|0,f=0;break}else{M=A+f|0,T=_,Pe=145;break e}}while(!1);d[7092]=d[7092]|4,Pe=143}while(!1);if((Pe|0)==143&&I>>>0<2147483647&&(qe=fl(I|0)|0,ve=fl(0)|0,Ie=ve-qe|0,Ye=Ie>>>0>(ie+40|0)>>>0,!((qe|0)==-1|Ye^1|qe>>>0>>0&((qe|0)!=-1&(ve|0)!=-1)^1))&&(M=Ye?Ie:f,T=qe,Pe=145),(Pe|0)==145){f=(d[7089]|0)+M|0,d[7089]=f,f>>>0>(d[7090]|0)>>>0&&(d[7090]=f),U=d[6987]|0;e:do if(U){for(f=28372;;){if(A=d[f>>2]|0,p=d[f+4>>2]|0,(T|0)==(A+p|0)){Pe=154;break}if(_=d[f+8>>2]|0,_)f=_;else break}if((Pe|0)==154&&(Ge=f+4|0,(d[f+12>>2]&8|0)==0)&&T>>>0>U>>>0&A>>>0<=U>>>0){d[Ge>>2]=p+M,Le=(d[6984]|0)+M|0,qe=U+8|0,qe=(qe&7|0)==0?0:0-qe&7,Ge=U+qe|0,qe=Le-qe|0,d[6987]=Ge,d[6984]=qe,d[Ge+4>>2]=qe|1,d[U+Le+4>>2]=40,d[6988]=d[7103];break}for(T>>>0<(d[6985]|0)>>>0&&(d[6985]=T),p=T+M|0,f=28372;;){if((d[f>>2]|0)==(p|0)){Pe=162;break}if(A=d[f+8>>2]|0,A)f=A;else break}if((Pe|0)==162&&(d[f+12>>2]&8|0)==0){d[f>>2]=T,H=f+4|0,d[H>>2]=(d[H>>2]|0)+M,H=T+8|0,H=T+((H&7|0)==0?0:0-H&7)|0,f=p+8|0,f=p+((f&7|0)==0?0:0-f&7)|0,I=H+ie|0,N=f-H-ie|0,d[H+4>>2]=ie|3;t:do if((U|0)==(f|0))Le=(d[6984]|0)+N|0,d[6984]=Le,d[6987]=I,d[I+4>>2]=Le|1;else{if((d[6986]|0)==(f|0)){Le=(d[6983]|0)+N|0,d[6983]=Le,d[6986]=I,d[I+4>>2]=Le|1,d[I+Le>>2]=Le;break}if(A=d[f+4>>2]|0,(A&3|0)==1){M=A&-8,_=A>>>3;n:do if(A>>>0<256)if(A=d[f+8>>2]|0,p=d[f+12>>2]|0,(p|0)==(A|0)){d[6981]=d[6981]&~(1<<_);break}else{d[A+12>>2]=p,d[p+8>>2]=A;break}else{T=d[f+24>>2]|0,A=d[f+12>>2]|0;do if((A|0)==(f|0)){if(p=f+16|0,_=p+4|0,A=d[_>>2]|0,A)p=_;else if(A=d[p>>2]|0,!A){A=0;break}for(;;)if(y=A+20|0,_=d[y>>2]|0,_)A=_,p=y;else if(y=A+16|0,_=d[y>>2]|0,_)A=_,p=y;else break;d[p>>2]=0}else Le=d[f+8>>2]|0,d[Le+12>>2]=A,d[A+8>>2]=Le;while(!1);if(!T)break;p=d[f+28>>2]|0,_=28228+(p<<2)|0;do if((d[_>>2]|0)!=(f|0)){if(Le=T+16|0,d[((d[Le>>2]|0)==(f|0)?Le:T+20|0)>>2]=A,!A)break n}else{if(d[_>>2]=A,A|0)break;d[6982]=d[6982]&~(1<>2]=T,p=f+16|0,_=d[p>>2]|0,_|0&&(d[A+16>>2]=_,d[_+24>>2]=A),p=d[p+4>>2]|0,!p)break;d[A+20>>2]=p,d[p+24>>2]=A}while(!1);f=f+M|0,y=M+N|0}else y=N;if(f=f+4|0,d[f>>2]=d[f>>2]&-2,d[I+4>>2]=y|1,d[I+y>>2]=y,f=y>>>3,y>>>0<256){p=27964+(f<<1<<2)|0,A=d[6981]|0,f=1<>2]|0):(d[6981]=A|f,f=p,A=p+8|0),d[A>>2]=I,d[f+12>>2]=I,d[I+8>>2]=f,d[I+12>>2]=p;break}f=y>>>8;do if(!f)_=0;else{if(y>>>0>16777215){_=31;break}Ge=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,_=14-(qe|Ge|_)+(Le<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1}while(!1);if(f=28228+(_<<2)|0,d[I+28>>2]=_,A=I+16|0,d[A+4>>2]=0,d[A>>2]=0,A=d[6982]|0,p=1<<_,!(A&p)){d[6982]=A|p,d[f>>2]=I,d[I+24>>2]=f,d[I+12>>2]=I,d[I+8>>2]=I;break}f=d[f>>2]|0;n:do if((d[f+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=f+16+(_>>>31<<2)|0,A=d[p>>2]|0,!!A;)if((d[A+4>>2]&-8|0)==(y|0)){f=A;break n}else _=_<<1,f=A;d[p>>2]=I,d[I+24>>2]=f,d[I+12>>2]=I,d[I+8>>2]=I;break t}while(!1);Ge=f+8|0,Le=d[Ge>>2]|0,d[Le+12>>2]=I,d[Ge>>2]=I,d[I+8>>2]=Le,d[I+12>>2]=f,d[I+24>>2]=0}while(!1);return Le=H+8|0,K=Lt,Le|0}for(f=28372;A=d[f>>2]|0,!(A>>>0<=U>>>0&&(Le=A+(d[f+4>>2]|0)|0,Le>>>0>U>>>0));)f=d[f+8>>2]|0;y=Le+-47|0,A=y+8|0,A=y+((A&7|0)==0?0:0-A&7)|0,y=U+16|0,A=A>>>0>>0?U:A,f=A+8|0,p=M+-40|0,qe=T+8|0,qe=(qe&7|0)==0?0:0-qe&7,Ge=T+qe|0,qe=p-qe|0,d[6987]=Ge,d[6984]=qe,d[Ge+4>>2]=qe|1,d[T+p+4>>2]=40,d[6988]=d[7103],p=A+4|0,d[p>>2]=27,d[f>>2]=d[7093],d[f+4>>2]=d[7094],d[f+8>>2]=d[7095],d[f+12>>2]=d[7096],d[7093]=T,d[7094]=M,d[7096]=0,d[7095]=f,f=A+24|0;do Ge=f,f=f+4|0,d[f>>2]=7;while((Ge+8|0)>>>0>>0);if((A|0)!=(U|0)){if(T=A-U|0,d[p>>2]=d[p>>2]&-2,d[U+4>>2]=T|1,d[A>>2]=T,f=T>>>3,T>>>0<256){p=27964+(f<<1<<2)|0,A=d[6981]|0,f=1<>2]|0):(d[6981]=A|f,f=p,A=p+8|0),d[A>>2]=U,d[f+12>>2]=U,d[U+8>>2]=f,d[U+12>>2]=p;break}if(f=T>>>8,f?T>>>0>16777215?_=31:(Ge=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,_=14-(qe|Ge|_)+(Le<<_>>>15)|0,_=T>>>(_+7|0)&1|_<<1):_=0,p=28228+(_<<2)|0,d[U+28>>2]=_,d[U+20>>2]=0,d[y>>2]=0,f=d[6982]|0,A=1<<_,!(f&A)){d[6982]=f|A,d[p>>2]=U,d[U+24>>2]=p,d[U+12>>2]=U,d[U+8>>2]=U;break}f=d[p>>2]|0;t:do if((d[f+4>>2]&-8|0)!=(T|0)){for(_=T<<((_|0)==31?0:25-(_>>>1)|0);p=f+16+(_>>>31<<2)|0,A=d[p>>2]|0,!!A;)if((d[A+4>>2]&-8|0)==(T|0)){f=A;break t}else _=_<<1,f=A;d[p>>2]=U,d[U+24>>2]=f,d[U+12>>2]=U,d[U+8>>2]=U;break e}while(!1);Ge=f+8|0,Le=d[Ge>>2]|0,d[Le+12>>2]=U,d[Ge>>2]=U,d[U+8>>2]=Le,d[U+12>>2]=f,d[U+24>>2]=0}}else Le=d[6985]|0,(Le|0)==0|T>>>0>>0&&(d[6985]=T),d[7093]=T,d[7094]=M,d[7096]=0,d[6990]=d[7099],d[6989]=-1,d[6994]=27964,d[6993]=27964,d[6996]=27972,d[6995]=27972,d[6998]=27980,d[6997]=27980,d[7e3]=27988,d[6999]=27988,d[7002]=27996,d[7001]=27996,d[7004]=28004,d[7003]=28004,d[7006]=28012,d[7005]=28012,d[7008]=28020,d[7007]=28020,d[7010]=28028,d[7009]=28028,d[7012]=28036,d[7011]=28036,d[7014]=28044,d[7013]=28044,d[7016]=28052,d[7015]=28052,d[7018]=28060,d[7017]=28060,d[7020]=28068,d[7019]=28068,d[7022]=28076,d[7021]=28076,d[7024]=28084,d[7023]=28084,d[7026]=28092,d[7025]=28092,d[7028]=28100,d[7027]=28100,d[7030]=28108,d[7029]=28108,d[7032]=28116,d[7031]=28116,d[7034]=28124,d[7033]=28124,d[7036]=28132,d[7035]=28132,d[7038]=28140,d[7037]=28140,d[7040]=28148,d[7039]=28148,d[7042]=28156,d[7041]=28156,d[7044]=28164,d[7043]=28164,d[7046]=28172,d[7045]=28172,d[7048]=28180,d[7047]=28180,d[7050]=28188,d[7049]=28188,d[7052]=28196,d[7051]=28196,d[7054]=28204,d[7053]=28204,d[7056]=28212,d[7055]=28212,Le=M+-40|0,qe=T+8|0,qe=(qe&7|0)==0?0:0-qe&7,Ge=T+qe|0,qe=Le-qe|0,d[6987]=Ge,d[6984]=qe,d[Ge+4>>2]=qe|1,d[T+Le+4>>2]=40,d[6988]=d[7103];while(!1);if(f=d[6984]|0,f>>>0>ie>>>0)return qe=f-ie|0,d[6984]=qe,Le=d[6987]|0,Ge=Le+ie|0,d[6987]=Ge,d[Ge+4>>2]=qe|1,d[Le+4>>2]=ie|3,Le=Le+8|0,K=Lt,Le|0}return Le=HA()|0,d[Le>>2]=12,Le=0,K=Lt,Le|0}function An(A){A=A|0;var f=0,p=0,_=0,y=0,T=0,M=0,N=0,U=0;if(A){p=A+-8|0,y=d[6985]|0,A=d[A+-4>>2]|0,f=A&-8,U=p+f|0;do if(A&1)N=p,M=p;else{if(_=d[p>>2]|0,!(A&3)||(M=p+(0-_)|0,T=_+f|0,M>>>0>>0))return;if((d[6986]|0)==(M|0)){if(A=U+4|0,f=d[A>>2]|0,(f&3|0)!=3){N=M,f=T;break}d[6983]=T,d[A>>2]=f&-2,d[M+4>>2]=T|1,d[M+T>>2]=T;return}if(p=_>>>3,_>>>0<256)if(A=d[M+8>>2]|0,f=d[M+12>>2]|0,(f|0)==(A|0)){d[6981]=d[6981]&~(1<>2]=f,d[f+8>>2]=A,N=M,f=T;break}y=d[M+24>>2]|0,A=d[M+12>>2]|0;do if((A|0)==(M|0)){if(f=M+16|0,p=f+4|0,A=d[p>>2]|0,A)f=p;else if(A=d[f>>2]|0,!A){A=0;break}for(;;)if(_=A+20|0,p=d[_>>2]|0,p)A=p,f=_;else if(_=A+16|0,p=d[_>>2]|0,p)A=p,f=_;else break;d[f>>2]=0}else N=d[M+8>>2]|0,d[N+12>>2]=A,d[A+8>>2]=N;while(!1);if(y){if(f=d[M+28>>2]|0,p=28228+(f<<2)|0,(d[p>>2]|0)==(M|0)){if(d[p>>2]=A,!A){d[6982]=d[6982]&~(1<>2]|0)==(M|0)?N:y+20|0)>>2]=A,!A){N=M,f=T;break}d[A+24>>2]=y,f=M+16|0,p=d[f>>2]|0,p|0&&(d[A+16>>2]=p,d[p+24>>2]=A),f=d[f+4>>2]|0,f?(d[A+20>>2]=f,d[f+24>>2]=A,N=M,f=T):(N=M,f=T)}else N=M,f=T}while(!1);if(!(M>>>0>=U>>>0)&&(A=U+4|0,_=d[A>>2]|0,!!(_&1))){if(_&2)d[A>>2]=_&-2,d[N+4>>2]=f|1,d[M+f>>2]=f,y=f;else{if((d[6987]|0)==(U|0)){if(U=(d[6984]|0)+f|0,d[6984]=U,d[6987]=N,d[N+4>>2]=U|1,(N|0)!=(d[6986]|0))return;d[6986]=0,d[6983]=0;return}if((d[6986]|0)==(U|0)){U=(d[6983]|0)+f|0,d[6983]=U,d[6986]=M,d[N+4>>2]=U|1,d[M+U>>2]=U;return}y=(_&-8)+f|0,p=_>>>3;do if(_>>>0<256)if(f=d[U+8>>2]|0,A=d[U+12>>2]|0,(A|0)==(f|0)){d[6981]=d[6981]&~(1<>2]=A,d[A+8>>2]=f;break}else{T=d[U+24>>2]|0,A=d[U+12>>2]|0;do if((A|0)==(U|0)){if(f=U+16|0,p=f+4|0,A=d[p>>2]|0,A)f=p;else if(A=d[f>>2]|0,!A){p=0;break}for(;;)if(_=A+20|0,p=d[_>>2]|0,p)A=p,f=_;else if(_=A+16|0,p=d[_>>2]|0,p)A=p,f=_;else break;d[f>>2]=0,p=A}else p=d[U+8>>2]|0,d[p+12>>2]=A,d[A+8>>2]=p,p=A;while(!1);if(T|0){if(A=d[U+28>>2]|0,f=28228+(A<<2)|0,(d[f>>2]|0)==(U|0)){if(d[f>>2]=p,!p){d[6982]=d[6982]&~(1<>2]|0)==(U|0)?_:T+20|0)>>2]=p,!p)break;d[p+24>>2]=T,A=U+16|0,f=d[A>>2]|0,f|0&&(d[p+16>>2]=f,d[f+24>>2]=p),A=d[A+4>>2]|0,A|0&&(d[p+20>>2]=A,d[A+24>>2]=p)}}while(!1);if(d[N+4>>2]=y|1,d[M+y>>2]=y,(N|0)==(d[6986]|0)){d[6983]=y;return}}if(A=y>>>3,y>>>0<256){p=27964+(A<<1<<2)|0,f=d[6981]|0,A=1<>2]|0):(d[6981]=f|A,A=p,f=p+8|0),d[f>>2]=N,d[A+12>>2]=N,d[N+8>>2]=A,d[N+12>>2]=p;return}A=y>>>8,A?y>>>0>16777215?_=31:(M=(A+1048320|0)>>>16&8,U=A<>>16&4,U=U<>>16&2,_=14-(T|M|_)+(U<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1):_=0,A=28228+(_<<2)|0,d[N+28>>2]=_,d[N+20>>2]=0,d[N+16>>2]=0,f=d[6982]|0,p=1<<_;e:do if(!(f&p))d[6982]=f|p,d[A>>2]=N,d[N+24>>2]=A,d[N+12>>2]=N,d[N+8>>2]=N;else{A=d[A>>2]|0;t:do if((d[A+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=A+16+(_>>>31<<2)|0,f=d[p>>2]|0,!!f;)if((d[f+4>>2]&-8|0)==(y|0)){A=f;break t}else _=_<<1,A=f;d[p>>2]=N,d[N+24>>2]=A,d[N+12>>2]=N,d[N+8>>2]=N;break e}while(!1);M=A+8|0,U=d[M>>2]|0,d[U+12>>2]=N,d[M>>2]=N,d[N+8>>2]=U,d[N+12>>2]=A,d[N+24>>2]=0}while(!1);if(U=(d[6989]|0)+-1|0,d[6989]=U,!(U|0)){for(A=28380;A=d[A>>2]|0,A;)A=A+8|0;d[6989]=-1}}}}function Ks(A,f){A=A|0,f=f|0;var p=0;return A?(p=Xe(f,A)|0,(f|A)>>>0>65535&&(p=((p>>>0)/(A>>>0)|0|0)==(f|0)?p:-1)):p=0,A=Fo(p)|0,!A||!(d[A+-4>>2]&3)||uo(A|0,0,p|0)|0,A|0}function Qt(A,f,p,_){return A=A|0,f=f|0,p=p|0,_=_|0,p=A+p>>>0,mt(f+_+(p>>>0>>0|0)>>>0|0),p|0|0}function Ur(A,f,p,_){return A=A|0,f=f|0,p=p|0,_=_|0,_=f-_-(p>>>0>A>>>0|0)>>>0,mt(_|0),A-p>>>0|0|0}function Jc(A){return A=A|0,(A?31-(Xt(A^A-1)|0)|0:32)|0}function Ju(A,f,p,_,y){A=A|0,f=f|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,N=0,U=0,I=0,H=0,ie=0,ge=0,Ae=0,ve=0;if(H=A,U=f,I=U,M=p,ge=_,N=ge,!I)return T=(y|0)!=0,N?T?(d[y>>2]=A|0,d[y+4>>2]=f&0,ge=0,y=0,mt(ge|0),y|0):(ge=0,y=0,mt(ge|0),y|0):(T&&(d[y>>2]=(H>>>0)%(M>>>0),d[y+4>>2]=0),ge=0,y=(H>>>0)/(M>>>0)>>>0,mt(ge|0),y|0);T=(N|0)==0;do if(M){if(!T){if(T=(Xt(N|0)|0)-(Xt(I|0)|0)|0,T>>>0<=31){ie=T+1|0,N=31-T|0,f=T-31>>31,M=ie,A=H>>>(ie>>>0)&f|I<>>(ie>>>0)&f,T=0,N=H<>2]=A|0,d[y+4>>2]=U|f&0,ge=0,y=0,mt(ge|0),y|0):(ge=0,y=0,mt(ge|0),y|0)}if(T=M-1|0,T&M|0){N=(Xt(M|0)|0)+33-(Xt(I|0)|0)|0,ve=64-N|0,ie=32-N|0,U=ie>>31,Ae=N-32|0,f=Ae>>31,M=N,A=ie-1>>31&I>>>(Ae>>>0)|(I<>>(N>>>0))&f,f=f&I>>>(N>>>0),T=H<>>(Ae>>>0))&U|H<>31;break}return y|0&&(d[y>>2]=T&H,d[y+4>>2]=0),(M|0)==1?(Ae=U|f&0,ve=A|0|0,mt(Ae|0),ve|0):(ve=Jc(M|0)|0,Ae=I>>>(ve>>>0)|0,ve=I<<32-ve|H>>>(ve>>>0)|0,mt(Ae|0),ve|0)}else{if(T)return y|0&&(d[y>>2]=(I>>>0)%(M>>>0),d[y+4>>2]=0),Ae=0,ve=(I>>>0)/(M>>>0)>>>0,mt(Ae|0),ve|0;if(!H)return y|0&&(d[y>>2]=0,d[y+4>>2]=(I>>>0)%(N>>>0)),Ae=0,ve=(I>>>0)/(N>>>0)>>>0,mt(Ae|0),ve|0;if(T=N-1|0,!(T&N))return y|0&&(d[y>>2]=A|0,d[y+4>>2]=T&I|f&0),Ae=0,ve=I>>>((Jc(N|0)|0)>>>0),mt(Ae|0),ve|0;if(T=(Xt(N|0)|0)-(Xt(I|0)|0)|0,T>>>0<=30){f=T+1|0,N=31-T|0,M=f,A=I<>>(f>>>0),f=I>>>(f>>>0),T=0,N=H<>2]=A|0,d[y+4>>2]=U|f&0,Ae=0,ve=0,mt(Ae|0),ve|0):(Ae=0,ve=0,mt(Ae|0),ve|0)}while(!1);if(!M)I=N,U=0,N=0;else{ie=p|0|0,H=ge|_&0,I=Qt(ie|0,H|0,-1,-1)|0,p=Z()|0,U=N,N=0;do _=U,U=T>>>31|U<<1,T=N|T<<1,_=A<<1|_>>>31|0,ge=A>>>31|f<<1|0,Ur(I|0,p|0,_|0,ge|0)|0,ve=Z()|0,Ae=ve>>31|((ve|0)<0?-1:0)<<1,N=Ae&1,A=Ur(_|0,ge|0,Ae&ie|0,(((ve|0)<0?-1:0)>>31|((ve|0)<0?-1:0)<<1)&H|0)|0,f=Z()|0,M=M-1|0;while((M|0)!=0);I=U,U=0}return M=0,y|0&&(d[y>>2]=A,d[y+4>>2]=f),Ae=(T|0)>>>31|(I|M)<<1|(M<<1|T>>>31)&0|U,ve=(T<<1|0)&-2|N,mt(Ae|0),ve|0}function ko(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0;return I=f>>31|((f|0)<0?-1:0)<<1,U=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,T=_>>31|((_|0)<0?-1:0)<<1,y=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,N=Ur(I^A|0,U^f|0,I|0,U|0)|0,M=Z()|0,A=T^I,f=y^U,Ur((Ju(N,M,Ur(T^p|0,y^_|0,T|0,y|0)|0,Z()|0,0)|0)^A|0,(Z()|0)^f|0,A|0,f|0)|0}function eh(A,f){A=A|0,f=f|0;var p=0,_=0,y=0,T=0;return T=A&65535,y=f&65535,p=Xe(y,T)|0,_=A>>>16,A=(p>>>16)+(Xe(y,_)|0)|0,y=f>>>16,f=Xe(y,T)|0,mt((A>>>16)+(Xe(y,_)|0)+(((A&65535)+f|0)>>>16)|0),A+f<<16|p&65535|0|0}function fr(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0;return y=A,T=p,p=eh(y,T)|0,A=Z()|0,mt((Xe(f,T)|0)+(Xe(_,y)|0)+A|A&0|0),p|0|0|0}function th(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0,M=0,N=0,U=0,I=0;return y=K,K=K+16|0,N=y|0,M=f>>31|((f|0)<0?-1:0)<<1,T=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,I=_>>31|((_|0)<0?-1:0)<<1,U=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,A=Ur(M^A|0,T^f|0,M|0,T|0)|0,f=Z()|0,Ju(A,f,Ur(I^p|0,U^_|0,I|0,U|0)|0,Z()|0,N)|0,_=Ur(d[N>>2]^M|0,d[N+4>>2]^T|0,M|0,T|0)|0,p=Z()|0,K=y,mt(p|0),_|0}function ec(A,f,p,_){A=A|0,f=f|0,p=p|0,_=_|0;var y=0,T=0;return T=K,K=K+16|0,y=T|0,Ju(A,f,p,_,y)|0,K=T,mt(d[y+4>>2]|0),d[y>>2]|0|0}function N1(A,f,p){return A=A|0,f=f|0,p=p|0,(p|0)<32?(mt(f>>p|0),A>>>p|(f&(1<>p-32|0)}function Mt(A,f,p){return A=A|0,f=f|0,p=p|0,(p|0)<32?(mt(f>>>p|0),A>>>p|(f&(1<>>p-32|0)}function Dt(A,f,p){return A=A|0,f=f|0,p=p|0,(p|0)<32?(mt(f<>>32-p|0),A<=0?+Xn(A+.5):+Qe(A-.5)}function Gl(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0;if((p|0)>=8192)return ui(A|0,f|0,p|0)|0,A|0;if(T=A|0,y=A+p|0,(A&3)==(f&3)){for(;A&3;){if(!p)return T|0;at[A>>0]=at[f>>0]|0,A=A+1|0,f=f+1|0,p=p-1|0}for(p=y&-4|0,_=p-64|0;(A|0)<=(_|0);)d[A>>2]=d[f>>2],d[A+4>>2]=d[f+4>>2],d[A+8>>2]=d[f+8>>2],d[A+12>>2]=d[f+12>>2],d[A+16>>2]=d[f+16>>2],d[A+20>>2]=d[f+20>>2],d[A+24>>2]=d[f+24>>2],d[A+28>>2]=d[f+28>>2],d[A+32>>2]=d[f+32>>2],d[A+36>>2]=d[f+36>>2],d[A+40>>2]=d[f+40>>2],d[A+44>>2]=d[f+44>>2],d[A+48>>2]=d[f+48>>2],d[A+52>>2]=d[f+52>>2],d[A+56>>2]=d[f+56>>2],d[A+60>>2]=d[f+60>>2],A=A+64|0,f=f+64|0;for(;(A|0)<(p|0);)d[A>>2]=d[f>>2],A=A+4|0,f=f+4|0}else for(p=y-4|0;(A|0)<(p|0);)at[A>>0]=at[f>>0]|0,at[A+1>>0]=at[f+1>>0]|0,at[A+2>>0]=at[f+2>>0]|0,at[A+3>>0]=at[f+3>>0]|0,A=A+4|0,f=f+4|0;for(;(A|0)<(y|0);)at[A>>0]=at[f>>0]|0,A=A+1|0,f=f+1|0;return T|0}function uo(A,f,p){A=A|0,f=f|0,p=p|0;var _=0,y=0,T=0,M=0;if(T=A+p|0,f=f&255,(p|0)>=67){for(;A&3;)at[A>>0]=f,A=A+1|0;for(_=T&-4|0,M=f|f<<8|f<<16|f<<24,y=_-64|0;(A|0)<=(y|0);)d[A>>2]=M,d[A+4>>2]=M,d[A+8>>2]=M,d[A+12>>2]=M,d[A+16>>2]=M,d[A+20>>2]=M,d[A+24>>2]=M,d[A+28>>2]=M,d[A+32>>2]=M,d[A+36>>2]=M,d[A+40>>2]=M,d[A+44>>2]=M,d[A+48>>2]=M,d[A+52>>2]=M,d[A+56>>2]=M,d[A+60>>2]=M,A=A+64|0;for(;(A|0)<(_|0);)d[A>>2]=M,A=A+4|0}for(;(A|0)<(T|0);)at[A>>0]=f,A=A+1|0;return T-p|0}function pf(A){return A=+A,A>=0?+Xn(A+.5):+Qe(A-.5)}function fl(A){A=A|0;var f=0,p=0,_=0;return _=fn()|0,p=d[Gn>>2]|0,f=p+A|0,(A|0)>0&(f|0)<(p|0)|(f|0)<0?(yi(f|0)|0,bn(12),-1):(f|0)>(_|0)&&!(ci(f|0)|0)?(bn(12),-1):(d[Gn>>2]=f,p|0)}return{___divdi3:ko,___muldi3:fr,___remdi3:th,___uremdi3:ec,_areNeighborCells:dx,_bitshift64Ashr:N1,_bitshift64Lshr:Mt,_bitshift64Shl:Dt,_calloc:Ks,_cellAreaKm2:mp,_cellAreaM2:UA,_cellAreaRads2:Fl,_cellToBoundary:Il,_cellToCenterChild:DA,_cellToChildPos:Ap,_cellToChildren:_1,_cellToChildrenSize:lf,_cellToLatLng:Ol,_cellToLocalIj:E1,_cellToParent:Fu,_cellToVertex:Qs,_cellToVertexes:Qu,_cellsToDirectedEdge:d1,_cellsToLinkedMultiPolygon:nl,_childPosToCell:S1,_compactCells:up,_constructCell:Sx,_destroyLinkedMultiPolygon:Wu,_directedEdgeToBoundary:CA,_directedEdgeToCells:gx,_edgeLengthKm:gp,_edgeLengthM:ju,_edgeLengthRads:BA,_emscripten_replace_memory:Un,_free:An,_getBaseCellNumber:g1,_getDirectedEdgeDestination:mx,_getDirectedEdgeOrigin:px,_getHexagonAreaAvgKm2:dp,_getHexagonAreaAvgM2:w1,_getHexagonEdgeLengthAvgKm:pp,_getHexagonEdgeLengthAvgM:oo,_getIcosahedronFaces:Gu,_getIndexDigit:bx,_getNumCells:Hu,_getPentagons:qu,_getRes0Cells:ef,_getResolution:Qc,_greatCircleDistanceKm:Zc,_greatCircleDistanceM:Mx,_greatCircleDistanceRads:T1,_gridDisk:ye,_gridDiskDistances:ot,_gridDistance:$u,_gridPathCells:C1,_gridPathCellsSize:vp,_gridRing:Yn,_gridRingUnsafe:xi,_i64Add:Qt,_i64Subtract:Ur,_isPentagon:Ci,_isResClassIII:b1,_isValidCell:NA,_isValidDirectedEdge:p1,_isValidIndex:v1,_isValidVertex:ul,_latLngToCell:PA,_llvm_ctlz_i64:ff,_llvm_maxnum_f64:Af,_llvm_minnum_f64:df,_llvm_round_f64:hl,_localIjToCell:IA,_malloc:Fo,_maxFaceCount:wx,_maxGridDiskSize:fa,_maxPolygonToCellsSize:Pr,_maxPolygonToCellsSizeExperimental:cf,_memcpy:Gl,_memset:uo,_originToDirectedEdges:vx,_pentagonCount:fp,_polygonToCells:Zh,_polygonToCellsExperimental:kA,_readInt64AsDoubleFromPointer:yp,_res0CellCount:s1,_round:pf,_sbrk:fl,_sizeOfCellBoundary:fs,_sizeOfCoordIJ:Pa,_sizeOfGeoLoop:sr,_sizeOfGeoPolygon:mi,_sizeOfH3Index:_p,_sizeOfLatLng:R1,_sizeOfLinkedGeoPolygon:kl,_uncompactCells:y1,_uncompactCellsSize:x1,_vertexToLatLng:ll,establishStackSpace:bs,stackAlloc:mn,stackRestore:hi,stackSave:yr}})(Nn,_i,Y);e.___divdi3=me.___divdi3,e.___muldi3=me.___muldi3,e.___remdi3=me.___remdi3,e.___uremdi3=me.___uremdi3,e._areNeighborCells=me._areNeighborCells,e._bitshift64Ashr=me._bitshift64Ashr,e._bitshift64Lshr=me._bitshift64Lshr,e._bitshift64Shl=me._bitshift64Shl,e._calloc=me._calloc,e._cellAreaKm2=me._cellAreaKm2,e._cellAreaM2=me._cellAreaM2,e._cellAreaRads2=me._cellAreaRads2,e._cellToBoundary=me._cellToBoundary,e._cellToCenterChild=me._cellToCenterChild,e._cellToChildPos=me._cellToChildPos,e._cellToChildren=me._cellToChildren,e._cellToChildrenSize=me._cellToChildrenSize,e._cellToLatLng=me._cellToLatLng,e._cellToLocalIj=me._cellToLocalIj,e._cellToParent=me._cellToParent,e._cellToVertex=me._cellToVertex,e._cellToVertexes=me._cellToVertexes,e._cellsToDirectedEdge=me._cellsToDirectedEdge,e._cellsToLinkedMultiPolygon=me._cellsToLinkedMultiPolygon,e._childPosToCell=me._childPosToCell,e._compactCells=me._compactCells,e._constructCell=me._constructCell,e._destroyLinkedMultiPolygon=me._destroyLinkedMultiPolygon,e._directedEdgeToBoundary=me._directedEdgeToBoundary,e._directedEdgeToCells=me._directedEdgeToCells,e._edgeLengthKm=me._edgeLengthKm,e._edgeLengthM=me._edgeLengthM,e._edgeLengthRads=me._edgeLengthRads;var bt=e._emscripten_replace_memory=me._emscripten_replace_memory;e._free=me._free,e._getBaseCellNumber=me._getBaseCellNumber,e._getDirectedEdgeDestination=me._getDirectedEdgeDestination,e._getDirectedEdgeOrigin=me._getDirectedEdgeOrigin,e._getHexagonAreaAvgKm2=me._getHexagonAreaAvgKm2,e._getHexagonAreaAvgM2=me._getHexagonAreaAvgM2,e._getHexagonEdgeLengthAvgKm=me._getHexagonEdgeLengthAvgKm,e._getHexagonEdgeLengthAvgM=me._getHexagonEdgeLengthAvgM,e._getIcosahedronFaces=me._getIcosahedronFaces,e._getIndexDigit=me._getIndexDigit,e._getNumCells=me._getNumCells,e._getPentagons=me._getPentagons,e._getRes0Cells=me._getRes0Cells,e._getResolution=me._getResolution,e._greatCircleDistanceKm=me._greatCircleDistanceKm,e._greatCircleDistanceM=me._greatCircleDistanceM,e._greatCircleDistanceRads=me._greatCircleDistanceRads,e._gridDisk=me._gridDisk,e._gridDiskDistances=me._gridDiskDistances,e._gridDistance=me._gridDistance,e._gridPathCells=me._gridPathCells,e._gridPathCellsSize=me._gridPathCellsSize,e._gridRing=me._gridRing,e._gridRingUnsafe=me._gridRingUnsafe,e._i64Add=me._i64Add,e._i64Subtract=me._i64Subtract,e._isPentagon=me._isPentagon,e._isResClassIII=me._isResClassIII,e._isValidCell=me._isValidCell,e._isValidDirectedEdge=me._isValidDirectedEdge,e._isValidIndex=me._isValidIndex,e._isValidVertex=me._isValidVertex,e._latLngToCell=me._latLngToCell,e._llvm_ctlz_i64=me._llvm_ctlz_i64,e._llvm_maxnum_f64=me._llvm_maxnum_f64,e._llvm_minnum_f64=me._llvm_minnum_f64,e._llvm_round_f64=me._llvm_round_f64,e._localIjToCell=me._localIjToCell,e._malloc=me._malloc,e._maxFaceCount=me._maxFaceCount,e._maxGridDiskSize=me._maxGridDiskSize,e._maxPolygonToCellsSize=me._maxPolygonToCellsSize,e._maxPolygonToCellsSizeExperimental=me._maxPolygonToCellsSizeExperimental,e._memcpy=me._memcpy,e._memset=me._memset,e._originToDirectedEdges=me._originToDirectedEdges,e._pentagonCount=me._pentagonCount,e._polygonToCells=me._polygonToCells,e._polygonToCellsExperimental=me._polygonToCellsExperimental,e._readInt64AsDoubleFromPointer=me._readInt64AsDoubleFromPointer,e._res0CellCount=me._res0CellCount,e._round=me._round,e._sbrk=me._sbrk,e._sizeOfCellBoundary=me._sizeOfCellBoundary,e._sizeOfCoordIJ=me._sizeOfCoordIJ,e._sizeOfGeoLoop=me._sizeOfGeoLoop,e._sizeOfGeoPolygon=me._sizeOfGeoPolygon,e._sizeOfH3Index=me._sizeOfH3Index,e._sizeOfLatLng=me._sizeOfLatLng,e._sizeOfLinkedGeoPolygon=me._sizeOfLinkedGeoPolygon,e._uncompactCells=me._uncompactCells,e._uncompactCellsSize=me._uncompactCellsSize,e._vertexToLatLng=me._vertexToLatLng,e.establishStackSpace=me.establishStackSpace;var tt=e.stackAlloc=me.stackAlloc,St=e.stackRestore=me.stackRestore,qt=e.stackSave=me.stackSave;if(e.asm=me,e.cwrap=L,e.setValue=S,e.getValue=w,fe){le(fe)||(fe=s(fe));{en();var Ht=function(Ze){Ze.byteLength&&(Ze=new Uint8Array(Ze)),te.set(Ze,x),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,xt()},xn=function(){a(fe,Ht,function(){throw"could not load memory initializer "+fe})},qi=Vt(fe);if(qi)Ht(qi.buffer);else if(e.memoryInitializerRequest){var rr=function(){var Ze=e.memoryInitializerRequest,vt=Ze.response;if(Ze.status!==200&&Ze.status!==0){var zt=Vt(e.memoryInitializerRequestURL);if(zt)vt=zt.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+Ze.status+", retrying "+fe),xn();return}}Ht(vt)};e.memoryInitializerRequest.response?setTimeout(rr,0):e.memoryInitializerRequest.addEventListener("load",rr)}else xn()}}var pn;yt=function Ze(){pn||$i(),pn||(yt=Ze)};function $i(Ze){if(Pt>0||(Ce(),Pt>0))return;function vt(){pn||(pn=!0,!R&&(dt(),At(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),wt()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),vt()},1)):vt()}e.run=$i;function Jr(Ze){throw e.onAbort&&e.onAbort(Ze),Ze+="",l(Ze),u(Ze),R=!0,"abort("+Ze+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=Jr,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return $i(),i})(typeof Ti=="object"?Ti:{}),Dn="number",Cn=Dn,Md=Dn,On=Dn,In=Dn,Cs=Dn,nn=Dn,JK=[["sizeOfH3Index",Dn],["sizeOfLatLng",Dn],["sizeOfCellBoundary",Dn],["sizeOfGeoLoop",Dn],["sizeOfGeoPolygon",Dn],["sizeOfLinkedGeoPolygon",Dn],["sizeOfCoordIJ",Dn],["readInt64AsDoubleFromPointer",Dn],["isValidCell",Md,[On,In]],["isValidIndex",Md,[On,In]],["latLngToCell",Cn,[Dn,Dn,Cs,nn]],["cellToLatLng",Cn,[On,In,nn]],["cellToBoundary",Cn,[On,In,nn]],["maxGridDiskSize",Cn,[Dn,nn]],["gridDisk",Cn,[On,In,Dn,nn]],["gridDiskDistances",Cn,[On,In,Dn,nn,nn]],["gridRing",Cn,[On,In,Dn,nn]],["gridRingUnsafe",Cn,[On,In,Dn,nn]],["maxPolygonToCellsSize",Cn,[nn,Cs,Dn,nn]],["polygonToCells",Cn,[nn,Cs,Dn,nn]],["maxPolygonToCellsSizeExperimental",Cn,[nn,Cs,Dn,nn]],["polygonToCellsExperimental",Cn,[nn,Cs,Dn,Dn,Dn,nn]],["cellsToLinkedMultiPolygon",Cn,[nn,Dn,nn]],["destroyLinkedMultiPolygon",null,[nn]],["compactCells",Cn,[nn,nn,Dn,Dn]],["uncompactCells",Cn,[nn,Dn,Dn,nn,Dn,Cs]],["uncompactCellsSize",Cn,[nn,Dn,Dn,Cs,nn]],["isPentagon",Md,[On,In]],["isResClassIII",Md,[On,In]],["getBaseCellNumber",Dn,[On,In]],["getResolution",Dn,[On,In]],["getIndexDigit",Dn,[On,In,Dn]],["constructCell",Cn,[Dn,Dn,nn,nn]],["maxFaceCount",Cn,[On,In,nn]],["getIcosahedronFaces",Cn,[On,In,nn]],["cellToParent",Cn,[On,In,Cs,nn]],["cellToChildren",Cn,[On,In,Cs,nn]],["cellToCenterChild",Cn,[On,In,Cs,nn]],["cellToChildrenSize",Cn,[On,In,Cs,nn]],["cellToChildPos",Cn,[On,In,Cs,nn]],["childPosToCell",Cn,[Dn,Dn,On,In,Cs,nn]],["areNeighborCells",Cn,[On,In,On,In,nn]],["cellsToDirectedEdge",Cn,[On,In,On,In,nn]],["getDirectedEdgeOrigin",Cn,[On,In,nn]],["getDirectedEdgeDestination",Cn,[On,In,nn]],["isValidDirectedEdge",Md,[On,In]],["directedEdgeToCells",Cn,[On,In,nn]],["originToDirectedEdges",Cn,[On,In,nn]],["directedEdgeToBoundary",Cn,[On,In,nn]],["gridDistance",Cn,[On,In,On,In,nn]],["gridPathCells",Cn,[On,In,On,In,nn]],["gridPathCellsSize",Cn,[On,In,On,In,nn]],["cellToLocalIj",Cn,[On,In,On,In,Dn,nn]],["localIjToCell",Cn,[On,In,nn,Dn,nn]],["getHexagonAreaAvgM2",Cn,[Cs,nn]],["getHexagonAreaAvgKm2",Cn,[Cs,nn]],["getHexagonEdgeLengthAvgM",Cn,[Cs,nn]],["getHexagonEdgeLengthAvgKm",Cn,[Cs,nn]],["greatCircleDistanceM",Dn,[nn,nn]],["greatCircleDistanceKm",Dn,[nn,nn]],["greatCircleDistanceRads",Dn,[nn,nn]],["cellAreaM2",Cn,[On,In,nn]],["cellAreaKm2",Cn,[On,In,nn]],["cellAreaRads2",Cn,[On,In,nn]],["edgeLengthM",Cn,[On,In,nn]],["edgeLengthKm",Cn,[On,In,nn]],["edgeLengthRads",Cn,[On,In,nn]],["getNumCells",Cn,[Cs,nn]],["getRes0Cells",Cn,[nn]],["res0CellCount",Dn],["getPentagons",Cn,[Dn,nn]],["pentagonCount",Dn],["cellToVertex",Cn,[On,In,Dn,nn]],["cellToVertexes",Cn,[On,In,nn]],["vertexToLatLng",Cn,[On,In,nn]],["isValidVertex",Md,[On,In]]],eZ=0,tZ=1,nZ=2,iZ=3,yP=4,rZ=5,sZ=6,aZ=7,oZ=8,lZ=9,uZ=10,cZ=11,hZ=12,fZ=13,AZ=14,dZ=15,pZ=16,mZ=17,gZ=18,vZ=19,Kr={};Kr[eZ]="Success";Kr[tZ]="The operation failed but a more specific error is not available";Kr[nZ]="Argument was outside of acceptable range";Kr[iZ]="Latitude or longitude arguments were outside of acceptable range";Kr[yP]="Resolution argument was outside of acceptable range";Kr[rZ]="Cell argument was not valid";Kr[sZ]="Directed edge argument was not valid";Kr[aZ]="Undirected edge argument was not valid";Kr[oZ]="Vertex argument was not valid";Kr[lZ]="Pentagon distortion was encountered";Kr[uZ]="Duplicate input";Kr[cZ]="Cell arguments were not neighbors";Kr[hZ]="Cell arguments had incompatible resolutions";Kr[fZ]="Memory allocation failed";Kr[AZ]="Bounds of provided memory were insufficient";Kr[dZ]="Mode or flags argument was not valid";Kr[pZ]="Index argument was not valid";Kr[mZ]="Base cell number was outside of acceptable range";Kr[gZ]="Child indexing digits invalid";Kr[vZ]="Child indexing digits refer to a deleted subsequence";var _Z=1e3,xP=1001,bP=1002,Ry={};Ry[_Z]="Unknown unit";Ry[xP]="Array length out of bounds";Ry[bP]="Got unexpected null value for H3 index";var yZ="Unknown error";function SP(i,e,t){var n=t&&"value"in t,r=new Error((i[e]||yZ)+" (code: "+e+(n?", value: "+t.value:"")+")");return r.code=e,r}function TP(i,e){var t=arguments.length===2?{value:e}:{};return SP(Kr,i,t)}function wP(i,e){var t=arguments.length===2?{value:e}:{};return SP(Ry,i,t)}function vg(i){if(i!==0)throw TP(i)}var eo={};JK.forEach(function(e){eo[e[0]]=Ti.cwrap.apply(Ti,e)});var Xd=16,_g=4,U0=8,xZ=8,j_=eo.sizeOfH3Index(),MM=eo.sizeOfLatLng(),bZ=eo.sizeOfCellBoundary(),SZ=eo.sizeOfGeoPolygon(),Lm=eo.sizeOfGeoLoop();eo.sizeOfLinkedGeoPolygon();eo.sizeOfCoordIJ();function TZ(i){if(typeof i!="number"||i<0||i>15||Math.floor(i)!==i)throw TP(yP,i);return i}function wZ(i){if(!i)throw wP(bP);return i}var MZ=Math.pow(2,32)-1;function EZ(i){if(i>MZ)throw wP(xP,i);return i}var CZ=/[^0-9a-fA-F]/;function MP(i){if(Array.isArray(i)&&i.length===2&&Number.isInteger(i[0])&&Number.isInteger(i[1]))return i;if(typeof i!="string"||CZ.test(i))return[0,0];var e=parseInt(i.substring(0,i.length-8),Xd),t=parseInt(i.substring(i.length-8),Xd);return[t,e]}function E6(i){if(i>=0)return i.toString(Xd);i=i&2147483647;var e=EP(8,i.toString(Xd)),t=(parseInt(e[0],Xd)+8).toString(Xd);return e=t+e.substring(1),e}function RZ(i,e){return E6(e)+EP(8,E6(i))}function EP(i,e){for(var t=i-e.length,n="",r=0;r0){l=Ti._calloc(t,Lm);for(var u=0;u0){for(var a=Ti.getValue(i+n,"i32"),l=0;l0){const{width:a,height:l}=e.context;t.bufferWidth=a,t.bufferHeight=l}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){const{object:t,material:n,geometry:r}=e,s=this.getRenderObjectData(e);if(s.worldMatrix.equals(t.matrixWorld)!==!0)return s.worldMatrix.copy(t.matrixWorld),!1;const a=s.material;for(const R in a){const C=a[R],E=n[R];if(C.equals!==void 0){if(C.equals(E)===!1)return C.copy(E),!1}else if(E.isTexture===!0){if(C.id!==E.id||C.version!==E.version)return C.id=E.id,C.version=E.version,!1}else if(C!==E)return a[R]=E,!1}if(a.transmission>0){const{width:R,height:C}=e.context;if(s.bufferWidth!==R||s.bufferHeight!==C)return s.bufferWidth=R,s.bufferHeight=C,!1}const l=s.geometry,u=r.attributes,h=l.attributes,m=Object.keys(h),v=Object.keys(u);if(m.length!==v.length)return s.geometry.attributes=this.getAttributesData(u),!1;for(const R of m){const C=h[R],E=u[R];if(E===void 0)return delete h[R],!1;if(C.version!==E.version)return C.version=E.version,!1}const x=r.index,S=l.indexVersion,w=x?x.version:null;if(S!==w)return l.indexVersion=w,!1;if(l.drawRange.start!==r.drawRange.start||l.drawRange.count!==r.drawRange.count)return l.drawRange.start=r.drawRange.start,l.drawRange.count=r.drawRange.count,!1;if(s.morphTargetInfluences){let R=!1;for(let C=0;C>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const PP=i=>yg(i),Ny=i=>yg(i),EM=(...i)=>yg(i);function LP(i,e=!1){const t=[];i.isNode===!0&&(t.push(i.id),i=i.getSelf());for(const{property:n,childNode:r}of $_(i))t.push(t,yg(n.slice(0,-4)),r.getCacheKey(e));return yg(t)}function*$_(i,e=!1){for(const t in i){if(t.startsWith("_")===!0)continue;const n=i[t];if(Array.isArray(n)===!0)for(let r=0;re.charCodeAt(0)).buffer}const IT={VERTEX:"vertex",FRAGMENT:"fragment"},jn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},VZ={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},sa={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},GP=["fragment","vertex"],FT=["setup","analyze","generate"],kT=[...GP,"compute"],gA=["x","y","z","w"];let HZ=0;class Mn extends zc{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=jn.NONE,this.updateBeforeType=jn.NONE,this.updateAfterType=jn.NONE,this.uuid=M0.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:HZ++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,jn.FRAME)}onRenderUpdate(e){return this.onUpdate(e,jn.RENDER)}onObjectUpdate(e){return this.onUpdate(e,jn.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of $_(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=EM(LP(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e){if(e.increaseUsage(this)===1){const n=e.getNodeProperties(this);for(const r of Object.values(n))r&&r.isNode===!0&&r.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){a.initialized=!0;const l=this.setup(e),u=l&&l.isNode===!0;for(const h of Object.values(a))h&&h.isNode===!0&&h.build(e);u&&l.build(e),a.outputNode=l}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const l=this.getNodeType(e),u=e.getDataFromNode(this);r=u.snippet,r===void 0?(r=this.generate(e)||"",u.snippet=r):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,l,t)}else r=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return $_(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(s)?[]:{}),n[r][s]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const s of e.inputNodes[n])r.push(t[s]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const s in e.inputNodes[n]){const a=e.inputNodes[n][s];r[s]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}if(r){const l=a(e.textures),u=a(e.images),h=a(e.nodes);l.length>0&&(s.textures=l),u.length>0&&(s.images=u),h.length>0&&(s.nodes=h)}return s}}class vA extends Mn{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),n=this.indexNode.build(e,"uint");return`${t}[ ${n} ]`}}class qP extends Mn{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),s=n.build(e,r);return e.format(s,r,t)}}class Zr extends Mn{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),l=e.getVarFromNode(this,null,r),u=e.getPropertyName(l);return e.addLineFlowCode(`${u} = ${a}`,this),s.snippet=a,s.propertyName=u,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class jZ extends Zr{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=this.nodes,s=e.getComponentType(n),a=[];for(const u of r){let h=u.build(e);const m=e.getComponentType(u.getNodeType(e));m!==s&&(h=e.format(h,m,s)),a.push(h)}const l=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(l,n,t)}}const WZ=gA.join("");class zT extends Mn{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(gA.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===WZ.slice(0,this.components.length)?s=e.format(u,a,t):s=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class $Z extends Zr{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,s=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),l=e.getTypeFromLength(n.length,a),u=r.build(e,l),h=t.build(e,s),m=e.getTypeLength(s),v=[];for(let x=0;xi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),D6=i=>VP(i).split("").sort().join(""),HP={setup(i,e){const t=e.shift();return i(Vg(t),...e)},get(i,e,t){if(typeof e=="string"&&i[e]===void 0){if(i.isStackNode!==!0&&e==="assign")return(...n)=>(B0.assign(t,...n),t);if(Yd.has(e)){const n=Yd.get(e);return i.isStackNode?(...r)=>t.add(n(...r)):(...r)=>n(t,...r)}else{if(e==="self")return i;if(e.endsWith("Assign")&&Yd.has(e.slice(0,e.length-6))){const n=Yd.get(e.slice(0,e.length-6));return i.isStackNode?(...r)=>t.assign(r[0],n(...r)):(...r)=>t.assign(n(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=VP(e),_t(new zT(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=D6(e.slice(3).toLowerCase()),n=>_t(new $Z(i,e,n));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=D6(e.slice(4).toLowerCase()),()=>_t(new XZ(_t(i),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),_t(new zT(i,e));if(/^\d+$/.test(e)===!0)return _t(new vA(t,new Ll(Number(e),"uint")))}}}return Reflect.get(i,e,t)},set(i,e,t,n){return typeof e=="string"&&i[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(i,e,t,n)}},W3=new WeakMap,P6=new WeakMap,YZ=function(i,e=null){const t=Uh(i);if(t==="node"){let n=W3.get(i);return n===void 0&&(n=new Proxy(i,HP),W3.set(i,n),W3.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return _t(GT(i,e));if(t==="shader")return je(i)}return i},QZ=function(i,e=null){for(const t in i)i[t]=_t(i[t],e);return i},KZ=function(i,e=null){const t=i.length;for(let n=0;n_t(n!==null?Object.assign(s,n):s);return e===null?(...s)=>r(new i(...tA(s))):t!==null?(t=_t(t),(...s)=>r(new i(e,...tA(s),t))):(...s)=>r(new i(e,...tA(s)))},JZ=function(i,...e){return _t(new i(...tA(e)))};class eJ extends Mn{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=P6.get(e.constructor);a===void 0&&(a=new WeakMap,P6.set(e.constructor,a));let l=a.get(t);l===void 0&&(l=_t(e.buildFunctionNode(t)),a.set(t,l)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(l),s=_t(l.call(n))}else{const a=t.jsFunc,l=n!==null?a(n,e):a(e);s=_t(l)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class tJ extends Mn{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Vg(e),_t(new eJ(this,e))}setup(){return this.call()}}const nJ=[!1,!0],iJ=[0,1,2,3],rJ=[-1,-2],jP=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],RM=new Map;for(const i of nJ)RM.set(i,new Ll(i));const NM=new Map;for(const i of iJ)NM.set(i,new Ll(i,"uint"));const DM=new Map([...NM].map(i=>new Ll(i.value,"int")));for(const i of rJ)DM.set(i,new Ll(i,"int"));const Dy=new Map([...DM].map(i=>new Ll(i.value)));for(const i of jP)Dy.set(i,new Ll(i));for(const i of jP)Dy.set(-i,new Ll(-i));const Py={bool:RM,uint:NM,ints:DM,float:Dy},L6=new Map([...RM,...Dy]),GT=(i,e)=>L6.has(i)?L6.get(i):i.isNode===!0?i:new Ll(i,e),sJ=i=>{try{return i.getNodeType()}catch{return}},ls=function(i,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>typeof r!="object"))&&(t=[IP(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return _t(e.get(t[0]));if(t.length===1){const r=GT(t[0],i);return sJ(r)===i?_t(r):_t(new qP(r,i))}const n=t.map(r=>GT(r));return _t(new jZ(n,i))}},xg=i=>typeof i=="object"&&i!==null?i.value:i,WP=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Um(i,e){return new Proxy(new tJ(i,e),HP)}const _t=(i,e=null)=>YZ(i,e),Vg=(i,e=null)=>new QZ(i,e),tA=(i,e=null)=>new KZ(i,e),ct=(...i)=>new ZZ(...i),Wt=(...i)=>new JZ(...i),je=(i,e)=>{const t=new Um(i,e),n=(...r)=>{let s;return Vg(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return n.shaderNode=t,n.setLayout=r=>(t.setLayout(r),n),n.once=()=>(t.once=!0,n),n},aJ=(...i)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),je(...i));ut("toGlobal",i=>(i.global=!0,i));const bg=i=>{B0=i},PM=()=>B0,ti=(...i)=>B0.If(...i);function $P(i){return B0&&B0.add(i),i}ut("append",$P);const XP=new ls("color"),_e=new ls("float",Py.float),Ee=new ls("int",Py.ints),Zt=new ls("uint",Py.uint),Ic=new ls("bool",Py.bool),Ct=new ls("vec2"),ms=new ls("ivec2"),YP=new ls("uvec2"),QP=new ls("bvec2"),Be=new ls("vec3"),KP=new ls("ivec3"),Y0=new ls("uvec3"),LM=new ls("bvec3"),dn=new ls("vec4"),ZP=new ls("ivec4"),JP=new ls("uvec4"),eL=new ls("bvec4"),Ly=new ls("mat2"),ha=new ls("mat3"),nA=new ls("mat4"),oJ=(i="")=>_t(new Ll(i,"string")),lJ=i=>_t(new Ll(i,"ArrayBuffer"));ut("toColor",XP);ut("toFloat",_e);ut("toInt",Ee);ut("toUint",Zt);ut("toBool",Ic);ut("toVec2",Ct);ut("toIVec2",ms);ut("toUVec2",YP);ut("toBVec2",QP);ut("toVec3",Be);ut("toIVec3",KP);ut("toUVec3",Y0);ut("toBVec3",LM);ut("toVec4",dn);ut("toIVec4",ZP);ut("toUVec4",JP);ut("toBVec4",eL);ut("toMat2",Ly);ut("toMat3",ha);ut("toMat4",nA);const tL=ct(vA),nL=(i,e)=>_t(new qP(_t(i),e)),uJ=(i,e)=>_t(new zT(_t(i),e));ut("element",tL);ut("convert",nL);class iL extends Mn{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const rL=i=>new iL(i),UM=(i,e=0)=>new iL(i,!0,e),sL=UM("frame"),Rn=UM("render"),BM=rL("object");class Hg extends CM{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=BM}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(r=>{const s=e(r,n);s!==void 0&&(this.value=s)},t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),l=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(l);return e.context.label!==void 0&&delete e.context.label,e.format(u,n,t)}}const gn=(i,e)=>{const t=WP(e||i),n=i&&i.isNode===!0?i.node&&i.node.value||i.value:i;return _t(new Hg(n,t))};class Gi extends Mn{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const aL=(i,e)=>_t(new Gi(i,e)),Sg=(i,e)=>_t(new Gi(i,e,!0)),Ui=Wt(Gi,"vec4","DiffuseColor"),qT=Wt(Gi,"vec3","EmissiveColor"),Zl=Wt(Gi,"float","Roughness"),Tg=Wt(Gi,"float","Metalness"),X_=Wt(Gi,"float","Clearcoat"),wg=Wt(Gi,"float","ClearcoatRoughness"),Xf=Wt(Gi,"vec3","Sheen"),Uy=Wt(Gi,"float","SheenRoughness"),By=Wt(Gi,"float","Iridescence"),OM=Wt(Gi,"float","IridescenceIOR"),IM=Wt(Gi,"float","IridescenceThickness"),Y_=Wt(Gi,"float","AlphaT"),Rh=Wt(Gi,"float","Anisotropy"),Bm=Wt(Gi,"vec3","AnisotropyT"),iA=Wt(Gi,"vec3","AnisotropyB"),ka=Wt(Gi,"color","SpecularColor"),Mg=Wt(Gi,"float","SpecularF90"),Q_=Wt(Gi,"float","Shininess"),Eg=Wt(Gi,"vec4","Output"),Qv=Wt(Gi,"float","dashSize"),VT=Wt(Gi,"float","gapSize"),cJ=Wt(Gi,"float","pointWidth"),Om=Wt(Gi,"float","IOR"),K_=Wt(Gi,"float","Transmission"),FM=Wt(Gi,"float","Thickness"),kM=Wt(Gi,"float","AttenuationDistance"),zM=Wt(Gi,"color","AttenuationColor"),GM=Wt(Gi,"float","Dispersion");class hJ extends Zr{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return gA.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:r}=this,s=this.needsSplitAssign(e),a=n.getNodeType(e),l=n.context({assign:!0}).build(e),u=r.build(e,a),h=r.getNodeType(e),m=e.getDataFromNode(this);let v;if(m.initialized===!0)t!=="void"&&(v=l);else if(s){const x=e.getVarFromNode(this,null,a),S=e.getPropertyName(x);e.addLineFlowCode(`${S} = ${u}`,this);const w=n.node.context({assign:!0}).build(e);for(let R=0;R{const m=h.type,v=m==="pointer";let x;return v?x="&"+u.build(e):x=u.build(e,m),x};if(Array.isArray(s))for(let u=0;u(e=e.length>1||e[0]&&e[0].isNode===!0?tA(e):Vg(e[0]),_t(new fJ(_t(i),e)));ut("call",lL);class Mr extends Zr{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let s=new Mr(e,t,n);for(let a=0;a>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="=="||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="<"||n===">"||n==="<="||n===">="){const u=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(l));return u>1?`bvec${u}`:"bool"}else return a==="float"&&e.isMatrix(l)?l:e.isMatrix(a)&&e.isVector(l)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(l)?e.getVectorFromMatrix(l):e.getTypeLength(l)>e.getTypeLength(a)?l:a}generate(e,t){const n=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let l=null,u=null;a!=="void"?(l=r.getNodeType(e),u=typeof s<"u"?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="?e.isVector(l)?u=l:l!==u&&(l=u="float"):n===">>"||n==="<<"?(l=a,u=e.changeComponentType(u,"uint")):e.isMatrix(l)&&e.isVector(u)?u=e.getVectorFromMatrix(l):e.isVector(l)&&e.isMatrix(u)?l=e.getVectorFromMatrix(u):l=u=a):l=u=a;const h=r.build(e,l),m=typeof s<"u"?s.build(e,u):null,v=e.getTypeLength(t),x=e.getFunctionOperator(n);if(t!=="void")return n==="<"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} < ${m} )`,a,t):n==="<="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} <= ${m} )`,a,t):n===">"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} > ${m} )`,a,t):n===">="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} >= ${m} )`,a,t):n==="!"||n==="~"?e.format(`(${n}${h})`,l,t):x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`( ${h} ${n} ${m} )`,a,t);if(l!=="void")return x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`${h} ${n} ${m}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Qr=ct(Mr,"+"),wi=ct(Mr,"-"),Wn=ct(Mr,"*"),Dl=ct(Mr,"/"),qM=ct(Mr,"%"),uL=ct(Mr,"=="),cL=ct(Mr,"!="),hL=ct(Mr,"<"),VM=ct(Mr,">"),fL=ct(Mr,"<="),AL=ct(Mr,">="),dL=ct(Mr,"&&"),pL=ct(Mr,"||"),mL=ct(Mr,"!"),gL=ct(Mr,"^^"),vL=ct(Mr,"&"),_L=ct(Mr,"~"),yL=ct(Mr,"|"),xL=ct(Mr,"^"),bL=ct(Mr,"<<"),SL=ct(Mr,">>");ut("add",Qr);ut("sub",wi);ut("mul",Wn);ut("div",Dl);ut("modInt",qM);ut("equal",uL);ut("notEqual",cL);ut("lessThan",hL);ut("greaterThan",VM);ut("lessThanEqual",fL);ut("greaterThanEqual",AL);ut("and",dL);ut("or",pL);ut("not",mL);ut("xor",gL);ut("bitAnd",vL);ut("bitNot",_L);ut("bitOr",yL);ut("bitXor",xL);ut("shiftLeft",bL);ut("shiftRight",SL);const TL=(...i)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),qM(...i));ut("remainder",TL);class He extends Zr{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),l=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>l?t:a>l?n:l>s?r:t}getNodeType(e){const t=this.method;return t===He.LENGTH||t===He.DISTANCE||t===He.DOT?"float":t===He.CROSS?"vec3":t===He.ALL?"bool":t===He.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===He.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){let n=this.method;const r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,l=this.bNode,u=this.cNode,h=e.renderer.coordinateSystem;if(n===He.TRANSFORM_DIRECTION){let m=a,v=l;e.isMatrix(m.getNodeType(e))?v=dn(Be(v),0):m=dn(Be(m),0);const x=Wn(m,v).xyz;return Fc(x).build(e,t)}else{if(n===He.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(n===He.ONE_MINUS)return wi(1,a).build(e,t);if(n===He.RECIPROCAL)return Dl(1,a).build(e,t);if(n===He.DIFFERENCE)return ur(wi(a,l)).build(e,t);{const m=[];return n===He.CROSS||n===He.MOD?m.push(a.build(e,r),l.build(e,r)):h===Ha&&n===He.STEP?m.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),l.build(e,s)):h===Ha&&(n===He.MIN||n===He.MAX)||n===He.MOD?m.push(a.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):n===He.REFRACT?m.push(a.build(e,s),l.build(e,s),u.build(e,"float")):n===He.MIX?m.push(a.build(e,s),l.build(e,s),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":s)):(h===pu&&n===He.ATAN&&l!==null&&(n="atan2"),m.push(a.build(e,s)),l!==null&&m.push(l.build(e,s)),u!==null&&m.push(u.build(e,s))),e.format(`${e.getMethod(n,r)}( ${m.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}He.ALL="all";He.ANY="any";He.RADIANS="radians";He.DEGREES="degrees";He.EXP="exp";He.EXP2="exp2";He.LOG="log";He.LOG2="log2";He.SQRT="sqrt";He.INVERSE_SQRT="inversesqrt";He.FLOOR="floor";He.CEIL="ceil";He.NORMALIZE="normalize";He.FRACT="fract";He.SIN="sin";He.COS="cos";He.TAN="tan";He.ASIN="asin";He.ACOS="acos";He.ATAN="atan";He.ABS="abs";He.SIGN="sign";He.LENGTH="length";He.NEGATE="negate";He.ONE_MINUS="oneMinus";He.DFDX="dFdx";He.DFDY="dFdy";He.ROUND="round";He.RECIPROCAL="reciprocal";He.TRUNC="trunc";He.FWIDTH="fwidth";He.TRANSPOSE="transpose";He.BITCAST="bitcast";He.EQUALS="equals";He.MIN="min";He.MAX="max";He.MOD="mod";He.STEP="step";He.REFLECT="reflect";He.DISTANCE="distance";He.DIFFERENCE="difference";He.DOT="dot";He.CROSS="cross";He.POW="pow";He.TRANSFORM_DIRECTION="transformDirection";He.MIX="mix";He.CLAMP="clamp";He.REFRACT="refract";He.SMOOTHSTEP="smoothstep";He.FACEFORWARD="faceforward";const wL=_e(1e-6),AJ=_e(1e6),Z_=_e(Math.PI),dJ=_e(Math.PI*2),HM=ct(He,He.ALL),ML=ct(He,He.ANY),EL=ct(He,He.RADIANS),CL=ct(He,He.DEGREES),jM=ct(He,He.EXP),O0=ct(He,He.EXP2),Oy=ct(He,He.LOG),cu=ct(He,He.LOG2),Cu=ct(He,He.SQRT),WM=ct(He,He.INVERSE_SQRT),hu=ct(He,He.FLOOR),Iy=ct(He,He.CEIL),Fc=ct(He,He.NORMALIZE),Hc=ct(He,He.FRACT),Mo=ct(He,He.SIN),yc=ct(He,He.COS),RL=ct(He,He.TAN),NL=ct(He,He.ASIN),DL=ct(He,He.ACOS),$M=ct(He,He.ATAN),ur=ct(He,He.ABS),Cg=ct(He,He.SIGN),Rc=ct(He,He.LENGTH),PL=ct(He,He.NEGATE),LL=ct(He,He.ONE_MINUS),XM=ct(He,He.DFDX),YM=ct(He,He.DFDY),UL=ct(He,He.ROUND),BL=ct(He,He.RECIPROCAL),QM=ct(He,He.TRUNC),OL=ct(He,He.FWIDTH),IL=ct(He,He.TRANSPOSE),pJ=ct(He,He.BITCAST),FL=ct(He,He.EQUALS),to=ct(He,He.MIN),qr=ct(He,He.MAX),KM=ct(He,He.MOD),Fy=ct(He,He.STEP),kL=ct(He,He.REFLECT),zL=ct(He,He.DISTANCE),GL=ct(He,He.DIFFERENCE),Xh=ct(He,He.DOT),ky=ct(He,He.CROSS),Cl=ct(He,He.POW),ZM=ct(He,He.POW,2),qL=ct(He,He.POW,3),VL=ct(He,He.POW,4),HL=ct(He,He.TRANSFORM_DIRECTION),jL=i=>Wn(Cg(i),Cl(ur(i),1/3)),WL=i=>Xh(i,i),Fi=ct(He,He.MIX),vu=(i,e=0,t=1)=>_t(new He(He.CLAMP,_t(i),_t(e),_t(t))),$L=i=>vu(i),JM=ct(He,He.REFRACT),kc=ct(He,He.SMOOTHSTEP),eE=ct(He,He.FACEFORWARD),XL=je(([i])=>{const n=43758.5453,r=Xh(i.xy,Ct(12.9898,78.233)),s=KM(r,Z_);return Hc(Mo(s).mul(n))}),YL=(i,e,t)=>Fi(e,t,i),QL=(i,e,t)=>kc(e,t,i),KL=(i,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),$M(i,e)),mJ=eE,gJ=WM;ut("all",HM);ut("any",ML);ut("equals",FL);ut("radians",EL);ut("degrees",CL);ut("exp",jM);ut("exp2",O0);ut("log",Oy);ut("log2",cu);ut("sqrt",Cu);ut("inverseSqrt",WM);ut("floor",hu);ut("ceil",Iy);ut("normalize",Fc);ut("fract",Hc);ut("sin",Mo);ut("cos",yc);ut("tan",RL);ut("asin",NL);ut("acos",DL);ut("atan",$M);ut("abs",ur);ut("sign",Cg);ut("length",Rc);ut("lengthSq",WL);ut("negate",PL);ut("oneMinus",LL);ut("dFdx",XM);ut("dFdy",YM);ut("round",UL);ut("reciprocal",BL);ut("trunc",QM);ut("fwidth",OL);ut("atan2",KL);ut("min",to);ut("max",qr);ut("mod",KM);ut("step",Fy);ut("reflect",kL);ut("distance",zL);ut("dot",Xh);ut("cross",ky);ut("pow",Cl);ut("pow2",ZM);ut("pow3",qL);ut("pow4",VL);ut("transformDirection",HL);ut("mix",YL);ut("clamp",vu);ut("refract",JM);ut("smoothstep",QL);ut("faceForward",eE);ut("difference",GL);ut("saturate",$L);ut("cbrt",jL);ut("transpose",IL);ut("rand",XL);class vJ extends Mn{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:l}=e.getNodeProperties(this),u=t!=="void",h=u?aL(n).build(e):"";r.nodeProperty=h;const m=s.build(e,"bool");e.addFlowCode(` -${e.tab}if ( ${m} ) { - -`).addFlowTab();let v=a.build(e,n);if(v&&(u?v=h+" = "+v+";":v="return "+v+";"),e.removeFlowTab().addFlowCode(e.tab+" "+v+` - -`+e.tab+"}"),l!==null){e.addFlowCode(` else { - -`).addFlowTab();let x=l.build(e,n);x&&(u?x=h+" = "+x+";":x="return "+x+";"),e.removeFlowTab().addFlowCode(e.tab+" "+x+` - -`+e.tab+`} - -`)}else e.addFlowCode(` - -`);return e.format(h,n,t)}}const zs=ct(vJ);ut("select",zs);const ZL=(...i)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),zs(...i));ut("cond",ZL);class JL extends Mn{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(n),r}}const zy=ct(JL),e9=(i,e)=>zy(i,{label:e});ut("context",zy);ut("label",e9);class Kv extends Mn{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const t9=ct(Kv);ut("toVar",(...i)=>t9(...i).append());const n9=i=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),t9(i));ut("temp",n9);class _J extends Mn{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,s),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e),r=e.shaderStage==="fragment"&&t.reassignPosition===!0&&e.context.needsPositionReassign;if(t.propertyName===void 0||r){const s=this.getNodeType(e),a=e.getPropertyName(n,IT.VERTEX);e.flowNodeFromShaderStage(IT.VERTEX,this.node,s,a),t.propertyName=a,r?t.reassignPosition=!1:t.reassignPosition===void 0&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(n)}}const ro=ct(_J),i9=i=>ro(i);ut("varying",ro);ut("vertexStage",i9);const r9=je(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return Fi(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),s9=je(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return Fi(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),jg="WorkingColorSpace",tE="OutputColorSpace";class Wg extends Zr{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===jg?ai.workingColorSpace:t===tE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return ai.enabled===!1||n===r||!n||!r||(ai.getTransfer(n)===Vi&&(s=dn(r9(s.rgb),s.a)),ai.getPrimaries(n)!==ai.getPrimaries(r)&&(s=dn(ha(ai._getMatrix(new Vn,n,r)).mul(s.rgb),s.a)),ai.getTransfer(r)===Vi&&(s=dn(s9(s.rgb),s.a))),s}}const a9=i=>_t(new Wg(_t(i),jg,tE)),o9=i=>_t(new Wg(_t(i),tE,jg)),l9=(i,e)=>_t(new Wg(_t(i),jg,e)),nE=(i,e)=>_t(new Wg(_t(i),e,jg)),yJ=(i,e,t)=>_t(new Wg(_t(i),e,t));ut("toOutputColorSpace",a9);ut("toWorkingColorSpace",o9);ut("workingToColorSpace",l9);ut("colorSpaceToWorking",nE);let xJ=class extends vA{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class u9 extends Mn{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=jn.OBJECT}setGroup(e){return this.group=e,this}element(e){return _t(new xJ(this,_t(e)))}setNodeType(e){const t=gn(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;r_t(new u9(i,e,t));class SJ extends u9{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Rn)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const c9=(i,e,t=null)=>_t(new SJ(i,e,t));class TJ extends Zr{static get type(){return"ToneMappingNode"}constructor(e,t=f9,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return EM(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Za)return t;let r=null;const s=e.renderer.library.getToneMappingFunction(n);return s!==null?r=dn(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const h9=(i,e,t)=>_t(new TJ(i,_t(e),_t(t))),f9=c9("toneMappingExposure","float");ut("toneMapping",(i,e,t)=>h9(e,t,i));class wJ extends CM{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=o_,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,l=n.isInterleavedBuffer===!0?n:new Qw(n,s),u=new nu(l,r,a);l.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=ro(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const $g=(i,e=null,t=0,n=0)=>_t(new wJ(i,e,t,n)),A9=(i,e=null,t=0,n=0)=>$g(i,e,t,n).setUsage(qd),J_=(i,e=null,t=0,n=0)=>$g(i,e,t,n).setInstanced(!0),HT=(i,e=null,t=0,n=0)=>A9(i,e,t,n).setInstanced(!0);ut("toAttribute",i=>$g(i.value));class MJ extends Mn{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=jn.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let r=1;r_t(new MJ(_t(i),e,t));ut("compute",d9);class EJ extends Mn{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(n),s}}const Im=(i,e)=>_t(new EJ(_t(i),e));ut("cache",Im);class CJ extends Mn{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const p9=ct(CJ);ut("bypass",p9);class m9 extends Mn{static get type(){return"RemapNode"}constructor(e,t,n,r=_e(0),s=_e(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:s,doClamp:a}=this;let l=e.sub(t).div(n.sub(t));return a===!0&&(l=l.clamp()),l.mul(s.sub(r)).add(r)}}const g9=ct(m9,null,null,{doClamp:!1}),v9=ct(m9);ut("remap",g9);ut("remapClamp",v9);class Zv extends Mn{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,n,t)}}const Hh=ct(Zv),_9=i=>(i?zs(i,Hh("discard")):Hh("discard")).append(),RJ=()=>Hh("return").append();ut("discard",_9);class NJ extends Zr{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Za,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Co;return n!==Za&&(t=t.toneMapping(n)),r!==Co&&r!==ai.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const y9=(i,e=null,t=null)=>_t(new NJ(_t(i),e,t));ut("renderOutput",y9);function DJ(i){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class x9 extends Mn{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(s),l=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(l.name,a,n):ro(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const _u=(i,e)=>_t(new x9(i,e)),Er=(i=0)=>_u("uv"+(i>0?i:""),"vec2");class PJ extends Mn{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const Fh=ct(PJ);class LJ extends Hg{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=jn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:s}=n;this.value=Math.log2(Math.max(r,s))}}}const b9=ct(LJ);class yu extends Hg{static get type(){return"TextureNode"}constructor(e,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=jn.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Rr?"uvec4":this.value.type===Ns?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Er(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=gn(this.value.matrix)),this._matrixUniform.mul(Be(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?jn.RENDER:jn.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Ee(Fh(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this)),r||(r=this.getDefaultUV()),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,n,r,s,a,l,u){const h=this.value;let m;return r?m=e.generateTextureLevel(h,t,n,r,a):s?m=e.generateTextureBias(h,t,n,s,a):u?m=e.generateTextureGrad(h,t,n,u,a):l?m=e.generateTextureCompare(h,t,n,l,a):this.sampler===!1?m=e.generateTextureLoad(h,t,n,a):m=e.generateTexture(h,t,n,a),m}generate(e,t){const n=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let l=a.propertyName;if(l===void 0){const{uvNode:m,levelNode:v,biasNode:x,compareNode:S,depthNode:w,gradNode:R}=r,C=this.generateUV(e,m),E=v?v.build(e,"float"):null,B=x?x.build(e,"float"):null,L=w?w.build(e,"int"):null,O=S?S.build(e,"float"):null,G=R?[R[0].build(e,"vec2"),R[1].build(e,"vec2")]:null,q=e.getVarFromNode(this);l=e.getPropertyName(q);const z=this.generateSnippet(e,s,C,E,B,L,O,G);e.addLineFlowCode(`${l} = ${z}`,this),a.snippet=z,a.propertyName=l}let u=l;const h=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=nE(Hh(u,h),n.colorSpace).setup(e).build(e,h)),e.format(u,h,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=_t(e),t.referenceNode=this.getSelf(),_t(t)}blur(e){const t=this.clone();return t.biasNode=_t(e).mul(b9(t)),t.referenceNode=this.getSelf(),_t(t)}level(e){const t=this.clone();return t.levelNode=_t(e),t.referenceNode=this.getSelf(),_t(t)}size(e){return Fh(this,e)}bias(e){const t=this.clone();return t.biasNode=_t(e),t.referenceNode=this.getSelf(),_t(t)}compare(e){const t=this.clone();return t.compareNode=_t(e),t.referenceNode=this.getSelf(),_t(t)}grad(e,t){const n=this.clone();return n.gradNode=[_t(e),_t(t)],n.referenceNode=this.getSelf(),_t(n)}depth(e){const t=this.clone();return t.depthNode=_t(e),t.referenceNode=this.getSelf(),_t(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const Ai=ct(yu),Fr=(...i)=>Ai(...i).setSampler(!1),UJ=i=>(i.isNode===!0?i:Ai(i)).convert("sampler"),Dh=gn("float").label("cameraNear").setGroup(Rn).onRenderUpdate(({camera:i})=>i.near),Ph=gn("float").label("cameraFar").setGroup(Rn).onRenderUpdate(({camera:i})=>i.far),_A=gn("mat4").label("cameraProjectionMatrix").setGroup(Rn).onRenderUpdate(({camera:i})=>i.projectionMatrix),BJ=gn("mat4").label("cameraProjectionMatrixInverse").setGroup(Rn).onRenderUpdate(({camera:i})=>i.projectionMatrixInverse),so=gn("mat4").label("cameraViewMatrix").setGroup(Rn).onRenderUpdate(({camera:i})=>i.matrixWorldInverse),OJ=gn("mat4").label("cameraWorldMatrix").setGroup(Rn).onRenderUpdate(({camera:i})=>i.matrixWorld),IJ=gn("mat3").label("cameraNormalMatrix").setGroup(Rn).onRenderUpdate(({camera:i})=>i.normalMatrix),S9=gn(new he).label("cameraPosition").setGroup(Rn).onRenderUpdate(({camera:i},e)=>e.value.setFromMatrixPosition(i.matrixWorld));class Li extends Mn{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=jn.OBJECT,this._uniformNode=new Hg(null)}getNodeType(){const e=this.scope;if(e===Li.WORLD_MATRIX)return"mat4";if(e===Li.POSITION||e===Li.VIEW_POSITION||e===Li.DIRECTION||e===Li.SCALE)return"vec3"}update(e){const t=this.object3d,n=this._uniformNode,r=this.scope;if(r===Li.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===Li.POSITION)n.value=n.value||new he,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===Li.SCALE)n.value=n.value||new he,n.value.setFromMatrixScale(t.matrixWorld);else if(r===Li.DIRECTION)n.value=n.value||new he,t.getWorldDirection(n.value);else if(r===Li.VIEW_POSITION){const s=e.camera;n.value=n.value||new he,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===Li.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===Li.POSITION||t===Li.VIEW_POSITION||t===Li.DIRECTION||t===Li.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Li.WORLD_MATRIX="worldMatrix";Li.POSITION="position";Li.SCALE="scale";Li.VIEW_POSITION="viewPosition";Li.DIRECTION="direction";const FJ=ct(Li,Li.DIRECTION),kJ=ct(Li,Li.WORLD_MATRIX),T9=ct(Li,Li.POSITION),zJ=ct(Li,Li.SCALE),GJ=ct(Li,Li.VIEW_POSITION);class xu extends Li{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const qJ=Wt(xu,xu.DIRECTION),$o=Wt(xu,xu.WORLD_MATRIX),VJ=Wt(xu,xu.POSITION),HJ=Wt(xu,xu.SCALE),jJ=Wt(xu,xu.VIEW_POSITION),w9=gn(new Vn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),WJ=gn(new kn).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),Q0=je(i=>i.renderer.nodes.modelViewMatrix||M9).once()().toVar("modelViewMatrix"),M9=so.mul($o),$J=je(i=>(i.context.isHighPrecisionModelViewMatrix=!0,gn("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),XJ=je(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return gn("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Gy=_u("position","vec3"),Gr=Gy.varying("positionLocal"),ey=Gy.varying("positionPrevious"),Nc=$o.mul(Gr).xyz.varying("v_positionWorld").context({needsPositionReassign:!0}),iE=Gr.transformDirection($o).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection").context({needsPositionReassign:!0}),Xr=je(i=>i.context.setupPositionView(),"vec3").once()().varying("v_positionView").context({needsPositionReassign:!0}),dr=Xr.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class YJ extends Mn{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===Ha&&n.side===hr?"false":e.getFrontFacing()}}const E9=Wt(YJ),Xg=_e(E9).mul(2).sub(1),qy=_u("normal","vec3"),no=je(i=>i.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),Be(0,1,0)):qy,"vec3").once()().toVar("normalLocal"),C9=Xr.dFdx().cross(Xr.dFdy()).normalize().toVar("normalFlat"),Jo=je(i=>{let e;return i.material.flatShading===!0?e=C9:e=ro(rE(no),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Vy=ro(Jo.transformDirection(so),"v_normalWorld").normalize().toVar("normalWorld"),zr=je(i=>i.context.setupNormal(),"vec3").once()().mul(Xg).toVar("transformedNormalView"),Hy=zr.transformDirection(so).toVar("transformedNormalWorld"),Qd=je(i=>i.context.setupClearcoatNormal(),"vec3").once()().mul(Xg).toVar("transformedClearcoatNormalView"),R9=je(([i,e=$o])=>{const t=ha(e),n=i.div(Be(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),rE=je(([i],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const n=w9.mul(i);return so.transformDirection(n)}),N9=gn(0).onReference(({material:i})=>i).onRenderUpdate(({material:i})=>i.refractionRatio),D9=dr.negate().reflect(zr),P9=dr.negate().refract(zr,N9),L9=D9.transformDirection(so).toVar("reflectVector"),U9=P9.transformDirection(so).toVar("reflectVector");class QJ extends yu{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Qo?L9:e.mapping===Ko?U9:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Be(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem===pu||!n.isRenderTargetTexture?Be(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const I0=ct(QJ);class sE extends Hg{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const Yg=(i,e,t)=>_t(new sE(i,e,t));class KJ extends vA{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class B9 extends sE{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Uh(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=jn.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;r_t(new B9(i,e)),ZJ=(i,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),_t(new B9(i,e)));class JJ extends vA{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class jy extends Mn{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=jn.OBJECT}element(e){return _t(new JJ(this,_t(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=Yg(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Sc(null,e):e==="texture"?t=Ai(null):e==="cubeTexture"?t=I0(null):t=gn(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;r_t(new jy(i,e,t)),jT=(i,e,t,n)=>_t(new jy(i,e,n,t));class eee extends jy{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const Tc=(i,e,t=null)=>_t(new eee(i,e,t)),Wy=je(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),_u("tangent","vec4")))(),Qg=Wy.xyz.toVar("tangentLocal"),Kg=Q0.mul(dn(Qg,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),O9=Kg.transformDirection(so).varying("v_tangentWorld").normalize().toVar("tangentWorld"),aE=Kg.toVar("transformedTangentView"),tee=aE.transformDirection(so).normalize().toVar("transformedTangentWorld"),Zg=i=>i.mul(Wy.w).xyz,nee=ro(Zg(qy.cross(Wy)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),iee=ro(Zg(no.cross(Qg)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),I9=ro(Zg(Jo.cross(Kg)),"v_bitangentView").normalize().toVar("bitangentView"),ree=ro(Zg(Vy.cross(O9)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),F9=Zg(zr.cross(aE)).normalize().toVar("transformedBitangentView"),see=F9.transformDirection(so).normalize().toVar("transformedBitangentWorld"),Yf=ha(Kg,I9,Jo),k9=dr.mul(Yf),aee=(i,e)=>i.sub(k9.mul(e)),z9=(()=>{let i=iA.cross(dr);return i=i.cross(iA).normalize(),i=Fi(i,zr,Rh.mul(Zl.oneMinus()).oneMinus().pow2().pow2()).normalize(),i})(),oee=je(i=>{const{eye_pos:e,surf_norm:t,mapN:n,uv:r}=i,s=e.dFdx(),a=e.dFdy(),l=r.dFdx(),u=r.dFdy(),h=t,m=a.cross(h),v=h.cross(s),x=m.mul(l.x).add(v.mul(u.x)),S=m.mul(l.y).add(v.mul(u.y)),w=x.dot(x).max(S.dot(S)),R=Xg.mul(w.inverseSqrt());return Qr(x.mul(n.x,R),S.mul(n.y,R),h.mul(n.z)).normalize()});class lee extends Zr{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Dc}setup(e){const{normalMapType:t,scaleNode:n}=this;let r=this.node.mul(2).sub(1);n!==null&&(r=Be(r.xy.mul(n),r.z));let s=null;return t===O7?s=rE(r):t===Dc&&(e.hasGeometryAttribute("tangent")===!0?s=Yf.mul(r).normalize():s=oee({eye_pos:Xr,surf_norm:Jo,mapN:r,uv:Er()})),s}}const WT=ct(lee),uee=je(({textureNode:i,bumpScale:e})=>{const t=r=>i.cache().context({getUV:s=>r(s.uvNode||Er()),forceUVContext:!0}),n=_e(t(r=>r));return Ct(_e(t(r=>r.add(r.dFdx()))).sub(n),_e(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),cee=je(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,l=s.cross(a),u=a.cross(r),h=r.dot(l).mul(Xg),m=h.sign().mul(n.x.mul(l).add(n.y.mul(u)));return h.abs().mul(t).sub(m).normalize()});class hee extends Zr{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=uee({textureNode:this.textureNode,bumpScale:e});return cee({surf_pos:Xr,surf_norm:Jo,dHdxy:t})}}const G9=ct(hee),U6=new Map;class st extends Mn{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=U6.get(e);return n===void 0&&(n=Tc(e,t),U6.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let r=null;if(n===st.COLOR){const s=t.color!==void 0?this.getColor(n):Be();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(n===st.OPACITY){const s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(n===st.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=_e(1);else if(n===st.SPECULAR_INTENSITY){const s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s}else if(n===st.SPECULAR_COLOR){const s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(n).rgb):r=s}else if(n===st.ROUGHNESS){const s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).g):r=s}else if(n===st.METALNESS){const s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(n).b):r=s}else if(n===st.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(n)):r=a}else if(n===st.NORMAL)t.normalMap?(r=WT(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=G9(this.getTexture("bump").r,this.getFloat("bumpScale")):r=Jo;else if(n===st.CLEARCOAT){const s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===st.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===st.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=WT(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=Jo;else if(n===st.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(n===st.SHEEN_ROUGHNESS){const s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s,r=r.clamp(.07,1)}else if(n===st.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(n);r=Ly(kd.x,kd.y,kd.y.negate(),kd.x).mul(s.rg.mul(2).sub(Ct(1)).normalize().mul(s.b))}else r=kd;else if(n===st.IRIDESCENCE_THICKNESS){const s=ji("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=ji("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(n).g).add(a)}else r=s}else if(n===st.TRANSMISSION){const s=this.getFloat(n);t.transmissionMap?r=s.mul(this.getTexture(n).r):r=s}else if(n===st.THICKNESS){const s=this.getFloat(n);t.thicknessMap?r=s.mul(this.getTexture(n).g):r=s}else if(n===st.IOR)r=this.getFloat(n);else if(n===st.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===st.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(n,s)}return r}}st.ALPHA_TEST="alphaTest";st.COLOR="color";st.OPACITY="opacity";st.SHININESS="shininess";st.SPECULAR="specular";st.SPECULAR_STRENGTH="specularStrength";st.SPECULAR_INTENSITY="specularIntensity";st.SPECULAR_COLOR="specularColor";st.REFLECTIVITY="reflectivity";st.ROUGHNESS="roughness";st.METALNESS="metalness";st.NORMAL="normal";st.CLEARCOAT="clearcoat";st.CLEARCOAT_ROUGHNESS="clearcoatRoughness";st.CLEARCOAT_NORMAL="clearcoatNormal";st.EMISSIVE="emissive";st.ROTATION="rotation";st.SHEEN="sheen";st.SHEEN_ROUGHNESS="sheenRoughness";st.ANISOTROPY="anisotropy";st.IRIDESCENCE="iridescence";st.IRIDESCENCE_IOR="iridescenceIOR";st.IRIDESCENCE_THICKNESS="iridescenceThickness";st.IOR="ior";st.TRANSMISSION="transmission";st.THICKNESS="thickness";st.ATTENUATION_DISTANCE="attenuationDistance";st.ATTENUATION_COLOR="attenuationColor";st.LINE_SCALE="scale";st.LINE_DASH_SIZE="dashSize";st.LINE_GAP_SIZE="gapSize";st.LINE_WIDTH="linewidth";st.LINE_DASH_OFFSET="dashOffset";st.POINT_WIDTH="pointWidth";st.DISPERSION="dispersion";st.LIGHT_MAP="light";st.AO="ao";const q9=Wt(st,st.ALPHA_TEST),V9=Wt(st,st.COLOR),H9=Wt(st,st.SHININESS),j9=Wt(st,st.EMISSIVE),oE=Wt(st,st.OPACITY),W9=Wt(st,st.SPECULAR),$T=Wt(st,st.SPECULAR_INTENSITY),$9=Wt(st,st.SPECULAR_COLOR),Fm=Wt(st,st.SPECULAR_STRENGTH),Jv=Wt(st,st.REFLECTIVITY),X9=Wt(st,st.ROUGHNESS),Y9=Wt(st,st.METALNESS),Q9=Wt(st,st.NORMAL).context({getUV:null}),K9=Wt(st,st.CLEARCOAT),Z9=Wt(st,st.CLEARCOAT_ROUGHNESS),J9=Wt(st,st.CLEARCOAT_NORMAL).context({getUV:null}),eU=Wt(st,st.ROTATION),tU=Wt(st,st.SHEEN),nU=Wt(st,st.SHEEN_ROUGHNESS),iU=Wt(st,st.ANISOTROPY),rU=Wt(st,st.IRIDESCENCE),sU=Wt(st,st.IRIDESCENCE_IOR),aU=Wt(st,st.IRIDESCENCE_THICKNESS),oU=Wt(st,st.TRANSMISSION),lU=Wt(st,st.THICKNESS),uU=Wt(st,st.IOR),cU=Wt(st,st.ATTENUATION_DISTANCE),hU=Wt(st,st.ATTENUATION_COLOR),fU=Wt(st,st.LINE_SCALE),AU=Wt(st,st.LINE_DASH_SIZE),dU=Wt(st,st.LINE_GAP_SIZE),fee=Wt(st,st.LINE_WIDTH),pU=Wt(st,st.LINE_DASH_OFFSET),Aee=Wt(st,st.POINT_WIDTH),mU=Wt(st,st.DISPERSION),lE=Wt(st,st.LIGHT_MAP),gU=Wt(st,st.AO),kd=gn(new gt).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),uE=je(i=>i.context.setupModelViewProjection(),"vec4").once()().varying("v_modelViewProjection");class pr extends Mn{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===pr.VERTEX)r=e.getVertexIndex();else if(n===pr.INSTANCE)r=e.getInstanceIndex();else if(n===pr.DRAW)r=e.getDrawIndex();else if(n===pr.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===pr.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===pr.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=ro(this).build(e,t),s}}pr.VERTEX="vertex";pr.INSTANCE="instance";pr.SUBGROUP="subgroup";pr.INVOCATION_LOCAL="invocationLocal";pr.INVOCATION_SUBGROUP="invocationSubgroup";pr.DRAW="draw";const vU=Wt(pr,pr.VERTEX),Jg=Wt(pr,pr.INSTANCE),dee=Wt(pr,pr.SUBGROUP),pee=Wt(pr,pr.INVOCATION_SUBGROUP),mee=Wt(pr,pr.INVOCATION_LOCAL),_U=Wt(pr,pr.DRAW);class yU extends Mn{static get type(){return"InstanceNode"}constructor(e,t,n){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=jn.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:n,instanceColor:r}=this;let{instanceMatrixNode:s,instanceColorNode:a}=this;if(s===null){if(t<=1e3)s=Yg(n.array,"mat4",Math.max(t,1)).element(Jg);else{const u=new h_(n.array,16,1);this.buffer=u;const h=n.usage===qd?HT:J_,m=[h(u,"vec4",16,0),h(u,"vec4",16,4),h(u,"vec4",16,8),h(u,"vec4",16,12)];s=nA(...m)}this.instanceMatrixNode=s}if(r&&a===null){const u=new Ig(r.array,3),h=r.usage===qd?HT:J_;this.bufferColor=u,a=Be(h(u,"vec3",3,0)),this.instanceColorNode=a}const l=s.mul(Gr).xyz;if(Gr.assign(l),e.hasGeometryAttribute("normal")){const u=R9(no,s);no.assign(u)}this.instanceColorNode!==null&&Sg("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==qd&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==qd&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const gee=ct(yU);class vee extends yU{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const xU=ct(vee);class _ee extends Mn{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Jg:this.batchingIdNode=_U);const n=je(([w])=>{const R=Fh(Fr(this.batchMesh._indirectTexture),0),C=Ee(w).modInt(Ee(R)),E=Ee(w).div(Ee(R));return Fr(this.batchMesh._indirectTexture,ms(C,E)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Ee(this.batchingIdNode)),r=this.batchMesh._matricesTexture,s=Fh(Fr(r),0),a=_e(n).mul(4).toInt().toVar(),l=a.modInt(s),u=a.div(Ee(s)),h=nA(Fr(r,ms(l,u)),Fr(r,ms(l.add(1),u)),Fr(r,ms(l.add(2),u)),Fr(r,ms(l.add(3),u))),m=this.batchMesh._colorsTexture;if(m!==null){const R=je(([C])=>{const E=Fh(Fr(m),0).x,B=C,L=B.modInt(E),O=B.div(E);return Fr(m,ms(L,O)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);Sg("vec3","vBatchColor").assign(R)}const v=ha(h);Gr.assign(h.mul(Gr));const x=no.div(Be(v[0].dot(v[0]),v[1].dot(v[1]),v[2].dot(v[2]))),S=v.mul(x).xyz;no.assign(S),e.hasGeometryAttribute("tangent")&&Qg.mulAssign(v)}}const bU=ct(_ee),B6=new WeakMap;class SU extends Mn{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=jn.OBJECT,this.skinIndexNode=_u("skinIndex","uvec4"),this.skinWeightNode=_u("skinWeight","vec4");let n,r,s;t?(n=ji("bindMatrix","mat4"),r=ji("bindMatrixInverse","mat4"),s=jT("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=gn(e.bindMatrix,"mat4"),r=gn(e.bindMatrixInverse,"mat4"),s=Yg(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=Gr){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w),v=s.mul(t),x=Qr(l.mul(r.x).mul(v),u.mul(r.y).mul(v),h.mul(r.z).mul(v),m.mul(r.w).mul(v));return a.mul(x).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=no){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w);let v=Qr(r.x.mul(l),r.y.mul(u),r.z.mul(h),r.w.mul(m));return v=a.mul(v).mul(s),v.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=jT("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,ey)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||FP(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&ey.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(Gr.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();no.assign(n),e.hasGeometryAttribute("tangent")&&Qg.assign(n)}}generate(e,t){if(t!=="void")return Gr.build(e,t)}update(e){const n=(this.useReference?e.object:this.skinnedMesh).skeleton;B6.get(n)!==e.frameId&&(B6.set(n,e.frameId),this.previousBoneMatricesNode!==null&&n.previousBoneMatrices.set(n.boneMatrices),n.update())}}const yee=i=>_t(new SU(i)),TU=i=>_t(new SU(i,!0));class xee extends Mn{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let s=0,a=this.params.length-1;sNumber(v)?w=">=":w="<"));const C={start:m,end:v},E=C.start,B=C.end;let L="",O="",G="";R||(S==="int"||S==="uint"?w.includes("<")?R="++":R="--":w.includes("<")?R="+= 1.":R="-= 1."),L+=e.getVar(S,x)+" = "+E,O+=x+" "+w+" "+B,G+=x+" "+R;const q=`for ( ${L}; ${O}; ${G} )`;e.addFlowCode((l===0?` -`:"")+e.tab+q+` { - -`).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(` -`+e.tab+s);for(let l=0,u=this.params.length-1;l_t(new xee(tA(i,"int"))).append(),bee=()=>Hh("continue").append(),wU=()=>Hh("break").append(),See=(...i)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),ki(...i)),$3=new WeakMap,vo=new Ln,O6=je(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const a=Ee(vU).mul(t).add(s),l=a.div(n),u=a.sub(l.mul(n));return Fr(i,ms(u,l)).depth(r).mul(e)});function Tee(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let a=$3.get(i);if(a===void 0||a.count!==s){let B=function(){C.dispose(),$3.delete(i),i.removeEventListener("dispose",B)};var l=B;a!==void 0&&a.texture.dispose();const u=i.morphAttributes.position||[],h=i.morphAttributes.normal||[],m=i.morphAttributes.color||[];let v=0;e===!0&&(v=1),t===!0&&(v=2),n===!0&&(v=3);let x=i.attributes.position.count*v,S=1;const w=4096;x>w&&(S=Math.ceil(x/w),x=w);const R=new Float32Array(x*S*4*s),C=new jw(R,x,S,s);C.type=$r,C.needsUpdate=!0;const E=v*4;for(let L=0;L{const x=_e(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?x.assign(Fr(this.mesh.morphTexture,ms(Ee(v).add(1),Ee(Jg))).r):x.assign(ji("morphTargetInfluences","float").element(v).toVar()),n===!0&&Gr.addAssign(O6({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:Ee(0)})),r===!0&&no.addAssign(O6({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:Ee(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const MU=ct(wee);class K0 extends Mn{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Mee extends K0{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Eee extends JL{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=Be().toVar("directDiffuse"),r=Be().toVar("directSpecular"),s=Be().toVar("indirectDiffuse"),a=Be().toVar("indirectSpecular"),l={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:Be().toVar("radiance"),irradiance:Be().toVar("irradiance"),iblIrradiance:Be().toVar("iblIrradiance"),ambientOcclusion:_e(1).toVar("ambientOcclusion"),reflectedLight:l,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const EU=ct(Eee);class Cee extends K0{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let am,om;class ss extends Mn{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ss.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=jn.NONE;return(this.scope===ss.SIZE||this.scope===ss.VIEWPORT)&&(e=jn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ss.VIEWPORT?t!==null?om.copy(t.viewport):(e.getViewport(om),om.multiplyScalar(e.getPixelRatio())):t!==null?(am.width=t.width,am.height=t.height):e.getDrawingBufferSize(am)}setup(){const e=this.scope;let t=null;return e===ss.SIZE?t=gn(am||(am=new gt)):e===ss.VIEWPORT?t=gn(om||(om=new Ln)):t=Ct(e1.div(Rg)),t}generate(e){if(this.scope===ss.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(Rg).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}ss.COORDINATE="coordinate";ss.VIEWPORT="viewport";ss.SIZE="size";ss.UV="uv";const bu=Wt(ss,ss.UV),Rg=Wt(ss,ss.SIZE),e1=Wt(ss,ss.COORDINATE),cE=Wt(ss,ss.VIEWPORT),CU=cE.zw,RU=e1.sub(cE.xy),Ree=RU.div(CU),Nee=je(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),Rg),"vec2").once()(),Dee=je(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),bu),"vec2").once()(),Pee=je(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),bu.flipY()),"vec2").once()(),lm=new gt;class $y extends yu{static get type(){return"ViewportTextureNode"}constructor(e=bu,t=null,n=null){n===null&&(n=new W7,n.minFilter=Va),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=jn.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(lm);const n=this.value;(n.image.width!==lm.width||n.image.height!==lm.height)&&(n.image.width=lm.width,n.image.height=lm.height,n.needsUpdate=!0);const r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Lee=ct($y),hE=ct($y,null,null,{generateMipmaps:!0});let X3=null;class Uee extends $y{static get type(){return"ViewportDepthTextureNode"}constructor(e=bu,t=null){X3===null&&(X3=new qc),super(e,t,X3)}}const fE=ct(Uee);class Xa extends Mn{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Xa.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===Xa.DEPTH_BASE)n!==null&&(r=DU().assign(n));else if(t===Xa.DEPTH)e.isPerspectiveCamera?r=NU(Xr.z,Dh,Ph):r=s0(Xr.z,Dh,Ph);else if(t===Xa.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const s=AE(n,Dh,Ph);r=s0(s,Dh,Ph)}else r=n;else r=s0(Xr.z,Dh,Ph);return r}}Xa.DEPTH_BASE="depthBase";Xa.DEPTH="depth";Xa.LINEAR_DEPTH="linearDepth";const s0=(i,e,t)=>i.add(e).div(e.sub(t)),Bee=(i,e,t)=>e.sub(t).mul(i).sub(e),NU=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),AE=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),dE=(i,e,t)=>{e=e.max(1e-6).toVar();const n=cu(i.negate().div(e)),r=cu(t.div(e));return n.div(r)},Oee=(i,e,t)=>{const n=i.mul(Oy(t.div(e)));return _e(Math.E).pow(n).mul(e).negate()},DU=ct(Xa,Xa.DEPTH_BASE),pE=Wt(Xa,Xa.DEPTH),ty=ct(Xa,Xa.LINEAR_DEPTH),Iee=ty(fE());pE.assign=i=>DU(i);class Fee extends Mn{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const kee=ct(Fee);class Yo extends Mn{static get type(){return"ClippingNode"}constructor(e=Yo.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Yo.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===Yo.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return je(()=>{const n=_e().toVar("distanceToPlane"),r=_e().toVar("distanceToGradient"),s=_e(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=Sc(t);ki(a,({i:h})=>{const m=u.element(h);n.assign(Xr.dot(m.xyz).negate().add(m.w)),r.assign(n.fwidth().div(2)),s.mulAssign(kc(r.negate(),r,n))})}const l=e.length;if(l>0){const u=Sc(e),h=_e(1).toVar("intersectionClipOpacity");ki(l,({i:m})=>{const v=u.element(m);n.assign(Xr.dot(v.xyz).negate().add(v.w)),r.assign(n.fwidth().div(2)),h.mulAssign(kc(r.negate(),r,n).oneMinus())}),s.mulAssign(h.oneMinus())}Ui.a.mulAssign(s),Ui.a.equal(0).discard()})()}setupDefault(e,t){return je(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const s=Sc(t);ki(n,({i:a})=>{const l=s.element(a);Xr.dot(l.xyz).greaterThan(l.w).discard()})}const r=e.length;if(r>0){const s=Sc(e),a=Ic(!0).toVar("clipped");ki(r,({i:l})=>{const u=s.element(l);a.assign(Xr.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),je(()=>{const r=Sc(e),s=kee(t.getClipDistance());ki(n,({i:a})=>{const l=r.element(a),u=Xr.dot(l.xyz).sub(l.w).negate();s.element(a).assign(u)})})()}}Yo.ALPHA_TO_COVERAGE="alphaToCoverage";Yo.DEFAULT="default";Yo.HARDWARE="hardware";const zee=()=>_t(new Yo),Gee=()=>_t(new Yo(Yo.ALPHA_TO_COVERAGE)),qee=()=>_t(new Yo(Yo.HARDWARE)),Vee=.05,I6=je(([i])=>Hc(Wn(1e4,Mo(Wn(17,i.x).add(Wn(.1,i.y)))).mul(Qr(.1,ur(Mo(Wn(13,i.y).add(i.x))))))),F6=je(([i])=>I6(Ct(I6(i.xy),i.z))),Hee=je(([i])=>{const e=qr(Rc(XM(i.xyz)),Rc(YM(i.xyz))),t=_e(1).div(_e(Vee).mul(e)).toVar("pixScale"),n=Ct(O0(hu(cu(t))),O0(Iy(cu(t)))),r=Ct(F6(hu(n.x.mul(i.xyz))),F6(hu(n.y.mul(i.xyz)))),s=Hc(cu(t)),a=Qr(Wn(s.oneMinus(),r.x),Wn(s,r.y)),l=to(s,s.oneMinus()),u=Be(a.mul(a).div(Wn(2,l).mul(wi(1,l))),a.sub(Wn(.5,l)).div(wi(1,l)),wi(1,wi(1,a).mul(wi(1,a)).div(Wn(2,l).mul(wi(1,l))))),h=a.lessThan(l.oneMinus()).select(a.lessThan(l).select(u.x,u.y),u.z);return vu(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class Vr extends ua{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+LP(this)}build(e){this.setup(e)}setupObserver(e){return new GZ(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const r=this.vertexNode||this.setupVertex(e);e.stack.outputNode=r,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let s;const a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);a!==null&&e.stack.add(a);const u=dn(l,Ui.a).max(0);if(s=this.setupOutput(e,u),Eg.assign(s),this.outputNode!==null&&(s=this.outputNode),n!==null){const h=t.getMRT(),m=this.mrtNode;h!==null?(s=h,m!==null&&(s=h.merge(m))):m!==null&&(s=m)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=dn(l)),s=this.setupOutput(e,l)}e.stack.outputNode=s,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=Gee():e.stack.add(zee())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(qee()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=dE(Xr.z,Dh,Ph):r=s0(Xr.z,Dh,Ph))}r!==null&&pE.assign(r).append()}setupPositionView(){return Q0.mul(Gr).xyz}setupModelViewProjection(){return _A.mul(Xr)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),uE}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&MU(t).append(),t.isSkinnedMesh===!0&&TU(t).append(),this.displacementMap){const r=Tc("displacementMap","texture"),s=Tc("displacementScale","float"),a=Tc("displacementBias","float");Gr.addAssign(no.normalize().mul(r.x.mul(s).add(a)))}return t.isBatchedMesh&&bU(t).append(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&xU(t).append(),this.positionNode!==null&&Gr.assign(this.positionNode.context({isPositionNodeInput:!0})),Gr}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?dn(this.colorNode):V9;this.vertexColors===!0&&t.hasAttribute("color")&&(n=dn(n.xyz.mul(_u("color","vec3")),n.a)),e.instanceColor&&(n=Sg("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=Sg("vec3","vBatchColor").mul(n)),Ui.assign(n);const r=this.opacityNode?_e(this.opacityNode):oE;if(Ui.a.assign(Ui.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?_e(this.alphaTestNode):q9;Ui.a.lessThanEqual(s).discard()}this.alphaHash===!0&&Ui.a.lessThan(Hee(Gr)).discard(),this.transparent===!1&&this.blending===Ka&&this.alphaToCoverage===!1&&Ui.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Be(0):Ui.rgb}setupNormal(){return this.normalNode?Be(this.normalNode):Q9}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Tc("envMap","cubeTexture"):Tc("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Cee(lE)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:gU;t.push(new Mee(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:s}=this,l=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(l&&l.getScope().hasLights){const h=this.setupLightingModel(e);u=EU(l,h,n,r)}else n!==null&&(u=Be(r!==null?Fi(u,n,r):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(qT.assign(Be(s||j9)),u=u.add(qT)),u}setupOutput(e,t){if(this.fog===!0){const n=e.fogNode;n&&(Eg.assign(t),t=dn(n))}return t}setDefaultValues(e){for(const n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=ua.prototype.toJSON.call(this,e),r=$_(this);n.inputNodes={};for(const{property:a,childNode:l}of r)n.inputNodes[a]=l.toJSON(e).uuid;function s(a){const l=[];for(const u in a){const h=a[u];delete h.metadata,l.push(h)}return l}if(t){const a=s(e.textures),l=s(e.images),u=s(e.nodes);a.length>0&&(n.textures=a),l.length>0&&(n.images=l),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const jee=new $0;class Wee extends Vr{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(jee),this.setValues(e)}}const $ee=new Bz;class Xee extends Vr{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues($ee),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?_e(this.offsetNode):pU,t=this.dashScaleNode?_e(this.dashScaleNode):fU,n=this.dashSizeNode?_e(this.dashSizeNode):AU,r=this.gapSizeNode?_e(this.gapSizeNode):dU;Qv.assign(n),VT.assign(r);const s=ro(_u("lineDistance").mul(t));(e?s.add(e):s).mod(Qv.add(VT)).greaterThan(Qv).discard()}}let Y3=null;class Yee extends $y{static get type(){return"ViewportSharedTextureNode"}constructor(e=bu,t=null){Y3===null&&(Y3=new W7),super(e,t,Y3)}updateReference(){return this}}const Qee=ct(Yee),PU=i=>_t(i).mul(.5).add(.5),Kee=i=>_t(i).mul(2).sub(1),Zee=new Dz;class Jee extends Vr{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Zee),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?_e(this.opacityNode):oE;Ui.assign(dn(PU(zr),e))}}class ete extends Zr{static get type(){return"EquirectUVNode"}constructor(e=iE){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Ct(t,n)}}const mE=ct(ete);class LU extends H7{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new $h(5,5,5),a=mE(iE),l=new Vr;l.colorNode=Ai(t,a,0),l.side=hr,l.blending=Qa;const u=new zi(s,l),h=new Yw;h.add(u),t.minFilter===Va&&(t.minFilter=gs);const m=new V7(1,10,this),v=e.getMRT();return e.setMRT(null),m.update(e,h),e.setMRT(v),t.minFilter=n,t.currentGenerateMipmaps=r,u.geometry.dispose(),u.material.dispose(),this}}const km=new WeakMap;class tte extends Zr{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=I0();const t=new yy;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=jn.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:n[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===zh||a===Gh){if(km.has(s)){const l=km.get(s);k6(l,s.mapping),this._cubeTexture=l}else{const l=s.image;if(nte(l)){const u=new LU(l.height);u.fromEquirectangularTexture(t,s),k6(u.texture,s.mapping),this._cubeTexture=u.texture,km.set(s,u.texture),s.addEventListener("dispose",UU)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function nte(i){return i==null?!1:i.height>0}function UU(i){const e=i.target;e.removeEventListener("dispose",UU);const t=km.get(e);t!==void 0&&(km.delete(e),t.dispose())}function k6(i,e){e===zh?i.mapping=Qo:e===Gh&&(i.mapping=Ko)}const BU=ct(tte);class gE extends K0{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=BU(this.envNode)}}class ite extends K0{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=_e(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Xy{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class OU extends Xy{constructor(){super()}indirect(e,t,n){const r=e.ambientOcclusion,s=e.reflectedLight,a=n.context.irradianceLightMap;s.indirectDiffuse.assign(dn(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(dn(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Ui.rgb)}finish(e,t,n){const r=n.material,s=e.outgoingLight,a=n.context.environment;if(a)switch(r.combine){case Lg:s.rgb.assign(Fi(s.rgb,s.rgb.mul(a.rgb),Fm.mul(Jv)));break;case C7:s.rgb.assign(Fi(s.rgb,a.rgb,Fm.mul(Jv)));break;case R7:s.rgb.addAssign(a.rgb.mul(Fm.mul(Jv)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const rte=new pA;class ste extends Vr{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(rte),this.setValues(e)}setupNormal(){return Jo}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new gE(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ite(lE)),t}setupOutgoingLight(){return Ui.rgb}setupLightingModel(){return new OU}}const F0=je(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),AA=je(i=>i.diffuseColor.mul(1/Math.PI)),ate=()=>_e(.25),ote=je(({dotNH:i})=>Q_.mul(_e(.5)).add(1).mul(_e(1/Math.PI)).mul(i.pow(Q_))),lte=je(({lightDirection:i})=>{const e=i.add(dr).normalize(),t=zr.dot(e).clamp(),n=dr.dot(e).clamp(),r=F0({f0:ka,f90:1,dotVH:n}),s=ate(),a=ote({dotNH:t});return r.mul(s).mul(a)});class IU extends OU{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=zr.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(AA({diffuseColor:Ui.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(lte({lightDirection:e})).mul(Fm))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(AA({diffuseColor:Ui}))),n.indirectDiffuse.mulAssign(e)}}const ute=new Vc;class cte extends Vr{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ute),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new gE(t):null}setupLightingModel(){return new IU(!1)}}const hte=new iD;class fte extends Vr{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(hte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new gE(t):null}setupLightingModel(){return new IU}setupVariants(){const e=(this.shininessNode?_e(this.shininessNode):H9).max(1e-4);Q_.assign(e);const t=this.specularNode||W9;ka.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const FU=je(i=>{if(i.geometry.hasAttribute("normal")===!1)return _e(0);const e=Jo.dFdx().abs().max(Jo.dFdy().abs());return e.x.max(e.y).max(e.z)}),vE=je(i=>{const{roughness:e}=i,t=FU();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),kU=je(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Dl(.5,r.add(s).max(wL))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Ate=je(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:s,dotNV:a,dotNL:l})=>{const u=l.mul(Be(i.mul(t),e.mul(n),a).length()),h=a.mul(Be(i.mul(r),e.mul(s),l).length());return Dl(.5,u.add(h)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),zU=je(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),dte=_e(1/Math.PI),pte=je(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const s=i.mul(e),a=Be(e.mul(n),i.mul(r),s.mul(t)),l=a.dot(a),u=s.div(l);return dte.mul(s.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),XT=je(i=>{const{lightDirection:e,f0:t,f90:n,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:l}=i,u=i.normalView||zr,h=r.pow2(),m=e.add(dr).normalize(),v=u.dot(e).clamp(),x=u.dot(dr).clamp(),S=u.dot(m).clamp(),w=dr.dot(m).clamp();let R=F0({f0:t,f90:n,dotVH:w}),C,E;if(xg(a)&&(R=By.mix(R,s)),xg(l)){const B=Bm.dot(e),L=Bm.dot(dr),O=Bm.dot(m),G=iA.dot(e),q=iA.dot(dr),z=iA.dot(m);C=Ate({alphaT:Y_,alphaB:h,dotTV:L,dotBV:q,dotTL:B,dotBL:G,dotNV:x,dotNL:v}),E=pte({alphaT:Y_,alphaB:h,dotNH:S,dotTH:O,dotBH:z})}else C=kU({alpha:h,dotNL:v,dotNV:x}),E=zU({alpha:h,dotNH:S});return R.mul(C).mul(E)}),_E=je(({roughness:i,dotNV:e})=>{const t=dn(-1,-.0275,-.572,.022),n=dn(1,.0425,1.04,-.04),r=i.mul(t).add(n),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return Ct(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),GU=je(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,s=_E({dotNV:e,roughness:r});return t.mul(s.x).add(n.mul(s.y))}),qU=je(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),s=n.mul(r,r).clamp(0,.9999);return i.sub(Be(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),mte=je(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=_e(1).div(t),s=e.pow2().oneMinus().max(.0078125);return _e(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),gte=je(({dotNV:i,dotNL:e})=>_e(1).div(_e(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),vte=je(({lightDirection:i})=>{const e=i.add(dr).normalize(),t=zr.dot(i).clamp(),n=zr.dot(dr).clamp(),r=zr.dot(e).clamp(),s=mte({roughness:Uy,dotNH:r}),a=gte({dotNV:n,dotNL:t});return Xf.mul(s).mul(a)}),_te=je(({N:i,V:e,roughness:t})=>{const s=.0078125,a=i.dot(e).saturate(),l=Ct(t,a.oneMinus().sqrt());return l.assign(l.mul(.984375).add(s)),l}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),yte=je(({f:i})=>{const e=i.length();return qr(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),lv=je(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=r.div(s),l=t.greaterThan(0).select(a,qr(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return i.cross(e).mul(l)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),z6=je(({N:i,V:e,P:t,mInv:n,p0:r,p1:s,p2:a,p3:l})=>{const u=s.sub(r).toVar(),h=l.sub(r).toVar(),m=u.cross(h),v=Be().toVar();return ti(m.dot(t.sub(r)).greaterThanEqual(0),()=>{const x=e.sub(i.mul(e.dot(i))).normalize(),S=i.cross(x).negate(),w=n.mul(ha(x,S,i).transpose()).toVar(),R=w.mul(r.sub(t)).normalize().toVar(),C=w.mul(s.sub(t)).normalize().toVar(),E=w.mul(a.sub(t)).normalize().toVar(),B=w.mul(l.sub(t)).normalize().toVar(),L=Be(0).toVar();L.addAssign(lv({v1:R,v2:C})),L.addAssign(lv({v1:C,v2:E})),L.addAssign(lv({v1:E,v2:B})),L.addAssign(lv({v1:B,v2:R})),v.assign(Be(yte({f:L})))}),v}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Yy=1/6,VU=i=>Wn(Yy,Wn(i,Wn(i,i.negate().add(3)).sub(3)).add(1)),YT=i=>Wn(Yy,Wn(i,Wn(i,Wn(3,i).sub(6))).add(4)),HU=i=>Wn(Yy,Wn(i,Wn(i,Wn(-3,i).add(3)).add(3)).add(1)),QT=i=>Wn(Yy,Cl(i,3)),G6=i=>VU(i).add(YT(i)),q6=i=>HU(i).add(QT(i)),V6=i=>Qr(-1,YT(i).div(VU(i).add(YT(i)))),H6=i=>Qr(1,QT(i).div(HU(i).add(QT(i)))),j6=(i,e,t)=>{const n=i.uvNode,r=Wn(n,e.zw).add(.5),s=hu(r),a=Hc(r),l=G6(a.x),u=q6(a.x),h=V6(a.x),m=H6(a.x),v=V6(a.y),x=H6(a.y),S=Ct(s.x.add(h),s.y.add(v)).sub(.5).mul(e.xy),w=Ct(s.x.add(m),s.y.add(v)).sub(.5).mul(e.xy),R=Ct(s.x.add(h),s.y.add(x)).sub(.5).mul(e.xy),C=Ct(s.x.add(m),s.y.add(x)).sub(.5).mul(e.xy),E=G6(a.y).mul(Qr(l.mul(i.sample(S).level(t)),u.mul(i.sample(w).level(t)))),B=q6(a.y).mul(Qr(l.mul(i.sample(R).level(t)),u.mul(i.sample(C).level(t))));return E.add(B)},jU=je(([i,e=_e(3)])=>{const t=Ct(i.size(Ee(e))),n=Ct(i.size(Ee(e.add(1)))),r=Dl(1,t),s=Dl(1,n),a=j6(i,dn(r,t),hu(e)),l=j6(i,dn(s,n),Iy(e));return Hc(e).mix(a,l)}),W6=je(([i,e,t,n,r])=>{const s=Be(JM(e.negate(),Fc(i),Dl(1,n))),a=Be(Rc(r[0].xyz),Rc(r[1].xyz),Rc(r[2].xyz));return Fc(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),xte=je(([i,e])=>i.mul(vu(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),bte=hE(),Ste=hE(),$6=je(([i,e,t],{material:n})=>{const s=(n.side===hr?bte:Ste).sample(i),a=cu(Rg.x).mul(xte(e,t));return jU(s,a)}),X6=je(([i,e,t])=>(ti(t.notEqual(0),()=>{const n=Oy(e).negate().div(t);return jM(n.negate().mul(i))}),Be(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Tte=je(([i,e,t,n,r,s,a,l,u,h,m,v,x,S,w])=>{let R,C;if(w){R=dn().toVar(),C=Be().toVar();const G=m.sub(1).mul(w.mul(.025)),q=Be(m.sub(G),m,m.add(G));ki({start:0,end:3},({i:z})=>{const j=q.element(z),F=W6(i,e,v,j,l),V=a.add(F),Y=h.mul(u.mul(dn(V,1))),ee=Ct(Y.xy.div(Y.w)).toVar();ee.addAssign(1),ee.divAssign(2),ee.assign(Ct(ee.x,ee.y.oneMinus()));const te=$6(ee,t,j);R.element(z).assign(te.element(z)),R.a.addAssign(te.a),C.element(z).assign(n.element(z).mul(X6(Rc(F),x,S).element(z)))}),R.a.divAssign(3)}else{const G=W6(i,e,v,m,l),q=a.add(G),z=h.mul(u.mul(dn(q,1))),j=Ct(z.xy.div(z.w)).toVar();j.addAssign(1),j.divAssign(2),j.assign(Ct(j.x,j.y.oneMinus())),R=$6(j,t,m),C=n.mul(X6(Rc(G),x,S))}const E=C.rgb.mul(R.rgb),B=i.dot(e).clamp(),L=Be(GU({dotNV:B,specularColor:r,specularF90:s,roughness:t})),O=C.r.add(C.g,C.b).div(3);return dn(L.oneMinus().mul(E),R.a.oneMinus().mul(O).oneMinus())}),wte=ha(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Mte=i=>{const e=i.sqrt();return Be(1).add(e).div(Be(1).sub(e))},Y6=(i,e)=>i.sub(e).div(i.add(e)).pow2(),Ete=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=Be(54856e-17,44201e-17,52481e-17),r=Be(1681e3,1795300,2208400),s=Be(43278e5,93046e5,66121e5),a=_e(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let l=n.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return l=Be(l.x.add(a),l.y,l.z).div(10685e-11),wte.mul(l)},Cte=je(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const s=Fi(i,e,kc(0,.03,n)),l=i.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();ti(l.lessThan(0),()=>Be(1));const u=l.sqrt(),h=Y6(s,i),m=F0({f0:h,f90:1,dotVH:t}),v=m.oneMinus(),x=s.lessThan(i).select(Math.PI,0),S=_e(Math.PI).sub(x),w=Mte(r.clamp(0,.9999)),R=Y6(w,s.toVec3()),C=F0({f0:R,f90:1,dotVH:u}),E=Be(w.x.lessThan(s).select(Math.PI,0),w.y.lessThan(s).select(Math.PI,0),w.z.lessThan(s).select(Math.PI,0)),B=s.mul(n,u,2),L=Be(S).add(E),O=m.mul(C).clamp(1e-5,.9999),G=O.sqrt(),q=v.pow2().mul(C).div(Be(1).sub(O)),j=m.add(q).toVar(),F=q.sub(v).toVar();return ki({start:1,end:2,condition:"<=",name:"m"},({m:V})=>{F.mulAssign(G);const Y=Ete(_e(V).mul(B),_e(V).mul(L)).mul(2);j.addAssign(F.mul(Y))}),j.max(Be(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Rte=je(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.pow2(),s=zs(t.lessThan(.25),_e(-339.2).mul(r).add(_e(161.4).mul(t)).sub(25.9),_e(-8.48).mul(r).add(_e(14.3).mul(t)).sub(9.95)),a=zs(t.lessThan(.25),_e(44).mul(r).sub(_e(23.7).mul(t)).add(3.26),_e(1.97).mul(r).sub(_e(3.27).mul(t)).add(.72));return zs(t.lessThan(.25),0,_e(.1).mul(t).sub(.025)).add(s.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),Q3=Be(.04),K3=_e(1);class WU extends Xy{constructor(e=!1,t=!1,n=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Be().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Be().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Be().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=Be().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Be().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=zr.dot(dr).clamp();this.iridescenceFresnel=Cte({outsideIOR:_e(1),eta2:OM,cosTheta1:t,thinFilmThickness:IM,baseF0:ka}),this.iridescenceF0=qU({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Nc,n=S9.sub(Nc).normalize(),r=Hy;e.backdrop=Tte(r,n,Zl,Ui,ka,Mg,t,$o,so,_A,Om,FM,zM,kM,this.dispersion?GM:null),e.backdropAlpha=K_,Ui.a.mulAssign(Fi(1,e.backdrop.a,K_))}}computeMultiscattering(e,t,n){const r=zr.dot(dr).clamp(),s=_E({roughness:Zl,dotNV:r}),l=(this.iridescenceF0?By.mix(ka,this.iridescenceF0):ka).mul(s.x).add(n.mul(s.y)),h=s.x.add(s.y).oneMinus(),m=ka.add(ka.oneMinus().mul(.047619)),v=l.mul(m).div(h.mul(m).oneMinus());e.addAssign(l),t.addAssign(v.mul(h))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=zr.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(s.mul(vte({lightDirection:e}))),this.clearcoat===!0){const l=Qd.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(l.mul(XT({lightDirection:e,f0:Q3,f90:K3,roughness:wg,normalView:Qd})))}n.directDiffuse.addAssign(s.mul(AA({diffuseColor:Ui.rgb}))),n.directSpecular.addAssign(s.mul(XT({lightDirection:e,f0:ka,f90:1,roughness:Zl,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:l}){const u=t.add(n).sub(r),h=t.sub(n).sub(r),m=t.sub(n).add(r),v=t.add(n).add(r),x=zr,S=dr,w=Xr.toVar(),R=_te({N:x,V:S,roughness:Zl}),C=a.sample(R).toVar(),E=l.sample(R).toVar(),B=ha(Be(C.x,0,C.y),Be(0,1,0),Be(C.z,0,C.w)).toVar(),L=ka.mul(E.x).add(ka.oneMinus().mul(E.y)).toVar();s.directSpecular.addAssign(e.mul(L).mul(z6({N:x,V:S,P:w,mInv:B,p0:u,p1:h,p2:m,p3:v}))),s.directDiffuse.addAssign(e.mul(Ui).mul(z6({N:x,V:S,P:w,mInv:ha(1,0,0,0,1,0,0,0,1),p0:u,p1:h,p2:m,p3:v})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(AA({diffuseColor:Ui})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Xf,Rte({normal:zr,viewDir:dr,roughness:Uy}))),this.clearcoat===!0){const h=Qd.dot(dr).clamp(),m=GU({dotNV:h,specularColor:Q3,specularF90:K3,roughness:wg});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const r=Be().toVar("singleScattering"),s=Be().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,Mg);const l=r.add(s),u=Ui.mul(l.r.max(l.g).max(l.b).oneMinus());n.indirectSpecular.addAssign(e.mul(r)),n.indirectSpecular.addAssign(s.mul(a)),n.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const r=zr.dot(dr).clamp().add(e),s=Zl.mul(-16).oneMinus().negate().exp2(),a=e.sub(r.pow(s).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(a)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=Qd.dot(dr).clamp(),r=F0({dotVH:n,f0:Q3,f90:K3}),s=t.mul(X_.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(X_));t.assign(s)}if(this.sheen===!0){const n=Xf.r.max(Xf.g).max(Xf.b).mul(.157).oneMinus(),r=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const Q6=_e(1),KT=_e(-2),uv=_e(.8),Z3=_e(-1),cv=_e(.4),J3=_e(2),hv=_e(.305),eS=_e(3),K6=_e(.21),Nte=_e(4),Z6=_e(4),Dte=_e(16),Pte=je(([i])=>{const e=Be(ur(i)).toVar(),t=_e(-1).toVar();return ti(e.x.greaterThan(e.z),()=>{ti(e.x.greaterThan(e.y),()=>{t.assign(zs(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(zs(i.y.greaterThan(0),1,4))})}).Else(()=>{ti(e.z.greaterThan(e.y),()=>{t.assign(zs(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(zs(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Lte=je(([i,e])=>{const t=Ct().toVar();return ti(e.equal(0),()=>{t.assign(Ct(i.z,i.y).div(ur(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Ct(i.x.negate(),i.z.negate()).div(ur(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Ct(i.x.negate(),i.y).div(ur(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Ct(i.z.negate(),i.y).div(ur(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Ct(i.x.negate(),i.z).div(ur(i.y)))}).Else(()=>{t.assign(Ct(i.x,i.y).div(ur(i.z)))}),Wn(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Ute=je(([i])=>{const e=_e(0).toVar();return ti(i.greaterThanEqual(uv),()=>{e.assign(Q6.sub(i).mul(Z3.sub(KT)).div(Q6.sub(uv)).add(KT))}).ElseIf(i.greaterThanEqual(cv),()=>{e.assign(uv.sub(i).mul(J3.sub(Z3)).div(uv.sub(cv)).add(Z3))}).ElseIf(i.greaterThanEqual(hv),()=>{e.assign(cv.sub(i).mul(eS.sub(J3)).div(cv.sub(hv)).add(J3))}).ElseIf(i.greaterThanEqual(K6),()=>{e.assign(hv.sub(i).mul(Nte.sub(eS)).div(hv.sub(K6)).add(eS))}).Else(()=>{e.assign(_e(-2).mul(cu(Wn(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),$U=je(([i,e])=>{const t=i.toVar();t.assign(Wn(2,t).sub(1));const n=Be(t,1).toVar();return ti(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),XU=je(([i,e,t,n,r,s])=>{const a=_e(t),l=Be(e),u=vu(Ute(a),KT,s),h=Hc(u),m=hu(u),v=Be(ZT(i,l,m,n,r,s)).toVar();return ti(h.notEqual(0),()=>{const x=Be(ZT(i,l,m.add(1),n,r,s)).toVar();v.assign(Fi(v,x,h))}),v}),ZT=je(([i,e,t,n,r,s])=>{const a=_e(t).toVar(),l=Be(e),u=_e(Pte(l)).toVar(),h=_e(qr(Z6.sub(a),0)).toVar();a.assign(qr(a,Z6));const m=_e(O0(a)).toVar(),v=Ct(Lte(l,u).mul(m.sub(2)).add(1)).toVar();return ti(u.greaterThan(2),()=>{v.y.addAssign(m),u.subAssign(3)}),v.x.addAssign(u.mul(m)),v.x.addAssign(h.mul(Wn(3,Dte))),v.y.addAssign(Wn(4,O0(s).sub(m))),v.x.mulAssign(n),v.y.mulAssign(r),i.sample(v).grad(Ct(),Ct())}),tS=je(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:l})=>{const u=yc(n),h=t.mul(u).add(r.cross(t).mul(Mo(n))).add(r.mul(r.dot(t).mul(u.oneMinus())));return ZT(i,h,e,s,a,l)}),YU=je(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:s,dTheta:a,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})=>{const x=Be(zs(e,t,ky(t,n))).toVar();ti(HM(x.equals(Be(0))),()=>{x.assign(Be(n.z,0,n.x.negate()))}),x.assign(Fc(x));const S=Be().toVar();return S.addAssign(r.element(Ee(0)).mul(tS({theta:0,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),ki({start:Ee(1),end:i},({i:w})=>{ti(w.greaterThanEqual(s),()=>{wU()});const R=_e(a.mul(_e(w))).toVar();S.addAssign(r.element(w).mul(tS({theta:R.mul(-1),axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),S.addAssign(r.element(w).mul(tS({theta:R,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})))}),dn(S,1)});let ny=null;const J6=new WeakMap;function Bte(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function Ote(i){let e=J6.get(i);if((e!==void 0?e.pmremVersion:-1)!==i.pmremVersion){const n=i.image;if(i.isCubeTexture)if(Fte(n))e=ny.fromCubemap(i,e);else return null;else if(kte(n))e=ny.fromEquirectangular(i,e);else return null;e.pmremVersion=i.pmremVersion,J6.set(i,e)}return e.texture}class Ite extends Zr{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new vs;r.isRenderTargetTexture=!0,this._texture=Ai(r),this._width=gn(0),this._height=gn(0),this._maxMip=gn(0),this.updateBeforeType=jn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=Bte(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(n.isPMREMTexture===!0?e=n:e=Ote(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ny===null&&(ny=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===Ha&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=Be(t.x.negate(),t.yz)),t=Be(t.x,t.y.negate(),t.z);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),XU(this._texture,t,r,this._width,this._height,this._maxMip)}}function Fte(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n0}const yE=ct(Ite),eN=new WeakMap;class zte extends K0{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const S=n.isTextureNode?n.value:t[n.property];let w=eN.get(S);w===void 0&&(w=yE(S),eN.set(S,w)),n=w}const s=t.envMap?ji("envMapIntensity","float",e.material):ji("environmentIntensity","float",e.scene),l=t.useAnisotropy===!0||t.anisotropy>0?z9:zr,u=n.context(tN(Zl,l)).mul(s),h=n.context(Gte(Hy)).mul(Math.PI).mul(s),m=Im(u),v=Im(h);e.context.radiance.addAssign(m),e.context.iblIrradiance.addAssign(v);const x=e.context.lightingModel.clearcoatRadiance;if(x){const S=n.context(tN(wg,Qd)).mul(s),w=Im(S);x.addAssign(w)}}}const tN=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=dr.negate().reflect(e),t=i.mul(i).mix(t,e).normalize(),t=t.transformDirection(so)),t),getTextureLevel:()=>i}},Gte=i=>({getUV:()=>i,getTextureLevel:()=>_e(1)}),qte=new nD;class QU extends Vr{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(qte),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new zte(t):null}setupLightingModel(){return new WU}setupSpecular(){const e=Fi(Be(.04),Ui.rgb,Tg);ka.assign(e),Mg.assign(1)}setupVariants(){const e=this.metalnessNode?_e(this.metalnessNode):Y9;Tg.assign(e);let t=this.roughnessNode?_e(this.roughnessNode):X9;t=vE({roughness:t}),Zl.assign(t),this.setupSpecular(),Ui.assign(dn(Ui.rgb.mul(e.oneMinus()),Ui.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const Vte=new Rz;class Hte extends QU{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(Vte),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?_e(this.iorNode):uU;Om.assign(e),ka.assign(Fi(to(ZM(Om.sub(1).div(Om.add(1))).mul($9),Be(1)).mul($T),Ui.rgb,Tg)),Mg.assign(Fi($T,1,Tg))}setupLightingModel(){return new WU(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?_e(this.clearcoatNode):K9,n=this.clearcoatRoughnessNode?_e(this.clearcoatRoughnessNode):Z9;X_.assign(t),wg.assign(vE({roughness:n}))}if(this.useSheen){const t=this.sheenNode?Be(this.sheenNode):tU,n=this.sheenRoughnessNode?_e(this.sheenRoughnessNode):nU;Xf.assign(t),Uy.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?_e(this.iridescenceNode):rU,n=this.iridescenceIORNode?_e(this.iridescenceIORNode):sU,r=this.iridescenceThicknessNode?_e(this.iridescenceThicknessNode):aU;By.assign(t),OM.assign(n),IM.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?Ct(this.anisotropyNode):iU).toVar();Rh.assign(t.length()),ti(Rh.equal(0),()=>{t.assign(Ct(1,0))}).Else(()=>{t.divAssign(Ct(Rh)),Rh.assign(Rh.saturate())}),Y_.assign(Rh.pow2().mix(Zl.pow2(),1)),Bm.assign(Yf[0].mul(t.x).add(Yf[1].mul(t.y))),iA.assign(Yf[1].mul(t.x).sub(Yf[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?_e(this.transmissionNode):oU,n=this.thicknessNode?_e(this.thicknessNode):lU,r=this.attenuationDistanceNode?_e(this.attenuationDistanceNode):cU,s=this.attenuationColorNode?Be(this.attenuationColorNode):hU;if(K_.assign(t),FM.assign(n),kM.assign(r),zM.assign(s),this.useDispersion){const a=this.dispersionNode?_e(this.dispersionNode):mU;GM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Be(this.clearcoatNormalNode):J9}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const jte=je(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=Ct(n.mul(.5).add(.5),0);if(t.material.gradientMap){const s=Tc("gradientMap","texture").context({getUV:()=>r});return Be(s.r)}else{const s=r.fwidth().mul(.5);return Fi(Be(.7),Be(1),kc(_e(.7).sub(s.x),_e(.7).add(s.x),r.x))}});class Wte extends Xy{direct({lightDirection:e,lightColor:t,reflectedLight:n},r,s){const a=jte({normal:qy,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(a.mul(AA({diffuseColor:Ui.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(AA({diffuseColor:Ui}))),n.indirectDiffuse.mulAssign(e)}}const $te=new Nz;class Xte extends Vr{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues($te),this.setValues(e)}setupLightingModel(){return new Wte}}class Yte extends Zr{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=Be(dr.z,0,dr.x.negate()).normalize(),t=dr.cross(e);return Ct(e.dot(zr),t.dot(zr)).mul(.495).add(.5)}}const KU=Wt(Yte),Qte=new Uz;class Kte extends Vr{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Qte),this.setValues(e)}setupVariants(e){const t=KU;let n;e.material.matcap?n=Tc("matcap","texture").context({getUV:()=>t}):n=Be(Fi(.2,.8,t.y)),Ui.rgb.mulAssign(n.rgb)}}const Zte=new Kw;class Jte extends Vr{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.setDefaultValues(Zte),this.setValues(e)}}class ene extends Zr{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),a=t.sin();return Ly(s,a,a.negate(),s).mul(n)}else{const s=t,a=nA(dn(1,0,0,0),dn(0,yc(s.x),Mo(s.x).negate(),0),dn(0,Mo(s.x),yc(s.x),0),dn(0,0,0,1)),l=nA(dn(yc(s.y),0,Mo(s.y),0),dn(0,1,0,0),dn(Mo(s.y).negate(),0,yc(s.y),0),dn(0,0,0,1)),u=nA(dn(yc(s.z),Mo(s.z).negate(),0,0),dn(Mo(s.z),yc(s.z),0,0),dn(0,0,1,0),dn(0,0,0,1));return a.mul(l).mul(u).mul(dn(n,1)).xyz}}}const xE=ct(ene),tne=new Wk;class nne extends Vr{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(tne),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:l}=this,u=Q0.mul(Be(s||0));let h=Ct($o[0].xyz.length(),$o[1].xyz.length());if(l!==null&&(h=h.mul(l)),r===!1)if(n.isPerspectiveCamera)h=h.mul(u.z.negate());else{const S=_e(2).div(_A.element(1).element(1));h=h.mul(S.mul(2))}let m=Gy.xy;if(t.center&&t.center.isVector2===!0){const S=bJ("center","vec2",t);m=m.sub(S.sub(.5))}m=m.mul(h);const v=_e(a||eU),x=xE(m,v);return dn(u.xy.add(x),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class ine extends Xy{constructor(){super(),this.shadowNode=_e(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Ui.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Ui.rgb)}}const rne=new Cz;class sne extends Vr{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(rne),this.setValues(e)}setupLightingModel(){return new ine}}const ane=je(({texture:i,uv:e})=>{const n=Be().toVar();return ti(e.x.lessThan(1e-4),()=>{n.assign(Be(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(Be(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(Be(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(Be(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(Be(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(Be(0,0,-1))}).Else(()=>{const s=i.sample(e.add(Be(-.01,0,0))).r.sub(i.sample(e.add(Be(.01,0,0))).r),a=i.sample(e.add(Be(0,-.01,0))).r.sub(i.sample(e.add(Be(0,.01,0))).r),l=i.sample(e.add(Be(0,0,-.01))).r.sub(i.sample(e.add(Be(0,0,.01))).r);n.assign(Be(s,a,l))}),n.normalize()});class one extends yu{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Be(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Ee(Fh(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return ane({texture:this,uv:e})}}const lne=ct(one);class une{constructor(e,t){this.nodes=e,this.info=t,this._context=self,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class Su{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const s of e){const a=s.node&&s.node.attribute?s.node.attribute:t.getAttribute(s.name);if(a===void 0)continue;n.push(a);const l=a.isInterleavedBufferAttribute?a.data:a;r.add(l)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:s}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),l=this.getIndex(),u=l!==null,h=n.isInstancedBufferGeometry?n.instanceCount:e.count>1?e.count:1;if(h===0)return null;if(a.instanceCount=h,e.isBatchedMesh===!0)return a;let m=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(m=2);let v=s.start*m,x=(s.start+s.count)*m;r!==null&&(v=Math.max(v,r.start*m),x=Math.min(x,(r.start+r.count)*m));const S=n.attributes.position;let w=1/0;u?w=l.count:S!=null&&(w=S.count),v=Math.max(v,0),x=Math.min(x,w);const R=x-v;return R<0||R===1/0?null:(a.vertexCount=R,a.firstVertex=v,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const r of hne(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const s=t[r];let a;if(s!==null){const l=typeof s;l==="number"?a=s!==0?"1":"0":l==="object"?(a="{",s.isTexture&&(a+=s.mapping),a+="}"):a=String(s)}else a=String(s);n+=a+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(n+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",PP(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Ed=[];class Ane{constructor(e,t,n,r,s,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=s,this.info=a,this.chainMaps={}}get(e,t,n,r,s,a,l,u){const h=this.getChainMap(u);Ed[0]=e,Ed[1]=t,Ed[2]=a,Ed[3]=s;let m=h.get(Ed);return m===void 0?(m=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,s,a,l,u),h.set(Ed,m)):(m.updateClipping(l),m.needsGeometryUpdate&&m.setGeometry(e.geometry),(m.version!==t.version||m.needsUpdate)&&(m.initialCacheKey!==m.getCacheKey()?(m.dispose(),m=this.get(e,t,n,r,s,a,l,u)):m.version=t.version)),m}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Su)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,s,a,l,u,h,m,v){const x=this.getChainMap(v),S=new fne(e,t,n,r,s,a,l,u,h,m);return S.onDispose=()=>{this.pipelines.delete(S),this.bindings.delete(S),this.nodes.delete(S),x.delete(S.getChainArray())},S}}class Yh{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const iu={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Lh=16,dne=211,pne=212;class mne extends Yh{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==void 0&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===iu.VERTEX?this.backend.createAttribute(e):t===iu.INDEX?this.backend.createIndexAttribute(e):t===iu.STORAGE?this.backend.createStorageAttribute(e):t===iu.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version=0;--e)if(i[e]>=65535)return!0;return!1}function ZU(i){return i.index!==null?i.index.version:i.attributes.position.version}function nN(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const s=t.array;for(let a=0,l=s.length;a{this.info.memory.geometries--;const s=t.index,a=e.getAttributes();s!==null&&this.attributes.delete(s);for(const u of a)this.attributes.delete(u);const l=this.wireframes.get(t);l!==void 0&&this.attributes.delete(l),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,iu.STORAGE):this.updateAttribute(s,iu.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,iu.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,iu.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const s=this.wireframes;let a=s.get(t);a===void 0?(a=nN(t),s.set(t,a)):a.version!==ZU(t)&&(this.attributes.delete(a),a=nN(t),s.set(t,a)),r=a}return r}}class _ne{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){this[e].timestampCalls===0&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class JU{constructor(e){this.cacheKey=e,this.usedTimes=0}}class yne extends JU{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class xne extends JU{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let bne=0;class nS{constructor(e,t,n,r=null,s=null){this.id=bne++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=s,this.usedTimes=0}}class Sne extends Yh{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let l=this.programs.compute.get(a.computeShader);l===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),l=new nS(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,l),n.createProgram(l));const u=this._getComputeCacheKey(e,l);let h=this.caches.get(u);h===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),h=this._getComputePipeline(e,l,u,t)),h.usedTimes++,l.usedTimes++,r.version=e.version,r.pipeline=h}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),l=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),u=new nS(a.vertexShader,"vertex",l),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let h=this.programs.fragment.get(a.fragmentShader);h===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),h=new nS(a.fragmentShader,"fragment",l),this.programs.fragment.set(a.fragmentShader,h),n.createProgram(h));const m=this._getRenderCacheKey(e,u,h);let v=this.caches.get(m);v===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),v=this._getRenderPipeline(e,u,h,m,t)):e.pipeline=v,v.usedTimes++,u.usedTimes++,h.usedTimes++,r.pipeline=v}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new xne(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,n,r,s){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new yne(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,s)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Tne extends Yh{constructor(e,t,n,r,s,a){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?iu.INDIRECT:iu.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,s=!0,a=0,l=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const h=this.textures.get(u.texture);u.needsBindingsUpdate(h.generation)&&(r=!0);const m=u.update(),v=u.texture;m&&this.textures.updateTexture(v);const x=n.get(v);if(x.externalTexture!==void 0||h.isDefaultTexture?s=!1:(a=a*10+v.id,l+=v.version),n.isWebGPUBackend===!0&&x.texture===void 0&&x.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,m,v,u.textureNode.value,r),this.textures.updateTexture(v),r=!0),v.isStorageTexture===!0){const S=this.get(v);u.store===!0?S.needsMipmap=!0:this.textures.needsMipmaps(v)&&S.needsMipmap===!0&&(this.backend.generateMipmaps(v),S.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,s?a:0,l)}}function wne(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function iN(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function rN(i){return(i.transmission>0||i.transmissionNode)&&i.side===as&&i.forceSinglePass===!1}class Mne{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,s,a,l){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:s,group:a,clippingContext:l},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=s,u.group=a,u.clippingContext=l),this.renderItemsIndex++,u}push(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(rN(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);n.transparent===!0||n.transmission>0?(rN(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||wne),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||iN),this.transparent.length>1&&this.transparent.sort(t||iN)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,h=l.height>>t;let m=e.depthTexture||s[t];const v=e.depthBuffer===!0||e.stencilBuffer===!0;let x=!1;m===void 0&&v&&(m=new qc,m.format=e.stencilBuffer?du:au,m.type=e.stencilBuffer?Au:Rr,m.image.width=u,m.image.height=h,s[t]=m),(n.width!==l.width||l.height!==n.height)&&(x=!0,m&&(m.needsUpdate=!0,m.image.width=u,m.image.height=h)),n.width=l.width,n.height=l.height,n.textures=a,n.depthTexture=m||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(x=!0,m&&(m.needsUpdate=!0),n.sampleCount=r);const S={sampleCount:r};for(let w=0;w{e.removeEventListener("dispose",w);for(let R=0;R0){const m=e.image;if(m===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(m.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const v=[];for(const x of e.images)v.push(x);t.images=v}else t.image=m;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&s.generateMipmaps(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const h=()=>{e.removeEventListener("dispose",h),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",h)}n.version=e.version}getSize(e,t=Dne){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return this.isEnvironmentTexture(e)||e.isCompressedTexture===!0||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===zh||t===Gh||t===Qo||t===Ko}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class bE extends an{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class tB extends Gi{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const Lne=(i,e)=>_t(new tB(i,e));class Une extends Mn{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new Um(t);return this._currentCond=zs(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Um(t),r=zs(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Um(e),this}build(e,...t){const n=PM();bg(this);for(const r of this.nodes)r.build(e,"void");return bg(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const e_=ct(Une);class nB extends Mn{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,n=[];for(let r=0;r{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),JT=(i,e)=>Cl(Wn(4,i.mul(wi(1,i))),e),Fne=(i,e)=>i.lessThan(.5)?JT(i.mul(2),e).div(2):wi(1,JT(Wn(wi(1,i),2),e).div(2)),kne=(i,e,t)=>Cl(Dl(Cl(i,e),Qr(Cl(i,e),Cl(wi(1,i),t))),1/e),zne=(i,e)=>Mo(Z_.mul(e.mul(i).sub(1))).div(Z_.mul(e.mul(i).sub(1))),xc=je(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Gne=je(([i])=>Be(xc(i.z.add(xc(i.y.mul(1)))),xc(i.z.add(xc(i.x.mul(1)))),xc(i.y.add(xc(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),qne=je(([i,e,t])=>{const n=Be(i).toVar(),r=_e(1.4).toVar(),s=_e(0).toVar(),a=Be(n).toVar();return ki({start:_e(0),end:_e(3),type:"float",condition:"<="},()=>{const l=Be(Gne(a.mul(2))).toVar();n.addAssign(l.add(t.mul(_e(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const u=_e(xc(n.z.add(xc(n.x.add(xc(n.y)))))).toVar();s.addAssign(u.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Vne extends Mn{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let r=null,s=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=u.inputs;if(t.length===h.length){let m=0;for(let v=0;vs&&(r=a,s=m)}}this._candidateFnCall=n=r(...t)}return n}}const Hne=ct(Vne),Vs=i=>(...e)=>Hne(i,...e),yA=gn(0).setGroup(Rn).onRenderUpdate(i=>i.time),sB=gn(0).setGroup(Rn).onRenderUpdate(i=>i.deltaTime),jne=gn(0,"uint").setGroup(Rn).onRenderUpdate(i=>i.frameId),Wne=(i=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),yA.mul(i)),$ne=(i=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),yA.mul(i)),Xne=(i=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),sB.mul(i)),Yne=(i=yA)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Qne=(i=yA)=>i.fract().round(),Kne=(i=yA)=>i.add(.5).fract().mul(2).sub(1).abs(),Zne=(i=yA)=>i.fract(),Jne=je(([i,e,t=Ct(.5)])=>xE(i.sub(t),e).add(t)),eie=je(([i,e,t=Ct(.5)])=>{const n=i.sub(t),r=n.dot(n),a=r.mul(r).mul(e);return i.add(n.mul(a))}),tie=je(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=$o.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=$o;const r=so.mul(n);return xg(e)&&(r[0][0]=$o[0].length(),r[0][1]=0,r[0][2]=0),xg(t)&&(r[1][0]=0,r[1][1]=$o[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,_A.mul(r).mul(Gr)}),nie=je(([i=null])=>{const e=ty();return ty(fE(i)).sub(e).lessThan(0).select(bu,i)});class iie extends Mn{static get type(){return"SpriteSheetUVNode"}constructor(e,t=Er(),n=_e(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:s}=n,a=e.mod(r.mul(s)).floor(),l=a.mod(r),u=s.sub(a.add(1).div(r).ceil()),h=n.reciprocal(),m=Ct(l,u);return t.add(m).mul(h)}}const rie=ct(iie);class sie extends Mn{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,n=null,r=_e(1),s=Gr,a=no){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:s,normalNode:a}=this;let l=a.abs().normalize();l=l.div(l.dot(Be(1)));const u=s.yz.mul(r),h=s.zx.mul(r),m=s.xy.mul(r),v=e.value,x=t!==null?t.value:v,S=n!==null?n.value:v,w=Ai(v,u).mul(l.x),R=Ai(x,h).mul(l.y),C=Ai(S,m).mul(l.z);return Qr(w,R,C)}}const aB=ct(sie),aie=(...i)=>aB(...i),Cd=new Yl,Cf=new he,Rd=new he,iS=new he,um=new kn,fv=new he(0,0,-1),Hl=new Ln,cm=new he,Av=new he,hm=new Ln,dv=new gt,iy=new Wh,oie=bu.flipX();iy.depthTexture=new qc(1,1);let rS=!1;class SE extends yu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||iy.texture,oie),this._reflectorBaseNode=e.reflector||new lie(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=_t(new SE({defaultTexture:iy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}}class lie extends Mn{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new vr,resolution:r=1,generateMipmaps:s=!1,bounces:a=!0,depth:l=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=s,this.bounces=a,this.depth=l,this.updateBeforeType=a?jn.RENDER:jn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const n=this.resolution;t.getDrawingBufferSize(dv),e.setSize(Math.round(dv.width*n),Math.round(dv.height*n))}setup(e){return this._updateResolution(iy,e.renderer),super.setup(e)}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Wh(0,0,{type:Gs}),this.generateMipmaps===!0&&(t.texture.minFilter=qF,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new qc),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&rS)return!1;rS=!0;const{scene:t,camera:n,renderer:r,material:s}=e,{target:a}=this,l=this.getVirtualCamera(n),u=this.getRenderTarget(l);if(r.getDrawingBufferSize(dv),this._updateResolution(u,r),Rd.setFromMatrixPosition(a.matrixWorld),iS.setFromMatrixPosition(n.matrixWorld),um.extractRotation(a.matrixWorld),Cf.set(0,0,1),Cf.applyMatrix4(um),cm.subVectors(Rd,iS),cm.dot(Cf)>0)return;cm.reflect(Cf).negate(),cm.add(Rd),um.extractRotation(n.matrixWorld),fv.set(0,0,-1),fv.applyMatrix4(um),fv.add(iS),Av.subVectors(Rd,fv),Av.reflect(Cf).negate(),Av.add(Rd),l.coordinateSystem=n.coordinateSystem,l.position.copy(cm),l.up.set(0,1,0),l.up.applyMatrix4(um),l.up.reflect(Cf),l.lookAt(Av),l.near=n.near,l.far=n.far,l.updateMatrixWorld(),l.projectionMatrix.copy(n.projectionMatrix),Cd.setFromNormalAndCoplanarPoint(Cf,Rd),Cd.applyMatrix4(l.matrixWorldInverse),Hl.set(Cd.normal.x,Cd.normal.y,Cd.normal.z,Cd.constant);const h=l.projectionMatrix;hm.x=(Math.sign(Hl.x)+h.elements[8])/h.elements[0],hm.y=(Math.sign(Hl.y)+h.elements[9])/h.elements[5],hm.z=-1,hm.w=(1+h.elements[10])/h.elements[14],Hl.multiplyScalar(1/Hl.dot(hm));const m=0;h.elements[2]=Hl.x,h.elements[6]=Hl.y,h.elements[10]=r.coordinateSystem===pu?Hl.z-m:Hl.z+1-m,h.elements[14]=Hl.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),s.visible=!1;const v=r.getRenderTarget(),x=r.getMRT(),S=r.autoClear;r.setMRT(null),r.setRenderTarget(u),r.autoClear=!0,r.render(t,l),r.setMRT(x),r.setRenderTarget(v),r.autoClear=S,s.visible=!0,rS=!1}}const uie=i=>_t(new SE(i)),sS=new kg(-1,1,1,-1,0,1);class cie extends Ki{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Mi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Mi(t,2))}}const hie=new cie;class TE extends zi{constructor(e=null){super(hie,e),this.camera=sS,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,sS)}render(e){e.render(this,sS)}}const fie=new gt;class Aie extends yu{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:Gs}){const s=new Wh(t,n,r);super(s.texture,Er()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new TE(new Vr),this.updateBeforeType=jn.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const n=e.getSize(fie);this.setSize(n.width,n.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new yu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const oB=(i,...e)=>_t(new Aie(_t(i),...e)),die=(i,...e)=>i.isTextureNode?i:i.isPassNode?i.getTextureNode():oB(i,...e),zd=je(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===pu?(i=Ct(i.x,i.y.oneMinus()).mul(2).sub(1),r=dn(Be(i,e),1)):r=dn(Be(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const s=dn(t.mul(r));return s.xyz.div(s.w)}),pie=je(([i,e])=>{const t=e.mul(dn(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Ct(n.x,n.y.oneMinus())}),mie=je(([i,e,t])=>{const n=Fh(Fr(e)),r=ms(i.mul(n)).toVar(),s=Fr(e,r).toVar(),a=Fr(e,r.sub(ms(2,0))).toVar(),l=Fr(e,r.sub(ms(1,0))).toVar(),u=Fr(e,r.add(ms(1,0))).toVar(),h=Fr(e,r.add(ms(2,0))).toVar(),m=Fr(e,r.add(ms(0,2))).toVar(),v=Fr(e,r.add(ms(0,1))).toVar(),x=Fr(e,r.sub(ms(0,1))).toVar(),S=Fr(e,r.sub(ms(0,2))).toVar(),w=ur(wi(_e(2).mul(l).sub(a),s)).toVar(),R=ur(wi(_e(2).mul(u).sub(h),s)).toVar(),C=ur(wi(_e(2).mul(v).sub(m),s)).toVar(),E=ur(wi(_e(2).mul(x).sub(S),s)).toVar(),B=zd(i,s,t).toVar(),L=w.lessThan(R).select(B.sub(zd(i.sub(Ct(_e(1).div(n.x),0)),l,t)),B.negate().add(zd(i.add(Ct(_e(1).div(n.x),0)),u,t))),O=C.lessThan(E).select(B.sub(zd(i.add(Ct(0,_e(1).div(n.y))),v,t)),B.negate().add(zd(i.sub(Ct(0,_e(1).div(n.y))),x,t)));return Fc(ky(L,O))});class t_ extends Ig{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class gie extends wr{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}class vie extends vA{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}const _ie=ct(vie);class yie extends sE{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t=UP(e.itemSize),n=e.count),super(e,t,n),this.isStorageBufferNode=!0,this.access=sa.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return _ie(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(sa.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=$g(this.value),this._varying=ro(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}generate(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const Qy=(i,e=null,t=0)=>_t(new yie(i,e,t)),xie=(i,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Qy(i,e,t).setPBO(!0)),bie=(i,e="float")=>{const t=OP(e),n=BP(e),r=new gie(i,t,n);return Qy(r,e,i)},Sie=(i,e="float")=>{const t=OP(e),n=BP(e),r=new t_(i,t,n);return Qy(r,e,i)};class Tie extends x9{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new Ln(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const wie=i=>_t(new Tie(i));class Mie extends Mn{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Eie=Wt(Mie),fm=new la,aS=new kn;class Ya extends Mn{static get type(){return"SceneNode"}constructor(e=Ya.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let r;return t===Ya.BACKGROUND_BLURRINESS?r=ji("backgroundBlurriness","float",n):t===Ya.BACKGROUND_INTENSITY?r=ji("backgroundIntensity","float",n):t===Ya.BACKGROUND_ROTATION?r=gn("mat4").label("backgroundRotation").setGroup(Rn).onRenderUpdate(()=>{const s=n.background;return s!==null&&s.isTexture&&s.mapping!==Lw?(fm.copy(n.backgroundRotation),fm.x*=-1,fm.y*=-1,fm.z*=-1,aS.makeRotationFromEuler(fm)):aS.identity(),aS}):console.error("THREE.SceneNode: Unknown scope:",t),r}}Ya.BACKGROUND_BLURRINESS="backgroundBlurriness";Ya.BACKGROUND_INTENSITY="backgroundIntensity";Ya.BACKGROUND_ROTATION="backgroundRotation";const lB=Wt(Ya,Ya.BACKGROUND_BLURRINESS),ew=Wt(Ya,Ya.BACKGROUND_INTENSITY),uB=Wt(Ya,Ya.BACKGROUND_ROTATION);class Cie extends yu{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=sa.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(sa.READ_WRITE)}toReadOnly(){return this.setAccess(sa.READ_ONLY)}toWriteOnly(){return this.setAccess(sa.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:r}=t,s=super.generate(e,"property"),a=n.build(e,"uvec2"),l=r.build(e,"vec4"),u=e.generateTextureStore(e,s,a,l);e.addLineFlowCode(u,this)}}const cB=ct(Cie),Rie=(i,e,t)=>{const n=cB(i,e,t);return t!==null&&n.append(),n};class Nie extends jy{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Die=(i,e,t)=>_t(new Nie(i,e,t)),sN=new WeakMap;class Pie extends Zr{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=jn.OBJECT,this.updateAfterType=jn.OBJECT,this.previousModelWorldMatrix=gn(new kn),this.previousProjectionMatrix=gn(new kn).setGroup(Rn),this.previousCameraViewMatrix=gn(new kn)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=aN(n);this.previousModelWorldMatrix.value.copy(r);const s=hB(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new kn,s.previousCameraViewMatrix=new kn,s.currentProjectionMatrix=new kn,s.currentCameraViewMatrix=new kn,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){aN(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?_A:gn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(Q0).mul(Gr),r=this.previousProjectionMatrix.mul(t).mul(ey),s=n.xy.div(n.w),a=r.xy.div(r.w);return wi(s,a)}}function hB(i){let e=sN.get(i);return e===void 0&&(e={},sN.set(i,e)),e}function aN(i,e=0){const t=hB(i);let n=t[e];return n===void 0&&(t[e]=n=new kn),n}const Lie=Wt(Pie),fB=je(([i,e])=>to(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),AB=je(([i,e])=>to(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),dB=je(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),pB=je(([i,e])=>Fi(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Fy(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Uie=je(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return dn(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),Bie=(...i)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),fB(i)),Oie=(...i)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),AB(i)),Iie=(...i)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),dB(i)),Fie=(...i)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),pB(i)),kie=je(([i])=>wE(i.rgb)),zie=je(([i,e=_e(1)])=>e.mix(wE(i.rgb),i.rgb)),Gie=je(([i,e=_e(1)])=>{const t=Qr(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),r=n.sub(t).mul(e).mul(-3);return Fi(i.rgb,n,r)}),qie=je(([i,e=_e(1)])=>{const t=Be(.57735,.57735,.57735),n=e.cos();return Be(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(Xh(t,i.rgb).mul(n.oneMinus())))))}),wE=(i,e=Be(ai.getLuminanceCoefficients(new he)))=>Xh(i,e),Vie=je(([i,e=Be(1),t=Be(0),n=Be(1),r=_e(1),s=Be(ai.getLuminanceCoefficients(new he,Ro))])=>{const a=i.rgb.dot(Be(s)),l=qr(i.rgb.mul(e).add(t),0).toVar(),u=l.pow(n).toVar();return ti(l.r.greaterThan(0),()=>{l.r.assign(u.r)}),ti(l.g.greaterThan(0),()=>{l.g.assign(u.g)}),ti(l.b.greaterThan(0),()=>{l.b.assign(u.b)}),l.assign(a.add(l.sub(a).mul(r))),dn(l.rgb,i.a)});class Hie extends Zr{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const jie=ct(Hie),Wie=new gt;class mB extends yu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class oN extends mB{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Tu extends Zr{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new qc;s.isRenderTargetTexture=!0,s.name="depth";const a=new Wh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Gs,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=gn(0),this._cameraFar=gn(0),this._mrt=null,this.isPassNode=!0,this.updateBeforeType=jn.FRAME}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=_t(new oN(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=_t(new oN(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=AE(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=s0(s,n,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.scope===Tu.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(Wie);this.setSize(s.width,s.height);const a=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const u in this._previousTextures)this.toggleTexture(u);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(a),t.setMRT(l)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Tu.COLOR="color";Tu.DEPTH="depth";const $ie=(i,e,t)=>_t(new Tu(Tu.COLOR,i,e,t)),Xie=(i,e)=>_t(new mB(i,e)),Yie=(i,e,t)=>_t(new Tu(Tu.DEPTH,i,e,t));class Qie extends Tu{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,s){super(Tu.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,l,u,h,m,v)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const x=this._getOutlineMaterial(u);t.renderObject(r,s,a,l,x,h,m,v)}t.renderObject(r,s,a,l,u,h,m,v)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new Vr;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=hr;const t=no.negate(),n=_A.mul(Q0),r=_e(1),s=n.mul(dn(Gr,1)),a=n.mul(dn(Gr.add(t),1)),l=Fc(s.sub(a));return e.vertexNode=s.add(l.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=dn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const Kie=(i,e,t=new an(0,0,0),n=.003,r=1)=>_t(new Qie(i,e,_t(t),_t(n),_t(r))),gB=je(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),vB=je(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),_B=je(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Zie=je(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),yB=je(([i,e])=>{const t=ha(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=ha(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=Zie(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Jie=ha(Be(1.6605,-.1246,-.0182),Be(-.5876,1.1329,-.1006),Be(-.0728,-.0083,1.1187)),ere=ha(Be(.6274,.0691,.0164),Be(.3293,.9195,.088),Be(.0433,.0113,.8956)),tre=je(([i])=>{const e=Be(i).toVar(),t=Be(e.mul(e)).toVar(),n=Be(t.mul(t)).toVar();return _e(15.5).mul(n.mul(t)).sub(Wn(40.14,n.mul(e))).add(Wn(31.96,n).sub(Wn(6.868,t.mul(e))).add(Wn(.4298,t).add(Wn(.1191,e).sub(.00232))))}),xB=je(([i,e])=>{const t=Be(i).toVar(),n=ha(Be(.856627153315983,.137318972929847,.11189821299995),Be(.0951212405381588,.761241990602591,.0767994186031903),Be(.0482516061458583,.101439036467562,.811302368396859)),r=ha(Be(1.1271005818144368,-.1413297634984383,-.14132976349843826),Be(-.11060664309660323,1.157823702216272,-.11060664309660294),Be(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=_e(-12.47393),a=_e(4.026069);return t.mulAssign(e),t.assign(ere.mul(t)),t.assign(n.mul(t)),t.assign(qr(t,1e-10)),t.assign(cu(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(vu(t,0,1)),t.assign(tre(t)),t.assign(r.mul(t)),t.assign(Cl(qr(Be(0),t),Be(2.2))),t.assign(Jie.mul(t)),t.assign(vu(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bB=je(([i,e])=>{const t=_e(.76),n=_e(.15);i=i.mul(e);const r=to(i.r,to(i.g,i.b)),s=zs(r.lessThan(.08),r.sub(Wn(6.25,r.mul(r))),.04);i.subAssign(s);const a=qr(i.r,qr(i.g,i.b));ti(a.lessThan(t),()=>i);const l=wi(1,t),u=wi(1,l.mul(l).div(a.add(l.sub(t))));i.mulAssign(u.div(a));const h=wi(1,Dl(1,n.mul(a.sub(u)).add(1)));return Fi(i,Be(u),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class rs extends Mn{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.includes=t,this.language=n}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ky=ct(rs),nre=(i,e)=>Ky(i,e,"js"),ire=(i,e)=>Ky(i,e,"wgsl"),rre=(i,e)=>Ky(i,e,"glsl");class SB extends rs{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,s=n.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const l=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(l);return a.code=u+` -`,t==="property"?l:e.format(`${l}()`,s,t)}}const TB=(i,e=[],t="")=>{for(let s=0;sn.call(...s);return r.functionNode=n,r},sre=(i,e)=>TB(i,e,"glsl"),are=(i,e)=>TB(i,e,"wgsl");class ore extends Mn{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new zc,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:_e()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=kP(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=zP(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const n_=ct(ore);class wB extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class lre{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const i_=new wB;class ure extends Mn{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new wB,this._output=n_(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=n_(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=n_(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r.constructor.name==="AsyncFunction"?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(h,m)=>this.setOutput(h,m),n=new lre(this),r=i_.get("THREE"),s=i_.get("TSL"),a=this.getMethod(),l=[n,this._local,i_,e,t,r,s];this._object=a(...l);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const h of u.elements){const m=h.id||h.name;h.inputType&&(this.getParameter(m)===void 0&&this.setParameter(m,null),this.getParameter(m).inputType=h.inputType),h.outputType&&(this.getOutput(m)===void 0&&this.setOutput(m,null),this.getOutput(m).outputType=h.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:_e()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),r="var "+n+`; var output = {}; -`,s=` -return { ...output, `+n+" };",a=r+this.codeNode.code+s;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[PP(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Ny(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const cre=ct(ure);function MB(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Xr.z).negate()}const ME=je(([i,e],t)=>{const n=MB(t);return kc(i,e,n)}),EE=je(([i],e)=>{const t=MB(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Ng=je(([i,e])=>dn(e.toFloat().mix(Eg.rgb,i.toVec3()),Eg.a));function hre(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Ng(i,ME(e,t))}function fre(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Ng(i,EE(e))}let Rf=null,Nf=null;class Are extends Mn{static get type(){return"RangeNode"}constructor(e=_e(),t=_e()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Uh(this.minNode.value)),n=e.getTypeLength(Uh(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Uh(r)),l=e.getTypeLength(Uh(s));Rf=Rf||new Ln,Nf=Nf||new Ln,Rf.setScalar(0),Nf.setScalar(0),a===1?Rf.setScalar(r):r.isColor?Rf.set(r.r,r.g,r.b,1):Rf.set(r.x,r.y,r.z||0,r.w||0),l===1?Nf.setScalar(s):s.isColor?Nf.set(s.r,s.g,s.b,1):Nf.set(s.x,s.y,s.z||0,s.w||0);const u=4,h=u*t.count,m=new Float32Array(h);for(let x=0;x_t(new pre(i,e)),mre=Zy("numWorkgroups","uvec3"),gre=Zy("workgroupId","uvec3"),vre=Zy("localId","uvec3"),_re=Zy("subgroupSize","uint");class yre extends Mn{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier -`):e.addLineFlowCode(`${t}Barrier()`,this)}}const CE=ct(yre),xre=()=>CE("workgroup").append(),bre=()=>CE("storage").append(),Sre=()=>CE("texture").append();class Tre extends vA{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}class wre extends Mn{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return _t(new Tre(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const Mre=(i,e)=>_t(new wre("Workgroup",i,e));class Ds extends Zr{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,l=[];l.push(`&${s.build(e,r)}`),l.push(a.build(e,r));const u=`${e.getMethod(t,n)}( ${l.join(", ")} )`;if(this.storeNode!==null){const h=this.storeNode.build(e,r);e.addLineFlowCode(`${h} = ${u}`,this)}else e.addLineFlowCode(u,this)}}Ds.ATOMIC_LOAD="atomicLoad";Ds.ATOMIC_STORE="atomicStore";Ds.ATOMIC_ADD="atomicAdd";Ds.ATOMIC_SUB="atomicSub";Ds.ATOMIC_MAX="atomicMax";Ds.ATOMIC_MIN="atomicMin";Ds.ATOMIC_AND="atomicAnd";Ds.ATOMIC_OR="atomicOr";Ds.ATOMIC_XOR="atomicXor";const Ere=ct(Ds),jc=(i,e,t,n=null)=>{const r=Ere(i,e,t,n);return r.append(),r},Cre=(i,e,t=null)=>jc(Ds.ATOMIC_STORE,i,e,t),Rre=(i,e,t=null)=>jc(Ds.ATOMIC_ADD,i,e,t),Nre=(i,e,t=null)=>jc(Ds.ATOMIC_SUB,i,e,t),Dre=(i,e,t=null)=>jc(Ds.ATOMIC_MAX,i,e,t),Pre=(i,e,t=null)=>jc(Ds.ATOMIC_MIN,i,e,t),Lre=(i,e,t=null)=>jc(Ds.ATOMIC_AND,i,e,t),Ure=(i,e,t=null)=>jc(Ds.ATOMIC_OR,i,e,t),Bre=(i,e,t=null)=>jc(Ds.ATOMIC_XOR,i,e,t);let pv;function t1(i){pv=pv||new WeakMap;let e=pv.get(i);return e===void 0&&pv.set(i,e={}),e}function RE(i){const e=t1(i);return e.shadowMatrix||(e.shadowMatrix=gn("mat4").setGroup(Rn).onRenderUpdate(()=>(i.castShadow!==!0&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function EB(i){const e=t1(i);if(e.projectionUV===void 0){const t=RE(i).mul(Nc);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function NE(i){const e=t1(i);return e.position||(e.position=gn(new he).setGroup(Rn).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function CB(i){const e=t1(i);return e.targetPosition||(e.targetPosition=gn(new he).setGroup(Rn).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function Jy(i){const e=t1(i);return e.viewPosition||(e.viewPosition=gn(new he).setGroup(Rn).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new he,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const DE=i=>so.transformDirection(NE(i).sub(CB(i))),Ore=i=>i.sort((e,t)=>e.id-t.id),Ire=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},oS=new WeakMap;class PE extends Mn{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Be().toVar("totalDiffuse"),this.totalSpecularNode=Be().toVar("totalSpecular"),this.outgoingLightNode=Be().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let n=0;n0}}const Fre=(i=[])=>_t(new PE).setLights(i);class kre extends Mn{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=jn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({material:e}){LE.assign(e.shadowPositionNode||Nc)}dispose(){this.updateBeforeType=jn.NONE}}const LE=Be().toVar("shadowPositionWorld");function zre(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new an),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function Gre(i,e){return e=zre(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function qre(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function Vre(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function Hre(i,e){return e=Vre(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function jre(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function Wre(i,e,t){return t=Gre(i,t),t=Hre(e,t),t}function $re(i,e,t){qre(i,t),jre(e,t)}const lN=new WeakMap,Xre=je(([i,e,t])=>{let n=Nc.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),Yre=i=>{const e=i.shadow.camera,t=ji("near","float",e).setGroup(Rn),n=ji("far","float",e).setGroup(Rn),r=T9(i);return Xre(r,t,n)},Qre=i=>{let e=lN.get(i);if(e===void 0){const t=i.isPointLight?Yre(i):null;e=new Vr,e.colorNode=dn(0,0,0,1),e.depthNode=t,e.isShadowNodeMaterial=!0,e.name="ShadowMaterial",e.fog=!1,lN.set(i,e)}return e},RB=je(({depthTexture:i,shadowCoord:e})=>Ai(i,e.xy).compare(e.z)),NB=je(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(R,C)=>Ai(i,R).compare(C),r=ji("mapSize","vec2",t).setGroup(Rn),s=ji("radius","float",t).setGroup(Rn),a=Ct(1).div(r),l=a.x.negate().mul(s),u=a.y.negate().mul(s),h=a.x.mul(s),m=a.y.mul(s),v=l.div(2),x=u.div(2),S=h.div(2),w=m.div(2);return Qr(n(e.xy.add(Ct(l,u)),e.z),n(e.xy.add(Ct(0,u)),e.z),n(e.xy.add(Ct(h,u)),e.z),n(e.xy.add(Ct(v,x)),e.z),n(e.xy.add(Ct(0,x)),e.z),n(e.xy.add(Ct(S,x)),e.z),n(e.xy.add(Ct(l,0)),e.z),n(e.xy.add(Ct(v,0)),e.z),n(e.xy,e.z),n(e.xy.add(Ct(S,0)),e.z),n(e.xy.add(Ct(h,0)),e.z),n(e.xy.add(Ct(v,w)),e.z),n(e.xy.add(Ct(0,w)),e.z),n(e.xy.add(Ct(S,w)),e.z),n(e.xy.add(Ct(l,m)),e.z),n(e.xy.add(Ct(0,m)),e.z),n(e.xy.add(Ct(h,m)),e.z)).mul(1/17)}),DB=je(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(m,v)=>Ai(i,m).compare(v),r=ji("mapSize","vec2",t).setGroup(Rn),s=Ct(1).div(r),a=s.x,l=s.y,u=e.xy,h=Hc(u.mul(r).add(.5));return u.subAssign(h.mul(s)),Qr(n(u,e.z),n(u.add(Ct(a,0)),e.z),n(u.add(Ct(0,l)),e.z),n(u.add(s),e.z),Fi(n(u.add(Ct(a.negate(),0)),e.z),n(u.add(Ct(a.mul(2),0)),e.z),h.x),Fi(n(u.add(Ct(a.negate(),l)),e.z),n(u.add(Ct(a.mul(2),l)),e.z),h.x),Fi(n(u.add(Ct(0,l.negate())),e.z),n(u.add(Ct(0,l.mul(2))),e.z),h.y),Fi(n(u.add(Ct(a,l.negate())),e.z),n(u.add(Ct(a,l.mul(2))),e.z),h.y),Fi(Fi(n(u.add(Ct(a.negate(),l.negate())),e.z),n(u.add(Ct(a.mul(2),l.negate())),e.z),h.x),Fi(n(u.add(Ct(a.negate(),l.mul(2))),e.z),n(u.add(Ct(a.mul(2),l.mul(2))),e.z),h.x),h.y)).mul(1/9)}),PB=je(({depthTexture:i,shadowCoord:e})=>{const t=_e(1).toVar(),n=Ai(i).sample(e.xy).rg,r=Fy(e.z,n.x);return ti(r.notEqual(_e(1)),()=>{const s=e.z.sub(n.x),a=qr(0,n.y.mul(n.y));let l=a.div(a.add(s.mul(s)));l=vu(wi(l,.3).div(.95-.3)),t.assign(vu(qr(r,l)))}),t}),Kre=je(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=_e(0).toVar(),s=_e(0).toVar(),a=i.lessThanEqual(_e(1)).select(_e(0),_e(2).div(i.sub(1))),l=i.lessThanEqual(_e(1)).select(_e(0),_e(-1));ki({start:Ee(0),end:Ee(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(_e(h).mul(a)),v=n.sample(Qr(e1.xy,Ct(0,m).mul(e)).div(t)).x;r.addAssign(v),s.addAssign(v.mul(v))}),r.divAssign(i),s.divAssign(i);const u=Cu(s.sub(r.mul(r)));return Ct(r,u)}),Zre=je(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=_e(0).toVar(),s=_e(0).toVar(),a=i.lessThanEqual(_e(1)).select(_e(0),_e(2).div(i.sub(1))),l=i.lessThanEqual(_e(1)).select(_e(0),_e(-1));ki({start:Ee(0),end:Ee(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(_e(h).mul(a)),v=n.sample(Qr(e1.xy,Ct(m,0).mul(e)).div(t));r.addAssign(v.x),s.addAssign(Qr(v.y.mul(v.y),v.x.mul(v.x)))}),r.divAssign(i),s.divAssign(i);const u=Cu(s.sub(r.mul(r)));return Ct(r,u)}),Jre=[RB,NB,DB,PB];let lS;const mv=new TE;class LB extends kre{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s}){const a=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:n,shadowCoord:r,shadow:s});return a.select(l,_e(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,s=ji("bias","float",n).setGroup(Rn);let a=t,l;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),l=a.z,r.coordinateSystem===pu&&(l=l.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const h=ji("near","float",n.camera).setGroup(Rn),m=ji("far","float",n.camera).setGroup(Rn);l=dE(u.negate(),h,m)}return a=Be(a.x,a.y.oneMinus(),l.add(s)),a}getShadowFilterFn(e){return Jre[e]}setupShadow(e){const{renderer:t}=e,{light:n,shadow:r}=this,s=t.shadowMap.type,a=new qc(r.mapSize.width,r.mapSize.height);a.compareFunction=my;const l=e.createRenderTarget(r.mapSize.width,r.mapSize.height);if(l.depthTexture=a,r.camera.updateProjectionMatrix(),s===xo){a.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:lA,type:Gs}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:lA,type:Gs});const E=Ai(a),B=Ai(this.vsmShadowMapVertical.texture),L=ji("blurSamples","float",r).setGroup(Rn),O=ji("radius","float",r).setGroup(Rn),G=ji("mapSize","vec2",r).setGroup(Rn);let q=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Vr);q.fragmentNode=Kre({samples:L,radius:O,size:G,shadowPass:E}).context(e.getSharedContext()),q.name="VSMVertical",q=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Vr),q.fragmentNode=Zre({samples:L,radius:O,size:G,shadowPass:B}).context(e.getSharedContext()),q.name="VSMHorizontal"}const u=ji("intensity","float",r).setGroup(Rn),h=ji("normalBias","float",r).setGroup(Rn),m=RE(n).mul(LE.add(Hy.mul(h))),v=this.setupShadowCoord(e,m),x=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(x===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const S=s===xo?this.vsmShadowMapHorizontal.texture:a,w=this.setupShadowFilter(e,{filterFn:x,shadowTexture:l.texture,depthTexture:S,shadowCoord:v,shadow:r}),R=Ai(l.texture,v),C=Fi(1,w.rgb.mix(R,1),u.mul(R.a)).toVar();return this.shadowMap=l,this.shadow.map=l,C}setup(e){if(e.renderer.shadowMap.enabled!==!1)return je(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height),s.render(a,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:s,scene:a,camera:l}=e,u=s.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h,r.camera.layers.mask=l.layers.mask;const m=s.getRenderObjectFunction(),v=s.getMRT(),x=v?v.has("velocity"):!1;lS=Wre(s,a,lS),a.overrideMaterial=Qre(n),s.setRenderObjectFunction((S,w,R,C,E,B,...L)=>{(S.castShadow===!0||S.receiveShadow&&u===xo)&&(x&&(FP(S).useVelocity=!0),S.onBeforeShadow(s,S,l,r.camera,C,w.overrideMaterial,B),s.renderObject(S,w,R,C,E,B,...L),S.onAfterShadow(s,S,l,r.camera,C,w.overrideMaterial,B))}),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(m),n.isPointLight!==!0&&u===xo&&this.vsmPass(s),$re(s,a,lS)}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),mv.material=this.vsmMaterialVertical,mv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),mv.material=this.vsmMaterialHorizontal,mv.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const UB=(i,e)=>_t(new LB(i,e));class xA extends K0{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new an,this.colorNode=e&&e.colorNode||gn(this.color).setGroup(Rn),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=jn.FRAME}customCacheKey(){return EM(this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return UB(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let s;r!==void 0?s=_t(r):s=this.setupShadowNode(e),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const UE=je(i=>{const{lightDistance:e,cutoffDistance:t,decayExponent:n}=i,r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),ese=new an,Xl=je(([i,e])=>{const t=i.toVar(),n=ur(t),r=Dl(1,qr(n.x,qr(n.y,n.z)));n.mulAssign(r),t.mulAssign(r.mul(e.mul(2).oneMinus()));const s=Ct(t.xy).toVar(),l=e.mul(1.5).oneMinus();return ti(n.z.greaterThanEqual(l),()=>{ti(t.z.greaterThan(0),()=>{s.x.assign(wi(4,t.x))})}).ElseIf(n.x.greaterThanEqual(l),()=>{const u=Cg(t.x);s.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(l),()=>{const u=Cg(t.y);s.x.assign(t.x.add(u.mul(2)).add(2)),s.y.assign(t.z.mul(u).sub(2))}),Ct(.125,.25).mul(s).add(Ct(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),tse=je(({depthTexture:i,bd3D:e,dp:t,texelSize:n})=>Ai(i,Xl(e,n.y)).compare(t)),nse=je(({depthTexture:i,bd3D:e,dp:t,texelSize:n,shadow:r})=>{const s=ji("radius","float",r).setGroup(Rn),a=Ct(-1,1).mul(s).mul(n.y);return Ai(i,Xl(e.add(a.xyy),n.y)).compare(t).add(Ai(i,Xl(e.add(a.yyy),n.y)).compare(t)).add(Ai(i,Xl(e.add(a.xyx),n.y)).compare(t)).add(Ai(i,Xl(e.add(a.yyx),n.y)).compare(t)).add(Ai(i,Xl(e,n.y)).compare(t)).add(Ai(i,Xl(e.add(a.xxy),n.y)).compare(t)).add(Ai(i,Xl(e.add(a.yxy),n.y)).compare(t)).add(Ai(i,Xl(e.add(a.xxx),n.y)).compare(t)).add(Ai(i,Xl(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),ise=je(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),s=r.length(),a=gn("float").setGroup(Rn).onRenderUpdate(()=>n.camera.near),l=gn("float").setGroup(Rn).onRenderUpdate(()=>n.camera.far),u=ji("bias","float",n).setGroup(Rn),h=gn(n.mapSize).setGroup(Rn),m=_e(1).toVar();return ti(s.sub(l).lessThanEqual(0).and(s.sub(a).greaterThanEqual(0)),()=>{const v=s.sub(a).div(l.sub(a)).toVar();v.addAssign(u);const x=r.normalize(),S=Ct(1).div(h.mul(Ct(4,2)));m.assign(i({depthTexture:e,bd3D:x,dp:v,texelSize:S,shadow:n}))}),m}),uN=new Ln,Nd=new gt,Am=new gt;class rse extends LB{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===BF?tse:nse}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a}){return ise({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e,l=t.getFrameExtents();Am.copy(t.mapSize),Am.multiply(l),n.setSize(Am.width,Am.height),Nd.copy(t.mapSize);const u=s.autoClear,h=s.getClearColor(ese),m=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha),s.clear();const v=t.getViewportCount();for(let x=0;x_t(new rse(i,e)),BB=je(({color:i,lightViewPosition:e,cutoffDistance:t,decayExponent:n},r)=>{const s=r.context.lightingModel,a=e.sub(Xr),l=a.normalize(),u=a.length(),h=UE({lightDistance:u,cutoffDistance:t,decayExponent:n}),m=i.mul(h),v=r.context.reflectedLight;s.direct({lightDirection:l,lightColor:m,reflectedLight:v},r.stack,r)});class ase extends xA{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=gn(0).setGroup(Rn),this.decayExponentNode=gn(2).setGroup(Rn)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return sse(this.light)}setup(e){super.setup(e),BB({color:this.colorNode,lightViewPosition:Jy(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const ose=je(([i=Er()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),zm=je(([i,e,t])=>{const n=_e(t).toVar(),r=_e(e).toVar(),s=Ic(i).toVar();return zs(s,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ry=je(([i,e])=>{const t=Ic(e).toVar(),n=_e(i).toVar();return zs(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Yr=je(([i])=>{const e=_e(i).toVar();return Ee(hu(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),_r=je(([i,e])=>{const t=_e(i).toVar();return e.assign(Yr(t)),t.sub(_e(e))}),lse=je(([i,e,t,n,r,s])=>{const a=_e(s).toVar(),l=_e(r).toVar(),u=_e(n).toVar(),h=_e(t).toVar(),m=_e(e).toVar(),v=_e(i).toVar(),x=_e(wi(1,l)).toVar();return wi(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),use=je(([i,e,t,n,r,s])=>{const a=_e(s).toVar(),l=_e(r).toVar(),u=Be(n).toVar(),h=Be(t).toVar(),m=Be(e).toVar(),v=Be(i).toVar(),x=_e(wi(1,l)).toVar();return wi(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),OB=Vs([lse,use]),cse=je(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=_e(m).toVar(),x=_e(h).toVar(),S=_e(u).toVar(),w=_e(l).toVar(),R=_e(a).toVar(),C=_e(s).toVar(),E=_e(r).toVar(),B=_e(n).toVar(),L=_e(t).toVar(),O=_e(e).toVar(),G=_e(i).toVar(),q=_e(wi(1,S)).toVar(),z=_e(wi(1,x)).toVar();return _e(wi(1,v)).toVar().mul(z.mul(G.mul(q).add(O.mul(S))).add(x.mul(L.mul(q).add(B.mul(S))))).add(v.mul(z.mul(E.mul(q).add(C.mul(S))).add(x.mul(R.mul(q).add(w.mul(S))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),hse=je(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=_e(m).toVar(),x=_e(h).toVar(),S=_e(u).toVar(),w=Be(l).toVar(),R=Be(a).toVar(),C=Be(s).toVar(),E=Be(r).toVar(),B=Be(n).toVar(),L=Be(t).toVar(),O=Be(e).toVar(),G=Be(i).toVar(),q=_e(wi(1,S)).toVar(),z=_e(wi(1,x)).toVar();return _e(wi(1,v)).toVar().mul(z.mul(G.mul(q).add(O.mul(S))).add(x.mul(L.mul(q).add(B.mul(S))))).add(v.mul(z.mul(E.mul(q).add(C.mul(S))).add(x.mul(R.mul(q).add(w.mul(S))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),IB=Vs([cse,hse]),fse=je(([i,e,t])=>{const n=_e(t).toVar(),r=_e(e).toVar(),s=Zt(i).toVar(),a=Zt(s.bitAnd(Zt(7))).toVar(),l=_e(zm(a.lessThan(Zt(4)),r,n)).toVar(),u=_e(Wn(2,zm(a.lessThan(Zt(4)),n,r))).toVar();return ry(l,Ic(a.bitAnd(Zt(1)))).add(ry(u,Ic(a.bitAnd(Zt(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),Ase=je(([i,e,t,n])=>{const r=_e(n).toVar(),s=_e(t).toVar(),a=_e(e).toVar(),l=Zt(i).toVar(),u=Zt(l.bitAnd(Zt(15))).toVar(),h=_e(zm(u.lessThan(Zt(8)),a,s)).toVar(),m=_e(zm(u.lessThan(Zt(4)),s,zm(u.equal(Zt(12)).or(u.equal(Zt(14))),a,r))).toVar();return ry(h,Ic(u.bitAnd(Zt(1)))).add(ry(m,Ic(u.bitAnd(Zt(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Rs=Vs([fse,Ase]),dse=je(([i,e,t])=>{const n=_e(t).toVar(),r=_e(e).toVar(),s=Y0(i).toVar();return Be(Rs(s.x,r,n),Rs(s.y,r,n),Rs(s.z,r,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),pse=je(([i,e,t,n])=>{const r=_e(n).toVar(),s=_e(t).toVar(),a=_e(e).toVar(),l=Y0(i).toVar();return Be(Rs(l.x,a,s,r),Rs(l.y,a,s,r),Rs(l.z,a,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Ho=Vs([dse,pse]),mse=je(([i])=>{const e=_e(i).toVar();return Wn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),gse=je(([i])=>{const e=_e(i).toVar();return Wn(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),vse=je(([i])=>{const e=Be(i).toVar();return Wn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),FB=Vs([mse,vse]),_se=je(([i])=>{const e=Be(i).toVar();return Wn(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),kB=Vs([gse,_se]),To=je(([i,e])=>{const t=Ee(e).toVar(),n=Zt(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(Ee(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),zB=je(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(To(t,Ee(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(To(i,Ee(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(To(e,Ee(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(To(t,Ee(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(To(i,Ee(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(To(e,Ee(4))),e.addAssign(i)}),n1=je(([i,e,t])=>{const n=Zt(t).toVar(),r=Zt(e).toVar(),s=Zt(i).toVar();return n.bitXorAssign(r),n.subAssign(To(r,Ee(14))),s.bitXorAssign(n),s.subAssign(To(n,Ee(11))),r.bitXorAssign(s),r.subAssign(To(s,Ee(25))),n.bitXorAssign(r),n.subAssign(To(r,Ee(16))),s.bitXorAssign(n),s.subAssign(To(n,Ee(4))),r.bitXorAssign(s),r.subAssign(To(s,Ee(14))),n.bitXorAssign(r),n.subAssign(To(r,Ee(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),oa=je(([i])=>{const e=Zt(i).toVar();return _e(e).div(_e(Zt(Ee(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),fu=je(([i])=>{const e=_e(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),yse=je(([i])=>{const e=Ee(i).toVar(),t=Zt(Zt(1)).toVar(),n=Zt(Zt(Ee(3735928559)).add(t.shiftLeft(Zt(2))).add(Zt(13))).toVar();return n1(n.add(Zt(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),xse=je(([i,e])=>{const t=Ee(e).toVar(),n=Ee(i).toVar(),r=Zt(Zt(2)).toVar(),s=Zt().toVar(),a=Zt().toVar(),l=Zt().toVar();return s.assign(a.assign(l.assign(Zt(Ee(3735928559)).add(r.shiftLeft(Zt(2))).add(Zt(13))))),s.addAssign(Zt(n)),a.addAssign(Zt(t)),n1(s,a,l)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),bse=je(([i,e,t])=>{const n=Ee(t).toVar(),r=Ee(e).toVar(),s=Ee(i).toVar(),a=Zt(Zt(3)).toVar(),l=Zt().toVar(),u=Zt().toVar(),h=Zt().toVar();return l.assign(u.assign(h.assign(Zt(Ee(3735928559)).add(a.shiftLeft(Zt(2))).add(Zt(13))))),l.addAssign(Zt(s)),u.addAssign(Zt(r)),h.addAssign(Zt(n)),n1(l,u,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Sse=je(([i,e,t,n])=>{const r=Ee(n).toVar(),s=Ee(t).toVar(),a=Ee(e).toVar(),l=Ee(i).toVar(),u=Zt(Zt(4)).toVar(),h=Zt().toVar(),m=Zt().toVar(),v=Zt().toVar();return h.assign(m.assign(v.assign(Zt(Ee(3735928559)).add(u.shiftLeft(Zt(2))).add(Zt(13))))),h.addAssign(Zt(l)),m.addAssign(Zt(a)),v.addAssign(Zt(s)),zB(h,m,v),h.addAssign(Zt(r)),n1(h,m,v)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Tse=je(([i,e,t,n,r])=>{const s=Ee(r).toVar(),a=Ee(n).toVar(),l=Ee(t).toVar(),u=Ee(e).toVar(),h=Ee(i).toVar(),m=Zt(Zt(5)).toVar(),v=Zt().toVar(),x=Zt().toVar(),S=Zt().toVar();return v.assign(x.assign(S.assign(Zt(Ee(3735928559)).add(m.shiftLeft(Zt(2))).add(Zt(13))))),v.addAssign(Zt(h)),x.addAssign(Zt(u)),S.addAssign(Zt(l)),zB(v,x,S),v.addAssign(Zt(a)),x.addAssign(Zt(s)),n1(v,x,S)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Wi=Vs([yse,xse,bse,Sse,Tse]),wse=je(([i,e])=>{const t=Ee(e).toVar(),n=Ee(i).toVar(),r=Zt(Wi(n,t)).toVar(),s=Y0().toVar();return s.x.assign(r.bitAnd(Ee(255))),s.y.assign(r.shiftRight(Ee(8)).bitAnd(Ee(255))),s.z.assign(r.shiftRight(Ee(16)).bitAnd(Ee(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Mse=je(([i,e,t])=>{const n=Ee(t).toVar(),r=Ee(e).toVar(),s=Ee(i).toVar(),a=Zt(Wi(s,r,n)).toVar(),l=Y0().toVar();return l.x.assign(a.bitAnd(Ee(255))),l.y.assign(a.shiftRight(Ee(8)).bitAnd(Ee(255))),l.z.assign(a.shiftRight(Ee(16)).bitAnd(Ee(255))),l}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),jo=Vs([wse,Mse]),Ese=je(([i])=>{const e=Ct(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=_e(_r(e.x,t)).toVar(),s=_e(_r(e.y,n)).toVar(),a=_e(fu(r)).toVar(),l=_e(fu(s)).toVar(),u=_e(OB(Rs(Wi(t,n),r,s),Rs(Wi(t.add(Ee(1)),n),r.sub(1),s),Rs(Wi(t,n.add(Ee(1))),r,s.sub(1)),Rs(Wi(t.add(Ee(1)),n.add(Ee(1))),r.sub(1),s.sub(1)),a,l)).toVar();return FB(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Cse=je(([i])=>{const e=Be(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=Ee().toVar(),s=_e(_r(e.x,t)).toVar(),a=_e(_r(e.y,n)).toVar(),l=_e(_r(e.z,r)).toVar(),u=_e(fu(s)).toVar(),h=_e(fu(a)).toVar(),m=_e(fu(l)).toVar(),v=_e(IB(Rs(Wi(t,n,r),s,a,l),Rs(Wi(t.add(Ee(1)),n,r),s.sub(1),a,l),Rs(Wi(t,n.add(Ee(1)),r),s,a.sub(1),l),Rs(Wi(t.add(Ee(1)),n.add(Ee(1)),r),s.sub(1),a.sub(1),l),Rs(Wi(t,n,r.add(Ee(1))),s,a,l.sub(1)),Rs(Wi(t.add(Ee(1)),n,r.add(Ee(1))),s.sub(1),a,l.sub(1)),Rs(Wi(t,n.add(Ee(1)),r.add(Ee(1))),s,a.sub(1),l.sub(1)),Rs(Wi(t.add(Ee(1)),n.add(Ee(1)),r.add(Ee(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return kB(v)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),BE=Vs([Ese,Cse]),Rse=je(([i])=>{const e=Ct(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=_e(_r(e.x,t)).toVar(),s=_e(_r(e.y,n)).toVar(),a=_e(fu(r)).toVar(),l=_e(fu(s)).toVar(),u=Be(OB(Ho(jo(t,n),r,s),Ho(jo(t.add(Ee(1)),n),r.sub(1),s),Ho(jo(t,n.add(Ee(1))),r,s.sub(1)),Ho(jo(t.add(Ee(1)),n.add(Ee(1))),r.sub(1),s.sub(1)),a,l)).toVar();return FB(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Nse=je(([i])=>{const e=Be(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=Ee().toVar(),s=_e(_r(e.x,t)).toVar(),a=_e(_r(e.y,n)).toVar(),l=_e(_r(e.z,r)).toVar(),u=_e(fu(s)).toVar(),h=_e(fu(a)).toVar(),m=_e(fu(l)).toVar(),v=Be(IB(Ho(jo(t,n,r),s,a,l),Ho(jo(t.add(Ee(1)),n,r),s.sub(1),a,l),Ho(jo(t,n.add(Ee(1)),r),s,a.sub(1),l),Ho(jo(t.add(Ee(1)),n.add(Ee(1)),r),s.sub(1),a.sub(1),l),Ho(jo(t,n,r.add(Ee(1))),s,a,l.sub(1)),Ho(jo(t.add(Ee(1)),n,r.add(Ee(1))),s.sub(1),a,l.sub(1)),Ho(jo(t,n.add(Ee(1)),r.add(Ee(1))),s,a.sub(1),l.sub(1)),Ho(jo(t.add(Ee(1)),n.add(Ee(1)),r.add(Ee(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return kB(v)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),OE=Vs([Rse,Nse]),Dse=je(([i])=>{const e=_e(i).toVar(),t=Ee(Yr(e)).toVar();return oa(Wi(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Pse=je(([i])=>{const e=Ct(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar();return oa(Wi(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Lse=je(([i])=>{const e=Be(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar();return oa(Wi(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Use=je(([i])=>{const e=dn(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar(),s=Ee(Yr(e.w)).toVar();return oa(Wi(t,n,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),Bse=Vs([Dse,Pse,Lse,Use]),Ose=je(([i])=>{const e=_e(i).toVar(),t=Ee(Yr(e)).toVar();return Be(oa(Wi(t,Ee(0))),oa(Wi(t,Ee(1))),oa(Wi(t,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Ise=je(([i])=>{const e=Ct(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar();return Be(oa(Wi(t,n,Ee(0))),oa(Wi(t,n,Ee(1))),oa(Wi(t,n,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Fse=je(([i])=>{const e=Be(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar();return Be(oa(Wi(t,n,r,Ee(0))),oa(Wi(t,n,r,Ee(1))),oa(Wi(t,n,r,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),kse=je(([i])=>{const e=dn(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar(),s=Ee(Yr(e.w)).toVar();return Be(oa(Wi(t,n,r,s,Ee(0))),oa(Wi(t,n,r,s,Ee(1))),oa(Wi(t,n,r,s,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),GB=Vs([Ose,Ise,Fse,kse]),sy=je(([i,e,t,n])=>{const r=_e(n).toVar(),s=_e(t).toVar(),a=Ee(e).toVar(),l=Be(i).toVar(),u=_e(0).toVar(),h=_e(1).toVar();return ki(a,()=>{u.addAssign(h.mul(BE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),qB=je(([i,e,t,n])=>{const r=_e(n).toVar(),s=_e(t).toVar(),a=Ee(e).toVar(),l=Be(i).toVar(),u=Be(0).toVar(),h=_e(1).toVar();return ki(a,()=>{u.addAssign(h.mul(OE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),zse=je(([i,e,t,n])=>{const r=_e(n).toVar(),s=_e(t).toVar(),a=Ee(e).toVar(),l=Be(i).toVar();return Ct(sy(l,a,s,r),sy(l.add(Be(Ee(19),Ee(193),Ee(17))),a,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Gse=je(([i,e,t,n])=>{const r=_e(n).toVar(),s=_e(t).toVar(),a=Ee(e).toVar(),l=Be(i).toVar(),u=Be(qB(l,a,s,r)).toVar(),h=_e(sy(l.add(Be(Ee(19),Ee(193),Ee(17))),a,s,r)).toVar();return dn(u,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),qse=je(([i,e,t,n,r,s,a])=>{const l=Ee(a).toVar(),u=_e(s).toVar(),h=Ee(r).toVar(),m=Ee(n).toVar(),v=Ee(t).toVar(),x=Ee(e).toVar(),S=Ct(i).toVar(),w=Be(GB(Ct(x.add(m),v.add(h)))).toVar(),R=Ct(w.x,w.y).toVar();R.subAssign(.5),R.mulAssign(u),R.addAssign(.5);const C=Ct(Ct(_e(x),_e(v)).add(R)).toVar(),E=Ct(C.sub(S)).toVar();return ti(l.equal(Ee(2)),()=>ur(E.x).add(ur(E.y))),ti(l.equal(Ee(3)),()=>qr(ur(E.x),ur(E.y))),Xh(E,E)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Vse=je(([i,e,t,n,r,s,a,l,u])=>{const h=Ee(u).toVar(),m=_e(l).toVar(),v=Ee(a).toVar(),x=Ee(s).toVar(),S=Ee(r).toVar(),w=Ee(n).toVar(),R=Ee(t).toVar(),C=Ee(e).toVar(),E=Be(i).toVar(),B=Be(GB(Be(C.add(S),R.add(x),w.add(v)))).toVar();B.subAssign(.5),B.mulAssign(m),B.addAssign(.5);const L=Be(Be(_e(C),_e(R),_e(w)).add(B)).toVar(),O=Be(L.sub(E)).toVar();return ti(h.equal(Ee(2)),()=>ur(O.x).add(ur(O.y)).add(ur(O.z))),ti(h.equal(Ee(3)),()=>qr(qr(ur(O.x),ur(O.y)),ur(O.z))),Xh(O,O)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Z0=Vs([qse,Vse]),Hse=je(([i,e,t])=>{const n=Ee(t).toVar(),r=_e(e).toVar(),s=Ct(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ct(_r(s.x,a),_r(s.y,l)).toVar(),h=_e(1e6).toVar();return ki({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{ki({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=_e(Z0(u,m,v,a,l,r,n)).toVar();h.assign(to(h,x))})}),ti(n.equal(Ee(0)),()=>{h.assign(Cu(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),jse=je(([i,e,t])=>{const n=Ee(t).toVar(),r=_e(e).toVar(),s=Ct(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ct(_r(s.x,a),_r(s.y,l)).toVar(),h=Ct(1e6,1e6).toVar();return ki({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{ki({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=_e(Z0(u,m,v,a,l,r,n)).toVar();ti(x.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.y.assign(x)})})}),ti(n.equal(Ee(0)),()=>{h.assign(Cu(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Wse=je(([i,e,t])=>{const n=Ee(t).toVar(),r=_e(e).toVar(),s=Ct(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ct(_r(s.x,a),_r(s.y,l)).toVar(),h=Be(1e6,1e6,1e6).toVar();return ki({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{ki({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=_e(Z0(u,m,v,a,l,r,n)).toVar();ti(x.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(x)}).ElseIf(x.lessThan(h.z),()=>{h.z.assign(x)})})}),ti(n.equal(Ee(0)),()=>{h.assign(Cu(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$se=je(([i,e,t])=>{const n=Ee(t).toVar(),r=_e(e).toVar(),s=Be(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Be(_r(s.x,a),_r(s.y,l),_r(s.z,u)).toVar(),m=_e(1e6).toVar();return ki({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{ki({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{ki({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const w=_e(Z0(h,v,x,S,a,l,u,r,n)).toVar();m.assign(to(m,w))})})}),ti(n.equal(Ee(0)),()=>{m.assign(Cu(m))}),m}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Xse=Vs([Hse,$se]),Yse=je(([i,e,t])=>{const n=Ee(t).toVar(),r=_e(e).toVar(),s=Be(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Be(_r(s.x,a),_r(s.y,l),_r(s.z,u)).toVar(),m=Ct(1e6,1e6).toVar();return ki({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{ki({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{ki({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const w=_e(Z0(h,v,x,S,a,l,u,r,n)).toVar();ti(w.lessThan(m.x),()=>{m.y.assign(m.x),m.x.assign(w)}).ElseIf(w.lessThan(m.y),()=>{m.y.assign(w)})})})}),ti(n.equal(Ee(0)),()=>{m.assign(Cu(m))}),m}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Qse=Vs([jse,Yse]),Kse=je(([i,e,t])=>{const n=Ee(t).toVar(),r=_e(e).toVar(),s=Be(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Be(_r(s.x,a),_r(s.y,l),_r(s.z,u)).toVar(),m=Be(1e6,1e6,1e6).toVar();return ki({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{ki({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{ki({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const w=_e(Z0(h,v,x,S,a,l,u,r,n)).toVar();ti(w.lessThan(m.x),()=>{m.z.assign(m.y),m.y.assign(m.x),m.x.assign(w)}).ElseIf(w.lessThan(m.y),()=>{m.z.assign(m.y),m.y.assign(w)}).ElseIf(w.lessThan(m.z),()=>{m.z.assign(w)})})})}),ti(n.equal(Ee(0)),()=>{m.assign(Cu(m))}),m}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Zse=Vs([Wse,Kse]),Jse=je(([i])=>{const e=i.y,t=i.z,n=Be().toVar();return ti(e.lessThan(1e-4),()=>{n.assign(Be(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(hu(r)).mul(6).toVar();const s=Ee(QM(r)),a=r.sub(_e(s)),l=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),h=t.mul(e.mul(a.oneMinus()).oneMinus());ti(s.equal(Ee(0)),()=>{n.assign(Be(t,h,l))}).ElseIf(s.equal(Ee(1)),()=>{n.assign(Be(u,t,l))}).ElseIf(s.equal(Ee(2)),()=>{n.assign(Be(l,t,h))}).ElseIf(s.equal(Ee(3)),()=>{n.assign(Be(l,u,t))}).ElseIf(s.equal(Ee(4)),()=>{n.assign(Be(h,l,t))}).Else(()=>{n.assign(Be(t,l,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),eae=je(([i])=>{const e=Be(i).toVar(),t=_e(e.x).toVar(),n=_e(e.y).toVar(),r=_e(e.z).toVar(),s=_e(to(t,to(n,r))).toVar(),a=_e(qr(t,qr(n,r))).toVar(),l=_e(a.sub(s)).toVar(),u=_e().toVar(),h=_e().toVar(),m=_e().toVar();return m.assign(a),ti(a.greaterThan(0),()=>{h.assign(l.div(a))}).Else(()=>{h.assign(0)}),ti(h.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{ti(t.greaterThanEqual(a),()=>{u.assign(n.sub(r).div(l))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(Qr(2,r.sub(t).div(l)))}).Else(()=>{u.assign(Qr(4,t.sub(n).div(l)))}),u.mulAssign(1/6),ti(u.lessThan(0),()=>{u.addAssign(1)})}),Be(u,h,m)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),tae=je(([i])=>{const e=Be(i).toVar(),t=LM(VM(e,Be(.04045))).toVar(),n=Be(e.div(12.92)).toVar(),r=Be(Cl(qr(e.add(Be(.055)),Be(0)).div(1.055),Be(2.4))).toVar();return Fi(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),VB=(i,e)=>{i=_e(i),e=_e(e);const t=Ct(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return kc(i.sub(t),i.add(t),e)},HB=(i,e,t,n)=>Fi(i,e,t[n].clamp()),nae=(i,e,t=Er())=>HB(i,e,t,"x"),iae=(i,e,t=Er())=>HB(i,e,t,"y"),jB=(i,e,t,n,r)=>Fi(i,e,VB(t,n[r])),rae=(i,e,t,n=Er())=>jB(i,e,t,n,"x"),sae=(i,e,t,n=Er())=>jB(i,e,t,n,"y"),aae=(i=1,e=0,t=Er())=>t.mul(i).add(e),oae=(i,e=1)=>(i=_e(i),i.abs().pow(e).mul(i.sign())),lae=(i,e=1,t=.5)=>_e(i).sub(t).mul(e).add(t),uae=(i=Er(),e=1,t=0)=>BE(i.convert("vec2|vec3")).mul(e).add(t),cae=(i=Er(),e=1,t=0)=>OE(i.convert("vec2|vec3")).mul(e).add(t),hae=(i=Er(),e=1,t=0)=>(i=i.convert("vec2|vec3"),dn(OE(i),BE(i.add(Ct(19,73)))).mul(e).add(t)),fae=(i=Er(),e=1)=>Xse(i.convert("vec2|vec3"),e,Ee(1)),Aae=(i=Er(),e=1)=>Qse(i.convert("vec2|vec3"),e,Ee(1)),dae=(i=Er(),e=1)=>Zse(i.convert("vec2|vec3"),e,Ee(1)),pae=(i=Er())=>Bse(i.convert("vec2|vec3")),mae=(i=Er(),e=3,t=2,n=.5,r=1)=>sy(i,Ee(e),t,n).mul(r),gae=(i=Er(),e=3,t=2,n=.5,r=1)=>zse(i,Ee(e),t,n).mul(r),vae=(i=Er(),e=3,t=2,n=.5,r=1)=>qB(i,Ee(e),t,n).mul(r),_ae=(i=Er(),e=3,t=2,n=.5,r=1)=>Gse(i,Ee(e),t,n).mul(r),yae=je(([i,e,t])=>{const n=Fc(i).toVar("nDir"),r=wi(_e(.5).mul(e.sub(t)),Nc).div(n).toVar("rbmax"),s=wi(_e(-.5).mul(e.sub(t)),Nc).div(n).toVar("rbmin"),a=Be().toVar("rbminmax");a.x=n.x.greaterThan(_e(0)).select(r.x,s.x),a.y=n.y.greaterThan(_e(0)).select(r.y,s.y),a.z=n.z.greaterThan(_e(0)).select(r.z,s.z);const l=to(to(a.x,a.y),a.z).toVar("correction");return Nc.add(n.mul(l)).toVar("boxIntersection").sub(t)}),WB=je(([i,e])=>{const t=i.x,n=i.y,r=i.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(Wn(t,t).sub(Wn(n,n)))),s});var W=Object.freeze({__proto__:null,BRDF_GGX:XT,BRDF_Lambert:AA,BasicShadowFilter:RB,Break:wU,Continue:bee,DFGApprox:_E,D_GGX:zU,Discard:_9,EPSILON:wL,F_Schlick:F0,Fn:je,INFINITY:AJ,If:ti,Loop:ki,NodeAccess:sa,NodeShaderStage:IT,NodeType:VZ,NodeUpdateType:jn,PCFShadowFilter:NB,PCFSoftShadowFilter:DB,PI:Z_,PI2:dJ,Return:RJ,Schlick_to_F0:qU,ScriptableNodeResources:i_,ShaderNode:Um,TBNViewMatrix:Yf,VSMShadowFilter:PB,V_GGX_SmithCorrelated:kU,abs:ur,acesFilmicToneMapping:yB,acos:DL,add:Qr,addMethodChaining:ut,addNodeElement:DJ,agxToneMapping:xB,all:HM,alphaT:Y_,and:dL,anisotropy:Rh,anisotropyB:iA,anisotropyT:Bm,any:ML,append:$P,arrayBuffer:lJ,asin:NL,assign:oL,atan:$M,atan2:KL,atomicAdd:Rre,atomicAnd:Lre,atomicFunc:jc,atomicMax:Dre,atomicMin:Pre,atomicOr:Ure,atomicStore:Cre,atomicSub:Nre,atomicXor:Bre,attenuationColor:zM,attenuationDistance:kM,attribute:_u,attributeArray:bie,backgroundBlurriness:lB,backgroundIntensity:ew,backgroundRotation:uB,batch:bU,billboarding:tie,bitAnd:vL,bitNot:_L,bitOr:yL,bitXor:xL,bitangentGeometry:nee,bitangentLocal:iee,bitangentView:I9,bitangentWorld:ree,bitcast:pJ,blendBurn:fB,blendColor:Uie,blendDodge:AB,blendOverlay:pB,blendScreen:dB,blur:YU,bool:Ic,buffer:Yg,bufferAttribute:$g,bumpMap:G9,burn:Bie,bvec2:QP,bvec3:LM,bvec4:eL,bypass:p9,cache:Im,call:lL,cameraFar:Ph,cameraNear:Dh,cameraNormalMatrix:IJ,cameraPosition:S9,cameraProjectionMatrix:_A,cameraProjectionMatrixInverse:BJ,cameraViewMatrix:so,cameraWorldMatrix:OJ,cbrt:jL,cdl:Vie,ceil:Iy,checker:ose,cineonToneMapping:_B,clamp:vu,clearcoat:X_,clearcoatRoughness:wg,code:Ky,color:XP,colorSpaceToWorking:nE,colorToDirection:Kee,compute:d9,cond:ZL,context:zy,convert:nL,convertColorSpace:yJ,convertToTexture:die,cos:yc,cross:ky,cubeTexture:I0,dFdx:XM,dFdy:YM,dashSize:Qv,defaultBuildStages:FT,defaultShaderStages:GP,defined:xg,degrees:CL,deltaTime:sB,densityFog:fre,densityFogFactor:EE,depth:pE,depthPass:Yie,difference:GL,diffuseColor:Ui,directPointLight:BB,directionToColor:PU,dispersion:GM,distance:zL,div:Dl,dodge:Oie,dot:Xh,drawIndex:_U,dynamicBufferAttribute:A9,element:tL,emissive:qT,equal:uL,equals:FL,equirectUV:mE,exp:jM,exp2:O0,expression:Hh,faceDirection:Xg,faceForward:eE,faceforward:mJ,float:_e,floor:hu,fog:Ng,fract:Hc,frameGroup:sL,frameId:jne,frontFacing:E9,fwidth:OL,gain:Fne,gapSize:VT,getConstNodeType:WP,getCurrentStack:PM,getDirection:$U,getDistanceAttenuation:UE,getGeometryRoughness:FU,getNormalFromDepth:mie,getParallaxCorrectNormal:yae,getRoughness:vE,getScreenPosition:pie,getShIrradianceAt:WB,getTextureIndex:iB,getViewPosition:zd,glsl:rre,glslFn:sre,grayscale:kie,greaterThan:VM,greaterThanEqual:AL,hash:Ine,highpModelNormalViewMatrix:XJ,highpModelViewMatrix:$J,hue:qie,instance:gee,instanceIndex:Jg,instancedArray:Sie,instancedBufferAttribute:J_,instancedDynamicBufferAttribute:HT,instancedMesh:xU,int:Ee,inverseSqrt:WM,inversesqrt:gJ,invocationLocalIndex:mee,invocationSubgroupIndex:pee,ior:Om,iridescence:By,iridescenceIOR:OM,iridescenceThickness:IM,ivec2:ms,ivec3:KP,ivec4:ZP,js:nre,label:e9,length:Rc,lengthSq:WL,lessThan:hL,lessThanEqual:fL,lightPosition:NE,lightProjectionUV:EB,lightShadowMatrix:RE,lightTargetDirection:DE,lightTargetPosition:CB,lightViewPosition:Jy,lightingContext:EU,lights:Fre,linearDepth:ty,linearToneMapping:gB,localId:vre,log:Oy,log2:cu,logarithmicDepthToViewZ:Oee,loop:See,luminance:wE,mat2:Ly,mat3:ha,mat4:nA,matcapUV:KU,materialAO:gU,materialAlphaTest:q9,materialAnisotropy:iU,materialAnisotropyVector:kd,materialAttenuationColor:hU,materialAttenuationDistance:cU,materialClearcoat:K9,materialClearcoatNormal:J9,materialClearcoatRoughness:Z9,materialColor:V9,materialDispersion:mU,materialEmissive:j9,materialIOR:uU,materialIridescence:rU,materialIridescenceIOR:sU,materialIridescenceThickness:aU,materialLightMap:lE,materialLineDashOffset:pU,materialLineDashSize:AU,materialLineGapSize:dU,materialLineScale:fU,materialLineWidth:fee,materialMetalness:Y9,materialNormal:Q9,materialOpacity:oE,materialPointWidth:Aee,materialReference:Tc,materialReflectivity:Jv,materialRefractionRatio:N9,materialRotation:eU,materialRoughness:X9,materialSheen:tU,materialSheenRoughness:nU,materialShininess:H9,materialSpecular:W9,materialSpecularColor:$9,materialSpecularIntensity:$T,materialSpecularStrength:Fm,materialThickness:lU,materialTransmission:oU,max:qr,maxMipLevel:b9,mediumpModelViewMatrix:M9,metalness:Tg,min:to,mix:Fi,mixElement:YL,mod:KM,modInt:qM,modelDirection:qJ,modelNormalMatrix:w9,modelPosition:VJ,modelScale:HJ,modelViewMatrix:Q0,modelViewPosition:jJ,modelViewProjection:uE,modelWorldMatrix:$o,modelWorldMatrixInverse:WJ,morphReference:MU,mrt:rB,mul:Wn,mx_aastep:VB,mx_cell_noise_float:pae,mx_contrast:lae,mx_fractal_noise_float:mae,mx_fractal_noise_vec2:gae,mx_fractal_noise_vec3:vae,mx_fractal_noise_vec4:_ae,mx_hsvtorgb:Jse,mx_noise_float:uae,mx_noise_vec3:cae,mx_noise_vec4:hae,mx_ramplr:nae,mx_ramptb:iae,mx_rgbtohsv:eae,mx_safepower:oae,mx_splitlr:rae,mx_splittb:sae,mx_srgb_texture_to_lin_rec709:tae,mx_transform_uv:aae,mx_worley_noise_float:fae,mx_worley_noise_vec2:Aae,mx_worley_noise_vec3:dae,negate:PL,neutralToneMapping:bB,nodeArray:tA,nodeImmutable:Wt,nodeObject:_t,nodeObjects:Vg,nodeProxy:ct,normalFlat:C9,normalGeometry:qy,normalLocal:no,normalMap:WT,normalView:Jo,normalWorld:Vy,normalize:Fc,not:mL,notEqual:cL,numWorkgroups:mre,objectDirection:FJ,objectGroup:BM,objectPosition:T9,objectScale:zJ,objectViewPosition:GJ,objectWorldMatrix:kJ,oneMinus:LL,or:pL,orthographicDepthToViewZ:Bee,oscSawtooth:Zne,oscSine:Yne,oscSquare:Qne,oscTriangle:Kne,output:Eg,outputStruct:Bne,overlay:Fie,overloadingFn:Vs,parabola:JT,parallaxDirection:k9,parallaxUV:aee,parameter:Lne,pass:$ie,passTexture:Xie,pcurve:kne,perspectiveDepthToViewZ:AE,pmremTexture:yE,pointUV:Eie,pointWidth:cJ,positionGeometry:Gy,positionLocal:Gr,positionPrevious:ey,positionView:Xr,positionViewDirection:dr,positionWorld:Nc,positionWorldDirection:iE,posterize:jie,pow:Cl,pow2:ZM,pow3:qL,pow4:VL,property:aL,radians:EL,rand:XL,range:dre,rangeFog:hre,rangeFogFactor:ME,reciprocal:BL,reference:ji,referenceBuffer:jT,reflect:kL,reflectVector:L9,reflectView:D9,reflector:uie,refract:JM,refractVector:U9,refractView:P9,reinhardToneMapping:vB,remainder:TL,remap:g9,remapClamp:v9,renderGroup:Rn,renderOutput:y9,rendererReference:c9,rotate:xE,rotateUV:Jne,roughness:Zl,round:UL,rtt:oB,sRGBTransferEOTF:r9,sRGBTransferOETF:s9,sampler:UJ,saturate:$L,saturation:zie,screen:Iie,screenCoordinate:e1,screenSize:Rg,screenUV:bu,scriptable:cre,scriptableValue:n_,select:zs,setCurrentStack:bg,shaderStages:kT,shadow:UB,shadowPositionWorld:LE,sharedUniformGroup:UM,sheen:Xf,sheenRoughness:Uy,shiftLeft:bL,shiftRight:SL,shininess:Q_,sign:Cg,sin:Mo,sinc:zne,skinning:yee,skinningReference:TU,smoothstep:kc,smoothstepElement:QL,specularColor:ka,specularF90:Mg,spherizeUV:eie,split:uJ,spritesheetUV:rie,sqrt:Cu,stack:e_,step:Fy,storage:Qy,storageBarrier:bre,storageObject:xie,storageTexture:cB,string:oJ,sub:wi,subgroupIndex:dee,subgroupSize:_re,tan:RL,tangentGeometry:Wy,tangentLocal:Qg,tangentView:Kg,tangentWorld:O9,temp:n9,texture:Ai,texture3D:lne,textureBarrier:Sre,textureBicubic:jU,textureCubeUV:XU,textureLoad:Fr,textureSize:Fh,textureStore:Rie,thickness:FM,time:yA,timerDelta:Xne,timerGlobal:$ne,timerLocal:Wne,toOutputColorSpace:a9,toWorkingColorSpace:o9,toneMapping:h9,toneMappingExposure:f9,toonOutlinePass:Kie,transformDirection:HL,transformNormal:R9,transformNormalToView:rE,transformedBentNormalView:z9,transformedBitangentView:F9,transformedBitangentWorld:see,transformedClearcoatNormalView:Qd,transformedNormalView:zr,transformedNormalWorld:Hy,transformedTangentView:aE,transformedTangentWorld:tee,transmission:K_,transpose:IL,triNoise3D:qne,triplanarTexture:aie,triplanarTextures:aB,trunc:QM,tslFn:aJ,uint:Zt,uniform:gn,uniformArray:Sc,uniformGroup:rL,uniforms:ZJ,userData:Die,uv:Er,uvec2:YP,uvec3:Y0,uvec4:JP,varying:ro,varyingProperty:Sg,vec2:Ct,vec3:Be,vec4:dn,vectorComponents:gA,velocity:Lie,vertexColor:wie,vertexIndex:vU,vertexStage:i9,vibrance:Gie,viewZToLogarithmicDepth:dE,viewZToOrthographicDepth:s0,viewZToPerspectiveDepth:NU,viewport:cE,viewportBottomLeft:Pee,viewportCoordinate:RU,viewportDepthTexture:fE,viewportLinearDepth:Iee,viewportMipTexture:hE,viewportResolution:Nee,viewportSafeUV:nie,viewportSharedTexture:Qee,viewportSize:CU,viewportTexture:Lee,viewportTopLeft:Dee,viewportUV:Ree,wgsl:ire,wgslFn:are,workgroupArray:Mre,workgroupBarrier:xre,workgroupId:gre,workingToColorSpace:l9,xor:gL});const vc=new bE;class xae extends Yh{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(s===null)r._clearColor.getRGB(vc,Ro),vc.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(vc,Ro),vc.a=1,a=!0;else if(s.isNode===!0){const l=this.get(e),u=s;vc.copy(r._clearColor);let h=l.backgroundMesh;if(h===void 0){const v=zy(dn(u).mul(ew),{getUV:()=>uB.mul(Vy),getTextureLevel:()=>lB});let x=uE;x=x.setZ(x.w);const S=new Vr;S.name="Background.material",S.side=hr,S.depthTest=!1,S.depthWrite=!1,S.fog=!1,S.lights=!1,S.vertexNode=x,S.colorNode=v,l.backgroundMeshNode=v,l.backgroundMesh=h=new zi(new Eu(1,32,32),S),h.frustumCulled=!1,h.name="Background.mesh",h.onBeforeRender=function(w,R,C){this.matrixWorld.copyPosition(C.matrixWorld)}}const m=u.getCacheKey();l.backgroundCacheKey!==m&&(l.backgroundMeshNode.node=dn(u).mul(ew),l.backgroundMeshNode.needsUpdate=!0,h.material.needsUpdate=!0,l.backgroundCacheKey=m),t.unshift(h,h.geometry,h.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",s);if(r.autoClear===!0||a===!0){const l=n.clearColorValue;l.r=vc.r,l.g=vc.g,l.b=vc.b,l.a=vc.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(l.r*=l.a,l.g*=l.a,l.b*=l.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let bae=0;class tw{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=bae++}}class Sae{constructor(e,t,n,r,s,a,l,u,h,m=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=m,this.nodeAttributes=r,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=l,this.updateAfterNodes=u,this.monitor=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new tw(t.name,[],t.index,t);e.push(r);for(const s of t.bindings)r.bindings.push(s.clone())}else e.push(t);return e}}class cN{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class Tae{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class $B{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class wae extends $B{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Mae{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Eae=0;class uS{constructor(e=null){this.id=Eae++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Cae extends Mn{static get type(){return"StructTypeNode"}constructor(e,t){super(),this.name=e,this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class bA{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class Rae extends bA{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Nae extends bA{constructor(e,t=new gt){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Dae extends bA{constructor(e,t=new he){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Pae extends bA{constructor(e,t=new Ln){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Lae extends bA{constructor(e,t=new an){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Uae extends bA{constructor(e,t=new Vn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class Bae extends bA{constructor(e,t=new kn){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class Oae extends Rae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Iae extends Nae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Fae extends Dae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class kae extends Pae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zae extends Lae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Gae extends Uae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qae extends Bae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const Kd=4,hN=[.125,.215,.35,.446,.526,.582],Gf=20,cS=new kg(-1,1,1,-1,0,1),Vae=new ya(90,1),fN=new an;let hS=null,fS=0,AS=0;const If=(1+Math.sqrt(5))/2,Dd=1/If,AN=[new he(-If,Dd,0),new he(If,Dd,0),new he(-Dd,0,If),new he(Dd,0,If),new he(0,If,-Dd),new he(0,If,Dd),new he(-1,1,-1),new he(1,1,-1),new he(-1,1,1),new he(1,1,1)],Hae=[3,1,5,0,4,2],dS=$U(Er(),_u("faceIndex")).normalize(),IE=Be(dS.x,dS.y,dS.z);class jae{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,s=null){if(this._setSize(256),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const l=s||this._allocateTargets();return this.fromSceneAsync(e,t,n,r,l),l}hS=this._renderer.getRenderTarget(),fS=this._renderer.getActiveCubeFace(),AS=this._renderer.getActiveMipmapLevel();const a=s||this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,n,r,a),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}async fromSceneAsync(e,t=0,n=.1,r=100,s=null){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=pN(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=mN(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Qo||e.mapping===Ko?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?R:0,R,R),u.render(e,s)}u.autoClear=h,e.background=x}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Qo||e.mapping===Ko;r?this._cubemapMaterial===null&&(this._cubemapMaterial=pN(e)):this._equirectMaterial===null&&(this._equirectMaterial=mN(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const l=this._cubeSize;gv(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,cS)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sGf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Gf}`);const E=[];let B=0;for(let z=0;zL-Kd?r-L+Kd:0),q=4*(this._cubeSize-O);gv(t,G,q,3*O,2*O),u.setRenderTarget(t),u.render(v,cS)}}function Wae(i){const e=[],t=[],n=[],r=[];let s=i;const a=i-Kd+1+hN.length;for(let l=0;li-Kd?h=hN[l-i+Kd-1]:l===0&&(h=0),n.push(h);const m=1/(u-2),v=-m,x=1+m,S=[v,v,x,v,x,x,v,v,x,x,v,x],w=6,R=6,C=3,E=2,B=1,L=new Float32Array(C*R*w),O=new Float32Array(E*R*w),G=new Float32Array(B*R*w);for(let z=0;z2?0:-1,V=[j,F,0,j+2/3,F,0,j+2/3,F+1,0,j,F,0,j+2/3,F+1,0,j,F+1,0],Y=Hae[z];L.set(V,C*R*Y),O.set(S,E*R*Y);const ee=[Y,Y,Y,Y,Y,Y];G.set(ee,B*R*Y)}const q=new Ki;q.setAttribute("position",new wr(L,C)),q.setAttribute("uv",new wr(O,E)),q.setAttribute("faceIndex",new wr(G,B)),e.push(q),r.push(new zi(q,null)),s>Kd&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:r}}function dN(i,e,t){const n=new Wh(i,e,t);return n.texture.mapping=sA,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function gv(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function FE(i){const e=new Vr;return e.depthTest=!1,e.depthWrite=!1,e.blending=Qa,e.name=`PMREM_${i}`,e}function $ae(i,e,t){const n=Sc(new Array(Gf).fill(0)),r=gn(new he(0,1,0)),s=gn(0),a=_e(Gf),l=gn(0),u=gn(1),h=Ai(null),m=gn(0),v=_e(1/e),x=_e(1/t),S=_e(i),w={n:a,latitudinal:l,weights:n,poleAxis:r,outputDirection:IE,dTheta:s,samples:u,envMap:h,mipInt:m,CUBEUV_TEXEL_WIDTH:v,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:S},R=FE("blur");return R.uniforms=w,R.fragmentNode=YU({...w,latitudinal:l.equal(1)}),R}function pN(i){const e=FE("cubemap");return e.fragmentNode=I0(i,IE),e}function mN(i){const e=FE("equirect");return e.fragmentNode=Ai(i,mE(IE),0),e}const gN=new WeakMap,Xae=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),vv=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class XB{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=e_(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new uS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=gN.get(this.renderer);return e===void 0&&(e=new Su,gN.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Wh(e,t,n)}createCubeRenderTarget(e,t){return new LU(e,t)}createPMREMGenerator(){return new jae(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let s=!0;for(const l of t)r.push(l),s=s&&l.groupNode.shared!==!0;let a;return s?(a=n.get(r),a===void 0&&(a=new tw(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new tw(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of kT)for(const s in n[r]){const a=n[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${vv(t.r)}, ${vv(t.g)}, ${vv(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const s of n)if(s.name===e)return s;const r=new cN(e,t);return n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Ns)return"int";if(t===Rr)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const n=UP(e);return(t==="float"?"":t[0])+n}getTypeFromArray(e){return Xae.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof G7)&&s!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=e_(this.stack),this.stacks.push(PM()||this.stack),bg(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,bg(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);return r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let r=n.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new cN("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e,n);let s=r.structType;if(s===void 0){const a=this.structs.index++;s=new Cae("StructType"+a,t),this.structs[n].push(s),r.structType=s}return s}getUniformFromNode(e,t,n=this.shaderStage,r=null){const s=this.getDataFromNode(e,n,this.globalCache);let a=s.uniform;if(a===void 0){const l=this.uniforms.index++;a=new Tae(r||"nodeUniform"+l,t,e),this.uniforms[n].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const l=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+l.length),a=new $B(t,n),l.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,l=a.length;t===null&&(t="nodeVarying"+l),s=new wae(t,n),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[n]||(this.codes[n]=[]),l=a.length;s=new Mae("nodeCode"+l,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const l of n)this.addLineFlowCode(l)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; -`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){const t=new SB,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const l=Object.values(this);return{next:()=>({value:l[a],done:a++>=l.length})}}};for(const a of t.inputs)n[a.name]=new tB(a.type,a.name);e.layout=null;const r=e.call(n),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,s=this.cache,a=this.buildStage,l=this.stack,u={code:""};this.flow=u,this.vars={},this.cache=new uS,this.stack=e_();for(const h of FT)this.setBuildStage(h),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.cache=s,this.stack=l,this.setBuildStage(a),u}getFunctionOperator(){return null}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const s=this.shaderStage;this.setShaderStage(e);const a=this.flowChildNode(t,n);return r!==null&&(a.code+=`${this.tab+r} = ${a.result}; -`),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(s),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+` -`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new Vr),r.build(this)}else this.addFlow("compute",e);for(const r of FT){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of kT){this.setShaderStage(s);const a=this.flowNodes[s];for(const l of a)r==="generate"?this.flowNode(l):l.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new Oae(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Iae(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new Fae(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new kae(e);if(t==="color")return new zae(e);if(t==="mat3")return new Gae(e);if(t==="mat4")return new qae(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),s=this.getTypeLength(n);return r===16&&s===9?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&s===4?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:r>4||s>4||s===0?e:r===s?`${this.getType(n)}( ${e} )`:r>s?this.format(`${e}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(t)),n):s===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${V0} - Node System -`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class vN{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===jn.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(n,this.frameId)}else if(t===jn.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(n,this.renderId)}else t===jn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===jn.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(n,this.frameId)}else if(t===jn.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(n,this.renderId)}else t===jn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===jn.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.frameId&&e.update(this)!==!1&&r.set(n,this.frameId)}else if(t===jn.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.renderId&&e.update(this)!==!1&&r.set(n,this.renderId)}else t===jn.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class kE{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}kE.isNodeFunctionInput=!0;class Yae extends xA{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,r=DE(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:s},e.stack,e)}}const pS=new kn,_v=new kn;let dm=null;class Qae extends xA{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=gn(new he).setGroup(Rn),this.halfWidth=gn(new he).setGroup(Rn),this.updateType=jn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;_v.identity(),pS.copy(t.matrixWorld),pS.premultiply(n),_v.extractRotation(pS),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(_v),this.halfHeight.value.applyMatrix4(_v)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=Ai(dm.LTC_FLOAT_1),n=Ai(dm.LTC_FLOAT_2)):(t=Ai(dm.LTC_HALF_1),n=Ai(dm.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,l=Jy(s),u=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:l,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:u,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){dm=e}}class YB extends xA{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=gn(0).setGroup(Rn),this.penumbraCosNode=gn(0).setGroup(Rn),this.cutoffDistanceNode=gn(0).setGroup(Rn),this.decayExponentNode=gn(0).setGroup(Rn)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return kc(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,l=Jy(a).sub(Xr),u=l.normalize(),h=u.dot(DE(a)),m=this.getSpotAttenuation(h),v=l.length(),x=UE({lightDistance:v,cutoffDistance:r,decayExponent:s});let S=n.mul(m).mul(x);if(a.map){const R=EB(a),C=Ai(a.map,R.xy).onRenderUpdate(()=>a.map);S=R.mul(2).sub(1).abs().lessThan(1).all().select(S.mul(C),S)}const w=e.context.reflectedLight;t.direct({lightDirection:u,lightColor:S,reflectedLight:w},e.stack,e)}}class Kae extends YB{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);n=Ai(t,Ct(r,0),0).r}else n=super.getSpotAttenuation(e);return n}}class Zae extends xA{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class Jae extends xA{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=NE(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=gn(new an).setGroup(Rn)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,a=Jo.dot(r).mul(.5).add(.5),l=Fi(n,t,a);e.context.irradiance.addAssign(l)}}class eoe extends xA{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new he);this.lightProbe=Sc(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=WB(Vy,this.lightProbe);e.context.irradiance.addAssign(t)}}class QB{parseFunction(){console.warn("Abstract function.")}}class zE{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn("Abstract function.")}}zE.isNodeFunction=!0;const toe=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,noe=/[a-z_0-9]+/ig,_N="#pragma main",ioe=i=>{i=i.trim();const e=i.indexOf(_N),t=e!==-1?i.slice(e+_N.length):i,n=t.match(toe);if(n!==null&&n.length===5){const r=n[4],s=[];let a=null;for(;(a=noe.exec(r))!==null;)s.push(a);const l=[];let u=0;for(;u0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===zh||n.mapping===Gh||n.mapping===sA){if(e.backgroundBlurriness>0||n.mapping===sA)return yE(n);{let a;return n.isCubeTexture===!0?a=I0(n):a=Ai(n),BU(a)}}else{if(n.isTexture===!0)return Ai(n,bu.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=s.get(t);return(a===void 0||r)&&(a=n(),s.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const s=ji("color","color",n).setGroup(Rn),a=ji("density","float",n).setGroup(Rn);return Ng(s,EE(a))}else if(n.isFog){const s=ji("color","color",n).setGroup(Rn),a=ji("near","float",n).setGroup(Rn),l=ji("far","float",n).setGroup(Rn);return Ng(s,ME(a,l))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return I0(n);if(n.isTexture===!0)return Ai(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,s=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=s,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return yN.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=Ai(e,bu).renderOutput(t.toneMapping,t.currentColorSpace);return yN.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new vN,this.nodeBuilderCache=new Map,this.cacheLib={}}}const mS=new Yl;class ay{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Vn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const r=e.length;for(let s=0;s{await this.compileAsync(v,x);const w=this._renderLists.get(v,x),R=this._renderContexts.get(v,x,this._renderTarget),C=v.overrideMaterial||S.material,E=this._objects.get(S,C,v,x,w.lightsNode,R,R.clippingContext),{fragmentShader:B,vertexShader:L}=E.getNodeBuilderState();return{fragmentShader:B,vertexShader:L}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),await n.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new aoe(this,n),this._animation=new une(this._nodes,this.info),this._attributes=new mne(n),this._background=new xae(this,this._nodes),this._geometries=new vne(this._attributes,this.info),this._textures=new Pne(this,n,this.info),this._pipelines=new Sne(n,this._nodes),this._bindings=new Tne(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new Ane(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new Ene(this.lighting),this._bundles=new loe,this._renderContexts=new Nne,this._animation.start(),this._initialized=!0,e()}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,s=r.renderId,a=this._currentRenderContext,l=this._currentRenderObjectFunction,u=this._compilationPromises,h=e.isScene===!0?e:xN;n===null&&(n=e);const m=this._renderTarget,v=this._renderContexts.get(n,t,m),x=this._activeMipmapLevel,S=[];this._currentRenderContext=v,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=S,r.renderId++,r.update(),v.depth=this.depth,v.stencil=this.stencil,v.clippingContext||(v.clippingContext=new ay),v.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,m);const w=this._renderLists.get(e,t);if(w.begin(),this._projectObject(e,t,0,w,v.clippingContext),n!==e&&n.traverseVisible(function(L){L.isLight&&L.layers.test(t.layers)&&w.pushLight(L)}),w.finish(),m!==null){this._textures.updateRenderTarget(m,x);const L=this._textures.get(m);v.textures=L.textures,v.depthTexture=L.depthTexture}else v.textures=null,v.depthTexture=null;this._background.update(h,w,v);const R=w.opaque,C=w.transparent,E=w.transparentDoublePass,B=w.lightsNode;this.opaque===!0&&R.length>0&&this._renderObjects(R,t,h,B),this.transparent===!0&&C.length>0&&this._renderTransparents(C,E,t,h,B),r.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=l,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(S)}async renderAsync(e,t){this._initialized===!1&&await this.init();const n=this._renderScene(e,t);await this.backend.resolveTimestampAsync(n,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: - -Message: ${e.message}`;e.reason&&(t+=` -Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:s,renderList:a}=e,l=this._currentRenderContext,u=this._bundles.get(r,s),h=this.backend.get(u);h.renderContexts===void 0&&(h.renderContexts=new Set);const m=r.version!==h.version,v=h.renderContexts.has(l)===!1||m;if(h.renderContexts.add(l),v){this.backend.beginBundle(l),(h.renderObjects===void 0||m)&&(h.renderObjects=[]),this._currentRenderBundle=u;const x=a.opaque;this.opaque===!0&&x.length>0&&this._renderObjects(x,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(l,u),h.version=r.version}else{const{renderObjects:x}=h;for(let S=0,w=x.length;S>=x,w.viewportValue.height>>=x,w.viewportValue.minDepth=L,w.viewportValue.maxDepth=O,w.viewport=w.viewportValue.equals(gS)===!1,w.scissorValue.copy(E).multiplyScalar(B).floor(),w.scissor=this._scissorTest&&w.scissorValue.equals(gS)===!1,w.scissorValue.width>>=x,w.scissorValue.height>>=x,w.clippingContext||(w.clippingContext=new ay),w.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,S),xv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),vS.setFromProjectionMatrix(xv,R);const G=this._renderLists.get(e,t);if(G.begin(),this._projectObject(e,t,0,G,w.clippingContext),G.finish(),this.sortObjects===!0&&G.sort(this._opaqueSort,this._transparentSort),S!==null){this._textures.updateRenderTarget(S,x);const Y=this._textures.get(S);w.textures=Y.textures,w.depthTexture=Y.depthTexture,w.width=Y.width,w.height=Y.height,w.renderTarget=S,w.depth=S.depthBuffer,w.stencil=S.stencilBuffer}else w.textures=null,w.depthTexture=null,w.width=this.domElement.width,w.height=this.domElement.height,w.depth=this.depth,w.stencil=this.stencil;w.width>>=x,w.height>>=x,w.activeCubeFace=v,w.activeMipmapLevel=x,w.occlusionQueryCount=G.occlusionQueryCount,this._background.update(h,G,w),this.backend.beginRender(w);const{bundles:q,lightsNode:z,transparentDoublePass:j,transparent:F,opaque:V}=G;if(q.length>0&&this._renderBundles(q,h,z),this.opaque===!0&&V.length>0&&this._renderObjects(V,t,h,z),this.transparent===!0&&F.length>0&&this._renderTransparents(F,j,t,h,z),this.backend.finishRender(w),s.renderId=a,this._currentRenderContext=l,this._currentRenderObjectFunction=u,r!==null){this.setRenderTarget(m,v,x);const Y=this._quad;this._nodes.hasOutputChange(S.texture)&&(Y.material.fragmentNode=this._nodes.getOutputNode(S.texture),Y.material.needsUpdate=!0),this._renderScene(Y,Y.camera,!1)}return h.onAfterRender(this,e,t,S),w}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,n=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){const s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,s=0,a=1){const l=this._viewport;e.isVector4?l.copy(e):l.set(e,t,n,r),l.minDepth=s,l.maxDepth=a}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);const r=this._renderTarget||this._getFrameBufferTarget();let s=null;if(r!==null){this._textures.updateRenderTarget(r);const a=this._textures.get(r);s=this._renderContexts.get(null,null,r),s.textures=a.textures,s.depthTexture=a.depthTexture,s.width=a.width,s.height=a.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer}if(this.backend.clear(e,t,n,s),r!==null&&this._renderTarget===null){const a=this._quad;this._nodes.hasOutputChange(r.texture)&&(a.material.fragmentNode=this._nodes.getOutputNode(r.texture),a.material.needsUpdate=!0),this._renderScene(a,a.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){this._initialized===!1&&await this.init(),this.clear(e,t,n)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this._renderTarget!==null?Za:this.toneMapping}get currentColorSpace(){return this._renderTarget!==null?Ro:this.outputColorSpace}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(this.isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,n=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const r=this.backend,s=this._pipelines,a=this._bindings,l=this._nodes,u=Array.isArray(e)?e:[e];if(u[0]===void 0||u[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");r.beginCompute(e);for(const h of u){if(s.has(h)===!1){const x=()=>{h.removeEventListener("dispose",x),s.delete(h),a.delete(h),l.delete(h)};h.addEventListener("dispose",x);const S=h.onInitFunction;S!==null&&S.call(h,{renderer:this})}l.updateForCompute(h),a.updateForCompute(h);const m=a.getForCompute(h),v=s.getForCompute(h,m);r.compute(e,h,m,v)}r.finishCompute(e),t.renderId=n}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e),await this.backend.resolveTimestampAsync(e,"compute")}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Sh.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Sh.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Sh.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n!==null?r=n.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,r=null,s=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,s)}async readRenderTargetPixelsAsync(e,t,n,r,s,a=0,l=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,s,l)}_projectObject(e,t,n,r,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||vS.intersectsSprite(e)){this.sortObjects===!0&&Sh.setFromMatrixPosition(e.matrixWorld).applyMatrix4(xv);const{geometry:u,material:h}=e;h.visible&&r.push(e,u,h,n,Sh.z,null,s)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||vS.intersectsObject(e))){const{geometry:u,material:h}=e;if(this.sortObjects===!0&&(u.boundingSphere===null&&u.computeBoundingSphere(),Sh.copy(u.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(xv)),Array.isArray(h)){const m=u.groups;for(let v=0,x=m.length;v0){for(const{material:a}of t)a.side=hr;this._renderObjects(t,n,r,s,"backSide");for(const{material:a}of t)a.side=Nl;this._renderObjects(e,n,r,s);for(const{material:a}of t)a.side=as}else this._renderObjects(e,n,r,s)}_renderObjects(e,t,n,r,s=null){for(let a=0,l=e.length;a0,S.isShadowNodeMaterial&&(S.side=s.shadowSide===null?s.side:s.shadowSide,s.depthNode&&s.depthNode.isNode&&(x=S.depthNode,S.depthNode=s.depthNode),s.castShadowNode&&s.castShadowNode.isNode&&(v=S.colorNode,S.colorNode=s.castShadowNode)),s=S}s.transparent===!0&&s.side===as&&s.forceSinglePass===!1?(s.side=hr,this._handleObjectFunction(e,s,t,n,l,a,u,"backSide"),s.side=Nl,this._handleObjectFunction(e,s,t,n,l,a,u,h),s.side=as):this._handleObjectFunction(e,s,t,n,l,a,u,h),m!==void 0&&(t.overrideMaterial.positionNode=m),x!==void 0&&(t.overrideMaterial.depthNode=x),v!==void 0&&(t.overrideMaterial.colorNode=v),e.onAfterRender(this,t,n,r,s,a)}_renderObjectDirect(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a;const m=this._nodes.needsRefresh(h);m&&(this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h)),this._pipelines.updateForRender(h),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(h),h.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(h,this.info),m&&this._nodes.updateAfter(h)}_createObjectPipeline(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a,this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h),this._pipelines.getForRender(h,this._compilationPromises),this._nodes.updateAfter(h)}get compile(){return this.compileAsync}}class GE{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function foe(i){return i+(Lh-i%Lh)%Lh}class ZB extends GE{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return foe(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class JB extends ZB{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let Aoe=0;class eO extends JB{constructor(e,t){super("UniformBuffer_"+Aoe++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class doe extends JB{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=0;for(let t=0,n=this.uniforms.length;t0?x:"";l=`${m.name} { - ${v} ${a.name}[${S}]; -}; -`}else l=`${this.getVectorType(a.type)} ${this.getPropertyName(a,e)};`,u=!0;const h=a.node.precision;if(h!==null&&(l=xoe[h]+" "+l),u){l=" "+l;const m=a.groupNode.name;(r[m]||(r[m]=[])).push(l)}else l="uniform "+l,n.push(l)}let s="";for(const a in r){const l=r[a];s+=this._getGLSLUniformStruct(e+"_"+a,l.join(` -`))+` -`}return s+=n.join(` -`),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ns){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let r=0;for(const s of n)t+=`layout( location = ${r++} ) in ${s.type} ${s.name}; -`}return t}getStructMembers(e){const t=[],n=e.getMemberTypes();for(let r=0;rn*r,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:r,behavior:s}of n.values())t.push(`#extension ${r} : ${s}`);return t.join(` -`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=bN[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const r=this.renderer.backend.extensions;r.has(n)&&(r.get(n),t=!0)}bN[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n0&&(n+=` -`),n+=` // flow -> ${h} - `),n+=`${u.code} - `,l===s&&t!=="compute"&&(n+=`// result - `,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(l.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);let l=a.uniformGPU;if(l===void 0){const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture")l=new ex(s.name,s.node,u),m.push(l);else if(t==="cubeTexture")l=new nO(s.name,s.node,u),m.push(l);else if(t==="texture3D")l=new iO(s.name,s.node,u),m.push(l);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;const v=new eO(e,u);v.name=e.name,m.push(v),l=v}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new tO(n+"_"+h,u),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}}let _S=null,Pd=null;class rO{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return _S=_S||new gt,this.renderer.getDrawingBufferSize(_S)}setScissorTest(){}getClearColor(){const e=this.renderer;return Pd=Pd||new bE,e.getClearColor(Pd),Pd.getRGB(Pd,this.renderer.currentColorSpace),Pd}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:F7(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${V0} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let Soe=0;class Toe{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class woe{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,a=e.usage||r.STATIC_DRAW,l=e.isInterleavedBufferAttribute?e.data:e,u=n.get(l);let h=u.bufferGPU;h===void 0&&(h=this._createBuffer(r,t,s,a),u.bufferGPU=h,u.bufferType=t,u.version=l.version);let m;if(s instanceof Float32Array)m=r.FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?m=r.HALF_FLOAT:m=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)m=r.SHORT;else if(s instanceof Uint32Array)m=r.UNSIGNED_INT;else if(s instanceof Int32Array)m=r.INT;else if(s instanceof Int8Array)m=r.BYTE;else if(s instanceof Uint8Array)m=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)m=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let v={bufferGPU:h,bufferType:t,type:m,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:m===r.INT||m===r.UNSIGNED_INT||e.gpuType===Ns,id:Soe++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const x=this._createBuffer(r,t,s,a);v=new Toe(v,x)}n.set(e,v)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,a=t.get(s),l=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(l,a.bufferGPU),u.length===0)n.bufferSubData(l,0,r);else{for(let h=0,m=u.length;h1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u{function s(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}}let wN=!1,bv,xS,MN;class Coe{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},wN===!1&&(this._init(this.gl),wN=!0)}_init(e){bv={[aA]:e.REPEAT,[eu]:e.CLAMP_TO_EDGE,[oA]:e.MIRRORED_REPEAT},xS={[mr]:e.NEAREST,[s_]:e.NEAREST_MIPMAP_NEAREST,[tu]:e.NEAREST_MIPMAP_LINEAR,[gs]:e.LINEAR,[Jd]:e.LINEAR_MIPMAP_NEAREST,[Va]:e.LINEAR_MIPMAP_LINEAR},MN={[Fw]:e.NEVER,[Vw]:e.ALWAYS,[my]:e.LESS,[gy]:e.LEQUAL,[kw]:e.EQUAL,[qw]:e.GEQUAL,[zw]:e.GREATER,[Gw]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===mr||e===s_||e===tu?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,s=!1){const{gl:a,extensions:l}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;return t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB&&(n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=r===_n&&s===!1?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5)),t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA&&(n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=r===_n&&s===!1?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)),t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_INT&&(u=a.DEPTH24_STENCIL8),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&l.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:r,backend:s}=this;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),n.texParameteri(e,n.TEXTURE_WRAP_S,bv[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,bv[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&n.texParameteri(e,n.TEXTURE_WRAP_R,bv[t.wrapR]),n.texParameteri(e,n.TEXTURE_MAG_FILTER,xS[t.magFilter]);const a=t.mipmaps!==void 0&&t.mipmaps.length>0,l=t.minFilter===gs&&a?Va:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,xS[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,MN[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===mr||t.minFilter!==tu&&t.minFilter!==Va||t.type===$r&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const u=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,s=this.getGLTextureType(e);let a=r[s];a===void 0&&(a=t.createTexture(),n.state.bindTexture(s,a),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=a),n.set(e,{textureGPU:a,glTextureType:s,isDefault:!0})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:s,width:a,height:l,depth:u}=t,h=r.utils.convert(e.format,e.colorSpace),m=r.utils.convert(e.type),v=this.getInternalFormat(e.internalFormat,h,m,e.colorSpace,e.isVideoTexture),x=n.createTexture(),S=this.getGLTextureType(e);r.state.bindTexture(S,x),this.setTextureParameters(S,e),e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,v,a,l,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,v,a,l,u):e.isVideoTexture||n.texStorage2D(S,s,v,a,l),r.set(e,{textureGPU:x,glTextureType:S,glFormat:h,glType:m,glInternalFormat:v})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:s,glTextureType:a,glFormat:l,glType:u}=r.get(t),{width:h,height:m}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,h,m,l,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:s}=t,{textureGPU:a,glTextureType:l,glFormat:u,glType:h,glInternalFormat:m}=this.backend.get(e);if(e.isRenderTargetTexture||a===void 0)return;const v=x=>x.isDataTexture?x.image.data:typeof HTMLImageElement<"u"&&x instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&x instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&x instanceof ImageBitmap||x instanceof OffscreenCanvas?x:x.data;if(this.backend.state.bindTexture(l,a),this.setTextureParameters(l,e),e.isCompressedTexture){const x=e.mipmaps,S=t.image;for(let w=0;w0,x=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(v){const S=l!==0||u!==0;let w,R;if(e.isDepthTexture===!0?(w=r.DEPTH_BUFFER_BIT,R=r.DEPTH_ATTACHMENT,t.stencil&&(w|=r.STENCIL_BUFFER_BIT)):(w=r.COLOR_BUFFER_BIT,R=r.COLOR_ATTACHMENT0),S){const C=this.backend.get(t.renderTarget),E=C.framebuffers[t.getCacheKey()],B=C.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,E),s.bindFramebuffer(r.READ_FRAMEBUFFER,B);const L=x-u-m;r.blitFramebuffer(l,L,l+h,L+m,l,L,l+h,L+m,w,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,E),s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,L,h,m),s.unbindTexture()}else{const C=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,C),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,R,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,h,m,0,0,h,m,w,r.NEAREST),r.deleteFramebuffer(C)}}else s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,x-m-u,h,m),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:n}=this,r=t.renderTarget,{samples:s,depthTexture:a,depthBuffer:l,stencilBuffer:u,width:h,height:m}=r;if(n.bindRenderbuffer(n.RENDERBUFFER,e),l&&!u){let v=n.DEPTH_COMPONENT24;s>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(v=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,s,v,h,m)):n.renderbufferStorage(n.RENDERBUFFER,v,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else l&&u&&(s>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,s,n.DEPTH24_STENCIL8,h,m):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,n,r,s,a){const{backend:l,gl:u}=this,{textureGPU:h,glFormat:m,glType:v}=this.backend.get(e),x=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,x);const S=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,S,h,0);const w=this._getTypedArrayType(v),R=this._getBytesPerTexel(v,m),E=r*s*R,B=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,B),u.bufferData(u.PIXEL_PACK_BUFFER,E,u.STREAM_READ),u.readPixels(t,n,r,s,m,v,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await l.utils._clientWaitAsync();const L=new w(E/w.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,B),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,L),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(x),L}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}}class Roe{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class Noe{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const EN={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class Doe{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:r,object:s,type:a,info:l,index:u}=this;u!==0?n.drawElements(r,t,a,e):n.drawArrays(r,e,t),l.update(s,t,r,1)}renderInstances(e,t,n){const{gl:r,mode:s,type:a,index:l,object:u,info:h}=this;n!==0&&(l!==0?r.drawElementsInstanced(s,t,a,e,n):r.drawArraysInstanced(s,e,t,n),h.update(u,t,s,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:s,object:a,info:l}=this;if(n===0)return;const u=r.get("WEBGL_multi_draw");if(u===null)for(let h=0;h0)){const n=t.queryQueue.shift();this.initTimestampQuery(n)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const n=this.get(e);n.gpuQueries||(n.gpuQueries=[]);for(let r=0;r0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),s=r.previousContext,a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const l=e.textures;if(l!==null)for(let u=0;u0){const m=u.framebuffers[e.getCacheKey()],v=t.COLOR_BUFFER_BIT,x=u.msaaFrameBuffer,S=e.textures;n.bindFramebuffer(t.READ_FRAMEBUFFER,x),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,m);for(let w=0;w{let u=0;for(let h=0;h0&&s.add(r[h]),n[h]=null,a.deleteQuery(m),u++)}u1?E.renderInstances(O,B,L):E.render(O,B),u.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new boe(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,s=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,r),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:s,vertexProgram:a}=r,l=n.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU;if(n.attachShader(l,u),n.attachShader(l,h),n.linkProgram(l),this.set(r,{programGPU:l,fragmentShader:u,vertexShader:h}),t!==null&&this.parallel){const m=new Promise(v=>{const x=this.parallel,S=()=>{n.getProgramParameter(l,x.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),v()):requestAnimationFrame(S)};S()});t.push(m);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(` -`),r=[],s=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let l=s;l":" "} ${u}: ${n[l]}`)}return r.join(` -`)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),s=e.getShaderInfoLog(t).trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const l=parseInt(a[1]);return n.toUpperCase()+` - -`+s+` - -`+this._handleSource(e.getShaderSource(t),l)}else return s}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,s=r.getProgramInfoLog(e).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,n,t);else{const a=this._getShaderErrors(r,n,"vertex"),l=this._getShaderErrors(r,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+` - -Program Info Log: `+s+` -`+a+` -`+l)}else s!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",s)}}_completeCompile(e,t){const{state:n,gl:r}=this,s=this.get(t),{programGPU:a,fragmentShader:l,vertexShader:u}=s;r.getProgramParameter(a,r.LINK_STATUS)===!1&&this._logProgramError(a,l,u),n.useProgram(a);const h=e.getBindings();this._setupBindings(h,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){const{state:n,gl:r}=this,s={stage:"fragment",code:`#version 300 es -precision highp float; -void main() {}`};this.createProgram(s);const{computeProgram:a}=e,l=r.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU,m=a.transforms,v=[],x=[];for(let C=0;CEN[r]===e),n=this.extensions;for(let r=0;r0){if(S===void 0){const E=[];S=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,S);const B=[],L=e.textures;for(let O=0;O, - @location( 0 ) vTex : vec2 -}; - -@vertex -fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { - - var Varys : VarysStruct; - - var pos = array< vec2, 4 >( - vec2( -1.0, 1.0 ), - vec2( 1.0, 1.0 ), - vec2( -1.0, -1.0 ), - vec2( 1.0, -1.0 ) - ); - - var tex = array< vec2, 4 >( - vec2( 0.0, 0.0 ), - vec2( 1.0, 0.0 ), - vec2( 0.0, 1.0 ), - vec2( 1.0, 1.0 ) - ); - - Varys.vTex = tex[ vertexIndex ]; - Varys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 ); - - return Varys; - -} -`,n=` -@group( 0 ) @binding( 0 ) -var imgSampler : sampler; - -@group( 0 ) @binding( 1 ) -var img : texture_2d; - -@fragment -fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { - - return textureSample( img, imgSampler, vTex ); - -} -`,r=` -@group( 0 ) @binding( 0 ) -var imgSampler : sampler; - -@group( 0 ) @binding( 1 ) -var img : texture_2d; - -@fragment -fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { - - return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); - -} -`;this.mipmapSampler=e.createSampler({minFilter:qf.Linear}),this.flipYSampler=e.createSampler({minFilter:qf.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:r})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Zd.TriangleStrip,stripIndexFormat:k0.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Zd.TriangleStrip,stripIndexFormat:k0.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const r=t.format,{width:s,height:a}=t.size,l=this.getTransferPipeline(r),u=this.getFlipYPipeline(r),h=this.device.createTexture({size:{width:s,height:a,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),m=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:za.TwoD,baseArrayLayer:n}),v=h.createView({baseMipLevel:0,mipLevelCount:1,dimension:za.TwoD,baseArrayLayer:0}),x=this.device.createCommandEncoder({}),S=(w,R,C)=>{const E=w.getBindGroupLayout(0),B=this.device.createBindGroup({layout:E,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:R}]}),L=x.beginRenderPass({colorAttachments:[{view:C,loadOp:Wr.Clear,storeOp:ia.Store,clearValue:[0,0,0,0]}]});L.setPipeline(w),L.setBindGroup(0,B),L.draw(4,1,0,0),L.end()};S(l,m,v),S(u,v,m),this.device.queue.submit([x.finish()]),h.destroy()}generateMipmaps(e,t,n=0){const r=this.get(e);r.useCount===void 0&&(r.useCount=0,r.layers=[]);const s=r.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,s),this.device.queue.submit([a.finish()]),r.useCount!==0&&(r.layers[n]=s),r.useCount++}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),s=r.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:za.TwoD,baseArrayLayer:n});const l=[];for(let u=1;u1;for(let l=0;l]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,Voe=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,DN={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},Hoe=i=>{i=i.trim();const e=i.match(qoe);if(e!==null&&e.length===4){const t=e[2],n=[];let r=null;for(;(r=Voe.exec(t))!==null;)n.push({name:r[1],type:r[2]});const s=[];for(let m=0;m "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class Woe extends QB{parseFunction(e){return new joe(e)}}const Ud=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},$oe={[sa.READ_ONLY]:"read",[sa.WRITE_ONLY]:"write",[sa.READ_WRITE]:"read_write"},PN={[aA]:"repeat",[eu]:"clamp",[oA]:"mirror"},Tv={vertex:Ud?Ud.VERTEX:1,fragment:Ud?Ud.FRAGMENT:2,compute:Ud?Ud.COMPUTE:4},LN={instance:!0,swizzleAssign:!1,storageBuffer:!0},Xoe={"^^":"tsl_xor"},Yoe={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},UN={},Wo={tsl_xor:new rs("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new rs("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new rs("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new rs("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new rs("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new rs("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new rs("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new rs("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new rs("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new rs("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new rs("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new rs("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new rs(` -fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { - - let res = vec2f( iRes ); - - let uvScaled = coord * res; - let uvWrapping = ( ( uvScaled % res ) + res ) % res; - - // https://www.shadertoy.com/view/WtyXRy - - let uv = uvWrapping - 0.5; - let iuv = floor( uv ); - let f = fract( uv ); - - let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); - let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); - let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); - let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); - - return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); - -} -`)},Mm={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(Wo.pow_float=new rs("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),Wo.pow_vec2=new rs("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[Wo.pow_float]),Wo.pow_vec3=new rs("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[Wo.pow_float]),Wo.pow_vec4=new rs("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[Wo.pow_float]),Mm.pow_float="tsl_pow_float",Mm.pow_vec2="tsl_pow_vec2",Mm.pow_vec3="tsl_pow_vec3",Mm.pow_vec4="tsl_pow_vec4");let sO="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(sO+=`diagnostic( off, derivative_uniformity ); -`);class Qoe extends XB{constructor(e,t){super(e,t,new Woe),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Co}_generateTextureSample(e,t,n,r,s=this.shaderStage){return s==="fragment"?r?`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n):this.generateTextureLod(e,t,n,r,"0")}_generateVideoSample(e,t,n=this.shaderStage){if(n==="fragment")return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${n} shader.`)}_generateTextureSampleLevel(e,t,n,r,s,a=this.shaderStage){return(a==="fragment"||a==="compute")&&this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r):this.generateTextureLod(e,t,n,s,r)}generateWrapFunction(e){const t=`tsl_coord_${PN[e.wrapS]}S_${PN[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=UN[t];if(n===void 0){const r=[],s=e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${s} ) -> ${s} { - - return ${s}( -`;const l=(u,h)=>{u===aA?(r.push(Wo.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${h} )`):u===eu?(r.push(Wo.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${h} )`):u===oA?(r.push(Wo.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${h} )`):(a+=` coord.${h}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};l(e.wrapS,"x"),a+=`, -`,l(e.wrapT,"y"),e.isData3DTexture&&(a+=`, -`,l(e.wrapR,"z")),a+=` - ); - -} -`,UN[t]=n=new rs(a,r)}return n.build(this),t}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,l;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),h=u>1;e.isData3DTexture?l="vec3":l="vec2",h||e.isVideoTexture||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,s=new Kv(new Zv(`textureDimensions( ${a} )`,l)),r.dimensionsSnippet[n]=s,(e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new Kv(new Zv(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new Kv(new Zv("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,n,r="0u"){this._include("biquadraticTexture");const s=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,r);return`tsl_biquadraticTexture( ${t}, ${s}( ${n} ), ${a}, u32( ${r} ) )`}generateTextureLod(e,t,n,r,s="0u"){const a=this.generateWrapFunction(e),l=this.generateTextureDimension(e,t,s),u=e.isData3DTexture?"vec3":"vec2",h=`${u}(${a}(${n}) * ${u}(${l}))`;return this.generateTextureLoad(e,t,h,r,s)}generateTextureLoad(e,t,n,r,s="0u"){return e.isVideoTexture===!0||e.isStorageTexture===!0?`textureLoad( ${t}, ${n} )`:r?`textureLoad( ${t}, ${n}, ${r}, u32( ${s} ) )`:`textureLoad( ${t}, ${n}, u32( ${s} ) )`}generateTextureStore(e,t,n,r){return`textureStore( ${t}, ${n}, ${r} )`}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===$r||this.isSampleCompare(e)===!1&&e.minFilter===mr&&e.magFilter===mr||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,s=this.shaderStage){let a=null;return e.isVideoTexture===!0?a=this._generateVideoSample(t,n,s):this.isUnfilterable(e)?a=this.generateTextureLod(e,t,n,r,"0",s):a=this._generateTextureSample(e,t,n,r,s),a}generateTextureGrad(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,r,s,a=this.shaderStage){let l=null;return e.isVideoTexture===!0?l=this._generateVideoSample(t,n,a):l=this._generateTextureSampleLevel(e,t,n,r,s,a),l}generateTextureBias(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const n=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="storageTexture"||r==="texture3D"?n:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?`NodeBuffer_${e.id}.${n}`:e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=Xoe[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?sa.READ_ONLY:e.access}getStorageAccess(e,t){return $oe[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let l;const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let v=null;const x=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?v=new ex(s.name,s.node,u,x):t==="cubeTexture"?v=new nO(s.name,s.node,u,x):t==="texture3D"&&(v=new iO(s.name,s.node,u,x)),v.store=e.isStorageTextureNode===!0,v.setVisibility(Tv[n]),(n==="fragment"||n==="compute")&&this.isUnfilterable(e.value)===!1&&v.store===!1){const S=new Uoe(`${s.name}_sampler`,s.node,u);S.setVisibility(Tv[n]),m.push(S,v),l=[S,v]}else m.push(v),l=[v]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const v=t==="buffer"?eO:Ioe,x=new v(e,u);x.setVisibility(Tv[n]),m.push(x),l=x}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new tO(h,u),x.setVisibility(Tv[n]),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}getBuiltin(e,t,n,r=this.shaderStage){const s=this.builtins[r]||(this.builtins[r]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const a of t.inputs)r.push(a.name+" : "+this.getType(a.type));let s=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} { -${n.vars} -${n.code} -`;return n.result&&(s+=` return ${n.result}; -`),s+=` -} -`,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==void 0)for(const r of n)t.push(`enable ${r};`);return t.join(` -`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==void 0)for(const{name:r,property:s,type:a}of n.values())t.push(`@builtin( ${r} ) ${s} : ${a}`);return t.join(`, - `)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:r,bufferType:s,bufferCount:a}of this.scopedArrays.values()){const l=this.getType(s);t.push(`var<${r}> ${n}: array< ${l}, ${a} >;`)}return t.join(` -`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","id","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const n=this.getBuiltins("attribute");n&&t.push(n);const r=this.getAttributesArray();for(let s=0,a=r.length;s`)}const r=this.getBuiltins("output");return r&&t.push(" "+r),t.join(`, -`)}getStructs(e){const t=[],n=this.structs[e];for(let r=0,s=n.length;r output : ${l}; - -`)}return t.join(` - -`)}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(` ${this.getVar(r.type,r.name)};`);return` -${t.join(` -`)} -`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4","vertex"),e==="vertex"||e==="fragment"){const s=this.varyings,a=this.vars[e];for(let l=0;l1&&(S="_multisampled"),v.isCubeTexture===!0)x="texture_cube";else if(v.isDataArrayTexture===!0||v.isCompressedArrayTexture===!0)x="texture_2d_array";else if(v.isDepthTexture===!0)x=`texture_depth${S}_2d`;else if(v.isVideoTexture===!0)x="texture_external";else if(v.isData3DTexture===!0)x="texture_3d";else if(u.node.isStorageTextureNode===!0){const R=iw(v),C=this.getStorageAccess(u.node,e);x=`texture_storage_2d<${R}, ${C}>`}else{const R=this.getComponentTypeFromTexture(v).charAt(0);x=`texture${S}_2d<${R}32>`}n.push(`@binding( ${m.binding++} ) @group( ${m.group} ) var ${u.name} : ${x};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const v=u.node,x=this.getType(v.bufferType),S=v.bufferCount,w=S>0&&u.type==="buffer"?", "+S:"",R=v.isAtomic?`atomic<${x}>`:`${x}`,C=` ${u.name} : array< ${R}${w} > -`,E=v.isStorageBufferNode?`storage, ${this.getStorageAccess(v,e)}`:"uniform";r.push(this._getWGSLStructBinding("NodeBuffer_"+v.id,C,E,m.binding++,m.group))}else{const v=this.getType(this.getVectorType(u.type)),x=u.groupNode.name;(a[x]||(a[x]={index:m.binding++,id:m.group,snippets:[]})).snippets.push(` ${u.name} : ${v}`)}}for(const u in a){const h=a[u];s.push(this._getWGSLStructBinding(u,h.snippets.join(`, -`),"uniform",h.index,h.id))}let l=n.join(` -`);return l+=r.join(` -`),l+=s.join(` -`),l}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code - -`;r+=this.flowCode[t];const s=this.flowNodes[t],a=s[s.length-1],l=a.outputNode,u=l!==void 0&&l.isOutputStructNode===!0;for(const h of s){const m=this.getFlowData(h),v=h.name;if(v&&(r.length>0&&(r+=` -`),r+=` // flow -> ${v} - `),r+=`${m.code} - `,h===a&&t!=="compute"){if(r+=`// result - - `,t==="vertex")r+=`varyings.Vertex = ${m.result};`;else if(t==="fragment")if(u)n.returnType=l.nodeType,r+=`return ${m.result};`;else{let x=" @location(0) color: vec4";const S=this.getBuiltins("output");S&&(x+=`, - `+S),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",x),n.structs+=` -var output : OutputStruct; - -`,r+=`output.color = ${m.result}; - - return output;`}}}n.flow=r}this.material!==null?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getType(e){return Yoe[e]||e}isAvailable(e){let t=LN[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),LN[e]=t),t}_getWGSLMethod(e){return Wo[e]!==void 0&&this._include(e),Mm[e]}_include(e){const t=Wo[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} -// directives -${e.directives} - -// uniforms -${e.uniforms} - -// varyings -${e.varyings} -var varyings : VaryingsStruct; - -// codes -${e.codes} - -@vertex -fn main( ${e.attributes} ) -> VaryingsStruct { - - // vars - ${e.vars} - - // flow - ${e.flow} - - return varyings; - -} -`}_getWGSLFragmentCode(e){return`${this.getSignature()} -// global -${sO} - -// uniforms -${e.uniforms} - -// structs -${e.structs} - -// codes -${e.codes} - -@fragment -fn main( ${e.varyings} ) -> ${e.returnType} { - - // vars - ${e.vars} - - // flow - ${e.flow} - -} -`}_getWGSLComputeCode(e,t){return`${this.getSignature()} -// directives -${e.directives} - -// system -var instanceIndex : u32; - -// locals -${e.scopedArrays} - -// uniforms -${e.uniforms} - -// codes -${e.codes} - -@compute @workgroup_size( ${t} ) -fn main( ${e.attributes} ) { - - // system - instanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t}); - - // vars - ${e.vars} - - // flow - ${e.flow} - -} -`}_getWGSLStruct(e,t){return` -struct ${e} { -${t} -};`}_getWGSLStructBinding(e,t,n,r=0,s=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)} -@binding( ${r} ) @group( ${s} ) -var<${n}> ${e} : ${a};`}}class Koe{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=Ue.Depth24PlusStencil8:e.depth&&(t=Ue.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,a=s.getRenderTarget();t=a?a.samples:s.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return Zd.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Zd.LineList;if(e.isLine)return Zd.LineStrip;if(e.isMesh)return Zd.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?Ue.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const Zoe=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),Joe=new Map([[G7,["float16"]]]),ele=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class tle{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let a=s.buffer;if(a===void 0){const l=r.device;let u=n.array;if(e.normalized===!1&&(u.constructor===Int16Array||u.constructor===Uint16Array)){const m=new Uint32Array(u.length);for(let v=0;v1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=Ld.UnfilterableFloat)),a.texture.isDepthTexture)u.sampleType=Ld.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const m=a.texture.type;m===Ns?u.sampleType=Ld.SInt:m===Rr?u.sampleType=Ld.UInt:m===$r&&(this.backend.hasFeature("float32-filterable")?u.sampleType=Ld.Float:u.sampleType=Ld.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=za.Cube:a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=za.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=za.ThreeD),l.texture=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);r.push(l)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){const{backend:s,bindGroupLayoutCache:a}=this,l=s.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let h;n>0&&(l.groups===void 0&&(l.groups=[],l.versions=[]),l.versions[n]===r&&(h=l.groups[n])),h===void 0&&(h=this.createBindGroup(e,u),n>0&&(l.groups[n]=h,l.versions[n]=r)),l.group=h,l.layout=u}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,s=t.get(e).buffer;n.queue.writeBuffer(s,0,r,0)}createBindGroup(e,t){const n=this.backend,r=n.device;let s=0;const a=[];for(const l of e.bindings){if(l.isUniformBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.byteLength,m=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,v=r.createBuffer({label:"bindingBuffer_"+l.name,size:h,usage:m});u.buffer=v}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isStorageBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.attribute;u.buffer=n.get(h).buffer}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isSampler){const u=n.get(l.texture);a.push({binding:s,resource:u.sampler})}else if(l.isSampledTexture){const u=n.get(l.texture);let h;if(u.externalTexture!==void 0)h=r.importExternalTexture({source:u.externalTexture});else{const m=l.store?1:u.texture.mipLevelCount,v=`view-${u.texture.width}-${u.texture.height}-${m}`;if(h=u[v],h===void 0){const x=Poe.All;let S;l.isSampledCubeTexture?S=za.Cube:l.isSampledTexture3D?S=za.ThreeD:l.texture.isDataArrayTexture||l.texture.isCompressedArrayTexture?S=za.TwoDArray:S=za.TwoD,h=u[v]=u.texture.createView({aspect:x,dimension:S,mipLevelCount:m})}}a.push({binding:s,resource:h})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}}class ile{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:s,pipeline:a}=e,{vertexProgram:l,fragmentProgram:u}=a,h=this.backend,m=h.device,v=h.utils,x=h.get(a),S=[];for(const te of e.getBindings()){const re=h.get(te);S.push(re.layout)}const w=h.attributeUtils.createShaderVertexBuffers(e);let R;r.transparent===!0&&r.blending!==Qa&&(R=this._getBlending(r));let C={};r.stencilWrite===!0&&(C={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const E=this._getColorWriteMask(r),B=[];if(e.context.textures!==null){const te=e.context.textures;for(let re=0;re1},layout:m.createPipelineLayout({bindGroupLayouts:S})},V={},Y=e.context.depth,ee=e.context.stencil;if((Y===!0||ee===!0)&&(Y===!0&&(V.format=z,V.depthWriteEnabled=r.depthWrite,V.depthCompare=q),ee===!0&&(V.stencilFront=C,V.stencilBack={},V.stencilReadMask=r.stencilFuncMask,V.stencilWriteMask=r.stencilWriteMask),F.depthStencil=V),t===null)x.pipeline=m.createRenderPipeline(F);else{const te=new Promise(re=>{m.createRenderPipelineAsync(F).then(ne=>{x.pipeline=ne,re()})});t.push(te)}}createBundleEncoder(e){const t=this.backend,{utils:n,device:r}=t,s=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormat(e),l=this._getSampleCount(e),u={label:"renderBundleEncoder",colorFormats:[a],depthStencilFormat:s,sampleCount:l};return r.createRenderBundleEncoder(u)}createComputePipeline(e,t){const n=this.backend,r=n.device,s=n.get(e.computeProgram).module,a=n.get(e),l=[];for(const u of t){const h=n.get(u);l.push(h.layout)}a.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:l})})}_getBlending(e){let t,n;const r=e.blending,s=e.blendSrc,a=e.blendDst,l=e.blendEquation;if(r===xw){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,h=e.blendDstAlpha!==null?e.blendDstAlpha:a,m=e.blendEquationAlpha!==null?e.blendEquationAlpha:l;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(l)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(h),operation:this._getBlendOperation(m)}}else{const u=e.premultipliedAlpha,h=(m,v,x,S)=>{t={srcFactor:m,dstFactor:v,operation:Df.Add},n={srcFactor:x,dstFactor:S,operation:Df.Add}};if(u)switch(r){case Ka:h(Kn.One,Kn.OneMinusSrcAlpha,Kn.One,Kn.OneMinusSrcAlpha);break;case a0:h(Kn.One,Kn.One,Kn.One,Kn.One);break;case o0:h(Kn.Zero,Kn.OneMinusSrc,Kn.Zero,Kn.One);break;case l0:h(Kn.Zero,Kn.Src,Kn.Zero,Kn.SrcAlpha);break}else switch(r){case Ka:h(Kn.SrcAlpha,Kn.OneMinusSrcAlpha,Kn.One,Kn.OneMinusSrcAlpha);break;case a0:h(Kn.SrcAlpha,Kn.One,Kn.SrcAlpha,Kn.One);break;case o0:h(Kn.Zero,Kn.OneMinusSrc,Kn.Zero,Kn.One);break;case l0:h(Kn.Zero,Kn.Src,Kn.Zero,Kn.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case Tw:t=Kn.Zero;break;case ww:t=Kn.One;break;case Mw:t=Kn.Src;break;case Ew:t=Kn.OneMinusSrc;break;case qm:t=Kn.SrcAlpha;break;case Vm:t=Kn.OneMinusSrcAlpha;break;case Nw:t=Kn.Dst;break;case Dw:t=Kn.OneMinusDstColor;break;case Cw:t=Kn.DstAlpha;break;case Rw:t=Kn.OneMinusDstAlpha;break;case Pw:t=Kn.SrcAlphaSaturated;break;case dne:t=Kn.Constant;break;case pne:t=Kn.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case tk:t=Bs.Never;break;case WS:t=Bs.Always;break;case nk:t=Bs.Less;break;case rk:t=Bs.LessEqual;break;case ik:t=Bs.Equal;break;case ok:t=Bs.GreaterEqual;break;case sk:t=Bs.Greater;break;case ak:t=Bs.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Uf:t=Th.Keep;break;case XF:t=Th.Zero;break;case YF:t=Th.Replace;break;case ek:t=Th.Invert;break;case QF:t=Th.IncrementClamp;break;case KF:t=Th.DecrementClamp;break;case ZF:t=Th.IncrementWrap;break;case JF:t=Th.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Eo:t=Df.Add;break;case bw:t=Df.Subtract;break;case Sw:t=Df.ReverseSubtract;break;case M7:t=Df.Min;break;case E7:t=Df.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},s=this.backend.utils;switch(r.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?k0.Uint16:k0.Uint32),n.side){case Nl:r.frontFace=bS.CCW,r.cullMode=SS.Back;break;case hr:r.frontFace=bS.CCW,r.cullMode=SS.Front;break;case as:r.frontFace=bS.CCW,r.cullMode=SS.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?RN.All:RN.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Bs.Always;else{const n=e.depthFunc;switch(n){case Hm:t=Bs.Never;break;case jm:t=Bs.Always;break;case Wm:t=Bs.Less;break;case kh:t=Bs.LessEqual;break;case $m:t=Bs.Equal;break;case Xm:t=Bs.GreaterEqual;break;case Ym:t=Bs.Greater;break;case Qm:t=Bs.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class rle extends rO{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.trackTimestamp=e.trackTimestamp===!0,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new Koe(this),this.attributeUtils=new tle(this),this.bindingUtils=new nle(this),this.pipelineUtils=new ile(this),this.textureUtils=new Goe(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===void 0){const a={powerPreference:t.powerPreference},l=typeof navigator<"u"?await navigator.gpu.requestAdapter(a):null;if(l===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const u=Object.values(nw),h=[];for(const v of u)l.features.has(v)&&h.push(v);const m={requiredFeatures:h,requiredLimits:t.requiredLimits};n=await l.requestDevice(m)}else n=t.device;n.lost.then(a=>{const l={api:"WebGPU",message:a.message||"Unknown reason",reason:a.reason||null,originalEvent:a};e.onDeviceLost(l)});const r=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=r;const s=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(nw.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s}),this.updateSize()}get coordinateSystem(){return pu}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let s=r.descriptors;if(s===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==n.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples||r.loadOp!==t.loadOp){s={},r.descriptors=s;const u=()=>{n.removeEventListener("dispose",u),this.delete(n)};n.addEventListener("dispose",u)}const a=e.getCacheKey();let l=s[a];if(l===void 0){const u=e.textures,h=[];let m;for(let v=0;v0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:Wr.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=s;const l=a.depthStencilAttachment;if(e.textures!==null){const m=a.colorAttachments;for(let v=0;v0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),n>0){const r=n*8;let s=this.occludedResolveCache.get(r);s===void 0&&(s=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,s));const a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const r=e.textures;for(let s=0;sl?(h.x=Math.min(t.dispatchCount,l),h.y=Math.ceil(t.dispatchCount/l)):h.x=t.dispatchCount,s.dispatchWorkgroups(h.x,h.y,h.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:n,context:r,pipeline:s}=e,a=e.getBindings(),l=this.get(r),u=this.get(s).pipeline,h=l.currentSets,m=l.currentPass,v=e.getDrawParameters();if(v===null)return;h.pipeline!==u&&(m.setPipeline(u),h.pipeline=u);const x=h.bindingGroups;for(let C=0,E=a.length;C1?0:O;w===!0?m.drawIndexed(E[O],G,C[O]/S.array.BYTES_PER_ELEMENT,0,q):m.draw(E[O],G,C[O],q)}}else if(w===!0){const{vertexCount:C,instanceCount:E,firstVertex:B}=v,L=e.getIndirect();if(L!==null){const O=this.get(L).buffer;m.drawIndexedIndirect(O,0)}else m.drawIndexed(C,E,B,0,0);t.update(n,C,E)}else{const{vertexCount:C,instanceCount:E,firstVertex:B}=v,L=e.getIndirect();if(L!==null){const O=this.get(L).buffer;m.drawIndirect(O,0)}else m.draw(C,E,B,0);t.update(n,C,E)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,s=this.utils,a=s.getSampleCountRenderContext(e.context),l=s.getCurrentColorSpace(e.context),u=s.getCurrentColorFormat(e.context),h=s.getCurrentDepthStencilFormat(e.context),m=s.getPrimitiveTopology(n,r);let v=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==l||t.colorFormat!==u||t.depthStencilFormat!==h||t.primitiveTopology!==m||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=l,t.colorFormat=u,t.depthStencilFormat=h,t.primitiveTopology=m,t.clippingContextCacheKey=e.clippingContextCacheKey,v=!0),v}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,s=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(s),r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const n=this.get(e);if(!n.timeStampQuerySet){const r=e.isComputeNode?"compute":"render",s=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${r}_${e.id}`});Object.assign(t,{timestampWrites:{querySet:s,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}),n.timeStampQuerySet=s}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const n=this.get(e),r=2*BigInt64Array.BYTES_PER_ELEMENT;n.currentTimestampQueryBuffers===void 0&&(n.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:s,resultBuffer:a}=n.currentTimestampQueryBuffers;t.resolveQuerySet(n.timeStampQuerySet,0,2,s,0),a.mapState==="unmapped"&&t.copyBufferToBuffer(s,0,a,0,r)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const n=this.get(e);if(n.currentTimestampQueryBuffers===void 0)return;const{resultBuffer:r}=n.currentTimestampQueryBuffers;r.mapState==="unmapped"&&r.mapAsync(GPUMapMode.READ).then(()=>{const s=new BigUint64Array(r.getMappedRange()),a=Number(s[1]-s[0])/1e6;this.renderer.info.updateTimestamp(t,a),r.unmap()})}createNodeBuilder(e,t){return new Qoe(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),s=n.currentPass.finish();this.get(t).bundleGPU=s,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,s=0){let a=0,l=0,u=0,h=0,m=0,v=0,x=e.image.width,S=e.image.height;n!==null&&(h=n.x,m=n.y,v=n.z||0,x=n.width,S=n.height),r!==null&&(a=r.x,l=r.y,u=r.z||0);const w=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),R=this.get(e).texture,C=this.get(t).texture;w.copyTextureToTexture({texture:R,mipLevel:s,origin:{x:h,y:m,z:v}},{texture:C,mipLevel:s,origin:{x:a,y:l,z:u}},[x,S,1]),this.device.queue.submit([w.finish()])}copyFramebufferToTexture(e,t,n){const r=this.get(t);let s=null;t.renderTarget?e.isDepthTexture?s=this.get(t.depthTexture).texture:s=this.get(t.textures[0]).texture:e.isDepthTexture?s=this.textureUtils.getDepthBuffer(t.depth,t.stencil):s=this.context.getCurrentTexture();const a=this.get(e).texture;if(s.format!==a.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,a.format);return}let l;if(r.currentPass?(r.currentPass.end(),l=r.encoder):l=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),l.copyTextureToTexture({texture:s,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),r.currentPass){const{descriptor:u}=r;for(let h=0;h(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new CN(e)));const n=new t(e);super(n,e),this.library=new ale,this.isWebGPURenderer=!0}}/** - * @license - * Copyright 2010-2024 Three.js Authors - * SPDX-License-Identifier: MIT - */W.BRDF_GGX;W.BRDF_Lambert;W.BasicShadowFilter;W.Break;W.Continue;W.DFGApprox;W.D_GGX;W.Discard;W.EPSILON;W.F_Schlick;const ole=W.Fn;W.INFINITY;const lle=W.If,ule=W.Loop;W.NodeShaderStage;W.NodeType;W.NodeUpdateType;W.NodeAccess;W.PCFShadowFilter;W.PCFSoftShadowFilter;W.PI;W.PI2;W.Return;W.Schlick_to_F0;W.ScriptableNodeResources;W.ShaderNode;W.TBNViewMatrix;W.VSMShadowFilter;W.V_GGX_SmithCorrelated;W.abs;W.acesFilmicToneMapping;W.acos;W.add;W.addNodeElement;W.agxToneMapping;W.all;W.alphaT;W.and;W.anisotropy;W.anisotropyB;W.anisotropyT;W.any;W.append;W.arrayBuffer;const cle=W.asin;W.assign;W.atan;W.atan2;W.atomicAdd;W.atomicAnd;W.atomicFunc;W.atomicMax;W.atomicMin;W.atomicOr;W.atomicStore;W.atomicSub;W.atomicXor;W.attenuationColor;W.attenuationDistance;W.attribute;W.attributeArray;W.backgroundBlurriness;W.backgroundIntensity;W.backgroundRotation;W.batch;W.billboarding;W.bitAnd;W.bitNot;W.bitOr;W.bitXor;W.bitangentGeometry;W.bitangentLocal;W.bitangentView;W.bitangentWorld;W.bitcast;W.blendBurn;W.blendColor;W.blendDodge;W.blendOverlay;W.blendScreen;W.blur;W.bool;W.buffer;W.bufferAttribute;W.bumpMap;W.burn;W.bvec2;W.bvec3;W.bvec4;W.bypass;W.cache;W.call;W.cameraFar;W.cameraNear;W.cameraNormalMatrix;W.cameraPosition;W.cameraProjectionMatrix;W.cameraProjectionMatrixInverse;W.cameraViewMatrix;W.cameraWorldMatrix;W.cbrt;W.cdl;W.ceil;W.checker;W.cineonToneMapping;W.clamp;W.clearcoat;W.clearcoatRoughness;W.code;W.color;W.colorSpaceToWorking;W.colorToDirection;W.compute;W.cond;W.context;W.convert;W.convertColorSpace;W.convertToTexture;const hle=W.cos;W.cross;W.cubeTexture;W.dFdx;W.dFdy;W.dashSize;W.defaultBuildStages;W.defaultShaderStages;W.defined;W.degrees;W.deltaTime;W.densityFog;W.densityFogFactor;W.depth;W.depthPass;W.difference;W.diffuseColor;W.directPointLight;W.directionToColor;W.dispersion;W.distance;W.div;W.dodge;W.dot;W.drawIndex;W.dynamicBufferAttribute;W.element;W.emissive;W.equal;W.equals;W.equirectUV;const fle=W.exp;W.exp2;W.expression;W.faceDirection;W.faceForward;W.faceforward;const Ale=W.float;W.floor;W.fog;W.fract;W.frameGroup;W.frameId;W.frontFacing;W.fwidth;W.gain;W.gapSize;W.getConstNodeType;W.getCurrentStack;W.getDirection;W.getDistanceAttenuation;W.getGeometryRoughness;W.getNormalFromDepth;W.getParallaxCorrectNormal;W.getRoughness;W.getScreenPosition;W.getShIrradianceAt;W.getTextureIndex;W.getViewPosition;W.glsl;W.glslFn;W.grayscale;W.greaterThan;W.greaterThanEqual;W.hash;W.highpModelNormalViewMatrix;W.highpModelViewMatrix;W.hue;W.instance;const dle=W.instanceIndex;W.instancedArray;W.instancedBufferAttribute;W.instancedDynamicBufferAttribute;W.instancedMesh;W.int;W.inverseSqrt;W.inversesqrt;W.invocationLocalIndex;W.invocationSubgroupIndex;W.ior;W.iridescence;W.iridescenceIOR;W.iridescenceThickness;W.ivec2;W.ivec3;W.ivec4;W.js;W.label;W.length;W.lengthSq;W.lessThan;W.lessThanEqual;W.lightPosition;W.lightTargetDirection;W.lightTargetPosition;W.lightViewPosition;W.lightingContext;W.lights;W.linearDepth;W.linearToneMapping;W.localId;W.log;W.log2;W.logarithmicDepthToViewZ;W.loop;W.luminance;W.mediumpModelViewMatrix;W.mat2;W.mat3;W.mat4;W.matcapUV;W.materialAO;W.materialAlphaTest;W.materialAnisotropy;W.materialAnisotropyVector;W.materialAttenuationColor;W.materialAttenuationDistance;W.materialClearcoat;W.materialClearcoatNormal;W.materialClearcoatRoughness;W.materialColor;W.materialDispersion;W.materialEmissive;W.materialIOR;W.materialIridescence;W.materialIridescenceIOR;W.materialIridescenceThickness;W.materialLightMap;W.materialLineDashOffset;W.materialLineDashSize;W.materialLineGapSize;W.materialLineScale;W.materialLineWidth;W.materialMetalness;W.materialNormal;W.materialOpacity;W.materialPointWidth;W.materialReference;W.materialReflectivity;W.materialRefractionRatio;W.materialRotation;W.materialRoughness;W.materialSheen;W.materialSheenRoughness;W.materialShininess;W.materialSpecular;W.materialSpecularColor;W.materialSpecularIntensity;W.materialSpecularStrength;W.materialThickness;W.materialTransmission;W.max;W.maxMipLevel;W.metalness;W.min;W.mix;W.mixElement;W.mod;W.modInt;W.modelDirection;W.modelNormalMatrix;W.modelPosition;W.modelScale;W.modelViewMatrix;W.modelViewPosition;W.modelViewProjection;W.modelWorldMatrix;W.modelWorldMatrixInverse;W.morphReference;W.mrt;W.mul;W.mx_aastep;W.mx_cell_noise_float;W.mx_contrast;W.mx_fractal_noise_float;W.mx_fractal_noise_vec2;W.mx_fractal_noise_vec3;W.mx_fractal_noise_vec4;W.mx_hsvtorgb;W.mx_noise_float;W.mx_noise_vec3;W.mx_noise_vec4;W.mx_ramplr;W.mx_ramptb;W.mx_rgbtohsv;W.mx_safepower;W.mx_splitlr;W.mx_splittb;W.mx_srgb_texture_to_lin_rec709;W.mx_transform_uv;W.mx_worley_noise_float;W.mx_worley_noise_vec2;W.mx_worley_noise_vec3;const ple=W.negate;W.neutralToneMapping;W.nodeArray;W.nodeImmutable;W.nodeObject;W.nodeObjects;W.nodeProxy;W.normalFlat;W.normalGeometry;W.normalLocal;W.normalMap;W.normalView;W.normalWorld;W.normalize;W.not;W.notEqual;W.numWorkgroups;W.objectDirection;W.objectGroup;W.objectPosition;W.objectScale;W.objectViewPosition;W.objectWorldMatrix;W.oneMinus;W.or;W.orthographicDepthToViewZ;W.oscSawtooth;W.oscSine;W.oscSquare;W.oscTriangle;W.output;W.outputStruct;W.overlay;W.overloadingFn;W.parabola;W.parallaxDirection;W.parallaxUV;W.parameter;W.pass;W.passTexture;W.pcurve;W.perspectiveDepthToViewZ;W.pmremTexture;W.pointUV;W.pointWidth;W.positionGeometry;W.positionLocal;W.positionPrevious;W.positionView;W.positionViewDirection;W.positionWorld;W.positionWorldDirection;W.posterize;W.pow;W.pow2;W.pow3;W.pow4;W.property;W.radians;W.rand;W.range;W.rangeFog;W.rangeFogFactor;W.reciprocal;W.reference;W.referenceBuffer;W.reflect;W.reflectVector;W.reflectView;W.reflector;W.refract;W.refractVector;W.refractView;W.reinhardToneMapping;W.remainder;W.remap;W.remapClamp;W.renderGroup;W.renderOutput;W.rendererReference;W.rotate;W.rotateUV;W.roughness;W.round;W.rtt;W.sRGBTransferEOTF;W.sRGBTransferOETF;W.sampler;W.saturate;W.saturation;W.screen;W.screenCoordinate;W.screenSize;W.screenUV;W.scriptable;W.scriptableValue;W.select;W.setCurrentStack;W.shaderStages;W.shadow;W.shadowPositionWorld;W.sharedUniformGroup;W.sheen;W.sheenRoughness;W.shiftLeft;W.shiftRight;W.shininess;W.sign;const mle=W.sin;W.sinc;W.skinning;W.skinningReference;W.smoothstep;W.smoothstepElement;W.specularColor;W.specularF90;W.spherizeUV;W.split;W.spritesheetUV;const gle=W.sqrt;W.stack;W.step;const vle=W.storage;W.storageBarrier;W.storageObject;W.storageTexture;W.string;W.sub;W.subgroupIndex;W.subgroupSize;W.tan;W.tangentGeometry;W.tangentLocal;W.tangentView;W.tangentWorld;W.temp;W.texture;W.texture3D;W.textureBarrier;W.textureBicubic;W.textureCubeUV;W.textureLoad;W.textureSize;W.textureStore;W.thickness;W.threshold;W.time;W.timerDelta;W.timerGlobal;W.timerLocal;W.toOutputColorSpace;W.toWorkingColorSpace;W.toneMapping;W.toneMappingExposure;W.toonOutlinePass;W.transformDirection;W.transformNormal;W.transformNormalToView;W.transformedBentNormalView;W.transformedBitangentView;W.transformedBitangentWorld;W.transformedClearcoatNormalView;W.transformedNormalView;W.transformedNormalWorld;W.transformedTangentView;W.transformedTangentWorld;W.transmission;W.transpose;W.tri;W.tri3;W.triNoise3D;W.triplanarTexture;W.triplanarTextures;W.trunc;W.tslFn;W.uint;const _le=W.uniform;W.uniformArray;W.uniformGroup;W.uniforms;W.userData;W.uv;W.uvec2;W.uvec3;W.uvec4;W.varying;W.varyingProperty;W.vec2;W.vec3;W.vec4;W.vectorComponents;W.velocity;W.vertexColor;W.vertexIndex;W.vibrance;W.viewZToLogarithmicDepth;W.viewZToOrthographicDepth;W.viewZToPerspectiveDepth;W.viewport;W.viewportBottomLeft;W.viewportCoordinate;W.viewportDepthTexture;W.viewportLinearDepth;W.viewportMipTexture;W.viewportResolution;W.viewportSafeUV;W.viewportSharedTexture;W.viewportSize;W.viewportTexture;W.viewportTopLeft;W.viewportUV;W.wgsl;W.wgslFn;W.workgroupArray;W.workgroupBarrier;W.workgroupId;W.workingToColorSpace;W.xor;const BN=new Gc,wv=new he;class oO extends $z{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Mi(e,3)),this.setAttribute("uv",new Mi(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new h_(t,6,1);return this.setAttribute("instanceStart",new nu(n,3,0)),this.setAttribute("instanceEnd",new nu(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new h_(t,6,1);return this.setAttribute("instanceColorStart",new nu(n,3,0)),this.setAttribute("instanceColorEnd",new nu(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Ez(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Gc);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),BN.setFromBufferAttribute(t),this.boundingBox.union(BN))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new dA),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let s=0,a=e.count;s - #include - #include - #include - #include - - uniform float linewidth; - uniform vec2 resolution; - - attribute vec3 instanceStart; - attribute vec3 instanceEnd; - - attribute vec3 instanceColorStart; - attribute vec3 instanceColorEnd; - - #ifdef WORLD_UNITS - - varying vec4 worldPos; - varying vec3 worldStart; - varying vec3 worldEnd; - - #ifdef USE_DASH - - varying vec2 vUv; - - #endif - - #else - - varying vec2 vUv; - - #endif - - #ifdef USE_DASH - - uniform float dashScale; - attribute float instanceDistanceStart; - attribute float instanceDistanceEnd; - varying float vLineDistance; - - #endif - - void trimSegment( const in vec4 start, inout vec4 end ) { - - // trim end segment so it terminates between the camera plane and the near plane - - // conservative estimate of the near plane - float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column - float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column - float nearEstimate = - 0.5 * b / a; - - float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); - - end.xyz = mix( start.xyz, end.xyz, alpha ); - - } - - void main() { - - #ifdef USE_COLOR - - vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; - - #endif - - #ifdef USE_DASH - - vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; - vUv = uv; - - #endif - - float aspect = resolution.x / resolution.y; - - // camera space - vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); - vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); - - #ifdef WORLD_UNITS - - worldStart = start.xyz; - worldEnd = end.xyz; - - #else - - vUv = uv; - - #endif - - // special case for perspective projection, and segments that terminate either in, or behind, the camera plane - // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space - // but we need to perform ndc-space calculations in the shader, so we must address this issue directly - // perhaps there is a more elegant solution -- WestLangley - - bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column - - if ( perspective ) { - - if ( start.z < 0.0 && end.z >= 0.0 ) { - - trimSegment( start, end ); - - } else if ( end.z < 0.0 && start.z >= 0.0 ) { - - trimSegment( end, start ); - - } - - } - - // clip space - vec4 clipStart = projectionMatrix * start; - vec4 clipEnd = projectionMatrix * end; - - // ndc space - vec3 ndcStart = clipStart.xyz / clipStart.w; - vec3 ndcEnd = clipEnd.xyz / clipEnd.w; - - // direction - vec2 dir = ndcEnd.xy - ndcStart.xy; - - // account for clip-space aspect ratio - dir.x *= aspect; - dir = normalize( dir ); - - #ifdef WORLD_UNITS - - vec3 worldDir = normalize( end.xyz - start.xyz ); - vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); - vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); - vec3 worldFwd = cross( worldDir, worldUp ); - worldPos = position.y < 0.5 ? start: end; - - // height offset - float hw = linewidth * 0.5; - worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; - - // don't extend the line if we're rendering dashes because we - // won't be rendering the endcaps - #ifndef USE_DASH - - // cap extension - worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; - - // add width to the box - worldPos.xyz += worldFwd * hw; - - // endcaps - if ( position.y > 1.0 || position.y < 0.0 ) { - - worldPos.xyz -= worldFwd * 2.0 * hw; - - } - - #endif - - // project the worldpos - vec4 clip = projectionMatrix * worldPos; - - // shift the depth of the projected points so the line - // segments overlap neatly - vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; - clip.z = clipPose.z * clip.w; - - #else - - vec2 offset = vec2( dir.y, - dir.x ); - // undo aspect ratio adjustment - dir.x /= aspect; - offset.x /= aspect; - - // sign flip - if ( position.x < 0.0 ) offset *= - 1.0; - - // endcaps - if ( position.y < 0.0 ) { - - offset += - dir; - - } else if ( position.y > 1.0 ) { - - offset += dir; - - } - - // adjust for linewidth - offset *= linewidth; - - // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... - offset /= resolution.y; - - // select end - vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; - - // back to clip space - offset *= clip.w; - - clip.xy += offset; - - #endif - - gl_Position = clip; - - vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation - - #include - #include - #include - - } - `,fragmentShader:` - uniform vec3 diffuse; - uniform float opacity; - uniform float linewidth; - - #ifdef USE_DASH - - uniform float dashOffset; - uniform float dashSize; - uniform float gapSize; - - #endif - - varying float vLineDistance; - - #ifdef WORLD_UNITS - - varying vec4 worldPos; - varying vec3 worldStart; - varying vec3 worldEnd; - - #ifdef USE_DASH - - varying vec2 vUv; - - #endif - - #else - - varying vec2 vUv; - - #endif - - #include - #include - #include - #include - #include - - vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { - - float mua; - float mub; - - vec3 p13 = p1 - p3; - vec3 p43 = p4 - p3; - - vec3 p21 = p2 - p1; - - float d1343 = dot( p13, p43 ); - float d4321 = dot( p43, p21 ); - float d1321 = dot( p13, p21 ); - float d4343 = dot( p43, p43 ); - float d2121 = dot( p21, p21 ); - - float denom = d2121 * d4343 - d4321 * d4321; - - float numer = d1343 * d4321 - d1321 * d4343; - - mua = numer / denom; - mua = clamp( mua, 0.0, 1.0 ); - mub = ( d1343 + d4321 * ( mua ) ) / d4343; - mub = clamp( mub, 0.0, 1.0 ); - - return vec2( mua, mub ); - - } - - void main() { - - #include - - #ifdef USE_DASH - - if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps - - if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX - - #endif - - float alpha = opacity; - - #ifdef WORLD_UNITS - - // Find the closest points on the view ray and the line segment - vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; - vec3 lineDir = worldEnd - worldStart; - vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); - - vec3 p1 = worldStart + lineDir * params.x; - vec3 p2 = rayEnd * params.y; - vec3 delta = p1 - p2; - float len = length( delta ); - float norm = len / linewidth; - - #ifndef USE_DASH - - #ifdef USE_ALPHA_TO_COVERAGE - - float dnorm = fwidth( norm ); - alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); - - #else - - if ( norm > 0.5 ) { - - discard; - - } - - #endif - - #endif - - #else - - #ifdef USE_ALPHA_TO_COVERAGE - - // artifacts appear on some hardware if a derivative is taken within a conditional - float a = vUv.x; - float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; - float len2 = a * a + b * b; - float dlen = fwidth( len2 ); - - if ( abs( vUv.y ) > 1.0 ) { - - alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); - - } - - #else - - if ( abs( vUv.y ) > 1.0 ) { - - float a = vUv.x; - float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; - float len2 = a * a + b * b; - - if ( len2 > 1.0 ) discard; - - } - - #endif - - #endif - - vec4 diffuseColor = vec4( diffuse, alpha ); - - #include - #include - - gl_FragColor = vec4( diffuseColor.rgb, alpha ); - - #include - #include - #include - #include - - } - `};class qE extends Ja{constructor(e){super({type:"LineMaterial",uniforms:vy.clone(Ga.line.uniforms),vertexShader:Ga.line.vertexShader,fragmentShader:Ga.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const ES=new Ln,ON=new he,IN=new he,Os=new Ln,Is=new Ln,jl=new Ln,CS=new he,RS=new kn,Fs=new Qz,FN=new he,Mv=new Gc,Ev=new dA,Wl=new Ln;let Jl,rA;function kN(i,e,t){return Wl.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),Wl.multiplyScalar(1/Wl.w),Wl.x=rA/t.width,Wl.y=rA/t.height,Wl.applyMatrix4(i.projectionMatrixInverse),Wl.multiplyScalar(1/Wl.w),Math.abs(Math.max(Wl.x,Wl.y))}function yle(i,e){const t=i.matrixWorld,n=i.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,r.count);for(let l=0,u=a;lv&&Is.z>v)continue;if(Os.z>v){const L=Os.z-Is.z,O=(Os.z-v)/L;Os.lerp(Is,O)}else if(Is.z>v){const L=Is.z-Os.z,O=(Is.z-v)/L;Is.lerp(Os,O)}Os.applyMatrix4(n),Is.applyMatrix4(n),Os.multiplyScalar(1/Os.w),Is.multiplyScalar(1/Is.w),Os.x*=s.x/2,Os.y*=s.y/2,Is.x*=s.x/2,Is.y*=s.y/2,Fs.start.copy(Os),Fs.start.z=0,Fs.end.copy(Is),Fs.end.z=0;const R=Fs.closestPointToPointParameter(CS,!0);Fs.at(R,FN);const C=M0.lerp(Os.z,Is.z,R),E=C>=-1&&C<=1,B=CS.distanceTo(FN)i.length)&&(e=i.length);for(var t=0,n=Array(e);t3?(Q=Te===ne)&&(j=ae[(z=ae[4])?5:(z=3,3)],ae[4]=ae[5]=i):ae[0]<=de&&((Q=re<2&&dene||ne>Te)&&(ae[4]=re,ae[5]=ne,ee.n=Te,z=0))}if(Q||re>1)return a;throw Y=!0,ne}return function(re,ne,Q){if(F>1)throw TypeError("Generator is already running");for(Y&&ne===1&&te(ne,Q),z=ne,j=Q;(e=z<2?i:j)||!Y;){q||(z?z<3?(z>1&&(ee.n=-1),te(z,j)):ee.n=j:ee.v=j);try{if(F=2,q){if(z||(re="next"),e=q[re]){if(!(e=e.call(q,j)))throw TypeError("iterator result is not an object");if(!e.done)return e;j=e.value,z<2&&(z=0)}else z===1&&(e=q.return)&&e.call(q),z<2&&(j=TypeError("The iterator does not provide a '"+re+"' method"),z=1);q=i}else if((e=(Y=ee.n<0)?j:L.call(O,ee))!==a)break}catch(ae){q=i,z=1,j=ae}finally{F=1}}return{value:e,done:Y}}})(S,R,C),!0),B}var a={};function l(){}function u(){}function h(){}e=Object.getPrototypeOf;var m=[][n]?e(e([][n]())):(yo(e={},n,function(){return this}),e),v=h.prototype=l.prototype=Object.create(m);function x(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,yo(S,r,"GeneratorFunction")),S.prototype=Object.create(v),S}return u.prototype=h,yo(v,"constructor",h),yo(h,"constructor",u),u.displayName="GeneratorFunction",yo(h,r,"GeneratorFunction"),yo(v),yo(v,r,"Generator"),yo(v,n,function(){return this}),yo(v,"toString",function(){return"[object Generator]"}),(aw=function(){return{w:s,m:x}})()}function yo(i,e,t,n){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}yo=function(s,a,l,u){function h(m,v){yo(s,m,function(x){return this._invoke(m,v,x)})}a?r?r(s,a,{value:l,enumerable:!u,configurable:!u,writable:!u}):s[a]=l:(h("next",0),h("throw",1),h("return",2))},yo(i,e,t,n)}function ow(i,e){return ow=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},ow(i,e)}function gr(i,e){return Ele(i)||Ule(i,e)||hO(i,e)||Ble()}function zle(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=z0(i))!==null;);return i}function PS(i,e,t,n){var r=sw(z0(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function Qi(i){return Cle(i)||Lle(i)||hO(i)||Ole()}function Gle(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function cO(i){var e=Gle(i,"string");return typeof e=="symbol"?e:e+""}function hO(i,e){if(i){if(typeof i=="string")return rw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?rw(i,e):void 0}}var fO=function(e){e instanceof Array?e.forEach(fO):(e.map&&e.map.dispose(),e.dispose())},jE=function(e){e.geometry&&e.geometry.dispose(),e.material&&fO(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(jE)},nr=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),jE(t)}};function wa(i,e){var t=new e;return{linkProp:function(r){return{default:t[r](),onChange:function(a,l){l[i][r](a)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var a=s[i],l=arguments.length,u=new Array(l>1?l-1:0),h=1;h2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180,s=cr*(1+t),a=Math.sin(n);return{x:s*a*Math.cos(r),y:s*Math.cos(n),z:s*a*Math.sin(r)}}function AO(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),a=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),altitude:r/cr-1}}function Vf(i){return i*Math.PI/180}var Dg=window.THREE?window.THREE:{BackSide:hr,BufferAttribute:wr,Color:an,Mesh:zi,ShaderMaterial:Ja},qle=` -uniform float hollowRadius; - -varying vec3 vVertexWorldPosition; -varying vec3 vVertexNormal; -varying float vCameraDistanceToObjCenter; -varying float vVertexAngularDistanceToHollowRadius; - -void main() { - vVertexNormal = normalize(normalMatrix * normal); - vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; - - vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); - vCameraDistanceToObjCenter = length(objCenterViewPosition); - - float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter); - float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition))); - vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle; - - gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); -}`,Vle=` -uniform vec3 color; -uniform float coefficient; -uniform float power; -uniform float hollowRadius; - -varying vec3 vVertexNormal; -varying vec3 vVertexWorldPosition; -varying float vCameraDistanceToObjCenter; -varying float vVertexAngularDistanceToHollowRadius; - -void main() { - if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius - if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius - - vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition; - vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz; - viewCameraToVertex = normalize(viewCameraToVertex); - float intensity = pow( - coefficient + dot(vVertexNormal, viewCameraToVertex), - power - ); - gl_FragColor = vec4(color, intensity); -}`;function Hle(i,e,t,n){return new Dg.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:qle,fragmentShader:Vle,uniforms:{coefficient:{value:i},color:{value:new Dg.Color(e)},power:{value:t},hollowRadius:{value:n}}})}function jle(i,e){for(var t=i.clone(),n=new Float32Array(i.attributes.position.count*3),r=0,s=n.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.color,a=s===void 0?"gold":s,l=r.size,u=l===void 0?2:l,h=r.coefficient,m=h===void 0?.5:h,v=r.power,x=v===void 0?1:v,S=r.hollowRadius,w=S===void 0?0:S,R=r.backside,C=R===void 0?!0:R;nx(this,e),n=tx(this,e);var E=jle(t,u),B=Hle(m,a,x,w);return C&&(B.side=Dg.BackSide),n.geometry=E,n.material=B,n}return rx(e,i),ix(e)})(Dg.Mesh),$l=window.THREE?window.THREE:{Color:an,Group:ja,LineBasicMaterial:$0,LineSegments:j7,Mesh:zi,MeshPhongMaterial:iD,SphereGeometry:Eu,SRGBColorSpace:_n,TextureLoader:rM},dO=xs({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){nr(e.globeObj),nr(e.tileEngine),nr(e.graticulesObj)}},stateInit:function(){var e=new $l.MeshPhongMaterial({color:0}),t=new $l.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new tY(cr),r=new $l.Group;r.__globeObjType="globe",r.add(t),r.add(n);var s=new $l.LineSegments(new cP(_X(),cr,2),new $l.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:r,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){nr(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var r;(r=e.globeObj.geometry)===null||r===void 0||r.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new $l.SphereGeometry(cr,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new $l.TextureLoader().load(e.globeImageUrl,function(l){l.colorSpace=$l.SRGBColorSpace,n.map=l,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new $l.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new $l.TextureLoader().load(e.bumpImageUrl,function(l){n.bumpMap=l,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),nr(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new Wle(e.globeObj.geometry,{color:e.atmosphereColor,size:cr*e.atmosphereAltitude,hollowRadius:cr,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType="atmosphere",e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),wu=function(e){return isNaN(e)?parseInt(yn(e).toHex(),16):e},Rl=function(e){return e&&isNaN(e)?cA(e).opacity:1},jh=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,s=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var l=a.slice(1),u=gr(l,4),h=u[0],m=u[1],v=u[2],x=u[3];r=new an("rgb(".concat(+h,",").concat(+m,",").concat(+v,")")),s=Math.min(+x,1)}else r=new an(e);n&&r.convertLinearToSRGB();var S=r.toArray();return t?[].concat(Qi(S),[s]):S};function $le(i,e,t){return i.opacity=e,i.transparent=e<1,i.depthWrite=e>=1,i}var HN=window.THREE?window.THREE:{BufferAttribute:wr};function Mu(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(e===1)return new HN.BufferAttribute(new t(i),e);for(var n=new HN.BufferAttribute(new t(i.length*e),e),r=0,s=i.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.dataBindAttr,a=s===void 0?"__data":s,l=r.objBindAttr,u=l===void 0?"__threeObj":l,h=r.removeDelay,m=h===void 0?0:h;return nx(this,e),n=tx(this,e),Ps(n,"scene",void 0),NS(n,LS,void 0),NS(n,Cv,void 0),NS(n,Rv,void 0),n.scene=t,DS(LS,n,a),DS(Cv,n,u),DS(Rv,n,m),n.onRemoveObj(function(){}),n}return rx(e,i),ix(e,[{key:"onCreateObj",value:function(n){var r=this;return PS(e,"onCreateObj",this)([function(s){var a=n(s);return s[mm(Cv,r)]=a,a[mm(LS,r)]=s,r.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return PS(e,"onRemoveObj",this)([function(s,a){var l=PS(e,"getData",r)([s]);n(s,a);var u=function(){r.scene.remove(s),nr(s),delete l[mm(Cv,r)]};mm(Rv,r)?setTimeout(u,mm(Rv,r)):u()}]),this}}])})(NQ),_l=window.THREE?window.THREE:{BufferGeometry:Ki,CylinderGeometry:eM,Matrix4:kn,Mesh:zi,MeshLambertMaterial:Vc,Object3D:vr,Vector3:he},jN=Object.assign({},yM),WN=jN.BufferGeometryUtils||jN,pO=xs({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;nr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new ao(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var n=Rt(e.pointLat),r=Rt(e.pointLng),s=Rt(e.pointAltitude),a=Rt(e.pointRadius),l=Rt(e.pointColor),u=new _l.CylinderGeometry(1,1,1,e.pointResolution);u.applyMatrix4(new _l.Matrix4().makeRotationX(Math.PI/2)),u.applyMatrix4(new _l.Matrix4().makeTranslation(0,0,-.5));var h=2*Math.PI*cr/360,m={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&nr(e.scene),e.dataMapper.scene=e.pointsMerge?new _l.Object3D:e.scene,e.dataMapper.onCreateObj(S).onUpdateObj(w).digest(e.pointsData),e.pointsMerge){var v=e.pointsData.length?(WN.mergeGeometries||WN.mergeBufferGeometries)(e.pointsData.map(function(R){var C=e.dataMapper.getObj(R),E=C.geometry.clone();C.updateMatrix(),E.applyMatrix4(C.matrix);var B=jh(l(R));return E.setAttribute("color",Mu(Array(E.getAttribute("position").count).fill(B),4)),E})):new _l.BufferGeometry,x=new _l.Mesh(v,new _l.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));x.__globeObjType="points",x.__data=e.pointsData,e.dataMapper.clear(),nr(e.scene),e.scene.add(x)}function S(){var R=new _l.Mesh(u);return R.__globeObjType="point",R}function w(R,C){var E=function(j){var F=R.__currentTargetD=j,V=F.r,Y=F.alt,ee=F.lat,te=F.lng;Object.assign(R.position,el(ee,te));var re=e.pointsMerge?new _l.Vector3(0,0,0):e.scene.localToWorld(new _l.Vector3(0,0,0));R.lookAt(re),R.scale.x=R.scale.y=Math.min(30,V)*h,R.scale.z=Math.max(Y*cr,.1)},B={alt:+s(C),r:+a(C),lat:+n(C),lng:+r(C)},L=R.__currentTargetD||Object.assign({},B,{alt:-.001});if(Object.keys(B).some(function(z){return L[z]!==B[z]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?E(B):e.tweenGroup.add(new ca(L).to(B,e.pointsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(E).start())),!e.pointsMerge){var O=l(C),G=O?Rl(O):0,q=!!G;R.visible=q,q&&(m.hasOwnProperty(O)||(m[O]=new _l.MeshLambertMaterial({color:wu(O),transparent:G<1,opacity:G})),R.material=m[O])}}}}),mO=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` - `.concat(Zn.common,` - `).concat(Zn.logdepthbuf_pars_vertex,` - - uniform float dashTranslate; - - attribute vec4 color; - varying vec4 vColor; - - attribute float relDistance; - varying float vRelDistance; - - void main() { - // pass through colors and distances - vColor = color; - vRelDistance = relDistance + dashTranslate; - gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); - - `).concat(Zn.logdepthbuf_vertex,` - } - `),fragmentShader:` - `.concat(Zn.logdepthbuf_pars_fragment,` - - uniform float dashOffset; - uniform float dashSize; - uniform float gapSize; - - varying vec4 vColor; - varying float vRelDistance; - - void main() { - // ignore pixels in the gap - if (vRelDistance < dashOffset) discard; - if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard; - - // set px color: [r, g, b, a], interpolated between vertices - gl_FragColor = vColor; - - `).concat(Zn.logdepthbuf_fragment,` - } - `)}},lw=function(e){return e.uniforms.uSurfaceRadius={type:"float",value:0},e.vertexShader=(`attribute float surfaceRadius; -varying float vSurfaceRadius; -varying vec3 vPos; -`+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join(` -`)),e.fragmentShader=(`uniform float uSurfaceRadius; -varying float vSurfaceRadius; -varying vec3 vPos; -`+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;"].join(` -`)),e},Yle=function(e){return e.vertexShader=` - attribute float r; - - const float PI = 3.1415926535897932384626433832795; - float toRad(in float a) { - return a * PI / 180.0; - } - - vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r] - float phi = toRad(90.0 - c.x); - float theta = toRad(90.0 - c.y); - float r = c.z; - return vec3( // x,y,z - r * sin(phi) * cos(theta), - r * cos(phi), - r * sin(phi) * sin(theta) - ); - } - - vec2 Cartesian2Polar(in vec3 p) { - float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z); - float phi = acos(p.y / r); - float theta = atan(p.z, p.x); - return vec2( // lat,lng - 90.0 - phi * 180.0 / PI, - 90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0) - ); - } - `.concat(e.vertexShader.replace("}",` - vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r)); - gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); - } - `),` - `),e},WE=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},Qle=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(r){return r};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(r){n(r),t(r.uniforms)}}},Kle=["stroke"],yl=window.THREE?window.THREE:{BufferGeometry:Ki,CubicBezierCurve3:X7,Curve:Pl,Group:ja,Line:xy,Mesh:zi,NormalBlending:Ka,ShaderMaterial:Ja,TubeGeometry:nM,Vector3:he},Zle=L0.default||L0,gO=xs({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new Zle,sharedMaterial:new yl.ShaderMaterial(Hi(Hi({},mO()),{},{transparent:!0,blending:yl.NormalBlending}))}},init:function(e,t){nr(e),t.scene=e,t.dataMapper=new ao(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var n=new yl.Group;return n.__globeObjType="arc",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=gr(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r,u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l})})},update:function(e){var t=Rt(e.arcStartLat),n=Rt(e.arcStartLng),r=Rt(e.arcStartAltitude),s=Rt(e.arcEndLat),a=Rt(e.arcEndLng),l=Rt(e.arcEndAltitude),u=Rt(e.arcAltitude),h=Rt(e.arcAltitudeAutoScale),m=Rt(e.arcStroke),v=Rt(e.arcColor),x=Rt(e.arcDashLength),S=Rt(e.arcDashGap),w=Rt(e.arcDashInitialGap),R=Rt(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(L,O){var G=m(O),q=G!=null;if(!L.children.length||q!==(L.children[0].type==="Mesh")){nr(L);var z=q?new yl.Mesh:new yl.Line(new yl.BufferGeometry);z.material=e.sharedMaterial.clone(),L.add(z)}var j=L.children[0];Object.assign(j.material.uniforms,{dashSize:{value:x(O)},gapSize:{value:S(O)},dashOffset:{value:w(O)}});var F=R(O);j.__dashAnimateStep=F>0?1e3/F:0;var V=E(v(O),e.arcCurveResolution,q?e.arcCircularResolution+1:1),Y=B(e.arcCurveResolution,q?e.arcCircularResolution+1:1,!0);j.geometry.setAttribute("color",V),j.geometry.setAttribute("relDistance",Y);var ee=function(Q){var ae=L.__currentTargetD=Q,de=ae.stroke,Te=Ile(ae,Kle),be=C(Te);q?(j.geometry&&j.geometry.dispose(),j.geometry=new yl.TubeGeometry(be,e.arcCurveResolution,de/2,e.arcCircularResolution),j.geometry.setAttribute("color",V),j.geometry.setAttribute("relDistance",Y)):j.geometry.setFromPoints(be.getPoints(e.arcCurveResolution))},te={stroke:G,alt:u(O),altAutoScale:+h(O),startLat:+t(O),startLng:+n(O),startAlt:+r(O),endLat:+s(O),endLng:+a(O),endAlt:+l(O)},re=L.__currentTargetD||Object.assign({},te,{altAutoScale:-.001});Object.keys(te).some(function(ne){return re[ne]!==te[ne]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?ee(te):e.tweenGroup.add(new ca(re).to(te,e.arcsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(ee).start()))}).digest(e.arcsData);function C(L){var O=L.alt,G=L.altAutoScale,q=L.startLat,z=L.startLng,j=L.startAlt,F=L.endLat,V=L.endLng,Y=L.endAlt,ee=function(Se){var Ce=gr(Se,3),dt=Ce[0],At=Ce[1],wt=Ce[2],Ft=el(At,dt,wt),$e=Ft.x,rt=Ft.y,ce=Ft.z;return new yl.Vector3($e,rt,ce)},te=[z,q],re=[V,F],ne=O;if(ne==null&&(ne=Vh(te,re)/2*G+Math.max(j,Y)),ne||j||Y){var Q=pM(te,re),ae=function(Se,Ce){return Ce+(Ce-Se)*(Se2&&arguments[2]!==void 0?arguments[2]:1,q=O+1,z;if(L instanceof Array||L instanceof Function){var j=L instanceof Array?Pc().domain(L.map(function(ne,Q){return Q/(L.length-1)})).range(L):L;z=function(Q){return jh(j(Q),!0,!0)}}else{var F=jh(L,!0,!0);z=function(){return F}}for(var V=[],Y=0,ee=q;Y1&&arguments[1]!==void 0?arguments[1]:1,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,q=L+1,z=[],j=0,F=q;j=j?G:q}),4)),O})):new wh.BufferGeometry,w=new wh.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:wh.DoubleSide});w.onBeforeCompile=function(B){w.userData.shader=lw(B)};var R=new wh.Mesh(S,w);R.__globeObjType="hexBinPoints",R.__data=v,e.dataMapper.clear(),nr(e.scene),e.scene.add(R)}function C(B){var L=new wh.Mesh;L.__hexCenter=RP(B.h3Idx),L.__hexGeoJson=NP(B.h3Idx,!0).reverse();var O=L.__hexCenter[1];return L.__hexGeoJson.forEach(function(G){var q=G[0];Math.abs(O-q)>170&&(G[0]+=O>q?360:-360)}),L.__globeObjType="hexbin",L}function E(B,L){var O=function(ae,de,Te){return ae-(ae-de)*Te},G=Math.max(0,Math.min(1,+h(L))),q=gr(B.__hexCenter,2),z=q[0],j=q[1],F=G===0?B.__hexGeoJson:B.__hexGeoJson.map(function(Q){var ae=gr(Q,2),de=ae[0],Te=ae[1];return[[de,j],[Te,z]].map(function(be){var ue=gr(be,2),we=ue[0],We=ue[1];return O(we,We,G)})}),V=e.hexTopCurvatureResolution;B.geometry&&B.geometry.dispose(),B.geometry=new wM([F],0,cr,!1,!0,!0,V);var Y={alt:+a(L)},ee=function(ae){var de=B.__currentTargetD=ae,Te=de.alt;B.scale.x=B.scale.y=B.scale.z=1+Te;var be=cr/(Te+1);B.geometry.setAttribute("surfaceRadius",Mu(Array(B.geometry.getAttribute("position").count).fill(be),1))},te=B.__currentTargetD||Object.assign({},Y,{alt:-.001});if(Object.keys(Y).some(function(Q){return te[Q]!==Y[Q]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?ee(Y):e.tweenGroup.add(new ca(te).to(Y,e.hexTransitionDuration).easing(os.Quadratic.InOut).onUpdate(ee).start())),!e.hexBinMerge){var re=u(L),ne=l(L);[re,ne].forEach(function(Q){if(!x.hasOwnProperty(Q)){var ae=Rl(Q);x[Q]=WE(new wh.MeshLambertMaterial({color:wu(Q),transparent:ae<1,opacity:ae,side:wh.DoubleSide}),lw)}}),B.material=[re,ne].map(function(Q){return x[Q]})}}}}),_O=function(e){return e*e},wc=function(e){return e*Math.PI/180};function Jle(i,e){var t=Math.sqrt,n=Math.cos,r=function(m){return _O(Math.sin(m/2))},s=wc(i[1]),a=wc(e[1]),l=wc(i[0]),u=wc(e[0]);return 2*Math.asin(t(r(a-s)+n(s)*n(a)*r(u-l)))}var eue=Math.sqrt(2*Math.PI);function tue(i,e){return Math.exp(-_O(i/e)/2)/(e*eue)}var nue=function(e){var t=gr(e,2),n=t[0],r=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},l=a.lngAccessor,u=l===void 0?function(C){return C[0]}:l,h=a.latAccessor,m=h===void 0?function(C){return C[1]}:h,v=a.weightAccessor,x=v===void 0?function(){return 1}:v,S=a.bandwidth,w=[n,r],R=S*Math.PI/180;return YW(s.map(function(C){var E=x(C);if(!E)return 0;var B=Jle(w,[u(C),m(C)]);return tue(B,R)*E}))},iue=(function(){var i=Nle(aw().m(function e(t){var n,r,s,a,l,u,h,m,v,x,S,w,R,C,E,B,L,O,G,q,z,j,F,V,Y,ee,te,re,ne,Q,ae,de,Te,be,ue,we,We,Ne,ze,Se,Ce=arguments,dt,At,wt;return aw().w(function(Ft){for(;;)switch(Ft.n){case 0:if(r=Ce.length>1&&Ce[1]!==void 0?Ce[1]:[],s=Ce.length>2&&Ce[2]!==void 0?Ce[2]:{},a=s.lngAccessor,l=a===void 0?function($e){return $e[0]}:a,u=s.latAccessor,h=u===void 0?function($e){return $e[1]}:u,m=s.weightAccessor,v=m===void 0?function(){return 1}:m,x=s.bandwidth,(n=navigator)!==null&&n!==void 0&&n.gpu){Ft.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),Ft.a(2,t.map(function($e){return nue($e,r,{lngAccessor:l,latAccessor:h,weightAccessor:v,bandwidth:x})}));case 1:return S=4,w=ole,R=lle,C=_le,E=vle,B=Ale,L=dle,O=ule,G=gle,q=mle,z=hle,j=cle,F=fle,V=ple,Y=E(new t_(new Float32Array(t.flat().map(wc)),2),"vec2",t.length),ee=E(new t_(new Float32Array(r.map(function($e){return[wc(l($e)),wc(h($e)),v($e)]}).flat()),3),"vec3",r.length),te=new t_(t.length,1),re=E(te,"float",t.length),ne=B(Math.PI),Q=G(ne.mul(2)),ae=function(rt){return rt.mul(rt)},de=function(rt){return ae(q(rt.div(2)))},Te=function(rt,ce){var Gt=B(rt[1]),ht=B(ce[1]),Pt=B(rt[0]),yt=B(ce[0]);return B(2).mul(j(G(de(ht.sub(Gt)).add(z(Gt).mul(z(ht)).mul(de(yt.sub(Pt)))))))},be=function(rt,ce){return F(V(ae(rt.div(ce)).div(2))).div(ce.mul(Q))},ue=C(wc(x)),we=C(wc(x*S)),We=C(r.length),Ne=w(function(){var $e=Y.element(L),rt=re.element(L);rt.assign(0),O(We,function(ce){var Gt=ce.i,ht=ee.element(Gt),Pt=ht.z;R(Pt,function(){var yt=Te(ht.xy,$e.xy);R(yt&&yt.lessThan(we),function(){rt.addAssign(be(yt,ue).mul(Pt))})})})}),ze=Ne().compute(t.length),Se=new aO,Ft.n=2,Se.computeAsync(ze);case 2:return dt=Array,At=Float32Array,Ft.n=3,Se.getArrayBufferAsync(te);case 3:return wt=Ft.v,Ft.a(2,dt.from.call(dt,new At(wt)))}},e)}));return function(t){return i.apply(this,arguments)}})(),Nv=window.THREE?window.THREE:{Mesh:zi,MeshLambertMaterial:Vc,SphereGeometry:Eu},rue=3.5,sue=.1,YN=100,aue=function(e){var t=cA(kZ(e));return t.opacity=Math.cbrt(e),t.formatRgb()},yO=xs({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return aue}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;nr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new ao(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var s=new Nv.Mesh(new Nv.SphereGeometry(cr),WE(new Nv.MeshLambertMaterial({vertexColors:!0,transparent:!0}),Yle));return s.__globeObjType="heatmap",s})},update:function(e){var t=Rt(e.heatmapPoints),n=Rt(e.heatmapPointLat),r=Rt(e.heatmapPointLng),s=Rt(e.heatmapPointWeight),a=Rt(e.heatmapBandwidth),l=Rt(e.heatmapColorFn),u=Rt(e.heatmapColorSaturation),h=Rt(e.heatmapBaseAltitude),m=Rt(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(v,x){var S=a(x),w=l(x),R=u(x),C=h(x),E=m(x),B=t(x).map(function(z){var j=n(z),F=r(z),V=el(j,F),Y=V.x,ee=V.y,te=V.z;return{x:Y,y:ee,z:te,lat:j,lng:F,weight:s(z)}}),L=Math.max(sue,S/rue),O=Math.ceil(360/(L||-1));v.geometry.parameters.widthSegments!==O&&(v.geometry.dispose(),v.geometry=new Nv.SphereGeometry(cr,O,O/2));var G=Xle(v.geometry.getAttribute("position")),q=G.map(function(z){var j=gr(z,3),F=j[0],V=j[1],Y=j[2],ee=AO({x:F,y:V,z:Y}),te=ee.lng,re=ee.lat;return[te,re]});iue(q,B,{latAccessor:function(j){return j.lat},lngAccessor:function(j){return j.lng},weightAccessor:function(j){return j.weight},bandwidth:S}).then(function(z){var j=Qi(new Array(YN)).map(function(ee,te){return jh(w(te/(YN-1)))}),F=function(te){var re=v.__currentTargetD=te,ne=re.kdeVals,Q=re.topAlt,ae=re.saturation,de=WW(ne.map(Math.abs))||1e-15,Te=ND([0,de/ae],j);v.geometry.setAttribute("color",Mu(ne.map(function(ue){return Te(Math.abs(ue))}),4));var be=Pc([0,de],[cr*(1+C),cr*(1+(Q||C))]);v.geometry.setAttribute("r",Mu(ne.map(be)))},V={kdeVals:z,topAlt:E,saturation:R},Y=v.__currentTargetD||Object.assign({},V,{kdeVals:z.map(function(){return 0}),topAlt:E&&C,saturation:.5});Y.kdeVals.length!==z.length&&(Y.kdeVals=z.slice()),Object.keys(V).some(function(ee){return Y[ee]!==V[ee]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?F(V):e.tweenGroup.add(new ca(Y).to(V,e.heatmapsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(F).start()))})}).digest(e.heatmapsData)}}),Mh=window.THREE?window.THREE:{DoubleSide:as,Group:ja,LineBasicMaterial:$0,LineSegments:j7,Mesh:zi,MeshBasicMaterial:pA},xO=xs({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;nr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new ao(e,{objBindAttr:"__threeObjPolygon"}).id(function(s){return s.id}).onCreateObj(function(){var s=new Mh.Group;return s.__defaultSideMaterial=WE(new Mh.MeshBasicMaterial({side:Mh.DoubleSide,depthWrite:!0}),lw),s.__defaultCapMaterial=new Mh.MeshBasicMaterial({side:Mh.DoubleSide,depthWrite:!0}),s.add(new Mh.Mesh(void 0,[s.__defaultSideMaterial,s.__defaultCapMaterial])),s.add(new Mh.LineSegments(void 0,new Mh.LineBasicMaterial)),s.__globeObjType="polygon",s})},update:function(e){var t=Rt(e.polygonGeoJsonGeometry),n=Rt(e.polygonAltitude),r=Rt(e.polygonCapCurvatureResolution),s=Rt(e.polygonCapColor),a=Rt(e.polygonCapMaterial),l=Rt(e.polygonSideColor),u=Rt(e.polygonSideMaterial),h=Rt(e.polygonStrokeColor),m=[];e.polygonsData.forEach(function(v){var x={data:v,capColor:s(v),capMaterial:a(v),sideColor:l(v),sideMaterial:u(v),strokeColor:h(v),altitude:+n(v),capCurvatureResolution:+r(v)},S=t(v),w=v.__id||"".concat(Math.round(Math.random()*1e9));v.__id=w,S.type==="Polygon"?m.push(Hi({id:"".concat(w,"_0"),coords:S.coordinates},x)):S.type==="MultiPolygon"?m.push.apply(m,Qi(S.coordinates.map(function(R,C){return Hi({id:"".concat(w,"_").concat(C),coords:R},x)}))):console.warn("Unsupported GeoJson geometry type: ".concat(S.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(v,x){var S=x.coords,w=x.capColor,R=x.capMaterial,C=x.sideColor,E=x.sideMaterial,B=x.strokeColor,L=x.altitude,O=x.capCurvatureResolution,G=gr(v.children,2),q=G[0],z=G[1],j=!!B;z.visible=j;var F=!!(w||R),V=!!(C||E);oue(q.geometry.parameters||{},{polygonGeoJson:S,curvatureResolution:O,closedTop:F,includeSides:V})||(q.geometry&&q.geometry.dispose(),q.geometry=new wM(S,0,cr,!1,F,V,O)),j&&(!z.geometry.parameters||z.geometry.parameters.geoJson.coordinates!==S||z.geometry.parameters.resolution!==O)&&(z.geometry&&z.geometry.dispose(),z.geometry=new cP({type:"Polygon",coordinates:S},cr,O));var Y=V?0:-1,ee=F?V?1:0:-1;if(Y>=0&&(q.material[Y]=E||v.__defaultSideMaterial),ee>=0&&(q.material[ee]=R||v.__defaultCapMaterial),[[!E&&C,Y],[!R&&w,ee]].forEach(function(de){var Te=gr(de,2),be=Te[0],ue=Te[1];if(!(!be||ue<0)){var we=q.material[ue],We=Rl(be);we.color.set(wu(be)),we.transparent=We<1,we.opacity=We}}),j){var te=z.material,re=Rl(B);te.color.set(wu(B)),te.transparent=re<1,te.opacity=re}var ne={alt:L},Q=function(Te){var be=v.__currentTargetD=Te,ue=be.alt;q.scale.x=q.scale.y=q.scale.z=1+ue,j&&(z.scale.x=z.scale.y=z.scale.z=1+ue+1e-4),Qle(v.__defaultSideMaterial,function(we){return we.uSurfaceRadius.value=cr/(ue+1)})},ae=v.__currentTargetD||Object.assign({},ne,{alt:-.001});Object.keys(ne).some(function(de){return ae[de]!==ne[de]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||ae.alt===ne.alt?Q(ne):e.tweenGroup.add(new ca(ae).to(ne,e.polygonsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(Q).start()))}).digest(m)}});function oue(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(n,r){return n===r}};return Object.entries(e).every(function(n){var r=gr(n,2),s=r[0],a=r[1];return i.hasOwnProperty(s)&&t(s)(i[s],a)})}var Bd=window.THREE?window.THREE:{BufferGeometry:Ki,DoubleSide:as,Mesh:zi,MeshLambertMaterial:Vc,Vector3:he},QN=Object.assign({},yM),KN=QN.BufferGeometryUtils||QN,bO=xs({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;nr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new ao(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var s=new Bd.Mesh(void 0,new Bd.MeshLambertMaterial({side:Bd.DoubleSide}));return s.__globeObjType="hexPolygon",s})},update:function(e){var t=Rt(e.hexPolygonGeoJsonGeometry),n=Rt(e.hexPolygonColor),r=Rt(e.hexPolygonAltitude),s=Rt(e.hexPolygonResolution),a=Rt(e.hexPolygonMargin),l=Rt(e.hexPolygonUseDots),u=Rt(e.hexPolygonCurvatureResolution),h=Rt(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(m,v){var x=t(v),S=s(v),w=r(v),R=Math.max(0,Math.min(1,+a(v))),C=l(v),E=u(v),B=h(v),L=n(v),O=Rl(L);m.material.color.set(wu(L)),m.material.transparent=O<1,m.material.opacity=O;var G={alt:w,margin:R,curvatureResolution:E},q={geoJson:x,h3Res:S},z=m.__currentTargetD||Object.assign({},G,{alt:-.001}),j=m.__currentMemD||q;if(Object.keys(G).some(function(ee){return z[ee]!==G[ee]})||Object.keys(q).some(function(ee){return j[ee]!==q[ee]})){m.__currentMemD=q;var F=[];x.type==="Polygon"?R6(x.coordinates,S,!0).forEach(function(ee){return F.push(ee)}):x.type==="MultiPolygon"?x.coordinates.forEach(function(ee){return R6(ee,S,!0).forEach(function(te){return F.push(te)})}):console.warn("Unsupported GeoJson geometry type: ".concat(x.type,". Skipping geometry..."));var V=F.map(function(ee){var te=RP(ee),re=NP(ee,!0).reverse(),ne=te[1];return re.forEach(function(Q){var ae=Q[0];Math.abs(ne-ae)>170&&(Q[0]+=ne>ae?360:-360)}),{h3Idx:ee,hexCenter:te,hexGeoJson:re}}),Y=function(te){var re=m.__currentTargetD=te,ne=re.alt,Q=re.margin,ae=re.curvatureResolution;m.geometry&&m.geometry.dispose(),m.geometry=V.length?(KN.mergeGeometries||KN.mergeBufferGeometries)(V.map(function(de){var Te=gr(de.hexCenter,2),be=Te[0],ue=Te[1];if(C){var we=el(be,ue,ne),We=el(de.hexGeoJson[0][1],de.hexGeoJson[0][0],ne),Ne=.85*(1-Q)*new Bd.Vector3(we.x,we.y,we.z).distanceTo(new Bd.Vector3(We.x,We.y,We.z)),ze=new by(Ne,B);return ze.rotateX(Vf(-be)),ze.rotateY(Vf(ue)),ze.translate(we.x,we.y,we.z),ze}else{var Se=function(At,wt,Ft){return At-(At-wt)*Ft},Ce=Q===0?de.hexGeoJson:de.hexGeoJson.map(function(dt){var At=gr(dt,2),wt=At[0],Ft=At[1];return[[wt,ue],[Ft,be]].map(function($e){var rt=gr($e,2),ce=rt[0],Gt=rt[1];return Se(ce,Gt,Q)})});return new wM([Ce],cr,cr*(1+ne),!1,!0,!1,ae)}})):new Bd.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?Y(G):e.tweenGroup.add(new ca(z).to(G,e.hexPolygonsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(Y).start())}}).digest(e.hexPolygonsData)}}),lue=window.THREE?window.THREE:{Vector3:he};function uue(i,e){var t=function(a,l){var u=a[a.length-1];return[].concat(Qi(a),Qi(Array(l-a.length).fill(u)))},n=Math.max(i.length,e.length),r=h$.apply(void 0,Qi([i,e].map(function(s){return s.map(function(a){var l=a.x,u=a.y,h=a.z;return[l,u,h]})}).map(function(s){return t(s,n)})));return function(s){return s===0?i:s===1?e:r(s).map(function(a){var l=gr(a,3),u=l[0],h=l[1],m=l[2];return new lue.Vector3(u,h,m)})}}var Pf=window.THREE?window.THREE:{BufferGeometry:Ki,Color:an,Group:ja,Line:xy,NormalBlending:Ka,ShaderMaterial:Ja,Vector3:he},cue=L0.default||L0,SO=xs({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new cue,sharedMaterial:new Pf.ShaderMaterial(Hi(Hi({},mO()),{},{transparent:!0,blending:Pf.NormalBlending}))}},init:function(e,t){nr(e),t.scene=e,t.dataMapper=new ao(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var n=new Pf.Group;return n.__globeObjType="path",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=gr(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r;if(a.type==="Line"){var u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l}else if(a.type==="Line2"){for(var h=a.material.dashOffset-l,m=a.material.dashSize+a.material.gapSize;h<=-m;)h+=m;a.material.dashOffset=h}})})},update:function(e){var t=Rt(e.pathPoints),n=Rt(e.pathPointLat),r=Rt(e.pathPointLng),s=Rt(e.pathPointAlt),a=Rt(e.pathStroke),l=Rt(e.pathColor),u=Rt(e.pathDashLength),h=Rt(e.pathDashGap),m=Rt(e.pathDashInitialGap),v=Rt(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(C,E){var B=a(E),L=B!=null;if(!C.children.length||L===(C.children[0].type==="Line")){nr(C);var O=L?new Sle(new lO,new qE):new Pf.Line(new Pf.BufferGeometry,e.sharedMaterial.clone());C.add(O)}var G=C.children[0],q=S(t(E),n,r,s,e.pathResolution),z=v(E);if(G.__dashAnimateStep=z>0?1e3/z:0,L){G.material.resolution=e.rendererSize;{var V=u(E),Y=h(E),ee=m(E);G.material.dashed=Y>0,G.material.dashed?G.material.defines.USE_DASH="":delete G.material.defines.USE_DASH,G.material.dashed&&(G.material.dashScale=1/x(q),G.material.dashSize=V,G.material.gapSize=Y,G.material.dashOffset=-ee)}{var te=l(E);if(te instanceof Array){var re=w(l(E),q.length-1,1,!1);G.geometry.setColors(re.array),G.material.vertexColors=!0}else{var ne=te,Q=Rl(ne);G.material.color=new Pf.Color(wu(ne)),G.material.transparent=Q<1,G.material.opacity=Q,G.material.vertexColors=!1}}G.material.needsUpdate=!0}else{Object.assign(G.material.uniforms,{dashSize:{value:u(E)},gapSize:{value:h(E)},dashOffset:{value:m(E)}});var j=w(l(E),q.length),F=R(q.length,1,!0);G.geometry.setAttribute("color",j),G.geometry.setAttribute("relDistance",F)}var ae=uue(C.__currentTargetD&&C.__currentTargetD.points||[q[0]],q),de=function(we){var We=C.__currentTargetD=we,Ne=We.stroke,ze=We.interpolK,Se=C.__currentTargetD.points=ae(ze);if(L){var Ce;G.geometry.setPositions((Ce=[]).concat.apply(Ce,Qi(Se.map(function(dt){var At=dt.x,wt=dt.y,Ft=dt.z;return[At,wt,Ft]})))),G.material.linewidth=Ne,G.material.dashed&&G.computeLineDistances()}else G.geometry.setFromPoints(Se),G.geometry.computeBoundingSphere()},Te={stroke:B,interpolK:1},be=Object.assign({},C.__currentTargetD||Te,{interpolK:0});Object.keys(Te).some(function(ue){return be[ue]!==Te[ue]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?de(Te):e.tweenGroup.add(new ca(be).to(Te,e.pathTransitionDuration).easing(os.Quadratic.InOut).onUpdate(de).start()))}).digest(e.pathsData);function x(C){var E=0,B;return C.forEach(function(L){B&&(E+=B.distanceTo(L)),B=L}),E}function S(C,E,B,L,O){var G=function(F,V,Y){for(var ee=[],te=1;te<=Y;te++)ee.push(F+(V-F)*te/(Y+1));return ee},q=function(){var F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Y=[],ee=null;return F.forEach(function(te){if(ee){for(;Math.abs(ee[1]-te[1])>180;)ee[1]+=360*(ee[1]V)for(var ne=Math.floor(re/V),Q=G(ee[0],te[0],ne),ae=G(ee[1],te[1],ne),de=G(ee[2],te[2],ne),Te=0,be=Q.length;Te2&&arguments[2]!==void 0?arguments[2]:1,L=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,O=E+1,G;if(C instanceof Array||C instanceof Function){var q=C instanceof Array?Pc().domain(C.map(function(te,re){return re/(C.length-1)})).range(C):C;G=function(re){return jh(q(re),L,!0)}}else{var z=jh(C,L,!0);G=function(){return z}}for(var j=[],F=0,V=O;F1&&arguments[1]!==void 0?arguments[1]:1,B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,L=C+1,O=[],G=0,q=L;G0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;nx(this,e),t=tx(this,e),t.type="CircleLineGeometry",t.parameters={radius:n,segmentCount:r};for(var s=[],a=0;a<=r;a++){var l=(a/r-.25)*Math.PI*2;s.push({x:Math.cos(l)*n,y:Math.sin(l)*n,z:0})}return t.setFromPoints(s),t}return rx(e,i),ix(e)})(hue.BufferGeometry),Id=window.THREE?window.THREE:{Color:an,Group:ja,Line:xy,LineBasicMaterial:$0,Vector3:he},Aue=L0.default||L0,MO=xs({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;nr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new ao(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var s=new Id.Group;return s.__globeObjType="ring",s}),t.ticker=new Aue,t.ticker.onTick.add(function(s){if(t.ringsData.length){var a=Rt(t.ringColor),l=Rt(t.ringAltitude),u=Rt(t.ringMaxRadius),h=Rt(t.ringPropagationSpeed),m=Rt(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(v){var x=gr(v,2),S=x[1];return S}).forEach(function(v){var x=gr(v,2),S=x[0],w=x[1];if((w.__nextRingTime||0)<=s){var R=m(S)/1e3;w.__nextRingTime=s+(R<=0?1/0:R);var C=new Id.Line(new fue(1,t.ringResolution),new Id.LineBasicMaterial),E=a(S),B=E instanceof Array||E instanceof Function,L;B?E instanceof Array?(L=Pc().domain(E.map(function(Y,ee){return ee/(E.length-1)})).range(E),C.material.transparent=E.some(function(Y){return Rl(Y)<1})):(L=E,C.material.transparent=!0):(C.material.color=new Id.Color(wu(E)),$le(C.material,Rl(E)));var O=cr*(1+l(S)),G=u(S),q=G*Math.PI/180,z=h(S),j=z<=0,F=function(ee){var te=ee.t,re=(j?1-te:te)*q;if(C.scale.x=C.scale.y=O*Math.sin(re),C.position.z=O*(1-Math.cos(re)),B){var ne=L(te);C.material.color=new Id.Color(wu(ne)),C.material.transparent&&(C.material.opacity=Rl(ne))}};if(z===0)F({t:0}),w.add(C);else{var V=Math.abs(G/z)*1e3;t.tweenGroup.add(new ca({t:0}).to({t:1},V).onUpdate(F).onStart(function(){return w.add(C)}).onComplete(function(){w.remove(C),jE(C)}).start())}}})}})},update:function(e){var t=Rt(e.ringLat),n=Rt(e.ringLng),r=Rt(e.ringAltitude),s=e.scene.localToWorld(new Id.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(a,l){var u=t(l),h=n(l),m=r(l);Object.assign(a.position,el(u,h,m)),a.lookAt(s)}).digest(e.ringsData)}}),due={0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},pue="normal",mue=1189,gue=-100,vue="normal",_ue={yMin:-334,xMin:-111,yMax:1189,xMax:1672},yue=1e3,xue={postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r -\r -Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r -\r -The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r -\r -The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r -\r -This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r -\r -The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r -\r -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},bue=-334,Sue="Helvetiker",Tue=1522,wue=50,Mue={glyphs:due,cssFontWeight:pue,ascender:mue,underlinePosition:gue,cssFontStyle:vue,boundingBox:_ue,resolution:yue,original_font_information:xue,descender:bue,familyName:Sue,lineHeight:Tue,underlineThickness:wue},xl=Hi(Hi({},window.THREE?window.THREE:{BoxGeometry:$h,CircleGeometry:by,DoubleSide:as,Group:ja,Mesh:zi,MeshLambertMaterial:Vc,TextGeometry:zN,Vector3:he}),{},{Font:Tle,TextGeometry:zN}),EO=xs({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:Mue,onChange:function(e,t){t.font=new xl.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;nr(e),t.scene=e,t.tweenGroup=r;var s=new xl.CircleGeometry(1,32);t.dataMapper=new ao(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var a=new xl.MeshLambertMaterial;a.side=as;var l=new xl.Group;l.add(new xl.Mesh(s,a));var u=new xl.Mesh(void 0,a);l.add(u);var h=new xl.Mesh;return h.visible=!1,u.add(h),l.__globeObjType="label",l})},update:function(e){var t=Rt(e.labelLat),n=Rt(e.labelLng),r=Rt(e.labelAltitude),s=Rt(e.labelText),a=Rt(e.labelSize),l=Rt(e.labelRotation),u=Rt(e.labelColor),h=Rt(e.labelIncludeDot),m=Rt(e.labelDotRadius),v=Rt(e.labelDotOrientation),x=new Set(["right","top","bottom"]),S=2*Math.PI*cr/360;e.dataMapper.onUpdateObj(function(w,R){var C=gr(w.children,2),E=C[0],B=C[1],L=gr(B.children,1),O=L[0],G=u(R),q=Rl(G);B.material.color.set(wu(G)),B.material.transparent=q<1,B.material.opacity=q;var z=h(R),j=v(R);!z||!x.has(j)&&(j="bottom");var F=z?+m(R)*S:1e-12;E.scale.x=E.scale.y=F;var V=+a(R)*S;if(B.geometry&&B.geometry.dispose(),B.geometry=new xl.TextGeometry(s(R),{font:e.font,size:V,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),O.geometry&&O.geometry.dispose(),B.geometry.computeBoundingBox(),O.geometry=VE(xl.BoxGeometry,Qi(new xl.Vector3().subVectors(B.geometry.boundingBox.max,B.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),j!=="right"&&B.geometry.center(),z){var Y=F+V/2;j==="right"&&(B.position.x=Y),B.position.y={right:-V/2,top:Y+V/2,bottom:-Y-V/2}[j]}var ee=function(Q){var ae=w.__currentTargetD=Q,de=ae.lat,Te=ae.lng,be=ae.alt,ue=ae.rot,we=ae.scale;Object.assign(w.position,el(de,Te,be)),w.lookAt(e.scene.localToWorld(new xl.Vector3(0,0,0))),w.rotateY(Math.PI),w.rotateZ(-ue*Math.PI/180),w.scale.x=w.scale.y=w.scale.z=we},te={lat:+t(R),lng:+n(R),alt:+r(R),rot:+l(R),scale:1},re=w.__currentTargetD||Object.assign({},te,{scale:1e-12});Object.keys(te).some(function(ne){return re[ne]!==te[ne]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?ee(te):e.tweenGroup.add(new ca(re).to(te,e.labelsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(ee).start()))}).digest(e.labelsData)}}),Eue=Hi(Hi({},window.THREE?window.THREE:{}),{},{CSS2DObject:Bj}),CO=xs({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){if(e.dataMapper){var n=t?[t]:e.dataMapper.entries().map(function(r){var s=gr(r,2),a=s[1];return a}).filter(function(r){return r});n.forEach(function(r){var s=!e.isBehindGlobe||!e.isBehindGlobe(r.position);e.htmlElementVisibilityModifier?(r.visible=!0,e.htmlElementVisibilityModifier(r.element,s)):r.visible=s})}}},init:function(e,t,n){var r=n.tweenGroup;nr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new ao(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(s){var a=Rt(t.htmlElement)(s),l=new Eue.CSS2DObject(a);return l.__globeObjType="html",l})},update:function(e,t){var n=this,r=Rt(e.htmlLat),s=Rt(e.htmlLng),a=Rt(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(l,u){var h=function(x){var S=l.__currentTargetD=x,w=S.alt,R=S.lat,C=S.lng;Object.assign(l.position,el(R,C,w)),n.updateObjVisibility(l)},m={lat:+r(u),lng:+s(u),alt:+a(u)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!l.__currentTargetD?h(m):e.tweenGroup.add(new ca(l.__currentTargetD).to(m,e.htmlTransitionDuration).easing(os.Quadratic.InOut).onUpdate(h).start())}).digest(e.htmlElementsData)}}),Pv=window.THREE?window.THREE:{Group:ja,Mesh:zi,MeshLambertMaterial:Vc,SphereGeometry:Eu},RO=xs({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new Pv.Mesh(new Pv.SphereGeometry(1,16,8),new Pv.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){nr(e),t.scene=e,t.dataMapper=new ao(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(n){var r=Rt(t.objectThreeObject)(n);t.objectThreeObject===r&&(r=r.clone());var s=new Pv.Group;return s.add(r),s.__globeObjType="object",s})},update:function(e,t){var n=Rt(e.objectLat),r=Rt(e.objectLng),s=Rt(e.objectAltitude),a=Rt(e.objectFacesSurface),l=Rt(e.objectRotation);t.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(u,h){var m=+n(h),v=+r(h),x=+s(h);Object.assign(u.position,el(m,v,x)),a(h)?u.setRotationFromEuler(new la(Vf(-m),Vf(v),0,"YXZ")):u.rotation.set(0,0,0);var S=u.children[0],w=l(h);w&&S.setRotationFromEuler(new la(Vf(w.x||0),Vf(w.y||0),Vf(w.z||0)))}).digest(e.objectsData)}}),NO=xs({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){nr(e),t.scene=e,t.dataMapper=new ao(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(n){var r=Rt(t.customThreeObject)(n,cr);return r&&(t.customThreeObject===r&&(r=r.clone()),r.__globeObjType="custom"),r})},update:function(e,t){e.customThreeObjectUpdate||nr(e.scene);var n=Rt(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(r,s){return n(r,s,cr)}).digest(e.customLayerData)}}),Lv=window.THREE?window.THREE:{Camera:_y,Group:ja,Vector2:gt,Vector3:he},Cue=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],DO=wa("globeLayer",dO),Rue=Object.assign.apply(Object,Qi(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(i){return Ps({},i,DO.linkProp(i))}))),Nue=Object.assign.apply(Object,Qi(["globeMaterial","globeTileEngineClearCache"].map(function(i){return Ps({},i,DO.linkMethod(i))}))),Due=wa("pointsLayer",pO),Pue=Object.assign.apply(Object,Qi(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(i){return Ps({},i,Due.linkProp(i))}))),Lue=wa("arcsLayer",gO),Uue=Object.assign.apply(Object,Qi(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(i){return Ps({},i,Lue.linkProp(i))}))),Bue=wa("hexBinLayer",vO),Oue=Object.assign.apply(Object,Qi(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(i){return Ps({},i,Bue.linkProp(i))}))),Iue=wa("heatmapsLayer",yO),Fue=Object.assign.apply(Object,Qi(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(i){return Ps({},i,Iue.linkProp(i))}))),kue=wa("hexedPolygonsLayer",bO),zue=Object.assign.apply(Object,Qi(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(i){return Ps({},i,kue.linkProp(i))}))),Gue=wa("polygonsLayer",xO),que=Object.assign.apply(Object,Qi(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(i){return Ps({},i,Gue.linkProp(i))}))),Vue=wa("pathsLayer",SO),Hue=Object.assign.apply(Object,Qi(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(i){return Ps({},i,Vue.linkProp(i))}))),jue=wa("tilesLayer",TO),Wue=Object.assign.apply(Object,Qi(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(i){return Ps({},i,jue.linkProp(i))}))),$ue=wa("particlesLayer",wO),Xue=Object.assign.apply(Object,Qi(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(i){return Ps({},i,$ue.linkProp(i))}))),Yue=wa("ringsLayer",MO),Que=Object.assign.apply(Object,Qi(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(i){return Ps({},i,Yue.linkProp(i))}))),Kue=wa("labelsLayer",EO),Zue=Object.assign.apply(Object,Qi(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(i){return Ps({},i,Kue.linkProp(i))}))),Jue=wa("htmlElementsLayer",CO),ece=Object.assign.apply(Object,Qi(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(i){return Ps({},i,Jue.linkProp(i))}))),tce=wa("objectsLayer",RO),nce=Object.assign.apply(Object,Qi(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(i){return Ps({},i,tce.linkProp(i))}))),ice=wa("customLayer",NO),rce=Object.assign.apply(Object,Qi(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(i){return Ps({},i,ice.linkProp(i))}))),sce=xs({props:Hi(Hi(Hi(Hi(Hi(Hi(Hi(Hi(Hi(Hi(Hi(Hi(Hi(Hi(Hi({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new Lv.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},Rue),Pue),Uue),Oue),Fue),que),zue),Hue),Wue),Xue),Que),Zue),ece),nce),rce),methods:Hi({getGlobeRadius:VN,getCoords:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=(function(r){function s(){var a;nx(this,s);for(var l=arguments.length,u=new Array(l),h=0;hZN&&(this.dispatchEvent(US),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>ZN||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(US),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Ii.NONE,this.keyState=Ii.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(US),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Eh.copy(this._panEnd).sub(this._panStart),Eh.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Eh.x*=e,Eh.y*=t}Eh.multiplyScalar(this._eye.length()*this.panSpeed),Bv.copy(this._eye).cross(this.object.up).setLength(Eh.x),Bv.add(lce.copy(this.object.up).setLength(Eh.y)),this.object.position.add(Bv),this.target.add(Bv),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Eh.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Iv.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Iv.length();e?(this._eye.copy(this.object.position).sub(this.target),JN.copy(this._eye).normalize(),Ov.copy(this.object.up).normalize(),OS.crossVectors(Ov,JN).normalize(),Ov.setLength(this._moveCurr.y-this._movePrev.y),OS.setLength(this._moveCurr.x-this._movePrev.x),Iv.copy(Ov.add(OS)),BS.crossVectors(Iv,this._eye).normalize(),e*=this.rotateSpeed,Fd.setFromAxisAngle(BS,e),this._eye.applyQuaternion(Fd),this.object.up.applyQuaternion(Fd),this._lastAxis.copy(BS),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),Fd.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(Fd),this.object.up.applyQuaternion(Fd)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Ii.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=M0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=M0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Uv.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Uv}_getMouseOnCircle(e,t){return Uv.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Uv}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=Fa),r<-Math.PI?r+=Fa:r>Math.PI&&(r-=Fa),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(ps.setFromSpherical(this._spherical),ps.applyQuaternion(this._quatInverse),t.copy(this.target).add(ps),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=ps.length();a=this._clampDistance(l*this._scale);const u=l-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),s=!!u}else if(this.object.isOrthographicCamera){const l=new he(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=u!==this.object.zoom;const h=new he(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(l),this.object.updateMatrixWorld(),a=ps.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Fv.origin.copy(this.object.position),Fv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Fv.direction))IS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>IS||this._lastTargetPosition.distanceToSquared(this.target)>IS?(this.dispatchEvent(e7),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Fa/60*this.autoRotateSpeed*e:Fa/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ps.setFromMatrixColumn(t,0),ps.multiplyScalar(-e),this._panOffset.add(ps)}_panUp(e,t){this.screenSpacePanning===!0?ps.setFromMatrixColumn(t,1):(ps.setFromMatrixColumn(t,0),ps.crossVectors(this.object.up,ps)),ps.multiplyScalar(e),this._panOffset.add(ps)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;ps.copy(r).sub(this.target);let s=ps.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,l=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Fa*this._rotateDelta.x/t.clientHeight),this._rotateUp(Fa*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Fa*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Fa*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Fa*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Fa*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Fa*this._rotateDelta.x/t.clientHeight),this._rotateUp(Fa*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tn7||8*(1-this._lastQuaternion.dot(t.quaternion))>n7)&&(this.dispatchEvent(Fce),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function zce(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function Gce(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function qce(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function Vce(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function Hce(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function jce(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Wce(i){this.enabled!==!1&&i.preventDefault()}const $ce={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` - - varying vec2 vUv; - - void main() { - - vUv = uv; - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); - - }`,fragmentShader:` - - uniform float opacity; - - uniform sampler2D tDiffuse; - - varying vec2 vUv; - - void main() { - - vec4 texel = texture2D( tDiffuse, vUv ); - gl_FragColor = opacity * texel; - - - }`};class sx{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Xce=new kg(-1,1,1,-1,0,1);class Yce extends Ki{constructor(){super(),this.setAttribute("position",new Mi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Mi([0,2,0,0,2,0],2))}}const Qce=new Yce;class Kce{constructor(e){this._mesh=new zi(Qce,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Xce)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Zce extends sx{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof Ja?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=vy.clone(e.uniforms),this.material=new Ja({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Kce(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class r7 extends sx{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,l;this.inverse?(a=0,l=1):(a=1,l=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),s.buffers.stencil.setClear(l),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class Jce extends sx{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class ehe{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new gt);this._width=n.width,this._height=n.height,t=new qh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Gs}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Zce($ce),this.copyPass.material.blending=Qa,this.clock=new oD}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&r<1?(l=s,u=a):r>=1&&r<2?(l=a,u=s):r>=2&&r<3?(u=s,h=a):r>=3&&r<4?(u=a,h=s):r>=4&&r<5?(l=a,h=s):r>=5&&r<6&&(l=s,h=a);var m=t-s/2,v=l+m,x=u+m,S=h+m;return n(v,x,S)}var s7={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function ohe(i){if(typeof i!="string")return i;var e=i.toLowerCase();return s7[e]?"#"+s7[e]:i}var lhe=/^#[a-fA-F0-9]{6}$/,uhe=/^#[a-fA-F0-9]{8}$/,che=/^#[a-fA-F0-9]{3}$/,hhe=/^#[a-fA-F0-9]{4}$/,kS=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,fhe=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,Ahe=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,dhe=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function G0(i){if(typeof i!="string")throw new ru(3);var e=ohe(i);if(e.match(lhe))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(uhe)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(che))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(hhe)){var n=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:n}}var r=kS.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var s=fhe.exec(e.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var a=Ahe.exec(e);if(a){var l=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,h=parseInt(""+a[3],10)/100,m="rgb("+oy(l,u,h)+")",v=kS.exec(m);if(!v)throw new ru(4,e,m);return{red:parseInt(""+v[1],10),green:parseInt(""+v[2],10),blue:parseInt(""+v[3],10)}}var x=dhe.exec(e.substring(0,50));if(x){var S=parseInt(""+x[1],10),w=parseInt(""+x[2],10)/100,R=parseInt(""+x[3],10)/100,C="rgb("+oy(S,w,R)+")",E=kS.exec(C);if(!E)throw new ru(4,e,C);return{red:parseInt(""+E[1],10),green:parseInt(""+E[2],10),blue:parseInt(""+E[3],10),alpha:parseFloat(""+x[4])>1?parseFloat(""+x[4])/100:parseFloat(""+x[4])}}throw new ru(5)}function phe(i){var e=i.red/255,t=i.green/255,n=i.blue/255,r=Math.max(e,t,n),s=Math.min(e,t,n),a=(r+s)/2;if(r===s)return i.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:i.alpha}:{hue:0,saturation:0,lightness:a};var l,u=r-s,h=a>.5?u/(2-r-s):u/(r+s);switch(r){case e:l=(t-n)/u+(t=1?BO(i.hue,i.saturation,i.lightness):"rgba("+oy(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new ru(2)}function OO(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return hw("#"+Ff(i)+Ff(e)+Ff(t));if(typeof i=="object"&&e===void 0&&t===void 0)return hw("#"+Ff(i.red)+Ff(i.green)+Ff(i.blue));throw new ru(6)}function ax(i,e,t,n){if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?OO(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")";throw new ru(7)}var yhe=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},xhe=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},bhe=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},She=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function Kh(i){if(typeof i!="object")throw new ru(8);if(xhe(i))return ax(i);if(yhe(i))return OO(i);if(She(i))return _he(i);if(bhe(i))return vhe(i);throw new ru(8)}function IO(i,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?i.apply(this,r):IO(i,e,r)}}function Do(i){return IO(i,i.length,[])}function The(i,e){if(e==="transparent")return e;var t=Qh(e);return Kh(io({},t,{hue:t.hue+parseFloat(i)}))}Do(The);function J0(i,e,t){return Math.max(i,Math.min(e,t))}function whe(i,e){if(e==="transparent")return e;var t=Qh(e);return Kh(io({},t,{lightness:J0(0,1,t.lightness-parseFloat(i))}))}Do(whe);function Mhe(i,e){if(e==="transparent")return e;var t=Qh(e);return Kh(io({},t,{saturation:J0(0,1,t.saturation-parseFloat(i))}))}Do(Mhe);function Ehe(i,e){if(e==="transparent")return e;var t=Qh(e);return Kh(io({},t,{lightness:J0(0,1,t.lightness+parseFloat(i))}))}Do(Ehe);function Che(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=G0(e),r=io({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),s=G0(t),a=io({},s,{alpha:typeof s.alpha=="number"?s.alpha:1}),l=r.alpha-a.alpha,u=parseFloat(i)*2-1,h=u*l===-1?u:u+l,m=1+u*l,v=(h/m+1)/2,x=1-v,S={red:Math.floor(r.red*v+a.red*x),green:Math.floor(r.green*v+a.green*x),blue:Math.floor(r.blue*v+a.blue*x),alpha:r.alpha*parseFloat(i)+a.alpha*(1-parseFloat(i))};return ax(S)}var Rhe=Do(Che),FO=Rhe;function Nhe(i,e){if(e==="transparent")return e;var t=G0(e),n=typeof t.alpha=="number"?t.alpha:1,r=io({},t,{alpha:J0(0,1,(n*100+parseFloat(i)*100)/100)});return ax(r)}var Dhe=Do(Nhe),Phe=Dhe;function Lhe(i,e){if(e==="transparent")return e;var t=Qh(e);return Kh(io({},t,{saturation:J0(0,1,t.saturation+parseFloat(i))}))}Do(Lhe);function Uhe(i,e){return e==="transparent"?e:Kh(io({},Qh(e),{hue:parseFloat(i)}))}Do(Uhe);function Bhe(i,e){return e==="transparent"?e:Kh(io({},Qh(e),{lightness:parseFloat(i)}))}Do(Bhe);function Ohe(i,e){return e==="transparent"?e:Kh(io({},Qh(e),{saturation:parseFloat(i)}))}Do(Ohe);function Ihe(i,e){return e==="transparent"?e:FO(parseFloat(i),"rgb(0, 0, 0)",e)}Do(Ihe);function Fhe(i,e){return e==="transparent"?e:FO(parseFloat(i),"rgb(255, 255, 255)",e)}Do(Fhe);function khe(i,e){if(e==="transparent")return e;var t=G0(e),n=typeof t.alpha=="number"?t.alpha:1,r=io({},t,{alpha:J0(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return ax(r)}Do(khe);var fw="http://www.w3.org/1999/xhtml";const a7={svg:"http://www.w3.org/2000/svg",xhtml:fw,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function kO(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),a7.hasOwnProperty(e)?{space:a7[e],local:i}:i}function zhe(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===fw&&e.documentElement.namespaceURI===fw?e.createElement(i):e.createElementNS(t,i)}}function Ghe(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function zO(i){var e=kO(i);return(e.local?Ghe:zhe)(e)}function qhe(){}function GO(i){return i==null?qhe:function(){return this.querySelector(i)}}function Vhe(i){typeof i!="function"&&(i=GO(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r=L&&(L=B+1);!(G=C[L])&&++L=0;)(a=n[r])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function mfe(i){i||(i=gfe);function e(v,x){return v&&x?i(v.__data__,x.__data__):!v-!x}for(var t=this._groups,n=t.length,r=new Array(n),s=0;se?1:i>=e?0:NaN}function vfe(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function _fe(){return Array.from(this)}function yfe(){for(var i=this._groups,e=0,t=i.length;e1?this.each((e==null?Dfe:typeof e=="function"?Lfe:Pfe)(i,e,t??"")):Bfe(this.node(),i)}function Bfe(i,e){return i.style.getPropertyValue(e)||HO(i).getComputedStyle(i,null).getPropertyValue(e)}function Ofe(i){return function(){delete this[i]}}function Ife(i,e){return function(){this[i]=e}}function Ffe(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function kfe(i,e){return arguments.length>1?this.each((e==null?Ofe:typeof e=="function"?Ffe:Ife)(i,e)):this.node()[i]}function jO(i){return i.trim().split(/^|\s+/)}function QE(i){return i.classList||new WO(i)}function WO(i){this._node=i,this._names=jO(i.getAttribute("class")||"")}WO.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function $O(i,e){for(var t=QE(i),n=-1,r=e.length;++n=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function AAe(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,r=e.length,s;t2&&(a.children=arguments.length>3?i1.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(s in i.defaultProps)a[s]===void 0&&(a[s]=i.defaultProps[s]);return Gm(i,a,n,r,null)}function Gm(i,e,t,n,r){var s={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++QO,__i:-1,__u:0};return r==null&&Tr.vnode!=null&&Tr.vnode(s),s}function lx(i){return i.children}function r_(i,e){this.props=i,this.context=e}function q0(i,e){if(e==null)return i.__?q0(i.__,i.__i+1):null;for(var t;ee&&Hf.sort(JO),i=Hf.shift(),e=Hf.length,EAe(i);hy.__r=0}function nI(i,e,t,n,r,s,a,l,u,h,m){var v,x,S,w,R,C,E,B=n&&n.__k||cy,L=e.length;for(u=CAe(t,e,B,u,L),v=0;v0?a=i.__k[s]=Gm(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):i.__k[s]=a,u=s+x,a.__=i,a.__b=i.__b+1,l=null,(h=a.__i=RAe(a,t,u,v))!=-1&&(v--,(l=t[h])&&(l.__u|=2)),l==null||l.__v==null?(h==-1&&(r>m?x--:ru?x--:x++,a.__u|=4))):i.__k[s]=null;if(v)for(s=0;s(m?1:0)){for(r=t-1,s=t+1;r>=0||s=0?r--:s++])!=null&&(2&h.__u)==0&&l==h.key&&u==h.type)return a}return-1}function u7(i,e,t){e[0]=="-"?i.setProperty(e,t??""):i[e]=t==null?"":typeof t!="number"||wAe.test(e)?t:t+"px"}function kv(i,e,t,n,r){var s,a;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||u7(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||u7(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(eI,"$1")),a=e.toLowerCase(),e=a in i||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+s]=t,t?n?t.u=n.u:(t.u=KE,i.addEventListener(e,s?dw:Aw,s)):i.removeEventListener(e,s?dw:Aw,s);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function c7(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=KE++;else if(e.t0?i:ox(i)?i.map(sI):su({},i)}function NAe(i,e,t,n,r,s,a,l,u){var h,m,v,x,S,w,R,C=t.props||uy,E=e.props,B=e.type;if(B=="svg"?r="http://www.w3.org/2000/svg":B=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(h=0;h2&&(l.children=arguments.length>3?i1.call(arguments,2):t),Gm(i.type,l,n||i.key,r||i.ref,null)}i1=cy.slice,Tr={__e:function(i,e,t,n){for(var r,s,a;e=e.__;)if((r=e.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(i)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(i,n||{}),a=r.__d),a)return r.__E=r}catch(l){i=l}throw i}},QO=0,KO=function(i){return i!=null&&i.constructor===void 0},r_.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=su({},this.state),typeof i=="function"&&(i=i(su({},t),this.props)),i&&su(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),l7(this))},r_.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),l7(this))},r_.prototype.render=lx,Hf=[],ZO=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,JO=function(i,e){return i.__v.__b-e.__v.__b},hy.__r=0,eI=/(PointerCapture)$|Capture$/i,KE=0,Aw=c7(!1),dw=c7(!0);function h7(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var jAe=`.float-tooltip-kap { - position: absolute; - width: max-content; /* prevent shrinking near right edge */ - max-width: max(50%, 150px); - padding: 3px 5px; - border-radius: 3px; - font: 12px sans-serif; - color: #eee; - background: rgba(0,0,0,0.6); - pointer-events: none; -} -`;HAe(jAe);var WAe=xs({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.style,s=r===void 0?{}:r,a=!!e&&fy(e)==="object"&&!!e.node&&typeof e.node=="function",l=bAe(a?e.node():e);l.style("position")==="static"&&l.style("position","relative"),t.tooltipEl=l.append("div").attr("class","float-tooltip-kap"),Object.entries(s).forEach(function(h){var m=FAe(h,2),v=m[0],x=m[1];return t.tooltipEl.style(v,x)}),t.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,l.on("mousemove.".concat(u),function(h){t.mouseInside=!0;var m=TAe(h),v=l.node(),x=v.offsetWidth,S=v.offsetHeight,w=[t.offsetX===null||t.offsetX===void 0?"-".concat(m[0]/x*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?S>130&&S-m[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",m[0]+"px").style("top",m[1]+"px").style("transform","translate(".concat(w.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseover.".concat(u),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseout.".concat(u),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):qAe(e.content)?(e.tooltipEl.text(""),VAe(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function $Ae(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var XAe=`.scene-nav-info { - position: absolute; - bottom: 5px; - width: 100%; - text-align: center; - color: slategrey; - opacity: 0.7; - font-size: 10px; - font-family: sans-serif; - pointer-events: none; - user-select: none; -} - -.scene-container canvas:focus { - outline: none; -}`;$Ae(XAe);function gw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,l){return e.hoverOrderComparator(a.object,l.object)});var s=r.find(function(a){return e.hoverFilter(a.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Rt(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var a=t,l=n||{x:0,y:0,z:0};if(!r)m(a),v(l);else{var u=Object.assign({},s.position),h=x();e.tweenGroup.add(new ca(u).to(a,r).easing(os.Quadratic.Out).onUpdate(m).start()),e.tweenGroup.add(new ca(h).to(l,r/3).easing(os.Quadratic.Out).onUpdate(v).start())}return this}return Object.assign({},s.position,{lookAt:x()});function m(S){var w=S.x,R=S.y,C=S.z;w!==void 0&&(s.position.x=w),R!==void 0&&(s.position.y=R),C!==void 0&&(s.position.z=C)}function v(S){var w=new br.Vector3(S.x,S.y,S.z);e.controls.enabled&&e.controls.target?e.controls.target=w:s.lookAt(w)}function x(){return Object.assign(new br.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var a=new br.Vector3(0,0,0),l=Math.max.apply(Math,Lf(Object.entries(t).map(function(S){var w=nde(S,2),R=w[0],C=w[1];return Math.max.apply(Math,Lf(C.map(function(E){return Math.abs(a[R]-E)})))})))*2,u=(1-r*2/e.height)*s.fov,h=l/Math.atan(u*Math.PI/180),m=h/s.aspect,v=Math.max(h,m);if(v>0){var x=a.clone().sub(s.position).normalize().multiplyScalar(-v);this.cameraPosition(x,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new br.Box3(new br.Vector3(0,0,0),new br.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,Lf(["x","y","z"].map(function(s){return KAe({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new br.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new br.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new br.Raycaster;return a.setFromCamera(s,e.camera),Object.assign({},a.ray.at(r,new br.Vector3))},intersectingObjects:function(e,t,n){var r=new br.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new br.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new br.Scene,camera:new br.PerspectiveCamera,clock:new br.Clock,tweenGroup:new My,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,a=n.useWebGPU,l=a===void 0?!1:a,u=n.rendererConfig,h=u===void 0?{}:u,m=n.extraRenderers,v=m===void 0?[]:m,x=n.waitForLoadComplete,S=x===void 0?!0:x;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new WAe(t.container),t.pointerPos=new br.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(w){return t.container.addEventListener(w,function(R){if(w==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&R.type==="pointermove"&&(R.pressure>0||t.isPointerPressed)&&(R.pointerType==="mouse"||R.movementX===void 0||[R.movementX,R.movementY].some(function(B){return Math.abs(B)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var C=E(t.container);t.pointerPos.x=R.pageX-C.left,t.pointerPos.y=R.pageY-C.top}function E(B){var L=B.getBoundingClientRect(),O=window.pageXOffset||document.documentElement.scrollLeft,G=window.pageYOffset||document.documentElement.scrollTop;return{top:L.top+G,left:L.left+O}}},{passive:!0})}),t.container.addEventListener("pointerup",function(w){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){w.button===0&&t.onClick(t.hoverObj||null,w,t.intersection),w.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,w,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(w){t.onRightClick&&w.preventDefault()}),t.renderer=new(l?aO:br.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},h)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=v,t.extraRenderers.forEach(function(w){w.domElement.style.position="absolute",w.domElement.style.top="0px",w.domElement.style.pointerEvents="none",t.container.appendChild(w.domElement)}),t.postProcessingComposer=new ehe(t.renderer),t.postProcessingComposer.addPass(new the(t.scene,t.camera)),t.controls=new{trackball:uce,orbit:wce,fly:kce}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Lf(t.extraRenderers)).forEach(function(w){return w.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new br.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!S,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Lf(e.extraRenderers)).forEach(function(S){return S.setSize(r,s)}),e.camera.aspect=r/s;var a=e.viewOffset.slice(0,2);a.some(function(S){return S})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(Lf(a),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var l,u=e.width,h=e.height,m=e.viewOffset.slice(0,2);m.some(function(S){return S})?(l=e.camera).setViewOffset.apply(l,[u,h].concat(Lf(m),[u,h])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new br.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var v=G0(e.backgroundColor).alpha;v===void 0&&(v=1),e.renderer.setClearColor(new br.Color(Phe(1,e.backgroundColor)),v)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new br.TextureLoader().load(e.backgroundImageUrl,function(S){S.colorSpace=br.SRGBColorSpace,e.skysphere.material=new br.MeshBasicMaterial({map:S,side:br.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&x()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&x())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(S){return e.scene.remove(S)}),e.lights.forEach(function(S){return e.scene.add(S)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(S){return e.scene.remove(S)}),e.objects.forEach(function(S){return e.scene.add(S)}));function x(){e.loadComplete=e.scene.visible=!0}}});function sde(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var ade=`.scene-container .clickable { - cursor: pointer; -}`;sde(ade);function vw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1?l-1:0),h=1;h1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=a();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(u){return s[u]=+s[u]}),!n)l(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new ca(r).to(s,n).easing(os.Cubic.InOut).onUpdate(l).start())}return this;function a(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(u){var h=u.lat,m=u.lng,v=u.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(h,m,v)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;slocalStorage.getItem("radio-theme")||"default"),[a,l]=xe.useState([]),[u,h]=xe.useState(null),[m,v]=xe.useState([]),[x,S]=xe.useState(!1),[w,R]=xe.useState({}),[C,E]=xe.useState([]),[B,L]=xe.useState(""),[O,G]=xe.useState(""),[q,z]=xe.useState(""),[j,F]=xe.useState([]),[V,Y]=xe.useState(!1),[ee,te]=xe.useState([]),[re,ne]=xe.useState(!1),[Q,ae]=xe.useState(!1),[de,Te]=xe.useState(.5),[be,ue]=xe.useState(null),[we,We]=xe.useState(!1),[Ne,ze]=xe.useState(!1),Se=xe.useRef(void 0),Ce=xe.useRef(void 0),dt=xe.useRef(B);xe.useEffect(()=>{fetch("/api/radio/places").then(X=>X.json()).then(l).catch(console.error),fetch("/api/radio/guilds").then(X=>X.json()).then(X=>{if(E(X),X.length>0){L(X[0].id);const le=X[0].voiceChannels.find(Re=>Re.members>0)??X[0].voiceChannels[0];le&&G(le.id)}}).catch(console.error),fetch("/api/radio/favorites").then(X=>X.json()).then(te).catch(console.error)},[]),xe.useEffect(()=>{dt.current=B},[B]),xe.useEffect(()=>{i!=null&&i.guildId&&"playing"in i&&i.type!=="radio_voicestats"?R(X=>{if(i.playing)return{...X,[i.guildId]:i.playing};const le={...X};return delete le[i.guildId],le}):i!=null&&i.playing&&!(i!=null&&i.guildId)&&R(i.playing),i!=null&&i.favorites&&te(i.favorites),i!=null&&i.volumes&&B&&i.volumes[B]!=null&&Te(i.volumes[B]),(i==null?void 0:i.volume)!=null&&(i==null?void 0:i.guildId)===B&&Te(i.volume),(i==null?void 0:i.type)==="radio_voicestats"&&i.guildId===dt.current&&ue({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})},[i,B]),xe.useEffect(()=>{if(localStorage.setItem("radio-theme",r),t.current&&e.current){const le=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim();t.current.pointColor(()=>`rgba(${le}, 0.85)`).atmosphereColor(`rgba(${le}, 0.25)`)}},[r]);const At=xe.useRef(u);At.current=u;const wt=xe.useRef(re);wt.current=re;const Ft=xe.useCallback(()=>{var le;const X=(le=t.current)==null?void 0:le.controls();X&&(X.autoRotate=!1),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{var pe;if(At.current||wt.current)return;const Re=(pe=t.current)==null?void 0:pe.controls();Re&&(Re.autoRotate=!0)},5e3)},[]);xe.useEffect(()=>{var le;const X=(le=t.current)==null?void 0:le.controls();X&&(u||re?(X.autoRotate=!1,n.current&&clearTimeout(n.current)):X.autoRotate=!0)},[u,re]);const $e=xe.useRef(void 0);$e.current=X=>{h(X),ne(!1),S(!0),v([]),Ft(),t.current&&t.current.pointOfView({lat:X.geo[1],lng:X.geo[0],altitude:.4},800),fetch(`/api/radio/place/${X.id}/channels`).then(le=>le.json()).then(le=>{v(le),S(!1)}).catch(()=>S(!1))},xe.useEffect(()=>{const X=e.current;if(!X)return;X.clientWidth>0&&X.clientHeight>0&&ze(!0);const le=new ResizeObserver(Re=>{for(const pe of Re){const{width:Me,height:nt}=pe.contentRect;Me>0&&nt>0&&ze(!0)}});return le.observe(X),()=>le.disconnect()},[]),xe.useEffect(()=>{if(!e.current||a.length===0)return;const X=e.current.clientWidth,le=e.current.clientHeight;if(t.current){t.current.pointsData(a),X>0&&le>0&&t.current.width(X).height(le);return}if(X===0||le===0)return;const pe=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim()||"230, 126, 34",Me=new yde(e.current).backgroundColor("rgba(0,0,0,0)").atmosphereColor(`rgba(${pe}, 0.25)`).atmosphereAltitude(.12).globeImageUrl("/nasa-blue-marble.jpg").pointsData(a).pointLat($t=>$t.geo[1]).pointLng($t=>$t.geo[0]).pointColor(()=>`rgba(${pe}, 0.85)`).pointRadius($t=>Math.max(.12,Math.min(.45,.06+($t.size??1)*.005))).pointAltitude(.001).pointResolution(24).pointLabel($t=>`

`).onPointClick($t=>{var kt;return(kt=$e.current)==null?void 0:kt.call($e,$t)}).width(e.current.clientWidth).height(e.current.clientHeight);Me.renderer().setPixelRatio(window.devicePixelRatio),Me.pointOfView({lat:48,lng:10,altitude:GS});const nt=Me.controls();nt&&(nt.autoRotate=!0,nt.autoRotateSpeed=.3);let lt=GS;const Ot=()=>{const kt=Me.pointOfView().altitude;if(Math.abs(kt-lt)/lt<.05)return;lt=kt;const Vt=Math.sqrt(kt/GS);Me.pointRadius(Nn=>Math.max(.12,Math.min(.45,.06+(Nn.size??1)*.005))*Math.max(.15,Math.min(2.5,Vt)))};nt.addEventListener("change",Ot),t.current=Me;const jt=e.current,pt=()=>Ft();jt.addEventListener("mousedown",pt),jt.addEventListener("touchstart",pt),jt.addEventListener("wheel",pt);const Yt=()=>{if(e.current&&t.current){const $t=e.current.clientWidth,kt=e.current.clientHeight;$t>0&&kt>0&&t.current.width($t).height(kt)}};window.addEventListener("resize",Yt);const rn=new ResizeObserver(()=>Yt());return rn.observe(jt),()=>{nt.removeEventListener("change",Ot),jt.removeEventListener("mousedown",pt),jt.removeEventListener("touchstart",pt),jt.removeEventListener("wheel",pt),window.removeEventListener("resize",Yt),rn.disconnect()}},[a,Ft,Ne]);const rt=xe.useCallback(async(X,le,Re,pe)=>{if(!(!B||!O)){ae(!0);try{(await(await fetch("/api/radio/play",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:B,voiceChannelId:O,stationId:X,stationName:le,placeName:Re??(u==null?void 0:u.title)??"",country:pe??(u==null?void 0:u.country)??""})})).json()).ok&&(R(lt=>{var Ot,jt;return{...lt,[B]:{stationId:X,stationName:le,placeName:Re??(u==null?void 0:u.title)??"",country:pe??(u==null?void 0:u.country)??"",startedAt:new Date().toISOString(),channelName:((jt=(Ot=C.find(pt=>pt.id===B))==null?void 0:Ot.voiceChannels.find(pt=>pt.id===O))==null?void 0:jt.name)??""}}}),Ft())}catch(Me){console.error(Me)}ae(!1)}},[B,O,u,C]),ce=xe.useCallback(async()=>{B&&(await fetch("/api/radio/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:B})}),R(X=>{const le={...X};return delete le[B],le}))},[B]),Gt=xe.useCallback(X=>{if(z(X),Se.current&&clearTimeout(Se.current),!X.trim()){F([]),Y(!1);return}Se.current=setTimeout(async()=>{try{const Re=await(await fetch(`/api/radio/search?q=${encodeURIComponent(X)}`)).json();F(Re),Y(!0)}catch{F([])}},350)},[]),ht=xe.useCallback(X=>{var le,Re,pe;if(Y(!1),z(""),F([]),X.type==="channel"){const Me=(le=X.url.match(/\/listen\/[^/]+\/([^/]+)/))==null?void 0:le[1];Me&&rt(Me,X.title,X.subtitle,"")}else if(X.type==="place"){const Me=(Re=X.url.match(/\/visit\/[^/]+\/([^/]+)/))==null?void 0:Re[1],nt=a.find(lt=>lt.id===Me);nt&&((pe=$e.current)==null||pe.call($e,nt))}},[a,rt]),Pt=xe.useCallback(async(X,le)=>{try{const pe=await(await fetch("/api/radio/favorites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stationId:X,stationName:le,placeName:(u==null?void 0:u.title)??"",country:(u==null?void 0:u.country)??"",placeId:(u==null?void 0:u.id)??""})})).json();pe.favorites&&te(pe.favorites)}catch{}},[u]),yt=xe.useCallback(X=>{Te(X),B&&(Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{fetch("/api/radio/volume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:B,volume:X})}).catch(console.error)},100))},[B]),en=X=>ee.some(le=>le.stationId===X),xt=B?w[B]:null,fe=C.find(X=>X.id===B);return k.jsxs("div",{className:"radio-container","data-theme":r,children:[k.jsxs("header",{className:"radio-topbar",children:[k.jsxs("div",{className:"radio-topbar-left",children:[k.jsx("span",{className:"radio-topbar-logo",children:"🌍"}),k.jsx("span",{className:"radio-topbar-title",children:"World Radio"}),C.length>1&&k.jsx("select",{className:"radio-sel",value:B,onChange:X=>{L(X.target.value);const le=C.find(pe=>pe.id===X.target.value),Re=(le==null?void 0:le.voiceChannels.find(pe=>pe.members>0))??(le==null?void 0:le.voiceChannels[0]);G((Re==null?void 0:Re.id)??"")},children:C.map(X=>k.jsx("option",{value:X.id,children:X.name},X.id))}),k.jsxs("select",{className:"radio-sel",value:O,onChange:X=>G(X.target.value),children:[k.jsx("option",{value:"",children:"Voice Channel..."}),fe==null?void 0:fe.voiceChannels.map(X=>k.jsxs("option",{value:X.id,children:["🔊"," ",X.name,X.members>0?` (${X.members})`:""]},X.id))]})]}),xt&&k.jsxs("div",{className:"radio-topbar-np",children:[k.jsxs("div",{className:"radio-eq radio-eq-np",children:[k.jsx("span",{}),k.jsx("span",{}),k.jsx("span",{})]}),k.jsxs("div",{className:"radio-np-info",children:[k.jsx("span",{className:"radio-np-name",children:xt.stationName}),k.jsxs("span",{className:"radio-np-loc",children:[xt.placeName,xt.country?`, ${xt.country}`:""]})]})]}),k.jsxs("div",{className:"radio-topbar-right",children:[xt&&k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"radio-volume",children:[k.jsx("span",{className:"radio-volume-icon",children:de===0?"🔇":de<.4?"🔉":"🔊"}),k.jsx("input",{type:"range",className:"radio-volume-slider",min:0,max:1,step:.01,value:de,onChange:X=>yt(Number(X.target.value))}),k.jsxs("span",{className:"radio-volume-val",children:[Math.round(de*100),"%"]})]}),k.jsxs("div",{className:"radio-conn",onClick:()=>We(!0),title:"Verbindungsdetails",children:[k.jsx("span",{className:"radio-conn-dot"}),"Verbunden",(be==null?void 0:be.voicePing)!=null&&k.jsxs("span",{className:"radio-conn-ping",children:[be.voicePing,"ms"]})]}),k.jsxs("button",{className:"radio-topbar-stop",onClick:ce,children:["⏹"," Stop"]})]}),k.jsx("div",{className:"radio-theme-inline",children:xde.map(X=>k.jsx("div",{className:`radio-theme-dot ${r===X.id?"active":""}`,style:{background:X.color},title:X.label,onClick:()=>s(X.id)},X.id))})]})]}),k.jsxs("div",{className:"radio-globe-wrap",children:[k.jsx("div",{className:"radio-globe",ref:e}),k.jsxs("div",{className:"radio-search",children:[k.jsxs("div",{className:"radio-search-wrap",children:[k.jsx("span",{className:"radio-search-icon",children:"🔍"}),k.jsx("input",{className:"radio-search-input",type:"text",placeholder:"Sender oder Stadt suchen...",value:q,onChange:X=>Gt(X.target.value),onFocus:()=>{j.length&&Y(!0)}}),q&&k.jsx("button",{className:"radio-search-clear",onClick:()=>{z(""),F([]),Y(!1)},children:"✕"})]}),V&&j.length>0&&k.jsx("div",{className:"radio-search-results",children:j.slice(0,12).map(X=>k.jsxs("button",{className:"radio-search-result",onClick:()=>ht(X),children:[k.jsx("span",{className:"radio-search-result-icon",children:X.type==="channel"?"📻":X.type==="place"?"📍":"🌍"}),k.jsxs("div",{className:"radio-search-result-text",children:[k.jsx("span",{className:"radio-search-result-title",children:X.title}),k.jsx("span",{className:"radio-search-result-sub",children:X.subtitle})]})]},X.id+X.url))})]}),!u&&!re&&k.jsxs("button",{className:"radio-fab",onClick:()=>{ne(!0),h(null)},title:"Favoriten",children:["⭐",ee.length>0&&k.jsx("span",{className:"radio-fab-badge",children:ee.length})]}),re&&k.jsxs("div",{className:"radio-panel open",children:[k.jsxs("div",{className:"radio-panel-header",children:[k.jsxs("h3",{children:["⭐"," Favoriten"]}),k.jsx("button",{className:"radio-panel-close",onClick:()=>ne(!1),children:"✕"})]}),k.jsx("div",{className:"radio-panel-body",children:ee.length===0?k.jsx("div",{className:"radio-panel-empty",children:"Noch keine Favoriten"}):ee.map(X=>k.jsxs("div",{className:`radio-station ${(xt==null?void 0:xt.stationId)===X.stationId?"playing":""}`,children:[k.jsxs("div",{className:"radio-station-info",children:[k.jsx("span",{className:"radio-station-name",children:X.stationName}),k.jsxs("span",{className:"radio-station-loc",children:[X.placeName,", ",X.country]})]}),k.jsxs("div",{className:"radio-station-btns",children:[k.jsx("button",{className:"radio-btn-play",onClick:()=>rt(X.stationId,X.stationName,X.placeName,X.country),disabled:!O||Q,children:"▶"}),k.jsx("button",{className:"radio-btn-fav active",onClick:()=>Pt(X.stationId,X.stationName),children:"★"})]})]},X.stationId))})]}),u&&!re&&k.jsxs("div",{className:"radio-panel open",children:[k.jsxs("div",{className:"radio-panel-header",children:[k.jsxs("div",{children:[k.jsx("h3",{children:u.title}),k.jsx("span",{className:"radio-panel-sub",children:u.country})]}),k.jsx("button",{className:"radio-panel-close",onClick:()=>h(null),children:"✕"})]}),k.jsx("div",{className:"radio-panel-body",children:x?k.jsxs("div",{className:"radio-panel-loading",children:[k.jsx("div",{className:"radio-spinner"}),"Sender werden geladen..."]}):m.length===0?k.jsx("div",{className:"radio-panel-empty",children:"Keine Sender gefunden"}):m.map(X=>k.jsxs("div",{className:`radio-station ${(xt==null?void 0:xt.stationId)===X.id?"playing":""}`,children:[k.jsxs("div",{className:"radio-station-info",children:[k.jsx("span",{className:"radio-station-name",children:X.title}),(xt==null?void 0:xt.stationId)===X.id&&k.jsxs("span",{className:"radio-station-live",children:[k.jsxs("span",{className:"radio-eq",children:[k.jsx("span",{}),k.jsx("span",{}),k.jsx("span",{})]}),"Live"]})]}),k.jsxs("div",{className:"radio-station-btns",children:[(xt==null?void 0:xt.stationId)===X.id?k.jsx("button",{className:"radio-btn-stop",onClick:ce,children:"⏹"}):k.jsx("button",{className:"radio-btn-play",onClick:()=>rt(X.id,X.title),disabled:!O||Q,children:"▶"}),k.jsx("button",{className:`radio-btn-fav ${en(X.id)?"active":""}`,onClick:()=>Pt(X.id,X.title),children:en(X.id)?"★":"☆"})]})]},X.id))})]}),k.jsxs("div",{className:"radio-counter",children:["📻"," ",a.length.toLocaleString("de-DE")," Sender weltweit"]}),k.jsx("a",{className:"radio-attribution",href:"https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/",target:"_blank",rel:"noreferrer",children:"Imagery © NASA Blue Marble"})]}),we&&(()=>{const X=be!=null&&be.connectedSince?Math.floor((Date.now()-new Date(be.connectedSince).getTime())/1e3):0,le=Math.floor(X/3600),Re=Math.floor(X%3600/60),pe=X%60,Me=le>0?`${le}h ${String(Re).padStart(2,"0")}m ${String(pe).padStart(2,"0")}s`:Re>0?`${Re}m ${String(pe).padStart(2,"0")}s`:`${pe}s`,nt=lt=>lt==null?"var(--text-faint)":lt<80?"var(--success)":lt<150?"#f0a830":"#e04040";return k.jsx("div",{className:"radio-modal-overlay",onClick:()=>We(!1),children:k.jsxs("div",{className:"radio-modal",onClick:lt=>lt.stopPropagation(),children:[k.jsxs("div",{className:"radio-modal-header",children:[k.jsx("span",{children:"📡"}),k.jsx("span",{children:"Verbindungsdetails"}),k.jsx("button",{className:"radio-modal-close",onClick:()=>We(!1),children:"✕"})]}),k.jsxs("div",{className:"radio-modal-body",children:[k.jsxs("div",{className:"radio-modal-stat",children:[k.jsx("span",{className:"radio-modal-label",children:"Voice Ping"}),k.jsxs("span",{className:"radio-modal-value",children:[k.jsx("span",{className:"radio-modal-dot",style:{background:nt((be==null?void 0:be.voicePing)??null)}}),(be==null?void 0:be.voicePing)!=null?`${be.voicePing} ms`:"---"]})]}),k.jsxs("div",{className:"radio-modal-stat",children:[k.jsx("span",{className:"radio-modal-label",children:"Gateway Ping"}),k.jsxs("span",{className:"radio-modal-value",children:[k.jsx("span",{className:"radio-modal-dot",style:{background:nt((be==null?void 0:be.gatewayPing)??null)}}),be&&be.gatewayPing>=0?`${be.gatewayPing} ms`:"---"]})]}),k.jsxs("div",{className:"radio-modal-stat",children:[k.jsx("span",{className:"radio-modal-label",children:"Status"}),k.jsx("span",{className:"radio-modal-value",style:{color:(be==null?void 0:be.status)==="ready"?"var(--success)":"#f0a830"},children:(be==null?void 0:be.status)==="ready"?"Verbunden":(be==null?void 0:be.status)??"Warte auf Verbindung"})]}),k.jsxs("div",{className:"radio-modal-stat",children:[k.jsx("span",{className:"radio-modal-label",children:"Kanal"}),k.jsx("span",{className:"radio-modal-value",children:(be==null?void 0:be.channelName)||"---"})]}),k.jsxs("div",{className:"radio-modal-stat",children:[k.jsx("span",{className:"radio-modal-label",children:"Verbunden seit"}),k.jsx("span",{className:"radio-modal-value",children:Me||"---"})]})]})]})})})()]})}function Sde(i,e,t=365){const n=new Date(Date.now()+t*24*60*60*1e3).toUTCString();document.cookie=`${encodeURIComponent(i)}=${encodeURIComponent(e)}; expires=${n}; path=/; SameSite=Lax`}function Tde(i){const e=`${encodeURIComponent(i)}=`,t=document.cookie.split(";");for(const n of t){const r=n.trim();if(r.startsWith(e))return decodeURIComponent(r.slice(e.length))}return null}const us="/api/soundboard";async function d7(i,e,t,n){const r=new URL(`${us}/sounds`,window.location.origin);i&&r.searchParams.set("q",i),e!==void 0&&r.searchParams.set("folder",e),r.searchParams.set("fuzzy","0");const s=await fetch(r.toString());if(!s.ok)throw new Error("Fehler beim Laden der Sounds");return s.json()}async function wde(){const i=await fetch(`${us}/analytics`);if(!i.ok)throw new Error("Fehler beim Laden der Analytics");return i.json()}async function Mde(){const i=await fetch(`${us}/categories`,{credentials:"include"});if(!i.ok)throw new Error("Fehler beim Laden der Kategorien");return i.json()}async function Ede(){const i=await fetch(`${us}/channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channels");return i.json()}async function Cde(){const i=await fetch(`${us}/selected-channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channel-Auswahl");const e=await i.json();return(e==null?void 0:e.selected)||{}}async function Rde(i,e){if(!(await fetch(`${us}/selected-channel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Channel-Auswahl setzen fehlgeschlagen")}async function Nde(i,e,t,n,r){const s=await fetch(`${us}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({soundName:i,guildId:e,channelId:t,volume:n,relativePath:r})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error((a==null?void 0:a.error)||"Play fehlgeschlagen")}}async function Dde(i,e,t,n,r){const s=await fetch(`${us}/play-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,guildId:e,channelId:t,volume:n,filename:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error((a==null?void 0:a.error)||"Play-URL fehlgeschlagen");return a}async function Pde(i,e){const t=await fetch(`${us}/download-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,filename:e})}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error((n==null?void 0:n.error)||"Download fehlgeschlagen");return n}async function Lde(i,e){if(!(await fetch(`${us}/party/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Partymode Start fehlgeschlagen")}async function Ude(i){if(!(await fetch(`${us}/party/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i})})).ok)throw new Error("Partymode Stop fehlgeschlagen")}async function p7(i,e){const t=await fetch(`${us}/volume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,volume:e})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error((n==null?void 0:n.error)||"Volume aendern fehlgeschlagen")}}async function Bde(i){const e=new URL(`${us}/volume`,window.location.origin);e.searchParams.set("guildId",i);const t=await fetch(e.toString());if(!t.ok)throw new Error("Fehler beim Laden der Lautstaerke");const n=await t.json();return typeof(n==null?void 0:n.volume)=="number"?n.volume:1}async function Ode(){const i=await fetch(`${us}/admin/status`,{credentials:"include"});if(!i.ok)return!1;const e=await i.json();return!!(e!=null&&e.authenticated)}async function Ide(i){return(await fetch(`${us}/admin/login`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({password:i})})).ok}async function Fde(){await fetch(`${us}/admin/logout`,{method:"POST",credentials:"include"})}async function kde(i){if(!(await fetch(`${us}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}async function zde(i,e){const t=await fetch(`${us}/admin/sounds/rename`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({from:i,to:e})});if(!t.ok)throw new Error("Umbenennen fehlgeschlagen");const n=await t.json();return n==null?void 0:n.to}function Gde(i,e){return new Promise((t,n)=>{const r=new FormData;r.append("files",i);const s=new XMLHttpRequest;s.open("POST",`${us}/upload`),s.upload.onprogress=a=>{a.lengthComputable&&e(Math.round(a.loaded/a.total*100))},s.onload=()=>{var a,l;if(s.status===200)try{const u=JSON.parse(s.responseText);t(((l=(a=u.files)==null?void 0:a[0])==null?void 0:l.name)??i.name)}catch{t(i.name)}else try{n(new Error(JSON.parse(s.responseText).error))}catch{n(new Error(`HTTP ${s.status}`))}},s.onerror=()=>n(new Error("Netzwerkfehler")),s.send(r)})}const qde=[{id:"default",color:"#5865f2",label:"Discord"},{id:"purple",color:"#9b59b6",label:"Midnight"},{id:"forest",color:"#2ecc71",label:"Forest"},{id:"sunset",color:"#e67e22",label:"Sunset"},{id:"ocean",color:"#3498db",label:"Ocean"}],m7=["#3b82f6","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#06b6d4","#ef4444","#a855f7","#84cc16","#d946ef","#0ea5e9","#f43f5e","#10b981"];function Vde({data:i}){const[e,t]=xe.useState([]),[n,r]=xe.useState(0),[s,a]=xe.useState([]),[l,u]=xe.useState([]),[h,m]=xe.useState({totalSounds:0,totalPlays:0,mostPlayed:[]}),[v,x]=xe.useState("all"),[S,w]=xe.useState(""),[R,C]=xe.useState(""),[E,B]=xe.useState(""),[L,O]=xe.useState(!1),[G,q]=xe.useState(null),[z,j]=xe.useState([]),[F,V]=xe.useState(""),Y=xe.useRef(""),[ee,te]=xe.useState(!1),[re,ne]=xe.useState(1),[Q,ae]=xe.useState(""),[de,Te]=xe.useState({}),[be,ue]=xe.useState(()=>localStorage.getItem("jb-theme")||"default"),[we,We]=xe.useState(()=>parseInt(localStorage.getItem("jb-card-size")||"110")),[Ne,ze]=xe.useState(!1),[Se,Ce]=xe.useState([]),dt=xe.useRef(!1),At=xe.useRef(void 0),[wt,Ft]=xe.useState(!1),[$e,rt]=xe.useState(!1),[ce,Gt]=xe.useState(""),[ht,Pt]=xe.useState([]),[yt,en]=xe.useState(!1),[xt,fe]=xe.useState(""),[X,le]=xe.useState({}),[Re,pe]=xe.useState(""),[Me,nt]=xe.useState(""),[lt,Ot]=xe.useState(!1),[jt,pt]=xe.useState([]),[Yt,rn]=xe.useState(!1),$t=xe.useRef(0),kt=xe.useRef(void 0),[Vt,Nn]=xe.useState(null),[_i,me]=xe.useState(!1),[bt,tt]=xe.useState(null),[St,qt]=xe.useState(""),[Ht,xn]=xe.useState(null),[qi,rr]=xe.useState(0);xe.useEffect(()=>{dt.current=Ne},[Ne]),xe.useEffect(()=>{Y.current=F},[F]),xe.useEffect(()=>{const ye=cn=>{var Yn;Array.from(((Yn=cn.dataTransfer)==null?void 0:Yn.items)??[]).some(xi=>xi.kind==="file")&&($t.current++,Ot(!0))},ot=()=>{$t.current=Math.max(0,$t.current-1),$t.current===0&&Ot(!1)},Nt=cn=>cn.preventDefault(),Jt=cn=>{var xi;cn.preventDefault(),$t.current=0,Ot(!1);const Yn=Array.from(((xi=cn.dataTransfer)==null?void 0:xi.files)??[]).filter(js=>/\.(mp3|wav)$/i.test(js.name));Yn.length&&Hs(Yn)};return window.addEventListener("dragenter",ye),window.addEventListener("dragleave",ot),window.addEventListener("dragover",Nt),window.addEventListener("drop",Jt),()=>{window.removeEventListener("dragenter",ye),window.removeEventListener("dragleave",ot),window.removeEventListener("dragover",Nt),window.removeEventListener("drop",Jt)}},[wt]);const pn=xe.useCallback((ye,ot="info")=>{tt({msg:ye,type:ot}),setTimeout(()=>tt(null),3e3)},[]),$i=xe.useCallback(ye=>ye.relativePath??ye.fileName,[]),Jr=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","music.youtube.com","instagram.com","www.instagram.com"],Ze=xe.useCallback(ye=>{const ot=ye.trim();return!ot||/^https?:\/\//i.test(ot)?ot:"https://"+ot},[]),vt=xe.useCallback(ye=>{try{const ot=new URL(Ze(ye)),Nt=ot.hostname.toLowerCase();return!!(ot.pathname.toLowerCase().endsWith(".mp3")||Jr.some(Jt=>Nt===Jt||Nt.endsWith("."+Jt)))}catch{return!1}},[Ze]),zt=xe.useCallback(ye=>{try{const ot=new URL(Ze(ye)),Nt=ot.hostname.toLowerCase();return Nt.includes("youtube")||Nt==="youtu.be"?"youtube":Nt.includes("instagram")?"instagram":ot.pathname.toLowerCase().endsWith(".mp3")?"mp3":null}catch{return null}},[Ze]),at=F?F.split(":")[0]:"",d=F?F.split(":")[1]:"",J=xe.useMemo(()=>z.find(ye=>`${ye.guildId}:${ye.channelId}`===F),[z,F]);xe.useEffect(()=>{const ye=()=>{const Nt=new Date,Jt=String(Nt.getHours()).padStart(2,"0"),cn=String(Nt.getMinutes()).padStart(2,"0"),Yn=String(Nt.getSeconds()).padStart(2,"0");qt(`${Jt}:${cn}:${Yn}`)};ye();const ot=setInterval(ye,1e3);return()=>clearInterval(ot)},[]),xe.useEffect(()=>{(async()=>{try{const[ye,ot]=await Promise.all([Ede(),Cde()]);if(j(ye),ye.length){const Nt=ye[0].guildId,Jt=ot[Nt],cn=Jt&&ye.find(Yn=>Yn.guildId===Nt&&Yn.channelId===Jt);V(cn?`${Nt}:${Jt}`:`${ye[0].guildId}:${ye[0].channelId}`)}}catch(ye){pn((ye==null?void 0:ye.message)||"Channel-Fehler","error")}try{Ft(await Ode())}catch{}try{const ye=await Mde();u(ye.categories||[])}catch{}})()},[]),xe.useEffect(()=>{localStorage.setItem("jb-theme",be)},[be]);const $n=xe.useRef(null);xe.useEffect(()=>{const ye=$n.current;if(!ye)return;ye.style.setProperty("--card-size",we+"px");const ot=we/110;ye.style.setProperty("--card-emoji",Math.round(28*ot)+"px"),ye.style.setProperty("--card-font",Math.max(9,Math.round(11*ot))+"px"),localStorage.setItem("jb-card-size",String(we))},[we]),xe.useEffect(()=>{var ye,ot,Nt,Jt,cn,Yn,xi,js;if(i){if(i.soundboard){const pi=i.soundboard;Array.isArray(pi.party)&&Ce(pi.party);try{const Pr=pi.selected||{},Ei=(ye=Y.current)==null?void 0:ye.split(":")[0];Ei&&Pr[Ei]&&V(`${Ei}:${Pr[Ei]}`)}catch{}try{const Pr=pi.volumes||{},Ei=(ot=Y.current)==null?void 0:ot.split(":")[0];Ei&&typeof Pr[Ei]=="number"&&ne(Pr[Ei])}catch{}try{const Pr=pi.nowplaying||{},Ei=(Nt=Y.current)==null?void 0:Nt.split(":")[0];Ei&&typeof Pr[Ei]=="string"&&ae(Pr[Ei])}catch{}try{const Pr=pi.voicestats||{},Ei=(Jt=Y.current)==null?void 0:Jt.split(":")[0];Ei&&Pr[Ei]&&Nn(Pr[Ei])}catch{}}if(i.type==="soundboard_party")Ce(pi=>{const Pr=new Set(pi);return i.active?Pr.add(i.guildId):Pr.delete(i.guildId),Array.from(Pr)});else if(i.type==="soundboard_channel"){const pi=(cn=Y.current)==null?void 0:cn.split(":")[0];i.guildId===pi&&V(`${i.guildId}:${i.channelId}`)}else if(i.type==="soundboard_volume"){const pi=(Yn=Y.current)==null?void 0:Yn.split(":")[0];i.guildId===pi&&typeof i.volume=="number"&&ne(i.volume)}else if(i.type==="soundboard_nowplaying"){const pi=(xi=Y.current)==null?void 0:xi.split(":")[0];i.guildId===pi&&ae(i.name||"")}else if(i.type==="soundboard_voicestats"){const pi=(js=Y.current)==null?void 0:js.split(":")[0];i.guildId===pi&&Nn({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})}}},[i]),xe.useEffect(()=>{ze(at?Se.includes(at):!1)},[F,Se,at]),xe.useEffect(()=>{(async()=>{try{let ye="__all__";v==="recent"?ye="__recent__":S&&(ye=S);const ot=await d7(R,ye,void 0,!1);t(ot.items),r(ot.total),a(ot.folders)}catch(ye){pn((ye==null?void 0:ye.message)||"Sounds-Fehler","error")}})()},[v,S,R,qi,pn]),xe.useEffect(()=>{Gn()},[qi]),xe.useEffect(()=>{const ye=Tde("favs");if(ye)try{Te(JSON.parse(ye))}catch{}},[]),xe.useEffect(()=>{try{Sde("favs",JSON.stringify(de))}catch{}},[de]),xe.useEffect(()=>{F&&(async()=>{try{const ye=await Bde(at);ne(ye)}catch{}})()},[F]),xe.useEffect(()=>{const ye=()=>{te(!1),xn(null)};return document.addEventListener("click",ye),()=>document.removeEventListener("click",ye)},[]),xe.useEffect(()=>{$e&&wt&&oe()},[$e,wt]);async function Gn(){try{const ye=await wde();m(ye)}catch{}}async function Xn(ye){if(!F)return pn("Bitte einen Voice-Channel auswaehlen","error");try{await Nde(ye.name,at,d,re,ye.relativePath),ae(ye.name),Gn()}catch(ot){pn((ot==null?void 0:ot.message)||"Play fehlgeschlagen","error")}}function un(){var Jt;const ye=Ze(E);if(!ye)return pn("Bitte einen Link eingeben","error");if(!vt(ye))return pn("Nur YouTube, Instagram oder direkte MP3-Links","error");const ot=zt(ye);let Nt="";if(ot==="mp3")try{Nt=((Jt=new URL(ye).pathname.split("/").pop())==null?void 0:Jt.replace(/\.mp3$/i,""))??""}catch{}q({url:ye,type:ot,filename:Nt,phase:"input"})}async function qn(){if(G){q(ye=>ye?{...ye,phase:"downloading"}:null);try{let ye;const ot=G.filename.trim()||void 0;F&&at&&d?ye=(await Dde(G.url,at,d,re,ot)).saved:ye=(await Pde(G.url,ot)).saved,q(Nt=>Nt?{...Nt,phase:"done",savedName:ye}:null),B(""),rr(Nt=>Nt+1),Gn(),setTimeout(()=>q(null),2500)}catch(ye){q(ot=>ot?{...ot,phase:"error",error:(ye==null?void 0:ye.message)||"Fehler"}:null)}}}async function Hs(ye){if(!wt){pn("Admin-Login erforderlich zum Hochladen","error");return}kt.current&&clearTimeout(kt.current);const ot=ye.map(Jt=>({id:Math.random().toString(36).slice(2),file:Jt,status:"waiting",progress:0}));pt(ot),rn(!0);const Nt=[...ot];for(let Jt=0;Jt{Nt[Jt]={...Nt[Jt],progress:Yn},pt([...Nt])});Nt[Jt]={...Nt[Jt],status:"done",progress:100,savedName:cn}}catch(cn){Nt[Jt]={...Nt[Jt],status:"error",error:(cn==null?void 0:cn.message)??"Fehler"}}pt([...Nt])}rr(Jt=>Jt+1),Gn(),kt.current=setTimeout(()=>{rn(!1),pt([])},3500)}async function li(){if(F){ae("");try{await fetch(`${us}/stop?guildId=${encodeURIComponent(at)}`,{method:"POST"})}catch{}}}async function Fn(){if(!Z.length||!F)return;const ye=Z[Math.floor(Math.random()*Z.length)];Xn(ye)}async function cs(){if(Ne){await li();try{await Ude(at)}catch{}}else{if(!F)return pn("Bitte einen Channel auswaehlen","error");try{await Lde(at,d)}catch{}}}async function Ma(ye){const ot=`${ye.guildId}:${ye.channelId}`;V(ot),te(!1);try{await Rde(ye.guildId,ye.channelId)}catch{}}function Ul(ye){Te(ot=>({...ot,[ye]:!ot[ye]}))}async function oe(){en(!0);try{const ye=await d7("","__all__",void 0,!1);Pt(ye.items||[])}catch(ye){pn((ye==null?void 0:ye.message)||"Admin-Sounds konnten nicht geladen werden","error")}finally{en(!1)}}function Fe(ye){le(ot=>({...ot,[ye]:!ot[ye]}))}function Qe(ye){pe($i(ye)),nt(ye.name)}function Xe(){pe(""),nt("")}async function ke(){if(!Re)return;const ye=Me.trim().replace(/\.(mp3|wav)$/i,"");if(!ye){pn("Bitte einen gueltigen Namen eingeben","error");return}try{await zde(Re,ye),pn("Sound umbenannt"),Xe(),rr(ot=>ot+1),$e&&await oe()}catch(ot){pn((ot==null?void 0:ot.message)||"Umbenennen fehlgeschlagen","error")}}async function It(ye){if(ye.length!==0)try{await kde(ye),pn(ye.length===1?"Sound geloescht":`${ye.length} Sounds geloescht`),le({}),Xe(),rr(ot=>ot+1),$e&&await oe()}catch(ot){pn((ot==null?void 0:ot.message)||"Loeschen fehlgeschlagen","error")}}async function Xt(){try{await Ide(ce)?(Ft(!0),Gt(""),pn("Admin eingeloggt")):pn("Falsches Passwort","error")}catch{pn("Login fehlgeschlagen","error")}}async function mt(){try{await Fde(),Ft(!1),le({}),Xe(),pn("Ausgeloggt")}catch{}}const Z=xe.useMemo(()=>v==="favorites"?e.filter(ye=>de[ye.relativePath??ye.fileName]):e,[e,v,de]),Bt=xe.useMemo(()=>Object.values(de).filter(Boolean).length,[de]),bn=xe.useMemo(()=>s.filter(ye=>!["__all__","__recent__","__top3__"].includes(ye.key)),[s]),fn=xe.useMemo(()=>{const ye={};return bn.forEach((ot,Nt)=>{ye[ot.key]=m7[Nt%m7.length]}),ye},[bn]),ui=xe.useMemo(()=>{const ye=new Set,ot=new Set;return Z.forEach((Nt,Jt)=>{const cn=Nt.name.charAt(0).toUpperCase();ye.has(cn)||(ye.add(cn),ot.add(Jt))}),ot},[Z]),ci=xe.useMemo(()=>{const ye={};return z.forEach(ot=>{ye[ot.guildName]||(ye[ot.guildName]=[]),ye[ot.guildName].push(ot)}),ye},[z]),yi=xe.useMemo(()=>{const ye=xt.trim().toLowerCase();return ye?ht.filter(ot=>{const Nt=$i(ot).toLowerCase();return ot.name.toLowerCase().includes(ye)||(ot.folder||"").toLowerCase().includes(ye)||Nt.includes(ye)}):ht},[xt,ht,$i]),K=xe.useMemo(()=>Object.keys(X).filter(ye=>X[ye]),[X]),Un=xe.useMemo(()=>yi.filter(ye=>!!X[$i(ye)]).length,[yi,X,$i]),mn=yi.length>0&&Un===yi.length,yr=h.mostPlayed.slice(0,10),hi=h.totalSounds||n,bs=St.slice(0,5),fa=St.slice(5);return k.jsxs("div",{className:"sb-app","data-theme":be,ref:$n,children:[Ne&&k.jsx("div",{className:"party-overlay active"}),k.jsxs("header",{className:"topbar",children:[k.jsxs("div",{className:"topbar-left",children:[k.jsx("div",{className:"sb-app-logo",children:k.jsx("span",{className:"material-icons",style:{fontSize:16,color:"white"},children:"music_note"})}),k.jsx("span",{className:"sb-app-title",children:"Soundboard"}),k.jsxs("div",{className:"channel-dropdown",onClick:ye=>ye.stopPropagation(),children:[k.jsxs("button",{className:`channel-btn ${ee?"open":""}`,onClick:()=>te(!ee),children:[k.jsx("span",{className:"material-icons cb-icon",children:"headset"}),F&&k.jsx("span",{className:"channel-status"}),k.jsx("span",{className:"channel-label",children:J?`${J.channelName}${J.members?` (${J.members})`:""}`:"Channel..."}),k.jsx("span",{className:"material-icons chevron",children:"expand_more"})]}),ee&&k.jsxs("div",{className:"channel-menu visible",children:[Object.entries(ci).map(([ye,ot])=>k.jsxs(UF.Fragment,{children:[k.jsx("div",{className:"channel-menu-header",children:ye}),ot.map(Nt=>k.jsxs("div",{className:`channel-option ${`${Nt.guildId}:${Nt.channelId}`===F?"active":""}`,onClick:()=>Ma(Nt),children:[k.jsx("span",{className:"material-icons co-icon",children:"volume_up"}),Nt.channelName,Nt.members?` (${Nt.members})`:""]},`${Nt.guildId}:${Nt.channelId}`))]},ye)),z.length===0&&k.jsx("div",{className:"channel-option",style:{color:"var(--text-faint)",cursor:"default"},children:"Keine Channels verfuegbar"})]})]})]}),k.jsx("div",{className:"clock-wrap",children:k.jsxs("div",{className:"clock",children:[bs,k.jsx("span",{className:"clock-seconds",children:fa})]})}),k.jsxs("div",{className:"topbar-right",children:[Q&&k.jsxs("div",{className:"now-playing",children:[k.jsxs("div",{className:"np-waves active",children:[k.jsx("div",{className:"np-wave-bar"}),k.jsx("div",{className:"np-wave-bar"}),k.jsx("div",{className:"np-wave-bar"}),k.jsx("div",{className:"np-wave-bar"})]}),k.jsx("span",{className:"np-label",children:"Last Played:"})," ",k.jsx("span",{className:"np-name",children:Q})]}),F&&k.jsxs("div",{className:"connection",onClick:()=>me(!0),style:{cursor:"pointer"},title:"Verbindungsdetails",children:[k.jsx("span",{className:"conn-dot"}),"Verbunden",(Vt==null?void 0:Vt.voicePing)!=null&&k.jsxs("span",{className:"conn-ping",children:[Vt.voicePing,"ms"]})]}),k.jsx("button",{className:`admin-btn-icon ${wt?"active":""}`,onClick:()=>rt(!0),title:"Admin",children:k.jsx("span",{className:"material-icons",children:"settings"})})]})]}),k.jsxs("div",{className:"toolbar",children:[k.jsxs("div",{className:"cat-tabs",children:[k.jsxs("button",{className:`cat-tab ${v==="all"?"active":""}`,onClick:()=>{x("all"),w("")},children:["Alle",k.jsx("span",{className:"tab-count",children:n})]}),k.jsx("button",{className:`cat-tab ${v==="recent"?"active":""}`,onClick:()=>{x("recent"),w("")},children:"Neu hinzugefuegt"}),k.jsxs("button",{className:`cat-tab ${v==="favorites"?"active":""}`,onClick:()=>{x("favorites"),w("")},children:["Favoriten",Bt>0&&k.jsx("span",{className:"tab-count",children:Bt})]})]}),k.jsxs("div",{className:"search-wrap",children:[k.jsx("span",{className:"material-icons search-icon",children:"search"}),k.jsx("input",{className:"search-input",type:"text",placeholder:"Suchen...",value:R,onChange:ye=>C(ye.target.value)}),R&&k.jsx("button",{className:"search-clear",onClick:()=>C(""),children:k.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),k.jsxs("div",{className:"url-import-wrap",children:[k.jsx("span",{className:"material-icons url-import-icon",children:zt(E)==="youtube"?"smart_display":zt(E)==="instagram"?"photo_camera":"link"}),k.jsx("input",{className:"url-import-input",type:"text",placeholder:"YouTube / Instagram / MP3-Link...",value:E,onChange:ye=>B(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&un()}}),E&&k.jsx("span",{className:`url-import-tag ${vt(E)?"valid":"invalid"}`,children:zt(E)==="youtube"?"YT":zt(E)==="instagram"?"IG":zt(E)==="mp3"?"MP3":"?"}),k.jsx("button",{className:"url-import-btn",onClick:()=>{un()},disabled:L||!!E&&!vt(E),title:"Sound herunterladen",children:L?"Laedt...":"Download"})]}),k.jsx("div",{className:"toolbar-spacer"}),k.jsxs("div",{className:"volume-control",children:[k.jsx("span",{className:"material-icons vol-icon",onClick:()=>{const ye=re>0?0:.5;ne(ye),at&&p7(at,ye).catch(()=>{})},children:re===0?"volume_off":re<.5?"volume_down":"volume_up"}),k.jsx("input",{type:"range",className:"vol-slider",min:0,max:1,step:.01,value:re,onChange:ye=>{const ot=parseFloat(ye.target.value);ne(ot),at&&(At.current&&clearTimeout(At.current),At.current=setTimeout(()=>{p7(at,ot).catch(()=>{})},120))},style:{"--vol":`${Math.round(re*100)}%`}}),k.jsxs("span",{className:"vol-pct",children:[Math.round(re*100),"%"]})]}),k.jsxs("button",{className:"tb-btn random",onClick:Fn,title:"Zufaelliger Sound",children:[k.jsx("span",{className:"material-icons tb-icon",children:"shuffle"}),"Random"]}),k.jsxs("button",{className:`tb-btn party ${Ne?"active":""}`,onClick:cs,title:"Party Mode",children:[k.jsx("span",{className:"material-icons tb-icon",children:Ne?"celebration":"auto_awesome"}),Ne?"Party!":"Party"]}),k.jsxs("button",{className:"tb-btn stop",onClick:li,title:"Alle stoppen",children:[k.jsx("span",{className:"material-icons tb-icon",children:"stop"}),"Stop"]}),k.jsxs("div",{className:"size-control",title:"Button-Groesse",children:[k.jsx("span",{className:"material-icons sc-icon",children:"grid_view"}),k.jsx("input",{type:"range",className:"size-slider",min:80,max:160,value:we,onChange:ye=>We(parseInt(ye.target.value))})]}),k.jsx("div",{className:"theme-selector",children:qde.map(ye=>k.jsx("div",{className:`theme-dot ${be===ye.id?"active":""}`,style:{background:ye.color},title:ye.label,onClick:()=>ue(ye.id)},ye.id))})]}),k.jsxs("div",{className:"analytics-strip",children:[k.jsxs("div",{className:"analytics-card",children:[k.jsx("span",{className:"material-icons analytics-icon",children:"library_music"}),k.jsxs("div",{className:"analytics-copy",children:[k.jsx("span",{className:"analytics-label",children:"Sounds gesamt"}),k.jsx("strong",{className:"analytics-value",children:hi})]})]}),k.jsxs("div",{className:"analytics-card analytics-wide",children:[k.jsx("span",{className:"material-icons analytics-icon",children:"leaderboard"}),k.jsxs("div",{className:"analytics-copy",children:[k.jsx("span",{className:"analytics-label",children:"Most Played"}),k.jsx("div",{className:"analytics-top-list",children:yr.length===0?k.jsx("span",{className:"analytics-muted",children:"Noch keine Plays"}):yr.map((ye,ot)=>k.jsxs("span",{className:"analytics-chip",children:[ot+1,". ",ye.name," (",ye.count,")"]},ye.relativePath))})]})]})]}),v==="all"&&bn.length>0&&k.jsx("div",{className:"category-strip",children:bn.map(ye=>{const ot=fn[ye.key]||"#888",Nt=S===ye.key;return k.jsxs("button",{className:`cat-chip ${Nt?"active":""}`,onClick:()=>w(Nt?"":ye.key),style:Nt?{borderColor:ot,color:ot}:void 0,children:[k.jsx("span",{className:"cat-dot",style:{background:ot}}),ye.name.replace(/\s*\(\d+\)\s*$/,""),k.jsx("span",{className:"cat-count",children:ye.count})]},ye.key)})}),k.jsx("main",{className:"main",children:Z.length===0?k.jsxs("div",{className:"empty-state visible",children:[k.jsx("div",{className:"empty-emoji",children:v==="favorites"?"⭐":"🔇"}),k.jsx("div",{className:"empty-title",children:v==="favorites"?"Noch keine Favoriten":R?`Kein Sound fuer "${R}" gefunden`:"Keine Sounds vorhanden"}),k.jsx("div",{className:"empty-desc",children:v==="favorites"?"Klick den Stern auf einem Sound!":"Hier gibt's noch nichts zu hoeren."})]}):k.jsx("div",{className:"sound-grid",children:Z.map((ye,ot)=>{var Pr;const Nt=ye.relativePath??ye.fileName,Jt=!!de[Nt],cn=Q===ye.name,Yn=ye.isRecent||((Pr=ye.badges)==null?void 0:Pr.includes("new")),xi=ye.name.charAt(0).toUpperCase(),js=ui.has(ot),pi=ye.folder&&fn[ye.folder]||"var(--accent)";return k.jsxs("div",{className:`sound-card ${cn?"playing":""} ${js?"has-initial":""}`,style:{animationDelay:`${Math.min(ot*20,400)}ms`},onClick:Ei=>{const Zh=Ei.currentTarget,Bl=Zh.getBoundingClientRect(),nl=document.createElement("div");nl.className="ripple";const Bi=Math.max(Bl.width,Bl.height);nl.style.width=nl.style.height=Bi+"px",nl.style.left=Ei.clientX-Bl.left-Bi/2+"px",nl.style.top=Ei.clientY-Bl.top-Bi/2+"px",Zh.appendChild(nl),setTimeout(()=>nl.remove(),500),Xn(ye)},onContextMenu:Ei=>{Ei.preventDefault(),Ei.stopPropagation(),xn({x:Math.min(Ei.clientX,window.innerWidth-170),y:Math.min(Ei.clientY,window.innerHeight-140),sound:ye})},title:`${ye.name}${ye.folder?` (${ye.folder})`:""}`,children:[Yn&&k.jsx("span",{className:"new-badge",children:"NEU"}),k.jsx("span",{className:`fav-star ${Jt?"active":""}`,onClick:Ei=>{Ei.stopPropagation(),Ul(Nt)},children:k.jsx("span",{className:"material-icons fav-icon",children:Jt?"star":"star_border"})}),js&&k.jsx("span",{className:"sound-emoji",style:{color:pi},children:xi}),k.jsx("span",{className:"sound-name",children:ye.name}),ye.folder&&k.jsx("span",{className:"sound-duration",children:ye.folder}),k.jsxs("div",{className:"playing-indicator",children:[k.jsx("div",{className:"wave-bar"}),k.jsx("div",{className:"wave-bar"}),k.jsx("div",{className:"wave-bar"}),k.jsx("div",{className:"wave-bar"})]})]},Nt)})})}),Ht&&k.jsxs("div",{className:"ctx-menu visible",style:{left:Ht.x,top:Ht.y},onClick:ye=>ye.stopPropagation(),children:[k.jsxs("div",{className:"ctx-item",onClick:()=>{Xn(Ht.sound),xn(null)},children:[k.jsx("span",{className:"material-icons ctx-icon",children:"play_arrow"}),"Abspielen"]}),k.jsxs("div",{className:"ctx-item",onClick:()=>{Ul(Ht.sound.relativePath??Ht.sound.fileName),xn(null)},children:[k.jsx("span",{className:"material-icons ctx-icon",children:de[Ht.sound.relativePath??Ht.sound.fileName]?"star":"star_border"}),"Favorit"]}),wt&&k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"ctx-sep"}),k.jsxs("div",{className:"ctx-item danger",onClick:async()=>{const ye=Ht.sound.relativePath??Ht.sound.fileName;await It([ye]),xn(null)},children:[k.jsx("span",{className:"material-icons ctx-icon",children:"delete"}),"Loeschen"]})]})]}),_i&&(()=>{const ye=Vt!=null&&Vt.connectedSince?Math.floor((Date.now()-new Date(Vt.connectedSince).getTime())/1e3):0,ot=Math.floor(ye/3600),Nt=Math.floor(ye%3600/60),Jt=ye%60,cn=ot>0?`${ot}h ${String(Nt).padStart(2,"0")}m ${String(Jt).padStart(2,"0")}s`:Nt>0?`${Nt}m ${String(Jt).padStart(2,"0")}s`:`${Jt}s`,Yn=xi=>xi==null?"var(--muted)":xi<80?"var(--green)":xi<150?"#f0a830":"#e04040";return k.jsx("div",{className:"conn-modal-overlay",onClick:()=>me(!1),children:k.jsxs("div",{className:"conn-modal",onClick:xi=>xi.stopPropagation(),children:[k.jsxs("div",{className:"conn-modal-header",children:[k.jsx("span",{className:"material-icons",style:{fontSize:20,color:"var(--green)"},children:"cell_tower"}),k.jsx("span",{children:"Verbindungsdetails"}),k.jsx("button",{className:"conn-modal-close",onClick:()=>me(!1),children:k.jsx("span",{className:"material-icons",children:"close"})})]}),k.jsxs("div",{className:"conn-modal-body",children:[k.jsxs("div",{className:"conn-stat",children:[k.jsx("span",{className:"conn-stat-label",children:"Voice Ping"}),k.jsxs("span",{className:"conn-stat-value",children:[k.jsx("span",{className:"conn-ping-dot",style:{background:Yn((Vt==null?void 0:Vt.voicePing)??null)}}),(Vt==null?void 0:Vt.voicePing)!=null?`${Vt.voicePing} ms`:"---"]})]}),k.jsxs("div",{className:"conn-stat",children:[k.jsx("span",{className:"conn-stat-label",children:"Gateway Ping"}),k.jsxs("span",{className:"conn-stat-value",children:[k.jsx("span",{className:"conn-ping-dot",style:{background:Yn((Vt==null?void 0:Vt.gatewayPing)??null)}}),Vt&&Vt.gatewayPing>=0?`${Vt.gatewayPing} ms`:"---"]})]}),k.jsxs("div",{className:"conn-stat",children:[k.jsx("span",{className:"conn-stat-label",children:"Status"}),k.jsx("span",{className:"conn-stat-value",style:{color:(Vt==null?void 0:Vt.status)==="ready"?"var(--green)":"#f0a830"},children:(Vt==null?void 0:Vt.status)==="ready"?"Verbunden":(Vt==null?void 0:Vt.status)??"Warte auf Verbindung"})]}),k.jsxs("div",{className:"conn-stat",children:[k.jsx("span",{className:"conn-stat-label",children:"Kanal"}),k.jsx("span",{className:"conn-stat-value",children:(Vt==null?void 0:Vt.channelName)||"---"})]}),k.jsxs("div",{className:"conn-stat",children:[k.jsx("span",{className:"conn-stat-label",children:"Verbunden seit"}),k.jsx("span",{className:"conn-stat-value",children:cn||"---"})]})]})]})})})(),bt&&k.jsxs("div",{className:`toast ${bt.type}`,children:[k.jsx("span",{className:"material-icons toast-icon",children:bt.type==="error"?"error_outline":"check_circle"}),bt.msg]}),$e&&k.jsx("div",{className:"admin-overlay",onClick:ye=>{ye.target===ye.currentTarget&&rt(!1)},children:k.jsxs("div",{className:"admin-panel",children:[k.jsxs("h3",{children:["Admin",k.jsx("button",{className:"admin-close",onClick:()=>rt(!1),children:k.jsx("span",{className:"material-icons",style:{fontSize:18},children:"close"})})]}),wt?k.jsxs("div",{className:"admin-shell",children:[k.jsxs("div",{className:"admin-header-row",children:[k.jsx("p",{className:"admin-status",children:"Eingeloggt als Admin"}),k.jsxs("div",{className:"admin-actions-inline",children:[k.jsx("button",{className:"admin-btn-action outline",onClick:()=>{oe()},disabled:yt,children:"Aktualisieren"}),k.jsx("button",{className:"admin-btn-action outline",onClick:mt,children:"Logout"})]})]}),k.jsxs("div",{className:"admin-field admin-search-field",children:[k.jsx("label",{children:"Sounds verwalten"}),k.jsx("input",{type:"text",value:xt,onChange:ye=>fe(ye.target.value),placeholder:"Nach Name, Ordner oder Pfad filtern..."})]}),k.jsxs("div",{className:"admin-bulk-row",children:[k.jsxs("label",{className:"admin-select-all",children:[k.jsx("input",{type:"checkbox",checked:mn,onChange:ye=>{const ot=ye.target.checked,Nt={...X};yi.forEach(Jt=>{Nt[$i(Jt)]=ot}),le(Nt)}}),k.jsxs("span",{children:["Alle sichtbaren auswaehlen (",Un,"/",yi.length,")"]})]}),k.jsx("button",{className:"admin-btn-action danger",disabled:K.length===0,onClick:async()=>{window.confirm(`Wirklich ${K.length} Sound(s) loeschen?`)&&await It(K)},children:"Ausgewaehlte loeschen"})]}),k.jsx("div",{className:"admin-list-wrap",children:yt?k.jsx("div",{className:"admin-empty",children:"Lade Sounds..."}):yi.length===0?k.jsx("div",{className:"admin-empty",children:"Keine Sounds gefunden."}):k.jsx("div",{className:"admin-list",children:yi.map(ye=>{const ot=$i(ye),Nt=Re===ot;return k.jsxs("div",{className:"admin-item",children:[k.jsx("label",{className:"admin-item-check",children:k.jsx("input",{type:"checkbox",checked:!!X[ot],onChange:()=>Fe(ot)})}),k.jsxs("div",{className:"admin-item-main",children:[k.jsx("div",{className:"admin-item-name",children:ye.name}),k.jsxs("div",{className:"admin-item-meta",children:[ye.folder?`Ordner: ${ye.folder}`:"Root"," · ",ot]}),Nt&&k.jsxs("div",{className:"admin-rename-row",children:[k.jsx("input",{value:Me,onChange:Jt=>nt(Jt.target.value),onKeyDown:Jt=>{Jt.key==="Enter"&&ke(),Jt.key==="Escape"&&Xe()},placeholder:"Neuer Name..."}),k.jsx("button",{className:"admin-btn-action primary",onClick:()=>{ke()},children:"Speichern"}),k.jsx("button",{className:"admin-btn-action outline",onClick:Xe,children:"Abbrechen"})]})]}),!Nt&&k.jsxs("div",{className:"admin-item-actions",children:[k.jsx("button",{className:"admin-btn-action outline",onClick:()=>Qe(ye),children:"Umbenennen"}),k.jsx("button",{className:"admin-btn-action danger ghost",onClick:async()=>{window.confirm(`Sound "${ye.name}" loeschen?`)&&await It([ot])},children:"Loeschen"})]})]},ot)})})})]}):k.jsxs("div",{children:[k.jsxs("div",{className:"admin-field",children:[k.jsx("label",{children:"Passwort"}),k.jsx("input",{type:"password",value:ce,onChange:ye=>Gt(ye.target.value),onKeyDown:ye=>ye.key==="Enter"&&Xt(),placeholder:"Admin-Passwort..."})]}),k.jsx("button",{className:"admin-btn-action primary",onClick:Xt,children:"Login"})]})]})}),lt&&k.jsx("div",{className:"drop-overlay",children:k.jsxs("div",{className:"drop-zone",children:[k.jsx("span",{className:"material-icons drop-icon",children:"cloud_upload"}),k.jsx("div",{className:"drop-title",children:"MP3 & WAV hier ablegen"}),k.jsx("div",{className:"drop-sub",children:"Mehrere Dateien gleichzeitig moeglich"})]})}),Yt&&jt.length>0&&k.jsxs("div",{className:"upload-queue",children:[k.jsxs("div",{className:"uq-header",children:[k.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),k.jsx("span",{children:jt.every(ye=>ye.status==="done"||ye.status==="error")?`${jt.filter(ye=>ye.status==="done").length} von ${jt.length} hochgeladen`:`Lade hoch… (${jt.filter(ye=>ye.status==="done").length}/${jt.length})`}),k.jsx("button",{className:"uq-close",onClick:()=>{rn(!1),pt([])},children:k.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),k.jsx("div",{className:"uq-list",children:jt.map(ye=>k.jsxs("div",{className:`uq-item uq-${ye.status}`,children:[k.jsx("span",{className:"material-icons uq-file-icon",children:"audio_file"}),k.jsxs("div",{className:"uq-info",children:[k.jsx("div",{className:"uq-name",title:ye.savedName??ye.file.name,children:ye.savedName??ye.file.name}),k.jsxs("div",{className:"uq-size",children:[(ye.file.size/1024).toFixed(0)," KB"]})]}),(ye.status==="waiting"||ye.status==="uploading")&&k.jsx("div",{className:"uq-progress-wrap",children:k.jsx("div",{className:"uq-progress-bar",style:{width:`${ye.progress}%`}})}),k.jsx("span",{className:`material-icons uq-status-icon uq-status-${ye.status}`,children:ye.status==="done"?"check_circle":ye.status==="error"?"error":ye.status==="uploading"?"sync":"schedule"}),ye.status==="error"&&k.jsx("div",{className:"uq-error",children:ye.error})]},ye.id))})]}),G&&k.jsx("div",{className:"dl-modal-overlay",onClick:()=>G.phase!=="downloading"&&q(null),children:k.jsxs("div",{className:"dl-modal",onClick:ye=>ye.stopPropagation(),children:[k.jsxs("div",{className:"dl-modal-header",children:[k.jsx("span",{className:"material-icons",style:{fontSize:20},children:G.type==="youtube"?"smart_display":G.type==="instagram"?"photo_camera":"audio_file"}),k.jsx("span",{children:G.phase==="input"?"Sound herunterladen":G.phase==="downloading"?"Wird heruntergeladen...":G.phase==="done"?"Fertig!":"Fehler"}),G.phase!=="downloading"&&k.jsx("button",{className:"dl-modal-close",onClick:()=>q(null),children:k.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),k.jsxs("div",{className:"dl-modal-body",children:[k.jsxs("div",{className:"dl-modal-url",children:[k.jsx("span",{className:`dl-modal-tag ${G.type??""}`,children:G.type==="youtube"?"YouTube":G.type==="instagram"?"Instagram":"MP3"}),k.jsx("span",{className:"dl-modal-url-text",title:G.url,children:G.url.length>60?G.url.slice(0,57)+"...":G.url})]}),G.phase==="input"&&k.jsxs("div",{className:"dl-modal-field",children:[k.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),k.jsxs("div",{className:"dl-modal-input-wrap",children:[k.jsx("input",{className:"dl-modal-input",type:"text",placeholder:G.type==="mp3"?"Dateiname...":"Wird automatisch erkannt...",value:G.filename,onChange:ye=>q(ot=>ot?{...ot,filename:ye.target.value}:null),onKeyDown:ye=>{ye.key==="Enter"&&qn()},autoFocus:!0}),k.jsx("span",{className:"dl-modal-ext",children:".mp3"})]}),k.jsx("span",{className:"dl-modal-hint",children:"Leer lassen = automatischer Name"})]}),G.phase==="downloading"&&k.jsxs("div",{className:"dl-modal-progress",children:[k.jsx("div",{className:"dl-modal-spinner"}),k.jsx("span",{children:G.type==="youtube"||G.type==="instagram"?"Audio wird extrahiert...":"MP3 wird heruntergeladen..."})]}),G.phase==="done"&&k.jsxs("div",{className:"dl-modal-success",children:[k.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),k.jsxs("span",{children:["Gespeichert als ",k.jsx("b",{children:G.savedName})]})]}),G.phase==="error"&&k.jsxs("div",{className:"dl-modal-error",children:[k.jsx("span",{className:"material-icons",style:{color:"#e74c3c"},children:"error"}),k.jsx("span",{children:G.error})]})]}),G.phase==="input"&&k.jsxs("div",{className:"dl-modal-actions",children:[k.jsx("button",{className:"dl-modal-cancel",onClick:()=>q(null),children:"Abbrechen"}),k.jsxs("button",{className:"dl-modal-submit",onClick:()=>void qn(),children:[k.jsx("span",{className:"material-icons",style:{fontSize:16},children:"download"}),"Herunterladen"]})]}),G.phase==="error"&&k.jsxs("div",{className:"dl-modal-actions",children:[k.jsx("button",{className:"dl-modal-cancel",onClick:()=>q(null),children:"Schliessen"}),k.jsxs("button",{className:"dl-modal-submit",onClick:()=>q(ye=>ye?{...ye,phase:"input",error:void 0}:null),children:[k.jsx("span",{className:"material-icons",style:{fontSize:16},children:"refresh"}),"Nochmal"]})]})]})})]})}const g7={IRON:"#6b6b6b",BRONZE:"#8c6239",SILVER:"#8c8c8c",GOLD:"#d4a017",PLATINUM:"#28b29e",EMERALD:"#1e9e5e",DIAMOND:"#576cce",MASTER:"#9d48e0",GRANDMASTER:"#e44c3e",CHALLENGER:"#f4c874"},Hde={SOLORANKED:"Ranked Solo",FLEXRANKED:"Ranked Flex",NORMAL:"Normal",ARAM:"ARAM",ARENA:"Arena",URF:"URF",BOT:"Co-op vs AI"},jde="https://ddragon.leagueoflegends.com/cdn/15.5.1/img";function zv(i){return`${jde}/champion/${i}.png`}function v7(i){const e=Math.floor((Date.now()-new Date(i).getTime())/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function Wde(i){const e=Math.floor(i/60),t=i%60;return`${e}:${String(t).padStart(2,"0")}`}function _7(i,e,t){return e===0?"Perfect":((i+t)/e).toFixed(2)}function y7(i,e){const t=i+e;return t>0?Math.round(i/t*100):0}function $de(i,e){if(!i)return"Unranked";const t=["","I","II","III","IV"];return`${i.charAt(0)}${i.slice(1).toLowerCase()}${e?" "+(t[e]??e):""}`}function Xde({data:i}){var we,We,Ne,ze;const[e,t]=xe.useState(""),[n,r]=xe.useState("EUW"),[s,a]=xe.useState([]),[l,u]=xe.useState(null),[h,m]=xe.useState([]),[v,x]=xe.useState(!1),[S,w]=xe.useState(null),[R,C]=xe.useState([]),[E,B]=xe.useState(null),[L,O]=xe.useState({}),[G,q]=xe.useState(!1),[z,j]=xe.useState(!1),[F,V]=xe.useState(null),Y=xe.useRef(null),ee=xe.useRef(null);xe.useEffect(()=>{fetch("/api/lolstats/regions").then(Se=>Se.json()).then(a).catch(()=>{}),fetch("/api/lolstats/recent").then(Se=>Se.json()).then(C).catch(()=>{})},[]),xe.useEffect(()=>{i&&(i.recentSearches&&C(i.recentSearches),i.regions&&!s.length&&a(i.regions))},[i]);const te=xe.useCallback(async(Se,Ce,dt)=>{j(!0);try{const At=`gameName=${encodeURIComponent(Se)}&tagLine=${encodeURIComponent(Ce)}®ion=${dt}`,wt=await fetch(`/api/lolstats/renew?${At}`,{method:"POST"});if(wt.ok){const Ft=await wt.json();return Ft.last_updated_at&&V(Ft.last_updated_at),Ft.renewed??!1}}catch{}return j(!1),!1},[]),re=xe.useCallback(async(Se,Ce,dt,At=!1)=>{var rt,ce;let wt=Se??"",Ft=Ce??"";const $e=dt??n;if(!wt){const Gt=e.split("#");wt=((rt=Gt[0])==null?void 0:rt.trim())??"",Ft=((ce=Gt[1])==null?void 0:ce.trim())??""}if(!wt||!Ft){w("Bitte im Format Name#Tag eingeben");return}x(!0),w(null),u(null),m([]),B(null),O({}),ee.current={gameName:wt,tagLine:Ft,region:$e},At||te(wt,Ft,$e).finally(()=>j(!1));try{const Gt=`gameName=${encodeURIComponent(wt)}&tagLine=${encodeURIComponent(Ft)}®ion=${$e}`,[ht,Pt]=await Promise.all([fetch(`/api/lolstats/profile?${Gt}`),fetch(`/api/lolstats/matches?${Gt}&limit=10`)]);if(!ht.ok){const en=await ht.json();throw new Error(en.error??`Fehler ${ht.status}`)}const yt=await ht.json();if(u(yt),yt.updated_at&&V(yt.updated_at),Pt.ok){const en=await Pt.json();m(Array.isArray(en)?en:[])}}catch(Gt){w(Gt.message)}x(!1)},[e,n,te]),ne=xe.useCallback(async()=>{const Se=ee.current;if(!(!Se||z)){j(!0);try{await te(Se.gameName,Se.tagLine,Se.region),await new Promise(Ce=>setTimeout(Ce,1500)),await re(Se.gameName,Se.tagLine,Se.region,!0)}finally{j(!1)}}},[te,re,z]),Q=xe.useCallback(async()=>{if(!(!l||G)){q(!0);try{const Se=`gameName=${encodeURIComponent(l.game_name)}&tagLine=${encodeURIComponent(l.tagline)}®ion=${n}&limit=20`,Ce=await fetch(`/api/lolstats/matches?${Se}`);if(Ce.ok){const dt=await Ce.json();m(Array.isArray(dt)?dt:[])}}catch{}q(!1)}},[l,n,G]),ae=xe.useCallback(async Se=>{var Ce;if(E===Se.id){B(null);return}if(B(Se.id),!(((Ce=Se.participants)==null?void 0:Ce.length)>=10||L[Se.id]))try{const dt=`region=${n}&createdAt=${encodeURIComponent(Se.created_at)}`,At=await fetch(`/api/lolstats/match/${encodeURIComponent(Se.id)}?${dt}`);if(At.ok){const wt=await At.json();O(Ft=>({...Ft,[Se.id]:wt}))}}catch{}},[E,L,n]),de=xe.useCallback(Se=>{t(`${Se.game_name}#${Se.tag_line}`),r(Se.region),re(Se.game_name,Se.tag_line,Se.region)},[re]),Te=xe.useCallback(Se=>{var dt,At,wt;if(!l)return((dt=Se.participants)==null?void 0:dt[0])??null;const Ce=l.game_name.toLowerCase();return((At=Se.participants)==null?void 0:At.find(Ft=>{var $e,rt;return((rt=($e=Ft.summoner)==null?void 0:$e.game_name)==null?void 0:rt.toLowerCase())===Ce}))??((wt=Se.participants)==null?void 0:wt[0])??null},[l]),be=Se=>{var ce,Gt,ht;const Ce=Te(Se);if(!Ce)return null;const dt=((ce=Ce.stats)==null?void 0:ce.result)==="WIN",At=_7(Ce.stats.kill,Ce.stats.death,Ce.stats.assist),wt=(Ce.stats.minion_kill??0)+(Ce.stats.neutral_minion_kill??0),Ft=Se.game_length_second>0?(wt/(Se.game_length_second/60)).toFixed(1):"0",$e=E===Se.id,rt=L[Se.id]??(((Gt=Se.participants)==null?void 0:Gt.length)>=10?Se:null);return k.jsxs("div",{children:[k.jsxs("div",{className:`lol-match ${dt?"win":"loss"}`,onClick:()=>ae(Se),children:[k.jsx("div",{className:"lol-match-result",children:dt?"W":"L"}),k.jsxs("div",{className:"lol-match-champ",children:[k.jsx("img",{src:zv(Ce.champion_name),alt:Ce.champion_name,title:Ce.champion_name}),k.jsx("span",{className:"lol-match-champ-level",children:Ce.stats.champion_level})]}),k.jsxs("div",{className:"lol-match-kda",children:[k.jsxs("div",{className:"lol-match-kda-nums",children:[Ce.stats.kill,"/",Ce.stats.death,"/",Ce.stats.assist]}),k.jsxs("div",{className:`lol-match-kda-ratio ${At==="Perfect"?"perfect":Number(At)>=4?"great":""}`,children:[At," KDA"]})]}),k.jsxs("div",{className:"lol-match-stats",children:[k.jsxs("span",{children:[wt," CS (",Ft,"/m)"]}),k.jsxs("span",{children:[Ce.stats.ward_place," wards"]})]}),k.jsx("div",{className:"lol-match-items",children:(Ce.items_names??[]).slice(0,7).map((Pt,yt)=>Pt?k.jsx("img",{src:zv("Aatrox"),alt:Pt,title:Pt,style:{background:"var(--bg-deep)"},onError:en=>{en.target.style.display="none"}},yt):k.jsx("div",{className:"lol-match-item-empty"},yt))}),k.jsxs("div",{className:"lol-match-meta",children:[k.jsx("div",{className:"lol-match-duration",children:Wde(Se.game_length_second)}),k.jsx("div",{className:"lol-match-queue",children:Hde[Se.game_type]??Se.game_type}),k.jsxs("div",{className:"lol-match-ago",children:[v7(Se.created_at)," ago"]})]})]}),$e&&rt&&k.jsx("div",{className:"lol-match-detail",children:ue(rt,(ht=Ce.summoner)==null?void 0:ht.game_name)})]},Se.id)},ue=(Se,Ce)=>{var $e,rt,ce,Gt,ht;const dt=(($e=Se.participants)==null?void 0:$e.filter(Pt=>Pt.team_key==="BLUE"))??[],At=((rt=Se.participants)==null?void 0:rt.filter(Pt=>Pt.team_key==="RED"))??[],wt=(ht=(Gt=(ce=Se.teams)==null?void 0:ce.find(Pt=>Pt.key==="BLUE"))==null?void 0:Gt.game_stat)==null?void 0:ht.is_win,Ft=(Pt,yt,en)=>k.jsxs("div",{className:"lol-match-detail-team",children:[k.jsxs("div",{className:`lol-match-detail-team-header ${yt?"win":"loss"}`,children:[en," — ",yt?"Victory":"Defeat"]}),Pt.map((xt,fe)=>{var Re,pe,Me,nt,lt,Ot,jt,pt,Yt,rn,$t,kt;const X=((pe=(Re=xt.summoner)==null?void 0:Re.game_name)==null?void 0:pe.toLowerCase())===(Ce==null?void 0:Ce.toLowerCase()),le=(((Me=xt.stats)==null?void 0:Me.minion_kill)??0)+(((nt=xt.stats)==null?void 0:nt.neutral_minion_kill)??0);return k.jsxs("div",{className:`lol-detail-row ${X?"me":""}`,children:[k.jsx("img",{className:"lol-detail-champ",src:zv(xt.champion_name),alt:xt.champion_name}),k.jsx("span",{className:"lol-detail-name",title:`${(lt=xt.summoner)==null?void 0:lt.game_name}#${(Ot=xt.summoner)==null?void 0:Ot.tagline}`,children:((jt=xt.summoner)==null?void 0:jt.game_name)??xt.champion_name}),k.jsxs("span",{className:"lol-detail-kda",children:[(pt=xt.stats)==null?void 0:pt.kill,"/",(Yt=xt.stats)==null?void 0:Yt.death,"/",(rn=xt.stats)==null?void 0:rn.assist]}),k.jsxs("span",{className:"lol-detail-cs",children:[le," CS"]}),k.jsxs("span",{className:"lol-detail-dmg",children:[(((($t=xt.stats)==null?void 0:$t.total_damage_dealt_to_champions)??0)/1e3).toFixed(1),"k"]}),k.jsxs("span",{className:"lol-detail-gold",children:[((((kt=xt.stats)==null?void 0:kt.gold_earned)??0)/1e3).toFixed(1),"k"]})]},fe)})]});return k.jsxs(k.Fragment,{children:[Ft(dt,wt,"Blue Team"),Ft(At,wt===void 0?void 0:!wt,"Red Team")]})};return k.jsxs("div",{className:"lol-container",children:[k.jsxs("div",{className:"lol-search",children:[k.jsx("input",{ref:Y,className:"lol-search-input",placeholder:"Summoner Name#Tag",value:e,onChange:Se=>t(Se.target.value),onKeyDown:Se=>Se.key==="Enter"&&re()}),k.jsx("select",{className:"lol-search-region",value:n,onChange:Se=>r(Se.target.value),children:s.map(Se=>k.jsx("option",{value:Se.code,children:Se.code},Se.code))}),k.jsx("button",{className:"lol-search-btn",onClick:()=>re(),disabled:v,children:v?"...":"Search"})]}),R.length>0&&k.jsx("div",{className:"lol-recent",children:R.map((Se,Ce)=>k.jsxs("button",{className:"lol-recent-chip",onClick:()=>de(Se),children:[Se.profile_image_url&&k.jsx("img",{src:Se.profile_image_url,alt:""}),Se.game_name,"#",Se.tag_line,Se.tier&&k.jsx("span",{className:"lol-recent-tier",style:{color:g7[Se.tier]},children:Se.tier})]},Ce))}),S&&k.jsx("div",{className:"lol-error",children:S}),v&&k.jsxs("div",{className:"lol-loading",children:[k.jsx("div",{className:"lol-spinner"}),"Lade Profil..."]}),l&&!v&&k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"lol-profile",children:[k.jsx("img",{className:"lol-profile-icon",src:l.profile_image_url,alt:""}),k.jsxs("div",{className:"lol-profile-info",children:[k.jsxs("h2",{children:[l.game_name,k.jsxs("span",{children:["#",l.tagline]})]}),k.jsxs("div",{className:"lol-profile-level",children:["Level ",l.level]}),((we=l.ladder_rank)==null?void 0:we.rank)&&k.jsxs("div",{className:"lol-profile-ladder",children:["Ladder Rank #",l.ladder_rank.rank.toLocaleString()," / ",(We=l.ladder_rank.total)==null?void 0:We.toLocaleString()]}),F&&k.jsxs("div",{className:"lol-profile-updated",children:["Updated ",v7(F)," ago"]})]}),k.jsxs("button",{className:`lol-update-btn ${z?"renewing":""}`,onClick:ne,disabled:z,title:"Refresh data from Riot servers",children:[k.jsx("span",{className:"lol-update-icon",children:z?"⟳":"↻"}),z?"Updating...":"Update"]})]}),k.jsx("div",{className:"lol-ranked-row",children:(l.league_stats??[]).filter(Se=>Se.game_type==="SOLORANKED"||Se.game_type==="FLEXRANKED").map(Se=>{const Ce=Se.tier_info,dt=!!(Ce!=null&&Ce.tier),At=g7[(Ce==null?void 0:Ce.tier)??""]??"var(--text-normal)";return k.jsxs("div",{className:`lol-ranked-card ${dt?"has-rank":""}`,style:{"--tier-color":At},children:[k.jsx("div",{className:"lol-ranked-type",children:Se.game_type==="SOLORANKED"?"Ranked Solo/Duo":"Ranked Flex"}),dt?k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"lol-ranked-tier",style:{color:At},children:[$de(Ce.tier,Ce.division),k.jsxs("span",{className:"lol-ranked-lp",children:[Ce.lp," LP"]})]}),k.jsxs("div",{className:"lol-ranked-record",children:[Se.win,"W ",Se.lose,"L",k.jsxs("span",{className:"lol-ranked-wr",children:["(",y7(Se.win??0,Se.lose??0),"%)"]}),Se.is_hot_streak&&k.jsx("span",{className:"lol-ranked-streak",children:"🔥"})]})]}):k.jsx("div",{className:"lol-ranked-tier",children:"Unranked"})]},Se.game_type)})}),((ze=(Ne=l.most_champions)==null?void 0:Ne.champion_stats)==null?void 0:ze.length)>0&&k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"lol-section-title",children:"Top Champions"}),k.jsx("div",{className:"lol-champs",children:l.most_champions.champion_stats.slice(0,7).map(Se=>{const Ce=y7(Se.win,Se.lose),dt=Se.play>0?_7(Se.kill/Se.play,Se.death/Se.play,Se.assist/Se.play):"0";return k.jsxs("div",{className:"lol-champ-card",children:[k.jsx("img",{className:"lol-champ-icon",src:zv(Se.champion_name),alt:Se.champion_name}),k.jsxs("div",{children:[k.jsx("div",{className:"lol-champ-name",children:Se.champion_name}),k.jsxs("div",{className:"lol-champ-stats",children:[Se.play," games · ",Ce,"% WR"]}),k.jsxs("div",{className:"lol-champ-kda",children:[dt," KDA"]})]})]},Se.champion_name)})})]}),h.length>0&&k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"lol-section-title",children:"Match History"}),k.jsx("div",{className:"lol-matches",children:h.map(Se=>be(Se))}),h.length<20&&k.jsx("button",{className:"lol-load-more",onClick:Q,disabled:G,children:G?"Laden...":"Mehr laden"})]})]}),!l&&!v&&!S&&k.jsxs("div",{className:"lol-empty",children:[k.jsx("div",{className:"lol-empty-icon",children:"⚔️"}),k.jsx("h3",{children:"League of Legends Stats"}),k.jsx("p",{children:"Gib einen Summoner Name#Tag ein und wähle die Region"})]})]})}const x7={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function qS(i){const e=Math.max(0,Math.floor((Date.now()-new Date(i).getTime())/1e3)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function Yde({data:i}){var fe,X;const[e,t]=xe.useState([]),[n,r]=xe.useState(()=>localStorage.getItem("streaming_name")||""),[s,a]=xe.useState("Screen Share"),[l,u]=xe.useState(""),[h,m]=xe.useState(null),[v,x]=xe.useState(null),[S,w]=xe.useState(null),[R,C]=xe.useState(!1),[E,B]=xe.useState(!1),[L,O]=xe.useState(null),[,G]=xe.useState(0),[q,z]=xe.useState(null),[j,F]=xe.useState(null),V=xe.useRef(null),Y=xe.useRef(""),ee=xe.useRef(null),te=xe.useRef(null),re=xe.useRef(null),ne=xe.useRef(new Map),Q=xe.useRef(null),ae=xe.useRef(new Map),de=xe.useRef(null),Te=xe.useRef(1e3),be=xe.useRef(!1),ue=xe.useRef(null);xe.useEffect(()=>{be.current=R},[R]),xe.useEffect(()=>{ue.current=L},[L]),xe.useEffect(()=>{if(!(e.length>0||R))return;const Re=setInterval(()=>G(pe=>pe+1),1e3);return()=>clearInterval(Re)},[e.length,R]),xe.useEffect(()=>{i!=null&&i.streams&&t(i.streams)},[i]),xe.useEffect(()=>{n&&localStorage.setItem("streaming_name",n)},[n]),xe.useEffect(()=>{if(!q)return;const le=()=>z(null);return document.addEventListener("click",le),()=>document.removeEventListener("click",le)},[q]);const we=xe.useCallback(le=>{var Re;((Re=V.current)==null?void 0:Re.readyState)===WebSocket.OPEN&&V.current.send(JSON.stringify(le))},[]),We=xe.useCallback((le,Re,pe)=>{if(le.remoteDescription)le.addIceCandidate(new RTCIceCandidate(pe)).catch(()=>{});else{let Me=ae.current.get(Re);Me||(Me=[],ae.current.set(Re,Me)),Me.push(pe)}},[]),Ne=xe.useCallback((le,Re)=>{const pe=ae.current.get(Re);if(pe){for(const Me of pe)le.addIceCandidate(new RTCIceCandidate(Me)).catch(()=>{});ae.current.delete(Re)}},[]),ze=xe.useCallback(()=>{Q.current&&(Q.current.close(),Q.current=null),re.current&&(re.current.srcObject=null)},[]),Se=xe.useRef(()=>{});Se.current=le=>{var Re;switch(le.type){case"welcome":Y.current=le.clientId,le.streams&&t(le.streams);break;case"broadcast_started":w(le.streamId),C(!0),be.current=!0,B(!1);break;case"stream_available":break;case"stream_ended":((Re=ue.current)==null?void 0:Re.streamId)===le.streamId&&(ze(),O(null));break;case"viewer_joined":{const pe=le.viewerId,Me=ne.current.get(pe);Me&&(Me.close(),ne.current.delete(pe)),ae.current.delete(pe);const nt=new RTCPeerConnection(x7);ne.current.set(pe,nt);const lt=ee.current;if(lt)for(const jt of lt.getTracks())nt.addTrack(jt,lt);nt.onicecandidate=jt=>{jt.candidate&&we({type:"ice_candidate",targetId:pe,candidate:jt.candidate.toJSON()})};const Ot=nt.getSenders().find(jt=>{var pt;return((pt=jt.track)==null?void 0:pt.kind)==="video"});if(Ot){const jt=Ot.getParameters();(!jt.encodings||jt.encodings.length===0)&&(jt.encodings=[{}]),jt.encodings[0].maxFramerate=60,jt.encodings[0].maxBitrate=8e6,Ot.setParameters(jt).catch(()=>{})}nt.createOffer().then(jt=>nt.setLocalDescription(jt)).then(()=>we({type:"offer",targetId:pe,sdp:nt.localDescription})).catch(console.error);break}case"viewer_left":{const pe=ne.current.get(le.viewerId);pe&&(pe.close(),ne.current.delete(le.viewerId)),ae.current.delete(le.viewerId);break}case"offer":{const pe=le.fromId;Q.current&&(Q.current.close(),Q.current=null),ae.current.delete(pe);const Me=new RTCPeerConnection(x7);Q.current=Me,Me.ontrack=nt=>{re.current&&nt.streams[0]&&(re.current.srcObject=nt.streams[0]),O(lt=>lt&&{...lt,phase:"connected"})},Me.onicecandidate=nt=>{nt.candidate&&we({type:"ice_candidate",targetId:pe,candidate:nt.candidate.toJSON()})},Me.oniceconnectionstatechange=()=>{(Me.iceConnectionState==="failed"||Me.iceConnectionState==="disconnected")&&O(nt=>nt&&{...nt,phase:"error",error:"Verbindung verloren"})},Me.setRemoteDescription(new RTCSessionDescription(le.sdp)).then(()=>(Ne(Me,pe),Me.createAnswer())).then(nt=>Me.setLocalDescription(nt)).then(()=>we({type:"answer",targetId:pe,sdp:Me.localDescription})).catch(console.error);break}case"answer":{const pe=ne.current.get(le.fromId);pe&&pe.setRemoteDescription(new RTCSessionDescription(le.sdp)).then(()=>Ne(pe,le.fromId)).catch(console.error);break}case"ice_candidate":{if(!le.candidate)break;const pe=ne.current.get(le.fromId);pe?We(pe,le.fromId,le.candidate):Q.current&&We(Q.current,le.fromId,le.candidate);break}case"error":le.code==="WRONG_PASSWORD"?x(pe=>pe&&{...pe,error:le.message}):m(le.message),B(!1);break}};const Ce=xe.useCallback(()=>{if(V.current&&V.current.readyState===WebSocket.OPEN)return;const le=location.protocol==="https:"?"wss":"ws",Re=new WebSocket(`${le}://${location.host}/ws/streaming`);V.current=Re,Re.onopen=()=>{Te.current=1e3},Re.onmessage=pe=>{let Me;try{Me=JSON.parse(pe.data)}catch{return}Se.current(Me)},Re.onclose=()=>{V.current=null,(be.current||ue.current)&&(de.current=setTimeout(()=>{Te.current=Math.min(Te.current*2,1e4),Ce()},Te.current))},Re.onerror=()=>{Re.close()}},[]),dt=xe.useCallback(async()=>{var le,Re;if(!n.trim()){m("Bitte gib einen Namen ein.");return}if(!l.trim()){m("Passwort ist Pflicht.");return}if(!((le=navigator.mediaDevices)!=null&&le.getDisplayMedia)){m("Dein Browser unterstützt keine Bildschirmfreigabe.");return}m(null),B(!0);try{const pe=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:60},width:{ideal:1920},height:{ideal:1080}},audio:!0});ee.current=pe,te.current&&(te.current.srcObject=pe),(Re=pe.getVideoTracks()[0])==null||Re.addEventListener("ended",()=>{At()}),Ce();const Me=()=>{var nt;((nt=V.current)==null?void 0:nt.readyState)===WebSocket.OPEN?we({type:"start_broadcast",name:n.trim(),title:s.trim()||"Screen Share",password:l.trim()}):setTimeout(Me,100)};Me()}catch(pe){B(!1),pe.name==="NotAllowedError"?m("Bildschirmfreigabe wurde abgelehnt."):m(`Fehler: ${pe.message}`)}},[n,s,l,Ce,we]),At=xe.useCallback(()=>{var le;we({type:"stop_broadcast"}),(le=ee.current)==null||le.getTracks().forEach(Re=>Re.stop()),ee.current=null,te.current&&(te.current.srcObject=null);for(const Re of ne.current.values())Re.close();ne.current.clear(),C(!1),be.current=!1,w(null),u("")},[we]),wt=xe.useCallback(le=>{x({streamId:le.id,streamTitle:le.title,broadcasterName:le.broadcasterName,password:"",error:null})},[]),Ft=xe.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(Me=>Me&&{...Me,error:"Passwort eingeben."});return}const{streamId:le,password:Re}=v;x(null),m(null),O({streamId:le,phase:"connecting"}),Ce();const pe=()=>{var Me;((Me=V.current)==null?void 0:Me.readyState)===WebSocket.OPEN?we({type:"join_viewer",name:n.trim()||"Viewer",streamId:le,password:Re.trim()}):setTimeout(pe,100)};pe()},[v,n,Ce,we]),$e=xe.useCallback(()=>{we({type:"leave_viewer"}),ze(),O(null)},[ze,we]);xe.useEffect(()=>{const le=pe=>{(be.current||ue.current)&&pe.preventDefault()},Re=()=>{Y.current&&navigator.sendBeacon("/api/streaming/disconnect",JSON.stringify({clientId:Y.current}))};return window.addEventListener("beforeunload",le),window.addEventListener("pagehide",Re),()=>{window.removeEventListener("beforeunload",le),window.removeEventListener("pagehide",Re)}},[]);const rt=xe.useRef(null),[ce,Gt]=xe.useState(!1),ht=xe.useCallback(()=>{const le=rt.current;le&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):le.requestFullscreen().catch(()=>{}))},[]);xe.useEffect(()=>{const le=()=>Gt(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",le),()=>document.removeEventListener("fullscreenchange",le)},[]),xe.useEffect(()=>()=>{var le;(le=ee.current)==null||le.getTracks().forEach(Re=>Re.stop());for(const Re of ne.current.values())Re.close();Q.current&&Q.current.close(),V.current&&V.current.close(),de.current&&clearTimeout(de.current)},[]);const Pt=xe.useRef(null);xe.useEffect(()=>{const Re=new URLSearchParams(location.search).get("viewStream");if(Re){Pt.current=Re;const pe=new URL(location.href);pe.searchParams.delete("viewStream"),window.history.replaceState({},"",pe.toString())}},[]),xe.useEffect(()=>{const le=Pt.current;if(!le||e.length===0)return;const Re=e.find(pe=>pe.id===le);Re&&(Pt.current=null,wt(Re))},[e,wt]);const yt=xe.useCallback(le=>{const Re=new URL(location.href);return Re.searchParams.set("viewStream",le),Re.hash="",Re.toString()},[]),en=xe.useCallback(le=>{navigator.clipboard.writeText(yt(le)).then(()=>{F(le),setTimeout(()=>F(null),2e3)}).catch(()=>{})},[yt]),xt=xe.useCallback(le=>{window.open(yt(le),"_blank","noopener"),z(null)},[yt]);if(L){const le=e.find(Re=>Re.id===L.streamId);return k.jsxs("div",{className:"stream-viewer-overlay",ref:rt,children:[k.jsxs("div",{className:"stream-viewer-header",children:[k.jsxs("div",{className:"stream-viewer-header-left",children:[k.jsxs("span",{className:"stream-live-badge",children:[k.jsx("span",{className:"stream-live-dot"})," LIVE"]}),k.jsxs("div",{children:[k.jsx("div",{className:"stream-viewer-title",children:(le==null?void 0:le.title)||"Stream"}),k.jsxs("div",{className:"stream-viewer-subtitle",children:[(le==null?void 0:le.broadcasterName)||"..."," ",le?` · ${le.viewerCount} Zuschauer`:""]})]})]}),k.jsxs("div",{className:"stream-viewer-header-right",children:[k.jsx("button",{className:"stream-viewer-fullscreen",onClick:ht,title:ce?"Vollbild verlassen":"Vollbild",children:ce?"✖":"⛶"}),k.jsx("button",{className:"stream-viewer-close",onClick:$e,children:"Verlassen"})]})]}),k.jsxs("div",{className:"stream-viewer-video",children:[L.phase==="connecting"?k.jsxs("div",{className:"stream-viewer-connecting",children:[k.jsx("div",{className:"stream-viewer-spinner"}),"Verbindung wird hergestellt..."]}):L.phase==="error"?k.jsxs("div",{className:"stream-viewer-connecting",children:[L.error||"Verbindungsfehler",k.jsx("button",{className:"stream-btn",onClick:$e,children:"Zurück"})]}):null,k.jsx("video",{ref:re,autoPlay:!0,playsInline:!0,style:L.phase==="connected"?{}:{display:"none"}})]})]})}return k.jsxs("div",{className:"stream-container",children:[h&&k.jsxs("div",{className:"stream-error",children:[h,k.jsx("button",{className:"stream-error-dismiss",onClick:()=>m(null),children:"×"})]}),k.jsxs("div",{className:"stream-topbar",children:[k.jsx("input",{className:"stream-input stream-input-name",placeholder:"Dein Name",value:n,onChange:le=>r(le.target.value),disabled:R}),k.jsx("input",{className:"stream-input stream-input-title",placeholder:"Stream-Titel",value:s,onChange:le=>a(le.target.value),disabled:R}),k.jsx("input",{className:"stream-input stream-input-password",type:"password",placeholder:"Passwort",value:l,onChange:le=>u(le.target.value),disabled:R}),R?k.jsxs("button",{className:"stream-btn stream-btn-stop",onClick:At,children:["⏹"," Stream beenden"]}):k.jsx("button",{className:"stream-btn",onClick:dt,disabled:E,children:E?"Starte...":"🖥️ Stream starten"})]}),e.length===0&&!R?k.jsxs("div",{className:"stream-empty",children:[k.jsx("div",{className:"stream-empty-icon",children:"📺"}),k.jsx("h3",{children:"Keine aktiven Streams"}),k.jsx("p",{children:"Starte einen Stream, um deinen Bildschirm zu teilen."})]}):k.jsxs("div",{className:"stream-grid",children:[R&&k.jsxs("div",{className:"stream-tile own broadcasting",children:[k.jsxs("div",{className:"stream-tile-preview",children:[k.jsx("video",{ref:te,autoPlay:!0,playsInline:!0,muted:!0}),k.jsxs("span",{className:"stream-live-badge",children:[k.jsx("span",{className:"stream-live-dot"})," LIVE"]}),k.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",((fe=e.find(le=>le.id===S))==null?void 0:fe.viewerCount)??0]})]}),k.jsxs("div",{className:"stream-tile-info",children:[k.jsxs("div",{className:"stream-tile-meta",children:[k.jsxs("div",{className:"stream-tile-name",children:[n," (Du)"]}),k.jsx("div",{className:"stream-tile-title",children:s})]}),k.jsx("span",{className:"stream-tile-time",children:S&&((X=e.find(le=>le.id===S))!=null&&X.startedAt)?qS(e.find(le=>le.id===S).startedAt):"0:00"})]})]}),e.filter(le=>le.id!==S).map(le=>k.jsxs("div",{className:"stream-tile",onClick:()=>xt(le.id),children:[k.jsxs("div",{className:"stream-tile-preview",children:[k.jsx("span",{className:"stream-tile-icon",children:"🖥️"}),k.jsxs("span",{className:"stream-live-badge",children:[k.jsx("span",{className:"stream-live-dot"})," LIVE"]}),k.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",le.viewerCount]}),le.hasPassword&&k.jsx("span",{className:"stream-tile-lock",children:"🔒"})]}),k.jsxs("div",{className:"stream-tile-info",children:[k.jsxs("div",{className:"stream-tile-meta",children:[k.jsx("div",{className:"stream-tile-name",children:le.broadcasterName}),k.jsx("div",{className:"stream-tile-title",children:le.title})]}),k.jsx("span",{className:"stream-tile-time",children:qS(le.startedAt)}),k.jsxs("div",{className:"stream-tile-menu-wrap",children:[k.jsx("button",{className:"stream-tile-menu",onClick:Re=>{Re.stopPropagation(),z(q===le.id?null:le.id)},children:"⋮"}),q===le.id&&k.jsxs("div",{className:"stream-tile-dropdown",onClick:Re=>Re.stopPropagation(),children:[k.jsxs("div",{className:"stream-tile-dropdown-header",children:[k.jsx("div",{className:"stream-tile-dropdown-name",children:le.broadcasterName}),k.jsx("div",{className:"stream-tile-dropdown-title",children:le.title}),k.jsxs("div",{className:"stream-tile-dropdown-detail",children:["👥"," ",le.viewerCount," Zuschauer · ",qS(le.startedAt)]})]}),k.jsx("div",{className:"stream-tile-dropdown-divider"}),k.jsxs("button",{className:"stream-tile-dropdown-item",onClick:()=>xt(le.id),children:["🗗"," In neuem Fenster öffnen"]}),k.jsx("button",{className:"stream-tile-dropdown-item",onClick:()=>{en(le.id),z(null)},children:j===le.id?"✅ Kopiert!":"🔗 Link teilen"})]})]})]})]},le.id))]}),v&&k.jsx("div",{className:"stream-pw-overlay",onClick:()=>x(null),children:k.jsxs("div",{className:"stream-pw-modal",onClick:le=>le.stopPropagation(),children:[k.jsx("h3",{children:v.broadcasterName}),k.jsx("p",{children:v.streamTitle}),v.error&&k.jsx("div",{className:"stream-pw-modal-error",children:v.error}),k.jsx("input",{className:"stream-input",type:"password",placeholder:"Stream-Passwort",value:v.password,onChange:le=>x(Re=>Re&&{...Re,password:le.target.value,error:null}),onKeyDown:le=>{le.key==="Enter"&&Ft()},autoFocus:!0}),k.jsxs("div",{className:"stream-pw-actions",children:[k.jsx("button",{className:"stream-pw-cancel",onClick:()=>x(null),children:"Abbrechen"}),k.jsx("button",{className:"stream-btn",onClick:Ft,children:"Beitreten"})]})]})})]})}function b7(i){const e=Math.floor(i),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function Qde(i){const e=i.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);return e?{type:"youtube",videoId:e[1]}:/\.(mp4|webm|ogg)(\?|$)/i.test(i)||i.startsWith("http")?{type:"direct",url:i}:null}function Kde({data:i}){var Re;const[e,t]=xe.useState([]),[n,r]=xe.useState(()=>localStorage.getItem("wt_name")||""),[s,a]=xe.useState(""),[l,u]=xe.useState(""),[h,m]=xe.useState(null),[v,x]=xe.useState(null),[S,w]=xe.useState(null),[R,C]=xe.useState(""),[E,B]=xe.useState(()=>{const pe=localStorage.getItem("wt_volume");return pe?parseFloat(pe):1}),[L,O]=xe.useState(!1),[G,q]=xe.useState(0),[z,j]=xe.useState(0),[F,V]=xe.useState(null),[Y,ee]=xe.useState(!1),te=xe.useRef(null),re=xe.useRef(""),ne=xe.useRef(null),Q=xe.useRef(1e3),ae=xe.useRef(null),de=xe.useRef(null),Te=xe.useRef(null),be=xe.useRef(null),ue=xe.useRef(null),we=xe.useRef(null),We=xe.useRef(!1),Ne=xe.useRef(!1),ze=xe.useRef(null);xe.useEffect(()=>{ae.current=h},[h]);const Se=h!=null&&re.current===h.hostId;xe.useEffect(()=>{i!=null&&i.rooms&&t(i.rooms)},[i]),xe.useEffect(()=>{n&&localStorage.setItem("wt_name",n)},[n]),xe.useEffect(()=>{localStorage.setItem("wt_volume",String(E)),Te.current&&typeof Te.current.setVolume=="function"&&Te.current.setVolume(E*100),be.current&&(be.current.volume=E)},[E]),xe.useEffect(()=>{if(window.YT){We.current=!0;return}const pe=document.createElement("script");pe.src="https://www.youtube.com/iframe_api",document.head.appendChild(pe);const Me=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{We.current=!0,Me&&Me()}},[]);const Ce=xe.useCallback(pe=>{var Me;((Me=te.current)==null?void 0:Me.readyState)===WebSocket.OPEN&&te.current.send(JSON.stringify(pe))},[]),dt=xe.useCallback(()=>we.current==="youtube"&&Te.current&&typeof Te.current.getCurrentTime=="function"?Te.current.getCurrentTime():we.current==="direct"&&be.current?be.current.currentTime:null,[]);xe.useCallback(()=>we.current==="youtube"&&Te.current&&typeof Te.current.getDuration=="function"?Te.current.getDuration()||0:we.current==="direct"&&be.current&&be.current.duration||0,[]);const At=xe.useCallback(()=>{if(Te.current){try{Te.current.destroy()}catch{}Te.current=null}be.current&&(be.current.pause(),be.current.removeAttribute("src"),be.current.load()),we.current=null,ze.current&&(clearInterval(ze.current),ze.current=null)},[]),wt=xe.useCallback(pe=>{At(),V(null);const Me=Qde(pe);if(Me)if(Me.type==="youtube"){if(we.current="youtube",!We.current||!ue.current)return;const nt=ue.current,lt=document.createElement("div");lt.id="wt-yt-player-"+Date.now(),nt.innerHTML="",nt.appendChild(lt),Te.current=new window.YT.Player(lt.id,{videoId:Me.videoId,playerVars:{autoplay:1,controls:0,modestbranding:1,rel:0},events:{onReady:Ot=>{Ot.target.setVolume(E*100),q(Ot.target.getDuration()||0),ze.current=setInterval(()=>{Te.current&&typeof Te.current.getCurrentTime=="function"&&(j(Te.current.getCurrentTime()),q(Te.current.getDuration()||0))},500)},onStateChange:Ot=>{if(Ot.data===window.YT.PlayerState.ENDED){const jt=ae.current;jt&&re.current===jt.hostId&&Ce({type:"skip"})}},onError:Ot=>{const jt=Ot.data;V(jt===101||jt===150?"Embedding deaktiviert — Video kann nur auf YouTube angesehen werden.":jt===100?"Video nicht gefunden oder entfernt.":"Wiedergabefehler — Video wird übersprungen."),setTimeout(()=>{const pt=ae.current;pt&&re.current===pt.hostId&&Ce({type:"skip"})},3e3)}}})}else we.current="direct",be.current&&(be.current.src=Me.url,be.current.volume=E,be.current.play().catch(()=>{}))},[At,E,Ce]);xe.useEffect(()=>{const pe=be.current;if(!pe)return;const Me=()=>{const lt=ae.current;lt&&re.current===lt.hostId&&Ce({type:"skip"})},nt=()=>{j(pe.currentTime),q(pe.duration||0)};return pe.addEventListener("ended",Me),pe.addEventListener("timeupdate",nt),()=>{pe.removeEventListener("ended",Me),pe.removeEventListener("timeupdate",nt)}},[Ce]);const Ft=xe.useRef(()=>{});Ft.current=pe=>{var Me,nt,lt,Ot,jt,pt,Yt,rn,$t,kt,Vt,Nn,_i,me;switch(pe.type){case"welcome":re.current=pe.clientId,pe.rooms&&t(pe.rooms);break;case"room_created":{const bt=pe.room;m({id:bt.id,name:bt.name,hostId:bt.hostId,members:bt.members||[],currentVideo:bt.currentVideo||null,playing:bt.playing||!1,currentTime:bt.currentTime||0,queue:bt.queue||[]});break}case"room_joined":{const bt=pe.room;m({id:bt.id,name:bt.name,hostId:bt.hostId,members:bt.members||[],currentVideo:bt.currentVideo||null,playing:bt.playing||!1,currentTime:bt.currentTime||0,queue:bt.queue||[]}),(Me=bt.currentVideo)!=null&&Me.url&&setTimeout(()=>wt(bt.currentVideo.url),100);break}case"playback_state":{const bt=ae.current;if(!bt)break;const tt=pe.currentVideo,St=(nt=bt.currentVideo)==null?void 0:nt.url;if(tt!=null&&tt.url&&tt.url!==St?wt(tt.url):!tt&&St&&At(),we.current==="youtube"&&Te.current){const qt=(Ot=(lt=Te.current).getPlayerState)==null?void 0:Ot.call(lt);pe.playing&&qt!==((pt=(jt=window.YT)==null?void 0:jt.PlayerState)==null?void 0:pt.PLAYING)?(rn=(Yt=Te.current).playVideo)==null||rn.call(Yt):!pe.playing&&qt===((kt=($t=window.YT)==null?void 0:$t.PlayerState)==null?void 0:kt.PLAYING)&&((Nn=(Vt=Te.current).pauseVideo)==null||Nn.call(Vt))}else we.current==="direct"&&be.current&&(pe.playing&&be.current.paused?be.current.play().catch(()=>{}):!pe.playing&&!be.current.paused&&be.current.pause());if(pe.currentTime!==void 0&&!Ne.current){const qt=dt();qt!==null&&Math.abs(qt-pe.currentTime)>2&&(we.current==="youtube"&&Te.current?(me=(_i=Te.current).seekTo)==null||me.call(_i,pe.currentTime,!0):we.current==="direct"&&be.current&&(be.current.currentTime=pe.currentTime))}m(qt=>qt&&{...qt,currentVideo:tt||null,playing:pe.playing,currentTime:pe.currentTime??qt.currentTime});break}case"queue_updated":m(bt=>bt&&{...bt,queue:pe.queue});break;case"members_updated":m(bt=>bt&&{...bt,members:pe.members,hostId:pe.hostId});break;case"error":pe.code==="WRONG_PASSWORD"?x(bt=>bt&&{...bt,error:pe.message}):w(pe.message);break}};const $e=xe.useCallback(()=>{if(te.current&&(te.current.readyState===WebSocket.OPEN||te.current.readyState===WebSocket.CONNECTING))return;const pe=location.protocol==="https:"?"wss":"ws",Me=new WebSocket(`${pe}://${location.host}/ws/watch-together`);te.current=Me,Me.onopen=()=>{Q.current=1e3},Me.onmessage=nt=>{let lt;try{lt=JSON.parse(nt.data)}catch{return}Ft.current(lt)},Me.onclose=()=>{te.current===Me&&(te.current=null),ae.current&&(ne.current=setTimeout(()=>{Q.current=Math.min(Q.current*2,1e4),$e()},Q.current))},Me.onerror=()=>{Me.close()}},[]),rt=xe.useCallback(()=>{if(!n.trim()){w("Bitte gib einen Namen ein.");return}if(!s.trim()){w("Bitte gib einen Raumnamen ein.");return}w(null),$e();const pe=Date.now(),Me=()=>{var nt;((nt=te.current)==null?void 0:nt.readyState)===WebSocket.OPEN?Ce({type:"create_room",name:s.trim(),userName:n.trim(),password:l.trim()||void 0}):Date.now()-pe>1e4?w("Verbindung zum Server fehlgeschlagen."):setTimeout(Me,100)};Me()},[n,s,l,$e,Ce]),ce=xe.useCallback((pe,Me)=>{if(!n.trim()){w("Bitte gib einen Namen ein.");return}w(null),$e();const nt=Date.now(),lt=()=>{var Ot;((Ot=te.current)==null?void 0:Ot.readyState)===WebSocket.OPEN?Ce({type:"join_room",userName:n.trim(),roomId:pe,password:(Me==null?void 0:Me.trim())||void 0}):Date.now()-nt>1e4?w("Verbindung zum Server fehlgeschlagen."):setTimeout(lt,100)};lt()},[n,$e,Ce]),Gt=xe.useCallback(()=>{Ce({type:"leave_room"}),At(),m(null),C(""),q(0),j(0)},[Ce,At]),ht=xe.useCallback(async()=>{const pe=R.trim();if(!pe)return;C(""),ee(!0);let Me="";try{const nt=await fetch(`/api/watch-together/video-info?url=${encodeURIComponent(pe)}`);nt.ok&&(Me=(await nt.json()).title||"")}catch{}Ce({type:"add_to_queue",url:pe,title:Me||void 0}),ee(!1)},[R,Ce]),Pt=xe.useCallback(pe=>{Ce({type:"remove_from_queue",index:pe})},[Ce]),yt=xe.useCallback(()=>{const pe=ae.current;pe&&Ce({type:pe.playing?"pause":"resume"})},[Ce]),en=xe.useCallback(()=>{Ce({type:"skip"})},[Ce]),xt=xe.useCallback(pe=>{var Me,nt;Ne.current=!0,Ce({type:"seek",time:pe}),we.current==="youtube"&&Te.current?(nt=(Me=Te.current).seekTo)==null||nt.call(Me,pe,!0):we.current==="direct"&&be.current&&(be.current.currentTime=pe),j(pe),setTimeout(()=>{Ne.current=!1},1e3)},[Ce]);xe.useEffect(()=>{if(!Se||!(h!=null&&h.playing))return;const pe=setInterval(()=>{const Me=dt();Me!==null&&Ce({type:"report_time",time:Me})},2e3);return()=>clearInterval(pe)},[Se,h==null?void 0:h.playing,Ce,dt]);const fe=xe.useCallback(()=>{const pe=de.current;pe&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):pe.requestFullscreen().catch(()=>{}))},[]);xe.useEffect(()=>{const pe=()=>O(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",pe),()=>document.removeEventListener("fullscreenchange",pe)},[]),xe.useEffect(()=>{const pe=nt=>{ae.current&&nt.preventDefault()},Me=()=>{re.current&&navigator.sendBeacon("/api/watch-together/disconnect",JSON.stringify({clientId:re.current}))};return window.addEventListener("beforeunload",pe),window.addEventListener("pagehide",Me),()=>{window.removeEventListener("beforeunload",pe),window.removeEventListener("pagehide",Me)}},[]),xe.useEffect(()=>()=>{At(),te.current&&te.current.close(),ne.current&&clearTimeout(ne.current)},[At]);const X=xe.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(nt=>nt&&{...nt,error:"Passwort eingeben."});return}const{roomId:pe,password:Me}=v;x(null),ce(pe,Me)},[v,ce]),le=xe.useCallback(pe=>{pe.hasPassword?x({roomId:pe.id,roomName:pe.name,password:"",error:null}):ce(pe.id)},[ce]);if(h){const pe=h.members.find(Me=>Me.id===h.hostId);return k.jsxs("div",{className:"wt-room-overlay",ref:de,children:[k.jsxs("div",{className:"wt-room-header",children:[k.jsxs("div",{className:"wt-room-header-left",children:[k.jsx("span",{className:"wt-room-name",children:h.name}),k.jsxs("span",{className:"wt-room-members",children:[h.members.length," Mitglieder"]}),pe&&k.jsxs("span",{className:"wt-host-badge",children:["Host: ",pe.name]})]}),k.jsxs("div",{className:"wt-room-header-right",children:[k.jsx("button",{className:"wt-fullscreen-btn",onClick:fe,title:L?"Vollbild verlassen":"Vollbild",children:L?"✖":"⛶"}),k.jsx("button",{className:"wt-leave-btn",onClick:Gt,children:"Verlassen"})]})]}),k.jsxs("div",{className:"wt-room-body",children:[k.jsxs("div",{className:"wt-player-section",children:[k.jsxs("div",{className:"wt-player-wrap",children:[k.jsx("div",{ref:ue,className:"wt-yt-container",style:we.current==="youtube"?{}:{display:"none"}}),k.jsx("video",{ref:be,className:"wt-video-element",style:we.current==="direct"?{}:{display:"none"},playsInline:!0}),F&&k.jsxs("div",{className:"wt-player-error",children:[k.jsx("div",{className:"wt-error-icon",children:"⚠️"}),k.jsx("p",{children:F}),((Re=h.currentVideo)==null?void 0:Re.url)&&k.jsx("a",{className:"wt-yt-link",href:h.currentVideo.url,target:"_blank",rel:"noopener noreferrer",children:"Auf YouTube öffnen ↗"}),k.jsx("p",{className:"wt-skip-info",children:"Wird in 3 Sekunden übersprungen..."})]}),!h.currentVideo&&k.jsxs("div",{className:"wt-player-placeholder",children:[k.jsx("div",{className:"wt-placeholder-icon",children:"🎬"}),k.jsx("p",{children:"Fuege ein Video zur Warteschlange hinzu"})]})]}),k.jsxs("div",{className:"wt-controls",children:[Se?k.jsxs(k.Fragment,{children:[k.jsx("button",{className:"wt-ctrl-btn",onClick:yt,disabled:!h.currentVideo,title:h.playing?"Pause":"Abspielen",children:h.playing?"⏸":"▶"}),k.jsx("button",{className:"wt-ctrl-btn",onClick:en,disabled:!h.currentVideo,title:"Weiter",children:"⏭"}),k.jsx("input",{className:"wt-seek",type:"range",min:0,max:G||0,step:.5,value:z,onChange:Me=>xt(parseFloat(Me.target.value)),disabled:!h.currentVideo})]}):k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"wt-ctrl-status",children:h.playing?"▶":"⏸"}),k.jsx("div",{className:"wt-seek-readonly",children:k.jsx("div",{className:"wt-seek-progress",style:{width:G>0?`${z/G*100}%`:"0%"}})})]}),k.jsxs("span",{className:"wt-time",children:[b7(z)," / ",b7(G)]}),k.jsxs("div",{className:"wt-volume",children:[k.jsx("span",{className:"wt-volume-icon",children:E===0?"🔇":E<.5?"🔉":"🔊"}),k.jsx("input",{className:"wt-volume-slider",type:"range",min:0,max:1,step:.01,value:E,onChange:Me=>B(parseFloat(Me.target.value))})]})]})]}),k.jsxs("div",{className:"wt-queue-panel",children:[k.jsxs("div",{className:"wt-queue-header",children:["Warteschlange (",h.queue.length,")"]}),k.jsx("div",{className:"wt-queue-list",children:h.queue.length===0?k.jsx("div",{className:"wt-queue-empty",children:"Keine Videos in der Warteschlange"}):h.queue.map((Me,nt)=>{var lt;return k.jsxs("div",{className:`wt-queue-item${((lt=h.currentVideo)==null?void 0:lt.url)===Me.url?" playing":""}${Se?" clickable":""}`,onClick:()=>Se&&Ce({type:"play_video",index:nt}),title:Se?"Klicken zum Abspielen":void 0,children:[k.jsxs("div",{className:"wt-queue-item-info",children:[k.jsx("div",{className:"wt-queue-item-title",children:Me.title||Me.url}),k.jsx("div",{className:"wt-queue-item-by",children:Me.addedBy})]}),Se&&k.jsx("button",{className:"wt-queue-item-remove",onClick:()=>Pt(nt),title:"Entfernen",children:"×"})]},nt)})}),k.jsxs("div",{className:"wt-queue-add",children:[k.jsx("input",{className:"wt-input wt-queue-input",placeholder:"Video-URL eingeben",value:R,onChange:Me=>C(Me.target.value),onKeyDown:Me=>{Me.key==="Enter"&&ht()}}),k.jsx("button",{className:"wt-btn wt-queue-add-btn",onClick:ht,disabled:Y,children:Y?"Laden...":"Hinzufuegen"})]})]})]})]})}return k.jsxs("div",{className:"wt-container",children:[S&&k.jsxs("div",{className:"wt-error",children:[S,k.jsx("button",{className:"wt-error-dismiss",onClick:()=>w(null),children:"×"})]}),k.jsxs("div",{className:"wt-topbar",children:[k.jsx("input",{className:"wt-input wt-input-name",placeholder:"Dein Name",value:n,onChange:pe=>r(pe.target.value)}),k.jsx("input",{className:"wt-input wt-input-room",placeholder:"Raumname",value:s,onChange:pe=>a(pe.target.value)}),k.jsx("input",{className:"wt-input wt-input-password",type:"password",placeholder:"Passwort (optional)",value:l,onChange:pe=>u(pe.target.value)}),k.jsx("button",{className:"wt-btn",onClick:rt,children:"Raum erstellen"})]}),e.length===0?k.jsxs("div",{className:"wt-empty",children:[k.jsx("div",{className:"wt-empty-icon",children:"🎬"}),k.jsx("h3",{children:"Keine aktiven Raeume"}),k.jsx("p",{children:"Erstelle einen Raum, um gemeinsam Videos zu schauen."})]}):k.jsx("div",{className:"wt-grid",children:e.map(pe=>k.jsxs("div",{className:"wt-tile",onClick:()=>le(pe),children:[k.jsxs("div",{className:"wt-tile-preview",children:[k.jsx("span",{className:"wt-tile-icon",children:"🎬"}),k.jsxs("span",{className:"wt-tile-members",children:["👥"," ",pe.memberCount]}),pe.hasPassword&&k.jsx("span",{className:"wt-tile-lock",children:"🔒"}),pe.playing&&k.jsx("span",{className:"wt-tile-playing",children:"▶"})]}),k.jsx("div",{className:"wt-tile-info",children:k.jsxs("div",{className:"wt-tile-meta",children:[k.jsx("div",{className:"wt-tile-name",children:pe.name}),k.jsx("div",{className:"wt-tile-host",children:pe.hostName})]})})]},pe.id))}),v&&k.jsx("div",{className:"wt-modal-overlay",onClick:()=>x(null),children:k.jsxs("div",{className:"wt-modal",onClick:pe=>pe.stopPropagation(),children:[k.jsx("h3",{children:v.roomName}),k.jsx("p",{children:"Raum-Passwort"}),v.error&&k.jsx("div",{className:"wt-modal-error",children:v.error}),k.jsx("input",{className:"wt-input",type:"password",placeholder:"Passwort",value:v.password,onChange:pe=>x(Me=>Me&&{...Me,password:pe.target.value,error:null}),onKeyDown:pe=>{pe.key==="Enter"&&X()},autoFocus:!0}),k.jsxs("div",{className:"wt-modal-actions",children:[k.jsx("button",{className:"wt-modal-cancel",onClick:()=>x(null),children:"Abbrechen"}),k.jsx("button",{className:"wt-btn",onClick:X,children:"Beitreten"})]})]})})]})}const Zde={radio:bde,soundboard:Vde,lolstats:Xde,streaming:Yde,"watch-together":Kde};function Jde(){const[i,e]=xe.useState(!1),[t,n]=xe.useState([]),[r,s]=xe.useState(()=>localStorage.getItem("hub_activeTab")??""),a=x=>{s(x),localStorage.setItem("hub_activeTab",x)},[l,u]=xe.useState({}),h=xe.useRef(null);xe.useEffect(()=>{fetch("/api/plugins").then(x=>x.json()).then(x=>{if(n(x),new URLSearchParams(location.search).has("viewStream")&&x.some(C=>C.name==="streaming")){a("streaming");return}const w=localStorage.getItem("hub_activeTab"),R=x.some(C=>C.name===w);x.length>0&&!R&&a(x[0].name)}).catch(()=>{})},[]),xe.useEffect(()=>{let x=null,S;function w(){x=new EventSource("/api/events"),h.current=x,x.onopen=()=>e(!0),x.onmessage=R=>{try{const C=JSON.parse(R.data);C.type==="snapshot"?u(E=>({...E,...C})):C.plugin&&u(E=>({...E,[C.plugin]:{...E[C.plugin]||{},...C}}))}catch{}},x.onerror=()=>{e(!1),x==null||x.close(),S=setTimeout(w,3e3)}}return w(),()=>{x==null||x.close(),clearTimeout(S)}},[]);const m="1.0.0-dev",v={radio:"🌍",soundboard:"🎵",lolstats:"⚔️",stats:"📊",events:"📅",games:"🎲",gamevote:"🎮",streaming:"📺","watch-together":"🎬"};return k.jsxs("div",{className:"hub-app",children:[k.jsxs("header",{className:"hub-header",children:[k.jsxs("div",{className:"hub-header-left",children:[k.jsx("span",{className:"hub-logo",children:"🎮"}),k.jsx("span",{className:"hub-title",children:"Gaming Hub"}),k.jsx("span",{className:`hub-conn-dot ${i?"online":""}`})]}),k.jsx("nav",{className:"hub-tabs",children:t.map(x=>k.jsxs("button",{className:`hub-tab ${r===x.name?"active":""}`,onClick:()=>a(x.name),title:x.description,children:[k.jsx("span",{className:"hub-tab-icon",children:v[x.name]??"📦"}),k.jsx("span",{className:"hub-tab-label",children:x.name})]},x.name))}),k.jsxs("div",{className:"hub-header-right",children:[!window.electronAPI&&k.jsx("a",{className:"hub-download-btn",href:"/downloads/GamingHub-Setup.exe",download:!0,title:"Desktop App herunterladen",children:"⬇️"}),k.jsxs("span",{className:"hub-version",children:["v",m]})]})]}),k.jsx("main",{className:"hub-content",children:t.length===0?k.jsxs("div",{className:"hub-empty",children:[k.jsx("span",{className:"hub-empty-icon",children:"📦"}),k.jsx("h2",{children:"Keine Plugins geladen"}),k.jsx("p",{children:"Plugins werden im Server konfiguriert."})]}):t.map(x=>{const S=Zde[x.name];if(!S)return null;const w=r===x.name;return k.jsx("div",{className:`hub-tab-panel ${w?"active":""}`,style:w?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{display:"none"},children:k.jsx(S,{data:l[x.name]||{}})},x.name)})})]})}LF.createRoot(document.getElementById("root")).render(k.jsx(Jde,{})); diff --git a/web/dist/assets/index-DEfJ3Ric.css b/web/dist/assets/index-DEfJ3Ric.css deleted file mode 100644 index 179a557..0000000 --- a/web/dist/assets/index-DEfJ3Ric.css +++ /dev/null @@ -1 +0,0 @@ -@import"https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap";@import"https://fonts.googleapis.com/icon?family=Material+Icons";.sb-app{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--bg-modifier-hover: rgba(79, 84, 92, .16);--bg-modifier-active: rgba(79, 84, 92, .24);--bg-modifier-selected: rgba(79, 84, 92, .32);--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #5865f2;--accent-rgb: 88, 101, 242;--accent-hover: #4752c4;--accent-glow: rgba(88, 101, 242, .45);--green: #23a55a;--red: #f23f42;--yellow: #f0b232;--white: #ffffff;--font: "DM Sans", "Outfit", "gg sans", "Noto Sans", Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;--radius: 8px;--radius-lg: 12px;--shadow-low: 0 1px 3px rgba(0, 0, 0, .24);--shadow-med: 0 4px 12px rgba(0, 0, 0, .32);--shadow-high: 0 8px 24px rgba(0, 0, 0, .4);--transition: .15s cubic-bezier(.4, 0, .2, 1);--card-size: 110px;--card-emoji: 28px;--card-font: 11px;color-scheme:dark}.sb-app[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad;--accent-glow: rgba(155, 89, 182, .45)}.sb-app[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60;--accent-glow: rgba(46, 204, 113, .4)}.sb-app[data-theme=sunset]{--bg-deep: #1a1210;--bg-primary: #231815;--bg-secondary: #2f201c;--bg-tertiary: #3d2a24;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--accent-glow: rgba(230, 126, 34, .4)}.sb-app[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9;--accent-glow: rgba(52, 152, 219, .4)}.sb-app{display:flex;flex-direction:column;height:100%;position:relative}.topbar{display:flex;align-items:center;padding:0 20px;height:52px;background:var(--bg-secondary);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px;transition:background .4s ease}.topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.sb-app-logo{width:28px;height:28px;background:var(--accent);border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .4s ease}.sb-app-title{font-size:16px;font-weight:700;color:var(--white);letter-spacing:-.02em}.clock-wrap{flex:1;display:flex;justify-content:center}.clock{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:.02em;font-variant-numeric:tabular-nums;opacity:.9}.clock-seconds{font-size:14px;color:var(--text-faint);font-weight:500}.topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0}.channel-dropdown{position:relative;flex-shrink:0}.channel-btn{display:flex;align-items:center;gap:8px;padding:5px 12px 5px 10px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-normal);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.channel-btn:hover{background:var(--bg-modifier-selected);border-color:#ffffff1f}.channel-btn.open{border-color:var(--accent)}.channel-btn .cb-icon{font-size:16px;color:var(--text-muted)}.channel-btn .chevron{font-size:12px;color:var(--text-faint);transition:transform var(--transition);margin-left:2px}.channel-btn.open .chevron{transform:rotate(180deg)}.channel-status{width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0}.channel-menu{position:absolute;top:calc(100% + 6px);left:0;min-width:220px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:6px;z-index:100;animation:ctx-in .1s ease-out}.channel-menu-header{padding:6px 8px 4px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-faint)}.channel-option{display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:4px;font-size:13px;color:var(--text-muted);cursor:pointer;transition:all var(--transition)}.channel-option:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.channel-option.active{background:var(--accent);color:var(--white)}.channel-option .co-icon{font-size:16px;opacity:.7}.connection{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:#23a55a1f;font-size:12px;color:var(--green);font-weight:600}.conn-dot{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 6px #23a55a99;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 6px #23a55a80}50%{box-shadow:0 0 12px #23a55acc}}.conn-ping{font-size:10px;opacity:.7;margin-left:2px}.conn-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fadeIn .15s ease}.conn-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:slideUp .2s ease}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.conn-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.conn-modal-close{margin-left:auto;background:none;border:none;color:var(--muted);cursor:pointer;padding:4px;border-radius:6px;display:flex;transition:all .15s}.conn-modal-close:hover{background:#ffffff14;color:var(--fg)}.conn-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.conn-stat{display:flex;justify-content:space-between;align-items:center}.conn-stat-label{color:var(--muted);font-size:13px}.conn-stat-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.conn-ping-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.admin-btn-icon{width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition);font-size:18px}.admin-btn-icon:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.admin-btn-icon.active{color:var(--accent)}.toolbar{display:flex;align-items:center;gap:10px;padding:10px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0;flex-wrap:wrap;transition:background .4s ease}.cat-tabs{display:flex;gap:4px;flex-shrink:0}.cat-tab{display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.cat-tab:hover{background:var(--bg-modifier-selected);color:var(--text-normal)}.cat-tab.active{background:var(--accent);color:var(--white)}.tab-count{font-size:10px;font-weight:700;background:#ffffff26;padding:0 6px;border-radius:8px;line-height:1.6}.search-wrap{position:relative;flex:1;max-width:280px;min-width:140px}.search-wrap .search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);font-size:15px;color:var(--text-faint);pointer-events:none}.search-input{width:100%;height:32px;padding:0 28px 0 32px;border:1px solid rgba(255,255,255,.06);border-radius:20px;background:var(--bg-secondary);color:var(--text-normal);font-family:var(--font);font-size:13px;outline:none;transition:all var(--transition)}.search-input::placeholder{color:var(--text-faint)}.search-input:focus{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.search-clear{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:20px;height:20px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition)}.search-clear:hover{background:var(--bg-tertiary);color:var(--text-normal)}.toolbar-spacer{flex:1}.url-import-wrap{display:flex;align-items:center;gap:6px;min-width:240px;max-width:460px;flex:1;padding:4px 6px 4px 8px;border-radius:20px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.url-import-icon{font-size:15px;color:var(--text-faint);flex-shrink:0}.url-import-input{flex:1;min-width:0;height:26px;border:none;background:transparent;color:var(--text-normal);font-size:12px;font-family:var(--font);outline:none}.url-import-input::placeholder{color:var(--text-faint)}.url-import-btn{height:24px;padding:0 10px;border-radius:14px;border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.45);background:rgba(var(--accent-rgb, 88, 101, 242),.12);color:var(--accent);font-size:11px;font-weight:700;white-space:nowrap;transition:all var(--transition)}.url-import-btn:hover{background:var(--accent);border-color:var(--accent);color:var(--white)}.url-import-btn:disabled{opacity:.5;pointer-events:none}.url-import-tag{flex-shrink:0;padding:1px 6px;border-radius:8px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.url-import-tag.valid{background:#2ecc712e;color:#2ecc71}.url-import-tag.invalid{background:#e74c3c2e;color:#e74c3c}.tb-btn{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.tb-btn:hover{background:var(--bg-modifier-selected);color:var(--text-normal);border-color:#ffffff1f}.tb-btn .tb-icon{font-size:15px}.tb-btn.random{border-color:#5865f24d;color:var(--accent)}.tb-btn.random:hover{background:var(--accent);color:var(--white);border-color:var(--accent)}.tb-btn.party{border-color:#f0b2324d;color:var(--yellow)}.tb-btn.party:hover{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow)}.tb-btn.party.active{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow);animation:party-btn .6s ease-in-out infinite alternate}@keyframes party-btn{0%{box-shadow:0 0 8px #f0b23266}to{box-shadow:0 0 20px #f0b232b3}}.tb-btn.stop{border-color:#f23f424d;color:var(--red)}.tb-btn.stop:hover{background:var(--red);color:var(--white);border-color:var(--red)}.size-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.size-control .sc-icon{font-size:14px;color:var(--text-faint)}.size-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:70px;height:3px;border-radius:2px;background:var(--bg-modifier-selected);outline:none;cursor:pointer}.size-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.size-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.size-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.theme-selector{display:flex;align-items:center;gap:4px;padding:4px 8px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:all var(--transition);border:2px solid transparent}.theme-dot:hover{transform:scale(1.2)}.theme-dot.active{border-color:var(--white);box-shadow:0 0 6px #ffffff4d}.analytics-strip{display:flex;align-items:stretch;gap:8px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0}.analytics-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:12px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.analytics-card.analytics-wide{flex:1;min-width:0}.analytics-icon{font-size:18px;color:var(--accent);flex-shrink:0}.analytics-copy{display:flex;flex-direction:column;gap:4px;min-width:0}.analytics-label{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--text-faint)}.analytics-value{font-size:18px;line-height:1;font-weight:800;color:var(--text-normal)}.analytics-top-list{display:flex;align-items:center;gap:6px;overflow-x:auto;scrollbar-width:none}.analytics-top-list::-webkit-scrollbar{display:none}.analytics-chip{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:999px;background:rgba(var(--accent-rgb, 88, 101, 242),.15);color:var(--accent);font-size:11px;font-weight:600;white-space:nowrap}.analytics-muted{color:var(--text-muted);font-size:12px}.category-strip{display:flex;align-items:center;gap:6px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);overflow-x:auto;flex-shrink:0;scrollbar-width:none;transition:background .4s ease}.category-strip::-webkit-scrollbar{display:none}.cat-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;font-size:12px;font-weight:600;color:var(--text-muted);background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06);white-space:nowrap;cursor:pointer;transition:all var(--transition);flex-shrink:0}.cat-chip:hover{border-color:#ffffff1f;color:var(--text-normal);background:var(--bg-tertiary)}.cat-chip.active{background:#5865f21a}.cat-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.cat-count{font-size:10px;font-weight:700;opacity:.5}.main{flex:1;overflow-y:auto;padding:16px 20px;background:var(--bg-primary);transition:background .4s ease}.sound-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--card-size),1fr));gap:8px}.sound-card{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:12px 6px 8px;background:var(--bg-secondary);border-radius:var(--radius-lg);cursor:pointer;transition:all var(--transition);border:2px solid transparent;-webkit-user-select:none;user-select:none;overflow:hidden;aspect-ratio:1;opacity:0;animation:card-enter .35s ease-out forwards}.sound-card:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;opacity:0;transition:opacity var(--transition);background:radial-gradient(ellipse at center,var(--accent-glow) 0%,transparent 70%);pointer-events:none}.sound-card:hover{background:var(--bg-tertiary);transform:translateY(-3px);box-shadow:var(--shadow-med),0 0 20px var(--accent-glow);border-color:#5865f233}.sound-card:hover:before{opacity:1}.sound-card:active{transform:translateY(0);transition-duration:50ms}.sound-card.playing{border-color:var(--accent);animation:card-enter .35s ease-out forwards,playing-glow 1.2s ease-in-out infinite alternate}@keyframes playing-glow{0%{box-shadow:0 0 4px var(--accent-glow)}to{box-shadow:0 0 16px var(--accent-glow)}}@keyframes card-enter{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.ripple{position:absolute;border-radius:50%;background:#5865f24d;transform:scale(0);animation:ripple-expand .5s ease-out forwards;pointer-events:none}@keyframes ripple-expand{to{transform:scale(3);opacity:0}}.sound-emoji{font-size:var(--card-emoji);font-weight:800;line-height:1;z-index:1;transition:transform var(--transition);opacity:.7;font-family:Syne,DM Sans,sans-serif}.sound-card:hover .sound-emoji{transform:scale(1.15);opacity:1}.sound-card.playing .sound-emoji{animation:emoji-bounce .4s ease;opacity:1}@keyframes emoji-bounce{0%,to{transform:scale(1)}40%{transform:scale(1.3)}70%{transform:scale(.95)}}.sound-name{font-size:var(--card-font);font-weight:600;text-align:center;color:var(--text-normal);z-index:1;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 4px}.sound-duration{font-size:9px;color:var(--text-faint);z-index:1;font-weight:500}.fav-star{position:absolute;top:4px;right:4px;opacity:0;transition:all var(--transition);cursor:pointer;z-index:2;color:var(--text-faint);padding:2px;line-height:1}.fav-star .fav-icon{font-size:14px}.sound-card:hover .fav-star{opacity:.6}.fav-star:hover{opacity:1!important;color:var(--yellow);transform:scale(1.2)}.fav-star.active{opacity:1!important;color:var(--yellow)}.new-badge{position:absolute;top:4px;left:4px;font-size:8px;font-weight:700;background:var(--green);color:#fff;padding:1px 5px;border-radius:6px;text-transform:uppercase;letter-spacing:.03em;z-index:2}.playing-indicator{position:absolute;bottom:3px;left:50%;transform:translate(-50%);display:none;gap:2px;align-items:flex-end;height:10px}.sound-card.playing .playing-indicator{display:flex}.wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .6s ease-in-out infinite alternate}.wave-bar:nth-child(1){height:3px;animation-delay:0ms}.wave-bar:nth-child(2){height:7px;animation-delay:.15s}.wave-bar:nth-child(3){height:5px;animation-delay:.3s}.wave-bar:nth-child(4){height:9px;animation-delay:.1s}@keyframes wave{0%{height:2px}to{height:10px}}.empty-state{display:none;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:60px 20px;text-align:center}.empty-state.visible{display:flex}.empty-emoji{font-size:42px}.empty-title{font-size:15px;font-weight:700;color:var(--text-normal)}.empty-desc{font-size:13px;color:var(--text-muted);max-width:260px}.now-playing{display:flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;background:rgba(var(--accent-rgb, 88, 101, 242),.12);border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.2);font-size:12px;color:var(--text-muted);max-width:none;min-width:0;animation:np-fade-in .3s ease}@keyframes np-fade-in{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}.np-name{color:var(--accent);font-weight:600;white-space:nowrap}.np-waves{display:none;gap:1.5px;align-items:flex-end;height:12px;flex-shrink:0}.np-waves.active{display:flex}.np-wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .5s ease-in-out infinite alternate}.np-wave-bar:nth-child(1){height:3px;animation-delay:0ms}.np-wave-bar:nth-child(2){height:8px;animation-delay:.12s}.np-wave-bar:nth-child(3){height:5px;animation-delay:.24s}.np-wave-bar:nth-child(4){height:10px;animation-delay:80ms}.volume-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.vol-icon{font-size:16px;color:var(--text-faint);cursor:pointer;transition:color var(--transition);-webkit-user-select:none;user-select:none}.vol-icon:hover{color:var(--text-normal)}.vol-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:80px;height:3px;border-radius:2px;background:linear-gradient(to right,var(--accent) 0%,var(--accent) var(--vol, 80%),var(--bg-modifier-selected) var(--vol, 80%));outline:none;cursor:pointer}.vol-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.vol-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.vol-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.vol-pct{font-size:11px;color:var(--text-faint);min-width:28px;text-align:right;font-variant-numeric:tabular-nums}.party-overlay{position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;z-index:50;opacity:0;transition:opacity .3s ease}.party-overlay.active{opacity:1;animation:party-hue 2s linear infinite}.party-overlay:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(45deg,#ff00000a,#00ff000a,#0000ff0a,#ffff000a);background-size:400% 400%;animation:party-grad 3s ease infinite}@keyframes party-grad{0%{background-position:0% 50%}50%{background-position:100% 50%}to{background-position:0% 50%}}@keyframes party-hue{to{filter:hue-rotate(360deg)}}.ctx-menu{position:fixed;min-width:160px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.06);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:4px;z-index:1000;animation:ctx-in .1s ease-out}@keyframes ctx-in{0%{opacity:0;transform:scale(.96) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.ctx-item{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:4px;font-size:13px;color:var(--text-normal);cursor:pointer;transition:all var(--transition)}.ctx-item:hover{background:var(--accent);color:var(--white)}.ctx-item.danger{color:var(--red)}.ctx-item.danger:hover{background:var(--red);color:var(--white)}.ctx-item .ctx-icon{font-size:15px}.ctx-sep{height:1px;background:#ffffff0f;margin:3px 8px}.toast{position:fixed;bottom:64px;left:50%;transform:translate(-50%);padding:10px 20px;border-radius:20px;font-size:13px;font-weight:600;z-index:100;display:flex;align-items:center;gap:8px;box-shadow:var(--shadow-high);animation:toast-in .3s cubic-bezier(.175,.885,.32,1.275);pointer-events:none}.toast .toast-icon{font-size:16px}.toast.error{background:var(--red);color:#fff}.toast.info{background:var(--green);color:#fff}@keyframes toast-in{0%{transform:translate(-50%,16px);opacity:0}to{transform:translate(-50%);opacity:1}}.admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:60;display:flex;align-items:center;justify-content:center;animation:fade-in .2s ease}.admin-panel{background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius-lg);padding:28px;width:92%;max-width:920px;max-height:min(88vh,860px);display:flex;flex-direction:column;box-shadow:var(--shadow-high)}.admin-panel h3{font-size:18px;font-weight:700;margin-bottom:16px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.admin-close{width:28px;height:28px;border-radius:6px;display:flex;align-items:center;justify-content:center;color:var(--text-muted);transition:all var(--transition)}.admin-close:hover{background:var(--bg-tertiary);color:var(--text-normal)}.admin-field{margin-bottom:16px}.admin-field label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.admin-field input{width:100%;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:10px 12px;font-size:14px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-field input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.admin-btn-action{padding:10px 20px;border-radius:8px;font-size:13px;font-weight:600;font-family:var(--font);cursor:pointer;transition:all var(--transition);line-height:1}.admin-btn-action.primary{background:var(--accent);color:#fff;border:none}.admin-btn-action.primary:hover{background:var(--accent-hover)}.admin-btn-action.outline{background:transparent;border:1px solid rgba(255,255,255,.08);color:var(--text-muted)}.admin-btn-action.outline:hover{border-color:#ffffff1f;color:var(--text-normal)}.admin-btn-action.danger{background:var(--red);color:var(--white);border:1px solid var(--red)}.admin-btn-action.danger:hover{filter:brightness(1.06)}.admin-btn-action.danger.ghost{background:transparent;color:var(--red);border:1px solid rgba(242,63,66,.5)}.admin-btn-action.danger.ghost:hover{background:#f23f4224}.admin-btn-action:disabled{opacity:.5;pointer-events:none}.admin-shell{display:flex;flex-direction:column;gap:12px;min-height:0}.admin-header-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.admin-status{font-size:13px;color:var(--text-muted)}.admin-actions-inline{display:flex;align-items:center;gap:8px}.admin-search-field{margin-bottom:0}.admin-bulk-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border-radius:10px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);flex-wrap:wrap}.admin-select-all{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted)}.admin-select-all input,.admin-item-check input{accent-color:var(--accent)}.admin-list-wrap{min-height:260px;max-height:52vh;overflow-y:auto;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:var(--bg-primary)}.admin-list{display:flex;flex-direction:column;gap:6px;padding:6px}.admin-empty{padding:24px 12px;text-align:center;color:var(--text-muted);font-size:13px}.admin-item{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px;border-radius:8px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06)}.admin-item-main{min-width:0}.admin-item-name{font-size:14px;font-weight:600;color:var(--text-normal);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-meta{margin-top:3px;font-size:11px;color:var(--text-faint);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-actions{display:flex;align-items:center;gap:6px}.admin-item-actions .admin-btn-action,.admin-rename-row .admin-btn-action{padding:8px 12px;font-size:12px}.admin-rename-row{display:flex;align-items:center;gap:6px;margin-top:8px}.admin-rename-row input{flex:1;min-width:120px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:8px 10px;font-size:13px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-rename-row input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}@media(max-width:700px){.toolbar{gap:6px;padding:8px 12px}.cat-tabs{overflow-x:auto;scrollbar-width:none}.cat-tabs::-webkit-scrollbar{display:none}.search-wrap,.url-import-wrap{max-width:100%;min-width:100%;order:-1}.size-control,.theme-selector{display:none}.main{padding:12px}.topbar{padding:0 12px;gap:8px}.channel-label{max-width:100px;overflow:hidden;text-overflow:ellipsis}.clock{font-size:16px}.clock-seconds{font-size:11px}.tb-btn span:not(.tb-icon){display:none}.analytics-strip{padding:8px 12px;flex-direction:column;gap:6px}.analytics-card.analytics-wide{width:100%}.admin-panel{width:96%;padding:16px;max-height:92vh}.admin-item{grid-template-columns:24px minmax(0,1fr)}.admin-item-actions{grid-column:1 / -1;justify-content:flex-end}.admin-rename-row{flex-wrap:wrap}}@media(max-width:480px){.connection,.sb-app-title{display:none}.now-playing{max-width:none}.toolbar .tb-btn{padding:6px 8px}.url-import-btn{padding:0 8px}}.drop-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000c7;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);z-index:300;display:flex;align-items:center;justify-content:center;animation:fade-in .12s ease;pointer-events:none}.drop-zone{display:flex;flex-direction:column;align-items:center;gap:14px;padding:64px 72px;border-radius:24px;border:2.5px dashed rgba(var(--accent-rgb),.55);background:rgba(var(--accent-rgb),.07);animation:drop-pulse 2.2s ease-in-out infinite}@keyframes drop-pulse{0%,to{border-color:rgba(var(--accent-rgb),.45);box-shadow:0 0 rgba(var(--accent-rgb),0)}50%{border-color:rgba(var(--accent-rgb),.9);box-shadow:0 0 60px 12px rgba(var(--accent-rgb),.12)}}.drop-icon{font-size:64px;color:var(--accent);animation:drop-bounce 1.8s ease-in-out infinite}@keyframes drop-bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-8px)}}.drop-title{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:-.3px}.drop-sub{font-size:13px;color:var(--text-muted)}.upload-queue{position:fixed;bottom:24px;right:24px;width:340px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.09);border-radius:14px;box-shadow:0 8px 40px #00000073;z-index:200;animation:slide-up .2s cubic-bezier(.16,1,.3,1)}@keyframes slide-up{0%{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}.uq-header{display:flex;align-items:center;gap:8px;padding:12px 14px;background:rgba(var(--accent-rgb),.12);border-bottom:1px solid rgba(255,255,255,.06);font-size:13px;font-weight:600;color:var(--text-normal)}.uq-header .material-icons{color:var(--accent)}.uq-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition),color var(--transition)}.uq-close:hover{background:#ffffff24;color:var(--text-normal)}.uq-list{display:flex;flex-direction:column;max-height:260px;overflow-y:auto;padding:6px 0}.uq-item{display:grid;grid-template-columns:20px 1fr auto 18px;align-items:center;gap:8px;padding:8px 14px;position:relative}.uq-item+.uq-item{border-top:1px solid rgba(255,255,255,.04)}.uq-file-icon{font-size:18px;color:var(--text-faint)}.uq-info{min-width:0}.uq-name{font-size:12px;font-weight:500;color:var(--text-normal);white-space:nowrap;text-overflow:ellipsis}.uq-size{font-size:10px;color:var(--text-faint);margin-top:1px}.uq-progress-wrap{grid-column:1 / -1;height:3px;background:#ffffff12;border-radius:2px;margin-top:4px}.uq-item{flex-wrap:wrap}.uq-progress-wrap{width:100%;order:10}.uq-progress-bar{height:100%;background:var(--accent);border-radius:2px;transition:width .12s ease}.uq-status-icon{font-size:16px}.uq-status-waiting .uq-status-icon{color:var(--text-faint)}.uq-status-uploading .uq-status-icon{color:var(--accent);animation:spin 1s linear infinite}.uq-status-done .uq-status-icon{color:var(--green)}.uq-status-error .uq-status-icon{color:var(--red)}.uq-error{grid-column:2 / -1;font-size:10px;color:var(--red);margin-top:2px}.dl-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;display:flex;align-items:center;justify-content:center;z-index:300;animation:fade-in .15s ease}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.dl-modal{width:420px;max-width:92vw;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.1);border-radius:16px;box-shadow:0 12px 60px #00000080;animation:scale-in .2s cubic-bezier(.16,1,.3,1)}@keyframes scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.dl-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.06);font-size:14px;font-weight:700;color:var(--text-normal)}.dl-modal-header .material-icons{color:var(--accent)}.dl-modal-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition)}.dl-modal-close:hover{background:#ffffff24;color:var(--text-normal)}.dl-modal-body{padding:16px;display:flex;flex-direction:column;gap:14px}.dl-modal-url{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:8px;background:#0003;overflow:hidden}.dl-modal-tag{flex-shrink:0;padding:2px 8px;border-radius:6px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.dl-modal-tag.youtube{background:#ff00002e;color:#f44}.dl-modal-tag.instagram{background:#e1306c2e;color:#e1306c}.dl-modal-tag.mp3{background:#2ecc712e;color:#2ecc71}.dl-modal-url-text{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-modal-field{display:flex;flex-direction:column;gap:5px}.dl-modal-label{font-size:11px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.dl-modal-input-wrap{display:flex;align-items:center;border:1px solid rgba(255,255,255,.1);border-radius:8px;background:#00000026;overflow:hidden;transition:border-color var(--transition)}.dl-modal-input-wrap:focus-within{border-color:var(--accent)}.dl-modal-input{flex:1;border:none;background:transparent;padding:8px 10px;color:var(--text-normal);font-size:13px;font-family:var(--font);outline:none}.dl-modal-input::placeholder{color:var(--text-faint)}.dl-modal-ext{padding:0 10px;font-size:12px;font-weight:600;color:var(--text-faint);background:#ffffff0a;align-self:stretch;display:flex;align-items:center}.dl-modal-hint{font-size:10px;color:var(--text-faint)}.dl-modal-progress{display:flex;align-items:center;gap:12px;padding:20px 0;justify-content:center;font-size:13px;color:var(--text-muted)}.dl-modal-spinner{width:24px;height:24px;border-radius:50%;border:3px solid rgba(var(--accent-rgb),.2);border-top-color:var(--accent);animation:spin .8s linear infinite}.dl-modal-success{display:flex;align-items:center;gap:10px;padding:16px 0;justify-content:center;font-size:13px;color:var(--text-normal)}.dl-modal-check{color:#2ecc71;font-size:28px}.dl-modal-error{display:flex;align-items:center;gap:10px;padding:12px 0;justify-content:center;font-size:13px;color:#e74c3c}.dl-modal-actions{display:flex;justify-content:flex-end;gap:8px;padding:0 16px 14px}.dl-modal-cancel{padding:7px 14px;border-radius:8px;border:1px solid rgba(255,255,255,.1);background:transparent;color:var(--text-muted);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition)}.dl-modal-cancel:hover{background:#ffffff0f;color:var(--text-normal)}.dl-modal-submit{display:flex;align-items:center;gap:5px;padding:7px 16px;border-radius:8px;border:none;background:var(--accent);color:#fff;font-size:12px;font-weight:700;cursor:pointer;transition:filter var(--transition)}.dl-modal-submit:hover{filter:brightness(1.15)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.lol-container{max-width:920px;margin:0 auto;padding:16px;height:100%;overflow-y:auto}.lol-search{display:flex;gap:8px;margin-bottom:12px}.lol-search-input{flex:1;min-width:0;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:15px;outline:none;transition:border-color .2s}.lol-search-input:focus{border-color:var(--accent)}.lol-search-input::placeholder{color:var(--text-faint)}.lol-search-region{padding:10px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none}.lol-search-btn{padding:10px 20px;border:none;border-radius:8px;background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:opacity .2s;white-space:nowrap}.lol-search-btn:hover{opacity:.85}.lol-search-btn:disabled{opacity:.4;cursor:not-allowed}.lol-recent{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:16px}.lol-recent-chip{display:flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;cursor:pointer;transition:border-color .2s,color .2s}.lol-recent-chip:hover{border-color:var(--accent);color:var(--text-normal)}.lol-recent-chip img{width:18px;height:18px;border-radius:50%}.lol-recent-tier{font-size:10px;font-weight:600;opacity:.7;text-transform:uppercase}.lol-profile{display:flex;align-items:center;gap:16px;padding:16px;border-radius:12px;background:var(--bg-secondary);margin-bottom:12px}.lol-profile-icon{width:72px;height:72px;border-radius:12px;border:2px solid var(--bg-tertiary);object-fit:cover}.lol-profile-info h2{margin:0 0 2px;font-size:20px;color:var(--text-normal)}.lol-profile-info h2 span{color:var(--text-faint);font-weight:400;font-size:14px}.lol-profile-level{font-size:12px;color:var(--text-muted)}.lol-profile-ladder{font-size:11px;color:var(--text-faint)}.lol-profile-updated{font-size:10px;color:var(--text-faint);margin-top:2px}.lol-profile-info{flex:1;min-width:0}.lol-update-btn{display:flex;align-items:center;gap:6px;padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-primary);color:var(--text-muted);font-size:13px;font-weight:500;cursor:pointer;transition:border-color .2s,color .2s,background .2s;white-space:nowrap;flex-shrink:0}.lol-update-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-update-btn:disabled{opacity:.6;cursor:not-allowed}.lol-update-btn.renewing{border-color:var(--accent);color:var(--accent)}.lol-update-icon{font-size:16px;display:inline-block}.lol-update-btn.renewing .lol-update-icon{animation:lol-spin 1s linear infinite}.lol-ranked-row{display:flex;gap:10px;margin-bottom:12px}.lol-ranked-card{flex:1;padding:12px 14px;border-radius:10px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary)}.lol-ranked-card.has-rank{border-left-color:var(--tier-color, var(--accent))}.lol-ranked-type{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}.lol-ranked-tier{font-size:18px;font-weight:700;color:var(--tier-color, var(--text-normal))}.lol-ranked-lp{font-size:13px;color:var(--text-muted);margin-left:4px;font-weight:400}.lol-ranked-record{font-size:12px;color:var(--text-muted);margin-top:2px}.lol-ranked-wr{color:var(--text-faint);margin-left:4px}.lol-ranked-streak{color:#e74c3c;font-size:11px;margin-left:4px}.lol-section-title{font-size:13px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;margin:16px 0 8px;padding-left:2px}.lol-champs{display:flex;gap:8px;margin-bottom:12px;overflow-x:auto;padding-bottom:4px}.lol-champ-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:8px;background:var(--bg-secondary);min-width:180px;flex-shrink:0}.lol-champ-icon{width:36px;height:36px;border-radius:50%;object-fit:cover}.lol-champ-name{font-size:13px;font-weight:600;color:var(--text-normal)}.lol-champ-stats{font-size:11px;color:var(--text-muted)}.lol-champ-kda{font-size:11px;color:var(--text-faint)}.lol-matches{display:flex;flex-direction:column;gap:6px}.lol-match{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary);cursor:pointer;transition:background .15s}.lol-match:hover{background:var(--bg-tertiary)}.lol-match.win{border-left-color:#2ecc71}.lol-match.loss{border-left-color:#e74c3c}.lol-match-result{width:28px;font-size:11px;font-weight:700;text-align:center;flex-shrink:0}.lol-match.win .lol-match-result{color:#2ecc71}.lol-match.loss .lol-match-result{color:#e74c3c}.lol-match-champ{position:relative;flex-shrink:0}.lol-match-champ img{width:40px;height:40px;border-radius:50%;display:block}.lol-match-champ-level{position:absolute;bottom:-2px;right:-2px;background:var(--bg-deep);color:var(--text-muted);font-size:9px;font-weight:700;width:16px;height:16px;border-radius:50%;display:flex;align-items:center;justify-content:center}.lol-match-kda{min-width:80px;text-align:center;flex-shrink:0}.lol-match-kda-nums{font-size:14px;font-weight:600;color:var(--text-normal)}.lol-match-kda-ratio{font-size:11px;color:var(--text-faint)}.lol-match-kda-ratio.perfect{color:#f39c12}.lol-match-kda-ratio.great{color:#2ecc71}.lol-match-stats{display:flex;flex-direction:column;gap:1px;min-width:70px;flex-shrink:0}.lol-match-stats span{font-size:11px;color:var(--text-muted)}.lol-match-items{display:flex;gap:2px;flex-shrink:0}.lol-match-items img,.lol-match-item-empty{width:24px;height:24px;border-radius:4px;background:var(--bg-deep)}.lol-match-meta{margin-left:auto;text-align:right;flex-shrink:0}.lol-match-duration{font-size:12px;color:var(--text-muted)}.lol-match-queue,.lol-match-ago{font-size:10px;color:var(--text-faint)}.lol-match-detail{background:var(--bg-primary);border-radius:8px;padding:8px;margin-top:4px;margin-bottom:4px}.lol-match-detail-team{margin-bottom:6px}.lol-match-detail-team-header{font-size:11px;font-weight:600;padding:4px 8px;border-radius:4px;margin-bottom:4px}.lol-match-detail-team-header.win{background:#2ecc7126;color:#2ecc71}.lol-match-detail-team-header.loss{background:#e74c3c26;color:#e74c3c}.lol-detail-row{display:flex;align-items:center;gap:8px;padding:3px 8px;border-radius:4px;font-size:12px;color:var(--text-muted)}.lol-detail-row:hover{background:var(--bg-secondary)}.lol-detail-row.me{background:#ffffff0a;font-weight:600}.lol-detail-champ{width:24px;height:24px;border-radius:50%}.lol-detail-name{width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-normal)}.lol-detail-kda{width:70px;text-align:center}.lol-detail-cs{width:45px;text-align:center}.lol-detail-dmg,.lol-detail-gold{width:55px;text-align:center}.lol-detail-items{display:flex;gap:1px}.lol-detail-items img{width:20px;height:20px;border-radius:3px}.lol-loading{display:flex;align-items:center;justify-content:center;gap:10px;padding:40px;color:var(--text-muted);font-size:14px}.lol-spinner{width:20px;height:20px;border:2px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:lol-spin .8s linear infinite}@keyframes lol-spin{to{transform:rotate(360deg)}}.lol-error{padding:16px;border-radius:8px;background:#e74c3c1a;color:#e74c3c;font-size:13px;text-align:center;margin-bottom:12px}.lol-empty{text-align:center;padding:60px 20px;color:var(--text-faint)}.lol-empty-icon{font-size:48px;margin-bottom:12px}.lol-empty h3{margin:0 0 8px;color:var(--text-muted);font-size:16px}.lol-empty p{margin:0;font-size:13px}.lol-load-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--bg-tertiary);border-radius:8px;background:transparent;color:var(--text-muted);font-size:13px;cursor:pointer;transition:border-color .2s,color .2s}.lol-load-more:hover{border-color:var(--accent);color:var(--text-normal)}@media(max-width:640px){.lol-search{flex-wrap:wrap}.lol-search-input{width:100%}.lol-match{flex-wrap:wrap;gap:6px}.lol-match-meta{margin-left:0;text-align:left}.lol-match-items,.lol-profile{flex-wrap:wrap}}.stream-container{height:100%;overflow-y:auto;padding:16px}.stream-topbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}.stream-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0}.stream-input:focus{border-color:var(--accent)}.stream-input::placeholder{color:var(--text-faint)}.stream-input-name{width:150px}.stream-input-title{flex:1;min-width:180px}.stream-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.stream-btn:hover{background:var(--accent-hover)}.stream-btn:disabled{opacity:.5;cursor:not-allowed}.stream-btn-stop{background:var(--danger)}.stream-btn-stop:hover{background:#c93b3e}.stream-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.stream-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.stream-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.stream-tile.own{border:2px solid var(--accent)}.stream-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.stream-tile-preview video{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover}.stream-tile-preview .stream-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.stream-live-badge{position:absolute;top:8px;left:8px;background:var(--danger);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;letter-spacing:.5px;display:flex;align-items:center;gap:4px}.stream-live-dot{width:6px;height:6px;border-radius:50%;background:#fff;animation:stream-pulse 1.5s ease-in-out infinite}@keyframes stream-pulse{0%,to{opacity:1}50%{opacity:.3}}.stream-tile-viewers{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.stream-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.stream-tile-meta{min-width:0;flex:1}.stream-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-title{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-time{font-size:12px;color:var(--text-faint);white-space:nowrap}.stream-tile-menu-wrap{position:relative}.stream-tile-menu{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 6px;font-size:18px;line-height:1;border-radius:4px;transition:background var(--transition)}.stream-tile-menu:hover{background:var(--bg-tertiary);color:var(--text-normal)}.stream-tile-dropdown{position:absolute;bottom:calc(100% + 6px);right:0;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius-lg);min-width:220px;z-index:100;box-shadow:0 8px 24px #0006;overflow:hidden}.stream-tile-dropdown-header{padding:12px 14px}.stream-tile-dropdown-name{font-size:14px;font-weight:600;color:var(--text-normal)}.stream-tile-dropdown-title{font-size:12px;color:var(--text-muted);margin-top:2px}.stream-tile-dropdown-detail{font-size:11px;color:var(--text-faint);margin-top:6px}.stream-tile-dropdown-divider{height:1px;background:var(--bg-tertiary)}.stream-tile-dropdown-item{display:flex;align-items:center;gap:8px;width:100%;padding:10px 14px;border:none;background:none;color:var(--text-normal);font-size:13px;cursor:pointer;text-align:left;transition:background var(--transition)}.stream-tile-dropdown-item:hover{background:var(--bg-tertiary)}.stream-viewer-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.stream-viewer-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1}.stream-viewer-header-left{display:flex;align-items:center;gap:12px}.stream-viewer-title{font-weight:600;font-size:16px}.stream-viewer-subtitle{font-size:13px;color:var(--text-muted)}.stream-viewer-header-right{display:flex;align-items:center;gap:8px}.stream-viewer-fullscreen{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.stream-viewer-fullscreen:hover{background:#ffffff40}.stream-viewer-close{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.stream-viewer-close:hover{background:#fff3}.stream-viewer-video{flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden}.stream-viewer-video video{max-width:100%;max-height:100%;width:100%;height:100%;object-fit:contain}.stream-viewer-connecting{color:var(--text-muted);font-size:16px;display:flex;flex-direction:column;align-items:center;gap:12px}.stream-viewer-spinner{width:32px;height:32px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:stream-spin .8s linear infinite}@keyframes stream-spin{to{transform:rotate(360deg)}}.stream-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.stream-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.stream-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.stream-empty p{font-size:14px}.stream-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.stream-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.stream-tile.broadcasting .stream-tile-preview{border:2px solid var(--danger);border-bottom:none}.stream-input-password{width:140px}.stream-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.stream-pw-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.stream-pw-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.stream-pw-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.stream-pw-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.stream-pw-modal .stream-input{width:100%;margin-bottom:12px}.stream-pw-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.stream-pw-actions{display:flex;gap:8px;justify-content:flex-end}.stream-pw-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.stream-pw-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.wt-container{height:100%;overflow-y:auto;padding:16px}.wt-topbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}.wt-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0}.wt-input:focus{border-color:var(--accent)}.wt-input::placeholder{color:var(--text-faint)}.wt-input-name{width:150px}.wt-input-room{flex:1;min-width:180px}.wt-input-password{width:170px}.wt-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.wt-btn:hover{background:var(--accent-hover)}.wt-btn:disabled{opacity:.5;cursor:not-allowed}.wt-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.wt-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.wt-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.wt-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.wt-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.wt-tile-members{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.wt-tile-playing{position:absolute;top:8px;left:8px;background:var(--accent);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.wt-tile-meta{min-width:0;flex:1}.wt-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-tile-host{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.wt-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.wt-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.wt-empty p{font-size:14px}.wt-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.wt-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.wt-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.wt-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.wt-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.wt-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.wt-modal .wt-input{width:100%;margin-bottom:12px}.wt-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.wt-modal-actions{display:flex;gap:8px;justify-content:flex-end}.wt-modal-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.wt-modal-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.wt-room-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.wt-room-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1;flex-shrink:0}.wt-room-header-left{display:flex;align-items:center;gap:12px}.wt-room-name{font-weight:600;font-size:16px}.wt-room-members{font-size:13px;color:var(--text-muted)}.wt-host-badge{font-size:11px;background:#ffffff1a;padding:2px 8px;border-radius:4px;color:var(--accent);font-weight:600}.wt-room-header-right{display:flex;align-items:center;gap:8px}.wt-fullscreen-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.wt-fullscreen-btn:hover{background:#ffffff40}.wt-leave-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.wt-leave-btn:hover{background:#fff3}.wt-room-body{display:flex;flex:1;overflow:hidden}.wt-player-section{flex:1;display:flex;flex-direction:column;min-width:0}.wt-player-wrap{position:relative;width:100%;flex:1;background:#000;display:flex;align-items:center;justify-content:center;overflow:hidden}.wt-yt-container{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}.wt-yt-container iframe{width:100%;height:100%}.wt-video-element{width:100%;height:100%;object-fit:contain}.wt-player-placeholder{display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--text-muted);font-size:16px}.wt-placeholder-icon{font-size:48px;opacity:.3}.wt-controls{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#000c;flex-shrink:0}.wt-ctrl-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;transition:background var(--transition);flex-shrink:0}.wt-ctrl-btn:hover:not(:disabled){background:#ffffff40}.wt-ctrl-btn:disabled{opacity:.3;cursor:not-allowed}.wt-ctrl-status{color:var(--text-muted);font-size:16px;width:36px;text-align:center;flex-shrink:0}.wt-seek{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer;min-width:60px}.wt-seek::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-webkit-slider-runnable-track{height:4px;border-radius:2px}.wt-seek::-moz-range-track{height:4px;border-radius:2px;background:var(--bg-tertiary)}.wt-seek-readonly{flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);position:relative;overflow:hidden;min-width:60px}.wt-seek-progress{position:absolute;top:0;left:0;height:100%;background:var(--accent);border-radius:2px;transition:width .3s linear}.wt-time{font-variant-numeric:tabular-nums;color:#fff;font-size:13px;white-space:nowrap;flex-shrink:0}.wt-volume{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.wt-volume-icon{font-size:16px;width:20px;text-align:center;cursor:default}.wt-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer}.wt-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-queue-panel{width:280px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-queue-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-list{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-queue-list::-webkit-scrollbar{width:4px}.wt-queue-list::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-queue-empty{padding:24px 16px;text-align:center;color:var(--text-faint);font-size:13px}.wt-queue-item{padding:10px 12px;border-bottom:1px solid var(--bg-tertiary);display:flex;align-items:center;gap:8px;transition:background var(--transition)}.wt-queue-item:hover{background:var(--bg-tertiary)}.wt-queue-item.playing{border-left:3px solid var(--accent);background:#e67e2214}.wt-queue-item-info{flex:1;min-width:0}.wt-queue-item-title{font-size:13px;font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-queue-item-by{font-size:11px;color:var(--text-faint);margin-top:2px}.wt-queue-item-remove{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:18px;padding:2px 6px;border-radius:4px;transition:all var(--transition);flex-shrink:0}.wt-queue-item-remove:hover{color:var(--danger);background:#ed42451f}.wt-queue-add{padding:12px;display:flex;gap:8px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-input{flex:1;font-size:13px;padding:8px 10px}.wt-queue-add-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-player-error{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:#000000d9;color:#fff;z-index:2;text-align:center;padding:20px}.wt-error-icon{font-size:48px}.wt-player-error p{font-size:15px;color:var(--text-muted);margin:0}.wt-yt-link{display:inline-block;padding:8px 20px;background:red;color:#fff;border-radius:var(--radius);text-decoration:none;font-weight:600;font-size:14px;transition:background var(--transition)}.wt-yt-link:hover{background:#c00}.wt-skip-info{font-size:12px!important;color:var(--text-faint)!important;font-style:italic}.wt-queue-item.clickable{cursor:pointer}.wt-queue-item.clickable:hover{background:#e67e221f}@media(max-width:768px){.wt-room-body{flex-direction:column}.wt-queue-panel{width:100%;max-height:40vh;border-left:none;border-top:1px solid var(--bg-tertiary)}.wt-player-wrap{min-height:200px}.wt-controls{flex-wrap:wrap;gap:8px;padding:10px 12px}.wt-volume{margin-left:0}.wt-volume-slider{width:80px}.wt-room-header{padding:10px 12px}.wt-room-name{font-size:14px}.wt-room-members,.wt-host-badge{font-size:11px}}@media(max-width:480px){.wt-topbar{gap:8px}.wt-input-name{width:100%}.wt-input-room{min-width:0}.wt-input-password{width:100%}.wt-volume-slider{width:60px}.wt-time{font-size:12px}.wt-host-badge{display:none}}:root{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--success: #57d28f;--danger: #ed4245;--warning: #fee75c;--border: rgba(255, 255, 255, .06);--radius: 8px;--radius-lg: 12px;--transition: .15s ease;--font: "Segoe UI", system-ui, -apple-system, sans-serif;--header-height: 56px}*,*:before,*:after{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;font-family:var(--font);font-size:15px;color:var(--text-normal);background:var(--bg-deep);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;overflow:hidden}#root{height:100%}.hub-app{display:flex;flex-direction:column;height:100vh;overflow:hidden}.hub-header{position:sticky;top:0;z-index:100;display:flex;align-items:center;height:var(--header-height);min-height:var(--header-height);padding:0 16px;background:var(--bg-primary);border-bottom:1px solid var(--border);gap:16px}.hub-header-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.hub-logo{font-size:24px;line-height:1}.hub-title{font-size:18px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em;white-space:nowrap}.hub-conn-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);flex-shrink:0;transition:background var(--transition);box-shadow:0 0 0 2px #ed424540}.hub-conn-dot.online{background:var(--success);box-shadow:0 0 0 2px #57d28f40;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 0 2px #57d28f40}50%{box-shadow:0 0 0 6px #57d28f1a}}.hub-tabs{display:flex;align-items:center;gap:4px;flex:1;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;padding:0 4px}.hub-tabs::-webkit-scrollbar{display:none}.hub-tab{display:flex;align-items:center;gap:6px;padding:8px 14px;border:none;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:var(--radius);white-space:nowrap;transition:all var(--transition);position:relative;-webkit-user-select:none;user-select:none}.hub-tab:hover{color:var(--text-normal);background:var(--bg-secondary)}.hub-tab.active{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-tab.active:after{content:"";position:absolute;bottom:-1px;left:50%;transform:translate(-50%);width:calc(100% - 16px);height:2px;background:var(--accent);border-radius:1px}.hub-tab-icon{font-size:16px;line-height:1}.hub-tab-label{text-transform:capitalize}.hub-header-right{display:flex;align-items:center;gap:12px;flex-shrink:0}.hub-download-btn{font-size:16px;text-decoration:none;opacity:.6;transition:opacity var(--transition);cursor:pointer}.hub-download-btn:hover{opacity:1}.hub-version{font-size:12px;color:var(--text-faint);font-weight:500;font-variant-numeric:tabular-nums;background:var(--bg-secondary);padding:4px 8px;border-radius:4px}.hub-content{flex:1;overflow-y:auto;overflow-x:hidden;background:var(--bg-deep);scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.hub-content::-webkit-scrollbar{width:6px}.hub-content::-webkit-scrollbar-track{background:transparent}.hub-content::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.hub-content::-webkit-scrollbar-thumb:hover{background:var(--text-faint)}.hub-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px;text-align:center;padding:32px;animation:fade-in .3s ease}.hub-empty-icon{font-size:64px;line-height:1;margin-bottom:20px;opacity:.6;filter:grayscale(30%)}.hub-empty h2{font-size:22px;font-weight:700;color:var(--text-normal);margin-bottom:8px}.hub-empty p{font-size:15px;color:var(--text-muted);max-width:360px;line-height:1.5}@keyframes fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}::selection{background:rgba(var(--accent-rgb),.3);color:var(--text-normal)}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(max-width:768px){:root{--header-height: 48px}.hub-header{padding:0 10px;gap:8px}.hub-title{font-size:15px}.hub-logo{font-size:20px}.hub-tab{padding:6px 10px;font-size:13px;gap:4px}.hub-tab-label{display:none}.hub-tab-icon{font-size:18px}.hub-version{font-size:11px}.hub-empty-icon{font-size:48px}.hub-empty h2{font-size:18px}.hub-empty p{font-size:14px}}@media(max-width:480px){.hub-header-right{display:none}.hub-header{padding:0 8px;gap:6px}.hub-title{font-size:14px}}.radio-container{display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;background:var(--bg-deep);--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--border: rgba(255, 255, 255, .06)}.radio-container[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad}.radio-container[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60}.radio-container[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9}.radio-container[data-theme=cherry]{--bg-deep: #1a0f14;--bg-primary: #22141a;--bg-secondary: #301c25;--bg-tertiary: #3e2530;--accent: #e74c6f;--accent-rgb: 231, 76, 111;--accent-hover: #c0392b}.radio-topbar{display:flex;align-items:center;padding:0 16px;height:52px;background:var(--bg-secondary, #2b2d31);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px}.radio-topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.radio-topbar-logo{font-size:20px}.radio-topbar-title{font-size:16px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em}.radio-topbar-np{flex:1;display:flex;align-items:center;gap:10px;min-width:0;justify-content:center}.radio-topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.radio-topbar-stop{display:flex;align-items:center;gap:4px;background:var(--danger);color:#fff;border:none;border-radius:var(--radius);padding:6px 14px;font-size:13px;font-family:var(--font);font-weight:600;cursor:pointer;transition:all var(--transition);flex-shrink:0}.radio-topbar-stop:hover{background:#c63639}.radio-theme-inline{display:flex;align-items:center;gap:4px;margin-left:4px}.radio-globe-wrap{position:relative;flex:1;overflow:hidden}.radio-globe{width:100%;height:100%}.radio-globe canvas{outline:none!important}.radio-search{position:absolute;top:16px;left:50%;transform:translate(-50%);z-index:20;width:min(440px,calc(100% - 32px))}.radio-search-wrap{display:flex;align-items:center;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);padding:0 14px;gap:8px;box-shadow:0 8px 32px #0006}.radio-search-icon{font-size:16px;opacity:.6;flex-shrink:0}.radio-search-input{flex:1;background:transparent;border:none;color:var(--text-normal);font-family:var(--font);font-size:14px;padding:12px 0;outline:none}.radio-search-input::placeholder{color:var(--text-faint)}.radio-search-clear{background:none;border:none;color:var(--text-muted);font-size:14px;cursor:pointer;padding:4px;border-radius:4px;transition:color var(--transition)}.radio-search-clear:hover{color:var(--text-normal)}.radio-search-results{margin-top:6px;background:#1e1f22f2;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);max-height:360px;overflow-y:auto;box-shadow:0 12px 40px #00000080;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-search-result{display:flex;align-items:center;gap:10px;width:100%;padding:10px 14px;background:none;border:none;border-bottom:1px solid var(--border);color:var(--text-normal);font-family:var(--font);font-size:14px;cursor:pointer;text-align:left;transition:background var(--transition)}.radio-search-result:last-child{border-bottom:none}.radio-search-result:hover{background:rgba(var(--accent-rgb),.08)}.radio-search-result-icon{font-size:18px;flex-shrink:0}.radio-search-result-text{display:flex;flex-direction:column;gap:2px;min-width:0}.radio-search-result-title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-search-result-sub{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-fab{position:absolute;top:16px;right:16px;z-index:20;display:flex;align-items:center;gap:4px;padding:10px 14px;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);color:var(--text-normal);font-size:16px;cursor:pointer;box-shadow:0 8px 32px #0006;transition:all var(--transition)}.radio-fab:hover,.radio-fab.active{background:rgba(var(--accent-rgb),.15);border-color:rgba(var(--accent-rgb),.3)}.radio-fab-badge{font-size:11px;font-weight:700;background:var(--accent);color:#fff;padding:1px 6px;border-radius:10px;min-width:18px;text-align:center}.radio-panel{position:absolute;top:0;right:0;width:340px;height:100%;z-index:15;background:#1e1f22f2;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border-left:1px solid var(--border);display:flex;flex-direction:column;animation:slide-in-right .2s ease;box-shadow:-8px 0 32px #0000004d}@keyframes slide-in-right{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}.radio-panel-header{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--border);flex-shrink:0}.radio-panel-header h3{font-size:16px;font-weight:700;color:var(--text-normal)}.radio-panel-sub{font-size:12px;color:var(--text-muted);display:block;margin-top:2px}.radio-panel-close{background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all var(--transition)}.radio-panel-close:hover{color:var(--text-normal);background:var(--bg-secondary)}.radio-panel-body{flex:1;overflow-y:auto;padding:8px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-panel-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:14px}.radio-panel-loading{display:flex;flex-direction:column;align-items:center;gap:12px;padding:40px 16px;color:var(--text-muted);font-size:14px}.radio-station{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);transition:background var(--transition);gap:10px}.radio-station:hover{background:var(--bg-secondary)}.radio-station.playing{background:rgba(var(--accent-rgb),.1);border:1px solid rgba(var(--accent-rgb),.2)}.radio-station-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.radio-station-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-loc{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-live{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--accent);font-weight:600}.radio-station-btns{display:flex;gap:4px;flex-shrink:0}.radio-btn-play,.radio-btn-stop{width:34px;height:34px;border:none;border-radius:50%;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-play{background:var(--accent);color:#fff}.radio-btn-play:hover:not(:disabled){background:var(--accent-hover);transform:scale(1.05)}.radio-btn-play:disabled{opacity:.4;cursor:not-allowed}.radio-btn-stop{background:var(--danger);color:#fff}.radio-btn-stop:hover{background:#c63639}.radio-btn-fav{width:34px;height:34px;border:none;border-radius:50%;font-size:16px;cursor:pointer;background:transparent;color:var(--text-faint);display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-fav:hover{color:var(--warning);background:#fee75c1a}.radio-btn-fav.active{color:var(--warning)}.radio-eq{display:flex;align-items:flex-end;gap:2px;height:14px}.radio-eq span{width:3px;background:var(--accent);border-radius:1px;animation:eq-bounce .8s ease-in-out infinite}.radio-eq span:nth-child(1){height:8px;animation-delay:0s}.radio-eq span:nth-child(2){height:14px;animation-delay:.15s}.radio-eq span:nth-child(3){height:10px;animation-delay:.3s}@keyframes eq-bounce{0%,to{transform:scaleY(.4)}50%{transform:scaleY(1)}}.radio-sel{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius);color:var(--text-normal);font-family:var(--font);font-size:13px;padding:6px 10px;cursor:pointer;outline:none;max-width:180px}.radio-sel:focus{border-color:var(--accent)}.radio-eq-np{flex-shrink:0}.radio-np-info{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}.radio-np-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-np-loc{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-volume{display:flex;align-items:center;gap:6px;flex-shrink:0}.radio-volume-icon{font-size:16px;width:20px;text-align:center;cursor:pointer}.radio-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary, #383a40);outline:none;cursor:pointer}.radio-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-val{font-size:11px;color:var(--text-muted);min-width:32px;text-align:right}.radio-theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:transform .15s ease,border-color .15s ease;border:2px solid transparent}.radio-theme-dot:hover{transform:scale(1.25)}.radio-theme-dot.active{border-color:#fff;box-shadow:0 0 6px #ffffff4d}.radio-counter{position:absolute;bottom:16px;left:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;pointer-events:none}.radio-attribution{position:absolute;right:16px;bottom:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;text-decoration:none;transition:color var(--transition),background var(--transition)}.radio-attribution:hover{color:var(--text-normal);background:#1e1f22eb}.radio-spinner{width:24px;height:24px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media(max-width:768px){.radio-panel{width:100%}.radio-fab{top:12px;right:12px;padding:8px 10px;font-size:14px}.radio-search{top:12px;width:calc(100% - 80px);left:calc(50% - 24px)}.radio-topbar{padding:0 12px;gap:8px}.radio-topbar-title{display:none}.radio-sel{max-width:140px;font-size:12px}}@media(max-width:480px){.radio-topbar-np,.radio-volume{display:none}.radio-sel{max-width:120px}}.radio-conn{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--success);cursor:pointer;padding:4px 10px;border-radius:20px;background:#57d28f14;transition:all var(--transition);flex-shrink:0;-webkit-user-select:none;user-select:none}.radio-conn:hover{background:#57d28f26}.radio-conn-dot{width:8px;height:8px;border-radius:50%;background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.radio-conn-ping{font-size:11px;color:var(--text-muted);font-weight:600;font-variant-numeric:tabular-nums}.radio-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fade-in .15s ease}.radio-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:radio-modal-in .2s ease}@keyframes radio-modal-in{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.radio-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.radio-modal-close{margin-left:auto;background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.radio-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.radio-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.radio-modal-stat{display:flex;justify-content:space-between;align-items:center}.radio-modal-label{color:var(--text-muted);font-size:13px}.radio-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.radio-modal-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0} diff --git a/web/dist/assets/index-TtdZJHkE.css b/web/dist/assets/index-TtdZJHkE.css new file mode 100644 index 0000000..76d2ca9 --- /dev/null +++ b/web/dist/assets/index-TtdZJHkE.css @@ -0,0 +1 @@ +@import"https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap";@import"https://fonts.googleapis.com/icon?family=Material+Icons";.sb-app{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--bg-modifier-hover: rgba(79, 84, 92, .16);--bg-modifier-active: rgba(79, 84, 92, .24);--bg-modifier-selected: rgba(79, 84, 92, .32);--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #5865f2;--accent-rgb: 88, 101, 242;--accent-hover: #4752c4;--accent-glow: rgba(88, 101, 242, .45);--green: #23a55a;--red: #f23f42;--yellow: #f0b232;--white: #ffffff;--font: "DM Sans", "Outfit", "gg sans", "Noto Sans", Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;--radius: 8px;--radius-lg: 12px;--shadow-low: 0 1px 3px rgba(0, 0, 0, .24);--shadow-med: 0 4px 12px rgba(0, 0, 0, .32);--shadow-high: 0 8px 24px rgba(0, 0, 0, .4);--transition: .15s cubic-bezier(.4, 0, .2, 1);--card-size: 110px;--card-emoji: 28px;--card-font: 11px;color-scheme:dark}.sb-app[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad;--accent-glow: rgba(155, 89, 182, .45)}.sb-app[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60;--accent-glow: rgba(46, 204, 113, .4)}.sb-app[data-theme=sunset]{--bg-deep: #1a1210;--bg-primary: #231815;--bg-secondary: #2f201c;--bg-tertiary: #3d2a24;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--accent-glow: rgba(230, 126, 34, .4)}.sb-app[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9;--accent-glow: rgba(52, 152, 219, .4)}.sb-app{display:flex;flex-direction:column;height:100%;position:relative}.topbar{display:flex;align-items:center;padding:0 20px;height:52px;background:var(--bg-secondary);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px;transition:background .4s ease}.topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.sb-app-logo{width:28px;height:28px;background:var(--accent);border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .4s ease}.sb-app-title{font-size:16px;font-weight:700;color:var(--white);letter-spacing:-.02em}.clock-wrap{flex:1;display:flex;justify-content:center}.clock{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:.02em;font-variant-numeric:tabular-nums;opacity:.9}.clock-seconds{font-size:14px;color:var(--text-faint);font-weight:500}.topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0}.channel-dropdown{position:relative;flex-shrink:0}.channel-btn{display:flex;align-items:center;gap:8px;padding:5px 12px 5px 10px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-normal);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.channel-btn:hover{background:var(--bg-modifier-selected);border-color:#ffffff1f}.channel-btn.open{border-color:var(--accent)}.channel-btn .cb-icon{font-size:16px;color:var(--text-muted)}.channel-btn .chevron{font-size:12px;color:var(--text-faint);transition:transform var(--transition);margin-left:2px}.channel-btn.open .chevron{transform:rotate(180deg)}.channel-status{width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0}.channel-menu{position:absolute;top:calc(100% + 6px);left:0;min-width:220px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:6px;z-index:100;animation:ctx-in .1s ease-out}.channel-menu-header{padding:6px 8px 4px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-faint)}.channel-option{display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:4px;font-size:13px;color:var(--text-muted);cursor:pointer;transition:all var(--transition)}.channel-option:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.channel-option.active{background:var(--accent);color:var(--white)}.channel-option .co-icon{font-size:16px;opacity:.7}.connection{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:#23a55a1f;font-size:12px;color:var(--green);font-weight:600}.conn-dot{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 6px #23a55a99;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 6px #23a55a80}50%{box-shadow:0 0 12px #23a55acc}}.conn-ping{font-size:10px;opacity:.7;margin-left:2px}.conn-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fadeIn .15s ease}.conn-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:slideUp .2s ease}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.conn-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.conn-modal-close{margin-left:auto;background:none;border:none;color:var(--muted);cursor:pointer;padding:4px;border-radius:6px;display:flex;transition:all .15s}.conn-modal-close:hover{background:#ffffff14;color:var(--fg)}.conn-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.conn-stat{display:flex;justify-content:space-between;align-items:center}.conn-stat-label{color:var(--muted);font-size:13px}.conn-stat-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.conn-ping-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.admin-btn-icon{width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition);font-size:18px}.admin-btn-icon:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.admin-btn-icon.active{color:var(--accent)}.toolbar{display:flex;align-items:center;gap:10px;padding:10px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0;flex-wrap:wrap;transition:background .4s ease}.cat-tabs{display:flex;gap:4px;flex-shrink:0}.cat-tab{display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.cat-tab:hover{background:var(--bg-modifier-selected);color:var(--text-normal)}.cat-tab.active{background:var(--accent);color:var(--white)}.tab-count{font-size:10px;font-weight:700;background:#ffffff26;padding:0 6px;border-radius:8px;line-height:1.6}.search-wrap{position:relative;flex:1;max-width:280px;min-width:140px}.search-wrap .search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);font-size:15px;color:var(--text-faint);pointer-events:none}.search-input{width:100%;height:32px;padding:0 28px 0 32px;border:1px solid rgba(255,255,255,.06);border-radius:20px;background:var(--bg-secondary);color:var(--text-normal);font-family:var(--font);font-size:13px;outline:none;transition:all var(--transition)}.search-input::placeholder{color:var(--text-faint)}.search-input:focus{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.search-clear{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:20px;height:20px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition)}.search-clear:hover{background:var(--bg-tertiary);color:var(--text-normal)}.toolbar-spacer{flex:1}.url-import-wrap{display:flex;align-items:center;gap:6px;min-width:240px;max-width:460px;flex:1;padding:4px 6px 4px 8px;border-radius:20px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.url-import-icon{font-size:15px;color:var(--text-faint);flex-shrink:0}.url-import-input{flex:1;min-width:0;height:26px;border:none;background:transparent;color:var(--text-normal);font-size:12px;font-family:var(--font);outline:none}.url-import-input::placeholder{color:var(--text-faint)}.url-import-btn{height:24px;padding:0 10px;border-radius:14px;border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.45);background:rgba(var(--accent-rgb, 88, 101, 242),.12);color:var(--accent);font-size:11px;font-weight:700;white-space:nowrap;transition:all var(--transition)}.url-import-btn:hover{background:var(--accent);border-color:var(--accent);color:var(--white)}.url-import-btn:disabled{opacity:.5;pointer-events:none}.url-import-tag{flex-shrink:0;padding:1px 6px;border-radius:8px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.url-import-tag.valid{background:#2ecc712e;color:#2ecc71}.url-import-tag.invalid{background:#e74c3c2e;color:#e74c3c}.tb-btn{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.tb-btn:hover{background:var(--bg-modifier-selected);color:var(--text-normal);border-color:#ffffff1f}.tb-btn .tb-icon{font-size:15px}.tb-btn.random{border-color:#5865f24d;color:var(--accent)}.tb-btn.random:hover{background:var(--accent);color:var(--white);border-color:var(--accent)}.tb-btn.party{border-color:#f0b2324d;color:var(--yellow)}.tb-btn.party:hover{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow)}.tb-btn.party.active{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow);animation:party-btn .6s ease-in-out infinite alternate}@keyframes party-btn{0%{box-shadow:0 0 8px #f0b23266}to{box-shadow:0 0 20px #f0b232b3}}.tb-btn.stop{border-color:#f23f424d;color:var(--red)}.tb-btn.stop:hover{background:var(--red);color:var(--white);border-color:var(--red)}.size-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.size-control .sc-icon{font-size:14px;color:var(--text-faint)}.size-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:70px;height:3px;border-radius:2px;background:var(--bg-modifier-selected);outline:none;cursor:pointer}.size-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.size-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.size-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.theme-selector{display:flex;align-items:center;gap:4px;padding:4px 8px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:all var(--transition);border:2px solid transparent}.theme-dot:hover{transform:scale(1.2)}.theme-dot.active{border-color:var(--white);box-shadow:0 0 6px #ffffff4d}.analytics-strip{display:flex;align-items:stretch;gap:8px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0}.analytics-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:12px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.analytics-card.analytics-wide{flex:1;min-width:0}.analytics-icon{font-size:18px;color:var(--accent);flex-shrink:0}.analytics-copy{display:flex;flex-direction:column;gap:4px;min-width:0}.analytics-label{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--text-faint)}.analytics-value{font-size:18px;line-height:1;font-weight:800;color:var(--text-normal)}.analytics-top-list{display:flex;align-items:center;gap:6px;overflow-x:auto;scrollbar-width:none}.analytics-top-list::-webkit-scrollbar{display:none}.analytics-chip{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:999px;background:rgba(var(--accent-rgb, 88, 101, 242),.15);color:var(--accent);font-size:11px;font-weight:600;white-space:nowrap}.analytics-muted{color:var(--text-muted);font-size:12px}.category-strip{display:flex;align-items:center;gap:6px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);overflow-x:auto;flex-shrink:0;scrollbar-width:none;transition:background .4s ease}.category-strip::-webkit-scrollbar{display:none}.cat-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;font-size:12px;font-weight:600;color:var(--text-muted);background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06);white-space:nowrap;cursor:pointer;transition:all var(--transition);flex-shrink:0}.cat-chip:hover{border-color:#ffffff1f;color:var(--text-normal);background:var(--bg-tertiary)}.cat-chip.active{background:#5865f21a}.cat-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.cat-count{font-size:10px;font-weight:700;opacity:.5}.main{flex:1;overflow-y:auto;padding:16px 20px;background:var(--bg-primary);transition:background .4s ease}.sound-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--card-size),1fr));gap:8px}.sound-card{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:12px 6px 8px;background:var(--bg-secondary);border-radius:var(--radius-lg);cursor:pointer;transition:all var(--transition);border:2px solid transparent;-webkit-user-select:none;user-select:none;overflow:hidden;aspect-ratio:1;opacity:0;animation:card-enter .35s ease-out forwards}.sound-card:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;opacity:0;transition:opacity var(--transition);background:radial-gradient(ellipse at center,var(--accent-glow) 0%,transparent 70%);pointer-events:none}.sound-card:hover{background:var(--bg-tertiary);transform:translateY(-3px);box-shadow:var(--shadow-med),0 0 20px var(--accent-glow);border-color:#5865f233}.sound-card:hover:before{opacity:1}.sound-card:active{transform:translateY(0);transition-duration:50ms}.sound-card.playing{border-color:var(--accent);animation:card-enter .35s ease-out forwards,playing-glow 1.2s ease-in-out infinite alternate}@keyframes playing-glow{0%{box-shadow:0 0 4px var(--accent-glow)}to{box-shadow:0 0 16px var(--accent-glow)}}@keyframes card-enter{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.ripple{position:absolute;border-radius:50%;background:#5865f24d;transform:scale(0);animation:ripple-expand .5s ease-out forwards;pointer-events:none}@keyframes ripple-expand{to{transform:scale(3);opacity:0}}.sound-emoji{font-size:var(--card-emoji);font-weight:800;line-height:1;z-index:1;transition:transform var(--transition);opacity:.7;font-family:Syne,DM Sans,sans-serif}.sound-card:hover .sound-emoji{transform:scale(1.15);opacity:1}.sound-card.playing .sound-emoji{animation:emoji-bounce .4s ease;opacity:1}@keyframes emoji-bounce{0%,to{transform:scale(1)}40%{transform:scale(1.3)}70%{transform:scale(.95)}}.sound-name{font-size:var(--card-font);font-weight:600;text-align:center;color:var(--text-normal);z-index:1;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 4px}.sound-duration{font-size:9px;color:var(--text-faint);z-index:1;font-weight:500}.fav-star{position:absolute;top:4px;right:4px;opacity:0;transition:all var(--transition);cursor:pointer;z-index:2;color:var(--text-faint);padding:2px;line-height:1}.fav-star .fav-icon{font-size:14px}.sound-card:hover .fav-star{opacity:.6}.fav-star:hover{opacity:1!important;color:var(--yellow);transform:scale(1.2)}.fav-star.active{opacity:1!important;color:var(--yellow)}.new-badge{position:absolute;top:4px;left:4px;font-size:8px;font-weight:700;background:var(--green);color:#fff;padding:1px 5px;border-radius:6px;text-transform:uppercase;letter-spacing:.03em;z-index:2}.playing-indicator{position:absolute;bottom:3px;left:50%;transform:translate(-50%);display:none;gap:2px;align-items:flex-end;height:10px}.sound-card.playing .playing-indicator{display:flex}.wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .6s ease-in-out infinite alternate}.wave-bar:nth-child(1){height:3px;animation-delay:0ms}.wave-bar:nth-child(2){height:7px;animation-delay:.15s}.wave-bar:nth-child(3){height:5px;animation-delay:.3s}.wave-bar:nth-child(4){height:9px;animation-delay:.1s}@keyframes wave{0%{height:2px}to{height:10px}}.empty-state{display:none;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:60px 20px;text-align:center}.empty-state.visible{display:flex}.empty-emoji{font-size:42px}.empty-title{font-size:15px;font-weight:700;color:var(--text-normal)}.empty-desc{font-size:13px;color:var(--text-muted);max-width:260px}.now-playing{display:flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;background:rgba(var(--accent-rgb, 88, 101, 242),.12);border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.2);font-size:12px;color:var(--text-muted);max-width:none;min-width:0;animation:np-fade-in .3s ease}@keyframes np-fade-in{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}.np-name{color:var(--accent);font-weight:600;white-space:nowrap}.np-waves{display:none;gap:1.5px;align-items:flex-end;height:12px;flex-shrink:0}.np-waves.active{display:flex}.np-wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .5s ease-in-out infinite alternate}.np-wave-bar:nth-child(1){height:3px;animation-delay:0ms}.np-wave-bar:nth-child(2){height:8px;animation-delay:.12s}.np-wave-bar:nth-child(3){height:5px;animation-delay:.24s}.np-wave-bar:nth-child(4){height:10px;animation-delay:80ms}.volume-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.vol-icon{font-size:16px;color:var(--text-faint);cursor:pointer;transition:color var(--transition);-webkit-user-select:none;user-select:none}.vol-icon:hover{color:var(--text-normal)}.vol-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:80px;height:3px;border-radius:2px;background:linear-gradient(to right,var(--accent) 0%,var(--accent) var(--vol, 80%),var(--bg-modifier-selected) var(--vol, 80%));outline:none;cursor:pointer}.vol-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.vol-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.vol-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.vol-pct{font-size:11px;color:var(--text-faint);min-width:28px;text-align:right;font-variant-numeric:tabular-nums}.party-overlay{position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;z-index:50;opacity:0;transition:opacity .3s ease}.party-overlay.active{opacity:1;animation:party-hue 2s linear infinite}.party-overlay:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(45deg,#ff00000a,#00ff000a,#0000ff0a,#ffff000a);background-size:400% 400%;animation:party-grad 3s ease infinite}@keyframes party-grad{0%{background-position:0% 50%}50%{background-position:100% 50%}to{background-position:0% 50%}}@keyframes party-hue{to{filter:hue-rotate(360deg)}}.ctx-menu{position:fixed;min-width:160px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.06);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:4px;z-index:1000;animation:ctx-in .1s ease-out}@keyframes ctx-in{0%{opacity:0;transform:scale(.96) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.ctx-item{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:4px;font-size:13px;color:var(--text-normal);cursor:pointer;transition:all var(--transition)}.ctx-item:hover{background:var(--accent);color:var(--white)}.ctx-item.danger{color:var(--red)}.ctx-item.danger:hover{background:var(--red);color:var(--white)}.ctx-item .ctx-icon{font-size:15px}.ctx-sep{height:1px;background:#ffffff0f;margin:3px 8px}.toast{position:fixed;bottom:64px;left:50%;transform:translate(-50%);padding:10px 20px;border-radius:20px;font-size:13px;font-weight:600;z-index:100;display:flex;align-items:center;gap:8px;box-shadow:var(--shadow-high);animation:toast-in .3s cubic-bezier(.175,.885,.32,1.275);pointer-events:none}.toast .toast-icon{font-size:16px}.toast.error{background:var(--red);color:#fff}.toast.info{background:var(--green);color:#fff}@keyframes toast-in{0%{transform:translate(-50%,16px);opacity:0}to{transform:translate(-50%);opacity:1}}.admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:60;display:flex;align-items:center;justify-content:center;animation:fade-in .2s ease}.admin-panel{background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius-lg);padding:28px;width:92%;max-width:920px;max-height:min(88vh,860px);display:flex;flex-direction:column;box-shadow:var(--shadow-high)}.admin-panel h3{font-size:18px;font-weight:700;margin-bottom:16px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.admin-close{width:28px;height:28px;border-radius:6px;display:flex;align-items:center;justify-content:center;color:var(--text-muted);transition:all var(--transition)}.admin-close:hover{background:var(--bg-tertiary);color:var(--text-normal)}.admin-field{margin-bottom:16px}.admin-field label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.admin-field input{width:100%;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:10px 12px;font-size:14px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-field input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.admin-btn-action{padding:10px 20px;border-radius:8px;font-size:13px;font-weight:600;font-family:var(--font);cursor:pointer;transition:all var(--transition);line-height:1}.admin-btn-action.primary{background:var(--accent);color:#fff;border:none}.admin-btn-action.primary:hover{background:var(--accent-hover)}.admin-btn-action.outline{background:transparent;border:1px solid rgba(255,255,255,.08);color:var(--text-muted)}.admin-btn-action.outline:hover{border-color:#ffffff1f;color:var(--text-normal)}.admin-btn-action.danger{background:var(--red);color:var(--white);border:1px solid var(--red)}.admin-btn-action.danger:hover{filter:brightness(1.06)}.admin-btn-action.danger.ghost{background:transparent;color:var(--red);border:1px solid rgba(242,63,66,.5)}.admin-btn-action.danger.ghost:hover{background:#f23f4224}.admin-btn-action:disabled{opacity:.5;pointer-events:none}.admin-shell{display:flex;flex-direction:column;gap:12px;min-height:0}.admin-header-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.admin-status{font-size:13px;color:var(--text-muted)}.admin-actions-inline{display:flex;align-items:center;gap:8px}.admin-search-field{margin-bottom:0}.admin-bulk-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border-radius:10px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);flex-wrap:wrap}.admin-select-all{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted)}.admin-select-all input,.admin-item-check input{accent-color:var(--accent)}.admin-list-wrap{min-height:260px;max-height:52vh;overflow-y:auto;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:var(--bg-primary)}.admin-list{display:flex;flex-direction:column;gap:6px;padding:6px}.admin-empty{padding:24px 12px;text-align:center;color:var(--text-muted);font-size:13px}.admin-item{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px;border-radius:8px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06)}.admin-item-main{min-width:0}.admin-item-name{font-size:14px;font-weight:600;color:var(--text-normal);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-meta{margin-top:3px;font-size:11px;color:var(--text-faint);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-actions{display:flex;align-items:center;gap:6px}.admin-item-actions .admin-btn-action,.admin-rename-row .admin-btn-action{padding:8px 12px;font-size:12px}.admin-rename-row{display:flex;align-items:center;gap:6px;margin-top:8px}.admin-rename-row input{flex:1;min-width:120px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:8px 10px;font-size:13px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-rename-row input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}@media(max-width:700px){.toolbar{gap:6px;padding:8px 12px}.cat-tabs{overflow-x:auto;scrollbar-width:none}.cat-tabs::-webkit-scrollbar{display:none}.search-wrap,.url-import-wrap{max-width:100%;min-width:100%;order:-1}.size-control,.theme-selector{display:none}.main{padding:12px}.topbar{padding:0 12px;gap:8px}.channel-label{max-width:100px;overflow:hidden;text-overflow:ellipsis}.clock{font-size:16px}.clock-seconds{font-size:11px}.tb-btn span:not(.tb-icon){display:none}.analytics-strip{padding:8px 12px;flex-direction:column;gap:6px}.analytics-card.analytics-wide{width:100%}.admin-panel{width:96%;padding:16px;max-height:92vh}.admin-item{grid-template-columns:24px minmax(0,1fr)}.admin-item-actions{grid-column:1 / -1;justify-content:flex-end}.admin-rename-row{flex-wrap:wrap}}@media(max-width:480px){.connection,.sb-app-title{display:none}.now-playing{max-width:none}.toolbar .tb-btn{padding:6px 8px}.url-import-btn{padding:0 8px}}.drop-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000c7;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);z-index:300;display:flex;align-items:center;justify-content:center;animation:fade-in .12s ease;pointer-events:none}.drop-zone{display:flex;flex-direction:column;align-items:center;gap:14px;padding:64px 72px;border-radius:24px;border:2.5px dashed rgba(var(--accent-rgb),.55);background:rgba(var(--accent-rgb),.07);animation:drop-pulse 2.2s ease-in-out infinite}@keyframes drop-pulse{0%,to{border-color:rgba(var(--accent-rgb),.45);box-shadow:0 0 rgba(var(--accent-rgb),0)}50%{border-color:rgba(var(--accent-rgb),.9);box-shadow:0 0 60px 12px rgba(var(--accent-rgb),.12)}}.drop-icon{font-size:64px;color:var(--accent);animation:drop-bounce 1.8s ease-in-out infinite}@keyframes drop-bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-8px)}}.drop-title{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:-.3px}.drop-sub{font-size:13px;color:var(--text-muted)}.upload-queue{position:fixed;bottom:24px;right:24px;width:340px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.09);border-radius:14px;box-shadow:0 8px 40px #00000073;z-index:200;animation:slide-up .2s cubic-bezier(.16,1,.3,1)}@keyframes slide-up{0%{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}.uq-header{display:flex;align-items:center;gap:8px;padding:12px 14px;background:rgba(var(--accent-rgb),.12);border-bottom:1px solid rgba(255,255,255,.06);font-size:13px;font-weight:600;color:var(--text-normal)}.uq-header .material-icons{color:var(--accent)}.uq-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition),color var(--transition)}.uq-close:hover{background:#ffffff24;color:var(--text-normal)}.uq-list{display:flex;flex-direction:column;max-height:260px;overflow-y:auto;padding:6px 0}.uq-item{display:grid;grid-template-columns:20px 1fr auto 18px;align-items:center;gap:8px;padding:8px 14px;position:relative}.uq-item+.uq-item{border-top:1px solid rgba(255,255,255,.04)}.uq-file-icon{font-size:18px;color:var(--text-faint)}.uq-info{min-width:0}.uq-name{font-size:12px;font-weight:500;color:var(--text-normal);white-space:nowrap;text-overflow:ellipsis}.uq-size{font-size:10px;color:var(--text-faint);margin-top:1px}.uq-progress-wrap{grid-column:1 / -1;height:3px;background:#ffffff12;border-radius:2px;margin-top:4px}.uq-item{flex-wrap:wrap}.uq-progress-wrap{width:100%;order:10}.uq-progress-bar{height:100%;background:var(--accent);border-radius:2px;transition:width .12s ease}.uq-status-icon{font-size:16px}.uq-status-waiting .uq-status-icon{color:var(--text-faint)}.uq-status-uploading .uq-status-icon{color:var(--accent);animation:spin 1s linear infinite}.uq-status-done .uq-status-icon{color:var(--green)}.uq-status-error .uq-status-icon{color:var(--red)}.uq-error{grid-column:2 / -1;font-size:10px;color:var(--red);margin-top:2px}.dl-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;display:flex;align-items:center;justify-content:center;z-index:300;animation:fade-in .15s ease}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.dl-modal{width:420px;max-width:92vw;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.1);border-radius:16px;box-shadow:0 12px 60px #00000080;animation:scale-in .2s cubic-bezier(.16,1,.3,1)}@keyframes scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.dl-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.06);font-size:14px;font-weight:700;color:var(--text-normal)}.dl-modal-header .material-icons{color:var(--accent)}.dl-modal-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition)}.dl-modal-close:hover{background:#ffffff24;color:var(--text-normal)}.dl-modal-body{padding:16px;display:flex;flex-direction:column;gap:14px}.dl-modal-url{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:8px;background:#0003;overflow:hidden}.dl-modal-tag{flex-shrink:0;padding:2px 8px;border-radius:6px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.dl-modal-tag.youtube{background:#ff00002e;color:#f44}.dl-modal-tag.instagram{background:#e1306c2e;color:#e1306c}.dl-modal-tag.mp3{background:#2ecc712e;color:#2ecc71}.dl-modal-url-text{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-modal-field{display:flex;flex-direction:column;gap:5px}.dl-modal-label{font-size:11px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.dl-modal-input-wrap{display:flex;align-items:center;border:1px solid rgba(255,255,255,.1);border-radius:8px;background:#00000026;overflow:hidden;transition:border-color var(--transition)}.dl-modal-input-wrap:focus-within{border-color:var(--accent)}.dl-modal-input{flex:1;border:none;background:transparent;padding:8px 10px;color:var(--text-normal);font-size:13px;font-family:var(--font);outline:none}.dl-modal-input::placeholder{color:var(--text-faint)}.dl-modal-ext{padding:0 10px;font-size:12px;font-weight:600;color:var(--text-faint);background:#ffffff0a;align-self:stretch;display:flex;align-items:center}.dl-modal-hint{font-size:10px;color:var(--text-faint)}.dl-modal-progress{display:flex;align-items:center;gap:12px;padding:20px 0;justify-content:center;font-size:13px;color:var(--text-muted)}.dl-modal-spinner{width:24px;height:24px;border-radius:50%;border:3px solid rgba(var(--accent-rgb),.2);border-top-color:var(--accent);animation:spin .8s linear infinite}.dl-modal-success{display:flex;align-items:center;gap:10px;padding:16px 0;justify-content:center;font-size:13px;color:var(--text-normal)}.dl-modal-check{color:#2ecc71;font-size:28px}.dl-modal-error{display:flex;align-items:center;gap:10px;padding:12px 0;justify-content:center;font-size:13px;color:#e74c3c}.dl-modal-actions{display:flex;justify-content:flex-end;gap:8px;padding:0 16px 14px}.dl-modal-cancel{padding:7px 14px;border-radius:8px;border:1px solid rgba(255,255,255,.1);background:transparent;color:var(--text-muted);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition)}.dl-modal-cancel:hover{background:#ffffff0f;color:var(--text-normal)}.dl-modal-submit{display:flex;align-items:center;gap:5px;padding:7px 16px;border-radius:8px;border:none;background:var(--accent);color:#fff;font-size:12px;font-weight:700;cursor:pointer;transition:filter var(--transition)}.dl-modal-submit:hover{filter:brightness(1.15)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.lol-container{max-width:920px;margin:0 auto;padding:16px;height:100%;overflow-y:auto}.lol-search{display:flex;gap:8px;margin-bottom:12px}.lol-search-input{flex:1;min-width:0;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:15px;outline:none;transition:border-color .2s}.lol-search-input:focus{border-color:var(--accent)}.lol-search-input::placeholder{color:var(--text-faint)}.lol-search-region{padding:10px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none}.lol-search-btn{padding:10px 20px;border:none;border-radius:8px;background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:opacity .2s;white-space:nowrap}.lol-search-btn:hover{opacity:.85}.lol-search-btn:disabled{opacity:.4;cursor:not-allowed}.lol-recent{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:16px}.lol-recent-chip{display:flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;cursor:pointer;transition:border-color .2s,color .2s}.lol-recent-chip:hover{border-color:var(--accent);color:var(--text-normal)}.lol-recent-chip img{width:18px;height:18px;border-radius:50%}.lol-recent-tier{font-size:10px;font-weight:600;opacity:.7;text-transform:uppercase}.lol-profile{display:flex;align-items:center;gap:16px;padding:16px;border-radius:12px;background:var(--bg-secondary);margin-bottom:12px}.lol-profile-icon{width:72px;height:72px;border-radius:12px;border:2px solid var(--bg-tertiary);object-fit:cover}.lol-profile-info h2{margin:0 0 2px;font-size:20px;color:var(--text-normal)}.lol-profile-info h2 span{color:var(--text-faint);font-weight:400;font-size:14px}.lol-profile-level{font-size:12px;color:var(--text-muted)}.lol-profile-ladder{font-size:11px;color:var(--text-faint)}.lol-profile-updated{font-size:10px;color:var(--text-faint);margin-top:2px}.lol-profile-info{flex:1;min-width:0}.lol-update-btn{display:flex;align-items:center;gap:6px;padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-primary);color:var(--text-muted);font-size:13px;font-weight:500;cursor:pointer;transition:border-color .2s,color .2s,background .2s;white-space:nowrap;flex-shrink:0}.lol-update-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-update-btn:disabled{opacity:.6;cursor:not-allowed}.lol-update-btn.renewing{border-color:var(--accent);color:var(--accent)}.lol-update-icon{font-size:16px;display:inline-block}.lol-update-btn.renewing .lol-update-icon{animation:lol-spin 1s linear infinite}.lol-ranked-row{display:flex;gap:10px;margin-bottom:12px}.lol-ranked-card{flex:1;padding:12px 14px;border-radius:10px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary)}.lol-ranked-card.has-rank{border-left-color:var(--tier-color, var(--accent))}.lol-ranked-type{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}.lol-ranked-tier{font-size:18px;font-weight:700;color:var(--tier-color, var(--text-normal))}.lol-ranked-lp{font-size:13px;color:var(--text-muted);margin-left:4px;font-weight:400}.lol-ranked-record{font-size:12px;color:var(--text-muted);margin-top:2px}.lol-ranked-wr{color:var(--text-faint);margin-left:4px}.lol-ranked-streak{color:#e74c3c;font-size:11px;margin-left:4px}.lol-section-title{font-size:13px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;margin:16px 0 8px;padding-left:2px}.lol-champs{display:flex;gap:8px;margin-bottom:12px;overflow-x:auto;padding-bottom:4px}.lol-champ-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:8px;background:var(--bg-secondary);min-width:180px;flex-shrink:0}.lol-champ-icon{width:36px;height:36px;border-radius:50%;object-fit:cover}.lol-champ-name{font-size:13px;font-weight:600;color:var(--text-normal)}.lol-champ-stats{font-size:11px;color:var(--text-muted)}.lol-champ-kda{font-size:11px;color:var(--text-faint)}.lol-matches{display:flex;flex-direction:column;gap:6px}.lol-match{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary);cursor:pointer;transition:background .15s}.lol-match:hover{background:var(--bg-tertiary)}.lol-match.win{border-left-color:#2ecc71}.lol-match.loss{border-left-color:#e74c3c}.lol-match-result{width:28px;font-size:11px;font-weight:700;text-align:center;flex-shrink:0}.lol-match.win .lol-match-result{color:#2ecc71}.lol-match.loss .lol-match-result{color:#e74c3c}.lol-match-champ{position:relative;flex-shrink:0}.lol-match-champ img{width:40px;height:40px;border-radius:50%;display:block}.lol-match-champ-level{position:absolute;bottom:-2px;right:-2px;background:var(--bg-deep);color:var(--text-muted);font-size:9px;font-weight:700;width:16px;height:16px;border-radius:50%;display:flex;align-items:center;justify-content:center}.lol-match-kda{min-width:80px;text-align:center;flex-shrink:0}.lol-match-kda-nums{font-size:14px;font-weight:600;color:var(--text-normal)}.lol-match-kda-ratio{font-size:11px;color:var(--text-faint)}.lol-match-kda-ratio.perfect{color:#f39c12}.lol-match-kda-ratio.great{color:#2ecc71}.lol-match-stats{display:flex;flex-direction:column;gap:1px;min-width:70px;flex-shrink:0}.lol-match-stats span{font-size:11px;color:var(--text-muted)}.lol-match-items{display:flex;gap:2px;flex-shrink:0}.lol-match-items img,.lol-match-item-empty{width:24px;height:24px;border-radius:4px;background:var(--bg-deep)}.lol-match-meta{margin-left:auto;text-align:right;flex-shrink:0}.lol-match-duration{font-size:12px;color:var(--text-muted)}.lol-match-queue,.lol-match-ago{font-size:10px;color:var(--text-faint)}.lol-match-detail{background:var(--bg-primary);border-radius:8px;padding:8px;margin-top:4px;margin-bottom:4px}.lol-match-detail-team{margin-bottom:6px}.lol-match-detail-team-header{font-size:11px;font-weight:600;padding:4px 8px;border-radius:4px;margin-bottom:4px}.lol-match-detail-team-header.win{background:#2ecc7126;color:#2ecc71}.lol-match-detail-team-header.loss{background:#e74c3c26;color:#e74c3c}.lol-detail-row{display:flex;align-items:center;gap:8px;padding:3px 8px;border-radius:4px;font-size:12px;color:var(--text-muted)}.lol-detail-row:hover{background:var(--bg-secondary)}.lol-detail-row.me{background:#ffffff0a;font-weight:600}.lol-detail-champ{width:24px;height:24px;border-radius:50%}.lol-detail-name{width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-normal)}.lol-detail-kda{width:70px;text-align:center}.lol-detail-cs{width:45px;text-align:center}.lol-detail-dmg,.lol-detail-gold{width:55px;text-align:center}.lol-detail-items{display:flex;gap:1px}.lol-detail-items img{width:20px;height:20px;border-radius:3px}.lol-loading{display:flex;align-items:center;justify-content:center;gap:10px;padding:40px;color:var(--text-muted);font-size:14px}.lol-spinner{width:20px;height:20px;border:2px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:lol-spin .8s linear infinite}@keyframes lol-spin{to{transform:rotate(360deg)}}.lol-error{padding:16px;border-radius:8px;background:#e74c3c1a;color:#e74c3c;font-size:13px;text-align:center;margin-bottom:12px}.lol-empty{text-align:center;padding:60px 20px;color:var(--text-faint)}.lol-empty-icon{font-size:48px;margin-bottom:12px}.lol-empty h3{margin:0 0 8px;color:var(--text-muted);font-size:16px}.lol-empty p{margin:0;font-size:13px}.lol-load-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--bg-tertiary);border-radius:8px;background:transparent;color:var(--text-muted);font-size:13px;cursor:pointer;transition:border-color .2s,color .2s}.lol-load-more:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-section{margin-top:24px;padding-top:16px;border-top:1px solid var(--bg-tertiary)}.lol-tier-controls{display:flex;gap:8px;align-items:center;margin-bottom:12px;flex-wrap:wrap}.lol-tier-modes{display:flex;gap:4px;flex-wrap:wrap}.lol-tier-mode-btn{padding:6px 14px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;font-weight:500;cursor:pointer;transition:all .2s;white-space:nowrap}.lol-tier-mode-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-mode-btn.active{background:var(--accent);border-color:var(--accent);color:#fff}.lol-tier-filter{padding:6px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:12px;outline:none;width:140px;margin-left:auto}.lol-tier-filter:focus{border-color:var(--accent)}.lol-tier-filter::placeholder{color:var(--text-faint)}.lol-tier-table{display:flex;flex-direction:column;gap:2px}.lol-tier-header{display:flex;align-items:center;gap:8px;padding:6px 10px;font-size:10px;font-weight:600;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px}.lol-tier-row{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:6px;background:var(--bg-secondary);font-size:13px;color:var(--text-muted);transition:background .15s}.lol-tier-row:hover{background:var(--bg-tertiary)}.lol-tier-row.tier-0{border-left:3px solid #f4c874}.lol-tier-row.tier-1{border-left:3px solid #d4a017}.lol-tier-row.tier-2{border-left:3px solid #576cce}.lol-tier-row.tier-3{border-left:3px solid #28b29e}.lol-tier-row.tier-4{border-left:3px solid var(--bg-tertiary)}.lol-tier-row.tier-5{border-left:3px solid var(--bg-tertiary);opacity:.7}.lol-tier-col-rank{width:32px;text-align:center;font-weight:600;flex-shrink:0}.lol-tier-col-champ{flex:1;display:flex;align-items:center;gap:8px;min-width:0;font-weight:500;color:var(--text-normal)}.lol-tier-col-champ img{width:28px;height:28px;border-radius:50%;flex-shrink:0}.lol-tier-col-tier{width:36px;text-align:center;font-weight:700;font-size:12px;flex-shrink:0}.lol-tier-col-wr,.lol-tier-col-pr,.lol-tier-col-br{width:60px;text-align:center;flex-shrink:0}.lol-tier-col-kda{width:50px;text-align:center;flex-shrink:0}.tier-badge-0{color:#f4c874}.tier-badge-1{color:#d4a017}.tier-badge-2{color:#576cce}.tier-badge-3{color:#28b29e}.tier-badge-4,.tier-badge-5{color:var(--text-faint)}@media(max-width:640px){.lol-search{flex-wrap:wrap}.lol-search-input{width:100%}.lol-match{flex-wrap:wrap;gap:6px}.lol-match-meta{margin-left:0;text-align:left}.lol-match-items,.lol-profile{flex-wrap:wrap}.lol-tier-controls{flex-direction:column;align-items:stretch}.lol-tier-filter{width:100%;margin-left:0}.lol-tier-col-br,.lol-tier-col-kda{display:none}}.stream-container{height:100%;overflow-y:auto;padding:16px}.stream-topbar{display:flex;align-items:flex-end;gap:10px;margin-bottom:16px;flex-wrap:wrap}.stream-field{display:flex;flex-direction:column;gap:4px}.stream-field-grow{flex:1;min-width:180px}.stream-field-label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:var(--text-faint);padding-left:2px}.stream-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0;width:100%;box-sizing:border-box}.stream-input:focus{border-color:var(--accent)}.stream-input::placeholder{color:var(--text-faint)}.stream-input-name{width:150px}.stream-input-title{width:100%}.stream-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.stream-btn:hover{background:var(--accent-hover)}.stream-btn:disabled{opacity:.5;cursor:not-allowed}.stream-btn-stop{background:var(--danger)}.stream-btn-stop:hover{background:#c93b3e}.stream-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.stream-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.stream-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.stream-tile.own{border:2px solid var(--accent)}.stream-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.stream-tile-preview video{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover}.stream-tile-preview .stream-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.stream-live-badge{position:absolute;top:8px;left:8px;background:var(--danger);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;letter-spacing:.5px;display:flex;align-items:center;gap:4px}.stream-live-dot{width:6px;height:6px;border-radius:50%;background:#fff;animation:stream-pulse 1.5s ease-in-out infinite}@keyframes stream-pulse{0%,to{opacity:1}50%{opacity:.3}}.stream-tile-viewers{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.stream-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.stream-tile-meta{min-width:0;flex:1}.stream-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-title{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-time{font-size:12px;color:var(--text-faint);white-space:nowrap}.stream-tile-menu-wrap{position:relative}.stream-tile-menu{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 6px;font-size:18px;line-height:1;border-radius:4px;transition:background var(--transition)}.stream-tile-menu:hover{background:var(--bg-tertiary);color:var(--text-normal)}.stream-tile-dropdown{position:absolute;bottom:calc(100% + 6px);right:0;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius-lg);min-width:220px;z-index:100;box-shadow:0 8px 24px #0006;overflow:hidden}.stream-tile-dropdown-header{padding:12px 14px}.stream-tile-dropdown-name{font-size:14px;font-weight:600;color:var(--text-normal)}.stream-tile-dropdown-title{font-size:12px;color:var(--text-muted);margin-top:2px}.stream-tile-dropdown-detail{font-size:11px;color:var(--text-faint);margin-top:6px}.stream-tile-dropdown-divider{height:1px;background:var(--bg-tertiary)}.stream-tile-dropdown-item{display:flex;align-items:center;gap:8px;width:100%;padding:10px 14px;border:none;background:none;color:var(--text-normal);font-size:13px;cursor:pointer;text-align:left;transition:background var(--transition)}.stream-tile-dropdown-item:hover{background:var(--bg-tertiary)}.stream-viewer-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.stream-viewer-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1}.stream-viewer-header-left{display:flex;align-items:center;gap:12px}.stream-viewer-title{font-weight:600;font-size:16px}.stream-viewer-subtitle{font-size:13px;color:var(--text-muted)}.stream-viewer-header-right{display:flex;align-items:center;gap:8px}.stream-viewer-fullscreen{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.stream-viewer-fullscreen:hover{background:#ffffff40}.stream-viewer-close{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.stream-viewer-close:hover{background:#fff3}.stream-viewer-video{flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden}.stream-viewer-video video{max-width:100%;max-height:100%;width:100%;height:100%;object-fit:contain}.stream-viewer-connecting{color:var(--text-muted);font-size:16px;display:flex;flex-direction:column;align-items:center;gap:12px}.stream-viewer-spinner{width:32px;height:32px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:stream-spin .8s linear infinite}@keyframes stream-spin{to{transform:rotate(360deg)}}.stream-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.stream-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.stream-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.stream-empty p{font-size:14px}.stream-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.stream-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.stream-tile.broadcasting .stream-tile-preview{border:2px solid var(--danger);border-bottom:none}.stream-input-password{width:180px}.stream-select-quality{width:210px;box-sizing:border-box;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none;transition:border-color var(--transition)}.stream-select-quality:focus{border-color:var(--accent)}.stream-select-quality:disabled{opacity:.5;cursor:not-allowed}.stream-select-quality option{background:var(--bg-secondary);color:var(--text-normal)}.stream-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.stream-pw-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.stream-pw-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.stream-pw-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.stream-pw-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.stream-pw-modal .stream-input{width:100%;margin-bottom:12px}.stream-pw-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.stream-pw-actions{display:flex;gap:8px;justify-content:flex-end}.stream-pw-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.stream-pw-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.stream-admin-btn{margin-left:auto;padding:8px;border:none;border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:18px;cursor:pointer;transition:all var(--transition);line-height:1}.stream-admin-btn:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;display:flex;align-items:center;justify-content:center;z-index:999;animation:fadeIn .15s ease}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.stream-admin-panel{background:var(--bg-secondary);border-radius:12px;width:560px;max-width:95vw;max-height:80vh;display:flex;flex-direction:column;box-shadow:0 8px 32px #0006;overflow:hidden}.stream-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-header h3{margin:0;font-size:16px;color:var(--text-normal)}.stream-admin-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:var(--radius)}.stream-admin-close:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-login{padding:24px 20px}.stream-admin-login p{margin:0 0 12px;color:var(--text-muted);font-size:14px}.stream-admin-login-row{display:flex;gap:8px}.stream-admin-login-row .stream-input{flex:1}.stream-admin-error{color:#ed4245;font-size:13px;margin-top:8px}.stream-admin-content{padding:16px 20px;overflow-y:auto}.stream-admin-toolbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;padding-bottom:12px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-status{font-size:13px;color:var(--text-muted)}.stream-admin-status b{color:var(--text-normal)}.stream-admin-logout{padding:4px 12px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:12px;cursor:pointer}.stream-admin-logout:hover{color:#ed4245;border-color:#ed4245}.stream-admin-loading,.stream-admin-empty{text-align:center;padding:32px 16px;color:var(--text-muted);font-size:14px}.stream-admin-hint{margin:0 0 12px;color:var(--text-muted);font-size:13px}.stream-admin-channel-list{display:flex;flex-direction:column;gap:8px;max-height:45vh;overflow-y:auto}.stream-admin-channel{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:var(--bg-deep);border-radius:var(--radius);gap:12px}.stream-admin-channel-info{display:flex;flex-direction:column;gap:2px;min-width:0}.stream-admin-channel-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-admin-channel-guild{font-size:11px;color:var(--text-faint)}.stream-admin-channel-events{display:flex;gap:6px;flex-shrink:0}.stream-admin-event-toggle{display:flex;align-items:center;gap:4px;padding:4px 10px;border-radius:14px;font-size:12px;color:var(--text-muted);background:var(--bg-secondary);cursor:pointer;transition:all var(--transition);white-space:nowrap}.stream-admin-event-toggle input{display:none}.stream-admin-event-toggle:hover{color:var(--text-normal)}.stream-admin-event-toggle.active{background:var(--accent);color:#fff}.stream-admin-actions{margin-top:16px;display:flex;justify-content:flex-end}.stream-admin-save{padding:8px 24px}.wt-container{height:100%;overflow-y:auto;padding:16px}.wt-topbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}.wt-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0}.wt-input:focus{border-color:var(--accent)}.wt-input::placeholder{color:var(--text-faint)}.wt-input-name{width:150px}.wt-input-room{flex:1;min-width:180px}.wt-input-password{width:170px}.wt-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.wt-btn:hover{background:var(--accent-hover)}.wt-btn:disabled{opacity:.5;cursor:not-allowed}.wt-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.wt-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.wt-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.wt-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.wt-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.wt-tile-members{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.wt-tile-playing{position:absolute;top:8px;left:8px;background:var(--accent);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.wt-tile-meta{min-width:0;flex:1}.wt-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-tile-host{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.wt-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.wt-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.wt-empty p{font-size:14px}.wt-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.wt-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.wt-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.wt-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.wt-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.wt-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.wt-modal .wt-input{width:100%;margin-bottom:12px}.wt-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.wt-modal-actions{display:flex;gap:8px;justify-content:flex-end}.wt-modal-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.wt-modal-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.wt-room-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.wt-room-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1;flex-shrink:0}.wt-room-header-left{display:flex;align-items:center;gap:12px}.wt-room-name{font-weight:600;font-size:16px}.wt-room-members{font-size:13px;color:var(--text-muted)}.wt-host-badge{font-size:11px;background:#ffffff1a;padding:2px 8px;border-radius:4px;color:var(--accent);font-weight:600}.wt-room-header-right{display:flex;align-items:center;gap:8px}.wt-fullscreen-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.wt-fullscreen-btn:hover{background:#ffffff40}.wt-leave-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.wt-leave-btn:hover{background:#fff3}.wt-room-body{display:flex;flex:1;overflow:hidden}.wt-player-section{flex:1;display:flex;flex-direction:column;min-width:0}.wt-player-wrap{position:relative;width:100%;flex:1;background:#000;display:flex;align-items:center;justify-content:center;overflow:hidden}.wt-yt-container{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}.wt-yt-container iframe{width:100%;height:100%}.wt-video-element{width:100%;height:100%;object-fit:contain}.wt-dm-container{width:100%;height:100%;border:none;position:absolute;top:0;left:0}.wt-player-placeholder{display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--text-muted);font-size:16px}.wt-placeholder-icon{font-size:48px;opacity:.3}.wt-controls{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#000c;flex-shrink:0}.wt-ctrl-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;transition:background var(--transition);flex-shrink:0}.wt-ctrl-btn:hover:not(:disabled){background:#ffffff40}.wt-ctrl-btn:disabled{opacity:.3;cursor:not-allowed}.wt-ctrl-status{color:var(--text-muted);font-size:16px;width:36px;text-align:center;flex-shrink:0}.wt-seek{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer;min-width:60px}.wt-seek::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-webkit-slider-runnable-track{height:4px;border-radius:2px}.wt-seek::-moz-range-track{height:4px;border-radius:2px;background:var(--bg-tertiary)}.wt-seek-readonly{flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);position:relative;overflow:hidden;min-width:60px}.wt-seek-progress{position:absolute;top:0;left:0;height:100%;background:var(--accent);border-radius:2px;transition:width .3s linear}.wt-time{font-variant-numeric:tabular-nums;color:#fff;font-size:13px;white-space:nowrap;flex-shrink:0}.wt-volume{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.wt-volume-icon{font-size:16px;width:20px;text-align:center;cursor:default}.wt-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer}.wt-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-quality-select{background:var(--bg-secondary, #2a2a3e);color:var(--text-primary, #e0e0e0);border:1px solid var(--border-color, #3a3a4e);border-radius:6px;padding:2px 6px;font-size:12px;cursor:pointer;outline:none;margin-left:4px}.wt-quality-select:hover{border-color:var(--accent, #7c5cff)}.wt-queue-panel{width:280px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-queue-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-list{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-queue-list::-webkit-scrollbar{width:4px}.wt-queue-list::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-queue-empty{padding:24px 16px;text-align:center;color:var(--text-faint);font-size:13px}.wt-queue-item{padding:10px 12px;border-bottom:1px solid var(--bg-tertiary);display:flex;align-items:center;gap:8px;transition:background var(--transition)}.wt-queue-item:hover{background:var(--bg-tertiary)}.wt-queue-item.playing{border-left:3px solid var(--accent);background:#e67e2214}.wt-queue-item-info{flex:1;min-width:0}.wt-queue-item-title{font-size:13px;font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-queue-item-by{font-size:11px;color:var(--text-faint);margin-top:2px}.wt-queue-item-remove{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:18px;padding:2px 6px;border-radius:4px;transition:all var(--transition);flex-shrink:0}.wt-queue-item-remove:hover{color:var(--danger);background:#ed42451f}.wt-queue-add{padding:12px;display:flex;gap:8px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-input{flex:1;font-size:13px;padding:8px 10px}.wt-queue-add-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-player-error{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:#000000d9;color:#fff;z-index:2;text-align:center;padding:20px}.wt-error-icon{font-size:48px}.wt-player-error p{font-size:15px;color:var(--text-muted);margin:0}.wt-yt-link{display:inline-block;padding:8px 20px;background:red;color:#fff;border-radius:var(--radius);text-decoration:none;font-weight:600;font-size:14px;transition:background var(--transition)}.wt-yt-link:hover{background:#c00}.wt-skip-info{font-size:12px!important;color:var(--text-faint)!important;font-style:italic}.wt-queue-item.clickable{cursor:pointer}.wt-queue-item.clickable:hover{background:#e67e221f}@media(max-width:768px){.wt-room-body{flex-direction:column}.wt-queue-panel{width:100%;max-height:40vh;border-left:none;border-top:1px solid var(--bg-tertiary)}.wt-player-wrap{min-height:200px}.wt-controls{flex-wrap:wrap;gap:8px;padding:10px 12px}.wt-volume{margin-left:0}.wt-volume-slider{width:80px}.wt-room-header{padding:10px 12px}.wt-room-name{font-size:14px}.wt-room-members,.wt-host-badge{font-size:11px}}@media(max-width:480px){.wt-topbar{gap:8px}.wt-input-name{width:100%}.wt-input-room{min-width:0}.wt-input-password{width:100%}.wt-volume-slider{width:60px}.wt-time{font-size:12px}.wt-host-badge{display:none}}.wt-queue-item.watched{opacity:.55;transition:opacity var(--transition),background var(--transition)}.wt-queue-item.watched:hover{opacity:.85}.wt-queue-item-check{color:#2ecc71;font-size:16px;font-weight:700;flex-shrink:0;line-height:1}.wt-queue-item-info{display:flex;align-items:center;gap:10px;min-width:0;flex:1}.wt-queue-thumb{width:48px;height:36px;object-fit:cover;border-radius:4px;flex-shrink:0}.wt-queue-item-text{min-width:0;flex:1}.wt-next-btn{display:flex;align-items:center;gap:4px;font-size:13px;padding:6px 12px;white-space:nowrap}.wt-sync-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.wt-sync-synced{background:#2ecc71;box-shadow:0 0 6px #2ecc7180}.wt-sync-drifting{background:#f1c40f;box-shadow:0 0 6px #f1c40f80}.wt-sync-desynced{background:#e74c3c;box-shadow:0 0 6px #e74c3c80}.wt-vote-btn{background:#ffffff14!important;border:1px solid rgba(255,255,255,.15)!important}.wt-vote-btn:hover:not(:disabled){background:#e67e2233!important;border-color:var(--accent)!important}.wt-vote-count{font-size:12px;color:var(--accent);font-weight:600;white-space:nowrap;padding:2px 8px;background:#e67e221f;border-radius:4px}.wt-header-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:13px;transition:background var(--transition)}.wt-header-btn:hover{background:#fff3}.wt-chat-panel{width:260px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-chat-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-messages{flex:1;overflow-y:auto;padding:8px 12px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-chat-messages::-webkit-scrollbar{width:4px}.wt-chat-messages::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-chat-empty{padding:24px 8px;text-align:center;color:var(--text-faint);font-size:13px}.wt-chat-msg{margin-bottom:6px;font-size:13px;line-height:1.4;word-break:break-word}.wt-chat-sender{font-weight:600;color:var(--accent);margin-right:6px}.wt-chat-text{color:var(--text-normal)}.wt-chat-input-row{padding:10px 12px;display:flex;gap:6px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-input{flex:1;font-size:13px;padding:8px 10px}.wt-chat-send-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-queue-header{display:flex;align-items:center;justify-content:space-between}.wt-queue-clear-btn{background:none;border:none;color:var(--text-faint);font-size:11px;cursor:pointer;padding:2px 6px;border-radius:4px;transition:all var(--transition)}.wt-queue-clear-btn:hover{color:var(--danger);background:#ed42451f}.wt-tile-members-list{font-size:11px;color:var(--text-faint);padding:0 12px 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:768px){.wt-chat-panel{width:100%;max-height:30vh;border-left:none;border-top:1px solid var(--bg-tertiary)}}.gl-container{padding:20px;max-width:1200px;margin:0 auto}.gl-login-bar{display:flex;gap:10px;margin-bottom:12px}.gl-connect-btn{color:#c7d5e0;padding:10px 20px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:all var(--transition);white-space:nowrap}.gl-steam-btn{background:#1b2838;border:1px solid #2a475e}.gl-steam-btn:hover{background:#2a475e;color:#fff}.gl-gog-btn{background:#2c1a4e;border:1px solid #4a2d7a;color:#c7b3e8}.gl-gog-btn:hover{background:#3d2566;color:#fff}.gl-profile-chips{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}.gl-profile-chip{display:flex;align-items:center;gap:8px;padding:6px 12px;border-radius:20px;background:#ffffff0d;border:1px solid rgba(255,255,255,.1);cursor:pointer;transition:all .2s}.gl-profile-chip.selected{border-color:#e67e22;background:#e67e221a}.gl-profile-chip:hover{background:#ffffff1a}.gl-profile-chip-avatar{width:28px;height:28px;border-radius:50%}.gl-profile-chip-info{display:flex;flex-direction:column;gap:2px}.gl-profile-chip-name{font-size:13px;font-weight:600;color:#e0e0e0}.gl-profile-chip-platforms{display:flex;gap:4px}.gl-profile-chip-count{font-size:11px;color:#667}.gl-platform-badge{font-size:9px;font-weight:700;padding:1px 5px;border-radius:3px;text-transform:uppercase}.gl-platform-badge.steam{background:#1b2838cc;color:#66c0f4;border:1px solid #2a475e}.gl-platform-badge.gog{background:#2c1a4ecc;color:#b388ff;border:1px solid #4a2d7a}.gl-game-platform-icon{font-size:9px;font-weight:700;padding:1px 4px;border-radius:3px;margin-right:6px;flex-shrink:0}.gl-game-platform-icon.steam{background:#1b283899;color:#66c0f4}.gl-game-platform-icon.gog{background:#2c1a4e99;color:#b388ff}.gl-users-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;margin-bottom:32px}.gl-user-card{background:var(--bg-secondary);border-radius:var(--radius);padding:16px;display:flex;flex-direction:column;align-items:center;gap:10px;cursor:pointer;transition:all var(--transition);border:1px solid var(--bg-tertiary)}.gl-user-card:hover{border-color:var(--accent);transform:translateY(-2px)}.gl-user-card-avatar{width:64px;height:64px;border-radius:50%}.gl-user-card-name{font-weight:600;font-size:15px;color:var(--text-normal)}.gl-user-card-games{font-size:13px;color:var(--text-faint)}.gl-user-card-updated{font-size:11px;color:var(--text-faint)}.gl-profile-card-platforms{display:flex;gap:6px;margin-top:4px}.gl-common-finder{background:var(--bg-secondary);border-radius:var(--radius);padding:20px;margin-bottom:24px}.gl-common-finder h3{margin:0 0 12px;font-size:15px;color:var(--text-normal)}.gl-common-users{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}.gl-common-check{display:flex;align-items:center;gap:6px;background:var(--bg-tertiary);padding:6px 12px 6px 6px;border-radius:20px;cursor:pointer;transition:all var(--transition)}.gl-common-check.checked{background:#e67e2226}.gl-common-check input{accent-color:var(--accent)}.gl-common-check-avatar{width:24px;height:24px;border-radius:50%}.gl-common-find-btn{background:var(--accent);color:#fff;border:none;padding:10px 24px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:background var(--transition)}.gl-common-find-btn:hover{filter:brightness(1.1)}.gl-common-find-btn:disabled{opacity:.5;cursor:not-allowed}.gl-search{margin-bottom:24px}.gl-search-input{width:100%;padding:10px 14px;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);box-sizing:border-box}.gl-search-input:focus{border-color:var(--accent)}.gl-search-input::placeholder{color:var(--text-faint)}.gl-game-list{display:flex;flex-direction:column;gap:4px}.gl-game-item{display:flex;align-items:center;gap:12px;padding:8px 12px;background:var(--bg-secondary);border-radius:var(--radius);transition:background var(--transition)}.gl-game-item:hover{background:var(--bg-tertiary)}.gl-game-icon{width:32px;height:32px;border-radius:4px;flex-shrink:0;background:var(--bg-tertiary)}.gl-game-name{flex:1;font-size:14px;color:var(--text-normal)}.gl-game-playtime{font-size:12px;color:var(--text-faint);white-space:nowrap}.gl-game-owners{display:flex;gap:4px}.gl-game-owner-avatar{width:20px;height:20px;border-radius:50%;border:1px solid var(--bg-tertiary)}.gl-detail-header{display:flex;align-items:center;gap:16px;margin-bottom:24px}.gl-back-btn{background:var(--bg-secondary);border:none;color:var(--text-normal);padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.gl-back-btn:hover{background:var(--bg-tertiary)}.gl-detail-avatar{width:48px;height:48px;border-radius:50%}.gl-detail-info{flex:1}.gl-detail-name{font-size:18px;font-weight:600;color:var(--text-normal)}.gl-detail-sub{font-size:13px;color:var(--text-faint);display:flex;align-items:center;gap:6px;margin-top:4px}.gl-refresh-btn{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:16px;padding:4px;transition:color var(--transition)}.gl-refresh-btn:hover{color:var(--accent)}.gl-platform-detail{display:inline-flex;align-items:center;gap:2px}.gl-disconnect-btn{background:none;border:none;color:#666;cursor:pointer;font-size:10px;padding:0 3px;line-height:1;border-radius:3px;transition:all .2s}.gl-disconnect-btn:hover{color:#e74c3c;background:#e74c3c26}.gl-link-gog-btn{background:#a855f726;color:#a855f7;border:1px solid rgba(168,85,247,.3);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-link-gog-btn:hover{background:#a855f740}.gl-loading{text-align:center;padding:48px;color:var(--text-faint);font-size:14px}.gl-empty{text-align:center;padding:60px 20px}.gl-empty-icon{font-size:48px;margin-bottom:16px}.gl-empty h3{color:var(--text-normal);margin:0 0 8px}.gl-empty p{color:var(--text-faint);margin:0;font-size:14px}.gl-common-playtimes{display:flex;gap:8px;flex-wrap:wrap}.gl-common-pt{font-size:11px;color:var(--text-faint);background:var(--bg-tertiary);padding:2px 8px;border-radius:4px}.gl-section-title{font-size:14px;font-weight:600;color:var(--text-normal);margin:0 0 12px}.gl-game-count{font-size:12px;color:var(--text-faint);margin-left:8px;font-weight:400}.gl-detail-avatars{display:flex;gap:-8px}.gl-detail-avatars img{width:36px;height:36px;border-radius:50%;border:2px solid var(--bg-primary);margin-left:-8px}.gl-detail-avatars img:first-child{margin-left:0}.gl-search-results-title{font-size:13px;color:var(--text-faint);margin-bottom:8px}.gl-game-item.enriched{align-items:flex-start;min-height:60px}.gl-game-visual{flex-shrink:0}.gl-game-cover{width:45px;height:64px;object-fit:cover;border-radius:4px}.gl-game-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.gl-game-genres{display:flex;flex-wrap:wrap;gap:4px}.gl-genre-tag{font-size:10px;padding:1px 6px;border-radius:3px;background:#e67e2226;color:#e67e22}.gl-game-platforms{font-size:10px;color:var(--text-muted, #888)}.gl-platform-tag{margin-left:4px;padding:1px 5px;border-radius:3px;background:#3498db26;color:#3498db}.gl-game-meta{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}.gl-game-rating{font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;min-width:28px;text-align:center}.gl-game-rating.high{background:#2ecc7133;color:#2ecc71}.gl-game-rating.mid{background:#f1c40f33;color:#f1c40f}.gl-game-rating.low{background:#e74c3c33;color:#e74c3c}.gl-enrich-btn{background:#3498db26;border:1px solid rgba(52,152,219,.3);color:#3498db;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-enrich-btn:hover:not(:disabled){background:#3498db40}.gl-enrich-btn:disabled{opacity:.5;cursor:not-allowed}.gl-enrich-btn.enriching{animation:gl-pulse 1.5s ease-in-out infinite}@keyframes gl-pulse{0%,to{opacity:.5}50%{opacity:1}}.gl-filter-bar{display:flex;align-items:center;gap:10px;margin-bottom:8px}.gl-filter-bar .gl-search-input{flex:1}.gl-sort-select{background:#ffffff0f;color:#c7d5e0;border:1px solid rgba(255,255,255,.1);padding:10px 12px;border-radius:var(--radius);font-size:13px;cursor:pointer;min-width:120px}.gl-sort-select:focus{outline:none;border-color:#ffffff40}.gl-sort-select option{background:#1a1a2e;color:#c7d5e0}.gl-genre-filters{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px;padding:8px 0}.gl-genre-chip{background:#ffffff0f;color:#8899a6;border:1px solid rgba(255,255,255,.08);padding:5px 12px;border-radius:20px;font-size:12px;cursor:pointer;transition:all .2s;white-space:nowrap}.gl-genre-chip:hover{background:#ffffff1a;color:#c7d5e0}.gl-genre-chip.active{background:#e67e2233;color:#e67e22;border-color:#e67e2266}.gl-genre-chip.active.clear{background:#3498db33;color:#3498db;border-color:#3498db66}.gl-filter-count{color:#556;font-size:12px;margin:0 0 8px}@media(max-width:768px){.gl-container{padding:12px}.gl-users-grid{grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}.gl-login-bar{flex-direction:column}}.gl-dialog-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;display:flex;align-items:center;justify-content:center;z-index:1000;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.gl-dialog{background:#2a2a3e;border-radius:12px;padding:24px;max-width:500px;width:90%;box-shadow:0 8px 32px #00000080}.gl-dialog h3{margin:0 0 12px;font-size:1.2rem;color:#fff}.gl-dialog-hint{font-size:.85rem;color:#aaa;margin-bottom:14px;line-height:1.5}.gl-dialog-input{width:100%;padding:10px 12px;background:#1a1a2e;border:1px solid #444;border-radius:8px;color:#fff;font-size:.9rem;outline:none;transition:border-color .2s}.gl-dialog-input:focus{border-color:#a855f7}.gl-dialog-status{margin-top:8px;font-size:.85rem;padding:6px 10px;border-radius:6px}.gl-dialog-status.loading{color:#a855f7}.gl-dialog-status.success{color:#4caf50}.gl-dialog-status.error{color:#e74c3c}.gl-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.gl-dialog-cancel{padding:8px 18px;background:#3a3a4e;color:#ccc;border:none;border-radius:8px;cursor:pointer;font-size:.9rem}.gl-dialog-cancel:hover{background:#4a4a5e}.gl-dialog-submit{padding:8px 18px;background:#a855f7;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:.9rem;font-weight:600}.gl-dialog-submit:hover:not(:disabled){background:#9333ea}.gl-dialog-submit:disabled{opacity:.5;cursor:not-allowed}.gl-login-bar-spacer{flex:1}.gl-admin-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#888;padding:8px 12px;border-radius:var(--radius);cursor:pointer;font-size:16px;transition:all .2s}.gl-admin-btn:hover{background:#ffffff1a;color:#ccc}.gl-admin-panel{background:#2a2a3e;border-radius:12px;padding:0;max-width:600px;width:92%;box-shadow:0 8px 32px #00000080;max-height:80vh;display:flex;flex-direction:column}.gl-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid rgba(255,255,255,.08)}.gl-admin-header h3{margin:0;font-size:1.1rem;color:#fff}.gl-admin-close{background:none;border:none;color:#888;font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px}.gl-admin-close:hover{color:#fff;background:#ffffff1a}.gl-admin-login{padding:20px}.gl-admin-login p{color:#aaa;margin:0 0 12px;font-size:14px}.gl-admin-login-row{display:flex;gap:8px}.gl-admin-login-btn{background:#e67e22;color:#fff;border:none;padding:10px 20px;border-radius:8px;cursor:pointer;font-weight:600;white-space:nowrap}.gl-admin-login-btn:hover{background:#d35400}.gl-admin-content{padding:0;overflow-y:auto}.gl-admin-toolbar{display:flex;align-items:center;gap:10px;padding:12px 20px;border-bottom:1px solid rgba(255,255,255,.06)}.gl-admin-status-text{font-size:13px;color:#4caf50;flex:1}.gl-admin-refresh-btn,.gl-admin-logout-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#aaa;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;transition:all .2s}.gl-admin-refresh-btn:hover{background:#ffffff1a;color:#fff}.gl-admin-logout-btn:hover{background:#e74c3c26;color:#e74c3c;border-color:#e74c3c4d}.gl-admin-list{padding:8px 12px}.gl-admin-item{display:flex;align-items:center;gap:12px;padding:10px 8px;border-bottom:1px solid rgba(255,255,255,.04);transition:background .15s}.gl-admin-item:last-child{border-bottom:none}.gl-admin-item:hover{background:#ffffff08}.gl-admin-item-avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0}.gl-admin-item-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.gl-admin-item-name{font-size:14px;font-weight:600;color:#e0e0e0}.gl-admin-item-details{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.gl-admin-item-total{font-size:11px;color:#667}.gl-admin-delete-btn{background:#e74c3c1a;color:#e74c3c;border:1px solid rgba(231,76,60,.2);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;white-space:nowrap;transition:all .2s;flex-shrink:0}.gl-admin-delete-btn:hover{background:#e74c3c40;border-color:#e74c3c66}:root{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--success: #57d28f;--danger: #ed4245;--warning: #fee75c;--border: rgba(255, 255, 255, .06);--radius: 8px;--radius-lg: 12px;--transition: .15s ease;--font: "Segoe UI", system-ui, -apple-system, sans-serif;--header-height: 56px}*,*:before,*:after{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;font-family:var(--font);font-size:15px;color:var(--text-normal);background:var(--bg-deep);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;overflow:hidden}#root{height:100%}.hub-app{display:flex;flex-direction:column;height:100vh;overflow:hidden}.hub-header{position:sticky;top:0;z-index:100;display:flex;align-items:center;height:var(--header-height);min-height:var(--header-height);padding:0 16px;background:var(--bg-primary);border-bottom:1px solid var(--border);gap:16px}.hub-header-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.hub-logo{font-size:24px;line-height:1}.hub-title{font-size:18px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em;white-space:nowrap}.hub-conn-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);flex-shrink:0;transition:background var(--transition);box-shadow:0 0 0 2px #ed424540}.hub-conn-dot.online{background:var(--success);box-shadow:0 0 0 2px #57d28f40;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 0 2px #57d28f40}50%{box-shadow:0 0 0 6px #57d28f1a}}.hub-tabs{display:flex;align-items:center;gap:4px;flex:1;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;padding:0 4px}.hub-tabs::-webkit-scrollbar{display:none}.hub-tab{display:flex;align-items:center;gap:6px;padding:8px 14px;border:none;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:var(--radius);white-space:nowrap;transition:all var(--transition);position:relative;-webkit-user-select:none;user-select:none}.hub-tab:hover{color:var(--text-normal);background:var(--bg-secondary)}.hub-tab.active{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-tab.active:after{content:"";position:absolute;bottom:-1px;left:50%;transform:translate(-50%);width:calc(100% - 16px);height:2px;background:var(--accent);border-radius:1px}.hub-tab-icon{font-size:16px;line-height:1}.hub-tab-label{text-transform:capitalize}.hub-header-right{display:flex;align-items:center;gap:12px;flex-shrink:0}.hub-download-btn{display:flex;align-items:center;gap:6px;padding:4px 10px;font-size:12px;font-weight:500;font-family:var(--font);text-decoration:none;color:var(--text-muted);background:var(--bg-secondary);border-radius:var(--radius);cursor:pointer;transition:all var(--transition);white-space:nowrap}.hub-download-btn:hover{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-download-icon{font-size:14px;line-height:1}.hub-download-label{line-height:1}.hub-version{font-size:12px;color:var(--text-faint);font-weight:500;font-variant-numeric:tabular-nums;background:var(--bg-secondary);padding:4px 8px;border-radius:4px}.hub-check-update-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-secondary);font-size:14px;padding:2px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-check-update-btn:hover:not(:disabled){color:var(--accent);border-color:var(--accent)}.hub-check-update-btn:disabled{opacity:.4;cursor:default}.hub-update-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-update-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:32px 40px;text-align:center;min-width:320px;max-width:400px;box-shadow:0 8px 32px #00000080}.hub-update-icon{font-size:40px;margin-bottom:12px}.hub-update-modal h2{margin:0 0 8px;font-size:18px;color:var(--text-primary)}.hub-update-modal p{margin:0 0 20px;font-size:14px;color:var(--text-secondary)}.hub-update-progress{height:4px;border-radius:2px;background:var(--bg-deep);overflow:hidden}.hub-update-progress-bar{height:100%;width:40%;border-radius:2px;background:var(--accent);animation:hub-update-slide 1.5s ease-in-out infinite}@keyframes hub-update-slide{0%{transform:translate(-100%)}to{transform:translate(350%)}}.hub-update-btn{padding:8px 32px;font-size:14px;font-weight:600;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;cursor:pointer;transition:opacity var(--transition)}.hub-update-btn:hover{opacity:.85}.hub-update-btn-secondary{background:var(--bg-tertiary);color:var(--text-secondary);margin-top:4px}.hub-update-versions{display:flex;flex-direction:column;gap:2px;margin:8px 0;font-size:12px;color:var(--text-muted)}.hub-update-error-detail{font-size:11px;color:#ef4444;background:#ef44441a;border-radius:var(--radius);padding:6px 10px;word-break:break-word;max-width:300px}.hub-refresh-btn{background:none;border:none;color:var(--text-muted);font-size:1rem;cursor:pointer;padding:4px 6px;border-radius:var(--radius);transition:all var(--transition);line-height:1}.hub-refresh-btn:hover{color:var(--accent);background:#e67e221a}.hub-admin-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-muted);font-size:16px;padding:4px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-admin-btn:hover{color:var(--accent);border-color:var(--accent)}.hub-admin-btn.active{color:#4ade80;border-color:#4ade80}.hub-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-admin-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;width:340px;box-shadow:0 8px 32px #00000080}.hub-admin-modal-header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--border);font-weight:600}.hub-admin-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:16px}.hub-admin-modal-close:hover{color:var(--text)}.hub-admin-modal-body{padding:20px;display:flex;flex-direction:column;gap:12px}.hub-admin-input{width:100%;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text);font-size:14px;font-family:var(--font);box-sizing:border-box}.hub-admin-input:focus{outline:none;border-color:var(--accent)}.hub-admin-error{color:#ef4444;font-size:13px;margin:0}.hub-admin-submit{padding:8px 16px;background:var(--accent);color:#fff;border:none;border-radius:var(--radius);font-size:14px;font-weight:500;cursor:pointer;transition:opacity var(--transition)}.hub-admin-submit:hover{opacity:.9}.hub-version-clickable{cursor:pointer;transition:all var(--transition);padding:2px 8px;border-radius:var(--radius)}.hub-version-clickable:hover{color:var(--accent);background:#e67e221a}.hub-version-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-version-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:hub-modal-in .2s ease}@keyframes hub-modal-in{0%{opacity:0;transform:scale(.95) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.hub-version-modal-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.hub-version-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.hub-version-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.hub-version-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.hub-version-modal-row{display:flex;justify-content:space-between;align-items:center}.hub-version-modal-label{color:var(--text-muted);font-size:13px}.hub-version-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.hub-version-modal-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);flex-shrink:0}.hub-version-modal-dot.online{background:var(--success)}.hub-version-modal-link{color:var(--accent);text-decoration:none;font-weight:500;font-size:13px}.hub-version-modal-link:hover{text-decoration:underline}.hub-version-modal-hint{font-size:11px;color:var(--accent);padding:6px 10px;background:#e67e221a;border-radius:var(--radius);text-align:center}.hub-version-modal-update{margin-top:4px;padding-top:12px;border-top:1px solid var(--border)}.hub-version-modal-update-btn{width:100%;padding:10px 16px;border:none;border-radius:var(--radius);background:var(--bg-tertiary);color:var(--text-normal);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);display:flex;align-items:center;justify-content:center;gap:8px}.hub-version-modal-update-btn:hover{background:var(--bg-hover);color:var(--accent)}.hub-version-modal-update-btn.ready{background:#2ecc7126;color:#2ecc71}.hub-version-modal-update-btn.ready:hover{background:#2ecc7140}.hub-version-modal-update-status{display:flex;align-items:center;justify-content:center;gap:8px;font-size:13px;color:var(--text-muted);padding:8px 0;flex-wrap:wrap}.hub-version-modal-update-status.success{color:#2ecc71}.hub-version-modal-update-status.error{color:#e74c3c}.hub-version-modal-update-retry{background:none;border:none;color:var(--text-muted);font-size:11px;cursor:pointer;text-decoration:underline;padding:2px 4px;width:100%;margin-top:4px}.hub-version-modal-update-retry:hover{color:var(--text-normal)}@keyframes hub-spin{to{transform:rotate(360deg)}}.hub-update-spinner{width:14px;height:14px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:hub-spin .8s linear infinite;flex-shrink:0}.hub-content{flex:1;overflow-y:auto;overflow-x:hidden;background:var(--bg-deep);scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.hub-content::-webkit-scrollbar{width:6px}.hub-content::-webkit-scrollbar-track{background:transparent}.hub-content::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.hub-content::-webkit-scrollbar-thumb:hover{background:var(--text-faint)}.hub-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px;text-align:center;padding:32px;animation:fade-in .3s ease}.hub-empty-icon{font-size:64px;line-height:1;margin-bottom:20px;opacity:.6;filter:grayscale(30%)}.hub-empty h2{font-size:22px;font-weight:700;color:var(--text-normal);margin-bottom:8px}.hub-empty p{font-size:15px;color:var(--text-muted);max-width:360px;line-height:1.5}@keyframes fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}::selection{background:rgba(var(--accent-rgb),.3);color:var(--text-normal)}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(max-width:768px){:root{--header-height: 48px}.hub-header{padding:0 10px;gap:8px}.hub-title{font-size:15px}.hub-logo{font-size:20px}.hub-tab{padding:6px 10px;font-size:13px;gap:4px}.hub-tab-label{display:none}.hub-tab-icon{font-size:18px}.hub-version{font-size:11px}.hub-empty-icon{font-size:48px}.hub-empty h2{font-size:18px}.hub-empty p{font-size:14px}}@media(max-width:480px){.hub-header-right{display:none}.hub-header{padding:0 8px;gap:6px}.hub-title{font-size:14px}}.radio-container{display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;background:var(--bg-deep);--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--border: rgba(255, 255, 255, .06)}.radio-container[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad}.radio-container[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60}.radio-container[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9}.radio-container[data-theme=cherry]{--bg-deep: #1a0f14;--bg-primary: #22141a;--bg-secondary: #301c25;--bg-tertiary: #3e2530;--accent: #e74c6f;--accent-rgb: 231, 76, 111;--accent-hover: #c0392b}.radio-topbar{display:flex;align-items:center;padding:0 16px;height:52px;background:var(--bg-secondary, #2b2d31);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px}.radio-topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.radio-topbar-logo{font-size:20px}.radio-topbar-title{font-size:16px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em}.radio-topbar-np{flex:1;display:flex;align-items:center;gap:10px;min-width:0;justify-content:center}.radio-topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.radio-topbar-stop{display:flex;align-items:center;gap:4px;background:var(--danger);color:#fff;border:none;border-radius:var(--radius);padding:6px 14px;font-size:13px;font-family:var(--font);font-weight:600;cursor:pointer;transition:all var(--transition);flex-shrink:0}.radio-topbar-stop:hover{background:#c63639}.radio-theme-inline{display:flex;align-items:center;gap:4px;margin-left:4px}.radio-globe-wrap{position:relative;flex:1;overflow:hidden}.radio-globe{width:100%;height:100%}.radio-globe canvas{outline:none!important}.radio-search{position:absolute;top:16px;left:50%;transform:translate(-50%);z-index:20;width:min(440px,calc(100% - 32px))}.radio-search-wrap{display:flex;align-items:center;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);padding:0 14px;gap:8px;box-shadow:0 8px 32px #0006}.radio-search-icon{font-size:16px;opacity:.6;flex-shrink:0}.radio-search-input{flex:1;background:transparent;border:none;color:var(--text-normal);font-family:var(--font);font-size:14px;padding:12px 0;outline:none}.radio-search-input::placeholder{color:var(--text-faint)}.radio-search-clear{background:none;border:none;color:var(--text-muted);font-size:14px;cursor:pointer;padding:4px;border-radius:4px;transition:color var(--transition)}.radio-search-clear:hover{color:var(--text-normal)}.radio-search-results{margin-top:6px;background:#1e1f22f2;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);max-height:360px;overflow-y:auto;box-shadow:0 12px 40px #00000080;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-search-result{display:flex;align-items:center;gap:10px;width:100%;padding:10px 14px;background:none;border:none;border-bottom:1px solid var(--border);color:var(--text-normal);font-family:var(--font);font-size:14px;cursor:pointer;text-align:left;transition:background var(--transition)}.radio-search-result:last-child{border-bottom:none}.radio-search-result:hover{background:rgba(var(--accent-rgb),.08)}.radio-search-result-icon{font-size:18px;flex-shrink:0}.radio-search-result-text{display:flex;flex-direction:column;gap:2px;min-width:0}.radio-search-result-title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-search-result-sub{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-fab{position:absolute;top:16px;right:16px;z-index:20;display:flex;align-items:center;gap:4px;padding:10px 14px;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);color:var(--text-normal);font-size:16px;cursor:pointer;box-shadow:0 8px 32px #0006;transition:all var(--transition)}.radio-fab:hover,.radio-fab.active{background:rgba(var(--accent-rgb),.15);border-color:rgba(var(--accent-rgb),.3)}.radio-fab-badge{font-size:11px;font-weight:700;background:var(--accent);color:#fff;padding:1px 6px;border-radius:10px;min-width:18px;text-align:center}.radio-panel{position:absolute;top:0;right:0;width:340px;height:100%;z-index:15;background:#1e1f22f2;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border-left:1px solid var(--border);display:flex;flex-direction:column;animation:slide-in-right .2s ease;box-shadow:-8px 0 32px #0000004d}@keyframes slide-in-right{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}.radio-panel-header{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--border);flex-shrink:0}.radio-panel-header h3{font-size:16px;font-weight:700;color:var(--text-normal)}.radio-panel-sub{font-size:12px;color:var(--text-muted);display:block;margin-top:2px}.radio-panel-close{background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all var(--transition)}.radio-panel-close:hover{color:var(--text-normal);background:var(--bg-secondary)}.radio-panel-body{flex:1;overflow-y:auto;padding:8px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-panel-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:14px}.radio-panel-loading{display:flex;flex-direction:column;align-items:center;gap:12px;padding:40px 16px;color:var(--text-muted);font-size:14px}.radio-station{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);transition:background var(--transition);gap:10px}.radio-station:hover{background:var(--bg-secondary)}.radio-station.playing{background:rgba(var(--accent-rgb),.1);border:1px solid rgba(var(--accent-rgb),.2)}.radio-station-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.radio-station-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-loc{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-live{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--accent);font-weight:600}.radio-station-btns{display:flex;gap:4px;flex-shrink:0}.radio-btn-play,.radio-btn-stop{width:34px;height:34px;border:none;border-radius:50%;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-play{background:var(--accent);color:#fff}.radio-btn-play:hover:not(:disabled){background:var(--accent-hover);transform:scale(1.05)}.radio-btn-play:disabled{opacity:.4;cursor:not-allowed}.radio-btn-stop{background:var(--danger);color:#fff}.radio-btn-stop:hover{background:#c63639}.radio-btn-fav{width:34px;height:34px;border:none;border-radius:50%;font-size:16px;cursor:pointer;background:transparent;color:var(--text-faint);display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-fav:hover{color:var(--warning);background:#fee75c1a}.radio-btn-fav.active{color:var(--warning)}.radio-eq{display:flex;align-items:flex-end;gap:2px;height:14px}.radio-eq span{width:3px;background:var(--accent);border-radius:1px;animation:eq-bounce .8s ease-in-out infinite}.radio-eq span:nth-child(1){height:8px;animation-delay:0s}.radio-eq span:nth-child(2){height:14px;animation-delay:.15s}.radio-eq span:nth-child(3){height:10px;animation-delay:.3s}@keyframes eq-bounce{0%,to{transform:scaleY(.4)}50%{transform:scaleY(1)}}.radio-sel{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius);color:var(--text-normal);font-family:var(--font);font-size:13px;padding:6px 10px;cursor:pointer;outline:none;max-width:180px}.radio-sel:focus{border-color:var(--accent)}.radio-eq-np{flex-shrink:0}.radio-np-info{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}.radio-np-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-np-loc{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-volume{display:flex;align-items:center;gap:6px;flex-shrink:0}.radio-volume-icon{font-size:16px;width:20px;text-align:center;cursor:pointer}.radio-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary, #383a40);outline:none;cursor:pointer}.radio-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-val{font-size:11px;color:var(--text-muted);min-width:32px;text-align:right}.radio-theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:transform .15s ease,border-color .15s ease;border:2px solid transparent}.radio-theme-dot:hover{transform:scale(1.25)}.radio-theme-dot.active{border-color:#fff;box-shadow:0 0 6px #ffffff4d}.radio-counter{position:absolute;bottom:16px;left:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;pointer-events:none}.radio-attribution{position:absolute;right:16px;bottom:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;text-decoration:none;transition:color var(--transition),background var(--transition)}.radio-attribution:hover{color:var(--text-normal);background:#1e1f22eb}.radio-spinner{width:24px;height:24px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media(max-width:768px){.radio-panel{width:100%}.radio-fab{top:12px;right:12px;padding:8px 10px;font-size:14px}.radio-search{top:12px;width:calc(100% - 80px);left:calc(50% - 24px)}.radio-topbar{padding:0 12px;gap:8px}.radio-topbar-title{display:none}.radio-sel{max-width:140px;font-size:12px}}@media(max-width:480px){.radio-topbar-np,.radio-volume{display:none}.radio-sel{max-width:120px}}.radio-conn{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--success);cursor:pointer;padding:4px 10px;border-radius:20px;background:#57d28f14;transition:all var(--transition);flex-shrink:0;-webkit-user-select:none;user-select:none}.radio-conn:hover{background:#57d28f26}.radio-conn-dot{width:8px;height:8px;border-radius:50%;background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.radio-conn-ping{font-size:11px;color:var(--text-muted);font-weight:600;font-variant-numeric:tabular-nums}.radio-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fade-in .15s ease}.radio-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:radio-modal-in .2s ease}@keyframes radio-modal-in{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.radio-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.radio-modal-close{margin-left:auto;background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.radio-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.radio-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.radio-modal-stat{display:flex;justify-content:space-between;align-items:center}.radio-modal-label{color:var(--text-muted);font-size:13px}.radio-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.radio-modal-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0} diff --git a/web/dist/index.html b/web/dist/index.html index 49c851e..40f4a36 100644 --- a/web/dist/index.html +++ b/web/dist/index.html @@ -5,8 +5,8 @@ Gaming Hub - - + +
diff --git a/web/src/App.tsx b/web/src/App.tsx index eeed0b4..ec899df 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -13,7 +13,7 @@ interface PluginInfo { } // Plugin tab components -const tabComponents: Record> = { +const tabComponents: Record> = { radio: RadioTab, soundboard: SoundboardTab, lolstats: LolstatsTab, @@ -22,7 +22,7 @@ const tabComponents: Record> = { 'game-library': GameLibraryTab, }; -export function registerTab(pluginName: string, component: React.FC<{ data: any }>) { +export function registerTab(pluginName: string, component: React.FC<{ data: any; isAdmin?: boolean }>) { tabComponents[pluginName] = component; } @@ -40,6 +40,12 @@ export default function App() { const [showVersionModal, setShowVersionModal] = useState(false); const [pluginData, setPluginData] = useState>({}); + // Centralized admin login state + const [isAdmin, setIsAdmin] = useState(false); + const [showAdminLogin, setShowAdminLogin] = useState(false); + const [adminPwd, setAdminPwd] = useState(''); + const [adminError, setAdminError] = useState(''); + // Electron auto-update state const isElectron = !!(window as any).electronAPI?.isElectron; const electronVersion = isElectron ? (window as any).electronAPI.version : null; @@ -54,6 +60,48 @@ export default function App() { } }, []); + // Check admin status on mount (shared cookie — any endpoint works) + useEffect(() => { + fetch('/api/soundboard/admin/status', { credentials: 'include' }) + .then(r => r.json()) + .then(d => setIsAdmin(!!d.authenticated)) + .catch(() => {}); + }, []); + + // Escape key closes admin login modal + useEffect(() => { + if (!showAdminLogin) return; + const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') setShowAdminLogin(false); }; + window.addEventListener('keydown', handler); + return () => window.removeEventListener('keydown', handler); + }, [showAdminLogin]); + + async function handleAdminLogin() { + setAdminError(''); + try { + const resp = await fetch('/api/soundboard/admin/login', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ password: adminPwd }), + credentials: 'include', + }); + if (resp.ok) { + setIsAdmin(true); + setAdminPwd(''); + setShowAdminLogin(false); + } else { + setAdminError('Falsches Passwort'); + } + } catch { + setAdminError('Verbindung fehlgeschlagen'); + } + } + + async function handleAdminLogout() { + await fetch('/api/soundboard/admin/logout', { method: 'POST', credentials: 'include' }); + setIsAdmin(false); + } + // Electron auto-update listeners useEffect(() => { if (!isElectron) return; @@ -188,6 +236,13 @@ export default function App() { Desktop App
)} +
)} + {showAdminLogin && ( +
setShowAdminLogin(false)}> +
e.stopPropagation()}> +
+ {'\uD83D\uDD12'} Admin Login + +
+
+ setAdminPwd(e.target.value)} + onKeyDown={e => e.key === 'Enter' && handleAdminLogin()} + autoFocus + /> + {adminError &&

{adminError}

} + +
+
+
+ )} +
{plugins.length === 0 ? (
@@ -330,7 +413,7 @@ export default function App() { : { display: 'none' } } > - +
); }) diff --git a/web/src/plugins/game-library/GameLibraryTab.tsx b/web/src/plugins/game-library/GameLibraryTab.tsx index 2f30c4d..bb279ff 100644 --- a/web/src/plugins/game-library/GameLibraryTab.tsx +++ b/web/src/plugins/game-library/GameLibraryTab.tsx @@ -89,7 +89,7 @@ function formatDate(iso: string): string { COMPONENT ══════════════════════════════════════════════════════════════════ */ -export default function GameLibraryTab({ data }: { data: any }) { +export default function GameLibraryTab({ data, isAdmin: isAdminProp }: { data: any; isAdmin?: boolean }) { // ── State ── const [profiles, setProfiles] = useState([]); const [mode, setMode] = useState<'overview' | 'user' | 'common'>('overview'); @@ -111,11 +111,9 @@ export default function GameLibraryTab({ data }: { data: any }) { // ── Admin state ── const [showAdmin, setShowAdmin] = useState(false); - const [isAdmin, setIsAdmin] = useState(false); - const [adminPwd, setAdminPwd] = useState(''); + const isAdmin = isAdminProp ?? false; const [adminProfiles, setAdminProfiles] = useState([]); const [adminLoading, setAdminLoading] = useState(false); - const [adminError, setAdminError] = useState(''); // ── SSE data sync ── useEffect(() => { @@ -133,43 +131,6 @@ export default function GameLibraryTab({ data }: { data: any }) { } catch { /* silent */ } }, []); - // ── Admin: check login status on mount ── - useEffect(() => { - fetch('/api/game-library/admin/status', { credentials: 'include' }) - .then(r => r.json()) - .then(d => setIsAdmin(d.admin === true)) - .catch(() => {}); - }, []); - - // ── Admin: login ── - const adminLogin = useCallback(async () => { - setAdminError(''); - try { - const resp = await fetch('/api/game-library/admin/login', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ password: adminPwd }), - credentials: 'include', - }); - if (resp.ok) { - setIsAdmin(true); - setAdminPwd(''); - } else { - const d = await resp.json(); - setAdminError(d.error || 'Fehler'); - } - } catch { - setAdminError('Verbindung fehlgeschlagen'); - } - }, [adminPwd]); - - // ── Admin: logout ── - const adminLogout = useCallback(async () => { - await fetch('/api/game-library/admin/logout', { method: 'POST', credentials: 'include' }); - setIsAdmin(false); - setShowAdmin(false); - }, []); - // ── Admin: load profiles ── const loadAdminProfiles = useCallback(async () => { setAdminLoading(true); @@ -552,9 +513,11 @@ export default function GameLibraryTab({ data }: { data: any }) { )}
- + {isAdmin && ( + + )}
{/* ── Profile Chips ── */} @@ -990,61 +953,41 @@ export default function GameLibraryTab({ data }: { data: any }) {
- {!isAdmin ? ( -
-

Admin-Passwort eingeben:

-
- setAdminPwd(e.target.value)} - onKeyDown={e => { if (e.key === 'Enter') adminLogin(); }} - autoFocus - /> - -
- {adminError &&

{adminError}

} +
+
+ ✅ Eingeloggt als Admin +
- ) : ( -
-
- ✅ Eingeloggt als Admin - - -
- {adminLoading ? ( -
Lade Profile...
- ) : adminProfiles.length === 0 ? ( -

Keine Profile vorhanden.

- ) : ( -
- {adminProfiles.map((p: any) => ( -
- {p.displayName} -
- {p.displayName} - - {p.steamName && Steam: {p.steamGames}} - {p.gogName && GOG: {p.gogGames}} - {p.totalGames} Spiele - -
- + {adminLoading ? ( +
Lade Profile...
+ ) : adminProfiles.length === 0 ? ( +

Keine Profile vorhanden.

+ ) : ( +
+ {adminProfiles.map((p: any) => ( +
+ {p.displayName} +
+ {p.displayName} + + {p.steamName && Steam: {p.steamGames}} + {p.gogName && GOG: {p.gogGames}} + {p.totalGames} Spiele +
- ))} -
- )} -
- )} + +
+ ))} +
+ )} +
)} diff --git a/web/src/plugins/soundboard/SoundboardTab.tsx b/web/src/plugins/soundboard/SoundboardTab.tsx index 064951b..4e1af67 100644 --- a/web/src/plugins/soundboard/SoundboardTab.tsx +++ b/web/src/plugins/soundboard/SoundboardTab.tsx @@ -186,25 +186,6 @@ async function apiGetVolume(guildId: string): Promise { return typeof data?.volume === 'number' ? data.volume : 1; } -async function apiAdminStatus(): Promise { - const res = await fetch(`${API_BASE}/admin/status`, { credentials: 'include' }); - if (!res.ok) return false; - const data = await res.json(); - return !!data?.authenticated; -} - -async function apiAdminLogin(password: string): Promise { - const res = await fetch(`${API_BASE}/admin/login`, { - method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', - body: JSON.stringify({ password }) - }); - return res.ok; -} - -async function apiAdminLogout(): Promise { - await fetch(`${API_BASE}/admin/logout`, { method: 'POST', credentials: 'include' }); -} - async function apiAdminDelete(paths: string[]): Promise { const res = await fetch(`${API_BASE}/admin/sounds/delete`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', @@ -324,13 +305,14 @@ interface VoiceStats { interface SoundboardTabProps { data: any; + isAdmin?: boolean; } /* ══════════════════════════════════════════════════════════════════ COMPONENT ══════════════════════════════════════════════════════════════════ */ -export default function SoundboardTab({ data }: SoundboardTabProps) { +export default function SoundboardTab({ data, isAdmin: isAdminProp }: SoundboardTabProps) { /* ── Data ── */ const [sounds, setSounds] = useState([]); const [total, setTotal] = useState(0); @@ -378,9 +360,8 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { const volDebounceRef = useRef>(undefined); /* ── Admin ── */ - const [isAdmin, setIsAdmin] = useState(false); + const isAdmin = isAdminProp ?? false; const [showAdmin, setShowAdmin] = useState(false); - const [adminPwd, setAdminPwd] = useState(''); const [adminSounds, setAdminSounds] = useState([]); const [adminLoading, setAdminLoading] = useState(false); const [adminQuery, setAdminQuery] = useState(''); @@ -521,7 +502,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { setSelected(match ? `${g}:${serverCid}` : `${ch[0].guildId}:${ch[0].channelId}`); } } catch (e: any) { notify(e?.message || 'Channel-Fehler', 'error'); } - try { setIsAdmin(await apiAdminStatus()); } catch { } try { const c = await fetchCategories(); setCategories(c.categories || []); } catch { } })(); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -879,28 +859,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { } } - async function handleAdminLogin() { - try { - const ok = await apiAdminLogin(adminPwd); - if (ok) { - setIsAdmin(true); - setAdminPwd(''); - notify('Admin eingeloggt'); - } - else notify('Falsches Passwort', 'error'); - } catch { notify('Login fehlgeschlagen', 'error'); } - } - - async function handleAdminLogout() { - try { - await apiAdminLogout(); - setIsAdmin(false); - setAdminSelection({}); - cancelRename(); - notify('Ausgeloggt'); - } catch { } - } - /* ── Computed ── */ const displaySounds = useMemo(() => { if (activeTab === 'favorites') return sounds.filter(s => favs[s.relativePath ?? s.fileName]); @@ -1040,13 +998,15 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { )}
)} - + {isAdmin && ( + + )}
@@ -1447,21 +1407,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { close - {!isAdmin ? ( -
-
- - setAdminPwd(e.target.value)} - onKeyDown={e => e.key === 'Enter' && handleAdminLogin()} - placeholder="Admin-Passwort..." - /> -
- -
- ) : (

Eingeloggt als Admin

@@ -1473,7 +1418,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { > Aktualisieren -
@@ -1585,7 +1529,6 @@ export default function SoundboardTab({ data }: SoundboardTabProps) { )}
- )}
)} diff --git a/web/src/plugins/streaming/StreamingTab.tsx b/web/src/plugins/streaming/StreamingTab.tsx index 06c1064..441fec6 100644 --- a/web/src/plugins/streaming/StreamingTab.tsx +++ b/web/src/plugins/streaming/StreamingTab.tsx @@ -55,7 +55,7 @@ const QUALITY_PRESETS = [ // ── Component ── -export default function StreamingTab({ data }: { data: any }) { +export default function StreamingTab({ data, isAdmin: isAdminProp }: { data: any; isAdmin?: boolean }) { // ── State ── const [streams, setStreams] = useState([]); const [userName, setUserName] = useState(() => localStorage.getItem('streaming_name') || ''); @@ -74,9 +74,7 @@ export default function StreamingTab({ data }: { data: any }) { // ── Admin / Notification Config ── const [showAdmin, setShowAdmin] = useState(false); - const [isAdmin, setIsAdmin] = useState(false); - const [adminPwd, setAdminPwd] = useState(''); - const [adminError, setAdminError] = useState(''); + const isAdmin = isAdminProp ?? false; const [availableChannels, setAvailableChannels] = useState>([]); const [notifyConfig, setNotifyConfig] = useState>([]); const [configLoading, setConfigLoading] = useState(false); @@ -137,12 +135,8 @@ export default function StreamingTab({ data }: { data: any }) { return () => document.removeEventListener('click', handler); }, [openMenu]); - // Check admin status on mount + // Check bot status on mount useEffect(() => { - fetch('/api/notifications/admin/status', { credentials: 'include' }) - .then(r => r.json()) - .then(d => setIsAdmin(d.admin === true)) - .catch(() => {}); fetch('/api/notifications/status') .then(r => r.json()) .then(d => setNotifyStatus(d)) @@ -609,35 +603,6 @@ export default function StreamingTab({ data }: { data: any }) { setOpenMenu(null); }, [buildStreamLink]); - // ── Admin functions ── - const adminLogin = useCallback(async () => { - setAdminError(''); - try { - const resp = await fetch('/api/notifications/admin/login', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ password: adminPwd }), - credentials: 'include', - }); - if (resp.ok) { - setIsAdmin(true); - setAdminPwd(''); - loadNotifyConfig(); - } else { - const d = await resp.json(); - setAdminError(d.error || 'Fehler'); - } - } catch { - setAdminError('Verbindung fehlgeschlagen'); - } - }, [adminPwd]); - - const adminLogout = useCallback(async () => { - await fetch('/api/notifications/admin/logout', { method: 'POST', credentials: 'include' }); - setIsAdmin(false); - setShowAdmin(false); - }, []); - const loadNotifyConfig = useCallback(async () => { setConfigLoading(true); try { @@ -806,9 +771,11 @@ export default function StreamingTab({ data }: { data: any }) { {starting ? 'Starte...' : '\u{1F5A5}\uFE0F Stream starten'} )} - + {isAdmin && ( + + )}
{streams.length === 0 && !isBroadcasting ? ( @@ -922,32 +889,13 @@ export default function StreamingTab({ data }: { data: any }) {
- {!isAdmin ? ( -
-

Admin-Passwort eingeben:

-
- setAdminPwd(e.target.value)} - onKeyDown={e => { if (e.key === 'Enter') adminLogin(); }} - autoFocus - /> - -
- {adminError &&

{adminError}

} -
- ) : ( -
+
{notifyStatus.online ? <>{'\u2705'} Bot online: {notifyStatus.botTag} : <>{'\u26A0\uFE0F'} Bot offline — DISCORD_TOKEN_NOTIFICATIONS setzen} -
{configLoading ? ( @@ -1003,7 +951,6 @@ export default function StreamingTab({ data }: { data: any }) { )}
- )}
)} diff --git a/web/src/styles.css b/web/src/styles.css index 656b9d5..77e8424 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -353,6 +353,104 @@ html, body { background: rgba(230, 126, 34, 0.1); } +/* ── Admin Button (header) ── */ +.hub-admin-btn { + background: none; + border: 1px solid var(--border); + border-radius: var(--radius); + color: var(--text-muted); + font-size: 16px; + padding: 4px 8px; + cursor: pointer; + transition: all var(--transition); + line-height: 1; +} +.hub-admin-btn:hover { + color: var(--accent); + border-color: var(--accent); +} +.hub-admin-btn.active { + color: #4ade80; + border-color: #4ade80; +} + +/* ── Admin Login Modal ── */ +.hub-admin-overlay { + position: fixed; + inset: 0; + z-index: 9999; + display: flex; + align-items: center; + justify-content: center; + background: rgba(0, 0, 0, 0.7); + backdrop-filter: blur(4px); +} +.hub-admin-modal { + background: var(--bg-card); + border: 1px solid var(--border); + border-radius: 12px; + width: 340px; + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); +} +.hub-admin-modal-header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 16px 20px; + border-bottom: 1px solid var(--border); + font-weight: 600; +} +.hub-admin-modal-close { + background: none; + border: none; + color: var(--text-muted); + cursor: pointer; + font-size: 16px; +} +.hub-admin-modal-close:hover { + color: var(--text); +} +.hub-admin-modal-body { + padding: 20px; + display: flex; + flex-direction: column; + gap: 12px; +} +.hub-admin-input { + width: 100%; + padding: 8px 12px; + border: 1px solid var(--border); + border-radius: var(--radius); + background: var(--bg-secondary); + color: var(--text); + font-size: 14px; + font-family: var(--font); + box-sizing: border-box; +} +.hub-admin-input:focus { + outline: none; + border-color: var(--accent); +} +.hub-admin-error { + color: #ef4444; + font-size: 13px; + margin: 0; +} +.hub-admin-submit { + padding: 8px 16px; + background: var(--accent); + color: #fff; + border: none; + border-radius: var(--radius); + font-size: 14px; + font-weight: 500; + cursor: pointer; + transition: opacity var(--transition); +} +.hub-admin-submit:hover { + opacity: 0.9; +} + /* ── Version Info Modal ── */ .hub-version-clickable { cursor: pointer; From 4b23d013f9c2c778bc518310684355fb5100ffcd Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Mon, 9 Mar 2026 21:02:15 +0000 Subject: [PATCH 21/53] v1.8.5 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index bfa363e..8decb92 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.4 +1.8.5 From 3f175ca02cfae3b9569ebcae01c56696508dfa5c Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 22:33:09 +0100 Subject: [PATCH 22/53] Unified Admin Panel: 3 Plugin-Settings in ein zentrales Modal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Neues AdminPanel.tsx mit Sidebar-Navigation (Soundboard/Streaming/Game Library) - Lazy-Loading: Daten werden erst beim Tab-Wechsel geladen - Admin-Button im Header öffnet jetzt das zentrale Panel (Rechtsklick = Logout) - Admin-Code aus SoundboardTab, StreamingTab und GameLibraryTab entfernt - ~500 Zeilen Plugin-Code entfernt, durch ~620 Zeilen zentrales Panel ersetzt Co-Authored-By: Claude Opus 4.6 --- web/dist/assets/index-BGKtt2gT.js | 4830 ----------------- web/dist/assets/index-BWeAEcYi.js | 4830 +++++++++++++++++ ...{index-TtdZJHkE.css => index-Bg-1_rjZ.css} | 2 +- web/dist/index.html | 4 +- web/src/AdminPanel.tsx | 660 +++ web/src/App.tsx | 11 +- .../plugins/game-library/GameLibraryTab.tsx | 94 +- web/src/plugins/soundboard/SoundboardTab.tsx | 246 +- web/src/plugins/streaming/StreamingTab.tsx | 159 +- web/src/styles.css | 621 +++ 10 files changed, 6137 insertions(+), 5320 deletions(-) delete mode 100644 web/dist/assets/index-BGKtt2gT.js create mode 100644 web/dist/assets/index-BWeAEcYi.js rename web/dist/assets/{index-TtdZJHkE.css => index-Bg-1_rjZ.css} (92%) create mode 100644 web/src/AdminPanel.tsx diff --git a/web/dist/assets/index-BGKtt2gT.js b/web/dist/assets/index-BGKtt2gT.js deleted file mode 100644 index 9881ac1..0000000 --- a/web/dist/assets/index-BGKtt2gT.js +++ /dev/null @@ -1,4830 +0,0 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function E7(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var $b={exports:{}},Xp={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var I8;function CF(){if(I8)return Xp;I8=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,r,s){var a=null;if(s!==void 0&&(a=""+s),r.key!==void 0&&(a=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:i,type:n,key:a,ref:r!==void 0?r:null,props:s}}return Xp.Fragment=e,Xp.jsx=t,Xp.jsxs=t,Xp}var F8;function NF(){return F8||(F8=1,$b.exports=CF()),$b.exports}var P=NF(),Xb={exports:{}},Yp={},Yb={exports:{}},Qb={};/** - * @license React - * scheduler.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var k8;function RF(){return k8||(k8=1,(function(i){function e(K,ae){var Ae=K.length;K.push(ae);e:for(;0>>1,Se=K[be];if(0>>1;ber(qe,Ae))Cer(ke,qe)?(K[be]=ke,K[Ce]=Ae,be=Ce):(K[be]=qe,K[Ee]=Ae,be=Ee);else if(Cer(ke,Ae))K[be]=ke,K[Ce]=Ae,be=Ce;else break e}}return ae}function r(K,ae){var Ae=K.sortIndex-ae.sortIndex;return Ae!==0?Ae:K.id-ae.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;i.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();i.unstable_now=function(){return a.now()-l}}var u=[],h=[],m=1,v=null,x=3,S=!1,w=!1,N=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function I(K){for(var ae=t(h);ae!==null;){if(ae.callback===null)n(h);else if(ae.startTime<=K)n(h),ae.sortIndex=ae.expirationTime,e(u,ae);else break;ae=t(h)}}function j(K){if(N=!1,I(K),!w)if(t(u)!==null)w=!0,z||(z=!0,te());else{var ae=t(h);ae!==null&&Q(j,ae.startTime-K)}}var z=!1,G=-1,W=5,q=-1;function V(){return C?!0:!(i.unstable_now()-qK&&V());){var be=v.callback;if(typeof be=="function"){v.callback=null,x=v.priorityLevel;var Se=be(v.expirationTime<=K);if(K=i.unstable_now(),typeof Se=="function"){v.callback=Se,I(K),ae=!0;break t}v===t(u)&&n(u),I(K)}else n(u);v=t(u)}if(v!==null)ae=!0;else{var se=t(h);se!==null&&Q(j,se.startTime-K),ae=!1}}break e}finally{v=null,x=Ae,S=!1}ae=void 0}}finally{ae?te():z=!1}}}var te;if(typeof U=="function")te=function(){U(Y)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,le=ne.port2;ne.port1.onmessage=Y,te=function(){le.postMessage(null)}}else te=function(){E(Y,0)};function Q(K,ae){G=E(function(){K(i.unstable_now())},ae)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(K){K.callback=null},i.unstable_forceFrameRate=function(K){0>K||125be?(K.sortIndex=Ae,e(h,K),t(u)===null&&K===t(h)&&(N?(O(G),G=-1):N=!0,Q(j,Ae-be))):(K.sortIndex=Se,e(u,K),w||S||(w=!0,z||(z=!0,te()))),K},i.unstable_shouldYield=V,i.unstable_wrapCallback=function(K){var ae=x;return function(){var Ae=x;x=ae;try{return K.apply(this,arguments)}finally{x=Ae}}}})(Qb)),Qb}var z8;function DF(){return z8||(z8=1,Yb.exports=RF()),Yb.exports}var Kb={exports:{}},ii={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var G8;function PF(){if(G8)return ii;G8=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(se){return se===null||typeof se!="object"?null:(se=x&&se[x]||se["@@iterator"],typeof se=="function"?se:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,C={};function E(se,Ee,qe){this.props=se,this.context=Ee,this.refs=C,this.updater=qe||w}E.prototype.isReactComponent={},E.prototype.setState=function(se,Ee){if(typeof se!="object"&&typeof se!="function"&&se!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,se,Ee,"setState")},E.prototype.forceUpdate=function(se){this.updater.enqueueForceUpdate(this,se,"forceUpdate")};function O(){}O.prototype=E.prototype;function U(se,Ee,qe){this.props=se,this.context=Ee,this.refs=C,this.updater=qe||w}var I=U.prototype=new O;I.constructor=U,N(I,E.prototype),I.isPureReactComponent=!0;var j=Array.isArray;function z(){}var G={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function q(se,Ee,qe){var Ce=qe.ref;return{$$typeof:i,type:se,key:Ee,ref:Ce!==void 0?Ce:null,props:qe}}function V(se,Ee){return q(se.type,Ee,se.props)}function Y(se){return typeof se=="object"&&se!==null&&se.$$typeof===i}function te(se){var Ee={"=":"=0",":":"=2"};return"$"+se.replace(/[=:]/g,function(qe){return Ee[qe]})}var ne=/\/+/g;function le(se,Ee){return typeof se=="object"&&se!==null&&se.key!=null?te(""+se.key):Ee.toString(36)}function Q(se){switch(se.status){case"fulfilled":return se.value;case"rejected":throw se.reason;default:switch(typeof se.status=="string"?se.then(z,z):(se.status="pending",se.then(function(Ee){se.status==="pending"&&(se.status="fulfilled",se.value=Ee)},function(Ee){se.status==="pending"&&(se.status="rejected",se.reason=Ee)})),se.status){case"fulfilled":return se.value;case"rejected":throw se.reason}}throw se}function K(se,Ee,qe,Ce,ke){var Qe=typeof se;(Qe==="undefined"||Qe==="boolean")&&(se=null);var et=!1;if(se===null)et=!0;else switch(Qe){case"bigint":case"string":case"number":et=!0;break;case"object":switch(se.$$typeof){case i:case e:et=!0;break;case m:return et=se._init,K(et(se._payload),Ee,qe,Ce,ke)}}if(et)return ke=ke(se),et=Ce===""?"."+le(se,0):Ce,j(ke)?(qe="",et!=null&&(qe=et.replace(ne,"$&/")+"/"),K(ke,Ee,qe,"",function(Gt){return Gt})):ke!=null&&(Y(ke)&&(ke=V(ke,qe+(ke.key==null||se&&se.key===ke.key?"":(""+ke.key).replace(ne,"$&/")+"/")+et)),Ee.push(ke)),1;et=0;var Pt=Ce===""?".":Ce+":";if(j(se))for(var Nt=0;Nt"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Zb.exports=LF(),Zb.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var H8;function BF(){if(H8)return Yp;H8=1;var i=DF(),e=xw(),t=UF();function n(o){var c="https://react.dev/errors/"+o;if(1Se||(o.current=be[Se],be[Se]=null,Se--)}function qe(o,c){Se++,be[Se]=o.current,o.current=c}var Ce=se(null),ke=se(null),Qe=se(null),et=se(null);function Pt(o,c){switch(qe(Qe,c),qe(ke,o),qe(Ce,null),c.nodeType){case 9:case 11:o=(o=c.documentElement)&&(o=o.namespaceURI)?a8(o):0;break;default:if(o=c.tagName,c=c.namespaceURI)c=a8(c),o=o8(c,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}Ee(Ce),qe(Ce,o)}function Nt(){Ee(Ce),Ee(ke),Ee(Qe)}function Gt(o){o.memoizedState!==null&&qe(et,o);var c=Ce.current,g=o8(c,o.type);c!==g&&(qe(ke,o),qe(Ce,g))}function Tt(o){ke.current===o&&(Ee(Ce),Ee(ke)),et.current===o&&(Ee(et),jp._currentValue=Ae)}var Ge,dt;function he(o){if(Ge===void 0)try{throw Error()}catch(g){var c=g.stack.trim().match(/\n( *(at )?)/);Ge=c&&c[1]||"",dt=-1)":-1D||Me[b]!==rt[D]){var _t=` -`+Me[b].replace(" at new "," at ");return o.displayName&&_t.includes("")&&(_t=_t.replace("",o.displayName)),_t}while(1<=b&&0<=D);break}}}finally{en=!1,Error.prepareStackTrace=g}return(g=o?o.displayName||o.name:"")?he(g):""}function qt(o,c){switch(o.tag){case 26:case 27:case 5:return he(o.type);case 16:return he("Lazy");case 13:return o.child!==c&&c!==null?he("Suspense Fallback"):he("Suspense");case 19:return he("SuspenseList");case 0:case 15:return wt(o.type,!1);case 11:return wt(o.type.render,!1);case 1:return wt(o.type,!0);case 31:return he("Activity");default:return""}}function Lt(o){try{var c="",g=null;do c+=qt(o,g),g=o,o=o.return;while(o);return c}catch(b){return` -Error generating stack: `+b.message+` -`+b.stack}}var hn=Object.prototype.hasOwnProperty,ut=i.unstable_scheduleCallback,fe=i.unstable_cancelCallback,k=i.unstable_shouldYield,_e=i.unstable_requestPaint,Be=i.unstable_now,Oe=i.unstable_getCurrentPriorityLevel,je=i.unstable_ImmediatePriority,Bt=i.unstable_UserBlockingPriority,yt=i.unstable_NormalPriority,Xt=i.unstable_LowPriority,ln=i.unstable_IdlePriority,mt=i.log,Wt=i.unstable_setDisableYieldValue,Yt=null,$t=null;function It(o){if(typeof mt=="function"&&Wt(o),$t&&typeof $t.setStrictMode=="function")try{$t.setStrictMode(Yt,o)}catch{}}var Te=Math.clz32?Math.clz32:ce,nt=Math.log,At=Math.LN2;function ce(o){return o>>>=0,o===0?32:31-(nt(o)/At|0)|0}var xt=256,Ze=262144,lt=4194304;function bt(o){var c=o&42;if(c!==0)return c;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function Kt(o,c,g){var b=o.pendingLanes;if(b===0)return 0;var D=0,L=o.suspendedLanes,X=o.pingedLanes;o=o.warmLanes;var oe=b&134217727;return oe!==0?(b=oe&~L,b!==0?D=bt(b):(X&=oe,X!==0?D=bt(X):g||(g=oe&~o,g!==0&&(D=bt(g))))):(oe=b&~L,oe!==0?D=bt(oe):X!==0?D=bt(X):g||(g=b&~o,g!==0&&(D=bt(g)))),D===0?0:c!==0&&c!==D&&(c&L)===0&&(L=D&-D,g=c&-c,L>=g||L===32&&(g&4194048)!==0)?c:D}function un(o,c){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&c)===0}function Ye(o,c){switch(o){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function St(){var o=lt;return lt<<=1,(lt&62914560)===0&&(lt=4194304),o}function ye(o){for(var c=[],g=0;31>g;g++)c.push(o);return c}function pt(o,c){o.pendingLanes|=c,c!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function Zt(o,c,g,b,D,L){var X=o.pendingLanes;o.pendingLanes=g,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=g,o.entangledLanes&=g,o.errorRecoveryDisabledLanes&=g,o.shellSuspendCounter=0;var oe=o.entanglements,Me=o.expirationTimes,rt=o.hiddenUpdates;for(g=X&~g;0"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var qr=/[\n"\\]/g;function Er(o){return o.replace(qr,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Ni(o,c,g,b,D,L,X,oe){o.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?o.type=X:o.removeAttribute("type"),c!=null?X==="number"?(c===0&&o.value===""||o.value!=c)&&(o.value=""+Vn(c)):o.value!==""+Vn(c)&&(o.value=""+Vn(c)):X!=="submit"&&X!=="reset"||o.removeAttribute("value"),c!=null?_i(o,X,Vn(c)):g!=null?_i(o,X,Vn(g)):b!=null&&o.removeAttribute("value"),D==null&&L!=null&&(o.defaultChecked=!!L),D!=null&&(o.checked=D&&typeof D!="function"&&typeof D!="symbol"),oe!=null&&typeof oe!="function"&&typeof oe!="symbol"&&typeof oe!="boolean"?o.name=""+Vn(oe):o.removeAttribute("name")}function Yi(o,c,g,b,D,L,X,oe){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(o.type=L),c!=null||g!=null){if(!(L!=="submit"&&L!=="reset"||c!=null)){pi(o);return}g=g!=null?""+Vn(g):"",c=c!=null?""+Vn(c):g,oe||c===o.value||(o.value=c),o.defaultValue=c}b=b??D,b=typeof b!="function"&&typeof b!="symbol"&&!!b,o.checked=oe?o.checked:!!b,o.defaultChecked=!!b,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(o.name=X),pi(o)}function _i(o,c,g){c==="number"&&Gr(o.ownerDocument)===o||o.defaultValue===""+g||(o.defaultValue=""+g)}function pr(o,c,g,b){if(o=o.options,c){c={};for(var D=0;D"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ed=!1;if(dl)try{var sf={};Object.defineProperty(sf,"passive",{get:function(){Ed=!0}}),window.addEventListener("test",sf,sf),window.removeEventListener("test",sf,sf)}catch{Ed=!1}var qo=null,af=null,Cd=null;function ip(){if(Cd)return Cd;var o,c=af,g=c.length,b,D="value"in qo?qo.value:qo.textContent,L=D.length;for(o=0;o=cf),ju=" ",g1=!1;function Pd(o,c){switch(o){case"keyup":return xx.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lp(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var nh=!1;function v1(o,c){switch(o){case"compositionend":return lp(c);case"keypress":return c.which!==32?null:(g1=!0,ju);case"textInput":return o=c.data,o===ju&&g1?null:o;default:return null}}function bx(o,c){if(nh)return o==="compositionend"||!Vu&&Pd(o,c)?(o=ip(),Cd=af=qo=null,nh=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:g,offset:c-o};o=b}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=Bd(g)}}function Xu(o,c){return o&&c?o===c?!0:o&&o.nodeType===3?!1:c&&c.nodeType===3?Xu(o,c.parentNode):"contains"in o?o.contains(c):o.compareDocumentPosition?!!(o.compareDocumentPosition(c)&16):!1:!1}function jl(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var c=Gr(o.document);c instanceof o.HTMLIFrameElement;){try{var g=typeof c.contentWindow.location.href=="string"}catch{g=!1}if(g)o=c.contentWindow;else break;c=Gr(o.document)}return c}function Hl(o){var c=o&&o.nodeName&&o.nodeName.toLowerCase();return c&&(c==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||c==="textarea"||o.contentEditable==="true")}var wx=dl&&"documentMode"in document&&11>=document.documentMode,Yu=null,dp=null,Qu=null,Ap=!1;function T1(o,c,g){var b=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;Ap||Yu==null||Yu!==Gr(b)||(b=Yu,"selectionStart"in b&&Hl(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Qu&&Ps(Qu,b)||(Qu=b,b=s2(dp,"onSelect"),0>=X,D-=X,Oa=1<<32-Te(c)+D|g<di?(wi=Sn,Sn=null):wi=Sn.sibling;var Ui=st(We,Sn,it[di],Dt);if(Ui===null){Sn===null&&(Sn=wi);break}o&&Sn&&Ui.alternate===null&&c(We,Sn),Ue=L(Ui,Ue,di),Li===null?Dn=Ui:Li.sibling=Ui,Li=Ui,Sn=wi}if(di===it.length)return g(We,Sn),xi&&Ho(We,di),Dn;if(Sn===null){for(;didi?(wi=Sn,Sn=null):wi=Sn.sibling;var yh=st(We,Sn,Ui.value,Dt);if(yh===null){Sn===null&&(Sn=wi);break}o&&Sn&&yh.alternate===null&&c(We,Sn),Ue=L(yh,Ue,di),Li===null?Dn=yh:Li.sibling=yh,Li=yh,Sn=wi}if(Ui.done)return g(We,Sn),xi&&Ho(We,di),Dn;if(Sn===null){for(;!Ui.done;di++,Ui=it.next())Ui=Ot(We,Ui.value,Dt),Ui!==null&&(Ue=L(Ui,Ue,di),Li===null?Dn=Ui:Li.sibling=Ui,Li=Ui);return xi&&Ho(We,di),Dn}for(Sn=b(Sn);!Ui.done;di++,Ui=it.next())Ui=ct(Sn,We,di,Ui.value,Dt),Ui!==null&&(o&&Ui.alternate!==null&&Sn.delete(Ui.key===null?di:Ui.key),Ue=L(Ui,Ue,di),Li===null?Dn=Ui:Li.sibling=Ui,Li=Ui);return o&&Sn.forEach(function(EF){return c(We,EF)}),xi&&Ho(We,di),Dn}function ir(We,Ue,it,Dt){if(typeof it=="object"&&it!==null&&it.type===N&&it.key===null&&(it=it.props.children),typeof it=="object"&&it!==null){switch(it.$$typeof){case S:e:{for(var Dn=it.key;Ue!==null;){if(Ue.key===Dn){if(Dn=it.type,Dn===N){if(Ue.tag===7){g(We,Ue.sibling),Dt=D(Ue,it.props.children),Dt.return=We,We=Dt;break e}}else if(Ue.elementType===Dn||typeof Dn=="object"&&Dn!==null&&Dn.$$typeof===W&&d(Dn)===Ue.type){g(We,Ue.sibling),Dt=D(Ue,it.props),B(Dt,it),Dt.return=We,We=Dt;break e}g(We,Ue);break}else c(We,Ue);Ue=Ue.sibling}it.type===N?(Dt=tc(it.props.children,We.mode,Dt,it.key),Dt.return=We,We=Dt):(Dt=zd(it.type,it.key,it.props,null,We.mode,Dt),B(Dt,it),Dt.return=We,We=Dt)}return X(We);case w:e:{for(Dn=it.key;Ue!==null;){if(Ue.key===Dn)if(Ue.tag===4&&Ue.stateNode.containerInfo===it.containerInfo&&Ue.stateNode.implementation===it.implementation){g(We,Ue.sibling),Dt=D(Ue,it.children||[]),Dt.return=We,We=Dt;break e}else{g(We,Ue);break}else c(We,Ue);Ue=Ue.sibling}Dt=jo(it,We.mode,Dt),Dt.return=We,We=Dt}return X(We);case W:return it=d(it),ir(We,Ue,it,Dt)}if(Q(it))return vn(We,Ue,it,Dt);if(te(it)){if(Dn=te(it),typeof Dn!="function")throw Error(n(150));return it=Dn.call(it),Gn(We,Ue,it,Dt)}if(typeof it.then=="function")return ir(We,Ue,R(it),Dt);if(it.$$typeof===U)return ir(We,Ue,$d(We,it),Dt);F(We,it)}return typeof it=="string"&&it!==""||typeof it=="number"||typeof it=="bigint"?(it=""+it,Ue!==null&&Ue.tag===6?(g(We,Ue.sibling),Dt=D(Ue,it),Dt.return=We,We=Dt):(g(We,Ue),Dt=_p(it,We.mode,Dt),Dt.return=We,We=Dt),X(We)):g(We,Ue)}return function(We,Ue,it,Dt){try{M=0;var Dn=ir(We,Ue,it,Dt);return T=null,Dn}catch(Sn){if(Sn===xl||Sn===vo)throw Sn;var Li=ia(29,Sn,null,We.mode);return Li.lanes=Dt,Li.return=We,Li}finally{}}}var re=H(!0),me=H(!1),pe=!1;function ge(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ne(o,c){o=o.updateQueue,c.updateQueue===o&&(c.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function Ie(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function Je(o,c,g){var b=o.updateQueue;if(b===null)return null;if(b=b.shared,(Fi&2)!==0){var D=b.pending;return D===null?c.next=c:(c.next=D.next,D.next=c),b.pending=c,c=kd(o),E1(o,null,g),c}return Fd(o,b,c,g),kd(o)}function He(o,c,g){if(c=c.updateQueue,c!==null&&(c=c.shared,(g&4194048)!==0)){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,at(o,g)}}function Ve(o,c){var g=o.updateQueue,b=o.alternate;if(b!==null&&(b=b.updateQueue,g===b)){var D=null,L=null;if(g=g.firstBaseUpdate,g!==null){do{var X={lane:g.lane,tag:g.tag,payload:g.payload,callback:null,next:null};L===null?D=L=X:L=L.next=X,g=g.next}while(g!==null);L===null?D=L=c:L=L.next=c}else D=L=c;g={baseState:b.baseState,firstBaseUpdate:D,lastBaseUpdate:L,shared:b.shared,callbacks:b.callbacks},o.updateQueue=g;return}o=g.lastBaseUpdate,o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=c}var Re=!1;function jt(){if(Re){var o=vr;if(o!==null)throw o}}function pn(o,c,g,b){Re=!1;var D=o.updateQueue;pe=!1;var L=D.firstBaseUpdate,X=D.lastBaseUpdate,oe=D.shared.pending;if(oe!==null){D.shared.pending=null;var Me=oe,rt=Me.next;Me.next=null,X===null?L=rt:X.next=rt,X=Me;var _t=o.alternate;_t!==null&&(_t=_t.updateQueue,oe=_t.lastBaseUpdate,oe!==X&&(oe===null?_t.firstBaseUpdate=rt:oe.next=rt,_t.lastBaseUpdate=Me))}if(L!==null){var Ot=D.baseState;X=0,_t=rt=Me=null,oe=L;do{var st=oe.lane&-536870913,ct=st!==oe.lane;if(ct?(Ti&st)===st:(b&st)===st){st!==0&&st===ah&&(Re=!0),_t!==null&&(_t=_t.next={lane:0,tag:oe.tag,payload:oe.payload,callback:null,next:null});e:{var vn=o,Gn=oe;st=c;var ir=g;switch(Gn.tag){case 1:if(vn=Gn.payload,typeof vn=="function"){Ot=vn.call(ir,Ot,st);break e}Ot=vn;break e;case 3:vn.flags=vn.flags&-65537|128;case 0:if(vn=Gn.payload,st=typeof vn=="function"?vn.call(ir,Ot,st):vn,st==null)break e;Ot=v({},Ot,st);break e;case 2:pe=!0}}st=oe.callback,st!==null&&(o.flags|=64,ct&&(o.flags|=8192),ct=D.callbacks,ct===null?D.callbacks=[st]:ct.push(st))}else ct={lane:st,tag:oe.tag,payload:oe.payload,callback:oe.callback,next:null},_t===null?(rt=_t=ct,Me=Ot):_t=_t.next=ct,X|=st;if(oe=oe.next,oe===null){if(oe=D.shared.pending,oe===null)break;ct=oe,oe=ct.next,ct.next=null,D.lastBaseUpdate=ct,D.shared.pending=null}}while(!0);_t===null&&(Me=Ot),D.baseState=Me,D.firstBaseUpdate=rt,D.lastBaseUpdate=_t,L===null&&(D.shared.lanes=0),ch|=X,o.lanes=X,o.memoizedState=Ot}}function cn(o,c){if(typeof o!="function")throw Error(n(191,o));o.call(c)}function jn(o,c){var g=o.callbacks;if(g!==null)for(o.callbacks=null,o=0;oL?L:8;var X=K.T,oe={};K.T=oe,Hx(o,!1,c,g);try{var Me=D(),rt=K.S;if(rt!==null&&rt(oe,Me),Me!==null&&typeof Me=="object"&&typeof Me.then=="function"){var _t=D1(Me,b);Ep(o,c,_t,bo(o))}else Ep(o,c,b,bo(o))}catch(Ot){Ep(o,c,{then:function(){},status:"rejected",reason:Ot},bo())}finally{ae.p=L,X!==null&&oe.types!==null&&(X.types=oe.types),K.T=X}}function bI(){}function Vx(o,c,g,b){if(o.tag!==5)throw Error(n(476));var D=P4(o).queue;D4(o,D,c,Ae,g===null?bI:function(){return L4(o),g(b)})}function P4(o){var c=o.memoizedState;if(c!==null)return c;c={memoizedState:Ae,baseState:Ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cc,lastRenderedState:Ae},next:null};var g={};return c.next={memoizedState:g,baseState:g,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:cc,lastRenderedState:g},next:null},o.memoizedState=c,o=o.alternate,o!==null&&(o.memoizedState=c),c}function L4(o){var c=P4(o);c.next===null&&(c=o.alternate.memoizedState),Ep(o,c.next.queue,{},bo())}function jx(){return bs(jp)}function U4(){return is().memoizedState}function B4(){return is().memoizedState}function SI(o){for(var c=o.return;c!==null;){switch(c.tag){case 24:case 3:var g=bo();o=Ie(g);var b=Je(c,o,g);b!==null&&(Va(b,c,g),He(b,c,g)),c={cache:Hr()},o.payload=c;return}c=c.return}}function TI(o,c,g){var b=bo();g={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},z1(o)?I4(c,g):(g=vp(o,c,g,b),g!==null&&(Va(g,o,b),F4(g,c,b)))}function O4(o,c,g){var b=bo();Ep(o,c,g,b)}function Ep(o,c,g,b){var D={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null};if(z1(o))I4(c,D);else{var L=o.alternate;if(o.lanes===0&&(L===null||L.lanes===0)&&(L=c.lastRenderedReducer,L!==null))try{var X=c.lastRenderedState,oe=L(X,g);if(D.hasEagerState=!0,D.eagerState=oe,ya(oe,X))return Fd(o,c,D,0),hr===null&&Id(),!1}catch{}finally{}if(g=vp(o,c,D,b),g!==null)return Va(g,o,b),F4(g,c,b),!0}return!1}function Hx(o,c,g,b){if(b={lane:2,revertLane:Sb(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},z1(o)){if(c)throw Error(n(479))}else c=vp(o,g,b,2),c!==null&&Va(c,o,2)}function z1(o){var c=o.alternate;return o===ui||c!==null&&c===ui}function I4(o,c){Xd=L1=!0;var g=o.pending;g===null?c.next=c:(c.next=g.next,g.next=c),o.pending=c}function F4(o,c,g){if((g&4194048)!==0){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,at(o,g)}}var Cp={readContext:bs,use:O1,useCallback:Wr,useContext:Wr,useEffect:Wr,useImperativeHandle:Wr,useLayoutEffect:Wr,useInsertionEffect:Wr,useMemo:Wr,useReducer:Wr,useRef:Wr,useState:Wr,useDebugValue:Wr,useDeferredValue:Wr,useTransition:Wr,useSyncExternalStore:Wr,useId:Wr,useHostTransitionStatus:Wr,useFormState:Wr,useActionState:Wr,useOptimistic:Wr,useMemoCache:Wr,useCacheRefresh:Wr};Cp.useEffectEvent=Wr;var k4={readContext:bs,use:O1,useCallback:function(o,c){return Sa().memoizedState=[o,c===void 0?null:c],o},useContext:bs,useEffect:b4,useImperativeHandle:function(o,c,g){g=g!=null?g.concat([o]):null,F1(4194308,4,M4.bind(null,c,o),g)},useLayoutEffect:function(o,c){return F1(4194308,4,o,c)},useInsertionEffect:function(o,c){F1(4,2,o,c)},useMemo:function(o,c){var g=Sa();c=c===void 0?null:c;var b=o();if(_f){It(!0);try{o()}finally{It(!1)}}return g.memoizedState=[b,c],b},useReducer:function(o,c,g){var b=Sa();if(g!==void 0){var D=g(c);if(_f){It(!0);try{g(c)}finally{It(!1)}}}else D=c;return b.memoizedState=b.baseState=D,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:D},b.queue=o,o=o.dispatch=TI.bind(null,ui,o),[b.memoizedState,o]},useRef:function(o){var c=Sa();return o={current:o},c.memoizedState=o},useState:function(o){o=Fx(o);var c=o.queue,g=O4.bind(null,ui,c);return c.dispatch=g,[o.memoizedState,g]},useDebugValue:Gx,useDeferredValue:function(o,c){var g=Sa();return qx(g,o,c)},useTransition:function(){var o=Fx(!1);return o=D4.bind(null,ui,o.queue,!0,!1),Sa().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,c,g){var b=ui,D=Sa();if(xi){if(g===void 0)throw Error(n(407));g=g()}else{if(g=c(),hr===null)throw Error(n(349));(Ti&127)!==0||a4(b,c,g)}D.memoizedState=g;var L={value:g,getSnapshot:c};return D.queue=L,b4(l4.bind(null,b,L,o),[o]),b.flags|=2048,Qd(9,{destroy:void 0},o4.bind(null,b,L,g,c),null),g},useId:function(){var o=Sa(),c=hr.identifierPrefix;if(xi){var g=Ia,b=Oa;g=(b&~(1<<32-Te(b)-1)).toString(32)+g,c="_"+c+"R_"+g,g=U1++,0<\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof b.is=="string"?X.createElement("select",{is:b.is}):X.createElement("select"),b.multiple?L.multiple=!0:b.size&&(L.size=b.size);break;default:L=typeof b.is=="string"?X.createElement(D,{is:b.is}):X.createElement(D)}}L[zn]=c,L[An]=b;e:for(X=c.child;X!==null;){if(X.tag===5||X.tag===6)L.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===c)break e;for(;X.sibling===null;){if(X.return===null||X.return===c)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}c.stateNode=L;e:switch(Vs(L,D,b),D){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&fc(c)}}return _r(c),sb(c,c.type,o===null?null:o.memoizedProps,c.pendingProps,g),null;case 6:if(o&&c.stateNode!=null)o.memoizedProps!==b&&fc(c);else{if(typeof b!="string"&&c.stateNode===null)throw Error(n(166));if(o=Qe.current,cr(c)){if(o=c.stateNode,g=c.memoizedProps,b=null,D=xs,D!==null)switch(D.tag){case 27:case 5:b=D.memoizedProps}o[zn]=c,o=!!(o.nodeValue===g||b!==null&&b.suppressHydrationWarning===!0||r8(o.nodeValue,g)),o||Xl(c,!0)}else o=a2(o).createTextNode(b),o[zn]=c,c.stateNode=o}return _r(c),null;case 31:if(g=c.memoizedState,o===null||o.memoizedState!==null){if(b=cr(c),g!==null){if(o===null){if(!b)throw Error(n(318));if(o=c.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(557));o[zn]=c}else ic(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;_r(c),o=!1}else g=Tp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=g),o=!0;if(!o)return c.flags&256?(_o(c),c):(_o(c),null);if((c.flags&128)!==0)throw Error(n(558))}return _r(c),null;case 13:if(b=c.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(D=cr(c),b!==null&&b.dehydrated!==null){if(o===null){if(!D)throw Error(n(318));if(D=c.memoizedState,D=D!==null?D.dehydrated:null,!D)throw Error(n(317));D[zn]=c}else ic(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;_r(c),D=!1}else D=Tp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=D),D=!0;if(!D)return c.flags&256?(_o(c),c):(_o(c),null)}return _o(c),(c.flags&128)!==0?(c.lanes=g,c):(g=b!==null,o=o!==null&&o.memoizedState!==null,g&&(b=c.child,D=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(D=b.alternate.memoizedState.cachePool.pool),L=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(L=b.memoizedState.cachePool.pool),L!==D&&(b.flags|=2048)),g!==o&&g&&(c.child.flags|=8192),H1(c,c.updateQueue),_r(c),null);case 4:return Nt(),o===null&&Eb(c.stateNode.containerInfo),_r(c),null;case 10:return Wo(c.type),_r(c),null;case 19:if(Ee(ns),b=c.memoizedState,b===null)return _r(c),null;if(D=(c.flags&128)!==0,L=b.rendering,L===null)if(D)Rp(b,!1);else{if($r!==0||o!==null&&(o.flags&128)!==0)for(o=c.child;o!==null;){if(L=P1(o),L!==null){for(c.flags|=128,Rp(b,!1),o=L.updateQueue,c.updateQueue=o,H1(c,o),c.subtreeFlags=0,o=g,g=c.child;g!==null;)C1(g,o),g=g.sibling;return qe(ns,ns.current&1|2),xi&&Ho(c,b.treeForkCount),c.child}o=o.sibling}b.tail!==null&&Be()>Q1&&(c.flags|=128,D=!0,Rp(b,!1),c.lanes=4194304)}else{if(!D)if(o=P1(L),o!==null){if(c.flags|=128,D=!0,o=o.updateQueue,c.updateQueue=o,H1(c,o),Rp(b,!0),b.tail===null&&b.tailMode==="hidden"&&!L.alternate&&!xi)return _r(c),null}else 2*Be()-b.renderingStartTime>Q1&&g!==536870912&&(c.flags|=128,D=!0,Rp(b,!1),c.lanes=4194304);b.isBackwards?(L.sibling=c.child,c.child=L):(o=b.last,o!==null?o.sibling=L:c.child=L,b.last=L)}return b.tail!==null?(o=b.tail,b.rendering=o,b.tail=o.sibling,b.renderingStartTime=Be(),o.sibling=null,g=ns.current,qe(ns,D?g&1|2:g&1),xi&&Ho(c,b.treeForkCount),o):(_r(c),null);case 22:case 23:return _o(c),Ht(),b=c.memoizedState!==null,o!==null?o.memoizedState!==null!==b&&(c.flags|=8192):b&&(c.flags|=8192),b?(g&536870912)!==0&&(c.flags&128)===0&&(_r(c),c.subtreeFlags&6&&(c.flags|=8192)):_r(c),g=c.updateQueue,g!==null&&H1(c,g.retryQueue),g=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),b=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(b=c.memoizedState.cachePool.pool),b!==g&&(c.flags|=2048),o!==null&&Ee(zt),null;case 24:return g=null,o!==null&&(g=o.memoizedState.cache),c.memoizedState.cache!==g&&(c.flags|=2048),Wo(rn),_r(c),null;case 25:return null;case 30:return null}throw Error(n(156,c.tag))}function NI(o,c){switch(yp(c),c.tag){case 1:return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 3:return Wo(rn),Nt(),o=c.flags,(o&65536)!==0&&(o&128)===0?(c.flags=o&-65537|128,c):null;case 26:case 27:case 5:return Tt(c),null;case 31:if(c.memoizedState!==null){if(_o(c),c.alternate===null)throw Error(n(340));ic()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 13:if(_o(c),o=c.memoizedState,o!==null&&o.dehydrated!==null){if(c.alternate===null)throw Error(n(340));ic()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 19:return Ee(ns),null;case 4:return Nt(),null;case 10:return Wo(c.type),null;case 22:case 23:return _o(c),Ht(),o!==null&&Ee(zt),o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 24:return Wo(rn),null;case 25:return null;default:return null}}function uC(o,c){switch(yp(c),c.tag){case 3:Wo(rn),Nt();break;case 26:case 27:case 5:Tt(c);break;case 4:Nt();break;case 31:c.memoizedState!==null&&_o(c);break;case 13:_o(c);break;case 19:Ee(ns);break;case 10:Wo(c.type);break;case 22:case 23:_o(c),Ht(),o!==null&&Ee(zt);break;case 24:Wo(rn)}}function Dp(o,c){try{var g=c.updateQueue,b=g!==null?g.lastEffect:null;if(b!==null){var D=b.next;g=D;do{if((g.tag&o)===o){b=void 0;var L=g.create,X=g.inst;b=L(),X.destroy=b}g=g.next}while(g!==D)}}catch(oe){Ki(c,c.return,oe)}}function lh(o,c,g){try{var b=c.updateQueue,D=b!==null?b.lastEffect:null;if(D!==null){var L=D.next;b=L;do{if((b.tag&o)===o){var X=b.inst,oe=X.destroy;if(oe!==void 0){X.destroy=void 0,D=c;var Me=g,rt=oe;try{rt()}catch(_t){Ki(D,Me,_t)}}}b=b.next}while(b!==L)}}catch(_t){Ki(c,c.return,_t)}}function cC(o){var c=o.updateQueue;if(c!==null){var g=o.stateNode;try{jn(c,g)}catch(b){Ki(o,o.return,b)}}}function hC(o,c,g){g.props=yf(o.type,o.memoizedProps),g.state=o.memoizedState;try{g.componentWillUnmount()}catch(b){Ki(o,c,b)}}function Pp(o,c){try{var g=o.ref;if(g!==null){switch(o.tag){case 26:case 27:case 5:var b=o.stateNode;break;case 30:b=o.stateNode;break;default:b=o.stateNode}typeof g=="function"?o.refCleanup=g(b):g.current=b}}catch(D){Ki(o,c,D)}}function Ql(o,c){var g=o.ref,b=o.refCleanup;if(g!==null)if(typeof b=="function")try{b()}catch(D){Ki(o,c,D)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof g=="function")try{g(null)}catch(D){Ki(o,c,D)}else g.current=null}function fC(o){var c=o.type,g=o.memoizedProps,b=o.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":g.autoFocus&&b.focus();break e;case"img":g.src?b.src=g.src:g.srcSet&&(b.srcset=g.srcSet)}}catch(D){Ki(o,o.return,D)}}function ab(o,c,g){try{var b=o.stateNode;KI(b,o.type,g,c),b[An]=c}catch(D){Ki(o,o.return,D)}}function dC(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&ph(o.type)||o.tag===4}function ob(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||dC(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&ph(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function lb(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?(g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g).insertBefore(o,c):(c=g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g,c.appendChild(o),g=g._reactRootContainer,g!=null||c.onclick!==null||(c.onclick=er));else if(b!==4&&(b===27&&ph(o.type)&&(g=o.stateNode,c=null),o=o.child,o!==null))for(lb(o,c,g),o=o.sibling;o!==null;)lb(o,c,g),o=o.sibling}function W1(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?g.insertBefore(o,c):g.appendChild(o);else if(b!==4&&(b===27&&ph(o.type)&&(g=o.stateNode),o=o.child,o!==null))for(W1(o,c,g),o=o.sibling;o!==null;)W1(o,c,g),o=o.sibling}function AC(o){var c=o.stateNode,g=o.memoizedProps;try{for(var b=o.type,D=c.attributes;D.length;)c.removeAttributeNode(D[0]);Vs(c,b,g),c[zn]=o,c[An]=g}catch(L){Ki(o,o.return,L)}}var dc=!1,ds=!1,ub=!1,pC=typeof WeakSet=="function"?WeakSet:Set,Bs=null;function RI(o,c){if(o=o.containerInfo,Rb=d2,o=jl(o),Hl(o)){if("selectionStart"in o)var g={start:o.selectionStart,end:o.selectionEnd};else e:{g=(g=o.ownerDocument)&&g.defaultView||window;var b=g.getSelection&&g.getSelection();if(b&&b.rangeCount!==0){g=b.anchorNode;var D=b.anchorOffset,L=b.focusNode;b=b.focusOffset;try{g.nodeType,L.nodeType}catch{g=null;break e}var X=0,oe=-1,Me=-1,rt=0,_t=0,Ot=o,st=null;t:for(;;){for(var ct;Ot!==g||D!==0&&Ot.nodeType!==3||(oe=X+D),Ot!==L||b!==0&&Ot.nodeType!==3||(Me=X+b),Ot.nodeType===3&&(X+=Ot.nodeValue.length),(ct=Ot.firstChild)!==null;)st=Ot,Ot=ct;for(;;){if(Ot===o)break t;if(st===g&&++rt===D&&(oe=X),st===L&&++_t===b&&(Me=X),(ct=Ot.nextSibling)!==null)break;Ot=st,st=Ot.parentNode}Ot=ct}g=oe===-1||Me===-1?null:{start:oe,end:Me}}else g=null}g=g||{start:0,end:0}}else g=null;for(Db={focusedElem:o,selectionRange:g},d2=!1,Bs=c;Bs!==null;)if(c=Bs,o=c.child,(c.subtreeFlags&1028)!==0&&o!==null)o.return=c,Bs=o;else for(;Bs!==null;){switch(c=Bs,L=c.alternate,o=c.flags,c.tag){case 0:if((o&4)!==0&&(o=c.updateQueue,o=o!==null?o.events:null,o!==null))for(g=0;g title"))),Vs(L,b,g),L[zn]=o,ze(L),b=L;break e;case"link":var X=x8("link","href",D).get(b+(g.href||""));if(X){for(var oe=0;oeir&&(X=ir,ir=Gn,Gn=X);var We=Od(oe,Gn),Ue=Od(oe,ir);if(We&&Ue&&(ct.rangeCount!==1||ct.anchorNode!==We.node||ct.anchorOffset!==We.offset||ct.focusNode!==Ue.node||ct.focusOffset!==Ue.offset)){var it=Ot.createRange();it.setStart(We.node,We.offset),ct.removeAllRanges(),Gn>ir?(ct.addRange(it),ct.extend(Ue.node,Ue.offset)):(it.setEnd(Ue.node,Ue.offset),ct.addRange(it))}}}}for(Ot=[],ct=oe;ct=ct.parentNode;)ct.nodeType===1&&Ot.push({element:ct,left:ct.scrollLeft,top:ct.scrollTop});for(typeof oe.focus=="function"&&oe.focus(),oe=0;oeg?32:g,K.T=null,g=mb,mb=null;var L=fh,X=vc;if(Ss=0,tA=fh=null,vc=0,(Fi&6)!==0)throw Error(n(331));var oe=Fi;if(Fi|=4,MC(L.current),SC(L,L.current,X,g),Fi=oe,Fp(0,!1),$t&&typeof $t.onPostCommitFiberRoot=="function")try{$t.onPostCommitFiberRoot(Yt,L)}catch{}return!0}finally{ae.p=D,K.T=b,jC(o,c)}}function WC(o,c,g){c=Ua(g,c),c=Yx(o.stateNode,c,2),o=Je(o,c,2),o!==null&&(pt(o,2),Kl(o))}function Ki(o,c,g){if(o.tag===3)WC(o,o,g);else for(;c!==null;){if(c.tag===3){WC(c,o,g);break}else if(c.tag===1){var b=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(hh===null||!hh.has(b))){o=Ua(g,o),g=$4(2),b=Je(c,g,2),b!==null&&(X4(g,b,c,o),pt(b,2),Kl(b));break}}c=c.return}}function yb(o,c,g){var b=o.pingCache;if(b===null){b=o.pingCache=new LI;var D=new Set;b.set(c,D)}else D=b.get(c),D===void 0&&(D=new Set,b.set(c,D));D.has(g)||(fb=!0,D.add(g),o=FI.bind(null,o,c,g),c.then(o,o))}function FI(o,c,g){var b=o.pingCache;b!==null&&b.delete(c),o.pingedLanes|=o.suspendedLanes&g,o.warmLanes&=~g,hr===o&&(Ti&g)===g&&($r===4||$r===3&&(Ti&62914560)===Ti&&300>Be()-Y1?(Fi&2)===0&&nA(o,0):db|=g,eA===Ti&&(eA=0)),Kl(o)}function $C(o,c){c===0&&(c=St()),o=Ju(o,c),o!==null&&(pt(o,c),Kl(o))}function kI(o){var c=o.memoizedState,g=0;c!==null&&(g=c.retryLane),$C(o,g)}function zI(o,c){var g=0;switch(o.tag){case 31:case 13:var b=o.stateNode,D=o.memoizedState;D!==null&&(g=D.retryLane);break;case 19:b=o.stateNode;break;case 22:b=o.stateNode._retryCache;break;default:throw Error(n(314))}b!==null&&b.delete(c),$C(o,g)}function GI(o,c){return ut(o,c)}var n2=null,rA=null,xb=!1,i2=!1,bb=!1,Ah=0;function Kl(o){o!==rA&&o.next===null&&(rA===null?n2=rA=o:rA=rA.next=o),i2=!0,xb||(xb=!0,VI())}function Fp(o,c){if(!bb&&i2){bb=!0;do for(var g=!1,b=n2;b!==null;){if(o!==0){var D=b.pendingLanes;if(D===0)var L=0;else{var X=b.suspendedLanes,oe=b.pingedLanes;L=(1<<31-Te(42|o)+1)-1,L&=D&~(X&~oe),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(g=!0,KC(b,L))}else L=Ti,L=Kt(b,b===hr?L:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(L&3)===0||un(b,L)||(g=!0,KC(b,L));b=b.next}while(g);bb=!1}}function qI(){XC()}function XC(){i2=xb=!1;var o=0;Ah!==0&&JI()&&(o=Ah);for(var c=Be(),g=null,b=n2;b!==null;){var D=b.next,L=YC(b,c);L===0?(b.next=null,g===null?n2=D:g.next=D,D===null&&(rA=g)):(g=b,(o!==0||(L&3)!==0)&&(i2=!0)),b=D}Ss!==0&&Ss!==5||Fp(o),Ah!==0&&(Ah=0)}function YC(o,c){for(var g=o.suspendedLanes,b=o.pingedLanes,D=o.expirationTimes,L=o.pendingLanes&-62914561;0oe)break;var _t=Me.transferSize,Ot=Me.initiatorType;_t&&s8(Ot)&&(Me=Me.responseEnd,X+=_t*(Me"u"?null:document;function g8(o,c,g){var b=sA;if(b&&typeof c=="string"&&c){var D=Er(c);D='link[rel="'+o+'"][href="'+D+'"]',typeof g=="string"&&(D+='[crossorigin="'+g+'"]'),m8.has(D)||(m8.add(D),o={rel:o,crossOrigin:g,href:c},b.querySelector(D)===null&&(c=b.createElement("link"),Vs(c,"link",o),ze(c),b.head.appendChild(c)))}}function lF(o){_c.D(o),g8("dns-prefetch",o,null)}function uF(o,c){_c.C(o,c),g8("preconnect",o,c)}function cF(o,c,g){_c.L(o,c,g);var b=sA;if(b&&o&&c){var D='link[rel="preload"][as="'+Er(c)+'"]';c==="image"&&g&&g.imageSrcSet?(D+='[imagesrcset="'+Er(g.imageSrcSet)+'"]',typeof g.imageSizes=="string"&&(D+='[imagesizes="'+Er(g.imageSizes)+'"]')):D+='[href="'+Er(o)+'"]';var L=D;switch(c){case"style":L=aA(o);break;case"script":L=oA(o)}Qo.has(L)||(o=v({rel:"preload",href:c==="image"&&g&&g.imageSrcSet?void 0:o,as:c},g),Qo.set(L,o),b.querySelector(D)!==null||c==="style"&&b.querySelector(qp(L))||c==="script"&&b.querySelector(Vp(L))||(c=b.createElement("link"),Vs(c,"link",o),ze(c),b.head.appendChild(c)))}}function hF(o,c){_c.m(o,c);var g=sA;if(g&&o){var b=c&&typeof c.as=="string"?c.as:"script",D='link[rel="modulepreload"][as="'+Er(b)+'"][href="'+Er(o)+'"]',L=D;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=oA(o)}if(!Qo.has(L)&&(o=v({rel:"modulepreload",href:o},c),Qo.set(L,o),g.querySelector(D)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(g.querySelector(Vp(L)))return}b=g.createElement("link"),Vs(b,"link",o),ze(b),g.head.appendChild(b)}}}function fF(o,c,g){_c.S(o,c,g);var b=sA;if(b&&o){var D=Ke(b).hoistableStyles,L=aA(o);c=c||"default";var X=D.get(L);if(!X){var oe={loading:0,preload:null};if(X=b.querySelector(qp(L)))oe.loading=5;else{o=v({rel:"stylesheet",href:o,"data-precedence":c},g),(g=Qo.get(L))&&Fb(o,g);var Me=X=b.createElement("link");ze(Me),Vs(Me,"link",o),Me._p=new Promise(function(rt,_t){Me.onload=rt,Me.onerror=_t}),Me.addEventListener("load",function(){oe.loading|=1}),Me.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,l2(X,c,b)}X={type:"stylesheet",instance:X,count:1,state:oe},D.set(L,X)}}}function dF(o,c){_c.X(o,c);var g=sA;if(g&&o){var b=Ke(g).hoistableScripts,D=oA(o),L=b.get(D);L||(L=g.querySelector(Vp(D)),L||(o=v({src:o,async:!0},c),(c=Qo.get(D))&&kb(o,c),L=g.createElement("script"),ze(L),Vs(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function AF(o,c){_c.M(o,c);var g=sA;if(g&&o){var b=Ke(g).hoistableScripts,D=oA(o),L=b.get(D);L||(L=g.querySelector(Vp(D)),L||(o=v({src:o,async:!0,type:"module"},c),(c=Qo.get(D))&&kb(o,c),L=g.createElement("script"),ze(L),Vs(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function v8(o,c,g,b){var D=(D=Qe.current)?o2(D):null;if(!D)throw Error(n(446));switch(o){case"meta":case"title":return null;case"style":return typeof g.precedence=="string"&&typeof g.href=="string"?(c=aA(g.href),g=Ke(D).hoistableStyles,b=g.get(c),b||(b={type:"style",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(g.rel==="stylesheet"&&typeof g.href=="string"&&typeof g.precedence=="string"){o=aA(g.href);var L=Ke(D).hoistableStyles,X=L.get(o);if(X||(D=D.ownerDocument||D,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(o,X),(L=D.querySelector(qp(o)))&&!L._p&&(X.instance=L,X.state.loading=5),Qo.has(o)||(g={rel:"preload",as:"style",href:g.href,crossOrigin:g.crossOrigin,integrity:g.integrity,media:g.media,hrefLang:g.hrefLang,referrerPolicy:g.referrerPolicy},Qo.set(o,g),L||pF(D,o,g,X.state))),c&&b===null)throw Error(n(528,""));return X}if(c&&b!==null)throw Error(n(529,""));return null;case"script":return c=g.async,g=g.src,typeof g=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=oA(g),g=Ke(D).hoistableScripts,b=g.get(c),b||(b={type:"script",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,o))}}function aA(o){return'href="'+Er(o)+'"'}function qp(o){return'link[rel="stylesheet"]['+o+"]"}function _8(o){return v({},o,{"data-precedence":o.precedence,precedence:null})}function pF(o,c,g,b){o.querySelector('link[rel="preload"][as="style"]['+c+"]")?b.loading=1:(c=o.createElement("link"),b.preload=c,c.addEventListener("load",function(){return b.loading|=1}),c.addEventListener("error",function(){return b.loading|=2}),Vs(c,"link",g),ze(c),o.head.appendChild(c))}function oA(o){return'[src="'+Er(o)+'"]'}function Vp(o){return"script[async]"+o}function y8(o,c,g){if(c.count++,c.instance===null)switch(c.type){case"style":var b=o.querySelector('style[data-href~="'+Er(g.href)+'"]');if(b)return c.instance=b,ze(b),b;var D=v({},g,{"data-href":g.href,"data-precedence":g.precedence,href:null,precedence:null});return b=(o.ownerDocument||o).createElement("style"),ze(b),Vs(b,"style",D),l2(b,g.precedence,o),c.instance=b;case"stylesheet":D=aA(g.href);var L=o.querySelector(qp(D));if(L)return c.state.loading|=4,c.instance=L,ze(L),L;b=_8(g),(D=Qo.get(D))&&Fb(b,D),L=(o.ownerDocument||o).createElement("link"),ze(L);var X=L;return X._p=new Promise(function(oe,Me){X.onload=oe,X.onerror=Me}),Vs(L,"link",b),c.state.loading|=4,l2(L,g.precedence,o),c.instance=L;case"script":return L=oA(g.src),(D=o.querySelector(Vp(L)))?(c.instance=D,ze(D),D):(b=g,(D=Qo.get(L))&&(b=v({},g),kb(b,D)),o=o.ownerDocument||o,D=o.createElement("script"),ze(D),Vs(D,"link",b),o.head.appendChild(D),c.instance=D);case"void":return null;default:throw Error(n(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(b=c.instance,c.state.loading|=4,l2(b,g.precedence,o));return c.instance}function l2(o,c,g){for(var b=g.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),D=b.length?b[b.length-1]:null,L=D,X=0;X title"):null)}function mF(o,c,g){if(g===1||c.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;switch(c.rel){case"stylesheet":return o=c.disabled,typeof c.precedence=="string"&&o==null;default:return!0}case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function S8(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function gF(o,c,g,b){if(g.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(g.state.loading&4)===0){if(g.instance===null){var D=aA(b.href),L=c.querySelector(qp(D));if(L){c=L._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(o.count++,o=c2.bind(o),c.then(o,o)),g.state.loading|=4,g.instance=L,ze(L);return}L=c.ownerDocument||c,b=_8(b),(D=Qo.get(D))&&Fb(b,D),L=L.createElement("link"),ze(L);var X=L;X._p=new Promise(function(oe,Me){X.onload=oe,X.onerror=Me}),Vs(L,"link",b),g.instance=L}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(g,c),(c=g.state.preload)&&(g.state.loading&3)===0&&(o.count++,g=c2.bind(o),c.addEventListener("load",g),c.addEventListener("error",g))}}var zb=0;function vF(o,c){return o.stylesheets&&o.count===0&&f2(o,o.stylesheets),0zb?50:800)+c);return o.unsuspend=g,function(){o.unsuspend=null,clearTimeout(b),clearTimeout(D)}}:null}function c2(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)f2(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var h2=null;function f2(o,c){o.stylesheets=null,o.unsuspend!==null&&(o.count++,h2=new Map,c.forEach(_F,o),h2=null,c2.call(o))}function _F(o,c){if(!(c.state.loading&4)){var g=h2.get(o);if(g)var b=g.get(null);else{g=new Map,h2.set(o,g);for(var D=o.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Xb.exports=BF(),Xb.exports}var IF=OF(),ie=xw();const FF=E7(ie);/** - * @license - * Copyright 2010-2024 Three.js Authors - * SPDX-License-Identifier: MIT - */const W0="172",il={ROTATE:0,DOLLY:1,PAN:2},jA={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},C7=0,HS=1,N7=2,kF=0,bw=1,zF=2,No=3,zl=0,gr=1,gs=2,no=0,io=1,u0=2,c0=3,h0=4,Sw=5,Bo=100,Tw=101,ww=102,R7=103,D7=104,Mw=200,Ew=201,Cw=202,Nw=203,jm=204,Hm=205,Rw=206,Dw=207,Pw=208,Lw=209,Uw=210,GF=211,qF=212,VF=213,jF=214,Wm=0,$m=1,Xm=2,Hh=3,Ym=4,Qm=5,Km=6,Zm=7,Bg=0,P7=1,L7=2,ro=0,U7=1,B7=2,O7=3,I7=4,HF=5,F7=6,k7=7,Bw=300,sl=301,al=302,Wh=303,$h=304,ld=306,ud=1e3,lu=1001,cd=1002,br=1003,s_=1004,uu=1005,Ms=1006,n0=1007,Ya=1008,WF=1008,Aa=1009,Jf=1010,ed=1011,Bl=1012,ks=1013,Ir=1014,ss=1015,Qs=1016,dy=1017,Ay=1018,xu=1020,py=35902,Ow=1021,Og=1022,Xs=1023,Iw=1024,Fw=1025,Au=1026,bu=1027,Ig=1028,$0=1029,hd=1030,X0=1031,$F=1032,Y0=1033,td=33776,Gh=33777,qh=33778,Vh=33779,Jm=35840,eg=35841,tg=35842,ng=35843,ig=36196,f0=37492,d0=37496,A0=37808,p0=37809,m0=37810,g0=37811,v0=37812,_0=37813,y0=37814,x0=37815,b0=37816,S0=37817,T0=37818,w0=37819,M0=37820,E0=37821,nd=36492,WS=36494,$S=36495,kw=36283,rg=36284,sg=36285,ag=36286,XF=0,YF=1,$8=2,QF=3200,KF=3201,kc=0,z7=1,Oo="",Nn="srgb",Io="srgb-linear",a_="linear",Hi="srgb",ZF=0,If=7680,JF=7681,ek=7682,tk=7683,nk=34055,ik=34056,rk=5386,sk=512,ak=513,ok=514,lk=515,uk=516,ck=517,hk=518,XS=519,zw=512,my=513,Gw=514,gy=515,qw=516,Vw=517,jw=518,Hw=519,o_=35044,HA=35048,X8="300 es",Qa=2e3,Su=2001;class Xc{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s>8&255]+oa[i>>16&255]+oa[i>>24&255]+"-"+oa[e&255]+oa[e>>8&255]+"-"+oa[e>>16&15|64]+oa[e>>24&255]+"-"+oa[t&63|128]+oa[t>>8&255]+"-"+oa[t>>16&255]+oa[t>>24&255]+oa[n&255]+oa[n>>8&255]+oa[n>>16&255]+oa[n>>24&255]).toLowerCase()}function ai(i,e,t){return Math.max(e,Math.min(t,i))}function Ww(i,e){return(i%e+e)%e}function fk(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function dk(i,e,t){return i!==e?(t-i)/(e-i):0}function Rm(i,e,t){return(1-t)*i+t*e}function Ak(i,e,t,n){return Rm(i,e,1-Math.exp(-t*n))}function pk(i,e=1){return e-Math.abs(Ww(i,e*2)-e)}function mk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function gk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function vk(i,e){return i+Math.floor(Math.random()*(e-i+1))}function _k(i,e){return i+Math.random()*(e-i)}function yk(i){return i*(.5-Math.random())}function xk(i){i!==void 0&&(Y8=i);let e=Y8+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function bk(i){return i*Nm}function Sk(i){return i*C0}function Tk(i){return(i&i-1)===0&&i!==0}function wk(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Mk(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ek(i,e,t,n,r){const s=Math.cos,a=Math.sin,l=s(t/2),u=a(t/2),h=s((e+n)/2),m=a((e+n)/2),v=s((e-n)/2),x=a((e-n)/2),S=s((n-e)/2),w=a((n-e)/2);switch(r){case"XYX":i.set(l*m,u*v,u*x,l*h);break;case"YZY":i.set(u*x,l*m,u*v,l*h);break;case"ZXZ":i.set(u*v,u*x,l*m,l*h);break;case"XZX":i.set(l*m,u*w,u*S,l*h);break;case"YXY":i.set(u*S,l*m,u*w,l*h);break;case"ZYZ":i.set(u*w,u*S,l*m,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Da(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function ci(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const N0={DEG2RAD:Nm,RAD2DEG:C0,generateUUID:pu,clamp:ai,euclideanModulo:Ww,mapLinear:fk,inverseLerp:dk,lerp:Rm,damp:Ak,pingpong:pk,smoothstep:mk,smootherstep:gk,randInt:vk,randFloat:_k,randFloatSpread:yk,seededRandom:xk,degToRad:bk,radToDeg:Sk,isPowerOfTwo:Tk,ceilPowerOfTwo:wk,floorPowerOfTwo:Mk,setQuaternionFromProperEuler:Ek,normalize:ci,denormalize:Da};class Et{constructor(e=0,t=0){Et.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ai(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ai(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qn{constructor(e,t,n,r,s,a,l,u,h){Qn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h)}set(e,t,n,r,s,a,l,u,h){const m=this.elements;return m[0]=e,m[1]=r,m[2]=l,m[3]=t,m[4]=s,m[5]=u,m[6]=n,m[7]=a,m[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[3],u=n[6],h=n[1],m=n[4],v=n[7],x=n[2],S=n[5],w=n[8],N=r[0],C=r[3],E=r[6],O=r[1],U=r[4],I=r[7],j=r[2],z=r[5],G=r[8];return s[0]=a*N+l*O+u*j,s[3]=a*C+l*U+u*z,s[6]=a*E+l*I+u*G,s[1]=h*N+m*O+v*j,s[4]=h*C+m*U+v*z,s[7]=h*E+m*I+v*G,s[2]=x*N+S*O+w*j,s[5]=x*C+S*U+w*z,s[8]=x*E+S*I+w*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8];return t*a*m-t*l*h-n*s*m+n*l*u+r*s*h-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=m*a-l*h,x=l*u-m*s,S=h*s-a*u,w=t*v+n*x+r*S;if(w===0)return this.set(0,0,0,0,0,0,0,0,0);const N=1/w;return e[0]=v*N,e[1]=(r*h-m*n)*N,e[2]=(l*n-r*a)*N,e[3]=x*N,e[4]=(m*t-r*u)*N,e[5]=(r*s-l*t)*N,e[6]=S*N,e[7]=(n*u-h*t)*N,e[8]=(a*t-n*s)*N,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,l){const u=Math.cos(s),h=Math.sin(s);return this.set(n*u,n*h,-n*(u*a+h*l)+a+e,-r*h,r*u,-r*(-h*a+u*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(Jb.makeScale(e,t)),this}rotate(e){return this.premultiply(Jb.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jb.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Jb=new Qn;function G7(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function og(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function q7(){const i=og("canvas");return i.style.display="block",i}const Q8={};function qf(i){i in Q8||(Q8[i]=!0,console.warn(i))}function Ck(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function Nk(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Rk(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const K8=new Qn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Z8=new Qn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Dk(){const i={enabled:!0,workingColorSpace:Io,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Hi&&(r.r=Uc(r.r),r.g=Uc(r.g),r.b=Uc(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Hi&&(r.r=i0(r.r),r.g=i0(r.g),r.b=i0(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Oo?a_:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Io]:{primaries:e,whitePoint:n,transfer:a_,toXYZ:K8,fromXYZ:Z8,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Nn},outputColorSpaceConfig:{drawingBufferColorSpace:Nn}},[Nn]:{primaries:e,whitePoint:n,transfer:Hi,toXYZ:K8,fromXYZ:Z8,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Nn}}}),i}const hi=Dk();function Uc(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function i0(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let uA;class Pk{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{uA===void 0&&(uA=og("canvas")),uA.width=e.width,uA.height=e.height;const n=uA.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=uA}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=og("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Bw)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ud:e.x=e.x-Math.floor(e.x);break;case lu:e.x=e.x<0?0:1;break;case cd:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ud:e.y=e.y-Math.floor(e.y);break;case lu:e.y=e.y<0?0:1;break;case cd:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Es.DEFAULT_IMAGE=null;Es.DEFAULT_MAPPING=Bw;Es.DEFAULT_ANISOTROPY=1;class qn{constructor(e=0,t=0,n=0,r=1){qn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const u=e.elements,h=u[0],m=u[4],v=u[8],x=u[1],S=u[5],w=u[9],N=u[2],C=u[6],E=u[10];if(Math.abs(m-x)<.01&&Math.abs(v-N)<.01&&Math.abs(w-C)<.01){if(Math.abs(m+x)<.1&&Math.abs(v+N)<.1&&Math.abs(w+C)<.1&&Math.abs(h+S+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const U=(h+1)/2,I=(S+1)/2,j=(E+1)/2,z=(m+x)/4,G=(v+N)/4,W=(w+C)/4;return U>I&&U>j?U<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(U),r=z/n,s=G/n):I>j?I<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(I),n=z/r,s=W/r):j<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(j),n=G/s,r=W/s),this.set(n,r,s,t),this}let O=Math.sqrt((C-w)*(C-w)+(v-N)*(v-N)+(x-m)*(x-m));return Math.abs(O)<.001&&(O=1),this.x=(C-w)/O,this.y=(v-N)/O,this.z=(x-m)/O,this.w=Math.acos((h+S+E-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this.z=ai(this.z,e.z,t.z),this.w=ai(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this.z=ai(this.z,e,t),this.w=ai(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ai(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Zh extends Xc{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new qn(0,0,e,t),this.scissorTest=!1,this.viewport=new qn(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ms,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new Es(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let l=0;l=0?1:-1,U=1-E*E;if(U>Number.EPSILON){const j=Math.sqrt(U),z=Math.atan2(j,E*O);C=Math.sin(C*z)/j,l=Math.sin(l*z)/j}const I=l*O;if(u=u*C+x*I,h=h*C+S*I,m=m*C+w*I,v=v*C+N*I,C===1-l){const j=1/Math.sqrt(u*u+h*h+m*m+v*v);u*=j,h*=j,m*=j,v*=j}}e[t]=u,e[t+1]=h,e[t+2]=m,e[t+3]=v}static multiplyQuaternionsFlat(e,t,n,r,s,a){const l=n[r],u=n[r+1],h=n[r+2],m=n[r+3],v=s[a],x=s[a+1],S=s[a+2],w=s[a+3];return e[t]=l*w+m*v+u*S-h*x,e[t+1]=u*w+m*x+h*v-l*S,e[t+2]=h*w+m*S+l*x-u*v,e[t+3]=m*w-l*v-u*x-h*S,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,l=Math.cos,u=Math.sin,h=l(n/2),m=l(r/2),v=l(s/2),x=u(n/2),S=u(r/2),w=u(s/2);switch(a){case"XYZ":this._x=x*m*v+h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v-x*S*w;break;case"YXZ":this._x=x*m*v+h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v+x*S*w;break;case"ZXY":this._x=x*m*v-h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v-x*S*w;break;case"ZYX":this._x=x*m*v-h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v+x*S*w;break;case"YZX":this._x=x*m*v+h*S*w,this._y=h*S*v+x*m*w,this._z=h*m*w-x*S*v,this._w=h*m*v-x*S*w;break;case"XZY":this._x=x*m*v-h*S*w,this._y=h*S*v-x*m*w,this._z=h*m*w+x*S*v,this._w=h*m*v+x*S*w;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],l=t[5],u=t[9],h=t[2],m=t[6],v=t[10],x=n+l+v;if(x>0){const S=.5/Math.sqrt(x+1);this._w=.25/S,this._x=(m-u)*S,this._y=(s-h)*S,this._z=(a-r)*S}else if(n>l&&n>v){const S=2*Math.sqrt(1+n-l-v);this._w=(m-u)/S,this._x=.25*S,this._y=(r+a)/S,this._z=(s+h)/S}else if(l>v){const S=2*Math.sqrt(1+l-n-v);this._w=(s-h)/S,this._x=(r+a)/S,this._y=.25*S,this._z=(u+m)/S}else{const S=2*Math.sqrt(1+v-n-l);this._w=(a-r)/S,this._x=(s+h)/S,this._y=(u+m)/S,this._z=.25*S}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ai(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,l=t._x,u=t._y,h=t._z,m=t._w;return this._x=n*m+a*l+r*h-s*u,this._y=r*m+a*u+s*l-n*h,this._z=s*m+a*h+n*u-r*l,this._w=a*m-n*l-r*u-s*h,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let l=a*e._w+n*e._x+r*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const u=1-l*l;if(u<=Number.EPSILON){const S=1-t;return this._w=S*a+t*this._w,this._x=S*n+t*this._x,this._y=S*r+t*this._y,this._z=S*s+t*this._z,this.normalize(),this}const h=Math.sqrt(u),m=Math.atan2(h,l),v=Math.sin((1-t)*m)/h,x=Math.sin(t*m)/h;return this._w=a*v+this._w*x,this._x=n*v+this._x*x,this._y=r*v+this._y*x,this._z=s*v+this._z*x,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class de{constructor(e=0,t=0,n=0){de.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(J8.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(J8.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,l=e.z,u=e.w,h=2*(a*r-l*n),m=2*(l*t-s*r),v=2*(s*n-a*t);return this.x=t+u*h+a*v-l*m,this.y=n+u*m+l*h-s*v,this.z=r+u*v+s*m-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this.z=ai(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this.z=ai(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ai(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,l=t.y,u=t.z;return this.x=r*u-s*l,this.y=s*a-n*u,this.z=n*l-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return t3.copy(this).projectOnVector(e),this.sub(t3)}reflect(e){return this.sub(t3.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ai(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const t3=new de,J8=new Tu;class Yc{constructor(e=new de(1/0,1/0,1/0),t=new de(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ml),Ml.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Qp),x2.subVectors(this.max,Qp),cA.subVectors(e.a,Qp),hA.subVectors(e.b,Qp),fA.subVectors(e.c,Qp),xh.subVectors(hA,cA),bh.subVectors(fA,hA),Sf.subVectors(cA,fA);let t=[0,-xh.z,xh.y,0,-bh.z,bh.y,0,-Sf.z,Sf.y,xh.z,0,-xh.x,bh.z,0,-bh.x,Sf.z,0,-Sf.x,-xh.y,xh.x,0,-bh.y,bh.x,0,-Sf.y,Sf.x,0];return!n3(t,cA,hA,fA,x2)||(t=[1,0,0,0,1,0,0,0,1],!n3(t,cA,hA,fA,x2))?!1:(b2.crossVectors(xh,bh),t=[b2.x,b2.y,b2.z],n3(t,cA,hA,fA,x2))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ml).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ml).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(yc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),yc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),yc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),yc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),yc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),yc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),yc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),yc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(yc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const yc=[new de,new de,new de,new de,new de,new de,new de,new de],Ml=new de,y2=new Yc,cA=new de,hA=new de,fA=new de,xh=new de,bh=new de,Sf=new de,Qp=new de,x2=new de,b2=new de,Tf=new de;function n3(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Tf.fromArray(i,s);const l=r.x*Math.abs(Tf.x)+r.y*Math.abs(Tf.y)+r.z*Math.abs(Tf.z),u=e.dot(Tf),h=t.dot(Tf),m=n.dot(Tf);if(Math.max(-Math.max(u,h,m),Math.min(u,h,m))>l)return!1}return!0}const Ok=new Yc,Kp=new de,i3=new de;class gd{constructor(e=new de,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ok.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Kp.subVectors(e,this.center);const t=Kp.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Kp,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(i3.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Kp.copy(e.center).add(i3)),this.expandByPoint(Kp.copy(e.center).sub(i3))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const xc=new de,r3=new de,S2=new de,Sh=new de,s3=new de,T2=new de,a3=new de;class Fg{constructor(e=new de,t=new de(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,xc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=xc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(xc.copy(this.origin).addScaledVector(this.direction,t),xc.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){r3.copy(e).add(t).multiplyScalar(.5),S2.copy(t).sub(e).normalize(),Sh.copy(this.origin).sub(r3);const s=e.distanceTo(t)*.5,a=-this.direction.dot(S2),l=Sh.dot(this.direction),u=-Sh.dot(S2),h=Sh.lengthSq(),m=Math.abs(1-a*a);let v,x,S,w;if(m>0)if(v=a*u-l,x=a*l-u,w=s*m,v>=0)if(x>=-w)if(x<=w){const N=1/m;v*=N,x*=N,S=v*(v+a*x+2*l)+x*(a*v+x+2*u)+h}else x=s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x=-s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x<=-w?(v=Math.max(0,-(-a*s+l)),x=v>0?-s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h):x<=w?(v=0,x=Math.min(Math.max(-s,-u),s),S=x*(x+2*u)+h):(v=Math.max(0,-(a*s+l)),x=v>0?s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h);else x=a>0?-s:s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,v),r&&r.copy(r3).addScaledVector(S2,x),S}intersectSphere(e,t){xc.subVectors(e.center,this.origin);const n=xc.dot(this.direction),r=xc.dot(xc)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),l=n-a,u=n+a;return u<0?null:l<0?this.at(u,t):this.at(l,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,l,u;const h=1/this.direction.x,m=1/this.direction.y,v=1/this.direction.z,x=this.origin;return h>=0?(n=(e.min.x-x.x)*h,r=(e.max.x-x.x)*h):(n=(e.max.x-x.x)*h,r=(e.min.x-x.x)*h),m>=0?(s=(e.min.y-x.y)*m,a=(e.max.y-x.y)*m):(s=(e.max.y-x.y)*m,a=(e.min.y-x.y)*m),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a=0?(l=(e.min.z-x.z)*v,u=(e.max.z-x.z)*v):(l=(e.max.z-x.z)*v,u=(e.min.z-x.z)*v),n>u||l>r)||((l>n||n!==n)&&(n=l),(u=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,xc)!==null}intersectTriangle(e,t,n,r,s){s3.subVectors(t,e),T2.subVectors(n,e),a3.crossVectors(s3,T2);let a=this.direction.dot(a3),l;if(a>0){if(r)return null;l=1}else if(a<0)l=-1,a=-a;else return null;Sh.subVectors(this.origin,e);const u=l*this.direction.dot(T2.crossVectors(Sh,T2));if(u<0)return null;const h=l*this.direction.dot(s3.cross(Sh));if(h<0||u+h>a)return null;const m=-l*Sh.dot(a3);return m<0?null:this.at(m/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Xn{constructor(e,t,n,r,s,a,l,u,h,m,v,x,S,w,N,C){Xn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h,m,v,x,S,w,N,C)}set(e,t,n,r,s,a,l,u,h,m,v,x,S,w,N,C){const E=this.elements;return E[0]=e,E[4]=t,E[8]=n,E[12]=r,E[1]=s,E[5]=a,E[9]=l,E[13]=u,E[2]=h,E[6]=m,E[10]=v,E[14]=x,E[3]=S,E[7]=w,E[11]=N,E[15]=C,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Xn().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/dA.setFromMatrixColumn(e,0).length(),s=1/dA.setFromMatrixColumn(e,1).length(),a=1/dA.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),l=Math.sin(n),u=Math.cos(r),h=Math.sin(r),m=Math.cos(s),v=Math.sin(s);if(e.order==="XYZ"){const x=a*m,S=a*v,w=l*m,N=l*v;t[0]=u*m,t[4]=-u*v,t[8]=h,t[1]=S+w*h,t[5]=x-N*h,t[9]=-l*u,t[2]=N-x*h,t[6]=w+S*h,t[10]=a*u}else if(e.order==="YXZ"){const x=u*m,S=u*v,w=h*m,N=h*v;t[0]=x+N*l,t[4]=w*l-S,t[8]=a*h,t[1]=a*v,t[5]=a*m,t[9]=-l,t[2]=S*l-w,t[6]=N+x*l,t[10]=a*u}else if(e.order==="ZXY"){const x=u*m,S=u*v,w=h*m,N=h*v;t[0]=x-N*l,t[4]=-a*v,t[8]=w+S*l,t[1]=S+w*l,t[5]=a*m,t[9]=N-x*l,t[2]=-a*h,t[6]=l,t[10]=a*u}else if(e.order==="ZYX"){const x=a*m,S=a*v,w=l*m,N=l*v;t[0]=u*m,t[4]=w*h-S,t[8]=x*h+N,t[1]=u*v,t[5]=N*h+x,t[9]=S*h-w,t[2]=-h,t[6]=l*u,t[10]=a*u}else if(e.order==="YZX"){const x=a*u,S=a*h,w=l*u,N=l*h;t[0]=u*m,t[4]=N-x*v,t[8]=w*v+S,t[1]=v,t[5]=a*m,t[9]=-l*m,t[2]=-h*m,t[6]=S*v+w,t[10]=x-N*v}else if(e.order==="XZY"){const x=a*u,S=a*h,w=l*u,N=l*h;t[0]=u*m,t[4]=-v,t[8]=h*m,t[1]=x*v+N,t[5]=a*m,t[9]=S*v-w,t[2]=w*v-S,t[6]=l*m,t[10]=N*v+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ik,e,Fk)}lookAt(e,t,n){const r=this.elements;return So.subVectors(e,t),So.lengthSq()===0&&(So.z=1),So.normalize(),Th.crossVectors(n,So),Th.lengthSq()===0&&(Math.abs(n.z)===1?So.x+=1e-4:So.z+=1e-4,So.normalize(),Th.crossVectors(n,So)),Th.normalize(),w2.crossVectors(So,Th),r[0]=Th.x,r[4]=w2.x,r[8]=So.x,r[1]=Th.y,r[5]=w2.y,r[9]=So.y,r[2]=Th.z,r[6]=w2.z,r[10]=So.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[4],u=n[8],h=n[12],m=n[1],v=n[5],x=n[9],S=n[13],w=n[2],N=n[6],C=n[10],E=n[14],O=n[3],U=n[7],I=n[11],j=n[15],z=r[0],G=r[4],W=r[8],q=r[12],V=r[1],Y=r[5],te=r[9],ne=r[13],le=r[2],Q=r[6],K=r[10],ae=r[14],Ae=r[3],be=r[7],Se=r[11],se=r[15];return s[0]=a*z+l*V+u*le+h*Ae,s[4]=a*G+l*Y+u*Q+h*be,s[8]=a*W+l*te+u*K+h*Se,s[12]=a*q+l*ne+u*ae+h*se,s[1]=m*z+v*V+x*le+S*Ae,s[5]=m*G+v*Y+x*Q+S*be,s[9]=m*W+v*te+x*K+S*Se,s[13]=m*q+v*ne+x*ae+S*se,s[2]=w*z+N*V+C*le+E*Ae,s[6]=w*G+N*Y+C*Q+E*be,s[10]=w*W+N*te+C*K+E*Se,s[14]=w*q+N*ne+C*ae+E*se,s[3]=O*z+U*V+I*le+j*Ae,s[7]=O*G+U*Y+I*Q+j*be,s[11]=O*W+U*te+I*K+j*Se,s[15]=O*q+U*ne+I*ae+j*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],l=e[5],u=e[9],h=e[13],m=e[2],v=e[6],x=e[10],S=e[14],w=e[3],N=e[7],C=e[11],E=e[15];return w*(+s*u*v-r*h*v-s*l*x+n*h*x+r*l*S-n*u*S)+N*(+t*u*S-t*h*x+s*a*x-r*a*S+r*h*m-s*u*m)+C*(+t*h*v-t*l*S-s*a*v+n*a*S+s*l*m-n*h*m)+E*(-r*l*m-t*u*v+t*l*x+r*a*v-n*a*x+n*u*m)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=e[9],x=e[10],S=e[11],w=e[12],N=e[13],C=e[14],E=e[15],O=v*C*h-N*x*h+N*u*S-l*C*S-v*u*E+l*x*E,U=w*x*h-m*C*h-w*u*S+a*C*S+m*u*E-a*x*E,I=m*N*h-w*v*h+w*l*S-a*N*S-m*l*E+a*v*E,j=w*v*u-m*N*u-w*l*x+a*N*x+m*l*C-a*v*C,z=t*O+n*U+r*I+s*j;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const G=1/z;return e[0]=O*G,e[1]=(N*x*s-v*C*s-N*r*S+n*C*S+v*r*E-n*x*E)*G,e[2]=(l*C*s-N*u*s+N*r*h-n*C*h-l*r*E+n*u*E)*G,e[3]=(v*u*s-l*x*s-v*r*h+n*x*h+l*r*S-n*u*S)*G,e[4]=U*G,e[5]=(m*C*s-w*x*s+w*r*S-t*C*S-m*r*E+t*x*E)*G,e[6]=(w*u*s-a*C*s-w*r*h+t*C*h+a*r*E-t*u*E)*G,e[7]=(a*x*s-m*u*s+m*r*h-t*x*h-a*r*S+t*u*S)*G,e[8]=I*G,e[9]=(w*v*s-m*N*s-w*n*S+t*N*S+m*n*E-t*v*E)*G,e[10]=(a*N*s-w*l*s+w*n*h-t*N*h-a*n*E+t*l*E)*G,e[11]=(m*l*s-a*v*s-m*n*h+t*v*h+a*n*S-t*l*S)*G,e[12]=j*G,e[13]=(m*N*r-w*v*r+w*n*x-t*N*x-m*n*C+t*v*C)*G,e[14]=(w*l*r-a*N*r-w*n*u+t*N*u+a*n*C-t*l*C)*G,e[15]=(a*v*r-m*l*r+m*n*u-t*v*u-a*n*x+t*l*x)*G,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,l=e.y,u=e.z,h=s*a,m=s*l;return this.set(h*a+n,h*l-r*u,h*u+r*l,0,h*l+r*u,m*l+n,m*u-r*a,0,h*u-r*l,m*u+r*a,s*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,l=t._z,u=t._w,h=s+s,m=a+a,v=l+l,x=s*h,S=s*m,w=s*v,N=a*m,C=a*v,E=l*v,O=u*h,U=u*m,I=u*v,j=n.x,z=n.y,G=n.z;return r[0]=(1-(N+E))*j,r[1]=(S+I)*j,r[2]=(w-U)*j,r[3]=0,r[4]=(S-I)*z,r[5]=(1-(x+E))*z,r[6]=(C+O)*z,r[7]=0,r[8]=(w+U)*G,r[9]=(C-O)*G,r[10]=(1-(x+N))*G,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=dA.set(r[0],r[1],r[2]).length();const a=dA.set(r[4],r[5],r[6]).length(),l=dA.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],El.copy(this);const h=1/s,m=1/a,v=1/l;return El.elements[0]*=h,El.elements[1]*=h,El.elements[2]*=h,El.elements[4]*=m,El.elements[5]*=m,El.elements[6]*=m,El.elements[8]*=v,El.elements[9]*=v,El.elements[10]*=v,t.setFromRotationMatrix(El),n.x=s,n.y=a,n.z=l,this}makePerspective(e,t,n,r,s,a,l=Qa){const u=this.elements,h=2*s/(t-e),m=2*s/(n-r),v=(t+e)/(t-e),x=(n+r)/(n-r);let S,w;if(l===Qa)S=-(a+s)/(a-s),w=-2*a*s/(a-s);else if(l===Su)S=-a/(a-s),w=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=h,u[4]=0,u[8]=v,u[12]=0,u[1]=0,u[5]=m,u[9]=x,u[13]=0,u[2]=0,u[6]=0,u[10]=S,u[14]=w,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,s,a,l=Qa){const u=this.elements,h=1/(t-e),m=1/(n-r),v=1/(a-s),x=(t+e)*h,S=(n+r)*m;let w,N;if(l===Qa)w=(a+s)*v,N=-2*v;else if(l===Su)w=s*v,N=-1*v;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=2*h,u[4]=0,u[8]=0,u[12]=-x,u[1]=0,u[5]=2*m,u[9]=0,u[13]=-S,u[2]=0,u[6]=0,u[10]=N,u[14]=-w,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const dA=new de,El=new Xn,Ik=new de(0,0,0),Fk=new de(1,1,1),Th=new de,w2=new de,So=new de,eN=new Xn,tN=new Tu;class ma{constructor(e=0,t=0,n=0,r=ma.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],l=r[8],u=r[1],h=r[5],m=r[9],v=r[2],x=r[6],S=r[10];switch(t){case"XYZ":this._y=Math.asin(ai(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-m,S),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(x,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ai(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(l,S),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-v,s),this._z=0);break;case"ZXY":this._x=Math.asin(ai(x,-1,1)),Math.abs(x)<.9999999?(this._y=Math.atan2(-v,S),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-ai(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(x,S),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(ai(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-m,h),this._y=Math.atan2(-v,s)):(this._x=0,this._y=Math.atan2(l,S));break;case"XZY":this._z=Math.asin(-ai(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(x,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-m,S),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return eN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(eN,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return tN.setFromEuler(this),this.setFromQuaternion(tN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ma.DEFAULT_ORDER="XYZ";class Xw{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(l,u){return l[u.uuid]===void 0&&(l[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const u=l.shapes;if(Array.isArray(u))for(let h=0,m=u.length;h0){r.children=[];for(let l=0;l0){r.animations=[];for(let l=0;l0&&(n.geometries=l),u.length>0&&(n.materials=u),h.length>0&&(n.textures=h),m.length>0&&(n.images=m),v.length>0&&(n.shapes=v),x.length>0&&(n.skeletons=x),S.length>0&&(n.animations=S),w.length>0&&(n.nodes=w)}return n.object=r,n;function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Cl.subVectors(r,t),Sc.subVectors(n,t),l3.subVectors(e,t);const a=Cl.dot(Cl),l=Cl.dot(Sc),u=Cl.dot(l3),h=Sc.dot(Sc),m=Sc.dot(l3),v=a*h-l*l;if(v===0)return s.set(0,0,0),null;const x=1/v,S=(h*u-l*m)*x,w=(a*m-l*u)*x;return s.set(1-S-w,w,S)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Tc)===null?!1:Tc.x>=0&&Tc.y>=0&&Tc.x+Tc.y<=1}static getInterpolation(e,t,n,r,s,a,l,u){return this.getBarycoord(e,t,n,r,Tc)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(s,Tc.x),u.addScaledVector(a,Tc.y),u.addScaledVector(l,Tc.z),u)}static getInterpolatedAttribute(e,t,n,r,s,a){return f3.setScalar(0),d3.setScalar(0),A3.setScalar(0),f3.fromBufferAttribute(e,t),d3.fromBufferAttribute(e,n),A3.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(f3,s.x),a.addScaledVector(d3,s.y),a.addScaledVector(A3,s.z),a}static isFrontFacing(e,t,n,r){return Cl.subVectors(n,t),Sc.subVectors(e,t),Cl.cross(Sc).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Cl.subVectors(this.c,this.b),Sc.subVectors(this.a,this.b),Cl.cross(Sc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ll.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ll.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Ll.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Ll.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ll.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,l;mA.subVectors(r,n),gA.subVectors(s,n),u3.subVectors(e,n);const u=mA.dot(u3),h=gA.dot(u3);if(u<=0&&h<=0)return t.copy(n);c3.subVectors(e,r);const m=mA.dot(c3),v=gA.dot(c3);if(m>=0&&v<=m)return t.copy(r);const x=u*v-m*h;if(x<=0&&u>=0&&m<=0)return a=u/(u-m),t.copy(n).addScaledVector(mA,a);h3.subVectors(e,s);const S=mA.dot(h3),w=gA.dot(h3);if(w>=0&&S<=w)return t.copy(s);const N=S*h-u*w;if(N<=0&&h>=0&&w<=0)return l=h/(h-w),t.copy(n).addScaledVector(gA,l);const C=m*w-S*v;if(C<=0&&v-m>=0&&S-w>=0)return oN.subVectors(s,r),l=(v-m)/(v-m+(S-w)),t.copy(r).addScaledVector(oN,l);const E=1/(C+N+x);return a=N*E,l=x*E,t.copy(n).addScaledVector(mA,a).addScaledVector(gA,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const j7={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},wh={h:0,s:0,l:0},E2={h:0,s:0,l:0};function p3(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let mn=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Nn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,hi.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=hi.workingColorSpace){return this.r=e,this.g=t,this.b=n,hi.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=hi.workingColorSpace){if(e=Ww(e,1),t=ai(t,0,1),n=ai(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=p3(a,s,e+1/3),this.g=p3(a,s,e),this.b=p3(a,s,e-1/3)}return hi.toWorkingColorSpace(this,r),this}setStyle(e,t=Nn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],l=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Nn){const n=j7[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Uc(e.r),this.g=Uc(e.g),this.b=Uc(e.b),this}copyLinearToSRGB(e){return this.r=i0(e.r),this.g=i0(e.g),this.b=i0(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nn){return hi.fromWorkingColorSpace(la.copy(this),e),Math.round(ai(la.r*255,0,255))*65536+Math.round(ai(la.g*255,0,255))*256+Math.round(ai(la.b*255,0,255))}getHexString(e=Nn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=hi.workingColorSpace){hi.fromWorkingColorSpace(la.copy(this),t);const n=la.r,r=la.g,s=la.b,a=Math.max(n,r,s),l=Math.min(n,r,s);let u,h;const m=(l+a)/2;if(l===a)u=0,h=0;else{const v=a-l;switch(h=m<=.5?v/(a+l):v/(2-a-l),a){case n:u=(r-s)/v+(r0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==io&&(n.blending=this.blending),this.side!==zl&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==jm&&(n.blendSrc=this.blendSrc),this.blendDst!==Hm&&(n.blendDst=this.blendDst),this.blendEquation!==Bo&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Hh&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==XS&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==If&&(n.stencilFail=this.stencilFail),this.stencilZFail!==If&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==If&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const l in s){const u=s[l];delete u.metadata,a.push(u)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class vd extends ga{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new mn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ma,this.combine=Bg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Rc=jk();function jk(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const h=u-127;h<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):h<-14?(n[u]=1024>>-h-14,n[u|256]=1024>>-h-14|32768,r[u]=-h-1,r[u|256]=-h-1):h<=15?(n[u]=h+15<<10,n[u|256]=h+15<<10|32768,r[u]=13,r[u|256]=13):h<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),l=new Uint32Array(64);for(let u=1;u<1024;++u){let h=u<<13,m=0;for(;(h&8388608)===0;)h<<=1,m-=8388608;h&=-8388609,m+=947912704,s[u]=h|m}for(let u=1024;u<2048;++u)s[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(l[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:l}}function To(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=ai(i,-65504,65504),Rc.floatView[0]=i;const e=Rc.uint32View[0],t=e>>23&511;return Rc.baseTable[t]+((e&8388607)>>Rc.shiftTable[t])}function C2(i){const e=i>>10;return Rc.uint32View[0]=Rc.mantissaTable[Rc.offsetTable[e]+(i&1023)]+Rc.exponentTable[e],Rc.floatView[0]}const As=new de,N2=new Et;class Lr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=o_,this.updateRanges=[],this.gpuType=ss,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;rt.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yc);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new de(-1/0,-1/0,-1/0),new de(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const h in u)u[h]!==void 0&&(e[h]=u[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const h=n[u];e.data.attributes[u]=h.toJSON(e.data)}const r={};let s=!1;for(const u in this.morphAttributes){const h=this.morphAttributes[u],m=[];for(let v=0,x=h.length;v0&&(r[u]=m,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const h in r){const m=r[h];this.setAttribute(h,m.clone(t))}const s=e.morphAttributes;for(const h in s){const m=[],v=s[h];for(let x=0,S=v.length;x0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s(e.far-e.near)**2))&&(lN.copy(s).invert(),wf.copy(e.ray).applyMatrix4(lN),!(n.boundingBox!==null&&wf.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,wf)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,l=s.index,u=s.attributes.position,h=s.attributes.uv,m=s.attributes.uv1,v=s.attributes.normal,x=s.groups,S=s.drawRange;if(l!==null)if(Array.isArray(a))for(let w=0,N=x.length;wt.far?null:{distance:h,point:B2.clone(),object:i}}function O2(i,e,t,n,r,s,a,l,u,h){i.getVertexPosition(l,D2),i.getVertexPosition(u,P2),i.getVertexPosition(h,L2);const m=Wk(i,e,t,n,D2,P2,L2,cN);if(m){const v=new de;Ll.getBarycoord(cN,D2,P2,L2,v),r&&(m.uv=Ll.getInterpolatedAttribute(r,l,u,h,v,new Et)),s&&(m.uv1=Ll.getInterpolatedAttribute(s,l,u,h,v,new Et)),a&&(m.normal=Ll.getInterpolatedAttribute(a,l,u,h,v,new de),m.normal.dot(n.direction)>0&&m.normal.multiplyScalar(-1));const x={a:l,b:u,c:h,normal:new de,materialIndex:0};Ll.getNormal(D2,P2,L2,x.normal),m.face=x,m.barycoord=v}return m}class Jh extends Ji{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const u=[],h=[],m=[],v=[];let x=0,S=0;w("z","y","x",-1,-1,n,t,e,a,s,0),w("z","y","x",1,-1,n,t,-e,a,s,1),w("x","z","y",1,1,e,n,t,r,a,2),w("x","z","y",1,-1,e,n,-t,r,a,3),w("x","y","z",1,-1,e,t,n,r,s,4),w("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(u),this.setAttribute("position",new Ci(h,3)),this.setAttribute("normal",new Ci(m,3)),this.setAttribute("uv",new Ci(v,2));function w(N,C,E,O,U,I,j,z,G,W,q){const V=I/G,Y=j/W,te=I/2,ne=j/2,le=z/2,Q=G+1,K=W+1;let ae=0,Ae=0;const be=new de;for(let Se=0;Se0?1:-1,m.push(be.x,be.y,be.z),v.push(Ee/G),v.push(1-Se/W),ae+=1}}for(let Se=0;Se0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class _y extends Tr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xn,this.projectionMatrix=new Xn,this.projectionMatrixInverse=new Xn,this.coordinateSystem=Qa}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Mh=new de,hN=new Et,fN=new Et;class Ea extends _y{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=C0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Nm*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return C0*2*Math.atan(Math.tan(Nm*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Mh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Mh.x,Mh.y).multiplyScalar(-e/Mh.z),Mh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Mh.x,Mh.y).multiplyScalar(-e/Mh.z)}getViewSize(e,t){return this.getViewBounds(e,hN,fN),t.subVectors(fN,hN)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Nm*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,h=a.fullHeight;s+=a.offsetX*r/u,t-=a.offsetY*n/h,r*=a.width/u,n*=a.height/h}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const _A=-90,yA=1;class $7 extends Tr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ea(_A,yA,e,t);r.layers=this.layers,this.add(r);const s=new Ea(_A,yA,e,t);s.layers=this.layers,this.add(s);const a=new Ea(_A,yA,e,t);a.layers=this.layers,this.add(a);const l=new Ea(_A,yA,e,t);l.layers=this.layers,this.add(l);const u=new Ea(_A,yA,e,t);u.layers=this.layers,this.add(u);const h=new Ea(_A,yA,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,l,u]=t;for(const h of t)this.remove(h);if(e===Qa)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===Su)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,l,u,h,m]=this.children,v=e.getRenderTarget(),x=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),w=e.xr.enabled;e.xr.enabled=!1;const N=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,l),e.setRenderTarget(n,3,r),e.render(t,u),e.setRenderTarget(n,4,r),e.render(t,h),n.texture.generateMipmaps=N,e.setRenderTarget(n,5,r),e.render(t,m),e.setRenderTarget(v,x,S),e.xr.enabled=w,n.texture.needsPMREMUpdate=!0}}class yy extends Es{constructor(e,t,n,r,s,a,l,u,h,m){e=e!==void 0?e:[],t=t!==void 0?t:sl,super(e,t,n,r,s,a,l,u,h,m),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class X7 extends Xh{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new yy(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Ms}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` - - varying vec3 vWorldDirection; - - vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); - - } - - void main() { - - vWorldDirection = transformDirection( position, modelMatrix ); - - #include - #include - - } - `,fragmentShader:` - - uniform sampler2D tEquirect; - - varying vec3 vWorldDirection; - - #include - - void main() { - - vec3 direction = normalize( vWorldDirection ); - - vec2 sampleUV = equirectUv( direction ); - - gl_FragColor = texture2D( tEquirect, sampleUV ); - - } - `},r=new Jh(5,5,5),s=new so({name:"CubemapFromEquirect",uniforms:R0(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:gr,blending:no});s.uniforms.tEquirect.value=t;const a=new qi(r,s),l=t.minFilter;return t.minFilter===Ya&&(t.minFilter=Ms),new $7(1,10,this).update(e,a),t.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class Kw extends Tr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ma,this.environmentIntensity=1,this.environmentRotation=new ma,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Zw{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=o_,this.updateRanges=[],this.version=0,this.uuid=pu()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Jk.getNormalMatrix(e),r=this.coplanarPoint(v3).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Mf=new gd,I2=new de;class zg{constructor(e=new iu,t=new iu,n=new iu,r=new iu,s=new iu,a=new iu){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(s),l[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Qa){const n=this.planes,r=e.elements,s=r[0],a=r[1],l=r[2],u=r[3],h=r[4],m=r[5],v=r[6],x=r[7],S=r[8],w=r[9],N=r[10],C=r[11],E=r[12],O=r[13],U=r[14],I=r[15];if(n[0].setComponents(u-s,x-h,C-S,I-E).normalize(),n[1].setComponents(u+s,x+h,C+S,I+E).normalize(),n[2].setComponents(u+a,x+m,C+w,I+O).normalize(),n[3].setComponents(u-a,x-m,C-w,I-O).normalize(),n[4].setComponents(u-l,x-v,C-N,I-U).normalize(),t===Qa)n[5].setComponents(u+l,x+v,C+N,I+U).normalize();else if(t===Su)n[5].setComponents(l,v,N,U).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Mf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Mf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Mf)}intersectsSprite(e){return Mf.center.set(0,0,0),Mf.radius=.7071067811865476,Mf.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mf)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,I2.y=r.normal.y>0?e.max.y:e.min.y,I2.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(I2)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Q0 extends ga{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new mn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const l_=new de,u_=new de,dN=new Xn,em=new Fg,F2=new gd,_3=new de,AN=new de;class xy extends Tr{constructor(e=new Ji,t=new Q0){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sn)return;_3.applyMatrix4(i.matrixWorld);const u=e.ray.origin.distanceTo(_3);if(!(ue.far))return{distance:u,point:AN.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const pN=new de,mN=new de;class Y7 extends xy{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}let Ka=class extends Tr{constructor(){super(),this.isGroup=!0,this.type="Group"}};class Q7 extends Es{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=br,this.minFilter=br,this.generateMipmaps=!1,this.needsUpdate=!0}}class Qc extends Es{constructor(e,t,n,r,s,a,l,u,h,m=Au){if(m!==Au&&m!==bu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&m===Au&&(n=Ir),n===void 0&&m===bu&&(n=xu),super(null,r,s,a,l,u,m,n,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:br,this.minFilter=u!==void 0?u:br,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class ql{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let l=0,u=s-1,h;for(;l<=u;)if(r=Math.floor(l+(u-l)/2),h=n[r]-a,h<0)l=r+1;else if(h>0)u=r-1;else{u=r;break}if(r=u,n[r]===a)return r/(s-1);const m=n[r],x=n[r+1]-m,S=(a-m)/x;return(r+S)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),l=this.getPoint(s),u=t||(a.isVector2?new Et:new de);return u.copy(l).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new de,r=[],s=[],a=[],l=new de,u=new Xn;for(let S=0;S<=e;S++){const w=S/e;r[S]=this.getTangentAt(w,new de)}s[0]=new de,a[0]=new de;let h=Number.MAX_VALUE;const m=Math.abs(r[0].x),v=Math.abs(r[0].y),x=Math.abs(r[0].z);m<=h&&(h=m,n.set(1,0,0)),v<=h&&(h=v,n.set(0,1,0)),x<=h&&n.set(0,0,1),l.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],l),a[0].crossVectors(r[0],s[0]);for(let S=1;S<=e;S++){if(s[S]=s[S-1].clone(),a[S]=a[S-1].clone(),l.crossVectors(r[S-1],r[S]),l.length()>Number.EPSILON){l.normalize();const w=Math.acos(ai(r[S-1].dot(r[S]),-1,1));s[S].applyMatrix4(u.makeRotationAxis(l,w))}a[S].crossVectors(r[S],s[S])}if(t===!0){let S=Math.acos(ai(s[0].dot(s[e]),-1,1));S/=e,r[0].dot(l.crossVectors(s[0],s[e]))>0&&(S=-S);for(let w=1;w<=e;w++)s[w].applyMatrix4(u.makeRotationAxis(r[w],S*w)),a[w].crossVectors(r[w],s[w])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class eM extends ql{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,l=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=l,this.aRotation=u}getPoint(e,t=new Et){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(l)/s)+1)*s:u===0&&l===s-1&&(l=s-2,u=1);let h,m;this.closed||l>0?h=r[(l-1)%s]:(q2.subVectors(r[0],r[1]).add(r[0]),h=q2);const v=r[l%s],x=r[(l+1)%s];if(this.closed||l+2r.length-2?r.length-1:a+1],v=r[a>r.length-3?r.length-1:a+2];return n.set(_N(l,u.x,h.x,m.x,v.x),_N(l,u.y,h.y,m.y,v.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[s]-n,l=this.curves[s],u=l.getLength(),h=u===0?0:1-a/u;return l.getPointAt(h,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const v=h.getPoint(0);v.equals(this.currentPoint)||this.lineTo(v.x,v.y)}this.curves.push(h);const m=h.getPoint(1);return this.currentPoint.copy(m),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class by extends Ji{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],l=[],u=[],h=new de,m=new Et;a.push(0,0,0),l.push(0,0,1),u.push(.5,.5);for(let v=0,x=3;v<=t;v++,x+=3){const S=n+v/t*r;h.x=e*Math.cos(S),h.y=e*Math.sin(S),a.push(h.x,h.y,h.z),l.push(0,0,1),m.x=(a[x]/e+1)/2,m.y=(a[x+1]/e+1)/2,u.push(m.x,m.y)}for(let v=1;v<=t;v++)s.push(v,v+1,0);this.setIndex(s),this.setAttribute("position",new Ci(a,3)),this.setAttribute("normal",new Ci(l,3)),this.setAttribute("uv",new Ci(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new by(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class nM extends Ji{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:l,thetaLength:u};const h=this;r=Math.floor(r),s=Math.floor(s);const m=[],v=[],x=[],S=[];let w=0;const N=[],C=n/2;let E=0;O(),a===!1&&(e>0&&U(!0),t>0&&U(!1)),this.setIndex(m),this.setAttribute("position",new Ci(v,3)),this.setAttribute("normal",new Ci(x,3)),this.setAttribute("uv",new Ci(S,2));function O(){const I=new de,j=new de;let z=0;const G=(t-e)/n;for(let W=0;W<=s;W++){const q=[],V=W/s,Y=V*(t-e)+e;for(let te=0;te<=r;te++){const ne=te/r,le=ne*u+l,Q=Math.sin(le),K=Math.cos(le);j.x=Y*Q,j.y=-V*n+C,j.z=Y*K,v.push(j.x,j.y,j.z),I.set(Q,G,K).normalize(),x.push(I.x,I.y,I.z),S.push(ne,1-V),q.push(w++)}N.push(q)}for(let W=0;W0||q!==0)&&(m.push(V,Y,ne),z+=3),(t>0||q!==s-1)&&(m.push(Y,te,ne),z+=3)}h.addGroup(E,z,0),E+=z}function U(I){const j=w,z=new Et,G=new de;let W=0;const q=I===!0?e:t,V=I===!0?1:-1;for(let te=1;te<=r;te++)v.push(0,C*V,0),x.push(0,V,0),S.push(.5,.5),w++;const Y=w;for(let te=0;te<=r;te++){const le=te/r*u+l,Q=Math.cos(le),K=Math.sin(le);G.x=q*K,G.y=C*V,G.z=q*Q,v.push(G.x,G.y,G.z),x.push(0,V,0),z.x=Q*.5+.5,z.y=K*.5*V+.5,S.push(z.x,z.y),w++}for(let te=0;te80*t){l=h=i[0],u=m=i[1];for(let w=t;wh&&(h=v),x>m&&(m=x);S=Math.max(h-l,m-u),S=S!==0?32767/S:0}return lg(s,a,t,l,u,S,0),a}};function iD(i,e,t,n,r){let s,a;if(r===Cz(i,e,t,n)>0)for(s=e;s=e;s-=n)a=yN(s,i[s],i[s+1],a);return a&&Sy(a,a.next)&&(cg(a),a=a.next),a}function fd(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Sy(t,t.next)||Fr(t.prev,t,t.next)===0)){if(cg(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function lg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&bz(i,n,r,s);let l=i,u,h;for(;i.prev!==i.next;){if(u=i.prev,h=i.next,s?Az(i,n,r,s):dz(i)){e.push(u.i/t|0),e.push(i.i/t|0),e.push(h.i/t|0),cg(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=pz(fd(i),e,t),lg(i,e,t,n,r,s,2)):a===2&&mz(i,e,t,n,r,s):lg(fd(i),e,t,n,r,s,1);break}}}function dz(i){const e=i.prev,t=i,n=i.next;if(Fr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=rs?r>a?r:a:s>a?s:a,S=l>u?l>h?l:h:u>h?u:h;let w=n.next;for(;w!==e;){if(w.x>=m&&w.x<=x&&w.y>=v&&w.y<=S&&WA(r,l,s,u,a,h,w.x,w.y)&&Fr(w.prev,w,w.next)>=0)return!1;w=w.next}return!0}function Az(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Fr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=lu?l>h?l:h:u>h?u:h,C=m>v?m>x?m:x:v>x?v:x,E=KS(S,w,e,t,n),O=KS(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=w&&U.y<=C&&U!==r&&U!==a&&WA(l,m,u,v,h,x,U.x,U.y)&&Fr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=w&&I.y<=C&&I!==r&&I!==a&&WA(l,m,u,v,h,x,I.x,I.y)&&Fr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=w&&U.y<=C&&U!==r&&U!==a&&WA(l,m,u,v,h,x,U.x,U.y)&&Fr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=w&&I.y<=C&&I!==r&&I!==a&&WA(l,m,u,v,h,x,I.x,I.y)&&Fr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function pz(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!Sy(r,s)&&rD(r,n,n.next,s)&&ug(r,s)&&ug(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),cg(n),cg(n.next),n=i=s),n=n.next}while(n!==i);return fd(n)}function mz(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&wz(a,l)){let u=sD(a,l);a=fd(a,a.next),u=fd(u,u.next),lg(a,e,t,n,r,s,0),lg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function gz(i,e,t,n){const r=[];let s,a,l,u,h;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const x=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=s&&x>n&&(n=x,r=t.x=t.x&&t.x>=u&&s!==t.x&&WA(ar.x||t.x===r.x&&xz(r,t)))&&(r=t,m=v)),t=t.next;while(t!==l);return r}function xz(i,e){return Fr(i.prev,i,e.prev)<0&&Fr(e.next,i,i.next)<0}function bz(i,e,t,n){let r=i;do r.z===0&&(r.z=KS(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Sz(r)}function Sz(i){let e,t,n,r,s,a,l,u,h=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,l=0,e=0;e0||u>0&&n;)l!==0&&(u===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,l--):(r=n,n=n.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,h*=2}while(a>1);return i}function KS(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function Tz(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function wz(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Mz(i,e)&&(ug(i,e)&&ug(e,i)&&Ez(i,e)&&(Fr(i.prev,i,e.prev)||Fr(i,e.prev,e))||Sy(i,e)&&Fr(i.prev,i,i.next)>0&&Fr(e.prev,e,e.next)>0)}function Fr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Sy(i,e){return i.x===e.x&&i.y===e.y}function rD(i,e,t,n){const r=j2(Fr(i,e,t)),s=j2(Fr(i,e,n)),a=j2(Fr(t,n,i)),l=j2(Fr(t,n,e));return!!(r!==s&&a!==l||r===0&&V2(i,t,e)||s===0&&V2(i,n,e)||a===0&&V2(t,i,n)||l===0&&V2(t,e,n))}function V2(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function j2(i){return i>0?1:i<0?-1:0}function Mz(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&rD(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ug(i,e){return Fr(i.prev,i,i.next)<0?Fr(i,e,i.next)>=0&&Fr(i,i.prev,e)>=0:Fr(i,e,i.prev)<0||Fr(i,i.next,e)<0}function Ez(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function sD(i,e){const t=new ZS(i.i,i.x,i.y),n=new ZS(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function yN(i,e,t,n){const r=new ZS(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function cg(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ZS(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Cz(i,e,t,n){let r=0;for(let s=e,a=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function bN(i,e){for(let t=0;tNumber.EPSILON){const Be=Math.sqrt(k),Oe=Math.sqrt(ut*ut+fe*fe),je=dt.x-hn/Be,Bt=dt.y+Lt/Be,yt=he.x-fe/Oe,Xt=he.y+ut/Oe,ln=((yt-je)*fe-(Xt-Bt)*ut)/(Lt*fe-hn*ut);en=je+Lt*ln-Ge.x,wt=Bt+hn*ln-Ge.y;const mt=en*en+wt*wt;if(mt<=2)return new Et(en,wt);qt=Math.sqrt(mt/2)}else{let Be=!1;Lt>Number.EPSILON?ut>Number.EPSILON&&(Be=!0):Lt<-Number.EPSILON?ut<-Number.EPSILON&&(Be=!0):Math.sign(hn)===Math.sign(fe)&&(Be=!0),Be?(en=-hn,wt=Lt,qt=Math.sqrt(k)):(en=Lt,wt=hn,qt=Math.sqrt(k/2))}return new Et(en/qt,wt/qt)}const be=[];for(let Ge=0,dt=le.length,he=dt-1,en=Ge+1;Ge=0;Ge--){const dt=Ge/C,he=S*Math.cos(dt*Math.PI/2),en=w*Math.sin(dt*Math.PI/2)+N;for(let wt=0,qt=le.length;wt=0;){const en=he;let wt=he-1;wt<0&&(wt=Ge.length-1);for(let qt=0,Lt=m+C*2;qt0)&&S.push(U,I,z),(E!==n-1||u0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class oD extends ga{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new mn(16777215),this.specular=new mn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ma,this.combine=Bg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Uz extends ga{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new mn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Bz extends ga{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Kc extends ga{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new mn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new mn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ma,this.combine=Bg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Oz extends ga{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=QF,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Iz extends ga{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Fz extends ga{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new mn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kc,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class kz extends Q0{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const TN={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class zz{constructor(e,t,n){const r=this;let s=!1,a=0,l=0,u;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(m){l++,s===!1&&r.onStart!==void 0&&r.onStart(m,a,l),s=!0},this.itemEnd=function(m){a++,r.onProgress!==void 0&&r.onProgress(m,a,l),a===l&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(m){r.onError!==void 0&&r.onError(m)},this.resolveURL=function(m){return u?u(m):m},this.setURLModifier=function(m){return u=m,this},this.addHandler=function(m,v){return h.push(m,v),this},this.removeHandler=function(m){const v=h.indexOf(m);return v!==-1&&h.splice(v,2),this},this.getHandler=function(m){for(let v=0,x=h.length;vNumber.EPSILON){if(V<0&&(G=O[z],q=-q,W=O[j],V=-V),E.yW.y)continue;if(E.y===G.y){if(E.x===G.x)return!0}else{const Y=V*(E.x-G.x)-q*(E.y-G.y);if(Y===0)return!0;if(Y<0)continue;I=!I}}else{if(E.y!==G.y)continue;if(W.x<=E.x&&E.x<=G.x||G.x<=E.x&&E.x<=W.x)return!0}}return I}const r=r0.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,l,u;const h=[];if(s.length===1)return l=s[0],u=new Gv,u.curves=l.curves,h.push(u),h;let m=!r(s[0].getPoints());m=e?!m:m;const v=[],x=[];let S=[],w=0,N;x[w]=void 0,S[w]=[];for(let E=0,O=s.length;E1){let E=!1,O=0;for(let U=0,I=x.length;U0&&E===!1&&(S=v)}let C;for(let E=0,O=x.length;ES.start-w.start);let x=0;for(let S=1;S 0 - vec4 plane; - #ifdef ALPHA_TO_COVERAGE - float distanceToPlane, distanceGradient; - float clipOpacity = 1.0; - #pragma unroll_loop_start - for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; - distanceGradient = fwidth( distanceToPlane ) / 2.0; - clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); - if ( clipOpacity == 0.0 ) discard; - } - #pragma unroll_loop_end - #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES - float unionClipOpacity = 1.0; - #pragma unroll_loop_start - for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; - distanceGradient = fwidth( distanceToPlane ) / 2.0; - unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); - } - #pragma unroll_loop_end - clipOpacity *= 1.0 - unionClipOpacity; - #endif - diffuseColor.a *= clipOpacity; - if ( diffuseColor.a == 0.0 ) discard; - #else - #pragma unroll_loop_start - for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; - } - #pragma unroll_loop_end - #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES - bool clipped = true; - #pragma unroll_loop_start - for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { - plane = clippingPlanes[ i ]; - clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; - } - #pragma unroll_loop_end - if ( clipped ) discard; - #endif - #endif -#endif`,yG=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; - uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,xG=`#if NUM_CLIPPING_PLANES > 0 - varying vec3 vClipPosition; -#endif`,bG=`#if NUM_CLIPPING_PLANES > 0 - vClipPosition = - mvPosition.xyz; -#endif`,SG=`#if defined( USE_COLOR_ALPHA ) - diffuseColor *= vColor; -#elif defined( USE_COLOR ) - diffuseColor.rgb *= vColor; -#endif`,TG=`#if defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#elif defined( USE_COLOR ) - varying vec3 vColor; -#endif`,wG=`#if defined( USE_COLOR_ALPHA ) - varying vec4 vColor; -#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) - varying vec3 vColor; -#endif`,MG=`#if defined( USE_COLOR_ALPHA ) - vColor = vec4( 1.0 ); -#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) - vColor = vec3( 1.0 ); -#endif -#ifdef USE_COLOR - vColor *= color; -#endif -#ifdef USE_INSTANCING_COLOR - vColor.xyz *= instanceColor.xyz; -#endif -#ifdef USE_BATCHING_COLOR - vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); - vColor.xyz *= batchingColor.xyz; -#endif`,EG=`#define PI 3.141592653589793 -#define PI2 6.283185307179586 -#define PI_HALF 1.5707963267948966 -#define RECIPROCAL_PI 0.3183098861837907 -#define RECIPROCAL_PI2 0.15915494309189535 -#define EPSILON 1e-6 -#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -#define whiteComplement( a ) ( 1.0 - saturate( a ) ) -float pow2( const in float x ) { return x*x; } -vec3 pow2( const in vec3 x ) { return x*x; } -float pow3( const in float x ) { return x*x*x; } -float pow4( const in float x ) { float x2 = x*x; return x2*x2; } -float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } -float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } -highp float rand( const in vec2 uv ) { - const highp float a = 12.9898, b = 78.233, c = 43758.5453; - highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); - return fract( sin( sn ) * c ); -} -#ifdef HIGH_PRECISION - float precisionSafeLength( vec3 v ) { return length( v ); } -#else - float precisionSafeLength( vec3 v ) { - float maxComponent = max3( abs( v ) ); - return length( v / maxComponent ) * maxComponent; - } -#endif -struct IncidentLight { - vec3 color; - vec3 direction; - bool visible; -}; -struct ReflectedLight { - vec3 directDiffuse; - vec3 directSpecular; - vec3 indirectDiffuse; - vec3 indirectSpecular; -}; -#ifdef USE_ALPHAHASH - varying vec3 vPosition; -#endif -vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); -} -vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { - return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); -} -mat3 transposeMat3( const in mat3 m ) { - mat3 tmp; - tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); - tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); - tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); - return tmp; -} -bool isPerspectiveMatrix( mat4 m ) { - return m[ 2 ][ 3 ] == - 1.0; -} -vec2 equirectUv( in vec3 dir ) { - float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; - float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; - return vec2( u, v ); -} -vec3 BRDF_Lambert( const in vec3 diffuseColor ) { - return RECIPROCAL_PI * diffuseColor; -} -vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} -float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { - float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); - return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,CG=`#ifdef ENVMAP_TYPE_CUBE_UV - #define cubeUV_minMipLevel 4.0 - #define cubeUV_minTileSize 16.0 - float getFace( vec3 direction ) { - vec3 absDirection = abs( direction ); - float face = - 1.0; - if ( absDirection.x > absDirection.z ) { - if ( absDirection.x > absDirection.y ) - face = direction.x > 0.0 ? 0.0 : 3.0; - else - face = direction.y > 0.0 ? 1.0 : 4.0; - } else { - if ( absDirection.z > absDirection.y ) - face = direction.z > 0.0 ? 2.0 : 5.0; - else - face = direction.y > 0.0 ? 1.0 : 4.0; - } - return face; - } - vec2 getUV( vec3 direction, float face ) { - vec2 uv; - if ( face == 0.0 ) { - uv = vec2( direction.z, direction.y ) / abs( direction.x ); - } else if ( face == 1.0 ) { - uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); - } else if ( face == 2.0 ) { - uv = vec2( - direction.x, direction.y ) / abs( direction.z ); - } else if ( face == 3.0 ) { - uv = vec2( - direction.z, direction.y ) / abs( direction.x ); - } else if ( face == 4.0 ) { - uv = vec2( - direction.x, direction.z ) / abs( direction.y ); - } else { - uv = vec2( direction.x, direction.y ) / abs( direction.z ); - } - return 0.5 * ( uv + 1.0 ); - } - vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { - float face = getFace( direction ); - float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); - mipInt = max( mipInt, cubeUV_minMipLevel ); - float faceSize = exp2( mipInt ); - highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; - if ( face > 2.0 ) { - uv.y += faceSize; - face -= 3.0; - } - uv.x += face * faceSize; - uv.x += filterInt * 3.0 * cubeUV_minTileSize; - uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); - uv.x *= CUBEUV_TEXEL_WIDTH; - uv.y *= CUBEUV_TEXEL_HEIGHT; - #ifdef texture2DGradEXT - return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; - #else - return texture2D( envMap, uv ).rgb; - #endif - } - #define cubeUV_r0 1.0 - #define cubeUV_m0 - 2.0 - #define cubeUV_r1 0.8 - #define cubeUV_m1 - 1.0 - #define cubeUV_r4 0.4 - #define cubeUV_m4 2.0 - #define cubeUV_r5 0.305 - #define cubeUV_m5 3.0 - #define cubeUV_r6 0.21 - #define cubeUV_m6 4.0 - float roughnessToMip( float roughness ) { - float mip = 0.0; - if ( roughness >= cubeUV_r1 ) { - mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; - } else if ( roughness >= cubeUV_r4 ) { - mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; - } else if ( roughness >= cubeUV_r5 ) { - mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; - } else if ( roughness >= cubeUV_r6 ) { - mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; - } else { - mip = - 2.0 * log2( 1.16 * roughness ); } - return mip; - } - vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { - float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); - float mipF = fract( mip ); - float mipInt = floor( mip ); - vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); - if ( mipF == 0.0 ) { - return vec4( color0, 1.0 ); - } else { - vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); - return vec4( mix( color0, color1, mipF ), 1.0 ); - } - } -#endif`,NG=`vec3 transformedNormal = objectNormal; -#ifdef USE_TANGENT - vec3 transformedTangent = objectTangent; -#endif -#ifdef USE_BATCHING - mat3 bm = mat3( batchingMatrix ); - transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); - transformedNormal = bm * transformedNormal; - #ifdef USE_TANGENT - transformedTangent = bm * transformedTangent; - #endif -#endif -#ifdef USE_INSTANCING - mat3 im = mat3( instanceMatrix ); - transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); - transformedNormal = im * transformedNormal; - #ifdef USE_TANGENT - transformedTangent = im * transformedTangent; - #endif -#endif -transformedNormal = normalMatrix * transformedNormal; -#ifdef FLIP_SIDED - transformedNormal = - transformedNormal; -#endif -#ifdef USE_TANGENT - transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; - #ifdef FLIP_SIDED - transformedTangent = - transformedTangent; - #endif -#endif`,RG=`#ifdef USE_DISPLACEMENTMAP - uniform sampler2D displacementMap; - uniform float displacementScale; - uniform float displacementBias; -#endif`,DG=`#ifdef USE_DISPLACEMENTMAP - transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,PG=`#ifdef USE_EMISSIVEMAP - vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); - #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE - emissiveColor = sRGBTransferEOTF( emissiveColor ); - #endif - totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,LG=`#ifdef USE_EMISSIVEMAP - uniform sampler2D emissiveMap; -#endif`,UG="gl_FragColor = linearToOutputTexel( gl_FragColor );",BG=`vec4 LinearTransferOETF( in vec4 value ) { - return value; -} -vec4 sRGBTransferEOTF( in vec4 value ) { - return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); -} -vec4 sRGBTransferOETF( in vec4 value ) { - return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); -}`,OG=`#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vec3 cameraToFrag; - if ( isOrthographic ) { - cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToFrag = normalize( vWorldPosition - cameraPosition ); - } - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vec3 reflectVec = reflect( cameraToFrag, worldNormal ); - #else - vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); - #endif - #else - vec3 reflectVec = vReflect; - #endif - #ifdef ENVMAP_TYPE_CUBE - vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); - #else - vec4 envColor = vec4( 0.0 ); - #endif - #ifdef ENVMAP_BLENDING_MULTIPLY - outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_MIX ) - outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); - #elif defined( ENVMAP_BLENDING_ADD ) - outgoingLight += envColor.xyz * specularStrength * reflectivity; - #endif -#endif`,IG=`#ifdef USE_ENVMAP - uniform float envMapIntensity; - uniform float flipEnvMap; - uniform mat3 envMapRotation; - #ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; - #else - uniform sampler2D envMap; - #endif - -#endif`,FG=`#ifdef USE_ENVMAP - uniform float reflectivity; - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) - #define ENV_WORLDPOS - #endif - #ifdef ENV_WORLDPOS - varying vec3 vWorldPosition; - uniform float refractionRatio; - #else - varying vec3 vReflect; - #endif -#endif`,kG=`#ifdef USE_ENVMAP - #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) - #define ENV_WORLDPOS - #endif - #ifdef ENV_WORLDPOS - - varying vec3 vWorldPosition; - #else - varying vec3 vReflect; - uniform float refractionRatio; - #endif -#endif`,zG=`#ifdef USE_ENVMAP - #ifdef ENV_WORLDPOS - vWorldPosition = worldPosition.xyz; - #else - vec3 cameraToVertex; - if ( isOrthographic ) { - cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); - } else { - cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); - } - vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - #ifdef ENVMAP_MODE_REFLECTION - vReflect = reflect( cameraToVertex, worldNormal ); - #else - vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); - #endif - #endif -#endif`,GG=`#ifdef USE_FOG - vFogDepth = - mvPosition.z; -#endif`,qG=`#ifdef USE_FOG - varying float vFogDepth; -#endif`,VG=`#ifdef USE_FOG - #ifdef FOG_EXP2 - float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); - #else - float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); - #endif - gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,jG=`#ifdef USE_FOG - uniform vec3 fogColor; - varying float vFogDepth; - #ifdef FOG_EXP2 - uniform float fogDensity; - #else - uniform float fogNear; - uniform float fogFar; - #endif -#endif`,HG=`#ifdef USE_GRADIENTMAP - uniform sampler2D gradientMap; -#endif -vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { - float dotNL = dot( normal, lightDirection ); - vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); - #ifdef USE_GRADIENTMAP - return vec3( texture2D( gradientMap, coord ).r ); - #else - vec2 fw = fwidth( coord ) * 0.5; - return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); - #endif -}`,WG=`#ifdef USE_LIGHTMAP - uniform sampler2D lightMap; - uniform float lightMapIntensity; -#endif`,$G=`LambertMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,XG=`varying vec3 vViewPosition; -struct LambertMaterial { - vec3 diffuseColor; - float specularStrength; -}; -void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,YG=`uniform bool receiveShadow; -uniform vec3 ambientLightColor; -#if defined( USE_LIGHT_PROBES ) - uniform vec3 lightProbe[ 9 ]; -#endif -vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { - float x = normal.x, y = normal.y, z = normal.z; - vec3 result = shCoefficients[ 0 ] * 0.886227; - result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; - result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; - result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; - result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; - result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; - result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); - result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; - result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); - return result; -} -vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); - return irradiance; -} -vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { - vec3 irradiance = ambientLightColor; - return irradiance; -} -float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { - float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); - if ( cutoffDistance > 0.0 ) { - distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); - } - return distanceFalloff; -} -float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { - return smoothstep( coneCosine, penumbraCosine, angleCosine ); -} -#if NUM_DIR_LIGHTS > 0 - struct DirectionalLight { - vec3 direction; - vec3 color; - }; - uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; - void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { - light.color = directionalLight.color; - light.direction = directionalLight.direction; - light.visible = true; - } -#endif -#if NUM_POINT_LIGHTS > 0 - struct PointLight { - vec3 position; - vec3 color; - float distance; - float decay; - }; - uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; - void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { - vec3 lVector = pointLight.position - geometryPosition; - light.direction = normalize( lVector ); - float lightDistance = length( lVector ); - light.color = pointLight.color; - light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } -#endif -#if NUM_SPOT_LIGHTS > 0 - struct SpotLight { - vec3 position; - vec3 direction; - vec3 color; - float distance; - float decay; - float coneCos; - float penumbraCos; - }; - uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; - void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { - vec3 lVector = spotLight.position - geometryPosition; - light.direction = normalize( lVector ); - float angleCos = dot( light.direction, spotLight.direction ); - float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); - if ( spotAttenuation > 0.0 ) { - float lightDistance = length( lVector ); - light.color = spotLight.color * spotAttenuation; - light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); - light.visible = ( light.color != vec3( 0.0 ) ); - } else { - light.color = vec3( 0.0 ); - light.visible = false; - } - } -#endif -#if NUM_RECT_AREA_LIGHTS > 0 - struct RectAreaLight { - vec3 color; - vec3 position; - vec3 halfWidth; - vec3 halfHeight; - }; - uniform sampler2D ltc_1; uniform sampler2D ltc_2; - uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; -#endif -#if NUM_HEMI_LIGHTS > 0 - struct HemisphereLight { - vec3 direction; - vec3 skyColor; - vec3 groundColor; - }; - uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; - vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { - float dotNL = dot( normal, hemiLight.direction ); - float hemiDiffuseWeight = 0.5 * dotNL + 0.5; - vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); - return irradiance; - } -#endif`,QG=`#ifdef USE_ENVMAP - vec3 getIBLIrradiance( const in vec3 normal ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); - return PI * envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 reflectVec = reflect( - viewDir, normal ); - reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); - reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); - vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); - return envMapColor.rgb * envMapIntensity; - #else - return vec3( 0.0 ); - #endif - } - #ifdef USE_ANISOTROPY - vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { - #ifdef ENVMAP_TYPE_CUBE_UV - vec3 bentNormal = cross( bitangent, viewDir ); - bentNormal = normalize( cross( bentNormal, bitangent ) ); - bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); - return getIBLRadiance( viewDir, bentNormal, roughness ); - #else - return vec3( 0.0 ); - #endif - } - #endif -#endif`,KG=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,ZG=`varying vec3 vViewPosition; -struct ToonMaterial { - vec3 diffuseColor; -}; -void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { - vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,JG=`BlinnPhongMaterial material; -material.diffuseColor = diffuseColor.rgb; -material.specularColor = specular; -material.specularShininess = shininess; -material.specularStrength = specularStrength;`,eq=`varying vec3 vViewPosition; -struct BlinnPhongMaterial { - vec3 diffuseColor; - vec3 specularColor; - float specularShininess; - float specularStrength; -}; -void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); - reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; -} -void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -#define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,tq=`PhysicalMaterial material; -material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); -vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); -float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); -material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; -material.roughness = min( material.roughness, 1.0 ); -#ifdef IOR - material.ior = ior; - #ifdef USE_SPECULAR - float specularIntensityFactor = specularIntensity; - vec3 specularColorFactor = specularColor; - #ifdef USE_SPECULAR_COLORMAP - specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; - #endif - #ifdef USE_SPECULAR_INTENSITYMAP - specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; - #endif - material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); - #else - float specularIntensityFactor = 1.0; - vec3 specularColorFactor = vec3( 1.0 ); - material.specularF90 = 1.0; - #endif - material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); -#else - material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); - material.specularF90 = 1.0; -#endif -#ifdef USE_CLEARCOAT - material.clearcoat = clearcoat; - material.clearcoatRoughness = clearcoatRoughness; - material.clearcoatF0 = vec3( 0.04 ); - material.clearcoatF90 = 1.0; - #ifdef USE_CLEARCOATMAP - material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; - #endif - #ifdef USE_CLEARCOAT_ROUGHNESSMAP - material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; - #endif - material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); - material.clearcoatRoughness += geometryRoughness; - material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); -#endif -#ifdef USE_DISPERSION - material.dispersion = dispersion; -#endif -#ifdef USE_IRIDESCENCE - material.iridescence = iridescence; - material.iridescenceIOR = iridescenceIOR; - #ifdef USE_IRIDESCENCEMAP - material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; - #endif - #ifdef USE_IRIDESCENCE_THICKNESSMAP - material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; - #else - material.iridescenceThickness = iridescenceThicknessMaximum; - #endif -#endif -#ifdef USE_SHEEN - material.sheenColor = sheenColor; - #ifdef USE_SHEEN_COLORMAP - material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; - #endif - material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); - #ifdef USE_SHEEN_ROUGHNESSMAP - material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; - #endif -#endif -#ifdef USE_ANISOTROPY - #ifdef USE_ANISOTROPYMAP - mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); - vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; - vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; - #else - vec2 anisotropyV = anisotropyVector; - #endif - material.anisotropy = length( anisotropyV ); - if( material.anisotropy == 0.0 ) { - anisotropyV = vec2( 1.0, 0.0 ); - } else { - anisotropyV /= material.anisotropy; - material.anisotropy = saturate( material.anisotropy ); - } - material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); - material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; - material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,nq=`struct PhysicalMaterial { - vec3 diffuseColor; - float roughness; - vec3 specularColor; - float specularF90; - float dispersion; - #ifdef USE_CLEARCOAT - float clearcoat; - float clearcoatRoughness; - vec3 clearcoatF0; - float clearcoatF90; - #endif - #ifdef USE_IRIDESCENCE - float iridescence; - float iridescenceIOR; - float iridescenceThickness; - vec3 iridescenceFresnel; - vec3 iridescenceF0; - #endif - #ifdef USE_SHEEN - vec3 sheenColor; - float sheenRoughness; - #endif - #ifdef IOR - float ior; - #endif - #ifdef USE_TRANSMISSION - float transmission; - float transmissionAlpha; - float thickness; - float attenuationDistance; - vec3 attenuationColor; - #endif - #ifdef USE_ANISOTROPY - float anisotropy; - float alphaT; - vec3 anisotropyT; - vec3 anisotropyB; - #endif -}; -vec3 clearcoatSpecularDirect = vec3( 0.0 ); -vec3 clearcoatSpecularIndirect = vec3( 0.0 ); -vec3 sheenSpecularDirect = vec3( 0.0 ); -vec3 sheenSpecularIndirect = vec3(0.0 ); -vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { - float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); - float x2 = x * x; - float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); - return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); -} -float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { - float a2 = pow2( alpha ); - float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); - float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); - return 0.5 / max( gv + gl, EPSILON ); -} -float D_GGX( const in float alpha, const in float dotNH ) { - float a2 = pow2( alpha ); - float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; - return RECIPROCAL_PI * a2 / pow2( denom ); -} -#ifdef USE_ANISOTROPY - float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { - float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); - float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); - float v = 0.5 / ( gv + gl ); - return saturate(v); - } - float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { - float a2 = alphaT * alphaB; - highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); - highp float v2 = dot( v, v ); - float w2 = a2 / v2; - return RECIPROCAL_PI * a2 * pow2 ( w2 ); - } -#endif -#ifdef USE_CLEARCOAT - vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { - vec3 f0 = material.clearcoatF0; - float f90 = material.clearcoatF90; - float roughness = material.clearcoatRoughness; - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - return F * ( V * D ); - } -#endif -vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { - vec3 f0 = material.specularColor; - float f90 = material.specularF90; - float roughness = material.roughness; - float alpha = pow2( roughness ); - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float dotVH = saturate( dot( viewDir, halfDir ) ); - vec3 F = F_Schlick( f0, f90, dotVH ); - #ifdef USE_IRIDESCENCE - F = mix( F, material.iridescenceFresnel, material.iridescence ); - #endif - #ifdef USE_ANISOTROPY - float dotTL = dot( material.anisotropyT, lightDir ); - float dotTV = dot( material.anisotropyT, viewDir ); - float dotTH = dot( material.anisotropyT, halfDir ); - float dotBL = dot( material.anisotropyB, lightDir ); - float dotBV = dot( material.anisotropyB, viewDir ); - float dotBH = dot( material.anisotropyB, halfDir ); - float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); - float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); - #else - float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); - float D = D_GGX( alpha, dotNH ); - #endif - return F * ( V * D ); -} -vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { - const float LUT_SIZE = 64.0; - const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; - const float LUT_BIAS = 0.5 / LUT_SIZE; - float dotNV = saturate( dot( N, V ) ); - vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); - uv = uv * LUT_SCALE + LUT_BIAS; - return uv; -} -float LTC_ClippedSphereFormFactor( const in vec3 f ) { - float l = length( f ); - return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); -} -vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { - float x = dot( v1, v2 ); - float y = abs( x ); - float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; - float b = 3.4175940 + ( 4.1616724 + y ) * y; - float v = a / b; - float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; - return cross( v1, v2 ) * theta_sintheta; -} -vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { - vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; - vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; - vec3 lightNormal = cross( v1, v2 ); - if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); - vec3 T1, T2; - T1 = normalize( V - N * dot( V, N ) ); - T2 = - cross( N, T1 ); - mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); - vec3 coords[ 4 ]; - coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); - coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); - coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); - coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); - coords[ 0 ] = normalize( coords[ 0 ] ); - coords[ 1 ] = normalize( coords[ 1 ] ); - coords[ 2 ] = normalize( coords[ 2 ] ); - coords[ 3 ] = normalize( coords[ 3 ] ); - vec3 vectorFormFactor = vec3( 0.0 ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); - vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); - float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); - return vec3( result ); -} -#if defined( USE_SHEEN ) -float D_Charlie( float roughness, float dotNH ) { - float alpha = pow2( roughness ); - float invAlpha = 1.0 / alpha; - float cos2h = dotNH * dotNH; - float sin2h = max( 1.0 - cos2h, 0.0078125 ); - return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); -} -float V_Neubelt( float dotNV, float dotNL ) { - return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); -} -vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { - vec3 halfDir = normalize( lightDir + viewDir ); - float dotNL = saturate( dot( normal, lightDir ) ); - float dotNV = saturate( dot( normal, viewDir ) ); - float dotNH = saturate( dot( normal, halfDir ) ); - float D = D_Charlie( sheenRoughness, dotNH ); - float V = V_Neubelt( dotNV, dotNL ); - return sheenColor * ( D * V ); -} -#endif -float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - float r2 = roughness * roughness; - float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; - float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; - float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); - return saturate( DG * RECIPROCAL_PI ); -} -vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { - float dotNV = saturate( dot( normal, viewDir ) ); - const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); - const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); - vec4 r = roughness * c0 + c1; - float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; - vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; - return fab; -} -vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { - vec2 fab = DFGApprox( normal, viewDir, roughness ); - return specularColor * fab.x + specularF90 * fab.y; -} -#ifdef USE_IRIDESCENCE -void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { -#else -void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { -#endif - vec2 fab = DFGApprox( normal, viewDir, roughness ); - #ifdef USE_IRIDESCENCE - vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); - #else - vec3 Fr = specularColor; - #endif - vec3 FssEss = Fr * fab.x + specularF90 * fab.y; - float Ess = fab.x + fab.y; - float Ems = 1.0 - Ess; - vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); - singleScatter += FssEss; - multiScatter += Fms * Ems; -} -#if NUM_RECT_AREA_LIGHTS > 0 - void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - vec3 normal = geometryNormal; - vec3 viewDir = geometryViewDir; - vec3 position = geometryPosition; - vec3 lightPos = rectAreaLight.position; - vec3 halfWidth = rectAreaLight.halfWidth; - vec3 halfHeight = rectAreaLight.halfHeight; - vec3 lightColor = rectAreaLight.color; - float roughness = material.roughness; - vec3 rectCoords[ 4 ]; - rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; - rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; - rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; - vec2 uv = LTC_Uv( normal, viewDir, roughness ); - vec4 t1 = texture2D( ltc_1, uv ); - vec4 t2 = texture2D( ltc_2, uv ); - mat3 mInv = mat3( - vec3( t1.x, 0, t1.y ), - vec3( 0, 1, 0 ), - vec3( t1.z, 0, t1.w ) - ); - vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); - reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); - reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); - } -#endif -void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); - vec3 irradiance = dotNL * directLight.color; - #ifdef USE_CLEARCOAT - float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); - vec3 ccIrradiance = dotNLcc * directLight.color; - clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); - #endif - #ifdef USE_SHEEN - sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); - #endif - reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); - reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { - reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); -} -void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { - #ifdef USE_CLEARCOAT - clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); - #endif - #ifdef USE_SHEEN - sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); - #endif - vec3 singleScattering = vec3( 0.0 ); - vec3 multiScattering = vec3( 0.0 ); - vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; - #ifdef USE_IRIDESCENCE - computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); - #else - computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); - #endif - vec3 totalScattering = singleScattering + multiScattering; - vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); - reflectedLight.indirectSpecular += radiance * singleScattering; - reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; - reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; -} -#define RE_Direct RE_Direct_Physical -#define RE_Direct_RectArea RE_Direct_RectArea_Physical -#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical -#define RE_IndirectSpecular RE_IndirectSpecular_Physical -float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { - return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,iq=` -vec3 geometryPosition = - vViewPosition; -vec3 geometryNormal = normal; -vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); -vec3 geometryClearcoatNormal = vec3( 0.0 ); -#ifdef USE_CLEARCOAT - geometryClearcoatNormal = clearcoatNormal; -#endif -#ifdef USE_IRIDESCENCE - float dotNVi = saturate( dot( normal, geometryViewDir ) ); - if ( material.iridescenceThickness == 0.0 ) { - material.iridescence = 0.0; - } else { - material.iridescence = saturate( material.iridescence ); - } - if ( material.iridescence > 0.0 ) { - material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); - material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); - } -#endif -IncidentLight directLight; -#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) - PointLight pointLight; - #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { - pointLight = pointLights[ i ]; - getPointLightInfo( pointLight, geometryPosition, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) - pointLightShadow = pointLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) - SpotLight spotLight; - vec4 spotColor; - vec3 spotLightCoord; - bool inSpotLightMap; - #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { - spotLight = spotLights[ i ]; - getSpotLightInfo( spotLight, geometryPosition, directLight ); - #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) - #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX - #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS - #else - #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) - #endif - #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) - spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; - inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); - spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); - directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; - #endif - #undef SPOT_LIGHT_MAP_INDEX - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - spotLightShadow = spotLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) - DirectionalLight directionalLight; - #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLightShadow; - #endif - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { - directionalLight = directionalLights[ i ]; - getDirectionalLightInfo( directionalLight, directLight ); - #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) - directionalLightShadow = directionalLightShadows[ i ]; - directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - #endif - RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) - RectAreaLight rectAreaLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { - rectAreaLight = rectAreaLights[ i ]; - RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); - } - #pragma unroll_loop_end -#endif -#if defined( RE_IndirectDiffuse ) - vec3 iblIrradiance = vec3( 0.0 ); - vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); - #if defined( USE_LIGHT_PROBES ) - irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); - #endif - #if ( NUM_HEMI_LIGHTS > 0 ) - #pragma unroll_loop_start - for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { - irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); - } - #pragma unroll_loop_end - #endif -#endif -#if defined( RE_IndirectSpecular ) - vec3 radiance = vec3( 0.0 ); - vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,rq=`#if defined( RE_IndirectDiffuse ) - #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); - vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; - irradiance += lightMapIrradiance; - #endif - #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) - iblIrradiance += getIBLIrradiance( geometryNormal ); - #endif -#endif -#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) - #ifdef USE_ANISOTROPY - radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); - #else - radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); - #endif - #ifdef USE_CLEARCOAT - clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); - #endif -#endif`,sq=`#if defined( RE_IndirectDiffuse ) - RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif -#if defined( RE_IndirectSpecular ) - RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,aq=`#if defined( USE_LOGDEPTHBUF ) - gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,oq=`#if defined( USE_LOGDEPTHBUF ) - uniform float logDepthBufFC; - varying float vFragDepth; - varying float vIsPerspective; -#endif`,lq=`#ifdef USE_LOGDEPTHBUF - varying float vFragDepth; - varying float vIsPerspective; -#endif`,uq=`#ifdef USE_LOGDEPTHBUF - vFragDepth = 1.0 + gl_Position.w; - vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,cq=`#ifdef USE_MAP - vec4 sampledDiffuseColor = texture2D( map, vMapUv ); - #ifdef DECODE_VIDEO_TEXTURE - sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); - #endif - diffuseColor *= sampledDiffuseColor; -#endif`,hq=`#ifdef USE_MAP - uniform sampler2D map; -#endif`,fq=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - #if defined( USE_POINTS_UV ) - vec2 uv = vUv; - #else - vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; - #endif -#endif -#ifdef USE_MAP - diffuseColor *= texture2D( map, uv ); -#endif -#ifdef USE_ALPHAMAP - diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,dq=`#if defined( USE_POINTS_UV ) - varying vec2 vUv; -#else - #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) - uniform mat3 uvTransform; - #endif -#endif -#ifdef USE_MAP - uniform sampler2D map; -#endif -#ifdef USE_ALPHAMAP - uniform sampler2D alphaMap; -#endif`,Aq=`float metalnessFactor = metalness; -#ifdef USE_METALNESSMAP - vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); - metalnessFactor *= texelMetalness.b; -#endif`,pq=`#ifdef USE_METALNESSMAP - uniform sampler2D metalnessMap; -#endif`,mq=`#ifdef USE_INSTANCING_MORPH - float morphTargetInfluences[ MORPHTARGETS_COUNT ]; - float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; - } -#endif`,gq=`#if defined( USE_MORPHCOLORS ) - vColor *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - #if defined( USE_COLOR_ALPHA ) - if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; - #elif defined( USE_COLOR ) - if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; - #endif - } -#endif`,vq=`#ifdef USE_MORPHNORMALS - objectNormal *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; - } -#endif`,_q=`#ifdef USE_MORPHTARGETS - #ifndef USE_INSTANCING_MORPH - uniform float morphTargetBaseInfluence; - uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; - #endif - uniform sampler2DArray morphTargetsTexture; - uniform ivec2 morphTargetsTextureSize; - vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { - int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; - int y = texelIndex / morphTargetsTextureSize.x; - int x = texelIndex - y * morphTargetsTextureSize.x; - ivec3 morphUV = ivec3( x, y, morphTargetIndex ); - return texelFetch( morphTargetsTexture, morphUV, 0 ); - } -#endif`,yq=`#ifdef USE_MORPHTARGETS - transformed *= morphTargetBaseInfluence; - for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { - if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; - } -#endif`,xq=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; -#ifdef FLAT_SHADED - vec3 fdx = dFdx( vViewPosition ); - vec3 fdy = dFdy( vViewPosition ); - vec3 normal = normalize( cross( fdx, fdy ) ); -#else - vec3 normal = normalize( vNormal ); - #ifdef DOUBLE_SIDED - normal *= faceDirection; - #endif -#endif -#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) - #ifdef USE_TANGENT - mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); - #else - mat3 tbn = getTangentFrame( - vViewPosition, normal, - #if defined( USE_NORMALMAP ) - vNormalMapUv - #elif defined( USE_CLEARCOAT_NORMALMAP ) - vClearcoatNormalMapUv - #else - vUv - #endif - ); - #endif - #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) - tbn[0] *= faceDirection; - tbn[1] *= faceDirection; - #endif -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - #ifdef USE_TANGENT - mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); - #else - mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); - #endif - #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) - tbn2[0] *= faceDirection; - tbn2[1] *= faceDirection; - #endif -#endif -vec3 nonPerturbedNormal = normal;`,bq=`#ifdef USE_NORMALMAP_OBJECTSPACE - normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; - #ifdef FLIP_SIDED - normal = - normal; - #endif - #ifdef DOUBLE_SIDED - normal = normal * faceDirection; - #endif - normal = normalize( normalMatrix * normal ); -#elif defined( USE_NORMALMAP_TANGENTSPACE ) - vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; - mapN.xy *= normalScale; - normal = normalize( tbn * mapN ); -#elif defined( USE_BUMPMAP ) - normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,Sq=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,Tq=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,wq=`#ifndef FLAT_SHADED - vNormal = normalize( transformedNormal ); - #ifdef USE_TANGENT - vTangent = normalize( transformedTangent ); - vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); - #endif -#endif`,Mq=`#ifdef USE_NORMALMAP - uniform sampler2D normalMap; - uniform vec2 normalScale; -#endif -#ifdef USE_NORMALMAP_OBJECTSPACE - uniform mat3 normalMatrix; -#endif -#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) - mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { - vec3 q0 = dFdx( eye_pos.xyz ); - vec3 q1 = dFdy( eye_pos.xyz ); - vec2 st0 = dFdx( uv.st ); - vec2 st1 = dFdy( uv.st ); - vec3 N = surf_norm; - vec3 q1perp = cross( q1, N ); - vec3 q0perp = cross( N, q0 ); - vec3 T = q1perp * st0.x + q0perp * st1.x; - vec3 B = q1perp * st0.y + q0perp * st1.y; - float det = max( dot( T, T ), dot( B, B ) ); - float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); - return mat3( T * scale, B * scale, N ); - } -#endif`,Eq=`#ifdef USE_CLEARCOAT - vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,Cq=`#ifdef USE_CLEARCOAT_NORMALMAP - vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; - clearcoatMapN.xy *= clearcoatNormalScale; - clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,Nq=`#ifdef USE_CLEARCOATMAP - uniform sampler2D clearcoatMap; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - uniform sampler2D clearcoatNormalMap; - uniform vec2 clearcoatNormalScale; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - uniform sampler2D clearcoatRoughnessMap; -#endif`,Rq=`#ifdef USE_IRIDESCENCEMAP - uniform sampler2D iridescenceMap; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - uniform sampler2D iridescenceThicknessMap; -#endif`,Dq=`#ifdef OPAQUE -diffuseColor.a = 1.0; -#endif -#ifdef USE_TRANSMISSION -diffuseColor.a *= material.transmissionAlpha; -#endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Pq=`vec3 packNormalToRGB( const in vec3 normal ) { - return normalize( normal ) * 0.5 + 0.5; -} -vec3 unpackRGBToNormal( const in vec3 rgb ) { - return 2.0 * rgb.xyz - 1.0; -} -const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; -const float Inv255 = 1. / 255.; -const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); -const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); -const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); -const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); -vec4 packDepthToRGBA( const in float v ) { - if( v <= 0.0 ) - return vec4( 0., 0., 0., 0. ); - if( v >= 1.0 ) - return vec4( 1., 1., 1., 1. ); - float vuf; - float af = modf( v * PackFactors.a, vuf ); - float bf = modf( vuf * ShiftRight8, vuf ); - float gf = modf( vuf * ShiftRight8, vuf ); - return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); -} -vec3 packDepthToRGB( const in float v ) { - if( v <= 0.0 ) - return vec3( 0., 0., 0. ); - if( v >= 1.0 ) - return vec3( 1., 1., 1. ); - float vuf; - float bf = modf( v * PackFactors.b, vuf ); - float gf = modf( vuf * ShiftRight8, vuf ); - return vec3( vuf * Inv255, gf * PackUpscale, bf ); -} -vec2 packDepthToRG( const in float v ) { - if( v <= 0.0 ) - return vec2( 0., 0. ); - if( v >= 1.0 ) - return vec2( 1., 1. ); - float vuf; - float gf = modf( v * 256., vuf ); - return vec2( vuf * Inv255, gf ); -} -float unpackRGBAToDepth( const in vec4 v ) { - return dot( v, UnpackFactors4 ); -} -float unpackRGBToDepth( const in vec3 v ) { - return dot( v, UnpackFactors3 ); -} -float unpackRGToDepth( const in vec2 v ) { - return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; -} -vec4 pack2HalfToRGBA( const in vec2 v ) { - vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); - return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); -} -vec2 unpackRGBATo2Half( const in vec4 v ) { - return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); -} -float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { - return ( viewZ + near ) / ( near - far ); -} -float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { - return depth * ( near - far ) - near; -} -float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { - return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); -} -float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { - return ( near * far ) / ( ( far - near ) * depth - far ); -}`,Lq=`#ifdef PREMULTIPLIED_ALPHA - gl_FragColor.rgb *= gl_FragColor.a; -#endif`,Uq=`vec4 mvPosition = vec4( transformed, 1.0 ); -#ifdef USE_BATCHING - mvPosition = batchingMatrix * mvPosition; -#endif -#ifdef USE_INSTANCING - mvPosition = instanceMatrix * mvPosition; -#endif -mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,Bq=`#ifdef DITHERING - gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,Oq=`#ifdef DITHERING - vec3 dithering( vec3 color ) { - float grid_position = rand( gl_FragCoord.xy ); - vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); - dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); - return color + dither_shift_RGB; - } -#endif`,Iq=`float roughnessFactor = roughness; -#ifdef USE_ROUGHNESSMAP - vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); - roughnessFactor *= texelRoughness.g; -#endif`,Fq=`#ifdef USE_ROUGHNESSMAP - uniform sampler2D roughnessMap; -#endif`,kq=`#if NUM_SPOT_LIGHT_COORDS > 0 - varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; -#endif -#if NUM_SPOT_LIGHT_MAPS > 0 - uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; -#endif -#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; - struct SpotLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif - float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { - return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); - } - vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { - return unpackRGBATo2Half( texture2D( shadow, uv ) ); - } - float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ - float occlusion = 1.0; - vec2 distribution = texture2DDistribution( shadow, uv ); - float hard_shadow = step( compare , distribution.x ); - if (hard_shadow != 1.0 ) { - float distance = compare - distribution.x ; - float variance = max( 0.00000, distribution.y * distribution.y ); - float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); - } - return occlusion; - } - float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { - float shadow = 1.0; - shadowCoord.xyz /= shadowCoord.w; - shadowCoord.z += shadowBias; - bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; - bool frustumTest = inFrustum && shadowCoord.z <= 1.0; - if ( frustumTest ) { - #if defined( SHADOWMAP_TYPE_PCF ) - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float dx0 = - texelSize.x * shadowRadius; - float dy0 = - texelSize.y * shadowRadius; - float dx1 = + texelSize.x * shadowRadius; - float dy1 = + texelSize.y * shadowRadius; - float dx2 = dx0 / 2.0; - float dy2 = dy0 / 2.0; - float dx3 = dx1 / 2.0; - float dy3 = dy1 / 2.0; - shadow = ( - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + - texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) - ) * ( 1.0 / 17.0 ); - #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) - vec2 texelSize = vec2( 1.0 ) / shadowMapSize; - float dx = texelSize.x; - float dy = texelSize.y; - vec2 uv = shadowCoord.xy; - vec2 f = fract( uv * shadowMapSize + 0.5 ); - uv -= f * texelSize; - shadow = ( - texture2DCompare( shadowMap, uv, shadowCoord.z ) + - texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + - texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + - texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), - f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), - f.x ) + - mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), - f.y ) + - mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), - f.y ) + - mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), - f.x ), - mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), - texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), - f.x ), - f.y ) - ) * ( 1.0 / 9.0 ); - #elif defined( SHADOWMAP_TYPE_VSM ) - shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); - #else - shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); - #endif - } - return mix( 1.0, shadow, shadowIntensity ); - } - vec2 cubeToUV( vec3 v, float texelSizeY ) { - vec3 absV = abs( v ); - float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); - absV *= scaleToCube; - v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); - vec2 planar = v.xy; - float almostATexel = 1.5 * texelSizeY; - float almostOne = 1.0 - almostATexel; - if ( absV.z >= almostOne ) { - if ( v.z > 0.0 ) - planar.x = 4.0 - v.x; - } else if ( absV.x >= almostOne ) { - float signX = sign( v.x ); - planar.x = v.z * signX + 2.0 * signX; - } else if ( absV.y >= almostOne ) { - float signY = sign( v.y ); - planar.x = v.x + 2.0 * signY + 2.0; - planar.y = v.z * signY - 2.0; - } - return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); - } - float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { - float shadow = 1.0; - vec3 lightToPosition = shadowCoord.xyz; - - float lightToPositionLength = length( lightToPosition ); - if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { - float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; - vec3 bd3D = normalize( lightToPosition ); - vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); - #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) - vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; - shadow = ( - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + - texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) - ) * ( 1.0 / 9.0 ); - #else - shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); - #endif - } - return mix( 1.0, shadow, shadowIntensity ); - } -#endif`,zq=`#if NUM_SPOT_LIGHT_COORDS > 0 - uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; - varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; -#endif -#ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; - varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; - struct DirectionalLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - struct SpotLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - }; - uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; - varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; - struct PointLightShadow { - float shadowIntensity; - float shadowBias; - float shadowNormalBias; - float shadowRadius; - vec2 shadowMapSize; - float shadowCameraNear; - float shadowCameraFar; - }; - uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; - #endif -#endif`,Gq=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) - vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); - vec4 shadowWorldPosition; -#endif -#if defined( USE_SHADOWMAP ) - #if NUM_DIR_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); - vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); - vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end - #endif -#endif -#if NUM_SPOT_LIGHT_COORDS > 0 - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { - shadowWorldPosition = worldPosition; - #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) - shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; - #endif - vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; - } - #pragma unroll_loop_end -#endif`,qq=`float getShadowMask() { - float shadow = 1.0; - #ifdef USE_SHADOWMAP - #if NUM_DIR_LIGHT_SHADOWS > 0 - DirectionalLightShadow directionalLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { - directionalLight = directionalLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_SPOT_LIGHT_SHADOWS > 0 - SpotLightShadow spotLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { - spotLight = spotLightShadows[ i ]; - shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; - } - #pragma unroll_loop_end - #endif - #if NUM_POINT_LIGHT_SHADOWS > 0 - PointLightShadow pointLight; - #pragma unroll_loop_start - for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { - pointLight = pointLightShadows[ i ]; - shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; - } - #pragma unroll_loop_end - #endif - #endif - return shadow; -}`,Vq=`#ifdef USE_SKINNING - mat4 boneMatX = getBoneMatrix( skinIndex.x ); - mat4 boneMatY = getBoneMatrix( skinIndex.y ); - mat4 boneMatZ = getBoneMatrix( skinIndex.z ); - mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,jq=`#ifdef USE_SKINNING - uniform mat4 bindMatrix; - uniform mat4 bindMatrixInverse; - uniform highp sampler2D boneTexture; - mat4 getBoneMatrix( const in float i ) { - int size = textureSize( boneTexture, 0 ).x; - int j = int( i ) * 4; - int x = j % size; - int y = j / size; - vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); - vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); - vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); - vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); - return mat4( v1, v2, v3, v4 ); - } -#endif`,Hq=`#ifdef USE_SKINNING - vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); - vec4 skinned = vec4( 0.0 ); - skinned += boneMatX * skinVertex * skinWeight.x; - skinned += boneMatY * skinVertex * skinWeight.y; - skinned += boneMatZ * skinVertex * skinWeight.z; - skinned += boneMatW * skinVertex * skinWeight.w; - transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,Wq=`#ifdef USE_SKINNING - mat4 skinMatrix = mat4( 0.0 ); - skinMatrix += skinWeight.x * boneMatX; - skinMatrix += skinWeight.y * boneMatY; - skinMatrix += skinWeight.z * boneMatZ; - skinMatrix += skinWeight.w * boneMatW; - skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; - objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; - #ifdef USE_TANGENT - objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; - #endif -#endif`,$q=`float specularStrength; -#ifdef USE_SPECULARMAP - vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); - specularStrength = texelSpecular.r; -#else - specularStrength = 1.0; -#endif`,Xq=`#ifdef USE_SPECULARMAP - uniform sampler2D specularMap; -#endif`,Yq=`#if defined( TONE_MAPPING ) - gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,Qq=`#ifndef saturate -#define saturate( a ) clamp( a, 0.0, 1.0 ) -#endif -uniform float toneMappingExposure; -vec3 LinearToneMapping( vec3 color ) { - return saturate( toneMappingExposure * color ); -} -vec3 ReinhardToneMapping( vec3 color ) { - color *= toneMappingExposure; - return saturate( color / ( vec3( 1.0 ) + color ) ); -} -vec3 CineonToneMapping( vec3 color ) { - color *= toneMappingExposure; - color = max( vec3( 0.0 ), color - 0.004 ); - return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); -} -vec3 RRTAndODTFit( vec3 v ) { - vec3 a = v * ( v + 0.0245786 ) - 0.000090537; - vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; - return a / b; -} -vec3 ACESFilmicToneMapping( vec3 color ) { - const mat3 ACESInputMat = mat3( - vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), - vec3( 0.04823, 0.01566, 0.83777 ) - ); - const mat3 ACESOutputMat = mat3( - vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), - vec3( -0.07367, -0.00605, 1.07602 ) - ); - color *= toneMappingExposure / 0.6; - color = ACESInputMat * color; - color = RRTAndODTFit( color ); - color = ACESOutputMat * color; - return saturate( color ); -} -const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( - vec3( 1.6605, - 0.1246, - 0.0182 ), - vec3( - 0.5876, 1.1329, - 0.1006 ), - vec3( - 0.0728, - 0.0083, 1.1187 ) -); -const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( - vec3( 0.6274, 0.0691, 0.0164 ), - vec3( 0.3293, 0.9195, 0.0880 ), - vec3( 0.0433, 0.0113, 0.8956 ) -); -vec3 agxDefaultContrastApprox( vec3 x ) { - vec3 x2 = x * x; - vec3 x4 = x2 * x2; - return + 15.5 * x4 * x2 - - 40.14 * x4 * x - + 31.96 * x4 - - 6.868 * x2 * x - + 0.4298 * x2 - + 0.1191 * x - - 0.00232; -} -vec3 AgXToneMapping( vec3 color ) { - const mat3 AgXInsetMatrix = mat3( - vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), - vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), - vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) - ); - const mat3 AgXOutsetMatrix = mat3( - vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), - vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), - vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) - ); - const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; - color *= toneMappingExposure; - color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; - color = AgXInsetMatrix * color; - color = max( color, 1e-10 ); color = log2( color ); - color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); - color = clamp( color, 0.0, 1.0 ); - color = agxDefaultContrastApprox( color ); - color = AgXOutsetMatrix * color; - color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); - color = LINEAR_REC2020_TO_LINEAR_SRGB * color; - color = clamp( color, 0.0, 1.0 ); - return color; -} -vec3 NeutralToneMapping( vec3 color ) { - const float StartCompression = 0.8 - 0.04; - const float Desaturation = 0.15; - color *= toneMappingExposure; - float x = min( color.r, min( color.g, color.b ) ); - float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; - color -= offset; - float peak = max( color.r, max( color.g, color.b ) ); - if ( peak < StartCompression ) return color; - float d = 1. - StartCompression; - float newPeak = 1. - d * d / ( peak + d - StartCompression ); - color *= newPeak / peak; - float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); - return mix( color, vec3( newPeak ), g ); -} -vec3 CustomToneMapping( vec3 color ) { return color; }`,Kq=`#ifdef USE_TRANSMISSION - material.transmission = transmission; - material.transmissionAlpha = 1.0; - material.thickness = thickness; - material.attenuationDistance = attenuationDistance; - material.attenuationColor = attenuationColor; - #ifdef USE_TRANSMISSIONMAP - material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; - #endif - #ifdef USE_THICKNESSMAP - material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; - #endif - vec3 pos = vWorldPosition; - vec3 v = normalize( cameraPosition - pos ); - vec3 n = inverseTransformDirection( normal, viewMatrix ); - vec4 transmitted = getIBLVolumeRefraction( - n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, - pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, - material.attenuationColor, material.attenuationDistance ); - material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); - totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,Zq=`#ifdef USE_TRANSMISSION - uniform float transmission; - uniform float thickness; - uniform float attenuationDistance; - uniform vec3 attenuationColor; - #ifdef USE_TRANSMISSIONMAP - uniform sampler2D transmissionMap; - #endif - #ifdef USE_THICKNESSMAP - uniform sampler2D thicknessMap; - #endif - uniform vec2 transmissionSamplerSize; - uniform sampler2D transmissionSamplerMap; - uniform mat4 modelMatrix; - uniform mat4 projectionMatrix; - varying vec3 vWorldPosition; - float w0( float a ) { - return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); - } - float w1( float a ) { - return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); - } - float w2( float a ){ - return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); - } - float w3( float a ) { - return ( 1.0 / 6.0 ) * ( a * a * a ); - } - float g0( float a ) { - return w0( a ) + w1( a ); - } - float g1( float a ) { - return w2( a ) + w3( a ); - } - float h0( float a ) { - return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); - } - float h1( float a ) { - return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); - } - vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { - uv = uv * texelSize.zw + 0.5; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - float g0x = g0( fuv.x ); - float g1x = g1( fuv.x ); - float h0x = h0( fuv.x ); - float h1x = h1( fuv.x ); - float h0y = h0( fuv.y ); - float h1y = h1( fuv.y ); - vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; - vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; - vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; - vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; - return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + - g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); - } - vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { - vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); - vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); - vec2 fLodSizeInv = 1.0 / fLodSize; - vec2 cLodSizeInv = 1.0 / cLodSize; - vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); - vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); - return mix( fSample, cSample, fract( lod ) ); - } - vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { - vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); - vec3 modelScale; - modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); - modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); - modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); - return normalize( refractionVector ) * thickness * modelScale; - } - float applyIorToRoughness( const in float roughness, const in float ior ) { - return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); - } - vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { - float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); - return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); - } - vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { - if ( isinf( attenuationDistance ) ) { - return vec3( 1.0 ); - } else { - vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; - vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; - } - } - vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, - const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, - const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, - const in vec3 attenuationColor, const in float attenuationDistance ) { - vec4 transmittedLight; - vec3 transmittance; - #ifdef USE_DISPERSION - float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; - vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); - for ( int i = 0; i < 3; i ++ ) { - vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); - vec3 refractedRayExit = position + transmissionRay; - vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); - vec2 refractionCoords = ndcPos.xy / ndcPos.w; - refractionCoords += 1.0; - refractionCoords /= 2.0; - vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); - transmittedLight[ i ] = transmissionSample[ i ]; - transmittedLight.a += transmissionSample.a; - transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; - } - transmittedLight.a /= 3.0; - #else - vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); - vec3 refractedRayExit = position + transmissionRay; - vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); - vec2 refractionCoords = ndcPos.xy / ndcPos.w; - refractionCoords += 1.0; - refractionCoords /= 2.0; - transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); - transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); - #endif - vec3 attenuatedColor = transmittance * transmittedLight.rgb; - vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); - float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; - return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); - } -#endif`,Jq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - varying vec2 vUv; -#endif -#ifdef USE_MAP - varying vec2 vMapUv; -#endif -#ifdef USE_ALPHAMAP - varying vec2 vAlphaMapUv; -#endif -#ifdef USE_LIGHTMAP - varying vec2 vLightMapUv; -#endif -#ifdef USE_AOMAP - varying vec2 vAoMapUv; -#endif -#ifdef USE_BUMPMAP - varying vec2 vBumpMapUv; -#endif -#ifdef USE_NORMALMAP - varying vec2 vNormalMapUv; -#endif -#ifdef USE_EMISSIVEMAP - varying vec2 vEmissiveMapUv; -#endif -#ifdef USE_METALNESSMAP - varying vec2 vMetalnessMapUv; -#endif -#ifdef USE_ROUGHNESSMAP - varying vec2 vRoughnessMapUv; -#endif -#ifdef USE_ANISOTROPYMAP - varying vec2 vAnisotropyMapUv; -#endif -#ifdef USE_CLEARCOATMAP - varying vec2 vClearcoatMapUv; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - varying vec2 vClearcoatNormalMapUv; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - varying vec2 vClearcoatRoughnessMapUv; -#endif -#ifdef USE_IRIDESCENCEMAP - varying vec2 vIridescenceMapUv; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - varying vec2 vIridescenceThicknessMapUv; -#endif -#ifdef USE_SHEEN_COLORMAP - varying vec2 vSheenColorMapUv; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - varying vec2 vSheenRoughnessMapUv; -#endif -#ifdef USE_SPECULARMAP - varying vec2 vSpecularMapUv; -#endif -#ifdef USE_SPECULAR_COLORMAP - varying vec2 vSpecularColorMapUv; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - varying vec2 vSpecularIntensityMapUv; -#endif -#ifdef USE_TRANSMISSIONMAP - uniform mat3 transmissionMapTransform; - varying vec2 vTransmissionMapUv; -#endif -#ifdef USE_THICKNESSMAP - uniform mat3 thicknessMapTransform; - varying vec2 vThicknessMapUv; -#endif`,eV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - varying vec2 vUv; -#endif -#ifdef USE_MAP - uniform mat3 mapTransform; - varying vec2 vMapUv; -#endif -#ifdef USE_ALPHAMAP - uniform mat3 alphaMapTransform; - varying vec2 vAlphaMapUv; -#endif -#ifdef USE_LIGHTMAP - uniform mat3 lightMapTransform; - varying vec2 vLightMapUv; -#endif -#ifdef USE_AOMAP - uniform mat3 aoMapTransform; - varying vec2 vAoMapUv; -#endif -#ifdef USE_BUMPMAP - uniform mat3 bumpMapTransform; - varying vec2 vBumpMapUv; -#endif -#ifdef USE_NORMALMAP - uniform mat3 normalMapTransform; - varying vec2 vNormalMapUv; -#endif -#ifdef USE_DISPLACEMENTMAP - uniform mat3 displacementMapTransform; - varying vec2 vDisplacementMapUv; -#endif -#ifdef USE_EMISSIVEMAP - uniform mat3 emissiveMapTransform; - varying vec2 vEmissiveMapUv; -#endif -#ifdef USE_METALNESSMAP - uniform mat3 metalnessMapTransform; - varying vec2 vMetalnessMapUv; -#endif -#ifdef USE_ROUGHNESSMAP - uniform mat3 roughnessMapTransform; - varying vec2 vRoughnessMapUv; -#endif -#ifdef USE_ANISOTROPYMAP - uniform mat3 anisotropyMapTransform; - varying vec2 vAnisotropyMapUv; -#endif -#ifdef USE_CLEARCOATMAP - uniform mat3 clearcoatMapTransform; - varying vec2 vClearcoatMapUv; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - uniform mat3 clearcoatNormalMapTransform; - varying vec2 vClearcoatNormalMapUv; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - uniform mat3 clearcoatRoughnessMapTransform; - varying vec2 vClearcoatRoughnessMapUv; -#endif -#ifdef USE_SHEEN_COLORMAP - uniform mat3 sheenColorMapTransform; - varying vec2 vSheenColorMapUv; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - uniform mat3 sheenRoughnessMapTransform; - varying vec2 vSheenRoughnessMapUv; -#endif -#ifdef USE_IRIDESCENCEMAP - uniform mat3 iridescenceMapTransform; - varying vec2 vIridescenceMapUv; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - uniform mat3 iridescenceThicknessMapTransform; - varying vec2 vIridescenceThicknessMapUv; -#endif -#ifdef USE_SPECULARMAP - uniform mat3 specularMapTransform; - varying vec2 vSpecularMapUv; -#endif -#ifdef USE_SPECULAR_COLORMAP - uniform mat3 specularColorMapTransform; - varying vec2 vSpecularColorMapUv; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - uniform mat3 specularIntensityMapTransform; - varying vec2 vSpecularIntensityMapUv; -#endif -#ifdef USE_TRANSMISSIONMAP - uniform mat3 transmissionMapTransform; - varying vec2 vTransmissionMapUv; -#endif -#ifdef USE_THICKNESSMAP - uniform mat3 thicknessMapTransform; - varying vec2 vThicknessMapUv; -#endif`,tV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) - vUv = vec3( uv, 1 ).xy; -#endif -#ifdef USE_MAP - vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ALPHAMAP - vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_LIGHTMAP - vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_AOMAP - vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_BUMPMAP - vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_NORMALMAP - vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_DISPLACEMENTMAP - vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_EMISSIVEMAP - vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_METALNESSMAP - vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ROUGHNESSMAP - vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_ANISOTROPYMAP - vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOATMAP - vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOAT_NORMALMAP - vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_CLEARCOAT_ROUGHNESSMAP - vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_IRIDESCENCEMAP - vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_IRIDESCENCE_THICKNESSMAP - vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SHEEN_COLORMAP - vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SHEEN_ROUGHNESSMAP - vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULARMAP - vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULAR_COLORMAP - vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_SPECULAR_INTENSITYMAP - vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_TRANSMISSIONMAP - vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; -#endif -#ifdef USE_THICKNESSMAP - vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,nV=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 - vec4 worldPosition = vec4( transformed, 1.0 ); - #ifdef USE_BATCHING - worldPosition = batchingMatrix * worldPosition; - #endif - #ifdef USE_INSTANCING - worldPosition = instanceMatrix * worldPosition; - #endif - worldPosition = modelMatrix * worldPosition; -#endif`;const iV=`varying vec2 vUv; -uniform mat3 uvTransform; -void main() { - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,rV=`uniform sampler2D t2D; -uniform float backgroundIntensity; -varying vec2 vUv; -void main() { - vec4 texColor = texture2D( t2D, vUv ); - #ifdef DECODE_VIDEO_TEXTURE - texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); - #endif - texColor.rgb *= backgroundIntensity; - gl_FragColor = texColor; - #include - #include -}`,sV=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`,aV=`#ifdef ENVMAP_TYPE_CUBE - uniform samplerCube envMap; -#elif defined( ENVMAP_TYPE_CUBE_UV ) - uniform sampler2D envMap; -#endif -uniform float flipEnvMap; -uniform float backgroundBlurriness; -uniform float backgroundIntensity; -uniform mat3 backgroundRotation; -varying vec3 vWorldDirection; -#include -void main() { - #ifdef ENVMAP_TYPE_CUBE - vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); - #elif defined( ENVMAP_TYPE_CUBE_UV ) - vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); - #else - vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - #endif - texColor.rgb *= backgroundIntensity; - gl_FragColor = texColor; - #include - #include -}`,oV=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include - gl_Position.z = gl_Position.w; -}`,lV=`uniform samplerCube tCube; -uniform float tFlip; -uniform float opacity; -varying vec3 vWorldDirection; -void main() { - vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); - gl_FragColor = texColor; - gl_FragColor.a *= opacity; - #include - #include -}`,uV=`#include -#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - #include - #include - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - vHighPrecisionZW = gl_Position.zw; -}`,cV=`#if DEPTH_PACKING == 3200 - uniform float opacity; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -varying vec2 vHighPrecisionZW; -void main() { - vec4 diffuseColor = vec4( 1.0 ); - #include - #if DEPTH_PACKING == 3200 - diffuseColor.a = opacity; - #endif - #include - #include - #include - #include - #include - float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; - #if DEPTH_PACKING == 3200 - gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); - #elif DEPTH_PACKING == 3201 - gl_FragColor = packDepthToRGBA( fragCoordZ ); - #elif DEPTH_PACKING == 3202 - gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); - #elif DEPTH_PACKING == 3203 - gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); - #endif -}`,hV=`#define DISTANCE -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #ifdef USE_DISPLACEMENTMAP - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - vWorldPosition = worldPosition.xyz; -}`,fV=`#define DISTANCE -uniform vec3 referencePosition; -uniform float nearDistance; -uniform float farDistance; -varying vec3 vWorldPosition; -#include -#include -#include -#include -#include -#include -#include -#include -void main () { - vec4 diffuseColor = vec4( 1.0 ); - #include - #include - #include - #include - #include - float dist = length( vWorldPosition - referencePosition ); - dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); - dist = saturate( dist ); - gl_FragColor = packDepthToRGBA( dist ); -}`,dV=`varying vec3 vWorldDirection; -#include -void main() { - vWorldDirection = transformDirection( position, modelMatrix ); - #include - #include -}`,AV=`uniform sampler2D tEquirect; -varying vec3 vWorldDirection; -#include -void main() { - vec3 direction = normalize( vWorldDirection ); - vec2 sampleUV = equirectUv( direction ); - gl_FragColor = texture2D( tEquirect, sampleUV ); - #include - #include -}`,pV=`uniform float scale; -attribute float lineDistance; -varying float vLineDistance; -#include -#include -#include -#include -#include -#include -#include -void main() { - vLineDistance = scale * lineDistance; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,mV=`uniform vec3 diffuse; -uniform float opacity; -uniform float dashSize; -uniform float totalSize; -varying float vLineDistance; -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - if ( mod( vLineDistance, totalSize ) > dashSize ) { - discard; - } - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include - #include -}`,gV=`#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) - #include - #include - #include - #include - #include - #endif - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,vV=`uniform vec3 diffuse; -uniform float opacity; -#ifndef FLAT_SHADED - varying vec3 vNormal; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - #include - #include - #include - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - #ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); - reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; - #else - reflectedLight.indirectDiffuse += vec3( 1.0 ); - #endif - #include - reflectedLight.indirectDiffuse *= diffuseColor.rgb; - vec3 outgoingLight = reflectedLight.indirectDiffuse; - #include - #include - #include - #include - #include - #include - #include -}`,_V=`#define LAMBERT -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include - #include -}`,yV=`#define LAMBERT -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`,xV=`#define MATCAP -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; -}`,bV=`#define MATCAP -uniform vec3 diffuse; -uniform float opacity; -uniform sampler2D matcap; -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 viewDir = normalize( vViewPosition ); - vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); - vec3 y = cross( viewDir, x ); - vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; - #ifdef USE_MATCAP - vec4 matcapColor = texture2D( matcap, uv ); - #else - vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); - #endif - vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; - #include - #include - #include - #include - #include - #include -}`,SV=`#define NORMAL -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - vViewPosition = - mvPosition.xyz; -#endif -}`,TV=`#define NORMAL -uniform float opacity; -#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) - varying vec3 vViewPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); - #include - #include - #include - #include - gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); - #ifdef OPAQUE - gl_FragColor.a = 1.0; - #endif -}`,wV=`#define PHONG -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include - #include -}`,MV=`#define PHONG -uniform vec3 diffuse; -uniform vec3 emissive; -uniform vec3 specular; -uniform float shininess; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include - #include -}`,EV=`#define STANDARD -varying vec3 vViewPosition; -#ifdef USE_TRANSMISSION - varying vec3 vWorldPosition; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include -#ifdef USE_TRANSMISSION - vWorldPosition = worldPosition.xyz; -#endif -}`,CV=`#define STANDARD -#ifdef PHYSICAL - #define IOR - #define USE_SPECULAR -#endif -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float roughness; -uniform float metalness; -uniform float opacity; -#ifdef IOR - uniform float ior; -#endif -#ifdef USE_SPECULAR - uniform float specularIntensity; - uniform vec3 specularColor; - #ifdef USE_SPECULAR_COLORMAP - uniform sampler2D specularColorMap; - #endif - #ifdef USE_SPECULAR_INTENSITYMAP - uniform sampler2D specularIntensityMap; - #endif -#endif -#ifdef USE_CLEARCOAT - uniform float clearcoat; - uniform float clearcoatRoughness; -#endif -#ifdef USE_DISPERSION - uniform float dispersion; -#endif -#ifdef USE_IRIDESCENCE - uniform float iridescence; - uniform float iridescenceIOR; - uniform float iridescenceThicknessMinimum; - uniform float iridescenceThicknessMaximum; -#endif -#ifdef USE_SHEEN - uniform vec3 sheenColor; - uniform float sheenRoughness; - #ifdef USE_SHEEN_COLORMAP - uniform sampler2D sheenColorMap; - #endif - #ifdef USE_SHEEN_ROUGHNESSMAP - uniform sampler2D sheenRoughnessMap; - #endif -#endif -#ifdef USE_ANISOTROPY - uniform vec2 anisotropyVector; - #ifdef USE_ANISOTROPYMAP - uniform sampler2D anisotropyMap; - #endif -#endif -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; - vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; - #include - vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; - #ifdef USE_SHEEN - float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); - outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; - #endif - #ifdef USE_CLEARCOAT - float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); - vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); - outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; - #endif - #include - #include - #include - #include - #include - #include -}`,NV=`#define TOON -varying vec3 vViewPosition; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vViewPosition = - mvPosition.xyz; - #include - #include - #include -}`,RV=`#define TOON -uniform vec3 diffuse; -uniform vec3 emissive; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); - vec3 totalEmissiveRadiance = emissive; - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; - #include - #include - #include - #include - #include - #include -}`,DV=`uniform float size; -uniform float scale; -#include -#include -#include -#include -#include -#include -#ifdef USE_POINTS_UV - varying vec2 vUv; - uniform mat3 uvTransform; -#endif -void main() { - #ifdef USE_POINTS_UV - vUv = ( uvTransform * vec3( uv, 1 ) ).xy; - #endif - #include - #include - #include - #include - #include - #include - gl_PointSize = size; - #ifdef USE_SIZEATTENUATION - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); - #endif - #include - #include - #include - #include -}`,PV=`uniform vec3 diffuse; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include - #include -}`,LV=`#include -#include -#include -#include -#include -#include -#include -void main() { - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -}`,UV=`uniform vec3 color; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - #include - gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); - #include - #include - #include -}`,BV=`uniform float rotation; -uniform vec2 center; -#include -#include -#include -#include -#include -void main() { - #include - vec4 mvPosition = modelViewMatrix[ 3 ]; - vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); - #ifndef USE_SIZEATTENUATION - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) scale *= - mvPosition.z; - #endif - vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; - vec2 rotatedPosition; - rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; - rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; - mvPosition.xy += rotatedPosition; - gl_Position = projectionMatrix * mvPosition; - #include - #include - #include -}`,OV=`uniform vec3 diffuse; -uniform float opacity; -#include -#include -#include -#include -#include -#include -#include -#include -#include -void main() { - vec4 diffuseColor = vec4( diffuse, opacity ); - #include - vec3 outgoingLight = vec3( 0.0 ); - #include - #include - #include - #include - #include - outgoingLight = diffuseColor.rgb; - #include - #include - #include - #include -}`,ni={alphahash_fragment:rG,alphahash_pars_fragment:sG,alphamap_fragment:aG,alphamap_pars_fragment:oG,alphatest_fragment:lG,alphatest_pars_fragment:uG,aomap_fragment:cG,aomap_pars_fragment:hG,batching_pars_vertex:fG,batching_vertex:dG,begin_vertex:AG,beginnormal_vertex:pG,bsdfs:mG,iridescence_fragment:gG,bumpmap_pars_fragment:vG,clipping_planes_fragment:_G,clipping_planes_pars_fragment:yG,clipping_planes_pars_vertex:xG,clipping_planes_vertex:bG,color_fragment:SG,color_pars_fragment:TG,color_pars_vertex:wG,color_vertex:MG,common:EG,cube_uv_reflection_fragment:CG,defaultnormal_vertex:NG,displacementmap_pars_vertex:RG,displacementmap_vertex:DG,emissivemap_fragment:PG,emissivemap_pars_fragment:LG,colorspace_fragment:UG,colorspace_pars_fragment:BG,envmap_fragment:OG,envmap_common_pars_fragment:IG,envmap_pars_fragment:FG,envmap_pars_vertex:kG,envmap_physical_pars_fragment:QG,envmap_vertex:zG,fog_vertex:GG,fog_pars_vertex:qG,fog_fragment:VG,fog_pars_fragment:jG,gradientmap_pars_fragment:HG,lightmap_pars_fragment:WG,lights_lambert_fragment:$G,lights_lambert_pars_fragment:XG,lights_pars_begin:YG,lights_toon_fragment:KG,lights_toon_pars_fragment:ZG,lights_phong_fragment:JG,lights_phong_pars_fragment:eq,lights_physical_fragment:tq,lights_physical_pars_fragment:nq,lights_fragment_begin:iq,lights_fragment_maps:rq,lights_fragment_end:sq,logdepthbuf_fragment:aq,logdepthbuf_pars_fragment:oq,logdepthbuf_pars_vertex:lq,logdepthbuf_vertex:uq,map_fragment:cq,map_pars_fragment:hq,map_particle_fragment:fq,map_particle_pars_fragment:dq,metalnessmap_fragment:Aq,metalnessmap_pars_fragment:pq,morphinstance_vertex:mq,morphcolor_vertex:gq,morphnormal_vertex:vq,morphtarget_pars_vertex:_q,morphtarget_vertex:yq,normal_fragment_begin:xq,normal_fragment_maps:bq,normal_pars_fragment:Sq,normal_pars_vertex:Tq,normal_vertex:wq,normalmap_pars_fragment:Mq,clearcoat_normal_fragment_begin:Eq,clearcoat_normal_fragment_maps:Cq,clearcoat_pars_fragment:Nq,iridescence_pars_fragment:Rq,opaque_fragment:Dq,packing:Pq,premultiplied_alpha_fragment:Lq,project_vertex:Uq,dithering_fragment:Bq,dithering_pars_fragment:Oq,roughnessmap_fragment:Iq,roughnessmap_pars_fragment:Fq,shadowmap_pars_fragment:kq,shadowmap_pars_vertex:zq,shadowmap_vertex:Gq,shadowmask_pars_fragment:qq,skinbase_vertex:Vq,skinning_pars_vertex:jq,skinning_vertex:Hq,skinnormal_vertex:Wq,specularmap_fragment:$q,specularmap_pars_fragment:Xq,tonemapping_fragment:Yq,tonemapping_pars_fragment:Qq,transmission_fragment:Kq,transmission_pars_fragment:Zq,uv_pars_fragment:Jq,uv_pars_vertex:eV,uv_vertex:tV,worldpos_vertex:nV,background_vert:iV,background_frag:rV,backgroundCube_vert:sV,backgroundCube_frag:aV,cube_vert:oV,cube_frag:lV,depth_vert:uV,depth_frag:cV,distanceRGBA_vert:hV,distanceRGBA_frag:fV,equirect_vert:dV,equirect_frag:AV,linedashed_vert:pV,linedashed_frag:mV,meshbasic_vert:gV,meshbasic_frag:vV,meshlambert_vert:_V,meshlambert_frag:yV,meshmatcap_vert:xV,meshmatcap_frag:bV,meshnormal_vert:SV,meshnormal_frag:TV,meshphong_vert:wV,meshphong_frag:MV,meshphysical_vert:EV,meshphysical_frag:CV,meshtoon_vert:NV,meshtoon_frag:RV,points_vert:DV,points_frag:PV,shadow_vert:LV,shadow_frag:UV,sprite_vert:BV,sprite_frag:OV},sn={common:{diffuse:{value:new mn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Qn},alphaMap:{value:null},alphaMapTransform:{value:new Qn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Qn}},envmap:{envMap:{value:null},envMapRotation:{value:new Qn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Qn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Qn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Qn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Qn},normalScale:{value:new Et(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Qn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Qn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Qn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Qn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new mn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new mn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Qn},alphaTest:{value:0},uvTransform:{value:new Qn}},sprite:{diffuse:{value:new mn(16777215)},opacity:{value:1},center:{value:new Et(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Qn},alphaMap:{value:null},alphaMapTransform:{value:new Qn},alphaTest:{value:0}}},$a={basic:{uniforms:Ma([sn.common,sn.specularmap,sn.envmap,sn.aomap,sn.lightmap,sn.fog]),vertexShader:ni.meshbasic_vert,fragmentShader:ni.meshbasic_frag},lambert:{uniforms:Ma([sn.common,sn.specularmap,sn.envmap,sn.aomap,sn.lightmap,sn.emissivemap,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.fog,sn.lights,{emissive:{value:new mn(0)}}]),vertexShader:ni.meshlambert_vert,fragmentShader:ni.meshlambert_frag},phong:{uniforms:Ma([sn.common,sn.specularmap,sn.envmap,sn.aomap,sn.lightmap,sn.emissivemap,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.fog,sn.lights,{emissive:{value:new mn(0)},specular:{value:new mn(1118481)},shininess:{value:30}}]),vertexShader:ni.meshphong_vert,fragmentShader:ni.meshphong_frag},standard:{uniforms:Ma([sn.common,sn.envmap,sn.aomap,sn.lightmap,sn.emissivemap,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.roughnessmap,sn.metalnessmap,sn.fog,sn.lights,{emissive:{value:new mn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ni.meshphysical_vert,fragmentShader:ni.meshphysical_frag},toon:{uniforms:Ma([sn.common,sn.aomap,sn.lightmap,sn.emissivemap,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.gradientmap,sn.fog,sn.lights,{emissive:{value:new mn(0)}}]),vertexShader:ni.meshtoon_vert,fragmentShader:ni.meshtoon_frag},matcap:{uniforms:Ma([sn.common,sn.bumpmap,sn.normalmap,sn.displacementmap,sn.fog,{matcap:{value:null}}]),vertexShader:ni.meshmatcap_vert,fragmentShader:ni.meshmatcap_frag},points:{uniforms:Ma([sn.points,sn.fog]),vertexShader:ni.points_vert,fragmentShader:ni.points_frag},dashed:{uniforms:Ma([sn.common,sn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ni.linedashed_vert,fragmentShader:ni.linedashed_frag},depth:{uniforms:Ma([sn.common,sn.displacementmap]),vertexShader:ni.depth_vert,fragmentShader:ni.depth_frag},normal:{uniforms:Ma([sn.common,sn.bumpmap,sn.normalmap,sn.displacementmap,{opacity:{value:1}}]),vertexShader:ni.meshnormal_vert,fragmentShader:ni.meshnormal_frag},sprite:{uniforms:Ma([sn.sprite,sn.fog]),vertexShader:ni.sprite_vert,fragmentShader:ni.sprite_frag},background:{uniforms:{uvTransform:{value:new Qn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ni.background_vert,fragmentShader:ni.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Qn}},vertexShader:ni.backgroundCube_vert,fragmentShader:ni.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ni.cube_vert,fragmentShader:ni.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ni.equirect_vert,fragmentShader:ni.equirect_frag},distanceRGBA:{uniforms:Ma([sn.common,sn.displacementmap,{referencePosition:{value:new de},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ni.distanceRGBA_vert,fragmentShader:ni.distanceRGBA_frag},shadow:{uniforms:Ma([sn.lights,sn.fog,{color:{value:new mn(0)},opacity:{value:1}}]),vertexShader:ni.shadow_vert,fragmentShader:ni.shadow_frag}};$a.physical={uniforms:Ma([$a.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Qn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Qn},clearcoatNormalScale:{value:new Et(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Qn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Qn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Qn},sheen:{value:0},sheenColor:{value:new mn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Qn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Qn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Qn},transmissionSamplerSize:{value:new Et},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Qn},attenuationDistance:{value:0},attenuationColor:{value:new mn(0)},specularColor:{value:new mn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Qn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Qn},anisotropyVector:{value:new Et},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Qn}}]),vertexShader:ni.meshphysical_vert,fragmentShader:ni.meshphysical_frag};const W2={r:0,b:0,g:0},Ef=new ma,IV=new Xn;function FV(i,e,t,n,r,s,a){const l=new mn(0);let u=s===!0?0:1,h,m,v=null,x=0,S=null;function w(U){let I=U.isScene===!0?U.background:null;return I&&I.isTexture&&(I=(U.backgroundBlurriness>0?t:e).get(I)),I}function N(U){let I=!1;const j=w(U);j===null?E(l,u):j&&j.isColor&&(E(j,1),I=!0);const z=i.xr.getEnvironmentBlendMode();z==="additive"?n.buffers.color.setClear(0,0,0,1,a):z==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function C(U,I){const j=w(I);j&&(j.isCubeTexture||j.mapping===ld)?(m===void 0&&(m=new qi(new Jh(1,1,1),new so({name:"BackgroundCubeMaterial",uniforms:R0($a.backgroundCube.uniforms),vertexShader:$a.backgroundCube.vertexShader,fragmentShader:$a.backgroundCube.fragmentShader,side:gr,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(z,G,W){this.matrixWorld.copyPosition(W.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(m)),Ef.copy(I.backgroundRotation),Ef.x*=-1,Ef.y*=-1,Ef.z*=-1,j.isCubeTexture&&j.isRenderTargetTexture===!1&&(Ef.y*=-1,Ef.z*=-1),m.material.uniforms.envMap.value=j,m.material.uniforms.flipEnvMap.value=j.isCubeTexture&&j.isRenderTargetTexture===!1?-1:1,m.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,m.material.uniforms.backgroundRotation.value.setFromMatrix4(IV.makeRotationFromEuler(Ef)),m.material.toneMapped=hi.getTransfer(j.colorSpace)!==Hi,(v!==j||x!==j.version||S!==i.toneMapping)&&(m.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),m.layers.enableAll(),U.unshift(m,m.geometry,m.material,0,0,null)):j&&j.isTexture&&(h===void 0&&(h=new qi(new Ty(2,2),new so({name:"BackgroundMaterial",uniforms:R0($a.background.uniforms),vertexShader:$a.background.vertexShader,fragmentShader:$a.background.fragmentShader,side:zl,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=j,h.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,h.material.toneMapped=hi.getTransfer(j.colorSpace)!==Hi,j.matrixAutoUpdate===!0&&j.updateMatrix(),h.material.uniforms.uvTransform.value.copy(j.matrix),(v!==j||x!==j.version||S!==i.toneMapping)&&(h.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),h.layers.enableAll(),U.unshift(h,h.geometry,h.material,0,0,null))}function E(U,I){U.getRGB(W2,W7(i)),n.buffers.color.setClear(W2.r,W2.g,W2.b,I,a)}function O(){m!==void 0&&(m.geometry.dispose(),m.material.dispose()),h!==void 0&&(h.geometry.dispose(),h.material.dispose())}return{getClearColor:function(){return l},setClearColor:function(U,I=1){l.set(U),u=I,E(l,u)},getClearAlpha:function(){return u},setClearAlpha:function(U){u=U,E(l,u)},render:N,addToRenderList:C,dispose:O}}function kV(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=x(null);let s=r,a=!1;function l(V,Y,te,ne,le){let Q=!1;const K=v(ne,te,Y);s!==K&&(s=K,h(s.object)),Q=S(V,ne,te,le),Q&&w(V,ne,te,le),le!==null&&e.update(le,i.ELEMENT_ARRAY_BUFFER),(Q||a)&&(a=!1,I(V,Y,te,ne),le!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(le).buffer))}function u(){return i.createVertexArray()}function h(V){return i.bindVertexArray(V)}function m(V){return i.deleteVertexArray(V)}function v(V,Y,te){const ne=te.wireframe===!0;let le=n[V.id];le===void 0&&(le={},n[V.id]=le);let Q=le[Y.id];Q===void 0&&(Q={},le[Y.id]=Q);let K=Q[ne];return K===void 0&&(K=x(u()),Q[ne]=K),K}function x(V){const Y=[],te=[],ne=[];for(let le=0;le=0){const Se=le[Ae];let se=Q[Ae];if(se===void 0&&(Ae==="instanceMatrix"&&V.instanceMatrix&&(se=V.instanceMatrix),Ae==="instanceColor"&&V.instanceColor&&(se=V.instanceColor)),Se===void 0||Se.attribute!==se||se&&Se.data!==se.data)return!0;K++}return s.attributesNum!==K||s.index!==ne}function w(V,Y,te,ne){const le={},Q=Y.attributes;let K=0;const ae=te.getAttributes();for(const Ae in ae)if(ae[Ae].location>=0){let Se=Q[Ae];Se===void 0&&(Ae==="instanceMatrix"&&V.instanceMatrix&&(Se=V.instanceMatrix),Ae==="instanceColor"&&V.instanceColor&&(Se=V.instanceColor));const se={};se.attribute=Se,Se&&Se.data&&(se.data=Se.data),le[Ae]=se,K++}s.attributes=le,s.attributesNum=K,s.index=ne}function N(){const V=s.newAttributes;for(let Y=0,te=V.length;Y=0){let be=le[ae];if(be===void 0&&(ae==="instanceMatrix"&&V.instanceMatrix&&(be=V.instanceMatrix),ae==="instanceColor"&&V.instanceColor&&(be=V.instanceColor)),be!==void 0){const Se=be.normalized,se=be.itemSize,Ee=e.get(be);if(Ee===void 0)continue;const qe=Ee.buffer,Ce=Ee.type,ke=Ee.bytesPerElement,Qe=Ce===i.INT||Ce===i.UNSIGNED_INT||be.gpuType===ks;if(be.isInterleavedBufferAttribute){const et=be.data,Pt=et.stride,Nt=be.offset;if(et.isInstancedInterleavedBuffer){for(let Gt=0;Gt0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";G="mediump"}return G==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const m=u(h);m!==h&&(console.warn("THREE.WebGLRenderer:",h,"not supported, using",m,"instead."),h=m);const v=t.logarithmicDepthBuffer===!0,x=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),S=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),w=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),N=i.getParameter(i.MAX_TEXTURE_SIZE),C=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),E=i.getParameter(i.MAX_VERTEX_ATTRIBS),O=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),U=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),j=w>0,z=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:l,precision:h,logarithmicDepthBuffer:v,reverseDepthBuffer:x,maxTextures:S,maxVertexTextures:w,maxTextureSize:N,maxCubemapSize:C,maxAttributes:E,maxVertexUniforms:O,maxVaryings:U,maxFragmentUniforms:I,vertexTextures:j,maxSamples:z}}function qV(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new iu,l=new Qn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(v,x){const S=v.length!==0||x||n!==0||r;return r=x,n=v.length,S},this.beginShadows=function(){s=!0,m(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(v,x){t=m(v,x,0)},this.setState=function(v,x,S){const w=v.clippingPlanes,N=v.clipIntersection,C=v.clipShadows,E=i.get(v);if(!r||w===null||w.length===0||s&&!C)s?m(null):h();else{const O=s?0:n,U=O*4;let I=E.clippingState||null;u.value=I,I=m(w,x,U,S);for(let j=0;j!==U;++j)I[j]=t[j];E.clippingState=I,this.numIntersection=N?this.numPlanes:0,this.numPlanes+=O}};function h(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function m(v,x,S,w){const N=v!==null?v.length:0;let C=null;if(N!==0){if(C=u.value,w!==!0||C===null){const E=S+N*4,O=x.matrixWorldInverse;l.getNormalMatrix(O),(C===null||C.length0){const h=new X7(u.height);return h.fromEquirectangularTexture(i,a),e.set(a,h),a.addEventListener("dispose",r),t(h.texture,a.mapping)}else return null}}return a}function r(a){const l=a.target;l.removeEventListener("dispose",r);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const $A=4,UN=[.125,.215,.35,.446,.526,.582],Vf=20,w3=new Gg,BN=new mn;let M3=null,E3=0,C3=0,N3=!1;const Ff=(1+Math.sqrt(5))/2,xA=1/Ff,ON=[new de(-Ff,xA,0),new de(Ff,xA,0),new de(-xA,0,Ff),new de(xA,0,Ff),new de(0,Ff,-xA),new de(0,Ff,xA),new de(-1,1,-1),new de(1,1,-1),new de(-1,1,1),new de(1,1,1)];let IN=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){M3=this._renderer.getRenderTarget(),E3=this._renderer.getActiveCubeFace(),C3=this._renderer.getActiveMipmapLevel(),N3=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zN(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=kN(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?U:0,U,U),m.setRenderTarget(r),N&&m.render(w,l),m.render(e,l)}w.geometry.dispose(),w.material.dispose(),m.toneMapping=x,m.autoClear=v,e.background=C}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===sl||e.mapping===al;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=zN()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=kN());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new qi(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const u=this._cubeSize;$2(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,w3)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sVf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Vf}`);const E=[];let O=0;for(let G=0;GU-$A?r-U+$A:0),z=4*(this._cubeSize-I);$2(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,w3)}};function jV(i){const e=[],t=[],n=[];let r=i;const s=i-$A+1+UN.length;for(let a=0;ai-$A?u=UN[a-i+$A-1]:a===0&&(u=0),n.push(u);const h=1/(l-2),m=-h,v=1+h,x=[m,m,v,m,v,v,m,m,v,v,m,v],S=6,w=6,N=3,C=2,E=1,O=new Float32Array(N*w*S),U=new Float32Array(C*w*S),I=new Float32Array(E*w*S);for(let z=0;z2?0:-1,q=[G,W,0,G+2/3,W,0,G+2/3,W+1,0,G,W,0,G+2/3,W+1,0,G,W+1,0];O.set(q,N*w*z),U.set(x,C*w*z);const V=[z,z,z,z,z,z];I.set(V,E*w*z)}const j=new Ji;j.setAttribute("position",new Lr(O,N)),j.setAttribute("uv",new Lr(U,C)),j.setAttribute("faceIndex",new Lr(I,E)),e.push(j),r>$A&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function FN(i,e,t){const n=new Xh(i,e,t);return n.texture.mapping=ld,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function $2(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function HV(i,e,t){const n=new Float32Array(Vf),r=new de(0,1,0);return new so({name:"SphericalGaussianBlur",defines:{n:Vf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:uM(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform int samples; - uniform float weights[ n ]; - uniform bool latitudinal; - uniform float dTheta; - uniform float mipInt; - uniform vec3 poleAxis; - - #define ENVMAP_TYPE_CUBE_UV - #include - - vec3 getSample( float theta, vec3 axis ) { - - float cosTheta = cos( theta ); - // Rodrigues' axis-angle rotation - vec3 sampleDirection = vOutputDirection * cosTheta - + cross( axis, vOutputDirection ) * sin( theta ) - + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); - - return bilinearCubeUV( envMap, sampleDirection, mipInt ); - - } - - void main() { - - vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); - - if ( all( equal( axis, vec3( 0.0 ) ) ) ) { - - axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); - - } - - axis = normalize( axis ); - - gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); - - for ( int i = 1; i < n; i++ ) { - - if ( i >= samples ) { - - break; - - } - - float theta = dTheta * float( i ); - gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); - gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); - - } - - } - `,blending:no,depthTest:!1,depthWrite:!1})}function kN(){return new so({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uM(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - - #include - - void main() { - - vec3 outputDirection = normalize( vOutputDirection ); - vec2 uv = equirectUv( outputDirection ); - - gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); - - } - `,blending:no,depthTest:!1,depthWrite:!1})}function zN(){return new so({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uM(),fragmentShader:` - - precision mediump float; - precision mediump int; - - uniform float flipEnvMap; - - varying vec3 vOutputDirection; - - uniform samplerCube envMap; - - void main() { - - gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); - - } - `,blending:no,depthTest:!1,depthWrite:!1})}function uM(){return` - - precision mediump float; - precision mediump int; - - attribute float faceIndex; - - varying vec3 vOutputDirection; - - // RH coordinate system; PMREM face-indexing convention - vec3 getDirection( vec2 uv, float face ) { - - uv = 2.0 * uv - 1.0; - - vec3 direction = vec3( uv, 1.0 ); - - if ( face == 0.0 ) { - - direction = direction.zyx; // ( 1, v, u ) pos x - - } else if ( face == 1.0 ) { - - direction = direction.xzy; - direction.xz *= -1.0; // ( -u, 1, -v ) pos y - - } else if ( face == 2.0 ) { - - direction.x *= -1.0; // ( -u, v, 1 ) pos z - - } else if ( face == 3.0 ) { - - direction = direction.zyx; - direction.xz *= -1.0; // ( -1, v, -u ) neg x - - } else if ( face == 4.0 ) { - - direction = direction.xzy; - direction.xy *= -1.0; // ( -u, -1, v ) neg y - - } else if ( face == 5.0 ) { - - direction.z *= -1.0; // ( u, v, -1 ) neg z - - } - - return direction; - - } - - void main() { - - vOutputDirection = getDirection( uv, faceIndex ); - gl_Position = vec4( position, 1.0 ); - - } - `}function WV(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const u=l.mapping,h=u===Wh||u===$h,m=u===sl||u===al;if(h||m){let v=e.get(l);const x=v!==void 0?v.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==x)return t===null&&(t=new IN(i)),v=h?t.fromEquirectangular(l,v):t.fromCubemap(l,v),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),v.texture;if(v!==void 0)return v.texture;{const S=l.image;return h&&S&&S.height>0||m&&S&&r(S)?(t===null&&(t=new IN(i)),v=h?t.fromEquirectangular(l):t.fromCubemap(l),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),l.addEventListener("dispose",s),v.texture):null}}}return l}function r(l){let u=0;const h=6;for(let m=0;me.maxTextureSize&&(z=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const G=new Float32Array(j*z*4*v),W=new $w(G,j,z,v);W.type=ss,W.needsUpdate=!0;const q=I*4;for(let Y=0;Y0)return i;const r=e*t;let s=qN[r];if(s===void 0&&(s=new Float32Array(r),qN[r]=s),e!==0){n.toArray(s,0);for(let a=1,l=0;a!==e;++a)l+=t,i[a].toArray(s,l)}return s}function Cs(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t":" "} ${l}: ${t[a]}`)}return n.join(` -`)}const YN=new Qn;function Wj(i){hi._getMatrix(YN,hi.workingColorSpace,i);const e=`mat3( ${YN.elements.map(t=>t.toFixed(4))} )`;switch(hi.getTransfer(i)){case a_:return[e,"LinearTransferOETF"];case Hi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function QN(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+` - -`+r+` - -`+Hj(i.getShaderSource(e),a)}else return r}function $j(i,e){const t=Wj(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` -`)}function Xj(i,e){let t;switch(e){case U7:t="Linear";break;case B7:t="Reinhard";break;case O7:t="Cineon";break;case I7:t="ACESFilmic";break;case F7:t="AgX";break;case k7:t="Neutral";break;case HF:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const X2=new de;function Yj(){hi.getLuminanceCoefficients(X2);const i=X2.x.toFixed(4),e=X2.y.toFixed(4),t=X2.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` -`)}function Qj(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(xm).join(` -`)}function Kj(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` -`)}function Zj(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function eT(i){return i.replace(Jj,tH)}const eH=new Map;function tH(i,e){let t=ni[e];if(t===void 0){const n=eH.get(e);if(n!==void 0)t=ni[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return eT(t)}const nH=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function JN(i){return i.replace(nH,iH)}function iH(i,e,t,n){let r="";for(let s=parseInt(e);s0&&(C+=` -`),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w].filter(xm).join(` -`),E.length>0&&(E+=` -`)):(C=[e5(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+m:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` -`].filter(xm).join(` -`),E=[e5(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+m:"",t.envMap?"#define "+v:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==ro?"#define TONE_MAPPING":"",t.toneMapping!==ro?ni.tonemapping_pars_fragment:"",t.toneMapping!==ro?Xj("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ni.colorspace_pars_fragment,$j("linearToOutputTexel",t.outputColorSpace),Yj(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` -`].filter(xm).join(` -`)),a=eT(a),a=KN(a,t),a=ZN(a,t),l=eT(l),l=KN(l,t),l=ZN(l,t),a=JN(a),l=JN(l),t.isRawShaderMaterial!==!0&&(O=`#version 300 es -`,C=[S,"#define attribute in","#define varying out","#define texture2D texture"].join(` -`)+` -`+C,E=["#define varying in",t.glslVersion===X8?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===X8?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` -`)+` -`+E);const U=O+C+a,I=O+E+l,j=XN(r,r.VERTEX_SHADER,U),z=XN(r,r.FRAGMENT_SHADER,I);r.attachShader(N,j),r.attachShader(N,z),t.index0AttributeName!==void 0?r.bindAttribLocation(N,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(N,0,"position"),r.linkProgram(N);function G(Y){if(i.debug.checkShaderErrors){const te=r.getProgramInfoLog(N).trim(),ne=r.getShaderInfoLog(j).trim(),le=r.getShaderInfoLog(z).trim();let Q=!0,K=!0;if(r.getProgramParameter(N,r.LINK_STATUS)===!1)if(Q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,N,j,z);else{const ae=QN(r,j,"vertex"),Ae=QN(r,z,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(N,r.VALIDATE_STATUS)+` - -Material Name: `+Y.name+` -Material Type: `+Y.type+` - -Program Info Log: `+te+` -`+ae+` -`+Ae)}else te!==""?console.warn("THREE.WebGLProgram: Program Info Log:",te):(ne===""||le==="")&&(K=!1);K&&(Y.diagnostics={runnable:Q,programLog:te,vertexShader:{log:ne,prefix:C},fragmentShader:{log:le,prefix:E}})}r.deleteShader(j),r.deleteShader(z),W=new qv(r,N),q=Zj(r,N)}let W;this.getUniforms=function(){return W===void 0&&G(this),W};let q;this.getAttributes=function(){return q===void 0&&G(this),q};let V=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return V===!1&&(V=r.getProgramParameter(N,Vj)),V},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(N),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=jj++,this.cacheKey=e,this.usedTimes=1,this.program=N,this.vertexShader=j,this.fragmentShader=z,this}let cH=0;class hH{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new fH(e),t.set(e,n)),n}}class fH{constructor(e){this.id=cH++,this.code=e,this.usedTimes=0}}function dH(i,e,t,n,r,s,a){const l=new Xw,u=new hH,h=new Set,m=[],v=r.logarithmicDepthBuffer,x=r.vertexTextures;let S=r.precision;const w={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function N(q){return h.add(q),q===0?"uv":`uv${q}`}function C(q,V,Y,te,ne){const le=te.fog,Q=ne.geometry,K=q.isMeshStandardMaterial?te.environment:null,ae=(q.isMeshStandardMaterial?t:e).get(q.envMap||K),Ae=ae&&ae.mapping===ld?ae.image.height:null,be=w[q.type];q.precision!==null&&(S=r.getMaxPrecision(q.precision),S!==q.precision&&console.warn("THREE.WebGLProgram.getParameters:",q.precision,"not supported, using",S,"instead."));const Se=Q.morphAttributes.position||Q.morphAttributes.normal||Q.morphAttributes.color,se=Se!==void 0?Se.length:0;let Ee=0;Q.morphAttributes.position!==void 0&&(Ee=1),Q.morphAttributes.normal!==void 0&&(Ee=2),Q.morphAttributes.color!==void 0&&(Ee=3);let qe,Ce,ke,Qe;if(be){const ye=$a[be];qe=ye.vertexShader,Ce=ye.fragmentShader}else qe=q.vertexShader,Ce=q.fragmentShader,u.update(q),ke=u.getVertexShaderID(q),Qe=u.getFragmentShaderID(q);const et=i.getRenderTarget(),Pt=i.state.buffers.depth.getReversed(),Nt=ne.isInstancedMesh===!0,Gt=ne.isBatchedMesh===!0,Tt=!!q.map,Ge=!!q.matcap,dt=!!ae,he=!!q.aoMap,en=!!q.lightMap,wt=!!q.bumpMap,qt=!!q.normalMap,Lt=!!q.displacementMap,hn=!!q.emissiveMap,ut=!!q.metalnessMap,fe=!!q.roughnessMap,k=q.anisotropy>0,_e=q.clearcoat>0,Be=q.dispersion>0,Oe=q.iridescence>0,je=q.sheen>0,Bt=q.transmission>0,yt=k&&!!q.anisotropyMap,Xt=_e&&!!q.clearcoatMap,ln=_e&&!!q.clearcoatNormalMap,mt=_e&&!!q.clearcoatRoughnessMap,Wt=Oe&&!!q.iridescenceMap,Yt=Oe&&!!q.iridescenceThicknessMap,$t=je&&!!q.sheenColorMap,It=je&&!!q.sheenRoughnessMap,Te=!!q.specularMap,nt=!!q.specularColorMap,At=!!q.specularIntensityMap,ce=Bt&&!!q.transmissionMap,xt=Bt&&!!q.thicknessMap,Ze=!!q.gradientMap,lt=!!q.alphaMap,bt=q.alphaTest>0,Kt=!!q.alphaHash,un=!!q.extensions;let Ye=ro;q.toneMapped&&(et===null||et.isXRRenderTarget===!0)&&(Ye=i.toneMapping);const St={shaderID:be,shaderType:q.type,shaderName:q.name,vertexShader:qe,fragmentShader:Ce,defines:q.defines,customVertexShaderID:ke,customFragmentShaderID:Qe,isRawShaderMaterial:q.isRawShaderMaterial===!0,glslVersion:q.glslVersion,precision:S,batching:Gt,batchingColor:Gt&&ne._colorsTexture!==null,instancing:Nt,instancingColor:Nt&&ne.instanceColor!==null,instancingMorph:Nt&&ne.morphTexture!==null,supportsVertexTextures:x,outputColorSpace:et===null?i.outputColorSpace:et.isXRRenderTarget===!0?et.texture.colorSpace:Io,alphaToCoverage:!!q.alphaToCoverage,map:Tt,matcap:Ge,envMap:dt,envMapMode:dt&&ae.mapping,envMapCubeUVHeight:Ae,aoMap:he,lightMap:en,bumpMap:wt,normalMap:qt,displacementMap:x&&Lt,emissiveMap:hn,normalMapObjectSpace:qt&&q.normalMapType===z7,normalMapTangentSpace:qt&&q.normalMapType===kc,metalnessMap:ut,roughnessMap:fe,anisotropy:k,anisotropyMap:yt,clearcoat:_e,clearcoatMap:Xt,clearcoatNormalMap:ln,clearcoatRoughnessMap:mt,dispersion:Be,iridescence:Oe,iridescenceMap:Wt,iridescenceThicknessMap:Yt,sheen:je,sheenColorMap:$t,sheenRoughnessMap:It,specularMap:Te,specularColorMap:nt,specularIntensityMap:At,transmission:Bt,transmissionMap:ce,thicknessMap:xt,gradientMap:Ze,opaque:q.transparent===!1&&q.blending===io&&q.alphaToCoverage===!1,alphaMap:lt,alphaTest:bt,alphaHash:Kt,combine:q.combine,mapUv:Tt&&N(q.map.channel),aoMapUv:he&&N(q.aoMap.channel),lightMapUv:en&&N(q.lightMap.channel),bumpMapUv:wt&&N(q.bumpMap.channel),normalMapUv:qt&&N(q.normalMap.channel),displacementMapUv:Lt&&N(q.displacementMap.channel),emissiveMapUv:hn&&N(q.emissiveMap.channel),metalnessMapUv:ut&&N(q.metalnessMap.channel),roughnessMapUv:fe&&N(q.roughnessMap.channel),anisotropyMapUv:yt&&N(q.anisotropyMap.channel),clearcoatMapUv:Xt&&N(q.clearcoatMap.channel),clearcoatNormalMapUv:ln&&N(q.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:mt&&N(q.clearcoatRoughnessMap.channel),iridescenceMapUv:Wt&&N(q.iridescenceMap.channel),iridescenceThicknessMapUv:Yt&&N(q.iridescenceThicknessMap.channel),sheenColorMapUv:$t&&N(q.sheenColorMap.channel),sheenRoughnessMapUv:It&&N(q.sheenRoughnessMap.channel),specularMapUv:Te&&N(q.specularMap.channel),specularColorMapUv:nt&&N(q.specularColorMap.channel),specularIntensityMapUv:At&&N(q.specularIntensityMap.channel),transmissionMapUv:ce&&N(q.transmissionMap.channel),thicknessMapUv:xt&&N(q.thicknessMap.channel),alphaMapUv:lt&&N(q.alphaMap.channel),vertexTangents:!!Q.attributes.tangent&&(qt||k),vertexColors:q.vertexColors,vertexAlphas:q.vertexColors===!0&&!!Q.attributes.color&&Q.attributes.color.itemSize===4,pointsUvs:ne.isPoints===!0&&!!Q.attributes.uv&&(Tt||lt),fog:!!le,useFog:q.fog===!0,fogExp2:!!le&&le.isFogExp2,flatShading:q.flatShading===!0,sizeAttenuation:q.sizeAttenuation===!0,logarithmicDepthBuffer:v,reverseDepthBuffer:Pt,skinning:ne.isSkinnedMesh===!0,morphTargets:Q.morphAttributes.position!==void 0,morphNormals:Q.morphAttributes.normal!==void 0,morphColors:Q.morphAttributes.color!==void 0,morphTargetsCount:se,morphTextureStride:Ee,numDirLights:V.directional.length,numPointLights:V.point.length,numSpotLights:V.spot.length,numSpotLightMaps:V.spotLightMap.length,numRectAreaLights:V.rectArea.length,numHemiLights:V.hemi.length,numDirLightShadows:V.directionalShadowMap.length,numPointLightShadows:V.pointShadowMap.length,numSpotLightShadows:V.spotShadowMap.length,numSpotLightShadowsWithMaps:V.numSpotLightShadowsWithMaps,numLightProbes:V.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:q.dithering,shadowMapEnabled:i.shadowMap.enabled&&Y.length>0,shadowMapType:i.shadowMap.type,toneMapping:Ye,decodeVideoTexture:Tt&&q.map.isVideoTexture===!0&&hi.getTransfer(q.map.colorSpace)===Hi,decodeVideoTextureEmissive:hn&&q.emissiveMap.isVideoTexture===!0&&hi.getTransfer(q.emissiveMap.colorSpace)===Hi,premultipliedAlpha:q.premultipliedAlpha,doubleSided:q.side===gs,flipSided:q.side===gr,useDepthPacking:q.depthPacking>=0,depthPacking:q.depthPacking||0,index0AttributeName:q.index0AttributeName,extensionClipCullDistance:un&&q.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(un&&q.extensions.multiDraw===!0||Gt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:q.customProgramCacheKey()};return St.vertexUv1s=h.has(1),St.vertexUv2s=h.has(2),St.vertexUv3s=h.has(3),h.clear(),St}function E(q){const V=[];if(q.shaderID?V.push(q.shaderID):(V.push(q.customVertexShaderID),V.push(q.customFragmentShaderID)),q.defines!==void 0)for(const Y in q.defines)V.push(Y),V.push(q.defines[Y]);return q.isRawShaderMaterial===!1&&(O(V,q),U(V,q),V.push(i.outputColorSpace)),V.push(q.customProgramCacheKey),V.join()}function O(q,V){q.push(V.precision),q.push(V.outputColorSpace),q.push(V.envMapMode),q.push(V.envMapCubeUVHeight),q.push(V.mapUv),q.push(V.alphaMapUv),q.push(V.lightMapUv),q.push(V.aoMapUv),q.push(V.bumpMapUv),q.push(V.normalMapUv),q.push(V.displacementMapUv),q.push(V.emissiveMapUv),q.push(V.metalnessMapUv),q.push(V.roughnessMapUv),q.push(V.anisotropyMapUv),q.push(V.clearcoatMapUv),q.push(V.clearcoatNormalMapUv),q.push(V.clearcoatRoughnessMapUv),q.push(V.iridescenceMapUv),q.push(V.iridescenceThicknessMapUv),q.push(V.sheenColorMapUv),q.push(V.sheenRoughnessMapUv),q.push(V.specularMapUv),q.push(V.specularColorMapUv),q.push(V.specularIntensityMapUv),q.push(V.transmissionMapUv),q.push(V.thicknessMapUv),q.push(V.combine),q.push(V.fogExp2),q.push(V.sizeAttenuation),q.push(V.morphTargetsCount),q.push(V.morphAttributeCount),q.push(V.numDirLights),q.push(V.numPointLights),q.push(V.numSpotLights),q.push(V.numSpotLightMaps),q.push(V.numHemiLights),q.push(V.numRectAreaLights),q.push(V.numDirLightShadows),q.push(V.numPointLightShadows),q.push(V.numSpotLightShadows),q.push(V.numSpotLightShadowsWithMaps),q.push(V.numLightProbes),q.push(V.shadowMapType),q.push(V.toneMapping),q.push(V.numClippingPlanes),q.push(V.numClipIntersection),q.push(V.depthPacking)}function U(q,V){l.disableAll(),V.supportsVertexTextures&&l.enable(0),V.instancing&&l.enable(1),V.instancingColor&&l.enable(2),V.instancingMorph&&l.enable(3),V.matcap&&l.enable(4),V.envMap&&l.enable(5),V.normalMapObjectSpace&&l.enable(6),V.normalMapTangentSpace&&l.enable(7),V.clearcoat&&l.enable(8),V.iridescence&&l.enable(9),V.alphaTest&&l.enable(10),V.vertexColors&&l.enable(11),V.vertexAlphas&&l.enable(12),V.vertexUv1s&&l.enable(13),V.vertexUv2s&&l.enable(14),V.vertexUv3s&&l.enable(15),V.vertexTangents&&l.enable(16),V.anisotropy&&l.enable(17),V.alphaHash&&l.enable(18),V.batching&&l.enable(19),V.dispersion&&l.enable(20),V.batchingColor&&l.enable(21),q.push(l.mask),l.disableAll(),V.fog&&l.enable(0),V.useFog&&l.enable(1),V.flatShading&&l.enable(2),V.logarithmicDepthBuffer&&l.enable(3),V.reverseDepthBuffer&&l.enable(4),V.skinning&&l.enable(5),V.morphTargets&&l.enable(6),V.morphNormals&&l.enable(7),V.morphColors&&l.enable(8),V.premultipliedAlpha&&l.enable(9),V.shadowMapEnabled&&l.enable(10),V.doubleSided&&l.enable(11),V.flipSided&&l.enable(12),V.useDepthPacking&&l.enable(13),V.dithering&&l.enable(14),V.transmission&&l.enable(15),V.sheen&&l.enable(16),V.opaque&&l.enable(17),V.pointsUvs&&l.enable(18),V.decodeVideoTexture&&l.enable(19),V.decodeVideoTextureEmissive&&l.enable(20),V.alphaToCoverage&&l.enable(21),q.push(l.mask)}function I(q){const V=w[q.type];let Y;if(V){const te=$a[V];Y=vy.clone(te.uniforms)}else Y=q.uniforms;return Y}function j(q,V){let Y;for(let te=0,ne=m.length;te0?n.push(E):S.transparent===!0?r.push(E):t.push(E)}function u(v,x,S,w,N,C){const E=a(v,x,S,w,N,C);S.transmission>0?n.unshift(E):S.transparent===!0?r.unshift(E):t.unshift(E)}function h(v,x){t.length>1&&t.sort(v||pH),n.length>1&&n.sort(x||t5),r.length>1&&r.sort(x||t5)}function m(){for(let v=e,x=i.length;v=s.length?(a=new n5,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function gH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new de,color:new mn};break;case"SpotLight":t={position:new de,direction:new de,color:new mn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new de,color:new mn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new de,skyColor:new mn,groundColor:new mn};break;case"RectAreaLight":t={color:new mn,position:new de,halfWidth:new de,halfHeight:new de};break}return i[e.id]=t,t}}}function vH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Et,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let _H=0;function yH(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function xH(i){const e=new gH,t=vH(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)n.probe.push(new de);const r=new de,s=new Xn,a=new Xn;function l(h){let m=0,v=0,x=0;for(let q=0;q<9;q++)n.probe[q].set(0,0,0);let S=0,w=0,N=0,C=0,E=0,O=0,U=0,I=0,j=0,z=0,G=0;h.sort(yH);for(let q=0,V=h.length;q0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=sn.LTC_FLOAT_1,n.rectAreaLTC2=sn.LTC_FLOAT_2):(n.rectAreaLTC1=sn.LTC_HALF_1,n.rectAreaLTC2=sn.LTC_HALF_2)),n.ambient[0]=m,n.ambient[1]=v,n.ambient[2]=x;const W=n.hash;(W.directionalLength!==S||W.pointLength!==w||W.spotLength!==N||W.rectAreaLength!==C||W.hemiLength!==E||W.numDirectionalShadows!==O||W.numPointShadows!==U||W.numSpotShadows!==I||W.numSpotMaps!==j||W.numLightProbes!==G)&&(n.directional.length=S,n.spot.length=N,n.rectArea.length=C,n.point.length=w,n.hemi.length=E,n.directionalShadow.length=O,n.directionalShadowMap.length=O,n.pointShadow.length=U,n.pointShadowMap.length=U,n.spotShadow.length=I,n.spotShadowMap.length=I,n.directionalShadowMatrix.length=O,n.pointShadowMatrix.length=U,n.spotLightMatrix.length=I+j-z,n.spotLightMap.length=j,n.numSpotLightShadowsWithMaps=z,n.numLightProbes=G,W.directionalLength=S,W.pointLength=w,W.spotLength=N,W.rectAreaLength=C,W.hemiLength=E,W.numDirectionalShadows=O,W.numPointShadows=U,W.numSpotShadows=I,W.numSpotMaps=j,W.numLightProbes=G,n.version=_H++)}function u(h,m){let v=0,x=0,S=0,w=0,N=0;const C=m.matrixWorldInverse;for(let E=0,O=h.length;E=a.length?(l=new i5(i),a.push(l)):l=a[s],l}function n(){e=new WeakMap}return{get:t,dispose:n}}const SH=`void main() { - gl_Position = vec4( position, 1.0 ); -}`,TH=`uniform sampler2D shadow_pass; -uniform vec2 resolution; -uniform float radius; -#include -void main() { - const float samples = float( VSM_SAMPLES ); - float mean = 0.0; - float squared_mean = 0.0; - float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); - float uvStart = samples <= 1.0 ? 0.0 : - 1.0; - for ( float i = 0.0; i < samples; i ++ ) { - float uvOffset = uvStart + i * uvStride; - #ifdef HORIZONTAL_PASS - vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); - mean += distribution.x; - squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; - #else - float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); - mean += depth; - squared_mean += depth * depth; - #endif - } - mean = mean / samples; - squared_mean = squared_mean / samples; - float std_dev = sqrt( squared_mean - mean * mean ); - gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function wH(i,e,t){let n=new zg;const r=new Et,s=new Et,a=new qn,l=new Oz({depthPacking:KF}),u=new Iz,h={},m=t.maxTextureSize,v={[zl]:gr,[gr]:zl,[gs]:gs},x=new so({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Et},radius:{value:4}},vertexShader:SH,fragmentShader:TH}),S=x.clone();S.defines.HORIZONTAL_PASS=1;const w=new Ji;w.setAttribute("position",new Lr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const N=new qi(w,x),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=bw;let E=this.type;this.render=function(z,G,W){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||z.length===0)return;const q=i.getRenderTarget(),V=i.getActiveCubeFace(),Y=i.getActiveMipmapLevel(),te=i.state;te.setBlending(no),te.buffers.color.setClear(1,1,1,1),te.buffers.depth.setTest(!0),te.setScissorTest(!1);const ne=E!==No&&this.type===No,le=E===No&&this.type!==No;for(let Q=0,K=z.length;Qm||r.y>m)&&(r.x>m&&(s.x=Math.floor(m/be.x),r.x=s.x*be.x,Ae.mapSize.x=s.x),r.y>m&&(s.y=Math.floor(m/be.y),r.y=s.y*be.y,Ae.mapSize.y=s.y)),Ae.map===null||ne===!0||le===!0){const se=this.type!==No?{minFilter:br,magFilter:br}:{};Ae.map!==null&&Ae.map.dispose(),Ae.map=new Xh(r.x,r.y,se),Ae.map.texture.name=ae.name+".shadowMap",Ae.camera.updateProjectionMatrix()}i.setRenderTarget(Ae.map),i.clear();const Se=Ae.getViewportCount();for(let se=0;se0||G.map&&G.alphaTest>0){const te=V.uuid,ne=G.uuid;let le=h[te];le===void 0&&(le={},h[te]=le);let Q=le[ne];Q===void 0&&(Q=V.clone(),le[ne]=Q,G.addEventListener("dispose",j)),V=Q}if(V.visible=G.visible,V.wireframe=G.wireframe,q===No?V.side=G.shadowSide!==null?G.shadowSide:G.side:V.side=G.shadowSide!==null?G.shadowSide:v[G.side],V.alphaMap=G.alphaMap,V.alphaTest=G.alphaTest,V.map=G.map,V.clipShadows=G.clipShadows,V.clippingPlanes=G.clippingPlanes,V.clipIntersection=G.clipIntersection,V.displacementMap=G.displacementMap,V.displacementScale=G.displacementScale,V.displacementBias=G.displacementBias,V.wireframeLinewidth=G.wireframeLinewidth,V.linewidth=G.linewidth,W.isPointLight===!0&&V.isMeshDistanceMaterial===!0){const te=i.properties.get(V);te.light=W}return V}function I(z,G,W,q,V){if(z.visible===!1)return;if(z.layers.test(G.layers)&&(z.isMesh||z.isLine||z.isPoints)&&(z.castShadow||z.receiveShadow&&V===No)&&(!z.frustumCulled||n.intersectsObject(z))){z.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,z.matrixWorld);const ne=e.update(z),le=z.material;if(Array.isArray(le)){const Q=ne.groups;for(let K=0,ae=Q.length;K=1):Ae.indexOf("OpenGL ES")!==-1&&(ae=parseFloat(/^OpenGL ES (\d)/.exec(Ae)[1]),K=ae>=2);let be=null,Se={};const se=i.getParameter(i.SCISSOR_BOX),Ee=i.getParameter(i.VIEWPORT),qe=new qn().fromArray(se),Ce=new qn().fromArray(Ee);function ke(ce,xt,Ze,lt){const bt=new Uint8Array(4),Kt=i.createTexture();i.bindTexture(ce,Kt),i.texParameteri(ce,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(ce,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let un=0;un"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new Et,m=new WeakMap;let v;const x=new WeakMap;let S=!1;try{S=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function w(fe,k){return S?new OffscreenCanvas(fe,k):og("canvas")}function N(fe,k,_e){let Be=1;const Oe=ut(fe);if((Oe.width>_e||Oe.height>_e)&&(Be=_e/Math.max(Oe.width,Oe.height)),Be<1)if(typeof HTMLImageElement<"u"&&fe instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&fe instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&fe instanceof ImageBitmap||typeof VideoFrame<"u"&&fe instanceof VideoFrame){const je=Math.floor(Be*Oe.width),Bt=Math.floor(Be*Oe.height);v===void 0&&(v=w(je,Bt));const yt=k?w(je,Bt):v;return yt.width=je,yt.height=Bt,yt.getContext("2d").drawImage(fe,0,0,je,Bt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Oe.width+"x"+Oe.height+") to ("+je+"x"+Bt+")."),yt}else return"data"in fe&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Oe.width+"x"+Oe.height+")."),fe;return fe}function C(fe){return fe.generateMipmaps}function E(fe){i.generateMipmap(fe)}function O(fe){return fe.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:fe.isWebGL3DRenderTarget?i.TEXTURE_3D:fe.isWebGLArrayRenderTarget||fe.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function U(fe,k,_e,Be,Oe=!1){if(fe!==null){if(i[fe]!==void 0)return i[fe];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+fe+"'")}let je=k;if(k===i.RED&&(_e===i.FLOAT&&(je=i.R32F),_e===i.HALF_FLOAT&&(je=i.R16F),_e===i.UNSIGNED_BYTE&&(je=i.R8)),k===i.RED_INTEGER&&(_e===i.UNSIGNED_BYTE&&(je=i.R8UI),_e===i.UNSIGNED_SHORT&&(je=i.R16UI),_e===i.UNSIGNED_INT&&(je=i.R32UI),_e===i.BYTE&&(je=i.R8I),_e===i.SHORT&&(je=i.R16I),_e===i.INT&&(je=i.R32I)),k===i.RG&&(_e===i.FLOAT&&(je=i.RG32F),_e===i.HALF_FLOAT&&(je=i.RG16F),_e===i.UNSIGNED_BYTE&&(je=i.RG8)),k===i.RG_INTEGER&&(_e===i.UNSIGNED_BYTE&&(je=i.RG8UI),_e===i.UNSIGNED_SHORT&&(je=i.RG16UI),_e===i.UNSIGNED_INT&&(je=i.RG32UI),_e===i.BYTE&&(je=i.RG8I),_e===i.SHORT&&(je=i.RG16I),_e===i.INT&&(je=i.RG32I)),k===i.RGB_INTEGER&&(_e===i.UNSIGNED_BYTE&&(je=i.RGB8UI),_e===i.UNSIGNED_SHORT&&(je=i.RGB16UI),_e===i.UNSIGNED_INT&&(je=i.RGB32UI),_e===i.BYTE&&(je=i.RGB8I),_e===i.SHORT&&(je=i.RGB16I),_e===i.INT&&(je=i.RGB32I)),k===i.RGBA_INTEGER&&(_e===i.UNSIGNED_BYTE&&(je=i.RGBA8UI),_e===i.UNSIGNED_SHORT&&(je=i.RGBA16UI),_e===i.UNSIGNED_INT&&(je=i.RGBA32UI),_e===i.BYTE&&(je=i.RGBA8I),_e===i.SHORT&&(je=i.RGBA16I),_e===i.INT&&(je=i.RGBA32I)),k===i.RGB&&_e===i.UNSIGNED_INT_5_9_9_9_REV&&(je=i.RGB9_E5),k===i.RGBA){const Bt=Oe?a_:hi.getTransfer(Be);_e===i.FLOAT&&(je=i.RGBA32F),_e===i.HALF_FLOAT&&(je=i.RGBA16F),_e===i.UNSIGNED_BYTE&&(je=Bt===Hi?i.SRGB8_ALPHA8:i.RGBA8),_e===i.UNSIGNED_SHORT_4_4_4_4&&(je=i.RGBA4),_e===i.UNSIGNED_SHORT_5_5_5_1&&(je=i.RGB5_A1)}return(je===i.R16F||je===i.R32F||je===i.RG16F||je===i.RG32F||je===i.RGBA16F||je===i.RGBA32F)&&e.get("EXT_color_buffer_float"),je}function I(fe,k){let _e;return fe?k===null||k===Ir||k===xu?_e=i.DEPTH24_STENCIL8:k===ss?_e=i.DEPTH32F_STENCIL8:k===Bl&&(_e=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):k===null||k===Ir||k===xu?_e=i.DEPTH_COMPONENT24:k===ss?_e=i.DEPTH_COMPONENT32F:k===Bl&&(_e=i.DEPTH_COMPONENT16),_e}function j(fe,k){return C(fe)===!0||fe.isFramebufferTexture&&fe.minFilter!==br&&fe.minFilter!==Ms?Math.log2(Math.max(k.width,k.height))+1:fe.mipmaps!==void 0&&fe.mipmaps.length>0?fe.mipmaps.length:fe.isCompressedTexture&&Array.isArray(fe.image)?k.mipmaps.length:1}function z(fe){const k=fe.target;k.removeEventListener("dispose",z),W(k),k.isVideoTexture&&m.delete(k)}function G(fe){const k=fe.target;k.removeEventListener("dispose",G),V(k)}function W(fe){const k=n.get(fe);if(k.__webglInit===void 0)return;const _e=fe.source,Be=x.get(_e);if(Be){const Oe=Be[k.__cacheKey];Oe.usedTimes--,Oe.usedTimes===0&&q(fe),Object.keys(Be).length===0&&x.delete(_e)}n.remove(fe)}function q(fe){const k=n.get(fe);i.deleteTexture(k.__webglTexture);const _e=fe.source,Be=x.get(_e);delete Be[k.__cacheKey],a.memory.textures--}function V(fe){const k=n.get(fe);if(fe.depthTexture&&(fe.depthTexture.dispose(),n.remove(fe.depthTexture)),fe.isWebGLCubeRenderTarget)for(let Be=0;Be<6;Be++){if(Array.isArray(k.__webglFramebuffer[Be]))for(let Oe=0;Oe=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+fe+" texture units while this GPU supports only "+r.maxTextures),Y+=1,fe}function le(fe){const k=[];return k.push(fe.wrapS),k.push(fe.wrapT),k.push(fe.wrapR||0),k.push(fe.magFilter),k.push(fe.minFilter),k.push(fe.anisotropy),k.push(fe.internalFormat),k.push(fe.format),k.push(fe.type),k.push(fe.generateMipmaps),k.push(fe.premultiplyAlpha),k.push(fe.flipY),k.push(fe.unpackAlignment),k.push(fe.colorSpace),k.join()}function Q(fe,k){const _e=n.get(fe);if(fe.isVideoTexture&&Lt(fe),fe.isRenderTargetTexture===!1&&fe.version>0&&_e.__version!==fe.version){const Be=fe.image;if(Be===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Be.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(_e,fe,k);return}}t.bindTexture(i.TEXTURE_2D,_e.__webglTexture,i.TEXTURE0+k)}function K(fe,k){const _e=n.get(fe);if(fe.version>0&&_e.__version!==fe.version){Ce(_e,fe,k);return}t.bindTexture(i.TEXTURE_2D_ARRAY,_e.__webglTexture,i.TEXTURE0+k)}function ae(fe,k){const _e=n.get(fe);if(fe.version>0&&_e.__version!==fe.version){Ce(_e,fe,k);return}t.bindTexture(i.TEXTURE_3D,_e.__webglTexture,i.TEXTURE0+k)}function Ae(fe,k){const _e=n.get(fe);if(fe.version>0&&_e.__version!==fe.version){ke(_e,fe,k);return}t.bindTexture(i.TEXTURE_CUBE_MAP,_e.__webglTexture,i.TEXTURE0+k)}const be={[ud]:i.REPEAT,[lu]:i.CLAMP_TO_EDGE,[cd]:i.MIRRORED_REPEAT},Se={[br]:i.NEAREST,[s_]:i.NEAREST_MIPMAP_NEAREST,[uu]:i.NEAREST_MIPMAP_LINEAR,[Ms]:i.LINEAR,[n0]:i.LINEAR_MIPMAP_NEAREST,[Ya]:i.LINEAR_MIPMAP_LINEAR},se={[zw]:i.NEVER,[Hw]:i.ALWAYS,[my]:i.LESS,[gy]:i.LEQUAL,[Gw]:i.EQUAL,[jw]:i.GEQUAL,[qw]:i.GREATER,[Vw]:i.NOTEQUAL};function Ee(fe,k){if(k.type===ss&&e.has("OES_texture_float_linear")===!1&&(k.magFilter===Ms||k.magFilter===n0||k.magFilter===uu||k.magFilter===Ya||k.minFilter===Ms||k.minFilter===n0||k.minFilter===uu||k.minFilter===Ya)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(fe,i.TEXTURE_WRAP_S,be[k.wrapS]),i.texParameteri(fe,i.TEXTURE_WRAP_T,be[k.wrapT]),(fe===i.TEXTURE_3D||fe===i.TEXTURE_2D_ARRAY)&&i.texParameteri(fe,i.TEXTURE_WRAP_R,be[k.wrapR]),i.texParameteri(fe,i.TEXTURE_MAG_FILTER,Se[k.magFilter]),i.texParameteri(fe,i.TEXTURE_MIN_FILTER,Se[k.minFilter]),k.compareFunction&&(i.texParameteri(fe,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(fe,i.TEXTURE_COMPARE_FUNC,se[k.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(k.magFilter===br||k.minFilter!==uu&&k.minFilter!==Ya||k.type===ss&&e.has("OES_texture_float_linear")===!1)return;if(k.anisotropy>1||n.get(k).__currentAnisotropy){const _e=e.get("EXT_texture_filter_anisotropic");i.texParameterf(fe,_e.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),n.get(k).__currentAnisotropy=k.anisotropy}}}function qe(fe,k){let _e=!1;fe.__webglInit===void 0&&(fe.__webglInit=!0,k.addEventListener("dispose",z));const Be=k.source;let Oe=x.get(Be);Oe===void 0&&(Oe={},x.set(Be,Oe));const je=le(k);if(je!==fe.__cacheKey){Oe[je]===void 0&&(Oe[je]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,_e=!0),Oe[je].usedTimes++;const Bt=Oe[fe.__cacheKey];Bt!==void 0&&(Oe[fe.__cacheKey].usedTimes--,Bt.usedTimes===0&&q(k)),fe.__cacheKey=je,fe.__webglTexture=Oe[je].texture}return _e}function Ce(fe,k,_e){let Be=i.TEXTURE_2D;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(Be=i.TEXTURE_2D_ARRAY),k.isData3DTexture&&(Be=i.TEXTURE_3D);const Oe=qe(fe,k),je=k.source;t.bindTexture(Be,fe.__webglTexture,i.TEXTURE0+_e);const Bt=n.get(je);if(je.version!==Bt.__version||Oe===!0){t.activeTexture(i.TEXTURE0+_e);const yt=hi.getPrimaries(hi.workingColorSpace),Xt=k.colorSpace===Oo?null:hi.getPrimaries(k.colorSpace),ln=k.colorSpace===Oo||yt===Xt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,k.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,k.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ln);let mt=N(k.image,!1,r.maxTextureSize);mt=hn(k,mt);const Wt=s.convert(k.format,k.colorSpace),Yt=s.convert(k.type);let $t=U(k.internalFormat,Wt,Yt,k.colorSpace,k.isVideoTexture);Ee(Be,k);let It;const Te=k.mipmaps,nt=k.isVideoTexture!==!0,At=Bt.__version===void 0||Oe===!0,ce=je.dataReady,xt=j(k,mt);if(k.isDepthTexture)$t=I(k.format===bu,k.type),At&&(nt?t.texStorage2D(i.TEXTURE_2D,1,$t,mt.width,mt.height):t.texImage2D(i.TEXTURE_2D,0,$t,mt.width,mt.height,0,Wt,Yt,null));else if(k.isDataTexture)if(Te.length>0){nt&&At&&t.texStorage2D(i.TEXTURE_2D,xt,$t,Te[0].width,Te[0].height);for(let Ze=0,lt=Te.length;Ze0){const bt=LN(It.width,It.height,k.format,k.type);for(const Kt of k.layerUpdates){const un=It.data.subarray(Kt*bt/It.data.BYTES_PER_ELEMENT,(Kt+1)*bt/It.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Ze,0,0,Kt,It.width,It.height,1,Wt,un)}k.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Ze,0,0,0,It.width,It.height,mt.depth,Wt,It.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Ze,$t,It.width,It.height,mt.depth,0,It.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else nt?ce&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Ze,0,0,0,It.width,It.height,mt.depth,Wt,Yt,It.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Ze,$t,It.width,It.height,mt.depth,0,Wt,Yt,It.data)}else{nt&&At&&t.texStorage2D(i.TEXTURE_2D,xt,$t,Te[0].width,Te[0].height);for(let Ze=0,lt=Te.length;Ze0){const Ze=LN(mt.width,mt.height,k.format,k.type);for(const lt of k.layerUpdates){const bt=mt.data.subarray(lt*Ze/mt.data.BYTES_PER_ELEMENT,(lt+1)*Ze/mt.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,lt,mt.width,mt.height,1,Wt,Yt,bt)}k.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,mt.width,mt.height,mt.depth,Wt,Yt,mt.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,$t,mt.width,mt.height,mt.depth,0,Wt,Yt,mt.data);else if(k.isData3DTexture)nt?(At&&t.texStorage3D(i.TEXTURE_3D,xt,$t,mt.width,mt.height,mt.depth),ce&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,mt.width,mt.height,mt.depth,Wt,Yt,mt.data)):t.texImage3D(i.TEXTURE_3D,0,$t,mt.width,mt.height,mt.depth,0,Wt,Yt,mt.data);else if(k.isFramebufferTexture){if(At)if(nt)t.texStorage2D(i.TEXTURE_2D,xt,$t,mt.width,mt.height);else{let Ze=mt.width,lt=mt.height;for(let bt=0;bt>=1,lt>>=1}}else if(Te.length>0){if(nt&&At){const Ze=ut(Te[0]);t.texStorage2D(i.TEXTURE_2D,xt,$t,Ze.width,Ze.height)}for(let Ze=0,lt=Te.length;Ze0&&xt++;const lt=ut(Wt[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,xt,Te,lt.width,lt.height)}for(let lt=0;lt<6;lt++)if(mt){nt?ce&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,0,0,Wt[lt].width,Wt[lt].height,$t,It,Wt[lt].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,Te,Wt[lt].width,Wt[lt].height,0,$t,It,Wt[lt].data);for(let bt=0;bt>je),Yt=Math.max(1,k.height>>je);Oe===i.TEXTURE_3D||Oe===i.TEXTURE_2D_ARRAY?t.texImage3D(Oe,je,Xt,Wt,Yt,k.depth,0,Bt,yt,null):t.texImage2D(Oe,je,Xt,Wt,Yt,0,Bt,yt,null)}t.bindFramebuffer(i.FRAMEBUFFER,fe),qt(k)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Be,Oe,mt.__webglTexture,0,wt(k)):(Oe===i.TEXTURE_2D||Oe>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Oe<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Be,Oe,mt.__webglTexture,je),t.bindFramebuffer(i.FRAMEBUFFER,null)}function et(fe,k,_e){if(i.bindRenderbuffer(i.RENDERBUFFER,fe),k.depthBuffer){const Be=k.depthTexture,Oe=Be&&Be.isDepthTexture?Be.type:null,je=I(k.stencilBuffer,Oe),Bt=k.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,yt=wt(k);qt(k)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,yt,je,k.width,k.height):_e?i.renderbufferStorageMultisample(i.RENDERBUFFER,yt,je,k.width,k.height):i.renderbufferStorage(i.RENDERBUFFER,je,k.width,k.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Bt,i.RENDERBUFFER,fe)}else{const Be=k.textures;for(let Oe=0;Oe{delete k.__boundDepthTexture,delete k.__depthDisposeCallback,Be.removeEventListener("dispose",Oe)};Be.addEventListener("dispose",Oe),k.__depthDisposeCallback=Oe}k.__boundDepthTexture=Be}if(fe.depthTexture&&!k.__autoAllocateDepthBuffer){if(_e)throw new Error("target.depthTexture not supported in Cube render targets");Pt(k.__webglFramebuffer,fe)}else if(_e){k.__webglDepthbuffer=[];for(let Be=0;Be<6;Be++)if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer[Be]),k.__webglDepthbuffer[Be]===void 0)k.__webglDepthbuffer[Be]=i.createRenderbuffer(),et(k.__webglDepthbuffer[Be],fe,!1);else{const Oe=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,je=k.__webglDepthbuffer[Be];i.bindRenderbuffer(i.RENDERBUFFER,je),i.framebufferRenderbuffer(i.FRAMEBUFFER,Oe,i.RENDERBUFFER,je)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer),k.__webglDepthbuffer===void 0)k.__webglDepthbuffer=i.createRenderbuffer(),et(k.__webglDepthbuffer,fe,!1);else{const Be=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Oe=k.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Oe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Be,i.RENDERBUFFER,Oe)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Gt(fe,k,_e){const Be=n.get(fe);k!==void 0&&Qe(Be.__webglFramebuffer,fe,fe.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),_e!==void 0&&Nt(fe)}function Tt(fe){const k=fe.texture,_e=n.get(fe),Be=n.get(k);fe.addEventListener("dispose",G);const Oe=fe.textures,je=fe.isWebGLCubeRenderTarget===!0,Bt=Oe.length>1;if(Bt||(Be.__webglTexture===void 0&&(Be.__webglTexture=i.createTexture()),Be.__version=k.version,a.memory.textures++),je){_e.__webglFramebuffer=[];for(let yt=0;yt<6;yt++)if(k.mipmaps&&k.mipmaps.length>0){_e.__webglFramebuffer[yt]=[];for(let Xt=0;Xt0){_e.__webglFramebuffer=[];for(let yt=0;yt0&&qt(fe)===!1){_e.__webglMultisampledFramebuffer=i.createFramebuffer(),_e.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,_e.__webglMultisampledFramebuffer);for(let yt=0;yt0)for(let Xt=0;Xt0)for(let Xt=0;Xt0){if(qt(fe)===!1){const k=fe.textures,_e=fe.width,Be=fe.height;let Oe=i.COLOR_BUFFER_BIT;const je=fe.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Bt=n.get(fe),yt=k.length>1;if(yt)for(let Xt=0;Xt0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function Lt(fe){const k=a.render.frame;m.get(fe)!==k&&(m.set(fe,k),fe.update())}function hn(fe,k){const _e=fe.colorSpace,Be=fe.format,Oe=fe.type;return fe.isCompressedTexture===!0||fe.isVideoTexture===!0||_e!==Io&&_e!==Oo&&(hi.getTransfer(_e)===Hi?(Be!==Xs||Oe!==Aa)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",_e)),k}function ut(fe){return typeof HTMLImageElement<"u"&&fe instanceof HTMLImageElement?(h.width=fe.naturalWidth||fe.width,h.height=fe.naturalHeight||fe.height):typeof VideoFrame<"u"&&fe instanceof VideoFrame?(h.width=fe.displayWidth,h.height=fe.displayHeight):(h.width=fe.width,h.height=fe.height),h}this.allocateTextureUnit=ne,this.resetTextureUnits=te,this.setTexture2D=Q,this.setTexture2DArray=K,this.setTexture3D=ae,this.setTextureCube=Ae,this.rebindTextures=Gt,this.setupRenderTarget=Tt,this.updateRenderTargetMipmap=Ge,this.updateMultisampleRenderTarget=en,this.setupDepthRenderbuffer=Nt,this.setupFrameBufferTexture=Qe,this.useMultisampledRTT=qt}function NH(i,e){function t(n,r=Oo){let s;const a=hi.getTransfer(r);if(n===Aa)return i.UNSIGNED_BYTE;if(n===dy)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ay)return i.UNSIGNED_SHORT_5_5_5_1;if(n===py)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Jf)return i.BYTE;if(n===ed)return i.SHORT;if(n===Bl)return i.UNSIGNED_SHORT;if(n===ks)return i.INT;if(n===Ir)return i.UNSIGNED_INT;if(n===ss)return i.FLOAT;if(n===Qs)return i.HALF_FLOAT;if(n===Ow)return i.ALPHA;if(n===Og)return i.RGB;if(n===Xs)return i.RGBA;if(n===Iw)return i.LUMINANCE;if(n===Fw)return i.LUMINANCE_ALPHA;if(n===Au)return i.DEPTH_COMPONENT;if(n===bu)return i.DEPTH_STENCIL;if(n===Ig)return i.RED;if(n===$0)return i.RED_INTEGER;if(n===hd)return i.RG;if(n===X0)return i.RG_INTEGER;if(n===Y0)return i.RGBA_INTEGER;if(n===td||n===Gh||n===qh||n===Vh)if(a===Hi)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===td)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Gh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===qh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Vh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===td)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Gh)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===qh)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Vh)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Jm||n===eg||n===tg||n===ng)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Jm)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===eg)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===tg)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ng)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ig||n===f0||n===d0)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ig||n===f0)return a===Hi?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===d0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===A0||n===p0||n===m0||n===g0||n===v0||n===_0||n===y0||n===x0||n===b0||n===S0||n===T0||n===w0||n===M0||n===E0)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===A0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===p0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===m0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===g0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===v0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===_0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===y0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===x0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===b0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===S0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===T0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===w0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===M0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===E0)return a===Hi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===nd||n===WS||n===$S)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===nd)return a===Hi?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===WS)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===$S)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===kw||n===rg||n===sg||n===ag)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===nd)return s.COMPRESSED_RED_RGTC1_EXT;if(n===rg)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===sg)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ag)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===xu?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const RH={type:"move"};class D3{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ka,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ka,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new de,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new de),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ka,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new de,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new de),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const l=this._targetRay,u=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const N of e.hand.values()){const C=t.getJointPose(N,n),E=this._getHandJoint(h,N);C!==null&&(E.matrix.fromArray(C.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=C.radius),E.visible=C!==null}const m=h.joints["index-finger-tip"],v=h.joints["thumb-tip"],x=m.position.distanceTo(v.position),S=.02,w=.005;h.inputState.pinching&&x>S+w?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&x<=S-w&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(RH)))}return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=s!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Ka;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const DH=` -void main() { - - gl_Position = vec4( position, 1.0 ); - -}`,PH=` -uniform sampler2DArray depthColor; -uniform float depthWidth; -uniform float depthHeight; - -void main() { - - vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); - - if ( coord.x >= 1.0 ) { - - gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; - - } else { - - gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; - - } - -}`;class LH{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new Es,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new so({vertexShader:DH,fragmentShader:PH,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new qi(new Ty(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class UH extends Xc{constructor(e,t){super();const n=this;let r=null,s=1,a=null,l="local-floor",u=1,h=null,m=null,v=null,x=null,S=null,w=null;const N=new LH,C=t.getContextAttributes();let E=null,O=null;const U=[],I=[],j=new Et;let z=null;const G=new Ea;G.viewport=new qn;const W=new Ea;W.viewport=new qn;const q=[G,W],V=new Zz;let Y=null,te=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ce){let ke=U[Ce];return ke===void 0&&(ke=new D3,U[Ce]=ke),ke.getTargetRaySpace()},this.getControllerGrip=function(Ce){let ke=U[Ce];return ke===void 0&&(ke=new D3,U[Ce]=ke),ke.getGripSpace()},this.getHand=function(Ce){let ke=U[Ce];return ke===void 0&&(ke=new D3,U[Ce]=ke),ke.getHandSpace()};function ne(Ce){const ke=I.indexOf(Ce.inputSource);if(ke===-1)return;const Qe=U[ke];Qe!==void 0&&(Qe.update(Ce.inputSource,Ce.frame,h||a),Qe.dispatchEvent({type:Ce.type,data:Ce.inputSource}))}function le(){r.removeEventListener("select",ne),r.removeEventListener("selectstart",ne),r.removeEventListener("selectend",ne),r.removeEventListener("squeeze",ne),r.removeEventListener("squeezestart",ne),r.removeEventListener("squeezeend",ne),r.removeEventListener("end",le),r.removeEventListener("inputsourceschange",Q);for(let Ce=0;Ce=0&&(I[et]=null,U[et].disconnect(Qe))}for(let ke=0;ke=I.length){I.push(Qe),et=Nt;break}else if(I[Nt]===null){I[Nt]=Qe,et=Nt;break}if(et===-1)break}const Pt=U[et];Pt&&Pt.connect(Qe)}}const K=new de,ae=new de;function Ae(Ce,ke,Qe){K.setFromMatrixPosition(ke.matrixWorld),ae.setFromMatrixPosition(Qe.matrixWorld);const et=K.distanceTo(ae),Pt=ke.projectionMatrix.elements,Nt=Qe.projectionMatrix.elements,Gt=Pt[14]/(Pt[10]-1),Tt=Pt[14]/(Pt[10]+1),Ge=(Pt[9]+1)/Pt[5],dt=(Pt[9]-1)/Pt[5],he=(Pt[8]-1)/Pt[0],en=(Nt[8]+1)/Nt[0],wt=Gt*he,qt=Gt*en,Lt=et/(-he+en),hn=Lt*-he;if(ke.matrixWorld.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.translateX(hn),Ce.translateZ(Lt),Ce.matrixWorld.compose(Ce.position,Ce.quaternion,Ce.scale),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert(),Pt[10]===-1)Ce.projectionMatrix.copy(ke.projectionMatrix),Ce.projectionMatrixInverse.copy(ke.projectionMatrixInverse);else{const ut=Gt+Lt,fe=Tt+Lt,k=wt-hn,_e=qt+(et-hn),Be=Ge*Tt/fe*ut,Oe=dt*Tt/fe*ut;Ce.projectionMatrix.makePerspective(k,_e,Be,Oe,ut,fe),Ce.projectionMatrixInverse.copy(Ce.projectionMatrix).invert()}}function be(Ce,ke){ke===null?Ce.matrixWorld.copy(Ce.matrix):Ce.matrixWorld.multiplyMatrices(ke.matrixWorld,Ce.matrix),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert()}this.updateCamera=function(Ce){if(r===null)return;let ke=Ce.near,Qe=Ce.far;N.texture!==null&&(N.depthNear>0&&(ke=N.depthNear),N.depthFar>0&&(Qe=N.depthFar)),V.near=W.near=G.near=ke,V.far=W.far=G.far=Qe,(Y!==V.near||te!==V.far)&&(r.updateRenderState({depthNear:V.near,depthFar:V.far}),Y=V.near,te=V.far),G.layers.mask=Ce.layers.mask|2,W.layers.mask=Ce.layers.mask|4,V.layers.mask=G.layers.mask|W.layers.mask;const et=Ce.parent,Pt=V.cameras;be(V,et);for(let Nt=0;Nt0&&(C.alphaTest.value=E.alphaTest);const O=e.get(E),U=O.envMap,I=O.envMapRotation;U&&(C.envMap.value=U,Cf.copy(I),Cf.x*=-1,Cf.y*=-1,Cf.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(Cf.y*=-1,Cf.z*=-1),C.envMapRotation.value.setFromMatrix4(BH.makeRotationFromEuler(Cf)),C.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,C.reflectivity.value=E.reflectivity,C.ior.value=E.ior,C.refractionRatio.value=E.refractionRatio),E.lightMap&&(C.lightMap.value=E.lightMap,C.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,C.lightMapTransform)),E.aoMap&&(C.aoMap.value=E.aoMap,C.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,C.aoMapTransform))}function a(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform))}function l(C,E){C.dashSize.value=E.dashSize,C.totalSize.value=E.dashSize+E.gapSize,C.scale.value=E.scale}function u(C,E,O,U){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.size.value=E.size*O,C.scale.value=U*.5,E.map&&(C.map.value=E.map,t(E.map,C.uvTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function h(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.rotation.value=E.rotation,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function m(C,E){C.specular.value.copy(E.specular),C.shininess.value=Math.max(E.shininess,1e-4)}function v(C,E){E.gradientMap&&(C.gradientMap.value=E.gradientMap)}function x(C,E){C.metalness.value=E.metalness,E.metalnessMap&&(C.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,C.metalnessMapTransform)),C.roughness.value=E.roughness,E.roughnessMap&&(C.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,C.roughnessMapTransform)),E.envMap&&(C.envMapIntensity.value=E.envMapIntensity)}function S(C,E,O){C.ior.value=E.ior,E.sheen>0&&(C.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),C.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(C.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,C.sheenColorMapTransform)),E.sheenRoughnessMap&&(C.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,C.sheenRoughnessMapTransform))),E.clearcoat>0&&(C.clearcoat.value=E.clearcoat,C.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(C.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,C.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(C.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,C.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(C.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,C.clearcoatNormalMapTransform),C.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===gr&&C.clearcoatNormalScale.value.negate())),E.dispersion>0&&(C.dispersion.value=E.dispersion),E.iridescence>0&&(C.iridescence.value=E.iridescence,C.iridescenceIOR.value=E.iridescenceIOR,C.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],C.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(C.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,C.iridescenceMapTransform)),E.iridescenceThicknessMap&&(C.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,C.iridescenceThicknessMapTransform))),E.transmission>0&&(C.transmission.value=E.transmission,C.transmissionSamplerMap.value=O.texture,C.transmissionSamplerSize.value.set(O.width,O.height),E.transmissionMap&&(C.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,C.transmissionMapTransform)),C.thickness.value=E.thickness,E.thicknessMap&&(C.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,C.thicknessMapTransform)),C.attenuationDistance.value=E.attenuationDistance,C.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(C.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(C.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,C.anisotropyMapTransform))),C.specularIntensity.value=E.specularIntensity,C.specularColor.value.copy(E.specularColor),E.specularColorMap&&(C.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,C.specularColorMapTransform)),E.specularIntensityMap&&(C.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,C.specularIntensityMapTransform))}function w(C,E){E.matcap&&(C.matcap.value=E.matcap)}function N(C,E){const O=e.get(E).light;C.referencePosition.value.setFromMatrixPosition(O.matrixWorld),C.nearDistance.value=O.shadow.camera.near,C.farDistance.value=O.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function IH(i,e,t,n){let r={},s={},a=[];const l=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(O,U){const I=U.program;n.uniformBlockBinding(O,I)}function h(O,U){let I=r[O.id];I===void 0&&(w(O),I=m(O),r[O.id]=I,O.addEventListener("dispose",C));const j=U.program;n.updateUBOMapping(O,j);const z=e.render.frame;s[O.id]!==z&&(x(O),s[O.id]=z)}function m(O){const U=v();O.__bindingPointIndex=U;const I=i.createBuffer(),j=O.__size,z=O.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,j,z),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,U,I),I}function v(){for(let O=0;O0&&(I+=j-z),O.__size=I,O.__cache={},this}function N(O){const U={boundary:0,storage:0};return typeof O=="number"||typeof O=="boolean"?(U.boundary=4,U.storage=4):O.isVector2?(U.boundary=8,U.storage=8):O.isVector3||O.isColor?(U.boundary=16,U.storage=12):O.isVector4?(U.boundary=16,U.storage=16):O.isMatrix3?(U.boundary=48,U.storage=48):O.isMatrix4?(U.boundary=64,U.storage=64):O.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",O),U}function C(O){const U=O.target;U.removeEventListener("dispose",C);const I=a.indexOf(U.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[U.id]),delete r[U.id],delete s[U.id]}function E(){for(const O in r)i.deleteBuffer(r[O]);a=[],r={},s={}}return{bind:u,update:h,dispose:E}}class FH{constructor(e={}){const{canvas:t=q7(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:l=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:h=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:v=!1,reverseDepthBuffer:x=!1}=e;this.isWebGLRenderer=!0;let S;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");S=n.getContextAttributes().alpha}else S=a;const w=new Uint32Array(4),N=new Int32Array(4);let C=null,E=null;const O=[],U=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Nn,this.toneMapping=ro,this.toneMappingExposure=1;const I=this;let j=!1,z=0,G=0,W=null,q=-1,V=null;const Y=new qn,te=new qn;let ne=null;const le=new mn(0);let Q=0,K=t.width,ae=t.height,Ae=1,be=null,Se=null;const se=new qn(0,0,K,ae),Ee=new qn(0,0,K,ae);let qe=!1;const Ce=new zg;let ke=!1,Qe=!1;this.transmissionResolutionScale=1;const et=new Xn,Pt=new Xn,Nt=new de,Gt=new qn,Tt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ge=!1;function dt(){return W===null?Ae:1}let he=n;function en(ue,Fe){return t.getContext(ue,Fe)}try{const ue={alpha:!0,depth:r,stencil:s,antialias:l,premultipliedAlpha:u,preserveDrawingBuffer:h,powerPreference:m,failIfMajorPerformanceCaveat:v};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${W0}`),t.addEventListener("webglcontextlost",lt,!1),t.addEventListener("webglcontextrestored",bt,!1),t.addEventListener("webglcontextcreationerror",Kt,!1),he===null){const Fe="webgl2";if(he=en(Fe,ue),he===null)throw en(Fe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ue){throw console.error("THREE.WebGLRenderer: "+ue.message),ue}let wt,qt,Lt,hn,ut,fe,k,_e,Be,Oe,je,Bt,yt,Xt,ln,mt,Wt,Yt,$t,It,Te,nt,At,ce;function xt(){wt=new $V(he),wt.init(),nt=new NH(he,wt),qt=new GV(he,wt,e,nt),Lt=new EH(he,wt),qt.reverseDepthBuffer&&x&&Lt.buffers.depth.setReversed(!0),hn=new QV(he),ut=new AH,fe=new CH(he,wt,Lt,ut,qt,nt,hn),k=new VV(I),_e=new WV(I),Be=new iG(he),At=new kV(he,Be),Oe=new XV(he,Be,hn,At),je=new ZV(he,Oe,Be,hn),$t=new KV(he,qt,fe),mt=new qV(ut),Bt=new dH(I,k,_e,wt,qt,At,mt),yt=new OH(I,ut),Xt=new mH,ln=new bH(wt),Yt=new FV(I,k,_e,Lt,je,S,u),Wt=new wH(I,je,qt),ce=new IH(he,hn,qt,Lt),It=new zV(he,wt,hn),Te=new YV(he,wt,hn),hn.programs=Bt.programs,I.capabilities=qt,I.extensions=wt,I.properties=ut,I.renderLists=Xt,I.shadowMap=Wt,I.state=Lt,I.info=hn}xt();const Ze=new UH(I,he);this.xr=Ze,this.getContext=function(){return he},this.getContextAttributes=function(){return he.getContextAttributes()},this.forceContextLoss=function(){const ue=wt.get("WEBGL_lose_context");ue&&ue.loseContext()},this.forceContextRestore=function(){const ue=wt.get("WEBGL_lose_context");ue&&ue.restoreContext()},this.getPixelRatio=function(){return Ae},this.setPixelRatio=function(ue){ue!==void 0&&(Ae=ue,this.setSize(K,ae,!1))},this.getSize=function(ue){return ue.set(K,ae)},this.setSize=function(ue,Fe,tt=!0){if(Ze.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=ue,ae=Fe,t.width=Math.floor(ue*Ae),t.height=Math.floor(Fe*Ae),tt===!0&&(t.style.width=ue+"px",t.style.height=Fe+"px"),this.setViewport(0,0,ue,Fe)},this.getDrawingBufferSize=function(ue){return ue.set(K*Ae,ae*Ae).floor()},this.setDrawingBufferSize=function(ue,Fe,tt){K=ue,ae=Fe,Ae=tt,t.width=Math.floor(ue*tt),t.height=Math.floor(Fe*tt),this.setViewport(0,0,ue,Fe)},this.getCurrentViewport=function(ue){return ue.copy(Y)},this.getViewport=function(ue){return ue.copy(se)},this.setViewport=function(ue,Fe,tt,Ke){ue.isVector4?se.set(ue.x,ue.y,ue.z,ue.w):se.set(ue,Fe,tt,Ke),Lt.viewport(Y.copy(se).multiplyScalar(Ae).round())},this.getScissor=function(ue){return ue.copy(Ee)},this.setScissor=function(ue,Fe,tt,Ke){ue.isVector4?Ee.set(ue.x,ue.y,ue.z,ue.w):Ee.set(ue,Fe,tt,Ke),Lt.scissor(te.copy(Ee).multiplyScalar(Ae).round())},this.getScissorTest=function(){return qe},this.setScissorTest=function(ue){Lt.setScissorTest(qe=ue)},this.setOpaqueSort=function(ue){be=ue},this.setTransparentSort=function(ue){Se=ue},this.getClearColor=function(ue){return ue.copy(Yt.getClearColor())},this.setClearColor=function(){Yt.setClearColor.apply(Yt,arguments)},this.getClearAlpha=function(){return Yt.getClearAlpha()},this.setClearAlpha=function(){Yt.setClearAlpha.apply(Yt,arguments)},this.clear=function(ue=!0,Fe=!0,tt=!0){let Ke=0;if(ue){let ze=!1;if(W!==null){const Qt=W.texture.format;ze=Qt===Y0||Qt===X0||Qt===$0}if(ze){const Qt=W.texture.type,tn=Qt===Aa||Qt===Ir||Qt===Bl||Qt===xu||Qt===dy||Qt===Ay,Mt=Yt.getClearColor(),ee=Yt.getClearAlpha(),Vt=Mt.r,Fn=Mt.g,Tn=Mt.b;tn?(w[0]=Vt,w[1]=Fn,w[2]=Tn,w[3]=ee,he.clearBufferuiv(he.COLOR,0,w)):(N[0]=Vt,N[1]=Fn,N[2]=Tn,N[3]=ee,he.clearBufferiv(he.COLOR,0,N))}else Ke|=he.COLOR_BUFFER_BIT}Fe&&(Ke|=he.DEPTH_BUFFER_BIT),tt&&(Ke|=he.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),he.clear(Ke)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",lt,!1),t.removeEventListener("webglcontextrestored",bt,!1),t.removeEventListener("webglcontextcreationerror",Kt,!1),Yt.dispose(),Xt.dispose(),ln.dispose(),ut.dispose(),k.dispose(),_e.dispose(),je.dispose(),At.dispose(),ce.dispose(),Bt.dispose(),Ze.dispose(),Ze.removeEventListener("sessionstart",Pe),Ze.removeEventListener("sessionend",at),ht.stop()};function lt(ue){ue.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),j=!0}function bt(){console.log("THREE.WebGLRenderer: Context Restored."),j=!1;const ue=hn.autoReset,Fe=Wt.enabled,tt=Wt.autoUpdate,Ke=Wt.needsUpdate,ze=Wt.type;xt(),hn.autoReset=ue,Wt.enabled=Fe,Wt.autoUpdate=tt,Wt.needsUpdate=Ke,Wt.type=ze}function Kt(ue){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ue.statusMessage)}function un(ue){const Fe=ue.target;Fe.removeEventListener("dispose",un),Ye(Fe)}function Ye(ue){St(ue),ut.remove(ue)}function St(ue){const Fe=ut.get(ue).programs;Fe!==void 0&&(Fe.forEach(function(tt){Bt.releaseProgram(tt)}),ue.isShaderMaterial&&Bt.releaseShaderCache(ue))}this.renderBufferDirect=function(ue,Fe,tt,Ke,ze,Qt){Fe===null&&(Fe=Tt);const tn=ze.isMesh&&ze.matrixWorld.determinant()<0,Mt=zr(ue,Fe,tt,Ke,ze);Lt.setMaterial(Ke,tn);let ee=tt.index,Vt=1;if(Ke.wireframe===!0){if(ee=Oe.getWireframeAttribute(tt),ee===void 0)return;Vt=2}const Fn=tt.drawRange,Tn=tt.attributes.position;let oi=Fn.start*Vt,Ai=(Fn.start+Fn.count)*Vt;Qt!==null&&(oi=Math.max(oi,Qt.start*Vt),Ai=Math.min(Ai,(Qt.start+Qt.count)*Vt)),ee!==null?(oi=Math.max(oi,0),Ai=Math.min(Ai,ee.count)):Tn!=null&&(oi=Math.max(oi,0),Ai=Math.min(Ai,Tn.count));const Ii=Ai-oi;if(Ii<0||Ii===1/0)return;At.setup(ze,Ke,Mt,tt,ee);let Z,Vn=It;if(ee!==null&&(Z=Be.get(ee),Vn=Te,Vn.setIndex(Z)),ze.isMesh)Ke.wireframe===!0?(Lt.setLineWidth(Ke.wireframeLinewidth*dt()),Vn.setMode(he.LINES)):Vn.setMode(he.TRIANGLES);else if(ze.isLine){let bn=Ke.linewidth;bn===void 0&&(bn=1),Lt.setLineWidth(bn*dt()),ze.isLineSegments?Vn.setMode(he.LINES):ze.isLineLoop?Vn.setMode(he.LINE_LOOP):Vn.setMode(he.LINE_STRIP)}else ze.isPoints?Vn.setMode(he.POINTS):ze.isSprite&&Vn.setMode(he.TRIANGLES);if(ze.isBatchedMesh)if(ze._multiDrawInstances!==null)Vn.renderMultiDrawInstances(ze._multiDrawStarts,ze._multiDrawCounts,ze._multiDrawCount,ze._multiDrawInstances);else if(wt.get("WEBGL_multi_draw"))Vn.renderMultiDraw(ze._multiDrawStarts,ze._multiDrawCounts,ze._multiDrawCount);else{const bn=ze._multiDrawStarts,Mr=ze._multiDrawCounts,pi=ze._multiDrawCount,Ds=ee?Be.get(ee).bytesPerElement:1,Gr=ut.get(Ke).currentProgram.getUniforms();for(let qr=0;qr{function Qt(){if(Ke.forEach(function(tn){ut.get(tn).currentProgram.isReady()&&Ke.delete(tn)}),Ke.size===0){ze(ue);return}setTimeout(Qt,10)}wt.get("KHR_parallel_shader_compile")!==null?Qt():setTimeout(Qt,10)})};let pt=null;function Zt(ue){pt&&pt(ue)}function Pe(){ht.stop()}function at(){ht.start()}const ht=new fD;ht.setAnimationLoop(Zt),typeof self<"u"&&ht.setContext(self),this.setAnimationLoop=function(ue){pt=ue,Ze.setAnimationLoop(ue),ue===null?ht.stop():ht.start()},Ze.addEventListener("sessionstart",Pe),Ze.addEventListener("sessionend",at),this.render=function(ue,Fe){if(Fe!==void 0&&Fe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(j===!0)return;if(ue.matrixWorldAutoUpdate===!0&&ue.updateMatrixWorld(),Fe.parent===null&&Fe.matrixWorldAutoUpdate===!0&&Fe.updateMatrixWorld(),Ze.enabled===!0&&Ze.isPresenting===!0&&(Ze.cameraAutoUpdate===!0&&Ze.updateCamera(Fe),Fe=Ze.getCamera()),ue.isScene===!0&&ue.onBeforeRender(I,ue,Fe,W),E=ln.get(ue,U.length),E.init(Fe),U.push(E),Pt.multiplyMatrices(Fe.projectionMatrix,Fe.matrixWorldInverse),Ce.setFromProjectionMatrix(Pt),Qe=this.localClippingEnabled,ke=mt.init(this.clippingPlanes,Qe),C=Xt.get(ue,O.length),C.init(),O.push(C),Ze.enabled===!0&&Ze.isPresenting===!0){const Qt=I.xr.getDepthSensingMesh();Qt!==null&&ot(Qt,Fe,-1/0,I.sortObjects)}ot(ue,Fe,0,I.sortObjects),C.finish(),I.sortObjects===!0&&C.sort(be,Se),Ge=Ze.enabled===!1||Ze.isPresenting===!1||Ze.hasDepthSensing()===!1,Ge&&Yt.addToRenderList(C,ue),this.info.render.frame++,ke===!0&&mt.beginShadows();const tt=E.state.shadowsArray;Wt.render(tt,ue,Fe),ke===!0&&mt.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ke=C.opaque,ze=C.transmissive;if(E.setupLights(),Fe.isArrayCamera){const Qt=Fe.cameras;if(ze.length>0)for(let tn=0,Mt=Qt.length;tn0&&J(Ke,ze,ue,Fe),Ge&&Yt.render(ue),f(C,ue,Fe);W!==null&&G===0&&(fe.updateMultisampleRenderTarget(W),fe.updateRenderTargetMipmap(W)),ue.isScene===!0&&ue.onAfterRender(I,ue,Fe),At.resetDefaultState(),q=-1,V=null,U.pop(),U.length>0?(E=U[U.length-1],ke===!0&&mt.setGlobalState(I.clippingPlanes,E.state.camera)):E=null,O.pop(),O.length>0?C=O[O.length-1]:C=null};function ot(ue,Fe,tt,Ke){if(ue.visible===!1)return;if(ue.layers.test(Fe.layers)){if(ue.isGroup)tt=ue.renderOrder;else if(ue.isLOD)ue.autoUpdate===!0&&ue.update(Fe);else if(ue.isLight)E.pushLight(ue),ue.castShadow&&E.pushShadow(ue);else if(ue.isSprite){if(!ue.frustumCulled||Ce.intersectsSprite(ue)){Ke&&Gt.setFromMatrixPosition(ue.matrixWorld).applyMatrix4(Pt);const tn=je.update(ue),Mt=ue.material;Mt.visible&&C.push(ue,tn,Mt,tt,Gt.z,null)}}else if((ue.isMesh||ue.isLine||ue.isPoints)&&(!ue.frustumCulled||Ce.intersectsObject(ue))){const tn=je.update(ue),Mt=ue.material;if(Ke&&(ue.boundingSphere!==void 0?(ue.boundingSphere===null&&ue.computeBoundingSphere(),Gt.copy(ue.boundingSphere.center)):(tn.boundingSphere===null&&tn.computeBoundingSphere(),Gt.copy(tn.boundingSphere.center)),Gt.applyMatrix4(ue.matrixWorld).applyMatrix4(Pt)),Array.isArray(Mt)){const ee=tn.groups;for(let Vt=0,Fn=ee.length;Vt0&&_n(ze,Fe,tt),Qt.length>0&&_n(Qt,Fe,tt),tn.length>0&&_n(tn,Fe,tt),Lt.buffers.depth.setTest(!0),Lt.buffers.depth.setMask(!0),Lt.buffers.color.setMask(!0),Lt.setPolygonOffset(!1)}function J(ue,Fe,tt,Ke){if((tt.isScene===!0?tt.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[Ke.id]===void 0&&(E.state.transmissionRenderTarget[Ke.id]=new Xh(1,1,{generateMipmaps:!0,type:wt.has("EXT_color_buffer_half_float")||wt.has("EXT_color_buffer_float")?Qs:Aa,minFilter:Ya,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:hi.workingColorSpace}));const Qt=E.state.transmissionRenderTarget[Ke.id],tn=Ke.viewport||Y;Qt.setSize(tn.z*I.transmissionResolutionScale,tn.w*I.transmissionResolutionScale);const Mt=I.getRenderTarget();I.setRenderTarget(Qt),I.getClearColor(le),Q=I.getClearAlpha(),Q<1&&I.setClearColor(16777215,.5),I.clear(),Ge&&Yt.render(tt);const ee=I.toneMapping;I.toneMapping=ro;const Vt=Ke.viewport;if(Ke.viewport!==void 0&&(Ke.viewport=void 0),E.setupLightsView(Ke),ke===!0&&mt.setGlobalState(I.clippingPlanes,Ke),_n(ue,tt,Ke),fe.updateMultisampleRenderTarget(Qt),fe.updateRenderTargetMipmap(Qt),wt.has("WEBGL_multisampled_render_to_texture")===!1){let Fn=!1;for(let Tn=0,oi=Fe.length;Tn0),Tn=!!tt.morphAttributes.position,oi=!!tt.morphAttributes.normal,Ai=!!tt.morphAttributes.color;let Ii=ro;Ke.toneMapped&&(W===null||W.isXRRenderTarget===!0)&&(Ii=I.toneMapping);const Z=tt.morphAttributes.position||tt.morphAttributes.normal||tt.morphAttributes.color,Vn=Z!==void 0?Z.length:0,bn=ut.get(Ke),Mr=E.state.lights;if(ke===!0&&(Qe===!0||ue!==V)){const pr=ue===V&&Ke.id===q;mt.setState(Ke,ue,pr)}let pi=!1;Ke.version===bn.__version?(bn.needsLights&&bn.lightsStateVersion!==Mr.state.version||bn.outputColorSpace!==Mt||ze.isBatchedMesh&&bn.batching===!1||!ze.isBatchedMesh&&bn.batching===!0||ze.isBatchedMesh&&bn.batchingColor===!0&&ze.colorTexture===null||ze.isBatchedMesh&&bn.batchingColor===!1&&ze.colorTexture!==null||ze.isInstancedMesh&&bn.instancing===!1||!ze.isInstancedMesh&&bn.instancing===!0||ze.isSkinnedMesh&&bn.skinning===!1||!ze.isSkinnedMesh&&bn.skinning===!0||ze.isInstancedMesh&&bn.instancingColor===!0&&ze.instanceColor===null||ze.isInstancedMesh&&bn.instancingColor===!1&&ze.instanceColor!==null||ze.isInstancedMesh&&bn.instancingMorph===!0&&ze.morphTexture===null||ze.isInstancedMesh&&bn.instancingMorph===!1&&ze.morphTexture!==null||bn.envMap!==ee||Ke.fog===!0&&bn.fog!==Qt||bn.numClippingPlanes!==void 0&&(bn.numClippingPlanes!==mt.numPlanes||bn.numIntersection!==mt.numIntersection)||bn.vertexAlphas!==Vt||bn.vertexTangents!==Fn||bn.morphTargets!==Tn||bn.morphNormals!==oi||bn.morphColors!==Ai||bn.toneMapping!==Ii||bn.morphTargetsCount!==Vn)&&(pi=!0):(pi=!0,bn.__version=Ke.version);let Ds=bn.currentProgram;pi===!0&&(Ds=zn(Ke,Fe,ze));let Gr=!1,qr=!1,Er=!1;const Ni=Ds.getUniforms(),Yi=bn.uniforms;if(Lt.useProgram(Ds.program)&&(Gr=!0,qr=!0,Er=!0),Ke.id!==q&&(q=Ke.id,qr=!0),Gr||V!==ue){Lt.buffers.depth.getReversed()?(et.copy(ue.projectionMatrix),Nk(et),Rk(et),Ni.setValue(he,"projectionMatrix",et)):Ni.setValue(he,"projectionMatrix",ue.projectionMatrix),Ni.setValue(he,"viewMatrix",ue.matrixWorldInverse);const Vr=Ni.map.cameraPosition;Vr!==void 0&&Vr.setValue(he,Nt.setFromMatrixPosition(ue.matrixWorld)),qt.logarithmicDepthBuffer&&Ni.setValue(he,"logDepthBufFC",2/(Math.log(ue.far+1)/Math.LN2)),(Ke.isMeshPhongMaterial||Ke.isMeshToonMaterial||Ke.isMeshLambertMaterial||Ke.isMeshBasicMaterial||Ke.isMeshStandardMaterial||Ke.isShaderMaterial)&&Ni.setValue(he,"isOrthographic",ue.isOrthographicCamera===!0),V!==ue&&(V=ue,qr=!0,Er=!0)}if(ze.isSkinnedMesh){Ni.setOptional(he,ze,"bindMatrix"),Ni.setOptional(he,ze,"bindMatrixInverse");const pr=ze.skeleton;pr&&(pr.boneTexture===null&&pr.computeBoneTexture(),Ni.setValue(he,"boneTexture",pr.boneTexture,fe))}ze.isBatchedMesh&&(Ni.setOptional(he,ze,"batchingTexture"),Ni.setValue(he,"batchingTexture",ze._matricesTexture,fe),Ni.setOptional(he,ze,"batchingIdTexture"),Ni.setValue(he,"batchingIdTexture",ze._indirectTexture,fe),Ni.setOptional(he,ze,"batchingColorTexture"),ze._colorsTexture!==null&&Ni.setValue(he,"batchingColorTexture",ze._colorsTexture,fe));const _i=tt.morphAttributes;if((_i.position!==void 0||_i.normal!==void 0||_i.color!==void 0)&&$t.update(ze,tt,Ds),(qr||bn.receiveShadow!==ze.receiveShadow)&&(bn.receiveShadow=ze.receiveShadow,Ni.setValue(he,"receiveShadow",ze.receiveShadow)),Ke.isMeshGouraudMaterial&&Ke.envMap!==null&&(Yi.envMap.value=ee,Yi.flipEnvMap.value=ee.isCubeTexture&&ee.isRenderTargetTexture===!1?-1:1),Ke.isMeshStandardMaterial&&Ke.envMap===null&&Fe.environment!==null&&(Yi.envMapIntensity.value=Fe.environmentIntensity),qr&&(Ni.setValue(he,"toneMappingExposure",I.toneMappingExposure),bn.needsLights&&on(Yi,Er),Qt&&Ke.fog===!0&&yt.refreshFogUniforms(Yi,Qt),yt.refreshMaterialUniforms(Yi,Ke,Ae,ae,E.state.transmissionRenderTarget[ue.id]),qv.upload(he,An(bn),Yi,fe)),Ke.isShaderMaterial&&Ke.uniformsNeedUpdate===!0&&(qv.upload(he,An(bn),Yi,fe),Ke.uniformsNeedUpdate=!1),Ke.isSpriteMaterial&&Ni.setValue(he,"center",ze.center),Ni.setValue(he,"modelViewMatrix",ze.modelViewMatrix),Ni.setValue(he,"normalMatrix",ze.normalMatrix),Ni.setValue(he,"modelMatrix",ze.matrixWorld),Ke.isShaderMaterial||Ke.isRawShaderMaterial){const pr=Ke.uniformsGroups;for(let Vr=0,hl=pr.length;Vr0&&fe.useMultisampledRTT(ue)===!1?ze=ut.get(ue).__webglMultisampledFramebuffer:Array.isArray(Fn)?ze=Fn[tt]:ze=Fn,Y.copy(ue.viewport),te.copy(ue.scissor),ne=ue.scissorTest}else Y.copy(se).multiplyScalar(Ae).floor(),te.copy(Ee).multiplyScalar(Ae).floor(),ne=qe;if(tt!==0&&(ze=Ar),Lt.bindFramebuffer(he.FRAMEBUFFER,ze)&&Ke&&Lt.drawBuffers(ue,ze),Lt.viewport(Y),Lt.scissor(te),Lt.setScissorTest(ne),Qt){const ee=ut.get(ue.texture);he.framebufferTexture2D(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,he.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,ee.__webglTexture,tt)}else if(tn){const ee=ut.get(ue.texture),Vt=Fe;he.framebufferTextureLayer(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,ee.__webglTexture,tt,Vt)}else if(ue!==null&&tt!==0){const ee=ut.get(ue.texture);he.framebufferTexture2D(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,he.TEXTURE_2D,ee.__webglTexture,tt)}q=-1},this.readRenderTargetPixels=function(ue,Fe,tt,Ke,ze,Qt,tn){if(!(ue&&ue.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Mt=ut.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&tn!==void 0&&(Mt=Mt[tn]),Mt){Lt.bindFramebuffer(he.FRAMEBUFFER,Mt);try{const ee=ue.texture,Vt=ee.format,Fn=ee.type;if(!qt.textureFormatReadable(Vt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!qt.textureTypeReadable(Fn)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Fe>=0&&Fe<=ue.width-Ke&&tt>=0&&tt<=ue.height-ze&&he.readPixels(Fe,tt,Ke,ze,nt.convert(Vt),nt.convert(Fn),Qt)}finally{const ee=W!==null?ut.get(W).__webglFramebuffer:null;Lt.bindFramebuffer(he.FRAMEBUFFER,ee)}}},this.readRenderTargetPixelsAsync=async function(ue,Fe,tt,Ke,ze,Qt,tn){if(!(ue&&ue.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Mt=ut.get(ue).__webglFramebuffer;if(ue.isWebGLCubeRenderTarget&&tn!==void 0&&(Mt=Mt[tn]),Mt){const ee=ue.texture,Vt=ee.format,Fn=ee.type;if(!qt.textureFormatReadable(Vt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!qt.textureTypeReadable(Fn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(Fe>=0&&Fe<=ue.width-Ke&&tt>=0&&tt<=ue.height-ze){Lt.bindFramebuffer(he.FRAMEBUFFER,Mt);const Tn=he.createBuffer();he.bindBuffer(he.PIXEL_PACK_BUFFER,Tn),he.bufferData(he.PIXEL_PACK_BUFFER,Qt.byteLength,he.STREAM_READ),he.readPixels(Fe,tt,Ke,ze,nt.convert(Vt),nt.convert(Fn),0);const oi=W!==null?ut.get(W).__webglFramebuffer:null;Lt.bindFramebuffer(he.FRAMEBUFFER,oi);const Ai=he.fenceSync(he.SYNC_GPU_COMMANDS_COMPLETE,0);return he.flush(),await Ck(he,Ai,4),he.bindBuffer(he.PIXEL_PACK_BUFFER,Tn),he.getBufferSubData(he.PIXEL_PACK_BUFFER,0,Qt),he.deleteBuffer(Tn),he.deleteSync(Ai),Qt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(ue,Fe=null,tt=0){ue.isTexture!==!0&&(qf("WebGLRenderer: copyFramebufferToTexture function signature has changed."),Fe=arguments[0]||null,ue=arguments[1]);const Ke=Math.pow(2,-tt),ze=Math.floor(ue.image.width*Ke),Qt=Math.floor(ue.image.height*Ke),tn=Fe!==null?Fe.x:0,Mt=Fe!==null?Fe.y:0;fe.setTexture2D(ue,0),he.copyTexSubImage2D(he.TEXTURE_2D,tt,0,0,tn,Mt,ze,Qt),Lt.unbindTexture()};const ji=he.createFramebuffer(),Ao=he.createFramebuffer();this.copyTextureToTexture=function(ue,Fe,tt=null,Ke=null,ze=0,Qt=null){ue.isTexture!==!0&&(qf("WebGLRenderer: copyTextureToTexture function signature has changed."),Ke=arguments[0]||null,ue=arguments[1],Fe=arguments[2],Qt=arguments[3]||0,tt=null),Qt===null&&(ze!==0?(qf("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Qt=ze,ze=0):Qt=0);let tn,Mt,ee,Vt,Fn,Tn,oi,Ai,Ii;const Z=ue.isCompressedTexture?ue.mipmaps[Qt]:ue.image;if(tt!==null)tn=tt.max.x-tt.min.x,Mt=tt.max.y-tt.min.y,ee=tt.isBox3?tt.max.z-tt.min.z:1,Vt=tt.min.x,Fn=tt.min.y,Tn=tt.isBox3?tt.min.z:0;else{const _i=Math.pow(2,-ze);tn=Math.floor(Z.width*_i),Mt=Math.floor(Z.height*_i),ue.isDataArrayTexture?ee=Z.depth:ue.isData3DTexture?ee=Math.floor(Z.depth*_i):ee=1,Vt=0,Fn=0,Tn=0}Ke!==null?(oi=Ke.x,Ai=Ke.y,Ii=Ke.z):(oi=0,Ai=0,Ii=0);const Vn=nt.convert(Fe.format),bn=nt.convert(Fe.type);let Mr;Fe.isData3DTexture?(fe.setTexture3D(Fe,0),Mr=he.TEXTURE_3D):Fe.isDataArrayTexture||Fe.isCompressedArrayTexture?(fe.setTexture2DArray(Fe,0),Mr=he.TEXTURE_2D_ARRAY):(fe.setTexture2D(Fe,0),Mr=he.TEXTURE_2D),he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,Fe.flipY),he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Fe.premultiplyAlpha),he.pixelStorei(he.UNPACK_ALIGNMENT,Fe.unpackAlignment);const pi=he.getParameter(he.UNPACK_ROW_LENGTH),Ds=he.getParameter(he.UNPACK_IMAGE_HEIGHT),Gr=he.getParameter(he.UNPACK_SKIP_PIXELS),qr=he.getParameter(he.UNPACK_SKIP_ROWS),Er=he.getParameter(he.UNPACK_SKIP_IMAGES);he.pixelStorei(he.UNPACK_ROW_LENGTH,Z.width),he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,Z.height),he.pixelStorei(he.UNPACK_SKIP_PIXELS,Vt),he.pixelStorei(he.UNPACK_SKIP_ROWS,Fn),he.pixelStorei(he.UNPACK_SKIP_IMAGES,Tn);const Ni=ue.isDataArrayTexture||ue.isData3DTexture,Yi=Fe.isDataArrayTexture||Fe.isData3DTexture;if(ue.isDepthTexture){const _i=ut.get(ue),pr=ut.get(Fe),Vr=ut.get(_i.__renderTarget),hl=ut.get(pr.__renderTarget);Lt.bindFramebuffer(he.READ_FRAMEBUFFER,Vr.__webglFramebuffer),Lt.bindFramebuffer(he.DRAW_FRAMEBUFFER,hl.__webglFramebuffer);for(let ts=0;ts=-1&&bA.z<=1&&w.layers.test(C.layers)===!0,O=w.element;O.style.display=E===!0?"":"none",E===!0&&(w.onBeforeRender(t,N,C),O.style.transform="translate("+-100*w.center.x+"%,"+-100*w.center.y+"%)translate("+(bA.x*s+s)+"px,"+(-bA.y*a+a)+"px)",O.parentNode!==u&&u.appendChild(O),w.onAfterRender(t,N,C));const U={distanceToCameraSquared:v(C,w)};l.objects.set(w,U)}for(let E=0,O=w.children.length;E=e||G<0||v&&W>=s}function E(){var z=P3();if(C(z))return O(z);l=setTimeout(E,N(z))}function O(z){return l=void 0,x&&n?S(z):(n=r=void 0,a)}function U(){l!==void 0&&clearTimeout(l),h=0,n=u=r=l=void 0}function I(){return l===void 0?a:O(P3())}function j(){var z=P3(),G=C(z);if(n=arguments,r=this,u=z,G){if(l===void 0)return w(u);if(v)return clearTimeout(l),l=setTimeout(E,e),S(u)}return l===void 0&&(l=setTimeout(E,e)),a}return j.cancel=U,j.flush=I,j}function h5(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),bm=function(){return performance.now()},My=(function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=bm()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(i[t],i[t-1],t-n):s(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},_D=(function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i})(),iT=new My,va=(function(){function i(e,t){t===void 0&&(t=iT),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=vs.Linear.None,this._interpolationFunction=nT.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=_D.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=bm()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,s){for(var a in n){var l=e[a],u=Array.isArray(l),h=u?"array":typeof l,m=!u&&Array.isArray(n[a]);if(!(h==="undefined"||h==="function")){if(m){var v=n[a];if(v.length===0)continue;for(var x=[l],S=0,w=v.length;S"u"||s)&&(t[a]=l),u||(t[a]*=1),m?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=bm()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=bm()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;ea)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,eh)return 1;var C=Math.trunc(l/u),E=l-C*u,O=Math.min(E/n._duration,1);return O===0&&l===n._duration?1:O},v=m(),x=this._easingFunction(v);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,x),this._onUpdateCallback&&this._onUpdateCallback(this._object,v),this._duration===0||l>=this._duration)if(this._repeat>0){var S=Math.min(Math.trunc((l-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=S);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*S,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var w=0,N=this._chainedTweens.length;w=(w=(u+v)/2))?u=w:v=w,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C,s=a,!(a=a[G=z<<2|j<<1|I]))return s[G]=l,i;if(E=+i._x.call(null,a.data),O=+i._y.call(null,a.data),U=+i._z.call(null,a.data),e===E&&t===O&&n===U)return l.next=a,s?s[G]=l:i._root=l,i;do s=s?s[G]=new Array(8):i._root=new Array(8),(I=e>=(w=(u+v)/2))?u=w:v=w,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C;while((G=z<<2|j<<1|I)===(W=(U>=C)<<2|(O>=N)<<1|E>=w));return s[W]=a,s[G]=l,i}function bW(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),n=new Float64Array(e),r=new Float64Array(e);let s=1/0,a=1/0,l=1/0,u=-1/0,h=-1/0,m=-1/0;for(let v=0,x,S,w,N;vu&&(u=S),wh&&(h=w),Nm&&(m=N));if(s>u||a>h||l>m)return this;this.cover(s,a,l).cover(u,h,m);for(let v=0;vi||i>=a||r>e||e>=l||s>t||t>=u;)switch(x=(tw||(h=U.y0)>N||(m=U.z0)>C||(v=U.x1)=G)<<2|(e>=z)<<1|i>=j)&&(U=E[E.length-1],E[E.length-1]=E[E.length-1-I],E[E.length-1-I]=U)}else{var W=i-+this._x.call(null,O.data),q=e-+this._y.call(null,O.data),V=t-+this._z.call(null,O.data),Y=W*W+q*q+V*V;if(YMath.sqrt((i-n)**2+(e-r)**2+(t-s)**2);function CW(i,e,t,n){const r=[],s=i-n,a=e-n,l=t-n,u=i+n,h=e+n,m=t+n;return this.visit((v,x,S,w,N,C,E)=>{if(!v.length)do{const O=v.data;EW(i,e,t,this._x(O),this._y(O),this._z(O))<=n&&r.push(O)}while(v=v.next);return x>u||S>h||w>m||N=(N=(a+h)/2))?a=N:h=N,(U=S>=(C=(l+m)/2))?l=C:m=C,(I=w>=(E=(u+v)/2))?u=E:v=E,e=t,!(t=t[j=I<<2|U<<1|O]))return this;if(!t.length)break;(e[j+1&7]||e[j+2&7]||e[j+3&7]||e[j+4&7]||e[j+5&7]||e[j+6&7]||e[j+7&7])&&(n=e,z=j)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[j]=s:delete e[j],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[z]=t:this._root=t),this):(this._root=s,this)}function RW(i){for(var e=0,t=i.length;ee?1:i>=e?0:NaN}function GW(i,e){return i==null||e==null?NaN:ei?1:e>=i?0:NaN}function bD(i){let e,t,n;i.length!==2?(e=Vv,t=(l,u)=>Vv(i(l),u),n=(l,u)=>i(l)-u):(e=i===Vv||i===GW?i:qW,t=i,n=i);function r(l,u,h=0,m=l.length){if(h>>1;t(l[v],u)<0?h=v+1:m=v}while(h>>1;t(l[v],u)<=0?h=v+1:m=v}while(hh&&n(l[v-1],u)>-n(l[v],u)?v-1:v}return{left:r,center:a,right:s}}function qW(){return 0}function VW(i){return i===null?NaN:+i}const jW=bD(Vv),SD=jW.right;bD(VW).center;function d_(i,e){let t,n;if(e===void 0)for(const r of i)r!=null&&(t===void 0?r>=r&&(t=n=r):(t>r&&(t=r),n=s&&(t=n=s):(t>s&&(t=s),n0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,s=r-(a-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(r=s*2,n=a+r,r==n-a&&(a=n))}return a}}const HW=Math.sqrt(50),WW=Math.sqrt(10),$W=Math.sqrt(2);function A_(i,e,t){const n=(e-i)/Math.max(0,t),r=Math.floor(Math.log10(n)),s=n/Math.pow(10,r),a=s>=HW?10:s>=WW?5:s>=$W?2:1;let l,u,h;return r<0?(h=Math.pow(10,-r)/a,l=Math.round(i*h),u=Math.round(e*h),l/he&&--u,h=-h):(h=Math.pow(10,r)*a,l=Math.round(i/h),u=Math.round(e/h),l*he&&--u),u0))return[];if(i===e)return[i];const n=e=r))return[];const l=s-r+1,u=new Array(l);if(n)if(a<0)for(let h=0;h=n)&&(t=n);return t}function KW(i,e){let t=0,n=0;if(e===void 0)for(let r of i)r!=null&&(r=+r)>=r&&(++t,n+=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*ZW(i){for(const e of i)yield*e}function hg(i){return Array.from(ZW(i))}function XA(i,e,t){i=+i,e=+e,t=(r=arguments.length)<2?(e=i,i=0,1):r<3?1:+t;for(var n=-1,r=Math.max(0,Math.ceil((e-i)/t))|0,s=new Array(r);++n>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?Y2(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?Y2(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=t$.exec(i))?new Za(e[1],e[2],e[3],1):(e=n$.exec(i))?new Za(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=i$.exec(i))?Y2(e[1],e[2],e[3],e[4]):(e=r$.exec(i))?Y2(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=s$.exec(i))?_5(e[1],e[2]/100,e[3]/100,1):(e=a$.exec(i))?_5(e[1],e[2]/100,e[3]/100,e[4]):d5.hasOwnProperty(i)?m5(d5[i]):i==="transparent"?new Za(NaN,NaN,NaN,0):null}function m5(i){return new Za(i>>16&255,i>>8&255,i&255,1)}function Y2(i,e,t,n){return n<=0&&(i=e=t=NaN),new Za(i,e,t,n)}function u$(i){return i instanceof qg||(i=dd(i)),i?(i=i.rgb(),new Za(i.r,i.g,i.b,i.opacity)):new Za}function sT(i,e,t,n){return arguments.length===1?u$(i):new Za(i,e,t,n??1)}function Za(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}hM(Za,sT,wD(qg,{brighter(i){return i=i==null?p_:Math.pow(p_,i),new Za(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?fg:Math.pow(fg,i),new Za(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new Za(id(this.r),id(this.g),id(this.b),m_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:g5,formatHex:g5,formatHex8:c$,formatRgb:v5,toString:v5}));function g5(){return`#${Yf(this.r)}${Yf(this.g)}${Yf(this.b)}`}function c$(){return`#${Yf(this.r)}${Yf(this.g)}${Yf(this.b)}${Yf((isNaN(this.opacity)?1:this.opacity)*255)}`}function v5(){const i=m_(this.opacity);return`${i===1?"rgb(":"rgba("}${id(this.r)}, ${id(this.g)}, ${id(this.b)}${i===1?")":`, ${i})`}`}function m_(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function id(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function Yf(i){return i=id(i),(i<16?"0":"")+i.toString(16)}function _5(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new Ul(i,e,t,n)}function MD(i){if(i instanceof Ul)return new Ul(i.h,i.s,i.l,i.opacity);if(i instanceof qg||(i=dd(i)),!i)return new Ul;if(i instanceof Ul)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,r=Math.min(e,t,n),s=Math.max(e,t,n),a=NaN,l=s-r,u=(s+r)/2;return l?(e===s?a=(t-n)/l+(t0&&u<1?0:a,new Ul(a,l,u,i.opacity)}function h$(i,e,t,n){return arguments.length===1?MD(i):new Ul(i,e,t,n??1)}function Ul(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}hM(Ul,h$,wD(qg,{brighter(i){return i=i==null?p_:Math.pow(p_,i),new Ul(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?fg:Math.pow(fg,i),new Ul(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,r=2*t-n;return new Za(L3(i>=240?i-240:i+120,r,n),L3(i,r,n),L3(i<120?i+240:i-120,r,n),this.opacity)},clamp(){return new Ul(y5(this.h),Q2(this.s),Q2(this.l),m_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=m_(this.opacity);return`${i===1?"hsl(":"hsla("}${y5(this.h)}, ${Q2(this.s)*100}%, ${Q2(this.l)*100}%${i===1?")":`, ${i})`}`}}));function y5(i){return i=(i||0)%360,i<0?i+360:i}function Q2(i){return Math.max(0,Math.min(1,i||0))}function L3(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const fM=i=>()=>i;function f$(i,e){return function(t){return i+t*e}}function d$(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function A$(i){return(i=+i)==1?ED:function(e,t){return t-e?d$(e,t,i):fM(isNaN(e)?t:e)}}function ED(i,e){var t=e-i;return t?f$(i,t):fM(isNaN(i)?e:i)}const x5=(function i(e){var t=A$(e);function n(r,s){var a=t((r=sT(r)).r,(s=sT(s)).r),l=t(r.g,s.g),u=t(r.b,s.b),h=ED(r.opacity,s.opacity);return function(m){return r.r=a(m),r.g=l(m),r.b=u(m),r.opacity=h(m),r+""}}return n.gamma=i,n})(1);function CD(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),r;return function(s){for(r=0;rt&&(s=e.slice(t,s),l[a]?l[a]+=s:l[++a]=s),(n=n[0])===(r=r[0])?l[a]?l[a]+=r:l[++a]=r:(l[++a]=null,u.push({i:a,x:Ag(n,r)})),t=U3.lastIndex;return te&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function w$(i,e,t){var n=i[0],r=i[1],s=e[0],a=e[1];return r2?M$:w$,u=h=null,v}function v(x){return x==null||isNaN(x=+x)?s:(u||(u=l(i.map(n),e,t)))(n(a(x)))}return v.invert=function(x){return a(r((h||(h=l(e,i.map(n),Ag)))(x)))},v.domain=function(x){return arguments.length?(i=Array.from(x,S$),m()):i.slice()},v.range=function(x){return arguments.length?(e=Array.from(x),m()):e.slice()},v.rangeRound=function(x){return e=Array.from(x),t=x$,m()},v.clamp=function(x){return arguments.length?(a=x?!0:YA,m()):a!==YA},v.interpolate=function(x){return arguments.length?(t=x,m()):t},v.unknown=function(x){return arguments.length?(s=x,v):s},function(x,S){return n=x,r=S,m()}}function N$(){return C$()(YA,YA)}function R$(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function g_(i,e){if(!isFinite(i)||i===0)return null;var t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"),n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function D0(i){return i=g_(Math.abs(i)),i?i[1]:NaN}function D$(i,e){return function(t,n){for(var r=t.length,s=[],a=0,l=i[0],u=0;r>0&&l>0&&(u+l+1>n&&(l=Math.max(1,n-u)),s.push(t.substring(r-=l,r+l)),!((u+=l+1)>n));)l=i[a=(a+1)%i.length];return s.reverse().join(e)}}function P$(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var L$=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function v_(i){if(!(e=L$.exec(i)))throw new Error("invalid format: "+i);var e;return new AM({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}v_.prototype=AM.prototype;function AM(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}AM.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function U$(i){e:for(var e=i.length,t=1,n=-1,r;t0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(r+1):i}var __;function B$(i,e){var t=g_(i,e);if(!t)return __=void 0,i.toPrecision(e);var n=t[0],r=t[1],s=r-(__=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+g_(i,Math.max(0,e+s-1))[0]}function S5(i,e){var t=g_(i,e);if(!t)return i+"";var n=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}const T5={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:R$,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>S5(i*100,e),r:S5,s:B$,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function w5(i){return i}var M5=Array.prototype.map,E5=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function O$(i){var e=i.grouping===void 0||i.thousands===void 0?w5:D$(M5.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",r=i.decimal===void 0?".":i.decimal+"",s=i.numerals===void 0?w5:P$(M5.call(i.numerals,String)),a=i.percent===void 0?"%":i.percent+"",l=i.minus===void 0?"−":i.minus+"",u=i.nan===void 0?"NaN":i.nan+"";function h(v,x){v=v_(v);var S=v.fill,w=v.align,N=v.sign,C=v.symbol,E=v.zero,O=v.width,U=v.comma,I=v.precision,j=v.trim,z=v.type;z==="n"?(U=!0,z="g"):T5[z]||(I===void 0&&(I=12),j=!0,z="g"),(E||S==="0"&&w==="=")&&(E=!0,S="0",w="=");var G=(x&&x.prefix!==void 0?x.prefix:"")+(C==="$"?t:C==="#"&&/[boxX]/.test(z)?"0"+z.toLowerCase():""),W=(C==="$"?n:/[%p]/.test(z)?a:"")+(x&&x.suffix!==void 0?x.suffix:""),q=T5[z],V=/[defgprs%]/.test(z);I=I===void 0?6:/[gprs]/.test(z)?Math.max(1,Math.min(21,I)):Math.max(0,Math.min(20,I));function Y(te){var ne=G,le=W,Q,K,ae;if(z==="c")le=q(te)+le,te="";else{te=+te;var Ae=te<0||1/te<0;if(te=isNaN(te)?u:q(Math.abs(te),I),j&&(te=U$(te)),Ae&&+te==0&&N!=="+"&&(Ae=!1),ne=(Ae?N==="("?N:l:N==="-"||N==="("?"":N)+ne,le=(z==="s"&&!isNaN(te)&&__!==void 0?E5[8+__/3]:"")+le+(Ae&&N==="("?")":""),V){for(Q=-1,K=te.length;++Qae||ae>57){le=(ae===46?r+te.slice(Q+1):te.slice(Q))+le,te=te.slice(0,Q);break}}}U&&!E&&(te=e(te,1/0));var be=ne.length+te.length+le.length,Se=be>1)+ne+te+le+Se.slice(be);break;default:te=Se+ne+te+le;break}return s(te)}return Y.toString=function(){return v+""},Y}function m(v,x){var S=Math.max(-8,Math.min(8,Math.floor(D0(x)/3)))*3,w=Math.pow(10,-S),N=h((v=v_(v),v.type="f",v),{suffix:E5[8+S/3]});return function(C){return N(w*C)}}return{format:h,formatPrefix:m}}var K2,DD,PD;I$({thousands:",",grouping:[3],currency:["$",""]});function I$(i){return K2=O$(i),DD=K2.format,PD=K2.formatPrefix,K2}function F$(i){return Math.max(0,-D0(Math.abs(i)))}function k$(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(D0(e)/3)))*3-D0(Math.abs(i)))}function z$(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,D0(e)-D0(i))+1}function G$(i,e,t,n){var r=YW(i,e,t),s;switch(n=v_(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(s=k$(r,a))&&(n.precision=s),PD(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=z$(r,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=F$(r))&&(n.precision=s-(n.type==="%")*2);break}}return DD(n)}function LD(i){var e=i.domain;return i.ticks=function(t){var n=e();return XW(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var r=e();return G$(r[0],r[r.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),r=0,s=n.length-1,a=n[r],l=n[s],u,h,m=10;for(l0;){if(h=rT(a,l,t),h===u)return n[r]=a,n[s]=l,e(n);if(h>0)a=Math.floor(a/h)*h,l=Math.ceil(l/h)*h;else if(h<0)a=Math.ceil(a*h)/h,l=Math.floor(l*h)/h;else break;u=h}return i},i}function zc(){var i=N$();return i.copy=function(){return E$(i,zc())},TD.apply(i,arguments),LD(i)}function UD(){var i=0,e=1,t=1,n=[.5],r=[0,1],s;function a(u){return u!=null&&u<=u?r[SD(n,u,0,t)]:s}function l(){var u=-1;for(n=new Array(t);++u=t?[n[t-1],e]:[n[h-1],n[h]]},a.unknown=function(u){return arguments.length&&(s=u),a},a.thresholds=function(){return n.slice()},a.copy=function(){return UD().domain([i,e]).range(r).unknown(s)},TD.apply(LD(a),arguments)}var vi=1e-6,y_=1e-12,Pi=Math.PI,Ja=Pi/2,x_=Pi/4,Fo=Pi*2,Qr=180/Pi,Kn=Pi/180,ar=Math.abs,pM=Math.atan,ol=Math.atan2,ri=Math.cos,Z2=Math.ceil,q$=Math.exp,lT=Math.hypot,V$=Math.log,Yn=Math.sin,j$=Math.sign||function(i){return i>0?1:i<0?-1:0},Gc=Math.sqrt,H$=Math.tan;function W$(i){return i>1?0:i<-1?Pi:Math.acos(i)}function qc(i){return i>1?Ja:i<-1?-Ja:Math.asin(i)}function C5(i){return(i=Yn(i/2))*i}function fa(){}function b_(i,e){i&&R5.hasOwnProperty(i.type)&&R5[i.type](i,e)}var N5={Feature:function(i,e){b_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n=0?1:-1,r=n*t,s=ri(e),a=Yn(e),l=fT*a,u=hT*s+l*ri(r),h=l*n*Yn(r);S_.add(ol(h,u)),cT=i,hT=s,fT=a}function T_(i){return[ol(i[1],i[0]),qc(i[2])]}function Ad(i){var e=i[0],t=i[1],n=ri(t);return[n*ri(e),n*Yn(e),Yn(t)]}function J2(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function P0(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function B3(i,e){i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}function ev(i,e){return[i[0]*e,i[1]*e,i[2]*e]}function w_(i){var e=Gc(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);i[0]/=e,i[1]/=e,i[2]/=e}var Or,Xa,Xr,Lo,kf,FD,kD,a0,Lm,Uh,jc,Ec={point:dT,lineStart:L5,lineEnd:U5,polygonStart:function(){Ec.point=GD,Ec.lineStart=Q$,Ec.lineEnd=K$,Lm=new Bc,Vc.polygonStart()},polygonEnd:function(){Vc.polygonEnd(),Ec.point=dT,Ec.lineStart=L5,Ec.lineEnd=U5,S_<0?(Or=-(Xr=180),Xa=-(Lo=90)):Lm>vi?Lo=90:Lm<-vi&&(Xa=-90),jc[0]=Or,jc[1]=Xr},sphere:function(){Or=-(Xr=180),Xa=-(Lo=90)}};function dT(i,e){Uh.push(jc=[Or=i,Xr=i]),eLo&&(Lo=e)}function zD(i,e){var t=Ad([i*Kn,e*Kn]);if(a0){var n=P0(a0,t),r=[n[1],-n[0],0],s=P0(r,n);w_(s),s=T_(s);var a=i-kf,l=a>0?1:-1,u=s[0]*Qr*l,h,m=ar(a)>180;m^(l*kfLo&&(Lo=h)):(u=(u+360)%360-180,m^(l*kfLo&&(Lo=e))),m?iRo(Or,Xr)&&(Xr=i):Ro(i,Xr)>Ro(Or,Xr)&&(Or=i):Xr>=Or?(iXr&&(Xr=i)):i>kf?Ro(Or,i)>Ro(Or,Xr)&&(Xr=i):Ro(i,Xr)>Ro(Or,Xr)&&(Or=i)}else Uh.push(jc=[Or=i,Xr=i]);eLo&&(Lo=e),a0=t,kf=i}function L5(){Ec.point=zD}function U5(){jc[0]=Or,jc[1]=Xr,Ec.point=dT,a0=null}function GD(i,e){if(a0){var t=i-kf;Lm.add(ar(t)>180?t+(t>0?360:-360):t)}else FD=i,kD=e;Vc.point(i,e),zD(i,e)}function Q$(){Vc.lineStart()}function K$(){GD(FD,kD),Vc.lineEnd(),ar(Lm)>vi&&(Or=-(Xr=180)),jc[0]=Or,jc[1]=Xr,a0=null}function Ro(i,e){return(e-=i)<0?e+360:e}function Z$(i,e){return i[0]-e[0]}function B5(i,e){return i[0]<=i[1]?i[0]<=e&&e<=i[1]:eRo(n[0],n[1])&&(n[1]=r[1]),Ro(r[0],n[1])>Ro(n[0],n[1])&&(n[0]=r[0])):s.push(n=r);for(a=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=r,++e)r=s[e],(l=Ro(n[1],r[0]))>a&&(a=l,Or=r[0],Xr=n[1])}return Uh=jc=null,Or===1/0||Xa===1/0?[[NaN,NaN],[NaN,NaN]]:[[Or,Xa],[Xr,Lo]]}var Sm,M_,E_,C_,N_,R_,D_,P_,AT,pT,mT,VD,jD,Ca,Na,Ra,Ol={sphere:fa,point:mM,lineStart:O5,lineEnd:I5,polygonStart:function(){Ol.lineStart=tX,Ol.lineEnd=nX},polygonEnd:function(){Ol.lineStart=O5,Ol.lineEnd=I5}};function mM(i,e){i*=Kn,e*=Kn;var t=ri(e);Vg(t*ri(i),t*Yn(i),Yn(e))}function Vg(i,e,t){++Sm,E_+=(i-E_)/Sm,C_+=(e-C_)/Sm,N_+=(t-N_)/Sm}function O5(){Ol.point=J$}function J$(i,e){i*=Kn,e*=Kn;var t=ri(e);Ca=t*ri(i),Na=t*Yn(i),Ra=Yn(e),Ol.point=eX,Vg(Ca,Na,Ra)}function eX(i,e){i*=Kn,e*=Kn;var t=ri(e),n=t*ri(i),r=t*Yn(i),s=Yn(e),a=ol(Gc((a=Na*s-Ra*r)*a+(a=Ra*n-Ca*s)*a+(a=Ca*r-Na*n)*a),Ca*n+Na*r+Ra*s);M_+=a,R_+=a*(Ca+(Ca=n)),D_+=a*(Na+(Na=r)),P_+=a*(Ra+(Ra=s)),Vg(Ca,Na,Ra)}function I5(){Ol.point=mM}function tX(){Ol.point=iX}function nX(){HD(VD,jD),Ol.point=mM}function iX(i,e){VD=i,jD=e,i*=Kn,e*=Kn,Ol.point=HD;var t=ri(e);Ca=t*ri(i),Na=t*Yn(i),Ra=Yn(e),Vg(Ca,Na,Ra)}function HD(i,e){i*=Kn,e*=Kn;var t=ri(e),n=t*ri(i),r=t*Yn(i),s=Yn(e),a=Na*s-Ra*r,l=Ra*n-Ca*s,u=Ca*r-Na*n,h=lT(a,l,u),m=qc(h),v=h&&-m/h;AT.add(v*a),pT.add(v*l),mT.add(v*u),M_+=m,R_+=m*(Ca+(Ca=n)),D_+=m*(Na+(Na=r)),P_+=m*(Ra+(Ra=s)),Vg(Ca,Na,Ra)}function F5(i){Sm=M_=E_=C_=N_=R_=D_=P_=0,AT=new Bc,pT=new Bc,mT=new Bc,Ey(i,Ol);var e=+AT,t=+pT,n=+mT,r=lT(e,t,n);return rPi&&(i-=Math.round(i/Fo)*Fo),[i,e]}vT.invert=vT;function WD(i,e,t){return(i%=Fo)?e||t?gT(z5(i),G5(e,t)):z5(i):e||t?G5(e,t):vT}function k5(i){return function(e,t){return e+=i,ar(e)>Pi&&(e-=Math.round(e/Fo)*Fo),[e,t]}}function z5(i){var e=k5(i);return e.invert=k5(-i),e}function G5(i,e){var t=ri(i),n=Yn(i),r=ri(e),s=Yn(e);function a(l,u){var h=ri(u),m=ri(l)*h,v=Yn(l)*h,x=Yn(u),S=x*t+m*n;return[ol(v*r-S*s,m*t-x*n),qc(S*r+v*s)]}return a.invert=function(l,u){var h=ri(u),m=ri(l)*h,v=Yn(l)*h,x=Yn(u),S=x*r-v*s;return[ol(v*r+x*s,m*t+S*n),qc(S*t-m*n)]},a}function rX(i){i=WD(i[0]*Kn,i[1]*Kn,i.length>2?i[2]*Kn:0);function e(t){return t=i(t[0]*Kn,t[1]*Kn),t[0]*=Qr,t[1]*=Qr,t}return e.invert=function(t){return t=i.invert(t[0]*Kn,t[1]*Kn),t[0]*=Qr,t[1]*=Qr,t},e}function sX(i,e,t,n,r,s){if(t){var a=ri(e),l=Yn(e),u=n*t;r==null?(r=e+n*Fo,s=e-u/2):(r=q5(a,r),s=q5(a,s),(n>0?rs)&&(r+=n*Fo));for(var h,m=r;n>0?m>s:m1&&i.push(i.pop().concat(i.shift()))},result:function(){var t=i;return i=[],e=null,t}}}function jv(i,e){return ar(i[0]-e[0])=0;--l)r.point((v=m[l])[0],v[1]);else n(x.x,x.p.x,-1,r);x=x.p}x=x.o,m=x.z,S=!S}while(!x.v);r.lineEnd()}}}function V5(i){if(e=i.length){for(var e,t=0,n=i[0],r;++t=0?1:-1,V=q*W,Y=V>Pi,te=C*z;if(u.add(ol(te*q*Yn(V),E*G+te*ri(V))),a+=Y?W+q*Fo:W,Y^w>=t^I>=t){var ne=P0(Ad(S),Ad(U));w_(ne);var le=P0(s,ne);w_(le);var Q=(Y^W>=0?-1:1)*qc(le[2]);(n>Q||n===Q&&(ne[0]||ne[1]))&&(l+=Y^W>=0?1:-1)}}return(a<-vi||a0){for(u||(r.polygonStart(),u=!0),r.lineStart(),z=0;z1&&I&2&&j.push(j.pop().concat(j.shift())),m.push(j.filter(aX))}}return x}}function aX(i){return i.length>1}function oX(i,e){return((i=i.x)[0]<0?i[1]-Ja-vi:Ja-i[1])-((e=e.x)[0]<0?e[1]-Ja-vi:Ja-e[1])}const j5=QD(function(){return!0},lX,cX,[-Pi,-Ja]);function lX(i){var e=NaN,t=NaN,n=NaN,r;return{lineStart:function(){i.lineStart(),r=1},point:function(s,a){var l=s>0?Pi:-Pi,u=ar(s-e);ar(u-Pi)0?Ja:-Ja),i.point(n,t),i.lineEnd(),i.lineStart(),i.point(l,t),i.point(s,t),r=0):n!==l&&u>=Pi&&(ar(e-n)vi?pM((Yn(e)*(s=ri(n))*Yn(t)-Yn(n)*(r=ri(e))*Yn(i))/(r*s*a)):(e+n)/2}function cX(i,e,t,n){var r;if(i==null)r=t*Ja,n.point(-Pi,r),n.point(0,r),n.point(Pi,r),n.point(Pi,0),n.point(Pi,-r),n.point(0,-r),n.point(-Pi,-r),n.point(-Pi,0),n.point(-Pi,r);else if(ar(i[0]-e[0])>vi){var s=i[0]0,r=ar(e)>vi;function s(m,v,x,S){sX(S,i,t,x,m,v)}function a(m,v){return ri(m)*ri(v)>e}function l(m){var v,x,S,w,N;return{lineStart:function(){w=S=!1,N=1},point:function(C,E){var O=[C,E],U,I=a(C,E),j=n?I?0:h(C,E):I?h(C+(C<0?Pi:-Pi),E):0;if(!v&&(w=S=I)&&m.lineStart(),I!==S&&(U=u(v,O),(!U||jv(v,U)||jv(O,U))&&(O[2]=1)),I!==S)N=0,I?(m.lineStart(),U=u(O,v),m.point(U[0],U[1])):(U=u(v,O),m.point(U[0],U[1],2),m.lineEnd()),v=U;else if(r&&v&&n^I){var z;!(j&x)&&(z=u(O,v,!0))&&(N=0,n?(m.lineStart(),m.point(z[0][0],z[0][1]),m.point(z[1][0],z[1][1]),m.lineEnd()):(m.point(z[1][0],z[1][1]),m.lineEnd(),m.lineStart(),m.point(z[0][0],z[0][1],3)))}I&&(!v||!jv(v,O))&&m.point(O[0],O[1]),v=O,S=I,x=j},lineEnd:function(){S&&m.lineEnd(),v=null},clean:function(){return N|(w&&S)<<1}}}function u(m,v,x){var S=Ad(m),w=Ad(v),N=[1,0,0],C=P0(S,w),E=J2(C,C),O=C[0],U=E-O*O;if(!U)return!x&&m;var I=e*E/U,j=-e*O/U,z=P0(N,C),G=ev(N,I),W=ev(C,j);B3(G,W);var q=z,V=J2(G,q),Y=J2(q,q),te=V*V-Y*(J2(G,G)-1);if(!(te<0)){var ne=Gc(te),le=ev(q,(-V-ne)/Y);if(B3(le,G),le=T_(le),!x)return le;var Q=m[0],K=v[0],ae=m[1],Ae=v[1],be;K0^le[1]<(ar(le[0]-Q)Pi^(Q<=le[0]&&le[0]<=K)){var qe=ev(q,(-V+ne)/Y);return B3(qe,G),[le,T_(qe)]}}}function h(m,v){var x=n?i:Pi-i,S=0;return m<-x?S|=1:m>x&&(S|=2),v<-x?S|=4:v>x&&(S|=8),S}return QD(a,l,s,n?[0,-i]:[-Pi,i-Pi])}function fX(i,e,t,n,r,s){var a=i[0],l=i[1],u=e[0],h=e[1],m=0,v=1,x=u-a,S=h-l,w;if(w=t-a,!(!x&&w>0)){if(w/=x,x<0){if(w0){if(w>v)return;w>m&&(m=w)}if(w=r-a,!(!x&&w<0)){if(w/=x,x<0){if(w>v)return;w>m&&(m=w)}else if(x>0){if(w0)){if(w/=S,S<0){if(w0){if(w>v)return;w>m&&(m=w)}if(w=s-l,!(!S&&w<0)){if(w/=S,S<0){if(w>v)return;w>m&&(m=w)}else if(S>0){if(w0&&(i[0]=a+m*x,i[1]=l+m*S),v<1&&(e[0]=a+v*x,e[1]=l+v*S),!0}}}}}var Tm=1e9,nv=-Tm;function dX(i,e,t,n){function r(h,m){return i<=h&&h<=t&&e<=m&&m<=n}function s(h,m,v,x){var S=0,w=0;if(h==null||(S=a(h,v))!==(w=a(m,v))||u(h,m)<0^v>0)do x.point(S===0||S===3?i:t,S>1?n:e);while((S=(S+v+4)%4)!==w);else x.point(m[0],m[1])}function a(h,m){return ar(h[0]-i)0?0:3:ar(h[0]-t)0?2:1:ar(h[1]-e)0?1:0:m>0?3:2}function l(h,m){return u(h.x,m.x)}function u(h,m){var v=a(h,1),x=a(m,1);return v!==x?v-x:v===0?m[1]-h[1]:v===1?h[0]-m[0]:v===2?h[1]-m[1]:m[0]-h[0]}return function(h){var m=h,v=$D(),x,S,w,N,C,E,O,U,I,j,z,G={point:W,lineStart:te,lineEnd:ne,polygonStart:V,polygonEnd:Y};function W(Q,K){r(Q,K)&&m.point(Q,K)}function q(){for(var Q=0,K=0,ae=S.length;Kn&&(Ce-Ee)*(n-qe)>(ke-qe)*(i-Ee)&&++Q:ke<=n&&(Ce-Ee)*(n-qe)<(ke-qe)*(i-Ee)&&--Q;return Q}function V(){m=v,x=[],S=[],z=!0}function Y(){var Q=q(),K=z&&Q,ae=(x=hg(x)).length;(K||ae)&&(h.polygonStart(),K&&(h.lineStart(),s(null,null,1,h),h.lineEnd()),ae&&XD(x,l,Q,s,h),h.polygonEnd()),m=h,x=S=w=null}function te(){G.point=le,S&&S.push(w=[]),j=!0,I=!1,O=U=NaN}function ne(){x&&(le(N,C),E&&I&&v.rejoin(),x.push(v.result())),G.point=W,I&&m.lineEnd()}function le(Q,K){var ae=r(Q,K);if(S&&w.push([Q,K]),j)N=Q,C=K,E=ae,j=!1,ae&&(m.lineStart(),m.point(Q,K));else if(ae&&I)m.point(Q,K);else{var Ae=[O=Math.max(nv,Math.min(Tm,O)),U=Math.max(nv,Math.min(Tm,U))],be=[Q=Math.max(nv,Math.min(Tm,Q)),K=Math.max(nv,Math.min(Tm,K))];fX(Ae,be,i,e,t,n)?(I||(m.lineStart(),m.point(Ae[0],Ae[1])),m.point(be[0],be[1]),ae||m.lineEnd(),z=!1):ae&&(m.lineStart(),m.point(Q,K),z=!1)}O=Q,U=K,I=ae}return G}}var _T,yT,Hv,Wv,L0={sphere:fa,point:fa,lineStart:AX,lineEnd:fa,polygonStart:fa,polygonEnd:fa};function AX(){L0.point=mX,L0.lineEnd=pX}function pX(){L0.point=L0.lineEnd=fa}function mX(i,e){i*=Kn,e*=Kn,yT=i,Hv=Yn(e),Wv=ri(e),L0.point=gX}function gX(i,e){i*=Kn,e*=Kn;var t=Yn(e),n=ri(e),r=ar(i-yT),s=ri(r),a=Yn(r),l=n*a,u=Wv*t-Hv*n*s,h=Hv*t+Wv*n*s;_T.add(ol(Gc(l*l+u*u),h)),yT=i,Hv=t,Wv=n}function vX(i){return _T=new Bc,Ey(i,L0),+_T}var xT=[null,null],_X={type:"LineString",coordinates:xT};function Yh(i,e){return xT[0]=i,xT[1]=e,vX(_X)}var H5={Feature:function(i,e){return L_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n0&&(r=Yh(i[s],i[s-1]),r>0&&t<=r&&n<=r&&(t+n-r)*(1-Math.pow((t-n)/r,2))vi}).map(x)).concat(XA(Z2(s/h)*h,r,h).filter(function(U){return ar(U%v)>vi}).map(S))}return E.lines=function(){return O().map(function(U){return{type:"LineString",coordinates:U}})},E.outline=function(){return{type:"Polygon",coordinates:[w(n).concat(N(a).slice(1),w(t).reverse().slice(1),N(l).reverse().slice(1))]}},E.extent=function(U){return arguments.length?E.extentMajor(U).extentMinor(U):E.extentMinor()},E.extentMajor=function(U){return arguments.length?(n=+U[0][0],t=+U[1][0],l=+U[0][1],a=+U[1][1],n>t&&(U=n,n=t,t=U),l>a&&(U=l,l=a,a=U),E.precision(C)):[[n,l],[t,a]]},E.extentMinor=function(U){return arguments.length?(e=+U[0][0],i=+U[1][0],s=+U[0][1],r=+U[1][1],e>i&&(U=e,e=i,i=U),s>r&&(U=s,s=r,r=U),E.precision(C)):[[e,s],[i,r]]},E.step=function(U){return arguments.length?E.stepMajor(U).stepMinor(U):E.stepMinor()},E.stepMajor=function(U){return arguments.length?(m=+U[0],v=+U[1],E):[m,v]},E.stepMinor=function(U){return arguments.length?(u=+U[0],h=+U[1],E):[u,h]},E.precision=function(U){return arguments.length?(C=+U,x=Q5(s,r,90),S=K5(e,i,C),w=Q5(l,a,90),N=K5(n,t,C),E):C},E.extentMajor([[-180,-90+vi],[180,90-vi]]).extentMinor([[-180,-80-vi],[180,80+vi]])}function SX(){return bX()()}function gM(i,e){var t=i[0]*Kn,n=i[1]*Kn,r=e[0]*Kn,s=e[1]*Kn,a=ri(n),l=Yn(n),u=ri(s),h=Yn(s),m=a*ri(t),v=a*Yn(t),x=u*ri(r),S=u*Yn(r),w=2*qc(Gc(C5(s-n)+a*u*C5(r-t))),N=Yn(w),C=w?function(E){var O=Yn(E*=w)/N,U=Yn(w-E)/N,I=U*m+O*x,j=U*v+O*S,z=U*l+O*h;return[ol(j,I)*Qr,ol(z,Gc(I*I+j*j))*Qr]}:function(){return[t*Qr,n*Qr]};return C.distance=w,C}const Z5=i=>i;var U0=1/0,U_=U0,pg=-U0,B_=pg,J5={point:TX,lineStart:fa,lineEnd:fa,polygonStart:fa,polygonEnd:fa,result:function(){var i=[[U0,U_],[pg,B_]];return pg=B_=-(U_=U0=1/0),i}};function TX(i,e){ipg&&(pg=i),eB_&&(B_=e)}function vM(i){return function(e){var t=new bT;for(var n in i)t[n]=i[n];return t.stream=e,t}}function bT(){}bT.prototype={constructor:bT,point:function(i,e){this.stream.point(i,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function _M(i,e,t){var n=i.clipExtent&&i.clipExtent();return i.scale(150).translate([0,0]),n!=null&&i.clipExtent(null),Ey(t,i.stream(J5)),e(J5.result()),n!=null&&i.clipExtent(n),i}function ZD(i,e,t){return _M(i,function(n){var r=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(r/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),l=+e[0][0]+(r-a*(n[1][0]+n[0][0]))/2,u=+e[0][1]+(s-a*(n[1][1]+n[0][1]))/2;i.scale(150*a).translate([l,u])},t)}function wX(i,e,t){return ZD(i,[[0,0],e],t)}function MX(i,e,t){return _M(i,function(n){var r=+e,s=r/(n[1][0]-n[0][0]),a=(r-s*(n[1][0]+n[0][0]))/2,l=-s*n[0][1];i.scale(150*s).translate([a,l])},t)}function EX(i,e,t){return _M(i,function(n){var r=+e,s=r/(n[1][1]-n[0][1]),a=-s*n[0][0],l=(r-s*(n[1][1]+n[0][1]))/2;i.scale(150*s).translate([a,l])},t)}var eR=16,CX=ri(30*Kn);function tR(i,e){return+e?RX(i,e):NX(i)}function NX(i){return vM({point:function(e,t){e=i(e,t),this.stream.point(e[0],e[1])}})}function RX(i,e){function t(n,r,s,a,l,u,h,m,v,x,S,w,N,C){var E=h-n,O=m-r,U=E*E+O*O;if(U>4*e&&N--){var I=a+x,j=l+S,z=u+w,G=Gc(I*I+j*j+z*z),W=qc(z/=G),q=ar(ar(z)-1)e||ar((E*ne+O*le)/U-.5)>.3||a*x+l*S+u*w2?Q[2]%360*Kn:0,ne()):[l*Qr,u*Qr,h*Qr]},Y.angle=function(Q){return arguments.length?(v=Q%360*Kn,ne()):v*Qr},Y.reflectX=function(Q){return arguments.length?(x=Q?-1:1,ne()):x<0},Y.reflectY=function(Q){return arguments.length?(S=Q?-1:1,ne()):S<0},Y.precision=function(Q){return arguments.length?(z=tR(G,j=Q*Q),le()):Gc(j)},Y.fitExtent=function(Q,K){return ZD(Y,Q,K)},Y.fitSize=function(Q,K){return wX(Y,Q,K)},Y.fitWidth=function(Q,K){return MX(Y,Q,K)},Y.fitHeight=function(Q,K){return EX(Y,Q,K)};function ne(){var Q=nR(t,0,0,x,S,v).apply(null,e(s,a)),K=nR(t,n-Q[0],r-Q[1],x,S,v);return m=WD(l,u,h),G=gT(e,K),W=gT(m,G),z=tR(G,j),le()}function le(){return q=V=null,Y}return function(){return e=i.apply(this,arguments),Y.invert=e.invert&&te,ne()}}function OX(i){return function(e,t){var n=Gc(e*e+t*t),r=i(n),s=Yn(r),a=ri(r);return[ol(e*s,n*a),qc(n&&t*s/n)]}}function yM(i,e){return[i,V$(H$((Ja+e)/2))]}yM.invert=function(i,e){return[i,2*pM(q$(e))-Ja]};function JD(i,e){var t=ri(e),n=1+ri(i)*t;return[t*Yn(i)/n,Yn(e)/n]}JD.invert=OX(function(i){return 2*pM(i)});function IX(){return UX(JD).scale(250).clipAngle(142)}function ST(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=zc().domain([1,0]).range([t,n]).clamp(!0),s=zc().domain([I3(t),I3(n)]).range([1,0]).clamp(!0),a=function(v){return s(I3(r(v)))},l=e.array,u=0,h=l.length;u2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,l=[],u=Math.pow(2,e),h=360/u,m=180/u,v=s===void 0?u-1:s,x=a===void 0?u-1:a,S=n,w=Math.min(u-1,v);S<=w;S++)for(var N=r,C=Math.min(u-1,x);N<=C;N++){var E=N,O=m;if(t){E=N===0?N:rR(N/u)*u;var U=N+1===u?N+1:rR((N+1)/u)*u;O=(U-E)*180/u}var I=-180+(S+.5)*h,j=90-(E*180/u+O/2),z=O;l.push({x:S,y:N,lng:I,lat:j,latLen:z})}return l},tY=6,nY=7,iY=3,rY=90,ru=new WeakMap,Oh=new WeakMap,F3=new WeakMap,iv=new WeakMap,Zo=new WeakMap,I_=new WeakMap,o0=new WeakMap,Rf=new WeakMap,rv=new WeakSet,sY=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.tileUrl,a=r.minLevel,l=a===void 0?0:a,u=r.maxLevel,h=u===void 0?17:u,m=r.mercatorProjection,v=m===void 0?!0:m;return qX(this,e),n=GX(this,e),VX(n,rv),Eh(n,ru,void 0),Eh(n,Oh,void 0),Eh(n,F3,void 0),Eh(n,iv,void 0),Eh(n,Zo,{}),Eh(n,I_,void 0),Eh(n,o0,void 0),Eh(n,Rf,void 0),SA(n,"minLevel",void 0),SA(n,"maxLevel",void 0),SA(n,"thresholds",nP(new Array(30)).map(function(x,S){return 8/Math.pow(2,S)})),SA(n,"curvatureResolution",5),SA(n,"tileMargin",0),SA(n,"clearTiles",function(){Object.values(mi(Zo,n)).forEach(function(x){x.forEach(function(S){S.obj&&(n.remove(S.obj),iR(S.obj),delete S.obj)})}),Ch(Zo,n,{})}),Ch(ru,n,t),n.tileUrl=s,Ch(Oh,n,v),n.minLevel=l,n.maxLevel=h,n.level=0,n.add(Ch(Rf,n,new qi(new Bu(mi(ru,n)*.99,180,90),new vd({color:0})))),mi(Rf,n).visible=!1,mi(Rf,n).material.polygonOffset=!0,mi(Rf,n).material.polygonOffsetUnits=3,mi(Rf,n).material.polygonOffsetFactor=1,n}return WX(e,i),HX(e,[{key:"tileUrl",get:function(){return mi(F3,this)},set:function(n){Ch(F3,this,n),this.updatePov(mi(o0,this))}},{key:"level",get:function(){return mi(iv,this)},set:function(n){var r,s=this;mi(Zo,this)[n]||Um(rv,this,aY).call(this,n);var a=mi(iv,this);if(Ch(iv,this,n),!(n===a||a===void 0)){if(mi(Rf,this).visible=n>0,mi(Zo,this)[n].forEach(function(u){return u.obj&&(u.obj.material.depthWrite=!0)}),an)for(var l=n+1;l<=a;l++)mi(Zo,this)[l]&&mi(Zo,this)[l].forEach(function(u){u.obj&&(s.remove(u.obj),iR(u.obj),delete u.obj)});Um(rv,this,aR).call(this)}}},{key:"updatePov",value:function(n){var r=this;if(!(!n||!(n instanceof _y))){Ch(o0,this,n);var s;if(Ch(I_,this,function(m){if(!m.hullPnts){var v=360/Math.pow(2,r.level),x=m.lng,S=m.lat,w=m.latLen,N=x-v/2,C=x+v/2,E=S-w/2,O=S+w/2;m.hullPnts=[[S,x],[E,N],[O,N],[E,C],[O,C]].map(function(U){var I=$v(U,2),j=I[0],z=I[1];return oP(j,z,mi(ru,r))}).map(function(U){var I=U.x,j=U.y,z=U.z;return new de(I,j,z)})}return s||(s=new zg,n.updateMatrix(),n.updateMatrixWorld(),s.setFromProjectionMatrix(new Xn().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse))),m.hullPnts.some(function(U){return s.containsPoint(U.clone().applyMatrix4(r.matrixWorld))})}),this.tileUrl){var a=n.position.clone(),l=a.distanceTo(this.getWorldPosition(new de)),u=(l-mi(ru,this))/mi(ru,this),h=this.thresholds.findIndex(function(m){return m&&m<=u});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,h<0?this.thresholds.length:h)),Um(rv,this,aR).call(this)}}}}])})(Ka);function aY(i){var e=this;if(i>nY){mi(Zo,this)[i]=[];return}var t=mi(Zo,this)[i]=wT(i,mi(Oh,this));t.forEach(function(n){return n.centroid=oP(n.lat,n.lng,mi(ru,e))}),t.octree=xD().x(function(n){return n.centroid.x}).y(function(n){return n.centroid.y}).z(function(n){return n.centroid.z}).addAll(t)}function aR(){var i=this;if(!(!this.tileUrl||this.level===void 0||!mi(Zo,this).hasOwnProperty(this.level))&&!(!mi(I_,this)&&this.level>tY)){var e=mi(Zo,this)[this.level];if(mi(o0,this)){var t=this.worldToLocal(mi(o0,this).position.clone());if(e.octree){var n,r=this.worldToLocal(mi(o0,this).position.clone()),s=(r.length()-mi(ru,this))*iY;e=(n=e.octree).findAllWithinRadius.apply(n,nP(r).concat([s]))}else{var a=JX(t),l=(a.r/mi(ru,this)-1)*rY,u=l/Math.cos(Nf(a.lat)),h=[a.lng-u,a.lng+u],m=[a.lat+l,a.lat-l],v=sR(this.level,mi(Oh,this),h[0],m[0]),x=$v(v,2),S=x[0],w=x[1],N=sR(this.level,mi(Oh,this),h[1],m[1]),C=$v(N,2),E=C[0],O=C[1];!e.record&&(e.record={});var U=e.record;if(!U.hasOwnProperty("".concat(Math.round((S+E)/2),"_").concat(Math.round((w+O)/2))))e=wT(this.level,mi(Oh,this),S,w,E,O).map(function(W){var q="".concat(W.x,"_").concat(W.y);return U.hasOwnProperty(q)?U[q]:(U[q]=W,e.push(W),W)});else{for(var I=[],j=S;j<=E;j++)for(var z=w;z<=O;z++){var G="".concat(j,"_").concat(z);U.hasOwnProperty(G)||(U[G]=wT(this.level,mi(Oh,this),j,z,j,z)[0],e.push(U[G])),I.push(U[G])}e=I}}}e.filter(function(W){return!W.obj}).filter(mi(I_,this)||function(){return!0}).forEach(function(W){var q=W.x,V=W.y,Y=W.lng,te=W.lat,ne=W.latLen,le=360/Math.pow(2,i.level);if(!W.obj){var Q=le*(1-i.tileMargin),K=ne*(1-i.tileMargin),ae=Nf(Y),Ae=Nf(-te),be=new qi(new Bu(mi(ru,i),Math.ceil(Q/i.curvatureResolution),Math.ceil(K/i.curvatureResolution),Nf(90-Q/2)+ae,Nf(Q),Nf(90-K/2)+Ae,Nf(K)),new Kc);if(mi(Oh,i)){var Se=[te+ne/2,te-ne/2].map(function(Ce){return .5-Ce/180}),se=$v(Se,2),Ee=se[0],qe=se[1];eY(be.geometry.attributes.uv,Ee,qe)}W.obj=be}W.loading||(W.loading=!0,new aM().load(i.tileUrl(q,V,i.level),function(Ce){var ke=W.obj;ke&&(Ce.colorSpace=Nn,ke.material.map=Ce,ke.material.color=null,ke.material.needsUpdate=!0,i.add(ke)),W.loading=!1}))})}}function oY(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=uP(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let l,u,h;if(n&&(s=fY(i,e,s,t)),i.length>80*t){l=i[0],u=i[1];let m=l,v=u;for(let x=t;xm&&(m=S),w>v&&(v=w)}h=Math.max(m-l,v-u),h=h!==0?32767/h:0}return mg(s,a,t,l,u,h,0),a}function uP(i,e,t,n,r){let s;if(r===SY(i,e,t,n)>0)for(let a=e;a=e;a-=n)s=oR(a/n|0,i[a],i[a+1],s);return s&&B0(s,s.next)&&(vg(s),s=s.next),s}function pd(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(B0(t,t.next)||kr(t.prev,t,t.next)===0)){if(vg(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function mg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&gY(i,n,r,s);let l=i;for(;i.prev!==i.next;){const u=i.prev,h=i.next;if(s?uY(i,n,r,s):lY(i)){e.push(u.i,i.i,h.i),vg(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=cY(pd(i),e),mg(i,e,t,n,r,s,2)):a===2&&hY(i,e,t,n,r,s):mg(pd(i),e,t,n,r,s,1);break}}}function lY(i){const e=i.prev,t=i,n=i.next;if(kr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=Math.min(r,s,a),v=Math.min(l,u,h),x=Math.max(r,s,a),S=Math.max(l,u,h);let w=n.next;for(;w!==e;){if(w.x>=m&&w.x<=x&&w.y>=v&&w.y<=S&&wm(r,l,s,u,a,h,w.x,w.y)&&kr(w.prev,w,w.next)>=0)return!1;w=w.next}return!0}function uY(i,e,t,n){const r=i.prev,s=i,a=i.next;if(kr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=Math.min(l,u,h),w=Math.min(m,v,x),N=Math.max(l,u,h),C=Math.max(m,v,x),E=MT(S,w,e,t,n),O=MT(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=w&&U.y<=C&&U!==r&&U!==a&&wm(l,m,u,v,h,x,U.x,U.y)&&kr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=w&&I.y<=C&&I!==r&&I!==a&&wm(l,m,u,v,h,x,I.x,I.y)&&kr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=w&&U.y<=C&&U!==r&&U!==a&&wm(l,m,u,v,h,x,U.x,U.y)&&kr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=w&&I.y<=C&&I!==r&&I!==a&&wm(l,m,u,v,h,x,I.x,I.y)&&kr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function cY(i,e){let t=i;do{const n=t.prev,r=t.next.next;!B0(n,r)&&hP(n,t,t.next,r)&&gg(n,r)&&gg(r,n)&&(e.push(n.i,t.i,r.i),vg(t),vg(t.next),t=i=r),t=t.next}while(t!==i);return pd(t)}function hY(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&yY(a,l)){let u=fP(a,l);a=pd(a,a.next),u=pd(u,u.next),mg(a,e,t,n,r,s,0),mg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function fY(i,e,t,n){const r=[];for(let s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const v=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=n&&v>s&&(s=v,a=t.x=t.x&&t.x>=u&&n!==t.x&&cP(ra.x||t.x===a.x&&mY(a,t)))&&(a=t,m=v)}t=t.next}while(t!==l);return a}function mY(i,e){return kr(i.prev,i,e.prev)<0&&kr(e.next,i,i.next)<0}function gY(i,e,t,n){let r=i;do r.z===0&&(r.z=MT(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,vY(r)}function vY(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,l=0;for(let h=0;h0||u>0&&a;)l!==0&&(u===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,l--):(r=a,a=a.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function MT(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function _Y(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function wm(i,e,t,n,r,s,a,l){return!(i===a&&e===l)&&cP(i,e,t,n,r,s,a,l)}function yY(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!xY(i,e)&&(gg(i,e)&&gg(e,i)&&bY(i,e)&&(kr(i.prev,i,e.prev)||kr(i,e.prev,e))||B0(i,e)&&kr(i.prev,i,i.next)>0&&kr(e.prev,e,e.next)>0)}function kr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function B0(i,e){return i.x===e.x&&i.y===e.y}function hP(i,e,t,n){const r=av(kr(i,e,t)),s=av(kr(i,e,n)),a=av(kr(t,n,i)),l=av(kr(t,n,e));return!!(r!==s&&a!==l||r===0&&sv(i,t,e)||s===0&&sv(i,n,e)||a===0&&sv(t,i,n)||l===0&&sv(t,e,n))}function sv(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function av(i){return i>0?1:i<0?-1:0}function xY(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&hP(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function gg(i,e){return kr(i.prev,i,i.next)<0?kr(i,e,i.next)>=0&&kr(i,i.prev,e)>=0:kr(i,e,i.prev)<0||kr(i,i.next,e)<0}function bY(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function fP(i,e){const t=ET(i.i,i.x,i.y),n=ET(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function oR(i,e,t,n){const r=ET(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function vg(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ET(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function SY(i,e,t,n){let r=0;for(let s=e,a=t-n;si.length)&&(e=i.length);for(var t=0,n=Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,l=!1;return{s:function(){t=t.call(i)},n:function(){var u=t.next();return a=u.done,u},e:function(u){l=!0,s=u},f:function(){try{a||t.return==null||t.return()}finally{if(l)throw s}}}}function k_(i){return k_=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},k_(i)}function DY(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&NT(i,e)}function dP(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dP=function(){return!!i})()}function PY(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function LY(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,a,l=[],u=!0,h=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=s.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(m){h=!0,r=m}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function UY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BY(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function OY(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return MY(i)}function NT(i,e){return NT=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},NT(i,e)}function im(i,e){return TY(i)||LY(i,e)||xM(i,e)||UY()}function IY(i){return wY(i)||PY(i)||xM(i)||BY()}function xM(i,e){if(i){if(typeof i=="string")return CT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?CT(i,e):void 0}}var lR=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(s){if(r){var a=Yh(s,r)*180/Math.PI;if(a>t)for(var l=gM(r,s),u=r.length>2||s.length>2?Ag(r[2]||0,s[2]||0):null,h=u?function(x){return[].concat(IY(l(x)),[u(x)])}:l,m=1/Math.ceil(a/t),v=m;v<1;)n.push(h(v)),v+=m}n.push(r=s)}),n},RT=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:Ji,Float32BufferAttribute:Ci},FY=new RT.BufferGeometry().setAttribute?"setAttribute":"addAttribute",AP=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;CY(this,e),n=EY(this,e),n.type="GeoJsonGeometry",n.parameters={geoJson:t,radius:r,resolution:s};var a=({Point:m,MultiPoint:v,LineString:x,MultiLineString:S,Polygon:w,MultiPolygon:N}[t.type]||function(){return[]})(t.coordinates,r),l=[],u=[],h=0;a.forEach(function(C){var E=l.length;rm({indices:l,vertices:u},C),n.addGroup(E,l.length-E,h++)}),l.length&&n.setIndex(l),u.length&&n[FY]("position",new RT.Float32BufferAttribute(u,3));function m(C,E){var O=k3(C[1],C[0],E+(C[2]||0)),U=[];return[{vertices:O,indices:U}]}function v(C,E){var O={vertices:[],indices:[]};return C.map(function(U){return m(U,E)}).forEach(function(U){var I=im(U,1),j=I[0];rm(O,j)}),[O]}function x(C,E){for(var O=lR(C,s).map(function(W){var q=im(W,3),V=q[0],Y=q[1],te=q[2],ne=te===void 0?0:te;return k3(Y,V,E+ne)}),U=F_([O]),I=U.vertices,j=Math.round(I.length/3),z=[],G=1;G2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function kY(i,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!i.hasAttribute("position")||!i.hasAttribute("normal")||!i.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(a){if(a.normalized||a.isInterleavedBufferAttribute){const l=new Float32Array(a.count*a.itemSize);for(let u=0,h=0;u2&&(l[h++]=a.getZ(u));return l}return a.array instanceof Float32Array?a.array:new Float32Array(a.array)}const r=i.index?i.toNonIndexed():i,s=e.generateTangents(n(r.attributes.position),n(r.attributes.normal),n(r.attributes.uv));if(t)for(let a=3;a=2&&a.setY(l,i.getY(l)),n>=3&&a.setZ(l,i.getZ(l)),n>=4&&a.setW(l,i.getW(l));return a}function VY(i){const e=i.attributes,t=i.morphTargets,n=new Map;for(const r in e){const s=e[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,z_(s)),e[r]=n.get(s))}for(const r in t){const s=t[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,z_(s)),t[r]=n.get(s))}}function jY(i){let e=0;for(const n in i.attributes){const r=i.getAttribute(n);e+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const t=i.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function HY(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=i.getIndex(),r=i.getAttribute("position"),s=n?n.count:r.count;let a=0;const l=Object.keys(i.attributes),u={},h={},m=[],v=["getX","getY","getZ","getW"],x=["setX","setY","setZ","setW"];for(let O=0,U=l.length;O{const q=new G.array.constructor(G.count*G.itemSize);h[I][W]=new G.constructor(q,G.itemSize,G.normalized)}))}const S=e*.5,w=Math.log10(1/e),N=Math.pow(10,w),C=S*N;for(let O=0;Oa.materialIndex!==l.materialIndex?a.materialIndex-l.materialIndex:a.start-l.start),i.getIndex()===null){const a=i.getAttribute("position"),l=[];for(let u=0;ut&&u.add(Y)}u.normalize(),w.setXYZ(E+j,u.x,u.y,u.z)}}return m.setAttribute("normal",w),m}const bM=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:kY,computeMorphedAttributes:$Y,deepCloneAttribute:GY,deinterleaveAttribute:z_,deinterleaveGeometry:VY,estimateBytesUsed:jY,interleaveAttributes:qY,mergeAttributes:DT,mergeGeometries:zY,mergeGroups:XY,mergeVertices:HY,toCreasedNormals:YY,toTrianglesDrawMode:WY},Symbol.toStringTag,{value:"Module"}));var kt=(function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}});function G_(i){"@babel/helpers - typeof";return G_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},G_(i)}var QY=/^\s+/,KY=/\s+$/;function Rn(i,e){if(i=i||"",e=e||{},i instanceof Rn)return i;if(!(this instanceof Rn))return new Rn(i,e);var t=ZY(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}Rn.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,r,s,a,l;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),n<=.03928?a=n/12.92:a=Math.pow((n+.055)/1.055,2.4),r<=.03928?l=r/12.92:l=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*a+.0722*l},setAlpha:function(e){return this._a=pP(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=hR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=hR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=cR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=cR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return fR(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return nQ(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Dr(this._r,255)*100)+"%",g:Math.round(Dr(this._g,255)*100)+"%",b:Math.round(Dr(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Dr(this._r,255)*100)+"%, "+Math.round(Dr(this._g,255)*100)+"%, "+Math.round(Dr(this._b,255)*100)+"%)":"rgba("+Math.round(Dr(this._r,255)*100)+"%, "+Math.round(Dr(this._g,255)*100)+"%, "+Math.round(Dr(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:AQ[fR(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+dR(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=Rn(e);n="#"+dR(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return Rn(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(aQ,arguments)},brighten:function(){return this._applyModification(oQ,arguments)},darken:function(){return this._applyModification(lQ,arguments)},desaturate:function(){return this._applyModification(iQ,arguments)},saturate:function(){return this._applyModification(rQ,arguments)},greyscale:function(){return this._applyModification(sQ,arguments)},spin:function(){return this._applyModification(uQ,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(fQ,arguments)},complement:function(){return this._applyCombination(cQ,arguments)},monochromatic:function(){return this._applyCombination(dQ,arguments)},splitcomplement:function(){return this._applyCombination(hQ,arguments)},triad:function(){return this._applyCombination(AR,[3])},tetrad:function(){return this._applyCombination(AR,[4])}};Rn.fromRatio=function(i,e){if(G_(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=Mm(i[n]));i=t}return Rn(i,e)};function ZY(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,s=null,a=!1,l=!1;return typeof i=="string"&&(i=vQ(i)),G_(i)=="object"&&(wc(i.r)&&wc(i.g)&&wc(i.b)?(e=JY(i.r,i.g,i.b),a=!0,l=String(i.r).substr(-1)==="%"?"prgb":"rgb"):wc(i.h)&&wc(i.s)&&wc(i.v)?(n=Mm(i.s),r=Mm(i.v),e=tQ(i.h,n,r),a=!0,l="hsv"):wc(i.h)&&wc(i.s)&&wc(i.l)&&(n=Mm(i.s),s=Mm(i.l),e=eQ(i.h,n,s),a=!0,l="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=pP(t),{ok:a,format:i.format||l,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function JY(i,e,t){return{r:Dr(i,255)*255,g:Dr(e,255)*255,b:Dr(t,255)*255}}function cR(i,e,t){i=Dr(i,255),e=Dr(e,255),t=Dr(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=(n+r)/2;if(n==r)s=a=0;else{var u=n-r;switch(a=l>.5?u/(2-n-r):u/(n+r),n){case i:s=(e-t)/u+(e1&&(v-=1),v<1/6?h+(m-h)*6*v:v<1/2?m:v<2/3?h+(m-h)*(2/3-v)*6:h}if(e===0)n=r=s=t;else{var l=t<.5?t*(1+e):t+e-t*e,u=2*t-l;n=a(u,l,i+1/3),r=a(u,l,i),s=a(u,l,i-1/3)}return{r:n*255,g:r*255,b:s*255}}function hR(i,e,t){i=Dr(i,255),e=Dr(e,255),t=Dr(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=n,u=n-r;if(a=n===0?0:u/n,n==r)s=0;else{switch(n){case i:s=(e-t)/u+(e>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(Rn(n));return s}function dQ(i,e){e=e||6;for(var t=Rn(i).toHsv(),n=t.h,r=t.s,s=t.v,a=[],l=1/e;e--;)a.push(Rn({h:n,s:r,v:s})),s=(s+l)%1;return a}Rn.mix=function(i,e,t){t=t===0?0:t||50;var n=Rn(i).toRgb(),r=Rn(e).toRgb(),s=t/100,a={r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a};return Rn(a)};Rn.readability=function(i,e){var t=Rn(i),n=Rn(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)};Rn.isReadable=function(i,e,t){var n=Rn.readability(i,e),r,s;switch(s=!1,r=_Q(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=n>=4.5;break;case"AAlarge":s=n>=3;break;case"AAAsmall":s=n>=7;break}return s};Rn.mostReadable=function(i,e,t){var n=null,r=0,s,a,l,u;t=t||{},a=t.includeFallbackColors,l=t.level,u=t.size;for(var h=0;hr&&(r=s,n=Rn(e[h]));return Rn.isReadable(i,n,{level:l,size:u})||!a?n:(t.includeFallbackColors=!1,Rn.mostReadable(i,["#fff","#000"],t))};var PT=Rn.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},AQ=Rn.hexNames=pQ(PT);function pQ(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function pP(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function Dr(i,e){mQ(i)&&(i="100%");var t=gQ(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function Cy(i){return Math.min(1,Math.max(0,i))}function Eo(i){return parseInt(i,16)}function mQ(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function gQ(i){return typeof i=="string"&&i.indexOf("%")!=-1}function Il(i){return i.length==1?"0"+i:""+i}function Mm(i){return i<=1&&(i=i*100+"%"),i}function mP(i){return Math.round(parseFloat(i)*255).toString(16)}function pR(i){return Eo(i)/255}var Pl=(function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function wc(i){return!!Pl.CSS_UNIT.exec(i)}function vQ(i){i=i.replace(QY,"").replace(KY,"").toLowerCase();var e=!1;if(PT[i])i=PT[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=Pl.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=Pl.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=Pl.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=Pl.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=Pl.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=Pl.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=Pl.hex8.exec(i))?{r:Eo(t[1]),g:Eo(t[2]),b:Eo(t[3]),a:pR(t[4]),format:e?"name":"hex8"}:(t=Pl.hex6.exec(i))?{r:Eo(t[1]),g:Eo(t[2]),b:Eo(t[3]),format:e?"name":"hex"}:(t=Pl.hex4.exec(i))?{r:Eo(t[1]+""+t[1]),g:Eo(t[2]+""+t[2]),b:Eo(t[3]+""+t[3]),a:pR(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=Pl.hex3.exec(i))?{r:Eo(t[1]+""+t[1]),g:Eo(t[2]+""+t[2]),b:Eo(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function _Q(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function LT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},l.prototype.update=function(u,h){h===void 0&&(h=!0),this._currentTick++,this._currentTime+=u,this._tickDeltaTime=u,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),h&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},l.prototype.getTimer=function(){return Date.now()},l})();Object.defineProperty(n,"__esModule",{value:!0}),n.default=a},function(t,n,r){(function(s,a){t.exports=a()})(this,function(){return(function(s){function a(u){if(l[u])return l[u].exports;var h=l[u]={exports:{},id:u,loaded:!1};return s[u].call(h.exports,h,h.exports,a),h.loaded=!0,h.exports}var l={};return a.m=s,a.c=l,a.p="",a(0)})([function(s,a){var l=(function(){function u(){this.functions=[]}return u.prototype.add=function(h){return this.functions.indexOf(h)===-1&&(this.functions.push(h),!0)},u.prototype.remove=function(h){var m=this.functions.indexOf(h);return m>-1&&(this.functions.splice(m,1),!0)},u.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},u.prototype.dispatch=function(){for(var h=[],m=0;mh==m>-h?(s=h,h=e[++v]):(s=m,m=n[++x]);let S=0;if(vh==m>-h?(a=h+s,l=s-(a-h),h=e[++v]):(a=m+s,l=s-(a-m),m=n[++x]),s=a,l!==0&&(r[S++]=l);vh==m>-h?(a=s+h,u=a-s,l=s-(a-u)+(h-u),h=e[++v]):(a=s+m,u=a-s,l=s-(a-u)+(m-u),m=n[++x]),s=a,l!==0&&(r[S++]=l);for(;v=le||-ne>=le||(v=i-q,l=i-(q+v)+(v-r),v=t-V,h=t-(V+v)+(v-r),v=e-Y,u=e-(Y+v)+(v-s),v=n-te,m=n-(te+v)+(v-s),l===0&&u===0&&h===0&&m===0)||(le=qQ*a+FQ*Math.abs(ne),ne+=q*m+te*l-(Y*h+V*u),ne>=le||-ne>=le))return ne;I=l*te,x=ca*l,S=x-(x-l),w=l-S,x=ca*te,N=x-(x-te),C=te-N,j=w*C-(I-S*N-w*N-S*C),z=u*V,x=ca*u,S=x-(x-u),w=u-S,x=ca*V,N=x-(x-V),C=V-N,G=w*C-(z-S*N-w*N-S*C),E=j-G,v=j-E,wa[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,wa[1]=U-(E+v)+(v-z),W=O+E,v=W-O,wa[2]=O-(W-v)+(E-v),wa[3]=W;const Q=V3(4,EA,4,wa,gR);I=q*m,x=ca*q,S=x-(x-q),w=q-S,x=ca*m,N=x-(x-m),C=m-N,j=w*C-(I-S*N-w*N-S*C),z=Y*h,x=ca*Y,S=x-(x-Y),w=Y-S,x=ca*h,N=x-(x-h),C=h-N,G=w*C-(z-S*N-w*N-S*C),E=j-G,v=j-E,wa[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,wa[1]=U-(E+v)+(v-z),W=O+E,v=W-O,wa[2]=O-(W-v)+(E-v),wa[3]=W;const K=V3(Q,gR,4,wa,vR);I=l*m,x=ca*l,S=x-(x-l),w=l-S,x=ca*m,N=x-(x-m),C=m-N,j=w*C-(I-S*N-w*N-S*C),z=u*h,x=ca*u,S=x-(x-u),w=u-S,x=ca*h,N=x-(x-h),C=h-N,G=w*C-(z-S*N-w*N-S*C),E=j-G,v=j-E,wa[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,wa[1]=U-(E+v)+(v-z),W=O+E,v=W-O,wa[2]=O-(W-v)+(E-v),wa[3]=W;const ae=V3(K,vR,4,wa,_R);return _R[ae-1]}function Em(i,e,t,n,r,s){const a=(e-s)*(t-r),l=(i-r)*(n-s),u=a-l,h=Math.abs(a+l);return Math.abs(u)>=zQ*h?u:-VQ(i,e,t,n,r,s,h)}const yR=Math.pow(2,-52),lv=new Uint32Array(512);class _g{static from(e,t=XQ,n=YQ){const r=e.length,s=new Float64Array(r*2);for(let a=0;a>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:s}=this,a=e.length>>1;let l=1/0,u=1/0,h=-1/0,m=-1/0;for(let q=0;qh&&(h=V),Y>m&&(m=Y),this._ids[q]=q}const v=(l+h)/2,x=(u+m)/2;let S,w,N;for(let q=0,V=1/0;q0&&(w=q,V=Y)}let O=e[2*w],U=e[2*w+1],I=1/0;for(let q=0;qte&&(q[V++]=ne,te=le)}this.hull=q.subarray(0,V),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Em(C,E,O,U,j,z)<0){const q=w,V=O,Y=U;w=N,O=j,U=z,N=q,j=V,z=Y}const G=$Q(C,E,O,U,j,z);this._cx=G.x,this._cy=G.y;for(let q=0;q0&&Math.abs(ne-V)<=yR&&Math.abs(le-Y)<=yR||(V=ne,Y=le,te===S||te===w||te===N))continue;let Q=0;for(let Se=0,se=this._hashKey(ne,le);Se=0;)if(K=ae,K===Q){K=-1;break}if(K===-1)continue;let Ae=this._addTriangle(K,te,n[K],-1,-1,r[K]);r[te]=this._legalize(Ae+2),r[K]=Ae,W++;let be=n[K];for(;ae=n[be],Em(ne,le,e[2*be],e[2*be+1],e[2*ae],e[2*ae+1])<0;)Ae=this._addTriangle(be,te,ae,r[te],-1,r[be]),r[te]=this._legalize(Ae+2),n[be]=be,W--,be=ae;if(K===Q)for(;ae=t[K],Em(ne,le,e[2*ae],e[2*ae+1],e[2*K],e[2*K+1])<0;)Ae=this._addTriangle(ae,te,K,-1,r[K],r[ae]),this._legalize(Ae+2),r[ae]=Ae,n[K]=K,W--,K=ae;this._hullStart=t[te]=K,n[K]=t[be]=te,n[te]=be,s[this._hashKey(ne,le)]=te,s[this._hashKey(e[2*K],e[2*K+1])]=K}this.hull=new Uint32Array(W);for(let q=0,V=this._hullStart;q0?3-t:1+t)/4}function j3(i,e,t,n){const r=i-t,s=e-n;return r*r+s*s}function HQ(i,e,t,n,r,s,a,l){const u=i-a,h=e-l,m=t-a,v=n-l,x=r-a,S=s-l,w=u*u+h*h,N=m*m+v*v,C=x*x+S*S;return u*(v*C-N*S)-h*(m*C-N*x)+w*(m*S-v*x)<0}function WQ(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=(h*m-l*v)*x,w=(a*v-u*m)*x;return S*S+w*w}function $Q(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=i+(h*m-l*v)*x,w=e+(a*v-u*m)*x;return{x:S,y:w}}function QA(i,e,t,n){if(n-t<=20)for(let r=t+1;r<=n;r++){const s=i[r],a=e[s];let l=r-1;for(;l>=t&&e[i[l]]>a;)i[l+1]=i[l--];i[l+1]=s}else{const r=t+n>>1;let s=t+1,a=n;am(i,r,s),e[i[t]]>e[i[n]]&&am(i,t,n),e[i[s]]>e[i[n]]&&am(i,s,n),e[i[t]]>e[i[s]]&&am(i,t,s);const l=i[s],u=e[l];for(;;){do s++;while(e[i[s]]u);if(a=a-t?(QA(i,e,s,n),QA(i,e,t,a-1)):(QA(i,e,t,a-1),QA(i,e,s,n))}}function am(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function XQ(i){return i[0]}function YQ(i){return i[1]}function QQ(i,e){var t,n,r=0,s,a,l,u,h,m,v,x=i[0],S=i[1],w=e.length;for(t=0;t=0||a<=0&&u>=0)return 0}else if(h>=0&&l<=0||h<=0&&l>=0){if(s=Em(a,u,l,h,0,0),s===0)return 0;(s>0&&h>0&&l<=0||s<0&&h<=0&&l>0)&&r++}m=v,l=h,a=u}}return r%2!==0}function KQ(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return[...i.geometry.coordinates];if(i.type==="Point")return[...i.coordinates]}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return[...i];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ZQ(i){return i.type==="Feature"?i.geometry:i}function JQ(i,e,t={}){if(!i)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=KQ(i),r=ZQ(e),s=r.type,a=e.bbox;let l=r.coordinates;if(a&&eK(n,a)===!1)return!1;s==="Polygon"&&(l=[l]);let u=!1;for(var h=0;h=i[0]&&e[3]>=i[1]}var tK=JQ;const xR=1e-6;class Qf{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const r=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${r},${s}`:(Math.abs(this._x1-r)>xR||Math.abs(this._y1-s)>xR)&&(this._+="L"+r+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=s}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class UT{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class nK{constructor(e,[t,n,r,s]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this;let s,a;const l=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let N=0,C=0,E=n.length,O,U;N1;)s-=2;for(let a=2;a0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function oK(i,e,t){return[i+Math.sin(i+e)*t,e+Math.cos(i-e)*t]}class SM{static from(e,t=rK,n=sK,r){return new SM("length"in e?lK(e,t,n,r):Float64Array.from(uK(e,t,n,r)))}constructor(e){this._delaunator=new _g(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&aK(e)){this.collinear=Int32Array.from({length:t.length/2},(x,S)=>S).sort((x,S)=>t[2*x]-t[2*S]||t[2*x+1]-t[2*S+1]);const u=this.collinear[0],h=this.collinear[this.collinear.length-1],m=[t[2*u],t[2*u+1],t[2*h],t[2*h+1]],v=1e-8*Math.hypot(m[3]-m[1],m[2]-m[0]);for(let x=0,S=t.length/2;x0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new nK(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:s,triangles:a,collinear:l}=this;if(l){const v=l.indexOf(e);v>0&&(yield l[v-1]),v=0&&s!==n&&s!==r;)n=s;return s}_step(e,t,n){const{inedges:r,hull:s,_hullIndex:a,halfedges:l,triangles:u,points:h}=this;if(r[e]===-1||!h.length)return(e+1)%(h.length>>1);let m=e,v=CA(t-h[e*2],2)+CA(n-h[e*2+1],2);const x=r[e];let S=x;do{let w=u[S];const N=CA(t-h[w*2],2)+CA(n-h[w*2+1],2);if(N0?1:i<0?-1:0},_P=Math.sqrt;function AK(i){return i>1?bR:i<-1?-bR:Math.asin(i)}function yP(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function Do(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function q_(i,e){return[i[0]+e[0],i[1]+e[1],i[2]+e[2]]}function V_(i){var e=_P(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);return[i[0]/e,i[1]/e,i[2]/e]}function wM(i){return[cK(i[1],i[0])*SR,AK(hK(-1,fK(1,i[2])))*SR]}function gu(i){const e=i[0]*TR,t=i[1]*TR,n=wR(t);return[n*wR(e),n*MR(e),MR(t)]}function MM(i){return i=i.map(e=>gu(e)),yP(i[0],Do(i[2],i[1]))}function pK(i){const e=gK(i),t=_K(e),n=vK(t,i),r=xK(t,i.length),s=mK(r,i),a=yK(t,i),{polygons:l,centers:u}=bK(a,t,i),h=SK(l),m=wK(t,i),v=TK(n,t);return{delaunay:e,edges:n,triangles:t,centers:u,neighbors:r,polygons:l,mesh:h,hull:m,urquhart:v,find:s}}function mK(i,e){function t(n,r){let s=n[0]-r[0],a=n[1]-r[1],l=n[2]-r[2];return s*s+a*a+l*l}return function(r,s,a){a===void 0&&(a=0);let l,u,h=a;const m=gu([r,s]);do l=a,a=null,u=t(m,gu(e[l])),i[l].forEach(v=>{let x=t(m,gu(e[v]));if(x1e32?r.push(v):S>s&&(s=S)}const a=1e6*_P(s);r.forEach(v=>i[v]=[a,0]),i.push([0,a]),i.push([-a,0]),i.push([0,-a]);const l=SM.from(i);l.projection=n;const{triangles:u,halfedges:h,inedges:m}=l;for(let v=0,x=h.length;vi.length-3-1&&(u[v]=e);return l}function vK(i,e){const t=new Set;return e.length===2?[[0,1]]:(i.forEach(n=>{if(n[0]!==n[1]&&!(MM(n.map(r=>e[r]))<0))for(let r=0,s;r<3;r++)s=(r+1)%3,t.add(d_([n[r],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function _K(i){const{triangles:e}=i;if(!e)return[];const t=[];for(let n=0,r=e.length/3;n{const n=t.map(s=>e[s]).map(gu),r=q_(q_(Do(n[1],n[0]),Do(n[2],n[1])),Do(n[0],n[2]));return wM(V_(r))})}function xK(i,e){const t=[];return i.forEach(n=>{for(let r=0;r<3;r++){const s=n[r],a=n[(r+1)%3];t[s]=t[s]||[],t[s].push(a)}}),i.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function bK(i,e,t){const n=[],r=i.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:r};if(t.length===2){const l=gu(t[0]),u=gu(t[1]),h=V_(q_(l,u)),m=V_(Do(l,u)),v=Do(h,m),x=[h,Do(h,v),Do(Do(h,v),v),Do(Do(Do(h,v),v),v)].map(wM).map(a);return n.push(x),n.push(x.slice().reverse()),{polygons:n,centers:r}}}e.forEach((l,u)=>{for(let h=0;h<3;h++){const m=l[h],v=l[(h+1)%3],x=l[(h+2)%3];n[m]=n[m]||[],n[m].push([v,x,u,[m,v,x]])}});const s=n.map(l=>{const u=[l[0][2]];let h=l[0][1];for(let m=1;m2)return u;if(u.length==2){const m=ER(t[l[0][3][0]],t[l[0][3][1]],r[u[0]]),v=ER(t[l[0][3][2]],t[l[0][3][0]],r[u[0]]),x=a(m),S=a(v);return[u[0],S,u[1],x]}});function a(l){let u=-1;return r.slice(e.length,1/0).forEach((h,m)=>{h[0]===l[0]&&h[1]===l[1]&&(u=m+e.length)}),u<0&&(u=r.length,r.push(l)),u}return{polygons:s,centers:r}}function ER(i,e,t){i=gu(i),e=gu(e),t=gu(t);const n=dK(yP(Do(e,i),t));return wM(V_(q_(i,e)).map(r=>n*r))}function SK(i){const e=[];return i.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let r of t)r>n&&e.push([n,r]),n=r}),e}function TK(i,e){return function(t){const n=new Map,r=new Map;return i.forEach((s,a)=>{const l=s.join("-");n.set(l,t[a]),r.set(l,!0)}),e.forEach(s=>{let a=0,l=-1;for(let u=0;u<3;u++){let h=d_([s[u],s[(u+1)%3]]).join("-");n.get(h)>a&&(a=n.get(h),l=h)}r.set(l,!1)}),i.map(s=>r.get(s.join("-")))}}function wK(i,e){const t=new Set,n=[];i.map(l=>{if(!(MM(l.map(u=>e[u>e.length?0:u]))>1e-12))for(let u=0;u<3;u++){let h=[l[u],l[(u+1)%3]],m=`${h[0]}-${h[1]}`;t.has(m)?t.delete(m):t.add(`${h[1]}-${h[0]}`)}});const r=new Map;let s;if(t.forEach(l=>{l=l.split("-").map(Number),r.set(l[0],l[1]),s=l[0]}),s===void 0)return n;let a=s;do{n.push(a);let l=r.get(a);r.set(a,-1),a=l}while(a>-1&&a!==s);return n}function MK(i){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(r=>[e._vx(r),e._vy(r),r]).filter(r=>isFinite(r[0]+r[1]));e.points=n.map(r=>[r[0],r[1]]),e.valid=n.map(r=>r[2]),e.delaunay=pK(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return F5(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return F5(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((r,s)=>n.features.push({type:"Feature",geometry:r?{type:"Polygon",coordinates:[[...r,r[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,r)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[r],n)).filter(n=>MM(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>Yh(e.points[s[0]],e.points[s[1]])),r=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[a],urquhart:!!r[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:r}=e.delaunay,s=[];for(const a of r)if(a)for(let l=a.length,u=a[l-1],h=a[0],m=0;mu&&s.push([n[u],n[h]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,r){if(e._found=e.delaunay.find(t,n,e._found),!r||Yh([t,n],e.points[e._found])r[s]),r[n[0]]]]}},i?e(i):e}function BT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,n=t===void 0?1/0:t,r=zK(i,n),s=hg(r),a=GK(i,n),l=[].concat(H3(s),H3(a)),u={type:"Polygon",coordinates:i},h=qD(u),m=su(h,2),v=su(m[0],2),x=v[0],S=v[1],w=su(m[1],2),N=w[0],C=w[1],E=x>N||C>=89||S<=-89,O=[];if(E){var U=MK(l).triangles(),I=new Map(l.map(function(ae,Ae){var be=su(ae,2),Se=be[0],se=be[1];return["".concat(Se,"-").concat(se),Ae]}));U.features.forEach(function(ae){var Ae,be=ae.geometry.coordinates[0].slice(0,3).reverse(),Se=[];if(be.forEach(function(Ee){var qe=su(Ee,2),Ce=qe[0],ke=qe[1],Qe="".concat(Ce,"-").concat(ke);I.has(Qe)&&Se.push(I.get(Qe))}),Se.length===3){if(Se.some(function(Ee){return Eee)for(var l=gM(r,s),u=1/Math.ceil(a/e),h=u;h<1;)n.push(l(h)),h+=u}n.push(r=s)}),n})}function GK(i,e){var t={type:"Polygon",coordinates:i},n=qD(t),r=su(n,2),s=su(r[0],2),a=s[0],l=s[1],u=su(r[1],2),h=u[0],m=u[1];if(Math.min(Math.abs(h-a),Math.abs(m-l))h||m>=89||l<=-89;return qK(e,{minLng:a,maxLng:h,minLat:l,maxLat:m}).filter(function(x){return IT(x,t,v)})}function qK(i){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,n=e.maxLng,r=e.minLat,s=e.maxLat,a=Math.round(Math.pow(360/i,2)/Math.PI),l=(1+Math.sqrt(5))/2,u=function(E){return E/l*360%360-180},h=function(E){return Math.acos(2*E/a-1)/Math.PI*180-90},m=function(E){return a*(Math.cos((E+90)*Math.PI/180)+1)/2},v=[s!==void 0?Math.ceil(m(s)):0,r!==void 0?Math.floor(m(r)):a-1],x=t===void 0&&n===void 0?function(){return!0}:t===void 0?function(C){return C<=n}:n===void 0?function(C){return C>=t}:n>=t?function(C){return C>=t&&C<=n}:function(C){return C>=t||C<=n},S=[],w=v[0];w<=v[1];w++){var N=u(w);x(N)&&S.push([N,h(w)])}return S}function IT(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?xX(e,i):tK(i,e)}var Yv=window.THREE?window.THREE:{BufferGeometry:Ji,Float32BufferAttribute:Ci},CR=new Yv.BufferGeometry().setAttribute?"setAttribute":"addAttribute",EM=(function(i){function e(t,n,r,s,a,l,u){var h;DK(this,e),h=RK(this,e),h.type="ConicPolygonGeometry",h.parameters={polygonGeoJson:t,bottomHeight:n,topHeight:r,closedBottom:s,closedTop:a,includeSides:l,curvatureResolution:u},n=n||0,r=r||1,s=s!==void 0?s:!0,a=a!==void 0?a:!0,l=l!==void 0?l:!0,u=u||5;var m=kK(t,{resolution:u}),v=m.contour,x=m.triangles,S=hg(x.uvs),w=[],N=[],C=[],E=0,O=function(G){var W=Math.round(w.length/3),q=C.length;w=w.concat(G.vertices),N=N.concat(G.uvs),C=C.concat(W?G.indices.map(function(V){return V+W}):G.indices),h.addGroup(q,C.length-q,E++)};l&&O(I()),s&&O(j(n,!1)),a&&O(j(r,!0)),h.setIndex(C),h[CR]("position",new Yv.Float32BufferAttribute(w,3)),h[CR]("uv",new Yv.Float32BufferAttribute(N,2)),h.computeVertexNormals();function U(z,G){var W=typeof G=="function"?G:function(){return G},q=z.map(function(V){return V.map(function(Y){var te=su(Y,2),ne=te[0],le=te[1];return VK(le,ne,W(ne,le))})});return F_(q)}function I(){for(var z=U(v,n),G=z.vertices,W=z.holes,q=U(v,r),V=q.vertices,Y=hg([V,G]),te=Math.round(V.length/3),ne=new Set(W),le=0,Q=[],K=0;K=0;Se--)for(var se=0;se1&&arguments[1]!==void 0?arguments[1]:!0;return{indices:G?x.indices:x.indices.slice().reverse(),vertices:U([x.points],z).vertices,uvs:S}}return h}return LK(e,i),PK(e)})(Yv.BufferGeometry);function VK(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function FT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(l){return{keyAccessor:l,isProp:!(l instanceof Function)}}),s=i.reduce(function(l,u){var h=l,m=u;return r.forEach(function(v,x){var S=v.keyAccessor,w=v.isProp,N;if(w){var C=m,E=C[S],O=QK(C,[S].map(tZ));N=E,m=O}else N=S(m,x);x+11&&arguments[1]!==void 0?arguments[1]:1;h===r.length?Object.keys(u).forEach(function(m){return u[m]=t(u[m])}):Object.values(u).forEach(function(m){return l(m,h+1)})})(s);var a=s;return n&&(a=[],(function l(u){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];h.length===r.length?a.push({keys:h,vals:u}):Object.entries(u).forEach(function(m){var v=ZK(m,2),x=v[0],S=v[1];return l(S,[].concat(JK(h),[x]))})})(s),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a}),Mi=(function(i){i=i||{};var e=typeof i<"u"?i:{},t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r="";function s(Pe){return e.locateFile?e.locateFile(Pe,r):r+Pe}var a;typeof document<"u"&&document.currentScript&&(r=document.currentScript.src),r.indexOf("blob:")!==0?r=r.substr(0,r.lastIndexOf("/")+1):r="",a=function(at,ht,ot){var f=new XMLHttpRequest;f.open("GET",at,!0),f.responseType="arraybuffer",f.onload=function(){if(f.status==200||f.status==0&&f.response){ht(f.response);return}var _n=Te(at);if(_n){ht(_n.buffer);return}ot()},f.onerror=ot,f.send(null)};var l=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&e.arguments;var h=0,m=function(Pe){h=Pe},v=function(){return h},x=8;function S(Pe,at,ht,ot){switch(ht=ht||"i8",ht.charAt(ht.length-1)==="*"&&(ht="i32"),ht){case"i1":te[Pe>>0]=at;break;case"i8":te[Pe>>0]=at;break;case"i16":le[Pe>>1]=at;break;case"i32":Q[Pe>>2]=at;break;case"i64":Oe=[at>>>0,(Be=at,+dt(Be)>=1?Be>0?(wt(+en(Be/4294967296),4294967295)|0)>>>0:~~+he((Be-+(~~Be>>>0))/4294967296)>>>0:0)],Q[Pe>>2]=Oe[0],Q[Pe+4>>2]=Oe[1];break;case"float":K[Pe>>2]=at;break;case"double":ae[Pe>>3]=at;break;default:Zt("invalid type for setValue: "+ht)}}function w(Pe,at,ht){switch(at=at||"i8",at.charAt(at.length-1)==="*"&&(at="i32"),at){case"i1":return te[Pe>>0];case"i8":return te[Pe>>0];case"i16":return le[Pe>>1];case"i32":return Q[Pe>>2];case"i64":return Q[Pe>>2];case"float":return K[Pe>>2];case"double":return ae[Pe>>3];default:Zt("invalid type for getValue: "+at)}return null}var N=!1;function C(Pe,at){Pe||Zt("Assertion failed: "+at)}function E(Pe){var at=e["_"+Pe];return C(at,"Cannot call unknown function "+Pe+", make sure it is exported"),at}function O(Pe,at,ht,ot,f){var J={string:function(xn){var Ar=0;if(xn!=null&&xn!==0){var ji=(xn.length<<2)+1;Ar=Ze(ji),W(xn,Ar,ji)}return Ar},array:function(xn){var Ar=Ze(xn.length);return q(xn,Ar),Ar}};function _n(xn){return at==="string"?z(xn):at==="boolean"?!!xn:xn}var fn=E(Pe),zn=[],An=0;if(ot)for(var yn=0;yn=ot);)++f;if(f-at>16&&Pe.subarray&&I)return I.decode(Pe.subarray(at,f));for(var J="";at>10,56320|An&1023)}}return J}function z(Pe,at){return Pe?j(ne,Pe,at):""}function G(Pe,at,ht,ot){if(!(ot>0))return 0;for(var f=ht,J=ht+ot-1,_n=0;_n=55296&&fn<=57343){var zn=Pe.charCodeAt(++_n);fn=65536+((fn&1023)<<10)|zn&1023}if(fn<=127){if(ht>=J)break;at[ht++]=fn}else if(fn<=2047){if(ht+1>=J)break;at[ht++]=192|fn>>6,at[ht++]=128|fn&63}else if(fn<=65535){if(ht+2>=J)break;at[ht++]=224|fn>>12,at[ht++]=128|fn>>6&63,at[ht++]=128|fn&63}else{if(ht+3>=J)break;at[ht++]=240|fn>>18,at[ht++]=128|fn>>12&63,at[ht++]=128|fn>>6&63,at[ht++]=128|fn&63}}return at[ht]=0,ht-f}function W(Pe,at,ht){return G(Pe,ne,at,ht)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function q(Pe,at){te.set(Pe,at)}function V(Pe,at){return Pe%at>0&&(Pe+=at-Pe%at),Pe}var Y,te,ne,le,Q,K,ae;function Ae(Pe){Y=Pe,e.HEAP8=te=new Int8Array(Pe),e.HEAP16=le=new Int16Array(Pe),e.HEAP32=Q=new Int32Array(Pe),e.HEAPU8=ne=new Uint8Array(Pe),e.HEAPU16=new Uint16Array(Pe),e.HEAPU32=new Uint32Array(Pe),e.HEAPF32=K=new Float32Array(Pe),e.HEAPF64=ae=new Float64Array(Pe)}var be=5271536,Se=28624,se=e.TOTAL_MEMORY||33554432;e.buffer?Y=e.buffer:Y=new ArrayBuffer(se),se=Y.byteLength,Ae(Y),Q[Se>>2]=be;function Ee(Pe){for(;Pe.length>0;){var at=Pe.shift();if(typeof at=="function"){at();continue}var ht=at.func;typeof ht=="number"?at.arg===void 0?e.dynCall_v(ht):e.dynCall_vi(ht,at.arg):ht(at.arg===void 0?null:at.arg)}}var qe=[],Ce=[],ke=[],Qe=[];function et(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Tt(e.preRun.shift());Ee(qe)}function Pt(){Ee(Ce)}function Nt(){Ee(ke)}function Gt(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Ge(e.postRun.shift());Ee(Qe)}function Tt(Pe){qe.unshift(Pe)}function Ge(Pe){Qe.unshift(Pe)}var dt=Math.abs,he=Math.ceil,en=Math.floor,wt=Math.min,qt=0,Lt=null;function hn(Pe){qt++,e.monitorRunDependencies&&e.monitorRunDependencies(qt)}function ut(Pe){if(qt--,e.monitorRunDependencies&&e.monitorRunDependencies(qt),qt==0&&Lt){var at=Lt;Lt=null,at()}}e.preloadedImages={},e.preloadedAudios={};var fe=null,k="data:application/octet-stream;base64,";function _e(Pe){return String.prototype.startsWith?Pe.startsWith(k):Pe.indexOf(k)===0}var Be,Oe;fe="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var je=28640;function Bt(Pe,at,ht,ot){Zt("Assertion failed: "+z(Pe)+", at: "+[at?z(at):"unknown filename",ht,ot?z(ot):"unknown function"])}function yt(){return te.length}function Xt(Pe,at,ht){ne.set(ne.subarray(at,at+ht),Pe)}function ln(Pe){return e.___errno_location&&(Q[e.___errno_location()>>2]=Pe),Pe}function mt(Pe){Zt("OOM")}function Wt(Pe){try{var at=new ArrayBuffer(Pe);return at.byteLength!=Pe?void 0:(new Int8Array(at).set(te),xt(at),Ae(at),1)}catch{}}function Yt(Pe){var at=yt(),ht=16777216,ot=2147483648-ht;if(Pe>ot)return!1;for(var f=16777216,J=Math.max(at,f);J>4,f=(fn&15)<<4|zn>>2,J=(zn&3)<<6|An,ht=ht+String.fromCharCode(ot),zn!==64&&(ht=ht+String.fromCharCode(f)),An!==64&&(ht=ht+String.fromCharCode(J));while(yn13780509?(d=Zu(15,d)|0,d|0):(p=((A|0)<0)<<31>>31,y=vr(A|0,p|0,3,0)|0,_=ee()|0,p=rn(A|0,p|0,1,0)|0,p=vr(y|0,_|0,p|0,ee()|0)|0,p=rn(p|0,ee()|0,1,0)|0,A=ee()|0,f[d>>2]=p,f[d+4>>2]=A,d=0,d|0)}function qr(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,Er(A,d,p,_,0)|0}function Er(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0;if(B=Z,Z=Z+16|0,M=B,!(Ni(A,d,p,_,y)|0))return _=0,Z=B,_|0;do if((p|0)>=0){if((p|0)>13780509){if(T=Zu(15,M)|0,T|0)break;R=M,M=f[R>>2]|0,R=f[R+4>>2]|0}else T=((p|0)<0)<<31>>31,F=vr(p|0,T|0,3,0)|0,R=ee()|0,T=rn(p|0,T|0,1,0)|0,T=vr(F|0,R|0,T|0,ee()|0)|0,T=rn(T|0,ee()|0,1,0)|0,R=ee()|0,f[M>>2]=T,f[M+4>>2]=R,M=T;if(vo(_|0,0,M<<3|0)|0,y|0){vo(y|0,0,M<<2|0)|0,T=Yi(A,d,p,_,y,M,R,0)|0;break}T=sa(M,4)|0,T?(F=Yi(A,d,p,_,T,M,R,0)|0,wn(T),T=F):T=13}else T=2;while(!1);return F=T,Z=B,F|0}function Ni(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0;if(Ne=Z,Z=Z+16|0,pe=Ne,ge=Ne+8|0,me=pe,f[me>>2]=A,f[me+4>>2]=d,(p|0)<0)return ge=2,Z=Ne,ge|0;if(T=_,f[T>>2]=A,f[T+4>>2]=d,T=(y|0)!=0,T&&(f[y>>2]=0),Ri(A,d)|0)return ge=9,Z=Ne,ge|0;f[ge>>2]=0;e:do if((p|0)>=1)if(T)for(H=1,F=0,re=0,me=1,T=A;;){if(!(F|re)){if(T=_i(T,d,4,ge,pe)|0,T|0)break e;if(d=pe,T=f[d>>2]|0,d=f[d+4>>2]|0,Ri(T,d)|0){T=9;break e}}if(T=_i(T,d,f[26800+(re<<2)>>2]|0,ge,pe)|0,T|0)break e;if(d=pe,T=f[d>>2]|0,d=f[d+4>>2]|0,A=_+(H<<3)|0,f[A>>2]=T,f[A+4>>2]=d,f[y+(H<<2)>>2]=me,A=F+1|0,M=(A|0)==(me|0),R=re+1|0,B=(R|0)==6,Ri(T,d)|0){T=9;break e}if(me=me+(B&M&1)|0,(me|0)>(p|0)){T=0;break}else H=H+1|0,F=M?0:A,re=M?B?0:R:re}else for(H=1,F=0,re=0,me=1,T=A;;){if(!(F|re)){if(T=_i(T,d,4,ge,pe)|0,T|0)break e;if(d=pe,T=f[d>>2]|0,d=f[d+4>>2]|0,Ri(T,d)|0){T=9;break e}}if(T=_i(T,d,f[26800+(re<<2)>>2]|0,ge,pe)|0,T|0)break e;if(d=pe,T=f[d>>2]|0,d=f[d+4>>2]|0,A=_+(H<<3)|0,f[A>>2]=T,f[A+4>>2]=d,A=F+1|0,M=(A|0)==(me|0),R=re+1|0,B=(R|0)==6,Ri(T,d)|0){T=9;break e}if(me=me+(B&M&1)|0,(me|0)>(p|0)){T=0;break}else H=H+1|0,F=M?0:A,re=M?B?0:R:re}else T=0;while(!1);return ge=T,Z=Ne,ge|0}function Yi(A,d,p,_,y,T,M,R){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0,R=R|0;var B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0;if(Ne=Z,Z=Z+16|0,pe=Ne+8|0,ge=Ne,B=lc(A|0,d|0,T|0,M|0)|0,H=ee()|0,re=_+(B<<3)|0,Ie=re,Je=f[Ie>>2]|0,Ie=f[Ie+4>>2]|0,F=(Je|0)==(A|0)&(Ie|0)==(d|0),!((Je|0)==0&(Ie|0)==0|F))do B=rn(B|0,H|0,1,0)|0,B=oh(B|0,ee()|0,T|0,M|0)|0,H=ee()|0,re=_+(B<<3)|0,Je=re,Ie=f[Je>>2]|0,Je=f[Je+4>>2]|0,F=(Ie|0)==(A|0)&(Je|0)==(d|0);while(!((Ie|0)==0&(Je|0)==0|F));if(B=y+(B<<2)|0,F&&(f[B>>2]|0)<=(R|0)||(Je=re,f[Je>>2]=A,f[Je+4>>2]=d,f[B>>2]=R,(R|0)>=(p|0)))return Je=0,Z=Ne,Je|0;switch(F=R+1|0,f[pe>>2]=0,B=_i(A,d,2,pe,ge)|0,B|0){case 9:{me=9;break}case 0:{B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B||(me=9);break}}e:do if((me|0)==9){switch(f[pe>>2]=0,B=_i(A,d,3,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}switch(f[pe>>2]=0,B=_i(A,d,1,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}switch(f[pe>>2]=0,B=_i(A,d,5,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}switch(f[pe>>2]=0,B=_i(A,d,4,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}switch(f[pe>>2]=0,B=_i(A,d,6,pe,ge)|0,B|0){case 9:break;case 0:{if(B=ge,B=Yi(f[B>>2]|0,f[B+4>>2]|0,p,_,y,T,M,F)|0,B|0)break e;break}default:break e}return Je=0,Z=Ne,Je|0}while(!1);return Je=B,Z=Ne,Je|0}function _i(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0;if(p>>>0>6)return y=1,y|0;if(re=(f[_>>2]|0)%6|0,f[_>>2]=re,(re|0)>0){T=0;do p=qu(p)|0,T=T+1|0;while((T|0)<(f[_>>2]|0))}if(re=Ut(A|0,d|0,45)|0,ee()|0,H=re&127,H>>>0>121)return y=5,y|0;B=ta(A,d)|0,T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15;e:do if(!T)F=8;else{for(;;){if(M=(15-T|0)*3|0,R=Ut(A|0,d|0,M|0)|0,ee()|0,R=R&7,(R|0)==7){d=5;break}if(ge=(Ps(T)|0)==0,T=T+-1|0,me=zt(7,0,M|0)|0,d=d&~(ee()|0),pe=zt(f[(ge?432:16)+(R*28|0)+(p<<2)>>2]|0,0,M|0)|0,M=ee()|0,p=f[(ge?640:224)+(R*28|0)+(p<<2)>>2]|0,A=pe|A&~me,d=M|d,!p){p=0;break e}if(!T){F=8;break e}}return d|0}while(!1);(F|0)==8&&(ge=f[848+(H*28|0)+(p<<2)>>2]|0,pe=zt(ge|0,0,45)|0,A=pe|A,d=ee()|0|d&-1040385,p=f[4272+(H*28|0)+(p<<2)>>2]|0,(ge&127|0)==127&&(ge=zt(f[848+(H*28|0)+20>>2]|0,0,45)|0,d=ee()|0|d&-1040385,p=f[4272+(H*28|0)+20>>2]|0,A=$u(ge|A,d)|0,d=ee()|0,f[_>>2]=(f[_>>2]|0)+1)),R=Ut(A|0,d|0,45)|0,ee()|0,R=R&127;e:do if($n(R)|0){t:do if((ta(A,d)|0)==1){if((H|0)!=(R|0))if(yi(R,f[7696+(H*28|0)>>2]|0)|0){A=fp(A,d)|0,M=1,d=ee()|0;break}else Vt(27795,26864,533,26872);switch(B|0){case 3:{A=$u(A,d)|0,d=ee()|0,f[_>>2]=(f[_>>2]|0)+1,M=0;break t}case 5:{A=fp(A,d)|0,d=ee()|0,f[_>>2]=(f[_>>2]|0)+5,M=0;break t}case 0:return ge=9,ge|0;default:return ge=1,ge|0}}else M=0;while(!1);if((p|0)>0){T=0;do A=hp(A,d)|0,d=ee()|0,T=T+1|0;while((T|0)!=(p|0))}if((H|0)!=(R|0)){if(!(or(R)|0)){if((M|0)!=0|(ta(A,d)|0)!=5)break;f[_>>2]=(f[_>>2]|0)+1;break}switch(re&127){case 8:case 118:break e}(ta(A,d)|0)!=3&&(f[_>>2]=(f[_>>2]|0)+1)}}else if((p|0)>0){T=0;do A=$u(A,d)|0,d=ee()|0,T=T+1|0;while((T|0)!=(p|0))}while(!1);return f[_>>2]=((f[_>>2]|0)+p|0)%6|0,ge=y,f[ge>>2]=A,f[ge+4>>2]=d,ge=0,ge|0}function pr(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,Vr(A,d,p,_)|0?(vo(_|0,0,p*48|0)|0,_=hl(A,d,p,_)|0,_|0):(_=0,_|0)}function Vr(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0;if(ge=Z,Z=Z+16|0,me=ge,pe=ge+8|0,re=me,f[re>>2]=A,f[re+4>>2]=d,(p|0)<0)return pe=2,Z=ge,pe|0;if(!p)return pe=_,f[pe>>2]=A,f[pe+4>>2]=d,pe=0,Z=ge,pe|0;f[pe>>2]=0;e:do if(Ri(A,d)|0)A=9;else{y=0,re=A;do{if(A=_i(re,d,4,pe,me)|0,A|0)break e;if(d=me,re=f[d>>2]|0,d=f[d+4>>2]|0,y=y+1|0,Ri(re,d)|0){A=9;break e}}while((y|0)<(p|0));H=_,f[H>>2]=re,f[H+4>>2]=d,H=p+-1|0,F=0,A=1;do{if(y=26800+(F<<2)|0,(F|0)==5)for(M=f[y>>2]|0,T=0,y=A;;){if(A=me,A=_i(f[A>>2]|0,f[A+4>>2]|0,M,pe,me)|0,A|0)break e;if((T|0)!=(H|0))if(B=me,R=f[B>>2]|0,B=f[B+4>>2]|0,A=_+(y<<3)|0,f[A>>2]=R,f[A+4>>2]=B,!(Ri(R,B)|0))A=y+1|0;else{A=9;break e}else A=y;if(T=T+1|0,(T|0)>=(p|0))break;y=A}else for(M=me,B=f[y>>2]|0,R=0,y=A,T=f[M>>2]|0,M=f[M+4>>2]|0;;){if(A=_i(T,M,B,pe,me)|0,A|0)break e;if(M=me,T=f[M>>2]|0,M=f[M+4>>2]|0,A=_+(y<<3)|0,f[A>>2]=T,f[A+4>>2]=M,A=y+1|0,Ri(T,M)|0){A=9;break e}if(R=R+1|0,(R|0)>=(p|0))break;y=A}F=F+1|0}while(F>>>0<6);A=me,A=(re|0)==(f[A>>2]|0)&&(d|0)==(f[A+4>>2]|0)?0:9}while(!1);return pe=A,Z=ge,pe|0}function hl(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;if(re=Z,Z=Z+16|0,M=re,!p)return f[_>>2]=A,f[_+4>>2]=d,_=0,Z=re,_|0;do if((p|0)>=0){if((p|0)>13780509){if(y=Zu(15,M)|0,y|0)break;T=M,y=f[T>>2]|0,T=f[T+4>>2]|0}else y=((p|0)<0)<<31>>31,H=vr(p|0,y|0,3,0)|0,T=ee()|0,y=rn(p|0,y|0,1,0)|0,y=vr(H|0,T|0,y|0,ee()|0)|0,y=rn(y|0,ee()|0,1,0)|0,T=ee()|0,H=M,f[H>>2]=y,f[H+4>>2]=T;if(F=sa(y,8)|0,!F)y=13;else{if(H=sa(y,4)|0,!H){wn(F),y=13;break}if(y=Yi(A,d,p,F,H,y,T,0)|0,y|0){wn(F),wn(H);break}if(d=f[M>>2]|0,M=f[M+4>>2]|0,(M|0)>0|(M|0)==0&d>>>0>0){y=0,R=0,B=0;do A=F+(R<<3)|0,T=f[A>>2]|0,A=f[A+4>>2]|0,!((T|0)==0&(A|0)==0)&&(f[H+(R<<2)>>2]|0)==(p|0)&&(me=_+(y<<3)|0,f[me>>2]=T,f[me+4>>2]=A,y=y+1|0),R=rn(R|0,B|0,1,0)|0,B=ee()|0;while((B|0)<(M|0)|(B|0)==(M|0)&R>>>0>>0)}wn(F),wn(H),y=0}}else y=2;while(!1);return me=y,Z=re,me|0}function ts(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;for(R=Z,Z=Z+16|0,T=R,M=R+8|0,y=(Ri(A,d)|0)==0,y=y?1:2;;){if(f[M>>2]=0,F=(_i(A,d,y,M,T)|0)==0,B=T,F&((f[B>>2]|0)==(p|0)?(f[B+4>>2]|0)==(_|0):0)){A=4;break}if(y=y+1|0,y>>>0>=7){y=7,A=4;break}}return(A|0)==4?(Z=R,y|0):0}function Md(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;if(R=Z,Z=Z+48|0,y=R+16|0,T=R+8|0,M=R,p=Ba(p)|0,p|0)return M=p,Z=R,M|0;if(F=A,B=f[F+4>>2]|0,p=T,f[p>>2]=f[F>>2],f[p+4>>2]=B,ba(T,y),p=lf(y,d,M)|0,!p){if(d=f[T>>2]|0,T=f[A+8>>2]|0,(T|0)>0){y=f[A+12>>2]|0,p=0;do d=(f[y+(p<<3)>>2]|0)+d|0,p=p+1|0;while((p|0)<(T|0))}p=M,y=f[p>>2]|0,p=f[p+4>>2]|0,T=((d|0)<0)<<31>>31,(p|0)<(T|0)|(p|0)==(T|0)&y>>>0>>0?(p=M,f[p>>2]=d,f[p+4>>2]=T,p=T):d=y,B=rn(d|0,p|0,12,0)|0,F=ee()|0,p=M,f[p>>2]=B,f[p+4>>2]=F,p=_,f[p>>2]=B,f[p+4>>2]=F,p=0}return F=p,Z=R,F|0}function xe(A,d,p,_,y,T,M){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0;var R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0,Cn=0,li=0,Ln=0,Di=0,Us=0,Sl=0;if(li=Z,Z=Z+64|0,Pn=li+48|0,gn=li+32|0,Ht=li+24|0,jt=li+8|0,pn=li,B=f[A>>2]|0,(B|0)<=0)return Cn=0,Z=li,Cn|0;for(cn=A+4|0,jn=Pn+8|0,Bn=gn+8|0,ei=jt+8|0,R=0,Ve=0;;){F=f[cn>>2]|0,He=F+(Ve<<4)|0,f[Pn>>2]=f[He>>2],f[Pn+4>>2]=f[He+4>>2],f[Pn+8>>2]=f[He+8>>2],f[Pn+12>>2]=f[He+12>>2],(Ve|0)==(B+-1|0)?(f[gn>>2]=f[F>>2],f[gn+4>>2]=f[F+4>>2],f[gn+8>>2]=f[F+8>>2],f[gn+12>>2]=f[F+12>>2]):(He=F+(Ve+1<<4)|0,f[gn>>2]=f[He>>2],f[gn+4>>2]=f[He+4>>2],f[gn+8>>2]=f[He+8>>2],f[gn+12>>2]=f[He+12>>2]),B=o1(Pn,gn,_,Ht)|0;e:do if(B)F=0,R=B;else if(B=Ht,F=f[B>>2]|0,B=f[B+4>>2]|0,(B|0)>0|(B|0)==0&F>>>0>0){Je=0,He=0;t:for(;;){if(Di=1/(+(F>>>0)+4294967296*+(B|0)),Sl=+J[Pn>>3],B=Hr(F|0,B|0,Je|0,He|0)|0,Us=+(B>>>0)+4294967296*+(ee()|0),Ln=+(Je>>>0)+4294967296*+(He|0),J[jt>>3]=Di*(Sl*Us)+Di*(+J[gn>>3]*Ln),J[ei>>3]=Di*(+J[jn>>3]*Us)+Di*(+J[Bn>>3]*Ln),B=Bd(jt,_,pn)|0,B|0){R=B;break}Ie=pn,Ne=f[Ie>>2]|0,Ie=f[Ie+4>>2]|0,me=lc(Ne|0,Ie|0,d|0,p|0)|0,H=ee()|0,B=M+(me<<3)|0,re=B,F=f[re>>2]|0,re=f[re+4>>2]|0;n:do if((F|0)==0&(re|0)==0)Re=B,Cn=16;else for(pe=0,ge=0;;){if((pe|0)>(p|0)|(pe|0)==(p|0)&ge>>>0>d>>>0){R=1;break t}if((F|0)==(Ne|0)&(re|0)==(Ie|0))break n;if(B=rn(me|0,H|0,1,0)|0,me=oh(B|0,ee()|0,d|0,p|0)|0,H=ee()|0,ge=rn(ge|0,pe|0,1,0)|0,pe=ee()|0,B=M+(me<<3)|0,re=B,F=f[re>>2]|0,re=f[re+4>>2]|0,(F|0)==0&(re|0)==0){Re=B,Cn=16;break}}while(!1);if((Cn|0)==16&&(Cn=0,!((Ne|0)==0&(Ie|0)==0))&&(ge=Re,f[ge>>2]=Ne,f[ge+4>>2]=Ie,ge=T+(f[y>>2]<<3)|0,f[ge>>2]=Ne,f[ge+4>>2]=Ie,ge=y,ge=rn(f[ge>>2]|0,f[ge+4>>2]|0,1,0)|0,Ne=ee()|0,Ie=y,f[Ie>>2]=ge,f[Ie+4>>2]=Ne),Je=rn(Je|0,He|0,1,0)|0,He=ee()|0,B=Ht,F=f[B>>2]|0,B=f[B+4>>2]|0,!((B|0)>(He|0)|(B|0)==(He|0)&F>>>0>Je>>>0)){F=1;break e}}F=0}else F=1;while(!1);if(Ve=Ve+1|0,!F){Cn=21;break}if(B=f[A>>2]|0,(Ve|0)>=(B|0)){R=0,Cn=21;break}}return(Cn|0)==21?(Z=li,R|0):0}function Rt(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0,Cn=0,li=0,Ln=0,Di=0,Us=0;if(Us=Z,Z=Z+112|0,Cn=Us+80|0,B=Us+72|0,li=Us,Ln=Us+56|0,y=Ba(p)|0,y|0)return Di=y,Z=Us,Di|0;if(F=A+8|0,Di=$o((f[F>>2]<<5)+32|0)|0,!Di)return Di=13,Z=Us,Di|0;if(Oa(A,Di),y=Ba(p)|0,!y){if(gn=A,Ht=f[gn+4>>2]|0,y=B,f[y>>2]=f[gn>>2],f[y+4>>2]=Ht,ba(B,Cn),y=lf(Cn,d,li)|0,y)gn=0,Ht=0;else{if(y=f[B>>2]|0,T=f[F>>2]|0,(T|0)>0){M=f[A+12>>2]|0,p=0;do y=(f[M+(p<<3)>>2]|0)+y|0,p=p+1|0;while((p|0)!=(T|0));p=y}else p=y;y=li,T=f[y>>2]|0,y=f[y+4>>2]|0,M=((p|0)<0)<<31>>31,(y|0)<(M|0)|(y|0)==(M|0)&T>>>0

>>0?(y=li,f[y>>2]=p,f[y+4>>2]=M,y=M):p=T,gn=rn(p|0,y|0,12,0)|0,Ht=ee()|0,y=li,f[y>>2]=gn,f[y+4>>2]=Ht,y=0}if(!y){if(p=sa(gn,8)|0,!p)return wn(Di),Di=13,Z=Us,Di|0;if(R=sa(gn,8)|0,!R)return wn(Di),wn(p),Di=13,Z=Us,Di|0;ei=Cn,f[ei>>2]=0,f[ei+4>>2]=0,ei=A,Pn=f[ei+4>>2]|0,y=B,f[y>>2]=f[ei>>2],f[y+4>>2]=Pn,y=xe(B,gn,Ht,d,Cn,p,R)|0;e:do if(y)wn(p),wn(R),wn(Di);else{t:do if((f[F>>2]|0)>0){for(M=A+12|0,T=0;y=xe((f[M>>2]|0)+(T<<3)|0,gn,Ht,d,Cn,p,R)|0,T=T+1|0,!(y|0);)if((T|0)>=(f[F>>2]|0))break t;wn(p),wn(R),wn(Di);break e}while(!1);(Ht|0)>0|(Ht|0)==0&gn>>>0>0&&vo(R|0,0,gn<<3|0)|0,Pn=Cn,ei=f[Pn+4>>2]|0;t:do if((ei|0)>0|(ei|0)==0&(f[Pn>>2]|0)>>>0>0){cn=p,jn=R,Bn=p,ei=R,Pn=p,y=p,Re=p,jt=R,pn=R,p=R;n:for(;;){for(Ie=0,Je=0,He=0,Ve=0,T=0,M=0;;){R=li,B=R+56|0;do f[R>>2]=0,R=R+4|0;while((R|0)<(B|0));if(d=cn+(Ie<<3)|0,F=f[d>>2]|0,d=f[d+4>>2]|0,Ni(F,d,1,li,0)|0){R=li,B=R+56|0;do f[R>>2]=0,R=R+4|0;while((R|0)<(B|0));R=sa(7,4)|0,R|0&&(Yi(F,d,1,li,R,7,0,0)|0,wn(R))}for(Ne=0;;){ge=li+(Ne<<3)|0,pe=f[ge>>2]|0,ge=f[ge+4>>2]|0;i:do if((pe|0)==0&(ge|0)==0)R=T,B=M;else{if(H=lc(pe|0,ge|0,gn|0,Ht|0)|0,F=ee()|0,R=_+(H<<3)|0,d=R,B=f[d>>2]|0,d=f[d+4>>2]|0,!((B|0)==0&(d|0)==0)){re=0,me=0;do{if((re|0)>(Ht|0)|(re|0)==(Ht|0)&me>>>0>gn>>>0)break n;if((B|0)==(pe|0)&(d|0)==(ge|0)){R=T,B=M;break i}R=rn(H|0,F|0,1,0)|0,H=oh(R|0,ee()|0,gn|0,Ht|0)|0,F=ee()|0,me=rn(me|0,re|0,1,0)|0,re=ee()|0,R=_+(H<<3)|0,d=R,B=f[d>>2]|0,d=f[d+4>>2]|0}while(!((B|0)==0&(d|0)==0))}if((pe|0)==0&(ge|0)==0){R=T,B=M;break}jl(pe,ge,Ln)|0,Ia(A,Di,Ln)|0&&(me=rn(T|0,M|0,1,0)|0,M=ee()|0,re=R,f[re>>2]=pe,f[re+4>>2]=ge,T=jn+(T<<3)|0,f[T>>2]=pe,f[T+4>>2]=ge,T=me),R=T,B=M}while(!1);if(Ne=Ne+1|0,Ne>>>0>=7)break;T=R,M=B}if(Ie=rn(Ie|0,Je|0,1,0)|0,Je=ee()|0,He=rn(He|0,Ve|0,1,0)|0,Ve=ee()|0,M=Cn,T=f[M>>2]|0,M=f[M+4>>2]|0,(Ve|0)<(M|0)|(Ve|0)==(M|0)&He>>>0>>0)T=R,M=B;else break}if((M|0)>0|(M|0)==0&T>>>0>0){T=0,M=0;do Ve=cn+(T<<3)|0,f[Ve>>2]=0,f[Ve+4>>2]=0,T=rn(T|0,M|0,1,0)|0,M=ee()|0,Ve=Cn,He=f[Ve+4>>2]|0;while((M|0)<(He|0)|((M|0)==(He|0)?T>>>0<(f[Ve>>2]|0)>>>0:0))}if(Ve=Cn,f[Ve>>2]=R,f[Ve+4>>2]=B,(B|0)>0|(B|0)==0&R>>>0>0)Ne=p,Ie=pn,Je=Pn,He=jt,Ve=jn,p=Re,pn=y,jt=Bn,Re=Ne,y=Ie,Pn=ei,ei=Je,Bn=He,jn=cn,cn=Ve;else break t}wn(Bn),wn(ei),wn(Di),y=1;break e}else y=R;while(!1);wn(Di),wn(p),wn(y),y=0}while(!1);return Di=y,Z=Us,Di|0}}return wn(Di),Di=y,Z=Us,Di|0}function nn(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(H=Z,Z=Z+176|0,B=H,(d|0)<1)return Wo(p,0,0),F=0,Z=H,F|0;for(R=A,R=Ut(f[R>>2]|0,f[R+4>>2]|0,52)|0,ee()|0,Wo(p,(d|0)>6?d:6,R&15),R=0;_=A+(R<<3)|0,_=Hl(f[_>>2]|0,f[_+4>>2]|0,B)|0,!(_|0);){if(_=f[B>>2]|0,(_|0)>0){M=0;do T=B+8+(M<<4)|0,M=M+1|0,_=B+8+(((M|0)%(_|0)|0)<<4)|0,y=ac(p,_,T)|0,y?sc(p,y)|0:Wd(p,T,_)|0,_=f[B>>2]|0;while((M|0)<(_|0))}if(R=R+1|0,(R|0)>=(d|0)){_=0,F=13;break}}return(F|0)==13?(Z=H,_|0):(jd(p),F=_,Z=H,F|0)}function fi(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;if(T=Z,Z=Z+32|0,_=T,y=T+16|0,A=nn(A,d,y)|0,A|0)return p=A,Z=T,p|0;if(f[p>>2]=0,f[p+4>>2]=0,f[p+8>>2]=0,A=Hd(y)|0,A|0)do{d=E1(p)|0;do kd(d,A)|0,M=A+16|0,f[_>>2]=f[M>>2],f[_+4>>2]=f[M+4>>2],f[_+8>>2]=f[M+8>>2],f[_+12>>2]=f[M+12>>2],sc(y,A)|0,A=bs(y,_)|0;while((A|0)!=0);A=Hd(y)|0}while((A|0)!=0);return jd(y),A=Nx(p)|0,A?(ec(p),M=A,Z=T,M|0):(M=0,Z=T,M|0)}function $n(A){return A=A|0,A>>>0>121?(A=0,A|0):(A=f[7696+(A*28|0)+16>>2]|0,A|0)}function or(A){return A=A|0,(A|0)==4|(A|0)==117|0}function er(A){return A=A|0,f[11120+((f[A>>2]|0)*216|0)+((f[A+4>>2]|0)*72|0)+((f[A+8>>2]|0)*24|0)+(f[A+12>>2]<<3)>>2]|0}function po(A){return A=A|0,f[11120+((f[A>>2]|0)*216|0)+((f[A+4>>2]|0)*72|0)+((f[A+8>>2]|0)*24|0)+(f[A+12>>2]<<3)+4>>2]|0}function Cr(A,d){A=A|0,d=d|0,A=7696+(A*28|0)|0,f[d>>2]=f[A>>2],f[d+4>>2]=f[A+4>>2],f[d+8>>2]=f[A+8>>2],f[d+12>>2]=f[A+12>>2]}function lr(A,d){A=A|0,d=d|0;var p=0,_=0;if(d>>>0>20)return d=-1,d|0;do if((f[11120+(d*216|0)>>2]|0)!=(A|0))if((f[11120+(d*216|0)+8>>2]|0)!=(A|0))if((f[11120+(d*216|0)+16>>2]|0)!=(A|0))if((f[11120+(d*216|0)+24>>2]|0)!=(A|0))if((f[11120+(d*216|0)+32>>2]|0)!=(A|0))if((f[11120+(d*216|0)+40>>2]|0)!=(A|0))if((f[11120+(d*216|0)+48>>2]|0)!=(A|0))if((f[11120+(d*216|0)+56>>2]|0)!=(A|0))if((f[11120+(d*216|0)+64>>2]|0)!=(A|0))if((f[11120+(d*216|0)+72>>2]|0)!=(A|0))if((f[11120+(d*216|0)+80>>2]|0)!=(A|0))if((f[11120+(d*216|0)+88>>2]|0)!=(A|0))if((f[11120+(d*216|0)+96>>2]|0)!=(A|0))if((f[11120+(d*216|0)+104>>2]|0)!=(A|0))if((f[11120+(d*216|0)+112>>2]|0)!=(A|0))if((f[11120+(d*216|0)+120>>2]|0)!=(A|0))if((f[11120+(d*216|0)+128>>2]|0)!=(A|0))if((f[11120+(d*216|0)+136>>2]|0)==(A|0))A=2,p=1,_=2;else{if((f[11120+(d*216|0)+144>>2]|0)==(A|0)){A=0,p=2,_=0;break}if((f[11120+(d*216|0)+152>>2]|0)==(A|0)){A=0,p=2,_=1;break}if((f[11120+(d*216|0)+160>>2]|0)==(A|0)){A=0,p=2,_=2;break}if((f[11120+(d*216|0)+168>>2]|0)==(A|0)){A=1,p=2,_=0;break}if((f[11120+(d*216|0)+176>>2]|0)==(A|0)){A=1,p=2,_=1;break}if((f[11120+(d*216|0)+184>>2]|0)==(A|0)){A=1,p=2,_=2;break}if((f[11120+(d*216|0)+192>>2]|0)==(A|0)){A=2,p=2,_=0;break}if((f[11120+(d*216|0)+200>>2]|0)==(A|0)){A=2,p=2,_=1;break}if((f[11120+(d*216|0)+208>>2]|0)==(A|0)){A=2,p=2,_=2;break}else A=-1;return A|0}else A=2,p=1,_=1;else A=2,p=1,_=0;else A=1,p=1,_=2;else A=1,p=1,_=1;else A=1,p=1,_=0;else A=0,p=1,_=2;else A=0,p=1,_=1;else A=0,p=1,_=0;else A=2,p=0,_=2;else A=2,p=0,_=1;else A=2,p=0,_=0;else A=1,p=0,_=2;else A=1,p=0,_=1;else A=1,p=0,_=0;else A=0,p=0,_=2;else A=0,p=0,_=1;else A=0,p=0,_=0;while(!1);return d=f[11120+(d*216|0)+(p*72|0)+(A*24|0)+(_<<3)+4>>2]|0,d|0}function yi(A,d){return A=A|0,d=d|0,(f[7696+(A*28|0)+20>>2]|0)==(d|0)?(d=1,d|0):(d=(f[7696+(A*28|0)+24>>2]|0)==(d|0),d|0)}function Iu(A,d){return A=A|0,d=d|0,f[848+(A*28|0)+(d<<2)>>2]|0}function zo(A,d){return A=A|0,d=d|0,(f[848+(A*28|0)>>2]|0)==(d|0)?(d=0,d|0):(f[848+(A*28|0)+4>>2]|0)==(d|0)?(d=1,d|0):(f[848+(A*28|0)+8>>2]|0)==(d|0)?(d=2,d|0):(f[848+(A*28|0)+12>>2]|0)==(d|0)?(d=3,d|0):(f[848+(A*28|0)+16>>2]|0)==(d|0)?(d=4,d|0):(f[848+(A*28|0)+20>>2]|0)==(d|0)?(d=5,d|0):((f[848+(A*28|0)+24>>2]|0)==(d|0)?6:7)|0}function Go(){return 122}function fl(A){A=A|0;var d=0,p=0,_=0;d=0;do zt(d|0,0,45)|0,_=ee()|0|134225919,p=A+(d<<3)|0,f[p>>2]=-1,f[p+4>>2]=_,d=d+1|0;while((d|0)!=122);return 0}function dl(A){A=A|0;var d=0,p=0,_=0;return _=+J[A+16>>3],p=+J[A+24>>3],d=_-p,+(_>3]<+J[A+24>>3]|0}function sf(A){return A=A|0,+(+J[A>>3]-+J[A+8>>3])}function qo(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;return p=+J[d>>3],!(p>=+J[A+8>>3])||!(p<=+J[A>>3])?(d=0,d|0):(_=+J[A+16>>3],p=+J[A+24>>3],y=+J[d+8>>3],d=y>=p,A=y<=_&1,_>3]<+J[d+8>>3]||+J[A+8>>3]>+J[d>>3]?(_=0,_|0):(T=+J[A+16>>3],p=A+24|0,H=+J[p>>3],M=T>3],y=d+24|0,B=+J[y>>3],R=F>3],d)||(H=+na(+J[p>>3],A),H>+na(+J[_>>3],d))?(R=0,R|0):(R=1,R|0))}function Cd(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0;T=+J[A+16>>3],B=+J[A+24>>3],A=T>3],M=+J[d+24>>3],y=R>2]=A?y|d?1:2:0,f[_>>2]=y?A?1:d?2:1:0}function ip(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;return+J[A>>3]<+J[d>>3]||+J[A+8>>3]>+J[d+8>>3]?(_=0,_|0):(_=A+16|0,B=+J[_>>3],T=+J[A+24>>3],M=B>3],y=d+24|0,F=+J[y>>3],R=H>3],d)?(H=+na(+J[_>>3],A),R=H>=+na(+J[p>>3],d),R|0):(R=0,R|0))}function of(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0;y=Z,Z=Z+176|0,_=y,f[_>>2]=4,R=+J[d>>3],J[_+8>>3]=R,T=+J[d+16>>3],J[_+16>>3]=T,J[_+24>>3]=R,R=+J[d+24>>3],J[_+32>>3]=R,M=+J[d+8>>3],J[_+40>>3]=M,J[_+48>>3]=R,J[_+56>>3]=M,J[_+64>>3]=T,d=_+72|0,p=d+96|0;do f[d>>2]=0,d=d+4|0;while((d|0)<(p|0));Yl(A|0,_|0,168)|0,Z=y}function lf(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0;ge=Z,Z=Z+288|0,H=ge+264|0,re=ge+96|0,F=ge,R=F,B=R+96|0;do f[R>>2]=0,R=R+4|0;while((R|0)<(B|0));return d=Qu(d,F)|0,d|0?(pe=d,Z=ge,pe|0):(B=F,F=f[B>>2]|0,B=f[B+4>>2]|0,jl(F,B,H)|0,Hl(F,B,re)|0,M=+rh(H,re+8|0),J[H>>3]=+J[A>>3],B=H+8|0,J[B>>3]=+J[A+16>>3],J[re>>3]=+J[A+8>>3],F=re+8|0,J[F>>3]=+J[A+24>>3],y=+rh(H,re),Ie=+J[B>>3]-+J[F>>3],T=+An(+Ie),Ne=+J[H>>3]-+J[re>>3],_=+An(+Ne),!(Ie==0|Ne==0)&&(Ie=+mf(+T,+_),Ie=+tt(+(y*y/+gf(+(Ie/+gf(+T,+_)),3)/(M*(M*2.59807621135)*.8))),J[_n>>3]=Ie,me=~~Ie>>>0,pe=+An(Ie)>=1?Ie>0?~~+ze(+zn(Ie/4294967296),4294967295)>>>0:~~+tt((Ie-+(~~Ie>>>0))/4294967296)>>>0:0,(f[_n+4>>2]&2146435072|0)!=2146435072)?(re=(me|0)==0&(pe|0)==0,d=p,f[d>>2]=re?1:me,f[d+4>>2]=re?0:pe,d=0):d=1,pe=d,Z=ge,pe|0)}function o1(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0;F=Z,Z=Z+288|0,M=F+264|0,R=F+96|0,B=F,y=B,T=y+96|0;do f[y>>2]=0,y=y+4|0;while((y|0)<(T|0));return p=Qu(p,B)|0,p|0?(_=p,Z=F,_|0):(p=B,y=f[p>>2]|0,p=f[p+4>>2]|0,jl(y,p,M)|0,Hl(y,p,R)|0,H=+rh(M,R+8|0),H=+tt(+(+rh(A,d)/(H*2))),J[_n>>3]=H,p=~~H>>>0,y=+An(H)>=1?H>0?~~+ze(+zn(H/4294967296),4294967295)>>>0:~~+tt((H-+(~~H>>>0))/4294967296)>>>0:0,(f[_n+4>>2]&2146435072|0)==2146435072?(_=1,Z=F,_|0):(B=(p|0)==0&(y|0)==0,f[_>>2]=B?1:p,f[_+4>>2]=B?0:y,_=0,Z=F,_|0))}function ea(A,d){A=A|0,d=+d;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;T=A+16|0,M=+J[T>>3],p=A+24|0,y=+J[p>>3],_=M-y,_=M>3],R=A+8|0,B=+J[R>>3],H=F-B,_=(_*d-_)*.5,d=(H*d-H)*.5,F=F+d,J[A>>3]=F>1.5707963267948966?1.5707963267948966:F,d=B-d,J[R>>3]=d<-1.5707963267948966?-1.5707963267948966:d,d=M+_,d=d>3.141592653589793?d+-6.283185307179586:d,J[T>>3]=d<-3.141592653589793?d+6.283185307179586:d,d=y-_,d=d>3.141592653589793?d+-6.283185307179586:d,J[p>>3]=d<-3.141592653589793?d+6.283185307179586:d}function Fu(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0,f[A>>2]=d,f[A+4>>2]=p,f[A+8>>2]=_}function Nd(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;re=d+8|0,f[re>>2]=0,B=+J[A>>3],M=+An(+B),F=+J[A+8>>3],R=+An(+F)*1.1547005383792515,M=M+R*.5,p=~~M,A=~~R,M=M-+(p|0),R=R-+(A|0);do if(M<.5)if(M<.3333333333333333)if(f[d>>2]=p,R<(M+1)*.5){f[d+4>>2]=A;break}else{A=A+1|0,f[d+4>>2]=A;break}else if(me=1-M,A=(!(R>2]=A,me<=R&R>2]=p;break}else{f[d>>2]=p;break}else{if(!(M<.6666666666666666))if(p=p+1|0,f[d>>2]=p,R>2]=A;break}else{A=A+1|0,f[d+4>>2]=A;break}if(R<1-M){if(f[d+4>>2]=A,M*2+-1>2]=p;break}}else A=A+1|0,f[d+4>>2]=A;p=p+1|0,f[d>>2]=p}while(!1);do if(B<0)if(A&1){H=(A+1|0)/2|0,H=Hr(p|0,((p|0)<0)<<31>>31|0,H|0,((H|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-((+(H>>>0)+4294967296*+(ee()|0))*2+1)),f[d>>2]=p;break}else{H=(A|0)/2|0,H=Hr(p|0,((p|0)<0)<<31>>31|0,H|0,((H|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-(+(H>>>0)+4294967296*+(ee()|0))*2),f[d>>2]=p;break}while(!1);H=d+4|0,F<0&&(p=p-((A<<1|1|0)/2|0)|0,f[d>>2]=p,A=0-A|0,f[H>>2]=A),_=A-p|0,(p|0)<0?(y=0-p|0,f[H>>2]=_,f[re>>2]=y,f[d>>2]=0,A=_,p=0):y=0,(A|0)<0&&(p=p-A|0,f[d>>2]=p,y=y-A|0,f[re>>2]=y,f[H>>2]=0,A=0),T=p-y|0,_=A-y|0,(y|0)<0&&(f[d>>2]=T,f[H>>2]=_,f[re>>2]=0,A=_,p=T,y=0),_=(A|0)<(p|0)?A:p,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(f[d>>2]=p-_,f[H>>2]=A-_,f[re>>2]=y-_)}function jr(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0;d=f[A>>2]|0,M=A+4|0,p=f[M>>2]|0,(d|0)<0&&(p=p-d|0,f[M>>2]=p,T=A+8|0,f[T>>2]=(f[T>>2]|0)-d,f[A>>2]=0,d=0),(p|0)<0?(d=d-p|0,f[A>>2]=d,T=A+8|0,y=(f[T>>2]|0)-p|0,f[T>>2]=y,f[M>>2]=0,p=0):(y=A+8|0,T=y,y=f[y>>2]|0),(y|0)<0&&(d=d-y|0,f[A>>2]=d,p=p-y|0,f[M>>2]=p,f[T>>2]=0,y=0),_=(p|0)<(d|0)?p:d,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(f[A>>2]=d-_,f[M>>2]=p-_,f[T>>2]=y-_)}function ku(A,d){A=A|0,d=d|0;var p=0,_=0;_=f[A+8>>2]|0,p=+((f[A+4>>2]|0)-_|0),J[d>>3]=+((f[A>>2]|0)-_|0)-p*.5,J[d+8>>3]=p*.8660254037844386}function ys(A,d,p){A=A|0,d=d|0,p=p|0,f[p>>2]=(f[d>>2]|0)+(f[A>>2]|0),f[p+4>>2]=(f[d+4>>2]|0)+(f[A+4>>2]|0),f[p+8>>2]=(f[d+8>>2]|0)+(f[A+8>>2]|0)}function uf(A,d,p){A=A|0,d=d|0,p=p|0,f[p>>2]=(f[A>>2]|0)-(f[d>>2]|0),f[p+4>>2]=(f[A+4>>2]|0)-(f[d+4>>2]|0),f[p+8>>2]=(f[A+8>>2]|0)-(f[d+8>>2]|0)}function eh(A,d){A=A|0,d=d|0;var p=0,_=0;p=Ke(f[A>>2]|0,d)|0,f[A>>2]=p,p=A+4|0,_=Ke(f[p>>2]|0,d)|0,f[p>>2]=_,A=A+8|0,d=Ke(f[A>>2]|0,d)|0,f[A>>2]=d}function zu(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;M=f[A>>2]|0,R=(M|0)<0,_=(f[A+4>>2]|0)-(R?M:0)|0,T=(_|0)<0,y=(T?0-_|0:0)+((f[A+8>>2]|0)-(R?M:0))|0,p=(y|0)<0,A=p?0:y,d=(T?0:_)-(p?y:0)|0,y=(R?0:M)-(T?_:0)-(p?y:0)|0,p=(d|0)<(y|0)?d:y,p=(A|0)<(p|0)?A:p,_=(p|0)>0,A=A-(_?p:0)|0,d=d-(_?p:0)|0;e:do switch(y-(_?p:0)|0){case 0:switch(d|0){case 0:return R=(A|0)==0?0:(A|0)==1?1:7,R|0;case 1:return R=(A|0)==0?2:(A|0)==1?3:7,R|0;default:break e}case 1:switch(d|0){case 0:return R=(A|0)==0?4:(A|0)==1?5:7,R|0;case 1:{if(!A)A=6;else break e;return A|0}default:break e}}while(!1);return R=7,R|0}function l1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0;if(B=A+8|0,M=f[B>>2]|0,R=(f[A>>2]|0)-M|0,F=A+4|0,M=(f[F>>2]|0)-M|0,R>>>0>715827881|M>>>0>715827881){if(_=(R|0)>0,y=2147483647-R|0,T=-2147483648-R|0,(_?(y|0)<(R|0):(T|0)>(R|0))||(p=R<<1,_?(2147483647-p|0)<(R|0):(-2147483648-p|0)>(R|0))||((M|0)>0?(2147483647-M|0)<(M|0):(-2147483648-M|0)>(M|0))||(d=R*3|0,p=M<<1,(_?(y|0)<(p|0):(T|0)>(p|0))||((R|0)>-1?(d|-2147483648|0)>=(M|0):(d^-2147483648|0)<(M|0))))return F=1,F|0}else p=M<<1,d=R*3|0;return _=yl(+(d-M|0)*.14285714285714285)|0,f[A>>2]=_,y=yl(+(p+R|0)*.14285714285714285)|0,f[F>>2]=y,f[B>>2]=0,p=(y|0)<(_|0),d=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((d|0)>0?(2147483647-d|0)<(p|0):(-2147483648-d|0)>(p|0)))&&Vt(27795,26892,354,26903),((d|0)>-1?(d|-2147483648|0)>=(p|0):(d^-2147483648|0)<(p|0))&&Vt(27795,26892,354,26903)),d=y-_|0,(_|0)<0?(p=0-_|0,f[F>>2]=d,f[B>>2]=p,f[A>>2]=0,_=0):(d=y,p=0),(d|0)<0&&(_=_-d|0,f[A>>2]=_,p=p-d|0,f[B>>2]=p,f[F>>2]=0,d=0),T=_-p|0,y=d-p|0,(p|0)<0?(f[A>>2]=T,f[F>>2]=y,f[B>>2]=0,d=y,y=T,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(F=0,F|0):(f[A>>2]=y-_,f[F>>2]=d-_,f[B>>2]=p-_,F=0,F|0)}function cx(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(M=A+8|0,y=f[M>>2]|0,T=(f[A>>2]|0)-y|0,R=A+4|0,y=(f[R>>2]|0)-y|0,T>>>0>715827881|y>>>0>715827881){if(p=(T|0)>0,(p?(2147483647-T|0)<(T|0):(-2147483648-T|0)>(T|0))||(d=T<<1,_=(y|0)>0,_?(2147483647-y|0)<(y|0):(-2147483648-y|0)>(y|0)))return R=1,R|0;if(B=y<<1,(_?(2147483647-B|0)<(y|0):(-2147483648-B|0)>(y|0))||(p?(2147483647-d|0)<(y|0):(-2147483648-d|0)>(y|0))||(p=y*3|0,(y|0)>-1?(p|-2147483648|0)>=(T|0):(p^-2147483648|0)<(T|0)))return B=1,B|0}else p=y*3|0,d=T<<1;return _=yl(+(d+y|0)*.14285714285714285)|0,f[A>>2]=_,y=yl(+(p-T|0)*.14285714285714285)|0,f[R>>2]=y,f[M>>2]=0,p=(y|0)<(_|0),d=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((d|0)>0?(2147483647-d|0)<(p|0):(-2147483648-d|0)>(p|0)))&&Vt(27795,26892,402,26917),((d|0)>-1?(d|-2147483648|0)>=(p|0):(d^-2147483648|0)<(p|0))&&Vt(27795,26892,402,26917)),d=y-_|0,(_|0)<0?(p=0-_|0,f[R>>2]=d,f[M>>2]=p,f[A>>2]=0,_=0):(d=y,p=0),(d|0)<0&&(_=_-d|0,f[A>>2]=_,p=p-d|0,f[M>>2]=p,f[R>>2]=0,d=0),T=_-p|0,y=d-p|0,(p|0)<0?(f[A>>2]=T,f[R>>2]=y,f[M>>2]=0,d=y,y=T,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(B=0,B|0):(f[A>>2]=y-_,f[R>>2]=d-_,f[M>>2]=p-_,B=0,B|0)}function hx(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;M=A+8|0,p=f[M>>2]|0,d=(f[A>>2]|0)-p|0,R=A+4|0,p=(f[R>>2]|0)-p|0,_=yl(+((d*3|0)-p|0)*.14285714285714285)|0,f[A>>2]=_,d=yl(+((p<<1)+d|0)*.14285714285714285)|0,f[R>>2]=d,f[M>>2]=0,p=d-_|0,(_|0)<0?(T=0-_|0,f[R>>2]=p,f[M>>2]=T,f[A>>2]=0,d=p,_=0,p=T):p=0,(d|0)<0&&(_=_-d|0,f[A>>2]=_,p=p-d|0,f[M>>2]=p,f[R>>2]=0,d=0),T=_-p|0,y=d-p|0,(p|0)<0?(f[A>>2]=T,f[R>>2]=y,f[M>>2]=0,d=y,y=T,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(f[A>>2]=y-_,f[R>>2]=d-_,f[M>>2]=p-_)}function u1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;M=A+8|0,p=f[M>>2]|0,d=(f[A>>2]|0)-p|0,R=A+4|0,p=(f[R>>2]|0)-p|0,_=yl(+((d<<1)+p|0)*.14285714285714285)|0,f[A>>2]=_,d=yl(+((p*3|0)-d|0)*.14285714285714285)|0,f[R>>2]=d,f[M>>2]=0,p=d-_|0,(_|0)<0?(T=0-_|0,f[R>>2]=p,f[M>>2]=T,f[A>>2]=0,d=p,_=0,p=T):p=0,(d|0)<0&&(_=_-d|0,f[A>>2]=_,p=p-d|0,f[M>>2]=p,f[R>>2]=0,d=0),T=_-p|0,y=d-p|0,(p|0)<0?(f[A>>2]=T,f[R>>2]=y,f[M>>2]=0,d=y,y=T,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(f[A>>2]=y-_,f[R>>2]=d-_,f[M>>2]=p-_)}function th(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;d=f[A>>2]|0,M=A+4|0,p=f[M>>2]|0,R=A+8|0,_=f[R>>2]|0,y=p+(d*3|0)|0,f[A>>2]=y,p=_+(p*3|0)|0,f[M>>2]=p,d=(_*3|0)+d|0,f[R>>2]=d,_=p-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=_,f[R>>2]=d,f[A>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=y,f[R>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[M>>2]=y-p,f[R>>2]=d-p)}function Gu(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;y=f[A>>2]|0,M=A+4|0,d=f[M>>2]|0,R=A+8|0,p=f[R>>2]|0,_=(d*3|0)+y|0,y=p+(y*3|0)|0,f[A>>2]=y,f[M>>2]=_,d=(p*3|0)+d|0,f[R>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=p,f[R>>2]=d,f[A>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,f[A>>2]=y,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=y-d|0,_=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=_,f[R>>2]=0,y=T,d=0):_=p,p=(_|0)<(y|0)?_:y,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=y-p,f[M>>2]=_-p,f[R>>2]=d-p)}function c1(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0;(d+-1|0)>>>0>=6||(y=(f[15440+(d*12|0)>>2]|0)+(f[A>>2]|0)|0,f[A>>2]=y,R=A+4|0,_=(f[15440+(d*12|0)+4>>2]|0)+(f[R>>2]|0)|0,f[R>>2]=_,M=A+8|0,d=(f[15440+(d*12|0)+8>>2]|0)+(f[M>>2]|0)|0,f[M>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[R>>2]=p,f[M>>2]=d,f[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[M>>2]=d,f[R>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[R>>2]=y,f[M>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[R>>2]=y-p,f[M>>2]=d-p))}function h1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;y=f[A>>2]|0,M=A+4|0,d=f[M>>2]|0,R=A+8|0,p=f[R>>2]|0,_=d+y|0,y=p+y|0,f[A>>2]=y,f[M>>2]=_,d=p+d|0,f[R>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=p,f[R>>2]=d,f[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=y,f[R>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[M>>2]=y-p,f[R>>2]=d-p)}function Rd(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;d=f[A>>2]|0,M=A+4|0,_=f[M>>2]|0,R=A+8|0,p=f[R>>2]|0,y=_+d|0,f[A>>2]=y,_=p+_|0,f[M>>2]=_,d=p+d|0,f[R>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=p,f[R>>2]=d,f[A>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=y,f[R>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[M>>2]=y-p,f[R>>2]=d-p)}function qu(A){switch(A=A|0,A|0){case 1:{A=5;break}case 5:{A=4;break}case 4:{A=6;break}case 6:{A=2;break}case 2:{A=3;break}case 3:{A=1;break}}return A|0}function Al(A){switch(A=A|0,A|0){case 1:{A=3;break}case 3:{A=2;break}case 2:{A=6;break}case 6:{A=4;break}case 4:{A=5;break}case 5:{A=1;break}}return A|0}function f1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;d=f[A>>2]|0,M=A+4|0,p=f[M>>2]|0,R=A+8|0,_=f[R>>2]|0,y=p+(d<<1)|0,f[A>>2]=y,p=_+(p<<1)|0,f[M>>2]=p,d=(_<<1)+d|0,f[R>>2]=d,_=p-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=_,f[R>>2]=d,f[A>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,f[A>>2]=_,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=_-d|0,y=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=y,f[R>>2]=0,_=T,d=0):y=p,p=(y|0)<(_|0)?y:_,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=_-p,f[M>>2]=y-p,f[R>>2]=d-p)}function d1(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;y=f[A>>2]|0,M=A+4|0,d=f[M>>2]|0,R=A+8|0,p=f[R>>2]|0,_=(d<<1)+y|0,y=p+(y<<1)|0,f[A>>2]=y,f[M>>2]=_,d=(p<<1)+d|0,f[R>>2]=d,p=_-y|0,(y|0)<0?(d=d-y|0,f[M>>2]=p,f[R>>2]=d,f[A>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,f[A>>2]=y,d=d-p|0,f[R>>2]=d,f[M>>2]=0,p=0),T=y-d|0,_=p-d|0,(d|0)<0?(f[A>>2]=T,f[M>>2]=_,f[R>>2]=0,y=T,d=0):_=p,p=(_|0)<(y|0)?_:y,p=(d|0)<(p|0)?d:p,!((p|0)<=0)&&(f[A>>2]=y-p,f[M>>2]=_-p,f[R>>2]=d-p)}function rp(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0;return M=(f[A>>2]|0)-(f[d>>2]|0)|0,R=(M|0)<0,_=(f[A+4>>2]|0)-(f[d+4>>2]|0)-(R?M:0)|0,T=(_|0)<0,y=(R?0-M|0:0)+(f[A+8>>2]|0)-(f[d+8>>2]|0)+(T?0-_|0:0)|0,A=(y|0)<0,d=A?0:y,p=(T?0:_)-(A?y:0)|0,y=(R?0:M)-(T?_:0)-(A?y:0)|0,A=(p|0)<(y|0)?p:y,A=(d|0)<(A|0)?d:A,_=(A|0)>0,d=d-(_?A:0)|0,p=p-(_?A:0)|0,A=y-(_?A:0)|0,A=(A|0)>-1?A:0-A|0,p=(p|0)>-1?p:0-p|0,d=(d|0)>-1?d:0-d|0,d=(p|0)>(d|0)?p:d,((A|0)>(d|0)?A:d)|0}function fx(A,d){A=A|0,d=d|0;var p=0;p=f[A+8>>2]|0,f[d>>2]=(f[A>>2]|0)-p,f[d+4>>2]=(f[A+4>>2]|0)-p}function sp(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0;return _=f[A>>2]|0,f[d>>2]=_,y=f[A+4>>2]|0,M=d+4|0,f[M>>2]=y,R=d+8|0,f[R>>2]=0,p=(y|0)<(_|0),A=p?_:y,p=p?y:_,(p|0)<0&&((p|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(p|0):(-2147483648-A|0)>(p|0))||((A|0)>-1?(A|-2147483648|0)>=(p|0):(A^-2147483648|0)<(p|0)))?(d=1,d|0):(A=y-_|0,(_|0)<0?(p=0-_|0,f[M>>2]=A,f[R>>2]=p,f[d>>2]=0,_=0):(A=y,p=0),(A|0)<0&&(_=_-A|0,f[d>>2]=_,p=p-A|0,f[R>>2]=p,f[M>>2]=0,A=0),T=_-p|0,y=A-p|0,(p|0)<0?(f[d>>2]=T,f[M>>2]=y,f[R>>2]=0,A=y,y=T,p=0):y=_,_=(A|0)<(y|0)?A:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(d=0,d|0):(f[d>>2]=y-_,f[M>>2]=A-_,f[R>>2]=p-_,d=0,d|0))}function A1(A){A=A|0;var d=0,p=0,_=0,y=0;d=A+8|0,y=f[d>>2]|0,p=y-(f[A>>2]|0)|0,f[A>>2]=p,_=A+4|0,A=(f[_>>2]|0)-y|0,f[_>>2]=A,f[d>>2]=0-(A+p)}function dx(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;p=f[A>>2]|0,d=0-p|0,f[A>>2]=d,M=A+8|0,f[M>>2]=0,R=A+4|0,_=f[R>>2]|0,y=_+p|0,(p|0)>0?(f[R>>2]=y,f[M>>2]=p,f[A>>2]=0,d=0,_=y):p=0,(_|0)<0?(T=d-_|0,f[A>>2]=T,p=p-_|0,f[M>>2]=p,f[R>>2]=0,y=T-p|0,d=0-p|0,(p|0)<0?(f[A>>2]=y,f[R>>2]=d,f[M>>2]=0,_=d,p=0):(_=0,y=T)):y=d,d=(_|0)<(y|0)?_:y,d=(p|0)<(d|0)?p:d,!((d|0)<=0)&&(f[A>>2]=y-d,f[R>>2]=_-d,f[M>>2]=p-d)}function Ax(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0;if(re=Z,Z=Z+64|0,H=re,R=re+56|0,!(!0&(d&2013265920|0)==134217728&(!0&(_&2013265920|0)==134217728)))return y=5,Z=re,y|0;if((A|0)==(p|0)&(d|0)==(_|0))return f[y>>2]=0,y=0,Z=re,y|0;if(M=Ut(A|0,d|0,52)|0,ee()|0,M=M&15,F=Ut(p|0,_|0,52)|0,ee()|0,(M|0)!=(F&15|0))return y=12,Z=re,y|0;if(T=M+-1|0,M>>>0>1){Wu(A,d,T,H)|0,Wu(p,_,T,R)|0,F=H,B=f[F>>2]|0,F=f[F+4>>2]|0;e:do if((B|0)==(f[R>>2]|0)&&(F|0)==(f[R+4>>2]|0)){M=(M^15)*3|0,T=Ut(A|0,d|0,M|0)|0,ee()|0,T=T&7,M=Ut(p|0,_|0,M|0)|0,ee()|0,M=M&7;do if((T|0)==0|(M|0)==0)f[y>>2]=1,T=0;else if((T|0)==7)T=5;else{if((T|0)==1|(M|0)==1&&Ri(B,F)|0){T=5;break}if((f[15536+(T<<2)>>2]|0)!=(M|0)&&(f[15568+(T<<2)>>2]|0)!=(M|0))break e;f[y>>2]=1,T=0}while(!1);return y=T,Z=re,y|0}while(!1)}T=H,M=T+56|0;do f[T>>2]=0,T=T+4|0;while((T|0)<(M|0));return qr(A,d,1,H)|0,d=H,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0))&&(d=H+8|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))&&(d=H+16|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))&&(d=H+24|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))&&(d=H+32|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))&&(d=H+40|0,!((f[d>>2]|0)==(p|0)&&(f[d+4>>2]|0)==(_|0)))?(T=H+48|0,T=((f[T>>2]|0)==(p|0)?(f[T+4>>2]|0)==(_|0):0)&1):T=1,f[y>>2]=T,y=0,Z=re,y|0}function p1(A,d,p,_,y){return A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,p=ts(A,d,p,_)|0,(p|0)==7?(y=11,y|0):(_=zt(p|0,0,56)|0,d=d&-2130706433|(ee()|0)|268435456,f[y>>2]=A|_,f[y+4>>2]=d,y=0,y|0)}function px(A,d,p){return A=A|0,d=d|0,p=p|0,!0&(d&2013265920|0)==268435456?(f[p>>2]=A,f[p+4>>2]=d&-2130706433|134217728,p=0,p|0):(p=6,p|0)}function mx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;return y=Z,Z=Z+16|0,_=y,f[_>>2]=0,!0&(d&2013265920|0)==268435456?(T=Ut(A|0,d|0,56)|0,ee()|0,_=_i(A,d&-2130706433|134217728,T&7,_,p)|0,Z=y,_|0):(_=6,Z=y,_|0)}function m1(A,d){A=A|0,d=d|0;var p=0;switch(p=Ut(A|0,d|0,56)|0,ee()|0,p&7){case 0:case 7:return p=0,p|0}return p=d&-2130706433|134217728,!(!0&(d&2013265920|0)==268435456)||!0&(d&117440512|0)==16777216&(Ri(A,p)|0)!=0?(p=0,p|0):(p=Ld(A,p)|0,p|0)}function gx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;return y=Z,Z=Z+16|0,_=y,!0&(d&2013265920|0)==268435456?(T=d&-2130706433|134217728,M=p,f[M>>2]=A,f[M+4>>2]=T,f[_>>2]=0,d=Ut(A|0,d|0,56)|0,ee()|0,_=_i(A,T,d&7,_,p+8|0)|0,Z=y,_|0):(_=6,Z=y,_|0)}function vx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;return y=(Ri(A,d)|0)==0,d=d&-2130706433,_=p,f[_>>2]=y?A:0,f[_+4>>2]=y?d|285212672:0,_=p+8|0,f[_>>2]=A,f[_+4>>2]=d|301989888,_=p+16|0,f[_>>2]=A,f[_+4>>2]=d|318767104,_=p+24|0,f[_>>2]=A,f[_+4>>2]=d|335544320,_=p+32|0,f[_>>2]=A,f[_+4>>2]=d|352321536,p=p+40|0,f[p>>2]=A,f[p+4>>2]=d|369098752,0}function Dd(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;return M=Z,Z=Z+16|0,y=M,T=d&-2130706433|134217728,!0&(d&2013265920|0)==268435456?(_=Ut(A|0,d|0,56)|0,ee()|0,_=Tp(A,T,_&7)|0,(_|0)==-1?(f[p>>2]=0,T=6,Z=M,T|0):(Xu(A,T,y)|0&&Vt(27795,26932,282,26947),d=Ut(A|0,d|0,52)|0,ee()|0,d=d&15,Ri(A,T)|0?ap(y,d,_,2,p):Pd(y,d,_,2,p),T=0,Z=M,T|0)):(T=6,Z=M,T|0)}function _x(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;_=Z,Z=Z+16|0,y=_,yx(A,d,p,y),Nd(y,p+4|0),Z=_}function yx(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0;if(R=Z,Z=Z+16|0,B=R,xx(A,p,B),T=+ji(+(1-+J[B>>3]*.5)),T<1e-16){f[_>>2]=0,f[_+4>>2]=0,f[_+8>>2]=0,f[_+12>>2]=0,Z=R;return}if(B=f[p>>2]|0,y=+J[15920+(B*24|0)>>3],y=+ih(y-+ih(+Ex(15600+(B<<4)|0,A))),Ps(d)|0?M=+ih(y+-.3334731722518321):M=y,y=+Ar(+T)*2.618033988749896,(d|0)>0){A=0;do y=y*2.6457513110645907,A=A+1|0;while((A|0)!=(d|0))}T=+on(+M)*y,J[_>>3]=T,M=+xn(+M)*y,J[_+8>>3]=M,Z=R}function xx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if(T=Z,Z=Z+32|0,y=T,ic(A,y),f[d>>2]=0,J[p>>3]=5,_=+cr(16400,y),_<+J[p>>3]&&(f[d>>2]=0,J[p>>3]=_),_=+cr(16424,y),_<+J[p>>3]&&(f[d>>2]=1,J[p>>3]=_),_=+cr(16448,y),_<+J[p>>3]&&(f[d>>2]=2,J[p>>3]=_),_=+cr(16472,y),_<+J[p>>3]&&(f[d>>2]=3,J[p>>3]=_),_=+cr(16496,y),_<+J[p>>3]&&(f[d>>2]=4,J[p>>3]=_),_=+cr(16520,y),_<+J[p>>3]&&(f[d>>2]=5,J[p>>3]=_),_=+cr(16544,y),_<+J[p>>3]&&(f[d>>2]=6,J[p>>3]=_),_=+cr(16568,y),_<+J[p>>3]&&(f[d>>2]=7,J[p>>3]=_),_=+cr(16592,y),_<+J[p>>3]&&(f[d>>2]=8,J[p>>3]=_),_=+cr(16616,y),_<+J[p>>3]&&(f[d>>2]=9,J[p>>3]=_),_=+cr(16640,y),_<+J[p>>3]&&(f[d>>2]=10,J[p>>3]=_),_=+cr(16664,y),_<+J[p>>3]&&(f[d>>2]=11,J[p>>3]=_),_=+cr(16688,y),_<+J[p>>3]&&(f[d>>2]=12,J[p>>3]=_),_=+cr(16712,y),_<+J[p>>3]&&(f[d>>2]=13,J[p>>3]=_),_=+cr(16736,y),_<+J[p>>3]&&(f[d>>2]=14,J[p>>3]=_),_=+cr(16760,y),_<+J[p>>3]&&(f[d>>2]=15,J[p>>3]=_),_=+cr(16784,y),_<+J[p>>3]&&(f[d>>2]=16,J[p>>3]=_),_=+cr(16808,y),_<+J[p>>3]&&(f[d>>2]=17,J[p>>3]=_),_=+cr(16832,y),_<+J[p>>3]&&(f[d>>2]=18,J[p>>3]=_),_=+cr(16856,y),!(_<+J[p>>3])){Z=T;return}f[d>>2]=19,J[p>>3]=_,Z=T}function Vu(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0;if(T=+Xl(A),T<1e-16){d=15600+(d<<4)|0,f[y>>2]=f[d>>2],f[y+4>>2]=f[d+4>>2],f[y+8>>2]=f[d+8>>2],f[y+12>>2]=f[d+12>>2];return}if(M=+Fe(+ +J[A+8>>3],+ +J[A>>3]),(p|0)>0){A=0;do T=T*.37796447300922725,A=A+1|0;while((A|0)!=(p|0))}R=T*.3333333333333333,_?(p=(Ps(p)|0)==0,T=+ue(+((p?R:R*.37796447300922725)*.381966011250105))):(T=+ue(+(T*.381966011250105)),Ps(p)|0&&(M=+ih(M+.3334731722518321))),Cx(15600+(d<<4)|0,+ih(+J[15920+(d*24|0)>>3]-M),T,y)}function cf(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;_=Z,Z=Z+16|0,y=_,ku(A+4|0,y),Vu(y,f[A>>2]|0,d,0,p),Z=_}function ap(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0,Cn=0,li=0,Ln=0;if(Cn=Z,Z=Z+272|0,T=Cn+256|0,He=Cn+240|0,Pn=Cn,gn=Cn+224|0,Ht=Cn+208|0,Ve=Cn+176|0,Re=Cn+160|0,jt=Cn+192|0,pn=Cn+144|0,cn=Cn+128|0,jn=Cn+112|0,Bn=Cn+96|0,ei=Cn+80|0,f[T>>2]=d,f[He>>2]=f[A>>2],f[He+4>>2]=f[A+4>>2],f[He+8>>2]=f[A+8>>2],f[He+12>>2]=f[A+12>>2],op(He,T,Pn),f[y>>2]=0,He=_+p+((_|0)==5&1)|0,(He|0)<=(p|0)){Z=Cn;return}B=f[T>>2]|0,F=gn+4|0,H=Ve+4|0,re=p+5|0,me=16880+(B<<2)|0,pe=16960+(B<<2)|0,ge=cn+8|0,Ne=jn+8|0,Ie=Bn+8|0,Je=Ht+4|0,R=p;e:for(;;){M=Pn+(((R|0)%5|0)<<4)|0,f[Ht>>2]=f[M>>2],f[Ht+4>>2]=f[M+4>>2],f[Ht+8>>2]=f[M+8>>2],f[Ht+12>>2]=f[M+12>>2];do;while((ju(Ht,B,0,1)|0)==2);if((R|0)>(p|0)&(Ps(d)|0)!=0){if(f[Ve>>2]=f[Ht>>2],f[Ve+4>>2]=f[Ht+4>>2],f[Ve+8>>2]=f[Ht+8>>2],f[Ve+12>>2]=f[Ht+12>>2],ku(F,Re),_=f[Ve>>2]|0,T=f[17040+(_*80|0)+(f[gn>>2]<<2)>>2]|0,f[Ve>>2]=f[18640+(_*80|0)+(T*20|0)>>2],M=f[18640+(_*80|0)+(T*20|0)+16>>2]|0,(M|0)>0){A=0;do h1(H),A=A+1|0;while((A|0)<(M|0))}switch(M=18640+(_*80|0)+(T*20|0)+4|0,f[jt>>2]=f[M>>2],f[jt+4>>2]=f[M+4>>2],f[jt+8>>2]=f[M+8>>2],eh(jt,(f[me>>2]|0)*3|0),ys(H,jt,H),jr(H),ku(H,pn),li=+(f[pe>>2]|0),J[cn>>3]=li*3,J[ge>>3]=0,Ln=li*-1.5,J[jn>>3]=Ln,J[Ne>>3]=li*2.598076211353316,J[Bn>>3]=Ln,J[Ie>>3]=li*-2.598076211353316,f[17040+((f[Ve>>2]|0)*80|0)+(f[Ht>>2]<<2)>>2]|0){case 1:{A=jn,_=cn;break}case 3:{A=Bn,_=jn;break}case 2:{A=cn,_=Bn;break}default:{A=12;break e}}bp(Re,pn,_,A,ei),Vu(ei,f[Ve>>2]|0,B,1,y+8+(f[y>>2]<<4)|0),f[y>>2]=(f[y>>2]|0)+1}if((R|0)<(re|0)&&(ku(Je,Ve),Vu(Ve,f[Ht>>2]|0,B,1,y+8+(f[y>>2]<<4)|0),f[y>>2]=(f[y>>2]|0)+1),f[gn>>2]=f[Ht>>2],f[gn+4>>2]=f[Ht+4>>2],f[gn+8>>2]=f[Ht+8>>2],f[gn+12>>2]=f[Ht+12>>2],R=R+1|0,(R|0)>=(He|0)){A=3;break}}if((A|0)==3){Z=Cn;return}else(A|0)==12&&Vt(26970,27017,572,27027)}function op(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0;B=Z,Z=Z+128|0,_=B+64|0,y=B,T=_,M=20240,R=T+60|0;do f[T>>2]=f[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(R|0));T=y,M=20304,R=T+60|0;do f[T>>2]=f[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(R|0));R=(Ps(f[d>>2]|0)|0)==0,_=R?_:y,y=A+4|0,f1(y),d1(y),Ps(f[d>>2]|0)|0&&(Gu(y),f[d>>2]=(f[d>>2]|0)+1),f[p>>2]=f[A>>2],d=p+4|0,ys(y,_,d),jr(d),f[p+16>>2]=f[A>>2],d=p+20|0,ys(y,_+12|0,d),jr(d),f[p+32>>2]=f[A>>2],d=p+36|0,ys(y,_+24|0,d),jr(d),f[p+48>>2]=f[A>>2],d=p+52|0,ys(y,_+36|0,d),jr(d),f[p+64>>2]=f[A>>2],p=p+68|0,ys(y,_+48|0,p),jr(p),Z=B}function ju(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0;if(ge=Z,Z=Z+32|0,me=ge+12|0,R=ge,pe=A+4|0,re=f[16960+(d<<2)>>2]|0,H=(_|0)!=0,re=H?re*3|0:re,y=f[pe>>2]|0,F=A+8|0,M=f[F>>2]|0,H){if(T=A+12|0,_=f[T>>2]|0,y=M+y+_|0,(y|0)==(re|0))return pe=1,Z=ge,pe|0;B=T}else B=A+12|0,_=f[B>>2]|0,y=M+y+_|0;if((y|0)<=(re|0))return pe=0,Z=ge,pe|0;do if((_|0)>0){if(_=f[A>>2]|0,(M|0)>0){T=18640+(_*80|0)+60|0,_=A;break}_=18640+(_*80|0)+40|0,p?(Fu(me,re,0,0),uf(pe,me,R),Rd(R),ys(R,me,pe),T=_,_=A):(T=_,_=A)}else T=18640+((f[A>>2]|0)*80|0)+20|0,_=A;while(!1);if(f[_>>2]=f[T>>2],y=T+16|0,(f[y>>2]|0)>0){_=0;do h1(pe),_=_+1|0;while((_|0)<(f[y>>2]|0))}return A=T+4|0,f[me>>2]=f[A>>2],f[me+4>>2]=f[A+4>>2],f[me+8>>2]=f[A+8>>2],d=f[16880+(d<<2)>>2]|0,eh(me,H?d*3|0:d),ys(pe,me,pe),jr(pe),H?_=((f[F>>2]|0)+(f[pe>>2]|0)+(f[B>>2]|0)|0)==(re|0)?1:2:_=2,pe=_,Z=ge,pe|0}function g1(A,d){A=A|0,d=d|0;var p=0;do p=ju(A,d,0,1)|0;while((p|0)==2);return p|0}function Pd(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0;if(Bn=Z,Z=Z+240|0,T=Bn+224|0,jt=Bn+208|0,pn=Bn,cn=Bn+192|0,jn=Bn+176|0,Ie=Bn+160|0,Je=Bn+144|0,He=Bn+128|0,Ve=Bn+112|0,Re=Bn+96|0,f[T>>2]=d,f[jt>>2]=f[A>>2],f[jt+4>>2]=f[A+4>>2],f[jt+8>>2]=f[A+8>>2],f[jt+12>>2]=f[A+12>>2],lp(jt,T,pn),f[y>>2]=0,Ne=_+p+((_|0)==6&1)|0,(Ne|0)<=(p|0)){Z=Bn;return}B=f[T>>2]|0,F=p+6|0,H=16960+(B<<2)|0,re=Je+8|0,me=He+8|0,pe=Ve+8|0,ge=cn+4|0,M=0,R=p,_=-1;e:for(;;){if(T=(R|0)%6|0,A=pn+(T<<4)|0,f[cn>>2]=f[A>>2],f[cn+4>>2]=f[A+4>>2],f[cn+8>>2]=f[A+8>>2],f[cn+12>>2]=f[A+12>>2],A=M,M=ju(cn,B,0,1)|0,(R|0)>(p|0)&(Ps(d)|0)!=0&&(A|0)!=1&&(f[cn>>2]|0)!=(_|0)){switch(ku(pn+(((T+5|0)%6|0)<<4)+4|0,jn),ku(pn+(T<<4)+4|0,Ie),ei=+(f[H>>2]|0),J[Je>>3]=ei*3,J[re>>3]=0,Pn=ei*-1.5,J[He>>3]=Pn,J[me>>3]=ei*2.598076211353316,J[Ve>>3]=Pn,J[pe>>3]=ei*-2.598076211353316,T=f[jt>>2]|0,f[17040+(T*80|0)+(((_|0)==(T|0)?f[cn>>2]|0:_)<<2)>>2]|0){case 1:{A=He,_=Je;break}case 3:{A=Ve,_=He;break}case 2:{A=Je,_=Ve;break}default:{A=8;break e}}bp(jn,Ie,_,A,Re),!(Sp(jn,Re)|0)&&!(Sp(Ie,Re)|0)&&(Vu(Re,f[jt>>2]|0,B,1,y+8+(f[y>>2]<<4)|0),f[y>>2]=(f[y>>2]|0)+1)}if((R|0)<(F|0)&&(ku(ge,jn),Vu(jn,f[cn>>2]|0,B,1,y+8+(f[y>>2]<<4)|0),f[y>>2]=(f[y>>2]|0)+1),R=R+1|0,(R|0)>=(Ne|0)){A=3;break}else _=f[cn>>2]|0}if((A|0)==3){Z=Bn;return}else(A|0)==8&&Vt(27054,27017,737,27099)}function lp(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0;B=Z,Z=Z+160|0,_=B+80|0,y=B,T=_,M=20368,R=T+72|0;do f[T>>2]=f[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(R|0));T=y,M=20448,R=T+72|0;do f[T>>2]=f[M>>2],T=T+4|0,M=M+4|0;while((T|0)<(R|0));R=(Ps(f[d>>2]|0)|0)==0,_=R?_:y,y=A+4|0,f1(y),d1(y),Ps(f[d>>2]|0)|0&&(Gu(y),f[d>>2]=(f[d>>2]|0)+1),f[p>>2]=f[A>>2],d=p+4|0,ys(y,_,d),jr(d),f[p+16>>2]=f[A>>2],d=p+20|0,ys(y,_+12|0,d),jr(d),f[p+32>>2]=f[A>>2],d=p+36|0,ys(y,_+24|0,d),jr(d),f[p+48>>2]=f[A>>2],d=p+52|0,ys(y,_+36|0,d),jr(d),f[p+64>>2]=f[A>>2],d=p+68|0,ys(y,_+48|0,d),jr(d),f[p+80>>2]=f[A>>2],p=p+84|0,ys(y,_+60|0,p),jr(p),Z=B}function nh(A,d){return A=A|0,d=d|0,d=Ut(A|0,d|0,52)|0,ee()|0,d&15|0}function v1(A,d){return A=A|0,d=d|0,d=Ut(A|0,d|0,45)|0,ee()|0,d&127|0}function bx(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,(p+-1|0)>>>0>14?(_=4,_|0):(p=Ut(A|0,d|0,(15-p|0)*3|0)|0,ee()|0,f[_>>2]=p&7,_=0,_|0)}function Sx(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;if(A>>>0>15)return _=4,_|0;if(d>>>0>121)return _=17,_|0;M=zt(A|0,0,52)|0,y=ee()|0,R=zt(d|0,0,45)|0,y=y|(ee()|0)|134225919;e:do if((A|0)>=1){for(R=1,M=(ot[20528+d>>0]|0)!=0,T=-1;;){if(d=f[p+(R+-1<<2)>>2]|0,d>>>0>6){y=18,d=10;break}if(!((d|0)==0|M^1))if((d|0)==1){y=19,d=10;break}else M=0;if(F=(15-R|0)*3|0,B=zt(7,0,F|0)|0,y=y&~(ee()|0),d=zt(d|0,((d|0)<0)<<31>>31|0,F|0)|0,T=d|T&~B,y=ee()|0|y,(R|0)<(A|0))R=R+1|0;else break e}if((d|0)==10)return y|0}else T=-1;while(!1);return F=_,f[F>>2]=T,f[F+4>>2]=y,F=0,F|0}function Ld(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;return!(!0&(d&-16777216|0)==134217728)||(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,p=Ut(A|0,d|0,45)|0,ee()|0,p=p&127,p>>>0>121)?(A=0,A|0):(M=(_^15)*3|0,y=Ut(A|0,d|0,M|0)|0,M=zt(y|0,ee()|0,M|0)|0,y=ee()|0,T=Hr(-1227133514,-1171,M|0,y|0)|0,!((M&613566756&T|0)==0&(y&4681&(ee()|0)|0)==0)||(M=(_*3|0)+19|0,T=zt(~A|0,~d|0,M|0)|0,M=Ut(T|0,ee()|0,M|0)|0,!((_|0)==15|(M|0)==0&(ee()|0)==0))?(M=0,M|0):!(ot[20528+p>>0]|0)||(d=d&8191,(A|0)==0&(d|0)==0)?(M=1,M|0):(M=pf(A|0,d|0)|0,ee()|0,((63-M|0)%3|0|0)!=0|0))}function _1(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;return!0&(d&-16777216|0)==134217728&&(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,p=Ut(A|0,d|0,45)|0,ee()|0,p=p&127,p>>>0<=121)&&(M=(_^15)*3|0,y=Ut(A|0,d|0,M|0)|0,M=zt(y|0,ee()|0,M|0)|0,y=ee()|0,T=Hr(-1227133514,-1171,M|0,y|0)|0,(M&613566756&T|0)==0&(y&4681&(ee()|0)|0)==0)&&(M=(_*3|0)+19|0,T=zt(~A|0,~d|0,M|0)|0,M=Ut(T|0,ee()|0,M|0)|0,(_|0)==15|(M|0)==0&(ee()|0)==0)&&(!(ot[20528+p>>0]|0)||(p=d&8191,(A|0)==0&(p|0)==0)||(M=pf(A|0,p|0)|0,ee()|0,(63-M|0)%3|0|0))||m1(A,d)|0?(M=1,M|0):(M=(_l(A,d)|0)!=0&1,M|0)}function Hu(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0;if(y=zt(d|0,0,52)|0,T=ee()|0,p=zt(p|0,0,45)|0,p=T|(ee()|0)|134225919,(d|0)<1){T=-1,_=p,d=A,f[d>>2]=T,A=A+4|0,f[A>>2]=_;return}for(T=1,y=-1;M=(15-T|0)*3|0,R=zt(7,0,M|0)|0,p=p&~(ee()|0),M=zt(_|0,0,M|0)|0,y=y&~R|M,p=p|(ee()|0),(T|0)!=(d|0);)T=T+1|0;R=A,M=R,f[M>>2]=y,R=R+4|0,f[R>>2]=p}function Wu(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0;if(T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,p>>>0>15)return _=4,_|0;if((T|0)<(p|0))return _=12,_|0;if((T|0)==(p|0))return f[_>>2]=A,f[_+4>>2]=d,_=0,_|0;if(y=zt(p|0,0,52)|0,y=y|A,A=ee()|0|d&-15728641,(T|0)>(p|0))do d=zt(7,0,(14-p|0)*3|0)|0,p=p+1|0,y=d|y,A=ee()|0|A;while((p|0)<(T|0));return f[_>>2]=y,f[_+4>>2]=A,_=0,_|0}function hf(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0;if(T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,!((p|0)<16&(T|0)<=(p|0)))return _=4,_|0;y=p-T|0,p=Ut(A|0,d|0,45)|0,ee()|0;e:do if(!($n(p&127)|0))p=jo(7,0,y,((y|0)<0)<<31>>31)|0,y=ee()|0;else{t:do if(T|0){for(p=1;M=zt(7,0,(15-p|0)*3|0)|0,!!((M&A|0)==0&((ee()|0)&d|0)==0);)if(p>>>0>>0)p=p+1|0;else break t;p=jo(7,0,y,((y|0)<0)<<31>>31)|0,y=ee()|0;break e}while(!1);p=jo(7,0,y,((y|0)<0)<<31>>31)|0,p=vr(p|0,ee()|0,5,0)|0,p=rn(p|0,ee()|0,-5,-1)|0,p=Xo(p|0,ee()|0,6,0)|0,p=rn(p|0,ee()|0,1,0)|0,y=ee()|0}while(!1);return M=_,f[M>>2]=p,f[M+4>>2]=y,M=0,M|0}function Ri(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;if(y=Ut(A|0,d|0,45)|0,ee()|0,!($n(y&127)|0))return y=0,y|0;y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15;e:do if(!y)p=0;else for(_=1;;){if(p=Ut(A|0,d|0,(15-_|0)*3|0)|0,ee()|0,p=p&7,p|0)break e;if(_>>>0>>0)_=_+1|0;else{p=0;break}}while(!1);return y=(p|0)==0&1,y|0}function y1(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0;if(M=Z,Z=Z+16|0,T=M,pl(T,A,d,p),d=T,A=f[d>>2]|0,d=f[d+4>>2]|0,(A|0)==0&(d|0)==0)return Z=M,0;y=0,p=0;do R=_+(y<<3)|0,f[R>>2]=A,f[R+4>>2]=d,y=rn(y|0,p|0,1,0)|0,p=ee()|0,ff(T),R=T,A=f[R>>2]|0,d=f[R+4>>2]|0;while(!((A|0)==0&(d|0)==0));return Z=M,0}function up(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,(_|0)<(p|0)?(p=d,_=A,Mt(p|0),_|0):(p=zt(-1,-1,((_-p|0)*3|0)+3|0)|0,_=zt(~p|0,~(ee()|0)|0,(15-_|0)*3|0)|0,p=~(ee()|0)&d,_=~_&A,Mt(p|0),_|0)}function Ud(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0;return y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,(p|0)<16&(y|0)<=(p|0)?((y|0)<(p|0)&&(y=zt(-1,-1,((p+-1-y|0)*3|0)+3|0)|0,y=zt(~y|0,~(ee()|0)|0,(15-p|0)*3|0)|0,d=~(ee()|0)&d,A=~y&A),y=zt(p|0,0,52)|0,p=d&-15728641|(ee()|0),f[_>>2]=A|y,f[_+4>>2]=p,_=0,_|0):(_=4,_|0)}function cp(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0;if((p|0)==0&(_|0)==0)return Ht=0,Ht|0;if(y=A,T=f[y>>2]|0,y=f[y+4>>2]|0,!0&(y&15728640|0)==0){if(!((_|0)>0|(_|0)==0&p>>>0>0)||(Ht=d,f[Ht>>2]=T,f[Ht+4>>2]=y,(p|0)==1&(_|0)==0))return Ht=0,Ht|0;y=1,T=0;do Pn=A+(y<<3)|0,gn=f[Pn+4>>2]|0,Ht=d+(y<<3)|0,f[Ht>>2]=f[Pn>>2],f[Ht+4>>2]=gn,y=rn(y|0,T|0,1,0)|0,T=ee()|0;while((T|0)<(_|0)|(T|0)==(_|0)&y>>>0

>>0);return y=0,y|0}if(ei=p<<3,gn=$o(ei)|0,!gn)return Ht=13,Ht|0;if(Yl(gn|0,A|0,ei|0)|0,Pn=sa(p,8)|0,!Pn)return wn(gn),Ht=13,Ht|0;e:for(;;){y=gn,F=f[y>>2]|0,y=f[y+4>>2]|0,jn=Ut(F|0,y|0,52)|0,ee()|0,jn=jn&15,Bn=jn+-1|0,cn=(jn|0)!=0,pn=(_|0)>0|(_|0)==0&p>>>0>0;t:do if(cn&pn){if(He=zt(Bn|0,0,52)|0,Ve=ee()|0,Bn>>>0>15){if(!((F|0)==0&(y|0)==0)){Ht=16;break e}for(T=0,A=0;;){if(T=rn(T|0,A|0,1,0)|0,A=ee()|0,!((A|0)<(_|0)|(A|0)==(_|0)&T>>>0

>>0))break t;if(M=gn+(T<<3)|0,jt=f[M>>2]|0,M=f[M+4>>2]|0,!((jt|0)==0&(M|0)==0)){y=M,Ht=16;break e}}}for(R=F,A=y,T=0,M=0;;){if(!((R|0)==0&(A|0)==0)){if(!(!0&(A&117440512|0)==0)){Ht=21;break e}if(H=Ut(R|0,A|0,52)|0,ee()|0,H=H&15,(H|0)<(Bn|0)){y=12,Ht=27;break e}if((H|0)!=(Bn|0)&&(R=R|He,A=A&-15728641|Ve,H>>>0>=jn>>>0)){B=Bn;do jt=zt(7,0,(14-B|0)*3|0)|0,B=B+1|0,R=jt|R,A=ee()|0|A;while(B>>>0>>0)}if(me=lc(R|0,A|0,p|0,_|0)|0,pe=ee()|0,B=Pn+(me<<3)|0,H=B,re=f[H>>2]|0,H=f[H+4>>2]|0,!((re|0)==0&(H|0)==0)){Ie=0,Je=0;do{if((Ie|0)>(_|0)|(Ie|0)==(_|0)&Je>>>0>p>>>0){Ht=31;break e}if((re|0)==(R|0)&(H&-117440513|0)==(A|0)){ge=Ut(re|0,H|0,56)|0,ee()|0,ge=ge&7,Ne=ge+1|0,jt=Ut(re|0,H|0,45)|0,ee()|0;n:do if(!($n(jt&127)|0))H=7;else{if(re=Ut(re|0,H|0,52)|0,ee()|0,re=re&15,!re){H=6;break}for(H=1;;){if(jt=zt(7,0,(15-H|0)*3|0)|0,!((jt&R|0)==0&((ee()|0)&A|0)==0)){H=7;break n}if(H>>>0>>0)H=H+1|0;else{H=6;break}}}while(!1);if((ge+2|0)>>>0>H>>>0){Ht=41;break e}jt=zt(Ne|0,0,56)|0,A=ee()|0|A&-117440513,Re=B,f[Re>>2]=0,f[Re+4>>2]=0,R=jt|R}else me=rn(me|0,pe|0,1,0)|0,me=oh(me|0,ee()|0,p|0,_|0)|0,pe=ee()|0;Je=rn(Je|0,Ie|0,1,0)|0,Ie=ee()|0,B=Pn+(me<<3)|0,H=B,re=f[H>>2]|0,H=f[H+4>>2]|0}while(!((re|0)==0&(H|0)==0))}jt=B,f[jt>>2]=R,f[jt+4>>2]=A}if(T=rn(T|0,M|0,1,0)|0,M=ee()|0,!((M|0)<(_|0)|(M|0)==(_|0)&T>>>0

>>0))break t;A=gn+(T<<3)|0,R=f[A>>2]|0,A=f[A+4>>2]|0}}while(!1);if(jt=rn(p|0,_|0,5,0)|0,Re=ee()|0,Re>>>0<0|(Re|0)==0&jt>>>0<11){Ht=85;break}if(jt=Xo(p|0,_|0,6,0)|0,ee()|0,jt=sa(jt,8)|0,!jt){Ht=48;break}do if(pn){for(Ne=0,A=0,ge=0,Ie=0;;){if(H=Pn+(Ne<<3)|0,M=H,T=f[M>>2]|0,M=f[M+4>>2]|0,(T|0)==0&(M|0)==0)Re=ge;else{re=Ut(T|0,M|0,56)|0,ee()|0,re=re&7,R=re+1|0,me=M&-117440513,Re=Ut(T|0,M|0,45)|0,ee()|0;t:do if($n(Re&127)|0){if(pe=Ut(T|0,M|0,52)|0,ee()|0,pe=pe&15,pe|0)for(B=1;;){if(Re=zt(7,0,(15-B|0)*3|0)|0,!((T&Re|0)==0&(me&(ee()|0)|0)==0))break t;if(B>>>0>>0)B=B+1|0;else break}M=zt(R|0,0,56)|0,T=M|T,M=ee()|0|me,R=H,f[R>>2]=T,f[R+4>>2]=M,R=re+2|0}while(!1);(R|0)==7?(Re=jt+(A<<3)|0,f[Re>>2]=T,f[Re+4>>2]=M&-117440513,A=rn(A|0,ge|0,1,0)|0,Re=ee()|0):Re=ge}if(Ne=rn(Ne|0,Ie|0,1,0)|0,Ie=ee()|0,(Ie|0)<(_|0)|(Ie|0)==(_|0)&Ne>>>0

>>0)ge=Re;else break}if(pn){if(Je=Bn>>>0>15,He=zt(Bn|0,0,52)|0,Ve=ee()|0,!cn){for(T=0,B=0,R=0,M=0;(F|0)==0&(y|0)==0||(Bn=d+(T<<3)|0,f[Bn>>2]=F,f[Bn+4>>2]=y,T=rn(T|0,B|0,1,0)|0,B=ee()|0),R=rn(R|0,M|0,1,0)|0,M=ee()|0,!!((M|0)<(_|0)|(M|0)==(_|0)&R>>>0

>>0);)y=gn+(R<<3)|0,F=f[y>>2]|0,y=f[y+4>>2]|0;y=Re;break}for(T=0,B=0,M=0,R=0;;){do if(!((F|0)==0&(y|0)==0)){if(pe=Ut(F|0,y|0,52)|0,ee()|0,pe=pe&15,Je|(pe|0)<(Bn|0)){Ht=80;break e}if((pe|0)!=(Bn|0)){if(H=F|He,re=y&-15728641|Ve,pe>>>0>=jn>>>0){me=Bn;do cn=zt(7,0,(14-me|0)*3|0)|0,me=me+1|0,H=cn|H,re=ee()|0|re;while(me>>>0>>0)}}else H=F,re=y;ge=lc(H|0,re|0,p|0,_|0)|0,me=0,pe=0,Ie=ee()|0;do{if((me|0)>(_|0)|(me|0)==(_|0)&pe>>>0>p>>>0){Ht=81;break e}if(cn=Pn+(ge<<3)|0,Ne=f[cn+4>>2]|0,(Ne&-117440513|0)==(re|0)&&(f[cn>>2]|0)==(H|0)){Ht=65;break}cn=rn(ge|0,Ie|0,1,0)|0,ge=oh(cn|0,ee()|0,p|0,_|0)|0,Ie=ee()|0,pe=rn(pe|0,me|0,1,0)|0,me=ee()|0,cn=Pn+(ge<<3)|0}while(!((f[cn>>2]|0)==(H|0)&&(f[cn+4>>2]|0)==(re|0)));if((Ht|0)==65&&(Ht=0,!0&(Ne&117440512|0)==100663296))break;cn=d+(T<<3)|0,f[cn>>2]=F,f[cn+4>>2]=y,T=rn(T|0,B|0,1,0)|0,B=ee()|0}while(!1);if(M=rn(M|0,R|0,1,0)|0,R=ee()|0,!((R|0)<(_|0)|(R|0)==(_|0)&M>>>0

>>0))break;y=gn+(M<<3)|0,F=f[y>>2]|0,y=f[y+4>>2]|0}y=Re}else T=0,y=Re}else T=0,A=0,y=0;while(!1);if(vo(Pn|0,0,ei|0)|0,Yl(gn|0,jt|0,A<<3|0)|0,wn(jt),(A|0)==0&(y|0)==0){Ht=89;break}else d=d+(T<<3)|0,_=y,p=A}if((Ht|0)==16)!0&(y&117440512|0)==0?(y=4,Ht=27):Ht=21;else if((Ht|0)==31)Vt(27795,27122,620,27132);else{if((Ht|0)==41)return wn(gn),wn(Pn),Ht=10,Ht|0;if((Ht|0)==48)return wn(gn),wn(Pn),Ht=13,Ht|0;(Ht|0)==80?Vt(27795,27122,711,27132):(Ht|0)==81?Vt(27795,27122,723,27132):(Ht|0)==85&&(Yl(d|0,gn|0,p<<3|0)|0,Ht=89)}return(Ht|0)==21?(wn(gn),wn(Pn),Ht=5,Ht|0):(Ht|0)==27?(wn(gn),wn(Pn),Ht=y,Ht|0):(Ht|0)==89?(wn(gn),wn(Pn),Ht=0,Ht|0):0}function x1(A,d,p,_,y,T,M){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0,M=M|0;var R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0;if(Ne=Z,Z=Z+16|0,ge=Ne,!((p|0)>0|(p|0)==0&d>>>0>0))return ge=0,Z=Ne,ge|0;if((M|0)>=16)return ge=12,Z=Ne,ge|0;me=0,pe=0,re=0,R=0;e:for(;;){if(F=A+(me<<3)|0,B=f[F>>2]|0,F=f[F+4>>2]|0,H=Ut(B|0,F|0,52)|0,ee()|0,(H&15|0)>(M|0)){R=12,B=11;break}if(pl(ge,B,F,M),H=ge,F=f[H>>2]|0,H=f[H+4>>2]|0,(F|0)==0&(H|0)==0)B=re;else{B=re;do{if(!((R|0)<(T|0)|(R|0)==(T|0)&B>>>0>>0)){B=10;break e}re=_+(B<<3)|0,f[re>>2]=F,f[re+4>>2]=H,B=rn(B|0,R|0,1,0)|0,R=ee()|0,ff(ge),re=ge,F=f[re>>2]|0,H=f[re+4>>2]|0}while(!((F|0)==0&(H|0)==0))}if(me=rn(me|0,pe|0,1,0)|0,pe=ee()|0,(pe|0)<(p|0)|(pe|0)==(p|0)&me>>>0>>0)re=B;else{R=0,B=11;break}}return(B|0)==10?(ge=14,Z=Ne,ge|0):(B|0)==11?(Z=Ne,R|0):0}function b1(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;me=Z,Z=Z+16|0,re=me;e:do if((p|0)>0|(p|0)==0&d>>>0>0){for(F=0,M=0,T=0,H=0;;){if(B=A+(F<<3)|0,R=f[B>>2]|0,B=f[B+4>>2]|0,!((R|0)==0&(B|0)==0)&&(B=(hf(R,B,_,re)|0)==0,R=re,M=rn(f[R>>2]|0,f[R+4>>2]|0,M|0,T|0)|0,T=ee()|0,!B)){T=12;break}if(F=rn(F|0,H|0,1,0)|0,H=ee()|0,!((H|0)<(p|0)|(H|0)==(p|0)&F>>>0>>0))break e}return Z=me,T|0}else M=0,T=0;while(!1);return f[y>>2]=M,f[y+4>>2]=T,y=0,Z=me,y|0}function S1(A,d){return A=A|0,d=d|0,d=Ut(A|0,d|0,52)|0,ee()|0,d&1|0}function ta(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;if(y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,!y)return y=0,y|0;for(_=1;;){if(p=Ut(A|0,d|0,(15-_|0)*3|0)|0,ee()|0,p=p&7,p|0){_=5;break}if(_>>>0>>0)_=_+1|0;else{p=0,_=5;break}}return(_|0)==5?p|0:0}function hp(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(B=Ut(A|0,d|0,52)|0,ee()|0,B=B&15,!B)return R=d,B=A,Mt(R|0),B|0;for(R=1,p=0;;){T=(15-R|0)*3|0,_=zt(7,0,T|0)|0,y=ee()|0,M=Ut(A|0,d|0,T|0)|0,ee()|0,T=zt(qu(M&7)|0,0,T|0)|0,M=ee()|0,A=T|A&~_,d=M|d&~y;e:do if(!p)if((T&_|0)==0&(M&y|0)==0)p=0;else if(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ut(A|0,d|0,(15-p|0)*3|0)|0,ee()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(M=(15-p|0)*3|0,y=Ut(A|0,d|0,M|0)|0,ee()|0,T=zt(7,0,M|0)|0,d=d&~(ee()|0),M=zt(qu(y&7)|0,0,M|0)|0,A=A&~T|M,d=d|(ee()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return Mt(d|0),A|0}function $u(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;if(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,!_)return p=d,_=A,Mt(p|0),_|0;for(p=1;T=(15-p|0)*3|0,M=Ut(A|0,d|0,T|0)|0,ee()|0,y=zt(7,0,T|0)|0,d=d&~(ee()|0),T=zt(qu(M&7)|0,0,T|0)|0,A=T|A&~y,d=ee()|0|d,p>>>0<_>>>0;)p=p+1|0;return Mt(d|0),A|0}function Tx(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(B=Ut(A|0,d|0,52)|0,ee()|0,B=B&15,!B)return R=d,B=A,Mt(R|0),B|0;for(R=1,p=0;;){T=(15-R|0)*3|0,_=zt(7,0,T|0)|0,y=ee()|0,M=Ut(A|0,d|0,T|0)|0,ee()|0,T=zt(Al(M&7)|0,0,T|0)|0,M=ee()|0,A=T|A&~_,d=M|d&~y;e:do if(!p)if((T&_|0)==0&(M&y|0)==0)p=0;else if(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ut(A|0,d|0,(15-p|0)*3|0)|0,ee()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(y=(15-p|0)*3|0,T=zt(7,0,y|0)|0,M=d&~(ee()|0),d=Ut(A|0,d|0,y|0)|0,ee()|0,d=zt(Al(d&7)|0,0,y|0)|0,A=A&~T|d,d=M|(ee()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return Mt(d|0),A|0}function fp(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;if(_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,!_)return p=d,_=A,Mt(p|0),_|0;for(p=1;M=(15-p|0)*3|0,T=zt(7,0,M|0)|0,y=d&~(ee()|0),d=Ut(A|0,d|0,M|0)|0,ee()|0,d=zt(Al(d&7)|0,0,M|0)|0,A=d|A&~T,d=ee()|0|y,p>>>0<_>>>0;)p=p+1|0;return Mt(d|0),A|0}function ya(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(B=Z,Z=Z+64|0,R=B+40|0,_=B+24|0,y=B+12|0,T=B,zt(d|0,0,52)|0,p=ee()|0|134225919,!d)return(f[A+4>>2]|0)>2||(f[A+8>>2]|0)>2||(f[A+12>>2]|0)>2?(M=0,R=0,Mt(M|0),Z=B,R|0):(zt(er(A)|0,0,45)|0,M=ee()|0|p,R=-1,Mt(M|0),Z=B,R|0);if(f[R>>2]=f[A>>2],f[R+4>>2]=f[A+4>>2],f[R+8>>2]=f[A+8>>2],f[R+12>>2]=f[A+12>>2],M=R+4|0,(d|0)>0)for(A=-1;f[_>>2]=f[M>>2],f[_+4>>2]=f[M+4>>2],f[_+8>>2]=f[M+8>>2],d&1?(hx(M),f[y>>2]=f[M>>2],f[y+4>>2]=f[M+4>>2],f[y+8>>2]=f[M+8>>2],th(y)):(u1(M),f[y>>2]=f[M>>2],f[y+4>>2]=f[M+4>>2],f[y+8>>2]=f[M+8>>2],Gu(y)),uf(_,y,T),jr(T),H=(15-d|0)*3|0,F=zt(7,0,H|0)|0,p=p&~(ee()|0),H=zt(zu(T)|0,0,H|0)|0,A=H|A&~F,p=ee()|0|p,(d|0)>1;)d=d+-1|0;else A=-1;e:do if((f[M>>2]|0)<=2&&(f[R+8>>2]|0)<=2&&(f[R+12>>2]|0)<=2){if(_=er(R)|0,d=zt(_|0,0,45)|0,d=d|A,A=ee()|0|p&-1040385,T=po(R)|0,!($n(_)|0)){if((T|0)<=0)break;for(y=0;;){if(_=Ut(d|0,A|0,52)|0,ee()|0,_=_&15,_)for(p=1;H=(15-p|0)*3|0,R=Ut(d|0,A|0,H|0)|0,ee()|0,F=zt(7,0,H|0)|0,A=A&~(ee()|0),H=zt(qu(R&7)|0,0,H|0)|0,d=d&~F|H,A=A|(ee()|0),p>>>0<_>>>0;)p=p+1|0;if(y=y+1|0,(y|0)==(T|0))break e}}y=Ut(d|0,A|0,52)|0,ee()|0,y=y&15;t:do if(y){p=1;n:for(;;){switch(H=Ut(d|0,A|0,(15-p|0)*3|0)|0,ee()|0,H&7){case 1:break n;case 0:break;default:break t}if(p>>>0>>0)p=p+1|0;else break t}if(yi(_,f[R>>2]|0)|0)for(p=1;R=(15-p|0)*3|0,F=zt(7,0,R|0)|0,H=A&~(ee()|0),A=Ut(d|0,A|0,R|0)|0,ee()|0,A=zt(Al(A&7)|0,0,R|0)|0,d=d&~F|A,A=H|(ee()|0),p>>>0>>0;)p=p+1|0;else for(p=1;H=(15-p|0)*3|0,R=Ut(d|0,A|0,H|0)|0,ee()|0,F=zt(7,0,H|0)|0,A=A&~(ee()|0),H=zt(qu(R&7)|0,0,H|0)|0,d=d&~F|H,A=A|(ee()|0),p>>>0>>0;)p=p+1|0}while(!1);if((T|0)>0){p=0;do d=hp(d,A)|0,A=ee()|0,p=p+1|0;while((p|0)!=(T|0))}}else d=0,A=0;while(!1);return F=A,H=d,Mt(F|0),Z=B,H|0}function Ps(A){return A=A|0,(A|0)%2|0|0}function Bd(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;return y=Z,Z=Z+16|0,_=y,d>>>0>15?(_=4,Z=y,_|0):(f[A+4>>2]&2146435072|0)==2146435072||(f[A+8+4>>2]&2146435072|0)==2146435072?(_=3,Z=y,_|0):(_x(A,d,_),d=ya(_,d)|0,_=ee()|0,f[p>>2]=d,f[p+4>>2]=_,(d|0)==0&(_|0)==0&&Vt(27795,27122,1050,27145),_=0,Z=y,_|0)}function Od(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;if(y=p+4|0,T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,M=Ut(A|0,d|0,45)|0,ee()|0,_=(T|0)==0,$n(M&127)|0){if(_)return M=1,M|0;_=1}else{if(_)return M=0,M|0;(f[y>>2]|0)==0&&(f[p+8>>2]|0)==0?_=(f[p+12>>2]|0)!=0&1:_=1}for(p=1;p&1?th(y):Gu(y),M=Ut(A|0,d|0,(15-p|0)*3|0)|0,ee()|0,c1(y,M&7),p>>>0>>0;)p=p+1|0;return _|0}function Xu(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(H=Z,Z=Z+16|0,B=H,F=Ut(A|0,d|0,45)|0,ee()|0,F=F&127,F>>>0>121)return f[p>>2]=0,f[p+4>>2]=0,f[p+8>>2]=0,f[p+12>>2]=0,F=5,Z=H,F|0;e:do if(($n(F)|0)!=0&&(T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,(T|0)!=0)){_=1;t:for(;;){switch(R=Ut(A|0,d|0,(15-_|0)*3|0)|0,ee()|0,R&7){case 5:break t;case 0:break;default:{_=d;break e}}if(_>>>0>>0)_=_+1|0;else{_=d;break e}}for(y=1,_=d;d=(15-y|0)*3|0,M=zt(7,0,d|0)|0,R=_&~(ee()|0),_=Ut(A|0,_|0,d|0)|0,ee()|0,_=zt(Al(_&7)|0,0,d|0)|0,A=A&~M|_,_=R|(ee()|0),y>>>0>>0;)y=y+1|0}else _=d;while(!1);if(R=7696+(F*28|0)|0,f[p>>2]=f[R>>2],f[p+4>>2]=f[R+4>>2],f[p+8>>2]=f[R+8>>2],f[p+12>>2]=f[R+12>>2],!(Od(A,_,p)|0))return F=0,Z=H,F|0;if(M=p+4|0,f[B>>2]=f[M>>2],f[B+4>>2]=f[M+4>>2],f[B+8>>2]=f[M+8>>2],T=Ut(A|0,_|0,52)|0,ee()|0,R=T&15,T&1?(Gu(M),T=R+1|0):T=R,!($n(F)|0))_=0;else{e:do if(!R)_=0;else for(d=1;;){if(y=Ut(A|0,_|0,(15-d|0)*3|0)|0,ee()|0,y=y&7,y|0){_=y;break e}if(d>>>0>>0)d=d+1|0;else{_=0;break}}while(!1);_=(_|0)==4&1}if(!(ju(p,T,_,0)|0))(T|0)!=(R|0)&&(f[M>>2]=f[B>>2],f[M+4>>2]=f[B+4>>2],f[M+8>>2]=f[B+8>>2]);else{if($n(F)|0)do;while((ju(p,T,0,0)|0)!=0);(T|0)!=(R|0)&&u1(M)}return F=0,Z=H,F|0}function jl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;return T=Z,Z=Z+16|0,_=T,y=Xu(A,d,_)|0,y|0?(Z=T,y|0):(y=Ut(A|0,d|0,52)|0,ee()|0,cf(_,y&15,p),y=0,Z=T,y|0)}function Hl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0;if(M=Z,Z=Z+16|0,T=M,_=Xu(A,d,T)|0,_|0)return T=_,Z=M,T|0;_=Ut(A|0,d|0,45)|0,ee()|0,_=($n(_&127)|0)==0,y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15;e:do if(!_){if(y|0)for(_=1;;){if(R=zt(7,0,(15-_|0)*3|0)|0,!((R&A|0)==0&((ee()|0)&d|0)==0))break e;if(_>>>0>>0)_=_+1|0;else break}return ap(T,y,0,5,p),R=0,Z=M,R|0}while(!1);return Pd(T,y,0,6,p),R=0,Z=M,R|0}function wx(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if(y=Ut(A|0,d|0,45)|0,ee()|0,!($n(y&127)|0))return y=2,f[p>>2]=y,0;if(y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,!y)return y=5,f[p>>2]=y,0;for(_=1;;){if(T=zt(7,0,(15-_|0)*3|0)|0,!((T&A|0)==0&((ee()|0)&d|0)==0)){_=2,A=6;break}if(_>>>0>>0)_=_+1|0;else{_=5,A=6;break}}return(A|0)==6&&(f[p>>2]=_),0}function Yu(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0;re=Z,Z=Z+128|0,F=re+112|0,T=re+96|0,H=re,y=Ut(A|0,d|0,52)|0,ee()|0,R=y&15,f[F>>2]=R,M=Ut(A|0,d|0,45)|0,ee()|0,M=M&127;e:do if($n(M)|0){if(R|0)for(_=1;;){if(B=zt(7,0,(15-_|0)*3|0)|0,!((B&A|0)==0&((ee()|0)&d|0)==0)){y=0;break e}if(_>>>0>>0)_=_+1|0;else break}if(y&1)y=1;else return B=zt(R+1|0,0,52)|0,H=ee()|0|d&-15728641,F=zt(7,0,(14-R|0)*3|0)|0,H=Yu((B|A)&~F,H&~(ee()|0),p)|0,Z=re,H|0}else y=0;while(!1);if(_=Xu(A,d,T)|0,!_){y?(op(T,F,H),B=5):(lp(T,F,H),B=6);e:do if($n(M)|0)if(!R)A=5;else for(_=1;;){if(M=zt(7,0,(15-_|0)*3|0)|0,!((M&A|0)==0&((ee()|0)&d|0)==0)){A=2;break e}if(_>>>0>>0)_=_+1|0;else{A=5;break}}else A=2;while(!1);vo(p|0,-1,A<<2|0)|0;e:do if(y)for(T=0;;){if(M=H+(T<<4)|0,g1(M,f[F>>2]|0)|0,M=f[M>>2]|0,R=f[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=A>>>0){_=1;break e}_=p+(y<<2)|0,R=f[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(f[_>>2]=M,T=T+1|0,T>>>0>=B>>>0){_=0;break}}else for(T=0;;){if(M=H+(T<<4)|0,ju(M,f[F>>2]|0,0,1)|0,M=f[M>>2]|0,R=f[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=A>>>0){_=1;break e}_=p+(y<<2)|0,R=f[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(f[_>>2]=M,T=T+1|0,T>>>0>=B>>>0){_=0;break}}while(!1)}return H=_,Z=re,H|0}function dp(){return 12}function Qu(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(A>>>0>15)return R=4,R|0;if(zt(A|0,0,52)|0,R=ee()|0|134225919,!A){p=0,_=0;do $n(_)|0&&(zt(_|0,0,45)|0,M=R|(ee()|0),A=d+(p<<3)|0,f[A>>2]=-1,f[A+4>>2]=M,p=p+1|0),_=_+1|0;while((_|0)!=122);return p=0,p|0}p=0,M=0;do{if($n(M)|0){for(zt(M|0,0,45)|0,_=1,y=-1,T=R|(ee()|0);B=zt(7,0,(15-_|0)*3|0)|0,y=y&~B,T=T&~(ee()|0),(_|0)!=(A|0);)_=_+1|0;B=d+(p<<3)|0,f[B>>2]=y,f[B+4>>2]=T,p=p+1|0}M=M+1|0}while((M|0)!=122);return p=0,p|0}function Ap(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0;if(He=Z,Z=Z+16|0,Ie=He,Je=Ut(A|0,d|0,52)|0,ee()|0,Je=Je&15,p>>>0>15)return Je=4,Z=He,Je|0;if((Je|0)<(p|0))return Je=12,Z=He,Je|0;if((Je|0)!=(p|0))if(T=zt(p|0,0,52)|0,T=T|A,R=ee()|0|d&-15728641,(Je|0)>(p|0)){B=p;do Ne=zt(7,0,(14-B|0)*3|0)|0,B=B+1|0,T=Ne|T,R=ee()|0|R;while((B|0)<(Je|0));Ne=T}else Ne=T;else Ne=A,R=d;ge=Ut(Ne|0,R|0,45)|0,ee()|0;e:do if($n(ge&127)|0){if(B=Ut(Ne|0,R|0,52)|0,ee()|0,B=B&15,B|0)for(T=1;;){if(ge=zt(7,0,(15-T|0)*3|0)|0,!((ge&Ne|0)==0&((ee()|0)&R|0)==0)){F=33;break e}if(T>>>0>>0)T=T+1|0;else break}if(ge=_,f[ge>>2]=0,f[ge+4>>2]=0,(Je|0)>(p|0)){for(ge=d&-15728641,pe=Je;;){if(me=pe,pe=pe+-1|0,pe>>>0>15|(Je|0)<(pe|0)){F=19;break}if((Je|0)!=(pe|0))if(T=zt(pe|0,0,52)|0,T=T|A,B=ee()|0|ge,(Je|0)<(me|0))re=T;else{F=pe;do re=zt(7,0,(14-F|0)*3|0)|0,F=F+1|0,T=re|T,B=ee()|0|B;while((F|0)<(Je|0));re=T}else re=A,B=d;if(H=Ut(re|0,B|0,45)|0,ee()|0,!($n(H&127)|0))T=0;else{H=Ut(re|0,B|0,52)|0,ee()|0,H=H&15;t:do if(!H)T=0;else for(F=1;;){if(T=Ut(re|0,B|0,(15-F|0)*3|0)|0,ee()|0,T=T&7,T|0)break t;if(F>>>0>>0)F=F+1|0;else{T=0;break}}while(!1);T=(T|0)==0&1}if(B=Ut(A|0,d|0,(15-me|0)*3|0)|0,ee()|0,B=B&7,(B|0)==7){y=5,F=42;break}if(T=(T|0)!=0,(B|0)==1&T){y=5,F=42;break}if(re=B+(((B|0)!=0&T)<<31>>31)|0,re|0&&(F=Je-me|0,F=jo(7,0,F,((F|0)<0)<<31>>31)|0,H=ee()|0,T?(T=vr(F|0,H|0,5,0)|0,T=rn(T|0,ee()|0,-5,-1)|0,T=Xo(T|0,ee()|0,6,0)|0,T=rn(T|0,ee()|0,1,0)|0,B=ee()|0):(T=F,B=H),me=re+-1|0,me=vr(F|0,H|0,me|0,((me|0)<0)<<31>>31|0)|0,me=rn(T|0,B|0,me|0,ee()|0)|0,re=ee()|0,H=_,H=rn(me|0,re|0,f[H>>2]|0,f[H+4>>2]|0)|0,re=ee()|0,me=_,f[me>>2]=H,f[me+4>>2]=re),(pe|0)<=(p|0)){F=37;break}}if((F|0)==19)Vt(27795,27122,1367,27158);else if((F|0)==37){M=_,y=f[M+4>>2]|0,M=f[M>>2]|0;break}else if((F|0)==42)return Z=He,y|0}else y=0,M=0}else F=33;while(!1);e:do if((F|0)==33)if(ge=_,f[ge>>2]=0,f[ge+4>>2]=0,(Je|0)>(p|0)){for(T=Je;;){if(y=Ut(A|0,d|0,(15-T|0)*3|0)|0,ee()|0,y=y&7,(y|0)==7){y=5;break}if(M=Je-T|0,M=jo(7,0,M,((M|0)<0)<<31>>31)|0,y=vr(M|0,ee()|0,y|0,0)|0,M=ee()|0,ge=_,M=rn(f[ge>>2]|0,f[ge+4>>2]|0,y|0,M|0)|0,y=ee()|0,ge=_,f[ge>>2]=M,f[ge+4>>2]=y,T=T+-1|0,(T|0)<=(p|0))break e}return Z=He,y|0}else y=0,M=0;while(!1);return hf(Ne,R,Je,Ie)|0&&Vt(27795,27122,1327,27173),Je=Ie,Ie=f[Je+4>>2]|0,((y|0)>-1|(y|0)==-1&M>>>0>4294967295)&((Ie|0)>(y|0)|((Ie|0)==(y|0)?(f[Je>>2]|0)>>>0>M>>>0:0))?(Je=0,Z=He,Je|0):(Vt(27795,27122,1407,27158),0)}function T1(A,d,p,_,y,T){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0;if(re=Z,Z=Z+16|0,M=re,y>>>0>15)return T=4,Z=re,T|0;if(R=Ut(p|0,_|0,52)|0,ee()|0,R=R&15,(R|0)>(y|0))return T=12,Z=re,T|0;if(hf(p,_,y,M)|0&&Vt(27795,27122,1327,27173),H=M,F=f[H+4>>2]|0,!(((d|0)>-1|(d|0)==-1&A>>>0>4294967295)&((F|0)>(d|0)|((F|0)==(d|0)?(f[H>>2]|0)>>>0>A>>>0:0))))return T=2,Z=re,T|0;H=y-R|0,y=zt(y|0,0,52)|0,B=ee()|0|_&-15728641,F=T,f[F>>2]=y|p,f[F+4>>2]=B,F=Ut(p|0,_|0,45)|0,ee()|0;e:do if($n(F&127)|0){if(R|0)for(M=1;;){if(F=zt(7,0,(15-M|0)*3|0)|0,!((F&p|0)==0&((ee()|0)&_|0)==0))break e;if(M>>>0>>0)M=M+1|0;else break}if((H|0)<1)return T=0,Z=re,T|0;for(F=R^15,_=-1,B=1,M=1;;){R=H-B|0,R=jo(7,0,R,((R|0)<0)<<31>>31)|0,p=ee()|0;do if(M)if(M=vr(R|0,p|0,5,0)|0,M=rn(M|0,ee()|0,-5,-1)|0,M=Xo(M|0,ee()|0,6,0)|0,y=ee()|0,(d|0)>(y|0)|(d|0)==(y|0)&A>>>0>M>>>0){d=rn(A|0,d|0,-1,-1)|0,d=Hr(d|0,ee()|0,M|0,y|0)|0,M=ee()|0,me=T,ge=f[me>>2]|0,me=f[me+4>>2]|0,Ne=(F+_|0)*3|0,pe=zt(7,0,Ne|0)|0,me=me&~(ee()|0),_=Xo(d|0,M|0,R|0,p|0)|0,A=ee()|0,y=rn(_|0,A|0,2,0)|0,Ne=zt(y|0,ee()|0,Ne|0)|0,me=ee()|0|me,y=T,f[y>>2]=Ne|ge&~pe,f[y+4>>2]=me,A=vr(_|0,A|0,R|0,p|0)|0,A=Hr(d|0,M|0,A|0,ee()|0)|0,M=0,d=ee()|0;break}else{Ne=T,pe=f[Ne>>2]|0,Ne=f[Ne+4>>2]|0,ge=zt(7,0,(F+_|0)*3|0)|0,Ne=Ne&~(ee()|0),M=T,f[M>>2]=pe&~ge,f[M+4>>2]=Ne,M=1;break}else pe=T,y=f[pe>>2]|0,pe=f[pe+4>>2]|0,_=(F+_|0)*3|0,me=zt(7,0,_|0)|0,pe=pe&~(ee()|0),Ne=Xo(A|0,d|0,R|0,p|0)|0,M=ee()|0,_=zt(Ne|0,M|0,_|0)|0,pe=ee()|0|pe,ge=T,f[ge>>2]=_|y&~me,f[ge+4>>2]=pe,M=vr(Ne|0,M|0,R|0,p|0)|0,A=Hr(A|0,d|0,M|0,ee()|0)|0,M=0,d=ee()|0;while(!1);if((H|0)>(B|0))_=~B,B=B+1|0;else{d=0;break}}return Z=re,d|0}while(!1);if((H|0)<1)return Ne=0,Z=re,Ne|0;for(y=R^15,M=1;;)if(ge=H-M|0,ge=jo(7,0,ge,((ge|0)<0)<<31>>31)|0,Ne=ee()|0,B=T,p=f[B>>2]|0,B=f[B+4>>2]|0,R=(y-M|0)*3|0,_=zt(7,0,R|0)|0,B=B&~(ee()|0),me=Xo(A|0,d|0,ge|0,Ne|0)|0,pe=ee()|0,R=zt(me|0,pe|0,R|0)|0,B=ee()|0|B,F=T,f[F>>2]=R|p&~_,f[F+4>>2]=B,Ne=vr(me|0,pe|0,ge|0,Ne|0)|0,A=Hr(A|0,d|0,Ne|0,ee()|0)|0,d=ee()|0,(H|0)<=(M|0)){d=0;break}else M=M+1|0;return Z=re,d|0}function pl(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0;y=Ut(d|0,p|0,52)|0,ee()|0,y=y&15,(d|0)==0&(p|0)==0|((_|0)>15|(y|0)>(_|0))?(T=-1,d=-1,p=0,y=0):(d=up(d,p,y+1|0,_)|0,M=(ee()|0)&-15728641,p=zt(_|0,0,52)|0,p=d|p,M=M|(ee()|0),d=(Ri(p,M)|0)==0,T=y,d=d?-1:_,y=M),M=A,f[M>>2]=p,f[M+4>>2]=y,f[A+8>>2]=T,f[A+12>>2]=d}function Ku(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0;if(y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,T=_+8|0,f[T>>2]=y,(A|0)==0&(d|0)==0|((p|0)>15|(y|0)>(p|0))){p=_,f[p>>2]=0,f[p+4>>2]=0,f[T>>2]=-1,f[_+12>>2]=-1;return}if(A=up(A,d,y+1|0,p)|0,T=(ee()|0)&-15728641,y=zt(p|0,0,52)|0,y=A|y,T=T|(ee()|0),A=_,f[A>>2]=y,f[A+4>>2]=T,A=_+12|0,Ri(y,T)|0){f[A>>2]=p;return}else{f[A>>2]=-1;return}}function ff(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0;if(p=A,d=f[p>>2]|0,p=f[p+4>>2]|0,!((d|0)==0&(p|0)==0)&&(_=Ut(d|0,p|0,52)|0,ee()|0,_=_&15,R=zt(1,0,(_^15)*3|0)|0,d=rn(R|0,ee()|0,d|0,p|0)|0,p=ee()|0,R=A,f[R>>2]=d,f[R+4>>2]=p,R=A+8|0,M=f[R>>2]|0,!((_|0)<(M|0)))){for(B=A+12|0,T=_;;){if((T|0)==(M|0)){_=5;break}if(F=(T|0)==(f[B>>2]|0),y=(15-T|0)*3|0,_=Ut(d|0,p|0,y|0)|0,ee()|0,_=_&7,F&((_|0)==1&!0)){_=7;break}if(!((_|0)==7&!0)){_=10;break}if(F=zt(1,0,y|0)|0,d=rn(d|0,p|0,F|0,ee()|0)|0,p=ee()|0,F=A,f[F>>2]=d,f[F+4>>2]=p,(T|0)>(M|0))T=T+-1|0;else{_=10;break}}if((_|0)==5){F=A,f[F>>2]=0,f[F+4>>2]=0,f[R>>2]=-1,f[B>>2]=-1;return}else if((_|0)==7){M=zt(1,0,y|0)|0,M=rn(d|0,p|0,M|0,ee()|0)|0,R=ee()|0,F=A,f[F>>2]=M,f[F+4>>2]=R,f[B>>2]=T+-1;return}else if((_|0)==10)return}}function ih(A){A=+A;var d=0;return d=A<0?A+6.283185307179586:A,+(A>=6.283185307179586?d+-6.283185307179586:d)}function La(A,d){return A=A|0,d=d|0,+An(+(+J[A>>3]-+J[d>>3]))<17453292519943298e-27?(d=+An(+(+J[A+8>>3]-+J[d+8>>3]))<17453292519943298e-27,d|0):(d=0,d|0)}function na(A,d){switch(A=+A,d=d|0,d|0){case 1:{A=A<0?A+6.283185307179586:A;break}case 2:{A=A>0?A+-6.283185307179586:A;break}}return+A}function w1(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return y=+J[d>>3],_=+J[A>>3],T=+xn(+((y-_)*.5)),p=+xn(+((+J[d+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+on(+y)*+on(+_)*p),+(+Fe(+ +yn(+p),+ +yn(+(1-p)))*2)}function rh(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return y=+J[d>>3],_=+J[A>>3],T=+xn(+((y-_)*.5)),p=+xn(+((+J[d+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+on(+y)*+on(+_)*p),+(+Fe(+ +yn(+p),+ +yn(+(1-p)))*2*6371.007180918475)}function Mx(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return y=+J[d>>3],_=+J[A>>3],T=+xn(+((y-_)*.5)),p=+xn(+((+J[d+8>>3]-+J[A+8>>3])*.5)),p=T*T+p*(+on(+y)*+on(+_)*p),+(+Fe(+ +yn(+p),+ +yn(+(1-p)))*2*6371.007180918475*1e3)}function Ex(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0;return T=+J[d>>3],_=+on(+T),y=+J[d+8>>3]-+J[A+8>>3],M=_*+xn(+y),p=+J[A>>3],+ +Fe(+M,+(+xn(+T)*+on(+p)-+on(+y)*(_*+xn(+p))))}function Cx(A,d,p,_){A=A|0,d=+d,p=+p,_=_|0;var y=0,T=0,M=0,R=0;if(p<1e-16){f[_>>2]=f[A>>2],f[_+4>>2]=f[A+4>>2],f[_+8>>2]=f[A+8>>2],f[_+12>>2]=f[A+12>>2];return}T=d<0?d+6.283185307179586:d,T=d>=6.283185307179586?T+-6.283185307179586:T;do if(T<1e-16)d=+J[A>>3]+p,J[_>>3]=d,y=_;else{if(y=+An(+(T+-3.141592653589793))<1e-16,d=+J[A>>3],y){d=d-p,J[_>>3]=d,y=_;break}if(M=+on(+p),p=+xn(+p),d=M*+xn(+d)+ +on(+T)*(p*+on(+d)),d=d>1?1:d,d=+Ao(+(d<-1?-1:d)),J[_>>3]=d,+An(+(d+-1.5707963267948966))<1e-16){J[_>>3]=1.5707963267948966,J[_+8>>3]=0;return}if(+An(+(d+1.5707963267948966))<1e-16){J[_>>3]=-1.5707963267948966,J[_+8>>3]=0;return}if(R=1/+on(+d),T=p*+xn(+T)*R,p=+J[A>>3],d=R*((M-+xn(+d)*+xn(+p))/+on(+p)),M=T>1?1:T,d=d>1?1:d,d=+J[A+8>>3]+ +Fe(+(M<-1?-1:M),+(d<-1?-1:d)),d>3.141592653589793)do d=d+-6.283185307179586;while(d>3.141592653589793);if(d<-3.141592653589793)do d=d+6.283185307179586;while(d<-3.141592653589793);J[_+8>>3]=d;return}while(!1);if(+An(+(d+-1.5707963267948966))<1e-16){J[y>>3]=1.5707963267948966,J[_+8>>3]=0;return}if(+An(+(d+1.5707963267948966))<1e-16){J[y>>3]=-1.5707963267948966,J[_+8>>3]=0;return}if(d=+J[A+8>>3],d>3.141592653589793)do d=d+-6.283185307179586;while(d>3.141592653589793);if(d<-3.141592653589793)do d=d+6.283185307179586;while(d<-3.141592653589793);J[_+8>>3]=d}function pp(A,d){return A=A|0,d=d|0,A>>>0>15?(d=4,d|0):(J[d>>3]=+J[20656+(A<<3)>>3],d=0,d|0)}function M1(A,d){return A=A|0,d=d|0,A>>>0>15?(d=4,d|0):(J[d>>3]=+J[20784+(A<<3)>>3],d=0,d|0)}function mp(A,d){return A=A|0,d=d|0,A>>>0>15?(d=4,d|0):(J[d>>3]=+J[20912+(A<<3)>>3],d=0,d|0)}function mo(A,d){return A=A|0,d=d|0,A>>>0>15?(d=4,d|0):(J[d>>3]=+J[21040+(A<<3)>>3],d=0,d|0)}function Zu(A,d){A=A|0,d=d|0;var p=0;return A>>>0>15?(d=4,d|0):(p=jo(7,0,A,((A|0)<0)<<31>>31)|0,p=vr(p|0,ee()|0,120,0)|0,A=ee()|0,f[d>>2]=p|2,f[d+4>>2]=A,d=0,d|0)}function xa(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;return me=+J[d>>3],H=+J[A>>3],B=+xn(+((me-H)*.5)),T=+J[d+8>>3],F=+J[A+8>>3],M=+xn(+((T-F)*.5)),R=+on(+H),re=+on(+me),M=B*B+M*(re*R*M),M=+Fe(+ +yn(+M),+ +yn(+(1-M)))*2,B=+J[p>>3],me=+xn(+((B-me)*.5)),_=+J[p+8>>3],T=+xn(+((_-T)*.5)),y=+on(+B),T=me*me+T*(re*y*T),T=+Fe(+ +yn(+T),+ +yn(+(1-T)))*2,B=+xn(+((H-B)*.5)),_=+xn(+((F-_)*.5)),_=B*B+_*(R*y*_),_=+Fe(+ +yn(+_),+ +yn(+(1-_)))*2,y=(M+T+_)*.5,+(+ue(+ +yn(+(+Ar(+(y*.5))*+Ar(+((y-M)*.5))*+Ar(+((y-T)*.5))*+Ar(+((y-_)*.5)))))*4)}function Wl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0;if(R=Z,Z=Z+192|0,T=R+168|0,M=R,y=jl(A,d,T)|0,y|0)return p=y,Z=R,p|0;if(Hl(A,d,M)|0&&Vt(27795,27190,415,27199),d=f[M>>2]|0,(d|0)>0){if(_=+xa(M+8|0,M+8+(((d|0)!=1&1)<<4)|0,T)+0,(d|0)!=1){A=1;do y=A,A=A+1|0,_=_+ +xa(M+8+(y<<4)|0,M+8+(((A|0)%(d|0)|0)<<4)|0,T);while((A|0)<(d|0))}}else _=0;return J[p>>3]=_,p=0,Z=R,p|0}function gp(A,d,p){return A=A|0,d=d|0,p=p|0,A=Wl(A,d,p)|0,A|0||(J[p>>3]=+J[p>>3]*6371.007180918475*6371.007180918475),A|0}function Id(A,d,p){return A=A|0,d=d|0,p=p|0,A=Wl(A,d,p)|0,A|0||(J[p>>3]=+J[p>>3]*6371.007180918475*6371.007180918475*1e3*1e3),A|0}function Fd(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(R=Z,Z=Z+176|0,M=R,A=Dd(A,d,M)|0,A|0)return M=A,Z=R,M|0;if(J[p>>3]=0,A=f[M>>2]|0,(A|0)<=1)return M=0,Z=R,M|0;d=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,F=_,_=+J[M+8+(A<<4)>>3],H=+xn(+((_-F)*.5)),B=y,y=+J[M+8+(A<<4)+8>>3],B=+xn(+((y-B)*.5)),B=H*H+B*(+on(+_)*+on(+F)*B),T=T+ +Fe(+ +yn(+B),+ +yn(+(1-B)))*2;while((A|0)<(d|0));return J[p>>3]=T,M=0,Z=R,M|0}function vp(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(R=Z,Z=Z+176|0,M=R,A=Dd(A,d,M)|0,A|0)return M=A,T=+J[p>>3],T=T*6371.007180918475,J[p>>3]=T,Z=R,M|0;if(J[p>>3]=0,A=f[M>>2]|0,(A|0)<=1)return M=0,T=0,T=T*6371.007180918475,J[p>>3]=T,Z=R,M|0;d=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,F=_,_=+J[M+8+(A<<4)>>3],H=+xn(+((_-F)*.5)),B=y,y=+J[M+8+(A<<4)+8>>3],B=+xn(+((y-B)*.5)),B=H*H+B*(+on(+F)*+on(+_)*B),T=T+ +Fe(+ +yn(+B),+ +yn(+(1-B)))*2;while((A|0)!=(d|0));return J[p>>3]=T,M=0,H=T,H=H*6371.007180918475,J[p>>3]=H,Z=R,M|0}function Ju(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(R=Z,Z=Z+176|0,M=R,A=Dd(A,d,M)|0,A|0)return M=A,T=+J[p>>3],T=T*6371.007180918475,T=T*1e3,J[p>>3]=T,Z=R,M|0;if(J[p>>3]=0,A=f[M>>2]|0,(A|0)<=1)return M=0,T=0,T=T*6371.007180918475,T=T*1e3,J[p>>3]=T,Z=R,M|0;d=A+-1|0,A=0,_=+J[M+8>>3],y=+J[M+16>>3],T=0;do A=A+1|0,F=_,_=+J[M+8+(A<<4)>>3],H=+xn(+((_-F)*.5)),B=y,y=+J[M+8+(A<<4)+8>>3],B=+xn(+((y-B)*.5)),B=H*H+B*(+on(+F)*+on(+_)*B),T=T+ +Fe(+ +yn(+B),+ +yn(+(1-B)))*2;while((A|0)!=(d|0));return J[p>>3]=T,M=0,H=T,H=H*6371.007180918475,H=H*1e3,J[p>>3]=H,Z=R,M|0}function E1(A){A=A|0;var d=0,p=0,_=0;return d=sa(1,12)|0,d||Vt(27280,27235,49,27293),p=A+4|0,_=f[p>>2]|0,_|0?(_=_+8|0,f[_>>2]=d,f[p>>2]=d,d|0):(f[A>>2]|0&&Vt(27310,27235,61,27333),_=A,f[_>>2]=d,f[p>>2]=d,d|0)}function kd(A,d){A=A|0,d=d|0;var p=0,_=0;return _=$o(24)|0,_||Vt(27347,27235,78,27361),f[_>>2]=f[d>>2],f[_+4>>2]=f[d+4>>2],f[_+8>>2]=f[d+8>>2],f[_+12>>2]=f[d+12>>2],f[_+16>>2]=0,d=A+4|0,p=f[d>>2]|0,p|0?(f[p+16>>2]=_,f[d>>2]=_,_|0):(f[A>>2]|0&&Vt(27376,27235,82,27361),f[A>>2]=_,f[d>>2]=_,_|0)}function ec(A){A=A|0;var d=0,p=0,_=0,y=0;if(A)for(_=1;;){if(d=f[A>>2]|0,d|0)do{if(p=f[d>>2]|0,p|0)do y=p,p=f[p+16>>2]|0,wn(y);while((p|0)!=0);y=d,d=f[d+8>>2]|0,wn(y)}while((d|0)!=0);if(d=A,A=f[A+8>>2]|0,_||wn(d),A)_=0;else break}}function Nx(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0,Bn=0,ei=0,Pn=0,gn=0,Ht=0,Cn=0,li=0,Ln=0;if(y=A+8|0,f[y>>2]|0)return Ln=1,Ln|0;if(_=f[A>>2]|0,!_)return Ln=0,Ln|0;d=_,p=0;do p=p+1|0,d=f[d+8>>2]|0;while((d|0)!=0);if(p>>>0<2)return Ln=0,Ln|0;Cn=$o(p<<2)|0,Cn||Vt(27396,27235,317,27415),Ht=$o(p<<5)|0,Ht||Vt(27437,27235,321,27415),f[A>>2]=0,pn=A+4|0,f[pn>>2]=0,f[y>>2]=0,p=0,gn=0,jt=0,re=0;e:for(;;){if(H=f[_>>2]|0,H){T=0,M=H;do{if(B=+J[M+8>>3],d=M,M=f[M+16>>2]|0,F=(M|0)==0,y=F?H:M,R=+J[y+8>>3],+An(+(B-R))>3.141592653589793){Ln=14;break}T=T+(R-B)*(+J[d>>3]+ +J[y>>3])}while(!F);if((Ln|0)==14){Ln=0,T=0,d=H;do Re=+J[d+8>>3],Pn=d+16|0,ei=f[Pn>>2]|0,ei=(ei|0)==0?H:ei,Ve=+J[ei+8>>3],T=T+(+J[d>>3]+ +J[ei>>3])*((Ve<0?Ve+6.283185307179586:Ve)-(Re<0?Re+6.283185307179586:Re)),d=f[((d|0)==0?_:Pn)>>2]|0;while((d|0)!=0)}T>0?(f[Cn+(gn<<2)>>2]=_,gn=gn+1|0,y=jt,d=re):Ln=19}else Ln=19;if((Ln|0)==19){Ln=0;do if(p){if(d=p+8|0,f[d>>2]|0){Ln=21;break e}if(p=sa(1,12)|0,!p){Ln=23;break e}f[d>>2]=p,y=p+4|0,M=p,d=re}else if(re){y=pn,M=re+8|0,d=_,p=A;break}else if(f[A>>2]|0){Ln=27;break e}else{y=pn,M=A,d=_,p=A;break}while(!1);if(f[M>>2]=_,f[y>>2]=_,M=Ht+(jt<<5)|0,F=f[_>>2]|0,F){for(H=Ht+(jt<<5)+8|0,J[H>>3]=17976931348623157e292,re=Ht+(jt<<5)+24|0,J[re>>3]=17976931348623157e292,J[M>>3]=-17976931348623157e292,me=Ht+(jt<<5)+16|0,J[me>>3]=-17976931348623157e292,Je=17976931348623157e292,He=-17976931348623157e292,y=0,pe=F,B=17976931348623157e292,Ne=17976931348623157e292,Ie=-17976931348623157e292,R=-17976931348623157e292;T=+J[pe>>3],Re=+J[pe+8>>3],pe=f[pe+16>>2]|0,ge=(pe|0)==0,Ve=+J[(ge?F:pe)+8>>3],T>3]=T,B=T),Re>3]=Re,Ne=Re),T>Ie?J[M>>3]=T:T=Ie,Re>R&&(J[me>>3]=Re,R=Re),Je=Re>0&ReHe?Re:He,y=y|+An(+(Re-Ve))>3.141592653589793,!ge;)Ie=T;y&&(J[me>>3]=He,J[re>>3]=Je)}else f[M>>2]=0,f[M+4>>2]=0,f[M+8>>2]=0,f[M+12>>2]=0,f[M+16>>2]=0,f[M+20>>2]=0,f[M+24>>2]=0,f[M+28>>2]=0;y=jt+1|0}if(Pn=_+8|0,_=f[Pn>>2]|0,f[Pn>>2]=0,_)jt=y,re=d;else{Ln=45;break}}if((Ln|0)==21)Vt(27213,27235,35,27247);else if((Ln|0)==23)Vt(27267,27235,37,27247);else if((Ln|0)==27)Vt(27310,27235,61,27333);else if((Ln|0)==45){e:do if((gn|0)>0){for(Pn=(y|0)==0,Bn=y<<2,ei=(A|0)==0,jn=0,d=0;;){if(cn=f[Cn+(jn<<2)>>2]|0,Pn)Ln=73;else{if(jt=$o(Bn)|0,!jt){Ln=50;break}if(pn=$o(Bn)|0,!pn){Ln=52;break}t:do if(ei)p=0;else{for(y=0,p=0,M=A;_=Ht+(y<<5)|0,ia(f[M>>2]|0,_,f[cn>>2]|0)|0?(f[jt+(p<<2)>>2]=M,f[pn+(p<<2)>>2]=_,ge=p+1|0):ge=p,M=f[M+8>>2]|0,M;)y=y+1|0,p=ge;if((ge|0)>0)if(_=f[jt>>2]|0,(ge|0)==1)p=_;else for(me=0,pe=-1,p=_,re=_;;){for(F=f[re>>2]|0,_=0,M=0;y=f[f[jt+(M<<2)>>2]>>2]|0,(y|0)==(F|0)?H=_:H=_+((ia(y,f[pn+(M<<2)>>2]|0,f[F>>2]|0)|0)&1)|0,M=M+1|0,(M|0)!=(ge|0);)_=H;if(y=(H|0)>(pe|0),p=y?re:p,_=me+1|0,(_|0)==(ge|0))break t;me=_,pe=y?H:pe,re=f[jt+(_<<2)>>2]|0}else p=0}while(!1);if(wn(jt),wn(pn),p){if(y=p+4|0,_=f[y>>2]|0,_)p=_+8|0;else if(f[p>>2]|0){Ln=70;break}f[p>>2]=cn,f[y>>2]=cn}else Ln=73}if((Ln|0)==73){if(Ln=0,d=f[cn>>2]|0,d|0)do pn=d,d=f[d+16>>2]|0,wn(pn);while((d|0)!=0);wn(cn),d=1}if(jn=jn+1|0,(jn|0)>=(gn|0)){li=d;break e}}(Ln|0)==50?Vt(27452,27235,249,27471):(Ln|0)==52?Vt(27490,27235,252,27471):(Ln|0)==70&&Vt(27310,27235,61,27333)}else li=0;while(!1);return wn(Cn),wn(Ht),Ln=li,Ln|0}return 0}function ia(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(!(qo(d,p)|0)||(d=Ed(d)|0,_=+J[p>>3],y=+J[p+8>>3],y=d&y<0?y+6.283185307179586:y,A=f[A>>2]|0,!A))return A=0,A|0;if(d){d=0,F=y,p=A;e:for(;;){for(;M=+J[p>>3],y=+J[p+8>>3],p=p+16|0,H=f[p>>2]|0,H=(H|0)==0?A:H,T=+J[H>>3],R=+J[H+8>>3],M>T?(B=M,M=R):(B=T,T=M,M=y,y=R),_=_==T|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=f[p>>2]|0,!p){p=22;break e}if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,F=R==F|M==F?F+-2220446049250313e-31:F,B=R+(M-R)*((_-T)/(B-T)),(B<0?B+6.283185307179586:B)>F&&(d=d^1),p=f[p>>2]|0,!p){p=22;break}}if((p|0)==22)return d|0}else{d=0,F=y,p=A;e:for(;;){for(;M=+J[p>>3],y=+J[p+8>>3],p=p+16|0,H=f[p>>2]|0,H=(H|0)==0?A:H,T=+J[H>>3],R=+J[H+8>>3],M>T?(B=M,M=R):(B=T,T=M,M=y,y=R),_=_==T|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=f[p>>2]|0,!p){p=22;break e}if(F=M==F|y==F?F+-2220446049250313e-31:F,M+(y-M)*((_-T)/(B-T))>F&&(d=d^1),p=f[p>>2]|0,!p){p=22;break}}if((p|0)==22)return d|0}return 0}function go(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0;if(He=Z,Z=Z+32|0,Je=He+16|0,Ie=He,T=Ut(A|0,d|0,52)|0,ee()|0,T=T&15,pe=Ut(p|0,_|0,52)|0,ee()|0,(T|0)!=(pe&15|0))return Je=12,Z=He,Je|0;if(F=Ut(A|0,d|0,45)|0,ee()|0,F=F&127,H=Ut(p|0,_|0,45)|0,ee()|0,H=H&127,F>>>0>121|H>>>0>121)return Je=5,Z=He,Je|0;if(pe=(F|0)!=(H|0),pe){if(R=zo(F,H)|0,(R|0)==7)return Je=1,Z=He,Je|0;B=zo(H,F)|0,(B|0)==7?Vt(27514,27538,161,27548):(ge=R,M=B)}else ge=0,M=0;re=$n(F)|0,me=$n(H)|0,f[Je>>2]=0,f[Je+4>>2]=0,f[Je+8>>2]=0,f[Je+12>>2]=0;do if(ge){if(H=f[4272+(F*28|0)+(ge<<2)>>2]|0,R=(H|0)>0,me)if(R){F=0,B=p,R=_;do B=Tx(B,R)|0,R=ee()|0,M=Al(M)|0,(M|0)==1&&(M=Al(1)|0),F=F+1|0;while((F|0)!=(H|0));H=M,F=B,B=R}else H=M,F=p,B=_;else if(R){F=0,B=p,R=_;do B=fp(B,R)|0,R=ee()|0,M=Al(M)|0,F=F+1|0;while((F|0)!=(H|0));H=M,F=B,B=R}else H=M,F=p,B=_;if(Od(F,B,Je)|0,pe||Vt(27563,27538,191,27548),R=(re|0)!=0,M=(me|0)!=0,R&M&&Vt(27590,27538,192,27548),R){if(M=ta(A,d)|0,(M|0)==7){T=5;break}if(ot[22e3+(M*7|0)+ge>>0]|0){T=1;break}B=f[21168+(M*28|0)+(ge<<2)>>2]|0,F=B}else if(M){if(M=ta(F,B)|0,(M|0)==7){T=5;break}if(ot[22e3+(M*7|0)+H>>0]|0){T=1;break}F=0,B=f[21168+(H*28|0)+(M<<2)>>2]|0}else F=0,B=0;if((F|B|0)<0)T=5;else{if((B|0)>0){R=Je+4|0,M=0;do Rd(R),M=M+1|0;while((M|0)!=(B|0))}if(f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ie+8>>2]=0,c1(Ie,ge),T|0)for(;Ps(T)|0?th(Ie):Gu(Ie),(T|0)>1;)T=T+-1|0;if((F|0)>0){T=0;do Rd(Ie),T=T+1|0;while((T|0)!=(F|0))}Ne=Je+4|0,ys(Ne,Ie,Ne),jr(Ne),Ne=51}}else if(Od(p,_,Je)|0,(re|0)!=0&(me|0)!=0)if((H|0)!=(F|0)&&Vt(27621,27538,261,27548),M=ta(A,d)|0,T=ta(p,_)|0,(M|0)==7|(T|0)==7)T=5;else if(ot[22e3+(M*7|0)+T>>0]|0)T=1;else if(M=f[21168+(M*28|0)+(T<<2)>>2]|0,(M|0)>0){R=Je+4|0,T=0;do Rd(R),T=T+1|0;while((T|0)!=(M|0));Ne=51}else Ne=51;else Ne=51;while(!1);return(Ne|0)==51&&(T=Je+4|0,f[y>>2]=f[T>>2],f[y+4>>2]=f[T+4>>2],f[y+8>>2]=f[T+8>>2],T=0),Je=T,Z=He,Je|0}function Vo(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0;if(Ne=Z,Z=Z+48|0,F=Ne+36|0,M=Ne+24|0,R=Ne+12|0,B=Ne,y=Ut(A|0,d|0,52)|0,ee()|0,y=y&15,me=Ut(A|0,d|0,45)|0,ee()|0,me=me&127,me>>>0>121)return _=5,Z=Ne,_|0;if(H=$n(me)|0,zt(y|0,0,52)|0,Ie=ee()|0|134225919,T=_,f[T>>2]=-1,f[T+4>>2]=Ie,!y)return y=zu(p)|0,(y|0)==7||(y=Iu(me,y)|0,(y|0)==127)?(Ie=1,Z=Ne,Ie|0):(pe=zt(y|0,0,45)|0,ge=ee()|0,me=_,ge=f[me+4>>2]&-1040385|ge,Ie=_,f[Ie>>2]=f[me>>2]|pe,f[Ie+4>>2]=ge,Ie=0,Z=Ne,Ie|0);for(f[F>>2]=f[p>>2],f[F+4>>2]=f[p+4>>2],f[F+8>>2]=f[p+8>>2],p=y;;){if(T=p,p=p+-1|0,f[M>>2]=f[F>>2],f[M+4>>2]=f[F+4>>2],f[M+8>>2]=f[F+8>>2],Ps(T)|0){if(y=l1(F)|0,y|0){p=13;break}f[R>>2]=f[F>>2],f[R+4>>2]=f[F+4>>2],f[R+8>>2]=f[F+8>>2],th(R)}else{if(y=cx(F)|0,y|0){p=13;break}f[R>>2]=f[F>>2],f[R+4>>2]=f[F+4>>2],f[R+8>>2]=f[F+8>>2],Gu(R)}if(uf(M,R,B),jr(B),y=_,He=f[y>>2]|0,y=f[y+4>>2]|0,Ve=(15-T|0)*3|0,Je=zt(7,0,Ve|0)|0,y=y&~(ee()|0),Ve=zt(zu(B)|0,0,Ve|0)|0,y=ee()|0|y,Ie=_,f[Ie>>2]=Ve|He&~Je,f[Ie+4>>2]=y,(T|0)<=1){p=14;break}}e:do if((p|0)!=13&&(p|0)==14)if((f[F>>2]|0)<=1&&(f[F+4>>2]|0)<=1&&(f[F+8>>2]|0)<=1){p=zu(F)|0,y=Iu(me,p)|0,(y|0)==127?B=0:B=$n(y)|0;t:do if(p){if(H){if(y=ta(A,d)|0,(y|0)==7){y=5;break e}if(T=f[21376+(y*28|0)+(p<<2)>>2]|0,(T|0)>0){y=p,p=0;do y=qu(y)|0,p=p+1|0;while((p|0)!=(T|0))}else y=p;if((y|0)==1){y=9;break e}p=Iu(me,y)|0,(p|0)==127&&Vt(27648,27538,411,27678),$n(p)|0?Vt(27693,27538,412,27678):(ge=p,pe=T,re=y)}else ge=y,pe=0,re=p;if(R=f[4272+(me*28|0)+(re<<2)>>2]|0,(R|0)<=-1&&Vt(27724,27538,419,27678),!B){if((pe|0)<0){y=5;break e}if(pe|0){T=_,y=0,p=f[T>>2]|0,T=f[T+4>>2]|0;do p=$u(p,T)|0,T=ee()|0,Ve=_,f[Ve>>2]=p,f[Ve+4>>2]=T,y=y+1|0;while((y|0)<(pe|0))}if((R|0)<=0){y=ge,p=58;break}for(T=_,y=0,p=f[T>>2]|0,T=f[T+4>>2]|0;;)if(p=$u(p,T)|0,T=ee()|0,Ve=_,f[Ve>>2]=p,f[Ve+4>>2]=T,y=y+1|0,(y|0)==(R|0)){y=ge,p=58;break t}}if(M=zo(ge,me)|0,(M|0)==7&&Vt(27514,27538,428,27678),y=_,p=f[y>>2]|0,y=f[y+4>>2]|0,(R|0)>0){T=0;do p=$u(p,y)|0,y=ee()|0,Ve=_,f[Ve>>2]=p,f[Ve+4>>2]=y,T=T+1|0;while((T|0)!=(R|0))}if(y=ta(p,y)|0,(y|0)==7&&Vt(27795,27538,440,27678),p=or(ge)|0,p=f[(p?21792:21584)+(M*28|0)+(y<<2)>>2]|0,(p|0)<0&&Vt(27795,27538,454,27678),!p)y=ge,p=58;else{M=_,y=0,T=f[M>>2]|0,M=f[M+4>>2]|0;do T=hp(T,M)|0,M=ee()|0,Ve=_,f[Ve>>2]=T,f[Ve+4>>2]=M,y=y+1|0;while((y|0)<(p|0));y=ge,p=58}}else if((H|0)!=0&(B|0)!=0){if(p=ta(A,d)|0,T=_,T=ta(f[T>>2]|0,f[T+4>>2]|0)|0,(p|0)==7|(T|0)==7){y=5;break e}if(T=f[21376+(p*28|0)+(T<<2)>>2]|0,(T|0)<0){y=5;break e}if(!T)p=59;else{R=_,p=0,M=f[R>>2]|0,R=f[R+4>>2]|0;do M=$u(M,R)|0,R=ee()|0,Ve=_,f[Ve>>2]=M,f[Ve+4>>2]=R,p=p+1|0;while((p|0)<(T|0));p=58}}else p=58;while(!1);if((p|0)==58&&B&&(p=59),(p|0)==59&&(Ve=_,(ta(f[Ve>>2]|0,f[Ve+4>>2]|0)|0)==1)){y=9;break}Ve=_,Je=f[Ve>>2]|0,Ve=f[Ve+4>>2]&-1040385,He=zt(y|0,0,45)|0,Ve=Ve|(ee()|0),y=_,f[y>>2]=Je|He,f[y+4>>2]=Ve,y=0}else y=1;while(!1);return Ve=y,Z=Ne,Ve|0}function C1(A,d,p,_,y,T){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,R=0;return R=Z,Z=Z+16|0,M=R,y?A=15:(A=go(A,d,p,_,M)|0,A||(fx(M,T),A=0)),Z=R,A|0}function zd(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0;return M=Z,Z=Z+16|0,T=M,_?p=15:(p=sp(p,T)|0,p||(p=Vo(A,d,T,y)|0)),Z=M,p|0}function tc(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0;return B=Z,Z=Z+32|0,M=B+12|0,R=B,T=go(A,d,A,d,M)|0,T|0?(R=T,Z=B,R|0):(A=go(A,d,p,_,R)|0,A|0?(R=A,Z=B,R|0):(M=rp(M,R)|0,R=y,f[R>>2]=M,f[R+4>>2]=((M|0)<0)<<31>>31,R=0,Z=B,R|0))}function _p(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0;return B=Z,Z=Z+32|0,M=B+12|0,R=B,T=go(A,d,A,d,M)|0,!T&&(T=go(A,d,p,_,R)|0,!T)?(_=rp(M,R)|0,_=rn(_|0,((_|0)<0)<<31>>31|0,1,0)|0,M=ee()|0,R=y,f[R>>2]=_,f[R+4>>2]=M,R=0,Z=B,R|0):(R=T,Z=B,R|0)}function N1(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0;if(cn=Z,Z=Z+48|0,jt=cn+24|0,M=cn+12|0,pn=cn,T=go(A,d,A,d,jt)|0,!T&&(T=go(A,d,p,_,M)|0,!T)){Ve=rp(jt,M)|0,Re=((Ve|0)<0)<<31>>31,f[jt>>2]=0,f[jt+4>>2]=0,f[jt+8>>2]=0,f[M>>2]=0,f[M+4>>2]=0,f[M+8>>2]=0,go(A,d,A,d,jt)|0&&Vt(27795,27538,692,27747),go(A,d,p,_,M)|0&&Vt(27795,27538,697,27747),A1(jt),A1(M),H=(Ve|0)==0?0:1/+(Ve|0),p=f[jt>>2]|0,Ne=H*+((f[M>>2]|0)-p|0),Ie=jt+4|0,_=f[Ie>>2]|0,Je=H*+((f[M+4>>2]|0)-_|0),He=jt+8|0,T=f[He>>2]|0,H=H*+((f[M+8>>2]|0)-T|0),f[pn>>2]=p,re=pn+4|0,f[re>>2]=_,me=pn+8|0,f[me>>2]=T;e:do if((Ve|0)<0)T=0;else for(pe=0,ge=0;;){B=+(ge>>>0)+4294967296*+(pe|0),jn=Ne*B+ +(p|0),R=Je*B+ +(_|0),B=H*B+ +(T|0),p=~~+xl(+jn),M=~~+xl(+R),T=~~+xl(+B),jn=+An(+(+(p|0)-jn)),R=+An(+(+(M|0)-R)),B=+An(+(+(T|0)-B));do if(jn>R&jn>B)p=0-(M+T)|0,_=M;else if(F=0-p|0,R>B){_=F-T|0;break}else{_=M,T=F-M|0;break}while(!1);if(f[pn>>2]=p,f[re>>2]=_,f[me>>2]=T,dx(pn),T=Vo(A,d,pn,y+(ge<<3)|0)|0,T|0)break e;if(!((pe|0)<(Re|0)|(pe|0)==(Re|0)&ge>>>0>>0)){T=0;break e}p=rn(ge|0,pe|0,1,0)|0,_=ee()|0,pe=_,ge=p,p=f[jt>>2]|0,_=f[Ie>>2]|0,T=f[He>>2]|0}while(!1);return pn=T,Z=cn,pn|0}return pn=T,Z=cn,pn|0}function jo(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0;if((p|0)==0&(_|0)==0)return y=0,T=1,Mt(y|0),T|0;T=A,y=d,A=1,d=0;do M=(p&1|0)==0&!0,A=vr((M?1:T)|0,(M?0:y)|0,A|0,d|0)|0,d=ee()|0,p=D1(p|0,_|0,1)|0,_=ee()|0,T=vr(T|0,y|0,T|0,y|0)|0,y=ee()|0;while(!((p|0)==0&(_|0)==0));return Mt(d|0),A|0}function Gd(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0;R=Z,Z=Z+16|0,T=R,M=Ut(A|0,d|0,52)|0,ee()|0,M=M&15;do if(M){if(y=jl(A,d,T)|0,!y){F=+J[T>>3],B=1/+on(+F),H=+J[25968+(M<<3)>>3],J[p>>3]=F+H,J[p+8>>3]=F-H,F=+J[T+8>>3],B=H*B,J[p+16>>3]=B+F,J[p+24>>3]=F-B;break}return M=y,Z=R,M|0}else{if(y=Ut(A|0,d|0,45)|0,ee()|0,y=y&127,y>>>0>121)return M=5,Z=R,M|0;T=22064+(y<<5)|0,f[p>>2]=f[T>>2],f[p+4>>2]=f[T+4>>2],f[p+8>>2]=f[T+8>>2],f[p+12>>2]=f[T+12>>2],f[p+16>>2]=f[T+16>>2],f[p+20>>2]=f[T+20>>2],f[p+24>>2]=f[T+24>>2],f[p+28>>2]=f[T+28>>2];break}while(!1);return ea(p,_?1.4:1.1),_=26096+(M<<3)|0,(f[_>>2]|0)==(A|0)&&(f[_+4>>2]|0)==(d|0)&&(J[p>>3]=1.5707963267948966),M=26224+(M<<3)|0,(f[M>>2]|0)==(A|0)&&(f[M+4>>2]|0)==(d|0)&&(J[p+8>>3]=-1.5707963267948966),+J[p>>3]!=1.5707963267948966&&+J[p+8>>3]!=-1.5707963267948966?(M=0,Z=R,M|0):(J[p+16>>3]=3.141592653589793,J[p+24>>3]=-3.141592653589793,M=0,Z=R,M|0)}function Ua(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0;F=Z,Z=Z+48|0,M=F+32|0,T=F+40|0,R=F,Hu(M,0,0,0),B=f[M>>2]|0,M=f[M+4>>2]|0;do if(p>>>0<=15){if(y=Ba(_)|0,y|0){_=R,f[_>>2]=0,f[_+4>>2]=0,f[R+8>>2]=y,f[R+12>>2]=-1,_=R+16|0,B=R+29|0,f[_>>2]=0,f[_+4>>2]=0,f[_+8>>2]=0,ot[_+12>>0]=0,ot[B>>0]=ot[T>>0]|0,ot[B+1>>0]=ot[T+1>>0]|0,ot[B+2>>0]=ot[T+2>>0]|0;break}if(y=sa((f[d+8>>2]|0)+1|0,32)|0,y){Oa(d,y),H=R,f[H>>2]=B,f[H+4>>2]=M,f[R+8>>2]=0,f[R+12>>2]=p,f[R+16>>2]=_,f[R+20>>2]=d,f[R+24>>2]=y,ot[R+28>>0]=0,B=R+29|0,ot[B>>0]=ot[T>>0]|0,ot[B+1>>0]=ot[T+1>>0]|0,ot[B+2>>0]=ot[T+2>>0]|0;break}else{_=R,f[_>>2]=0,f[_+4>>2]=0,f[R+8>>2]=13,f[R+12>>2]=-1,_=R+16|0,B=R+29|0,f[_>>2]=0,f[_+4>>2]=0,f[_+8>>2]=0,ot[_+12>>0]=0,ot[B>>0]=ot[T>>0]|0,ot[B+1>>0]=ot[T+1>>0]|0,ot[B+2>>0]=ot[T+2>>0]|0;break}}else B=R,f[B>>2]=0,f[B+4>>2]=0,f[R+8>>2]=4,f[R+12>>2]=-1,B=R+16|0,H=R+29|0,f[B>>2]=0,f[B+4>>2]=0,f[B+8>>2]=0,ot[B+12>>0]=0,ot[H>>0]=ot[T>>0]|0,ot[H+1>>0]=ot[T+1>>0]|0,ot[H+2>>0]=ot[T+2>>0]|0;while(!1);ml(R),f[A>>2]=f[R>>2],f[A+4>>2]=f[R+4>>2],f[A+8>>2]=f[R+8>>2],f[A+12>>2]=f[R+12>>2],f[A+16>>2]=f[R+16>>2],f[A+20>>2]=f[R+20>>2],f[A+24>>2]=f[R+24>>2],f[A+28>>2]=f[R+28>>2],Z=F}function ml(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0;if(Re=Z,Z=Z+336|0,pe=Re+168|0,ge=Re,_=A,p=f[_>>2]|0,_=f[_+4>>2]|0,(p|0)==0&(_|0)==0){Z=Re;return}if(d=A+28|0,ot[d>>0]|0?(p=nc(p,_)|0,_=ee()|0):ot[d>>0]=1,Ve=A+20|0,!(f[f[Ve>>2]>>2]|0)){d=A+24|0,p=f[d>>2]|0,p|0&&wn(p),He=A,f[He>>2]=0,f[He+4>>2]=0,f[A+8>>2]=0,f[Ve>>2]=0,f[A+12>>2]=-1,f[A+16>>2]=0,f[d>>2]=0,Z=Re;return}He=A+16|0,d=f[He>>2]|0,y=d&15;e:do if((p|0)==0&(_|0)==0)Je=A+24|0;else{Ne=A+12|0,re=(y|0)==3,H=d&255,B=(y|1|0)==3,me=A+24|0,F=(y+-1|0)>>>0<3,M=(y|2|0)==3,R=ge+8|0;t:for(;;){if(T=Ut(p|0,_|0,52)|0,ee()|0,T=T&15,(T|0)==(f[Ne>>2]|0)){switch(H&15){case 0:case 2:case 3:{if(y=jl(p,_,pe)|0,y|0){Ie=15;break t}if(Ia(f[Ve>>2]|0,f[me>>2]|0,pe)|0){Ie=19;break t}break}}if(B&&(y=f[(f[Ve>>2]|0)+4>>2]|0,f[pe>>2]=f[y>>2],f[pe+4>>2]=f[y+4>>2],f[pe+8>>2]=f[y+8>>2],f[pe+12>>2]=f[y+12>>2],qo(26832,pe)|0)){if(Bd(f[(f[Ve>>2]|0)+4>>2]|0,T,ge)|0){Ie=25;break}if(y=ge,(f[y>>2]|0)==(p|0)&&(f[y+4>>2]|0)==(_|0)){Ie=29;break}}if(F){if(y=Hl(p,_,pe)|0,y|0){Ie=32;break}if(Gd(p,_,ge,0)|0){Ie=36;break}if(M&&Ho(f[Ve>>2]|0,f[me>>2]|0,pe,ge)|0){Ie=42;break}if(B&&Vd(f[Ve>>2]|0,f[me>>2]|0,pe,ge)|0){Ie=42;break}}if(re){if(d=Gd(p,_,pe,1)|0,y=f[me>>2]|0,d|0){Ie=45;break}if(af(y,pe)|0){if(of(ge,pe),ip(pe,f[me>>2]|0)|0){Ie=53;break}if(Ia(f[Ve>>2]|0,f[me>>2]|0,R)|0){Ie=53;break}if(Vd(f[Ve>>2]|0,f[me>>2]|0,ge,pe)|0){Ie=53;break}}}}do if((T|0)<(f[Ne>>2]|0)){if(d=Gd(p,_,pe,1)|0,y=f[me>>2]|0,d|0){Ie=58;break t}if(!(af(y,pe)|0)){Ie=73;break}if(ip(f[me>>2]|0,pe)|0&&(of(ge,pe),Ho(f[Ve>>2]|0,f[me>>2]|0,ge,pe)|0)){Ie=65;break t}if(p=Ud(p,_,T+1|0,ge)|0,p|0){Ie=67;break t}_=ge,p=f[_>>2]|0,_=f[_+4>>2]|0}else Ie=73;while(!1);if((Ie|0)==73&&(Ie=0,p=nc(p,_)|0,_=ee()|0),(p|0)==0&(_|0)==0){Je=me;break e}}switch(Ie|0){case 15:{d=f[me>>2]|0,d|0&&wn(d),Ie=A,f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=y,Ie=20;break}case 19:{f[A>>2]=p,f[A+4>>2]=_,Ie=20;break}case 25:{Vt(27795,27761,470,27772);break}case 29:{f[A>>2]=p,f[A+4>>2]=_,Z=Re;return}case 32:{d=f[me>>2]|0,d|0&&wn(d),Je=A,f[Je>>2]=0,f[Je+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=y,Z=Re;return}case 36:{Vt(27795,27761,493,27772);break}case 42:{f[A>>2]=p,f[A+4>>2]=_,Z=Re;return}case 45:{y|0&&wn(y),Ie=A,f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=d,Ie=55;break}case 53:{f[A>>2]=p,f[A+4>>2]=_,Ie=55;break}case 58:{y|0&&wn(y),Ie=A,f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=d,Ie=71;break}case 65:{f[A>>2]=p,f[A+4>>2]=_,Ie=71;break}case 67:{d=f[me>>2]|0,d|0&&wn(d),Je=A,f[Je>>2]=0,f[Je+4>>2]=0,f[Ve>>2]=0,f[Ne>>2]=-1,f[He>>2]=0,f[me>>2]=0,f[A+8>>2]=p,Z=Re;return}}if((Ie|0)==20){Z=Re;return}else if((Ie|0)==55){Z=Re;return}else if((Ie|0)==71){Z=Re;return}}while(!1);d=f[Je>>2]|0,d|0&&wn(d),Ie=A,f[Ie>>2]=0,f[Ie+4>>2]=0,f[A+8>>2]=0,f[Ve>>2]=0,f[A+12>>2]=-1,f[He>>2]=0,f[Je>>2]=0,Z=Re}function nc(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0;re=Z,Z=Z+16|0,H=re,_=Ut(A|0,d|0,52)|0,ee()|0,_=_&15,p=Ut(A|0,d|0,45)|0,ee()|0;do if(_){for(;p=zt(_+4095|0,0,52)|0,y=ee()|0|d&-15728641,T=(15-_|0)*3|0,M=zt(7,0,T|0)|0,R=ee()|0,p=p|A|M,y=y|R,B=Ut(A|0,d|0,T|0)|0,ee()|0,B=B&7,_=_+-1|0,!(B>>>0<6);)if(_)d=y,A=p;else{F=4;break}if((F|0)==4){p=Ut(p|0,y|0,45)|0,ee()|0;break}return H=(B|0)==0&(Ri(p,y)|0)!=0,H=zt((H?2:1)+B|0,0,T|0)|0,F=ee()|0|d&~R,H=H|A&~M,Mt(F|0),Z=re,H|0}while(!1);return p=p&127,p>>>0>120?(F=0,H=0,Mt(F|0),Z=re,H|0):(Hu(H,0,p+1|0,0),F=f[H+4>>2]|0,H=f[H>>2]|0,Mt(F|0),Z=re,H|0)}function qd(A,d,p,_,y,T){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0,T=T|0;var M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0;Ie=Z,Z=Z+160|0,re=Ie+80|0,R=Ie+64|0,me=Ie+112|0,Ne=Ie,Ua(re,A,d,p),F=re,pl(R,f[F>>2]|0,f[F+4>>2]|0,d),F=R,B=f[F>>2]|0,F=f[F+4>>2]|0,M=f[re+8>>2]|0,pe=me+4|0,f[pe>>2]=f[re>>2],f[pe+4>>2]=f[re+4>>2],f[pe+8>>2]=f[re+8>>2],f[pe+12>>2]=f[re+12>>2],f[pe+16>>2]=f[re+16>>2],f[pe+20>>2]=f[re+20>>2],f[pe+24>>2]=f[re+24>>2],f[pe+28>>2]=f[re+28>>2],pe=Ne,f[pe>>2]=B,f[pe+4>>2]=F,pe=Ne+8|0,f[pe>>2]=M,A=Ne+12|0,d=me,p=A+36|0;do f[A>>2]=f[d>>2],A=A+4|0,d=d+4|0;while((A|0)<(p|0));if(me=Ne+48|0,f[me>>2]=f[R>>2],f[me+4>>2]=f[R+4>>2],f[me+8>>2]=f[R+8>>2],f[me+12>>2]=f[R+12>>2],(B|0)==0&(F|0)==0)return Ne=M,Z=Ie,Ne|0;p=Ne+16|0,H=Ne+24|0,re=Ne+28|0,M=0,R=0,d=B,A=F;do{if(!((M|0)<(y|0)|(M|0)==(y|0)&R>>>0<_>>>0)){ge=4;break}if(F=R,R=rn(R|0,M|0,1,0)|0,M=ee()|0,F=T+(F<<3)|0,f[F>>2]=d,f[F+4>>2]=A,ff(me),A=me,d=f[A>>2]|0,A=f[A+4>>2]|0,(d|0)==0&(A|0)==0){if(ml(p),d=p,A=f[d>>2]|0,d=f[d+4>>2]|0,(A|0)==0&(d|0)==0){ge=10;break}Ku(A,d,f[re>>2]|0,me),A=me,d=f[A>>2]|0,A=f[A+4>>2]|0}F=Ne,f[F>>2]=d,f[F+4>>2]=A}while(!((d|0)==0&(A|0)==0));return(ge|0)==4?(A=Ne+40|0,d=f[A>>2]|0,d|0&&wn(d),ge=Ne+16|0,f[ge>>2]=0,f[ge+4>>2]=0,f[H>>2]=0,f[Ne+36>>2]=0,f[re>>2]=-1,f[Ne+32>>2]=0,f[A>>2]=0,Ku(0,0,0,me),f[Ne>>2]=0,f[Ne+4>>2]=0,f[pe>>2]=0,Ne=14,Z=Ie,Ne|0):((ge|0)==10&&(f[Ne>>2]=0,f[Ne+4>>2]=0,f[pe>>2]=f[H>>2]),Ne=f[pe>>2]|0,Z=Ie,Ne|0)}function df(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0;if(re=Z,Z=Z+48|0,B=re+32|0,R=re+40|0,F=re,!(f[A>>2]|0))return H=_,f[H>>2]=0,f[H+4>>2]=0,H=0,Z=re,H|0;Hu(B,0,0,0),M=B,y=f[M>>2]|0,M=f[M+4>>2]|0;do if(d>>>0>15)H=F,f[H>>2]=0,f[H+4>>2]=0,f[F+8>>2]=4,f[F+12>>2]=-1,H=F+16|0,p=F+29|0,f[H>>2]=0,f[H+4>>2]=0,f[H+8>>2]=0,ot[H+12>>0]=0,ot[p>>0]=ot[R>>0]|0,ot[p+1>>0]=ot[R+1>>0]|0,ot[p+2>>0]=ot[R+2>>0]|0,p=4,H=9;else{if(p=Ba(p)|0,p|0){B=F,f[B>>2]=0,f[B+4>>2]=0,f[F+8>>2]=p,f[F+12>>2]=-1,B=F+16|0,H=F+29|0,f[B>>2]=0,f[B+4>>2]=0,f[B+8>>2]=0,ot[B+12>>0]=0,ot[H>>0]=ot[R>>0]|0,ot[H+1>>0]=ot[R+1>>0]|0,ot[H+2>>0]=ot[R+2>>0]|0,H=9;break}if(p=sa((f[A+8>>2]|0)+1|0,32)|0,!p){H=F,f[H>>2]=0,f[H+4>>2]=0,f[F+8>>2]=13,f[F+12>>2]=-1,H=F+16|0,p=F+29|0,f[H>>2]=0,f[H+4>>2]=0,f[H+8>>2]=0,ot[H+12>>0]=0,ot[p>>0]=ot[R>>0]|0,ot[p+1>>0]=ot[R+1>>0]|0,ot[p+2>>0]=ot[R+2>>0]|0,p=13,H=9;break}Oa(A,p),pe=F,f[pe>>2]=y,f[pe+4>>2]=M,M=F+8|0,f[M>>2]=0,f[F+12>>2]=d,f[F+20>>2]=A,f[F+24>>2]=p,ot[F+28>>0]=0,y=F+29|0,ot[y>>0]=ot[R>>0]|0,ot[y+1>>0]=ot[R+1>>0]|0,ot[y+2>>0]=ot[R+2>>0]|0,f[F+16>>2]=3,me=+sf(p),me=me*+dl(p),T=+An(+ +J[p>>3]),T=me/+on(+ +gf(+T,+ +An(+ +J[p+8>>3])))*6371.007180918475*6371.007180918475,y=F+12|0,p=f[y>>2]|0;e:do if((p|0)>0)do{if(pp(p+-1|0,B)|0,!(T/+J[B>>3]>10))break e;pe=f[y>>2]|0,p=pe+-1|0,f[y>>2]=p}while((pe|0)>1);while(!1);if(ml(F),y=_,f[y>>2]=0,f[y+4>>2]=0,y=F,p=f[y>>2]|0,y=f[y+4>>2]|0,!((p|0)==0&(y|0)==0))do hf(p,y,d,B)|0,R=B,A=_,R=rn(f[A>>2]|0,f[A+4>>2]|0,f[R>>2]|0,f[R+4>>2]|0)|0,A=ee()|0,pe=_,f[pe>>2]=R,f[pe+4>>2]=A,ml(F),pe=F,p=f[pe>>2]|0,y=f[pe+4>>2]|0;while(!((p|0)==0&(y|0)==0));p=f[M>>2]|0}while(!1);return pe=p,Z=re,pe|0}function Ls(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;if(!(qo(d,p)|0)||(d=Ed(d)|0,_=+J[p>>3],y=+J[p+8>>3],y=d&y<0?y+6.283185307179586:y,me=f[A>>2]|0,(me|0)<=0))return me=0,me|0;if(re=f[A+4>>2]|0,d){d=0,H=y,p=-1,A=0;e:for(;;){for(F=A;M=+J[re+(F<<4)>>3],y=+J[re+(F<<4)+8>>3],A=(p+2|0)%(me|0)|0,T=+J[re+(A<<4)>>3],R=+J[re+(A<<4)+8>>3],M>T?(B=M,M=R):(B=T,T=M,M=y,y=R),_=_==T|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(me|0)){p=22;break e}else A=F,F=p,p=A;if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,H=R==H|M==H?H+-2220446049250313e-31:H,B=R+(M-R)*((_-T)/(B-T)),(B<0?B+6.283185307179586:B)>H&&(d=d^1),A=F+1|0,(A|0)>=(me|0)){p=22;break}else p=F}if((p|0)==22)return d|0}else{d=0,H=y,p=-1,A=0;e:for(;;){for(F=A;M=+J[re+(F<<4)>>3],y=+J[re+(F<<4)+8>>3],A=(p+2|0)%(me|0)|0,T=+J[re+(A<<4)>>3],R=+J[re+(A<<4)+8>>3],M>T?(B=M,M=R):(B=T,T=M,M=y,y=R),_=_==T|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(me|0)){p=22;break e}else A=F,F=p,p=A;if(H=M==H|y==H?H+-2220446049250313e-31:H,M+(y-M)*((_-T)/(B-T))>H&&(d=d^1),A=F+1|0,(A|0)>=(me|0)){p=22;break}else p=F}if((p|0)==22)return d|0}return 0}function ba(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0;if(ge=f[A>>2]|0,!ge){f[d>>2]=0,f[d+4>>2]=0,f[d+8>>2]=0,f[d+12>>2]=0,f[d+16>>2]=0,f[d+20>>2]=0,f[d+24>>2]=0,f[d+28>>2]=0;return}if(Ne=d+8|0,J[Ne>>3]=17976931348623157e292,Ie=d+24|0,J[Ie>>3]=17976931348623157e292,J[d>>3]=-17976931348623157e292,Je=d+16|0,J[Je>>3]=-17976931348623157e292,!((ge|0)<=0)){for(me=f[A+4>>2]|0,F=17976931348623157e292,H=-17976931348623157e292,re=0,A=-1,T=17976931348623157e292,M=17976931348623157e292,B=-17976931348623157e292,_=-17976931348623157e292,pe=0;p=+J[me+(pe<<4)>>3],R=+J[me+(pe<<4)+8>>3],A=A+2|0,y=+J[me+(((A|0)==(ge|0)?0:A)<<4)+8>>3],p>3]=p,T=p),R>3]=R,M=R),p>B?J[d>>3]=p:p=B,R>_&&(J[Je>>3]=R,_=R),F=R>0&RH?R:H,re=re|+An(+(R-y))>3.141592653589793,A=pe+1|0,(A|0)!=(ge|0);)He=pe,B=p,pe=A,A=He;re&&(J[Je>>3]=H,J[Ie>>3]=F)}}function Ba(A){return A=A|0,(A>>>0<4?0:15)|0}function Oa(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0;if(ge=f[A>>2]|0,ge){if(Ne=d+8|0,J[Ne>>3]=17976931348623157e292,Ie=d+24|0,J[Ie>>3]=17976931348623157e292,J[d>>3]=-17976931348623157e292,Je=d+16|0,J[Je>>3]=-17976931348623157e292,(ge|0)>0){for(y=f[A+4>>2]|0,me=17976931348623157e292,pe=-17976931348623157e292,_=0,p=-1,B=17976931348623157e292,F=17976931348623157e292,re=-17976931348623157e292,M=-17976931348623157e292,He=0;T=+J[y+(He<<4)>>3],H=+J[y+(He<<4)+8>>3],pn=p+2|0,R=+J[y+(((pn|0)==(ge|0)?0:pn)<<4)+8>>3],T>3]=T,B=T),H>3]=H,F=H),T>re?J[d>>3]=T:T=re,H>M&&(J[Je>>3]=H,M=H),me=H>0&Hpe?H:pe,_=_|+An(+(H-R))>3.141592653589793,p=He+1|0,(p|0)!=(ge|0);)pn=He,re=T,He=p,p=pn;_&&(J[Je>>3]=pe,J[Ie>>3]=me)}}else f[d>>2]=0,f[d+4>>2]=0,f[d+8>>2]=0,f[d+12>>2]=0,f[d+16>>2]=0,f[d+20>>2]=0,f[d+24>>2]=0,f[d+28>>2]=0;if(pn=A+8|0,p=f[pn>>2]|0,!((p|0)<=0)){jt=A+12|0,Re=0;do if(y=f[jt>>2]|0,_=Re,Re=Re+1|0,Ie=d+(Re<<5)|0,Je=f[y+(_<<3)>>2]|0,Je){if(He=d+(Re<<5)+8|0,J[He>>3]=17976931348623157e292,A=d+(Re<<5)+24|0,J[A>>3]=17976931348623157e292,J[Ie>>3]=-17976931348623157e292,Ve=d+(Re<<5)+16|0,J[Ve>>3]=-17976931348623157e292,(Je|0)>0){for(ge=f[y+(_<<3)+4>>2]|0,me=17976931348623157e292,pe=-17976931348623157e292,y=0,_=-1,Ne=0,B=17976931348623157e292,F=17976931348623157e292,H=-17976931348623157e292,M=-17976931348623157e292;T=+J[ge+(Ne<<4)>>3],re=+J[ge+(Ne<<4)+8>>3],_=_+2|0,R=+J[ge+(((_|0)==(Je|0)?0:_)<<4)+8>>3],T>3]=T,B=T),re>3]=re,F=re),T>H?J[Ie>>3]=T:T=H,re>M&&(J[Ve>>3]=re,M=re),me=re>0&repe?re:pe,y=y|+An(+(re-R))>3.141592653589793,_=Ne+1|0,(_|0)!=(Je|0);)cn=Ne,Ne=_,H=T,_=cn;y&&(J[Ve>>3]=pe,J[A>>3]=me)}}else f[Ie>>2]=0,f[Ie+4>>2]=0,f[Ie+8>>2]=0,f[Ie+12>>2]=0,f[Ie+16>>2]=0,f[Ie+20>>2]=0,f[Ie+24>>2]=0,f[Ie+28>>2]=0,p=f[pn>>2]|0;while((Re|0)<(p|0))}}function Ia(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if(!(Ls(A,d,p)|0))return y=0,y|0;if(y=A+8|0,(f[y>>2]|0)<=0)return y=1,y|0;for(_=A+12|0,A=0;;){if(T=A,A=A+1|0,Ls((f[_>>2]|0)+(T<<3)|0,d+(A<<5)|0,p)|0){A=0,_=6;break}if((A|0)>=(f[y>>2]|0)){A=1,_=6;break}}return(_|0)==6?A|0:0}function Ho(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(F=Z,Z=Z+16|0,R=F,M=p+8|0,!(Ls(A,d,M)|0))return B=0,Z=F,B|0;B=A+8|0;e:do if((f[B>>2]|0)>0){for(T=A+12|0,y=0;;){if(H=y,y=y+1|0,Ls((f[T>>2]|0)+(H<<3)|0,d+(y<<5)|0,M)|0){y=0;break}if((y|0)>=(f[B>>2]|0))break e}return Z=F,y|0}while(!1);if(Af(A,d,p,_)|0)return H=0,Z=F,H|0;f[R>>2]=f[p>>2],f[R+4>>2]=M,y=f[B>>2]|0;e:do if((y|0)>0)for(A=A+12|0,M=0,T=y;;){if(y=f[A>>2]|0,(f[y+(M<<3)>>2]|0)>0){if(Ls(R,_,f[y+(M<<3)+4>>2]|0)|0){y=0;break e}if(y=M+1|0,Af((f[A>>2]|0)+(M<<3)|0,d+(y<<5)|0,p,_)|0){y=0;break e}T=f[B>>2]|0}else y=M+1|0;if((y|0)<(T|0))M=y;else{y=1;break}}else y=1;while(!1);return H=y,Z=F,H|0}function Af(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0,pn=0,cn=0,jn=0;if(pn=Z,Z=Z+176|0,He=pn+172|0,y=pn+168|0,Ve=pn,!(af(d,_)|0))return A=0,Z=pn,A|0;if(Cd(d,_,He,y),Yl(Ve|0,p|0,168)|0,(f[p>>2]|0)>0){d=0;do cn=Ve+8+(d<<4)+8|0,Je=+na(+J[cn>>3],f[y>>2]|0),J[cn>>3]=Je,d=d+1|0;while((d|0)<(f[p>>2]|0))}Ne=+J[_>>3],Ie=+J[_+8>>3],Je=+na(+J[_+16>>3],f[y>>2]|0),pe=+na(+J[_+24>>3],f[y>>2]|0);e:do if((f[A>>2]|0)>0){if(_=A+4|0,y=f[Ve>>2]|0,(y|0)<=0){for(d=0;;)if(d=d+1|0,(d|0)>=(f[A>>2]|0)){d=0;break e}}for(p=0;;){if(d=f[_>>2]|0,me=+J[d+(p<<4)>>3],ge=+na(+J[d+(p<<4)+8>>3],f[He>>2]|0),d=f[_>>2]|0,p=p+1|0,cn=(p|0)%(f[A>>2]|0)|0,T=+J[d+(cn<<4)>>3],M=+na(+J[d+(cn<<4)+8>>3],f[He>>2]|0),!(me>=Ne)|!(T>=Ne)&&!(me<=Ie)|!(T<=Ie)&&!(ge<=pe)|!(M<=pe)&&!(ge>=Je)|!(M>=Je)){re=T-me,F=M-ge,d=0;do if(jn=d,d=d+1|0,cn=(d|0)==(y|0)?0:d,T=+J[Ve+8+(jn<<4)+8>>3],M=+J[Ve+8+(cn<<4)+8>>3]-T,R=+J[Ve+8+(jn<<4)>>3],B=+J[Ve+8+(cn<<4)>>3]-R,H=re*M-F*B,H!=0&&(Re=ge-T,jt=me-R,B=(Re*B-M*jt)/H,!(B<0|B>1))&&(H=(re*Re-F*jt)/H,H>=0&H<=1)){d=1;break e}while((d|0)<(y|0))}if((p|0)>=(f[A>>2]|0)){d=0;break}}}else d=0;while(!1);return jn=d,Z=pn,jn|0}function Vd(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0;if(Af(A,d,p,_)|0)return T=1,T|0;if(T=A+8|0,(f[T>>2]|0)<=0)return T=0,T|0;for(y=A+12|0,A=0;;){if(M=A,A=A+1|0,Af((f[y>>2]|0)+(M<<3)|0,d+(A<<5)|0,p,_)|0){A=1,y=6;break}if((A|0)>=(f[T>>2]|0)){A=0,y=6;break}}return(y|0)==6?A|0:0}function yp(){return 8}function R1(){return 16}function xs(){return 168}function ur(){return 8}function xi(){return 16}function $l(){return 12}function Fa(){return 8}function xp(A){return A=A|0,+(+((f[A>>2]|0)>>>0)+4294967296*+(f[A+4>>2]|0))}function Xl(A){A=A|0;var d=0,p=0;return p=+J[A>>3],d=+J[A+8>>3],+ +yn(+(p*p+d*d))}function bp(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0;F=+J[A>>3],B=+J[d>>3]-F,R=+J[A+8>>3],M=+J[d+8>>3]-R,re=+J[p>>3],T=+J[_>>3]-re,me=+J[p+8>>3],H=+J[_+8>>3]-me,T=(T*(R-me)-(F-re)*H)/(B*H-M*T),J[y>>3]=F+B*T,J[y+8>>3]=R+M*T}function Sp(A,d){return A=A|0,d=d|0,+An(+(+J[A>>3]-+J[d>>3]))<11920928955078125e-23?(d=+An(+(+J[A+8>>3]-+J[d+8>>3]))<11920928955078125e-23,d|0):(d=0,d|0)}function cr(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;return y=+J[A>>3]-+J[d>>3],_=+J[A+8>>3]-+J[d+8>>3],p=+J[A+16>>3]-+J[d+16>>3],+(y*y+_*_+p*p)}function ic(A,d){A=A|0,d=d|0;var p=0,_=0,y=0;p=+J[A>>3],_=+on(+p),p=+xn(+p),J[d+16>>3]=p,p=+J[A+8>>3],y=_*+on(+p),J[d>>3]=y,p=_*+xn(+p),J[d+8>>3]=p}function Tp(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if(T=Z,Z=Z+16|0,y=T,_=Ri(A,d)|0,(p+-1|0)>>>0>5||(_=(_|0)!=0,(p|0)==1&_))return y=-1,Z=T,y|0;do if(gl(A,d,y)|0)_=-1;else if(_){_=((f[26352+(p<<2)>>2]|0)+5-(f[y>>2]|0)|0)%5|0;break}else{_=((f[26384+(p<<2)>>2]|0)+6-(f[y>>2]|0)|0)%6|0;break}while(!1);return y=_,Z=T,y|0}function gl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0;if(H=Z,Z=Z+32|0,R=H+16|0,B=H,_=Xu(A,d,R)|0,_|0)return p=_,Z=H,p|0;T=v1(A,d)|0,F=ta(A,d)|0,Cr(T,B),_=lr(T,f[R>>2]|0)|0;do if($n(T)|0){do switch(T|0){case 4:{y=0;break}case 14:{y=1;break}case 24:{y=2;break}case 38:{y=3;break}case 49:{y=4;break}case 58:{y=5;break}case 63:{y=6;break}case 72:{y=7;break}case 83:{y=8;break}case 97:{y=9;break}case 107:{y=10;break}case 117:{y=11;break}default:Vt(27795,27797,75,27806)}while(!1);if(M=f[26416+(y*24|0)+8>>2]|0,d=f[26416+(y*24|0)+16>>2]|0,A=f[R>>2]|0,(A|0)!=(f[B>>2]|0)&&(B=or(T)|0,A=f[R>>2]|0,B|(A|0)==(d|0)&&(_=(_+1|0)%6|0)),(F|0)==3&(A|0)==(d|0)){_=(_+5|0)%6|0;break}(F|0)==5&(A|0)==(M|0)&&(_=(_+1|0)%6|0)}while(!1);return f[p>>2]=_,p=0,Z=H,p|0}function ra(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0;if(Ve=Z,Z=Z+32|0,He=Ve+24|0,Ie=Ve+20|0,ge=Ve+8|0,pe=Ve+16|0,me=Ve,B=(Ri(A,d)|0)==0,B=B?6:5,H=Ut(A|0,d|0,52)|0,ee()|0,H=H&15,B>>>0<=p>>>0)return _=2,Z=Ve,_|0;re=(H|0)==0,!re&&(Ne=zt(7,0,(H^15)*3|0)|0,(Ne&A|0)==0&((ee()|0)&d|0)==0)?y=p:T=4;e:do if((T|0)==4){if(y=(Ri(A,d)|0)!=0,((y?4:5)|0)<(p|0)||gl(A,d,He)|0||(T=(f[He>>2]|0)+p|0,y?y=26704+(((T|0)%5|0)<<2)|0:y=26736+(((T|0)%6|0)<<2)|0,Ne=f[y>>2]|0,(Ne|0)==7))return _=1,Z=Ve,_|0;f[Ie>>2]=0,y=_i(A,d,Ne,Ie,ge)|0;do if(!y){if(R=ge,F=f[R>>2]|0,R=f[R+4>>2]|0,M=R>>>0>>0|(R|0)==(d|0)&F>>>0>>0,T=M?F:A,M=M?R:d,!re&&(re=zt(7,0,(H^15)*3|0)|0,(F&re|0)==0&(R&(ee()|0)|0)==0))y=p;else{if(R=(p+-1+B|0)%(B|0)|0,y=Ri(A,d)|0,(R|0)<0&&Vt(27795,27797,248,27822),B=(y|0)!=0,((B?4:5)|0)<(R|0)&&Vt(27795,27797,248,27822),gl(A,d,He)|0&&Vt(27795,27797,248,27822),y=(f[He>>2]|0)+R|0,B?y=26704+(((y|0)%5|0)<<2)|0:y=26736+(((y|0)%6|0)<<2)|0,R=f[y>>2]|0,(R|0)==7&&Vt(27795,27797,248,27822),f[pe>>2]=0,y=_i(A,d,R,pe,me)|0,y|0)break;F=me,B=f[F>>2]|0,F=f[F+4>>2]|0;do if(F>>>0>>0|(F|0)==(M|0)&B>>>0>>0){if(Ri(B,F)|0?T=ts(B,F,A,d)|0:T=f[26800+((((f[pe>>2]|0)+(f[26768+(R<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=Ri(B,F)|0,(T+-1|0)>>>0>5){y=-1,T=B,M=F;break}if(y=(y|0)!=0,(T|0)==1&y){y=-1,T=B,M=F;break}do if(gl(B,F,He)|0)y=-1;else if(y){y=((f[26352+(T<<2)>>2]|0)+5-(f[He>>2]|0)|0)%5|0;break}else{y=((f[26384+(T<<2)>>2]|0)+6-(f[He>>2]|0)|0)%6|0;break}while(!1);T=B,M=F}else y=p;while(!1);R=ge,F=f[R>>2]|0,R=f[R+4>>2]|0}if((T|0)==(F|0)&(M|0)==(R|0)){if(B=(Ri(F,R)|0)!=0,B?A=ts(F,R,A,d)|0:A=f[26800+((((f[Ie>>2]|0)+(f[26768+(Ne<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=Ri(F,R)|0,(A+-1|0)>>>0<=5&&(Je=(y|0)!=0,!((A|0)==1&Je)))do if(gl(F,R,He)|0)y=-1;else if(Je){y=((f[26352+(A<<2)>>2]|0)+5-(f[He>>2]|0)|0)%5|0;break}else{y=((f[26384+(A<<2)>>2]|0)+6-(f[He>>2]|0)|0)%6|0;break}while(!1);else y=-1;y=y+1|0,y=(y|0)==6|B&(y|0)==5?0:y}d=M,A=T;break e}while(!1);return _=y,Z=Ve,_|0}while(!1);return Je=zt(y|0,0,56)|0,He=ee()|0|d&-2130706433|536870912,f[_>>2]=Je|A,f[_+4>>2]=He,_=0,Z=Ve,_|0}function rc(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;return T=(Ri(A,d)|0)==0,_=ra(A,d,0,p)|0,y=(_|0)==0,T?!y||(_=ra(A,d,1,p+8|0)|0,_|0)||(_=ra(A,d,2,p+16|0)|0,_|0)||(_=ra(A,d,3,p+24|0)|0,_|0)||(_=ra(A,d,4,p+32|0)|0,_)?(T=_,T|0):ra(A,d,5,p+40|0)|0:!y||(_=ra(A,d,1,p+8|0)|0,_|0)||(_=ra(A,d,2,p+16|0)|0,_|0)||(_=ra(A,d,3,p+24|0)|0,_|0)||(_=ra(A,d,4,p+32|0)|0,_|0)?(T=_,T|0):(T=p+40|0,f[T>>2]=0,f[T+4>>2]=0,T=0,T|0)}function vl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0,R=0,B=0;return B=Z,Z=Z+192|0,y=B,T=B+168|0,M=Ut(A|0,d|0,56)|0,ee()|0,M=M&7,R=d&-2130706433|134217728,_=Xu(A,R,T)|0,_|0?(R=_,Z=B,R|0):(d=Ut(A|0,d|0,52)|0,ee()|0,d=d&15,Ri(A,R)|0?ap(T,d,M,1,y):Pd(T,d,M,1,y),R=y+8|0,f[p>>2]=f[R>>2],f[p+4>>2]=f[R+4>>2],f[p+8>>2]=f[R+8>>2],f[p+12>>2]=f[R+12>>2],R=0,Z=B,R|0)}function _l(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return y=Z,Z=Z+16|0,p=y,!(!0&(d&2013265920|0)==536870912)||(_=d&-2130706433|134217728,!(Ld(A,_)|0))?(_=0,Z=y,_|0):(T=Ut(A|0,d|0,56)|0,ee()|0,T=(ra(A,_,T&7,p)|0)==0,_=p,_=T&((f[_>>2]|0)==(A|0)?(f[_+4>>2]|0)==(d|0):0)&1,Z=y,_|0)}function Wo(A,d,p){A=A|0,d=d|0,p=p|0;var _=0;(d|0)>0?(_=sa(d,4)|0,f[A>>2]=_,_||Vt(27835,27858,40,27872)):f[A>>2]=0,f[A+4>>2]=d,f[A+8>>2]=0,f[A+12>>2]=p}function jd(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0;y=A+4|0,T=A+12|0,M=A+8|0;e:for(;;){for(p=f[y>>2]|0,d=0;;){if((d|0)>=(p|0))break e;if(_=f[A>>2]|0,R=f[_+(d<<2)>>2]|0,!R)d=d+1|0;else break}d=_+(~~(+An(+(+zr(10,+ +(15-(f[T>>2]|0)|0))*(+J[R>>3]+ +J[R+8>>3])))%+(p|0))>>>0<<2)|0,p=f[d>>2]|0;t:do if(p|0){if(_=R+32|0,(p|0)==(R|0))f[d>>2]=f[_>>2];else{if(p=p+32|0,d=f[p>>2]|0,!d)break;for(;(d|0)!=(R|0);)if(p=d+32|0,d=f[p>>2]|0,!d)break t;f[p>>2]=f[_>>2]}wn(R),f[M>>2]=(f[M>>2]|0)+-1}while(!1)}wn(f[A>>2]|0)}function Hd(A){A=A|0;var d=0,p=0,_=0;for(_=f[A+4>>2]|0,p=0;;){if((p|0)>=(_|0)){d=0,p=4;break}if(d=f[(f[A>>2]|0)+(p<<2)>>2]|0,!d)p=p+1|0;else{p=4;break}}return(p|0)==4?d|0:0}function sc(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;if(p=~~(+An(+(+zr(10,+ +(15-(f[A+12>>2]|0)|0))*(+J[d>>3]+ +J[d+8>>3])))%+(f[A+4>>2]|0))>>>0,p=(f[A>>2]|0)+(p<<2)|0,_=f[p>>2]|0,!_)return T=1,T|0;T=d+32|0;do if((_|0)!=(d|0)){if(p=f[_+32>>2]|0,!p)return T=1,T|0;for(y=p;;){if((y|0)==(d|0)){y=8;break}if(p=f[y+32>>2]|0,p)_=y,y=p;else{p=1,y=10;break}}if((y|0)==8){f[_+32>>2]=f[T>>2];break}else if((y|0)==10)return p|0}else f[p>>2]=f[T>>2];while(!1);return wn(d),T=A+8|0,f[T>>2]=(f[T>>2]|0)+-1,T=0,T|0}function Wd(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;T=$o(40)|0,T||Vt(27888,27858,98,27901),f[T>>2]=f[d>>2],f[T+4>>2]=f[d+4>>2],f[T+8>>2]=f[d+8>>2],f[T+12>>2]=f[d+12>>2],y=T+16|0,f[y>>2]=f[p>>2],f[y+4>>2]=f[p+4>>2],f[y+8>>2]=f[p+8>>2],f[y+12>>2]=f[p+12>>2],f[T+32>>2]=0,y=~~(+An(+(+zr(10,+ +(15-(f[A+12>>2]|0)|0))*(+J[d>>3]+ +J[d+8>>3])))%+(f[A+4>>2]|0))>>>0,y=(f[A>>2]|0)+(y<<2)|0,_=f[y>>2]|0;do if(!_)f[y>>2]=T;else{for(;!(La(_,d)|0&&La(_+16|0,p)|0);)if(y=f[_+32>>2]|0,_=(y|0)==0?_:y,!(f[_+32>>2]|0)){M=10;break}if((M|0)==10){f[_+32>>2]=T;break}return wn(T),M=_,M|0}while(!1);return M=A+8|0,f[M>>2]=(f[M>>2]|0)+1,M=T,M|0}function ac(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0;if(y=~~(+An(+(+zr(10,+ +(15-(f[A+12>>2]|0)|0))*(+J[d>>3]+ +J[d+8>>3])))%+(f[A+4>>2]|0))>>>0,y=f[(f[A>>2]|0)+(y<<2)>>2]|0,!y)return p=0,p|0;if(!p){for(A=y;;){if(La(A,d)|0){_=10;break}if(A=f[A+32>>2]|0,!A){A=0,_=10;break}}if((_|0)==10)return A|0}for(A=y;;){if(La(A,d)|0&&La(A+16|0,p)|0){_=10;break}if(A=f[A+32>>2]|0,!A){A=0,_=10;break}}return(_|0)==10?A|0:0}function bs(A,d){A=A|0,d=d|0;var p=0;if(p=~~(+An(+(+zr(10,+ +(15-(f[A+12>>2]|0)|0))*(+J[d>>3]+ +J[d+8>>3])))%+(f[A+4>>2]|0))>>>0,A=f[(f[A>>2]|0)+(p<<2)>>2]|0,!A)return p=0,p|0;for(;;){if(La(A,d)|0){d=5;break}if(A=f[A+32>>2]|0,!A){A=0,d=5;break}}return(d|0)==5?A|0:0}function $d(){return 27920}function yl(A){return A=+A,~~+vf(+A)|0}function $o(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0,Ne=0,Ie=0,Je=0,He=0,Ve=0,Re=0,jt=0;jt=Z,Z=Z+16|0,me=jt;do if(A>>>0<245){if(F=A>>>0<11?16:A+11&-8,A=F>>>3,re=f[6981]|0,p=re>>>A,p&3|0)return d=(p&1^1)+A|0,A=27964+(d<<1<<2)|0,p=A+8|0,_=f[p>>2]|0,y=_+8|0,T=f[y>>2]|0,(T|0)==(A|0)?f[6981]=re&~(1<>2]=A,f[p>>2]=T),Re=d<<3,f[_+4>>2]=Re|3,Re=_+Re+4|0,f[Re>>2]=f[Re>>2]|1,Re=y,Z=jt,Re|0;if(H=f[6983]|0,F>>>0>H>>>0){if(p|0)return d=2<>>12&16,d=d>>>R,p=d>>>5&8,d=d>>>p,T=d>>>2&4,d=d>>>T,A=d>>>1&2,d=d>>>A,_=d>>>1&1,_=(p|R|T|A|_)+(d>>>_)|0,d=27964+(_<<1<<2)|0,A=d+8|0,T=f[A>>2]|0,R=T+8|0,p=f[R>>2]|0,(p|0)==(d|0)?(A=re&~(1<<_),f[6981]=A):(f[p+12>>2]=d,f[A>>2]=p,A=re),Re=_<<3,M=Re-F|0,f[T+4>>2]=F|3,y=T+F|0,f[y+4>>2]=M|1,f[T+Re>>2]=M,H|0&&(_=f[6986]|0,d=H>>>3,p=27964+(d<<1<<2)|0,d=1<>2]|0):(f[6981]=A|d,d=p,A=p+8|0),f[A>>2]=_,f[d+12>>2]=_,f[_+8>>2]=d,f[_+12>>2]=p),f[6983]=M,f[6986]=y,Re=R,Z=jt,Re|0;if(T=f[6982]|0,T){for(p=(T&0-T)+-1|0,y=p>>>12&16,p=p>>>y,_=p>>>5&8,p=p>>>_,M=p>>>2&4,p=p>>>M,R=p>>>1&2,p=p>>>R,B=p>>>1&1,B=f[28228+((_|y|M|R|B)+(p>>>B)<<2)>>2]|0,p=B,R=B,B=(f[B+4>>2]&-8)-F|0;A=f[p+16>>2]|0,!(!A&&(A=f[p+20>>2]|0,!A));)M=(f[A+4>>2]&-8)-F|0,y=M>>>0>>0,p=A,R=y?A:R,B=y?M:B;if(M=R+F|0,M>>>0>R>>>0){y=f[R+24>>2]|0,d=f[R+12>>2]|0;do if((d|0)==(R|0)){if(A=R+20|0,d=f[A>>2]|0,!d&&(A=R+16|0,d=f[A>>2]|0,!d)){p=0;break}for(;;)if(_=d+20|0,p=f[_>>2]|0,p)d=p,A=_;else if(_=d+16|0,p=f[_>>2]|0,p)d=p,A=_;else break;f[A>>2]=0,p=d}else p=f[R+8>>2]|0,f[p+12>>2]=d,f[d+8>>2]=p,p=d;while(!1);do if(y|0){if(d=f[R+28>>2]|0,A=28228+(d<<2)|0,(R|0)==(f[A>>2]|0)){if(f[A>>2]=p,!p){f[6982]=T&~(1<>2]|0)==(R|0)?Re:y+20|0)>>2]=p,!p)break;f[p+24>>2]=y,d=f[R+16>>2]|0,d|0&&(f[p+16>>2]=d,f[d+24>>2]=p),d=f[R+20>>2]|0,d|0&&(f[p+20>>2]=d,f[d+24>>2]=p)}while(!1);return B>>>0<16?(Re=B+F|0,f[R+4>>2]=Re|3,Re=R+Re+4|0,f[Re>>2]=f[Re>>2]|1):(f[R+4>>2]=F|3,f[M+4>>2]=B|1,f[M+B>>2]=B,H|0&&(_=f[6986]|0,d=H>>>3,p=27964+(d<<1<<2)|0,d=1<>2]|0):(f[6981]=d|re,d=p,A=p+8|0),f[A>>2]=_,f[d+12>>2]=_,f[_+8>>2]=d,f[_+12>>2]=p),f[6983]=B,f[6986]=M),Re=R+8|0,Z=jt,Re|0}else re=F}else re=F}else re=F}else if(A>>>0<=4294967231)if(A=A+11|0,F=A&-8,_=f[6982]|0,_){y=0-F|0,A=A>>>8,A?F>>>0>16777215?B=31:(re=(A+1048320|0)>>>16&8,Ne=A<>>16&4,Ne=Ne<>>16&2,B=14-(R|re|B)+(Ne<>>15)|0,B=F>>>(B+7|0)&1|B<<1):B=0,p=f[28228+(B<<2)>>2]|0;e:do if(!p)p=0,A=0,Ne=61;else for(A=0,R=F<<((B|0)==31?0:25-(B>>>1)|0),T=0;;){if(M=(f[p+4>>2]&-8)-F|0,M>>>0>>0)if(M)A=p,y=M;else{A=p,y=0,Ne=65;break e}if(Ne=f[p+20>>2]|0,p=f[p+16+(R>>>31<<2)>>2]|0,T=(Ne|0)==0|(Ne|0)==(p|0)?T:Ne,p)R=R<<1;else{p=T,Ne=61;break}}while(!1);if((Ne|0)==61){if((p|0)==0&(A|0)==0){if(A=2<>>12&16,re=re>>>M,T=re>>>5&8,re=re>>>T,R=re>>>2&4,re=re>>>R,B=re>>>1&2,re=re>>>B,p=re>>>1&1,A=0,p=f[28228+((T|M|R|B|p)+(re>>>p)<<2)>>2]|0}p?Ne=65:(R=A,M=y)}if((Ne|0)==65)for(T=p;;)if(re=(f[T+4>>2]&-8)-F|0,p=re>>>0>>0,y=p?re:y,A=p?T:A,p=f[T+16>>2]|0,p||(p=f[T+20>>2]|0),p)T=p;else{R=A,M=y;break}if((R|0)!=0&&M>>>0<((f[6983]|0)-F|0)>>>0&&(H=R+F|0,H>>>0>R>>>0)){T=f[R+24>>2]|0,d=f[R+12>>2]|0;do if((d|0)==(R|0)){if(A=R+20|0,d=f[A>>2]|0,!d&&(A=R+16|0,d=f[A>>2]|0,!d)){d=0;break}for(;;)if(y=d+20|0,p=f[y>>2]|0,p)d=p,A=y;else if(y=d+16|0,p=f[y>>2]|0,p)d=p,A=y;else break;f[A>>2]=0}else Re=f[R+8>>2]|0,f[Re+12>>2]=d,f[d+8>>2]=Re;while(!1);do if(T){if(A=f[R+28>>2]|0,p=28228+(A<<2)|0,(R|0)==(f[p>>2]|0)){if(f[p>>2]=d,!d){_=_&~(1<>2]|0)==(R|0)?Re:T+20|0)>>2]=d,!d)break;f[d+24>>2]=T,A=f[R+16>>2]|0,A|0&&(f[d+16>>2]=A,f[A+24>>2]=d),A=f[R+20>>2]|0,A&&(f[d+20>>2]=A,f[A+24>>2]=d)}while(!1);e:do if(M>>>0<16)Re=M+F|0,f[R+4>>2]=Re|3,Re=R+Re+4|0,f[Re>>2]=f[Re>>2]|1;else{if(f[R+4>>2]=F|3,f[H+4>>2]=M|1,f[H+M>>2]=M,d=M>>>3,M>>>0<256){p=27964+(d<<1<<2)|0,A=f[6981]|0,d=1<>2]|0):(f[6981]=A|d,d=p,A=p+8|0),f[A>>2]=H,f[d+12>>2]=H,f[H+8>>2]=d,f[H+12>>2]=p;break}if(d=M>>>8,d?M>>>0>16777215?p=31:(Ve=(d+1048320|0)>>>16&8,Re=d<>>16&4,Re=Re<>>16&2,p=14-(He|Ve|p)+(Re<

>>15)|0,p=M>>>(p+7|0)&1|p<<1):p=0,d=28228+(p<<2)|0,f[H+28>>2]=p,A=H+16|0,f[A+4>>2]=0,f[A>>2]=0,A=1<>2]=H,f[H+24>>2]=d,f[H+12>>2]=H,f[H+8>>2]=H;break}d=f[d>>2]|0;t:do if((f[d+4>>2]&-8|0)!=(M|0)){for(_=M<<((p|0)==31?0:25-(p>>>1)|0);p=d+16+(_>>>31<<2)|0,A=f[p>>2]|0,!!A;)if((f[A+4>>2]&-8|0)==(M|0)){d=A;break t}else _=_<<1,d=A;f[p>>2]=H,f[H+24>>2]=d,f[H+12>>2]=H,f[H+8>>2]=H;break e}while(!1);Ve=d+8|0,Re=f[Ve>>2]|0,f[Re+12>>2]=H,f[Ve>>2]=H,f[H+8>>2]=Re,f[H+12>>2]=d,f[H+24>>2]=0}while(!1);return Re=R+8|0,Z=jt,Re|0}else re=F}else re=F;else re=-1;while(!1);if(p=f[6983]|0,p>>>0>=re>>>0)return d=p-re|0,A=f[6986]|0,d>>>0>15?(Re=A+re|0,f[6986]=Re,f[6983]=d,f[Re+4>>2]=d|1,f[A+p>>2]=d,f[A+4>>2]=re|3):(f[6983]=0,f[6986]=0,f[A+4>>2]=p|3,Re=A+p+4|0,f[Re>>2]=f[Re>>2]|1),Re=A+8|0,Z=jt,Re|0;if(M=f[6984]|0,M>>>0>re>>>0)return He=M-re|0,f[6984]=He,Re=f[6987]|0,Ve=Re+re|0,f[6987]=Ve,f[Ve+4>>2]=He|1,f[Re+4>>2]=re|3,Re=Re+8|0,Z=jt,Re|0;if(f[7099]|0?A=f[7101]|0:(f[7101]=4096,f[7100]=4096,f[7102]=-1,f[7103]=-1,f[7104]=0,f[7092]=0,f[7099]=me&-16^1431655768,A=4096),R=re+48|0,B=re+47|0,T=A+B|0,y=0-A|0,F=T&y,F>>>0<=re>>>0||(A=f[7091]|0,A|0&&(H=f[7089]|0,me=H+F|0,me>>>0<=H>>>0|me>>>0>A>>>0)))return Re=0,Z=jt,Re|0;e:do if(f[7092]&4)d=0,Ne=143;else{p=f[6987]|0;t:do if(p){for(_=28372;me=f[_>>2]|0,!(me>>>0<=p>>>0&&(me+(f[_+4>>2]|0)|0)>>>0>p>>>0);)if(A=f[_+8>>2]|0,A)_=A;else{Ne=128;break t}if(d=T-M&y,d>>>0<2147483647)if(A=bl(d|0)|0,(A|0)==((f[_>>2]|0)+(f[_+4>>2]|0)|0)){if((A|0)!=-1){M=d,T=A,Ne=145;break e}}else _=A,Ne=136;else d=0}else Ne=128;while(!1);do if((Ne|0)==128)if(p=bl(0)|0,(p|0)!=-1&&(d=p,pe=f[7100]|0,ge=pe+-1|0,d=((ge&d|0)==0?0:(ge+d&0-pe)-d|0)+F|0,pe=f[7089]|0,ge=d+pe|0,d>>>0>re>>>0&d>>>0<2147483647)){if(me=f[7091]|0,me|0&&ge>>>0<=pe>>>0|ge>>>0>me>>>0){d=0;break}if(A=bl(d|0)|0,(A|0)==(p|0)){M=d,T=p,Ne=145;break e}else _=A,Ne=136}else d=0;while(!1);do if((Ne|0)==136){if(p=0-d|0,!(R>>>0>d>>>0&(d>>>0<2147483647&(_|0)!=-1)))if((_|0)==-1){d=0;break}else{M=d,T=_,Ne=145;break e}if(A=f[7101]|0,A=B-d+A&0-A,A>>>0>=2147483647){M=d,T=_,Ne=145;break e}if((bl(A|0)|0)==-1){bl(p|0)|0,d=0;break}else{M=A+d|0,T=_,Ne=145;break e}}while(!1);f[7092]=f[7092]|4,Ne=143}while(!1);if((Ne|0)==143&&F>>>0<2147483647&&(He=bl(F|0)|0,ge=bl(0)|0,Ie=ge-He|0,Je=Ie>>>0>(re+40|0)>>>0,!((He|0)==-1|Je^1|He>>>0>>0&((He|0)!=-1&(ge|0)!=-1)^1))&&(M=Je?Ie:d,T=He,Ne=145),(Ne|0)==145){d=(f[7089]|0)+M|0,f[7089]=d,d>>>0>(f[7090]|0)>>>0&&(f[7090]=d),B=f[6987]|0;e:do if(B){for(d=28372;;){if(A=f[d>>2]|0,p=f[d+4>>2]|0,(T|0)==(A+p|0)){Ne=154;break}if(_=f[d+8>>2]|0,_)d=_;else break}if((Ne|0)==154&&(Ve=d+4|0,(f[d+12>>2]&8|0)==0)&&T>>>0>B>>>0&A>>>0<=B>>>0){f[Ve>>2]=p+M,Re=(f[6984]|0)+M|0,He=B+8|0,He=(He&7|0)==0?0:0-He&7,Ve=B+He|0,He=Re-He|0,f[6987]=Ve,f[6984]=He,f[Ve+4>>2]=He|1,f[B+Re+4>>2]=40,f[6988]=f[7103];break}for(T>>>0<(f[6985]|0)>>>0&&(f[6985]=T),p=T+M|0,d=28372;;){if((f[d>>2]|0)==(p|0)){Ne=162;break}if(A=f[d+8>>2]|0,A)d=A;else break}if((Ne|0)==162&&(f[d+12>>2]&8|0)==0){f[d>>2]=T,H=d+4|0,f[H>>2]=(f[H>>2]|0)+M,H=T+8|0,H=T+((H&7|0)==0?0:0-H&7)|0,d=p+8|0,d=p+((d&7|0)==0?0:0-d&7)|0,F=H+re|0,R=d-H-re|0,f[H+4>>2]=re|3;t:do if((B|0)==(d|0))Re=(f[6984]|0)+R|0,f[6984]=Re,f[6987]=F,f[F+4>>2]=Re|1;else{if((f[6986]|0)==(d|0)){Re=(f[6983]|0)+R|0,f[6983]=Re,f[6986]=F,f[F+4>>2]=Re|1,f[F+Re>>2]=Re;break}if(A=f[d+4>>2]|0,(A&3|0)==1){M=A&-8,_=A>>>3;n:do if(A>>>0<256)if(A=f[d+8>>2]|0,p=f[d+12>>2]|0,(p|0)==(A|0)){f[6981]=f[6981]&~(1<<_);break}else{f[A+12>>2]=p,f[p+8>>2]=A;break}else{T=f[d+24>>2]|0,A=f[d+12>>2]|0;do if((A|0)==(d|0)){if(p=d+16|0,_=p+4|0,A=f[_>>2]|0,A)p=_;else if(A=f[p>>2]|0,!A){A=0;break}for(;;)if(y=A+20|0,_=f[y>>2]|0,_)A=_,p=y;else if(y=A+16|0,_=f[y>>2]|0,_)A=_,p=y;else break;f[p>>2]=0}else Re=f[d+8>>2]|0,f[Re+12>>2]=A,f[A+8>>2]=Re;while(!1);if(!T)break;p=f[d+28>>2]|0,_=28228+(p<<2)|0;do if((f[_>>2]|0)!=(d|0)){if(Re=T+16|0,f[((f[Re>>2]|0)==(d|0)?Re:T+20|0)>>2]=A,!A)break n}else{if(f[_>>2]=A,A|0)break;f[6982]=f[6982]&~(1<>2]=T,p=d+16|0,_=f[p>>2]|0,_|0&&(f[A+16>>2]=_,f[_+24>>2]=A),p=f[p+4>>2]|0,!p)break;f[A+20>>2]=p,f[p+24>>2]=A}while(!1);d=d+M|0,y=M+R|0}else y=R;if(d=d+4|0,f[d>>2]=f[d>>2]&-2,f[F+4>>2]=y|1,f[F+y>>2]=y,d=y>>>3,y>>>0<256){p=27964+(d<<1<<2)|0,A=f[6981]|0,d=1<>2]|0):(f[6981]=A|d,d=p,A=p+8|0),f[A>>2]=F,f[d+12>>2]=F,f[F+8>>2]=d,f[F+12>>2]=p;break}d=y>>>8;do if(!d)_=0;else{if(y>>>0>16777215){_=31;break}Ve=(d+1048320|0)>>>16&8,Re=d<>>16&4,Re=Re<>>16&2,_=14-(He|Ve|_)+(Re<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1}while(!1);if(d=28228+(_<<2)|0,f[F+28>>2]=_,A=F+16|0,f[A+4>>2]=0,f[A>>2]=0,A=f[6982]|0,p=1<<_,!(A&p)){f[6982]=A|p,f[d>>2]=F,f[F+24>>2]=d,f[F+12>>2]=F,f[F+8>>2]=F;break}d=f[d>>2]|0;n:do if((f[d+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=d+16+(_>>>31<<2)|0,A=f[p>>2]|0,!!A;)if((f[A+4>>2]&-8|0)==(y|0)){d=A;break n}else _=_<<1,d=A;f[p>>2]=F,f[F+24>>2]=d,f[F+12>>2]=F,f[F+8>>2]=F;break t}while(!1);Ve=d+8|0,Re=f[Ve>>2]|0,f[Re+12>>2]=F,f[Ve>>2]=F,f[F+8>>2]=Re,f[F+12>>2]=d,f[F+24>>2]=0}while(!1);return Re=H+8|0,Z=jt,Re|0}for(d=28372;A=f[d>>2]|0,!(A>>>0<=B>>>0&&(Re=A+(f[d+4>>2]|0)|0,Re>>>0>B>>>0));)d=f[d+8>>2]|0;y=Re+-47|0,A=y+8|0,A=y+((A&7|0)==0?0:0-A&7)|0,y=B+16|0,A=A>>>0>>0?B:A,d=A+8|0,p=M+-40|0,He=T+8|0,He=(He&7|0)==0?0:0-He&7,Ve=T+He|0,He=p-He|0,f[6987]=Ve,f[6984]=He,f[Ve+4>>2]=He|1,f[T+p+4>>2]=40,f[6988]=f[7103],p=A+4|0,f[p>>2]=27,f[d>>2]=f[7093],f[d+4>>2]=f[7094],f[d+8>>2]=f[7095],f[d+12>>2]=f[7096],f[7093]=T,f[7094]=M,f[7096]=0,f[7095]=d,d=A+24|0;do Ve=d,d=d+4|0,f[d>>2]=7;while((Ve+8|0)>>>0>>0);if((A|0)!=(B|0)){if(T=A-B|0,f[p>>2]=f[p>>2]&-2,f[B+4>>2]=T|1,f[A>>2]=T,d=T>>>3,T>>>0<256){p=27964+(d<<1<<2)|0,A=f[6981]|0,d=1<>2]|0):(f[6981]=A|d,d=p,A=p+8|0),f[A>>2]=B,f[d+12>>2]=B,f[B+8>>2]=d,f[B+12>>2]=p;break}if(d=T>>>8,d?T>>>0>16777215?_=31:(Ve=(d+1048320|0)>>>16&8,Re=d<>>16&4,Re=Re<>>16&2,_=14-(He|Ve|_)+(Re<<_>>>15)|0,_=T>>>(_+7|0)&1|_<<1):_=0,p=28228+(_<<2)|0,f[B+28>>2]=_,f[B+20>>2]=0,f[y>>2]=0,d=f[6982]|0,A=1<<_,!(d&A)){f[6982]=d|A,f[p>>2]=B,f[B+24>>2]=p,f[B+12>>2]=B,f[B+8>>2]=B;break}d=f[p>>2]|0;t:do if((f[d+4>>2]&-8|0)!=(T|0)){for(_=T<<((_|0)==31?0:25-(_>>>1)|0);p=d+16+(_>>>31<<2)|0,A=f[p>>2]|0,!!A;)if((f[A+4>>2]&-8|0)==(T|0)){d=A;break t}else _=_<<1,d=A;f[p>>2]=B,f[B+24>>2]=d,f[B+12>>2]=B,f[B+8>>2]=B;break e}while(!1);Ve=d+8|0,Re=f[Ve>>2]|0,f[Re+12>>2]=B,f[Ve>>2]=B,f[B+8>>2]=Re,f[B+12>>2]=d,f[B+24>>2]=0}}else Re=f[6985]|0,(Re|0)==0|T>>>0>>0&&(f[6985]=T),f[7093]=T,f[7094]=M,f[7096]=0,f[6990]=f[7099],f[6989]=-1,f[6994]=27964,f[6993]=27964,f[6996]=27972,f[6995]=27972,f[6998]=27980,f[6997]=27980,f[7e3]=27988,f[6999]=27988,f[7002]=27996,f[7001]=27996,f[7004]=28004,f[7003]=28004,f[7006]=28012,f[7005]=28012,f[7008]=28020,f[7007]=28020,f[7010]=28028,f[7009]=28028,f[7012]=28036,f[7011]=28036,f[7014]=28044,f[7013]=28044,f[7016]=28052,f[7015]=28052,f[7018]=28060,f[7017]=28060,f[7020]=28068,f[7019]=28068,f[7022]=28076,f[7021]=28076,f[7024]=28084,f[7023]=28084,f[7026]=28092,f[7025]=28092,f[7028]=28100,f[7027]=28100,f[7030]=28108,f[7029]=28108,f[7032]=28116,f[7031]=28116,f[7034]=28124,f[7033]=28124,f[7036]=28132,f[7035]=28132,f[7038]=28140,f[7037]=28140,f[7040]=28148,f[7039]=28148,f[7042]=28156,f[7041]=28156,f[7044]=28164,f[7043]=28164,f[7046]=28172,f[7045]=28172,f[7048]=28180,f[7047]=28180,f[7050]=28188,f[7049]=28188,f[7052]=28196,f[7051]=28196,f[7054]=28204,f[7053]=28204,f[7056]=28212,f[7055]=28212,Re=M+-40|0,He=T+8|0,He=(He&7|0)==0?0:0-He&7,Ve=T+He|0,He=Re-He|0,f[6987]=Ve,f[6984]=He,f[Ve+4>>2]=He|1,f[T+Re+4>>2]=40,f[6988]=f[7103];while(!1);if(d=f[6984]|0,d>>>0>re>>>0)return He=d-re|0,f[6984]=He,Re=f[6987]|0,Ve=Re+re|0,f[6987]=Ve,f[Ve+4>>2]=He|1,f[Re+4>>2]=re|3,Re=Re+8|0,Z=jt,Re|0}return Re=$d()|0,f[Re>>2]=12,Re=0,Z=jt,Re|0}function wn(A){A=A|0;var d=0,p=0,_=0,y=0,T=0,M=0,R=0,B=0;if(A){p=A+-8|0,y=f[6985]|0,A=f[A+-4>>2]|0,d=A&-8,B=p+d|0;do if(A&1)R=p,M=p;else{if(_=f[p>>2]|0,!(A&3)||(M=p+(0-_)|0,T=_+d|0,M>>>0>>0))return;if((f[6986]|0)==(M|0)){if(A=B+4|0,d=f[A>>2]|0,(d&3|0)!=3){R=M,d=T;break}f[6983]=T,f[A>>2]=d&-2,f[M+4>>2]=T|1,f[M+T>>2]=T;return}if(p=_>>>3,_>>>0<256)if(A=f[M+8>>2]|0,d=f[M+12>>2]|0,(d|0)==(A|0)){f[6981]=f[6981]&~(1<>2]=d,f[d+8>>2]=A,R=M,d=T;break}y=f[M+24>>2]|0,A=f[M+12>>2]|0;do if((A|0)==(M|0)){if(d=M+16|0,p=d+4|0,A=f[p>>2]|0,A)d=p;else if(A=f[d>>2]|0,!A){A=0;break}for(;;)if(_=A+20|0,p=f[_>>2]|0,p)A=p,d=_;else if(_=A+16|0,p=f[_>>2]|0,p)A=p,d=_;else break;f[d>>2]=0}else R=f[M+8>>2]|0,f[R+12>>2]=A,f[A+8>>2]=R;while(!1);if(y){if(d=f[M+28>>2]|0,p=28228+(d<<2)|0,(f[p>>2]|0)==(M|0)){if(f[p>>2]=A,!A){f[6982]=f[6982]&~(1<>2]|0)==(M|0)?R:y+20|0)>>2]=A,!A){R=M,d=T;break}f[A+24>>2]=y,d=M+16|0,p=f[d>>2]|0,p|0&&(f[A+16>>2]=p,f[p+24>>2]=A),d=f[d+4>>2]|0,d?(f[A+20>>2]=d,f[d+24>>2]=A,R=M,d=T):(R=M,d=T)}else R=M,d=T}while(!1);if(!(M>>>0>=B>>>0)&&(A=B+4|0,_=f[A>>2]|0,!!(_&1))){if(_&2)f[A>>2]=_&-2,f[R+4>>2]=d|1,f[M+d>>2]=d,y=d;else{if((f[6987]|0)==(B|0)){if(B=(f[6984]|0)+d|0,f[6984]=B,f[6987]=R,f[R+4>>2]=B|1,(R|0)!=(f[6986]|0))return;f[6986]=0,f[6983]=0;return}if((f[6986]|0)==(B|0)){B=(f[6983]|0)+d|0,f[6983]=B,f[6986]=M,f[R+4>>2]=B|1,f[M+B>>2]=B;return}y=(_&-8)+d|0,p=_>>>3;do if(_>>>0<256)if(d=f[B+8>>2]|0,A=f[B+12>>2]|0,(A|0)==(d|0)){f[6981]=f[6981]&~(1<>2]=A,f[A+8>>2]=d;break}else{T=f[B+24>>2]|0,A=f[B+12>>2]|0;do if((A|0)==(B|0)){if(d=B+16|0,p=d+4|0,A=f[p>>2]|0,A)d=p;else if(A=f[d>>2]|0,!A){p=0;break}for(;;)if(_=A+20|0,p=f[_>>2]|0,p)A=p,d=_;else if(_=A+16|0,p=f[_>>2]|0,p)A=p,d=_;else break;f[d>>2]=0,p=A}else p=f[B+8>>2]|0,f[p+12>>2]=A,f[A+8>>2]=p,p=A;while(!1);if(T|0){if(A=f[B+28>>2]|0,d=28228+(A<<2)|0,(f[d>>2]|0)==(B|0)){if(f[d>>2]=p,!p){f[6982]=f[6982]&~(1<>2]|0)==(B|0)?_:T+20|0)>>2]=p,!p)break;f[p+24>>2]=T,A=B+16|0,d=f[A>>2]|0,d|0&&(f[p+16>>2]=d,f[d+24>>2]=p),A=f[A+4>>2]|0,A|0&&(f[p+20>>2]=A,f[A+24>>2]=p)}}while(!1);if(f[R+4>>2]=y|1,f[M+y>>2]=y,(R|0)==(f[6986]|0)){f[6983]=y;return}}if(A=y>>>3,y>>>0<256){p=27964+(A<<1<<2)|0,d=f[6981]|0,A=1<>2]|0):(f[6981]=d|A,A=p,d=p+8|0),f[d>>2]=R,f[A+12>>2]=R,f[R+8>>2]=A,f[R+12>>2]=p;return}A=y>>>8,A?y>>>0>16777215?_=31:(M=(A+1048320|0)>>>16&8,B=A<>>16&4,B=B<>>16&2,_=14-(T|M|_)+(B<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1):_=0,A=28228+(_<<2)|0,f[R+28>>2]=_,f[R+20>>2]=0,f[R+16>>2]=0,d=f[6982]|0,p=1<<_;e:do if(!(d&p))f[6982]=d|p,f[A>>2]=R,f[R+24>>2]=A,f[R+12>>2]=R,f[R+8>>2]=R;else{A=f[A>>2]|0;t:do if((f[A+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=A+16+(_>>>31<<2)|0,d=f[p>>2]|0,!!d;)if((f[d+4>>2]&-8|0)==(y|0)){A=d;break t}else _=_<<1,A=d;f[p>>2]=R,f[R+24>>2]=A,f[R+12>>2]=R,f[R+8>>2]=R;break e}while(!1);M=A+8|0,B=f[M>>2]|0,f[B+12>>2]=R,f[M>>2]=R,f[R+8>>2]=B,f[R+12>>2]=A,f[R+24>>2]=0}while(!1);if(B=(f[6989]|0)+-1|0,f[6989]=B,!(B|0)){for(A=28380;A=f[A>>2]|0,A;)A=A+8|0;f[6989]=-1}}}}function sa(A,d){A=A|0,d=d|0;var p=0;return A?(p=Ke(d,A)|0,(d|A)>>>0>65535&&(p=((p>>>0)/(A>>>0)|0|0)==(d|0)?p:-1)):p=0,A=$o(p)|0,!A||!(f[A+-4>>2]&3)||vo(A|0,0,p|0)|0,A|0}function rn(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,p=A+p>>>0,Mt(d+_+(p>>>0>>0|0)>>>0|0),p|0|0}function Hr(A,d,p,_){return A=A|0,d=d|0,p=p|0,_=_|0,_=d-_-(p>>>0>A>>>0|0)>>>0,Mt(_|0),A-p>>>0|0|0}function sh(A){return A=A|0,(A?31-(tn(A^A-1)|0)|0:32)|0}function oc(A,d,p,_,y){A=A|0,d=d|0,p=p|0,_=_|0,y=y|0;var T=0,M=0,R=0,B=0,F=0,H=0,re=0,me=0,pe=0,ge=0;if(H=A,B=d,F=B,M=p,me=_,R=me,!F)return T=(y|0)!=0,R?T?(f[y>>2]=A|0,f[y+4>>2]=d&0,me=0,y=0,Mt(me|0),y|0):(me=0,y=0,Mt(me|0),y|0):(T&&(f[y>>2]=(H>>>0)%(M>>>0),f[y+4>>2]=0),me=0,y=(H>>>0)/(M>>>0)>>>0,Mt(me|0),y|0);T=(R|0)==0;do if(M){if(!T){if(T=(tn(R|0)|0)-(tn(F|0)|0)|0,T>>>0<=31){re=T+1|0,R=31-T|0,d=T-31>>31,M=re,A=H>>>(re>>>0)&d|F<>>(re>>>0)&d,T=0,R=H<>2]=A|0,f[y+4>>2]=B|d&0,me=0,y=0,Mt(me|0),y|0):(me=0,y=0,Mt(me|0),y|0)}if(T=M-1|0,T&M|0){R=(tn(M|0)|0)+33-(tn(F|0)|0)|0,ge=64-R|0,re=32-R|0,B=re>>31,pe=R-32|0,d=pe>>31,M=R,A=re-1>>31&F>>>(pe>>>0)|(F<>>(R>>>0))&d,d=d&F>>>(R>>>0),T=H<>>(pe>>>0))&B|H<>31;break}return y|0&&(f[y>>2]=T&H,f[y+4>>2]=0),(M|0)==1?(pe=B|d&0,ge=A|0|0,Mt(pe|0),ge|0):(ge=sh(M|0)|0,pe=F>>>(ge>>>0)|0,ge=F<<32-ge|H>>>(ge>>>0)|0,Mt(pe|0),ge|0)}else{if(T)return y|0&&(f[y>>2]=(F>>>0)%(M>>>0),f[y+4>>2]=0),pe=0,ge=(F>>>0)/(M>>>0)>>>0,Mt(pe|0),ge|0;if(!H)return y|0&&(f[y>>2]=0,f[y+4>>2]=(F>>>0)%(R>>>0)),pe=0,ge=(F>>>0)/(R>>>0)>>>0,Mt(pe|0),ge|0;if(T=R-1|0,!(T&R))return y|0&&(f[y>>2]=A|0,f[y+4>>2]=T&F|d&0),pe=0,ge=F>>>((sh(R|0)|0)>>>0),Mt(pe|0),ge|0;if(T=(tn(R|0)|0)-(tn(F|0)|0)|0,T>>>0<=30){d=T+1|0,R=31-T|0,M=d,A=F<>>(d>>>0),d=F>>>(d>>>0),T=0,R=H<>2]=A|0,f[y+4>>2]=B|d&0,pe=0,ge=0,Mt(pe|0),ge|0):(pe=0,ge=0,Mt(pe|0),ge|0)}while(!1);if(!M)F=R,B=0,R=0;else{re=p|0|0,H=me|_&0,F=rn(re|0,H|0,-1,-1)|0,p=ee()|0,B=R,R=0;do _=B,B=T>>>31|B<<1,T=R|T<<1,_=A<<1|_>>>31|0,me=A>>>31|d<<1|0,Hr(F|0,p|0,_|0,me|0)|0,ge=ee()|0,pe=ge>>31|((ge|0)<0?-1:0)<<1,R=pe&1,A=Hr(_|0,me|0,pe&re|0,(((ge|0)<0?-1:0)>>31|((ge|0)<0?-1:0)<<1)&H|0)|0,d=ee()|0,M=M-1|0;while((M|0)!=0);F=B,B=0}return M=0,y|0&&(f[y>>2]=A,f[y+4>>2]=d),pe=(T|0)>>>31|(F|M)<<1|(M<<1|T>>>31)&0|B,ge=(T<<1|0)&-2|R,Mt(pe|0),ge|0}function Xo(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;return F=d>>31|((d|0)<0?-1:0)<<1,B=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1,T=_>>31|((_|0)<0?-1:0)<<1,y=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,R=Hr(F^A|0,B^d|0,F|0,B|0)|0,M=ee()|0,A=T^F,d=y^B,Hr((oc(R,M,Hr(T^p|0,y^_|0,T|0,y|0)|0,ee()|0,0)|0)^A|0,(ee()|0)^d|0,A|0,d|0)|0}function ah(A,d){A=A|0,d=d|0;var p=0,_=0,y=0,T=0;return T=A&65535,y=d&65535,p=Ke(y,T)|0,_=A>>>16,A=(p>>>16)+(Ke(y,_)|0)|0,y=d>>>16,d=Ke(y,T)|0,Mt((A>>>16)+(Ke(y,_)|0)+(((A&65535)+d|0)>>>16)|0),A+d<<16|p&65535|0|0}function vr(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0;return y=A,T=p,p=ah(y,T)|0,A=ee()|0,Mt((Ke(d,T)|0)+(Ke(_,y)|0)+A|A&0|0),p|0|0|0}function oh(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0,M=0,R=0,B=0,F=0;return y=Z,Z=Z+16|0,R=y|0,M=d>>31|((d|0)<0?-1:0)<<1,T=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1,F=_>>31|((_|0)<0?-1:0)<<1,B=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,A=Hr(M^A|0,T^d|0,M|0,T|0)|0,d=ee()|0,oc(A,d,Hr(F^p|0,B^_|0,F|0,B|0)|0,ee()|0,R)|0,_=Hr(f[R>>2]^M|0,f[R+4>>2]^T|0,M|0,T|0)|0,p=ee()|0,Z=y,Mt(p|0),_|0}function lc(A,d,p,_){A=A|0,d=d|0,p=p|0,_=_|0;var y=0,T=0;return T=Z,Z=Z+16|0,y=T|0,oc(A,d,p,_,y)|0,Z=T,Mt(f[y+4>>2]|0),f[y>>2]|0|0}function D1(A,d,p){return A=A|0,d=d|0,p=p|0,(p|0)<32?(Mt(d>>p|0),A>>>p|(d&(1<>p-32|0)}function Ut(A,d,p){return A=A|0,d=d|0,p=p|0,(p|0)<32?(Mt(d>>>p|0),A>>>p|(d&(1<>>p-32|0)}function zt(A,d,p){return A=A|0,d=d|0,p=p|0,(p|0)<32?(Mt(d<>>32-p|0),A<=0?+zn(A+.5):+tt(A-.5)}function Yl(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0;if((p|0)>=8192)return oi(A|0,d|0,p|0)|0,A|0;if(T=A|0,y=A+p|0,(A&3)==(d&3)){for(;A&3;){if(!p)return T|0;ot[A>>0]=ot[d>>0]|0,A=A+1|0,d=d+1|0,p=p-1|0}for(p=y&-4|0,_=p-64|0;(A|0)<=(_|0);)f[A>>2]=f[d>>2],f[A+4>>2]=f[d+4>>2],f[A+8>>2]=f[d+8>>2],f[A+12>>2]=f[d+12>>2],f[A+16>>2]=f[d+16>>2],f[A+20>>2]=f[d+20>>2],f[A+24>>2]=f[d+24>>2],f[A+28>>2]=f[d+28>>2],f[A+32>>2]=f[d+32>>2],f[A+36>>2]=f[d+36>>2],f[A+40>>2]=f[d+40>>2],f[A+44>>2]=f[d+44>>2],f[A+48>>2]=f[d+48>>2],f[A+52>>2]=f[d+52>>2],f[A+56>>2]=f[d+56>>2],f[A+60>>2]=f[d+60>>2],A=A+64|0,d=d+64|0;for(;(A|0)<(p|0);)f[A>>2]=f[d>>2],A=A+4|0,d=d+4|0}else for(p=y-4|0;(A|0)<(p|0);)ot[A>>0]=ot[d>>0]|0,ot[A+1>>0]=ot[d+1>>0]|0,ot[A+2>>0]=ot[d+2>>0]|0,ot[A+3>>0]=ot[d+3>>0]|0,A=A+4|0,d=d+4|0;for(;(A|0)<(y|0);)ot[A>>0]=ot[d>>0]|0,A=A+1|0,d=d+1|0;return T|0}function vo(A,d,p){A=A|0,d=d|0,p=p|0;var _=0,y=0,T=0,M=0;if(T=A+p|0,d=d&255,(p|0)>=67){for(;A&3;)ot[A>>0]=d,A=A+1|0;for(_=T&-4|0,M=d|d<<8|d<<16|d<<24,y=_-64|0;(A|0)<=(y|0);)f[A>>2]=M,f[A+4>>2]=M,f[A+8>>2]=M,f[A+12>>2]=M,f[A+16>>2]=M,f[A+20>>2]=M,f[A+24>>2]=M,f[A+28>>2]=M,f[A+32>>2]=M,f[A+36>>2]=M,f[A+40>>2]=M,f[A+44>>2]=M,f[A+48>>2]=M,f[A+52>>2]=M,f[A+56>>2]=M,f[A+60>>2]=M,A=A+64|0;for(;(A|0)<(_|0);)f[A>>2]=M,A=A+4|0}for(;(A|0)<(T|0);)ot[A>>0]=d,A=A+1|0;return T-p|0}function vf(A){return A=+A,A>=0?+zn(A+.5):+tt(A-.5)}function bl(A){A=A|0;var d=0,p=0,_=0;return _=Tn()|0,p=f[fn>>2]|0,d=p+A|0,(A|0)>0&(d|0)<(p|0)|(d|0)<0?(Ii(d|0)|0,Fn(12),-1):(d|0)>(_|0)&&!(Ai(d|0)|0)?(Fn(12),-1):(f[fn>>2]=d,p|0)}return{___divdi3:Xo,___muldi3:vr,___remdi3:oh,___uremdi3:lc,_areNeighborCells:Ax,_bitshift64Ashr:D1,_bitshift64Lshr:Ut,_bitshift64Shl:zt,_calloc:sa,_cellAreaKm2:gp,_cellAreaM2:Id,_cellAreaRads2:Wl,_cellToBoundary:Hl,_cellToCenterChild:Ud,_cellToChildPos:Ap,_cellToChildren:y1,_cellToChildrenSize:hf,_cellToLatLng:jl,_cellToLocalIj:C1,_cellToParent:Wu,_cellToVertex:ra,_cellToVertexes:rc,_cellsToDirectedEdge:p1,_cellsToLinkedMultiPolygon:fi,_childPosToCell:T1,_compactCells:cp,_constructCell:Sx,_destroyLinkedMultiPolygon:ec,_directedEdgeToBoundary:Dd,_directedEdgeToCells:gx,_edgeLengthKm:vp,_edgeLengthM:Ju,_edgeLengthRads:Fd,_emscripten_replace_memory:Vn,_free:wn,_getBaseCellNumber:v1,_getDirectedEdgeDestination:mx,_getDirectedEdgeOrigin:px,_getHexagonAreaAvgKm2:pp,_getHexagonAreaAvgM2:M1,_getHexagonEdgeLengthAvgKm:mp,_getHexagonEdgeLengthAvgM:mo,_getIcosahedronFaces:Yu,_getIndexDigit:bx,_getNumCells:Zu,_getPentagons:Qu,_getRes0Cells:fl,_getResolution:nh,_greatCircleDistanceKm:rh,_greatCircleDistanceM:Mx,_greatCircleDistanceRads:w1,_gridDisk:qr,_gridDiskDistances:Er,_gridDistance:tc,_gridPathCells:N1,_gridPathCellsSize:_p,_gridRing:pr,_gridRingUnsafe:Vr,_i64Add:rn,_i64Subtract:Hr,_isPentagon:Ri,_isResClassIII:S1,_isValidCell:Ld,_isValidDirectedEdge:m1,_isValidIndex:_1,_isValidVertex:_l,_latLngToCell:Bd,_llvm_ctlz_i64:pf,_llvm_maxnum_f64:mf,_llvm_minnum_f64:gf,_llvm_round_f64:xl,_localIjToCell:zd,_malloc:$o,_maxFaceCount:wx,_maxGridDiskSize:Gr,_maxPolygonToCellsSize:Md,_maxPolygonToCellsSizeExperimental:df,_memcpy:Yl,_memset:vo,_originToDirectedEdges:vx,_pentagonCount:dp,_polygonToCells:Rt,_polygonToCellsExperimental:qd,_readInt64AsDoubleFromPointer:xp,_res0CellCount:Go,_round:vf,_sbrk:bl,_sizeOfCellBoundary:xs,_sizeOfCoordIJ:Fa,_sizeOfGeoLoop:ur,_sizeOfGeoPolygon:xi,_sizeOfH3Index:yp,_sizeOfLatLng:R1,_sizeOfLinkedGeoPolygon:$l,_uncompactCells:x1,_uncompactCellsSize:b1,_vertexToLatLng:vl,establishStackSpace:Ds,stackAlloc:bn,stackRestore:pi,stackSave:Mr}})(nt,At,Y);e.___divdi3=ce.___divdi3,e.___muldi3=ce.___muldi3,e.___remdi3=ce.___remdi3,e.___uremdi3=ce.___uremdi3,e._areNeighborCells=ce._areNeighborCells,e._bitshift64Ashr=ce._bitshift64Ashr,e._bitshift64Lshr=ce._bitshift64Lshr,e._bitshift64Shl=ce._bitshift64Shl,e._calloc=ce._calloc,e._cellAreaKm2=ce._cellAreaKm2,e._cellAreaM2=ce._cellAreaM2,e._cellAreaRads2=ce._cellAreaRads2,e._cellToBoundary=ce._cellToBoundary,e._cellToCenterChild=ce._cellToCenterChild,e._cellToChildPos=ce._cellToChildPos,e._cellToChildren=ce._cellToChildren,e._cellToChildrenSize=ce._cellToChildrenSize,e._cellToLatLng=ce._cellToLatLng,e._cellToLocalIj=ce._cellToLocalIj,e._cellToParent=ce._cellToParent,e._cellToVertex=ce._cellToVertex,e._cellToVertexes=ce._cellToVertexes,e._cellsToDirectedEdge=ce._cellsToDirectedEdge,e._cellsToLinkedMultiPolygon=ce._cellsToLinkedMultiPolygon,e._childPosToCell=ce._childPosToCell,e._compactCells=ce._compactCells,e._constructCell=ce._constructCell,e._destroyLinkedMultiPolygon=ce._destroyLinkedMultiPolygon,e._directedEdgeToBoundary=ce._directedEdgeToBoundary,e._directedEdgeToCells=ce._directedEdgeToCells,e._edgeLengthKm=ce._edgeLengthKm,e._edgeLengthM=ce._edgeLengthM,e._edgeLengthRads=ce._edgeLengthRads;var xt=e._emscripten_replace_memory=ce._emscripten_replace_memory;e._free=ce._free,e._getBaseCellNumber=ce._getBaseCellNumber,e._getDirectedEdgeDestination=ce._getDirectedEdgeDestination,e._getDirectedEdgeOrigin=ce._getDirectedEdgeOrigin,e._getHexagonAreaAvgKm2=ce._getHexagonAreaAvgKm2,e._getHexagonAreaAvgM2=ce._getHexagonAreaAvgM2,e._getHexagonEdgeLengthAvgKm=ce._getHexagonEdgeLengthAvgKm,e._getHexagonEdgeLengthAvgM=ce._getHexagonEdgeLengthAvgM,e._getIcosahedronFaces=ce._getIcosahedronFaces,e._getIndexDigit=ce._getIndexDigit,e._getNumCells=ce._getNumCells,e._getPentagons=ce._getPentagons,e._getRes0Cells=ce._getRes0Cells,e._getResolution=ce._getResolution,e._greatCircleDistanceKm=ce._greatCircleDistanceKm,e._greatCircleDistanceM=ce._greatCircleDistanceM,e._greatCircleDistanceRads=ce._greatCircleDistanceRads,e._gridDisk=ce._gridDisk,e._gridDiskDistances=ce._gridDiskDistances,e._gridDistance=ce._gridDistance,e._gridPathCells=ce._gridPathCells,e._gridPathCellsSize=ce._gridPathCellsSize,e._gridRing=ce._gridRing,e._gridRingUnsafe=ce._gridRingUnsafe,e._i64Add=ce._i64Add,e._i64Subtract=ce._i64Subtract,e._isPentagon=ce._isPentagon,e._isResClassIII=ce._isResClassIII,e._isValidCell=ce._isValidCell,e._isValidDirectedEdge=ce._isValidDirectedEdge,e._isValidIndex=ce._isValidIndex,e._isValidVertex=ce._isValidVertex,e._latLngToCell=ce._latLngToCell,e._llvm_ctlz_i64=ce._llvm_ctlz_i64,e._llvm_maxnum_f64=ce._llvm_maxnum_f64,e._llvm_minnum_f64=ce._llvm_minnum_f64,e._llvm_round_f64=ce._llvm_round_f64,e._localIjToCell=ce._localIjToCell,e._malloc=ce._malloc,e._maxFaceCount=ce._maxFaceCount,e._maxGridDiskSize=ce._maxGridDiskSize,e._maxPolygonToCellsSize=ce._maxPolygonToCellsSize,e._maxPolygonToCellsSizeExperimental=ce._maxPolygonToCellsSizeExperimental,e._memcpy=ce._memcpy,e._memset=ce._memset,e._originToDirectedEdges=ce._originToDirectedEdges,e._pentagonCount=ce._pentagonCount,e._polygonToCells=ce._polygonToCells,e._polygonToCellsExperimental=ce._polygonToCellsExperimental,e._readInt64AsDoubleFromPointer=ce._readInt64AsDoubleFromPointer,e._res0CellCount=ce._res0CellCount,e._round=ce._round,e._sbrk=ce._sbrk,e._sizeOfCellBoundary=ce._sizeOfCellBoundary,e._sizeOfCoordIJ=ce._sizeOfCoordIJ,e._sizeOfGeoLoop=ce._sizeOfGeoLoop,e._sizeOfGeoPolygon=ce._sizeOfGeoPolygon,e._sizeOfH3Index=ce._sizeOfH3Index,e._sizeOfLatLng=ce._sizeOfLatLng,e._sizeOfLinkedGeoPolygon=ce._sizeOfLinkedGeoPolygon,e._uncompactCells=ce._uncompactCells,e._uncompactCellsSize=ce._uncompactCellsSize,e._vertexToLatLng=ce._vertexToLatLng,e.establishStackSpace=ce.establishStackSpace;var Ze=e.stackAlloc=ce.stackAlloc,lt=e.stackRestore=ce.stackRestore,bt=e.stackSave=ce.stackSave;if(e.asm=ce,e.cwrap=U,e.setValue=S,e.getValue=w,fe){_e(fe)||(fe=s(fe));{hn();var Kt=function(Pe){Pe.byteLength&&(Pe=new Uint8Array(Pe)),ne.set(Pe,x),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,ut()},un=function(){a(fe,Kt,function(){throw"could not load memory initializer "+fe})},Ye=Te(fe);if(Ye)Kt(Ye.buffer);else if(e.memoryInitializerRequest){var St=function(){var Pe=e.memoryInitializerRequest,at=Pe.response;if(Pe.status!==200&&Pe.status!==0){var ht=Te(e.memoryInitializerRequestURL);if(ht)at=ht.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+Pe.status+", retrying "+fe),un();return}}Kt(at)};e.memoryInitializerRequest.response?setTimeout(St,0):e.memoryInitializerRequest.addEventListener("load",St)}else un()}}var ye;Lt=function Pe(){ye||pt(),ye||(Lt=Pe)};function pt(Pe){if(qt>0||(et(),qt>0))return;function at(){ye||(ye=!0,!N&&(Pt(),Nt(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Gt()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),at()},1)):at()}e.run=pt;function Zt(Pe){throw e.onAbort&&e.onAbort(Pe),Pe+="",l(Pe),u(Pe),N=!0,"abort("+Pe+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=Zt,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return pt(),i})(typeof Mi=="object"?Mi:{}),kn="number",On=kn,NA=kn,Hn=kn,Wn=kn,Is=kn,dn=kn,iZ=[["sizeOfH3Index",kn],["sizeOfLatLng",kn],["sizeOfCellBoundary",kn],["sizeOfGeoLoop",kn],["sizeOfGeoPolygon",kn],["sizeOfLinkedGeoPolygon",kn],["sizeOfCoordIJ",kn],["readInt64AsDoubleFromPointer",kn],["isValidCell",NA,[Hn,Wn]],["isValidIndex",NA,[Hn,Wn]],["latLngToCell",On,[kn,kn,Is,dn]],["cellToLatLng",On,[Hn,Wn,dn]],["cellToBoundary",On,[Hn,Wn,dn]],["maxGridDiskSize",On,[kn,dn]],["gridDisk",On,[Hn,Wn,kn,dn]],["gridDiskDistances",On,[Hn,Wn,kn,dn,dn]],["gridRing",On,[Hn,Wn,kn,dn]],["gridRingUnsafe",On,[Hn,Wn,kn,dn]],["maxPolygonToCellsSize",On,[dn,Is,kn,dn]],["polygonToCells",On,[dn,Is,kn,dn]],["maxPolygonToCellsSizeExperimental",On,[dn,Is,kn,dn]],["polygonToCellsExperimental",On,[dn,Is,kn,kn,kn,dn]],["cellsToLinkedMultiPolygon",On,[dn,kn,dn]],["destroyLinkedMultiPolygon",null,[dn]],["compactCells",On,[dn,dn,kn,kn]],["uncompactCells",On,[dn,kn,kn,dn,kn,Is]],["uncompactCellsSize",On,[dn,kn,kn,Is,dn]],["isPentagon",NA,[Hn,Wn]],["isResClassIII",NA,[Hn,Wn]],["getBaseCellNumber",kn,[Hn,Wn]],["getResolution",kn,[Hn,Wn]],["getIndexDigit",kn,[Hn,Wn,kn]],["constructCell",On,[kn,kn,dn,dn]],["maxFaceCount",On,[Hn,Wn,dn]],["getIcosahedronFaces",On,[Hn,Wn,dn]],["cellToParent",On,[Hn,Wn,Is,dn]],["cellToChildren",On,[Hn,Wn,Is,dn]],["cellToCenterChild",On,[Hn,Wn,Is,dn]],["cellToChildrenSize",On,[Hn,Wn,Is,dn]],["cellToChildPos",On,[Hn,Wn,Is,dn]],["childPosToCell",On,[kn,kn,Hn,Wn,Is,dn]],["areNeighborCells",On,[Hn,Wn,Hn,Wn,dn]],["cellsToDirectedEdge",On,[Hn,Wn,Hn,Wn,dn]],["getDirectedEdgeOrigin",On,[Hn,Wn,dn]],["getDirectedEdgeDestination",On,[Hn,Wn,dn]],["isValidDirectedEdge",NA,[Hn,Wn]],["directedEdgeToCells",On,[Hn,Wn,dn]],["originToDirectedEdges",On,[Hn,Wn,dn]],["directedEdgeToBoundary",On,[Hn,Wn,dn]],["gridDistance",On,[Hn,Wn,Hn,Wn,dn]],["gridPathCells",On,[Hn,Wn,Hn,Wn,dn]],["gridPathCellsSize",On,[Hn,Wn,Hn,Wn,dn]],["cellToLocalIj",On,[Hn,Wn,Hn,Wn,kn,dn]],["localIjToCell",On,[Hn,Wn,dn,kn,dn]],["getHexagonAreaAvgM2",On,[Is,dn]],["getHexagonAreaAvgKm2",On,[Is,dn]],["getHexagonEdgeLengthAvgM",On,[Is,dn]],["getHexagonEdgeLengthAvgKm",On,[Is,dn]],["greatCircleDistanceM",kn,[dn,dn]],["greatCircleDistanceKm",kn,[dn,dn]],["greatCircleDistanceRads",kn,[dn,dn]],["cellAreaM2",On,[Hn,Wn,dn]],["cellAreaKm2",On,[Hn,Wn,dn]],["cellAreaRads2",On,[Hn,Wn,dn]],["edgeLengthM",On,[Hn,Wn,dn]],["edgeLengthKm",On,[Hn,Wn,dn]],["edgeLengthRads",On,[Hn,Wn,dn]],["getNumCells",On,[Is,dn]],["getRes0Cells",On,[dn]],["res0CellCount",kn],["getPentagons",On,[kn,dn]],["pentagonCount",kn],["cellToVertex",On,[Hn,Wn,kn,dn]],["cellToVertexes",On,[Hn,Wn,dn]],["vertexToLatLng",On,[Hn,Wn,dn]],["isValidVertex",NA,[Hn,Wn]]],rZ=0,sZ=1,aZ=2,oZ=3,TP=4,lZ=5,uZ=6,cZ=7,hZ=8,fZ=9,dZ=10,AZ=11,pZ=12,mZ=13,gZ=14,vZ=15,_Z=16,yZ=17,xZ=18,bZ=19,us={};us[rZ]="Success";us[sZ]="The operation failed but a more specific error is not available";us[aZ]="Argument was outside of acceptable range";us[oZ]="Latitude or longitude arguments were outside of acceptable range";us[TP]="Resolution argument was outside of acceptable range";us[lZ]="Cell argument was not valid";us[uZ]="Directed edge argument was not valid";us[cZ]="Undirected edge argument was not valid";us[hZ]="Vertex argument was not valid";us[fZ]="Pentagon distortion was encountered";us[dZ]="Duplicate input";us[AZ]="Cell arguments were not neighbors";us[pZ]="Cell arguments had incompatible resolutions";us[mZ]="Memory allocation failed";us[gZ]="Bounds of provided memory were insufficient";us[vZ]="Mode or flags argument was not valid";us[_Z]="Index argument was not valid";us[yZ]="Base cell number was outside of acceptable range";us[xZ]="Child indexing digits invalid";us[bZ]="Child indexing digits refer to a deleted subsequence";var SZ=1e3,wP=1001,MP=1002,Ny={};Ny[SZ]="Unknown unit";Ny[wP]="Array length out of bounds";Ny[MP]="Got unexpected null value for H3 index";var TZ="Unknown error";function EP(i,e,t){var n=t&&"value"in t,r=new Error((i[e]||TZ)+" (code: "+e+(n?", value: "+t.value:"")+")");return r.code=e,r}function CP(i,e){var t=arguments.length===2?{value:e}:{};return EP(us,i,t)}function NP(i,e){var t=arguments.length===2?{value:e}:{};return EP(Ny,i,t)}function yg(i){if(i!==0)throw CP(i)}var ao={};iZ.forEach(function(e){ao[e[0]]=Mi.cwrap.apply(Mi,e)});var KA=16,xg=4,I0=8,wZ=8,H_=ao.sizeOfH3Index(),CM=ao.sizeOfLatLng(),MZ=ao.sizeOfCellBoundary(),EZ=ao.sizeOfGeoPolygon(),Bm=ao.sizeOfGeoLoop();ao.sizeOfLinkedGeoPolygon();ao.sizeOfCoordIJ();function CZ(i){if(typeof i!="number"||i<0||i>15||Math.floor(i)!==i)throw CP(TP,i);return i}function NZ(i){if(!i)throw NP(MP);return i}var RZ=Math.pow(2,32)-1;function DZ(i){if(i>RZ)throw NP(wP,i);return i}var PZ=/[^0-9a-fA-F]/;function RP(i){if(Array.isArray(i)&&i.length===2&&Number.isInteger(i[0])&&Number.isInteger(i[1]))return i;if(typeof i!="string"||PZ.test(i))return[0,0];var e=parseInt(i.substring(0,i.length-8),KA),t=parseInt(i.substring(i.length-8),KA);return[t,e]}function NR(i){if(i>=0)return i.toString(KA);i=i&2147483647;var e=DP(8,i.toString(KA)),t=(parseInt(e[0],KA)+8).toString(KA);return e=t+e.substring(1),e}function LZ(i,e){return NR(e)+DP(8,NR(i))}function DP(i,e){for(var t=i-e.length,n="",r=0;r0){l=Mi._calloc(t,Bm);for(var u=0;u0){for(var a=Mi.getValue(i+n,"i32"),l=0;l0){const{width:a,height:l}=e.context;t.bufferWidth=a,t.bufferHeight=l}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){const{object:t,material:n,geometry:r}=e,s=this.getRenderObjectData(e);if(s.worldMatrix.equals(t.matrixWorld)!==!0)return s.worldMatrix.copy(t.matrixWorld),!1;const a=s.material;for(const N in a){const C=a[N],E=n[N];if(C.equals!==void 0){if(C.equals(E)===!1)return C.copy(E),!1}else if(E.isTexture===!0){if(C.id!==E.id||C.version!==E.version)return C.id=E.id,C.version=E.version,!1}else if(C!==E)return a[N]=E,!1}if(a.transmission>0){const{width:N,height:C}=e.context;if(s.bufferWidth!==N||s.bufferHeight!==C)return s.bufferWidth=N,s.bufferHeight=C,!1}const l=s.geometry,u=r.attributes,h=l.attributes,m=Object.keys(h),v=Object.keys(u);if(m.length!==v.length)return s.geometry.attributes=this.getAttributesData(u),!1;for(const N of m){const C=h[N],E=u[N];if(E===void 0)return delete h[N],!1;if(C.version!==E.version)return C.version=E.version,!1}const x=r.index,S=l.indexVersion,w=x?x.version:null;if(S!==w)return l.indexVersion=w,!1;if(l.drawRange.start!==r.drawRange.start||l.drawRange.count!==r.drawRange.count)return l.drawRange.start=r.drawRange.start,l.drawRange.count=r.drawRange.count,!1;if(s.morphTargetInfluences){let N=!1;for(let C=0;C>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const OP=i=>bg(i),Ry=i=>bg(i),NM=(...i)=>bg(i);function IP(i,e=!1){const t=[];i.isNode===!0&&(t.push(i.id),i=i.getSelf());for(const{property:n,childNode:r}of $_(i))t.push(t,bg(n.slice(0,-4)),r.getCacheKey(e));return bg(t)}function*$_(i,e=!1){for(const t in i){if(t.startsWith("_")===!0)continue;const n=i[t];if(Array.isArray(n)===!0)for(let r=0;re.charCodeAt(0)).buffer}const kT={VERTEX:"vertex",FRAGMENT:"fragment"},Zn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},$Z={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},da={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},HP=["fragment","vertex"],zT=["setup","analyze","generate"],GT=[...HP,"compute"],yd=["x","y","z","w"];let XZ=0;class Un extends Xc{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Zn.NONE,this.updateBeforeType=Zn.NONE,this.updateAfterType=Zn.NONE,this.uuid=N0.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:XZ++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Zn.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Zn.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Zn.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of $_(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=NM(IP(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e){if(e.increaseUsage(this)===1){const n=e.getNodeProperties(this);for(const r of Object.values(n))r&&r.isNode===!0&&r.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){a.initialized=!0;const l=this.setup(e),u=l&&l.isNode===!0;for(const h of Object.values(a))h&&h.isNode===!0&&h.build(e);u&&l.build(e),a.outputNode=l}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const l=this.getNodeType(e),u=e.getDataFromNode(this);r=u.snippet,r===void 0?(r=this.generate(e)||"",u.snippet=r):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,l,t)}else r=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return $_(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(s)?[]:{}),n[r][s]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const s of e.inputNodes[n])r.push(t[s]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const s in e.inputNodes[n]){const a=e.inputNodes[n][s];r[s]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}if(r){const l=a(e.textures),u=a(e.images),h=a(e.nodes);l.length>0&&(s.textures=l),u.length>0&&(s.images=u),h.length>0&&(s.nodes=h)}return s}}class xd extends Un{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),n=this.indexNode.build(e,"uint");return`${t}[ ${n} ]`}}class WP extends Un{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),s=n.build(e,r);return e.format(s,r,t)}}class cs extends Un{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),l=e.getVarFromNode(this,null,r),u=e.getPropertyName(l);return e.addLineFlowCode(`${u} = ${a}`,this),s.snippet=a,s.propertyName=u,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class YZ extends cs{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=this.nodes,s=e.getComponentType(n),a=[];for(const u of r){let h=u.build(e);const m=e.getComponentType(u.getNodeType(e));m!==s&&(h=e.format(h,m,s)),a.push(h)}const l=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(l,n,t)}}const QZ=yd.join("");class qT extends Un{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(yd.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===QZ.slice(0,this.components.length)?s=e.format(u,a,t):s=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class KZ extends cs{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,s=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),l=e.getTypeFromLength(n.length,a),u=r.build(e,l),h=t.build(e,s),m=e.getTypeLength(s),v=[];for(let x=0;xi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),LR=i=>$P(i).split("").sort().join(""),XP={setup(i,e){const t=e.shift();return i(Hg(t),...e)},get(i,e,t){if(typeof e=="string"&&i[e]===void 0){if(i.isStackNode!==!0&&e==="assign")return(...n)=>(F0.assign(t,...n),t);if(ZA.has(e)){const n=ZA.get(e);return i.isStackNode?(...r)=>t.add(n(...r)):(...r)=>n(t,...r)}else{if(e==="self")return i;if(e.endsWith("Assign")&&ZA.has(e.slice(0,e.length-6))){const n=ZA.get(e.slice(0,e.length-6));return i.isStackNode?(...r)=>t.assign(r[0],n(...r)):(...r)=>t.assign(n(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=$P(e),Ct(new qT(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=LR(e.slice(3).toLowerCase()),n=>Ct(new KZ(i,e,n));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=LR(e.slice(4).toLowerCase()),()=>Ct(new ZZ(Ct(i),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),Ct(new qT(i,e));if(/^\d+$/.test(e)===!0)return Ct(new xd(t,new Vl(Number(e),"uint")))}}}return Reflect.get(i,e,t)},set(i,e,t,n){return typeof e=="string"&&i[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(i,e,t,n)}},W3=new WeakMap,UR=new WeakMap,JZ=function(i,e=null){const t=zh(i);if(t==="node"){let n=W3.get(i);return n===void 0&&(n=new Proxy(i,XP),W3.set(i,n),W3.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return Ct(VT(i,e));if(t==="shader")return Xe(i)}return i},eJ=function(i,e=null){for(const t in i)i[t]=Ct(i[t],e);return i},tJ=function(i,e=null){const t=i.length;for(let n=0;nCt(n!==null?Object.assign(s,n):s);return e===null?(...s)=>r(new i(...rd(s))):t!==null?(t=Ct(t),(...s)=>r(new i(e,...rd(s),t))):(...s)=>r(new i(e,...rd(s)))},iJ=function(i,...e){return Ct(new i(...rd(e)))};class rJ extends Un{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=UR.get(e.constructor);a===void 0&&(a=new WeakMap,UR.set(e.constructor,a));let l=a.get(t);l===void 0&&(l=Ct(e.buildFunctionNode(t)),a.set(t,l)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(l),s=Ct(l.call(n))}else{const a=t.jsFunc,l=n!==null?a(n,e):a(e);s=Ct(l)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class sJ extends Un{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Hg(e),Ct(new rJ(this,e))}setup(){return this.call()}}const aJ=[!1,!0],oJ=[0,1,2,3],lJ=[-1,-2],YP=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],DM=new Map;for(const i of aJ)DM.set(i,new Vl(i));const PM=new Map;for(const i of oJ)PM.set(i,new Vl(i,"uint"));const LM=new Map([...PM].map(i=>new Vl(i.value,"int")));for(const i of lJ)LM.set(i,new Vl(i,"int"));const Dy=new Map([...LM].map(i=>new Vl(i.value)));for(const i of YP)Dy.set(i,new Vl(i));for(const i of YP)Dy.set(-i,new Vl(-i));const Py={bool:DM,uint:PM,ints:LM,float:Dy},BR=new Map([...DM,...Dy]),VT=(i,e)=>BR.has(i)?BR.get(i):i.isNode===!0?i:new Vl(i,e),uJ=i=>{try{return i.getNodeType()}catch{return}},_s=function(i,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>typeof r!="object"))&&(t=[GP(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return Ct(e.get(t[0]));if(t.length===1){const r=VT(t[0],i);return uJ(r)===i?Ct(r):Ct(new WP(r,i))}const n=t.map(r=>VT(r));return Ct(new YZ(n,i))}},Sg=i=>typeof i=="object"&&i!==null?i.value:i,QP=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Om(i,e){return new Proxy(new sJ(i,e),XP)}const Ct=(i,e=null)=>JZ(i,e),Hg=(i,e=null)=>new eJ(i,e),rd=(i,e=null)=>new tJ(i,e),vt=(...i)=>new nJ(...i),Jt=(...i)=>new iJ(...i),Xe=(i,e)=>{const t=new Om(i,e),n=(...r)=>{let s;return Hg(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return n.shaderNode=t,n.setLayout=r=>(t.setLayout(r),n),n.once=()=>(t.once=!0,n),n},cJ=(...i)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),Xe(...i));gt("toGlobal",i=>(i.global=!0,i));const Tg=i=>{F0=i},UM=()=>F0,si=(...i)=>F0.If(...i);function KP(i){return F0&&F0.add(i),i}gt("append",KP);const ZP=new _s("color"),ve=new _s("float",Py.float),we=new _s("int",Py.ints),an=new _s("uint",Py.uint),Hc=new _s("bool",Py.bool),Ft=new _s("vec2"),ws=new _s("ivec2"),JP=new _s("uvec2"),eL=new _s("bvec2"),Le=new _s("vec3"),tL=new _s("ivec3"),Z0=new _s("uvec3"),BM=new _s("bvec3"),Mn=new _s("vec4"),nL=new _s("ivec4"),iL=new _s("uvec4"),rL=new _s("bvec4"),Ly=new _s("mat2"),_a=new _s("mat3"),sd=new _s("mat4"),hJ=(i="")=>Ct(new Vl(i,"string")),fJ=i=>Ct(new Vl(i,"ArrayBuffer"));gt("toColor",ZP);gt("toFloat",ve);gt("toInt",we);gt("toUint",an);gt("toBool",Hc);gt("toVec2",Ft);gt("toIVec2",ws);gt("toUVec2",JP);gt("toBVec2",eL);gt("toVec3",Le);gt("toIVec3",tL);gt("toUVec3",Z0);gt("toBVec3",BM);gt("toVec4",Mn);gt("toIVec4",nL);gt("toUVec4",iL);gt("toBVec4",rL);gt("toMat2",Ly);gt("toMat3",_a);gt("toMat4",sd);const sL=vt(xd),aL=(i,e)=>Ct(new WP(Ct(i),e)),dJ=(i,e)=>Ct(new qT(Ct(i),e));gt("element",sL);gt("convert",aL);class oL extends Un{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const lL=i=>new oL(i),OM=(i,e=0)=>new oL(i,!0,e),uL=OM("frame"),In=OM("render"),IM=lL("object");class Wg extends RM{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=IM}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(r=>{const s=e(r,n);s!==void 0&&(this.value=s)},t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),l=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(l);return e.context.label!==void 0&&delete e.context.label,e.format(u,n,t)}}const En=(i,e)=>{const t=QP(e||i),n=i&&i.isNode===!0?i.node&&i.node.value||i.value:i;return Ct(new Wg(n,t))};class Vi extends Un{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const cL=(i,e)=>Ct(new Vi(i,e)),wg=(i,e)=>Ct(new Vi(i,e,!0)),Oi=Jt(Vi,"vec4","DiffuseColor"),jT=Jt(Vi,"vec3","EmissiveColor"),au=Jt(Vi,"float","Roughness"),Mg=Jt(Vi,"float","Metalness"),X_=Jt(Vi,"float","Clearcoat"),Eg=Jt(Vi,"float","ClearcoatRoughness"),Kf=Jt(Vi,"vec3","Sheen"),Uy=Jt(Vi,"float","SheenRoughness"),By=Jt(Vi,"float","Iridescence"),FM=Jt(Vi,"float","IridescenceIOR"),kM=Jt(Vi,"float","IridescenceThickness"),Y_=Jt(Vi,"float","AlphaT"),Bh=Jt(Vi,"float","Anisotropy"),Im=Jt(Vi,"vec3","AnisotropyT"),ad=Jt(Vi,"vec3","AnisotropyB"),Ha=Jt(Vi,"color","SpecularColor"),Cg=Jt(Vi,"float","SpecularF90"),Q_=Jt(Vi,"float","Shininess"),Ng=Jt(Vi,"vec4","Output"),Qv=Jt(Vi,"float","dashSize"),HT=Jt(Vi,"float","gapSize"),AJ=Jt(Vi,"float","pointWidth"),Fm=Jt(Vi,"float","IOR"),K_=Jt(Vi,"float","Transmission"),zM=Jt(Vi,"float","Thickness"),GM=Jt(Vi,"float","AttenuationDistance"),qM=Jt(Vi,"color","AttenuationColor"),VM=Jt(Vi,"float","Dispersion");class pJ extends cs{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return yd.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:r}=this,s=this.needsSplitAssign(e),a=n.getNodeType(e),l=n.context({assign:!0}).build(e),u=r.build(e,a),h=r.getNodeType(e),m=e.getDataFromNode(this);let v;if(m.initialized===!0)t!=="void"&&(v=l);else if(s){const x=e.getVarFromNode(this,null,a),S=e.getPropertyName(x);e.addLineFlowCode(`${S} = ${u}`,this);const w=n.node.context({assign:!0}).build(e);for(let N=0;N{const m=h.type,v=m==="pointer";let x;return v?x="&"+u.build(e):x=u.build(e,m),x};if(Array.isArray(s))for(let u=0;u(e=e.length>1||e[0]&&e[0].isNode===!0?rd(e):Hg(e[0]),Ct(new mJ(Ct(i),e)));gt("call",fL);class Ur extends cs{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let s=new Ur(e,t,n);for(let a=0;a>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="=="||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="<"||n===">"||n==="<="||n===">="){const u=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(l));return u>1?`bvec${u}`:"bool"}else return a==="float"&&e.isMatrix(l)?l:e.isMatrix(a)&&e.isVector(l)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(l)?e.getVectorFromMatrix(l):e.getTypeLength(l)>e.getTypeLength(a)?l:a}generate(e,t){const n=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let l=null,u=null;a!=="void"?(l=r.getNodeType(e),u=typeof s<"u"?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="?e.isVector(l)?u=l:l!==u&&(l=u="float"):n===">>"||n==="<<"?(l=a,u=e.changeComponentType(u,"uint")):e.isMatrix(l)&&e.isVector(u)?u=e.getVectorFromMatrix(l):e.isVector(l)&&e.isMatrix(u)?l=e.getVectorFromMatrix(u):l=u=a):l=u=a;const h=r.build(e,l),m=typeof s<"u"?s.build(e,u):null,v=e.getTypeLength(t),x=e.getFunctionOperator(n);if(t!=="void")return n==="<"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} < ${m} )`,a,t):n==="<="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} <= ${m} )`,a,t):n===">"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} > ${m} )`,a,t):n===">="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} >= ${m} )`,a,t):n==="!"||n==="~"?e.format(`(${n}${h})`,l,t):x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`( ${h} ${n} ${m} )`,a,t);if(l!=="void")return x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`${h} ${n} ${m}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const ls=vt(Ur,"+"),Ei=vt(Ur,"-"),Jn=vt(Ur,"*"),Gl=vt(Ur,"/"),jM=vt(Ur,"%"),dL=vt(Ur,"=="),AL=vt(Ur,"!="),pL=vt(Ur,"<"),HM=vt(Ur,">"),mL=vt(Ur,"<="),gL=vt(Ur,">="),vL=vt(Ur,"&&"),_L=vt(Ur,"||"),yL=vt(Ur,"!"),xL=vt(Ur,"^^"),bL=vt(Ur,"&"),SL=vt(Ur,"~"),TL=vt(Ur,"|"),wL=vt(Ur,"^"),ML=vt(Ur,"<<"),EL=vt(Ur,">>");gt("add",ls);gt("sub",Ei);gt("mul",Jn);gt("div",Gl);gt("modInt",jM);gt("equal",dL);gt("notEqual",AL);gt("lessThan",pL);gt("greaterThan",HM);gt("lessThanEqual",mL);gt("greaterThanEqual",gL);gt("and",vL);gt("or",_L);gt("not",yL);gt("xor",xL);gt("bitAnd",bL);gt("bitNot",SL);gt("bitOr",TL);gt("bitXor",wL);gt("shiftLeft",ML);gt("shiftRight",EL);const CL=(...i)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),jM(...i));gt("remainder",CL);class $e extends cs{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),l=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>l?t:a>l?n:l>s?r:t}getNodeType(e){const t=this.method;return t===$e.LENGTH||t===$e.DISTANCE||t===$e.DOT?"float":t===$e.CROSS?"vec3":t===$e.ALL?"bool":t===$e.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===$e.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){let n=this.method;const r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,l=this.bNode,u=this.cNode,h=e.renderer.coordinateSystem;if(n===$e.TRANSFORM_DIRECTION){let m=a,v=l;e.isMatrix(m.getNodeType(e))?v=Mn(Le(v),0):m=Mn(Le(m),0);const x=Jn(m,v).xyz;return Wc(x).build(e,t)}else{if(n===$e.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(n===$e.ONE_MINUS)return Ei(1,a).build(e,t);if(n===$e.RECIPROCAL)return Gl(1,a).build(e,t);if(n===$e.DIFFERENCE)return dr(Ei(a,l)).build(e,t);{const m=[];return n===$e.CROSS||n===$e.MOD?m.push(a.build(e,r),l.build(e,r)):h===Qa&&n===$e.STEP?m.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),l.build(e,s)):h===Qa&&(n===$e.MIN||n===$e.MAX)||n===$e.MOD?m.push(a.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):n===$e.REFRACT?m.push(a.build(e,s),l.build(e,s),u.build(e,"float")):n===$e.MIX?m.push(a.build(e,s),l.build(e,s),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":s)):(h===Su&&n===$e.ATAN&&l!==null&&(n="atan2"),m.push(a.build(e,s)),l!==null&&m.push(l.build(e,s)),u!==null&&m.push(u.build(e,s))),e.format(`${e.getMethod(n,r)}( ${m.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}$e.ALL="all";$e.ANY="any";$e.RADIANS="radians";$e.DEGREES="degrees";$e.EXP="exp";$e.EXP2="exp2";$e.LOG="log";$e.LOG2="log2";$e.SQRT="sqrt";$e.INVERSE_SQRT="inversesqrt";$e.FLOOR="floor";$e.CEIL="ceil";$e.NORMALIZE="normalize";$e.FRACT="fract";$e.SIN="sin";$e.COS="cos";$e.TAN="tan";$e.ASIN="asin";$e.ACOS="acos";$e.ATAN="atan";$e.ABS="abs";$e.SIGN="sign";$e.LENGTH="length";$e.NEGATE="negate";$e.ONE_MINUS="oneMinus";$e.DFDX="dFdx";$e.DFDY="dFdy";$e.ROUND="round";$e.RECIPROCAL="reciprocal";$e.TRUNC="trunc";$e.FWIDTH="fwidth";$e.TRANSPOSE="transpose";$e.BITCAST="bitcast";$e.EQUALS="equals";$e.MIN="min";$e.MAX="max";$e.MOD="mod";$e.STEP="step";$e.REFLECT="reflect";$e.DISTANCE="distance";$e.DIFFERENCE="difference";$e.DOT="dot";$e.CROSS="cross";$e.POW="pow";$e.TRANSFORM_DIRECTION="transformDirection";$e.MIX="mix";$e.CLAMP="clamp";$e.REFRACT="refract";$e.SMOOTHSTEP="smoothstep";$e.FACEFORWARD="faceforward";const NL=ve(1e-6),gJ=ve(1e6),Z_=ve(Math.PI),vJ=ve(Math.PI*2),WM=vt($e,$e.ALL),RL=vt($e,$e.ANY),DL=vt($e,$e.RADIANS),PL=vt($e,$e.DEGREES),$M=vt($e,$e.EXP),k0=vt($e,$e.EXP2),Oy=vt($e,$e.LOG),vu=vt($e,$e.LOG2),Ou=vt($e,$e.SQRT),XM=vt($e,$e.INVERSE_SQRT),_u=vt($e,$e.FLOOR),Iy=vt($e,$e.CEIL),Wc=vt($e,$e.NORMALIZE),Zc=vt($e,$e.FRACT),Uo=vt($e,$e.SIN),Cc=vt($e,$e.COS),LL=vt($e,$e.TAN),UL=vt($e,$e.ASIN),BL=vt($e,$e.ACOS),YM=vt($e,$e.ATAN),dr=vt($e,$e.ABS),Rg=vt($e,$e.SIGN),Ic=vt($e,$e.LENGTH),OL=vt($e,$e.NEGATE),IL=vt($e,$e.ONE_MINUS),QM=vt($e,$e.DFDX),KM=vt($e,$e.DFDY),FL=vt($e,$e.ROUND),kL=vt($e,$e.RECIPROCAL),ZM=vt($e,$e.TRUNC),zL=vt($e,$e.FWIDTH),GL=vt($e,$e.TRANSPOSE),_J=vt($e,$e.BITCAST),qL=vt($e,$e.EQUALS),oo=vt($e,$e.MIN),Jr=vt($e,$e.MAX),JM=vt($e,$e.MOD),Fy=vt($e,$e.STEP),VL=vt($e,$e.REFLECT),jL=vt($e,$e.DISTANCE),HL=vt($e,$e.DIFFERENCE),ef=vt($e,$e.DOT),ky=vt($e,$e.CROSS),Fl=vt($e,$e.POW),eE=vt($e,$e.POW,2),WL=vt($e,$e.POW,3),$L=vt($e,$e.POW,4),XL=vt($e,$e.TRANSFORM_DIRECTION),YL=i=>Jn(Rg(i),Fl(dr(i),1/3)),QL=i=>ef(i,i),zi=vt($e,$e.MIX),Mu=(i,e=0,t=1)=>Ct(new $e($e.CLAMP,Ct(i),Ct(e),Ct(t))),KL=i=>Mu(i),tE=vt($e,$e.REFRACT),$c=vt($e,$e.SMOOTHSTEP),nE=vt($e,$e.FACEFORWARD),ZL=Xe(([i])=>{const n=43758.5453,r=ef(i.xy,Ft(12.9898,78.233)),s=JM(r,Z_);return Zc(Uo(s).mul(n))}),JL=(i,e,t)=>zi(e,t,i),e9=(i,e,t)=>$c(e,t,i),t9=(i,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),YM(i,e)),yJ=nE,xJ=XM;gt("all",WM);gt("any",RL);gt("equals",qL);gt("radians",DL);gt("degrees",PL);gt("exp",$M);gt("exp2",k0);gt("log",Oy);gt("log2",vu);gt("sqrt",Ou);gt("inverseSqrt",XM);gt("floor",_u);gt("ceil",Iy);gt("normalize",Wc);gt("fract",Zc);gt("sin",Uo);gt("cos",Cc);gt("tan",LL);gt("asin",UL);gt("acos",BL);gt("atan",YM);gt("abs",dr);gt("sign",Rg);gt("length",Ic);gt("lengthSq",QL);gt("negate",OL);gt("oneMinus",IL);gt("dFdx",QM);gt("dFdy",KM);gt("round",FL);gt("reciprocal",kL);gt("trunc",ZM);gt("fwidth",zL);gt("atan2",t9);gt("min",oo);gt("max",Jr);gt("mod",JM);gt("step",Fy);gt("reflect",VL);gt("distance",jL);gt("dot",ef);gt("cross",ky);gt("pow",Fl);gt("pow2",eE);gt("pow3",WL);gt("pow4",$L);gt("transformDirection",XL);gt("mix",JL);gt("clamp",Mu);gt("refract",tE);gt("smoothstep",e9);gt("faceForward",nE);gt("difference",HL);gt("saturate",KL);gt("cbrt",YL);gt("transpose",GL);gt("rand",ZL);class bJ extends Un{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:l}=e.getNodeProperties(this),u=t!=="void",h=u?cL(n).build(e):"";r.nodeProperty=h;const m=s.build(e,"bool");e.addFlowCode(` -${e.tab}if ( ${m} ) { - -`).addFlowTab();let v=a.build(e,n);if(v&&(u?v=h+" = "+v+";":v="return "+v+";"),e.removeFlowTab().addFlowCode(e.tab+" "+v+` - -`+e.tab+"}"),l!==null){e.addFlowCode(` else { - -`).addFlowTab();let x=l.build(e,n);x&&(u?x=h+" = "+x+";":x="return "+x+";"),e.removeFlowTab().addFlowCode(e.tab+" "+x+` - -`+e.tab+`} - -`)}else e.addFlowCode(` - -`);return e.format(h,n,t)}}const Ys=vt(bJ);gt("select",Ys);const n9=(...i)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),Ys(...i));gt("cond",n9);class i9 extends Un{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(n),r}}const zy=vt(i9),r9=(i,e)=>zy(i,{label:e});gt("context",zy);gt("label",r9);class Kv extends Un{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const s9=vt(Kv);gt("toVar",(...i)=>s9(...i).append());const a9=i=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),s9(i));gt("temp",a9);class SJ extends Un{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,s),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e),r=e.shaderStage==="fragment"&&t.reassignPosition===!0&&e.context.needsPositionReassign;if(t.propertyName===void 0||r){const s=this.getNodeType(e),a=e.getPropertyName(n,kT.VERTEX);e.flowNodeFromShaderStage(kT.VERTEX,this.node,s,a),t.propertyName=a,r?t.reassignPosition=!1:t.reassignPosition===void 0&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(n)}}const co=vt(SJ),o9=i=>co(i);gt("varying",co);gt("vertexStage",o9);const l9=Xe(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return zi(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),u9=Xe(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return zi(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),$g="WorkingColorSpace",iE="OutputColorSpace";class Xg extends cs{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===$g?hi.workingColorSpace:t===iE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return hi.enabled===!1||n===r||!n||!r||(hi.getTransfer(n)===Hi&&(s=Mn(l9(s.rgb),s.a)),hi.getPrimaries(n)!==hi.getPrimaries(r)&&(s=Mn(_a(hi._getMatrix(new Qn,n,r)).mul(s.rgb),s.a)),hi.getTransfer(r)===Hi&&(s=Mn(u9(s.rgb),s.a))),s}}const c9=i=>Ct(new Xg(Ct(i),$g,iE)),h9=i=>Ct(new Xg(Ct(i),iE,$g)),f9=(i,e)=>Ct(new Xg(Ct(i),$g,e)),rE=(i,e)=>Ct(new Xg(Ct(i),e,$g)),TJ=(i,e,t)=>Ct(new Xg(Ct(i),e,t));gt("toOutputColorSpace",c9);gt("toWorkingColorSpace",h9);gt("workingToColorSpace",f9);gt("colorSpaceToWorking",rE);let wJ=class extends xd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class d9 extends Un{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=Zn.OBJECT}setGroup(e){return this.group=e,this}element(e){return Ct(new wJ(this,Ct(e)))}setNodeType(e){const t=En(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rCt(new d9(i,e,t));class EJ extends d9{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(In)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const A9=(i,e,t=null)=>Ct(new EJ(i,e,t));class CJ extends cs{static get type(){return"ToneMappingNode"}constructor(e,t=m9,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return NM(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===ro)return t;let r=null;const s=e.renderer.library.getToneMappingFunction(n);return s!==null?r=Mn(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const p9=(i,e,t)=>Ct(new CJ(i,Ct(e),Ct(t))),m9=A9("toneMappingExposure","float");gt("toneMapping",(i,e,t)=>p9(e,t,i));class NJ extends RM{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=o_,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,l=n.isInterleavedBuffer===!0?n:new Zw(n,s),u=new cu(l,r,a);l.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=co(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Yg=(i,e=null,t=0,n=0)=>Ct(new NJ(i,e,t,n)),g9=(i,e=null,t=0,n=0)=>Yg(i,e,t,n).setUsage(HA),J_=(i,e=null,t=0,n=0)=>Yg(i,e,t,n).setInstanced(!0),WT=(i,e=null,t=0,n=0)=>g9(i,e,t,n).setInstanced(!0);gt("toAttribute",i=>Yg(i.value));class RJ extends Un{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Zn.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let r=1;rCt(new RJ(Ct(i),e,t));gt("compute",v9);class DJ extends Un{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(n),s}}const km=(i,e)=>Ct(new DJ(Ct(i),e));gt("cache",km);class PJ extends Un{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const _9=vt(PJ);gt("bypass",_9);class y9 extends Un{static get type(){return"RemapNode"}constructor(e,t,n,r=ve(0),s=ve(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:s,doClamp:a}=this;let l=e.sub(t).div(n.sub(t));return a===!0&&(l=l.clamp()),l.mul(s.sub(r)).add(r)}}const x9=vt(y9,null,null,{doClamp:!1}),b9=vt(y9);gt("remap",x9);gt("remapClamp",b9);class Zv extends Un{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,n,t)}}const Qh=vt(Zv),S9=i=>(i?Ys(i,Qh("discard")):Qh("discard")).append(),LJ=()=>Qh("return").append();gt("discard",S9);class UJ extends cs{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||ro,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Oo;return n!==ro&&(t=t.toneMapping(n)),r!==Oo&&r!==hi.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const T9=(i,e=null,t=null)=>Ct(new UJ(Ct(i),e,t));gt("renderOutput",T9);function BJ(i){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class w9 extends Un{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(s),l=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(l.name,a,n):co(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Eu=(i,e)=>Ct(new w9(i,e)),Br=(i=0)=>Eu("uv"+(i>0?i:""),"vec2");class OJ extends Un{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const jh=vt(OJ);class IJ extends Wg{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Zn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:s}=n;this.value=Math.log2(Math.max(r,s))}}}const M9=vt(IJ);class Cu extends Wg{static get type(){return"TextureNode"}constructor(e,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Zn.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Ir?"uvec4":this.value.type===ks?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Br(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=En(this.value.matrix)),this._matrixUniform.mul(Le(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Zn.RENDER:Zn.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(we(jh(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this)),r||(r=this.getDefaultUV()),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,n,r,s,a,l,u){const h=this.value;let m;return r?m=e.generateTextureLevel(h,t,n,r,a):s?m=e.generateTextureBias(h,t,n,s,a):u?m=e.generateTextureGrad(h,t,n,u,a):l?m=e.generateTextureCompare(h,t,n,l,a):this.sampler===!1?m=e.generateTextureLoad(h,t,n,a):m=e.generateTexture(h,t,n,a),m}generate(e,t){const n=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let l=a.propertyName;if(l===void 0){const{uvNode:m,levelNode:v,biasNode:x,compareNode:S,depthNode:w,gradNode:N}=r,C=this.generateUV(e,m),E=v?v.build(e,"float"):null,O=x?x.build(e,"float"):null,U=w?w.build(e,"int"):null,I=S?S.build(e,"float"):null,j=N?[N[0].build(e,"vec2"),N[1].build(e,"vec2")]:null,z=e.getVarFromNode(this);l=e.getPropertyName(z);const G=this.generateSnippet(e,s,C,E,O,U,I,j);e.addLineFlowCode(`${l} = ${G}`,this),a.snippet=G,a.propertyName=l}let u=l;const h=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=rE(Qh(u,h),n.colorSpace).setup(e).build(e,h)),e.format(u,h,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}blur(e){const t=this.clone();return t.biasNode=Ct(e).mul(M9(t)),t.referenceNode=this.getSelf(),Ct(t)}level(e){const t=this.clone();return t.levelNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}size(e){return jh(this,e)}bias(e){const t=this.clone();return t.biasNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}compare(e){const t=this.clone();return t.compareNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}grad(e,t){const n=this.clone();return n.gradNode=[Ct(e),Ct(t)],n.referenceNode=this.getSelf(),Ct(n)}depth(e){const t=this.clone();return t.depthNode=Ct(e),t.referenceNode=this.getSelf(),Ct(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const gi=vt(Cu),Yr=(...i)=>gi(...i).setSampler(!1),FJ=i=>(i.isNode===!0?i:gi(i)).convert("sampler"),Ih=En("float").label("cameraNear").setGroup(In).onRenderUpdate(({camera:i})=>i.near),Fh=En("float").label("cameraFar").setGroup(In).onRenderUpdate(({camera:i})=>i.far),bd=En("mat4").label("cameraProjectionMatrix").setGroup(In).onRenderUpdate(({camera:i})=>i.projectionMatrix),kJ=En("mat4").label("cameraProjectionMatrixInverse").setGroup(In).onRenderUpdate(({camera:i})=>i.projectionMatrixInverse),ho=En("mat4").label("cameraViewMatrix").setGroup(In).onRenderUpdate(({camera:i})=>i.matrixWorldInverse),zJ=En("mat4").label("cameraWorldMatrix").setGroup(In).onRenderUpdate(({camera:i})=>i.matrixWorld),GJ=En("mat3").label("cameraNormalMatrix").setGroup(In).onRenderUpdate(({camera:i})=>i.normalMatrix),E9=En(new de).label("cameraPosition").setGroup(In).onRenderUpdate(({camera:i},e)=>e.value.setFromMatrixPosition(i.matrixWorld));class Bi extends Un{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Zn.OBJECT,this._uniformNode=new Wg(null)}getNodeType(){const e=this.scope;if(e===Bi.WORLD_MATRIX)return"mat4";if(e===Bi.POSITION||e===Bi.VIEW_POSITION||e===Bi.DIRECTION||e===Bi.SCALE)return"vec3"}update(e){const t=this.object3d,n=this._uniformNode,r=this.scope;if(r===Bi.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===Bi.POSITION)n.value=n.value||new de,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===Bi.SCALE)n.value=n.value||new de,n.value.setFromMatrixScale(t.matrixWorld);else if(r===Bi.DIRECTION)n.value=n.value||new de,t.getWorldDirection(n.value);else if(r===Bi.VIEW_POSITION){const s=e.camera;n.value=n.value||new de,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===Bi.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===Bi.POSITION||t===Bi.VIEW_POSITION||t===Bi.DIRECTION||t===Bi.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Bi.WORLD_MATRIX="worldMatrix";Bi.POSITION="position";Bi.SCALE="scale";Bi.VIEW_POSITION="viewPosition";Bi.DIRECTION="direction";const qJ=vt(Bi,Bi.DIRECTION),VJ=vt(Bi,Bi.WORLD_MATRIX),C9=vt(Bi,Bi.POSITION),jJ=vt(Bi,Bi.SCALE),HJ=vt(Bi,Bi.VIEW_POSITION);class Nu extends Bi{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const WJ=Jt(Nu,Nu.DIRECTION),nl=Jt(Nu,Nu.WORLD_MATRIX),$J=Jt(Nu,Nu.POSITION),XJ=Jt(Nu,Nu.SCALE),YJ=Jt(Nu,Nu.VIEW_POSITION),N9=En(new Qn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),QJ=En(new Xn).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),J0=Xe(i=>i.renderer.nodes.modelViewMatrix||R9).once()().toVar("modelViewMatrix"),R9=ho.mul(nl),KJ=Xe(i=>(i.context.isHighPrecisionModelViewMatrix=!0,En("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),ZJ=Xe(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return En("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Gy=Eu("position","vec3"),Zr=Gy.varying("positionLocal"),ey=Gy.varying("positionPrevious"),Fc=nl.mul(Zr).xyz.varying("v_positionWorld").context({needsPositionReassign:!0}),sE=Zr.transformDirection(nl).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection").context({needsPositionReassign:!0}),as=Xe(i=>i.context.setupPositionView(),"vec3").once()().varying("v_positionView").context({needsPositionReassign:!0}),yr=as.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class JJ extends Un{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===Qa&&n.side===gr?"false":e.getFrontFacing()}}const D9=Jt(JJ),Qg=ve(D9).mul(2).sub(1),qy=Eu("normal","vec3"),lo=Xe(i=>i.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),Le(0,1,0)):qy,"vec3").once()().toVar("normalLocal"),P9=as.dFdx().cross(as.dFdy()).normalize().toVar("normalFlat"),ll=Xe(i=>{let e;return i.material.flatShading===!0?e=P9:e=co(aE(lo),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Vy=co(ll.transformDirection(ho),"v_normalWorld").normalize().toVar("normalWorld"),Kr=Xe(i=>i.context.setupNormal(),"vec3").once()().mul(Qg).toVar("transformedNormalView"),jy=Kr.transformDirection(ho).toVar("transformedNormalWorld"),JA=Xe(i=>i.context.setupClearcoatNormal(),"vec3").once()().mul(Qg).toVar("transformedClearcoatNormalView"),L9=Xe(([i,e=nl])=>{const t=_a(e),n=i.div(Le(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),aE=Xe(([i],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const n=N9.mul(i);return ho.transformDirection(n)}),U9=En(0).onReference(({material:i})=>i).onRenderUpdate(({material:i})=>i.refractionRatio),B9=yr.negate().reflect(Kr),O9=yr.negate().refract(Kr,U9),I9=B9.transformDirection(ho).toVar("reflectVector"),F9=O9.transformDirection(ho).toVar("reflectVector");class eee extends Cu{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===sl?I9:e.mapping===al?F9:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Le(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem===Su||!n.isRenderTargetTexture?Le(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const z0=vt(eee);class oE extends Wg{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const Kg=(i,e,t)=>Ct(new oE(i,e,t));class tee extends xd{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class k9 extends oE{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?zh(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Zn.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;rCt(new k9(i,e)),nee=(i,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),Ct(new k9(i,e)));class iee extends xd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class Hy extends Un{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Zn.OBJECT}element(e){return Ct(new iee(this,Ct(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=Kg(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Dc(null,e):e==="texture"?t=gi(null):e==="cubeTexture"?t=z0(null):t=En(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rCt(new Hy(i,e,t)),$T=(i,e,t,n)=>Ct(new Hy(i,e,n,t));class ree extends Hy{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const Pc=(i,e,t=null)=>Ct(new ree(i,e,t)),Wy=Xe(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),Eu("tangent","vec4")))(),Zg=Wy.xyz.toVar("tangentLocal"),Jg=J0.mul(Mn(Zg,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),z9=Jg.transformDirection(ho).varying("v_tangentWorld").normalize().toVar("tangentWorld"),lE=Jg.toVar("transformedTangentView"),see=lE.transformDirection(ho).normalize().toVar("transformedTangentWorld"),e1=i=>i.mul(Wy.w).xyz,aee=co(e1(qy.cross(Wy)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),oee=co(e1(lo.cross(Zg)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),G9=co(e1(ll.cross(Jg)),"v_bitangentView").normalize().toVar("bitangentView"),lee=co(e1(Vy.cross(z9)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),q9=e1(Kr.cross(lE)).normalize().toVar("transformedBitangentView"),uee=q9.transformDirection(ho).normalize().toVar("transformedBitangentWorld"),Zf=_a(Jg,G9,ll),V9=yr.mul(Zf),cee=(i,e)=>i.sub(V9.mul(e)),j9=(()=>{let i=ad.cross(yr);return i=i.cross(ad).normalize(),i=zi(i,Kr,Bh.mul(au.oneMinus()).oneMinus().pow2().pow2()).normalize(),i})(),hee=Xe(i=>{const{eye_pos:e,surf_norm:t,mapN:n,uv:r}=i,s=e.dFdx(),a=e.dFdy(),l=r.dFdx(),u=r.dFdy(),h=t,m=a.cross(h),v=h.cross(s),x=m.mul(l.x).add(v.mul(u.x)),S=m.mul(l.y).add(v.mul(u.y)),w=x.dot(x).max(S.dot(S)),N=Qg.mul(w.inverseSqrt());return ls(x.mul(n.x,N),S.mul(n.y,N),h.mul(n.z)).normalize()});class fee extends cs{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=kc}setup(e){const{normalMapType:t,scaleNode:n}=this;let r=this.node.mul(2).sub(1);n!==null&&(r=Le(r.xy.mul(n),r.z));let s=null;return t===z7?s=aE(r):t===kc&&(e.hasGeometryAttribute("tangent")===!0?s=Zf.mul(r).normalize():s=hee({eye_pos:as,surf_norm:ll,mapN:r,uv:Br()})),s}}const XT=vt(fee),dee=Xe(({textureNode:i,bumpScale:e})=>{const t=r=>i.cache().context({getUV:s=>r(s.uvNode||Br()),forceUVContext:!0}),n=ve(t(r=>r));return Ft(ve(t(r=>r.add(r.dFdx()))).sub(n),ve(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),Aee=Xe(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,l=s.cross(a),u=a.cross(r),h=r.dot(l).mul(Qg),m=h.sign().mul(n.x.mul(l).add(n.y.mul(u)));return h.abs().mul(t).sub(m).normalize()});class pee extends cs{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=dee({textureNode:this.textureNode,bumpScale:e});return Aee({surf_pos:as,surf_norm:ll,dHdxy:t})}}const H9=vt(pee),OR=new Map;class ft extends Un{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=OR.get(e);return n===void 0&&(n=Pc(e,t),OR.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let r=null;if(n===ft.COLOR){const s=t.color!==void 0?this.getColor(n):Le();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(n===ft.OPACITY){const s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(n===ft.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=ve(1);else if(n===ft.SPECULAR_INTENSITY){const s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s}else if(n===ft.SPECULAR_COLOR){const s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(n).rgb):r=s}else if(n===ft.ROUGHNESS){const s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).g):r=s}else if(n===ft.METALNESS){const s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(n).b):r=s}else if(n===ft.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(n)):r=a}else if(n===ft.NORMAL)t.normalMap?(r=XT(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=H9(this.getTexture("bump").r,this.getFloat("bumpScale")):r=ll;else if(n===ft.CLEARCOAT){const s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===ft.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===ft.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=XT(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=ll;else if(n===ft.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(n===ft.SHEEN_ROUGHNESS){const s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s,r=r.clamp(.07,1)}else if(n===ft.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(n);r=Ly(qA.x,qA.y,qA.y.negate(),qA.x).mul(s.rg.mul(2).sub(Ft(1)).normalize().mul(s.b))}else r=qA;else if(n===ft.IRIDESCENCE_THICKNESS){const s=$i("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=$i("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(n).g).add(a)}else r=s}else if(n===ft.TRANSMISSION){const s=this.getFloat(n);t.transmissionMap?r=s.mul(this.getTexture(n).r):r=s}else if(n===ft.THICKNESS){const s=this.getFloat(n);t.thicknessMap?r=s.mul(this.getTexture(n).g):r=s}else if(n===ft.IOR)r=this.getFloat(n);else if(n===ft.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===ft.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(n,s)}return r}}ft.ALPHA_TEST="alphaTest";ft.COLOR="color";ft.OPACITY="opacity";ft.SHININESS="shininess";ft.SPECULAR="specular";ft.SPECULAR_STRENGTH="specularStrength";ft.SPECULAR_INTENSITY="specularIntensity";ft.SPECULAR_COLOR="specularColor";ft.REFLECTIVITY="reflectivity";ft.ROUGHNESS="roughness";ft.METALNESS="metalness";ft.NORMAL="normal";ft.CLEARCOAT="clearcoat";ft.CLEARCOAT_ROUGHNESS="clearcoatRoughness";ft.CLEARCOAT_NORMAL="clearcoatNormal";ft.EMISSIVE="emissive";ft.ROTATION="rotation";ft.SHEEN="sheen";ft.SHEEN_ROUGHNESS="sheenRoughness";ft.ANISOTROPY="anisotropy";ft.IRIDESCENCE="iridescence";ft.IRIDESCENCE_IOR="iridescenceIOR";ft.IRIDESCENCE_THICKNESS="iridescenceThickness";ft.IOR="ior";ft.TRANSMISSION="transmission";ft.THICKNESS="thickness";ft.ATTENUATION_DISTANCE="attenuationDistance";ft.ATTENUATION_COLOR="attenuationColor";ft.LINE_SCALE="scale";ft.LINE_DASH_SIZE="dashSize";ft.LINE_GAP_SIZE="gapSize";ft.LINE_WIDTH="linewidth";ft.LINE_DASH_OFFSET="dashOffset";ft.POINT_WIDTH="pointWidth";ft.DISPERSION="dispersion";ft.LIGHT_MAP="light";ft.AO="ao";const W9=Jt(ft,ft.ALPHA_TEST),$9=Jt(ft,ft.COLOR),X9=Jt(ft,ft.SHININESS),Y9=Jt(ft,ft.EMISSIVE),uE=Jt(ft,ft.OPACITY),Q9=Jt(ft,ft.SPECULAR),YT=Jt(ft,ft.SPECULAR_INTENSITY),K9=Jt(ft,ft.SPECULAR_COLOR),zm=Jt(ft,ft.SPECULAR_STRENGTH),Jv=Jt(ft,ft.REFLECTIVITY),Z9=Jt(ft,ft.ROUGHNESS),J9=Jt(ft,ft.METALNESS),eU=Jt(ft,ft.NORMAL).context({getUV:null}),tU=Jt(ft,ft.CLEARCOAT),nU=Jt(ft,ft.CLEARCOAT_ROUGHNESS),iU=Jt(ft,ft.CLEARCOAT_NORMAL).context({getUV:null}),rU=Jt(ft,ft.ROTATION),sU=Jt(ft,ft.SHEEN),aU=Jt(ft,ft.SHEEN_ROUGHNESS),oU=Jt(ft,ft.ANISOTROPY),lU=Jt(ft,ft.IRIDESCENCE),uU=Jt(ft,ft.IRIDESCENCE_IOR),cU=Jt(ft,ft.IRIDESCENCE_THICKNESS),hU=Jt(ft,ft.TRANSMISSION),fU=Jt(ft,ft.THICKNESS),dU=Jt(ft,ft.IOR),AU=Jt(ft,ft.ATTENUATION_DISTANCE),pU=Jt(ft,ft.ATTENUATION_COLOR),mU=Jt(ft,ft.LINE_SCALE),gU=Jt(ft,ft.LINE_DASH_SIZE),vU=Jt(ft,ft.LINE_GAP_SIZE),mee=Jt(ft,ft.LINE_WIDTH),_U=Jt(ft,ft.LINE_DASH_OFFSET),gee=Jt(ft,ft.POINT_WIDTH),yU=Jt(ft,ft.DISPERSION),cE=Jt(ft,ft.LIGHT_MAP),xU=Jt(ft,ft.AO),qA=En(new Et).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),hE=Xe(i=>i.context.setupModelViewProjection(),"vec4").once()().varying("v_modelViewProjection");class xr extends Un{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===xr.VERTEX)r=e.getVertexIndex();else if(n===xr.INSTANCE)r=e.getInstanceIndex();else if(n===xr.DRAW)r=e.getDrawIndex();else if(n===xr.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===xr.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===xr.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=co(this).build(e,t),s}}xr.VERTEX="vertex";xr.INSTANCE="instance";xr.SUBGROUP="subgroup";xr.INVOCATION_LOCAL="invocationLocal";xr.INVOCATION_SUBGROUP="invocationSubgroup";xr.DRAW="draw";const bU=Jt(xr,xr.VERTEX),t1=Jt(xr,xr.INSTANCE),vee=Jt(xr,xr.SUBGROUP),_ee=Jt(xr,xr.INVOCATION_SUBGROUP),yee=Jt(xr,xr.INVOCATION_LOCAL),SU=Jt(xr,xr.DRAW);class TU extends Un{static get type(){return"InstanceNode"}constructor(e,t,n){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Zn.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:n,instanceColor:r}=this;let{instanceMatrixNode:s,instanceColorNode:a}=this;if(s===null){if(t<=1e3)s=Kg(n.array,"mat4",Math.max(t,1)).element(t1);else{const u=new h_(n.array,16,1);this.buffer=u;const h=n.usage===HA?WT:J_,m=[h(u,"vec4",16,0),h(u,"vec4",16,4),h(u,"vec4",16,8),h(u,"vec4",16,12)];s=sd(...m)}this.instanceMatrixNode=s}if(r&&a===null){const u=new kg(r.array,3),h=r.usage===HA?WT:J_;this.bufferColor=u,a=Le(h(u,"vec3",3,0)),this.instanceColorNode=a}const l=s.mul(Zr).xyz;if(Zr.assign(l),e.hasGeometryAttribute("normal")){const u=L9(lo,s);lo.assign(u)}this.instanceColorNode!==null&&wg("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==HA&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==HA&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const xee=vt(TU);class bee extends TU{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const wU=vt(bee);class See extends Un{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=t1:this.batchingIdNode=SU);const n=Xe(([w])=>{const N=jh(Yr(this.batchMesh._indirectTexture),0),C=we(w).modInt(we(N)),E=we(w).div(we(N));return Yr(this.batchMesh._indirectTexture,ws(C,E)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(we(this.batchingIdNode)),r=this.batchMesh._matricesTexture,s=jh(Yr(r),0),a=ve(n).mul(4).toInt().toVar(),l=a.modInt(s),u=a.div(we(s)),h=sd(Yr(r,ws(l,u)),Yr(r,ws(l.add(1),u)),Yr(r,ws(l.add(2),u)),Yr(r,ws(l.add(3),u))),m=this.batchMesh._colorsTexture;if(m!==null){const N=Xe(([C])=>{const E=jh(Yr(m),0).x,O=C,U=O.modInt(E),I=O.div(E);return Yr(m,ws(U,I)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);wg("vec3","vBatchColor").assign(N)}const v=_a(h);Zr.assign(h.mul(Zr));const x=lo.div(Le(v[0].dot(v[0]),v[1].dot(v[1]),v[2].dot(v[2]))),S=v.mul(x).xyz;lo.assign(S),e.hasGeometryAttribute("tangent")&&Zg.mulAssign(v)}}const MU=vt(See),IR=new WeakMap;class EU extends Un{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=Zn.OBJECT,this.skinIndexNode=Eu("skinIndex","uvec4"),this.skinWeightNode=Eu("skinWeight","vec4");let n,r,s;t?(n=$i("bindMatrix","mat4"),r=$i("bindMatrixInverse","mat4"),s=$T("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=En(e.bindMatrix,"mat4"),r=En(e.bindMatrixInverse,"mat4"),s=Kg(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=Zr){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w),v=s.mul(t),x=ls(l.mul(r.x).mul(v),u.mul(r.y).mul(v),h.mul(r.z).mul(v),m.mul(r.w).mul(v));return a.mul(x).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=lo){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w);let v=ls(r.x.mul(l),r.y.mul(u),r.z.mul(h),r.w.mul(m));return v=a.mul(v).mul(s),v.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=$T("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,ey)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||qP(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&ey.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(Zr.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();lo.assign(n),e.hasGeometryAttribute("tangent")&&Zg.assign(n)}}generate(e,t){if(t!=="void")return Zr.build(e,t)}update(e){const n=(this.useReference?e.object:this.skinnedMesh).skeleton;IR.get(n)!==e.frameId&&(IR.set(n,e.frameId),this.previousBoneMatricesNode!==null&&n.previousBoneMatrices.set(n.boneMatrices),n.update())}}const Tee=i=>Ct(new EU(i)),CU=i=>Ct(new EU(i,!0));class wee extends Un{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let s=0,a=this.params.length-1;sNumber(v)?w=">=":w="<"));const C={start:m,end:v},E=C.start,O=C.end;let U="",I="",j="";N||(S==="int"||S==="uint"?w.includes("<")?N="++":N="--":w.includes("<")?N="+= 1.":N="-= 1."),U+=e.getVar(S,x)+" = "+E,I+=x+" "+w+" "+O,j+=x+" "+N;const z=`for ( ${U}; ${I}; ${j} )`;e.addFlowCode((l===0?` -`:"")+e.tab+z+` { - -`).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(` -`+e.tab+s);for(let l=0,u=this.params.length-1;lCt(new wee(rd(i,"int"))).append(),Mee=()=>Qh("continue").append(),NU=()=>Qh("break").append(),Eee=(...i)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),Gi(...i)),$3=new WeakMap,Mo=new qn,FR=Xe(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const a=we(bU).mul(t).add(s),l=a.div(n),u=a.sub(l.mul(n));return Yr(i,ws(u,l)).depth(r).mul(e)});function Cee(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let a=$3.get(i);if(a===void 0||a.count!==s){let O=function(){C.dispose(),$3.delete(i),i.removeEventListener("dispose",O)};var l=O;a!==void 0&&a.texture.dispose();const u=i.morphAttributes.position||[],h=i.morphAttributes.normal||[],m=i.morphAttributes.color||[];let v=0;e===!0&&(v=1),t===!0&&(v=2),n===!0&&(v=3);let x=i.attributes.position.count*v,S=1;const w=4096;x>w&&(S=Math.ceil(x/w),x=w);const N=new Float32Array(x*S*4*s),C=new $w(N,x,S,s);C.type=ss,C.needsUpdate=!0;const E=v*4;for(let U=0;U{const x=ve(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?x.assign(Yr(this.mesh.morphTexture,ws(we(v).add(1),we(t1))).r):x.assign($i("morphTargetInfluences","float").element(v).toVar()),n===!0&&Zr.addAssign(FR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:we(0)})),r===!0&&lo.addAssign(FR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:we(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const RU=vt(Nee);class ep extends Un{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Ree extends ep{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Dee extends i9{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=Le().toVar("directDiffuse"),r=Le().toVar("directSpecular"),s=Le().toVar("indirectDiffuse"),a=Le().toVar("indirectSpecular"),l={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:Le().toVar("radiance"),irradiance:Le().toVar("irradiance"),iblIrradiance:Le().toVar("iblIrradiance"),ambientOcclusion:ve(1).toVar("ambientOcclusion"),reflectedLight:l,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const DU=vt(Dee);class Pee extends ep{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let om,lm;class ms extends Un{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ms.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Zn.NONE;return(this.scope===ms.SIZE||this.scope===ms.VIEWPORT)&&(e=Zn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ms.VIEWPORT?t!==null?lm.copy(t.viewport):(e.getViewport(lm),lm.multiplyScalar(e.getPixelRatio())):t!==null?(om.width=t.width,om.height=t.height):e.getDrawingBufferSize(om)}setup(){const e=this.scope;let t=null;return e===ms.SIZE?t=En(om||(om=new Et)):e===ms.VIEWPORT?t=En(lm||(lm=new qn)):t=Ft(n1.div(Dg)),t}generate(e){if(this.scope===ms.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(Dg).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}ms.COORDINATE="coordinate";ms.VIEWPORT="viewport";ms.SIZE="size";ms.UV="uv";const Ru=Jt(ms,ms.UV),Dg=Jt(ms,ms.SIZE),n1=Jt(ms,ms.COORDINATE),fE=Jt(ms,ms.VIEWPORT),PU=fE.zw,LU=n1.sub(fE.xy),Lee=LU.div(PU),Uee=Xe(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),Dg),"vec2").once()(),Bee=Xe(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),Ru),"vec2").once()(),Oee=Xe(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),Ru.flipY()),"vec2").once()(),um=new Et;class $y extends Cu{static get type(){return"ViewportTextureNode"}constructor(e=Ru,t=null,n=null){n===null&&(n=new Q7,n.minFilter=Ya),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Zn.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(um);const n=this.value;(n.image.width!==um.width||n.image.height!==um.height)&&(n.image.width=um.width,n.image.height=um.height,n.needsUpdate=!0);const r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Iee=vt($y),dE=vt($y,null,null,{generateMipmaps:!0});let X3=null;class Fee extends $y{static get type(){return"ViewportDepthTextureNode"}constructor(e=Ru,t=null){X3===null&&(X3=new Qc),super(e,t,X3)}}const AE=vt(Fee);class eo extends Un{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===eo.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===eo.DEPTH_BASE)n!==null&&(r=BU().assign(n));else if(t===eo.DEPTH)e.isPerspectiveCamera?r=UU(as.z,Ih,Fh):r=l0(as.z,Ih,Fh);else if(t===eo.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const s=pE(n,Ih,Fh);r=l0(s,Ih,Fh)}else r=n;else r=l0(as.z,Ih,Fh);return r}}eo.DEPTH_BASE="depthBase";eo.DEPTH="depth";eo.LINEAR_DEPTH="linearDepth";const l0=(i,e,t)=>i.add(e).div(e.sub(t)),kee=(i,e,t)=>e.sub(t).mul(i).sub(e),UU=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),pE=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),mE=(i,e,t)=>{e=e.max(1e-6).toVar();const n=vu(i.negate().div(e)),r=vu(t.div(e));return n.div(r)},zee=(i,e,t)=>{const n=i.mul(Oy(t.div(e)));return ve(Math.E).pow(n).mul(e).negate()},BU=vt(eo,eo.DEPTH_BASE),gE=Jt(eo,eo.DEPTH),ty=vt(eo,eo.LINEAR_DEPTH),Gee=ty(AE());gE.assign=i=>BU(i);class qee extends Un{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Vee=vt(qee);class rl extends Un{static get type(){return"ClippingNode"}constructor(e=rl.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===rl.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===rl.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return Xe(()=>{const n=ve().toVar("distanceToPlane"),r=ve().toVar("distanceToGradient"),s=ve(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=Dc(t);Gi(a,({i:h})=>{const m=u.element(h);n.assign(as.dot(m.xyz).negate().add(m.w)),r.assign(n.fwidth().div(2)),s.mulAssign($c(r.negate(),r,n))})}const l=e.length;if(l>0){const u=Dc(e),h=ve(1).toVar("intersectionClipOpacity");Gi(l,({i:m})=>{const v=u.element(m);n.assign(as.dot(v.xyz).negate().add(v.w)),r.assign(n.fwidth().div(2)),h.mulAssign($c(r.negate(),r,n).oneMinus())}),s.mulAssign(h.oneMinus())}Oi.a.mulAssign(s),Oi.a.equal(0).discard()})()}setupDefault(e,t){return Xe(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const s=Dc(t);Gi(n,({i:a})=>{const l=s.element(a);as.dot(l.xyz).greaterThan(l.w).discard()})}const r=e.length;if(r>0){const s=Dc(e),a=Hc(!0).toVar("clipped");Gi(r,({i:l})=>{const u=s.element(l);a.assign(as.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Xe(()=>{const r=Dc(e),s=Vee(t.getClipDistance());Gi(n,({i:a})=>{const l=r.element(a),u=as.dot(l.xyz).sub(l.w).negate();s.element(a).assign(u)})})()}}rl.ALPHA_TO_COVERAGE="alphaToCoverage";rl.DEFAULT="default";rl.HARDWARE="hardware";const jee=()=>Ct(new rl),Hee=()=>Ct(new rl(rl.ALPHA_TO_COVERAGE)),Wee=()=>Ct(new rl(rl.HARDWARE)),$ee=.05,kR=Xe(([i])=>Zc(Jn(1e4,Uo(Jn(17,i.x).add(Jn(.1,i.y)))).mul(ls(.1,dr(Uo(Jn(13,i.y).add(i.x))))))),zR=Xe(([i])=>kR(Ft(kR(i.xy),i.z))),Xee=Xe(([i])=>{const e=Jr(Ic(QM(i.xyz)),Ic(KM(i.xyz))),t=ve(1).div(ve($ee).mul(e)).toVar("pixScale"),n=Ft(k0(_u(vu(t))),k0(Iy(vu(t)))),r=Ft(zR(_u(n.x.mul(i.xyz))),zR(_u(n.y.mul(i.xyz)))),s=Zc(vu(t)),a=ls(Jn(s.oneMinus(),r.x),Jn(s,r.y)),l=oo(s,s.oneMinus()),u=Le(a.mul(a).div(Jn(2,l).mul(Ei(1,l))),a.sub(Jn(.5,l)).div(Ei(1,l)),Ei(1,Ei(1,a).mul(Ei(1,a)).div(Jn(2,l).mul(Ei(1,l))))),h=a.lessThan(l.oneMinus()).select(a.lessThan(l).select(u.x,u.y),u.z);return Mu(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class es extends ga{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+IP(this)}build(e){this.setup(e)}setupObserver(e){return new HZ(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const r=this.vertexNode||this.setupVertex(e);e.stack.outputNode=r,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let s;const a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);a!==null&&e.stack.add(a);const u=Mn(l,Oi.a).max(0);if(s=this.setupOutput(e,u),Ng.assign(s),this.outputNode!==null&&(s=this.outputNode),n!==null){const h=t.getMRT(),m=this.mrtNode;h!==null?(s=h,m!==null&&(s=h.merge(m))):m!==null&&(s=m)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=Mn(l)),s=this.setupOutput(e,l)}e.stack.outputNode=s,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=Hee():e.stack.add(jee())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Wee()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=mE(as.z,Ih,Fh):r=l0(as.z,Ih,Fh))}r!==null&&gE.assign(r).append()}setupPositionView(){return J0.mul(Zr).xyz}setupModelViewProjection(){return bd.mul(as)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),hE}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&RU(t).append(),t.isSkinnedMesh===!0&&CU(t).append(),this.displacementMap){const r=Pc("displacementMap","texture"),s=Pc("displacementScale","float"),a=Pc("displacementBias","float");Zr.addAssign(lo.normalize().mul(r.x.mul(s).add(a)))}return t.isBatchedMesh&&MU(t).append(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&wU(t).append(),this.positionNode!==null&&Zr.assign(this.positionNode.context({isPositionNodeInput:!0})),Zr}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?Mn(this.colorNode):$9;this.vertexColors===!0&&t.hasAttribute("color")&&(n=Mn(n.xyz.mul(Eu("color","vec3")),n.a)),e.instanceColor&&(n=wg("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=wg("vec3","vBatchColor").mul(n)),Oi.assign(n);const r=this.opacityNode?ve(this.opacityNode):uE;if(Oi.a.assign(Oi.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?ve(this.alphaTestNode):W9;Oi.a.lessThanEqual(s).discard()}this.alphaHash===!0&&Oi.a.lessThan(Xee(Zr)).discard(),this.transparent===!1&&this.blending===io&&this.alphaToCoverage===!1&&Oi.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Le(0):Oi.rgb}setupNormal(){return this.normalNode?Le(this.normalNode):eU}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Pc("envMap","cubeTexture"):Pc("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Pee(cE)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:xU;t.push(new Ree(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:s}=this,l=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(l&&l.getScope().hasLights){const h=this.setupLightingModel(e);u=DU(l,h,n,r)}else n!==null&&(u=Le(r!==null?zi(u,n,r):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(jT.assign(Le(s||Y9)),u=u.add(jT)),u}setupOutput(e,t){if(this.fog===!0){const n=e.fogNode;n&&(Ng.assign(t),t=Mn(n))}return t}setDefaultValues(e){for(const n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=ga.prototype.toJSON.call(this,e),r=$_(this);n.inputNodes={};for(const{property:a,childNode:l}of r)n.inputNodes[a]=l.toJSON(e).uuid;function s(a){const l=[];for(const u in a){const h=a[u];delete h.metadata,l.push(h)}return l}if(t){const a=s(e.textures),l=s(e.images),u=s(e.nodes);a.length>0&&(n.textures=a),l.length>0&&(n.images=l),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const Yee=new Q0;class Qee extends es{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Yee),this.setValues(e)}}const Kee=new kz;class Zee extends es{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Kee),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ve(this.offsetNode):_U,t=this.dashScaleNode?ve(this.dashScaleNode):mU,n=this.dashSizeNode?ve(this.dashSizeNode):gU,r=this.gapSizeNode?ve(this.gapSizeNode):vU;Qv.assign(n),HT.assign(r);const s=co(Eu("lineDistance").mul(t));(e?s.add(e):s).mod(Qv.add(HT)).greaterThan(Qv).discard()}}let Y3=null;class Jee extends $y{static get type(){return"ViewportSharedTextureNode"}constructor(e=Ru,t=null){Y3===null&&(Y3=new Q7),super(e,t,Y3)}updateReference(){return this}}const ete=vt(Jee),OU=i=>Ct(i).mul(.5).add(.5),tte=i=>Ct(i).mul(2).sub(1),nte=new Bz;class ite extends es{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(nte),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ve(this.opacityNode):uE;Oi.assign(Mn(OU(Kr),e))}}class rte extends cs{static get type(){return"EquirectUVNode"}constructor(e=sE){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Ft(t,n)}}const vE=vt(rte);class IU extends X7{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new Jh(5,5,5),a=vE(sE),l=new es;l.colorNode=gi(t,a,0),l.side=gr,l.blending=no;const u=new qi(s,l),h=new Kw;h.add(u),t.minFilter===Ya&&(t.minFilter=Ms);const m=new $7(1,10,this),v=e.getMRT();return e.setMRT(null),m.update(e,h),e.setMRT(v),t.minFilter=n,t.currentGenerateMipmaps=r,u.geometry.dispose(),u.material.dispose(),this}}const Gm=new WeakMap;class ste extends cs{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=z0();const t=new yy;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Zn.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:n[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===Wh||a===$h){if(Gm.has(s)){const l=Gm.get(s);GR(l,s.mapping),this._cubeTexture=l}else{const l=s.image;if(ate(l)){const u=new IU(l.height);u.fromEquirectangularTexture(t,s),GR(u.texture,s.mapping),this._cubeTexture=u.texture,Gm.set(s,u.texture),s.addEventListener("dispose",FU)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function ate(i){return i==null?!1:i.height>0}function FU(i){const e=i.target;e.removeEventListener("dispose",FU);const t=Gm.get(e);t!==void 0&&(Gm.delete(e),t.dispose())}function GR(i,e){e===Wh?i.mapping=sl:e===$h&&(i.mapping=al)}const kU=vt(ste);class _E extends ep{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=kU(this.envNode)}}class ote extends ep{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ve(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Xy{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class zU extends Xy{constructor(){super()}indirect(e,t,n){const r=e.ambientOcclusion,s=e.reflectedLight,a=n.context.irradianceLightMap;s.indirectDiffuse.assign(Mn(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(Mn(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Oi.rgb)}finish(e,t,n){const r=n.material,s=e.outgoingLight,a=n.context.environment;if(a)switch(r.combine){case Bg:s.rgb.assign(zi(s.rgb,s.rgb.mul(a.rgb),zm.mul(Jv)));break;case P7:s.rgb.assign(zi(s.rgb,a.rgb,zm.mul(Jv)));break;case L7:s.rgb.addAssign(a.rgb.mul(zm.mul(Jv)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const lte=new vd;class ute extends es{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lte),this.setValues(e)}setupNormal(){return ll}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _E(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ote(cE)),t}setupOutgoingLight(){return Oi.rgb}setupLightingModel(){return new zU}}const G0=Xe(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),md=Xe(i=>i.diffuseColor.mul(1/Math.PI)),cte=()=>ve(.25),hte=Xe(({dotNH:i})=>Q_.mul(ve(.5)).add(1).mul(ve(1/Math.PI)).mul(i.pow(Q_))),fte=Xe(({lightDirection:i})=>{const e=i.add(yr).normalize(),t=Kr.dot(e).clamp(),n=yr.dot(e).clamp(),r=G0({f0:Ha,f90:1,dotVH:n}),s=cte(),a=hte({dotNH:t});return r.mul(s).mul(a)});class GU extends zU{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=Kr.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(md({diffuseColor:Oi.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(fte({lightDirection:e})).mul(zm))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(md({diffuseColor:Oi}))),n.indirectDiffuse.mulAssign(e)}}const dte=new Kc;class Ate extends es{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(dte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _E(t):null}setupLightingModel(){return new GU(!1)}}const pte=new oD;class mte extends es{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(pte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new _E(t):null}setupLightingModel(){return new GU}setupVariants(){const e=(this.shininessNode?ve(this.shininessNode):X9).max(1e-4);Q_.assign(e);const t=this.specularNode||Q9;Ha.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const qU=Xe(i=>{if(i.geometry.hasAttribute("normal")===!1)return ve(0);const e=ll.dFdx().abs().max(ll.dFdy().abs());return e.x.max(e.y).max(e.z)}),yE=Xe(i=>{const{roughness:e}=i,t=qU();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),VU=Xe(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Gl(.5,r.add(s).max(NL))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),gte=Xe(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:s,dotNV:a,dotNL:l})=>{const u=l.mul(Le(i.mul(t),e.mul(n),a).length()),h=a.mul(Le(i.mul(r),e.mul(s),l).length());return Gl(.5,u.add(h)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),jU=Xe(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),vte=ve(1/Math.PI),_te=Xe(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const s=i.mul(e),a=Le(e.mul(n),i.mul(r),s.mul(t)),l=a.dot(a),u=s.div(l);return vte.mul(s.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),QT=Xe(i=>{const{lightDirection:e,f0:t,f90:n,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:l}=i,u=i.normalView||Kr,h=r.pow2(),m=e.add(yr).normalize(),v=u.dot(e).clamp(),x=u.dot(yr).clamp(),S=u.dot(m).clamp(),w=yr.dot(m).clamp();let N=G0({f0:t,f90:n,dotVH:w}),C,E;if(Sg(a)&&(N=By.mix(N,s)),Sg(l)){const O=Im.dot(e),U=Im.dot(yr),I=Im.dot(m),j=ad.dot(e),z=ad.dot(yr),G=ad.dot(m);C=gte({alphaT:Y_,alphaB:h,dotTV:U,dotBV:z,dotTL:O,dotBL:j,dotNV:x,dotNL:v}),E=_te({alphaT:Y_,alphaB:h,dotNH:S,dotTH:I,dotBH:G})}else C=VU({alpha:h,dotNL:v,dotNV:x}),E=jU({alpha:h,dotNH:S});return N.mul(C).mul(E)}),xE=Xe(({roughness:i,dotNV:e})=>{const t=Mn(-1,-.0275,-.572,.022),n=Mn(1,.0425,1.04,-.04),r=i.mul(t).add(n),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return Ft(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),HU=Xe(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,s=xE({dotNV:e,roughness:r});return t.mul(s.x).add(n.mul(s.y))}),WU=Xe(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),s=n.mul(r,r).clamp(0,.9999);return i.sub(Le(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),yte=Xe(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=ve(1).div(t),s=e.pow2().oneMinus().max(.0078125);return ve(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),xte=Xe(({dotNV:i,dotNL:e})=>ve(1).div(ve(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),bte=Xe(({lightDirection:i})=>{const e=i.add(yr).normalize(),t=Kr.dot(i).clamp(),n=Kr.dot(yr).clamp(),r=Kr.dot(e).clamp(),s=yte({roughness:Uy,dotNH:r}),a=xte({dotNV:n,dotNL:t});return Kf.mul(s).mul(a)}),Ste=Xe(({N:i,V:e,roughness:t})=>{const s=.0078125,a=i.dot(e).saturate(),l=Ft(t,a.oneMinus().sqrt());return l.assign(l.mul(.984375).add(s)),l}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),Tte=Xe(({f:i})=>{const e=i.length();return Jr(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),uv=Xe(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=r.div(s),l=t.greaterThan(0).select(a,Jr(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return i.cross(e).mul(l)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),qR=Xe(({N:i,V:e,P:t,mInv:n,p0:r,p1:s,p2:a,p3:l})=>{const u=s.sub(r).toVar(),h=l.sub(r).toVar(),m=u.cross(h),v=Le().toVar();return si(m.dot(t.sub(r)).greaterThanEqual(0),()=>{const x=e.sub(i.mul(e.dot(i))).normalize(),S=i.cross(x).negate(),w=n.mul(_a(x,S,i).transpose()).toVar(),N=w.mul(r.sub(t)).normalize().toVar(),C=w.mul(s.sub(t)).normalize().toVar(),E=w.mul(a.sub(t)).normalize().toVar(),O=w.mul(l.sub(t)).normalize().toVar(),U=Le(0).toVar();U.addAssign(uv({v1:N,v2:C})),U.addAssign(uv({v1:C,v2:E})),U.addAssign(uv({v1:E,v2:O})),U.addAssign(uv({v1:O,v2:N})),v.assign(Le(Tte({f:U})))}),v}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Yy=1/6,$U=i=>Jn(Yy,Jn(i,Jn(i,i.negate().add(3)).sub(3)).add(1)),KT=i=>Jn(Yy,Jn(i,Jn(i,Jn(3,i).sub(6))).add(4)),XU=i=>Jn(Yy,Jn(i,Jn(i,Jn(-3,i).add(3)).add(3)).add(1)),ZT=i=>Jn(Yy,Fl(i,3)),VR=i=>$U(i).add(KT(i)),jR=i=>XU(i).add(ZT(i)),HR=i=>ls(-1,KT(i).div($U(i).add(KT(i)))),WR=i=>ls(1,ZT(i).div(XU(i).add(ZT(i)))),$R=(i,e,t)=>{const n=i.uvNode,r=Jn(n,e.zw).add(.5),s=_u(r),a=Zc(r),l=VR(a.x),u=jR(a.x),h=HR(a.x),m=WR(a.x),v=HR(a.y),x=WR(a.y),S=Ft(s.x.add(h),s.y.add(v)).sub(.5).mul(e.xy),w=Ft(s.x.add(m),s.y.add(v)).sub(.5).mul(e.xy),N=Ft(s.x.add(h),s.y.add(x)).sub(.5).mul(e.xy),C=Ft(s.x.add(m),s.y.add(x)).sub(.5).mul(e.xy),E=VR(a.y).mul(ls(l.mul(i.sample(S).level(t)),u.mul(i.sample(w).level(t)))),O=jR(a.y).mul(ls(l.mul(i.sample(N).level(t)),u.mul(i.sample(C).level(t))));return E.add(O)},YU=Xe(([i,e=ve(3)])=>{const t=Ft(i.size(we(e))),n=Ft(i.size(we(e.add(1)))),r=Gl(1,t),s=Gl(1,n),a=$R(i,Mn(r,t),_u(e)),l=$R(i,Mn(s,n),Iy(e));return Zc(e).mix(a,l)}),XR=Xe(([i,e,t,n,r])=>{const s=Le(tE(e.negate(),Wc(i),Gl(1,n))),a=Le(Ic(r[0].xyz),Ic(r[1].xyz),Ic(r[2].xyz));return Wc(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),wte=Xe(([i,e])=>i.mul(Mu(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Mte=dE(),Ete=dE(),YR=Xe(([i,e,t],{material:n})=>{const s=(n.side===gr?Mte:Ete).sample(i),a=vu(Dg.x).mul(wte(e,t));return YU(s,a)}),QR=Xe(([i,e,t])=>(si(t.notEqual(0),()=>{const n=Oy(e).negate().div(t);return $M(n.negate().mul(i))}),Le(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Cte=Xe(([i,e,t,n,r,s,a,l,u,h,m,v,x,S,w])=>{let N,C;if(w){N=Mn().toVar(),C=Le().toVar();const j=m.sub(1).mul(w.mul(.025)),z=Le(m.sub(j),m,m.add(j));Gi({start:0,end:3},({i:G})=>{const W=z.element(G),q=XR(i,e,v,W,l),V=a.add(q),Y=h.mul(u.mul(Mn(V,1))),te=Ft(Y.xy.div(Y.w)).toVar();te.addAssign(1),te.divAssign(2),te.assign(Ft(te.x,te.y.oneMinus()));const ne=YR(te,t,W);N.element(G).assign(ne.element(G)),N.a.addAssign(ne.a),C.element(G).assign(n.element(G).mul(QR(Ic(q),x,S).element(G)))}),N.a.divAssign(3)}else{const j=XR(i,e,v,m,l),z=a.add(j),G=h.mul(u.mul(Mn(z,1))),W=Ft(G.xy.div(G.w)).toVar();W.addAssign(1),W.divAssign(2),W.assign(Ft(W.x,W.y.oneMinus())),N=YR(W,t,m),C=n.mul(QR(Ic(j),x,S))}const E=C.rgb.mul(N.rgb),O=i.dot(e).clamp(),U=Le(HU({dotNV:O,specularColor:r,specularF90:s,roughness:t})),I=C.r.add(C.g,C.b).div(3);return Mn(U.oneMinus().mul(E),N.a.oneMinus().mul(I).oneMinus())}),Nte=_a(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Rte=i=>{const e=i.sqrt();return Le(1).add(e).div(Le(1).sub(e))},KR=(i,e)=>i.sub(e).div(i.add(e)).pow2(),Dte=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=Le(54856e-17,44201e-17,52481e-17),r=Le(1681e3,1795300,2208400),s=Le(43278e5,93046e5,66121e5),a=ve(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let l=n.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return l=Le(l.x.add(a),l.y,l.z).div(10685e-11),Nte.mul(l)},Pte=Xe(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const s=zi(i,e,$c(0,.03,n)),l=i.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();si(l.lessThan(0),()=>Le(1));const u=l.sqrt(),h=KR(s,i),m=G0({f0:h,f90:1,dotVH:t}),v=m.oneMinus(),x=s.lessThan(i).select(Math.PI,0),S=ve(Math.PI).sub(x),w=Rte(r.clamp(0,.9999)),N=KR(w,s.toVec3()),C=G0({f0:N,f90:1,dotVH:u}),E=Le(w.x.lessThan(s).select(Math.PI,0),w.y.lessThan(s).select(Math.PI,0),w.z.lessThan(s).select(Math.PI,0)),O=s.mul(n,u,2),U=Le(S).add(E),I=m.mul(C).clamp(1e-5,.9999),j=I.sqrt(),z=v.pow2().mul(C).div(Le(1).sub(I)),W=m.add(z).toVar(),q=z.sub(v).toVar();return Gi({start:1,end:2,condition:"<=",name:"m"},({m:V})=>{q.mulAssign(j);const Y=Dte(ve(V).mul(O),ve(V).mul(U)).mul(2);W.addAssign(q.mul(Y))}),W.max(Le(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Lte=Xe(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.pow2(),s=Ys(t.lessThan(.25),ve(-339.2).mul(r).add(ve(161.4).mul(t)).sub(25.9),ve(-8.48).mul(r).add(ve(14.3).mul(t)).sub(9.95)),a=Ys(t.lessThan(.25),ve(44).mul(r).sub(ve(23.7).mul(t)).add(3.26),ve(1.97).mul(r).sub(ve(3.27).mul(t)).add(.72));return Ys(t.lessThan(.25),0,ve(.1).mul(t).sub(.025)).add(s.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),Q3=Le(.04),K3=ve(1);class QU extends Xy{constructor(e=!1,t=!1,n=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Le().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Le().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Le().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=Le().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Le().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Kr.dot(yr).clamp();this.iridescenceFresnel=Pte({outsideIOR:ve(1),eta2:FM,cosTheta1:t,thinFilmThickness:kM,baseF0:Ha}),this.iridescenceF0=WU({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Fc,n=E9.sub(Fc).normalize(),r=jy;e.backdrop=Cte(r,n,au,Oi,Ha,Cg,t,nl,ho,bd,Fm,zM,qM,GM,this.dispersion?VM:null),e.backdropAlpha=K_,Oi.a.mulAssign(zi(1,e.backdrop.a,K_))}}computeMultiscattering(e,t,n){const r=Kr.dot(yr).clamp(),s=xE({roughness:au,dotNV:r}),l=(this.iridescenceF0?By.mix(Ha,this.iridescenceF0):Ha).mul(s.x).add(n.mul(s.y)),h=s.x.add(s.y).oneMinus(),m=Ha.add(Ha.oneMinus().mul(.047619)),v=l.mul(m).div(h.mul(m).oneMinus());e.addAssign(l),t.addAssign(v.mul(h))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=Kr.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(s.mul(bte({lightDirection:e}))),this.clearcoat===!0){const l=JA.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(l.mul(QT({lightDirection:e,f0:Q3,f90:K3,roughness:Eg,normalView:JA})))}n.directDiffuse.addAssign(s.mul(md({diffuseColor:Oi.rgb}))),n.directSpecular.addAssign(s.mul(QT({lightDirection:e,f0:Ha,f90:1,roughness:au,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:l}){const u=t.add(n).sub(r),h=t.sub(n).sub(r),m=t.sub(n).add(r),v=t.add(n).add(r),x=Kr,S=yr,w=as.toVar(),N=Ste({N:x,V:S,roughness:au}),C=a.sample(N).toVar(),E=l.sample(N).toVar(),O=_a(Le(C.x,0,C.y),Le(0,1,0),Le(C.z,0,C.w)).toVar(),U=Ha.mul(E.x).add(Ha.oneMinus().mul(E.y)).toVar();s.directSpecular.addAssign(e.mul(U).mul(qR({N:x,V:S,P:w,mInv:O,p0:u,p1:h,p2:m,p3:v}))),s.directDiffuse.addAssign(e.mul(Oi).mul(qR({N:x,V:S,P:w,mInv:_a(1,0,0,0,1,0,0,0,1),p0:u,p1:h,p2:m,p3:v})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(md({diffuseColor:Oi})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Kf,Lte({normal:Kr,viewDir:yr,roughness:Uy}))),this.clearcoat===!0){const h=JA.dot(yr).clamp(),m=HU({dotNV:h,specularColor:Q3,specularF90:K3,roughness:Eg});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const r=Le().toVar("singleScattering"),s=Le().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,Cg);const l=r.add(s),u=Oi.mul(l.r.max(l.g).max(l.b).oneMinus());n.indirectSpecular.addAssign(e.mul(r)),n.indirectSpecular.addAssign(s.mul(a)),n.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const r=Kr.dot(yr).clamp().add(e),s=au.mul(-16).oneMinus().negate().exp2(),a=e.sub(r.pow(s).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(a)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=JA.dot(yr).clamp(),r=G0({dotVH:n,f0:Q3,f90:K3}),s=t.mul(X_.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(X_));t.assign(s)}if(this.sheen===!0){const n=Kf.r.max(Kf.g).max(Kf.b).mul(.157).oneMinus(),r=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const ZR=ve(1),JT=ve(-2),cv=ve(.8),Z3=ve(-1),hv=ve(.4),J3=ve(2),fv=ve(.305),eS=ve(3),JR=ve(.21),Ute=ve(4),e6=ve(4),Bte=ve(16),Ote=Xe(([i])=>{const e=Le(dr(i)).toVar(),t=ve(-1).toVar();return si(e.x.greaterThan(e.z),()=>{si(e.x.greaterThan(e.y),()=>{t.assign(Ys(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ys(i.y.greaterThan(0),1,4))})}).Else(()=>{si(e.z.greaterThan(e.y),()=>{t.assign(Ys(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ys(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Ite=Xe(([i,e])=>{const t=Ft().toVar();return si(e.equal(0),()=>{t.assign(Ft(i.z,i.y).div(dr(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Ft(i.x.negate(),i.z.negate()).div(dr(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Ft(i.x.negate(),i.y).div(dr(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Ft(i.z.negate(),i.y).div(dr(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Ft(i.x.negate(),i.z).div(dr(i.y)))}).Else(()=>{t.assign(Ft(i.x,i.y).div(dr(i.z)))}),Jn(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Fte=Xe(([i])=>{const e=ve(0).toVar();return si(i.greaterThanEqual(cv),()=>{e.assign(ZR.sub(i).mul(Z3.sub(JT)).div(ZR.sub(cv)).add(JT))}).ElseIf(i.greaterThanEqual(hv),()=>{e.assign(cv.sub(i).mul(J3.sub(Z3)).div(cv.sub(hv)).add(Z3))}).ElseIf(i.greaterThanEqual(fv),()=>{e.assign(hv.sub(i).mul(eS.sub(J3)).div(hv.sub(fv)).add(J3))}).ElseIf(i.greaterThanEqual(JR),()=>{e.assign(fv.sub(i).mul(Ute.sub(eS)).div(fv.sub(JR)).add(eS))}).Else(()=>{e.assign(ve(-2).mul(vu(Jn(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),KU=Xe(([i,e])=>{const t=i.toVar();t.assign(Jn(2,t).sub(1));const n=Le(t,1).toVar();return si(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ZU=Xe(([i,e,t,n,r,s])=>{const a=ve(t),l=Le(e),u=Mu(Fte(a),JT,s),h=Zc(u),m=_u(u),v=Le(ew(i,l,m,n,r,s)).toVar();return si(h.notEqual(0),()=>{const x=Le(ew(i,l,m.add(1),n,r,s)).toVar();v.assign(zi(v,x,h))}),v}),ew=Xe(([i,e,t,n,r,s])=>{const a=ve(t).toVar(),l=Le(e),u=ve(Ote(l)).toVar(),h=ve(Jr(e6.sub(a),0)).toVar();a.assign(Jr(a,e6));const m=ve(k0(a)).toVar(),v=Ft(Ite(l,u).mul(m.sub(2)).add(1)).toVar();return si(u.greaterThan(2),()=>{v.y.addAssign(m),u.subAssign(3)}),v.x.addAssign(u.mul(m)),v.x.addAssign(h.mul(Jn(3,Bte))),v.y.addAssign(Jn(4,k0(s).sub(m))),v.x.mulAssign(n),v.y.mulAssign(r),i.sample(v).grad(Ft(),Ft())}),tS=Xe(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:l})=>{const u=Cc(n),h=t.mul(u).add(r.cross(t).mul(Uo(n))).add(r.mul(r.dot(t).mul(u.oneMinus())));return ew(i,h,e,s,a,l)}),JU=Xe(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:s,dTheta:a,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})=>{const x=Le(Ys(e,t,ky(t,n))).toVar();si(WM(x.equals(Le(0))),()=>{x.assign(Le(n.z,0,n.x.negate()))}),x.assign(Wc(x));const S=Le().toVar();return S.addAssign(r.element(we(0)).mul(tS({theta:0,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),Gi({start:we(1),end:i},({i:w})=>{si(w.greaterThanEqual(s),()=>{NU()});const N=ve(a.mul(ve(w))).toVar();S.addAssign(r.element(w).mul(tS({theta:N.mul(-1),axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),S.addAssign(r.element(w).mul(tS({theta:N,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})))}),Mn(S,1)});let ny=null;const t6=new WeakMap;function kte(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function zte(i){let e=t6.get(i);if((e!==void 0?e.pmremVersion:-1)!==i.pmremVersion){const n=i.image;if(i.isCubeTexture)if(qte(n))e=ny.fromCubemap(i,e);else return null;else if(Vte(n))e=ny.fromEquirectangular(i,e);else return null;e.pmremVersion=i.pmremVersion,t6.set(i,e)}return e.texture}class Gte extends cs{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new Es;r.isRenderTargetTexture=!0,this._texture=gi(r),this._width=En(0),this._height=En(0),this._maxMip=En(0),this.updateBeforeType=Zn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=kte(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(n.isPMREMTexture===!0?e=n:e=zte(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ny===null&&(ny=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===Qa&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=Le(t.x.negate(),t.yz)),t=Le(t.x,t.y.negate(),t.z);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ZU(this._texture,t,r,this._width,this._height,this._maxMip)}}function qte(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n0}const bE=vt(Gte),n6=new WeakMap;class jte extends ep{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const S=n.isTextureNode?n.value:t[n.property];let w=n6.get(S);w===void 0&&(w=bE(S),n6.set(S,w)),n=w}const s=t.envMap?$i("envMapIntensity","float",e.material):$i("environmentIntensity","float",e.scene),l=t.useAnisotropy===!0||t.anisotropy>0?j9:Kr,u=n.context(i6(au,l)).mul(s),h=n.context(Hte(jy)).mul(Math.PI).mul(s),m=km(u),v=km(h);e.context.radiance.addAssign(m),e.context.iblIrradiance.addAssign(v);const x=e.context.lightingModel.clearcoatRadiance;if(x){const S=n.context(i6(Eg,JA)).mul(s),w=km(S);x.addAssign(w)}}}const i6=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=yr.negate().reflect(e),t=i.mul(i).mix(t,e).normalize(),t=t.transformDirection(ho)),t),getTextureLevel:()=>i}},Hte=i=>({getUV:()=>i,getTextureLevel:()=>ve(1)}),Wte=new aD;class eB extends es{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Wte),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new jte(t):null}setupLightingModel(){return new QU}setupSpecular(){const e=zi(Le(.04),Oi.rgb,Mg);Ha.assign(e),Cg.assign(1)}setupVariants(){const e=this.metalnessNode?ve(this.metalnessNode):J9;Mg.assign(e);let t=this.roughnessNode?ve(this.roughnessNode):Z9;t=yE({roughness:t}),au.assign(t),this.setupSpecular(),Oi.assign(Mn(Oi.rgb.mul(e.oneMinus()),Oi.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const $te=new Lz;class Xte extends eB{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues($te),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?ve(this.iorNode):dU;Fm.assign(e),Ha.assign(zi(oo(eE(Fm.sub(1).div(Fm.add(1))).mul(K9),Le(1)).mul(YT),Oi.rgb,Mg)),Cg.assign(zi(YT,1,Mg))}setupLightingModel(){return new QU(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?ve(this.clearcoatNode):tU,n=this.clearcoatRoughnessNode?ve(this.clearcoatRoughnessNode):nU;X_.assign(t),Eg.assign(yE({roughness:n}))}if(this.useSheen){const t=this.sheenNode?Le(this.sheenNode):sU,n=this.sheenRoughnessNode?ve(this.sheenRoughnessNode):aU;Kf.assign(t),Uy.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?ve(this.iridescenceNode):lU,n=this.iridescenceIORNode?ve(this.iridescenceIORNode):uU,r=this.iridescenceThicknessNode?ve(this.iridescenceThicknessNode):cU;By.assign(t),FM.assign(n),kM.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?Ft(this.anisotropyNode):oU).toVar();Bh.assign(t.length()),si(Bh.equal(0),()=>{t.assign(Ft(1,0))}).Else(()=>{t.divAssign(Ft(Bh)),Bh.assign(Bh.saturate())}),Y_.assign(Bh.pow2().mix(au.pow2(),1)),Im.assign(Zf[0].mul(t.x).add(Zf[1].mul(t.y))),ad.assign(Zf[1].mul(t.x).sub(Zf[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?ve(this.transmissionNode):hU,n=this.thicknessNode?ve(this.thicknessNode):fU,r=this.attenuationDistanceNode?ve(this.attenuationDistanceNode):AU,s=this.attenuationColorNode?Le(this.attenuationColorNode):pU;if(K_.assign(t),zM.assign(n),GM.assign(r),qM.assign(s),this.useDispersion){const a=this.dispersionNode?ve(this.dispersionNode):yU;VM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Le(this.clearcoatNormalNode):iU}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const Yte=Xe(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=Ft(n.mul(.5).add(.5),0);if(t.material.gradientMap){const s=Pc("gradientMap","texture").context({getUV:()=>r});return Le(s.r)}else{const s=r.fwidth().mul(.5);return zi(Le(.7),Le(1),$c(ve(.7).sub(s.x),ve(.7).add(s.x),r.x))}});class Qte extends Xy{direct({lightDirection:e,lightColor:t,reflectedLight:n},r,s){const a=Yte({normal:qy,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(a.mul(md({diffuseColor:Oi.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(md({diffuseColor:Oi}))),n.indirectDiffuse.mulAssign(e)}}const Kte=new Uz;class Zte extends es{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Kte),this.setValues(e)}setupLightingModel(){return new Qte}}class Jte extends cs{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=Le(yr.z,0,yr.x.negate()).normalize(),t=yr.cross(e);return Ft(e.dot(Kr),t.dot(Kr)).mul(.495).add(.5)}}const tB=Jt(Jte),ene=new Fz;class tne extends es{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(ene),this.setValues(e)}setupVariants(e){const t=tB;let n;e.material.matcap?n=Pc("matcap","texture").context({getUV:()=>t}):n=Le(zi(.2,.8,t.y)),Oi.rgb.mulAssign(n.rgb)}}const nne=new Jw;class ine extends es{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.setDefaultValues(nne),this.setValues(e)}}class rne extends cs{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),a=t.sin();return Ly(s,a,a.negate(),s).mul(n)}else{const s=t,a=sd(Mn(1,0,0,0),Mn(0,Cc(s.x),Uo(s.x).negate(),0),Mn(0,Uo(s.x),Cc(s.x),0),Mn(0,0,0,1)),l=sd(Mn(Cc(s.y),0,Uo(s.y),0),Mn(0,1,0,0),Mn(Uo(s.y).negate(),0,Cc(s.y),0),Mn(0,0,0,1)),u=sd(Mn(Cc(s.z),Uo(s.z).negate(),0,0),Mn(Uo(s.z),Cc(s.z),0,0),Mn(0,0,1,0),Mn(0,0,0,1));return a.mul(l).mul(u).mul(Mn(n,1)).xyz}}}const SE=vt(rne),sne=new Qk;class ane extends es{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(sne),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:l}=this,u=J0.mul(Le(s||0));let h=Ft(nl[0].xyz.length(),nl[1].xyz.length());if(l!==null&&(h=h.mul(l)),r===!1)if(n.isPerspectiveCamera)h=h.mul(u.z.negate());else{const S=ve(2).div(bd.element(1).element(1));h=h.mul(S.mul(2))}let m=Gy.xy;if(t.center&&t.center.isVector2===!0){const S=MJ("center","vec2",t);m=m.sub(S.sub(.5))}m=m.mul(h);const v=ve(a||rU),x=SE(m,v);return Mn(u.xy.add(x),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class one extends Xy{constructor(){super(),this.shadowNode=ve(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Oi.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Oi.rgb)}}const lne=new Pz;class une extends es{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lne),this.setValues(e)}setupLightingModel(){return new one}}const cne=Xe(({texture:i,uv:e})=>{const n=Le().toVar();return si(e.x.lessThan(1e-4),()=>{n.assign(Le(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(Le(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(Le(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(Le(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(Le(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(Le(0,0,-1))}).Else(()=>{const s=i.sample(e.add(Le(-.01,0,0))).r.sub(i.sample(e.add(Le(.01,0,0))).r),a=i.sample(e.add(Le(0,-.01,0))).r.sub(i.sample(e.add(Le(0,.01,0))).r),l=i.sample(e.add(Le(0,0,-.01))).r.sub(i.sample(e.add(Le(0,0,.01))).r);n.assign(Le(s,a,l))}),n.normalize()});class hne extends Cu{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Le(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(we(jh(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return cne({texture:this,uv:e})}}const fne=vt(hne);class dne{constructor(e,t){this.nodes=e,this.info=t,this._context=self,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class Du{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const s of e){const a=s.node&&s.node.attribute?s.node.attribute:t.getAttribute(s.name);if(a===void 0)continue;n.push(a);const l=a.isInterleavedBufferAttribute?a.data:a;r.add(l)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:s}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),l=this.getIndex(),u=l!==null,h=n.isInstancedBufferGeometry?n.instanceCount:e.count>1?e.count:1;if(h===0)return null;if(a.instanceCount=h,e.isBatchedMesh===!0)return a;let m=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(m=2);let v=s.start*m,x=(s.start+s.count)*m;r!==null&&(v=Math.max(v,r.start*m),x=Math.min(x,(r.start+r.count)*m));const S=n.attributes.position;let w=1/0;u?w=l.count:S!=null&&(w=S.count),v=Math.max(v,0),x=Math.min(x,w);const N=x-v;return N<0||N===1/0?null:(a.vertexCount=N,a.firstVertex=v,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const r of pne(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const s=t[r];let a;if(s!==null){const l=typeof s;l==="number"?a=s!==0?"1":"0":l==="object"?(a="{",s.isTexture&&(a+=s.mapping),a+="}"):a=String(s)}else a=String(s);n+=a+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(n+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",OP(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const RA=[];class gne{constructor(e,t,n,r,s,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=s,this.info=a,this.chainMaps={}}get(e,t,n,r,s,a,l,u){const h=this.getChainMap(u);RA[0]=e,RA[1]=t,RA[2]=a,RA[3]=s;let m=h.get(RA);return m===void 0?(m=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,s,a,l,u),h.set(RA,m)):(m.updateClipping(l),m.needsGeometryUpdate&&m.setGeometry(e.geometry),(m.version!==t.version||m.needsUpdate)&&(m.initialCacheKey!==m.getCacheKey()?(m.dispose(),m=this.get(e,t,n,r,s,a,l,u)):m.version=t.version)),m}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Du)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,s,a,l,u,h,m,v){const x=this.getChainMap(v),S=new mne(e,t,n,r,s,a,l,u,h,m);return S.onDispose=()=>{this.pipelines.delete(S),this.bindings.delete(S),this.nodes.delete(S),x.delete(S.getChainArray())},S}}class tf{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const hu={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},kh=16,vne=211,_ne=212;class yne extends tf{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==void 0&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===hu.VERTEX?this.backend.createAttribute(e):t===hu.INDEX?this.backend.createIndexAttribute(e):t===hu.STORAGE?this.backend.createStorageAttribute(e):t===hu.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version=0;--e)if(i[e]>=65535)return!0;return!1}function nB(i){return i.index!==null?i.index.version:i.attributes.position.version}function r6(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const s=t.array;for(let a=0,l=s.length;a{this.info.memory.geometries--;const s=t.index,a=e.getAttributes();s!==null&&this.attributes.delete(s);for(const u of a)this.attributes.delete(u);const l=this.wireframes.get(t);l!==void 0&&this.attributes.delete(l),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,hu.STORAGE):this.updateAttribute(s,hu.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,hu.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,hu.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const s=this.wireframes;let a=s.get(t);a===void 0?(a=r6(t),s.set(t,a)):a.version!==nB(t)&&(this.attributes.delete(a),a=r6(t),s.set(t,a)),r=a}return r}}class Sne{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){this[e].timestampCalls===0&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class iB{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Tne extends iB{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class wne extends iB{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Mne=0;class nS{constructor(e,t,n,r=null,s=null){this.id=Mne++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=s,this.usedTimes=0}}class Ene extends tf{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let l=this.programs.compute.get(a.computeShader);l===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),l=new nS(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,l),n.createProgram(l));const u=this._getComputeCacheKey(e,l);let h=this.caches.get(u);h===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),h=this._getComputePipeline(e,l,u,t)),h.usedTimes++,l.usedTimes++,r.version=e.version,r.pipeline=h}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),l=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),u=new nS(a.vertexShader,"vertex",l),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let h=this.programs.fragment.get(a.fragmentShader);h===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),h=new nS(a.fragmentShader,"fragment",l),this.programs.fragment.set(a.fragmentShader,h),n.createProgram(h));const m=this._getRenderCacheKey(e,u,h);let v=this.caches.get(m);v===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),v=this._getRenderPipeline(e,u,h,m,t)):e.pipeline=v,v.usedTimes++,u.usedTimes++,h.usedTimes++,r.pipeline=v}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new wne(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,n,r,s){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new Tne(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,s)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Cne extends tf{constructor(e,t,n,r,s,a){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?hu.INDIRECT:hu.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,s=!0,a=0,l=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const h=this.textures.get(u.texture);u.needsBindingsUpdate(h.generation)&&(r=!0);const m=u.update(),v=u.texture;m&&this.textures.updateTexture(v);const x=n.get(v);if(x.externalTexture!==void 0||h.isDefaultTexture?s=!1:(a=a*10+v.id,l+=v.version),n.isWebGPUBackend===!0&&x.texture===void 0&&x.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,m,v,u.textureNode.value,r),this.textures.updateTexture(v),r=!0),v.isStorageTexture===!0){const S=this.get(v);u.store===!0?S.needsMipmap=!0:this.textures.needsMipmaps(v)&&S.needsMipmap===!0&&(this.backend.generateMipmaps(v),S.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,s?a:0,l)}}function Nne(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function s6(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function a6(i){return(i.transmission>0||i.transmissionNode)&&i.side===gs&&i.forceSinglePass===!1}class Rne{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,s,a,l){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:s,group:a,clippingContext:l},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=s,u.group=a,u.clippingContext=l),this.renderItemsIndex++,u}push(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(a6(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);n.transparent===!0||n.transmission>0?(a6(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Nne),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||s6),this.transparent.length>1&&this.transparent.sort(t||s6)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,h=l.height>>t;let m=e.depthTexture||s[t];const v=e.depthBuffer===!0||e.stencilBuffer===!0;let x=!1;m===void 0&&v&&(m=new Qc,m.format=e.stencilBuffer?bu:Au,m.type=e.stencilBuffer?xu:Ir,m.image.width=u,m.image.height=h,s[t]=m),(n.width!==l.width||l.height!==n.height)&&(x=!0,m&&(m.needsUpdate=!0,m.image.width=u,m.image.height=h)),n.width=l.width,n.height=l.height,n.textures=a,n.depthTexture=m||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(x=!0,m&&(m.needsUpdate=!0),n.sampleCount=r);const S={sampleCount:r};for(let w=0;w{e.removeEventListener("dispose",w);for(let N=0;N0){const m=e.image;if(m===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(m.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const v=[];for(const x of e.images)v.push(x);t.images=v}else t.image=m;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&s.generateMipmaps(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const h=()=>{e.removeEventListener("dispose",h),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",h)}n.version=e.version}getSize(e,t=Bne){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return this.isEnvironmentTexture(e)||e.isCompressedTexture===!0||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===Wh||t===$h||t===sl||t===al}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class TE extends mn{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class sB extends Vi{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const Ine=(i,e)=>Ct(new sB(i,e));class Fne extends Un{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new Om(t);return this._currentCond=Ys(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Om(t),r=Ys(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Om(e),this}build(e,...t){const n=UM();Tg(this);for(const r of this.nodes)r.build(e,"void");return Tg(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const e_=vt(Fne);class aB extends Un{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,n=[];for(let r=0;r{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),tw=(i,e)=>Fl(Jn(4,i.mul(Ei(1,i))),e),qne=(i,e)=>i.lessThan(.5)?tw(i.mul(2),e).div(2):Ei(1,tw(Jn(Ei(1,i),2),e).div(2)),Vne=(i,e,t)=>Fl(Gl(Fl(i,e),ls(Fl(i,e),Fl(Ei(1,i),t))),1/e),jne=(i,e)=>Uo(Z_.mul(e.mul(i).sub(1))).div(Z_.mul(e.mul(i).sub(1))),Nc=Xe(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Hne=Xe(([i])=>Le(Nc(i.z.add(Nc(i.y.mul(1)))),Nc(i.z.add(Nc(i.x.mul(1)))),Nc(i.y.add(Nc(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Wne=Xe(([i,e,t])=>{const n=Le(i).toVar(),r=ve(1.4).toVar(),s=ve(0).toVar(),a=Le(n).toVar();return Gi({start:ve(0),end:ve(3),type:"float",condition:"<="},()=>{const l=Le(Hne(a.mul(2))).toVar();n.addAssign(l.add(t.mul(ve(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const u=ve(Nc(n.z.add(Nc(n.x.add(Nc(n.y)))))).toVar();s.addAssign(u.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class $ne extends Un{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let r=null,s=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=u.inputs;if(t.length===h.length){let m=0;for(let v=0;vs&&(r=a,s=m)}}this._candidateFnCall=n=r(...t)}return n}}const Xne=vt($ne),Zs=i=>(...e)=>Xne(i,...e),Sd=En(0).setGroup(In).onRenderUpdate(i=>i.time),uB=En(0).setGroup(In).onRenderUpdate(i=>i.deltaTime),Yne=En(0,"uint").setGroup(In).onRenderUpdate(i=>i.frameId),Qne=(i=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),Sd.mul(i)),Kne=(i=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),Sd.mul(i)),Zne=(i=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),uB.mul(i)),Jne=(i=Sd)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),eie=(i=Sd)=>i.fract().round(),tie=(i=Sd)=>i.add(.5).fract().mul(2).sub(1).abs(),nie=(i=Sd)=>i.fract(),iie=Xe(([i,e,t=Ft(.5)])=>SE(i.sub(t),e).add(t)),rie=Xe(([i,e,t=Ft(.5)])=>{const n=i.sub(t),r=n.dot(n),a=r.mul(r).mul(e);return i.add(n.mul(a))}),sie=Xe(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=nl.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=nl;const r=ho.mul(n);return Sg(e)&&(r[0][0]=nl[0].length(),r[0][1]=0,r[0][2]=0),Sg(t)&&(r[1][0]=0,r[1][1]=nl[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,bd.mul(r).mul(Zr)}),aie=Xe(([i=null])=>{const e=ty();return ty(AE(i)).sub(e).lessThan(0).select(Ru,i)});class oie extends Un{static get type(){return"SpriteSheetUVNode"}constructor(e,t=Br(),n=ve(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:s}=n,a=e.mod(r.mul(s)).floor(),l=a.mod(r),u=s.sub(a.add(1).div(r).ceil()),h=n.reciprocal(),m=Ft(l,u);return t.add(m).mul(h)}}const lie=vt(oie);class uie extends Un{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,n=null,r=ve(1),s=Zr,a=lo){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:s,normalNode:a}=this;let l=a.abs().normalize();l=l.div(l.dot(Le(1)));const u=s.yz.mul(r),h=s.zx.mul(r),m=s.xy.mul(r),v=e.value,x=t!==null?t.value:v,S=n!==null?n.value:v,w=gi(v,u).mul(l.x),N=gi(x,h).mul(l.y),C=gi(S,m).mul(l.z);return ls(w,N,C)}}const cB=vt(uie),cie=(...i)=>cB(...i),DA=new iu,Df=new de,PA=new de,iS=new de,cm=new Xn,dv=new de(0,0,-1),Zl=new qn,hm=new de,Av=new de,fm=new qn,pv=new Et,iy=new Zh,hie=Ru.flipX();iy.depthTexture=new Qc(1,1);let rS=!1;class wE extends Cu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||iy.texture,hie),this._reflectorBaseNode=e.reflector||new fie(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Ct(new wE({defaultTexture:iy.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}}class fie extends Un{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new Tr,resolution:r=1,generateMipmaps:s=!1,bounces:a=!0,depth:l=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=s,this.bounces=a,this.depth=l,this.updateBeforeType=a?Zn.RENDER:Zn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const n=this.resolution;t.getDrawingBufferSize(pv),e.setSize(Math.round(pv.width*n),Math.round(pv.height*n))}setup(e){return this._updateResolution(iy,e.renderer),super.setup(e)}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new Zh(0,0,{type:Qs}),this.generateMipmaps===!0&&(t.texture.minFilter=WF,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Qc),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&rS)return!1;rS=!0;const{scene:t,camera:n,renderer:r,material:s}=e,{target:a}=this,l=this.getVirtualCamera(n),u=this.getRenderTarget(l);if(r.getDrawingBufferSize(pv),this._updateResolution(u,r),PA.setFromMatrixPosition(a.matrixWorld),iS.setFromMatrixPosition(n.matrixWorld),cm.extractRotation(a.matrixWorld),Df.set(0,0,1),Df.applyMatrix4(cm),hm.subVectors(PA,iS),hm.dot(Df)>0)return;hm.reflect(Df).negate(),hm.add(PA),cm.extractRotation(n.matrixWorld),dv.set(0,0,-1),dv.applyMatrix4(cm),dv.add(iS),Av.subVectors(PA,dv),Av.reflect(Df).negate(),Av.add(PA),l.coordinateSystem=n.coordinateSystem,l.position.copy(hm),l.up.set(0,1,0),l.up.applyMatrix4(cm),l.up.reflect(Df),l.lookAt(Av),l.near=n.near,l.far=n.far,l.updateMatrixWorld(),l.projectionMatrix.copy(n.projectionMatrix),DA.setFromNormalAndCoplanarPoint(Df,PA),DA.applyMatrix4(l.matrixWorldInverse),Zl.set(DA.normal.x,DA.normal.y,DA.normal.z,DA.constant);const h=l.projectionMatrix;fm.x=(Math.sign(Zl.x)+h.elements[8])/h.elements[0],fm.y=(Math.sign(Zl.y)+h.elements[9])/h.elements[5],fm.z=-1,fm.w=(1+h.elements[10])/h.elements[14],Zl.multiplyScalar(1/Zl.dot(fm));const m=0;h.elements[2]=Zl.x,h.elements[6]=Zl.y,h.elements[10]=r.coordinateSystem===Su?Zl.z-m:Zl.z+1-m,h.elements[14]=Zl.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),s.visible=!1;const v=r.getRenderTarget(),x=r.getMRT(),S=r.autoClear;r.setMRT(null),r.setRenderTarget(u),r.autoClear=!0,r.render(t,l),r.setMRT(x),r.setRenderTarget(v),r.autoClear=S,s.visible=!0,rS=!1}}const die=i=>Ct(new wE(i)),sS=new Gg(-1,1,1,-1,0,1);class Aie extends Ji{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Ci([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ci(t,2))}}const pie=new Aie;class ME extends qi{constructor(e=null){super(pie,e),this.camera=sS,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,sS)}render(e){e.render(this,sS)}}const mie=new Et;class gie extends Cu{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:Qs}){const s=new Zh(t,n,r);super(s.texture,Br()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new ME(new es),this.updateBeforeType=Zn.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const n=e.getSize(mie);this.setSize(n.width,n.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Cu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const hB=(i,...e)=>Ct(new gie(Ct(i),...e)),vie=(i,...e)=>i.isTextureNode?i:i.isPassNode?i.getTextureNode():hB(i,...e),VA=Xe(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===Su?(i=Ft(i.x,i.y.oneMinus()).mul(2).sub(1),r=Mn(Le(i,e),1)):r=Mn(Le(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const s=Mn(t.mul(r));return s.xyz.div(s.w)}),_ie=Xe(([i,e])=>{const t=e.mul(Mn(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Ft(n.x,n.y.oneMinus())}),yie=Xe(([i,e,t])=>{const n=jh(Yr(e)),r=ws(i.mul(n)).toVar(),s=Yr(e,r).toVar(),a=Yr(e,r.sub(ws(2,0))).toVar(),l=Yr(e,r.sub(ws(1,0))).toVar(),u=Yr(e,r.add(ws(1,0))).toVar(),h=Yr(e,r.add(ws(2,0))).toVar(),m=Yr(e,r.add(ws(0,2))).toVar(),v=Yr(e,r.add(ws(0,1))).toVar(),x=Yr(e,r.sub(ws(0,1))).toVar(),S=Yr(e,r.sub(ws(0,2))).toVar(),w=dr(Ei(ve(2).mul(l).sub(a),s)).toVar(),N=dr(Ei(ve(2).mul(u).sub(h),s)).toVar(),C=dr(Ei(ve(2).mul(v).sub(m),s)).toVar(),E=dr(Ei(ve(2).mul(x).sub(S),s)).toVar(),O=VA(i,s,t).toVar(),U=w.lessThan(N).select(O.sub(VA(i.sub(Ft(ve(1).div(n.x),0)),l,t)),O.negate().add(VA(i.add(Ft(ve(1).div(n.x),0)),u,t))),I=C.lessThan(E).select(O.sub(VA(i.add(Ft(0,ve(1).div(n.y))),v,t)),O.negate().add(VA(i.sub(Ft(0,ve(1).div(n.y))),x,t)));return Wc(ky(U,I))});class t_ extends kg{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class xie extends Lr{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}class bie extends xd{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}const Sie=vt(bie);class Tie extends oE{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t=FP(e.itemSize),n=e.count),super(e,t,n),this.isStorageBufferNode=!0,this.access=da.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Sie(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(da.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Yg(this.value),this._varying=co(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}generate(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const Qy=(i,e=null,t=0)=>Ct(new Tie(i,e,t)),wie=(i,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Qy(i,e,t).setPBO(!0)),Mie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new xie(i,t,n);return Qy(r,e,i)},Eie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new t_(i,t,n);return Qy(r,e,i)};class Cie extends w9{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new qn(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const Nie=i=>Ct(new Cie(i));class Rie extends Un{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Die=Jt(Rie),dm=new ma,aS=new Xn;class to extends Un{static get type(){return"SceneNode"}constructor(e=to.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let r;return t===to.BACKGROUND_BLURRINESS?r=$i("backgroundBlurriness","float",n):t===to.BACKGROUND_INTENSITY?r=$i("backgroundIntensity","float",n):t===to.BACKGROUND_ROTATION?r=En("mat4").label("backgroundRotation").setGroup(In).onRenderUpdate(()=>{const s=n.background;return s!==null&&s.isTexture&&s.mapping!==Bw?(dm.copy(n.backgroundRotation),dm.x*=-1,dm.y*=-1,dm.z*=-1,aS.makeRotationFromEuler(dm)):aS.identity(),aS}):console.error("THREE.SceneNode: Unknown scope:",t),r}}to.BACKGROUND_BLURRINESS="backgroundBlurriness";to.BACKGROUND_INTENSITY="backgroundIntensity";to.BACKGROUND_ROTATION="backgroundRotation";const fB=Jt(to,to.BACKGROUND_BLURRINESS),nw=Jt(to,to.BACKGROUND_INTENSITY),dB=Jt(to,to.BACKGROUND_ROTATION);class Pie extends Cu{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=da.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(da.READ_WRITE)}toReadOnly(){return this.setAccess(da.READ_ONLY)}toWriteOnly(){return this.setAccess(da.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:r}=t,s=super.generate(e,"property"),a=n.build(e,"uvec2"),l=r.build(e,"vec4"),u=e.generateTextureStore(e,s,a,l);e.addLineFlowCode(u,this)}}const AB=vt(Pie),Lie=(i,e,t)=>{const n=AB(i,e,t);return t!==null&&n.append(),n};class Uie extends Hy{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Bie=(i,e,t)=>Ct(new Uie(i,e,t)),o6=new WeakMap;class Oie extends cs{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Zn.OBJECT,this.updateAfterType=Zn.OBJECT,this.previousModelWorldMatrix=En(new Xn),this.previousProjectionMatrix=En(new Xn).setGroup(In),this.previousCameraViewMatrix=En(new Xn)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=l6(n);this.previousModelWorldMatrix.value.copy(r);const s=pB(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new Xn,s.previousCameraViewMatrix=new Xn,s.currentProjectionMatrix=new Xn,s.currentCameraViewMatrix=new Xn,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){l6(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?bd:En(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(J0).mul(Zr),r=this.previousProjectionMatrix.mul(t).mul(ey),s=n.xy.div(n.w),a=r.xy.div(r.w);return Ei(s,a)}}function pB(i){let e=o6.get(i);return e===void 0&&(e={},o6.set(i,e)),e}function l6(i,e=0){const t=pB(i);let n=t[e];return n===void 0&&(t[e]=n=new Xn),n}const Iie=Jt(Oie),mB=Xe(([i,e])=>oo(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),gB=Xe(([i,e])=>oo(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vB=Xe(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_B=Xe(([i,e])=>zi(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Fy(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Fie=Xe(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return Mn(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kie=(...i)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),mB(i)),zie=(...i)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),gB(i)),Gie=(...i)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),vB(i)),qie=(...i)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),_B(i)),Vie=Xe(([i])=>EE(i.rgb)),jie=Xe(([i,e=ve(1)])=>e.mix(EE(i.rgb),i.rgb)),Hie=Xe(([i,e=ve(1)])=>{const t=ls(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),r=n.sub(t).mul(e).mul(-3);return zi(i.rgb,n,r)}),Wie=Xe(([i,e=ve(1)])=>{const t=Le(.57735,.57735,.57735),n=e.cos();return Le(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(ef(t,i.rgb).mul(n.oneMinus())))))}),EE=(i,e=Le(hi.getLuminanceCoefficients(new de)))=>ef(i,e),$ie=Xe(([i,e=Le(1),t=Le(0),n=Le(1),r=ve(1),s=Le(hi.getLuminanceCoefficients(new de,Io))])=>{const a=i.rgb.dot(Le(s)),l=Jr(i.rgb.mul(e).add(t),0).toVar(),u=l.pow(n).toVar();return si(l.r.greaterThan(0),()=>{l.r.assign(u.r)}),si(l.g.greaterThan(0),()=>{l.g.assign(u.g)}),si(l.b.greaterThan(0),()=>{l.b.assign(u.b)}),l.assign(a.add(l.sub(a).mul(r))),Mn(l.rgb,i.a)});class Xie extends cs{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const Yie=vt(Xie),Qie=new Et;class yB extends Cu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class u6 extends yB{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class Pu extends cs{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new Qc;s.isRenderTargetTexture=!0,s.name="depth";const a=new Zh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Qs,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=En(0),this._cameraFar=En(0),this._mrt=null,this.isPassNode=!0,this.updateBeforeType=Zn.FRAME}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=Ct(new u6(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=Ct(new u6(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=pE(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=l0(s,n,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.scope===Pu.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(Qie);this.setSize(s.width,s.height);const a=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const u in this._previousTextures)this.toggleTexture(u);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(a),t.setMRT(l)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Pu.COLOR="color";Pu.DEPTH="depth";const Kie=(i,e,t)=>Ct(new Pu(Pu.COLOR,i,e,t)),Zie=(i,e)=>Ct(new yB(i,e)),Jie=(i,e,t)=>Ct(new Pu(Pu.DEPTH,i,e,t));class ere extends Pu{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,s){super(Pu.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,l,u,h,m,v)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const x=this._getOutlineMaterial(u);t.renderObject(r,s,a,l,x,h,m,v)}t.renderObject(r,s,a,l,u,h,m,v)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new es;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=gr;const t=lo.negate(),n=bd.mul(J0),r=ve(1),s=n.mul(Mn(Zr,1)),a=n.mul(Mn(Zr.add(t),1)),l=Wc(s.sub(a));return e.vertexNode=s.add(l.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=Mn(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const tre=(i,e,t=new mn(0,0,0),n=.003,r=1)=>Ct(new ere(i,e,Ct(t),Ct(n),Ct(r))),xB=Xe(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bB=Xe(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SB=Xe(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),nre=Xe(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),TB=Xe(([i,e])=>{const t=_a(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=_a(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=nre(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ire=_a(Le(1.6605,-.1246,-.0182),Le(-.5876,1.1329,-.1006),Le(-.0728,-.0083,1.1187)),rre=_a(Le(.6274,.0691,.0164),Le(.3293,.9195,.088),Le(.0433,.0113,.8956)),sre=Xe(([i])=>{const e=Le(i).toVar(),t=Le(e.mul(e)).toVar(),n=Le(t.mul(t)).toVar();return ve(15.5).mul(n.mul(t)).sub(Jn(40.14,n.mul(e))).add(Jn(31.96,n).sub(Jn(6.868,t.mul(e))).add(Jn(.4298,t).add(Jn(.1191,e).sub(.00232))))}),wB=Xe(([i,e])=>{const t=Le(i).toVar(),n=_a(Le(.856627153315983,.137318972929847,.11189821299995),Le(.0951212405381588,.761241990602591,.0767994186031903),Le(.0482516061458583,.101439036467562,.811302368396859)),r=_a(Le(1.1271005818144368,-.1413297634984383,-.14132976349843826),Le(-.11060664309660323,1.157823702216272,-.11060664309660294),Le(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=ve(-12.47393),a=ve(4.026069);return t.mulAssign(e),t.assign(rre.mul(t)),t.assign(n.mul(t)),t.assign(Jr(t,1e-10)),t.assign(vu(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(Mu(t,0,1)),t.assign(sre(t)),t.assign(r.mul(t)),t.assign(Fl(Jr(Le(0),t),Le(2.2))),t.assign(ire.mul(t)),t.assign(Mu(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MB=Xe(([i,e])=>{const t=ve(.76),n=ve(.15);i=i.mul(e);const r=oo(i.r,oo(i.g,i.b)),s=Ys(r.lessThan(.08),r.sub(Jn(6.25,r.mul(r))),.04);i.subAssign(s);const a=Jr(i.r,Jr(i.g,i.b));si(a.lessThan(t),()=>i);const l=Ei(1,t),u=Ei(1,l.mul(l).div(a.add(l.sub(t))));i.mulAssign(u.div(a));const h=Ei(1,Gl(1,n.mul(a.sub(u)).add(1)));return zi(i,Le(u),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class ps extends Un{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.includes=t,this.language=n}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Ky=vt(ps),are=(i,e)=>Ky(i,e,"js"),ore=(i,e)=>Ky(i,e,"wgsl"),lre=(i,e)=>Ky(i,e,"glsl");class EB extends ps{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,s=n.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const l=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(l);return a.code=u+` -`,t==="property"?l:e.format(`${l}()`,s,t)}}const CB=(i,e=[],t="")=>{for(let s=0;sn.call(...s);return r.functionNode=n,r},ure=(i,e)=>CB(i,e,"glsl"),cre=(i,e)=>CB(i,e,"wgsl");class hre extends Un{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Xc,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ve()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=VP(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=jP(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const n_=vt(hre);class NB extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class fre{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const i_=new NB;class dre extends Un{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new NB,this._output=n_(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=n_(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=n_(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r.constructor.name==="AsyncFunction"?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(h,m)=>this.setOutput(h,m),n=new fre(this),r=i_.get("THREE"),s=i_.get("TSL"),a=this.getMethod(),l=[n,this._local,i_,e,t,r,s];this._object=a(...l);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const h of u.elements){const m=h.id||h.name;h.inputType&&(this.getParameter(m)===void 0&&this.setParameter(m,null),this.getParameter(m).inputType=h.inputType),h.outputType&&(this.getOutput(m)===void 0&&this.setOutput(m,null),this.getOutput(m).outputType=h.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ve()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),r="var "+n+`; var output = {}; -`,s=` -return { ...output, `+n+" };",a=r+this.codeNode.code+s;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[OP(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Ry(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Are=vt(dre);function RB(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||as.z).negate()}const CE=Xe(([i,e],t)=>{const n=RB(t);return $c(i,e,n)}),NE=Xe(([i],e)=>{const t=RB(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Pg=Xe(([i,e])=>Mn(e.toFloat().mix(Ng.rgb,i.toVec3()),Ng.a));function pre(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Pg(i,CE(e,t))}function mre(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Pg(i,NE(e))}let Pf=null,Lf=null;class gre extends Un{static get type(){return"RangeNode"}constructor(e=ve(),t=ve()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(zh(this.minNode.value)),n=e.getTypeLength(zh(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(zh(r)),l=e.getTypeLength(zh(s));Pf=Pf||new qn,Lf=Lf||new qn,Pf.setScalar(0),Lf.setScalar(0),a===1?Pf.setScalar(r):r.isColor?Pf.set(r.r,r.g,r.b,1):Pf.set(r.x,r.y,r.z||0,r.w||0),l===1?Lf.setScalar(s):s.isColor?Lf.set(s.r,s.g,s.b,1):Lf.set(s.x,s.y,s.z||0,s.w||0);const u=4,h=u*t.count,m=new Float32Array(h);for(let x=0;xCt(new _re(i,e)),yre=Zy("numWorkgroups","uvec3"),xre=Zy("workgroupId","uvec3"),bre=Zy("localId","uvec3"),Sre=Zy("subgroupSize","uint");class Tre extends Un{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier -`):e.addLineFlowCode(`${t}Barrier()`,this)}}const RE=vt(Tre),wre=()=>RE("workgroup").append(),Mre=()=>RE("storage").append(),Ere=()=>RE("texture").append();class Cre extends xd{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}class Nre extends Un{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Ct(new Cre(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const Rre=(i,e)=>Ct(new Nre("Workgroup",i,e));class zs extends cs{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,l=[];l.push(`&${s.build(e,r)}`),l.push(a.build(e,r));const u=`${e.getMethod(t,n)}( ${l.join(", ")} )`;if(this.storeNode!==null){const h=this.storeNode.build(e,r);e.addLineFlowCode(`${h} = ${u}`,this)}else e.addLineFlowCode(u,this)}}zs.ATOMIC_LOAD="atomicLoad";zs.ATOMIC_STORE="atomicStore";zs.ATOMIC_ADD="atomicAdd";zs.ATOMIC_SUB="atomicSub";zs.ATOMIC_MAX="atomicMax";zs.ATOMIC_MIN="atomicMin";zs.ATOMIC_AND="atomicAnd";zs.ATOMIC_OR="atomicOr";zs.ATOMIC_XOR="atomicXor";const Dre=vt(zs),Jc=(i,e,t,n=null)=>{const r=Dre(i,e,t,n);return r.append(),r},Pre=(i,e,t=null)=>Jc(zs.ATOMIC_STORE,i,e,t),Lre=(i,e,t=null)=>Jc(zs.ATOMIC_ADD,i,e,t),Ure=(i,e,t=null)=>Jc(zs.ATOMIC_SUB,i,e,t),Bre=(i,e,t=null)=>Jc(zs.ATOMIC_MAX,i,e,t),Ore=(i,e,t=null)=>Jc(zs.ATOMIC_MIN,i,e,t),Ire=(i,e,t=null)=>Jc(zs.ATOMIC_AND,i,e,t),Fre=(i,e,t=null)=>Jc(zs.ATOMIC_OR,i,e,t),kre=(i,e,t=null)=>Jc(zs.ATOMIC_XOR,i,e,t);let mv;function i1(i){mv=mv||new WeakMap;let e=mv.get(i);return e===void 0&&mv.set(i,e={}),e}function DE(i){const e=i1(i);return e.shadowMatrix||(e.shadowMatrix=En("mat4").setGroup(In).onRenderUpdate(()=>(i.castShadow!==!0&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function DB(i){const e=i1(i);if(e.projectionUV===void 0){const t=DE(i).mul(Fc);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function PE(i){const e=i1(i);return e.position||(e.position=En(new de).setGroup(In).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function PB(i){const e=i1(i);return e.targetPosition||(e.targetPosition=En(new de).setGroup(In).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function Jy(i){const e=i1(i);return e.viewPosition||(e.viewPosition=En(new de).setGroup(In).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new de,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const LE=i=>ho.transformDirection(PE(i).sub(PB(i))),zre=i=>i.sort((e,t)=>e.id-t.id),Gre=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},oS=new WeakMap;class UE extends Un{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Le().toVar("totalDiffuse"),this.totalSpecularNode=Le().toVar("totalSpecular"),this.outgoingLightNode=Le().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let n=0;n0}}const qre=(i=[])=>Ct(new UE).setLights(i);class Vre extends Un{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Zn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({material:e}){BE.assign(e.shadowPositionNode||Fc)}dispose(){this.updateBeforeType=Zn.NONE}}const BE=Le().toVar("shadowPositionWorld");function jre(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new mn),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function Hre(i,e){return e=jre(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function Wre(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function $re(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function Xre(i,e){return e=$re(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function Yre(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function Qre(i,e,t){return t=Hre(i,t),t=Xre(e,t),t}function Kre(i,e,t){Wre(i,t),Yre(e,t)}const c6=new WeakMap,Zre=Xe(([i,e,t])=>{let n=Fc.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),Jre=i=>{const e=i.shadow.camera,t=$i("near","float",e).setGroup(In),n=$i("far","float",e).setGroup(In),r=C9(i);return Zre(r,t,n)},ese=i=>{let e=c6.get(i);if(e===void 0){const t=i.isPointLight?Jre(i):null;e=new es,e.colorNode=Mn(0,0,0,1),e.depthNode=t,e.isShadowNodeMaterial=!0,e.name="ShadowMaterial",e.fog=!1,c6.set(i,e)}return e},LB=Xe(({depthTexture:i,shadowCoord:e})=>gi(i,e.xy).compare(e.z)),UB=Xe(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(N,C)=>gi(i,N).compare(C),r=$i("mapSize","vec2",t).setGroup(In),s=$i("radius","float",t).setGroup(In),a=Ft(1).div(r),l=a.x.negate().mul(s),u=a.y.negate().mul(s),h=a.x.mul(s),m=a.y.mul(s),v=l.div(2),x=u.div(2),S=h.div(2),w=m.div(2);return ls(n(e.xy.add(Ft(l,u)),e.z),n(e.xy.add(Ft(0,u)),e.z),n(e.xy.add(Ft(h,u)),e.z),n(e.xy.add(Ft(v,x)),e.z),n(e.xy.add(Ft(0,x)),e.z),n(e.xy.add(Ft(S,x)),e.z),n(e.xy.add(Ft(l,0)),e.z),n(e.xy.add(Ft(v,0)),e.z),n(e.xy,e.z),n(e.xy.add(Ft(S,0)),e.z),n(e.xy.add(Ft(h,0)),e.z),n(e.xy.add(Ft(v,w)),e.z),n(e.xy.add(Ft(0,w)),e.z),n(e.xy.add(Ft(S,w)),e.z),n(e.xy.add(Ft(l,m)),e.z),n(e.xy.add(Ft(0,m)),e.z),n(e.xy.add(Ft(h,m)),e.z)).mul(1/17)}),BB=Xe(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(m,v)=>gi(i,m).compare(v),r=$i("mapSize","vec2",t).setGroup(In),s=Ft(1).div(r),a=s.x,l=s.y,u=e.xy,h=Zc(u.mul(r).add(.5));return u.subAssign(h.mul(s)),ls(n(u,e.z),n(u.add(Ft(a,0)),e.z),n(u.add(Ft(0,l)),e.z),n(u.add(s),e.z),zi(n(u.add(Ft(a.negate(),0)),e.z),n(u.add(Ft(a.mul(2),0)),e.z),h.x),zi(n(u.add(Ft(a.negate(),l)),e.z),n(u.add(Ft(a.mul(2),l)),e.z),h.x),zi(n(u.add(Ft(0,l.negate())),e.z),n(u.add(Ft(0,l.mul(2))),e.z),h.y),zi(n(u.add(Ft(a,l.negate())),e.z),n(u.add(Ft(a,l.mul(2))),e.z),h.y),zi(zi(n(u.add(Ft(a.negate(),l.negate())),e.z),n(u.add(Ft(a.mul(2),l.negate())),e.z),h.x),zi(n(u.add(Ft(a.negate(),l.mul(2))),e.z),n(u.add(Ft(a.mul(2),l.mul(2))),e.z),h.x),h.y)).mul(1/9)}),OB=Xe(({depthTexture:i,shadowCoord:e})=>{const t=ve(1).toVar(),n=gi(i).sample(e.xy).rg,r=Fy(e.z,n.x);return si(r.notEqual(ve(1)),()=>{const s=e.z.sub(n.x),a=Jr(0,n.y.mul(n.y));let l=a.div(a.add(s.mul(s)));l=Mu(Ei(l,.3).div(.95-.3)),t.assign(Mu(Jr(r,l)))}),t}),tse=Xe(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=ve(0).toVar(),s=ve(0).toVar(),a=i.lessThanEqual(ve(1)).select(ve(0),ve(2).div(i.sub(1))),l=i.lessThanEqual(ve(1)).select(ve(0),ve(-1));Gi({start:we(0),end:we(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(ve(h).mul(a)),v=n.sample(ls(n1.xy,Ft(0,m).mul(e)).div(t)).x;r.addAssign(v),s.addAssign(v.mul(v))}),r.divAssign(i),s.divAssign(i);const u=Ou(s.sub(r.mul(r)));return Ft(r,u)}),nse=Xe(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=ve(0).toVar(),s=ve(0).toVar(),a=i.lessThanEqual(ve(1)).select(ve(0),ve(2).div(i.sub(1))),l=i.lessThanEqual(ve(1)).select(ve(0),ve(-1));Gi({start:we(0),end:we(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(ve(h).mul(a)),v=n.sample(ls(n1.xy,Ft(m,0).mul(e)).div(t));r.addAssign(v.x),s.addAssign(ls(v.y.mul(v.y),v.x.mul(v.x)))}),r.divAssign(i),s.divAssign(i);const u=Ou(s.sub(r.mul(r)));return Ft(r,u)}),ise=[LB,UB,BB,OB];let lS;const gv=new ME;class IB extends Vre{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s}){const a=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:n,shadowCoord:r,shadow:s});return a.select(l,ve(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,s=$i("bias","float",n).setGroup(In);let a=t,l;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),l=a.z,r.coordinateSystem===Su&&(l=l.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const h=$i("near","float",n.camera).setGroup(In),m=$i("far","float",n.camera).setGroup(In);l=mE(u.negate(),h,m)}return a=Le(a.x,a.y.oneMinus(),l.add(s)),a}getShadowFilterFn(e){return ise[e]}setupShadow(e){const{renderer:t}=e,{light:n,shadow:r}=this,s=t.shadowMap.type,a=new Qc(r.mapSize.width,r.mapSize.height);a.compareFunction=my;const l=e.createRenderTarget(r.mapSize.width,r.mapSize.height);if(l.depthTexture=a,r.camera.updateProjectionMatrix(),s===No){a.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:hd,type:Qs}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:hd,type:Qs});const E=gi(a),O=gi(this.vsmShadowMapVertical.texture),U=$i("blurSamples","float",r).setGroup(In),I=$i("radius","float",r).setGroup(In),j=$i("mapSize","vec2",r).setGroup(In);let z=this.vsmMaterialVertical||(this.vsmMaterialVertical=new es);z.fragmentNode=tse({samples:U,radius:I,size:j,shadowPass:E}).context(e.getSharedContext()),z.name="VSMVertical",z=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new es),z.fragmentNode=nse({samples:U,radius:I,size:j,shadowPass:O}).context(e.getSharedContext()),z.name="VSMHorizontal"}const u=$i("intensity","float",r).setGroup(In),h=$i("normalBias","float",r).setGroup(In),m=DE(n).mul(BE.add(jy.mul(h))),v=this.setupShadowCoord(e,m),x=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(x===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const S=s===No?this.vsmShadowMapHorizontal.texture:a,w=this.setupShadowFilter(e,{filterFn:x,shadowTexture:l.texture,depthTexture:S,shadowCoord:v,shadow:r}),N=gi(l.texture,v),C=zi(1,w.rgb.mix(N,1),u.mul(N.a)).toVar();return this.shadowMap=l,this.shadow.map=l,C}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Xe(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height),s.render(a,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:s,scene:a,camera:l}=e,u=s.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h,r.camera.layers.mask=l.layers.mask;const m=s.getRenderObjectFunction(),v=s.getMRT(),x=v?v.has("velocity"):!1;lS=Qre(s,a,lS),a.overrideMaterial=ese(n),s.setRenderObjectFunction((S,w,N,C,E,O,...U)=>{(S.castShadow===!0||S.receiveShadow&&u===No)&&(x&&(qP(S).useVelocity=!0),S.onBeforeShadow(s,S,l,r.camera,C,w.overrideMaterial,O),s.renderObject(S,w,N,C,E,O,...U),S.onAfterShadow(s,S,l,r.camera,C,w.overrideMaterial,O))}),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(m),n.isPointLight!==!0&&u===No&&this.vsmPass(s),Kre(s,a,lS)}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),gv.material=this.vsmMaterialVertical,gv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),gv.material=this.vsmMaterialHorizontal,gv.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const FB=(i,e)=>Ct(new IB(i,e));class Td extends ep{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new mn,this.colorNode=e&&e.colorNode||En(this.color).setGroup(In),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Zn.FRAME}customCacheKey(){return NM(this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return FB(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let s;r!==void 0?s=Ct(r):s=this.setupShadowNode(e),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const OE=Xe(i=>{const{lightDistance:e,cutoffDistance:t,decayExponent:n}=i,r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),rse=new mn,nu=Xe(([i,e])=>{const t=i.toVar(),n=dr(t),r=Gl(1,Jr(n.x,Jr(n.y,n.z)));n.mulAssign(r),t.mulAssign(r.mul(e.mul(2).oneMinus()));const s=Ft(t.xy).toVar(),l=e.mul(1.5).oneMinus();return si(n.z.greaterThanEqual(l),()=>{si(t.z.greaterThan(0),()=>{s.x.assign(Ei(4,t.x))})}).ElseIf(n.x.greaterThanEqual(l),()=>{const u=Rg(t.x);s.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(l),()=>{const u=Rg(t.y);s.x.assign(t.x.add(u.mul(2)).add(2)),s.y.assign(t.z.mul(u).sub(2))}),Ft(.125,.25).mul(s).add(Ft(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),sse=Xe(({depthTexture:i,bd3D:e,dp:t,texelSize:n})=>gi(i,nu(e,n.y)).compare(t)),ase=Xe(({depthTexture:i,bd3D:e,dp:t,texelSize:n,shadow:r})=>{const s=$i("radius","float",r).setGroup(In),a=Ft(-1,1).mul(s).mul(n.y);return gi(i,nu(e.add(a.xyy),n.y)).compare(t).add(gi(i,nu(e.add(a.yyy),n.y)).compare(t)).add(gi(i,nu(e.add(a.xyx),n.y)).compare(t)).add(gi(i,nu(e.add(a.yyx),n.y)).compare(t)).add(gi(i,nu(e,n.y)).compare(t)).add(gi(i,nu(e.add(a.xxy),n.y)).compare(t)).add(gi(i,nu(e.add(a.yxy),n.y)).compare(t)).add(gi(i,nu(e.add(a.xxx),n.y)).compare(t)).add(gi(i,nu(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),ose=Xe(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),s=r.length(),a=En("float").setGroup(In).onRenderUpdate(()=>n.camera.near),l=En("float").setGroup(In).onRenderUpdate(()=>n.camera.far),u=$i("bias","float",n).setGroup(In),h=En(n.mapSize).setGroup(In),m=ve(1).toVar();return si(s.sub(l).lessThanEqual(0).and(s.sub(a).greaterThanEqual(0)),()=>{const v=s.sub(a).div(l.sub(a)).toVar();v.addAssign(u);const x=r.normalize(),S=Ft(1).div(h.mul(Ft(4,2)));m.assign(i({depthTexture:e,bd3D:x,dp:v,texelSize:S,shadow:n}))}),m}),h6=new qn,LA=new Et,Am=new Et;class lse extends IB{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===kF?sse:ase}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a}){return ose({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e,l=t.getFrameExtents();Am.copy(t.mapSize),Am.multiply(l),n.setSize(Am.width,Am.height),LA.copy(t.mapSize);const u=s.autoClear,h=s.getClearColor(rse),m=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha),s.clear();const v=t.getViewportCount();for(let x=0;xCt(new lse(i,e)),kB=Xe(({color:i,lightViewPosition:e,cutoffDistance:t,decayExponent:n},r)=>{const s=r.context.lightingModel,a=e.sub(as),l=a.normalize(),u=a.length(),h=OE({lightDistance:u,cutoffDistance:t,decayExponent:n}),m=i.mul(h),v=r.context.reflectedLight;s.direct({lightDirection:l,lightColor:m,reflectedLight:v},r.stack,r)});class cse extends Td{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=En(0).setGroup(In),this.decayExponentNode=En(2).setGroup(In)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return use(this.light)}setup(e){super.setup(e),kB({color:this.colorNode,lightViewPosition:Jy(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const hse=Xe(([i=Br()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),qm=Xe(([i,e,t])=>{const n=ve(t).toVar(),r=ve(e).toVar(),s=Hc(i).toVar();return Ys(s,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ry=Xe(([i,e])=>{const t=Hc(e).toVar(),n=ve(i).toVar();return Ys(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),os=Xe(([i])=>{const e=ve(i).toVar();return we(_u(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),wr=Xe(([i,e])=>{const t=ve(i).toVar();return e.assign(os(t)),t.sub(ve(e))}),fse=Xe(([i,e,t,n,r,s])=>{const a=ve(s).toVar(),l=ve(r).toVar(),u=ve(n).toVar(),h=ve(t).toVar(),m=ve(e).toVar(),v=ve(i).toVar(),x=ve(Ei(1,l)).toVar();return Ei(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),dse=Xe(([i,e,t,n,r,s])=>{const a=ve(s).toVar(),l=ve(r).toVar(),u=Le(n).toVar(),h=Le(t).toVar(),m=Le(e).toVar(),v=Le(i).toVar(),x=ve(Ei(1,l)).toVar();return Ei(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),zB=Zs([fse,dse]),Ase=Xe(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=ve(m).toVar(),x=ve(h).toVar(),S=ve(u).toVar(),w=ve(l).toVar(),N=ve(a).toVar(),C=ve(s).toVar(),E=ve(r).toVar(),O=ve(n).toVar(),U=ve(t).toVar(),I=ve(e).toVar(),j=ve(i).toVar(),z=ve(Ei(1,S)).toVar(),G=ve(Ei(1,x)).toVar();return ve(Ei(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(w.mul(S))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),pse=Xe(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=ve(m).toVar(),x=ve(h).toVar(),S=ve(u).toVar(),w=Le(l).toVar(),N=Le(a).toVar(),C=Le(s).toVar(),E=Le(r).toVar(),O=Le(n).toVar(),U=Le(t).toVar(),I=Le(e).toVar(),j=Le(i).toVar(),z=ve(Ei(1,S)).toVar(),G=ve(Ei(1,x)).toVar();return ve(Ei(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(w.mul(S))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),GB=Zs([Ase,pse]),mse=Xe(([i,e,t])=>{const n=ve(t).toVar(),r=ve(e).toVar(),s=an(i).toVar(),a=an(s.bitAnd(an(7))).toVar(),l=ve(qm(a.lessThan(an(4)),r,n)).toVar(),u=ve(Jn(2,qm(a.lessThan(an(4)),n,r))).toVar();return ry(l,Hc(a.bitAnd(an(1)))).add(ry(u,Hc(a.bitAnd(an(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),gse=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=ve(e).toVar(),l=an(i).toVar(),u=an(l.bitAnd(an(15))).toVar(),h=ve(qm(u.lessThan(an(8)),a,s)).toVar(),m=ve(qm(u.lessThan(an(4)),s,qm(u.equal(an(12)).or(u.equal(an(14))),a,r))).toVar();return ry(h,Hc(u.bitAnd(an(1)))).add(ry(m,Hc(u.bitAnd(an(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Fs=Zs([mse,gse]),vse=Xe(([i,e,t])=>{const n=ve(t).toVar(),r=ve(e).toVar(),s=Z0(i).toVar();return Le(Fs(s.x,r,n),Fs(s.y,r,n),Fs(s.z,r,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),_se=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=ve(e).toVar(),l=Z0(i).toVar();return Le(Fs(l.x,a,s,r),Fs(l.y,a,s,r),Fs(l.z,a,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Jo=Zs([vse,_se]),yse=Xe(([i])=>{const e=ve(i).toVar();return Jn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),xse=Xe(([i])=>{const e=ve(i).toVar();return Jn(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bse=Xe(([i])=>{const e=Le(i).toVar();return Jn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),qB=Zs([yse,bse]),Sse=Xe(([i])=>{const e=Le(i).toVar();return Jn(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),VB=Zs([xse,Sse]),Po=Xe(([i,e])=>{const t=we(e).toVar(),n=an(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(we(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),jB=Xe(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(Po(t,we(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Po(i,we(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Po(e,we(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(Po(t,we(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Po(i,we(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Po(e,we(4))),e.addAssign(i)}),r1=Xe(([i,e,t])=>{const n=an(t).toVar(),r=an(e).toVar(),s=an(i).toVar();return n.bitXorAssign(r),n.subAssign(Po(r,we(14))),s.bitXorAssign(n),s.subAssign(Po(n,we(11))),r.bitXorAssign(s),r.subAssign(Po(s,we(25))),n.bitXorAssign(r),n.subAssign(Po(r,we(16))),s.bitXorAssign(n),s.subAssign(Po(n,we(4))),r.bitXorAssign(s),r.subAssign(Po(s,we(14))),n.bitXorAssign(r),n.subAssign(Po(r,we(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),pa=Xe(([i])=>{const e=an(i).toVar();return ve(e).div(ve(an(we(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),yu=Xe(([i])=>{const e=ve(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),Tse=Xe(([i])=>{const e=we(i).toVar(),t=an(an(1)).toVar(),n=an(an(we(3735928559)).add(t.shiftLeft(an(2))).add(an(13))).toVar();return r1(n.add(an(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),wse=Xe(([i,e])=>{const t=we(e).toVar(),n=we(i).toVar(),r=an(an(2)).toVar(),s=an().toVar(),a=an().toVar(),l=an().toVar();return s.assign(a.assign(l.assign(an(we(3735928559)).add(r.shiftLeft(an(2))).add(an(13))))),s.addAssign(an(n)),a.addAssign(an(t)),r1(s,a,l)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Mse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=we(e).toVar(),s=we(i).toVar(),a=an(an(3)).toVar(),l=an().toVar(),u=an().toVar(),h=an().toVar();return l.assign(u.assign(h.assign(an(we(3735928559)).add(a.shiftLeft(an(2))).add(an(13))))),l.addAssign(an(s)),u.addAssign(an(r)),h.addAssign(an(n)),r1(l,u,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Ese=Xe(([i,e,t,n])=>{const r=we(n).toVar(),s=we(t).toVar(),a=we(e).toVar(),l=we(i).toVar(),u=an(an(4)).toVar(),h=an().toVar(),m=an().toVar(),v=an().toVar();return h.assign(m.assign(v.assign(an(we(3735928559)).add(u.shiftLeft(an(2))).add(an(13))))),h.addAssign(an(l)),m.addAssign(an(a)),v.addAssign(an(s)),jB(h,m,v),h.addAssign(an(r)),r1(h,m,v)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Cse=Xe(([i,e,t,n,r])=>{const s=we(r).toVar(),a=we(n).toVar(),l=we(t).toVar(),u=we(e).toVar(),h=we(i).toVar(),m=an(an(5)).toVar(),v=an().toVar(),x=an().toVar(),S=an().toVar();return v.assign(x.assign(S.assign(an(we(3735928559)).add(m.shiftLeft(an(2))).add(an(13))))),v.addAssign(an(h)),x.addAssign(an(u)),S.addAssign(an(l)),jB(v,x,S),v.addAssign(an(a)),x.addAssign(an(s)),r1(v,x,S)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Xi=Zs([Tse,wse,Mse,Ese,Cse]),Nse=Xe(([i,e])=>{const t=we(e).toVar(),n=we(i).toVar(),r=an(Xi(n,t)).toVar(),s=Z0().toVar();return s.x.assign(r.bitAnd(we(255))),s.y.assign(r.shiftRight(we(8)).bitAnd(we(255))),s.z.assign(r.shiftRight(we(16)).bitAnd(we(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Rse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=we(e).toVar(),s=we(i).toVar(),a=an(Xi(s,r,n)).toVar(),l=Z0().toVar();return l.x.assign(a.bitAnd(we(255))),l.y.assign(a.shiftRight(we(8)).bitAnd(we(255))),l.z.assign(a.shiftRight(we(16)).bitAnd(we(255))),l}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),el=Zs([Nse,Rse]),Dse=Xe(([i])=>{const e=Ft(i).toVar(),t=we().toVar(),n=we().toVar(),r=ve(wr(e.x,t)).toVar(),s=ve(wr(e.y,n)).toVar(),a=ve(yu(r)).toVar(),l=ve(yu(s)).toVar(),u=ve(zB(Fs(Xi(t,n),r,s),Fs(Xi(t.add(we(1)),n),r.sub(1),s),Fs(Xi(t,n.add(we(1))),r,s.sub(1)),Fs(Xi(t.add(we(1)),n.add(we(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Pse=Xe(([i])=>{const e=Le(i).toVar(),t=we().toVar(),n=we().toVar(),r=we().toVar(),s=ve(wr(e.x,t)).toVar(),a=ve(wr(e.y,n)).toVar(),l=ve(wr(e.z,r)).toVar(),u=ve(yu(s)).toVar(),h=ve(yu(a)).toVar(),m=ve(yu(l)).toVar(),v=ve(GB(Fs(Xi(t,n,r),s,a,l),Fs(Xi(t.add(we(1)),n,r),s.sub(1),a,l),Fs(Xi(t,n.add(we(1)),r),s,a.sub(1),l),Fs(Xi(t.add(we(1)),n.add(we(1)),r),s.sub(1),a.sub(1),l),Fs(Xi(t,n,r.add(we(1))),s,a,l.sub(1)),Fs(Xi(t.add(we(1)),n,r.add(we(1))),s.sub(1),a,l.sub(1)),Fs(Xi(t,n.add(we(1)),r.add(we(1))),s,a.sub(1),l.sub(1)),Fs(Xi(t.add(we(1)),n.add(we(1)),r.add(we(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),IE=Zs([Dse,Pse]),Lse=Xe(([i])=>{const e=Ft(i).toVar(),t=we().toVar(),n=we().toVar(),r=ve(wr(e.x,t)).toVar(),s=ve(wr(e.y,n)).toVar(),a=ve(yu(r)).toVar(),l=ve(yu(s)).toVar(),u=Le(zB(Jo(el(t,n),r,s),Jo(el(t.add(we(1)),n),r.sub(1),s),Jo(el(t,n.add(we(1))),r,s.sub(1)),Jo(el(t.add(we(1)),n.add(we(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Use=Xe(([i])=>{const e=Le(i).toVar(),t=we().toVar(),n=we().toVar(),r=we().toVar(),s=ve(wr(e.x,t)).toVar(),a=ve(wr(e.y,n)).toVar(),l=ve(wr(e.z,r)).toVar(),u=ve(yu(s)).toVar(),h=ve(yu(a)).toVar(),m=ve(yu(l)).toVar(),v=Le(GB(Jo(el(t,n,r),s,a,l),Jo(el(t.add(we(1)),n,r),s.sub(1),a,l),Jo(el(t,n.add(we(1)),r),s,a.sub(1),l),Jo(el(t.add(we(1)),n.add(we(1)),r),s.sub(1),a.sub(1),l),Jo(el(t,n,r.add(we(1))),s,a,l.sub(1)),Jo(el(t.add(we(1)),n,r.add(we(1))),s.sub(1),a,l.sub(1)),Jo(el(t,n.add(we(1)),r.add(we(1))),s,a.sub(1),l.sub(1)),Jo(el(t.add(we(1)),n.add(we(1)),r.add(we(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),FE=Zs([Lse,Use]),Bse=Xe(([i])=>{const e=ve(i).toVar(),t=we(os(e)).toVar();return pa(Xi(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Ose=Xe(([i])=>{const e=Ft(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar();return pa(Xi(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Ise=Xe(([i])=>{const e=Le(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar(),r=we(os(e.z)).toVar();return pa(Xi(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Fse=Xe(([i])=>{const e=Mn(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar(),r=we(os(e.z)).toVar(),s=we(os(e.w)).toVar();return pa(Xi(t,n,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),kse=Zs([Bse,Ose,Ise,Fse]),zse=Xe(([i])=>{const e=ve(i).toVar(),t=we(os(e)).toVar();return Le(pa(Xi(t,we(0))),pa(Xi(t,we(1))),pa(Xi(t,we(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Gse=Xe(([i])=>{const e=Ft(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar();return Le(pa(Xi(t,n,we(0))),pa(Xi(t,n,we(1))),pa(Xi(t,n,we(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),qse=Xe(([i])=>{const e=Le(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar(),r=we(os(e.z)).toVar();return Le(pa(Xi(t,n,r,we(0))),pa(Xi(t,n,r,we(1))),pa(Xi(t,n,r,we(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Vse=Xe(([i])=>{const e=Mn(i).toVar(),t=we(os(e.x)).toVar(),n=we(os(e.y)).toVar(),r=we(os(e.z)).toVar(),s=we(os(e.w)).toVar();return Le(pa(Xi(t,n,r,s,we(0))),pa(Xi(t,n,r,s,we(1))),pa(Xi(t,n,r,s,we(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),HB=Zs([zse,Gse,qse,Vse]),sy=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=we(e).toVar(),l=Le(i).toVar(),u=ve(0).toVar(),h=ve(1).toVar();return Gi(a,()=>{u.addAssign(h.mul(IE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),WB=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=we(e).toVar(),l=Le(i).toVar(),u=Le(0).toVar(),h=ve(1).toVar();return Gi(a,()=>{u.addAssign(h.mul(FE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),jse=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=we(e).toVar(),l=Le(i).toVar();return Ft(sy(l,a,s,r),sy(l.add(Le(we(19),we(193),we(17))),a,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Hse=Xe(([i,e,t,n])=>{const r=ve(n).toVar(),s=ve(t).toVar(),a=we(e).toVar(),l=Le(i).toVar(),u=Le(WB(l,a,s,r)).toVar(),h=ve(sy(l.add(Le(we(19),we(193),we(17))),a,s,r)).toVar();return Mn(u,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Wse=Xe(([i,e,t,n,r,s,a])=>{const l=we(a).toVar(),u=ve(s).toVar(),h=we(r).toVar(),m=we(n).toVar(),v=we(t).toVar(),x=we(e).toVar(),S=Ft(i).toVar(),w=Le(HB(Ft(x.add(m),v.add(h)))).toVar(),N=Ft(w.x,w.y).toVar();N.subAssign(.5),N.mulAssign(u),N.addAssign(.5);const C=Ft(Ft(ve(x),ve(v)).add(N)).toVar(),E=Ft(C.sub(S)).toVar();return si(l.equal(we(2)),()=>dr(E.x).add(dr(E.y))),si(l.equal(we(3)),()=>Jr(dr(E.x),dr(E.y))),ef(E,E)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$se=Xe(([i,e,t,n,r,s,a,l,u])=>{const h=we(u).toVar(),m=ve(l).toVar(),v=we(a).toVar(),x=we(s).toVar(),S=we(r).toVar(),w=we(n).toVar(),N=we(t).toVar(),C=we(e).toVar(),E=Le(i).toVar(),O=Le(HB(Le(C.add(S),N.add(x),w.add(v)))).toVar();O.subAssign(.5),O.mulAssign(m),O.addAssign(.5);const U=Le(Le(ve(C),ve(N),ve(w)).add(O)).toVar(),I=Le(U.sub(E)).toVar();return si(h.equal(we(2)),()=>dr(I.x).add(dr(I.y)).add(dr(I.z))),si(h.equal(we(3)),()=>Jr(Jr(dr(I.x),dr(I.y)),dr(I.z))),ef(I,I)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),tp=Zs([Wse,$se]),Xse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Ft(i).toVar(),a=we().toVar(),l=we().toVar(),u=Ft(wr(s.x,a),wr(s.y,l)).toVar(),h=ve(1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:m})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:v})=>{const x=ve(tp(u,m,v,a,l,r,n)).toVar();h.assign(oo(h,x))})}),si(n.equal(we(0)),()=>{h.assign(Ou(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Yse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Ft(i).toVar(),a=we().toVar(),l=we().toVar(),u=Ft(wr(s.x,a),wr(s.y,l)).toVar(),h=Ft(1e6,1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:m})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:v})=>{const x=ve(tp(u,m,v,a,l,r,n)).toVar();si(x.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.y.assign(x)})})}),si(n.equal(we(0)),()=>{h.assign(Ou(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Qse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Ft(i).toVar(),a=we().toVar(),l=we().toVar(),u=Ft(wr(s.x,a),wr(s.y,l)).toVar(),h=Le(1e6,1e6,1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:m})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:v})=>{const x=ve(tp(u,m,v,a,l,r,n)).toVar();si(x.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(x)}).ElseIf(x.lessThan(h.z),()=>{h.z.assign(x)})})}),si(n.equal(we(0)),()=>{h.assign(Ou(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Kse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Le(i).toVar(),a=we().toVar(),l=we().toVar(),u=we().toVar(),h=Le(wr(s.x,a),wr(s.y,l),wr(s.z,u)).toVar(),m=ve(1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:v})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:x})=>{Gi({start:-1,end:we(1),name:"z",condition:"<="},({z:S})=>{const w=ve(tp(h,v,x,S,a,l,u,r,n)).toVar();m.assign(oo(m,w))})})}),si(n.equal(we(0)),()=>{m.assign(Ou(m))}),m}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Zse=Zs([Xse,Kse]),Jse=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Le(i).toVar(),a=we().toVar(),l=we().toVar(),u=we().toVar(),h=Le(wr(s.x,a),wr(s.y,l),wr(s.z,u)).toVar(),m=Ft(1e6,1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:v})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:x})=>{Gi({start:-1,end:we(1),name:"z",condition:"<="},({z:S})=>{const w=ve(tp(h,v,x,S,a,l,u,r,n)).toVar();si(w.lessThan(m.x),()=>{m.y.assign(m.x),m.x.assign(w)}).ElseIf(w.lessThan(m.y),()=>{m.y.assign(w)})})})}),si(n.equal(we(0)),()=>{m.assign(Ou(m))}),m}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),eae=Zs([Yse,Jse]),tae=Xe(([i,e,t])=>{const n=we(t).toVar(),r=ve(e).toVar(),s=Le(i).toVar(),a=we().toVar(),l=we().toVar(),u=we().toVar(),h=Le(wr(s.x,a),wr(s.y,l),wr(s.z,u)).toVar(),m=Le(1e6,1e6,1e6).toVar();return Gi({start:-1,end:we(1),name:"x",condition:"<="},({x:v})=>{Gi({start:-1,end:we(1),name:"y",condition:"<="},({y:x})=>{Gi({start:-1,end:we(1),name:"z",condition:"<="},({z:S})=>{const w=ve(tp(h,v,x,S,a,l,u,r,n)).toVar();si(w.lessThan(m.x),()=>{m.z.assign(m.y),m.y.assign(m.x),m.x.assign(w)}).ElseIf(w.lessThan(m.y),()=>{m.z.assign(m.y),m.y.assign(w)}).ElseIf(w.lessThan(m.z),()=>{m.z.assign(w)})})})}),si(n.equal(we(0)),()=>{m.assign(Ou(m))}),m}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nae=Zs([Qse,tae]),iae=Xe(([i])=>{const e=i.y,t=i.z,n=Le().toVar();return si(e.lessThan(1e-4),()=>{n.assign(Le(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(_u(r)).mul(6).toVar();const s=we(ZM(r)),a=r.sub(ve(s)),l=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),h=t.mul(e.mul(a.oneMinus()).oneMinus());si(s.equal(we(0)),()=>{n.assign(Le(t,h,l))}).ElseIf(s.equal(we(1)),()=>{n.assign(Le(u,t,l))}).ElseIf(s.equal(we(2)),()=>{n.assign(Le(l,t,h))}).ElseIf(s.equal(we(3)),()=>{n.assign(Le(l,u,t))}).ElseIf(s.equal(we(4)),()=>{n.assign(Le(h,l,t))}).Else(()=>{n.assign(Le(t,l,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),rae=Xe(([i])=>{const e=Le(i).toVar(),t=ve(e.x).toVar(),n=ve(e.y).toVar(),r=ve(e.z).toVar(),s=ve(oo(t,oo(n,r))).toVar(),a=ve(Jr(t,Jr(n,r))).toVar(),l=ve(a.sub(s)).toVar(),u=ve().toVar(),h=ve().toVar(),m=ve().toVar();return m.assign(a),si(a.greaterThan(0),()=>{h.assign(l.div(a))}).Else(()=>{h.assign(0)}),si(h.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{si(t.greaterThanEqual(a),()=>{u.assign(n.sub(r).div(l))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(ls(2,r.sub(t).div(l)))}).Else(()=>{u.assign(ls(4,t.sub(n).div(l)))}),u.mulAssign(1/6),si(u.lessThan(0),()=>{u.addAssign(1)})}),Le(u,h,m)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),sae=Xe(([i])=>{const e=Le(i).toVar(),t=BM(HM(e,Le(.04045))).toVar(),n=Le(e.div(12.92)).toVar(),r=Le(Fl(Jr(e.add(Le(.055)),Le(0)).div(1.055),Le(2.4))).toVar();return zi(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),$B=(i,e)=>{i=ve(i),e=ve(e);const t=Ft(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return $c(i.sub(t),i.add(t),e)},XB=(i,e,t,n)=>zi(i,e,t[n].clamp()),aae=(i,e,t=Br())=>XB(i,e,t,"x"),oae=(i,e,t=Br())=>XB(i,e,t,"y"),YB=(i,e,t,n,r)=>zi(i,e,$B(t,n[r])),lae=(i,e,t,n=Br())=>YB(i,e,t,n,"x"),uae=(i,e,t,n=Br())=>YB(i,e,t,n,"y"),cae=(i=1,e=0,t=Br())=>t.mul(i).add(e),hae=(i,e=1)=>(i=ve(i),i.abs().pow(e).mul(i.sign())),fae=(i,e=1,t=.5)=>ve(i).sub(t).mul(e).add(t),dae=(i=Br(),e=1,t=0)=>IE(i.convert("vec2|vec3")).mul(e).add(t),Aae=(i=Br(),e=1,t=0)=>FE(i.convert("vec2|vec3")).mul(e).add(t),pae=(i=Br(),e=1,t=0)=>(i=i.convert("vec2|vec3"),Mn(FE(i),IE(i.add(Ft(19,73)))).mul(e).add(t)),mae=(i=Br(),e=1)=>Zse(i.convert("vec2|vec3"),e,we(1)),gae=(i=Br(),e=1)=>eae(i.convert("vec2|vec3"),e,we(1)),vae=(i=Br(),e=1)=>nae(i.convert("vec2|vec3"),e,we(1)),_ae=(i=Br())=>kse(i.convert("vec2|vec3")),yae=(i=Br(),e=3,t=2,n=.5,r=1)=>sy(i,we(e),t,n).mul(r),xae=(i=Br(),e=3,t=2,n=.5,r=1)=>jse(i,we(e),t,n).mul(r),bae=(i=Br(),e=3,t=2,n=.5,r=1)=>WB(i,we(e),t,n).mul(r),Sae=(i=Br(),e=3,t=2,n=.5,r=1)=>Hse(i,we(e),t,n).mul(r),Tae=Xe(([i,e,t])=>{const n=Wc(i).toVar("nDir"),r=Ei(ve(.5).mul(e.sub(t)),Fc).div(n).toVar("rbmax"),s=Ei(ve(-.5).mul(e.sub(t)),Fc).div(n).toVar("rbmin"),a=Le().toVar("rbminmax");a.x=n.x.greaterThan(ve(0)).select(r.x,s.x),a.y=n.y.greaterThan(ve(0)).select(r.y,s.y),a.z=n.z.greaterThan(ve(0)).select(r.z,s.z);const l=oo(oo(a.x,a.y),a.z).toVar("correction");return Fc.add(n.mul(l)).toVar("boxIntersection").sub(t)}),QB=Xe(([i,e])=>{const t=i.x,n=i.y,r=i.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(Jn(t,t).sub(Jn(n,n)))),s});var $=Object.freeze({__proto__:null,BRDF_GGX:QT,BRDF_Lambert:md,BasicShadowFilter:LB,Break:NU,Continue:Mee,DFGApprox:xE,D_GGX:jU,Discard:S9,EPSILON:NL,F_Schlick:G0,Fn:Xe,INFINITY:gJ,If:si,Loop:Gi,NodeAccess:da,NodeShaderStage:kT,NodeType:$Z,NodeUpdateType:Zn,PCFShadowFilter:UB,PCFSoftShadowFilter:BB,PI:Z_,PI2:vJ,Return:LJ,Schlick_to_F0:WU,ScriptableNodeResources:i_,ShaderNode:Om,TBNViewMatrix:Zf,VSMShadowFilter:OB,V_GGX_SmithCorrelated:VU,abs:dr,acesFilmicToneMapping:TB,acos:BL,add:ls,addMethodChaining:gt,addNodeElement:BJ,agxToneMapping:wB,all:WM,alphaT:Y_,and:vL,anisotropy:Bh,anisotropyB:ad,anisotropyT:Im,any:RL,append:KP,arrayBuffer:fJ,asin:UL,assign:hL,atan:YM,atan2:t9,atomicAdd:Lre,atomicAnd:Ire,atomicFunc:Jc,atomicMax:Bre,atomicMin:Ore,atomicOr:Fre,atomicStore:Pre,atomicSub:Ure,atomicXor:kre,attenuationColor:qM,attenuationDistance:GM,attribute:Eu,attributeArray:Mie,backgroundBlurriness:fB,backgroundIntensity:nw,backgroundRotation:dB,batch:MU,billboarding:sie,bitAnd:bL,bitNot:SL,bitOr:TL,bitXor:wL,bitangentGeometry:aee,bitangentLocal:oee,bitangentView:G9,bitangentWorld:lee,bitcast:_J,blendBurn:mB,blendColor:Fie,blendDodge:gB,blendOverlay:_B,blendScreen:vB,blur:JU,bool:Hc,buffer:Kg,bufferAttribute:Yg,bumpMap:H9,burn:kie,bvec2:eL,bvec3:BM,bvec4:rL,bypass:_9,cache:km,call:fL,cameraFar:Fh,cameraNear:Ih,cameraNormalMatrix:GJ,cameraPosition:E9,cameraProjectionMatrix:bd,cameraProjectionMatrixInverse:kJ,cameraViewMatrix:ho,cameraWorldMatrix:zJ,cbrt:YL,cdl:$ie,ceil:Iy,checker:hse,cineonToneMapping:SB,clamp:Mu,clearcoat:X_,clearcoatRoughness:Eg,code:Ky,color:ZP,colorSpaceToWorking:rE,colorToDirection:tte,compute:v9,cond:n9,context:zy,convert:aL,convertColorSpace:TJ,convertToTexture:vie,cos:Cc,cross:ky,cubeTexture:z0,dFdx:QM,dFdy:KM,dashSize:Qv,defaultBuildStages:zT,defaultShaderStages:HP,defined:Sg,degrees:PL,deltaTime:uB,densityFog:mre,densityFogFactor:NE,depth:gE,depthPass:Jie,difference:HL,diffuseColor:Oi,directPointLight:kB,directionToColor:OU,dispersion:VM,distance:jL,div:Gl,dodge:zie,dot:ef,drawIndex:SU,dynamicBufferAttribute:g9,element:sL,emissive:jT,equal:dL,equals:qL,equirectUV:vE,exp:$M,exp2:k0,expression:Qh,faceDirection:Qg,faceForward:nE,faceforward:yJ,float:ve,floor:_u,fog:Pg,fract:Zc,frameGroup:uL,frameId:Yne,frontFacing:D9,fwidth:zL,gain:qne,gapSize:HT,getConstNodeType:QP,getCurrentStack:UM,getDirection:KU,getDistanceAttenuation:OE,getGeometryRoughness:qU,getNormalFromDepth:yie,getParallaxCorrectNormal:Tae,getRoughness:yE,getScreenPosition:_ie,getShIrradianceAt:QB,getTextureIndex:oB,getViewPosition:VA,glsl:lre,glslFn:ure,grayscale:Vie,greaterThan:HM,greaterThanEqual:gL,hash:Gne,highpModelNormalViewMatrix:ZJ,highpModelViewMatrix:KJ,hue:Wie,instance:xee,instanceIndex:t1,instancedArray:Eie,instancedBufferAttribute:J_,instancedDynamicBufferAttribute:WT,instancedMesh:wU,int:we,inverseSqrt:XM,inversesqrt:xJ,invocationLocalIndex:yee,invocationSubgroupIndex:_ee,ior:Fm,iridescence:By,iridescenceIOR:FM,iridescenceThickness:kM,ivec2:ws,ivec3:tL,ivec4:nL,js:are,label:r9,length:Ic,lengthSq:QL,lessThan:pL,lessThanEqual:mL,lightPosition:PE,lightProjectionUV:DB,lightShadowMatrix:DE,lightTargetDirection:LE,lightTargetPosition:PB,lightViewPosition:Jy,lightingContext:DU,lights:qre,linearDepth:ty,linearToneMapping:xB,localId:bre,log:Oy,log2:vu,logarithmicDepthToViewZ:zee,loop:Eee,luminance:EE,mat2:Ly,mat3:_a,mat4:sd,matcapUV:tB,materialAO:xU,materialAlphaTest:W9,materialAnisotropy:oU,materialAnisotropyVector:qA,materialAttenuationColor:pU,materialAttenuationDistance:AU,materialClearcoat:tU,materialClearcoatNormal:iU,materialClearcoatRoughness:nU,materialColor:$9,materialDispersion:yU,materialEmissive:Y9,materialIOR:dU,materialIridescence:lU,materialIridescenceIOR:uU,materialIridescenceThickness:cU,materialLightMap:cE,materialLineDashOffset:_U,materialLineDashSize:gU,materialLineGapSize:vU,materialLineScale:mU,materialLineWidth:mee,materialMetalness:J9,materialNormal:eU,materialOpacity:uE,materialPointWidth:gee,materialReference:Pc,materialReflectivity:Jv,materialRefractionRatio:U9,materialRotation:rU,materialRoughness:Z9,materialSheen:sU,materialSheenRoughness:aU,materialShininess:X9,materialSpecular:Q9,materialSpecularColor:K9,materialSpecularIntensity:YT,materialSpecularStrength:zm,materialThickness:fU,materialTransmission:hU,max:Jr,maxMipLevel:M9,mediumpModelViewMatrix:R9,metalness:Mg,min:oo,mix:zi,mixElement:JL,mod:JM,modInt:jM,modelDirection:WJ,modelNormalMatrix:N9,modelPosition:$J,modelScale:XJ,modelViewMatrix:J0,modelViewPosition:YJ,modelViewProjection:hE,modelWorldMatrix:nl,modelWorldMatrixInverse:QJ,morphReference:RU,mrt:lB,mul:Jn,mx_aastep:$B,mx_cell_noise_float:_ae,mx_contrast:fae,mx_fractal_noise_float:yae,mx_fractal_noise_vec2:xae,mx_fractal_noise_vec3:bae,mx_fractal_noise_vec4:Sae,mx_hsvtorgb:iae,mx_noise_float:dae,mx_noise_vec3:Aae,mx_noise_vec4:pae,mx_ramplr:aae,mx_ramptb:oae,mx_rgbtohsv:rae,mx_safepower:hae,mx_splitlr:lae,mx_splittb:uae,mx_srgb_texture_to_lin_rec709:sae,mx_transform_uv:cae,mx_worley_noise_float:mae,mx_worley_noise_vec2:gae,mx_worley_noise_vec3:vae,negate:OL,neutralToneMapping:MB,nodeArray:rd,nodeImmutable:Jt,nodeObject:Ct,nodeObjects:Hg,nodeProxy:vt,normalFlat:P9,normalGeometry:qy,normalLocal:lo,normalMap:XT,normalView:ll,normalWorld:Vy,normalize:Wc,not:yL,notEqual:AL,numWorkgroups:yre,objectDirection:qJ,objectGroup:IM,objectPosition:C9,objectScale:jJ,objectViewPosition:HJ,objectWorldMatrix:VJ,oneMinus:IL,or:_L,orthographicDepthToViewZ:kee,oscSawtooth:nie,oscSine:Jne,oscSquare:eie,oscTriangle:tie,output:Ng,outputStruct:kne,overlay:qie,overloadingFn:Zs,parabola:tw,parallaxDirection:V9,parallaxUV:cee,parameter:Ine,pass:Kie,passTexture:Zie,pcurve:Vne,perspectiveDepthToViewZ:pE,pmremTexture:bE,pointUV:Die,pointWidth:AJ,positionGeometry:Gy,positionLocal:Zr,positionPrevious:ey,positionView:as,positionViewDirection:yr,positionWorld:Fc,positionWorldDirection:sE,posterize:Yie,pow:Fl,pow2:eE,pow3:WL,pow4:$L,property:cL,radians:DL,rand:ZL,range:vre,rangeFog:pre,rangeFogFactor:CE,reciprocal:kL,reference:$i,referenceBuffer:$T,reflect:VL,reflectVector:I9,reflectView:B9,reflector:die,refract:tE,refractVector:F9,refractView:O9,reinhardToneMapping:bB,remainder:CL,remap:x9,remapClamp:b9,renderGroup:In,renderOutput:T9,rendererReference:A9,rotate:SE,rotateUV:iie,roughness:au,round:FL,rtt:hB,sRGBTransferEOTF:l9,sRGBTransferOETF:u9,sampler:FJ,saturate:KL,saturation:jie,screen:Gie,screenCoordinate:n1,screenSize:Dg,screenUV:Ru,scriptable:Are,scriptableValue:n_,select:Ys,setCurrentStack:Tg,shaderStages:GT,shadow:FB,shadowPositionWorld:BE,sharedUniformGroup:OM,sheen:Kf,sheenRoughness:Uy,shiftLeft:ML,shiftRight:EL,shininess:Q_,sign:Rg,sin:Uo,sinc:jne,skinning:Tee,skinningReference:CU,smoothstep:$c,smoothstepElement:e9,specularColor:Ha,specularF90:Cg,spherizeUV:rie,split:dJ,spritesheetUV:lie,sqrt:Ou,stack:e_,step:Fy,storage:Qy,storageBarrier:Mre,storageObject:wie,storageTexture:AB,string:hJ,sub:Ei,subgroupIndex:vee,subgroupSize:Sre,tan:LL,tangentGeometry:Wy,tangentLocal:Zg,tangentView:Jg,tangentWorld:z9,temp:a9,texture:gi,texture3D:fne,textureBarrier:Ere,textureBicubic:YU,textureCubeUV:ZU,textureLoad:Yr,textureSize:jh,textureStore:Lie,thickness:zM,time:Sd,timerDelta:Zne,timerGlobal:Kne,timerLocal:Qne,toOutputColorSpace:c9,toWorkingColorSpace:h9,toneMapping:p9,toneMappingExposure:m9,toonOutlinePass:tre,transformDirection:XL,transformNormal:L9,transformNormalToView:aE,transformedBentNormalView:j9,transformedBitangentView:q9,transformedBitangentWorld:uee,transformedClearcoatNormalView:JA,transformedNormalView:Kr,transformedNormalWorld:jy,transformedTangentView:lE,transformedTangentWorld:see,transmission:K_,transpose:GL,triNoise3D:Wne,triplanarTexture:cie,triplanarTextures:cB,trunc:ZM,tslFn:cJ,uint:an,uniform:En,uniformArray:Dc,uniformGroup:lL,uniforms:nee,userData:Bie,uv:Br,uvec2:JP,uvec3:Z0,uvec4:iL,varying:co,varyingProperty:wg,vec2:Ft,vec3:Le,vec4:Mn,vectorComponents:yd,velocity:Iie,vertexColor:Nie,vertexIndex:bU,vertexStage:o9,vibrance:Hie,viewZToLogarithmicDepth:mE,viewZToOrthographicDepth:l0,viewZToPerspectiveDepth:UU,viewport:fE,viewportBottomLeft:Oee,viewportCoordinate:LU,viewportDepthTexture:AE,viewportLinearDepth:Gee,viewportMipTexture:dE,viewportResolution:Uee,viewportSafeUV:aie,viewportSharedTexture:ete,viewportSize:PU,viewportTexture:Iee,viewportTopLeft:Bee,viewportUV:Lee,wgsl:ore,wgslFn:cre,workgroupArray:Rre,workgroupBarrier:wre,workgroupId:xre,workingToColorSpace:f9,xor:xL});const Mc=new TE;class wae extends tf{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(s===null)r._clearColor.getRGB(Mc,Io),Mc.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(Mc,Io),Mc.a=1,a=!0;else if(s.isNode===!0){const l=this.get(e),u=s;Mc.copy(r._clearColor);let h=l.backgroundMesh;if(h===void 0){const v=zy(Mn(u).mul(nw),{getUV:()=>dB.mul(Vy),getTextureLevel:()=>fB});let x=hE;x=x.setZ(x.w);const S=new es;S.name="Background.material",S.side=gr,S.depthTest=!1,S.depthWrite=!1,S.fog=!1,S.lights=!1,S.vertexNode=x,S.colorNode=v,l.backgroundMeshNode=v,l.backgroundMesh=h=new qi(new Bu(1,32,32),S),h.frustumCulled=!1,h.name="Background.mesh",h.onBeforeRender=function(w,N,C){this.matrixWorld.copyPosition(C.matrixWorld)}}const m=u.getCacheKey();l.backgroundCacheKey!==m&&(l.backgroundMeshNode.node=Mn(u).mul(nw),l.backgroundMeshNode.needsUpdate=!0,h.material.needsUpdate=!0,l.backgroundCacheKey=m),t.unshift(h,h.geometry,h.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",s);if(r.autoClear===!0||a===!0){const l=n.clearColorValue;l.r=Mc.r,l.g=Mc.g,l.b=Mc.b,l.a=Mc.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(l.r*=l.a,l.g*=l.a,l.b*=l.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let Mae=0;class iw{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=Mae++}}class Eae{constructor(e,t,n,r,s,a,l,u,h,m=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=m,this.nodeAttributes=r,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=l,this.updateAfterNodes=u,this.monitor=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new iw(t.name,[],t.index,t);e.push(r);for(const s of t.bindings)r.bindings.push(s.clone())}else e.push(t);return e}}class f6{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class Cae{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class KB{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Nae extends KB{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Rae{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Dae=0;class uS{constructor(e=null){this.id=Dae++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Pae extends Un{static get type(){return"StructTypeNode"}constructor(e,t){super(),this.name=e,this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class wd{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class Lae extends wd{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Uae extends wd{constructor(e,t=new Et){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Bae extends wd{constructor(e,t=new de){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Oae extends wd{constructor(e,t=new qn){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Iae extends wd{constructor(e,t=new mn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Fae extends wd{constructor(e,t=new Qn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kae extends wd{constructor(e,t=new Xn){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class zae extends Lae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Gae extends Uae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qae extends Bae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vae extends Oae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jae extends Iae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Hae extends Fae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Wae extends kae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const e0=4,d6=[.125,.215,.35,.446,.526,.582],jf=20,cS=new Gg(-1,1,1,-1,0,1),$ae=new Ea(90,1),A6=new mn;let hS=null,fS=0,dS=0;const zf=(1+Math.sqrt(5))/2,UA=1/zf,p6=[new de(-zf,UA,0),new de(zf,UA,0),new de(-UA,0,zf),new de(UA,0,zf),new de(0,zf,-UA),new de(0,zf,UA),new de(-1,1,-1),new de(1,1,-1),new de(-1,1,1),new de(1,1,1)],Xae=[3,1,5,0,4,2],AS=KU(Br(),Eu("faceIndex")).normalize(),kE=Le(AS.x,AS.y,AS.z);class Yae{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,s=null){if(this._setSize(256),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const l=s||this._allocateTargets();return this.fromSceneAsync(e,t,n,r,l),l}hS=this._renderer.getRenderTarget(),fS=this._renderer.getActiveCubeFace(),dS=this._renderer.getActiveMipmapLevel();const a=s||this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,n,r,a),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}async fromSceneAsync(e,t=0,n=.1,r=100,s=null){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=g6(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=v6(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===sl||e.mapping===al?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?N:0,N,N),u.render(e,s)}u.autoClear=h,e.background=x}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===sl||e.mapping===al;r?this._cubemapMaterial===null&&(this._cubemapMaterial=g6(e)):this._equirectMaterial===null&&(this._equirectMaterial=v6(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const l=this._cubeSize;vv(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,cS)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sjf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${jf}`);const E=[];let O=0;for(let G=0;GU-e0?r-U+e0:0),z=4*(this._cubeSize-I);vv(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,cS)}}function Qae(i){const e=[],t=[],n=[],r=[];let s=i;const a=i-e0+1+d6.length;for(let l=0;li-e0?h=d6[l-i+e0-1]:l===0&&(h=0),n.push(h);const m=1/(u-2),v=-m,x=1+m,S=[v,v,x,v,x,x,v,v,x,x,v,x],w=6,N=6,C=3,E=2,O=1,U=new Float32Array(C*N*w),I=new Float32Array(E*N*w),j=new Float32Array(O*N*w);for(let G=0;G2?0:-1,V=[W,q,0,W+2/3,q,0,W+2/3,q+1,0,W,q,0,W+2/3,q+1,0,W,q+1,0],Y=Xae[G];U.set(V,C*N*Y),I.set(S,E*N*Y);const te=[Y,Y,Y,Y,Y,Y];j.set(te,O*N*Y)}const z=new Ji;z.setAttribute("position",new Lr(U,C)),z.setAttribute("uv",new Lr(I,E)),z.setAttribute("faceIndex",new Lr(j,O)),e.push(z),r.push(new qi(z,null)),s>e0&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:r}}function m6(i,e,t){const n=new Zh(i,e,t);return n.texture.mapping=ld,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function vv(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function zE(i){const e=new es;return e.depthTest=!1,e.depthWrite=!1,e.blending=no,e.name=`PMREM_${i}`,e}function Kae(i,e,t){const n=Dc(new Array(jf).fill(0)),r=En(new de(0,1,0)),s=En(0),a=ve(jf),l=En(0),u=En(1),h=gi(null),m=En(0),v=ve(1/e),x=ve(1/t),S=ve(i),w={n:a,latitudinal:l,weights:n,poleAxis:r,outputDirection:kE,dTheta:s,samples:u,envMap:h,mipInt:m,CUBEUV_TEXEL_WIDTH:v,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:S},N=zE("blur");return N.uniforms=w,N.fragmentNode=JU({...w,latitudinal:l.equal(1)}),N}function g6(i){const e=zE("cubemap");return e.fragmentNode=z0(i,kE),e}function v6(i){const e=zE("equirect");return e.fragmentNode=gi(i,vE(kE),0),e}const _6=new WeakMap,Zae=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),_v=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class ZB{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=e_(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new uS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=_6.get(this.renderer);return e===void 0&&(e=new Du,_6.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Zh(e,t,n)}createCubeRenderTarget(e,t){return new IU(e,t)}createPMREMGenerator(){return new Yae(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let s=!0;for(const l of t)r.push(l),s=s&&l.groupNode.shared!==!0;let a;return s?(a=n.get(r),a===void 0&&(a=new iw(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new iw(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of GT)for(const s in n[r]){const a=n[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${_v(t.r)}, ${_v(t.g)}, ${_v(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const s of n)if(s.name===e)return s;const r=new f6(e,t);return n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===ks)return"int";if(t===Ir)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const n=FP(e);return(t==="float"?"":t[0])+n}getTypeFromArray(e){return Zae.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof H7)&&s!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=e_(this.stack),this.stacks.push(UM()||this.stack),Tg(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Tg(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);return r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let r=n.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new f6("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e,n);let s=r.structType;if(s===void 0){const a=this.structs.index++;s=new Pae("StructType"+a,t),this.structs[n].push(s),r.structType=s}return s}getUniformFromNode(e,t,n=this.shaderStage,r=null){const s=this.getDataFromNode(e,n,this.globalCache);let a=s.uniform;if(a===void 0){const l=this.uniforms.index++;a=new Cae(r||"nodeUniform"+l,t,e),this.uniforms[n].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const l=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+l.length),a=new KB(t,n),l.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,l=a.length;t===null&&(t="nodeVarying"+l),s=new Nae(t,n),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[n]||(this.codes[n]=[]),l=a.length;s=new Rae("nodeCode"+l,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const l of n)this.addLineFlowCode(l)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; -`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){const t=new EB,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const l=Object.values(this);return{next:()=>({value:l[a],done:a++>=l.length})}}};for(const a of t.inputs)n[a.name]=new sB(a.type,a.name);e.layout=null;const r=e.call(n),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,s=this.cache,a=this.buildStage,l=this.stack,u={code:""};this.flow=u,this.vars={},this.cache=new uS,this.stack=e_();for(const h of zT)this.setBuildStage(h),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.cache=s,this.stack=l,this.setBuildStage(a),u}getFunctionOperator(){return null}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const s=this.shaderStage;this.setShaderStage(e);const a=this.flowChildNode(t,n);return r!==null&&(a.code+=`${this.tab+r} = ${a.result}; -`),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(s),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+` -`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new es),r.build(this)}else this.addFlow("compute",e);for(const r of zT){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of GT){this.setShaderStage(s);const a=this.flowNodes[s];for(const l of a)r==="generate"?this.flowNode(l):l.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new zae(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Gae(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new qae(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new Vae(e);if(t==="color")return new jae(e);if(t==="mat3")return new Hae(e);if(t==="mat4")return new Wae(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),s=this.getTypeLength(n);return r===16&&s===9?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&s===4?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:r>4||s>4||s===0?e:r===s?`${this.getType(n)}( ${e} )`:r>s?this.format(`${e}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(t)),n):s===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${W0} - Node System -`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class y6{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Zn.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(n,this.frameId)}else if(t===Zn.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(n,this.renderId)}else t===Zn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Zn.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(n,this.frameId)}else if(t===Zn.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(n,this.renderId)}else t===Zn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===Zn.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.frameId&&e.update(this)!==!1&&r.set(n,this.frameId)}else if(t===Zn.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.renderId&&e.update(this)!==!1&&r.set(n,this.renderId)}else t===Zn.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class GE{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}GE.isNodeFunctionInput=!0;class Jae extends Td{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,r=LE(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:s},e.stack,e)}}const pS=new Xn,yv=new Xn;let pm=null;class eoe extends Td{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=En(new de).setGroup(In),this.halfWidth=En(new de).setGroup(In),this.updateType=Zn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;yv.identity(),pS.copy(t.matrixWorld),pS.premultiply(n),yv.extractRotation(pS),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(yv),this.halfHeight.value.applyMatrix4(yv)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=gi(pm.LTC_FLOAT_1),n=gi(pm.LTC_FLOAT_2)):(t=gi(pm.LTC_HALF_1),n=gi(pm.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,l=Jy(s),u=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:l,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:u,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){pm=e}}class JB extends Td{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=En(0).setGroup(In),this.penumbraCosNode=En(0).setGroup(In),this.cutoffDistanceNode=En(0).setGroup(In),this.decayExponentNode=En(0).setGroup(In)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return $c(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,l=Jy(a).sub(as),u=l.normalize(),h=u.dot(LE(a)),m=this.getSpotAttenuation(h),v=l.length(),x=OE({lightDistance:v,cutoffDistance:r,decayExponent:s});let S=n.mul(m).mul(x);if(a.map){const N=DB(a),C=gi(a.map,N.xy).onRenderUpdate(()=>a.map);S=N.mul(2).sub(1).abs().lessThan(1).all().select(S.mul(C),S)}const w=e.context.reflectedLight;t.direct({lightDirection:u,lightColor:S,reflectedLight:w},e.stack,e)}}class toe extends JB{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);n=gi(t,Ft(r,0),0).r}else n=super.getSpotAttenuation(e);return n}}class noe extends Td{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class ioe extends Td{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=PE(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=En(new mn).setGroup(In)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,a=ll.dot(r).mul(.5).add(.5),l=zi(n,t,a);e.context.irradiance.addAssign(l)}}class roe extends Td{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new de);this.lightProbe=Dc(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=QB(Vy,this.lightProbe);e.context.irradiance.addAssign(t)}}class eO{parseFunction(){console.warn("Abstract function.")}}class qE{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn("Abstract function.")}}qE.isNodeFunction=!0;const soe=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,aoe=/[a-z_0-9]+/ig,x6="#pragma main",ooe=i=>{i=i.trim();const e=i.indexOf(x6),t=e!==-1?i.slice(e+x6.length):i,n=t.match(soe);if(n!==null&&n.length===5){const r=n[4],s=[];let a=null;for(;(a=aoe.exec(r))!==null;)s.push(a);const l=[];let u=0;for(;u0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Wh||n.mapping===$h||n.mapping===ld){if(e.backgroundBlurriness>0||n.mapping===ld)return bE(n);{let a;return n.isCubeTexture===!0?a=z0(n):a=gi(n),kU(a)}}else{if(n.isTexture===!0)return gi(n,Ru.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=s.get(t);return(a===void 0||r)&&(a=n(),s.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const s=$i("color","color",n).setGroup(In),a=$i("density","float",n).setGroup(In);return Pg(s,NE(a))}else if(n.isFog){const s=$i("color","color",n).setGroup(In),a=$i("near","float",n).setGroup(In),l=$i("far","float",n).setGroup(In);return Pg(s,CE(a,l))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return z0(n);if(n.isTexture===!0)return gi(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,s=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=s,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return b6.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=gi(e,Ru).renderOutput(t.toneMapping,t.currentColorSpace);return b6.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new y6,this.nodeBuilderCache=new Map,this.cacheLib={}}}const mS=new iu;class ay{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Qn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const r=e.length;for(let s=0;s{await this.compileAsync(v,x);const w=this._renderLists.get(v,x),N=this._renderContexts.get(v,x,this._renderTarget),C=v.overrideMaterial||S.material,E=this._objects.get(S,C,v,x,w.lightsNode,N,N.clippingContext),{fragmentShader:O,vertexShader:U}=E.getNodeBuilderState();return{fragmentShader:O,vertexShader:U}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),await n.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new coe(this,n),this._animation=new dne(this._nodes,this.info),this._attributes=new yne(n),this._background=new wae(this,this._nodes),this._geometries=new bne(this._attributes,this.info),this._textures=new One(this,n,this.info),this._pipelines=new Ene(n,this._nodes),this._bindings=new Cne(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new gne(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new Dne(this.lighting),this._bundles=new foe,this._renderContexts=new Une,this._animation.start(),this._initialized=!0,e()}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,s=r.renderId,a=this._currentRenderContext,l=this._currentRenderObjectFunction,u=this._compilationPromises,h=e.isScene===!0?e:S6;n===null&&(n=e);const m=this._renderTarget,v=this._renderContexts.get(n,t,m),x=this._activeMipmapLevel,S=[];this._currentRenderContext=v,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=S,r.renderId++,r.update(),v.depth=this.depth,v.stencil=this.stencil,v.clippingContext||(v.clippingContext=new ay),v.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,m);const w=this._renderLists.get(e,t);if(w.begin(),this._projectObject(e,t,0,w,v.clippingContext),n!==e&&n.traverseVisible(function(U){U.isLight&&U.layers.test(t.layers)&&w.pushLight(U)}),w.finish(),m!==null){this._textures.updateRenderTarget(m,x);const U=this._textures.get(m);v.textures=U.textures,v.depthTexture=U.depthTexture}else v.textures=null,v.depthTexture=null;this._background.update(h,w,v);const N=w.opaque,C=w.transparent,E=w.transparentDoublePass,O=w.lightsNode;this.opaque===!0&&N.length>0&&this._renderObjects(N,t,h,O),this.transparent===!0&&C.length>0&&this._renderTransparents(C,E,t,h,O),r.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=l,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(S)}async renderAsync(e,t){this._initialized===!1&&await this.init();const n=this._renderScene(e,t);await this.backend.resolveTimestampAsync(n,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: - -Message: ${e.message}`;e.reason&&(t+=` -Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:s,renderList:a}=e,l=this._currentRenderContext,u=this._bundles.get(r,s),h=this.backend.get(u);h.renderContexts===void 0&&(h.renderContexts=new Set);const m=r.version!==h.version,v=h.renderContexts.has(l)===!1||m;if(h.renderContexts.add(l),v){this.backend.beginBundle(l),(h.renderObjects===void 0||m)&&(h.renderObjects=[]),this._currentRenderBundle=u;const x=a.opaque;this.opaque===!0&&x.length>0&&this._renderObjects(x,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(l,u),h.version=r.version}else{const{renderObjects:x}=h;for(let S=0,w=x.length;S>=x,w.viewportValue.height>>=x,w.viewportValue.minDepth=U,w.viewportValue.maxDepth=I,w.viewport=w.viewportValue.equals(gS)===!1,w.scissorValue.copy(E).multiplyScalar(O).floor(),w.scissor=this._scissorTest&&w.scissorValue.equals(gS)===!1,w.scissorValue.width>>=x,w.scissorValue.height>>=x,w.clippingContext||(w.clippingContext=new ay),w.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,S),bv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),vS.setFromProjectionMatrix(bv,N);const j=this._renderLists.get(e,t);if(j.begin(),this._projectObject(e,t,0,j,w.clippingContext),j.finish(),this.sortObjects===!0&&j.sort(this._opaqueSort,this._transparentSort),S!==null){this._textures.updateRenderTarget(S,x);const Y=this._textures.get(S);w.textures=Y.textures,w.depthTexture=Y.depthTexture,w.width=Y.width,w.height=Y.height,w.renderTarget=S,w.depth=S.depthBuffer,w.stencil=S.stencilBuffer}else w.textures=null,w.depthTexture=null,w.width=this.domElement.width,w.height=this.domElement.height,w.depth=this.depth,w.stencil=this.stencil;w.width>>=x,w.height>>=x,w.activeCubeFace=v,w.activeMipmapLevel=x,w.occlusionQueryCount=j.occlusionQueryCount,this._background.update(h,j,w),this.backend.beginRender(w);const{bundles:z,lightsNode:G,transparentDoublePass:W,transparent:q,opaque:V}=j;if(z.length>0&&this._renderBundles(z,h,G),this.opaque===!0&&V.length>0&&this._renderObjects(V,t,h,G),this.transparent===!0&&q.length>0&&this._renderTransparents(q,W,t,h,G),this.backend.finishRender(w),s.renderId=a,this._currentRenderContext=l,this._currentRenderObjectFunction=u,r!==null){this.setRenderTarget(m,v,x);const Y=this._quad;this._nodes.hasOutputChange(S.texture)&&(Y.material.fragmentNode=this._nodes.getOutputNode(S.texture),Y.material.needsUpdate=!0),this._renderScene(Y,Y.camera,!1)}return h.onAfterRender(this,e,t,S),w}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,n=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){const s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,s=0,a=1){const l=this._viewport;e.isVector4?l.copy(e):l.set(e,t,n,r),l.minDepth=s,l.maxDepth=a}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);const r=this._renderTarget||this._getFrameBufferTarget();let s=null;if(r!==null){this._textures.updateRenderTarget(r);const a=this._textures.get(r);s=this._renderContexts.get(null,null,r),s.textures=a.textures,s.depthTexture=a.depthTexture,s.width=a.width,s.height=a.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer}if(this.backend.clear(e,t,n,s),r!==null&&this._renderTarget===null){const a=this._quad;this._nodes.hasOutputChange(r.texture)&&(a.material.fragmentNode=this._nodes.getOutputNode(r.texture),a.material.needsUpdate=!0),this._renderScene(a,a.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){this._initialized===!1&&await this.init(),this.clear(e,t,n)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this._renderTarget!==null?ro:this.toneMapping}get currentColorSpace(){return this._renderTarget!==null?Io:this.outputColorSpace}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(this.isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,n=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const r=this.backend,s=this._pipelines,a=this._bindings,l=this._nodes,u=Array.isArray(e)?e:[e];if(u[0]===void 0||u[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");r.beginCompute(e);for(const h of u){if(s.has(h)===!1){const x=()=>{h.removeEventListener("dispose",x),s.delete(h),a.delete(h),l.delete(h)};h.addEventListener("dispose",x);const S=h.onInitFunction;S!==null&&S.call(h,{renderer:this})}l.updateForCompute(h),a.updateForCompute(h);const m=a.getForCompute(h),v=s.getForCompute(h,m);r.compute(e,h,m,v)}r.finishCompute(e),t.renderId=n}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e),await this.backend.resolveTimestampAsync(e,"compute")}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Nh.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Nh.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Nh.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n!==null?r=n.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,r=null,s=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,s)}async readRenderTargetPixelsAsync(e,t,n,r,s,a=0,l=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,s,l)}_projectObject(e,t,n,r,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||vS.intersectsSprite(e)){this.sortObjects===!0&&Nh.setFromMatrixPosition(e.matrixWorld).applyMatrix4(bv);const{geometry:u,material:h}=e;h.visible&&r.push(e,u,h,n,Nh.z,null,s)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||vS.intersectsObject(e))){const{geometry:u,material:h}=e;if(this.sortObjects===!0&&(u.boundingSphere===null&&u.computeBoundingSphere(),Nh.copy(u.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(bv)),Array.isArray(h)){const m=u.groups;for(let v=0,x=m.length;v0){for(const{material:a}of t)a.side=gr;this._renderObjects(t,n,r,s,"backSide");for(const{material:a}of t)a.side=zl;this._renderObjects(e,n,r,s);for(const{material:a}of t)a.side=gs}else this._renderObjects(e,n,r,s)}_renderObjects(e,t,n,r,s=null){for(let a=0,l=e.length;a0,S.isShadowNodeMaterial&&(S.side=s.shadowSide===null?s.side:s.shadowSide,s.depthNode&&s.depthNode.isNode&&(x=S.depthNode,S.depthNode=s.depthNode),s.castShadowNode&&s.castShadowNode.isNode&&(v=S.colorNode,S.colorNode=s.castShadowNode)),s=S}s.transparent===!0&&s.side===gs&&s.forceSinglePass===!1?(s.side=gr,this._handleObjectFunction(e,s,t,n,l,a,u,"backSide"),s.side=zl,this._handleObjectFunction(e,s,t,n,l,a,u,h),s.side=gs):this._handleObjectFunction(e,s,t,n,l,a,u,h),m!==void 0&&(t.overrideMaterial.positionNode=m),x!==void 0&&(t.overrideMaterial.depthNode=x),v!==void 0&&(t.overrideMaterial.colorNode=v),e.onAfterRender(this,t,n,r,s,a)}_renderObjectDirect(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a;const m=this._nodes.needsRefresh(h);m&&(this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h)),this._pipelines.updateForRender(h),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(h),h.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(h,this.info),m&&this._nodes.updateAfter(h)}_createObjectPipeline(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a,this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h),this._pipelines.getForRender(h,this._compilationPromises),this._nodes.updateAfter(h)}get compile(){return this.compileAsync}}class VE{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function moe(i){return i+(kh-i%kh)%kh}class nO extends VE{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return moe(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class iO extends nO{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let goe=0;class rO extends iO{constructor(e,t){super("UniformBuffer_"+goe++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class voe extends iO{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=0;for(let t=0,n=this.uniforms.length;t0?x:"";l=`${m.name} { - ${v} ${a.name}[${S}]; -}; -`}else l=`${this.getVectorType(a.type)} ${this.getPropertyName(a,e)};`,u=!0;const h=a.node.precision;if(h!==null&&(l=woe[h]+" "+l),u){l=" "+l;const m=a.groupNode.name;(r[m]||(r[m]=[])).push(l)}else l="uniform "+l,n.push(l)}let s="";for(const a in r){const l=r[a];s+=this._getGLSLUniformStruct(e+"_"+a,l.join(` -`))+` -`}return s+=n.join(` -`),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==ks){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let r=0;for(const s of n)t+=`layout( location = ${r++} ) in ${s.type} ${s.name}; -`}return t}getStructMembers(e){const t=[],n=e.getMemberTypes();for(let r=0;rn*r,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:r,behavior:s}of n.values())t.push(`#extension ${r} : ${s}`);return t.join(` -`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=T6[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const r=this.renderer.backend.extensions;r.has(n)&&(r.get(n),t=!0)}T6[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n0&&(n+=` -`),n+=` // flow -> ${h} - `),n+=`${u.code} - `,l===s&&t!=="compute"&&(n+=`// result - `,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(l.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);let l=a.uniformGPU;if(l===void 0){const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture")l=new ex(s.name,s.node,u),m.push(l);else if(t==="cubeTexture")l=new aO(s.name,s.node,u),m.push(l);else if(t==="texture3D")l=new oO(s.name,s.node,u),m.push(l);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;const v=new rO(e,u);v.name=e.name,m.push(v),l=v}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new sO(n+"_"+h,u),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}}let _S=null,BA=null;class lO{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return _S=_S||new Et,this.renderer.getDrawingBufferSize(_S)}setScissorTest(){}getClearColor(){const e=this.renderer;return BA=BA||new TE,e.getClearColor(BA),BA.getRGB(BA,this.renderer.currentColorSpace),BA}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:q7(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${W0} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let Eoe=0;class Coe{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class Noe{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,a=e.usage||r.STATIC_DRAW,l=e.isInterleavedBufferAttribute?e.data:e,u=n.get(l);let h=u.bufferGPU;h===void 0&&(h=this._createBuffer(r,t,s,a),u.bufferGPU=h,u.bufferType=t,u.version=l.version);let m;if(s instanceof Float32Array)m=r.FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?m=r.HALF_FLOAT:m=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)m=r.SHORT;else if(s instanceof Uint32Array)m=r.UNSIGNED_INT;else if(s instanceof Int32Array)m=r.INT;else if(s instanceof Int8Array)m=r.BYTE;else if(s instanceof Uint8Array)m=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)m=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let v={bufferGPU:h,bufferType:t,type:m,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:m===r.INT||m===r.UNSIGNED_INT||e.gpuType===ks,id:Eoe++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const x=this._createBuffer(r,t,s,a);v=new Coe(v,x)}n.set(e,v)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,a=t.get(s),l=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(l,a.bufferGPU),u.length===0)n.bufferSubData(l,0,r);else{for(let h=0,m=u.length;h1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u{function s(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}}let E6=!1,Sv,xS,C6;class Poe{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},E6===!1&&(this._init(this.gl),E6=!0)}_init(e){Sv={[ud]:e.REPEAT,[lu]:e.CLAMP_TO_EDGE,[cd]:e.MIRRORED_REPEAT},xS={[br]:e.NEAREST,[s_]:e.NEAREST_MIPMAP_NEAREST,[uu]:e.NEAREST_MIPMAP_LINEAR,[Ms]:e.LINEAR,[n0]:e.LINEAR_MIPMAP_NEAREST,[Ya]:e.LINEAR_MIPMAP_LINEAR},C6={[zw]:e.NEVER,[Hw]:e.ALWAYS,[my]:e.LESS,[gy]:e.LEQUAL,[Gw]:e.EQUAL,[jw]:e.GEQUAL,[qw]:e.GREATER,[Vw]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===br||e===s_||e===uu?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,s=!1){const{gl:a,extensions:l}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;return t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB&&(n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=r===Nn&&s===!1?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5)),t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA&&(n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=r===Nn&&s===!1?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)),t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_INT&&(u=a.DEPTH24_STENCIL8),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&l.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:r,backend:s}=this;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),n.texParameteri(e,n.TEXTURE_WRAP_S,Sv[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,Sv[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&n.texParameteri(e,n.TEXTURE_WRAP_R,Sv[t.wrapR]),n.texParameteri(e,n.TEXTURE_MAG_FILTER,xS[t.magFilter]);const a=t.mipmaps!==void 0&&t.mipmaps.length>0,l=t.minFilter===Ms&&a?Ya:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,xS[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,C6[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===br||t.minFilter!==uu&&t.minFilter!==Ya||t.type===ss&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const u=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,s=this.getGLTextureType(e);let a=r[s];a===void 0&&(a=t.createTexture(),n.state.bindTexture(s,a),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=a),n.set(e,{textureGPU:a,glTextureType:s,isDefault:!0})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:s,width:a,height:l,depth:u}=t,h=r.utils.convert(e.format,e.colorSpace),m=r.utils.convert(e.type),v=this.getInternalFormat(e.internalFormat,h,m,e.colorSpace,e.isVideoTexture),x=n.createTexture(),S=this.getGLTextureType(e);r.state.bindTexture(S,x),this.setTextureParameters(S,e),e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,v,a,l,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,v,a,l,u):e.isVideoTexture||n.texStorage2D(S,s,v,a,l),r.set(e,{textureGPU:x,glTextureType:S,glFormat:h,glType:m,glInternalFormat:v})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:s,glTextureType:a,glFormat:l,glType:u}=r.get(t),{width:h,height:m}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,h,m,l,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:s}=t,{textureGPU:a,glTextureType:l,glFormat:u,glType:h,glInternalFormat:m}=this.backend.get(e);if(e.isRenderTargetTexture||a===void 0)return;const v=x=>x.isDataTexture?x.image.data:typeof HTMLImageElement<"u"&&x instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&x instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&x instanceof ImageBitmap||x instanceof OffscreenCanvas?x:x.data;if(this.backend.state.bindTexture(l,a),this.setTextureParameters(l,e),e.isCompressedTexture){const x=e.mipmaps,S=t.image;for(let w=0;w0,x=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(v){const S=l!==0||u!==0;let w,N;if(e.isDepthTexture===!0?(w=r.DEPTH_BUFFER_BIT,N=r.DEPTH_ATTACHMENT,t.stencil&&(w|=r.STENCIL_BUFFER_BIT)):(w=r.COLOR_BUFFER_BIT,N=r.COLOR_ATTACHMENT0),S){const C=this.backend.get(t.renderTarget),E=C.framebuffers[t.getCacheKey()],O=C.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,E),s.bindFramebuffer(r.READ_FRAMEBUFFER,O);const U=x-u-m;r.blitFramebuffer(l,U,l+h,U+m,l,U,l+h,U+m,w,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,E),s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,U,h,m),s.unbindTexture()}else{const C=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,C),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,N,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,h,m,0,0,h,m,w,r.NEAREST),r.deleteFramebuffer(C)}}else s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,x-m-u,h,m),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:n}=this,r=t.renderTarget,{samples:s,depthTexture:a,depthBuffer:l,stencilBuffer:u,width:h,height:m}=r;if(n.bindRenderbuffer(n.RENDERBUFFER,e),l&&!u){let v=n.DEPTH_COMPONENT24;s>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(v=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,s,v,h,m)):n.renderbufferStorage(n.RENDERBUFFER,v,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else l&&u&&(s>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,s,n.DEPTH24_STENCIL8,h,m):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,n,r,s,a){const{backend:l,gl:u}=this,{textureGPU:h,glFormat:m,glType:v}=this.backend.get(e),x=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,x);const S=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,S,h,0);const w=this._getTypedArrayType(v),N=this._getBytesPerTexel(v,m),E=r*s*N,O=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.bufferData(u.PIXEL_PACK_BUFFER,E,u.STREAM_READ),u.readPixels(t,n,r,s,m,v,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await l.utils._clientWaitAsync();const U=new w(E/w.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,U),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(x),U}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}}class Loe{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class Uoe{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const N6={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class Boe{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:r,object:s,type:a,info:l,index:u}=this;u!==0?n.drawElements(r,t,a,e):n.drawArrays(r,e,t),l.update(s,t,r,1)}renderInstances(e,t,n){const{gl:r,mode:s,type:a,index:l,object:u,info:h}=this;n!==0&&(l!==0?r.drawElementsInstanced(s,t,a,e,n):r.drawArraysInstanced(s,e,t,n),h.update(u,t,s,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:s,object:a,info:l}=this;if(n===0)return;const u=r.get("WEBGL_multi_draw");if(u===null)for(let h=0;h0)){const n=t.queryQueue.shift();this.initTimestampQuery(n)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const n=this.get(e);n.gpuQueries||(n.gpuQueries=[]);for(let r=0;r0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),s=r.previousContext,a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const l=e.textures;if(l!==null)for(let u=0;u0){const m=u.framebuffers[e.getCacheKey()],v=t.COLOR_BUFFER_BIT,x=u.msaaFrameBuffer,S=e.textures;n.bindFramebuffer(t.READ_FRAMEBUFFER,x),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,m);for(let w=0;w{let u=0;for(let h=0;h0&&s.add(r[h]),n[h]=null,a.deleteQuery(m),u++)}u1?E.renderInstances(I,O,U):E.render(I,O),u.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new Moe(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,s=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,r),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:s,vertexProgram:a}=r,l=n.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU;if(n.attachShader(l,u),n.attachShader(l,h),n.linkProgram(l),this.set(r,{programGPU:l,fragmentShader:u,vertexShader:h}),t!==null&&this.parallel){const m=new Promise(v=>{const x=this.parallel,S=()=>{n.getProgramParameter(l,x.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),v()):requestAnimationFrame(S)};S()});t.push(m);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(` -`),r=[],s=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let l=s;l":" "} ${u}: ${n[l]}`)}return r.join(` -`)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),s=e.getShaderInfoLog(t).trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const l=parseInt(a[1]);return n.toUpperCase()+` - -`+s+` - -`+this._handleSource(e.getShaderSource(t),l)}else return s}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,s=r.getProgramInfoLog(e).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,n,t);else{const a=this._getShaderErrors(r,n,"vertex"),l=this._getShaderErrors(r,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+` - -Program Info Log: `+s+` -`+a+` -`+l)}else s!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",s)}}_completeCompile(e,t){const{state:n,gl:r}=this,s=this.get(t),{programGPU:a,fragmentShader:l,vertexShader:u}=s;r.getProgramParameter(a,r.LINK_STATUS)===!1&&this._logProgramError(a,l,u),n.useProgram(a);const h=e.getBindings();this._setupBindings(h,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){const{state:n,gl:r}=this,s={stage:"fragment",code:`#version 300 es -precision highp float; -void main() {}`};this.createProgram(s);const{computeProgram:a}=e,l=r.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU,m=a.transforms,v=[],x=[];for(let C=0;CN6[r]===e),n=this.extensions;for(let r=0;r0){if(S===void 0){const E=[];S=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,S);const O=[],U=e.textures;for(let I=0;I, - @location( 0 ) vTex : vec2 -}; - -@vertex -fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { - - var Varys : VarysStruct; - - var pos = array< vec2, 4 >( - vec2( -1.0, 1.0 ), - vec2( 1.0, 1.0 ), - vec2( -1.0, -1.0 ), - vec2( 1.0, -1.0 ) - ); - - var tex = array< vec2, 4 >( - vec2( 0.0, 0.0 ), - vec2( 1.0, 0.0 ), - vec2( 0.0, 1.0 ), - vec2( 1.0, 1.0 ) - ); - - Varys.vTex = tex[ vertexIndex ]; - Varys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 ); - - return Varys; - -} -`,n=` -@group( 0 ) @binding( 0 ) -var imgSampler : sampler; - -@group( 0 ) @binding( 1 ) -var img : texture_2d; - -@fragment -fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { - - return textureSample( img, imgSampler, vTex ); - -} -`,r=` -@group( 0 ) @binding( 0 ) -var imgSampler : sampler; - -@group( 0 ) @binding( 1 ) -var img : texture_2d; - -@fragment -fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { - - return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); - -} -`;this.mipmapSampler=e.createSampler({minFilter:Hf.Linear}),this.flipYSampler=e.createSampler({minFilter:Hf.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:r})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:t0.TriangleStrip,stripIndexFormat:q0.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:t0.TriangleStrip,stripIndexFormat:q0.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const r=t.format,{width:s,height:a}=t.size,l=this.getTransferPipeline(r),u=this.getFlipYPipeline(r),h=this.device.createTexture({size:{width:s,height:a,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),m=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Wa.TwoD,baseArrayLayer:n}),v=h.createView({baseMipLevel:0,mipLevelCount:1,dimension:Wa.TwoD,baseArrayLayer:0}),x=this.device.createCommandEncoder({}),S=(w,N,C)=>{const E=w.getBindGroupLayout(0),O=this.device.createBindGroup({layout:E,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:N}]}),U=x.beginRenderPass({colorAttachments:[{view:C,loadOp:rs.Clear,storeOp:ha.Store,clearValue:[0,0,0,0]}]});U.setPipeline(w),U.setBindGroup(0,O),U.draw(4,1,0,0),U.end()};S(l,m,v),S(u,v,m),this.device.queue.submit([x.finish()]),h.destroy()}generateMipmaps(e,t,n=0){const r=this.get(e);r.useCount===void 0&&(r.useCount=0,r.layers=[]);const s=r.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,s),this.device.queue.submit([a.finish()]),r.useCount!==0&&(r.layers[n]=s),r.useCount++}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),s=r.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Wa.TwoD,baseArrayLayer:n});const l=[];for(let u=1;u1;for(let l=0;l]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,$oe=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,L6={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},Xoe=i=>{i=i.trim();const e=i.match(Woe);if(e!==null&&e.length===4){const t=e[2],n=[];let r=null;for(;(r=$oe.exec(t))!==null;)n.push({name:r[1],type:r[2]});const s=[];for(let m=0;m "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class Qoe extends eO{parseFunction(e){return new Yoe(e)}}const IA=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Koe={[da.READ_ONLY]:"read",[da.WRITE_ONLY]:"write",[da.READ_WRITE]:"read_write"},U6={[ud]:"repeat",[lu]:"clamp",[cd]:"mirror"},wv={vertex:IA?IA.VERTEX:1,fragment:IA?IA.FRAGMENT:2,compute:IA?IA.COMPUTE:4},B6={instance:!0,swizzleAssign:!1,storageBuffer:!0},Zoe={"^^":"tsl_xor"},Joe={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},O6={},tl={tsl_xor:new ps("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new ps("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new ps("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new ps("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new ps("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new ps("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new ps("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new ps("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new ps("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new ps("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new ps("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new ps("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new ps(` -fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { - - let res = vec2f( iRes ); - - let uvScaled = coord * res; - let uvWrapping = ( ( uvScaled % res ) + res ) % res; - - // https://www.shadertoy.com/view/WtyXRy - - let uv = uvWrapping - 0.5; - let iuv = floor( uv ); - let f = fract( uv ); - - let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); - let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); - let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); - let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); - - return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); - -} -`)},Cm={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(tl.pow_float=new ps("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),tl.pow_vec2=new ps("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[tl.pow_float]),tl.pow_vec3=new ps("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[tl.pow_float]),tl.pow_vec4=new ps("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[tl.pow_float]),Cm.pow_float="tsl_pow_float",Cm.pow_vec2="tsl_pow_vec2",Cm.pow_vec3="tsl_pow_vec3",Cm.pow_vec4="tsl_pow_vec4");let uO="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(uO+=`diagnostic( off, derivative_uniformity ); -`);class ele extends ZB{constructor(e,t){super(e,t,new Qoe),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==Oo}_generateTextureSample(e,t,n,r,s=this.shaderStage){return s==="fragment"?r?`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n):this.generateTextureLod(e,t,n,r,"0")}_generateVideoSample(e,t,n=this.shaderStage){if(n==="fragment")return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${n} shader.`)}_generateTextureSampleLevel(e,t,n,r,s,a=this.shaderStage){return(a==="fragment"||a==="compute")&&this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r):this.generateTextureLod(e,t,n,s,r)}generateWrapFunction(e){const t=`tsl_coord_${U6[e.wrapS]}S_${U6[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=O6[t];if(n===void 0){const r=[],s=e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${s} ) -> ${s} { - - return ${s}( -`;const l=(u,h)=>{u===ud?(r.push(tl.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${h} )`):u===lu?(r.push(tl.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${h} )`):u===cd?(r.push(tl.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${h} )`):(a+=` coord.${h}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};l(e.wrapS,"x"),a+=`, -`,l(e.wrapT,"y"),e.isData3DTexture&&(a+=`, -`,l(e.wrapR,"z")),a+=` - ); - -} -`,O6[t]=n=new ps(a,r)}return n.build(this),t}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,l;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),h=u>1;e.isData3DTexture?l="vec3":l="vec2",h||e.isVideoTexture||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,s=new Kv(new Zv(`textureDimensions( ${a} )`,l)),r.dimensionsSnippet[n]=s,(e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new Kv(new Zv(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new Kv(new Zv("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,n,r="0u"){this._include("biquadraticTexture");const s=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,r);return`tsl_biquadraticTexture( ${t}, ${s}( ${n} ), ${a}, u32( ${r} ) )`}generateTextureLod(e,t,n,r,s="0u"){const a=this.generateWrapFunction(e),l=this.generateTextureDimension(e,t,s),u=e.isData3DTexture?"vec3":"vec2",h=`${u}(${a}(${n}) * ${u}(${l}))`;return this.generateTextureLoad(e,t,h,r,s)}generateTextureLoad(e,t,n,r,s="0u"){return e.isVideoTexture===!0||e.isStorageTexture===!0?`textureLoad( ${t}, ${n} )`:r?`textureLoad( ${t}, ${n}, ${r}, u32( ${s} ) )`:`textureLoad( ${t}, ${n}, u32( ${s} ) )`}generateTextureStore(e,t,n,r){return`textureStore( ${t}, ${n}, ${r} )`}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===ss||this.isSampleCompare(e)===!1&&e.minFilter===br&&e.magFilter===br||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,s=this.shaderStage){let a=null;return e.isVideoTexture===!0?a=this._generateVideoSample(t,n,s):this.isUnfilterable(e)?a=this.generateTextureLod(e,t,n,r,"0",s):a=this._generateTextureSample(e,t,n,r,s),a}generateTextureGrad(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,r,s,a=this.shaderStage){let l=null;return e.isVideoTexture===!0?l=this._generateVideoSample(t,n,a):l=this._generateTextureSampleLevel(e,t,n,r,s,a),l}generateTextureBias(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const n=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="storageTexture"||r==="texture3D"?n:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?`NodeBuffer_${e.id}.${n}`:e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=Zoe[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?da.READ_ONLY:e.access}getStorageAccess(e,t){return Koe[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let l;const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let v=null;const x=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?v=new ex(s.name,s.node,u,x):t==="cubeTexture"?v=new aO(s.name,s.node,u,x):t==="texture3D"&&(v=new oO(s.name,s.node,u,x)),v.store=e.isStorageTextureNode===!0,v.setVisibility(wv[n]),(n==="fragment"||n==="compute")&&this.isUnfilterable(e.value)===!1&&v.store===!1){const S=new Foe(`${s.name}_sampler`,s.node,u);S.setVisibility(wv[n]),m.push(S,v),l=[S,v]}else m.push(v),l=[v]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const v=t==="buffer"?rO:Goe,x=new v(e,u);x.setVisibility(wv[n]),m.push(x),l=x}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new sO(h,u),x.setVisibility(wv[n]),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}getBuiltin(e,t,n,r=this.shaderStage){const s=this.builtins[r]||(this.builtins[r]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const a of t.inputs)r.push(a.name+" : "+this.getType(a.type));let s=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} { -${n.vars} -${n.code} -`;return n.result&&(s+=` return ${n.result}; -`),s+=` -} -`,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==void 0)for(const r of n)t.push(`enable ${r};`);return t.join(` -`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==void 0)for(const{name:r,property:s,type:a}of n.values())t.push(`@builtin( ${r} ) ${s} : ${a}`);return t.join(`, - `)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:r,bufferType:s,bufferCount:a}of this.scopedArrays.values()){const l=this.getType(s);t.push(`var<${r}> ${n}: array< ${l}, ${a} >;`)}return t.join(` -`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","id","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const n=this.getBuiltins("attribute");n&&t.push(n);const r=this.getAttributesArray();for(let s=0,a=r.length;s`)}const r=this.getBuiltins("output");return r&&t.push(" "+r),t.join(`, -`)}getStructs(e){const t=[],n=this.structs[e];for(let r=0,s=n.length;r output : ${l}; - -`)}return t.join(` - -`)}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(` ${this.getVar(r.type,r.name)};`);return` -${t.join(` -`)} -`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4","vertex"),e==="vertex"||e==="fragment"){const s=this.varyings,a=this.vars[e];for(let l=0;l1&&(S="_multisampled"),v.isCubeTexture===!0)x="texture_cube";else if(v.isDataArrayTexture===!0||v.isCompressedArrayTexture===!0)x="texture_2d_array";else if(v.isDepthTexture===!0)x=`texture_depth${S}_2d`;else if(v.isVideoTexture===!0)x="texture_external";else if(v.isData3DTexture===!0)x="texture_3d";else if(u.node.isStorageTextureNode===!0){const N=sw(v),C=this.getStorageAccess(u.node,e);x=`texture_storage_2d<${N}, ${C}>`}else{const N=this.getComponentTypeFromTexture(v).charAt(0);x=`texture${S}_2d<${N}32>`}n.push(`@binding( ${m.binding++} ) @group( ${m.group} ) var ${u.name} : ${x};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const v=u.node,x=this.getType(v.bufferType),S=v.bufferCount,w=S>0&&u.type==="buffer"?", "+S:"",N=v.isAtomic?`atomic<${x}>`:`${x}`,C=` ${u.name} : array< ${N}${w} > -`,E=v.isStorageBufferNode?`storage, ${this.getStorageAccess(v,e)}`:"uniform";r.push(this._getWGSLStructBinding("NodeBuffer_"+v.id,C,E,m.binding++,m.group))}else{const v=this.getType(this.getVectorType(u.type)),x=u.groupNode.name;(a[x]||(a[x]={index:m.binding++,id:m.group,snippets:[]})).snippets.push(` ${u.name} : ${v}`)}}for(const u in a){const h=a[u];s.push(this._getWGSLStructBinding(u,h.snippets.join(`, -`),"uniform",h.index,h.id))}let l=n.join(` -`);return l+=r.join(` -`),l+=s.join(` -`),l}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code - -`;r+=this.flowCode[t];const s=this.flowNodes[t],a=s[s.length-1],l=a.outputNode,u=l!==void 0&&l.isOutputStructNode===!0;for(const h of s){const m=this.getFlowData(h),v=h.name;if(v&&(r.length>0&&(r+=` -`),r+=` // flow -> ${v} - `),r+=`${m.code} - `,h===a&&t!=="compute"){if(r+=`// result - - `,t==="vertex")r+=`varyings.Vertex = ${m.result};`;else if(t==="fragment")if(u)n.returnType=l.nodeType,r+=`return ${m.result};`;else{let x=" @location(0) color: vec4";const S=this.getBuiltins("output");S&&(x+=`, - `+S),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",x),n.structs+=` -var output : OutputStruct; - -`,r+=`output.color = ${m.result}; - - return output;`}}}n.flow=r}this.material!==null?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getType(e){return Joe[e]||e}isAvailable(e){let t=B6[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),B6[e]=t),t}_getWGSLMethod(e){return tl[e]!==void 0&&this._include(e),Cm[e]}_include(e){const t=tl[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} -// directives -${e.directives} - -// uniforms -${e.uniforms} - -// varyings -${e.varyings} -var varyings : VaryingsStruct; - -// codes -${e.codes} - -@vertex -fn main( ${e.attributes} ) -> VaryingsStruct { - - // vars - ${e.vars} - - // flow - ${e.flow} - - return varyings; - -} -`}_getWGSLFragmentCode(e){return`${this.getSignature()} -// global -${uO} - -// uniforms -${e.uniforms} - -// structs -${e.structs} - -// codes -${e.codes} - -@fragment -fn main( ${e.varyings} ) -> ${e.returnType} { - - // vars - ${e.vars} - - // flow - ${e.flow} - -} -`}_getWGSLComputeCode(e,t){return`${this.getSignature()} -// directives -${e.directives} - -// system -var instanceIndex : u32; - -// locals -${e.scopedArrays} - -// uniforms -${e.uniforms} - -// codes -${e.codes} - -@compute @workgroup_size( ${t} ) -fn main( ${e.attributes} ) { - - // system - instanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t}); - - // vars - ${e.vars} - - // flow - ${e.flow} - -} -`}_getWGSLStruct(e,t){return` -struct ${e} { -${t} -};`}_getWGSLStructBinding(e,t,n,r=0,s=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)} -@binding( ${r} ) @group( ${s} ) -var<${n}> ${e} : ${a};`}}class tle{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=De.Depth24PlusStencil8:e.depth&&(t=De.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,a=s.getRenderTarget();t=a?a.samples:s.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return t0.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return t0.LineList;if(e.isLine)return t0.LineStrip;if(e.isMesh)return t0.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?De.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const nle=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),ile=new Map([[H7,["float16"]]]),rle=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class sle{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let a=s.buffer;if(a===void 0){const l=r.device;let u=n.array;if(e.normalized===!1&&(u.constructor===Int16Array||u.constructor===Uint16Array)){const m=new Uint32Array(u.length);for(let v=0;v1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=OA.UnfilterableFloat)),a.texture.isDepthTexture)u.sampleType=OA.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const m=a.texture.type;m===ks?u.sampleType=OA.SInt:m===Ir?u.sampleType=OA.UInt:m===ss&&(this.backend.hasFeature("float32-filterable")?u.sampleType=OA.Float:u.sampleType=OA.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=Wa.Cube:a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=Wa.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=Wa.ThreeD),l.texture=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);r.push(l)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){const{backend:s,bindGroupLayoutCache:a}=this,l=s.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let h;n>0&&(l.groups===void 0&&(l.groups=[],l.versions=[]),l.versions[n]===r&&(h=l.groups[n])),h===void 0&&(h=this.createBindGroup(e,u),n>0&&(l.groups[n]=h,l.versions[n]=r)),l.group=h,l.layout=u}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,s=t.get(e).buffer;n.queue.writeBuffer(s,0,r,0)}createBindGroup(e,t){const n=this.backend,r=n.device;let s=0;const a=[];for(const l of e.bindings){if(l.isUniformBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.byteLength,m=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,v=r.createBuffer({label:"bindingBuffer_"+l.name,size:h,usage:m});u.buffer=v}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isStorageBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.attribute;u.buffer=n.get(h).buffer}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isSampler){const u=n.get(l.texture);a.push({binding:s,resource:u.sampler})}else if(l.isSampledTexture){const u=n.get(l.texture);let h;if(u.externalTexture!==void 0)h=r.importExternalTexture({source:u.externalTexture});else{const m=l.store?1:u.texture.mipLevelCount,v=`view-${u.texture.width}-${u.texture.height}-${m}`;if(h=u[v],h===void 0){const x=Ooe.All;let S;l.isSampledCubeTexture?S=Wa.Cube:l.isSampledTexture3D?S=Wa.ThreeD:l.texture.isDataArrayTexture||l.texture.isCompressedArrayTexture?S=Wa.TwoDArray:S=Wa.TwoD,h=u[v]=u.texture.createView({aspect:x,dimension:S,mipLevelCount:m})}}a.push({binding:s,resource:h})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}}class ole{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:s,pipeline:a}=e,{vertexProgram:l,fragmentProgram:u}=a,h=this.backend,m=h.device,v=h.utils,x=h.get(a),S=[];for(const ne of e.getBindings()){const le=h.get(ne);S.push(le.layout)}const w=h.attributeUtils.createShaderVertexBuffers(e);let N;r.transparent===!0&&r.blending!==no&&(N=this._getBlending(r));let C={};r.stencilWrite===!0&&(C={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const E=this._getColorWriteMask(r),O=[];if(e.context.textures!==null){const ne=e.context.textures;for(let le=0;le1},layout:m.createPipelineLayout({bindGroupLayouts:S})},V={},Y=e.context.depth,te=e.context.stencil;if((Y===!0||te===!0)&&(Y===!0&&(V.format=G,V.depthWriteEnabled=r.depthWrite,V.depthCompare=z),te===!0&&(V.stencilFront=C,V.stencilBack={},V.stencilReadMask=r.stencilFuncMask,V.stencilWriteMask=r.stencilWriteMask),q.depthStencil=V),t===null)x.pipeline=m.createRenderPipeline(q);else{const ne=new Promise(le=>{m.createRenderPipelineAsync(q).then(Q=>{x.pipeline=Q,le()})});t.push(ne)}}createBundleEncoder(e){const t=this.backend,{utils:n,device:r}=t,s=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormat(e),l=this._getSampleCount(e),u={label:"renderBundleEncoder",colorFormats:[a],depthStencilFormat:s,sampleCount:l};return r.createRenderBundleEncoder(u)}createComputePipeline(e,t){const n=this.backend,r=n.device,s=n.get(e.computeProgram).module,a=n.get(e),l=[];for(const u of t){const h=n.get(u);l.push(h.layout)}a.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:l})})}_getBlending(e){let t,n;const r=e.blending,s=e.blendSrc,a=e.blendDst,l=e.blendEquation;if(r===Sw){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,h=e.blendDstAlpha!==null?e.blendDstAlpha:a,m=e.blendEquationAlpha!==null?e.blendEquationAlpha:l;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(l)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(h),operation:this._getBlendOperation(m)}}else{const u=e.premultipliedAlpha,h=(m,v,x,S)=>{t={srcFactor:m,dstFactor:v,operation:Uf.Add},n={srcFactor:x,dstFactor:S,operation:Uf.Add}};if(u)switch(r){case io:h(ti.One,ti.OneMinusSrcAlpha,ti.One,ti.OneMinusSrcAlpha);break;case u0:h(ti.One,ti.One,ti.One,ti.One);break;case c0:h(ti.Zero,ti.OneMinusSrc,ti.Zero,ti.One);break;case h0:h(ti.Zero,ti.Src,ti.Zero,ti.SrcAlpha);break}else switch(r){case io:h(ti.SrcAlpha,ti.OneMinusSrcAlpha,ti.One,ti.OneMinusSrcAlpha);break;case u0:h(ti.SrcAlpha,ti.One,ti.SrcAlpha,ti.One);break;case c0:h(ti.Zero,ti.OneMinusSrc,ti.Zero,ti.One);break;case h0:h(ti.Zero,ti.Src,ti.Zero,ti.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case Mw:t=ti.Zero;break;case Ew:t=ti.One;break;case Cw:t=ti.Src;break;case Nw:t=ti.OneMinusSrc;break;case jm:t=ti.SrcAlpha;break;case Hm:t=ti.OneMinusSrcAlpha;break;case Pw:t=ti.Dst;break;case Lw:t=ti.OneMinusDstColor;break;case Rw:t=ti.DstAlpha;break;case Dw:t=ti.OneMinusDstAlpha;break;case Uw:t=ti.SrcAlphaSaturated;break;case vne:t=ti.Constant;break;case _ne:t=ti.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case sk:t=js.Never;break;case XS:t=js.Always;break;case ak:t=js.Less;break;case lk:t=js.LessEqual;break;case ok:t=js.Equal;break;case hk:t=js.GreaterEqual;break;case uk:t=js.Greater;break;case ck:t=js.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case If:t=Rh.Keep;break;case ZF:t=Rh.Zero;break;case JF:t=Rh.Replace;break;case rk:t=Rh.Invert;break;case ek:t=Rh.IncrementClamp;break;case tk:t=Rh.DecrementClamp;break;case nk:t=Rh.IncrementWrap;break;case ik:t=Rh.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Bo:t=Uf.Add;break;case Tw:t=Uf.Subtract;break;case ww:t=Uf.ReverseSubtract;break;case R7:t=Uf.Min;break;case D7:t=Uf.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},s=this.backend.utils;switch(r.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?q0.Uint16:q0.Uint32),n.side){case zl:r.frontFace=bS.CCW,r.cullMode=SS.Back;break;case gr:r.frontFace=bS.CCW,r.cullMode=SS.Front;break;case gs:r.frontFace=bS.CCW,r.cullMode=SS.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?D6.All:D6.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=js.Always;else{const n=e.depthFunc;switch(n){case Wm:t=js.Never;break;case $m:t=js.Always;break;case Xm:t=js.Less;break;case Hh:t=js.LessEqual;break;case Ym:t=js.Equal;break;case Qm:t=js.GreaterEqual;break;case Km:t=js.Greater;break;case Zm:t=js.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class lle extends lO{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.trackTimestamp=e.trackTimestamp===!0,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new tle(this),this.attributeUtils=new sle(this),this.bindingUtils=new ale(this),this.pipelineUtils=new ole(this),this.textureUtils=new Hoe(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===void 0){const a={powerPreference:t.powerPreference},l=typeof navigator<"u"?await navigator.gpu.requestAdapter(a):null;if(l===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const u=Object.values(rw),h=[];for(const v of u)l.features.has(v)&&h.push(v);const m={requiredFeatures:h,requiredLimits:t.requiredLimits};n=await l.requestDevice(m)}else n=t.device;n.lost.then(a=>{const l={api:"WebGPU",message:a.message||"Unknown reason",reason:a.reason||null,originalEvent:a};e.onDeviceLost(l)});const r=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=r;const s=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(rw.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s}),this.updateSize()}get coordinateSystem(){return Su}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let s=r.descriptors;if(s===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==n.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples||r.loadOp!==t.loadOp){s={},r.descriptors=s;const u=()=>{n.removeEventListener("dispose",u),this.delete(n)};n.addEventListener("dispose",u)}const a=e.getCacheKey();let l=s[a];if(l===void 0){const u=e.textures,h=[];let m;for(let v=0;v0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:rs.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=s;const l=a.depthStencilAttachment;if(e.textures!==null){const m=a.colorAttachments;for(let v=0;v0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),n>0){const r=n*8;let s=this.occludedResolveCache.get(r);s===void 0&&(s=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,s));const a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const r=e.textures;for(let s=0;sl?(h.x=Math.min(t.dispatchCount,l),h.y=Math.ceil(t.dispatchCount/l)):h.x=t.dispatchCount,s.dispatchWorkgroups(h.x,h.y,h.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:n,context:r,pipeline:s}=e,a=e.getBindings(),l=this.get(r),u=this.get(s).pipeline,h=l.currentSets,m=l.currentPass,v=e.getDrawParameters();if(v===null)return;h.pipeline!==u&&(m.setPipeline(u),h.pipeline=u);const x=h.bindingGroups;for(let C=0,E=a.length;C1?0:I;w===!0?m.drawIndexed(E[I],j,C[I]/S.array.BYTES_PER_ELEMENT,0,z):m.draw(E[I],j,C[I],z)}}else if(w===!0){const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndexedIndirect(I,0)}else m.drawIndexed(C,E,O,0,0);t.update(n,C,E)}else{const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndirect(I,0)}else m.draw(C,E,O,0);t.update(n,C,E)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,s=this.utils,a=s.getSampleCountRenderContext(e.context),l=s.getCurrentColorSpace(e.context),u=s.getCurrentColorFormat(e.context),h=s.getCurrentDepthStencilFormat(e.context),m=s.getPrimitiveTopology(n,r);let v=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==l||t.colorFormat!==u||t.depthStencilFormat!==h||t.primitiveTopology!==m||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=l,t.colorFormat=u,t.depthStencilFormat=h,t.primitiveTopology=m,t.clippingContextCacheKey=e.clippingContextCacheKey,v=!0),v}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,s=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(s),r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const n=this.get(e);if(!n.timeStampQuerySet){const r=e.isComputeNode?"compute":"render",s=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${r}_${e.id}`});Object.assign(t,{timestampWrites:{querySet:s,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}),n.timeStampQuerySet=s}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const n=this.get(e),r=2*BigInt64Array.BYTES_PER_ELEMENT;n.currentTimestampQueryBuffers===void 0&&(n.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:s,resultBuffer:a}=n.currentTimestampQueryBuffers;t.resolveQuerySet(n.timeStampQuerySet,0,2,s,0),a.mapState==="unmapped"&&t.copyBufferToBuffer(s,0,a,0,r)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const n=this.get(e);if(n.currentTimestampQueryBuffers===void 0)return;const{resultBuffer:r}=n.currentTimestampQueryBuffers;r.mapState==="unmapped"&&r.mapAsync(GPUMapMode.READ).then(()=>{const s=new BigUint64Array(r.getMappedRange()),a=Number(s[1]-s[0])/1e6;this.renderer.info.updateTimestamp(t,a),r.unmap()})}createNodeBuilder(e,t){return new ele(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),s=n.currentPass.finish();this.get(t).bundleGPU=s,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,s=0){let a=0,l=0,u=0,h=0,m=0,v=0,x=e.image.width,S=e.image.height;n!==null&&(h=n.x,m=n.y,v=n.z||0,x=n.width,S=n.height),r!==null&&(a=r.x,l=r.y,u=r.z||0);const w=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),N=this.get(e).texture,C=this.get(t).texture;w.copyTextureToTexture({texture:N,mipLevel:s,origin:{x:h,y:m,z:v}},{texture:C,mipLevel:s,origin:{x:a,y:l,z:u}},[x,S,1]),this.device.queue.submit([w.finish()])}copyFramebufferToTexture(e,t,n){const r=this.get(t);let s=null;t.renderTarget?e.isDepthTexture?s=this.get(t.depthTexture).texture:s=this.get(t.textures[0]).texture:e.isDepthTexture?s=this.textureUtils.getDepthBuffer(t.depth,t.stencil):s=this.context.getCurrentTexture();const a=this.get(e).texture;if(s.format!==a.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,a.format);return}let l;if(r.currentPass?(r.currentPass.end(),l=r.encoder):l=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),l.copyTextureToTexture({texture:s,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),r.currentPass){const{descriptor:u}=r;for(let h=0;h(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new R6(e)));const n=new t(e);super(n,e),this.library=new cle,this.isWebGPURenderer=!0}}/** - * @license - * Copyright 2010-2024 Three.js Authors - * SPDX-License-Identifier: MIT - */$.BRDF_GGX;$.BRDF_Lambert;$.BasicShadowFilter;$.Break;$.Continue;$.DFGApprox;$.D_GGX;$.Discard;$.EPSILON;$.F_Schlick;const hle=$.Fn;$.INFINITY;const fle=$.If,dle=$.Loop;$.NodeShaderStage;$.NodeType;$.NodeUpdateType;$.NodeAccess;$.PCFShadowFilter;$.PCFSoftShadowFilter;$.PI;$.PI2;$.Return;$.Schlick_to_F0;$.ScriptableNodeResources;$.ShaderNode;$.TBNViewMatrix;$.VSMShadowFilter;$.V_GGX_SmithCorrelated;$.abs;$.acesFilmicToneMapping;$.acos;$.add;$.addNodeElement;$.agxToneMapping;$.all;$.alphaT;$.and;$.anisotropy;$.anisotropyB;$.anisotropyT;$.any;$.append;$.arrayBuffer;const Ale=$.asin;$.assign;$.atan;$.atan2;$.atomicAdd;$.atomicAnd;$.atomicFunc;$.atomicMax;$.atomicMin;$.atomicOr;$.atomicStore;$.atomicSub;$.atomicXor;$.attenuationColor;$.attenuationDistance;$.attribute;$.attributeArray;$.backgroundBlurriness;$.backgroundIntensity;$.backgroundRotation;$.batch;$.billboarding;$.bitAnd;$.bitNot;$.bitOr;$.bitXor;$.bitangentGeometry;$.bitangentLocal;$.bitangentView;$.bitangentWorld;$.bitcast;$.blendBurn;$.blendColor;$.blendDodge;$.blendOverlay;$.blendScreen;$.blur;$.bool;$.buffer;$.bufferAttribute;$.bumpMap;$.burn;$.bvec2;$.bvec3;$.bvec4;$.bypass;$.cache;$.call;$.cameraFar;$.cameraNear;$.cameraNormalMatrix;$.cameraPosition;$.cameraProjectionMatrix;$.cameraProjectionMatrixInverse;$.cameraViewMatrix;$.cameraWorldMatrix;$.cbrt;$.cdl;$.ceil;$.checker;$.cineonToneMapping;$.clamp;$.clearcoat;$.clearcoatRoughness;$.code;$.color;$.colorSpaceToWorking;$.colorToDirection;$.compute;$.cond;$.context;$.convert;$.convertColorSpace;$.convertToTexture;const ple=$.cos;$.cross;$.cubeTexture;$.dFdx;$.dFdy;$.dashSize;$.defaultBuildStages;$.defaultShaderStages;$.defined;$.degrees;$.deltaTime;$.densityFog;$.densityFogFactor;$.depth;$.depthPass;$.difference;$.diffuseColor;$.directPointLight;$.directionToColor;$.dispersion;$.distance;$.div;$.dodge;$.dot;$.drawIndex;$.dynamicBufferAttribute;$.element;$.emissive;$.equal;$.equals;$.equirectUV;const mle=$.exp;$.exp2;$.expression;$.faceDirection;$.faceForward;$.faceforward;const gle=$.float;$.floor;$.fog;$.fract;$.frameGroup;$.frameId;$.frontFacing;$.fwidth;$.gain;$.gapSize;$.getConstNodeType;$.getCurrentStack;$.getDirection;$.getDistanceAttenuation;$.getGeometryRoughness;$.getNormalFromDepth;$.getParallaxCorrectNormal;$.getRoughness;$.getScreenPosition;$.getShIrradianceAt;$.getTextureIndex;$.getViewPosition;$.glsl;$.glslFn;$.grayscale;$.greaterThan;$.greaterThanEqual;$.hash;$.highpModelNormalViewMatrix;$.highpModelViewMatrix;$.hue;$.instance;const vle=$.instanceIndex;$.instancedArray;$.instancedBufferAttribute;$.instancedDynamicBufferAttribute;$.instancedMesh;$.int;$.inverseSqrt;$.inversesqrt;$.invocationLocalIndex;$.invocationSubgroupIndex;$.ior;$.iridescence;$.iridescenceIOR;$.iridescenceThickness;$.ivec2;$.ivec3;$.ivec4;$.js;$.label;$.length;$.lengthSq;$.lessThan;$.lessThanEqual;$.lightPosition;$.lightTargetDirection;$.lightTargetPosition;$.lightViewPosition;$.lightingContext;$.lights;$.linearDepth;$.linearToneMapping;$.localId;$.log;$.log2;$.logarithmicDepthToViewZ;$.loop;$.luminance;$.mediumpModelViewMatrix;$.mat2;$.mat3;$.mat4;$.matcapUV;$.materialAO;$.materialAlphaTest;$.materialAnisotropy;$.materialAnisotropyVector;$.materialAttenuationColor;$.materialAttenuationDistance;$.materialClearcoat;$.materialClearcoatNormal;$.materialClearcoatRoughness;$.materialColor;$.materialDispersion;$.materialEmissive;$.materialIOR;$.materialIridescence;$.materialIridescenceIOR;$.materialIridescenceThickness;$.materialLightMap;$.materialLineDashOffset;$.materialLineDashSize;$.materialLineGapSize;$.materialLineScale;$.materialLineWidth;$.materialMetalness;$.materialNormal;$.materialOpacity;$.materialPointWidth;$.materialReference;$.materialReflectivity;$.materialRefractionRatio;$.materialRotation;$.materialRoughness;$.materialSheen;$.materialSheenRoughness;$.materialShininess;$.materialSpecular;$.materialSpecularColor;$.materialSpecularIntensity;$.materialSpecularStrength;$.materialThickness;$.materialTransmission;$.max;$.maxMipLevel;$.metalness;$.min;$.mix;$.mixElement;$.mod;$.modInt;$.modelDirection;$.modelNormalMatrix;$.modelPosition;$.modelScale;$.modelViewMatrix;$.modelViewPosition;$.modelViewProjection;$.modelWorldMatrix;$.modelWorldMatrixInverse;$.morphReference;$.mrt;$.mul;$.mx_aastep;$.mx_cell_noise_float;$.mx_contrast;$.mx_fractal_noise_float;$.mx_fractal_noise_vec2;$.mx_fractal_noise_vec3;$.mx_fractal_noise_vec4;$.mx_hsvtorgb;$.mx_noise_float;$.mx_noise_vec3;$.mx_noise_vec4;$.mx_ramplr;$.mx_ramptb;$.mx_rgbtohsv;$.mx_safepower;$.mx_splitlr;$.mx_splittb;$.mx_srgb_texture_to_lin_rec709;$.mx_transform_uv;$.mx_worley_noise_float;$.mx_worley_noise_vec2;$.mx_worley_noise_vec3;const _le=$.negate;$.neutralToneMapping;$.nodeArray;$.nodeImmutable;$.nodeObject;$.nodeObjects;$.nodeProxy;$.normalFlat;$.normalGeometry;$.normalLocal;$.normalMap;$.normalView;$.normalWorld;$.normalize;$.not;$.notEqual;$.numWorkgroups;$.objectDirection;$.objectGroup;$.objectPosition;$.objectScale;$.objectViewPosition;$.objectWorldMatrix;$.oneMinus;$.or;$.orthographicDepthToViewZ;$.oscSawtooth;$.oscSine;$.oscSquare;$.oscTriangle;$.output;$.outputStruct;$.overlay;$.overloadingFn;$.parabola;$.parallaxDirection;$.parallaxUV;$.parameter;$.pass;$.passTexture;$.pcurve;$.perspectiveDepthToViewZ;$.pmremTexture;$.pointUV;$.pointWidth;$.positionGeometry;$.positionLocal;$.positionPrevious;$.positionView;$.positionViewDirection;$.positionWorld;$.positionWorldDirection;$.posterize;$.pow;$.pow2;$.pow3;$.pow4;$.property;$.radians;$.rand;$.range;$.rangeFog;$.rangeFogFactor;$.reciprocal;$.reference;$.referenceBuffer;$.reflect;$.reflectVector;$.reflectView;$.reflector;$.refract;$.refractVector;$.refractView;$.reinhardToneMapping;$.remainder;$.remap;$.remapClamp;$.renderGroup;$.renderOutput;$.rendererReference;$.rotate;$.rotateUV;$.roughness;$.round;$.rtt;$.sRGBTransferEOTF;$.sRGBTransferOETF;$.sampler;$.saturate;$.saturation;$.screen;$.screenCoordinate;$.screenSize;$.screenUV;$.scriptable;$.scriptableValue;$.select;$.setCurrentStack;$.shaderStages;$.shadow;$.shadowPositionWorld;$.sharedUniformGroup;$.sheen;$.sheenRoughness;$.shiftLeft;$.shiftRight;$.shininess;$.sign;const yle=$.sin;$.sinc;$.skinning;$.skinningReference;$.smoothstep;$.smoothstepElement;$.specularColor;$.specularF90;$.spherizeUV;$.split;$.spritesheetUV;const xle=$.sqrt;$.stack;$.step;const ble=$.storage;$.storageBarrier;$.storageObject;$.storageTexture;$.string;$.sub;$.subgroupIndex;$.subgroupSize;$.tan;$.tangentGeometry;$.tangentLocal;$.tangentView;$.tangentWorld;$.temp;$.texture;$.texture3D;$.textureBarrier;$.textureBicubic;$.textureCubeUV;$.textureLoad;$.textureSize;$.textureStore;$.thickness;$.threshold;$.time;$.timerDelta;$.timerGlobal;$.timerLocal;$.toOutputColorSpace;$.toWorkingColorSpace;$.toneMapping;$.toneMappingExposure;$.toonOutlinePass;$.transformDirection;$.transformNormal;$.transformNormalToView;$.transformedBentNormalView;$.transformedBitangentView;$.transformedBitangentWorld;$.transformedClearcoatNormalView;$.transformedNormalView;$.transformedNormalWorld;$.transformedTangentView;$.transformedTangentWorld;$.transmission;$.transpose;$.tri;$.tri3;$.triNoise3D;$.triplanarTexture;$.triplanarTextures;$.trunc;$.tslFn;$.uint;const Sle=$.uniform;$.uniformArray;$.uniformGroup;$.uniforms;$.userData;$.uv;$.uvec2;$.uvec3;$.uvec4;$.varying;$.varyingProperty;$.vec2;$.vec3;$.vec4;$.vectorComponents;$.velocity;$.vertexColor;$.vertexIndex;$.vibrance;$.viewZToLogarithmicDepth;$.viewZToOrthographicDepth;$.viewZToPerspectiveDepth;$.viewport;$.viewportBottomLeft;$.viewportCoordinate;$.viewportDepthTexture;$.viewportLinearDepth;$.viewportMipTexture;$.viewportResolution;$.viewportSafeUV;$.viewportSharedTexture;$.viewportSize;$.viewportTexture;$.viewportTopLeft;$.viewportUV;$.wgsl;$.wgslFn;$.workgroupArray;$.workgroupBarrier;$.workgroupId;$.workingToColorSpace;$.xor;const I6=new Yc,Mv=new de;class hO extends Kz{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Ci(e,3)),this.setAttribute("uv",new Ci(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new h_(t,6,1);return this.setAttribute("instanceStart",new cu(n,3,0)),this.setAttribute("instanceEnd",new cu(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new h_(t,6,1);return this.setAttribute("instanceColorStart",new cu(n,3,0)),this.setAttribute("instanceColorEnd",new cu(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Dz(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yc);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),I6.setFromBufferAttribute(t),this.boundingBox.union(I6))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new gd),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let s=0,a=e.count;s - #include - #include - #include - #include - - uniform float linewidth; - uniform vec2 resolution; - - attribute vec3 instanceStart; - attribute vec3 instanceEnd; - - attribute vec3 instanceColorStart; - attribute vec3 instanceColorEnd; - - #ifdef WORLD_UNITS - - varying vec4 worldPos; - varying vec3 worldStart; - varying vec3 worldEnd; - - #ifdef USE_DASH - - varying vec2 vUv; - - #endif - - #else - - varying vec2 vUv; - - #endif - - #ifdef USE_DASH - - uniform float dashScale; - attribute float instanceDistanceStart; - attribute float instanceDistanceEnd; - varying float vLineDistance; - - #endif - - void trimSegment( const in vec4 start, inout vec4 end ) { - - // trim end segment so it terminates between the camera plane and the near plane - - // conservative estimate of the near plane - float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column - float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column - float nearEstimate = - 0.5 * b / a; - - float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); - - end.xyz = mix( start.xyz, end.xyz, alpha ); - - } - - void main() { - - #ifdef USE_COLOR - - vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; - - #endif - - #ifdef USE_DASH - - vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; - vUv = uv; - - #endif - - float aspect = resolution.x / resolution.y; - - // camera space - vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); - vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); - - #ifdef WORLD_UNITS - - worldStart = start.xyz; - worldEnd = end.xyz; - - #else - - vUv = uv; - - #endif - - // special case for perspective projection, and segments that terminate either in, or behind, the camera plane - // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space - // but we need to perform ndc-space calculations in the shader, so we must address this issue directly - // perhaps there is a more elegant solution -- WestLangley - - bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column - - if ( perspective ) { - - if ( start.z < 0.0 && end.z >= 0.0 ) { - - trimSegment( start, end ); - - } else if ( end.z < 0.0 && start.z >= 0.0 ) { - - trimSegment( end, start ); - - } - - } - - // clip space - vec4 clipStart = projectionMatrix * start; - vec4 clipEnd = projectionMatrix * end; - - // ndc space - vec3 ndcStart = clipStart.xyz / clipStart.w; - vec3 ndcEnd = clipEnd.xyz / clipEnd.w; - - // direction - vec2 dir = ndcEnd.xy - ndcStart.xy; - - // account for clip-space aspect ratio - dir.x *= aspect; - dir = normalize( dir ); - - #ifdef WORLD_UNITS - - vec3 worldDir = normalize( end.xyz - start.xyz ); - vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); - vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); - vec3 worldFwd = cross( worldDir, worldUp ); - worldPos = position.y < 0.5 ? start: end; - - // height offset - float hw = linewidth * 0.5; - worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; - - // don't extend the line if we're rendering dashes because we - // won't be rendering the endcaps - #ifndef USE_DASH - - // cap extension - worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; - - // add width to the box - worldPos.xyz += worldFwd * hw; - - // endcaps - if ( position.y > 1.0 || position.y < 0.0 ) { - - worldPos.xyz -= worldFwd * 2.0 * hw; - - } - - #endif - - // project the worldpos - vec4 clip = projectionMatrix * worldPos; - - // shift the depth of the projected points so the line - // segments overlap neatly - vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; - clip.z = clipPose.z * clip.w; - - #else - - vec2 offset = vec2( dir.y, - dir.x ); - // undo aspect ratio adjustment - dir.x /= aspect; - offset.x /= aspect; - - // sign flip - if ( position.x < 0.0 ) offset *= - 1.0; - - // endcaps - if ( position.y < 0.0 ) { - - offset += - dir; - - } else if ( position.y > 1.0 ) { - - offset += dir; - - } - - // adjust for linewidth - offset *= linewidth; - - // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... - offset /= resolution.y; - - // select end - vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; - - // back to clip space - offset *= clip.w; - - clip.xy += offset; - - #endif - - gl_Position = clip; - - vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation - - #include - #include - #include - - } - `,fragmentShader:` - uniform vec3 diffuse; - uniform float opacity; - uniform float linewidth; - - #ifdef USE_DASH - - uniform float dashOffset; - uniform float dashSize; - uniform float gapSize; - - #endif - - varying float vLineDistance; - - #ifdef WORLD_UNITS - - varying vec4 worldPos; - varying vec3 worldStart; - varying vec3 worldEnd; - - #ifdef USE_DASH - - varying vec2 vUv; - - #endif - - #else - - varying vec2 vUv; - - #endif - - #include - #include - #include - #include - #include - - vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { - - float mua; - float mub; - - vec3 p13 = p1 - p3; - vec3 p43 = p4 - p3; - - vec3 p21 = p2 - p1; - - float d1343 = dot( p13, p43 ); - float d4321 = dot( p43, p21 ); - float d1321 = dot( p13, p21 ); - float d4343 = dot( p43, p43 ); - float d2121 = dot( p21, p21 ); - - float denom = d2121 * d4343 - d4321 * d4321; - - float numer = d1343 * d4321 - d1321 * d4343; - - mua = numer / denom; - mua = clamp( mua, 0.0, 1.0 ); - mub = ( d1343 + d4321 * ( mua ) ) / d4343; - mub = clamp( mub, 0.0, 1.0 ); - - return vec2( mua, mub ); - - } - - void main() { - - #include - - #ifdef USE_DASH - - if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps - - if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX - - #endif - - float alpha = opacity; - - #ifdef WORLD_UNITS - - // Find the closest points on the view ray and the line segment - vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; - vec3 lineDir = worldEnd - worldStart; - vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); - - vec3 p1 = worldStart + lineDir * params.x; - vec3 p2 = rayEnd * params.y; - vec3 delta = p1 - p2; - float len = length( delta ); - float norm = len / linewidth; - - #ifndef USE_DASH - - #ifdef USE_ALPHA_TO_COVERAGE - - float dnorm = fwidth( norm ); - alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); - - #else - - if ( norm > 0.5 ) { - - discard; - - } - - #endif - - #endif - - #else - - #ifdef USE_ALPHA_TO_COVERAGE - - // artifacts appear on some hardware if a derivative is taken within a conditional - float a = vUv.x; - float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; - float len2 = a * a + b * b; - float dlen = fwidth( len2 ); - - if ( abs( vUv.y ) > 1.0 ) { - - alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); - - } - - #else - - if ( abs( vUv.y ) > 1.0 ) { - - float a = vUv.x; - float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; - float len2 = a * a + b * b; - - if ( len2 > 1.0 ) discard; - - } - - #endif - - #endif - - vec4 diffuseColor = vec4( diffuse, alpha ); - - #include - #include - - gl_FragColor = vec4( diffuseColor.rgb, alpha ); - - #include - #include - #include - #include - - } - `};class jE extends so{constructor(e){super({type:"LineMaterial",uniforms:vy.clone($a.line.uniforms),vertexShader:$a.line.vertexShader,fragmentShader:$a.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const ES=new qn,F6=new de,k6=new de,Hs=new qn,Ws=new qn,Jl=new qn,CS=new de,NS=new Xn,$s=new eG,z6=new de,Ev=new Yc,Cv=new gd,eu=new qn;let ou,od;function G6(i,e,t){return eu.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),eu.multiplyScalar(1/eu.w),eu.x=od/t.width,eu.y=od/t.height,eu.applyMatrix4(i.projectionMatrixInverse),eu.multiplyScalar(1/eu.w),Math.abs(Math.max(eu.x,eu.y))}function Tle(i,e){const t=i.matrixWorld,n=i.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,r.count);for(let l=0,u=a;lv&&Ws.z>v)continue;if(Hs.z>v){const U=Hs.z-Ws.z,I=(Hs.z-v)/U;Hs.lerp(Ws,I)}else if(Ws.z>v){const U=Ws.z-Hs.z,I=(Ws.z-v)/U;Ws.lerp(Hs,I)}Hs.applyMatrix4(n),Ws.applyMatrix4(n),Hs.multiplyScalar(1/Hs.w),Ws.multiplyScalar(1/Ws.w),Hs.x*=s.x/2,Hs.y*=s.y/2,Ws.x*=s.x/2,Ws.y*=s.y/2,$s.start.copy(Hs),$s.start.z=0,$s.end.copy(Ws),$s.end.z=0;const N=$s.closestPointToPointParameter(CS,!0);$s.at(N,z6);const C=N0.lerp(Hs.z,Ws.z,N),E=C>=-1&&C<=1,O=CS.distanceTo(z6)i.length)&&(e=i.length);for(var t=0,n=Array(e);t3?(K=be===Q)&&(W=ae[(G=ae[4])?5:(G=3,3)],ae[4]=ae[5]=i):ae[0]<=Ae&&((K=le<2&&AeQ||Q>be)&&(ae[4]=le,ae[5]=Q,te.n=be,G=0))}if(K||le>1)return a;throw Y=!0,Q}return function(le,Q,K){if(q>1)throw TypeError("Generator is already running");for(Y&&Q===1&&ne(Q,K),G=Q,W=K;(e=G<2?i:W)||!Y;){z||(G?G<3?(G>1&&(te.n=-1),ne(G,W)):te.n=W:te.v=W);try{if(q=2,z){if(G||(le="next"),e=z[le]){if(!(e=e.call(z,W)))throw TypeError("iterator result is not an object");if(!e.done)return e;W=e.value,G<2&&(G=0)}else G===1&&(e=z.return)&&e.call(z),G<2&&(W=TypeError("The iterator does not provide a '"+le+"' method"),G=1);z=i}else if((e=(Y=te.n<0)?W:U.call(I,te))!==a)break}catch(ae){z=i,G=1,W=ae}finally{q=1}}return{value:e,done:Y}}})(S,N,C),!0),O}var a={};function l(){}function u(){}function h(){}e=Object.getPrototypeOf;var m=[][n]?e(e([][n]())):(Co(e={},n,function(){return this}),e),v=h.prototype=l.prototype=Object.create(m);function x(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,Co(S,r,"GeneratorFunction")),S.prototype=Object.create(v),S}return u.prototype=h,Co(v,"constructor",h),Co(h,"constructor",u),u.displayName="GeneratorFunction",Co(h,r,"GeneratorFunction"),Co(v),Co(v,r,"Generator"),Co(v,n,function(){return this}),Co(v,"toString",function(){return"[object Generator]"}),(lw=function(){return{w:s,m:x}})()}function Co(i,e,t,n){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}Co=function(s,a,l,u){function h(m,v){Co(s,m,function(x){return this._invoke(m,v,x)})}a?r?r(s,a,{value:l,enumerable:!u,configurable:!u,writable:!u}):s[a]=l:(h("next",0),h("throw",1),h("return",2))},Co(i,e,t,n)}function uw(i,e){return uw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},uw(i,e)}function Sr(i,e){return Dle(i)||Fle(i,e)||pO(i,e)||kle()}function jle(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=V0(i))!==null;);return i}function PS(i,e,t,n){var r=ow(V0(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function Zi(i){return Ple(i)||Ile(i)||pO(i)||zle()}function Hle(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function AO(i){var e=Hle(i,"string");return typeof e=="symbol"?e:e+""}function pO(i,e){if(i){if(typeof i=="string")return aw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?aw(i,e):void 0}}var mO=function(e){e instanceof Array?e.forEach(mO):(e.map&&e.map.dispose(),e.dispose())},$E=function(e){e.geometry&&e.geometry.dispose(),e.material&&mO(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach($E)},sr=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),$E(t)}};function Pa(i,e){var t=new e;return{linkProp:function(r){return{default:t[r](),onChange:function(a,l){l[i][r](a)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var a=s[i],l=arguments.length,u=new Array(l>1?l-1:0),h=1;h2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180,s=mr*(1+t),a=Math.sin(n);return{x:s*a*Math.cos(r),y:s*Math.cos(n),z:s*a*Math.sin(r)}}function gO(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),a=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),altitude:r/mr-1}}function Wf(i){return i*Math.PI/180}var Lg=window.THREE?window.THREE:{BackSide:gr,BufferAttribute:Lr,Color:mn,Mesh:qi,ShaderMaterial:so},Wle=` -uniform float hollowRadius; - -varying vec3 vVertexWorldPosition; -varying vec3 vVertexNormal; -varying float vCameraDistanceToObjCenter; -varying float vVertexAngularDistanceToHollowRadius; - -void main() { - vVertexNormal = normalize(normalMatrix * normal); - vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; - - vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); - vCameraDistanceToObjCenter = length(objCenterViewPosition); - - float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter); - float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition))); - vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle; - - gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); -}`,$le=` -uniform vec3 color; -uniform float coefficient; -uniform float power; -uniform float hollowRadius; - -varying vec3 vVertexNormal; -varying vec3 vVertexWorldPosition; -varying float vCameraDistanceToObjCenter; -varying float vVertexAngularDistanceToHollowRadius; - -void main() { - if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius - if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius - - vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition; - vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz; - viewCameraToVertex = normalize(viewCameraToVertex); - float intensity = pow( - coefficient + dot(vVertexNormal, viewCameraToVertex), - power - ); - gl_FragColor = vec4(color, intensity); -}`;function Xle(i,e,t,n){return new Lg.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:Wle,fragmentShader:$le,uniforms:{coefficient:{value:i},color:{value:new Lg.Color(e)},power:{value:t},hollowRadius:{value:n}}})}function Yle(i,e){for(var t=i.clone(),n=new Float32Array(i.attributes.position.count*3),r=0,s=n.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.color,a=s===void 0?"gold":s,l=r.size,u=l===void 0?2:l,h=r.coefficient,m=h===void 0?.5:h,v=r.power,x=v===void 0?1:v,S=r.hollowRadius,w=S===void 0?0:S,N=r.backside,C=N===void 0?!0:N;nx(this,e),n=tx(this,e);var E=Yle(t,u),O=Xle(m,a,x,w);return C&&(O.side=Lg.BackSide),n.geometry=E,n.material=O,n}return rx(e,i),ix(e)})(Lg.Mesh),tu=window.THREE?window.THREE:{Color:mn,Group:Ka,LineBasicMaterial:Q0,LineSegments:Y7,Mesh:qi,MeshPhongMaterial:oD,SphereGeometry:Bu,SRGBColorSpace:Nn,TextureLoader:aM},vO=Rs({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){sr(e.globeObj),sr(e.tileEngine),sr(e.graticulesObj)}},stateInit:function(){var e=new tu.MeshPhongMaterial({color:0}),t=new tu.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new sY(mr),r=new tu.Group;r.__globeObjType="globe",r.add(t),r.add(n);var s=new tu.LineSegments(new AP(SX(),mr,2),new tu.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:r,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){sr(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var r;(r=e.globeObj.geometry)===null||r===void 0||r.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new tu.SphereGeometry(mr,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new tu.TextureLoader().load(e.globeImageUrl,function(l){l.colorSpace=tu.SRGBColorSpace,n.map=l,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new tu.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new tu.TextureLoader().load(e.bumpImageUrl,function(l){n.bumpMap=l,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),sr(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new Qle(e.globeObj.geometry,{color:e.atmosphereColor,size:mr*e.atmosphereAltitude,hollowRadius:mr,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType="atmosphere",e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),Lu=function(e){return isNaN(e)?parseInt(Rn(e).toHex(),16):e},kl=function(e){return e&&isNaN(e)?dd(e).opacity:1},Kh=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,s=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var l=a.slice(1),u=Sr(l,4),h=u[0],m=u[1],v=u[2],x=u[3];r=new mn("rgb(".concat(+h,",").concat(+m,",").concat(+v,")")),s=Math.min(+x,1)}else r=new mn(e);n&&r.convertLinearToSRGB();var S=r.toArray();return t?[].concat(Zi(S),[s]):S};function Kle(i,e,t){return i.opacity=e,i.transparent=e<1,i.depthWrite=e>=1,i}var W6=window.THREE?window.THREE:{BufferAttribute:Lr};function Uu(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(e===1)return new W6.BufferAttribute(new t(i),e);for(var n=new W6.BufferAttribute(new t(i.length*e),e),r=0,s=i.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.dataBindAttr,a=s===void 0?"__data":s,l=r.objBindAttr,u=l===void 0?"__threeObj":l,h=r.removeDelay,m=h===void 0?0:h;return nx(this,e),n=tx(this,e),Gs(n,"scene",void 0),RS(n,LS,void 0),RS(n,Nv,void 0),RS(n,Rv,void 0),n.scene=t,DS(LS,n,a),DS(Nv,n,u),DS(Rv,n,m),n.onRemoveObj(function(){}),n}return rx(e,i),ix(e,[{key:"onCreateObj",value:function(n){var r=this;return PS(e,"onCreateObj",this)([function(s){var a=n(s);return s[gm(Nv,r)]=a,a[gm(LS,r)]=s,r.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return PS(e,"onRemoveObj",this)([function(s,a){var l=PS(e,"getData",r)([s]);n(s,a);var u=function(){r.scene.remove(s),sr(s),delete l[gm(Nv,r)]};gm(Rv,r)?setTimeout(u,gm(Rv,r)):u()}]),this}}])})(UQ),Nl=window.THREE?window.THREE:{BufferGeometry:Ji,CylinderGeometry:nM,Matrix4:Xn,Mesh:qi,MeshLambertMaterial:Kc,Object3D:Tr,Vector3:de},$6=Object.assign({},bM),X6=$6.BufferGeometryUtils||$6,_O=Rs({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var n=kt(e.pointLat),r=kt(e.pointLng),s=kt(e.pointAltitude),a=kt(e.pointRadius),l=kt(e.pointColor),u=new Nl.CylinderGeometry(1,1,1,e.pointResolution);u.applyMatrix4(new Nl.Matrix4().makeRotationX(Math.PI/2)),u.applyMatrix4(new Nl.Matrix4().makeTranslation(0,0,-.5));var h=2*Math.PI*mr/360,m={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&sr(e.scene),e.dataMapper.scene=e.pointsMerge?new Nl.Object3D:e.scene,e.dataMapper.onCreateObj(S).onUpdateObj(w).digest(e.pointsData),e.pointsMerge){var v=e.pointsData.length?(X6.mergeGeometries||X6.mergeBufferGeometries)(e.pointsData.map(function(N){var C=e.dataMapper.getObj(N),E=C.geometry.clone();C.updateMatrix(),E.applyMatrix4(C.matrix);var O=Kh(l(N));return E.setAttribute("color",Uu(Array(E.getAttribute("position").count).fill(O),4)),E})):new Nl.BufferGeometry,x=new Nl.Mesh(v,new Nl.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));x.__globeObjType="points",x.__data=e.pointsData,e.dataMapper.clear(),sr(e.scene),e.scene.add(x)}function S(){var N=new Nl.Mesh(u);return N.__globeObjType="point",N}function w(N,C){var E=function(W){var q=N.__currentTargetD=W,V=q.r,Y=q.alt,te=q.lat,ne=q.lng;Object.assign(N.position,ul(te,ne));var le=e.pointsMerge?new Nl.Vector3(0,0,0):e.scene.localToWorld(new Nl.Vector3(0,0,0));N.lookAt(le),N.scale.x=N.scale.y=Math.min(30,V)*h,N.scale.z=Math.max(Y*mr,.1)},O={alt:+s(C),r:+a(C),lat:+n(C),lng:+r(C)},U=N.__currentTargetD||Object.assign({},O,{alt:-.001});if(Object.keys(O).some(function(G){return U[G]!==O[G]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?E(O):e.tweenGroup.add(new va(U).to(O,e.pointsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(E).start())),!e.pointsMerge){var I=l(C),j=I?kl(I):0,z=!!j;N.visible=z,z&&(m.hasOwnProperty(I)||(m[I]=new Nl.MeshLambertMaterial({color:Lu(I),transparent:j<1,opacity:j})),N.material=m[I])}}}}),yO=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` - `.concat(ni.common,` - `).concat(ni.logdepthbuf_pars_vertex,` - - uniform float dashTranslate; - - attribute vec4 color; - varying vec4 vColor; - - attribute float relDistance; - varying float vRelDistance; - - void main() { - // pass through colors and distances - vColor = color; - vRelDistance = relDistance + dashTranslate; - gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); - - `).concat(ni.logdepthbuf_vertex,` - } - `),fragmentShader:` - `.concat(ni.logdepthbuf_pars_fragment,` - - uniform float dashOffset; - uniform float dashSize; - uniform float gapSize; - - varying vec4 vColor; - varying float vRelDistance; - - void main() { - // ignore pixels in the gap - if (vRelDistance < dashOffset) discard; - if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard; - - // set px color: [r, g, b, a], interpolated between vertices - gl_FragColor = vColor; - - `).concat(ni.logdepthbuf_fragment,` - } - `)}},cw=function(e){return e.uniforms.uSurfaceRadius={type:"float",value:0},e.vertexShader=(`attribute float surfaceRadius; -varying float vSurfaceRadius; -varying vec3 vPos; -`+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join(` -`)),e.fragmentShader=(`uniform float uSurfaceRadius; -varying float vSurfaceRadius; -varying vec3 vPos; -`+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;"].join(` -`)),e},Jle=function(e){return e.vertexShader=` - attribute float r; - - const float PI = 3.1415926535897932384626433832795; - float toRad(in float a) { - return a * PI / 180.0; - } - - vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r] - float phi = toRad(90.0 - c.x); - float theta = toRad(90.0 - c.y); - float r = c.z; - return vec3( // x,y,z - r * sin(phi) * cos(theta), - r * cos(phi), - r * sin(phi) * sin(theta) - ); - } - - vec2 Cartesian2Polar(in vec3 p) { - float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z); - float phi = acos(p.y / r); - float theta = atan(p.z, p.x); - return vec2( // lat,lng - 90.0 - phi * 180.0 / PI, - 90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0) - ); - } - `.concat(e.vertexShader.replace("}",` - vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r)); - gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); - } - `),` - `),e},XE=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},eue=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(r){return r};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(r){n(r),t(r.uniforms)}}},tue=["stroke"],Rl=window.THREE?window.THREE:{BufferGeometry:Ji,CubicBezierCurve3:Z7,Curve:ql,Group:Ka,Line:xy,Mesh:qi,NormalBlending:io,ShaderMaterial:so,TubeGeometry:rM,Vector3:de},nue=O0.default||O0,xO=Rs({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new nue,sharedMaterial:new Rl.ShaderMaterial(Wi(Wi({},yO()),{},{transparent:!0,blending:Rl.NormalBlending}))}},init:function(e,t){sr(e),t.scene=e,t.dataMapper=new fo(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var n=new Rl.Group;return n.__globeObjType="arc",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Sr(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r,u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l})})},update:function(e){var t=kt(e.arcStartLat),n=kt(e.arcStartLng),r=kt(e.arcStartAltitude),s=kt(e.arcEndLat),a=kt(e.arcEndLng),l=kt(e.arcEndAltitude),u=kt(e.arcAltitude),h=kt(e.arcAltitudeAutoScale),m=kt(e.arcStroke),v=kt(e.arcColor),x=kt(e.arcDashLength),S=kt(e.arcDashGap),w=kt(e.arcDashInitialGap),N=kt(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(U,I){var j=m(I),z=j!=null;if(!U.children.length||z!==(U.children[0].type==="Mesh")){sr(U);var G=z?new Rl.Mesh:new Rl.Line(new Rl.BufferGeometry);G.material=e.sharedMaterial.clone(),U.add(G)}var W=U.children[0];Object.assign(W.material.uniforms,{dashSize:{value:x(I)},gapSize:{value:S(I)},dashOffset:{value:w(I)}});var q=N(I);W.__dashAnimateStep=q>0?1e3/q:0;var V=E(v(I),e.arcCurveResolution,z?e.arcCircularResolution+1:1),Y=O(e.arcCurveResolution,z?e.arcCircularResolution+1:1,!0);W.geometry.setAttribute("color",V),W.geometry.setAttribute("relDistance",Y);var te=function(K){var ae=U.__currentTargetD=K,Ae=ae.stroke,be=Gle(ae,tue),Se=C(be);z?(W.geometry&&W.geometry.dispose(),W.geometry=new Rl.TubeGeometry(Se,e.arcCurveResolution,Ae/2,e.arcCircularResolution),W.geometry.setAttribute("color",V),W.geometry.setAttribute("relDistance",Y)):W.geometry.setFromPoints(Se.getPoints(e.arcCurveResolution))},ne={stroke:j,alt:u(I),altAutoScale:+h(I),startLat:+t(I),startLng:+n(I),startAlt:+r(I),endLat:+s(I),endLng:+a(I),endAlt:+l(I)},le=U.__currentTargetD||Object.assign({},ne,{altAutoScale:-.001});Object.keys(ne).some(function(Q){return le[Q]!==ne[Q]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?te(ne):e.tweenGroup.add(new va(le).to(ne,e.arcsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(te).start()))}).digest(e.arcsData);function C(U){var I=U.alt,j=U.altAutoScale,z=U.startLat,G=U.startLng,W=U.startAlt,q=U.endLat,V=U.endLng,Y=U.endAlt,te=function(Qe){var et=Sr(Qe,3),Pt=et[0],Nt=et[1],Gt=et[2],Tt=ul(Nt,Pt,Gt),Ge=Tt.x,dt=Tt.y,he=Tt.z;return new Rl.Vector3(Ge,dt,he)},ne=[G,z],le=[V,q],Q=I;if(Q==null&&(Q=Yh(ne,le)/2*j+Math.max(W,Y)),Q||W||Y){var K=gM(ne,le),ae=function(Qe,et){return et+(et-Qe)*(Qe2&&arguments[2]!==void 0?arguments[2]:1,z=I+1,G;if(U instanceof Array||U instanceof Function){var W=U instanceof Array?zc().domain(U.map(function(Q,K){return K/(U.length-1)})).range(U):U;G=function(K){return Kh(W(K),!0,!0)}}else{var q=Kh(U,!0,!0);G=function(){return q}}for(var V=[],Y=0,te=z;Y1&&arguments[1]!==void 0?arguments[1]:1,j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,z=U+1,G=[],W=0,q=z;W=W?j:z}),4)),I})):new Dh.BufferGeometry,w=new Dh.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:Dh.DoubleSide});w.onBeforeCompile=function(O){w.userData.shader=cw(O)};var N=new Dh.Mesh(S,w);N.__globeObjType="hexBinPoints",N.__data=v,e.dataMapper.clear(),sr(e.scene),e.scene.add(N)}function C(O){var U=new Dh.Mesh;U.__hexCenter=LP(O.h3Idx),U.__hexGeoJson=UP(O.h3Idx,!0).reverse();var I=U.__hexCenter[1];return U.__hexGeoJson.forEach(function(j){var z=j[0];Math.abs(I-z)>170&&(j[0]+=I>z?360:-360)}),U.__globeObjType="hexbin",U}function E(O,U){var I=function(ae,Ae,be){return ae-(ae-Ae)*be},j=Math.max(0,Math.min(1,+h(U))),z=Sr(O.__hexCenter,2),G=z[0],W=z[1],q=j===0?O.__hexGeoJson:O.__hexGeoJson.map(function(K){var ae=Sr(K,2),Ae=ae[0],be=ae[1];return[[Ae,W],[be,G]].map(function(Se){var se=Sr(Se,2),Ee=se[0],qe=se[1];return I(Ee,qe,j)})}),V=e.hexTopCurvatureResolution;O.geometry&&O.geometry.dispose(),O.geometry=new EM([q],0,mr,!1,!0,!0,V);var Y={alt:+a(U)},te=function(ae){var Ae=O.__currentTargetD=ae,be=Ae.alt;O.scale.x=O.scale.y=O.scale.z=1+be;var Se=mr/(be+1);O.geometry.setAttribute("surfaceRadius",Uu(Array(O.geometry.getAttribute("position").count).fill(Se),1))},ne=O.__currentTargetD||Object.assign({},Y,{alt:-.001});if(Object.keys(Y).some(function(K){return ne[K]!==Y[K]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?te(Y):e.tweenGroup.add(new va(ne).to(Y,e.hexTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(te).start())),!e.hexBinMerge){var le=u(U),Q=l(U);[le,Q].forEach(function(K){if(!x.hasOwnProperty(K)){var ae=kl(K);x[K]=XE(new Dh.MeshLambertMaterial({color:Lu(K),transparent:ae<1,opacity:ae,side:Dh.DoubleSide}),cw)}}),O.material=[le,Q].map(function(K){return x[K]})}}}}),SO=function(e){return e*e},Lc=function(e){return e*Math.PI/180};function iue(i,e){var t=Math.sqrt,n=Math.cos,r=function(m){return SO(Math.sin(m/2))},s=Lc(i[1]),a=Lc(e[1]),l=Lc(i[0]),u=Lc(e[0]);return 2*Math.asin(t(r(a-s)+n(s)*n(a)*r(u-l)))}var rue=Math.sqrt(2*Math.PI);function sue(i,e){return Math.exp(-SO(i/e)/2)/(e*rue)}var aue=function(e){var t=Sr(e,2),n=t[0],r=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},l=a.lngAccessor,u=l===void 0?function(C){return C[0]}:l,h=a.latAccessor,m=h===void 0?function(C){return C[1]}:h,v=a.weightAccessor,x=v===void 0?function(){return 1}:v,S=a.bandwidth,w=[n,r],N=S*Math.PI/180;return JW(s.map(function(C){var E=x(C);if(!E)return 0;var O=iue(w,[u(C),m(C)]);return sue(O,N)*E}))},oue=(function(){var i=Ule(lw().m(function e(t){var n,r,s,a,l,u,h,m,v,x,S,w,N,C,E,O,U,I,j,z,G,W,q,V,Y,te,ne,le,Q,K,ae,Ae,be,Se,se,Ee,qe,Ce,ke,Qe,et=arguments,Pt,Nt,Gt;return lw().w(function(Tt){for(;;)switch(Tt.n){case 0:if(r=et.length>1&&et[1]!==void 0?et[1]:[],s=et.length>2&&et[2]!==void 0?et[2]:{},a=s.lngAccessor,l=a===void 0?function(Ge){return Ge[0]}:a,u=s.latAccessor,h=u===void 0?function(Ge){return Ge[1]}:u,m=s.weightAccessor,v=m===void 0?function(){return 1}:m,x=s.bandwidth,(n=navigator)!==null&&n!==void 0&&n.gpu){Tt.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),Tt.a(2,t.map(function(Ge){return aue(Ge,r,{lngAccessor:l,latAccessor:h,weightAccessor:v,bandwidth:x})}));case 1:return S=4,w=hle,N=fle,C=Sle,E=ble,O=gle,U=vle,I=dle,j=xle,z=yle,G=ple,W=Ale,q=mle,V=_le,Y=E(new t_(new Float32Array(t.flat().map(Lc)),2),"vec2",t.length),te=E(new t_(new Float32Array(r.map(function(Ge){return[Lc(l(Ge)),Lc(h(Ge)),v(Ge)]}).flat()),3),"vec3",r.length),ne=new t_(t.length,1),le=E(ne,"float",t.length),Q=O(Math.PI),K=j(Q.mul(2)),ae=function(dt){return dt.mul(dt)},Ae=function(dt){return ae(z(dt.div(2)))},be=function(dt,he){var en=O(dt[1]),wt=O(he[1]),qt=O(dt[0]),Lt=O(he[0]);return O(2).mul(W(j(Ae(wt.sub(en)).add(G(en).mul(G(wt)).mul(Ae(Lt.sub(qt)))))))},Se=function(dt,he){return q(V(ae(dt.div(he)).div(2))).div(he.mul(K))},se=C(Lc(x)),Ee=C(Lc(x*S)),qe=C(r.length),Ce=w(function(){var Ge=Y.element(U),dt=le.element(U);dt.assign(0),I(qe,function(he){var en=he.i,wt=te.element(en),qt=wt.z;N(qt,function(){var Lt=be(wt.xy,Ge.xy);N(Lt&&Lt.lessThan(Ee),function(){dt.addAssign(Se(Lt,se).mul(qt))})})})}),ke=Ce().compute(t.length),Qe=new cO,Tt.n=2,Qe.computeAsync(ke);case 2:return Pt=Array,Nt=Float32Array,Tt.n=3,Qe.getArrayBufferAsync(ne);case 3:return Gt=Tt.v,Tt.a(2,Pt.from.call(Pt,new Nt(Gt)))}},e)}));return function(t){return i.apply(this,arguments)}})(),Dv=window.THREE?window.THREE:{Mesh:qi,MeshLambertMaterial:Kc,SphereGeometry:Bu},lue=3.5,uue=.1,K6=100,cue=function(e){var t=dd(VZ(e));return t.opacity=Math.cbrt(e),t.formatRgb()},TO=Rs({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return cue}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var s=new Dv.Mesh(new Dv.SphereGeometry(mr),XE(new Dv.MeshLambertMaterial({vertexColors:!0,transparent:!0}),Jle));return s.__globeObjType="heatmap",s})},update:function(e){var t=kt(e.heatmapPoints),n=kt(e.heatmapPointLat),r=kt(e.heatmapPointLng),s=kt(e.heatmapPointWeight),a=kt(e.heatmapBandwidth),l=kt(e.heatmapColorFn),u=kt(e.heatmapColorSaturation),h=kt(e.heatmapBaseAltitude),m=kt(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(v,x){var S=a(x),w=l(x),N=u(x),C=h(x),E=m(x),O=t(x).map(function(G){var W=n(G),q=r(G),V=ul(W,q),Y=V.x,te=V.y,ne=V.z;return{x:Y,y:te,z:ne,lat:W,lng:q,weight:s(G)}}),U=Math.max(uue,S/lue),I=Math.ceil(360/(U||-1));v.geometry.parameters.widthSegments!==I&&(v.geometry.dispose(),v.geometry=new Dv.SphereGeometry(mr,I,I/2));var j=Zle(v.geometry.getAttribute("position")),z=j.map(function(G){var W=Sr(G,3),q=W[0],V=W[1],Y=W[2],te=gO({x:q,y:V,z:Y}),ne=te.lng,le=te.lat;return[ne,le]});oue(z,O,{latAccessor:function(W){return W.lat},lngAccessor:function(W){return W.lng},weightAccessor:function(W){return W.weight},bandwidth:S}).then(function(G){var W=Zi(new Array(K6)).map(function(te,ne){return Kh(w(ne/(K6-1)))}),q=function(ne){var le=v.__currentTargetD=ne,Q=le.kdeVals,K=le.topAlt,ae=le.saturation,Ae=QW(Q.map(Math.abs))||1e-15,be=UD([0,Ae/ae],W);v.geometry.setAttribute("color",Uu(Q.map(function(se){return be(Math.abs(se))}),4));var Se=zc([0,Ae],[mr*(1+C),mr*(1+(K||C))]);v.geometry.setAttribute("r",Uu(Q.map(Se)))},V={kdeVals:G,topAlt:E,saturation:N},Y=v.__currentTargetD||Object.assign({},V,{kdeVals:G.map(function(){return 0}),topAlt:E&&C,saturation:.5});Y.kdeVals.length!==G.length&&(Y.kdeVals=G.slice()),Object.keys(V).some(function(te){return Y[te]!==V[te]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?q(V):e.tweenGroup.add(new va(Y).to(V,e.heatmapsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(q).start()))})}).digest(e.heatmapsData)}}),Ph=window.THREE?window.THREE:{DoubleSide:gs,Group:Ka,LineBasicMaterial:Q0,LineSegments:Y7,Mesh:qi,MeshBasicMaterial:vd},wO=Rs({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjPolygon"}).id(function(s){return s.id}).onCreateObj(function(){var s=new Ph.Group;return s.__defaultSideMaterial=XE(new Ph.MeshBasicMaterial({side:Ph.DoubleSide,depthWrite:!0}),cw),s.__defaultCapMaterial=new Ph.MeshBasicMaterial({side:Ph.DoubleSide,depthWrite:!0}),s.add(new Ph.Mesh(void 0,[s.__defaultSideMaterial,s.__defaultCapMaterial])),s.add(new Ph.LineSegments(void 0,new Ph.LineBasicMaterial)),s.__globeObjType="polygon",s})},update:function(e){var t=kt(e.polygonGeoJsonGeometry),n=kt(e.polygonAltitude),r=kt(e.polygonCapCurvatureResolution),s=kt(e.polygonCapColor),a=kt(e.polygonCapMaterial),l=kt(e.polygonSideColor),u=kt(e.polygonSideMaterial),h=kt(e.polygonStrokeColor),m=[];e.polygonsData.forEach(function(v){var x={data:v,capColor:s(v),capMaterial:a(v),sideColor:l(v),sideMaterial:u(v),strokeColor:h(v),altitude:+n(v),capCurvatureResolution:+r(v)},S=t(v),w=v.__id||"".concat(Math.round(Math.random()*1e9));v.__id=w,S.type==="Polygon"?m.push(Wi({id:"".concat(w,"_0"),coords:S.coordinates},x)):S.type==="MultiPolygon"?m.push.apply(m,Zi(S.coordinates.map(function(N,C){return Wi({id:"".concat(w,"_").concat(C),coords:N},x)}))):console.warn("Unsupported GeoJson geometry type: ".concat(S.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(v,x){var S=x.coords,w=x.capColor,N=x.capMaterial,C=x.sideColor,E=x.sideMaterial,O=x.strokeColor,U=x.altitude,I=x.capCurvatureResolution,j=Sr(v.children,2),z=j[0],G=j[1],W=!!O;G.visible=W;var q=!!(w||N),V=!!(C||E);hue(z.geometry.parameters||{},{polygonGeoJson:S,curvatureResolution:I,closedTop:q,includeSides:V})||(z.geometry&&z.geometry.dispose(),z.geometry=new EM(S,0,mr,!1,q,V,I)),W&&(!G.geometry.parameters||G.geometry.parameters.geoJson.coordinates!==S||G.geometry.parameters.resolution!==I)&&(G.geometry&&G.geometry.dispose(),G.geometry=new AP({type:"Polygon",coordinates:S},mr,I));var Y=V?0:-1,te=q?V?1:0:-1;if(Y>=0&&(z.material[Y]=E||v.__defaultSideMaterial),te>=0&&(z.material[te]=N||v.__defaultCapMaterial),[[!E&&C,Y],[!N&&w,te]].forEach(function(Ae){var be=Sr(Ae,2),Se=be[0],se=be[1];if(!(!Se||se<0)){var Ee=z.material[se],qe=kl(Se);Ee.color.set(Lu(Se)),Ee.transparent=qe<1,Ee.opacity=qe}}),W){var ne=G.material,le=kl(O);ne.color.set(Lu(O)),ne.transparent=le<1,ne.opacity=le}var Q={alt:U},K=function(be){var Se=v.__currentTargetD=be,se=Se.alt;z.scale.x=z.scale.y=z.scale.z=1+se,W&&(G.scale.x=G.scale.y=G.scale.z=1+se+1e-4),eue(v.__defaultSideMaterial,function(Ee){return Ee.uSurfaceRadius.value=mr/(se+1)})},ae=v.__currentTargetD||Object.assign({},Q,{alt:-.001});Object.keys(Q).some(function(Ae){return ae[Ae]!==Q[Ae]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||ae.alt===Q.alt?K(Q):e.tweenGroup.add(new va(ae).to(Q,e.polygonsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(K).start()))}).digest(m)}});function hue(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(n,r){return n===r}};return Object.entries(e).every(function(n){var r=Sr(n,2),s=r[0],a=r[1];return i.hasOwnProperty(s)&&t(s)(i[s],a)})}var FA=window.THREE?window.THREE:{BufferGeometry:Ji,DoubleSide:gs,Mesh:qi,MeshLambertMaterial:Kc,Vector3:de},Z6=Object.assign({},bM),J6=Z6.BufferGeometryUtils||Z6,MO=Rs({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var s=new FA.Mesh(void 0,new FA.MeshLambertMaterial({side:FA.DoubleSide}));return s.__globeObjType="hexPolygon",s})},update:function(e){var t=kt(e.hexPolygonGeoJsonGeometry),n=kt(e.hexPolygonColor),r=kt(e.hexPolygonAltitude),s=kt(e.hexPolygonResolution),a=kt(e.hexPolygonMargin),l=kt(e.hexPolygonUseDots),u=kt(e.hexPolygonCurvatureResolution),h=kt(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(m,v){var x=t(v),S=s(v),w=r(v),N=Math.max(0,Math.min(1,+a(v))),C=l(v),E=u(v),O=h(v),U=n(v),I=kl(U);m.material.color.set(Lu(U)),m.material.transparent=I<1,m.material.opacity=I;var j={alt:w,margin:N,curvatureResolution:E},z={geoJson:x,h3Res:S},G=m.__currentTargetD||Object.assign({},j,{alt:-.001}),W=m.__currentMemD||z;if(Object.keys(j).some(function(te){return G[te]!==j[te]})||Object.keys(z).some(function(te){return W[te]!==z[te]})){m.__currentMemD=z;var q=[];x.type==="Polygon"?DR(x.coordinates,S,!0).forEach(function(te){return q.push(te)}):x.type==="MultiPolygon"?x.coordinates.forEach(function(te){return DR(te,S,!0).forEach(function(ne){return q.push(ne)})}):console.warn("Unsupported GeoJson geometry type: ".concat(x.type,". Skipping geometry..."));var V=q.map(function(te){var ne=LP(te),le=UP(te,!0).reverse(),Q=ne[1];return le.forEach(function(K){var ae=K[0];Math.abs(Q-ae)>170&&(K[0]+=Q>ae?360:-360)}),{h3Idx:te,hexCenter:ne,hexGeoJson:le}}),Y=function(ne){var le=m.__currentTargetD=ne,Q=le.alt,K=le.margin,ae=le.curvatureResolution;m.geometry&&m.geometry.dispose(),m.geometry=V.length?(J6.mergeGeometries||J6.mergeBufferGeometries)(V.map(function(Ae){var be=Sr(Ae.hexCenter,2),Se=be[0],se=be[1];if(C){var Ee=ul(Se,se,Q),qe=ul(Ae.hexGeoJson[0][1],Ae.hexGeoJson[0][0],Q),Ce=.85*(1-K)*new FA.Vector3(Ee.x,Ee.y,Ee.z).distanceTo(new FA.Vector3(qe.x,qe.y,qe.z)),ke=new by(Ce,O);return ke.rotateX(Wf(-Se)),ke.rotateY(Wf(se)),ke.translate(Ee.x,Ee.y,Ee.z),ke}else{var Qe=function(Nt,Gt,Tt){return Nt-(Nt-Gt)*Tt},et=K===0?Ae.hexGeoJson:Ae.hexGeoJson.map(function(Pt){var Nt=Sr(Pt,2),Gt=Nt[0],Tt=Nt[1];return[[Gt,se],[Tt,Se]].map(function(Ge){var dt=Sr(Ge,2),he=dt[0],en=dt[1];return Qe(he,en,K)})});return new EM([et],mr,mr*(1+Q),!1,!0,!1,ae)}})):new FA.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?Y(j):e.tweenGroup.add(new va(G).to(j,e.hexPolygonsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(Y).start())}}).digest(e.hexPolygonsData)}}),fue=window.THREE?window.THREE:{Vector3:de};function due(i,e){var t=function(a,l){var u=a[a.length-1];return[].concat(Zi(a),Zi(Array(l-a.length).fill(u)))},n=Math.max(i.length,e.length),r=p$.apply(void 0,Zi([i,e].map(function(s){return s.map(function(a){var l=a.x,u=a.y,h=a.z;return[l,u,h]})}).map(function(s){return t(s,n)})));return function(s){return s===0?i:s===1?e:r(s).map(function(a){var l=Sr(a,3),u=l[0],h=l[1],m=l[2];return new fue.Vector3(u,h,m)})}}var Bf=window.THREE?window.THREE:{BufferGeometry:Ji,Color:mn,Group:Ka,Line:xy,NormalBlending:io,ShaderMaterial:so,Vector3:de},Aue=O0.default||O0,EO=Rs({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new Aue,sharedMaterial:new Bf.ShaderMaterial(Wi(Wi({},yO()),{},{transparent:!0,blending:Bf.NormalBlending}))}},init:function(e,t){sr(e),t.scene=e,t.dataMapper=new fo(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var n=new Bf.Group;return n.__globeObjType="path",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Sr(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r;if(a.type==="Line"){var u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l}else if(a.type==="Line2"){for(var h=a.material.dashOffset-l,m=a.material.dashSize+a.material.gapSize;h<=-m;)h+=m;a.material.dashOffset=h}})})},update:function(e){var t=kt(e.pathPoints),n=kt(e.pathPointLat),r=kt(e.pathPointLng),s=kt(e.pathPointAlt),a=kt(e.pathStroke),l=kt(e.pathColor),u=kt(e.pathDashLength),h=kt(e.pathDashGap),m=kt(e.pathDashInitialGap),v=kt(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(C,E){var O=a(E),U=O!=null;if(!C.children.length||U===(C.children[0].type==="Line")){sr(C);var I=U?new Ele(new fO,new jE):new Bf.Line(new Bf.BufferGeometry,e.sharedMaterial.clone());C.add(I)}var j=C.children[0],z=S(t(E),n,r,s,e.pathResolution),G=v(E);if(j.__dashAnimateStep=G>0?1e3/G:0,U){j.material.resolution=e.rendererSize;{var V=u(E),Y=h(E),te=m(E);j.material.dashed=Y>0,j.material.dashed?j.material.defines.USE_DASH="":delete j.material.defines.USE_DASH,j.material.dashed&&(j.material.dashScale=1/x(z),j.material.dashSize=V,j.material.gapSize=Y,j.material.dashOffset=-te)}{var ne=l(E);if(ne instanceof Array){var le=w(l(E),z.length-1,1,!1);j.geometry.setColors(le.array),j.material.vertexColors=!0}else{var Q=ne,K=kl(Q);j.material.color=new Bf.Color(Lu(Q)),j.material.transparent=K<1,j.material.opacity=K,j.material.vertexColors=!1}}j.material.needsUpdate=!0}else{Object.assign(j.material.uniforms,{dashSize:{value:u(E)},gapSize:{value:h(E)},dashOffset:{value:m(E)}});var W=w(l(E),z.length),q=N(z.length,1,!0);j.geometry.setAttribute("color",W),j.geometry.setAttribute("relDistance",q)}var ae=due(C.__currentTargetD&&C.__currentTargetD.points||[z[0]],z),Ae=function(Ee){var qe=C.__currentTargetD=Ee,Ce=qe.stroke,ke=qe.interpolK,Qe=C.__currentTargetD.points=ae(ke);if(U){var et;j.geometry.setPositions((et=[]).concat.apply(et,Zi(Qe.map(function(Pt){var Nt=Pt.x,Gt=Pt.y,Tt=Pt.z;return[Nt,Gt,Tt]})))),j.material.linewidth=Ce,j.material.dashed&&j.computeLineDistances()}else j.geometry.setFromPoints(Qe),j.geometry.computeBoundingSphere()},be={stroke:O,interpolK:1},Se=Object.assign({},C.__currentTargetD||be,{interpolK:0});Object.keys(be).some(function(se){return Se[se]!==be[se]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?Ae(be):e.tweenGroup.add(new va(Se).to(be,e.pathTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(Ae).start()))}).digest(e.pathsData);function x(C){var E=0,O;return C.forEach(function(U){O&&(E+=O.distanceTo(U)),O=U}),E}function S(C,E,O,U,I){var j=function(q,V,Y){for(var te=[],ne=1;ne<=Y;ne++)te.push(q+(V-q)*ne/(Y+1));return te},z=function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Y=[],te=null;return q.forEach(function(ne){if(te){for(;Math.abs(te[1]-ne[1])>180;)te[1]+=360*(te[1]V)for(var Q=Math.floor(le/V),K=j(te[0],ne[0],Q),ae=j(te[1],ne[1],Q),Ae=j(te[2],ne[2],Q),be=0,Se=K.length;be2&&arguments[2]!==void 0?arguments[2]:1,U=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,I=E+1,j;if(C instanceof Array||C instanceof Function){var z=C instanceof Array?zc().domain(C.map(function(ne,le){return le/(C.length-1)})).range(C):C;j=function(le){return Kh(z(le),U,!0)}}else{var G=Kh(C,U,!0);j=function(){return G}}for(var W=[],q=0,V=I;q1&&arguments[1]!==void 0?arguments[1]:1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,U=C+1,I=[],j=0,z=U;j0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;nx(this,e),t=tx(this,e),t.type="CircleLineGeometry",t.parameters={radius:n,segmentCount:r};for(var s=[],a=0;a<=r;a++){var l=(a/r-.25)*Math.PI*2;s.push({x:Math.cos(l)*n,y:Math.sin(l)*n,z:0})}return t.setFromPoints(s),t}return rx(e,i),ix(e)})(pue.BufferGeometry),zA=window.THREE?window.THREE:{Color:mn,Group:Ka,Line:xy,LineBasicMaterial:Q0,Vector3:de},gue=O0.default||O0,RO=Rs({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var s=new zA.Group;return s.__globeObjType="ring",s}),t.ticker=new gue,t.ticker.onTick.add(function(s){if(t.ringsData.length){var a=kt(t.ringColor),l=kt(t.ringAltitude),u=kt(t.ringMaxRadius),h=kt(t.ringPropagationSpeed),m=kt(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(v){var x=Sr(v,2),S=x[1];return S}).forEach(function(v){var x=Sr(v,2),S=x[0],w=x[1];if((w.__nextRingTime||0)<=s){var N=m(S)/1e3;w.__nextRingTime=s+(N<=0?1/0:N);var C=new zA.Line(new mue(1,t.ringResolution),new zA.LineBasicMaterial),E=a(S),O=E instanceof Array||E instanceof Function,U;O?E instanceof Array?(U=zc().domain(E.map(function(Y,te){return te/(E.length-1)})).range(E),C.material.transparent=E.some(function(Y){return kl(Y)<1})):(U=E,C.material.transparent=!0):(C.material.color=new zA.Color(Lu(E)),Kle(C.material,kl(E)));var I=mr*(1+l(S)),j=u(S),z=j*Math.PI/180,G=h(S),W=G<=0,q=function(te){var ne=te.t,le=(W?1-ne:ne)*z;if(C.scale.x=C.scale.y=I*Math.sin(le),C.position.z=I*(1-Math.cos(le)),O){var Q=U(ne);C.material.color=new zA.Color(Lu(Q)),C.material.transparent&&(C.material.opacity=kl(Q))}};if(G===0)q({t:0}),w.add(C);else{var V=Math.abs(j/G)*1e3;t.tweenGroup.add(new va({t:0}).to({t:1},V).onUpdate(q).onStart(function(){return w.add(C)}).onComplete(function(){w.remove(C),$E(C)}).start())}}})}})},update:function(e){var t=kt(e.ringLat),n=kt(e.ringLng),r=kt(e.ringAltitude),s=e.scene.localToWorld(new zA.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(a,l){var u=t(l),h=n(l),m=r(l);Object.assign(a.position,ul(u,h,m)),a.lookAt(s)}).digest(e.ringsData)}}),vue={0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},_ue="normal",yue=1189,xue=-100,bue="normal",Sue={yMin:-334,xMin:-111,yMax:1189,xMax:1672},Tue=1e3,wue={postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r -\r -Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r -\r -The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r -\r -The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r -\r -This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r -\r -The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r -\r -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},Mue=-334,Eue="Helvetiker",Cue=1522,Nue=50,Rue={glyphs:vue,cssFontWeight:_ue,ascender:yue,underlinePosition:xue,cssFontStyle:bue,boundingBox:Sue,resolution:Tue,original_font_information:wue,descender:Mue,familyName:Eue,lineHeight:Cue,underlineThickness:Nue},Dl=Wi(Wi({},window.THREE?window.THREE:{BoxGeometry:Jh,CircleGeometry:by,DoubleSide:gs,Group:Ka,Mesh:qi,MeshLambertMaterial:Kc,TextGeometry:q6,Vector3:de}),{},{Font:Cle,TextGeometry:q6}),DO=Rs({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:Rue,onChange:function(e,t){t.font=new Dl.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r;var s=new Dl.CircleGeometry(1,32);t.dataMapper=new fo(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var a=new Dl.MeshLambertMaterial;a.side=gs;var l=new Dl.Group;l.add(new Dl.Mesh(s,a));var u=new Dl.Mesh(void 0,a);l.add(u);var h=new Dl.Mesh;return h.visible=!1,u.add(h),l.__globeObjType="label",l})},update:function(e){var t=kt(e.labelLat),n=kt(e.labelLng),r=kt(e.labelAltitude),s=kt(e.labelText),a=kt(e.labelSize),l=kt(e.labelRotation),u=kt(e.labelColor),h=kt(e.labelIncludeDot),m=kt(e.labelDotRadius),v=kt(e.labelDotOrientation),x=new Set(["right","top","bottom"]),S=2*Math.PI*mr/360;e.dataMapper.onUpdateObj(function(w,N){var C=Sr(w.children,2),E=C[0],O=C[1],U=Sr(O.children,1),I=U[0],j=u(N),z=kl(j);O.material.color.set(Lu(j)),O.material.transparent=z<1,O.material.opacity=z;var G=h(N),W=v(N);!G||!x.has(W)&&(W="bottom");var q=G?+m(N)*S:1e-12;E.scale.x=E.scale.y=q;var V=+a(N)*S;if(O.geometry&&O.geometry.dispose(),O.geometry=new Dl.TextGeometry(s(N),{font:e.font,size:V,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),I.geometry&&I.geometry.dispose(),O.geometry.computeBoundingBox(),I.geometry=HE(Dl.BoxGeometry,Zi(new Dl.Vector3().subVectors(O.geometry.boundingBox.max,O.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),W!=="right"&&O.geometry.center(),G){var Y=q+V/2;W==="right"&&(O.position.x=Y),O.position.y={right:-V/2,top:Y+V/2,bottom:-Y-V/2}[W]}var te=function(K){var ae=w.__currentTargetD=K,Ae=ae.lat,be=ae.lng,Se=ae.alt,se=ae.rot,Ee=ae.scale;Object.assign(w.position,ul(Ae,be,Se)),w.lookAt(e.scene.localToWorld(new Dl.Vector3(0,0,0))),w.rotateY(Math.PI),w.rotateZ(-se*Math.PI/180),w.scale.x=w.scale.y=w.scale.z=Ee},ne={lat:+t(N),lng:+n(N),alt:+r(N),rot:+l(N),scale:1},le=w.__currentTargetD||Object.assign({},ne,{scale:1e-12});Object.keys(ne).some(function(Q){return le[Q]!==ne[Q]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?te(ne):e.tweenGroup.add(new va(le).to(ne,e.labelsTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(te).start()))}).digest(e.labelsData)}}),Due=Wi(Wi({},window.THREE?window.THREE:{}),{},{CSS2DObject:kH}),PO=Rs({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){if(e.dataMapper){var n=t?[t]:e.dataMapper.entries().map(function(r){var s=Sr(r,2),a=s[1];return a}).filter(function(r){return r});n.forEach(function(r){var s=!e.isBehindGlobe||!e.isBehindGlobe(r.position);e.htmlElementVisibilityModifier?(r.visible=!0,e.htmlElementVisibilityModifier(r.element,s)):r.visible=s})}}},init:function(e,t,n){var r=n.tweenGroup;sr(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new fo(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(s){var a=kt(t.htmlElement)(s),l=new Due.CSS2DObject(a);return l.__globeObjType="html",l})},update:function(e,t){var n=this,r=kt(e.htmlLat),s=kt(e.htmlLng),a=kt(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(l,u){var h=function(x){var S=l.__currentTargetD=x,w=S.alt,N=S.lat,C=S.lng;Object.assign(l.position,ul(N,C,w)),n.updateObjVisibility(l)},m={lat:+r(u),lng:+s(u),alt:+a(u)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!l.__currentTargetD?h(m):e.tweenGroup.add(new va(l.__currentTargetD).to(m,e.htmlTransitionDuration).easing(vs.Quadratic.InOut).onUpdate(h).start())}).digest(e.htmlElementsData)}}),Lv=window.THREE?window.THREE:{Group:Ka,Mesh:qi,MeshLambertMaterial:Kc,SphereGeometry:Bu},LO=Rs({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new Lv.Mesh(new Lv.SphereGeometry(1,16,8),new Lv.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){sr(e),t.scene=e,t.dataMapper=new fo(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(n){var r=kt(t.objectThreeObject)(n);t.objectThreeObject===r&&(r=r.clone());var s=new Lv.Group;return s.add(r),s.__globeObjType="object",s})},update:function(e,t){var n=kt(e.objectLat),r=kt(e.objectLng),s=kt(e.objectAltitude),a=kt(e.objectFacesSurface),l=kt(e.objectRotation);t.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(u,h){var m=+n(h),v=+r(h),x=+s(h);Object.assign(u.position,ul(m,v,x)),a(h)?u.setRotationFromEuler(new ma(Wf(-m),Wf(v),0,"YXZ")):u.rotation.set(0,0,0);var S=u.children[0],w=l(h);w&&S.setRotationFromEuler(new ma(Wf(w.x||0),Wf(w.y||0),Wf(w.z||0)))}).digest(e.objectsData)}}),UO=Rs({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){sr(e),t.scene=e,t.dataMapper=new fo(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(n){var r=kt(t.customThreeObject)(n,mr);return r&&(t.customThreeObject===r&&(r=r.clone()),r.__globeObjType="custom"),r})},update:function(e,t){e.customThreeObjectUpdate||sr(e.scene);var n=kt(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(r,s){return n(r,s,mr)}).digest(e.customLayerData)}}),Uv=window.THREE?window.THREE:{Camera:_y,Group:Ka,Vector2:Et,Vector3:de},Pue=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],BO=Pa("globeLayer",vO),Lue=Object.assign.apply(Object,Zi(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(i){return Gs({},i,BO.linkProp(i))}))),Uue=Object.assign.apply(Object,Zi(["globeMaterial","globeTileEngineClearCache"].map(function(i){return Gs({},i,BO.linkMethod(i))}))),Bue=Pa("pointsLayer",_O),Oue=Object.assign.apply(Object,Zi(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(i){return Gs({},i,Bue.linkProp(i))}))),Iue=Pa("arcsLayer",xO),Fue=Object.assign.apply(Object,Zi(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(i){return Gs({},i,Iue.linkProp(i))}))),kue=Pa("hexBinLayer",bO),zue=Object.assign.apply(Object,Zi(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(i){return Gs({},i,kue.linkProp(i))}))),Gue=Pa("heatmapsLayer",TO),que=Object.assign.apply(Object,Zi(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(i){return Gs({},i,Gue.linkProp(i))}))),Vue=Pa("hexedPolygonsLayer",MO),jue=Object.assign.apply(Object,Zi(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(i){return Gs({},i,Vue.linkProp(i))}))),Hue=Pa("polygonsLayer",wO),Wue=Object.assign.apply(Object,Zi(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(i){return Gs({},i,Hue.linkProp(i))}))),$ue=Pa("pathsLayer",EO),Xue=Object.assign.apply(Object,Zi(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(i){return Gs({},i,$ue.linkProp(i))}))),Yue=Pa("tilesLayer",CO),Que=Object.assign.apply(Object,Zi(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(i){return Gs({},i,Yue.linkProp(i))}))),Kue=Pa("particlesLayer",NO),Zue=Object.assign.apply(Object,Zi(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(i){return Gs({},i,Kue.linkProp(i))}))),Jue=Pa("ringsLayer",RO),ece=Object.assign.apply(Object,Zi(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(i){return Gs({},i,Jue.linkProp(i))}))),tce=Pa("labelsLayer",DO),nce=Object.assign.apply(Object,Zi(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(i){return Gs({},i,tce.linkProp(i))}))),ice=Pa("htmlElementsLayer",PO),rce=Object.assign.apply(Object,Zi(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(i){return Gs({},i,ice.linkProp(i))}))),sce=Pa("objectsLayer",LO),ace=Object.assign.apply(Object,Zi(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(i){return Gs({},i,sce.linkProp(i))}))),oce=Pa("customLayer",UO),lce=Object.assign.apply(Object,Zi(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(i){return Gs({},i,oce.linkProp(i))}))),uce=Rs({props:Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi(Wi({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new Uv.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},Lue),Oue),Fue),zue),que),Wue),jue),Xue),Que),Zue),ece),nce),rce),ace),lce),methods:Wi({getGlobeRadius:H6,getCoords:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=(function(r){function s(){var a;nx(this,s);for(var l=arguments.length,u=new Array(l),h=0;he7&&(this.dispatchEvent(US),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>e7||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(US),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=ki.NONE,this.keyState=ki.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(US),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Lh.copy(this._panEnd).sub(this._panStart),Lh.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Lh.x*=e,Lh.y*=t}Lh.multiplyScalar(this._eye.length()*this.panSpeed),Ov.copy(this._eye).cross(this.object.up).setLength(Lh.x),Ov.add(fce.copy(this.object.up).setLength(Lh.y)),this.object.position.add(Ov),this.target.add(Ov),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Lh.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Fv.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Fv.length();e?(this._eye.copy(this.object.position).sub(this.target),t7.copy(this._eye).normalize(),Iv.copy(this.object.up).normalize(),OS.crossVectors(Iv,t7).normalize(),Iv.setLength(this._moveCurr.y-this._movePrev.y),OS.setLength(this._moveCurr.x-this._movePrev.x),Fv.copy(Iv.add(OS)),BS.crossVectors(Fv,this._eye).normalize(),e*=this.rotateSpeed,GA.setFromAxisAngle(BS,e),this._eye.applyQuaternion(GA),this.object.up.applyQuaternion(GA),this._lastAxis.copy(BS),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),GA.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(GA),this.object.up.applyQuaternion(GA)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===ki.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=N0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=N0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Bv.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Bv}_getMouseOnCircle(e,t){return Bv.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Bv}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=ja),r<-Math.PI?r+=ja:r>Math.PI&&(r-=ja),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(Ts.setFromSpherical(this._spherical),Ts.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ts),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=Ts.length();a=this._clampDistance(l*this._scale);const u=l-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),s=!!u}else if(this.object.isOrthographicCamera){const l=new de(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=u!==this.object.zoom;const h=new de(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(l),this.object.updateMatrixWorld(),a=Ts.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(kv.origin.copy(this.object.position),kv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(kv.direction))IS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>IS||this._lastTargetPosition.distanceToSquared(this.target)>IS?(this.dispatchEvent(n7),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ja/60*this.autoRotateSpeed*e:ja/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ts.setFromMatrixColumn(t,0),Ts.multiplyScalar(-e),this._panOffset.add(Ts)}_panUp(e,t){this.screenSpacePanning===!0?Ts.setFromMatrixColumn(t,1):(Ts.setFromMatrixColumn(t,0),Ts.crossVectors(this.object.up,Ts)),Ts.multiplyScalar(e),this._panOffset.add(Ts)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;Ts.copy(r).sub(this.target);let s=Ts.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,l=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(ja*this._rotateDelta.x/t.clientHeight),this._rotateUp(ja*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(ja*this._rotateDelta.x/t.clientHeight),this._rotateUp(ja*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tr7||8*(1-this._lastQuaternion.dot(t.quaternion))>r7)&&(this.dispatchEvent(qce),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function jce(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function Hce(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function Wce(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function $ce(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function Xce(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function Yce(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Qce(i){this.enabled!==!1&&i.preventDefault()}const Kce={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` - - varying vec2 vUv; - - void main() { - - vUv = uv; - gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); - - }`,fragmentShader:` - - uniform float opacity; - - uniform sampler2D tDiffuse; - - varying vec2 vUv; - - void main() { - - vec4 texel = texture2D( tDiffuse, vUv ); - gl_FragColor = opacity * texel; - - - }`};class sx{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Zce=new Gg(-1,1,1,-1,0,1);class Jce extends Ji{constructor(){super(),this.setAttribute("position",new Ci([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ci([0,2,0,0,2,0],2))}}const ehe=new Jce;class the{constructor(e){this._mesh=new qi(ehe,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Zce)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class nhe extends sx{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof so?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=vy.clone(e.uniforms),this.material=new so({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new the(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class a7 extends sx{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,l;this.inverse?(a=0,l=1):(a=1,l=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),s.buffers.stencil.setClear(l),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class ihe extends sx{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class rhe{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new Et);this._width=n.width,this._height=n.height,t=new Xh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Qs}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new nhe(Kce),this.copyPass.material.blending=no,this.clock=new hD}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&r<1?(l=s,u=a):r>=1&&r<2?(l=a,u=s):r>=2&&r<3?(u=s,h=a):r>=3&&r<4?(u=a,h=s):r>=4&&r<5?(l=a,h=s):r>=5&&r<6&&(l=s,h=a);var m=t-s/2,v=l+m,x=u+m,S=h+m;return n(v,x,S)}var o7={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function hhe(i){if(typeof i!="string")return i;var e=i.toLowerCase();return o7[e]?"#"+o7[e]:i}var fhe=/^#[a-fA-F0-9]{6}$/,dhe=/^#[a-fA-F0-9]{8}$/,Ahe=/^#[a-fA-F0-9]{3}$/,phe=/^#[a-fA-F0-9]{4}$/,kS=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,mhe=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,ghe=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,vhe=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function j0(i){if(typeof i!="string")throw new fu(3);var e=hhe(i);if(e.match(fhe))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(dhe)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(Ahe))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(phe)){var n=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:n}}var r=kS.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var s=mhe.exec(e.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var a=ghe.exec(e);if(a){var l=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,h=parseInt(""+a[3],10)/100,m="rgb("+oy(l,u,h)+")",v=kS.exec(m);if(!v)throw new fu(4,e,m);return{red:parseInt(""+v[1],10),green:parseInt(""+v[2],10),blue:parseInt(""+v[3],10)}}var x=vhe.exec(e.substring(0,50));if(x){var S=parseInt(""+x[1],10),w=parseInt(""+x[2],10)/100,N=parseInt(""+x[3],10)/100,C="rgb("+oy(S,w,N)+")",E=kS.exec(C);if(!E)throw new fu(4,e,C);return{red:parseInt(""+E[1],10),green:parseInt(""+E[2],10),blue:parseInt(""+E[3],10),alpha:parseFloat(""+x[4])>1?parseFloat(""+x[4])/100:parseFloat(""+x[4])}}throw new fu(5)}function _he(i){var e=i.red/255,t=i.green/255,n=i.blue/255,r=Math.max(e,t,n),s=Math.min(e,t,n),a=(r+s)/2;if(r===s)return i.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:i.alpha}:{hue:0,saturation:0,lightness:a};var l,u=r-s,h=a>.5?u/(2-r-s):u/(r+s);switch(r){case e:l=(t-n)/u+(t=1?kO(i.hue,i.saturation,i.lightness):"rgba("+oy(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new fu(2)}function zO(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return dw("#"+Gf(i)+Gf(e)+Gf(t));if(typeof i=="object"&&e===void 0&&t===void 0)return dw("#"+Gf(i.red)+Gf(i.green)+Gf(i.blue));throw new fu(6)}function ax(i,e,t,n){if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?zO(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")";throw new fu(7)}var The=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},whe=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},Mhe=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Ehe=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function rf(i){if(typeof i!="object")throw new fu(8);if(whe(i))return ax(i);if(The(i))return zO(i);if(Ehe(i))return She(i);if(Mhe(i))return bhe(i);throw new fu(8)}function GO(i,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?i.apply(this,r):GO(i,e,r)}}function ko(i){return GO(i,i.length,[])}function Che(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{hue:t.hue+parseFloat(i)}))}ko(Che);function np(i,e,t){return Math.max(i,Math.min(e,t))}function Nhe(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{lightness:np(0,1,t.lightness-parseFloat(i))}))}ko(Nhe);function Rhe(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{saturation:np(0,1,t.saturation-parseFloat(i))}))}ko(Rhe);function Dhe(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{lightness:np(0,1,t.lightness+parseFloat(i))}))}ko(Dhe);function Phe(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=j0(e),r=uo({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),s=j0(t),a=uo({},s,{alpha:typeof s.alpha=="number"?s.alpha:1}),l=r.alpha-a.alpha,u=parseFloat(i)*2-1,h=u*l===-1?u:u+l,m=1+u*l,v=(h/m+1)/2,x=1-v,S={red:Math.floor(r.red*v+a.red*x),green:Math.floor(r.green*v+a.green*x),blue:Math.floor(r.blue*v+a.blue*x),alpha:r.alpha*parseFloat(i)+a.alpha*(1-parseFloat(i))};return ax(S)}var Lhe=ko(Phe),qO=Lhe;function Uhe(i,e){if(e==="transparent")return e;var t=j0(e),n=typeof t.alpha=="number"?t.alpha:1,r=uo({},t,{alpha:np(0,1,(n*100+parseFloat(i)*100)/100)});return ax(r)}var Bhe=ko(Uhe),Ohe=Bhe;function Ihe(i,e){if(e==="transparent")return e;var t=nf(e);return rf(uo({},t,{saturation:np(0,1,t.saturation+parseFloat(i))}))}ko(Ihe);function Fhe(i,e){return e==="transparent"?e:rf(uo({},nf(e),{hue:parseFloat(i)}))}ko(Fhe);function khe(i,e){return e==="transparent"?e:rf(uo({},nf(e),{lightness:parseFloat(i)}))}ko(khe);function zhe(i,e){return e==="transparent"?e:rf(uo({},nf(e),{saturation:parseFloat(i)}))}ko(zhe);function Ghe(i,e){return e==="transparent"?e:qO(parseFloat(i),"rgb(0, 0, 0)",e)}ko(Ghe);function qhe(i,e){return e==="transparent"?e:qO(parseFloat(i),"rgb(255, 255, 255)",e)}ko(qhe);function Vhe(i,e){if(e==="transparent")return e;var t=j0(e),n=typeof t.alpha=="number"?t.alpha:1,r=uo({},t,{alpha:np(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return ax(r)}ko(Vhe);var Aw="http://www.w3.org/1999/xhtml";const l7={svg:"http://www.w3.org/2000/svg",xhtml:Aw,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function VO(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),l7.hasOwnProperty(e)?{space:l7[e],local:i}:i}function jhe(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===Aw&&e.documentElement.namespaceURI===Aw?e.createElement(i):e.createElementNS(t,i)}}function Hhe(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function jO(i){var e=VO(i);return(e.local?Hhe:jhe)(e)}function Whe(){}function HO(i){return i==null?Whe:function(){return this.querySelector(i)}}function $he(i){typeof i!="function"&&(i=HO(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r=U&&(U=O+1);!(j=C[U])&&++U=0;)(a=n[r])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function yfe(i){i||(i=xfe);function e(v,x){return v&&x?i(v.__data__,x.__data__):!v-!x}for(var t=this._groups,n=t.length,r=new Array(n),s=0;se?1:i>=e?0:NaN}function bfe(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function Sfe(){return Array.from(this)}function Tfe(){for(var i=this._groups,e=0,t=i.length;e1?this.each((e==null?Bfe:typeof e=="function"?Ife:Ofe)(i,e,t??"")):kfe(this.node(),i)}function kfe(i,e){return i.style.getPropertyValue(e)||XO(i).getComputedStyle(i,null).getPropertyValue(e)}function zfe(i){return function(){delete this[i]}}function Gfe(i,e){return function(){this[i]=e}}function qfe(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function Vfe(i,e){return arguments.length>1?this.each((e==null?zfe:typeof e=="function"?qfe:Gfe)(i,e)):this.node()[i]}function YO(i){return i.trim().split(/^|\s+/)}function ZE(i){return i.classList||new QO(i)}function QO(i){this._node=i,this._names=YO(i.getAttribute("class")||"")}QO.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function KO(i,e){for(var t=ZE(i),n=-1,r=e.length;++n=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function gde(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,r=e.length,s;t2&&(a.children=arguments.length>3?s1.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(s in i.defaultProps)a[s]===void 0&&(a[s]=i.defaultProps[s]);return Vm(i,a,n,r,null)}function Vm(i,e,t,n,r){var s={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++eI,__i:-1,__u:0};return r==null&&Pr.vnode!=null&&Pr.vnode(s),s}function lx(i){return i.children}function r_(i,e){this.props=i,this.context=e}function H0(i,e){if(e==null)return i.__?H0(i.__,i.__i+1):null;for(var t;ee&&$f.sort(iI),i=$f.shift(),e=$f.length,Dde(i);hy.__r=0}function aI(i,e,t,n,r,s,a,l,u,h,m){var v,x,S,w,N,C,E,O=n&&n.__k||cy,U=e.length;for(u=Pde(t,e,O,u,U),v=0;v0?a=i.__k[s]=Vm(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):i.__k[s]=a,u=s+x,a.__=i,a.__b=i.__b+1,l=null,(h=a.__i=Lde(a,t,u,v))!=-1&&(v--,(l=t[h])&&(l.__u|=2)),l==null||l.__v==null?(h==-1&&(r>m?x--:ru?x--:x++,a.__u|=4))):i.__k[s]=null;if(v)for(s=0;s(m?1:0)){for(r=t-1,s=t+1;r>=0||s=0?r--:s++])!=null&&(2&h.__u)==0&&l==h.key&&u==h.type)return a}return-1}function h7(i,e,t){e[0]=="-"?i.setProperty(e,t??""):i[e]=t==null?"":typeof t!="number"||Nde.test(e)?t:t+"px"}function zv(i,e,t,n,r){var s,a;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||h7(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||h7(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(rI,"$1")),a=e.toLowerCase(),e=a in i||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+s]=t,t?n?t.u=n.u:(t.u=JE,i.addEventListener(e,s?mw:pw,s)):i.removeEventListener(e,s?mw:pw,s);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function f7(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=JE++;else if(e.t0?i:ox(i)?i.map(uI):du({},i)}function Ude(i,e,t,n,r,s,a,l,u){var h,m,v,x,S,w,N,C=t.props||uy,E=e.props,O=e.type;if(O=="svg"?r="http://www.w3.org/2000/svg":O=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(h=0;h2&&(l.children=arguments.length>3?s1.call(arguments,2):t),Vm(i.type,l,n||i.key,r||i.ref,null)}s1=cy.slice,Pr={__e:function(i,e,t,n){for(var r,s,a;e=e.__;)if((r=e.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(i)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(i,n||{}),a=r.__d),a)return r.__E=r}catch(l){i=l}throw i}},eI=0,tI=function(i){return i!=null&&i.constructor===void 0},r_.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=du({},this.state),typeof i=="function"&&(i=i(du({},t),this.props)),i&&du(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),c7(this))},r_.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),c7(this))},r_.prototype.render=lx,$f=[],nI=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,iI=function(i,e){return i.__v.__b-e.__v.__b},hy.__r=0,rI=/(PointerCapture)$|Capture$/i,JE=0,pw=f7(!1),mw=f7(!0);function d7(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var Yde=`.float-tooltip-kap { - position: absolute; - width: max-content; /* prevent shrinking near right edge */ - max-width: max(50%, 150px); - padding: 3px 5px; - border-radius: 3px; - font: 12px sans-serif; - color: #eee; - background: rgba(0,0,0,0.6); - pointer-events: none; -} -`;Xde(Yde);var Qde=Rs({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.style,s=r===void 0?{}:r,a=!!e&&fy(e)==="object"&&!!e.node&&typeof e.node=="function",l=Mde(a?e.node():e);l.style("position")==="static"&&l.style("position","relative"),t.tooltipEl=l.append("div").attr("class","float-tooltip-kap"),Object.entries(s).forEach(function(h){var m=qde(h,2),v=m[0],x=m[1];return t.tooltipEl.style(v,x)}),t.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,l.on("mousemove.".concat(u),function(h){t.mouseInside=!0;var m=Cde(h),v=l.node(),x=v.offsetWidth,S=v.offsetHeight,w=[t.offsetX===null||t.offsetX===void 0?"-".concat(m[0]/x*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?S>130&&S-m[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",m[0]+"px").style("top",m[1]+"px").style("transform","translate(".concat(w.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseover.".concat(u),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseout.".concat(u),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):Wde(e.content)?(e.tooltipEl.text(""),$de(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function Kde(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var Zde=`.scene-nav-info { - position: absolute; - bottom: 5px; - width: 100%; - text-align: center; - color: slategrey; - opacity: 0.7; - font-size: 10px; - font-family: sans-serif; - pointer-events: none; - user-select: none; -} - -.scene-container canvas:focus { - outline: none; -}`;Kde(Zde);function _w(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,l){return e.hoverOrderComparator(a.object,l.object)});var s=r.find(function(a){return e.hoverFilter(a.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&kt(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var a=t,l=n||{x:0,y:0,z:0};if(!r)m(a),v(l);else{var u=Object.assign({},s.position),h=x();e.tweenGroup.add(new va(u).to(a,r).easing(vs.Quadratic.Out).onUpdate(m).start()),e.tweenGroup.add(new va(h).to(l,r/3).easing(vs.Quadratic.Out).onUpdate(v).start())}return this}return Object.assign({},s.position,{lookAt:x()});function m(S){var w=S.x,N=S.y,C=S.z;w!==void 0&&(s.position.x=w),N!==void 0&&(s.position.y=N),C!==void 0&&(s.position.z=C)}function v(S){var w=new Rr.Vector3(S.x,S.y,S.z);e.controls.enabled&&e.controls.target?e.controls.target=w:s.lookAt(w)}function x(){return Object.assign(new Rr.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var a=new Rr.Vector3(0,0,0),l=Math.max.apply(Math,Of(Object.entries(t).map(function(S){var w=aAe(S,2),N=w[0],C=w[1];return Math.max.apply(Math,Of(C.map(function(E){return Math.abs(a[N]-E)})))})))*2,u=(1-r*2/e.height)*s.fov,h=l/Math.atan(u*Math.PI/180),m=h/s.aspect,v=Math.max(h,m);if(v>0){var x=a.clone().sub(s.position).normalize().multiplyScalar(-v);this.cameraPosition(x,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new Rr.Box3(new Rr.Vector3(0,0,0),new Rr.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,Of(["x","y","z"].map(function(s){return tAe({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new Rr.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new Rr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new Rr.Raycaster;return a.setFromCamera(s,e.camera),Object.assign({},a.ray.at(r,new Rr.Vector3))},intersectingObjects:function(e,t,n){var r=new Rr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new Rr.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new Rr.Scene,camera:new Rr.PerspectiveCamera,clock:new Rr.Clock,tweenGroup:new My,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,a=n.useWebGPU,l=a===void 0?!1:a,u=n.rendererConfig,h=u===void 0?{}:u,m=n.extraRenderers,v=m===void 0?[]:m,x=n.waitForLoadComplete,S=x===void 0?!0:x;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new Qde(t.container),t.pointerPos=new Rr.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(w){return t.container.addEventListener(w,function(N){if(w==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&N.type==="pointermove"&&(N.pressure>0||t.isPointerPressed)&&(N.pointerType==="mouse"||N.movementX===void 0||[N.movementX,N.movementY].some(function(O){return Math.abs(O)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var C=E(t.container);t.pointerPos.x=N.pageX-C.left,t.pointerPos.y=N.pageY-C.top}function E(O){var U=O.getBoundingClientRect(),I=window.pageXOffset||document.documentElement.scrollLeft,j=window.pageYOffset||document.documentElement.scrollTop;return{top:U.top+j,left:U.left+I}}},{passive:!0})}),t.container.addEventListener("pointerup",function(w){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){w.button===0&&t.onClick(t.hoverObj||null,w,t.intersection),w.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,w,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(w){t.onRightClick&&w.preventDefault()}),t.renderer=new(l?cO:Rr.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},h)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=v,t.extraRenderers.forEach(function(w){w.domElement.style.position="absolute",w.domElement.style.top="0px",w.domElement.style.pointerEvents="none",t.container.appendChild(w.domElement)}),t.postProcessingComposer=new rhe(t.renderer),t.postProcessingComposer.addPass(new she(t.scene,t.camera)),t.controls=new{trackball:dce,orbit:Nce,fly:Vce}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Of(t.extraRenderers)).forEach(function(w){return w.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new Rr.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!S,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Of(e.extraRenderers)).forEach(function(S){return S.setSize(r,s)}),e.camera.aspect=r/s;var a=e.viewOffset.slice(0,2);a.some(function(S){return S})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(Of(a),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var l,u=e.width,h=e.height,m=e.viewOffset.slice(0,2);m.some(function(S){return S})?(l=e.camera).setViewOffset.apply(l,[u,h].concat(Of(m),[u,h])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new Rr.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var v=j0(e.backgroundColor).alpha;v===void 0&&(v=1),e.renderer.setClearColor(new Rr.Color(Ohe(1,e.backgroundColor)),v)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new Rr.TextureLoader().load(e.backgroundImageUrl,function(S){S.colorSpace=Rr.SRGBColorSpace,e.skysphere.material=new Rr.MeshBasicMaterial({map:S,side:Rr.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&x()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&x())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(S){return e.scene.remove(S)}),e.lights.forEach(function(S){return e.scene.add(S)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(S){return e.scene.remove(S)}),e.objects.forEach(function(S){return e.scene.add(S)}));function x(){e.loadComplete=e.scene.visible=!0}}});function uAe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var cAe=`.scene-container .clickable { - cursor: pointer; -}`;uAe(cAe);function yw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1?l-1:0),h=1;h1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=a();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(u){return s[u]=+s[u]}),!n)l(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new va(r).to(s,n).easing(vs.Cubic.InOut).onUpdate(l).start())}return this;function a(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(u){var h=u.lat,m=u.lng,v=u.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(h,m,v)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;slocalStorage.getItem("radio-theme")||"default"),[a,l]=ie.useState([]),[u,h]=ie.useState(null),[m,v]=ie.useState([]),[x,S]=ie.useState(!1),[w,N]=ie.useState({}),[C,E]=ie.useState([]),[O,U]=ie.useState(""),[I,j]=ie.useState(""),[z,G]=ie.useState(""),[W,q]=ie.useState([]),[V,Y]=ie.useState(!1),[te,ne]=ie.useState([]),[le,Q]=ie.useState(!1),[K,ae]=ie.useState(!1),[Ae,be]=ie.useState(.5),[Se,se]=ie.useState(null),[Ee,qe]=ie.useState(!1),[Ce,ke]=ie.useState(!1),Qe=ie.useRef(void 0),et=ie.useRef(void 0),Pt=ie.useRef(O);ie.useEffect(()=>{fetch("/api/radio/places").then(k=>k.json()).then(l).catch(console.error),fetch("/api/radio/guilds").then(k=>k.json()).then(k=>{if(E(k),k.length>0){U(k[0].id);const _e=k[0].voiceChannels.find(Be=>Be.members>0)??k[0].voiceChannels[0];_e&&j(_e.id)}}).catch(console.error),fetch("/api/radio/favorites").then(k=>k.json()).then(ne).catch(console.error)},[]),ie.useEffect(()=>{Pt.current=O},[O]),ie.useEffect(()=>{i!=null&&i.guildId&&"playing"in i&&i.type!=="radio_voicestats"?N(k=>{if(i.playing)return{...k,[i.guildId]:i.playing};const _e={...k};return delete _e[i.guildId],_e}):i!=null&&i.playing&&!(i!=null&&i.guildId)&&N(i.playing),i!=null&&i.favorites&&ne(i.favorites),i!=null&&i.volumes&&O&&i.volumes[O]!=null&&be(i.volumes[O]),(i==null?void 0:i.volume)!=null&&(i==null?void 0:i.guildId)===O&&be(i.volume),(i==null?void 0:i.type)==="radio_voicestats"&&i.guildId===Pt.current&&se({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})},[i,O]),ie.useEffect(()=>{if(localStorage.setItem("radio-theme",r),t.current&&e.current){const _e=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim();t.current.pointColor(()=>`rgba(${_e}, 0.85)`).atmosphereColor(`rgba(${_e}, 0.25)`)}},[r]);const Nt=ie.useRef(u);Nt.current=u;const Gt=ie.useRef(le);Gt.current=le;const Tt=ie.useCallback(()=>{var _e;const k=(_e=t.current)==null?void 0:_e.controls();k&&(k.autoRotate=!1),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{var Oe;if(Nt.current||Gt.current)return;const Be=(Oe=t.current)==null?void 0:Oe.controls();Be&&(Be.autoRotate=!0)},5e3)},[]);ie.useEffect(()=>{var _e;const k=(_e=t.current)==null?void 0:_e.controls();k&&(u||le?(k.autoRotate=!1,n.current&&clearTimeout(n.current)):k.autoRotate=!0)},[u,le]);const Ge=ie.useRef(void 0);Ge.current=k=>{h(k),Q(!1),S(!0),v([]),Tt(),t.current&&t.current.pointOfView({lat:k.geo[1],lng:k.geo[0],altitude:.4},800),fetch(`/api/radio/place/${k.id}/channels`).then(_e=>_e.json()).then(_e=>{v(_e),S(!1)}).catch(()=>S(!1))},ie.useEffect(()=>{const k=e.current;if(!k)return;k.clientWidth>0&&k.clientHeight>0&&ke(!0);const _e=new ResizeObserver(Be=>{for(const Oe of Be){const{width:je,height:Bt}=Oe.contentRect;je>0&&Bt>0&&ke(!0)}});return _e.observe(k),()=>_e.disconnect()},[]),ie.useEffect(()=>{if(!e.current||a.length===0)return;const k=e.current.clientWidth,_e=e.current.clientHeight;if(t.current){t.current.pointsData(a),k>0&&_e>0&&t.current.width(k).height(_e);return}if(k===0||_e===0)return;const Oe=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim()||"230, 126, 34",je=new TAe(e.current).backgroundColor("rgba(0,0,0,0)").atmosphereColor(`rgba(${Oe}, 0.25)`).atmosphereAltitude(.12).globeImageUrl("/nasa-blue-marble.jpg").pointsData(a).pointLat($t=>$t.geo[1]).pointLng($t=>$t.geo[0]).pointColor(()=>`rgba(${Oe}, 0.85)`).pointRadius($t=>Math.max(.12,Math.min(.45,.06+($t.size??1)*.005))).pointAltitude(.001).pointResolution(24).pointLabel($t=>`

`).onPointClick($t=>{var It;return(It=Ge.current)==null?void 0:It.call(Ge,$t)}).width(e.current.clientWidth).height(e.current.clientHeight);je.renderer().setPixelRatio(window.devicePixelRatio),je.pointOfView({lat:48,lng:10,altitude:GS});const Bt=je.controls();Bt&&(Bt.autoRotate=!0,Bt.autoRotateSpeed=.3);let yt=GS;const Xt=()=>{const It=je.pointOfView().altitude;if(Math.abs(It-yt)/yt<.05)return;yt=It;const Te=Math.sqrt(It/GS);je.pointRadius(nt=>Math.max(.12,Math.min(.45,.06+(nt.size??1)*.005))*Math.max(.15,Math.min(2.5,Te)))};Bt.addEventListener("change",Xt),t.current=je;const ln=e.current,mt=()=>Tt();ln.addEventListener("mousedown",mt),ln.addEventListener("touchstart",mt),ln.addEventListener("wheel",mt);const Wt=()=>{if(e.current&&t.current){const $t=e.current.clientWidth,It=e.current.clientHeight;$t>0&&It>0&&t.current.width($t).height(It)}};window.addEventListener("resize",Wt);const Yt=new ResizeObserver(()=>Wt());return Yt.observe(ln),()=>{Bt.removeEventListener("change",Xt),ln.removeEventListener("mousedown",mt),ln.removeEventListener("touchstart",mt),ln.removeEventListener("wheel",mt),window.removeEventListener("resize",Wt),Yt.disconnect()}},[a,Tt,Ce]);const dt=ie.useCallback(async(k,_e,Be,Oe)=>{if(!(!O||!I)){ae(!0);try{(await(await fetch("/api/radio/play",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,voiceChannelId:I,stationId:k,stationName:_e,placeName:Be??(u==null?void 0:u.title)??"",country:Oe??(u==null?void 0:u.country)??""})})).json()).ok&&(N(yt=>{var Xt,ln;return{...yt,[O]:{stationId:k,stationName:_e,placeName:Be??(u==null?void 0:u.title)??"",country:Oe??(u==null?void 0:u.country)??"",startedAt:new Date().toISOString(),channelName:((ln=(Xt=C.find(mt=>mt.id===O))==null?void 0:Xt.voiceChannels.find(mt=>mt.id===I))==null?void 0:ln.name)??""}}}),Tt())}catch(je){console.error(je)}ae(!1)}},[O,I,u,C]),he=ie.useCallback(async()=>{O&&(await fetch("/api/radio/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O})}),N(k=>{const _e={...k};return delete _e[O],_e}))},[O]),en=ie.useCallback(k=>{if(G(k),Qe.current&&clearTimeout(Qe.current),!k.trim()){q([]),Y(!1);return}Qe.current=setTimeout(async()=>{try{const Be=await(await fetch(`/api/radio/search?q=${encodeURIComponent(k)}`)).json();q(Be),Y(!0)}catch{q([])}},350)},[]),wt=ie.useCallback(k=>{var _e,Be,Oe;if(Y(!1),G(""),q([]),k.type==="channel"){const je=(_e=k.url.match(/\/listen\/[^/]+\/([^/]+)/))==null?void 0:_e[1];je&&dt(je,k.title,k.subtitle,"")}else if(k.type==="place"){const je=(Be=k.url.match(/\/visit\/[^/]+\/([^/]+)/))==null?void 0:Be[1],Bt=a.find(yt=>yt.id===je);Bt&&((Oe=Ge.current)==null||Oe.call(Ge,Bt))}},[a,dt]),qt=ie.useCallback(async(k,_e)=>{try{const Oe=await(await fetch("/api/radio/favorites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stationId:k,stationName:_e,placeName:(u==null?void 0:u.title)??"",country:(u==null?void 0:u.country)??"",placeId:(u==null?void 0:u.id)??""})})).json();Oe.favorites&&ne(Oe.favorites)}catch{}},[u]),Lt=ie.useCallback(k=>{be(k),O&&(et.current&&clearTimeout(et.current),et.current=setTimeout(()=>{fetch("/api/radio/volume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,volume:k})}).catch(console.error)},100))},[O]),hn=k=>te.some(_e=>_e.stationId===k),ut=O?w[O]:null,fe=C.find(k=>k.id===O);return P.jsxs("div",{className:"radio-container","data-theme":r,children:[P.jsxs("header",{className:"radio-topbar",children:[P.jsxs("div",{className:"radio-topbar-left",children:[P.jsx("span",{className:"radio-topbar-logo",children:"🌍"}),P.jsx("span",{className:"radio-topbar-title",children:"World Radio"}),C.length>1&&P.jsx("select",{className:"radio-sel",value:O,onChange:k=>{U(k.target.value);const _e=C.find(Oe=>Oe.id===k.target.value),Be=(_e==null?void 0:_e.voiceChannels.find(Oe=>Oe.members>0))??(_e==null?void 0:_e.voiceChannels[0]);j((Be==null?void 0:Be.id)??"")},children:C.map(k=>P.jsx("option",{value:k.id,children:k.name},k.id))}),P.jsxs("select",{className:"radio-sel",value:I,onChange:k=>j(k.target.value),children:[P.jsx("option",{value:"",children:"Voice Channel..."}),fe==null?void 0:fe.voiceChannels.map(k=>P.jsxs("option",{value:k.id,children:["🔊"," ",k.name,k.members>0?` (${k.members})`:""]},k.id))]})]}),ut&&P.jsxs("div",{className:"radio-topbar-np",children:[P.jsxs("div",{className:"radio-eq radio-eq-np",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),P.jsxs("div",{className:"radio-np-info",children:[P.jsx("span",{className:"radio-np-name",children:ut.stationName}),P.jsxs("span",{className:"radio-np-loc",children:[ut.placeName,ut.country?`, ${ut.country}`:""]})]})]}),P.jsxs("div",{className:"radio-topbar-right",children:[ut&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"radio-volume",children:[P.jsx("span",{className:"radio-volume-icon",children:Ae===0?"🔇":Ae<.4?"🔉":"🔊"}),P.jsx("input",{type:"range",className:"radio-volume-slider",min:0,max:1,step:.01,value:Ae,onChange:k=>Lt(Number(k.target.value))}),P.jsxs("span",{className:"radio-volume-val",children:[Math.round(Ae*100),"%"]})]}),P.jsxs("div",{className:"radio-conn",onClick:()=>qe(!0),title:"Verbindungsdetails",children:[P.jsx("span",{className:"radio-conn-dot"}),"Verbunden",(Se==null?void 0:Se.voicePing)!=null&&P.jsxs("span",{className:"radio-conn-ping",children:[Se.voicePing,"ms"]})]}),P.jsxs("button",{className:"radio-topbar-stop",onClick:he,children:["⏹"," Stop"]})]}),P.jsx("div",{className:"radio-theme-inline",children:wAe.map(k=>P.jsx("div",{className:`radio-theme-dot ${r===k.id?"active":""}`,style:{background:k.color},title:k.label,onClick:()=>s(k.id)},k.id))})]})]}),P.jsxs("div",{className:"radio-globe-wrap",children:[P.jsx("div",{className:"radio-globe",ref:e}),P.jsxs("div",{className:"radio-search",children:[P.jsxs("div",{className:"radio-search-wrap",children:[P.jsx("span",{className:"radio-search-icon",children:"🔍"}),P.jsx("input",{className:"radio-search-input",type:"text",placeholder:"Sender oder Stadt suchen...",value:z,onChange:k=>en(k.target.value),onFocus:()=>{W.length&&Y(!0)}}),z&&P.jsx("button",{className:"radio-search-clear",onClick:()=>{G(""),q([]),Y(!1)},children:"✕"})]}),V&&W.length>0&&P.jsx("div",{className:"radio-search-results",children:W.slice(0,12).map(k=>P.jsxs("button",{className:"radio-search-result",onClick:()=>wt(k),children:[P.jsx("span",{className:"radio-search-result-icon",children:k.type==="channel"?"📻":k.type==="place"?"📍":"🌍"}),P.jsxs("div",{className:"radio-search-result-text",children:[P.jsx("span",{className:"radio-search-result-title",children:k.title}),P.jsx("span",{className:"radio-search-result-sub",children:k.subtitle})]})]},k.id+k.url))})]}),!u&&!le&&P.jsxs("button",{className:"radio-fab",onClick:()=>{Q(!0),h(null)},title:"Favoriten",children:["⭐",te.length>0&&P.jsx("span",{className:"radio-fab-badge",children:te.length})]}),le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("h3",{children:["⭐"," Favoriten"]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>Q(!1),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:te.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Noch keine Favoriten"}):te.map(k=>P.jsxs("div",{className:`radio-station ${(ut==null?void 0:ut.stationId)===k.stationId?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.stationName}),P.jsxs("span",{className:"radio-station-loc",children:[k.placeName,", ",k.country]})]}),P.jsxs("div",{className:"radio-station-btns",children:[P.jsx("button",{className:"radio-btn-play",onClick:()=>dt(k.stationId,k.stationName,k.placeName,k.country),disabled:!I||K,children:"▶"}),P.jsx("button",{className:"radio-btn-fav active",onClick:()=>qt(k.stationId,k.stationName),children:"★"})]})]},k.stationId))})]}),u&&!le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("div",{children:[P.jsx("h3",{children:u.title}),P.jsx("span",{className:"radio-panel-sub",children:u.country})]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>h(null),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:x?P.jsxs("div",{className:"radio-panel-loading",children:[P.jsx("div",{className:"radio-spinner"}),"Sender werden geladen..."]}):m.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Keine Sender gefunden"}):m.map(k=>P.jsxs("div",{className:`radio-station ${(ut==null?void 0:ut.stationId)===k.id?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.title}),(ut==null?void 0:ut.stationId)===k.id&&P.jsxs("span",{className:"radio-station-live",children:[P.jsxs("span",{className:"radio-eq",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),"Live"]})]}),P.jsxs("div",{className:"radio-station-btns",children:[(ut==null?void 0:ut.stationId)===k.id?P.jsx("button",{className:"radio-btn-stop",onClick:he,children:"⏹"}):P.jsx("button",{className:"radio-btn-play",onClick:()=>dt(k.id,k.title),disabled:!I||K,children:"▶"}),P.jsx("button",{className:`radio-btn-fav ${hn(k.id)?"active":""}`,onClick:()=>qt(k.id,k.title),children:hn(k.id)?"★":"☆"})]})]},k.id))})]}),P.jsxs("div",{className:"radio-counter",children:["📻"," ",a.length.toLocaleString("de-DE")," Sender weltweit"]}),P.jsx("a",{className:"radio-attribution",href:"https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/",target:"_blank",rel:"noreferrer",children:"Imagery © NASA Blue Marble"})]}),Ee&&(()=>{const k=Se!=null&&Se.connectedSince?Math.floor((Date.now()-new Date(Se.connectedSince).getTime())/1e3):0,_e=Math.floor(k/3600),Be=Math.floor(k%3600/60),Oe=k%60,je=_e>0?`${_e}h ${String(Be).padStart(2,"0")}m ${String(Oe).padStart(2,"0")}s`:Be>0?`${Be}m ${String(Oe).padStart(2,"0")}s`:`${Oe}s`,Bt=yt=>yt==null?"var(--text-faint)":yt<80?"var(--success)":yt<150?"#f0a830":"#e04040";return P.jsx("div",{className:"radio-modal-overlay",onClick:()=>qe(!1),children:P.jsxs("div",{className:"radio-modal",onClick:yt=>yt.stopPropagation(),children:[P.jsxs("div",{className:"radio-modal-header",children:[P.jsx("span",{children:"📡"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"radio-modal-close",onClick:()=>qe(!1),children:"✕"})]}),P.jsxs("div",{className:"radio-modal-body",children:[P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Voice Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:Bt((Se==null?void 0:Se.voicePing)??null)}}),(Se==null?void 0:Se.voicePing)!=null?`${Se.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Gateway Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:Bt((Se==null?void 0:Se.gatewayPing)??null)}}),Se&&Se.gatewayPing>=0?`${Se.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Status"}),P.jsx("span",{className:"radio-modal-value",style:{color:(Se==null?void 0:Se.status)==="ready"?"var(--success)":"#f0a830"},children:(Se==null?void 0:Se.status)==="ready"?"Verbunden":(Se==null?void 0:Se.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Kanal"}),P.jsx("span",{className:"radio-modal-value",children:(Se==null?void 0:Se.channelName)||"---"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Verbunden seit"}),P.jsx("span",{className:"radio-modal-value",children:je||"---"})]})]})]})})})()]})}function EAe(i,e,t=365){const n=new Date(Date.now()+t*24*60*60*1e3).toUTCString();document.cookie=`${encodeURIComponent(i)}=${encodeURIComponent(e)}; expires=${n}; path=/; SameSite=Lax`}function CAe(i){const e=`${encodeURIComponent(i)}=`,t=document.cookie.split(";");for(const n of t){const r=n.trim();if(r.startsWith(e))return decodeURIComponent(r.slice(e.length))}return null}const Js="/api/soundboard";async function m7(i,e,t,n){const r=new URL(`${Js}/sounds`,window.location.origin);i&&r.searchParams.set("q",i),e!==void 0&&r.searchParams.set("folder",e),r.searchParams.set("fuzzy","0");const s=await fetch(r.toString());if(!s.ok)throw new Error("Fehler beim Laden der Sounds");return s.json()}async function NAe(){const i=await fetch(`${Js}/analytics`);if(!i.ok)throw new Error("Fehler beim Laden der Analytics");return i.json()}async function RAe(){const i=await fetch(`${Js}/categories`,{credentials:"include"});if(!i.ok)throw new Error("Fehler beim Laden der Kategorien");return i.json()}async function DAe(){const i=await fetch(`${Js}/channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channels");return i.json()}async function PAe(){const i=await fetch(`${Js}/selected-channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channel-Auswahl");const e=await i.json();return(e==null?void 0:e.selected)||{}}async function LAe(i,e){if(!(await fetch(`${Js}/selected-channel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Channel-Auswahl setzen fehlgeschlagen")}async function UAe(i,e,t,n,r){const s=await fetch(`${Js}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({soundName:i,guildId:e,channelId:t,volume:n,relativePath:r})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error((a==null?void 0:a.error)||"Play fehlgeschlagen")}}async function BAe(i,e,t,n,r){const s=await fetch(`${Js}/play-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,guildId:e,channelId:t,volume:n,filename:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error((a==null?void 0:a.error)||"Play-URL fehlgeschlagen");return a}async function OAe(i,e){const t=await fetch(`${Js}/download-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,filename:e})}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error((n==null?void 0:n.error)||"Download fehlgeschlagen");return n}async function IAe(i,e){if(!(await fetch(`${Js}/party/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Partymode Start fehlgeschlagen")}async function FAe(i){if(!(await fetch(`${Js}/party/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i})})).ok)throw new Error("Partymode Stop fehlgeschlagen")}async function g7(i,e){const t=await fetch(`${Js}/volume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,volume:e})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error((n==null?void 0:n.error)||"Volume aendern fehlgeschlagen")}}async function kAe(i){const e=new URL(`${Js}/volume`,window.location.origin);e.searchParams.set("guildId",i);const t=await fetch(e.toString());if(!t.ok)throw new Error("Fehler beim Laden der Lautstaerke");const n=await t.json();return typeof(n==null?void 0:n.volume)=="number"?n.volume:1}async function zAe(i){if(!(await fetch(`${Js}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}async function GAe(i,e){const t=await fetch(`${Js}/admin/sounds/rename`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({from:i,to:e})});if(!t.ok)throw new Error("Umbenennen fehlgeschlagen");const n=await t.json();return n==null?void 0:n.to}function qAe(i,e,t){return new Promise((n,r)=>{const s=new FormData;s.append("files",i),e&&s.append("customName",e);const a=new XMLHttpRequest;a.open("POST",`${Js}/upload`),a.upload.onprogress=l=>{l.lengthComputable&&t(Math.round(l.loaded/l.total*100))},a.onload=()=>{var l,u;if(a.status===200)try{const h=JSON.parse(a.responseText);n(((u=(l=h.files)==null?void 0:l[0])==null?void 0:u.name)??i.name)}catch{n(i.name)}else try{r(new Error(JSON.parse(a.responseText).error))}catch{r(new Error(`HTTP ${a.status}`))}},a.onerror=()=>r(new Error("Netzwerkfehler")),a.send(s)})}const VAe=[{id:"default",color:"#5865f2",label:"Discord"},{id:"purple",color:"#9b59b6",label:"Midnight"},{id:"forest",color:"#2ecc71",label:"Forest"},{id:"sunset",color:"#e67e22",label:"Sunset"},{id:"ocean",color:"#3498db",label:"Ocean"}],v7=["#3b82f6","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#06b6d4","#ef4444","#a855f7","#84cc16","#d946ef","#0ea5e9","#f43f5e","#10b981"];function jAe({data:i,isAdmin:e}){var hl,ts,Md;const[t,n]=ie.useState([]),[r,s]=ie.useState(0),[a,l]=ie.useState([]),[u,h]=ie.useState([]),[m,v]=ie.useState({totalSounds:0,totalPlays:0,mostPlayed:[]}),[x,S]=ie.useState("all"),[w,N]=ie.useState(""),[C,E]=ie.useState(""),[O,U]=ie.useState(""),[I,j]=ie.useState(!1),[z,G]=ie.useState(null),[W,q]=ie.useState([]),[V,Y]=ie.useState(""),te=ie.useRef(""),[ne,le]=ie.useState(!1),[Q,K]=ie.useState(1),[ae,Ae]=ie.useState(""),[be,Se]=ie.useState({}),[se,Ee]=ie.useState(()=>localStorage.getItem("jb-theme")||"default"),[qe,Ce]=ie.useState(()=>parseInt(localStorage.getItem("jb-card-size")||"110")),[ke,Qe]=ie.useState(!1),[et,Pt]=ie.useState([]),Nt=ie.useRef(!1),Gt=ie.useRef(void 0),Tt=e??!1,[Ge,dt]=ie.useState(!1),[he,en]=ie.useState([]),[wt,qt]=ie.useState(!1),[Lt,hn]=ie.useState(""),[ut,fe]=ie.useState({}),[k,_e]=ie.useState(""),[Be,Oe]=ie.useState(""),[je,Bt]=ie.useState(!1),[yt,Xt]=ie.useState([]),[ln,mt]=ie.useState(!1),Wt=ie.useRef(0);ie.useRef(void 0);const[Yt,$t]=ie.useState([]),[It,Te]=ie.useState(0),[nt,At]=ie.useState(""),[ce,xt]=ie.useState("naming"),[Ze,lt]=ie.useState(0),[bt,Kt]=ie.useState(null),[un,Ye]=ie.useState(!1),[St,ye]=ie.useState(null),[pt,Zt]=ie.useState(""),[Pe,at]=ie.useState(null),[ht,ot]=ie.useState(0);ie.useEffect(()=>{Nt.current=ke},[ke]),ie.useEffect(()=>{te.current=V},[V]),ie.useEffect(()=>{const xe=$n=>{var or;Array.from(((or=$n.dataTransfer)==null?void 0:or.items)??[]).some(er=>er.kind==="file")&&(Wt.current++,Bt(!0))},Rt=()=>{Wt.current=Math.max(0,Wt.current-1),Wt.current===0&&Bt(!1)},nn=$n=>$n.preventDefault(),fi=$n=>{var er;$n.preventDefault(),Wt.current=0,Bt(!1);const or=Array.from(((er=$n.dataTransfer)==null?void 0:er.files)??[]).filter(po=>/\.(mp3|wav)$/i.test(po.name));or.length&&Fe(or)};return window.addEventListener("dragenter",xe),window.addEventListener("dragleave",Rt),window.addEventListener("dragover",nn),window.addEventListener("drop",fi),()=>{window.removeEventListener("dragenter",xe),window.removeEventListener("dragleave",Rt),window.removeEventListener("dragover",nn),window.removeEventListener("drop",fi)}},[Tt]);const f=ie.useCallback((xe,Rt="info")=>{ye({msg:xe,type:Rt}),setTimeout(()=>ye(null),3e3)},[]),J=ie.useCallback(xe=>xe.relativePath??xe.fileName,[]),_n=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","music.youtube.com","instagram.com","www.instagram.com"],fn=ie.useCallback(xe=>{const Rt=xe.trim();return!Rt||/^https?:\/\//i.test(Rt)?Rt:"https://"+Rt},[]),zn=ie.useCallback(xe=>{try{const Rt=new URL(fn(xe)),nn=Rt.hostname.toLowerCase();return!!(Rt.pathname.toLowerCase().endsWith(".mp3")||_n.some(fi=>nn===fi||nn.endsWith("."+fi)))}catch{return!1}},[fn]),An=ie.useCallback(xe=>{try{const Rt=new URL(fn(xe)),nn=Rt.hostname.toLowerCase();return nn.includes("youtube")||nn==="youtu.be"?"youtube":nn.includes("instagram")?"instagram":Rt.pathname.toLowerCase().endsWith(".mp3")?"mp3":null}catch{return null}},[fn]),yn=V?V.split(":")[0]:"",zr=V?V.split(":")[1]:"",on=ie.useMemo(()=>W.find(xe=>`${xe.guildId}:${xe.channelId}`===V),[W,V]);ie.useEffect(()=>{const xe=()=>{const nn=new Date,fi=String(nn.getHours()).padStart(2,"0"),$n=String(nn.getMinutes()).padStart(2,"0"),or=String(nn.getSeconds()).padStart(2,"0");Zt(`${fi}:${$n}:${or}`)};xe();const Rt=setInterval(xe,1e3);return()=>clearInterval(Rt)},[]),ie.useEffect(()=>{(async()=>{try{const[xe,Rt]=await Promise.all([DAe(),PAe()]);if(q(xe),xe.length){const nn=xe[0].guildId,fi=Rt[nn],$n=fi&&xe.find(or=>or.guildId===nn&&or.channelId===fi);Y($n?`${nn}:${fi}`:`${xe[0].guildId}:${xe[0].channelId}`)}}catch(xe){f((xe==null?void 0:xe.message)||"Channel-Fehler","error")}try{const xe=await RAe();h(xe.categories||[])}catch{}})()},[]),ie.useEffect(()=>{localStorage.setItem("jb-theme",se)},[se]);const xn=ie.useRef(null);ie.useEffect(()=>{const xe=xn.current;if(!xe)return;xe.style.setProperty("--card-size",qe+"px");const Rt=qe/110;xe.style.setProperty("--card-emoji",Math.round(28*Rt)+"px"),xe.style.setProperty("--card-font",Math.max(9,Math.round(11*Rt))+"px"),localStorage.setItem("jb-card-size",String(qe))},[qe]),ie.useEffect(()=>{var xe,Rt,nn,fi,$n,or,er,po;if(i){if(i.soundboard){const Cr=i.soundboard;Array.isArray(Cr.party)&&Pt(Cr.party);try{const lr=Cr.selected||{},yi=(xe=te.current)==null?void 0:xe.split(":")[0];yi&&lr[yi]&&Y(`${yi}:${lr[yi]}`)}catch{}try{const lr=Cr.volumes||{},yi=(Rt=te.current)==null?void 0:Rt.split(":")[0];yi&&typeof lr[yi]=="number"&&K(lr[yi])}catch{}try{const lr=Cr.nowplaying||{},yi=(nn=te.current)==null?void 0:nn.split(":")[0];yi&&typeof lr[yi]=="string"&&Ae(lr[yi])}catch{}try{const lr=Cr.voicestats||{},yi=(fi=te.current)==null?void 0:fi.split(":")[0];yi&&lr[yi]&&Kt(lr[yi])}catch{}}if(i.type==="soundboard_party")Pt(Cr=>{const lr=new Set(Cr);return i.active?lr.add(i.guildId):lr.delete(i.guildId),Array.from(lr)});else if(i.type==="soundboard_channel"){const Cr=($n=te.current)==null?void 0:$n.split(":")[0];i.guildId===Cr&&Y(`${i.guildId}:${i.channelId}`)}else if(i.type==="soundboard_volume"){const Cr=(or=te.current)==null?void 0:or.split(":")[0];i.guildId===Cr&&typeof i.volume=="number"&&K(i.volume)}else if(i.type==="soundboard_nowplaying"){const Cr=(er=te.current)==null?void 0:er.split(":")[0];i.guildId===Cr&&Ae(i.name||"")}else if(i.type==="soundboard_voicestats"){const Cr=(po=te.current)==null?void 0:po.split(":")[0];i.guildId===Cr&&Kt({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})}}},[i]),ie.useEffect(()=>{Qe(yn?et.includes(yn):!1)},[V,et,yn]),ie.useEffect(()=>{(async()=>{try{let xe="__all__";x==="recent"?xe="__recent__":w&&(xe=w);const Rt=await m7(C,xe,void 0,!1);n(Rt.items),s(Rt.total),l(Rt.folders)}catch(xe){f((xe==null?void 0:xe.message)||"Sounds-Fehler","error")}})()},[x,w,C,ht,f]),ie.useEffect(()=>{Ar()},[ht]),ie.useEffect(()=>{const xe=CAe("favs");if(xe)try{Se(JSON.parse(xe))}catch{}},[]),ie.useEffect(()=>{try{EAe("favs",JSON.stringify(be))}catch{}},[be]),ie.useEffect(()=>{V&&(async()=>{try{const xe=await kAe(yn);K(xe)}catch{}})()},[V]),ie.useEffect(()=>{const xe=()=>{le(!1),at(null)};return document.addEventListener("click",xe),()=>document.removeEventListener("click",xe)},[]),ie.useEffect(()=>{Ge&&Tt&&Vt()},[Ge,Tt]);async function Ar(){try{const xe=await NAe();v(xe)}catch{}}async function ji(xe){if(!V)return f("Bitte einen Voice-Channel auswaehlen","error");try{await UAe(xe.name,yn,zr,Q,xe.relativePath),Ae(xe.name),Ar()}catch(Rt){f((Rt==null?void 0:Rt.message)||"Play fehlgeschlagen","error")}}function Ao(){var fi;const xe=fn(O);if(!xe)return f("Bitte einen Link eingeben","error");if(!zn(xe))return f("Nur YouTube, Instagram oder direkte MP3-Links","error");const Rt=An(xe);let nn="";if(Rt==="mp3")try{nn=((fi=new URL(xe).pathname.split("/").pop())==null?void 0:fi.replace(/\.mp3$/i,""))??""}catch{}G({url:xe,type:Rt,filename:nn,phase:"input"})}async function ue(){if(z){G(xe=>xe?{...xe,phase:"downloading"}:null);try{let xe;const Rt=z.filename.trim()||void 0;V&&yn&&zr?xe=(await BAe(z.url,yn,zr,Q,Rt)).saved:xe=(await OAe(z.url,Rt)).saved,G(nn=>nn?{...nn,phase:"done",savedName:xe}:null),U(""),ot(nn=>nn+1),Ar(),setTimeout(()=>G(null),2500)}catch(xe){G(Rt=>Rt?{...Rt,phase:"error",error:(xe==null?void 0:xe.message)||"Fehler"}:null)}}}async function Fe(xe){if(!Tt){f("Admin-Login erforderlich zum Hochladen","error");return}if(xe.length===0)return;$t(xe),Te(0);const Rt=xe[0].name.replace(/\.(mp3|wav)$/i,"");At(Rt),xt("naming"),lt(0)}async function tt(){if(Yt.length===0)return;const xe=Yt[It],Rt=nt.trim()||xe.name.replace(/\.(mp3|wav)$/i,"");xt("uploading"),lt(0);try{await qAe(xe,Rt,nn=>lt(nn)),xt("done"),setTimeout(()=>{const nn=It+1;if(nnfi+1),Ar(),f(`${Yt.length} Sound${Yt.length>1?"s":""} hochgeladen`,"info")},800)}catch(nn){f((nn==null?void 0:nn.message)||"Upload fehlgeschlagen","error"),$t([])}}function Ke(){const xe=It+1;if(xe0&&(ot(Rt=>Rt+1),Ar())}async function ze(){if(V){Ae("");try{await fetch(`${Js}/stop?guildId=${encodeURIComponent(yn)}`,{method:"POST"})}catch{}}}async function Qt(){if(!Z.length||!V)return;const xe=Z[Math.floor(Math.random()*Z.length)];ji(xe)}async function tn(){if(ke){await ze();try{await FAe(yn)}catch{}}else{if(!V)return f("Bitte einen Channel auswaehlen","error");try{await IAe(yn,zr)}catch{}}}async function Mt(xe){const Rt=`${xe.guildId}:${xe.channelId}`;Y(Rt),le(!1);try{await LAe(xe.guildId,xe.channelId)}catch{}}function ee(xe){Se(Rt=>({...Rt,[xe]:!Rt[xe]}))}async function Vt(){qt(!0);try{const xe=await m7("","__all__",void 0,!1);en(xe.items||[])}catch(xe){f((xe==null?void 0:xe.message)||"Admin-Sounds konnten nicht geladen werden","error")}finally{qt(!1)}}function Fn(xe){fe(Rt=>({...Rt,[xe]:!Rt[xe]}))}function Tn(xe){_e(J(xe)),Oe(xe.name)}function oi(){_e(""),Oe("")}async function Ai(){if(!k)return;const xe=Be.trim().replace(/\.(mp3|wav)$/i,"");if(!xe){f("Bitte einen gueltigen Namen eingeben","error");return}try{await GAe(k,xe),f("Sound umbenannt"),oi(),ot(Rt=>Rt+1),Ge&&await Vt()}catch(Rt){f((Rt==null?void 0:Rt.message)||"Umbenennen fehlgeschlagen","error")}}async function Ii(xe){if(xe.length!==0)try{await zAe(xe),f(xe.length===1?"Sound geloescht":`${xe.length} Sounds geloescht`),fe({}),oi(),ot(Rt=>Rt+1),Ge&&await Vt()}catch(Rt){f((Rt==null?void 0:Rt.message)||"Loeschen fehlgeschlagen","error")}}const Z=ie.useMemo(()=>x==="favorites"?t.filter(xe=>be[xe.relativePath??xe.fileName]):t,[t,x,be]),Vn=ie.useMemo(()=>Object.values(be).filter(Boolean).length,[be]),bn=ie.useMemo(()=>a.filter(xe=>!["__all__","__recent__","__top3__"].includes(xe.key)),[a]),Mr=ie.useMemo(()=>{const xe={};return bn.forEach((Rt,nn)=>{xe[Rt.key]=v7[nn%v7.length]}),xe},[bn]),pi=ie.useMemo(()=>{const xe=new Set,Rt=new Set;return Z.forEach((nn,fi)=>{const $n=nn.name.charAt(0).toUpperCase();xe.has($n)||(xe.add($n),Rt.add(fi))}),Rt},[Z]),Ds=ie.useMemo(()=>{const xe={};return W.forEach(Rt=>{xe[Rt.guildName]||(xe[Rt.guildName]=[]),xe[Rt.guildName].push(Rt)}),xe},[W]),Gr=ie.useMemo(()=>{const xe=Lt.trim().toLowerCase();return xe?he.filter(Rt=>{const nn=J(Rt).toLowerCase();return Rt.name.toLowerCase().includes(xe)||(Rt.folder||"").toLowerCase().includes(xe)||nn.includes(xe)}):he},[Lt,he,J]),qr=ie.useMemo(()=>Object.keys(ut).filter(xe=>ut[xe]),[ut]),Er=ie.useMemo(()=>Gr.filter(xe=>!!ut[J(xe)]).length,[Gr,ut,J]),Ni=Gr.length>0&&Er===Gr.length,Yi=m.mostPlayed.slice(0,10),_i=m.totalSounds||r,pr=pt.slice(0,5),Vr=pt.slice(5);return P.jsxs("div",{className:"sb-app","data-theme":se,ref:xn,children:[ke&&P.jsx("div",{className:"party-overlay active"}),P.jsxs("header",{className:"topbar",children:[P.jsxs("div",{className:"topbar-left",children:[P.jsx("div",{className:"sb-app-logo",children:P.jsx("span",{className:"material-icons",style:{fontSize:16,color:"white"},children:"music_note"})}),P.jsx("span",{className:"sb-app-title",children:"Soundboard"}),P.jsxs("div",{className:"channel-dropdown",onClick:xe=>xe.stopPropagation(),children:[P.jsxs("button",{className:`channel-btn ${ne?"open":""}`,onClick:()=>le(!ne),children:[P.jsx("span",{className:"material-icons cb-icon",children:"headset"}),V&&P.jsx("span",{className:"channel-status"}),P.jsx("span",{className:"channel-label",children:on?`${on.channelName}${on.members?` (${on.members})`:""}`:"Channel..."}),P.jsx("span",{className:"material-icons chevron",children:"expand_more"})]}),ne&&P.jsxs("div",{className:"channel-menu visible",children:[Object.entries(Ds).map(([xe,Rt])=>P.jsxs(FF.Fragment,{children:[P.jsx("div",{className:"channel-menu-header",children:xe}),Rt.map(nn=>P.jsxs("div",{className:`channel-option ${`${nn.guildId}:${nn.channelId}`===V?"active":""}`,onClick:()=>Mt(nn),children:[P.jsx("span",{className:"material-icons co-icon",children:"volume_up"}),nn.channelName,nn.members?` (${nn.members})`:""]},`${nn.guildId}:${nn.channelId}`))]},xe)),W.length===0&&P.jsx("div",{className:"channel-option",style:{color:"var(--text-faint)",cursor:"default"},children:"Keine Channels verfuegbar"})]})]})]}),P.jsx("div",{className:"clock-wrap",children:P.jsxs("div",{className:"clock",children:[pr,P.jsx("span",{className:"clock-seconds",children:Vr})]})}),P.jsxs("div",{className:"topbar-right",children:[ae&&P.jsxs("div",{className:"now-playing",children:[P.jsxs("div",{className:"np-waves active",children:[P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"})]}),P.jsx("span",{className:"np-label",children:"Last Played:"})," ",P.jsx("span",{className:"np-name",children:ae})]}),V&&P.jsxs("div",{className:"connection",onClick:()=>Ye(!0),style:{cursor:"pointer"},title:"Verbindungsdetails",children:[P.jsx("span",{className:"conn-dot"}),"Verbunden",(bt==null?void 0:bt.voicePing)!=null&&P.jsxs("span",{className:"conn-ping",children:[bt.voicePing,"ms"]})]}),Tt&&P.jsx("button",{className:"admin-btn-icon active",onClick:()=>dt(!0),title:"Admin",children:P.jsx("span",{className:"material-icons",children:"settings"})})]})]}),P.jsxs("div",{className:"toolbar",children:[P.jsxs("div",{className:"cat-tabs",children:[P.jsxs("button",{className:`cat-tab ${x==="all"?"active":""}`,onClick:()=>{S("all"),N("")},children:["Alle",P.jsx("span",{className:"tab-count",children:r})]}),P.jsx("button",{className:`cat-tab ${x==="recent"?"active":""}`,onClick:()=>{S("recent"),N("")},children:"Neu hinzugefuegt"}),P.jsxs("button",{className:`cat-tab ${x==="favorites"?"active":""}`,onClick:()=>{S("favorites"),N("")},children:["Favoriten",Vn>0&&P.jsx("span",{className:"tab-count",children:Vn})]})]}),P.jsxs("div",{className:"search-wrap",children:[P.jsx("span",{className:"material-icons search-icon",children:"search"}),P.jsx("input",{className:"search-input",type:"text",placeholder:"Suchen...",value:C,onChange:xe=>E(xe.target.value)}),C&&P.jsx("button",{className:"search-clear",onClick:()=>E(""),children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsxs("div",{className:"url-import-wrap",children:[P.jsx("span",{className:"material-icons url-import-icon",children:An(O)==="youtube"?"smart_display":An(O)==="instagram"?"photo_camera":"link"}),P.jsx("input",{className:"url-import-input",type:"text",placeholder:"YouTube / Instagram / MP3-Link...",value:O,onChange:xe=>U(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&Ao()}}),O&&P.jsx("span",{className:`url-import-tag ${zn(O)?"valid":"invalid"}`,children:An(O)==="youtube"?"YT":An(O)==="instagram"?"IG":An(O)==="mp3"?"MP3":"?"}),P.jsx("button",{className:"url-import-btn",onClick:()=>{Ao()},disabled:I||!!O&&!zn(O),title:"Sound herunterladen",children:I?"Laedt...":"Download"})]}),P.jsx("div",{className:"toolbar-spacer"}),P.jsxs("div",{className:"volume-control",children:[P.jsx("span",{className:"material-icons vol-icon",onClick:()=>{const xe=Q>0?0:.5;K(xe),yn&&g7(yn,xe).catch(()=>{})},children:Q===0?"volume_off":Q<.5?"volume_down":"volume_up"}),P.jsx("input",{type:"range",className:"vol-slider",min:0,max:1,step:.01,value:Q,onChange:xe=>{const Rt=parseFloat(xe.target.value);K(Rt),yn&&(Gt.current&&clearTimeout(Gt.current),Gt.current=setTimeout(()=>{g7(yn,Rt).catch(()=>{})},120))},style:{"--vol":`${Math.round(Q*100)}%`}}),P.jsxs("span",{className:"vol-pct",children:[Math.round(Q*100),"%"]})]}),P.jsxs("button",{className:"tb-btn random",onClick:Qt,title:"Zufaelliger Sound",children:[P.jsx("span",{className:"material-icons tb-icon",children:"shuffle"}),"Random"]}),P.jsxs("button",{className:`tb-btn party ${ke?"active":""}`,onClick:tn,title:"Party Mode",children:[P.jsx("span",{className:"material-icons tb-icon",children:ke?"celebration":"auto_awesome"}),ke?"Party!":"Party"]}),P.jsxs("button",{className:"tb-btn stop",onClick:ze,title:"Alle stoppen",children:[P.jsx("span",{className:"material-icons tb-icon",children:"stop"}),"Stop"]}),P.jsxs("div",{className:"size-control",title:"Button-Groesse",children:[P.jsx("span",{className:"material-icons sc-icon",children:"grid_view"}),P.jsx("input",{type:"range",className:"size-slider",min:80,max:160,value:qe,onChange:xe=>Ce(parseInt(xe.target.value))})]}),P.jsx("div",{className:"theme-selector",children:VAe.map(xe=>P.jsx("div",{className:`theme-dot ${se===xe.id?"active":""}`,style:{background:xe.color},title:xe.label,onClick:()=>Ee(xe.id)},xe.id))})]}),P.jsxs("div",{className:"analytics-strip",children:[P.jsxs("div",{className:"analytics-card",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"library_music"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Sounds gesamt"}),P.jsx("strong",{className:"analytics-value",children:_i})]})]}),P.jsxs("div",{className:"analytics-card analytics-wide",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"leaderboard"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Most Played"}),P.jsx("div",{className:"analytics-top-list",children:Yi.length===0?P.jsx("span",{className:"analytics-muted",children:"Noch keine Plays"}):Yi.map((xe,Rt)=>P.jsxs("span",{className:"analytics-chip",children:[Rt+1,". ",xe.name," (",xe.count,")"]},xe.relativePath))})]})]})]}),x==="all"&&bn.length>0&&P.jsx("div",{className:"category-strip",children:bn.map(xe=>{const Rt=Mr[xe.key]||"#888",nn=w===xe.key;return P.jsxs("button",{className:`cat-chip ${nn?"active":""}`,onClick:()=>N(nn?"":xe.key),style:nn?{borderColor:Rt,color:Rt}:void 0,children:[P.jsx("span",{className:"cat-dot",style:{background:Rt}}),xe.name.replace(/\s*\(\d+\)\s*$/,""),P.jsx("span",{className:"cat-count",children:xe.count})]},xe.key)})}),P.jsx("main",{className:"main",children:Z.length===0?P.jsxs("div",{className:"empty-state visible",children:[P.jsx("div",{className:"empty-emoji",children:x==="favorites"?"⭐":"🔇"}),P.jsx("div",{className:"empty-title",children:x==="favorites"?"Noch keine Favoriten":C?`Kein Sound fuer "${C}" gefunden`:"Keine Sounds vorhanden"}),P.jsx("div",{className:"empty-desc",children:x==="favorites"?"Klick den Stern auf einem Sound!":"Hier gibt's noch nichts zu hoeren."})]}):P.jsx("div",{className:"sound-grid",children:Z.map((xe,Rt)=>{var lr;const nn=xe.relativePath??xe.fileName,fi=!!be[nn],$n=ae===xe.name,or=xe.isRecent||((lr=xe.badges)==null?void 0:lr.includes("new")),er=xe.name.charAt(0).toUpperCase(),po=pi.has(Rt),Cr=xe.folder&&Mr[xe.folder]||"var(--accent)";return P.jsxs("div",{className:`sound-card ${$n?"playing":""} ${po?"has-initial":""}`,style:{animationDelay:`${Math.min(Rt*20,400)}ms`},onClick:yi=>{const Iu=yi.currentTarget,zo=Iu.getBoundingClientRect(),Go=document.createElement("div");Go.className="ripple";const fl=Math.max(zo.width,zo.height);Go.style.width=Go.style.height=fl+"px",Go.style.left=yi.clientX-zo.left-fl/2+"px",Go.style.top=yi.clientY-zo.top-fl/2+"px",Iu.appendChild(Go),setTimeout(()=>Go.remove(),500),ji(xe)},onContextMenu:yi=>{yi.preventDefault(),yi.stopPropagation(),at({x:Math.min(yi.clientX,window.innerWidth-170),y:Math.min(yi.clientY,window.innerHeight-140),sound:xe})},title:`${xe.name}${xe.folder?` (${xe.folder})`:""}`,children:[or&&P.jsx("span",{className:"new-badge",children:"NEU"}),P.jsx("span",{className:`fav-star ${fi?"active":""}`,onClick:yi=>{yi.stopPropagation(),ee(nn)},children:P.jsx("span",{className:"material-icons fav-icon",children:fi?"star":"star_border"})}),po&&P.jsx("span",{className:"sound-emoji",style:{color:Cr},children:er}),P.jsx("span",{className:"sound-name",children:xe.name}),xe.folder&&P.jsx("span",{className:"sound-duration",children:xe.folder}),P.jsxs("div",{className:"playing-indicator",children:[P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"})]})]},nn)})})}),Pe&&P.jsxs("div",{className:"ctx-menu visible",style:{left:Pe.x,top:Pe.y},onClick:xe=>xe.stopPropagation(),children:[P.jsxs("div",{className:"ctx-item",onClick:()=>{ji(Pe.sound),at(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"play_arrow"}),"Abspielen"]}),P.jsxs("div",{className:"ctx-item",onClick:()=>{ee(Pe.sound.relativePath??Pe.sound.fileName),at(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:be[Pe.sound.relativePath??Pe.sound.fileName]?"star":"star_border"}),"Favorit"]}),Tt&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"ctx-sep"}),P.jsxs("div",{className:"ctx-item danger",onClick:async()=>{const xe=Pe.sound.relativePath??Pe.sound.fileName;await Ii([xe]),at(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"delete"}),"Loeschen"]})]})]}),un&&(()=>{const xe=bt!=null&&bt.connectedSince?Math.floor((Date.now()-new Date(bt.connectedSince).getTime())/1e3):0,Rt=Math.floor(xe/3600),nn=Math.floor(xe%3600/60),fi=xe%60,$n=Rt>0?`${Rt}h ${String(nn).padStart(2,"0")}m ${String(fi).padStart(2,"0")}s`:nn>0?`${nn}m ${String(fi).padStart(2,"0")}s`:`${fi}s`,or=er=>er==null?"var(--muted)":er<80?"var(--green)":er<150?"#f0a830":"#e04040";return P.jsx("div",{className:"conn-modal-overlay",onClick:()=>Ye(!1),children:P.jsxs("div",{className:"conn-modal",onClick:er=>er.stopPropagation(),children:[P.jsxs("div",{className:"conn-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20,color:"var(--green)"},children:"cell_tower"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"conn-modal-close",onClick:()=>Ye(!1),children:P.jsx("span",{className:"material-icons",children:"close"})})]}),P.jsxs("div",{className:"conn-modal-body",children:[P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Voice Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:or((bt==null?void 0:bt.voicePing)??null)}}),(bt==null?void 0:bt.voicePing)!=null?`${bt.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Gateway Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:or((bt==null?void 0:bt.gatewayPing)??null)}}),bt&&bt.gatewayPing>=0?`${bt.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Status"}),P.jsx("span",{className:"conn-stat-value",style:{color:(bt==null?void 0:bt.status)==="ready"?"var(--green)":"#f0a830"},children:(bt==null?void 0:bt.status)==="ready"?"Verbunden":(bt==null?void 0:bt.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Kanal"}),P.jsx("span",{className:"conn-stat-value",children:(bt==null?void 0:bt.channelName)||"---"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Verbunden seit"}),P.jsx("span",{className:"conn-stat-value",children:$n||"---"})]})]})]})})})(),St&&P.jsxs("div",{className:`toast ${St.type}`,children:[P.jsx("span",{className:"material-icons toast-icon",children:St.type==="error"?"error_outline":"check_circle"}),St.msg]}),Ge&&P.jsx("div",{className:"admin-overlay",onClick:xe=>{xe.target===xe.currentTarget&&dt(!1)},children:P.jsxs("div",{className:"admin-panel",children:[P.jsxs("h3",{children:["Admin",P.jsx("button",{className:"admin-close",onClick:()=>dt(!1),children:P.jsx("span",{className:"material-icons",style:{fontSize:18},children:"close"})})]}),P.jsxs("div",{className:"admin-shell",children:[P.jsxs("div",{className:"admin-header-row",children:[P.jsx("p",{className:"admin-status",children:"Eingeloggt als Admin"}),P.jsx("div",{className:"admin-actions-inline",children:P.jsx("button",{className:"admin-btn-action outline",onClick:()=>{Vt()},disabled:wt,children:"Aktualisieren"})})]}),P.jsxs("div",{className:"admin-field admin-search-field",children:[P.jsx("label",{children:"Sounds verwalten"}),P.jsx("input",{type:"text",value:Lt,onChange:xe=>hn(xe.target.value),placeholder:"Nach Name, Ordner oder Pfad filtern..."})]}),P.jsxs("div",{className:"admin-bulk-row",children:[P.jsxs("label",{className:"admin-select-all",children:[P.jsx("input",{type:"checkbox",checked:Ni,onChange:xe=>{const Rt=xe.target.checked,nn={...ut};Gr.forEach(fi=>{nn[J(fi)]=Rt}),fe(nn)}}),P.jsxs("span",{children:["Alle sichtbaren auswaehlen (",Er,"/",Gr.length,")"]})]}),P.jsx("button",{className:"admin-btn-action danger",disabled:qr.length===0,onClick:async()=>{window.confirm(`Wirklich ${qr.length} Sound(s) loeschen?`)&&await Ii(qr)},children:"Ausgewaehlte loeschen"})]}),P.jsx("div",{className:"admin-list-wrap",children:wt?P.jsx("div",{className:"admin-empty",children:"Lade Sounds..."}):Gr.length===0?P.jsx("div",{className:"admin-empty",children:"Keine Sounds gefunden."}):P.jsx("div",{className:"admin-list",children:Gr.map(xe=>{const Rt=J(xe),nn=k===Rt;return P.jsxs("div",{className:"admin-item",children:[P.jsx("label",{className:"admin-item-check",children:P.jsx("input",{type:"checkbox",checked:!!ut[Rt],onChange:()=>Fn(Rt)})}),P.jsxs("div",{className:"admin-item-main",children:[P.jsx("div",{className:"admin-item-name",children:xe.name}),P.jsxs("div",{className:"admin-item-meta",children:[xe.folder?`Ordner: ${xe.folder}`:"Root"," · ",Rt]}),nn&&P.jsxs("div",{className:"admin-rename-row",children:[P.jsx("input",{value:Be,onChange:fi=>Oe(fi.target.value),onKeyDown:fi=>{fi.key==="Enter"&&Ai(),fi.key==="Escape"&&oi()},placeholder:"Neuer Name..."}),P.jsx("button",{className:"admin-btn-action primary",onClick:()=>{Ai()},children:"Speichern"}),P.jsx("button",{className:"admin-btn-action outline",onClick:oi,children:"Abbrechen"})]})]}),!nn&&P.jsxs("div",{className:"admin-item-actions",children:[P.jsx("button",{className:"admin-btn-action outline",onClick:()=>Tn(xe),children:"Umbenennen"}),P.jsx("button",{className:"admin-btn-action danger ghost",onClick:async()=>{window.confirm(`Sound "${xe.name}" loeschen?`)&&await Ii([Rt])},children:"Loeschen"})]})]},Rt)})})})]})]})}),je&&P.jsx("div",{className:"drop-overlay",children:P.jsxs("div",{className:"drop-zone",children:[P.jsx("span",{className:"material-icons drop-icon",children:"cloud_upload"}),P.jsx("div",{className:"drop-title",children:"MP3 & WAV hier ablegen"}),P.jsx("div",{className:"drop-sub",children:"Mehrere Dateien gleichzeitig moeglich"})]})}),ln&&yt.length>0&&P.jsxs("div",{className:"upload-queue",children:[P.jsxs("div",{className:"uq-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),P.jsx("span",{children:yt.every(xe=>xe.status==="done"||xe.status==="error")?`${yt.filter(xe=>xe.status==="done").length} von ${yt.length} hochgeladen`:`Lade hoch… (${yt.filter(xe=>xe.status==="done").length}/${yt.length})`}),P.jsx("button",{className:"uq-close",onClick:()=>{mt(!1),Xt([])},children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsx("div",{className:"uq-list",children:yt.map(xe=>P.jsxs("div",{className:`uq-item uq-${xe.status}`,children:[P.jsx("span",{className:"material-icons uq-file-icon",children:"audio_file"}),P.jsxs("div",{className:"uq-info",children:[P.jsx("div",{className:"uq-name",title:xe.savedName??xe.file.name,children:xe.savedName??xe.file.name}),P.jsxs("div",{className:"uq-size",children:[(xe.file.size/1024).toFixed(0)," KB"]})]}),(xe.status==="waiting"||xe.status==="uploading")&&P.jsx("div",{className:"uq-progress-wrap",children:P.jsx("div",{className:"uq-progress-bar",style:{width:`${xe.progress}%`}})}),P.jsx("span",{className:`material-icons uq-status-icon uq-status-${xe.status}`,children:xe.status==="done"?"check_circle":xe.status==="error"?"error":xe.status==="uploading"?"sync":"schedule"}),xe.status==="error"&&P.jsx("div",{className:"uq-error",children:xe.error})]},xe.id))})]}),Yt.length>0&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>ce==="naming"&&Ke(),children:P.jsxs("div",{className:"dl-modal",onClick:xe=>xe.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:"upload_file"}),P.jsxs("span",{children:[ce==="naming"?"Sound benennen":ce==="uploading"?"Wird hochgeladen...":"Gespeichert!",Yt.length>1&&` (${It+1}/${Yt.length})`]}),ce==="naming"&&P.jsx("button",{className:"dl-modal-close",onClick:Ke,children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:"dl-modal-tag mp3",children:"Datei"}),P.jsx("span",{className:"dl-modal-url-text",title:(hl=Yt[It])==null?void 0:hl.name,children:(ts=Yt[It])==null?void 0:ts.name}),P.jsxs("span",{style:{marginLeft:"auto",opacity:.5,fontSize:12},children:[((((Md=Yt[It])==null?void 0:Md.size)??0)/1024).toFixed(0)," KB"]})]}),ce==="naming"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:"Dateiname eingeben...",value:nt,onChange:xe=>At(xe.target.value),onKeyDown:xe=>{xe.key==="Enter"&&tt()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]})]}),ce==="uploading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsxs("span",{children:["Upload: ",Ze,"%"]})]}),ce==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsx("span",{children:"Erfolgreich hochgeladen!"})]})]}),ce==="naming"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:Ke,children:Yt.length>1?"Überspringen":"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void tt(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),"Hochladen"]})]})]})}),z&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>z.phase!=="downloading"&&G(null),children:P.jsxs("div",{className:"dl-modal",onClick:xe=>xe.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:z.type==="youtube"?"smart_display":z.type==="instagram"?"photo_camera":"audio_file"}),P.jsx("span",{children:z.phase==="input"?"Sound herunterladen":z.phase==="downloading"?"Wird heruntergeladen...":z.phase==="done"?"Fertig!":"Fehler"}),z.phase!=="downloading"&&P.jsx("button",{className:"dl-modal-close",onClick:()=>G(null),children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:`dl-modal-tag ${z.type??""}`,children:z.type==="youtube"?"YouTube":z.type==="instagram"?"Instagram":"MP3"}),P.jsx("span",{className:"dl-modal-url-text",title:z.url,children:z.url.length>60?z.url.slice(0,57)+"...":z.url})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:z.type==="mp3"?"Dateiname...":"Wird automatisch erkannt...",value:z.filename,onChange:xe=>G(Rt=>Rt?{...Rt,filename:xe.target.value}:null),onKeyDown:xe=>{xe.key==="Enter"&&ue()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]}),P.jsx("span",{className:"dl-modal-hint",children:"Leer lassen = automatischer Name"})]}),z.phase==="downloading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsx("span",{children:z.type==="youtube"||z.type==="instagram"?"Audio wird extrahiert...":"MP3 wird heruntergeladen..."})]}),z.phase==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsxs("span",{children:["Gespeichert als ",P.jsx("b",{children:z.savedName})]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-error",children:[P.jsx("span",{className:"material-icons",style:{color:"#e74c3c"},children:"error"}),P.jsx("span",{children:z.error})]})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void ue(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"download"}),"Herunterladen"]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Schliessen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>G(xe=>xe?{...xe,phase:"input",error:void 0}:null),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"refresh"}),"Nochmal"]})]})]})})]})}const _7={IRON:"#6b6b6b",BRONZE:"#8c6239",SILVER:"#8c8c8c",GOLD:"#d4a017",PLATINUM:"#28b29e",EMERALD:"#1e9e5e",DIAMOND:"#576cce",MASTER:"#9d48e0",GRANDMASTER:"#e44c3e",CHALLENGER:"#f4c874"},HAe={SOLORANKED:"Ranked Solo",FLEXRANKED:"Ranked Flex",NORMAL:"Normal",ARAM:"ARAM",ARENA:"Arena",URF:"URF",BOT:"Co-op vs AI"},WAe="https://ddragon.leagueoflegends.com/cdn/15.5.1/img";function ym(i){return`${WAe}/champion/${i}.png`}function y7(i){const e=Math.floor((Date.now()-new Date(i).getTime())/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function $Ae(i){const e=Math.floor(i/60),t=i%60;return`${e}:${String(t).padStart(2,"0")}`}function x7(i,e,t){return e===0?"Perfect":((i+t)/e).toFixed(2)}function b7(i,e){const t=i+e;return t>0?Math.round(i/t*100):0}function XAe(i,e){if(!i)return"Unranked";const t=["","I","II","III","IV"];return`${i.charAt(0)}${i.slice(1).toLowerCase()}${e?" "+(t[e]??e):""}`}function YAe({data:i}){var Lt,hn,ut,fe;const[e,t]=ie.useState(""),[n,r]=ie.useState("EUW"),[s,a]=ie.useState([]),[l,u]=ie.useState(null),[h,m]=ie.useState([]),[v,x]=ie.useState(!1),[S,w]=ie.useState(null),[N,C]=ie.useState([]),[E,O]=ie.useState(null),[U,I]=ie.useState({}),[j,z]=ie.useState(!1),[G,W]=ie.useState(!1),[q,V]=ie.useState(null),[Y,te]=ie.useState("aram"),[ne,le]=ie.useState("EUW"),[Q,K]=ie.useState([]),[ae,Ae]=ie.useState(!1),[be,Se]=ie.useState(null),[se,Ee]=ie.useState([]),[qe,Ce]=ie.useState(""),[ke,Qe]=ie.useState(!1),et=ie.useRef(null),Pt=ie.useRef(null);ie.useEffect(()=>{fetch("/api/lolstats/regions").then(k=>k.json()).then(a).catch(()=>{}),fetch("/api/lolstats/recent").then(k=>k.json()).then(C).catch(()=>{}),fetch("/api/lolstats/modes").then(k=>k.json()).then(Ee).catch(()=>{})},[]),ie.useEffect(()=>{Y&&(Ae(!0),Se(null),Qe(!1),fetch(`/api/lolstats/tierlist?mode=${Y}®ion=${ne}`).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>K(k.champions??[])).catch(k=>Se(k.message)).finally(()=>Ae(!1)))},[Y,ne]),ie.useEffect(()=>{i&&(i.recentSearches&&C(i.recentSearches),i.regions&&!s.length&&a(i.regions))},[i]);const Nt=ie.useCallback(async(k,_e,Be)=>{W(!0);try{const Oe=`gameName=${encodeURIComponent(k)}&tagLine=${encodeURIComponent(_e)}®ion=${Be}`,je=await fetch(`/api/lolstats/renew?${Oe}`,{method:"POST"});if(je.ok){const Bt=await je.json();return Bt.last_updated_at&&V(Bt.last_updated_at),Bt.renewed??!1}}catch{}return W(!1),!1},[]),Gt=ie.useCallback(async(k,_e,Be,Oe=!1)=>{var Xt,ln;let je=k??"",Bt=_e??"";const yt=Be??n;if(!je){const mt=e.split("#");je=((Xt=mt[0])==null?void 0:Xt.trim())??"",Bt=((ln=mt[1])==null?void 0:ln.trim())??""}if(!je||!Bt){w("Bitte im Format Name#Tag eingeben");return}x(!0),w(null),u(null),m([]),O(null),I({}),Pt.current={gameName:je,tagLine:Bt,region:yt},Oe||Nt(je,Bt,yt).finally(()=>W(!1));try{const mt=`gameName=${encodeURIComponent(je)}&tagLine=${encodeURIComponent(Bt)}®ion=${yt}`,[Wt,Yt]=await Promise.all([fetch(`/api/lolstats/profile?${mt}`),fetch(`/api/lolstats/matches?${mt}&limit=10`)]);if(!Wt.ok){const It=await Wt.json();throw new Error(It.error??`Fehler ${Wt.status}`)}const $t=await Wt.json();if(u($t),$t.updated_at&&V($t.updated_at),Yt.ok){const It=await Yt.json();m(Array.isArray(It)?It:[])}}catch(mt){w(mt.message)}x(!1)},[e,n,Nt]),Tt=ie.useCallback(async()=>{const k=Pt.current;if(!(!k||G)){W(!0);try{await Nt(k.gameName,k.tagLine,k.region),await new Promise(_e=>setTimeout(_e,1500)),await Gt(k.gameName,k.tagLine,k.region,!0)}finally{W(!1)}}},[Nt,Gt,G]),Ge=ie.useCallback(async()=>{if(!(!l||j)){z(!0);try{const k=`gameName=${encodeURIComponent(l.game_name)}&tagLine=${encodeURIComponent(l.tagline)}®ion=${n}&limit=20`,_e=await fetch(`/api/lolstats/matches?${k}`);if(_e.ok){const Be=await _e.json();m(Array.isArray(Be)?Be:[])}}catch{}z(!1)}},[l,n,j]),dt=ie.useCallback(async k=>{var _e;if(E===k.id){O(null);return}if(O(k.id),!(((_e=k.participants)==null?void 0:_e.length)>=10||U[k.id]))try{const Be=`region=${n}&createdAt=${encodeURIComponent(k.created_at)}`,Oe=await fetch(`/api/lolstats/match/${encodeURIComponent(k.id)}?${Be}`);if(Oe.ok){const je=await Oe.json();I(Bt=>({...Bt,[k.id]:je}))}}catch{}},[E,U,n]),he=ie.useCallback(k=>{t(`${k.game_name}#${k.tag_line}`),r(k.region),Gt(k.game_name,k.tag_line,k.region)},[Gt]),en=ie.useCallback(k=>{var Be,Oe,je;if(!l)return((Be=k.participants)==null?void 0:Be[0])??null;const _e=l.game_name.toLowerCase();return((Oe=k.participants)==null?void 0:Oe.find(Bt=>{var yt,Xt;return((Xt=(yt=Bt.summoner)==null?void 0:yt.game_name)==null?void 0:Xt.toLowerCase())===_e}))??((je=k.participants)==null?void 0:je[0])??null},[l]),wt=k=>{var ln,mt,Wt;const _e=en(k);if(!_e)return null;const Be=((ln=_e.stats)==null?void 0:ln.result)==="WIN",Oe=x7(_e.stats.kill,_e.stats.death,_e.stats.assist),je=(_e.stats.minion_kill??0)+(_e.stats.neutral_minion_kill??0),Bt=k.game_length_second>0?(je/(k.game_length_second/60)).toFixed(1):"0",yt=E===k.id,Xt=U[k.id]??(((mt=k.participants)==null?void 0:mt.length)>=10?k:null);return P.jsxs("div",{children:[P.jsxs("div",{className:`lol-match ${Be?"win":"loss"}`,onClick:()=>dt(k),children:[P.jsx("div",{className:"lol-match-result",children:Be?"W":"L"}),P.jsxs("div",{className:"lol-match-champ",children:[P.jsx("img",{src:ym(_e.champion_name),alt:_e.champion_name,title:_e.champion_name}),P.jsx("span",{className:"lol-match-champ-level",children:_e.stats.champion_level})]}),P.jsxs("div",{className:"lol-match-kda",children:[P.jsxs("div",{className:"lol-match-kda-nums",children:[_e.stats.kill,"/",_e.stats.death,"/",_e.stats.assist]}),P.jsxs("div",{className:`lol-match-kda-ratio ${Oe==="Perfect"?"perfect":Number(Oe)>=4?"great":""}`,children:[Oe," KDA"]})]}),P.jsxs("div",{className:"lol-match-stats",children:[P.jsxs("span",{children:[je," CS (",Bt,"/m)"]}),P.jsxs("span",{children:[_e.stats.ward_place," wards"]})]}),P.jsx("div",{className:"lol-match-items",children:(_e.items_names??[]).slice(0,7).map((Yt,$t)=>Yt?P.jsx("img",{src:ym("Aatrox"),alt:Yt,title:Yt,style:{background:"var(--bg-deep)"},onError:It=>{It.target.style.display="none"}},$t):P.jsx("div",{className:"lol-match-item-empty"},$t))}),P.jsxs("div",{className:"lol-match-meta",children:[P.jsx("div",{className:"lol-match-duration",children:$Ae(k.game_length_second)}),P.jsx("div",{className:"lol-match-queue",children:HAe[k.game_type]??k.game_type}),P.jsxs("div",{className:"lol-match-ago",children:[y7(k.created_at)," ago"]})]})]}),yt&&Xt&&P.jsx("div",{className:"lol-match-detail",children:qt(Xt,(Wt=_e.summoner)==null?void 0:Wt.game_name)})]},k.id)},qt=(k,_e)=>{var yt,Xt,ln,mt,Wt;const Be=((yt=k.participants)==null?void 0:yt.filter(Yt=>Yt.team_key==="BLUE"))??[],Oe=((Xt=k.participants)==null?void 0:Xt.filter(Yt=>Yt.team_key==="RED"))??[],je=(Wt=(mt=(ln=k.teams)==null?void 0:ln.find(Yt=>Yt.key==="BLUE"))==null?void 0:mt.game_stat)==null?void 0:Wt.is_win,Bt=(Yt,$t,It)=>P.jsxs("div",{className:"lol-match-detail-team",children:[P.jsxs("div",{className:`lol-match-detail-team-header ${$t?"win":"loss"}`,children:[It," — ",$t?"Victory":"Defeat"]}),Yt.map((Te,nt)=>{var xt,Ze,lt,bt,Kt,un,Ye,St,ye,pt,Zt,Pe;const At=((Ze=(xt=Te.summoner)==null?void 0:xt.game_name)==null?void 0:Ze.toLowerCase())===(_e==null?void 0:_e.toLowerCase()),ce=(((lt=Te.stats)==null?void 0:lt.minion_kill)??0)+(((bt=Te.stats)==null?void 0:bt.neutral_minion_kill)??0);return P.jsxs("div",{className:`lol-detail-row ${At?"me":""}`,children:[P.jsx("img",{className:"lol-detail-champ",src:ym(Te.champion_name),alt:Te.champion_name}),P.jsx("span",{className:"lol-detail-name",title:`${(Kt=Te.summoner)==null?void 0:Kt.game_name}#${(un=Te.summoner)==null?void 0:un.tagline}`,children:((Ye=Te.summoner)==null?void 0:Ye.game_name)??Te.champion_name}),P.jsxs("span",{className:"lol-detail-kda",children:[(St=Te.stats)==null?void 0:St.kill,"/",(ye=Te.stats)==null?void 0:ye.death,"/",(pt=Te.stats)==null?void 0:pt.assist]}),P.jsxs("span",{className:"lol-detail-cs",children:[ce," CS"]}),P.jsxs("span",{className:"lol-detail-dmg",children:[((((Zt=Te.stats)==null?void 0:Zt.total_damage_dealt_to_champions)??0)/1e3).toFixed(1),"k"]}),P.jsxs("span",{className:"lol-detail-gold",children:[((((Pe=Te.stats)==null?void 0:Pe.gold_earned)??0)/1e3).toFixed(1),"k"]})]},nt)})]});return P.jsxs(P.Fragment,{children:[Bt(Be,je,"Blue Team"),Bt(Oe,je===void 0?void 0:!je,"Red Team")]})};return P.jsxs("div",{className:"lol-container",children:[P.jsxs("div",{className:"lol-search",children:[P.jsx("input",{ref:et,className:"lol-search-input",placeholder:"Summoner Name#Tag",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>k.key==="Enter"&&Gt()}),P.jsx("select",{className:"lol-search-region",value:n,onChange:k=>r(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("button",{className:"lol-search-btn",onClick:()=>Gt(),disabled:v,children:v?"...":"Search"})]}),N.length>0&&P.jsx("div",{className:"lol-recent",children:N.map((k,_e)=>P.jsxs("button",{className:"lol-recent-chip",onClick:()=>he(k),children:[k.profile_image_url&&P.jsx("img",{src:k.profile_image_url,alt:""}),k.game_name,"#",k.tag_line,k.tier&&P.jsx("span",{className:"lol-recent-tier",style:{color:_7[k.tier]},children:k.tier})]},_e))}),S&&P.jsx("div",{className:"lol-error",children:S}),v&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Profil..."]}),l&&!v&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-profile",children:[P.jsx("img",{className:"lol-profile-icon",src:l.profile_image_url,alt:""}),P.jsxs("div",{className:"lol-profile-info",children:[P.jsxs("h2",{children:[l.game_name,P.jsxs("span",{children:["#",l.tagline]})]}),P.jsxs("div",{className:"lol-profile-level",children:["Level ",l.level]}),((Lt=l.ladder_rank)==null?void 0:Lt.rank)&&P.jsxs("div",{className:"lol-profile-ladder",children:["Ladder Rank #",l.ladder_rank.rank.toLocaleString()," / ",(hn=l.ladder_rank.total)==null?void 0:hn.toLocaleString()]}),q&&P.jsxs("div",{className:"lol-profile-updated",children:["Updated ",y7(q)," ago"]})]}),P.jsxs("button",{className:`lol-update-btn ${G?"renewing":""}`,onClick:Tt,disabled:G,title:"Refresh data from Riot servers",children:[P.jsx("span",{className:"lol-update-icon",children:G?"⟳":"↻"}),G?"Updating...":"Update"]})]}),P.jsx("div",{className:"lol-ranked-row",children:(l.league_stats??[]).filter(k=>k.game_type==="SOLORANKED"||k.game_type==="FLEXRANKED").map(k=>{const _e=k.tier_info,Be=!!(_e!=null&&_e.tier),Oe=_7[(_e==null?void 0:_e.tier)??""]??"var(--text-normal)";return P.jsxs("div",{className:`lol-ranked-card ${Be?"has-rank":""}`,style:{"--tier-color":Oe},children:[P.jsx("div",{className:"lol-ranked-type",children:k.game_type==="SOLORANKED"?"Ranked Solo/Duo":"Ranked Flex"}),Be?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-ranked-tier",style:{color:Oe},children:[XAe(_e.tier,_e.division),P.jsxs("span",{className:"lol-ranked-lp",children:[_e.lp," LP"]})]}),P.jsxs("div",{className:"lol-ranked-record",children:[k.win,"W ",k.lose,"L",P.jsxs("span",{className:"lol-ranked-wr",children:["(",b7(k.win??0,k.lose??0),"%)"]}),k.is_hot_streak&&P.jsx("span",{className:"lol-ranked-streak",children:"🔥"})]})]}):P.jsx("div",{className:"lol-ranked-tier",children:"Unranked"})]},k.game_type)})}),((fe=(ut=l.most_champions)==null?void 0:ut.champion_stats)==null?void 0:fe.length)>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Top Champions"}),P.jsx("div",{className:"lol-champs",children:l.most_champions.champion_stats.slice(0,7).map(k=>{const _e=b7(k.win,k.lose),Be=k.play>0?x7(k.kill/k.play,k.death/k.play,k.assist/k.play):"0";return P.jsxs("div",{className:"lol-champ-card",children:[P.jsx("img",{className:"lol-champ-icon",src:ym(k.champion_name),alt:k.champion_name}),P.jsxs("div",{children:[P.jsx("div",{className:"lol-champ-name",children:k.champion_name}),P.jsxs("div",{className:"lol-champ-stats",children:[k.play," games · ",_e,"% WR"]}),P.jsxs("div",{className:"lol-champ-kda",children:[Be," KDA"]})]})]},k.champion_name)})})]}),h.length>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Match History"}),P.jsx("div",{className:"lol-matches",children:h.map(k=>wt(k))}),h.length<20&&P.jsx("button",{className:"lol-load-more",onClick:Ge,disabled:j,children:j?"Laden...":"Mehr laden"})]})]}),!l&&!v&&!S&&P.jsxs("div",{className:"lol-empty",children:[P.jsx("div",{className:"lol-empty-icon",children:"⚔️"}),P.jsx("h3",{children:"League of Legends Stats"}),P.jsx("p",{children:"Gib einen Summoner Name#Tag ein und wähle die Region"})]}),P.jsxs("div",{className:"lol-tier-section",children:[P.jsx("div",{className:"lol-section-title",children:"Champion Tier List"}),P.jsxs("div",{className:"lol-tier-controls",children:[P.jsx("div",{className:"lol-tier-modes",children:se.map(k=>P.jsx("button",{className:`lol-tier-mode-btn ${Y===k.key?"active":""}`,onClick:()=>te(k.key),children:k.label},k.key))}),P.jsx("select",{className:"lol-search-region",value:ne,onChange:k=>le(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("input",{className:"lol-tier-filter",placeholder:"Filter champion...",value:qe,onChange:k=>Ce(k.target.value)})]}),ae&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Tier List..."]}),be&&P.jsx("div",{className:"lol-error",children:be}),!ae&&!be&&Q.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-tier-table",children:[P.jsxs("div",{className:"lol-tier-header",children:[P.jsx("span",{className:"lol-tier-col-rank",children:"#"}),P.jsx("span",{className:"lol-tier-col-champ",children:"Champion"}),P.jsx("span",{className:"lol-tier-col-tier",children:"Tier"}),P.jsx("span",{className:"lol-tier-col-wr",children:Y==="arena"?"Win":"Win %"}),P.jsx("span",{className:"lol-tier-col-pr",children:"Pick %"}),Y!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:"Ban %"}),P.jsx("span",{className:"lol-tier-col-kda",children:Y==="arena"?"Avg Place":"KDA"})]}),Q.filter(k=>!qe||k.champion_name.toLowerCase().includes(qe.toLowerCase())).slice(0,ke?void 0:50).map(k=>{var Be,Oe;const _e=["OP","1","2","3","4","5"];return P.jsxs("div",{className:`lol-tier-row tier-${k.tier}`,children:[P.jsx("span",{className:"lol-tier-col-rank",children:k.rank}),P.jsxs("span",{className:"lol-tier-col-champ",children:[P.jsx("img",{src:ym(k.champion_name),alt:k.champion_name}),k.champion_name]}),P.jsx("span",{className:`lol-tier-col-tier tier-badge-${k.tier}`,children:_e[k.tier]??k.tier}),P.jsx("span",{className:"lol-tier-col-wr",children:k.win_rate!=null?`${(k.win_rate*100).toFixed(1)}%`:"-"}),P.jsxs("span",{className:"lol-tier-col-pr",children:[(k.pick_rate*100).toFixed(1),"%"]}),Y!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:k.ban_rate!=null?`${(k.ban_rate*100).toFixed(1)}%`:"-"}),P.jsx("span",{className:"lol-tier-col-kda",children:Y==="arena"?((Be=k.average_placement)==null?void 0:Be.toFixed(1))??"-":((Oe=k.kda)==null?void 0:Oe.toFixed(2))??"-"})]},k.champion_id)})]}),!ke&&Q.length>50&&P.jsxs("button",{className:"lol-load-more",onClick:()=>Qe(!0),children:["Alle ",Q.length," Champions anzeigen"]})]})]})]})}const S7={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function qS(i){const e=Math.max(0,Math.floor((Date.now()-new Date(i).getTime())/1e3)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}const VS=[{label:"Niedrig · 4 Mbit · 60fps",fps:60,bitrate:4e6},{label:"Mittel · 8 Mbit · 60fps",fps:60,bitrate:8e6},{label:"Hoch · 14 Mbit · 60fps",fps:60,bitrate:14e6},{label:"Ultra · 25 Mbit · 60fps",fps:60,bitrate:25e6},{label:"Max · 50 Mbit · 165fps",fps:165,bitrate:5e7}];function QAe({data:i,isAdmin:e}){var Ye,St;const[t,n]=ie.useState([]),[r,s]=ie.useState(()=>localStorage.getItem("streaming_name")||""),[a,l]=ie.useState("Screen Share"),[u,h]=ie.useState(""),[m,v]=ie.useState(1),[x,S]=ie.useState(null),[w,N]=ie.useState(null),[C,E]=ie.useState(null),[O,U]=ie.useState(!1),[I,j]=ie.useState(!1),[z,G]=ie.useState(null),[,W]=ie.useState(0),[q,V]=ie.useState(null),[Y,te]=ie.useState(null),[ne,le]=ie.useState(!1),Q=e??!1,[K,ae]=ie.useState([]),[Ae,be]=ie.useState([]),[Se,se]=ie.useState(!1),[Ee,qe]=ie.useState(!1),[Ce,ke]=ie.useState({online:!1,botTag:null}),Qe=ie.useRef(null),et=ie.useRef(""),Pt=ie.useRef(null),Nt=ie.useRef(null),Gt=ie.useRef(null),Tt=ie.useRef(new Map),Ge=ie.useRef(null),dt=ie.useRef(null),he=ie.useRef(new Map),en=ie.useRef(null),wt=ie.useRef(1e3),qt=ie.useRef(!1),Lt=ie.useRef(null),hn=ie.useRef(VS[1]);ie.useEffect(()=>{qt.current=O},[O]),ie.useEffect(()=>{Lt.current=z},[z]),ie.useEffect(()=>{hn.current=VS[m]},[m]),ie.useEffect(()=>{var ye,pt;(pt=(ye=window.electronAPI)==null?void 0:ye.setStreaming)==null||pt.call(ye,O||z!==null)},[O,z]),ie.useEffect(()=>{if(!(t.length>0||O))return;const pt=setInterval(()=>W(Zt=>Zt+1),1e3);return()=>clearInterval(pt)},[t.length,O]),ie.useEffect(()=>{i!=null&&i.streams&&n(i.streams)},[i]),ie.useEffect(()=>{r&&localStorage.setItem("streaming_name",r)},[r]),ie.useEffect(()=>{if(!q)return;const ye=()=>V(null);return document.addEventListener("click",ye),()=>document.removeEventListener("click",ye)},[q]),ie.useEffect(()=>{fetch("/api/notifications/status").then(ye=>ye.json()).then(ye=>ke(ye)).catch(()=>{})},[]);const ut=ie.useCallback(ye=>{var pt;((pt=Qe.current)==null?void 0:pt.readyState)===WebSocket.OPEN&&Qe.current.send(JSON.stringify(ye))},[]),fe=ie.useCallback((ye,pt,Zt)=>{if(ye.remoteDescription)ye.addIceCandidate(new RTCIceCandidate(Zt)).catch(()=>{});else{let Pe=he.current.get(pt);Pe||(Pe=[],he.current.set(pt,Pe)),Pe.push(Zt)}},[]),k=ie.useCallback((ye,pt)=>{const Zt=he.current.get(pt);if(Zt){for(const Pe of Zt)ye.addIceCandidate(new RTCIceCandidate(Pe)).catch(()=>{});he.current.delete(pt)}},[]),_e=ie.useCallback((ye,pt)=>{ye.srcObject=pt;const Zt=ye.play();Zt&&Zt.catch(()=>{ye.muted=!0,ye.play().catch(()=>{})})},[]),Be=ie.useCallback(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),Ge.current&&(Ge.current.close(),Ge.current=null),dt.current=null,Gt.current&&(Gt.current.srcObject=null)},[]),Oe=ie.useRef(()=>{});Oe.current=ye=>{var pt,Zt,Pe;switch(ye.type){case"welcome":et.current=ye.clientId,ye.streams&&n(ye.streams);break;case"broadcast_started":E(ye.streamId),U(!0),qt.current=!0,j(!1),(pt=window.electronAPI)!=null&&pt.showNotification&&window.electronAPI.showNotification("Stream gestartet","Dein Stream ist jetzt live!");break;case"stream_available":n(ht=>ht.some(ot=>ot.id===ye.streamId)?ht:[...ht,{id:ye.streamId,broadcasterName:ye.broadcasterName,title:ye.title,startedAt:new Date().toISOString(),viewerCount:0,hasPassword:!!ye.hasPassword}]);const at=`${ye.broadcasterName} streamt: ${ye.title}`;(Zt=window.electronAPI)!=null&&Zt.showNotification?window.electronAPI.showNotification("Neuer Stream",at):Notification.permission==="granted"&&new Notification("Neuer Stream",{body:at,icon:"/assets/icon.png"});break;case"stream_ended":n(ht=>ht.filter(ot=>ot.id!==ye.streamId)),((Pe=Lt.current)==null?void 0:Pe.streamId)===ye.streamId&&(Be(),G(null));break;case"viewer_joined":{const ht=ye.viewerId,ot=Tt.current.get(ht);ot&&(ot.close(),Tt.current.delete(ht)),he.current.delete(ht);const f=new RTCPeerConnection(S7);Tt.current.set(ht,f);const J=Pt.current;if(J)for(const fn of J.getTracks())f.addTrack(fn,J);f.onicecandidate=fn=>{fn.candidate&&ut({type:"ice_candidate",targetId:ht,candidate:fn.candidate.toJSON()})};const _n=f.getSenders().find(fn=>{var zn;return((zn=fn.track)==null?void 0:zn.kind)==="video"});if(_n){const fn=_n.getParameters();(!fn.encodings||fn.encodings.length===0)&&(fn.encodings=[{}]),fn.encodings[0].maxFramerate=hn.current.fps,fn.encodings[0].maxBitrate=hn.current.bitrate,_n.setParameters(fn).catch(()=>{})}f.createOffer().then(fn=>f.setLocalDescription(fn)).then(()=>ut({type:"offer",targetId:ht,sdp:f.localDescription})).catch(console.error);break}case"viewer_left":{const ht=Tt.current.get(ye.viewerId);ht&&(ht.close(),Tt.current.delete(ye.viewerId)),he.current.delete(ye.viewerId);break}case"offer":{const ht=ye.fromId;Ge.current&&(Ge.current.close(),Ge.current=null),he.current.delete(ht);const ot=new RTCPeerConnection(S7);Ge.current=ot,ot.ontrack=f=>{const J=f.streams[0];if(!J)return;dt.current=J;const _n=Gt.current;_n&&_e(_n,J),G(fn=>fn&&{...fn,phase:"connected"})},ot.onicecandidate=f=>{f.candidate&&ut({type:"ice_candidate",targetId:ht,candidate:f.candidate.toJSON()})},ot.oniceconnectionstatechange=()=>{(ot.iceConnectionState==="failed"||ot.iceConnectionState==="disconnected")&&G(f=>f&&{...f,phase:"error",error:"Verbindung verloren"})},ot.setRemoteDescription(new RTCSessionDescription(ye.sdp)).then(()=>(k(ot,ht),ot.createAnswer())).then(f=>ot.setLocalDescription(f)).then(()=>ut({type:"answer",targetId:ht,sdp:ot.localDescription})).catch(console.error);break}case"answer":{const ht=Tt.current.get(ye.fromId);ht&&ht.setRemoteDescription(new RTCSessionDescription(ye.sdp)).then(()=>k(ht,ye.fromId)).catch(console.error);break}case"ice_candidate":{if(!ye.candidate)break;const ht=Tt.current.get(ye.fromId);ht?fe(ht,ye.fromId,ye.candidate):Ge.current&&fe(Ge.current,ye.fromId,ye.candidate);break}case"error":ye.code==="WRONG_PASSWORD"?N(ht=>ht&&{...ht,error:ye.message}):S(ye.message),j(!1);break}};const je=ie.useCallback(()=>{if(Qe.current&&Qe.current.readyState===WebSocket.OPEN)return;const ye=location.protocol==="https:"?"wss":"ws",pt=new WebSocket(`${ye}://${location.host}/ws/streaming`);Qe.current=pt,pt.onopen=()=>{wt.current=1e3},pt.onmessage=Zt=>{let Pe;try{Pe=JSON.parse(Zt.data)}catch{return}Oe.current(Pe)},pt.onclose=()=>{Qe.current=null,en.current=setTimeout(()=>{wt.current=Math.min(wt.current*2,1e4),je()},wt.current)},pt.onerror=()=>{pt.close()}},[]);ie.useEffect(()=>(je(),()=>{en.current&&clearTimeout(en.current)}),[je]);const Bt=ie.useCallback(async()=>{var ye,pt;if(!r.trim()){S("Bitte gib einen Namen ein.");return}if(!((ye=navigator.mediaDevices)!=null&&ye.getDisplayMedia)){S("Dein Browser unterstützt keine Bildschirmfreigabe.");return}S(null),j(!0);try{const Zt=hn.current,Pe=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:Zt.fps}},audio:!0});Pt.current=Pe,Nt.current&&(Nt.current.srcObject=Pe),(pt=Pe.getVideoTracks()[0])==null||pt.addEventListener("ended",()=>{yt()}),je();const at=()=>{var ht;((ht=Qe.current)==null?void 0:ht.readyState)===WebSocket.OPEN?ut({type:"start_broadcast",name:r.trim(),title:a.trim()||"Screen Share",password:u.trim()||void 0}):setTimeout(at,100)};at()}catch(Zt){j(!1),Zt.name==="NotAllowedError"?S("Bildschirmfreigabe wurde abgelehnt."):S(`Fehler: ${Zt.message}`)}},[r,a,u,je,ut]),yt=ie.useCallback(()=>{var ye;ut({type:"stop_broadcast"}),(ye=Pt.current)==null||ye.getTracks().forEach(pt=>pt.stop()),Pt.current=null,Nt.current&&(Nt.current.srcObject=null);for(const pt of Tt.current.values())pt.close();Tt.current.clear(),U(!1),qt.current=!1,E(null),h("")},[ut]),Xt=ie.useCallback(ye=>{S(null),G({streamId:ye,phase:"connecting"}),je();const pt=()=>{var Zt;((Zt=Qe.current)==null?void 0:Zt.readyState)===WebSocket.OPEN?ut({type:"join_viewer",name:r.trim()||"Viewer",streamId:ye}):setTimeout(pt,100)};pt()},[r,je,ut]),ln=ie.useCallback(ye=>{ye.hasPassword?N({streamId:ye.id,streamTitle:ye.title,broadcasterName:ye.broadcasterName,password:"",error:null}):Xt(ye.id)},[Xt]),mt=ie.useCallback(()=>{if(!w)return;if(!w.password.trim()){N(Pe=>Pe&&{...Pe,error:"Passwort eingeben."});return}const{streamId:ye,password:pt}=w;N(null),S(null),G({streamId:ye,phase:"connecting"}),je();const Zt=()=>{var Pe;((Pe=Qe.current)==null?void 0:Pe.readyState)===WebSocket.OPEN?ut({type:"join_viewer",name:r.trim()||"Viewer",streamId:ye,password:pt.trim()}):setTimeout(Zt,100)};Zt()},[w,r,je,ut]),Wt=ie.useCallback(()=>{ut({type:"leave_viewer"}),Be(),G(null)},[Be,ut]);ie.useEffect(()=>{const ye=Zt=>{(qt.current||Lt.current)&&Zt.preventDefault()},pt=()=>{et.current&&navigator.sendBeacon("/api/streaming/disconnect",JSON.stringify({clientId:et.current}))};return window.addEventListener("beforeunload",ye),window.addEventListener("pagehide",pt),()=>{window.removeEventListener("beforeunload",ye),window.removeEventListener("pagehide",pt)}},[]);const Yt=ie.useRef(null),[$t,It]=ie.useState(!1),Te=ie.useCallback(()=>{const ye=Yt.current;ye&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):ye.requestFullscreen().catch(()=>{}))},[]);ie.useEffect(()=>{const ye=()=>It(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",ye),()=>document.removeEventListener("fullscreenchange",ye)},[]),ie.useEffect(()=>()=>{var ye;(ye=Pt.current)==null||ye.getTracks().forEach(pt=>pt.stop());for(const pt of Tt.current.values())pt.close();Ge.current&&Ge.current.close(),Qe.current&&Qe.current.close(),en.current&&clearTimeout(en.current)},[]),ie.useEffect(()=>{z&&dt.current&&Gt.current&&!Gt.current.srcObject&&_e(Gt.current,dt.current)},[z,_e]);const nt=ie.useRef(null);ie.useEffect(()=>{const pt=new URLSearchParams(location.search).get("viewStream");if(pt){nt.current=pt;const Zt=new URL(location.href);Zt.searchParams.delete("viewStream"),window.history.replaceState({},"",Zt.toString())}},[]),ie.useEffect(()=>{const ye=nt.current;if(!ye||t.length===0)return;const pt=t.find(Zt=>Zt.id===ye);pt&&(nt.current=null,ln(pt))},[t,ln]);const At=ie.useCallback(ye=>{const pt=new URL(location.href);return pt.searchParams.set("viewStream",ye),pt.hash="",pt.toString()},[]),ce=ie.useCallback(ye=>{navigator.clipboard.writeText(At(ye)).then(()=>{te(ye),setTimeout(()=>te(null),2e3)}).catch(()=>{})},[At]),xt=ie.useCallback(ye=>{window.open(At(ye),"_blank","noopener"),V(null)},[At]),Ze=ie.useCallback(async()=>{se(!0);try{const[ye,pt]=await Promise.all([fetch("/api/notifications/channels",{credentials:"include"}),fetch("/api/notifications/config",{credentials:"include"})]);if(ye.ok){const Zt=await ye.json();ae(Zt.channels||[])}if(pt.ok){const Zt=await pt.json();be(Zt.channels||[])}}catch{}finally{se(!1)}},[]),lt=ie.useCallback(()=>{le(!0),Q&&Ze()},[Q,Ze]),bt=ie.useCallback((ye,pt,Zt,Pe,at)=>{be(ht=>{const ot=ht.find(f=>f.channelId===ye);if(ot){const J=ot.events.includes(at)?ot.events.filter(_n=>_n!==at):[...ot.events,at];return J.length===0?ht.filter(_n=>_n.channelId!==ye):ht.map(_n=>_n.channelId===ye?{..._n,events:J}:_n)}else return[...ht,{channelId:ye,channelName:pt,guildId:Zt,guildName:Pe,events:[at]}]})},[]),Kt=ie.useCallback(async()=>{qe(!0);try{(await fetch("/api/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channels:Ae}),credentials:"include"})).ok}catch{}finally{qe(!1)}},[Ae]),un=ie.useCallback((ye,pt)=>{const Zt=Ae.find(Pe=>Pe.channelId===ye);return(Zt==null?void 0:Zt.events.includes(pt))??!1},[Ae]);if(z){const ye=t.find(pt=>pt.id===z.streamId);return P.jsxs("div",{className:"stream-viewer-overlay",ref:Yt,children:[P.jsxs("div",{className:"stream-viewer-header",children:[P.jsxs("div",{className:"stream-viewer-header-left",children:[P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("div",{children:[P.jsx("div",{className:"stream-viewer-title",children:(ye==null?void 0:ye.title)||"Stream"}),P.jsxs("div",{className:"stream-viewer-subtitle",children:[(ye==null?void 0:ye.broadcasterName)||"..."," ",ye?` · ${ye.viewerCount} Zuschauer`:""]})]})]}),P.jsxs("div",{className:"stream-viewer-header-right",children:[P.jsx("button",{className:"stream-viewer-fullscreen",onClick:Te,title:$t?"Vollbild verlassen":"Vollbild",children:$t?"✖":"⛶"}),P.jsx("button",{className:"stream-viewer-close",onClick:Wt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"stream-viewer-video",children:[z.phase==="connecting"?P.jsxs("div",{className:"stream-viewer-connecting",children:[P.jsx("div",{className:"stream-viewer-spinner"}),"Verbindung wird hergestellt..."]}):z.phase==="error"?P.jsxs("div",{className:"stream-viewer-connecting",children:[z.error||"Verbindungsfehler",P.jsx("button",{className:"stream-btn",onClick:Wt,children:"Zurück"})]}):null,P.jsx("video",{ref:Gt,autoPlay:!0,playsInline:!0,style:z.phase==="connected"?{}:{display:"none"}})]})]})}return P.jsxs("div",{className:"stream-container",children:[x&&P.jsxs("div",{className:"stream-error",children:[x,P.jsx("button",{className:"stream-error-dismiss",onClick:()=>S(null),children:"×"})]}),P.jsxs("div",{className:"stream-topbar",children:[P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Name"}),P.jsx("input",{className:"stream-input stream-input-name",placeholder:"Dein Name",value:r,onChange:ye=>s(ye.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field stream-field-grow",children:[P.jsx("span",{className:"stream-field-label",children:"Titel"}),P.jsx("input",{className:"stream-input stream-input-title",placeholder:"Stream-Titel",value:a,onChange:ye=>l(ye.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Passwort"}),P.jsx("input",{className:"stream-input stream-input-password",type:"password",placeholder:"optional",value:u,onChange:ye=>h(ye.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsxs("span",{className:"stream-field-label",children:["Qualit","ä","t"]}),P.jsx("select",{className:"stream-select-quality",value:m,onChange:ye=>v(Number(ye.target.value)),disabled:O,children:VS.map((ye,pt)=>P.jsx("option",{value:pt,children:ye.label},ye.label))})]}),O?P.jsxs("button",{className:"stream-btn stream-btn-stop",onClick:yt,children:["⏹"," Stream beenden"]}):P.jsx("button",{className:"stream-btn",onClick:Bt,disabled:I,children:I?"Starte...":"🖥️ Stream starten"}),Q&&P.jsx("button",{className:"stream-admin-btn",onClick:lt,title:"Notification Einstellungen",children:"⚙️"})]}),t.length===0&&!O?P.jsxs("div",{className:"stream-empty",children:[P.jsx("div",{className:"stream-empty-icon",children:"📺"}),P.jsx("h3",{children:"Keine aktiven Streams"}),P.jsx("p",{children:"Starte einen Stream, um deinen Bildschirm zu teilen."})]}):P.jsxs("div",{className:"stream-grid",children:[O&&P.jsxs("div",{className:"stream-tile own broadcasting",children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("video",{ref:Nt,autoPlay:!0,playsInline:!0,muted:!0}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",((Ye=t.find(ye=>ye.id===C))==null?void 0:Ye.viewerCount)??0]})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsxs("div",{className:"stream-tile-name",children:[r," (Du)"]}),P.jsx("div",{className:"stream-tile-title",children:a})]}),P.jsx("span",{className:"stream-tile-time",children:C&&((St=t.find(ye=>ye.id===C))!=null&&St.startedAt)?qS(t.find(ye=>ye.id===C).startedAt):"0:00"})]})]}),t.filter(ye=>ye.id!==C).map(ye=>P.jsxs("div",{className:"stream-tile",onClick:()=>ln(ye),children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("span",{className:"stream-tile-icon",children:"🖥️"}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",ye.viewerCount]}),ye.hasPassword&&P.jsx("span",{className:"stream-tile-lock",children:"🔒"})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsx("div",{className:"stream-tile-name",children:ye.broadcasterName}),P.jsx("div",{className:"stream-tile-title",children:ye.title})]}),P.jsx("span",{className:"stream-tile-time",children:qS(ye.startedAt)}),P.jsxs("div",{className:"stream-tile-menu-wrap",children:[P.jsx("button",{className:"stream-tile-menu",onClick:pt=>{pt.stopPropagation(),V(q===ye.id?null:ye.id)},children:"⋮"}),q===ye.id&&P.jsxs("div",{className:"stream-tile-dropdown",onClick:pt=>pt.stopPropagation(),children:[P.jsxs("div",{className:"stream-tile-dropdown-header",children:[P.jsx("div",{className:"stream-tile-dropdown-name",children:ye.broadcasterName}),P.jsx("div",{className:"stream-tile-dropdown-title",children:ye.title}),P.jsxs("div",{className:"stream-tile-dropdown-detail",children:["👥"," ",ye.viewerCount," Zuschauer · ",qS(ye.startedAt)]})]}),P.jsx("div",{className:"stream-tile-dropdown-divider"}),P.jsxs("button",{className:"stream-tile-dropdown-item",onClick:()=>xt(ye.id),children:["🗗"," In neuem Fenster öffnen"]}),P.jsx("button",{className:"stream-tile-dropdown-item",onClick:()=>{ce(ye.id),V(null)},children:Y===ye.id?"✅ Kopiert!":"🔗 Link teilen"})]})]})]})]},ye.id))]}),w&&P.jsx("div",{className:"stream-pw-overlay",onClick:()=>N(null),children:P.jsxs("div",{className:"stream-pw-modal",onClick:ye=>ye.stopPropagation(),children:[P.jsx("h3",{children:w.broadcasterName}),P.jsx("p",{children:w.streamTitle}),w.error&&P.jsx("div",{className:"stream-pw-modal-error",children:w.error}),P.jsx("input",{className:"stream-input",type:"password",placeholder:"Stream-Passwort",value:w.password,onChange:ye=>N(pt=>pt&&{...pt,password:ye.target.value,error:null}),onKeyDown:ye=>{ye.key==="Enter"&&mt()},autoFocus:!0}),P.jsxs("div",{className:"stream-pw-actions",children:[P.jsx("button",{className:"stream-pw-cancel",onClick:()=>N(null),children:"Abbrechen"}),P.jsx("button",{className:"stream-btn",onClick:mt,children:"Beitreten"})]})]})}),ne&&P.jsx("div",{className:"stream-admin-overlay",onClick:()=>le(!1),children:P.jsxs("div",{className:"stream-admin-panel",onClick:ye=>ye.stopPropagation(),children:[P.jsxs("div",{className:"stream-admin-header",children:[P.jsxs("h3",{children:["🔔"," Benachrichtigungen"]}),P.jsx("button",{className:"stream-admin-close",onClick:()=>le(!1),children:"✕"})]}),P.jsxs("div",{className:"stream-admin-content",children:[P.jsx("div",{className:"stream-admin-toolbar",children:P.jsx("span",{className:"stream-admin-status",children:Ce.online?P.jsxs(P.Fragment,{children:["✅"," Bot online: ",P.jsx("b",{children:Ce.botTag})]}):P.jsxs(P.Fragment,{children:["⚠️"," Bot offline — ",P.jsx("code",{children:"DISCORD_TOKEN_NOTIFICATIONS"})," setzen"]})})}),Se?P.jsxs("div",{className:"stream-admin-loading",children:["Lade Kan","ä","le..."]}):K.length===0?P.jsx("div",{className:"stream-admin-empty",children:Ce.online?"Keine Text-Kanäle gefunden. Bot hat möglicherweise keinen Zugriff.":"Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren."}):P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"stream-admin-hint",children:["W","ä","hle die Kan","ä","le, in die Benachrichtigungen gesendet werden sollen:"]}),P.jsx("div",{className:"stream-admin-channel-list",children:K.map(ye=>P.jsxs("div",{className:"stream-admin-channel",children:[P.jsxs("div",{className:"stream-admin-channel-info",children:[P.jsxs("span",{className:"stream-admin-channel-name",children:["#",ye.channelName]}),P.jsx("span",{className:"stream-admin-channel-guild",children:ye.guildName})]}),P.jsxs("div",{className:"stream-admin-channel-events",children:[P.jsxs("label",{className:`stream-admin-event-toggle${un(ye.channelId,"stream_start")?" active":""}`,children:[P.jsx("input",{type:"checkbox",checked:un(ye.channelId,"stream_start"),onChange:()=>bt(ye.channelId,ye.channelName,ye.guildId,ye.guildName,"stream_start")}),"🔴"," Stream Start"]}),P.jsxs("label",{className:`stream-admin-event-toggle${un(ye.channelId,"stream_end")?" active":""}`,children:[P.jsx("input",{type:"checkbox",checked:un(ye.channelId,"stream_end"),onChange:()=>bt(ye.channelId,ye.channelName,ye.guildId,ye.guildName,"stream_end")}),"⏹️"," Stream Ende"]})]})]},ye.channelId))}),P.jsx("div",{className:"stream-admin-actions",children:P.jsx("button",{className:"stream-btn stream-admin-save",onClick:Kt,disabled:Ee,children:Ee?"Speichern...":"💾 Speichern"})})]})]})]})})]})}function T7(i){const e=Math.floor(i),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function KAe(i){const e=i.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(e)return{type:"youtube",videoId:e[1]};const t=i.match(/(?:dailymotion\.com\/video\/|dai\.ly\/)([a-zA-Z0-9]+)/);return t?{type:"dailymotion",videoId:t[1]}:/\.(mp4|webm|ogg)(\?|$)/i.test(i)||i.startsWith("http")?{type:"direct",url:i}:null}function ZAe({data:i}){var un;const[e,t]=ie.useState([]),[n,r]=ie.useState(()=>localStorage.getItem("wt_name")||""),[s,a]=ie.useState(""),[l,u]=ie.useState(""),[h,m]=ie.useState(null),[v,x]=ie.useState(null),[S,w]=ie.useState(null),[N,C]=ie.useState(""),[E,O]=ie.useState(()=>{const Ye=localStorage.getItem("wt_volume");return Ye?parseFloat(Ye):1}),[U,I]=ie.useState(!1),[j,z]=ie.useState(0),[G,W]=ie.useState(0),[q,V]=ie.useState(null),[Y,te]=ie.useState(!1),[ne,le]=ie.useState([]),[Q,K]=ie.useState(""),[ae,Ae]=ie.useState(null),[be,Se]=ie.useState("synced"),[se,Ee]=ie.useState(!0),[qe,Ce]=ie.useState(()=>localStorage.getItem("wt_yt_quality")||"hd1080"),ke=ie.useRef(null),Qe=ie.useRef(""),et=ie.useRef(null),Pt=ie.useRef(1e3),Nt=ie.useRef(null),Gt=ie.useRef(null),Tt=ie.useRef(null),Ge=ie.useRef(null),dt=ie.useRef(null),he=ie.useRef(null),en=ie.useRef(!1),wt=ie.useRef(!1),qt=ie.useRef(null),Lt=ie.useRef(null),hn=ie.useRef(qe),ut=ie.useRef(null),fe=ie.useRef(!1),k=ie.useRef(0),_e=ie.useRef(0);ie.useEffect(()=>{Nt.current=h},[h]);const Be=h!=null&&Qe.current===h.hostId;ie.useEffect(()=>{hn.current=qe,localStorage.setItem("wt_yt_quality",qe),Tt.current&&typeof Tt.current.setPlaybackQuality=="function"&&Tt.current.setPlaybackQuality(qe)},[qe]),ie.useEffect(()=>{i!=null&&i.rooms&&t(i.rooms)},[i]),ie.useEffect(()=>{var Ye;(Ye=Lt.current)==null||Ye.scrollIntoView({behavior:"smooth"})},[ne]),ie.useEffect(()=>{const St=new URLSearchParams(window.location.search).get("wt");if(St&&n.trim()){const ye=setTimeout(()=>Wt(St),1500);return()=>clearTimeout(ye)}},[]),ie.useEffect(()=>{n&&localStorage.setItem("wt_name",n)},[n]),ie.useEffect(()=>{var Ye;localStorage.setItem("wt_volume",String(E)),Tt.current&&typeof Tt.current.setVolume=="function"&&Tt.current.setVolume(E*100),Ge.current&&(Ge.current.volume=E),(Ye=ut.current)!=null&&Ye.contentWindow&&he.current==="dailymotion"&&ut.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com")},[E]),ie.useEffect(()=>{if(window.YT){en.current=!0;return}const Ye=document.createElement("script");Ye.src="https://www.youtube.com/iframe_api",document.head.appendChild(Ye);const St=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{en.current=!0,St&&St()}},[]);const Oe=ie.useCallback(Ye=>{var St;((St=ke.current)==null?void 0:St.readyState)===WebSocket.OPEN&&ke.current.send(JSON.stringify(Ye))},[]),je=ie.useCallback(()=>he.current==="youtube"&&Tt.current&&typeof Tt.current.getCurrentTime=="function"?Tt.current.getCurrentTime():he.current==="direct"&&Ge.current?Ge.current.currentTime:he.current==="dailymotion"?k.current:null,[]);ie.useCallback(()=>he.current==="youtube"&&Tt.current&&typeof Tt.current.getDuration=="function"?Tt.current.getDuration()||0:he.current==="direct"&&Ge.current?Ge.current.duration||0:he.current==="dailymotion"?_e.current:0,[]);const Bt=ie.useCallback(()=>{if(Tt.current){try{Tt.current.destroy()}catch{}Tt.current=null}Ge.current&&(Ge.current.pause(),Ge.current.removeAttribute("src"),Ge.current.load()),ut.current&&(ut.current.src="",fe.current=!1,k.current=0,_e.current=0),he.current=null,qt.current&&(clearInterval(qt.current),qt.current=null)},[]),yt=ie.useCallback(Ye=>{Bt(),V(null);const St=KAe(Ye);if(St)if(St.type==="youtube"){if(he.current="youtube",!en.current||!dt.current)return;const ye=dt.current,pt=document.createElement("div");pt.id="wt-yt-player-"+Date.now(),ye.innerHTML="",ye.appendChild(pt),Tt.current=new window.YT.Player(pt.id,{videoId:St.videoId,playerVars:{autoplay:1,controls:0,modestbranding:1,rel:0},events:{onReady:Zt=>{Zt.target.setVolume(E*100),Zt.target.setPlaybackQuality(hn.current),z(Zt.target.getDuration()||0),qt.current=setInterval(()=>{Tt.current&&typeof Tt.current.getCurrentTime=="function"&&(W(Tt.current.getCurrentTime()),z(Tt.current.getDuration()||0))},500)},onStateChange:Zt=>{if(Zt.data===window.YT.PlayerState.ENDED){const Pe=Nt.current;Pe&&Qe.current===Pe.hostId&&Oe({type:"skip"})}},onError:Zt=>{const Pe=Zt.data;V(Pe===101||Pe===150?"Embedding deaktiviert — Video kann nur auf YouTube angesehen werden.":Pe===100?"Video nicht gefunden oder entfernt.":"Wiedergabefehler — Video wird übersprungen."),setTimeout(()=>{const at=Nt.current;at&&Qe.current===at.hostId&&Oe({type:"skip"})},3e3)}}})}else St.type==="dailymotion"?(he.current="dailymotion",ut.current&&(ut.current.src=`https://www.dailymotion.com/embed/video/${St.videoId}?api=postMessage&autoplay=1&controls=0&mute=0&queue-enable=0`)):(he.current="direct",Ge.current&&(Ge.current.src=St.url,Ge.current.volume=E,Ge.current.play().catch(()=>{})))},[Bt,E,Oe]);ie.useEffect(()=>{const Ye=Ge.current;if(!Ye)return;const St=()=>{const pt=Nt.current;pt&&Qe.current===pt.hostId&&Oe({type:"skip"})},ye=()=>{W(Ye.currentTime),z(Ye.duration||0)};return Ye.addEventListener("ended",St),Ye.addEventListener("timeupdate",ye),()=>{Ye.removeEventListener("ended",St),Ye.removeEventListener("timeupdate",ye)}},[Oe]),ie.useEffect(()=>{const Ye=St=>{var Pe;if(St.origin!=="https://www.dailymotion.com"||typeof St.data!="string")return;const ye=new URLSearchParams(St.data),pt=ye.get("method"),Zt=ye.get("value");if(pt==="timeupdate"&&Zt){const at=parseFloat(Zt);k.current=at,W(at)}else if(pt==="durationchange"&&Zt){const at=parseFloat(Zt);_e.current=at,z(at)}else if(pt==="ended"){const at=Nt.current;at&&Qe.current===at.hostId&&Oe({type:"skip"})}else pt==="apiready"&&(fe.current=!0,(Pe=ut.current)!=null&&Pe.contentWindow&&ut.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com"))};return window.addEventListener("message",Ye),()=>window.removeEventListener("message",Ye)},[Oe,E]);const Xt=ie.useRef(()=>{});Xt.current=Ye=>{var St,ye,pt,Zt,Pe,at,ht,ot,f,J,_n,fn,zn,An,yn,zr;switch(Ye.type){case"welcome":Qe.current=Ye.clientId,Ye.rooms&&t(Ye.rooms);break;case"room_created":{const on=Ye.room;m({id:on.id,name:on.name,hostId:on.hostId,members:on.members||[],currentVideo:on.currentVideo||null,playing:on.playing||!1,currentTime:on.currentTime||0,queue:on.queue||[]});break}case"room_joined":{const on=Ye.room;m({id:on.id,name:on.name,hostId:on.hostId,members:on.members||[],currentVideo:on.currentVideo||null,playing:on.playing||!1,currentTime:on.currentTime||0,queue:on.queue||[]}),(St=on.currentVideo)!=null&&St.url&&setTimeout(()=>yt(on.currentVideo.url),100);break}case"playback_state":{const on=Nt.current;if(!on)break;const xn=Ye.currentVideo,Ar=(ye=on.currentVideo)==null?void 0:ye.url;if(xn!=null&&xn.url&&xn.url!==Ar?yt(xn.url):!xn&&Ar&&Bt(),he.current==="youtube"&&Tt.current){const ji=(Zt=(pt=Tt.current).getPlayerState)==null?void 0:Zt.call(pt);Ye.playing&&ji!==((at=(Pe=window.YT)==null?void 0:Pe.PlayerState)==null?void 0:at.PLAYING)?(ot=(ht=Tt.current).playVideo)==null||ot.call(ht):!Ye.playing&&ji===((J=(f=window.YT)==null?void 0:f.PlayerState)==null?void 0:J.PLAYING)&&((fn=(_n=Tt.current).pauseVideo)==null||fn.call(_n))}else he.current==="direct"&&Ge.current?Ye.playing&&Ge.current.paused?Ge.current.play().catch(()=>{}):!Ye.playing&&!Ge.current.paused&&Ge.current.pause():he.current==="dailymotion"&&((zn=ut.current)!=null&&zn.contentWindow)&&(Ye.playing?ut.current.contentWindow.postMessage("play","https://www.dailymotion.com"):ut.current.contentWindow.postMessage("pause","https://www.dailymotion.com"));if(Ye.currentTime!==void 0&&!wt.current){const ji=je();ji!==null&&Math.abs(ji-Ye.currentTime)>2&&(he.current==="youtube"&&Tt.current?(yn=(An=Tt.current).seekTo)==null||yn.call(An,Ye.currentTime,!0):he.current==="direct"&&Ge.current?Ge.current.currentTime=Ye.currentTime:he.current==="dailymotion"&&((zr=ut.current)!=null&&zr.contentWindow)&&ut.current.contentWindow.postMessage(`seek?to=${Ye.currentTime}`,"https://www.dailymotion.com"))}if(Ye.currentTime!==void 0){const ji=je();if(ji!==null){const Ao=Math.abs(ji-Ye.currentTime);Ao<1.5?Se("synced"):Ao<5?Se("drifting"):Se("desynced")}}m(ji=>ji&&{...ji,currentVideo:xn||null,playing:Ye.playing,currentTime:Ye.currentTime??ji.currentTime});break}case"queue_updated":m(on=>on&&{...on,queue:Ye.queue});break;case"members_updated":m(on=>on&&{...on,members:Ye.members,hostId:Ye.hostId});break;case"vote_updated":Ae(Ye.votes);break;case"chat":le(on=>{const xn=[...on,{sender:Ye.sender,text:Ye.text,timestamp:Ye.timestamp}];return xn.length>100?xn.slice(-100):xn});break;case"chat_history":le(Ye.messages||[]);break;case"error":Ye.code==="WRONG_PASSWORD"?x(on=>on&&{...on,error:Ye.message}):w(Ye.message);break}};const ln=ie.useCallback(()=>{if(ke.current&&(ke.current.readyState===WebSocket.OPEN||ke.current.readyState===WebSocket.CONNECTING))return;const Ye=location.protocol==="https:"?"wss":"ws",St=new WebSocket(`${Ye}://${location.host}/ws/watch-together`);ke.current=St,St.onopen=()=>{Pt.current=1e3},St.onmessage=ye=>{let pt;try{pt=JSON.parse(ye.data)}catch{return}Xt.current(pt)},St.onclose=()=>{ke.current===St&&(ke.current=null),Nt.current&&(et.current=setTimeout(()=>{Pt.current=Math.min(Pt.current*2,1e4),ln()},Pt.current))},St.onerror=()=>{St.close()}},[]),mt=ie.useCallback(()=>{if(!n.trim()){w("Bitte gib einen Namen ein.");return}if(!s.trim()){w("Bitte gib einen Raumnamen ein.");return}w(null),ln();const Ye=Date.now(),St=()=>{var ye;((ye=ke.current)==null?void 0:ye.readyState)===WebSocket.OPEN?Oe({type:"create_room",name:s.trim(),userName:n.trim(),password:l.trim()||void 0}):Date.now()-Ye>1e4?w("Verbindung zum Server fehlgeschlagen."):setTimeout(St,100)};St()},[n,s,l,ln,Oe]),Wt=ie.useCallback((Ye,St)=>{if(!n.trim()){w("Bitte gib einen Namen ein.");return}w(null),ln();const ye=Date.now(),pt=()=>{var Zt;((Zt=ke.current)==null?void 0:Zt.readyState)===WebSocket.OPEN?Oe({type:"join_room",userName:n.trim(),roomId:Ye,password:(St==null?void 0:St.trim())||void 0}):Date.now()-ye>1e4?w("Verbindung zum Server fehlgeschlagen."):setTimeout(pt,100)};pt()},[n,ln,Oe]),Yt=ie.useCallback(()=>{Oe({type:"leave_room"}),Bt(),m(null),C(""),z(0),W(0),le([]),Ae(null),Se("synced")},[Oe,Bt]),$t=ie.useCallback(async()=>{const Ye=N.trim();if(!Ye)return;C(""),te(!0);let St="";try{const ye=await fetch(`/api/watch-together/video-info?url=${encodeURIComponent(Ye)}`);ye.ok&&(St=(await ye.json()).title||"")}catch{}Oe({type:"add_to_queue",url:Ye,title:St||void 0}),te(!1)},[N,Oe]),It=ie.useCallback(()=>{const Ye=Q.trim();Ye&&(K(""),Oe({type:"chat_message",text:Ye}))},[Q,Oe]);ie.useCallback(()=>{Oe({type:"vote_skip"})},[Oe]),ie.useCallback(()=>{Oe({type:"vote_pause"})},[Oe]);const Te=ie.useCallback(()=>{Oe({type:"clear_watched"})},[Oe]),nt=ie.useCallback(()=>{if(!h)return;const Ye=`${window.location.origin}${window.location.pathname}?wt=${h.id}`;navigator.clipboard.writeText(Ye).catch(()=>{})},[h]),At=ie.useCallback(Ye=>{Oe({type:"remove_from_queue",index:Ye})},[Oe]),ce=ie.useCallback(()=>{const Ye=Nt.current;Ye&&Oe({type:Ye.playing?"pause":"resume"})},[Oe]),xt=ie.useCallback(()=>{Oe({type:"skip"})},[Oe]),Ze=ie.useCallback(Ye=>{var St,ye,pt;wt.current=!0,Oe({type:"seek",time:Ye}),he.current==="youtube"&&Tt.current?(ye=(St=Tt.current).seekTo)==null||ye.call(St,Ye,!0):he.current==="direct"&&Ge.current?Ge.current.currentTime=Ye:he.current==="dailymotion"&&((pt=ut.current)!=null&&pt.contentWindow)&&ut.current.contentWindow.postMessage(`seek?to=${Ye}`,"https://www.dailymotion.com"),W(Ye),setTimeout(()=>{wt.current=!1},3e3)},[Oe]);ie.useEffect(()=>{if(!Be||!(h!=null&&h.playing))return;const Ye=setInterval(()=>{const St=je();St!==null&&Oe({type:"report_time",time:St})},2e3);return()=>clearInterval(Ye)},[Be,h==null?void 0:h.playing,Oe,je]);const lt=ie.useCallback(()=>{const Ye=Gt.current;Ye&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):Ye.requestFullscreen().catch(()=>{}))},[]);ie.useEffect(()=>{const Ye=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",Ye),()=>document.removeEventListener("fullscreenchange",Ye)},[]),ie.useEffect(()=>{const Ye=ye=>{Nt.current&&ye.preventDefault()},St=()=>{Qe.current&&navigator.sendBeacon("/api/watch-together/disconnect",JSON.stringify({clientId:Qe.current}))};return window.addEventListener("beforeunload",Ye),window.addEventListener("pagehide",St),()=>{window.removeEventListener("beforeunload",Ye),window.removeEventListener("pagehide",St)}},[]),ie.useEffect(()=>()=>{Bt(),ke.current&&ke.current.close(),et.current&&clearTimeout(et.current)},[Bt]);const bt=ie.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(ye=>ye&&{...ye,error:"Passwort eingeben."});return}const{roomId:Ye,password:St}=v;x(null),Wt(Ye,St)},[v,Wt]),Kt=ie.useCallback(Ye=>{Ye.hasPassword?x({roomId:Ye.id,roomName:Ye.name,password:"",error:null}):Wt(Ye.id)},[Wt]);if(h){const Ye=h.members.find(St=>St.id===h.hostId);return P.jsxs("div",{className:"wt-room-overlay",ref:Gt,children:[P.jsxs("div",{className:"wt-room-header",children:[P.jsxs("div",{className:"wt-room-header-left",children:[P.jsx("span",{className:"wt-room-name",children:h.name}),P.jsxs("span",{className:"wt-room-members",children:[h.members.length," Mitglieder"]}),Ye&&P.jsxs("span",{className:"wt-host-badge",children:["Host: ",Ye.name]})]}),P.jsxs("div",{className:"wt-room-header-right",children:[P.jsx("div",{className:`wt-sync-dot wt-sync-${be}`,title:be==="synced"?"Synchron":be==="drifting"?"Leichte Verzögerung":"Nicht synchron"}),P.jsx("button",{className:"wt-header-btn",onClick:nt,title:"Link kopieren",children:"Link"}),P.jsx("button",{className:"wt-header-btn",onClick:()=>Ee(St=>!St),title:se?"Chat ausblenden":"Chat einblenden",children:"Chat"}),P.jsx("button",{className:"wt-fullscreen-btn",onClick:lt,title:U?"Vollbild verlassen":"Vollbild",children:U?"✖":"⛶"}),P.jsx("button",{className:"wt-leave-btn",onClick:Yt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"wt-room-body",children:[P.jsxs("div",{className:"wt-player-section",children:[P.jsxs("div",{className:"wt-player-wrap",children:[P.jsx("div",{ref:dt,className:"wt-yt-container",style:he.current==="youtube"?{}:{display:"none"}}),P.jsx("video",{ref:Ge,className:"wt-video-element",style:he.current==="direct"?{}:{display:"none"},playsInline:!0}),P.jsx("iframe",{ref:ut,className:"wt-dm-container",style:he.current==="dailymotion"?{}:{display:"none"},allow:"autoplay; fullscreen",allowFullScreen:!0}),q&&P.jsxs("div",{className:"wt-player-error",children:[P.jsx("div",{className:"wt-error-icon",children:"⚠️"}),P.jsx("p",{children:q}),((un=h.currentVideo)==null?void 0:un.url)&&P.jsx("a",{className:"wt-yt-link",href:h.currentVideo.url,target:"_blank",rel:"noopener noreferrer",children:"Auf YouTube öffnen ↗"}),P.jsx("p",{className:"wt-skip-info",children:"Wird in 3 Sekunden übersprungen..."})]}),!h.currentVideo&&P.jsxs("div",{className:"wt-player-placeholder",children:[P.jsx("div",{className:"wt-placeholder-icon",children:"🎬"}),P.jsx("p",{children:"Fuege ein Video zur Warteschlange hinzu"})]})]}),P.jsxs("div",{className:"wt-controls",children:[P.jsx("button",{className:"wt-ctrl-btn",onClick:ce,disabled:!h.currentVideo,title:h.playing?"Pause":"Abspielen",children:h.playing?"⏸":"▶"}),P.jsxs("button",{className:"wt-ctrl-btn wt-next-btn",onClick:xt,disabled:!h.currentVideo&&h.queue.length===0,title:"Nächstes Video",children:["⏭"," Weiter"]}),P.jsx("input",{className:"wt-seek",type:"range",min:0,max:j||0,step:.5,value:G,onChange:St=>Ze(parseFloat(St.target.value)),disabled:!h.currentVideo}),P.jsxs("span",{className:"wt-time",children:[T7(G)," / ",T7(j)]}),P.jsxs("div",{className:"wt-volume",children:[P.jsx("span",{className:"wt-volume-icon",children:E===0?"🔇":E<.5?"🔉":"🔊"}),P.jsx("input",{className:"wt-volume-slider",type:"range",min:0,max:1,step:.01,value:E,onChange:St=>O(parseFloat(St.target.value))})]}),he.current==="youtube"&&P.jsxs("select",{className:"wt-quality-select",value:qe,onChange:St=>Ce(St.target.value),title:"Videoqualität",children:[P.jsx("option",{value:"highres",children:"4K+"}),P.jsx("option",{value:"hd2160",children:"2160p"}),P.jsx("option",{value:"hd1440",children:"1440p"}),P.jsx("option",{value:"hd1080",children:"1080p"}),P.jsx("option",{value:"hd720",children:"720p"}),P.jsx("option",{value:"large",children:"480p"}),P.jsx("option",{value:"medium",children:"360p"}),P.jsx("option",{value:"small",children:"240p"})]})]})]}),P.jsxs("div",{className:"wt-queue-panel",children:[P.jsxs("div",{className:"wt-queue-header",children:[P.jsxs("span",{children:["Warteschlange (",h.queue.length,")"]}),h.queue.some(St=>St.watched)&&P.jsx("button",{className:"wt-queue-clear-btn",onClick:Te,title:"Gesehene entfernen",children:"Gesehene entfernen"})]}),P.jsx("div",{className:"wt-queue-list",children:h.queue.length===0?P.jsx("div",{className:"wt-queue-empty",children:"Keine Videos in der Warteschlange"}):h.queue.map((St,ye)=>{var Zt,Pe;const pt=((Zt=h.currentVideo)==null?void 0:Zt.url)===St.url;return P.jsxs("div",{className:`wt-queue-item${pt?" playing":""}${St.watched&&!pt?" watched":""} clickable`,onClick:()=>Oe({type:"play_video",index:ye}),title:"Klicken zum Abspielen",children:[P.jsxs("div",{className:"wt-queue-item-info",children:[St.watched&&!pt&&P.jsx("span",{className:"wt-queue-item-check",children:"✓"}),St.url.match(/youtu/)&&P.jsx("img",{className:"wt-queue-thumb",src:`https://img.youtube.com/vi/${(Pe=St.url.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/))==null?void 0:Pe[1]}/default.jpg`,alt:""}),P.jsxs("div",{className:"wt-queue-item-text",children:[P.jsx("div",{className:"wt-queue-item-title",children:St.title||St.url}),P.jsx("div",{className:"wt-queue-item-by",children:St.addedBy})]})]}),Be&&P.jsx("button",{className:"wt-queue-item-remove",onClick:at=>{at.stopPropagation(),At(ye)},title:"Entfernen",children:"×"})]},ye)})}),P.jsxs("div",{className:"wt-queue-add",children:[P.jsx("input",{className:"wt-input wt-queue-input",placeholder:"Video-URL eingeben",value:N,onChange:St=>C(St.target.value),onKeyDown:St=>{St.key==="Enter"&&$t()}}),P.jsx("button",{className:"wt-btn wt-queue-add-btn",onClick:$t,disabled:Y,children:Y?"Laden...":"Hinzufuegen"})]})]}),se&&P.jsxs("div",{className:"wt-chat-panel",children:[P.jsx("div",{className:"wt-chat-header",children:"Chat"}),P.jsxs("div",{className:"wt-chat-messages",children:[ne.length===0?P.jsx("div",{className:"wt-chat-empty",children:"Noch keine Nachrichten"}):ne.map((St,ye)=>P.jsxs("div",{className:"wt-chat-msg",children:[P.jsx("span",{className:"wt-chat-sender",children:St.sender}),P.jsx("span",{className:"wt-chat-text",children:St.text})]},ye)),P.jsx("div",{ref:Lt})]}),P.jsxs("div",{className:"wt-chat-input-row",children:[P.jsx("input",{className:"wt-input wt-chat-input",placeholder:"Nachricht...",value:Q,onChange:St=>K(St.target.value),onKeyDown:St=>{St.key==="Enter"&&It()},maxLength:500}),P.jsx("button",{className:"wt-btn wt-chat-send-btn",onClick:It,children:"Senden"})]})]})]})]})}return P.jsxs("div",{className:"wt-container",children:[S&&P.jsxs("div",{className:"wt-error",children:[S,P.jsx("button",{className:"wt-error-dismiss",onClick:()=>w(null),children:"×"})]}),P.jsxs("div",{className:"wt-topbar",children:[P.jsx("input",{className:"wt-input wt-input-name",placeholder:"Dein Name",value:n,onChange:Ye=>r(Ye.target.value)}),P.jsx("input",{className:"wt-input wt-input-room",placeholder:"Raumname",value:s,onChange:Ye=>a(Ye.target.value)}),P.jsx("input",{className:"wt-input wt-input-password",type:"password",placeholder:"Passwort (optional)",value:l,onChange:Ye=>u(Ye.target.value)}),P.jsx("button",{className:"wt-btn",onClick:mt,children:"Raum erstellen"})]}),e.length===0?P.jsxs("div",{className:"wt-empty",children:[P.jsx("div",{className:"wt-empty-icon",children:"🎬"}),P.jsx("h3",{children:"Keine aktiven Raeume"}),P.jsx("p",{children:"Erstelle einen Raum, um gemeinsam Videos zu schauen."})]}):P.jsx("div",{className:"wt-grid",children:e.map(Ye=>P.jsxs("div",{className:"wt-tile",onClick:()=>Kt(Ye),children:[P.jsxs("div",{className:"wt-tile-preview",children:[P.jsx("span",{className:"wt-tile-icon",children:"🎬"}),P.jsxs("span",{className:"wt-tile-members",children:["👥"," ",Ye.memberCount]}),Ye.hasPassword&&P.jsx("span",{className:"wt-tile-lock",children:"🔒"}),Ye.playing&&P.jsx("span",{className:"wt-tile-playing",children:"▶"})]}),P.jsxs("div",{className:"wt-tile-info",children:[P.jsxs("div",{className:"wt-tile-meta",children:[P.jsx("div",{className:"wt-tile-name",children:Ye.name}),P.jsx("div",{className:"wt-tile-host",children:Ye.hostName})]}),Ye.memberNames&&Ye.memberNames.length>0&&P.jsxs("div",{className:"wt-tile-members-list",children:[Ye.memberNames.slice(0,5).join(", "),Ye.memberNames.length>5&&` +${Ye.memberNames.length-5}`]})]})]},Ye.id))}),v&&P.jsx("div",{className:"wt-modal-overlay",onClick:()=>x(null),children:P.jsxs("div",{className:"wt-modal",onClick:Ye=>Ye.stopPropagation(),children:[P.jsx("h3",{children:v.roomName}),P.jsx("p",{children:"Raum-Passwort"}),v.error&&P.jsx("div",{className:"wt-modal-error",children:v.error}),P.jsx("input",{className:"wt-input",type:"password",placeholder:"Passwort",value:v.password,onChange:Ye=>x(St=>St&&{...St,password:Ye.target.value,error:null}),onKeyDown:Ye=>{Ye.key==="Enter"&&bt()},autoFocus:!0}),P.jsxs("div",{className:"wt-modal-actions",children:[P.jsx("button",{className:"wt-modal-cancel",onClick:()=>x(null),children:"Abbrechen"}),P.jsx("button",{className:"wt-btn",onClick:bt,children:"Beitreten"})]})]})})]})}function jS(i,e){return`https://media.steampowered.com/steamcommunity/public/images/apps/${i}/${e}.jpg`}function w7(i){if(i==null||i===0)return"—";if(i<60)return`${i} Min`;const e=Math.floor(i/60),t=i%60;return t>0?`${e}h ${t}m`:`${e}h`}function JAe(i){try{return new Date(i).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function e0e({data:i,isAdmin:e}){const[t,n]=ie.useState([]),[r,s]=ie.useState("overview"),[a,l]=ie.useState(null),[u,h]=ie.useState(new Set),[m,v]=ie.useState(null),[x,S]=ie.useState(null),[w,N]=ie.useState(""),[C,E]=ie.useState(null),[O,U]=ie.useState(!1),[I,j]=ie.useState(null),[z,G]=ie.useState(new Set),[W,q]=ie.useState("playtime"),V=ie.useRef(null),Y=ie.useRef(null),[te,ne]=ie.useState(""),[le,Q]=ie.useState(!1),K=e??!1,[ae,Ae]=ie.useState([]),[be,Se]=ie.useState(!1);ie.useEffect(()=>{i!=null&&i.profiles&&n(i.profiles)},[i]);const se=ie.useCallback(async()=>{try{const Te=await fetch("/api/game-library/profiles");if(Te.ok){const nt=await Te.json();n(nt.profiles||[])}}catch{}},[]),Ee=ie.useCallback(async()=>{Se(!0);try{const Te=await fetch("/api/game-library/admin/profiles",{credentials:"include"});if(Te.ok){const nt=await Te.json();Ae(nt.profiles||[])}}catch{}finally{Se(!1)}},[]),qe=ie.useCallback(()=>{Q(!0),K&&Ee()},[K,Ee]),Ce=ie.useCallback(async(Te,nt)=>{if(confirm(`Profil "${nt}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`))try{(await fetch(`/api/game-library/admin/profile/${Te}`,{method:"DELETE",credentials:"include"})).ok&&(Ee(),se())}catch{}},[Ee,se]),ke=ie.useCallback(()=>{const Te=window.open("/api/game-library/steam/login","_blank","width=800,height=600"),nt=setInterval(()=>{Te&&Te.closed&&(clearInterval(nt),setTimeout(se,1e3))},500)},[se]),Qe=navigator.userAgent.includes("GamingHubDesktop"),[et,Pt]=ie.useState(!1),[Nt,Gt]=ie.useState(""),[Tt,Ge]=ie.useState("idle"),[dt,he]=ie.useState(""),en=ie.useCallback(()=>{const Te=a?`?linkTo=${a}`:"";if(Qe){const nt=window.open(`/api/game-library/gog/login${Te}`,"_blank","width=800,height=700"),At=setInterval(()=>{nt&&nt.closed&&(clearInterval(At),setTimeout(se,1e3))},500)}else window.open(`/api/game-library/gog/login${Te}`,"_blank","width=800,height=700"),Gt(""),Ge("idle"),he(""),Pt(!0)},[se,a,Qe]),wt=ie.useCallback(async()=>{let Te=Nt.trim();const nt=Te.match(/[?&]code=([^&]+)/);if(nt&&(Te=nt[1]),!!Te){Ge("loading"),he("Verbinde mit GOG...");try{const At=await fetch("/api/game-library/gog/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:Te,linkTo:a||""})}),ce=await At.json();At.ok&&ce.ok?(Ge("success"),he(`${ce.profileName}: ${ce.gameCount} Spiele geladen!`),se(),setTimeout(()=>Pt(!1),2e3)):(Ge("error"),he(ce.error||"Unbekannter Fehler"))}catch{Ge("error"),he("Verbindung fehlgeschlagen.")}}},[Nt,a,se]);ie.useEffect(()=>{const Te=()=>se();return window.addEventListener("gog-connected",Te),()=>window.removeEventListener("gog-connected",Te)},[se]),ie.useEffect(()=>{const Te=()=>se();return window.addEventListener("focus",Te),()=>window.removeEventListener("focus",Te)},[se]);const qt=ie.useCallback(async Te=>{var nt,At;s("user"),l(Te),v(null),ne(""),U(!0);try{const ce=await fetch(`/api/game-library/profile/${Te}/games`);if(ce.ok){const xt=await ce.json(),Ze=xt.games||xt;v(Ze);const lt=t.find(Kt=>Kt.id===Te),bt=(At=(nt=lt==null?void 0:lt.platforms)==null?void 0:nt.steam)==null?void 0:At.steamId;bt&&Ze.filter(un=>!un.igdb).length>0&&(j(Te),fetch(`/api/game-library/igdb/enrich/${bt}`).then(un=>un.ok?un.json():null).then(()=>fetch(`/api/game-library/profile/${Te}/games`)).then(un=>un.ok?un.json():null).then(un=>{un&&v(un.games||un)}).catch(()=>{}).finally(()=>j(null)))}}catch{}finally{U(!1)}},[t]),Lt=ie.useCallback(async(Te,nt)=>{var xt,Ze;nt&&nt.stopPropagation();const At=t.find(lt=>lt.id===Te),ce=(Ze=(xt=At==null?void 0:At.platforms)==null?void 0:xt.steam)==null?void 0:Ze.steamId;try{ce&&await fetch(`/api/game-library/user/${ce}?refresh=true`),await se(),r==="user"&&a===Te&&qt(Te)}catch{}},[se,r,a,qt,t]),hn=ie.useCallback(async Te=>{var ce,xt;const nt=t.find(Ze=>Ze.id===Te),At=(xt=(ce=nt==null?void 0:nt.platforms)==null?void 0:ce.steam)==null?void 0:xt.steamId;if(At){j(Te);try{(await fetch(`/api/game-library/igdb/enrich/${At}`)).ok&&r==="user"&&a===Te&&qt(Te)}catch{}finally{j(null)}}},[r,a,qt,t]),ut=ie.useCallback(Te=>{h(nt=>{const At=new Set(nt);return At.has(Te)?At.delete(Te):At.add(Te),At})},[]),fe=ie.useCallback(async()=>{if(!(u.size<2)){s("common"),S(null),U(!0);try{const Te=Array.from(u).join(","),nt=await fetch(`/api/game-library/common-games?users=${Te}`);if(nt.ok){const At=await nt.json();S(At.games||At)}else console.error("[GameLibrary] common-games error:",nt.status,await nt.text().catch(()=>"")),S([])}catch(Te){console.error("[GameLibrary] common-games fetch failed:",Te)}finally{U(!1)}}},[u]),k=ie.useCallback(Te=>{if(N(Te),V.current&&clearTimeout(V.current),Te.length<2){E(null);return}V.current=setTimeout(async()=>{try{const nt=await fetch(`/api/game-library/search?q=${encodeURIComponent(Te)}`);if(nt.ok){const At=await nt.json();E(At.results||At)}}catch{}},300)},[]),_e=ie.useCallback(Te=>{G(nt=>{const At=new Set(nt);return At.has(Te)?At.delete(Te):At.add(Te),At})},[]),Be=ie.useCallback(async(Te,nt)=>{if(confirm(`${nt==="steam"?"Steam":"GOG"}-Verknuepfung wirklich trennen?`))try{const At=await fetch(`/api/game-library/profile/${Te}/${nt}`,{method:"DELETE"});if(At.ok&&(se(),(await At.json()).ok)){const xt=t.find(lt=>lt.id===Te);(nt==="steam"?xt==null?void 0:xt.platforms.gog:xt==null?void 0:xt.platforms.steam)||Oe()}}catch{}},[se,t]);ie.useCallback(async Te=>{const nt=t.find(At=>At.id===Te);if(confirm(`Profil "${nt==null?void 0:nt.displayName}" wirklich komplett loeschen?`))try{(await fetch(`/api/game-library/profile/${Te}`,{method:"DELETE"})).ok&&(se(),Oe())}catch{}},[se,t]);const Oe=ie.useCallback(()=>{s("overview"),l(null),v(null),S(null),ne(""),G(new Set),q("playtime")},[]),je=Oe,Bt=ie.useCallback(Te=>t.find(nt=>nt.id===Te),[t]),yt=ie.useCallback(Te=>typeof Te.playtime_forever=="number"?Te.playtime_forever:Array.isArray(Te.owners)?Math.max(...Te.owners.map(nt=>nt.playtime_forever||0)):0,[]),Xt=ie.useCallback(Te=>[...Te].sort((nt,At)=>{var ce,xt;if(W==="rating"){const Ze=((ce=nt.igdb)==null?void 0:ce.rating)??-1;return(((xt=At.igdb)==null?void 0:xt.rating)??-1)-Ze}return W==="name"?nt.name.localeCompare(At.name):yt(At)-yt(nt)}),[W,yt]),ln=ie.useCallback(Te=>{var nt,At;return z.size===0?!0:(At=(nt=Te.igdb)==null?void 0:nt.genres)!=null&&At.length?Te.igdb.genres.some(ce=>z.has(ce)):!1},[z]),mt=ie.useCallback(Te=>{var At;const nt=new Map;for(const ce of Te)if((At=ce.igdb)!=null&&At.genres)for(const xt of ce.igdb.genres)nt.set(xt,(nt.get(xt)||0)+1);return[...nt.entries()].sort((ce,xt)=>xt[1]-ce[1]).map(([ce])=>ce)},[]),Wt=m?Xt(m.filter(Te=>!te||Te.name.toLowerCase().includes(te.toLowerCase())).filter(ln)):null,Yt=m?mt(m):[],$t=x?mt(x):[],It=x?Xt(x.filter(ln)):null;return P.jsxs("div",{className:"gl-container",children:[P.jsxs("div",{className:"gl-login-bar",children:[!a&&P.jsx("button",{className:"gl-connect-btn gl-steam-btn",onClick:ke,children:"🎮 Steam verbinden"}),P.jsx("div",{className:"gl-login-bar-spacer"}),K&&P.jsx("button",{className:"gl-admin-btn",onClick:qe,title:"Admin Panel",children:"⚙️"})]}),t.length>0&&P.jsx("div",{className:"gl-profile-chips",children:t.map(Te=>P.jsxs("div",{className:`gl-profile-chip${a===Te.id?" selected":""}`,onClick:()=>qt(Te.id),children:[P.jsx("img",{className:"gl-profile-chip-avatar",src:Te.avatarUrl,alt:Te.displayName}),P.jsxs("div",{className:"gl-profile-chip-info",children:[P.jsx("span",{className:"gl-profile-chip-name",children:Te.displayName}),P.jsxs("span",{className:"gl-profile-chip-platforms",children:[Te.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:`Steam: ${Te.platforms.steam.gameCount} Spiele`,children:"S"}),Te.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:`GOG: ${Te.platforms.gog.gameCount} Spiele`,children:"G"})]})]}),P.jsxs("span",{className:"gl-profile-chip-count",children:["(",Te.totalGames,")"]})]},Te.id))}),r==="overview"&&P.jsx(P.Fragment,{children:t.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"🎮"}),P.jsx("h3",{children:"Keine Konten verbunden"}),P.jsx("p",{children:"Klicke oben auf “Steam verbinden” oder “GOG verbinden”, um deine Spielebibliothek hinzuzufuegen."})]}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"gl-section-title",children:"Verbundene Spieler"}),P.jsx("div",{className:"gl-users-grid",children:t.map(Te=>P.jsxs("div",{className:"gl-user-card",onClick:()=>qt(Te.id),children:[P.jsx("img",{className:"gl-user-card-avatar",src:Te.avatarUrl,alt:Te.displayName}),P.jsx("span",{className:"gl-user-card-name",children:Te.displayName}),P.jsxs("div",{className:"gl-profile-card-platforms",children:[Te.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:"Steam",children:"S"}),Te.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:"GOG",children:"G"})]}),P.jsxs("span",{className:"gl-user-card-games",children:[Te.totalGames," Spiele"]}),P.jsxs("span",{className:"gl-user-card-updated",children:["Aktualisiert: ",JAe(Te.lastUpdated)]})]},Te.id))}),t.length>=2&&P.jsxs("div",{className:"gl-common-finder",children:[P.jsx("h3",{children:"Gemeinsame Spiele finden"}),P.jsx("div",{className:"gl-common-users",children:t.map(Te=>P.jsxs("label",{className:`gl-common-check${u.has(Te.id)?" checked":""}`,children:[P.jsx("input",{type:"checkbox",checked:u.has(Te.id),onChange:()=>ut(Te.id)}),P.jsx("img",{className:"gl-common-check-avatar",src:Te.avatarUrl,alt:Te.displayName}),Te.displayName,P.jsxs("span",{className:"gl-profile-chip-platforms",style:{marginLeft:4},children:[Te.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",children:"S"}),Te.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",children:"G"})]})]},Te.id))}),P.jsx("button",{className:"gl-common-find-btn",disabled:u.size<2,onClick:fe,children:"Finden"})]}),P.jsx("div",{className:"gl-search",children:P.jsx("input",{className:"gl-search-input",type:"text",placeholder:"Spiel suchen...",value:w,onChange:Te=>k(Te.target.value)})}),C&&C.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"gl-search-results-title",children:[C.length," Ergebnis",C.length!==1?"se":""]}),P.jsx("div",{className:"gl-game-list",children:C.map(Te=>P.jsxs("div",{className:"gl-game-item",children:[Te.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:jS(Te.appid,Te.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"}),P.jsx("span",{className:"gl-game-name",children:Te.name}),P.jsx("div",{className:"gl-game-owners",children:Te.owners.map(nt=>{const At=t.find(ce=>{var xt;return((xt=ce.platforms.steam)==null?void 0:xt.steamId)===nt.steamId});return At?P.jsx("img",{className:"gl-game-owner-avatar",src:At.avatarUrl,alt:nt.personaName,title:nt.personaName},nt.steamId):null})})]},Te.appid))})]}),C&&C.length===0&&P.jsx("p",{className:"gl-search-results-title",children:"Keine Ergebnisse gefunden."})]})}),r==="user"&&(()=>{const Te=a?Bt(a):null;return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:je,children:"← Zurueck"}),Te&&P.jsxs(P.Fragment,{children:[P.jsx("img",{className:"gl-detail-avatar",src:Te.avatarUrl,alt:Te.displayName}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsxs("div",{className:"gl-detail-name",children:[Te.displayName,P.jsxs("span",{className:"gl-game-count",children:[Te.totalGames," Spiele"]})]}),P.jsxs("div",{className:"gl-detail-sub",children:[Te.platforms.steam&&P.jsxs("span",{className:"gl-platform-detail steam",children:[P.jsx("span",{className:"gl-platform-badge steam",children:"Steam ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:nt=>{nt.stopPropagation(),Be(Te.id,"steam")},title:"Steam trennen",children:"✕"})]}),Te.platforms.gog?P.jsxs("span",{className:"gl-platform-detail gog",children:[P.jsx("span",{className:"gl-platform-badge gog",children:"GOG ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:nt=>{nt.stopPropagation(),Be(Te.id,"gog")},title:"GOG trennen",children:"✕"})]}):P.jsx("button",{className:"gl-link-gog-btn",onClick:en,children:"🟣 GOG verknuepfen"})]})]}),P.jsx("button",{className:"gl-refresh-btn",onClick:()=>Lt(Te.id),title:"Aktualisieren",children:"↻"}),Te.platforms.steam&&P.jsxs("button",{className:`gl-enrich-btn ${I===a?"enriching":""}`,onClick:()=>hn(a),disabled:I===a,title:I===a?"IGDB-Daten werden geladen...":"Mit IGDB-Daten anreichern (erneut)",children:[I===a?"⏳":"🌐"," IGDB"]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Bibliothek wird geladen..."}):Wt?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-filter-bar",children:[P.jsx("input",{ref:Y,className:"gl-search-input",type:"text",placeholder:"Bibliothek durchsuchen...",value:te,onChange:nt=>ne(nt.target.value)}),P.jsxs("select",{className:"gl-sort-select",value:W,onChange:nt=>q(nt.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})]}),Yt.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),Yt.map(nt=>P.jsx("button",{className:`gl-genre-chip${z.has(nt)?" active":""}`,onClick:()=>_e(nt),children:nt},nt))]}),P.jsxs("p",{className:"gl-filter-count",children:[Wt.length," Spiele"]}),Wt.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Spiele gefunden."}):P.jsx("div",{className:"gl-game-list",children:Wt.map((nt,At)=>{var ce,xt,Ze;return P.jsxs("div",{className:`gl-game-item ${nt.igdb?"enriched":""}`,children:[P.jsx("span",{className:`gl-game-platform-icon ${nt.platform||"steam"}`,children:nt.platform==="gog"?"G":"S"}),P.jsx("div",{className:"gl-game-visual",children:(ce=nt.igdb)!=null&&ce.coverUrl?P.jsx("img",{className:"gl-game-cover",src:nt.igdb.coverUrl,alt:""}):nt.img_icon_url&&nt.appid?P.jsx("img",{className:"gl-game-icon",src:jS(nt.appid,nt.img_icon_url),alt:""}):nt.image?P.jsx("img",{className:"gl-game-icon",src:nt.image,alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:nt.name}),((xt=nt.igdb)==null?void 0:xt.genres)&&nt.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:nt.igdb.genres.slice(0,3).map(lt=>P.jsx("span",{className:"gl-genre-tag",children:lt},lt))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Ze=nt.igdb)==null?void 0:Ze.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${nt.igdb.rating>=75?"high":nt.igdb.rating>=50?"mid":"low"}`,children:Math.round(nt.igdb.rating)}),P.jsx("span",{className:"gl-game-playtime",children:w7(nt.playtime_forever)})]})]},nt.appid??nt.gogId??At)})})]}):null]})})(),r==="common"&&(()=>{const Te=Array.from(u).map(At=>Bt(At)).filter(Boolean),nt=Te.map(At=>At.displayName).join(", ");return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:je,children:"← Zurueck"}),P.jsx("div",{className:"gl-detail-avatars",children:Te.map(At=>P.jsx("img",{src:At.avatarUrl,alt:At.displayName},At.id))}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsx("div",{className:"gl-detail-name",children:"Gemeinsame Spiele"}),P.jsxs("div",{className:"gl-detail-sub",children:["von ",nt]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Gemeinsame Spiele werden gesucht..."}):x?x.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"😔"}),P.jsx("h3",{children:"Keine gemeinsamen Spiele"}),P.jsx("p",{children:"Die ausgewaehlten Spieler besitzen leider keine gemeinsamen Spiele."})]}):P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"gl-filter-bar",children:P.jsxs("select",{className:"gl-sort-select",value:W,onChange:At=>q(At.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})}),$t.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),$t.map(At=>P.jsx("button",{className:`gl-genre-chip${z.has(At)?" active":""}`,onClick:()=>_e(At),children:At},At))]}),P.jsxs("p",{className:"gl-section-title",children:[It.length," gemeinsame",It.length!==1?" Spiele":"s Spiel",z.size>0?` (von ${x.length})`:""]}),P.jsx("div",{className:"gl-game-list",children:It.map(At=>{var ce,xt,Ze;return P.jsxs("div",{className:`gl-game-item ${At.igdb?"enriched":""}`,children:[P.jsx("div",{className:"gl-game-visual",children:(ce=At.igdb)!=null&&ce.coverUrl?P.jsx("img",{className:"gl-game-cover",src:At.igdb.coverUrl,alt:""}):At.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:jS(At.appid,At.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:At.name}),((xt=At.igdb)==null?void 0:xt.genres)&&At.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:At.igdb.genres.slice(0,3).map(lt=>P.jsx("span",{className:"gl-genre-tag",children:lt},lt))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Ze=At.igdb)==null?void 0:Ze.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${At.igdb.rating>=75?"high":At.igdb.rating>=50?"mid":"low"}`,children:Math.round(At.igdb.rating)}),P.jsx("div",{className:"gl-common-playtimes",children:At.owners.map(lt=>P.jsxs("span",{className:"gl-common-pt",children:[lt.personaName,": ",w7(lt.playtime_forever)]},lt.steamId))})]})]},At.appid)})})]}):null]})})(),le&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>Q(!1),children:P.jsxs("div",{className:"gl-admin-panel",onClick:Te=>Te.stopPropagation(),children:[P.jsxs("div",{className:"gl-admin-header",children:[P.jsx("h3",{children:"⚙️ Game Library Admin"}),P.jsx("button",{className:"gl-admin-close",onClick:()=>Q(!1),children:"✕"})]}),P.jsxs("div",{className:"gl-admin-content",children:[P.jsxs("div",{className:"gl-admin-toolbar",children:[P.jsx("span",{className:"gl-admin-status-text",children:"✅ Eingeloggt als Admin"}),P.jsx("button",{className:"gl-admin-refresh-btn",onClick:Ee,children:"↻ Aktualisieren"})]}),be?P.jsx("div",{className:"gl-loading",children:"Lade Profile..."}):ae.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Profile vorhanden."}):P.jsx("div",{className:"gl-admin-list",children:ae.map(Te=>P.jsxs("div",{className:"gl-admin-item",children:[P.jsx("img",{className:"gl-admin-item-avatar",src:Te.avatarUrl,alt:Te.displayName}),P.jsxs("div",{className:"gl-admin-item-info",children:[P.jsx("span",{className:"gl-admin-item-name",children:Te.displayName}),P.jsxs("span",{className:"gl-admin-item-details",children:[Te.steamName&&P.jsxs("span",{className:"gl-platform-badge steam",children:["Steam: ",Te.steamGames]}),Te.gogName&&P.jsxs("span",{className:"gl-platform-badge gog",children:["GOG: ",Te.gogGames]}),P.jsxs("span",{className:"gl-admin-item-total",children:[Te.totalGames," Spiele"]})]})]}),P.jsx("button",{className:"gl-admin-delete-btn",onClick:()=>Ce(Te.id,Te.displayName),title:"Profil loeschen",children:"🗑️ Entfernen"})]},Te.id))})]})]})}),et&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>Pt(!1),children:P.jsxs("div",{className:"gl-dialog",onClick:Te=>Te.stopPropagation(),children:[P.jsx("h3",{children:"🟣 GOG verbinden"}),P.jsxs("p",{className:"gl-dialog-hint",children:["Nach dem GOG-Login wirst du auf eine Seite weitergeleitet. Kopiere die ",P.jsx("strong",{children:"komplette URL"})," aus der Adressleiste und füge sie hier ein:"]}),P.jsx("input",{className:"gl-dialog-input",type:"text",placeholder:"https://embed.gog.com/on_login_success?code=...",value:Nt,onChange:Te=>Gt(Te.target.value),onKeyDown:Te=>{Te.key==="Enter"&&wt()},disabled:Tt==="loading"||Tt==="success",autoFocus:!0}),dt&&P.jsx("p",{className:`gl-dialog-status ${Tt}`,children:dt}),P.jsxs("div",{className:"gl-dialog-actions",children:[P.jsx("button",{onClick:()=>Pt(!1),className:"gl-dialog-cancel",children:"Abbrechen"}),P.jsx("button",{onClick:wt,className:"gl-dialog-submit",disabled:!Nt.trim()||Tt==="loading"||Tt==="success",children:Tt==="loading"?"Verbinde...":"Verbinden"})]})]})})]})}const M7={radio:MAe,soundboard:jAe,lolstats:YAe,streaming:QAe,"watch-together":ZAe,"game-library":e0e};function t0e(){var le;const[i,e]=ie.useState(!1),[t,n]=ie.useState([]),[r,s]=ie.useState(()=>localStorage.getItem("hub_activeTab")??""),a=Q=>{s(Q),localStorage.setItem("hub_activeTab",Q)},[l,u]=ie.useState(!1),[h,m]=ie.useState({}),[v,x]=ie.useState(!1),[S,w]=ie.useState(!1),[N,C]=ie.useState(""),[E,O]=ie.useState(""),U=!!((le=window.electronAPI)!=null&&le.isElectron),I=U?window.electronAPI.version:null,[j,z]=ie.useState("idle"),[G,W]=ie.useState(""),q=ie.useRef(null);ie.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]),ie.useEffect(()=>{fetch("/api/soundboard/admin/status",{credentials:"include"}).then(Q=>Q.json()).then(Q=>x(!!Q.authenticated)).catch(()=>{})},[]),ie.useEffect(()=>{if(!S)return;const Q=K=>{K.key==="Escape"&&w(!1)};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[S]);async function V(){O("");try{(await fetch("/api/soundboard/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:N}),credentials:"include"})).ok?(x(!0),C(""),w(!1)):O("Falsches Passwort")}catch{O("Verbindung fehlgeschlagen")}}async function Y(){await fetch("/api/soundboard/admin/logout",{method:"POST",credentials:"include"}),x(!1)}ie.useEffect(()=>{var ae;if(!U)return;const Q=window.electronAPI;Q.onUpdateAvailable(()=>z("downloading")),Q.onUpdateReady(()=>z("ready")),Q.onUpdateNotAvailable(()=>z("upToDate")),Q.onUpdateError(Ae=>{z("error"),W(Ae||"Unbekannter Fehler")});const K=(ae=Q.getUpdateStatus)==null?void 0:ae.call(Q);K==="downloading"?z("downloading"):K==="ready"?z("ready"):K==="checking"&&z("checking")},[U]),ie.useEffect(()=>{fetch("/api/plugins").then(Q=>Q.json()).then(Q=>{if(n(Q),new URLSearchParams(location.search).has("viewStream")&&Q.some(be=>be.name==="streaming")){a("streaming");return}const ae=localStorage.getItem("hub_activeTab"),Ae=Q.some(be=>be.name===ae);Q.length>0&&!Ae&&a(Q[0].name)}).catch(()=>{})},[]),ie.useEffect(()=>{let Q=null,K;function ae(){Q=new EventSource("/api/events"),q.current=Q,Q.onopen=()=>e(!0),Q.onmessage=Ae=>{try{const be=JSON.parse(Ae.data);be.type==="snapshot"?m(Se=>({...Se,...be})):be.plugin&&m(Se=>({...Se,[be.plugin]:{...Se[be.plugin]||{},...be}}))}catch{}},Q.onerror=()=>{e(!1),Q==null||Q.close(),K=setTimeout(ae,3e3)}}return ae(),()=>{Q==null||Q.close(),clearTimeout(K)}},[]);const te="1.0.0-dev";ie.useEffect(()=>{if(!l)return;const Q=K=>{K.key==="Escape"&&u(!1)};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[l]);const ne={radio:"🌍",soundboard:"🎵",lolstats:"⚔️",stats:"📊",events:"📅",games:"🎲",gamevote:"🎮",streaming:"📺","watch-together":"🎬","game-library":"🎮"};return P.jsxs("div",{className:"hub-app",children:[P.jsxs("header",{className:"hub-header",children:[P.jsxs("div",{className:"hub-header-left",children:[P.jsx("span",{className:"hub-logo",children:"🎮"}),P.jsx("span",{className:"hub-title",children:"Gaming Hub"}),P.jsx("span",{className:`hub-conn-dot ${i?"online":""}`})]}),P.jsx("nav",{className:"hub-tabs",children:t.filter(Q=>Q.name in M7).map(Q=>P.jsxs("button",{className:`hub-tab ${r===Q.name?"active":""}`,onClick:()=>a(Q.name),title:Q.description,children:[P.jsx("span",{className:"hub-tab-icon",children:ne[Q.name]??"📦"}),P.jsx("span",{className:"hub-tab-label",children:Q.name})]},Q.name))}),P.jsxs("div",{className:"hub-header-right",children:[!window.electronAPI&&P.jsxs("a",{className:"hub-download-btn",href:"/downloads/GamingHub-Setup.exe",download:!0,title:"Desktop App herunterladen",children:[P.jsx("span",{className:"hub-download-icon",children:"⬇️"}),P.jsx("span",{className:"hub-download-label",children:"Desktop App"})]}),P.jsx("button",{className:`hub-admin-btn ${v?"active":""}`,onClick:()=>v?Y():w(!0),title:v?"Admin abmelden":"Admin Login",children:v?"🔓":"🔒"}),P.jsx("button",{className:"hub-refresh-btn",onClick:()=>window.location.reload(),title:"Seite neu laden",children:"🔄"}),P.jsxs("span",{className:"hub-version hub-version-clickable",onClick:()=>{var Q;if(U){const K=window.electronAPI,ae=(Q=K.getUpdateStatus)==null?void 0:Q.call(K);ae==="downloading"?z("downloading"):ae==="ready"?z("ready"):ae==="checking"&&z("checking")}u(!0)},title:"Versionsinformationen",children:["v",te]})]})]}),l&&P.jsx("div",{className:"hub-version-overlay",onClick:()=>u(!1),children:P.jsxs("div",{className:"hub-version-modal",onClick:Q=>Q.stopPropagation(),children:[P.jsxs("div",{className:"hub-version-modal-header",children:[P.jsx("span",{children:"Versionsinformationen"}),P.jsx("button",{className:"hub-version-modal-close",onClick:()=>u(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-version-modal-body",children:[P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Hub-Version"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",te]})]}),U&&P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Desktop-App"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",I]})]}),P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Server"}),P.jsxs("span",{className:"hub-version-modal-value",children:[P.jsx("span",{className:`hub-version-modal-dot ${i?"online":""}`}),i?"Verbunden":"Getrennt"]})]}),U&&P.jsxs("div",{className:"hub-version-modal-update",children:[j==="idle"&&P.jsxs("button",{className:"hub-version-modal-update-btn",onClick:()=>{z("checking"),W(""),window.electronAPI.checkForUpdates()},children:["🔄"," Nach Updates suchen"]}),j==="checking"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Suche nach Updates…"]}),j==="downloading"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Update wird heruntergeladen…"]}),j==="ready"&&P.jsxs("button",{className:"hub-version-modal-update-btn ready",onClick:()=>window.electronAPI.installUpdate(),children:["✅"," Jetzt installieren & neu starten"]}),j==="upToDate"&&P.jsxs("div",{className:"hub-version-modal-update-status success",children:["✅"," App ist aktuell",P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>z("idle"),children:"Erneut prüfen"})]}),j==="error"&&P.jsxs("div",{className:"hub-version-modal-update-status error",children:["❌"," ",G,P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>z("idle"),children:"Erneut versuchen"})]})]})]})]})}),S&&P.jsx("div",{className:"hub-admin-overlay",onClick:()=>w(!1),children:P.jsxs("div",{className:"hub-admin-modal",onClick:Q=>Q.stopPropagation(),children:[P.jsxs("div",{className:"hub-admin-modal-header",children:[P.jsxs("span",{children:["🔒"," Admin Login"]}),P.jsx("button",{className:"hub-admin-modal-close",onClick:()=>w(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-admin-modal-body",children:[P.jsx("input",{type:"password",className:"hub-admin-input",placeholder:"Admin-Passwort...",value:N,onChange:Q=>C(Q.target.value),onKeyDown:Q=>Q.key==="Enter"&&V(),autoFocus:!0}),E&&P.jsx("p",{className:"hub-admin-error",children:E}),P.jsx("button",{className:"hub-admin-submit",onClick:V,children:"Login"})]})]})}),P.jsx("main",{className:"hub-content",children:t.length===0?P.jsxs("div",{className:"hub-empty",children:[P.jsx("span",{className:"hub-empty-icon",children:"📦"}),P.jsx("h2",{children:"Keine Plugins geladen"}),P.jsx("p",{children:"Plugins werden im Server konfiguriert."})]}):t.map(Q=>{const K=M7[Q.name];if(!K)return null;const ae=r===Q.name;return P.jsx("div",{className:`hub-tab-panel ${ae?"active":""}`,style:ae?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{display:"none"},children:P.jsx(K,{data:h[Q.name]||{},isAdmin:v})},Q.name)})})]})}IF.createRoot(document.getElementById("root")).render(P.jsx(t0e,{})); diff --git a/web/dist/assets/index-BWeAEcYi.js b/web/dist/assets/index-BWeAEcYi.js new file mode 100644 index 0000000..c9b56e4 --- /dev/null +++ b/web/dist/assets/index-BWeAEcYi.js @@ -0,0 +1,4830 @@ +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();function E7(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Xb={exports:{}},jp={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var F8;function CF(){if(F8)return jp;F8=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,r,s){var a=null;if(s!==void 0&&(a=""+s),r.key!==void 0&&(a=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:i,type:n,key:a,ref:r!==void 0?r:null,props:s}}return jp.Fragment=e,jp.jsx=t,jp.jsxs=t,jp}var k8;function NF(){return k8||(k8=1,Xb.exports=CF()),Xb.exports}var P=NF(),Yb={exports:{}},Hp={},Qb={exports:{}},Kb={};/** + * @license React + * scheduler.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var z8;function RF(){return z8||(z8=1,(function(i){function e(Z,te){var de=Z.length;Z.push(te);e:for(;0>>1,Te=Z[Se];if(0>>1;Ser(Ve,de))Cer(Fe,Ve)?(Z[Se]=Fe,Z[Ce]=de,Se=Ce):(Z[Se]=Ve,Z[Me]=de,Se=Me);else if(Cer(Fe,de))Z[Se]=Fe,Z[Ce]=de,Se=Ce;else break e}}return te}function r(Z,te){var de=Z.sortIndex-te.sortIndex;return de!==0?de:Z.id-te.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;i.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();i.unstable_now=function(){return a.now()-l}}var u=[],h=[],m=1,v=null,x=3,S=!1,T=!1,N=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function I(Z){for(var te=t(h);te!==null;){if(te.callback===null)n(h);else if(te.startTime<=Z)n(h),te.sortIndex=te.expirationTime,e(u,te);else break;te=t(h)}}function j(Z){if(N=!1,I(Z),!T)if(t(u)!==null)T=!0,z||(z=!0,J());else{var te=t(h);te!==null&&ie(j,te.startTime-Z)}}var z=!1,G=-1,H=5,q=-1;function V(){return C?!0:!(i.unstable_now()-qZ&&V());){var Se=v.callback;if(typeof Se=="function"){v.callback=null,x=v.priorityLevel;var Te=Se(v.expirationTime<=Z);if(Z=i.unstable_now(),typeof Te=="function"){v.callback=Te,I(Z),te=!0;break t}v===t(u)&&n(u),I(Z)}else n(u);v=t(u)}if(v!==null)te=!0;else{var ae=t(h);ae!==null&&ie(j,ae.startTime-Z),te=!1}}break e}finally{v=null,x=de,S=!1}te=void 0}}finally{te?J():z=!1}}}var J;if(typeof U=="function")J=function(){U(Q)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,oe=ne.port2;ne.port1.onmessage=Q,J=function(){oe.postMessage(null)}}else J=function(){E(Q,0)};function ie(Z,te){G=E(function(){Z(i.unstable_now())},te)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(Z){Z.callback=null},i.unstable_forceFrameRate=function(Z){0>Z||125Se?(Z.sortIndex=de,e(h,Z),t(u)===null&&Z===t(h)&&(N?(O(G),G=-1):N=!0,ie(j,de-Se))):(Z.sortIndex=Te,e(u,Z),T||S||(T=!0,z||(z=!0,J()))),Z},i.unstable_shouldYield=V,i.unstable_wrapCallback=function(Z){var te=x;return function(){var de=x;x=te;try{return Z.apply(this,arguments)}finally{x=de}}}})(Kb)),Kb}var G8;function DF(){return G8||(G8=1,Qb.exports=RF()),Qb.exports}var Zb={exports:{}},ti={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var q8;function PF(){if(q8)return ti;q8=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(ae){return ae===null||typeof ae!="object"?null:(ae=x&&ae[x]||ae["@@iterator"],typeof ae=="function"?ae:null)}var T={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,C={};function E(ae,Me,Ve){this.props=ae,this.context=Me,this.refs=C,this.updater=Ve||T}E.prototype.isReactComponent={},E.prototype.setState=function(ae,Me){if(typeof ae!="object"&&typeof ae!="function"&&ae!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,ae,Me,"setState")},E.prototype.forceUpdate=function(ae){this.updater.enqueueForceUpdate(this,ae,"forceUpdate")};function O(){}O.prototype=E.prototype;function U(ae,Me,Ve){this.props=ae,this.context=Me,this.refs=C,this.updater=Ve||T}var I=U.prototype=new O;I.constructor=U,N(I,E.prototype),I.isPureReactComponent=!0;var j=Array.isArray;function z(){}var G={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function q(ae,Me,Ve){var Ce=Ve.ref;return{$$typeof:i,type:ae,key:Me,ref:Ce!==void 0?Ce:null,props:Ve}}function V(ae,Me){return q(ae.type,Me,ae.props)}function Q(ae){return typeof ae=="object"&&ae!==null&&ae.$$typeof===i}function J(ae){var Me={"=":"=0",":":"=2"};return"$"+ae.replace(/[=:]/g,function(Ve){return Me[Ve]})}var ne=/\/+/g;function oe(ae,Me){return typeof ae=="object"&&ae!==null&&ae.key!=null?J(""+ae.key):Me.toString(36)}function ie(ae){switch(ae.status){case"fulfilled":return ae.value;case"rejected":throw ae.reason;default:switch(typeof ae.status=="string"?ae.then(z,z):(ae.status="pending",ae.then(function(Me){ae.status==="pending"&&(ae.status="fulfilled",ae.value=Me)},function(Me){ae.status==="pending"&&(ae.status="rejected",ae.reason=Me)})),ae.status){case"fulfilled":return ae.value;case"rejected":throw ae.reason}}throw ae}function Z(ae,Me,Ve,Ce,Fe){var et=typeof ae;(et==="undefined"||et==="boolean")&&(ae=null);var He=!1;if(ae===null)He=!0;else switch(et){case"bigint":case"string":case"number":He=!0;break;case"object":switch(ae.$$typeof){case i:case e:He=!0;break;case m:return He=ae._init,Z(He(ae._payload),Me,Ve,Ce,Fe)}}if(He)return Fe=Fe(ae),He=Ce===""?"."+oe(ae,0):Ce,j(Fe)?(Ve="",He!=null&&(Ve=He.replace(ne,"$&/")+"/"),Z(Fe,Me,Ve,"",function(zt){return zt})):Fe!=null&&(Q(Fe)&&(Fe=V(Fe,Ve+(Fe.key==null||ae&&ae.key===Fe.key?"":(""+Fe.key).replace(ne,"$&/")+"/")+He)),Me.push(Fe)),1;He=0;var Rt=Ce===""?".":Ce+":";if(j(ae))for(var Et=0;Et"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Jb.exports=LF(),Jb.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var W8;function BF(){if(W8)return Hp;W8=1;var i=DF(),e=bT(),t=UF();function n(o){var c="https://react.dev/errors/"+o;if(1Te||(o.current=Se[Te],Se[Te]=null,Te--)}function Ve(o,c){Te++,Se[Te]=o.current,o.current=c}var Ce=ae(null),Fe=ae(null),et=ae(null),He=ae(null);function Rt(o,c){switch(Ve(et,c),Ve(Fe,o),Ve(Ce,null),c.nodeType){case 9:case 11:o=(o=c.documentElement)&&(o=o.namespaceURI)?o8(o):0;break;default:if(o=c.tagName,c=c.namespaceURI)c=o8(c),o=l8(c,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}Me(Ce),Ve(Ce,o)}function Et(){Me(Ce),Me(Fe),Me(et)}function zt(o){o.memoizedState!==null&&Ve(He,o);var c=Ce.current,g=l8(c,o.type);c!==g&&(Ve(Fe,o),Ve(Ce,g))}function Pt(o){Fe.current===o&&(Me(Ce),Me(Fe)),He.current===o&&(Me(He),zp._currentValue=de)}var We,ft;function fe(o){if(We===void 0)try{throw Error()}catch(g){var c=g.stack.trim().match(/\n( *(at )?)/);We=c&&c[1]||"",ft=-1)":-1D||Re[b]!==at[D]){var vt=` +`+Re[b].replace(" at new "," at ");return o.displayName&&vt.includes("")&&(vt=vt.replace("",o.displayName)),vt}while(1<=b&&0<=D);break}}}finally{Wt=!1,Error.prepareStackTrace=g}return(g=o?o.displayName||o.name:"")?fe(g):""}function Gt(o,c){switch(o.tag){case 26:case 27:case 5:return fe(o.type);case 16:return fe("Lazy");case 13:return o.child!==c&&c!==null?fe("Suspense Fallback"):fe("Suspense");case 19:return fe("SuspenseList");case 0:case 15:return yt(o.type,!1);case 11:return yt(o.type.render,!1);case 1:return yt(o.type,!0);case 31:return fe("Activity");default:return""}}function _t(o){try{var c="",g=null;do c+=Gt(o,g),g=o,o=o.return;while(o);return c}catch(b){return` +Error generating stack: `+b.message+` +`+b.stack}}var Xt=Object.prototype.hasOwnProperty,pt=i.unstable_scheduleCallback,Ae=i.unstable_cancelCallback,k=i.unstable_shouldYield,be=i.unstable_requestPaint,Oe=i.unstable_now,pe=i.unstable_getCurrentPriorityLevel,le=i.unstable_ImmediatePriority,Ne=i.unstable_UserBlockingPriority,De=i.unstable_NormalPriority,Je=i.unstable_LowPriority,we=i.unstable_IdlePriority,Ue=i.log,ut=i.unstable_setDisableYieldValue,Dt=null,Bt=null;function ct(o){if(typeof Ue=="function"&&ut(o),Bt&&typeof Bt.setStrictMode=="function")try{Bt.setStrictMode(Dt,o)}catch{}}var jt=Math.clz32?Math.clz32:ge,Jt=Math.log,In=Math.LN2;function ge(o){return o>>>=0,o===0?32:31-(Jt(o)/In|0)|0}var Ot=256,ot=262144,Tt=4194304;function Ht(o){var c=o&42;if(c!==0)return c;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function Yt(o,c,g){var b=o.pendingLanes;if(b===0)return 0;var D=0,L=o.suspendedLanes,Y=o.pingedLanes;o=o.warmLanes;var ue=b&134217727;return ue!==0?(b=ue&~L,b!==0?D=Ht(b):(Y&=ue,Y!==0?D=Ht(Y):g||(g=ue&~o,g!==0&&(D=Ht(g))))):(ue=b&~L,ue!==0?D=Ht(ue):Y!==0?D=Ht(Y):g||(g=b&~o,g!==0&&(D=Ht(g)))),D===0?0:c!==0&&c!==D&&(c&L)===0&&(L=D&-D,g=c&-c,L>=g||L===32&&(g&4194048)!==0)?c:D}function pn(o,c){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&c)===0}function $e(o,c){switch(o){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function St(){var o=Tt;return Tt<<=1,(Tt&62914560)===0&&(Tt=4194304),o}function Kt(o){for(var c=[],g=0;31>g;g++)c.push(o);return c}function wn(o,c){o.pendingLanes|=c,c!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function qn(o,c,g,b,D,L){var Y=o.pendingLanes;o.pendingLanes=g,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=g,o.entangledLanes&=g,o.errorRecoveryDisabledLanes&=g,o.shellSuspendCounter=0;var ue=o.entanglements,Re=o.expirationTimes,at=o.hiddenUpdates;for(g=Y&~g;0"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var ys=/[\n"\\]/g;function Vr(o){return o.replace(ys,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Di(o,c,g,b,D,L,Y,ue){o.name="",Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?o.type=Y:o.removeAttribute("type"),c!=null?Y==="number"?(c===0&&o.value===""||o.value!=c)&&(o.value=""+hn(c)):o.value!==""+hn(c)&&(o.value=""+hn(c)):Y!=="submit"&&Y!=="reset"||o.removeAttribute("value"),c!=null?bi(o,Y,hn(c)):g!=null?bi(o,Y,hn(g)):b!=null&&o.removeAttribute("value"),D==null&&L!=null&&(o.defaultChecked=!!L),D!=null&&(o.checked=D&&typeof D!="function"&&typeof D!="symbol"),ue!=null&&typeof ue!="function"&&typeof ue!="symbol"&&typeof ue!="boolean"?o.name=""+hn(ue):o.removeAttribute("name")}function sr(o,c,g,b,D,L,Y,ue){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(o.type=L),c!=null||g!=null){if(!(L!=="submit"&&L!=="reset"||c!=null)){ui(o);return}g=g!=null?""+hn(g):"",c=c!=null?""+hn(c):g,ue||c===o.value||(o.value=c),o.defaultValue=c}b=b??D,b=typeof b!="function"&&typeof b!="symbol"&&!!b,o.checked=ue?o.checked:!!b,o.defaultChecked=!!b,Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"&&(o.name=Y),ui(o)}function bi(o,c,g){c==="number"&&Ps(o.ownerDocument)===o||o.defaultValue===""+g||(o.defaultValue=""+g)}function _r(o,c,g,b){if(o=o.options,c){c={};for(var D=0;D"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_d=!1;if(el)try{var Qh={};Object.defineProperty(Qh,"passive",{get:function(){_d=!0}}),window.addEventListener("test",Qh,Qh),window.removeEventListener("test",Qh,Qh)}catch{_d=!1}var Do=null,Kh=null,yd=null;function J0(){if(yd)return yd;var o,c=Kh,g=c.length,b,D="value"in Do?Do.value:Do.textContent,L=D.length;for(o=0;o=tf),Du=" ",p1=!1;function wd(o,c){switch(o){case"keyup":return bx.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function rp(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Wc=!1;function m1(o,c){switch(o){case"compositionend":return rp(c);case"keypress":return c.which!==32?null:(p1=!0,Du);case"textInput":return o=c.data,o===Du&&p1?null:o;default:return null}}function Sx(o,c){if(Wc)return o==="compositionend"||!Ru&&wd(o,c)?(o=J0(),yd=Kh=Do=null,Wc=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:g,offset:c-o};o=b}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=Ed(g)}}function Bu(o,c){return o&&c?o===c?!0:o&&o.nodeType===3?!1:c&&c.nodeType===3?Bu(o,c.parentNode):"contains"in o?o.contains(c):o.compareDocumentPosition?!!(o.compareDocumentPosition(c)&16):!1:!1}function Dl(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var c=Ps(o.document);c instanceof o.HTMLIFrameElement;){try{var g=typeof c.contentWindow.location.href=="string"}catch{g=!1}if(g)o=c.contentWindow;else break;c=Ps(o.document)}return c}function Pl(o){var c=o&&o.nodeName&&o.nodeName.toLowerCase();return c&&(c==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||c==="textarea"||o.contentEditable==="true")}var Mx=el&&"documentMode"in document&&11>=document.documentMode,Ou=null,up=null,Iu=null,cp=!1;function b1(o,c,g){var b=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;cp||Ou==null||Ou!==Ps(b)||(b=Ou,"selectionStart"in b&&Pl(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Iu&&bs(Iu,b)||(Iu=b,b=i2(up,"onSelect"),0>=Y,D-=Y,Ea=1<<32-jt(c)+D|g<ci?(vi=gn,gn=null):vi=gn.sibling;var Ci=lt(Ye,gn,st[ci],Mt);if(Ci===null){gn===null&&(gn=vi);break}o&&gn&&Ci.alternate===null&&c(Ye,gn),ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci,gn=vi}if(ci===st.length)return g(Ye,gn),Ai&&Uo(Ye,ci),Mn;if(gn===null){for(;cici?(vi=gn,gn=null):vi=gn.sibling;var ch=lt(Ye,gn,Ci.value,Mt);if(ch===null){gn===null&&(gn=vi);break}o&&gn&&ch.alternate===null&&c(Ye,gn),ke=L(ch,ke,ci),Ei===null?Mn=ch:Ei.sibling=ch,Ei=ch,gn=vi}if(Ci.done)return g(Ye,gn),Ai&&Uo(Ye,ci),Mn;if(gn===null){for(;!Ci.done;ci++,Ci=st.next())Ci=Nt(Ye,Ci.value,Mt),Ci!==null&&(ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci);return Ai&&Uo(Ye,ci),Mn}for(gn=b(gn);!Ci.done;ci++,Ci=st.next())Ci=ht(gn,Ye,ci,Ci.value,Mt),Ci!==null&&(o&&Ci.alternate!==null&&gn.delete(Ci.key===null?ci:Ci.key),ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci);return o&&gn.forEach(function(EF){return c(Ye,EF)}),Ai&&Uo(Ye,ci),Mn}function Yi(Ye,ke,st,Mt){if(typeof st=="object"&&st!==null&&st.type===N&&st.key===null&&(st=st.props.children),typeof st=="object"&&st!==null){switch(st.$$typeof){case S:e:{for(var Mn=st.key;ke!==null;){if(ke.key===Mn){if(Mn=st.type,Mn===N){if(ke.tag===7){g(Ye,ke.sibling),Mt=D(ke,st.props.children),Mt.return=Ye,Ye=Mt;break e}}else if(ke.elementType===Mn||typeof Mn=="object"&&Mn!==null&&Mn.$$typeof===H&&f(Mn)===ke.type){g(Ye,ke.sibling),Mt=D(ke,st.props),B(Mt,st),Mt.return=Ye,Ye=Mt;break e}g(Ye,ke);break}else c(Ye,ke);ke=ke.sibling}st.type===N?(Mt=qu(st.props.children,Ye.mode,Mt,st.key),Mt.return=Ye,Ye=Mt):(Mt=Pd(st.type,st.key,st.props,null,Ye.mode,Mt),B(Mt,st),Mt.return=Ye,Ye=Mt)}return Y(Ye);case T:e:{for(Mn=st.key;ke!==null;){if(ke.key===Mn)if(ke.tag===4&&ke.stateNode.containerInfo===st.containerInfo&&ke.stateNode.implementation===st.implementation){g(Ye,ke.sibling),Mt=D(ke,st.children||[]),Mt.return=Ye,Ye=Mt;break e}else{g(Ye,ke);break}else c(Ye,ke);ke=ke.sibling}Mt=Lo(st,Ye.mode,Mt),Mt.return=Ye,Ye=Mt}return Y(Ye);case H:return st=f(st),Yi(Ye,ke,st,Mt)}if(ie(st))return An(Ye,ke,st,Mt);if(J(st)){if(Mn=J(st),typeof Mn!="function")throw Error(n(150));return st=Mn.call(st),Bn(Ye,ke,st,Mt)}if(typeof st.then=="function")return Yi(Ye,ke,R(st),Mt);if(st.$$typeof===U)return Yi(Ye,ke,kd(Ye,st),Mt);F(Ye,st)}return typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint"?(st=""+st,ke!==null&&ke.tag===6?(g(Ye,ke.sibling),Mt=D(ke,st),Mt.return=Ye,Ye=Mt):(g(Ye,ke),Mt=pp(st,Ye.mode,Mt),Mt.return=Ye,Ye=Mt),Y(Ye)):g(Ye,ke)}return function(Ye,ke,st,Mt){try{M=0;var Mn=Yi(Ye,ke,st,Mt);return w=null,Mn}catch(gn){if(gn===ll||gn===ao)throw gn;var Ei=$s(29,gn,null,Ye.mode);return Ei.lanes=Mt,Ei.return=Ye,Ei}finally{}}}var se=W(!0),_e=W(!1),ve=!1;function ye(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pe(o,c){o=o.updateQueue,c.updateQueue===o&&(c.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function ze(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function nt(o,c,g){var b=o.updateQueue;if(b===null)return null;if(b=b.shared,(Pi&2)!==0){var D=b.pending;return D===null?c.next=c:(c.next=D.next,D.next=c),b.pending=c,c=Dd(o),T1(o,null,g),c}return Rd(o,b,c,g),Dd(o)}function Xe(o,c,g){if(c=c.updateQueue,c!==null&&(c=c.shared,(g&4194048)!==0)){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,dt(o,g)}}function je(o,c){var g=o.updateQueue,b=o.alternate;if(b!==null&&(b=b.updateQueue,g===b)){var D=null,L=null;if(g=g.firstBaseUpdate,g!==null){do{var Y={lane:g.lane,tag:g.tag,payload:g.payload,callback:null,next:null};L===null?D=L=Y:L=L.next=Y,g=g.next}while(g!==null);L===null?D=L=c:L=L.next=c}else D=L=c;g={baseState:b.baseState,firstBaseUpdate:D,lastBaseUpdate:L,shared:b.shared,callbacks:b.callbacks},o.updateQueue=g;return}o=g.lastBaseUpdate,o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=c}var Le=!1;function Ft(){if(Le){var o=ur;if(o!==null)throw o}}function un(o,c,g,b){Le=!1;var D=o.updateQueue;ve=!1;var L=D.firstBaseUpdate,Y=D.lastBaseUpdate,ue=D.shared.pending;if(ue!==null){D.shared.pending=null;var Re=ue,at=Re.next;Re.next=null,Y===null?L=at:Y.next=at,Y=Re;var vt=o.alternate;vt!==null&&(vt=vt.updateQueue,ue=vt.lastBaseUpdate,ue!==Y&&(ue===null?vt.firstBaseUpdate=at:ue.next=at,vt.lastBaseUpdate=Re))}if(L!==null){var Nt=D.baseState;Y=0,vt=at=Re=null,ue=L;do{var lt=ue.lane&-536870913,ht=lt!==ue.lane;if(ht?(gi<)===lt:(b<)===lt){lt!==0&<===Qc&&(Le=!0),vt!==null&&(vt=vt.next={lane:0,tag:ue.tag,payload:ue.payload,callback:null,next:null});e:{var An=o,Bn=ue;lt=c;var Yi=g;switch(Bn.tag){case 1:if(An=Bn.payload,typeof An=="function"){Nt=An.call(Yi,Nt,lt);break e}Nt=An;break e;case 3:An.flags=An.flags&-65537|128;case 0:if(An=Bn.payload,lt=typeof An=="function"?An.call(Yi,Nt,lt):An,lt==null)break e;Nt=v({},Nt,lt);break e;case 2:ve=!0}}lt=ue.callback,lt!==null&&(o.flags|=64,ht&&(o.flags|=8192),ht=D.callbacks,ht===null?D.callbacks=[lt]:ht.push(lt))}else ht={lane:lt,tag:ue.tag,payload:ue.payload,callback:ue.callback,next:null},vt===null?(at=vt=ht,Re=Nt):vt=vt.next=ht,Y|=lt;if(ue=ue.next,ue===null){if(ue=D.shared.pending,ue===null)break;ht=ue,ue=ht.next,ht.next=null,D.lastBaseUpdate=ht,D.shared.pending=null}}while(!0);vt===null&&(Re=Nt),D.baseState=Re,D.firstBaseUpdate=at,D.lastBaseUpdate=vt,L===null&&(D.shared.lanes=0),eh|=Y,o.lanes=Y,o.memoizedState=Nt}}function on(o,c){if(typeof o!="function")throw Error(n(191,o));o.call(c)}function kn(o,c){var g=o.callbacks;if(g!==null)for(o.callbacks=null,o=0;oL?L:8;var Y=Z.T,ue={};Z.T=ue,Wx(o,!1,c,g);try{var Re=D(),at=Z.S;if(at!==null&&at(ue,Re),Re!==null&&typeof Re=="object"&&typeof Re.then=="function"){var vt=N1(Re,b);Sp(o,c,vt,co(o))}else Sp(o,c,b,co(o))}catch(Nt){Sp(o,c,{then:function(){},status:"rejected",reason:Nt},co())}finally{te.p=L,Y!==null&&ue.types!==null&&(Y.types=ue.types),Z.T=Y}}function bI(){}function jx(o,c,g,b){if(o.tag!==5)throw Error(n(476));var D=L4(o).queue;P4(o,D,c,de,g===null?bI:function(){return U4(o),g(b)})}function L4(o){var c=o.memoizedState;if(c!==null)return c;c={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ku,lastRenderedState:de},next:null};var g={};return c.next={memoizedState:g,baseState:g,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ku,lastRenderedState:g},next:null},o.memoizedState=c,o=o.alternate,o!==null&&(o.memoizedState=c),c}function U4(o){var c=L4(o);c.next===null&&(c=o.alternate.memoizedState),Sp(o,c.next.queue,{},co())}function Hx(){return hs(zp)}function B4(){return Hr().memoizedState}function O4(){return Hr().memoizedState}function SI(o){for(var c=o.return;c!==null;){switch(c.tag){case 24:case 3:var g=co();o=ze(g);var b=nt(c,o,g);b!==null&&(Ua(b,c,g),Xe(b,c,g)),c={cache:Lr()},o.payload=c;return}c=c.return}}function wI(o,c,g){var b=co();g={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},F1(o)?F4(c,g):(g=Ap(o,c,g,b),g!==null&&(Ua(g,o,b),k4(g,c,b)))}function I4(o,c,g){var b=co();Sp(o,c,g,b)}function Sp(o,c,g,b){var D={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null};if(F1(o))F4(c,D);else{var L=o.alternate;if(o.lanes===0&&(L===null||L.lanes===0)&&(L=c.lastRenderedReducer,L!==null))try{var Y=c.lastRenderedState,ue=L(Y,g);if(D.hasEagerState=!0,D.eagerState=ue,ha(ue,Y))return Rd(o,c,D,0),nr===null&&Nd(),!1}catch{}finally{}if(g=Ap(o,c,D,b),g!==null)return Ua(g,o,b),k4(g,c,b),!0}return!1}function Wx(o,c,g,b){if(b={lane:2,revertLane:wb(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},F1(o)){if(c)throw Error(n(479))}else c=Ap(o,g,b,2),c!==null&&Ua(c,o,2)}function F1(o){var c=o.alternate;return o===ai||c!==null&&c===ai}function F4(o,c){zd=D1=!0;var g=o.pending;g===null?c.next=c:(c.next=g.next,g.next=c),o.pending=c}function k4(o,c,g){if((g&4194048)!==0){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,dt(o,g)}}var wp={readContext:hs,use:U1,useCallback:Ur,useContext:Ur,useEffect:Ur,useImperativeHandle:Ur,useLayoutEffect:Ur,useInsertionEffect:Ur,useMemo:Ur,useReducer:Ur,useRef:Ur,useState:Ur,useDebugValue:Ur,useDeferredValue:Ur,useTransition:Ur,useSyncExternalStore:Ur,useId:Ur,useHostTransitionStatus:Ur,useFormState:Ur,useActionState:Ur,useOptimistic:Ur,useMemoCache:Ur,useCacheRefresh:Ur};wp.useEffectEvent=Ur;var z4={readContext:hs,use:U1,useCallback:function(o,c){return Aa().memoizedState=[o,c===void 0?null:c],o},useContext:hs,useEffect:S4,useImperativeHandle:function(o,c,g){g=g!=null?g.concat([o]):null,O1(4194308,4,E4.bind(null,c,o),g)},useLayoutEffect:function(o,c){return O1(4194308,4,o,c)},useInsertionEffect:function(o,c){O1(4,2,o,c)},useMemo:function(o,c){var g=Aa();c=c===void 0?null:c;var b=o();if(hf){ct(!0);try{o()}finally{ct(!1)}}return g.memoizedState=[b,c],b},useReducer:function(o,c,g){var b=Aa();if(g!==void 0){var D=g(c);if(hf){ct(!0);try{g(c)}finally{ct(!1)}}}else D=c;return b.memoizedState=b.baseState=D,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:D},b.queue=o,o=o.dispatch=wI.bind(null,ai,o),[b.memoizedState,o]},useRef:function(o){var c=Aa();return o={current:o},c.memoizedState=o},useState:function(o){o=kx(o);var c=o.queue,g=I4.bind(null,ai,c);return c.dispatch=g,[o.memoizedState,g]},useDebugValue:qx,useDeferredValue:function(o,c){var g=Aa();return Vx(g,o,c)},useTransition:function(){var o=kx(!1);return o=P4.bind(null,ai,o.queue,!0,!1),Aa().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,c,g){var b=ai,D=Aa();if(Ai){if(g===void 0)throw Error(n(407));g=g()}else{if(g=c(),nr===null)throw Error(n(349));(gi&127)!==0||o4(b,c,g)}D.memoizedState=g;var L={value:g,getSnapshot:c};return D.queue=L,S4(u4.bind(null,b,L,o),[o]),b.flags|=2048,qd(9,{destroy:void 0},l4.bind(null,b,L,g,c),null),g},useId:function(){var o=Aa(),c=nr.identifierPrefix;if(Ai){var g=Ca,b=Ea;g=(b&~(1<<32-jt(b)-1)).toString(32)+g,c="_"+c+"R_"+g,g=P1++,0<\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof b.is=="string"?Y.createElement("select",{is:b.is}):Y.createElement("select"),b.multiple?L.multiple=!0:b.size&&(L.size=b.size);break;default:L=typeof b.is=="string"?Y.createElement(D,{is:b.is}):Y.createElement(D)}}L[$n]=c,L[dn]=b;e:for(Y=c.child;Y!==null;){if(Y.tag===5||Y.tag===6)L.appendChild(Y.stateNode);else if(Y.tag!==4&&Y.tag!==27&&Y.child!==null){Y.child.return=Y,Y=Y.child;continue}if(Y===c)break e;for(;Y.sibling===null;){if(Y.return===null||Y.return===c)break e;Y=Y.return}Y.sibling.return=Y.return,Y=Y.sibling}c.stateNode=L;e:switch(Us(L,D,b),D){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&Ju(c)}}return cr(c),ab(c,c.type,o===null?null:o.memoizedProps,c.pendingProps,g),null;case 6:if(o&&c.stateNode!=null)o.memoizedProps!==b&&Ju(c);else{if(typeof b!="string"&&c.stateNode===null)throw Error(n(166));if(o=et.current,tr(c)){if(o=c.stateNode,g=c.memoizedProps,b=null,D=cs,D!==null)switch(D.tag){case 27:case 5:b=D.memoizedProps}o[$n]=c,o=!!(o.nodeValue===g||b!==null&&b.suppressHydrationWarning===!0||s8(o.nodeValue,g)),o||Bl(c,!0)}else o=r2(o).createTextNode(b),o[$n]=c,c.stateNode=o}return cr(c),null;case 31:if(g=c.memoizedState,o===null||o.memoizedState!==null){if(b=tr(c),g!==null){if(o===null){if(!b)throw Error(n(318));if(o=c.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(557));o[$n]=c}else ju(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;cr(c),o=!1}else g=yp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=g),o=!0;if(!o)return c.flags&256?(oo(c),c):(oo(c),null);if((c.flags&128)!==0)throw Error(n(558))}return cr(c),null;case 13:if(b=c.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(D=tr(c),b!==null&&b.dehydrated!==null){if(o===null){if(!D)throw Error(n(318));if(D=c.memoizedState,D=D!==null?D.dehydrated:null,!D)throw Error(n(317));D[$n]=c}else ju(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;cr(c),D=!1}else D=yp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=D),D=!0;if(!D)return c.flags&256?(oo(c),c):(oo(c),null)}return oo(c),(c.flags&128)!==0?(c.lanes=g,c):(g=b!==null,o=o!==null&&o.memoizedState!==null,g&&(b=c.child,D=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(D=b.alternate.memoizedState.cachePool.pool),L=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(L=b.memoizedState.cachePool.pool),L!==D&&(b.flags|=2048)),g!==o&&g&&(c.child.flags|=8192),V1(c,c.updateQueue),cr(c),null);case 4:return Et(),o===null&&Cb(c.stateNode.containerInfo),cr(c),null;case 10:return Bo(c.type),cr(c),null;case 19:if(Me(jr),b=c.memoizedState,b===null)return cr(c),null;if(D=(c.flags&128)!==0,L=b.rendering,L===null)if(D)Mp(b,!1);else{if(Br!==0||o!==null&&(o.flags&128)!==0)for(o=c.child;o!==null;){if(L=R1(o),L!==null){for(c.flags|=128,Mp(b,!1),o=L.updateQueue,c.updateQueue=o,V1(c,o),c.subtreeFlags=0,o=g,g=c.child;g!==null;)M1(g,o),g=g.sibling;return Ve(jr,jr.current&1|2),Ai&&Uo(c,b.treeForkCount),c.child}o=o.sibling}b.tail!==null&&Oe()>X1&&(c.flags|=128,D=!0,Mp(b,!1),c.lanes=4194304)}else{if(!D)if(o=R1(L),o!==null){if(c.flags|=128,D=!0,o=o.updateQueue,c.updateQueue=o,V1(c,o),Mp(b,!0),b.tail===null&&b.tailMode==="hidden"&&!L.alternate&&!Ai)return cr(c),null}else 2*Oe()-b.renderingStartTime>X1&&g!==536870912&&(c.flags|=128,D=!0,Mp(b,!1),c.lanes=4194304);b.isBackwards?(L.sibling=c.child,c.child=L):(o=b.last,o!==null?o.sibling=L:c.child=L,b.last=L)}return b.tail!==null?(o=b.tail,b.rendering=o,b.tail=o.sibling,b.renderingStartTime=Oe(),o.sibling=null,g=jr.current,Ve(jr,D?g&1|2:g&1),Ai&&Uo(c,b.treeForkCount),o):(cr(c),null);case 22:case 23:return oo(c),kt(),b=c.memoizedState!==null,o!==null?o.memoizedState!==null!==b&&(c.flags|=8192):b&&(c.flags|=8192),b?(g&536870912)!==0&&(c.flags&128)===0&&(cr(c),c.subtreeFlags&6&&(c.flags|=8192)):cr(c),g=c.updateQueue,g!==null&&V1(c,g.retryQueue),g=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),b=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(b=c.memoizedState.cachePool.pool),b!==g&&(c.flags|=2048),o!==null&&Me(It),null;case 24:return g=null,o!==null&&(g=o.memoizedState.cache),c.memoizedState.cache!==g&&(c.flags|=2048),Bo(tn),cr(c),null;case 25:return null;case 30:return null}throw Error(n(156,c.tag))}function NI(o,c){switch(mp(c),c.tag){case 1:return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 3:return Bo(tn),Et(),o=c.flags,(o&65536)!==0&&(o&128)===0?(c.flags=o&-65537|128,c):null;case 26:case 27:case 5:return Pt(c),null;case 31:if(c.memoizedState!==null){if(oo(c),c.alternate===null)throw Error(n(340));ju()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 13:if(oo(c),o=c.memoizedState,o!==null&&o.dehydrated!==null){if(c.alternate===null)throw Error(n(340));ju()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 19:return Me(jr),null;case 4:return Et(),null;case 10:return Bo(c.type),null;case 22:case 23:return oo(c),kt(),o!==null&&Me(It),o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 24:return Bo(tn),null;case 25:return null;default:return null}}function cC(o,c){switch(mp(c),c.tag){case 3:Bo(tn),Et();break;case 26:case 27:case 5:Pt(c);break;case 4:Et();break;case 31:c.memoizedState!==null&&oo(c);break;case 13:oo(c);break;case 19:Me(jr);break;case 10:Bo(c.type);break;case 22:case 23:oo(c),kt(),o!==null&&Me(It);break;case 24:Bo(tn)}}function Ep(o,c){try{var g=c.updateQueue,b=g!==null?g.lastEffect:null;if(b!==null){var D=b.next;g=D;do{if((g.tag&o)===o){b=void 0;var L=g.create,Y=g.inst;b=L(),Y.destroy=b}g=g.next}while(g!==D)}}catch(ue){Vi(c,c.return,ue)}}function Zc(o,c,g){try{var b=c.updateQueue,D=b!==null?b.lastEffect:null;if(D!==null){var L=D.next;b=L;do{if((b.tag&o)===o){var Y=b.inst,ue=Y.destroy;if(ue!==void 0){Y.destroy=void 0,D=c;var Re=g,at=ue;try{at()}catch(vt){Vi(D,Re,vt)}}}b=b.next}while(b!==L)}}catch(vt){Vi(c,c.return,vt)}}function hC(o){var c=o.updateQueue;if(c!==null){var g=o.stateNode;try{kn(c,g)}catch(b){Vi(o,o.return,b)}}}function fC(o,c,g){g.props=ff(o.type,o.memoizedProps),g.state=o.memoizedState;try{g.componentWillUnmount()}catch(b){Vi(o,c,b)}}function Cp(o,c){try{var g=o.ref;if(g!==null){switch(o.tag){case 26:case 27:case 5:var b=o.stateNode;break;case 30:b=o.stateNode;break;default:b=o.stateNode}typeof g=="function"?o.refCleanup=g(b):g.current=b}}catch(D){Vi(o,c,D)}}function Il(o,c){var g=o.ref,b=o.refCleanup;if(g!==null)if(typeof b=="function")try{b()}catch(D){Vi(o,c,D)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof g=="function")try{g(null)}catch(D){Vi(o,c,D)}else g.current=null}function dC(o){var c=o.type,g=o.memoizedProps,b=o.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":g.autoFocus&&b.focus();break e;case"img":g.src?b.src=g.src:g.srcSet&&(b.srcset=g.srcSet)}}catch(D){Vi(o,o.return,D)}}function ob(o,c,g){try{var b=o.stateNode;KI(b,o.type,g,c),b[dn]=c}catch(D){Vi(o,o.return,D)}}function AC(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&sh(o.type)||o.tag===4}function lb(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||AC(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&sh(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function ub(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?(g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g).insertBefore(o,c):(c=g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g,c.appendChild(o),g=g._reactRootContainer,g!=null||c.onclick!==null||(c.onclick=Ro));else if(b!==4&&(b===27&&sh(o.type)&&(g=o.stateNode,c=null),o=o.child,o!==null))for(ub(o,c,g),o=o.sibling;o!==null;)ub(o,c,g),o=o.sibling}function j1(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?g.insertBefore(o,c):g.appendChild(o);else if(b!==4&&(b===27&&sh(o.type)&&(g=o.stateNode),o=o.child,o!==null))for(j1(o,c,g),o=o.sibling;o!==null;)j1(o,c,g),o=o.sibling}function pC(o){var c=o.stateNode,g=o.memoizedProps;try{for(var b=o.type,D=c.attributes;D.length;)c.removeAttributeNode(D[0]);Us(c,b,g),c[$n]=o,c[dn]=g}catch(L){Vi(o,o.return,L)}}var ec=!1,ns=!1,cb=!1,mC=typeof WeakSet=="function"?WeakSet:Set,Ts=null;function RI(o,c){if(o=o.containerInfo,Db=h2,o=Dl(o),Pl(o)){if("selectionStart"in o)var g={start:o.selectionStart,end:o.selectionEnd};else e:{g=(g=o.ownerDocument)&&g.defaultView||window;var b=g.getSelection&&g.getSelection();if(b&&b.rangeCount!==0){g=b.anchorNode;var D=b.anchorOffset,L=b.focusNode;b=b.focusOffset;try{g.nodeType,L.nodeType}catch{g=null;break e}var Y=0,ue=-1,Re=-1,at=0,vt=0,Nt=o,lt=null;t:for(;;){for(var ht;Nt!==g||D!==0&&Nt.nodeType!==3||(ue=Y+D),Nt!==L||b!==0&&Nt.nodeType!==3||(Re=Y+b),Nt.nodeType===3&&(Y+=Nt.nodeValue.length),(ht=Nt.firstChild)!==null;)lt=Nt,Nt=ht;for(;;){if(Nt===o)break t;if(lt===g&&++at===D&&(ue=Y),lt===L&&++vt===b&&(Re=Y),(ht=Nt.nextSibling)!==null)break;Nt=lt,lt=Nt.parentNode}Nt=ht}g=ue===-1||Re===-1?null:{start:ue,end:Re}}else g=null}g=g||{start:0,end:0}}else g=null;for(Pb={focusedElem:o,selectionRange:g},h2=!1,Ts=c;Ts!==null;)if(c=Ts,o=c.child,(c.subtreeFlags&1028)!==0&&o!==null)o.return=c,Ts=o;else for(;Ts!==null;){switch(c=Ts,L=c.alternate,o=c.flags,c.tag){case 0:if((o&4)!==0&&(o=c.updateQueue,o=o!==null?o.events:null,o!==null))for(g=0;g title"))),Us(L,b,g),L[$n]=o,qe(L),b=L;break e;case"link":var Y=b8("link","href",D).get(b+(g.href||""));if(Y){for(var ue=0;ueYi&&(Y=Yi,Yi=Bn,Bn=Y);var Ye=Cd(ue,Bn),ke=Cd(ue,Yi);if(Ye&&ke&&(ht.rangeCount!==1||ht.anchorNode!==Ye.node||ht.anchorOffset!==Ye.offset||ht.focusNode!==ke.node||ht.focusOffset!==ke.offset)){var st=Nt.createRange();st.setStart(Ye.node,Ye.offset),ht.removeAllRanges(),Bn>Yi?(ht.addRange(st),ht.extend(ke.node,ke.offset)):(st.setEnd(ke.node,ke.offset),ht.addRange(st))}}}}for(Nt=[],ht=ue;ht=ht.parentNode;)ht.nodeType===1&&Nt.push({element:ht,left:ht.scrollLeft,top:ht.scrollTop});for(typeof ue.focus=="function"&&ue.focus(),ue=0;ueg?32:g,Z.T=null,g=gb,gb=null;var L=nh,Y=sc;if(fs=0,$d=nh=null,sc=0,(Pi&6)!==0)throw Error(n(331));var ue=Pi;if(Pi|=4,EC(L.current),wC(L,L.current,Y,g),Pi=ue,Up(0,!1),Bt&&typeof Bt.onPostCommitFiberRoot=="function")try{Bt.onPostCommitFiberRoot(Dt,L)}catch{}return!0}finally{te.p=D,Z.T=b,HC(o,c)}}function $C(o,c,g){c=Ta(g,c),c=Qx(o.stateNode,c,2),o=nt(o,c,2),o!==null&&(wn(o,2),Fl(o))}function Vi(o,c,g){if(o.tag===3)$C(o,o,g);else for(;c!==null;){if(c.tag===3){$C(c,o,g);break}else if(c.tag===1){var b=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(th===null||!th.has(b))){o=Ta(g,o),g=X4(2),b=nt(c,g,2),b!==null&&(Y4(g,b,c,o),wn(b,2),Fl(b));break}}c=c.return}}function xb(o,c,g){var b=o.pingCache;if(b===null){b=o.pingCache=new LI;var D=new Set;b.set(c,D)}else D=b.get(c),D===void 0&&(D=new Set,b.set(c,D));D.has(g)||(db=!0,D.add(g),o=FI.bind(null,o,c,g),c.then(o,o))}function FI(o,c,g){var b=o.pingCache;b!==null&&b.delete(c),o.pingedLanes|=o.suspendedLanes&g,o.warmLanes&=~g,nr===o&&(gi&g)===g&&(Br===4||Br===3&&(gi&62914560)===gi&&300>Oe()-$1?(Pi&2)===0&&Xd(o,0):Ab|=g,Wd===gi&&(Wd=0)),Fl(o)}function XC(o,c){c===0&&(c=St()),o=zu(o,c),o!==null&&(wn(o,c),Fl(o))}function kI(o){var c=o.memoizedState,g=0;c!==null&&(g=c.retryLane),XC(o,g)}function zI(o,c){var g=0;switch(o.tag){case 31:case 13:var b=o.stateNode,D=o.memoizedState;D!==null&&(g=D.retryLane);break;case 19:b=o.stateNode;break;case 22:b=o.stateNode._retryCache;break;default:throw Error(n(314))}b!==null&&b.delete(c),XC(o,g)}function GI(o,c){return pt(o,c)}var e2=null,Qd=null,bb=!1,t2=!1,Sb=!1,rh=0;function Fl(o){o!==Qd&&o.next===null&&(Qd===null?e2=Qd=o:Qd=Qd.next=o),t2=!0,bb||(bb=!0,VI())}function Up(o,c){if(!Sb&&t2){Sb=!0;do for(var g=!1,b=e2;b!==null;){if(o!==0){var D=b.pendingLanes;if(D===0)var L=0;else{var Y=b.suspendedLanes,ue=b.pingedLanes;L=(1<<31-jt(42|o)+1)-1,L&=D&~(Y&~ue),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(g=!0,ZC(b,L))}else L=gi,L=Yt(b,b===nr?L:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(L&3)===0||pn(b,L)||(g=!0,ZC(b,L));b=b.next}while(g);Sb=!1}}function qI(){YC()}function YC(){t2=bb=!1;var o=0;rh!==0&&JI()&&(o=rh);for(var c=Oe(),g=null,b=e2;b!==null;){var D=b.next,L=QC(b,c);L===0?(b.next=null,g===null?e2=D:g.next=D,D===null&&(Qd=g)):(g=b,(o!==0||(L&3)!==0)&&(t2=!0)),b=D}fs!==0&&fs!==5||Up(o),rh!==0&&(rh=0)}function QC(o,c){for(var g=o.suspendedLanes,b=o.pingedLanes,D=o.expirationTimes,L=o.pendingLanes&-62914561;0ue)break;var vt=Re.transferSize,Nt=Re.initiatorType;vt&&a8(Nt)&&(Re=Re.responseEnd,Y+=vt*(Re"u"?null:document;function v8(o,c,g){var b=Kd;if(b&&typeof c=="string"&&c){var D=Vr(c);D='link[rel="'+o+'"][href="'+D+'"]',typeof g=="string"&&(D+='[crossorigin="'+g+'"]'),g8.has(D)||(g8.add(D),o={rel:o,crossOrigin:g,href:c},b.querySelector(D)===null&&(c=b.createElement("link"),Us(c,"link",o),qe(c),b.head.appendChild(c)))}}function lF(o){ac.D(o),v8("dns-prefetch",o,null)}function uF(o,c){ac.C(o,c),v8("preconnect",o,c)}function cF(o,c,g){ac.L(o,c,g);var b=Kd;if(b&&o&&c){var D='link[rel="preload"][as="'+Vr(c)+'"]';c==="image"&&g&&g.imageSrcSet?(D+='[imagesrcset="'+Vr(g.imageSrcSet)+'"]',typeof g.imageSizes=="string"&&(D+='[imagesizes="'+Vr(g.imageSizes)+'"]')):D+='[href="'+Vr(o)+'"]';var L=D;switch(c){case"style":L=Zd(o);break;case"script":L=Jd(o)}ko.has(L)||(o=v({rel:"preload",href:c==="image"&&g&&g.imageSrcSet?void 0:o,as:c},g),ko.set(L,o),b.querySelector(D)!==null||c==="style"&&b.querySelector(Fp(L))||c==="script"&&b.querySelector(kp(L))||(c=b.createElement("link"),Us(c,"link",o),qe(c),b.head.appendChild(c)))}}function hF(o,c){ac.m(o,c);var g=Kd;if(g&&o){var b=c&&typeof c.as=="string"?c.as:"script",D='link[rel="modulepreload"][as="'+Vr(b)+'"][href="'+Vr(o)+'"]',L=D;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=Jd(o)}if(!ko.has(L)&&(o=v({rel:"modulepreload",href:o},c),ko.set(L,o),g.querySelector(D)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(g.querySelector(kp(L)))return}b=g.createElement("link"),Us(b,"link",o),qe(b),g.head.appendChild(b)}}}function fF(o,c,g){ac.S(o,c,g);var b=Kd;if(b&&o){var D=it(b).hoistableStyles,L=Zd(o);c=c||"default";var Y=D.get(L);if(!Y){var ue={loading:0,preload:null};if(Y=b.querySelector(Fp(L)))ue.loading=5;else{o=v({rel:"stylesheet",href:o,"data-precedence":c},g),(g=ko.get(L))&&kb(o,g);var Re=Y=b.createElement("link");qe(Re),Us(Re,"link",o),Re._p=new Promise(function(at,vt){Re.onload=at,Re.onerror=vt}),Re.addEventListener("load",function(){ue.loading|=1}),Re.addEventListener("error",function(){ue.loading|=2}),ue.loading|=4,a2(Y,c,b)}Y={type:"stylesheet",instance:Y,count:1,state:ue},D.set(L,Y)}}}function dF(o,c){ac.X(o,c);var g=Kd;if(g&&o){var b=it(g).hoistableScripts,D=Jd(o),L=b.get(D);L||(L=g.querySelector(kp(D)),L||(o=v({src:o,async:!0},c),(c=ko.get(D))&&zb(o,c),L=g.createElement("script"),qe(L),Us(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function AF(o,c){ac.M(o,c);var g=Kd;if(g&&o){var b=it(g).hoistableScripts,D=Jd(o),L=b.get(D);L||(L=g.querySelector(kp(D)),L||(o=v({src:o,async:!0,type:"module"},c),(c=ko.get(D))&&zb(o,c),L=g.createElement("script"),qe(L),Us(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function _8(o,c,g,b){var D=(D=et.current)?s2(D):null;if(!D)throw Error(n(446));switch(o){case"meta":case"title":return null;case"style":return typeof g.precedence=="string"&&typeof g.href=="string"?(c=Zd(g.href),g=it(D).hoistableStyles,b=g.get(c),b||(b={type:"style",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(g.rel==="stylesheet"&&typeof g.href=="string"&&typeof g.precedence=="string"){o=Zd(g.href);var L=it(D).hoistableStyles,Y=L.get(o);if(Y||(D=D.ownerDocument||D,Y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(o,Y),(L=D.querySelector(Fp(o)))&&!L._p&&(Y.instance=L,Y.state.loading=5),ko.has(o)||(g={rel:"preload",as:"style",href:g.href,crossOrigin:g.crossOrigin,integrity:g.integrity,media:g.media,hrefLang:g.hrefLang,referrerPolicy:g.referrerPolicy},ko.set(o,g),L||pF(D,o,g,Y.state))),c&&b===null)throw Error(n(528,""));return Y}if(c&&b!==null)throw Error(n(529,""));return null;case"script":return c=g.async,g=g.src,typeof g=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=Jd(g),g=it(D).hoistableScripts,b=g.get(c),b||(b={type:"script",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,o))}}function Zd(o){return'href="'+Vr(o)+'"'}function Fp(o){return'link[rel="stylesheet"]['+o+"]"}function y8(o){return v({},o,{"data-precedence":o.precedence,precedence:null})}function pF(o,c,g,b){o.querySelector('link[rel="preload"][as="style"]['+c+"]")?b.loading=1:(c=o.createElement("link"),b.preload=c,c.addEventListener("load",function(){return b.loading|=1}),c.addEventListener("error",function(){return b.loading|=2}),Us(c,"link",g),qe(c),o.head.appendChild(c))}function Jd(o){return'[src="'+Vr(o)+'"]'}function kp(o){return"script[async]"+o}function x8(o,c,g){if(c.count++,c.instance===null)switch(c.type){case"style":var b=o.querySelector('style[data-href~="'+Vr(g.href)+'"]');if(b)return c.instance=b,qe(b),b;var D=v({},g,{"data-href":g.href,"data-precedence":g.precedence,href:null,precedence:null});return b=(o.ownerDocument||o).createElement("style"),qe(b),Us(b,"style",D),a2(b,g.precedence,o),c.instance=b;case"stylesheet":D=Zd(g.href);var L=o.querySelector(Fp(D));if(L)return c.state.loading|=4,c.instance=L,qe(L),L;b=y8(g),(D=ko.get(D))&&kb(b,D),L=(o.ownerDocument||o).createElement("link"),qe(L);var Y=L;return Y._p=new Promise(function(ue,Re){Y.onload=ue,Y.onerror=Re}),Us(L,"link",b),c.state.loading|=4,a2(L,g.precedence,o),c.instance=L;case"script":return L=Jd(g.src),(D=o.querySelector(kp(L)))?(c.instance=D,qe(D),D):(b=g,(D=ko.get(L))&&(b=v({},g),zb(b,D)),o=o.ownerDocument||o,D=o.createElement("script"),qe(D),Us(D,"link",b),o.head.appendChild(D),c.instance=D);case"void":return null;default:throw Error(n(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(b=c.instance,c.state.loading|=4,a2(b,g.precedence,o));return c.instance}function a2(o,c,g){for(var b=g.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),D=b.length?b[b.length-1]:null,L=D,Y=0;Y title"):null)}function mF(o,c,g){if(g===1||c.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;switch(c.rel){case"stylesheet":return o=c.disabled,typeof c.precedence=="string"&&o==null;default:return!0}case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function w8(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function gF(o,c,g,b){if(g.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(g.state.loading&4)===0){if(g.instance===null){var D=Zd(b.href),L=c.querySelector(Fp(D));if(L){c=L._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(o.count++,o=l2.bind(o),c.then(o,o)),g.state.loading|=4,g.instance=L,qe(L);return}L=c.ownerDocument||c,b=y8(b),(D=ko.get(D))&&kb(b,D),L=L.createElement("link"),qe(L);var Y=L;Y._p=new Promise(function(ue,Re){Y.onload=ue,Y.onerror=Re}),Us(L,"link",b),g.instance=L}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(g,c),(c=g.state.preload)&&(g.state.loading&3)===0&&(o.count++,g=l2.bind(o),c.addEventListener("load",g),c.addEventListener("error",g))}}var Gb=0;function vF(o,c){return o.stylesheets&&o.count===0&&c2(o,o.stylesheets),0Gb?50:800)+c);return o.unsuspend=g,function(){o.unsuspend=null,clearTimeout(b),clearTimeout(D)}}:null}function l2(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)c2(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var u2=null;function c2(o,c){o.stylesheets=null,o.unsuspend!==null&&(o.count++,u2=new Map,c.forEach(_F,o),u2=null,l2.call(o))}function _F(o,c){if(!(c.state.loading&4)){var g=u2.get(o);if(g)var b=g.get(null);else{g=new Map,u2.set(o,g);for(var D=o.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Yb.exports=BF(),Yb.exports}var IF=OF(),re=bT();const FF=E7(re);/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */const F0="172",Wo={ROTATE:0,DOLLY:1,PAN:2},OA={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},C7=0,WS=1,N7=2,kF=0,ST=1,zF=2,vo=3,El=0,or=1,as=2,$a=0,Xa=1,t0=2,n0=3,i0=4,wT=5,wo=100,TT=101,MT=102,R7=103,D7=104,ET=200,CT=201,NT=202,RT=203,zm=204,Gm=205,DT=206,PT=207,LT=208,UT=209,BT=210,GF=211,qF=212,VF=213,jF=214,qm=0,Vm=1,jm=2,Bh=3,Hm=4,Wm=5,$m=6,Xm=7,Dg=0,P7=1,L7=2,Ya=0,U7=1,B7=2,O7=3,I7=4,HF=5,F7=6,k7=7,OT=300,Xo=301,Yo=302,Oh=303,Ih=304,ed=306,td=1e3,Yl=1001,nd=1002,dr=1003,i_=1004,Ql=1005,ps=1006,XA=1007,za=1008,WF=1008,ra=1009,Hf=1010,Wf=1011,bl=1012,Ns=1013,Nr=1014,$r=1015,Gs=1016,hy=1017,fy=1018,lu=1020,dy=35902,IT=1021,Pg=1022,ks=1023,FT=1024,kT=1025,tu=1026,uu=1027,Lg=1028,k0=1029,id=1030,z0=1031,$F=1032,G0=1033,$f=33776,Dh=33777,Ph=33778,Lh=33779,Ym=35840,Qm=35841,Km=35842,Zm=35843,Jm=36196,r0=37492,s0=37496,a0=37808,o0=37809,l0=37810,u0=37811,c0=37812,h0=37813,f0=37814,d0=37815,A0=37816,p0=37817,m0=37818,g0=37819,v0=37820,_0=37821,Xf=36492,$S=36494,XS=36495,zT=36283,eg=36284,tg=36285,ng=36286,XF=0,YF=1,X8=2,QF=3200,KF=3201,Mc=0,z7=1,To="",bn="srgb",Mo="srgb-linear",r_="linear",Fi="srgb",ZF=0,Nf=7680,JF=7681,ek=7682,tk=7683,nk=34055,ik=34056,rk=5386,sk=512,ak=513,ok=514,lk=515,uk=516,ck=517,hk=518,YS=519,GT=512,Ay=513,qT=514,py=515,VT=516,jT=517,HT=518,WT=519,s_=35044,IA=35048,Y8="300 es",Ga=2e3,cu=2001;class Bc{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s>8&255]+Ks[i>>16&255]+Ks[i>>24&255]+"-"+Ks[e&255]+Ks[e>>8&255]+"-"+Ks[e>>16&15|64]+Ks[e>>24&255]+"-"+Ks[t&63|128]+Ks[t>>8&255]+"-"+Ks[t>>16&255]+Ks[t>>24&255]+Ks[n&255]+Ks[n>>8&255]+Ks[n>>16&255]+Ks[n>>24&255]).toLowerCase()}function ri(i,e,t){return Math.max(e,Math.min(t,i))}function $T(i,e){return(i%e+e)%e}function fk(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function dk(i,e,t){return i!==e?(t-i)/(e-i):0}function Mm(i,e,t){return(1-t)*i+t*e}function Ak(i,e,t,n){return Mm(i,e,1-Math.exp(-t*n))}function pk(i,e=1){return e-Math.abs($T(i,e*2)-e)}function mk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function gk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function vk(i,e){return i+Math.floor(Math.random()*(e-i+1))}function _k(i,e){return i+Math.random()*(e-i)}function yk(i){return i*(.5-Math.random())}function xk(i){i!==void 0&&(Q8=i);let e=Q8+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function bk(i){return i*Tm}function Sk(i){return i*y0}function wk(i){return(i&i-1)===0&&i!==0}function Tk(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Mk(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ek(i,e,t,n,r){const s=Math.cos,a=Math.sin,l=s(t/2),u=a(t/2),h=s((e+n)/2),m=a((e+n)/2),v=s((e-n)/2),x=a((e-n)/2),S=s((n-e)/2),T=a((n-e)/2);switch(r){case"XYX":i.set(l*m,u*v,u*x,l*h);break;case"YZY":i.set(u*x,l*m,u*v,l*h);break;case"ZXZ":i.set(u*v,u*x,l*m,l*h);break;case"XZX":i.set(l*m,u*T,u*S,l*h);break;case"YXY":i.set(u*S,l*m,u*T,l*h);break;case"ZYZ":i.set(u*T,u*S,l*m,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ba(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function oi(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const x0={DEG2RAD:Tm,RAD2DEG:y0,generateUUID:nu,clamp:ri,euclideanModulo:$T,mapLinear:fk,inverseLerp:dk,lerp:Mm,damp:Ak,pingpong:pk,smoothstep:mk,smootherstep:gk,randInt:vk,randFloat:_k,randFloatSpread:yk,seededRandom:xk,degToRad:bk,radToDeg:Sk,isPowerOfTwo:wk,ceilPowerOfTwo:Tk,floorPowerOfTwo:Mk,setQuaternionFromProperEuler:Ek,normalize:oi,denormalize:ba};class bt{constructor(e=0,t=0){bt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ri(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xn{constructor(e,t,n,r,s,a,l,u,h){Xn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h)}set(e,t,n,r,s,a,l,u,h){const m=this.elements;return m[0]=e,m[1]=r,m[2]=l,m[3]=t,m[4]=s,m[5]=u,m[6]=n,m[7]=a,m[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[3],u=n[6],h=n[1],m=n[4],v=n[7],x=n[2],S=n[5],T=n[8],N=r[0],C=r[3],E=r[6],O=r[1],U=r[4],I=r[7],j=r[2],z=r[5],G=r[8];return s[0]=a*N+l*O+u*j,s[3]=a*C+l*U+u*z,s[6]=a*E+l*I+u*G,s[1]=h*N+m*O+v*j,s[4]=h*C+m*U+v*z,s[7]=h*E+m*I+v*G,s[2]=x*N+S*O+T*j,s[5]=x*C+S*U+T*z,s[8]=x*E+S*I+T*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8];return t*a*m-t*l*h-n*s*m+n*l*u+r*s*h-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=m*a-l*h,x=l*u-m*s,S=h*s-a*u,T=t*v+n*x+r*S;if(T===0)return this.set(0,0,0,0,0,0,0,0,0);const N=1/T;return e[0]=v*N,e[1]=(r*h-m*n)*N,e[2]=(l*n-r*a)*N,e[3]=x*N,e[4]=(m*t-r*u)*N,e[5]=(r*s-l*t)*N,e[6]=S*N,e[7]=(n*u-h*t)*N,e[8]=(a*t-n*s)*N,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,l){const u=Math.cos(s),h=Math.sin(s);return this.set(n*u,n*h,-n*(u*a+h*l)+a+e,-r*h,r*u,-r*(-h*a+u*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(e3.makeScale(e,t)),this}rotate(e){return this.premultiply(e3.makeRotation(-e)),this}translate(e,t){return this.premultiply(e3.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const e3=new Xn;function G7(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ig(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function q7(){const i=ig("canvas");return i.style.display="block",i}const K8={};function Uf(i){i in K8||(K8[i]=!0,console.warn(i))}function Ck(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function Nk(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Rk(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const Z8=new Xn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),J8=new Xn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Dk(){const i={enabled:!0,workingColorSpace:Mo,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Fi&&(r.r=xc(r.r),r.g=xc(r.g),r.b=xc(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Fi&&(r.r=YA(r.r),r.g=YA(r.g),r.b=YA(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===To?r_:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Mo]:{primaries:e,whitePoint:n,transfer:r_,toXYZ:Z8,fromXYZ:J8,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:bn},outputColorSpaceConfig:{drawingBufferColorSpace:bn}},[bn]:{primaries:e,whitePoint:n,transfer:Fi,toXYZ:Z8,fromXYZ:J8,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:bn}}}),i}const li=Dk();function xc(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function YA(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let tA;class Pk{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{tA===void 0&&(tA=ig("canvas")),tA.width=e.width,tA.height=e.height;const n=tA.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=tA}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ig("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==OT)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case td:e.x=e.x-Math.floor(e.x);break;case Yl:e.x=e.x<0?0:1;break;case nd:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case td:e.y=e.y-Math.floor(e.y);break;case Yl:e.y=e.y<0?0:1;break;case nd:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ms.DEFAULT_IMAGE=null;ms.DEFAULT_MAPPING=OT;ms.DEFAULT_ANISOTROPY=1;class On{constructor(e=0,t=0,n=0,r=1){On.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const u=e.elements,h=u[0],m=u[4],v=u[8],x=u[1],S=u[5],T=u[9],N=u[2],C=u[6],E=u[10];if(Math.abs(m-x)<.01&&Math.abs(v-N)<.01&&Math.abs(T-C)<.01){if(Math.abs(m+x)<.1&&Math.abs(v+N)<.1&&Math.abs(T+C)<.1&&Math.abs(h+S+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const U=(h+1)/2,I=(S+1)/2,j=(E+1)/2,z=(m+x)/4,G=(v+N)/4,H=(T+C)/4;return U>I&&U>j?U<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(U),r=z/n,s=G/n):I>j?I<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(I),n=z/r,s=H/r):j<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(j),n=G/s,r=H/s),this.set(n,r,s,t),this}let O=Math.sqrt((C-T)*(C-T)+(v-N)*(v-N)+(x-m)*(x-m));return Math.abs(O)<.001&&(O=1),this.x=(C-T)/O,this.y=(v-N)/O,this.z=(x-m)/O,this.w=Math.acos((h+S+E-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this.z=ri(this.z,e.z,t.z),this.w=ri(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this.z=ri(this.z,e,t),this.w=ri(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class qh extends Bc{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new On(0,0,e,t),this.scissorTest=!1,this.viewport=new On(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ps,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new ms(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let l=0;l=0?1:-1,U=1-E*E;if(U>Number.EPSILON){const j=Math.sqrt(U),z=Math.atan2(j,E*O);C=Math.sin(C*z)/j,l=Math.sin(l*z)/j}const I=l*O;if(u=u*C+x*I,h=h*C+S*I,m=m*C+T*I,v=v*C+N*I,C===1-l){const j=1/Math.sqrt(u*u+h*h+m*m+v*v);u*=j,h*=j,m*=j,v*=j}}e[t]=u,e[t+1]=h,e[t+2]=m,e[t+3]=v}static multiplyQuaternionsFlat(e,t,n,r,s,a){const l=n[r],u=n[r+1],h=n[r+2],m=n[r+3],v=s[a],x=s[a+1],S=s[a+2],T=s[a+3];return e[t]=l*T+m*v+u*S-h*x,e[t+1]=u*T+m*x+h*v-l*S,e[t+2]=h*T+m*S+l*x-u*v,e[t+3]=m*T-l*v-u*x-h*S,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,l=Math.cos,u=Math.sin,h=l(n/2),m=l(r/2),v=l(s/2),x=u(n/2),S=u(r/2),T=u(s/2);switch(a){case"XYZ":this._x=x*m*v+h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v-x*S*T;break;case"YXZ":this._x=x*m*v+h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v+x*S*T;break;case"ZXY":this._x=x*m*v-h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v-x*S*T;break;case"ZYX":this._x=x*m*v-h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v+x*S*T;break;case"YZX":this._x=x*m*v+h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v-x*S*T;break;case"XZY":this._x=x*m*v-h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v+x*S*T;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],l=t[5],u=t[9],h=t[2],m=t[6],v=t[10],x=n+l+v;if(x>0){const S=.5/Math.sqrt(x+1);this._w=.25/S,this._x=(m-u)*S,this._y=(s-h)*S,this._z=(a-r)*S}else if(n>l&&n>v){const S=2*Math.sqrt(1+n-l-v);this._w=(m-u)/S,this._x=.25*S,this._y=(r+a)/S,this._z=(s+h)/S}else if(l>v){const S=2*Math.sqrt(1+l-n-v);this._w=(s-h)/S,this._x=(r+a)/S,this._y=.25*S,this._z=(u+m)/S}else{const S=2*Math.sqrt(1+v-n-l);this._w=(a-r)/S,this._x=(s+h)/S,this._y=(u+m)/S,this._z=.25*S}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ri(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,l=t._x,u=t._y,h=t._z,m=t._w;return this._x=n*m+a*l+r*h-s*u,this._y=r*m+a*u+s*l-n*h,this._z=s*m+a*h+n*u-r*l,this._w=a*m-n*l-r*u-s*h,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let l=a*e._w+n*e._x+r*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const u=1-l*l;if(u<=Number.EPSILON){const S=1-t;return this._w=S*a+t*this._w,this._x=S*n+t*this._x,this._y=S*r+t*this._y,this._z=S*s+t*this._z,this.normalize(),this}const h=Math.sqrt(u),m=Math.atan2(h,l),v=Math.sin((1-t)*m)/h,x=Math.sin(t*m)/h;return this._w=a*v+this._w*x,this._x=n*v+this._x*x,this._y=r*v+this._y*x,this._z=s*v+this._z*x,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class me{constructor(e=0,t=0,n=0){me.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(eN.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(eN.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,l=e.z,u=e.w,h=2*(a*r-l*n),m=2*(l*t-s*r),v=2*(s*n-a*t);return this.x=t+u*h+a*v-l*m,this.y=n+u*m+l*h-s*v,this.z=r+u*v+s*m-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this.z=ri(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this.z=ri(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,l=t.y,u=t.z;return this.x=r*u-s*l,this.y=s*a-n*u,this.z=n*l-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return n3.copy(this).projectOnVector(e),this.sub(n3)}reflect(e){return this.sub(n3.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ri(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const n3=new me,eN=new hu;class Oc{constructor(e=new me(1/0,1/0,1/0),t=new me(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,dl),dl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wp),_2.subVectors(this.max,Wp),nA.subVectors(e.a,Wp),iA.subVectors(e.b,Wp),rA.subVectors(e.c,Wp),hh.subVectors(iA,nA),fh.subVectors(rA,iA),pf.subVectors(nA,rA);let t=[0,-hh.z,hh.y,0,-fh.z,fh.y,0,-pf.z,pf.y,hh.z,0,-hh.x,fh.z,0,-fh.x,pf.z,0,-pf.x,-hh.y,hh.x,0,-fh.y,fh.x,0,-pf.y,pf.x,0];return!i3(t,nA,iA,rA,_2)||(t=[1,0,0,0,1,0,0,0,1],!i3(t,nA,iA,rA,_2))?!1:(y2.crossVectors(hh,fh),t=[y2.x,y2.y,y2.z],i3(t,nA,iA,rA,_2))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,dl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(dl).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const oc=[new me,new me,new me,new me,new me,new me,new me,new me],dl=new me,v2=new Oc,nA=new me,iA=new me,rA=new me,hh=new me,fh=new me,pf=new me,Wp=new me,_2=new me,y2=new me,mf=new me;function i3(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){mf.fromArray(i,s);const l=r.x*Math.abs(mf.x)+r.y*Math.abs(mf.y)+r.z*Math.abs(mf.z),u=e.dot(mf),h=t.dot(mf),m=n.dot(mf);if(Math.max(-Math.max(u,h,m),Math.min(u,h,m))>l)return!1}return!0}const Ok=new Oc,$p=new me,r3=new me;class ud{constructor(e=new me,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ok.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;$p.subVectors(e,this.center);const t=$p.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector($p,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(r3.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint($p.copy(e.center).add(r3)),this.expandByPoint($p.copy(e.center).sub(r3))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const lc=new me,s3=new me,x2=new me,dh=new me,a3=new me,b2=new me,o3=new me;class Ug{constructor(e=new me,t=new me(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,lc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=lc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(lc.copy(this.origin).addScaledVector(this.direction,t),lc.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){s3.copy(e).add(t).multiplyScalar(.5),x2.copy(t).sub(e).normalize(),dh.copy(this.origin).sub(s3);const s=e.distanceTo(t)*.5,a=-this.direction.dot(x2),l=dh.dot(this.direction),u=-dh.dot(x2),h=dh.lengthSq(),m=Math.abs(1-a*a);let v,x,S,T;if(m>0)if(v=a*u-l,x=a*l-u,T=s*m,v>=0)if(x>=-T)if(x<=T){const N=1/m;v*=N,x*=N,S=v*(v+a*x+2*l)+x*(a*v+x+2*u)+h}else x=s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x=-s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x<=-T?(v=Math.max(0,-(-a*s+l)),x=v>0?-s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h):x<=T?(v=0,x=Math.min(Math.max(-s,-u),s),S=x*(x+2*u)+h):(v=Math.max(0,-(a*s+l)),x=v>0?s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h);else x=a>0?-s:s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,v),r&&r.copy(s3).addScaledVector(x2,x),S}intersectSphere(e,t){lc.subVectors(e.center,this.origin);const n=lc.dot(this.direction),r=lc.dot(lc)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),l=n-a,u=n+a;return u<0?null:l<0?this.at(u,t):this.at(l,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,l,u;const h=1/this.direction.x,m=1/this.direction.y,v=1/this.direction.z,x=this.origin;return h>=0?(n=(e.min.x-x.x)*h,r=(e.max.x-x.x)*h):(n=(e.max.x-x.x)*h,r=(e.min.x-x.x)*h),m>=0?(s=(e.min.y-x.y)*m,a=(e.max.y-x.y)*m):(s=(e.max.y-x.y)*m,a=(e.min.y-x.y)*m),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a=0?(l=(e.min.z-x.z)*v,u=(e.max.z-x.z)*v):(l=(e.max.z-x.z)*v,u=(e.min.z-x.z)*v),n>u||l>r)||((l>n||n!==n)&&(n=l),(u=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,lc)!==null}intersectTriangle(e,t,n,r,s){a3.subVectors(t,e),b2.subVectors(n,e),o3.crossVectors(a3,b2);let a=this.direction.dot(o3),l;if(a>0){if(r)return null;l=1}else if(a<0)l=-1,a=-a;else return null;dh.subVectors(this.origin,e);const u=l*this.direction.dot(b2.crossVectors(dh,b2));if(u<0)return null;const h=l*this.direction.dot(a3.cross(dh));if(h<0||u+h>a)return null;const m=-l*dh.dot(o3);return m<0?null:this.at(m/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class jn{constructor(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C){jn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C)}set(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C){const E=this.elements;return E[0]=e,E[4]=t,E[8]=n,E[12]=r,E[1]=s,E[5]=a,E[9]=l,E[13]=u,E[2]=h,E[6]=m,E[10]=v,E[14]=x,E[3]=S,E[7]=T,E[11]=N,E[15]=C,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new jn().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/sA.setFromMatrixColumn(e,0).length(),s=1/sA.setFromMatrixColumn(e,1).length(),a=1/sA.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),l=Math.sin(n),u=Math.cos(r),h=Math.sin(r),m=Math.cos(s),v=Math.sin(s);if(e.order==="XYZ"){const x=a*m,S=a*v,T=l*m,N=l*v;t[0]=u*m,t[4]=-u*v,t[8]=h,t[1]=S+T*h,t[5]=x-N*h,t[9]=-l*u,t[2]=N-x*h,t[6]=T+S*h,t[10]=a*u}else if(e.order==="YXZ"){const x=u*m,S=u*v,T=h*m,N=h*v;t[0]=x+N*l,t[4]=T*l-S,t[8]=a*h,t[1]=a*v,t[5]=a*m,t[9]=-l,t[2]=S*l-T,t[6]=N+x*l,t[10]=a*u}else if(e.order==="ZXY"){const x=u*m,S=u*v,T=h*m,N=h*v;t[0]=x-N*l,t[4]=-a*v,t[8]=T+S*l,t[1]=S+T*l,t[5]=a*m,t[9]=N-x*l,t[2]=-a*h,t[6]=l,t[10]=a*u}else if(e.order==="ZYX"){const x=a*m,S=a*v,T=l*m,N=l*v;t[0]=u*m,t[4]=T*h-S,t[8]=x*h+N,t[1]=u*v,t[5]=N*h+x,t[9]=S*h-T,t[2]=-h,t[6]=l*u,t[10]=a*u}else if(e.order==="YZX"){const x=a*u,S=a*h,T=l*u,N=l*h;t[0]=u*m,t[4]=N-x*v,t[8]=T*v+S,t[1]=v,t[5]=a*m,t[9]=-l*m,t[2]=-h*m,t[6]=S*v+T,t[10]=x-N*v}else if(e.order==="XZY"){const x=a*u,S=a*h,T=l*u,N=l*h;t[0]=u*m,t[4]=-v,t[8]=h*m,t[1]=x*v+N,t[5]=a*m,t[9]=S*v-T,t[2]=T*v-S,t[6]=l*m,t[10]=N*v+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ik,e,Fk)}lookAt(e,t,n){const r=this.elements;return ho.subVectors(e,t),ho.lengthSq()===0&&(ho.z=1),ho.normalize(),Ah.crossVectors(n,ho),Ah.lengthSq()===0&&(Math.abs(n.z)===1?ho.x+=1e-4:ho.z+=1e-4,ho.normalize(),Ah.crossVectors(n,ho)),Ah.normalize(),S2.crossVectors(ho,Ah),r[0]=Ah.x,r[4]=S2.x,r[8]=ho.x,r[1]=Ah.y,r[5]=S2.y,r[9]=ho.y,r[2]=Ah.z,r[6]=S2.z,r[10]=ho.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[4],u=n[8],h=n[12],m=n[1],v=n[5],x=n[9],S=n[13],T=n[2],N=n[6],C=n[10],E=n[14],O=n[3],U=n[7],I=n[11],j=n[15],z=r[0],G=r[4],H=r[8],q=r[12],V=r[1],Q=r[5],J=r[9],ne=r[13],oe=r[2],ie=r[6],Z=r[10],te=r[14],de=r[3],Se=r[7],Te=r[11],ae=r[15];return s[0]=a*z+l*V+u*oe+h*de,s[4]=a*G+l*Q+u*ie+h*Se,s[8]=a*H+l*J+u*Z+h*Te,s[12]=a*q+l*ne+u*te+h*ae,s[1]=m*z+v*V+x*oe+S*de,s[5]=m*G+v*Q+x*ie+S*Se,s[9]=m*H+v*J+x*Z+S*Te,s[13]=m*q+v*ne+x*te+S*ae,s[2]=T*z+N*V+C*oe+E*de,s[6]=T*G+N*Q+C*ie+E*Se,s[10]=T*H+N*J+C*Z+E*Te,s[14]=T*q+N*ne+C*te+E*ae,s[3]=O*z+U*V+I*oe+j*de,s[7]=O*G+U*Q+I*ie+j*Se,s[11]=O*H+U*J+I*Z+j*Te,s[15]=O*q+U*ne+I*te+j*ae,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],l=e[5],u=e[9],h=e[13],m=e[2],v=e[6],x=e[10],S=e[14],T=e[3],N=e[7],C=e[11],E=e[15];return T*(+s*u*v-r*h*v-s*l*x+n*h*x+r*l*S-n*u*S)+N*(+t*u*S-t*h*x+s*a*x-r*a*S+r*h*m-s*u*m)+C*(+t*h*v-t*l*S-s*a*v+n*a*S+s*l*m-n*h*m)+E*(-r*l*m-t*u*v+t*l*x+r*a*v-n*a*x+n*u*m)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=e[9],x=e[10],S=e[11],T=e[12],N=e[13],C=e[14],E=e[15],O=v*C*h-N*x*h+N*u*S-l*C*S-v*u*E+l*x*E,U=T*x*h-m*C*h-T*u*S+a*C*S+m*u*E-a*x*E,I=m*N*h-T*v*h+T*l*S-a*N*S-m*l*E+a*v*E,j=T*v*u-m*N*u-T*l*x+a*N*x+m*l*C-a*v*C,z=t*O+n*U+r*I+s*j;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const G=1/z;return e[0]=O*G,e[1]=(N*x*s-v*C*s-N*r*S+n*C*S+v*r*E-n*x*E)*G,e[2]=(l*C*s-N*u*s+N*r*h-n*C*h-l*r*E+n*u*E)*G,e[3]=(v*u*s-l*x*s-v*r*h+n*x*h+l*r*S-n*u*S)*G,e[4]=U*G,e[5]=(m*C*s-T*x*s+T*r*S-t*C*S-m*r*E+t*x*E)*G,e[6]=(T*u*s-a*C*s-T*r*h+t*C*h+a*r*E-t*u*E)*G,e[7]=(a*x*s-m*u*s+m*r*h-t*x*h-a*r*S+t*u*S)*G,e[8]=I*G,e[9]=(T*v*s-m*N*s-T*n*S+t*N*S+m*n*E-t*v*E)*G,e[10]=(a*N*s-T*l*s+T*n*h-t*N*h-a*n*E+t*l*E)*G,e[11]=(m*l*s-a*v*s-m*n*h+t*v*h+a*n*S-t*l*S)*G,e[12]=j*G,e[13]=(m*N*r-T*v*r+T*n*x-t*N*x-m*n*C+t*v*C)*G,e[14]=(T*l*r-a*N*r-T*n*u+t*N*u+a*n*C-t*l*C)*G,e[15]=(a*v*r-m*l*r+m*n*u-t*v*u-a*n*x+t*l*x)*G,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,l=e.y,u=e.z,h=s*a,m=s*l;return this.set(h*a+n,h*l-r*u,h*u+r*l,0,h*l+r*u,m*l+n,m*u-r*a,0,h*u-r*l,m*u+r*a,s*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,l=t._z,u=t._w,h=s+s,m=a+a,v=l+l,x=s*h,S=s*m,T=s*v,N=a*m,C=a*v,E=l*v,O=u*h,U=u*m,I=u*v,j=n.x,z=n.y,G=n.z;return r[0]=(1-(N+E))*j,r[1]=(S+I)*j,r[2]=(T-U)*j,r[3]=0,r[4]=(S-I)*z,r[5]=(1-(x+E))*z,r[6]=(C+O)*z,r[7]=0,r[8]=(T+U)*G,r[9]=(C-O)*G,r[10]=(1-(x+N))*G,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=sA.set(r[0],r[1],r[2]).length();const a=sA.set(r[4],r[5],r[6]).length(),l=sA.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Al.copy(this);const h=1/s,m=1/a,v=1/l;return Al.elements[0]*=h,Al.elements[1]*=h,Al.elements[2]*=h,Al.elements[4]*=m,Al.elements[5]*=m,Al.elements[6]*=m,Al.elements[8]*=v,Al.elements[9]*=v,Al.elements[10]*=v,t.setFromRotationMatrix(Al),n.x=s,n.y=a,n.z=l,this}makePerspective(e,t,n,r,s,a,l=Ga){const u=this.elements,h=2*s/(t-e),m=2*s/(n-r),v=(t+e)/(t-e),x=(n+r)/(n-r);let S,T;if(l===Ga)S=-(a+s)/(a-s),T=-2*a*s/(a-s);else if(l===cu)S=-a/(a-s),T=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=h,u[4]=0,u[8]=v,u[12]=0,u[1]=0,u[5]=m,u[9]=x,u[13]=0,u[2]=0,u[6]=0,u[10]=S,u[14]=T,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,s,a,l=Ga){const u=this.elements,h=1/(t-e),m=1/(n-r),v=1/(a-s),x=(t+e)*h,S=(n+r)*m;let T,N;if(l===Ga)T=(a+s)*v,N=-2*v;else if(l===cu)T=s*v,N=-1*v;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=2*h,u[4]=0,u[8]=0,u[12]=-x,u[1]=0,u[5]=2*m,u[9]=0,u[13]=-S,u[2]=0,u[6]=0,u[10]=N,u[14]=-T,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const sA=new me,Al=new jn,Ik=new me(0,0,0),Fk=new me(1,1,1),Ah=new me,S2=new me,ho=new me,tN=new jn,nN=new hu;class aa{constructor(e=0,t=0,n=0,r=aa.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],l=r[8],u=r[1],h=r[5],m=r[9],v=r[2],x=r[6],S=r[10];switch(t){case"XYZ":this._y=Math.asin(ri(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-m,S),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(x,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ri(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(l,S),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-v,s),this._z=0);break;case"ZXY":this._x=Math.asin(ri(x,-1,1)),Math.abs(x)<.9999999?(this._y=Math.atan2(-v,S),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-ri(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(x,S),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(ri(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-m,h),this._y=Math.atan2(-v,s)):(this._x=0,this._y=Math.atan2(l,S));break;case"XZY":this._z=Math.asin(-ri(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(x,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-m,S),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return tN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(tN,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return nN.setFromEuler(this),this.setFromQuaternion(nN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}aa.DEFAULT_ORDER="XYZ";class YT{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(l,u){return l[u.uuid]===void 0&&(l[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const u=l.shapes;if(Array.isArray(u))for(let h=0,m=u.length;h0){r.children=[];for(let l=0;l0){r.animations=[];for(let l=0;l0&&(n.geometries=l),u.length>0&&(n.materials=u),h.length>0&&(n.textures=h),m.length>0&&(n.images=m),v.length>0&&(n.shapes=v),x.length>0&&(n.skeletons=x),S.length>0&&(n.animations=S),T.length>0&&(n.nodes=T)}return n.object=r,n;function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){pl.subVectors(r,t),cc.subVectors(n,t),u3.subVectors(e,t);const a=pl.dot(pl),l=pl.dot(cc),u=pl.dot(u3),h=cc.dot(cc),m=cc.dot(u3),v=a*h-l*l;if(v===0)return s.set(0,0,0),null;const x=1/v,S=(h*u-l*m)*x,T=(a*m-l*u)*x;return s.set(1-S-T,T,S)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,hc)===null?!1:hc.x>=0&&hc.y>=0&&hc.x+hc.y<=1}static getInterpolation(e,t,n,r,s,a,l,u){return this.getBarycoord(e,t,n,r,hc)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(s,hc.x),u.addScaledVector(a,hc.y),u.addScaledVector(l,hc.z),u)}static getInterpolatedAttribute(e,t,n,r,s,a){return d3.setScalar(0),A3.setScalar(0),p3.setScalar(0),d3.fromBufferAttribute(e,t),A3.fromBufferAttribute(e,n),p3.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(d3,s.x),a.addScaledVector(A3,s.y),a.addScaledVector(p3,s.z),a}static isFrontFacing(e,t,n,r){return pl.subVectors(n,t),cc.subVectors(e,t),pl.cross(cc).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return pl.subVectors(this.c,this.b),cc.subVectors(this.a,this.b),pl.cross(cc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yl.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return yl.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return yl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,l;lA.subVectors(r,n),uA.subVectors(s,n),c3.subVectors(e,n);const u=lA.dot(c3),h=uA.dot(c3);if(u<=0&&h<=0)return t.copy(n);h3.subVectors(e,r);const m=lA.dot(h3),v=uA.dot(h3);if(m>=0&&v<=m)return t.copy(r);const x=u*v-m*h;if(x<=0&&u>=0&&m<=0)return a=u/(u-m),t.copy(n).addScaledVector(lA,a);f3.subVectors(e,s);const S=lA.dot(f3),T=uA.dot(f3);if(T>=0&&S<=T)return t.copy(s);const N=S*h-u*T;if(N<=0&&h>=0&&T<=0)return l=h/(h-T),t.copy(n).addScaledVector(uA,l);const C=m*T-S*v;if(C<=0&&v-m>=0&&S-T>=0)return lN.subVectors(s,r),l=(v-m)/(v-m+(S-T)),t.copy(r).addScaledVector(lN,l);const E=1/(C+N+x);return a=N*E,l=x*E,t.copy(n).addScaledVector(lA,a).addScaledVector(uA,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const j7={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ph={h:0,s:0,l:0},T2={h:0,s:0,l:0};function m3(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let cn=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=bn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,li.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=li.workingColorSpace){return this.r=e,this.g=t,this.b=n,li.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=li.workingColorSpace){if(e=$T(e,1),t=ri(t,0,1),n=ri(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=m3(a,s,e+1/3),this.g=m3(a,s,e),this.b=m3(a,s,e-1/3)}return li.toWorkingColorSpace(this,r),this}setStyle(e,t=bn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],l=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=bn){const n=j7[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=xc(e.r),this.g=xc(e.g),this.b=xc(e.b),this}copyLinearToSRGB(e){return this.r=YA(e.r),this.g=YA(e.g),this.b=YA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=bn){return li.fromWorkingColorSpace(Zs.copy(this),e),Math.round(ri(Zs.r*255,0,255))*65536+Math.round(ri(Zs.g*255,0,255))*256+Math.round(ri(Zs.b*255,0,255))}getHexString(e=bn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=li.workingColorSpace){li.fromWorkingColorSpace(Zs.copy(this),t);const n=Zs.r,r=Zs.g,s=Zs.b,a=Math.max(n,r,s),l=Math.min(n,r,s);let u,h;const m=(l+a)/2;if(l===a)u=0,h=0;else{const v=a-l;switch(h=m<=.5?v/(a+l):v/(2-a-l),a){case n:u=(r-s)/v+(r0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Xa&&(n.blending=this.blending),this.side!==El&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==zm&&(n.blendSrc=this.blendSrc),this.blendDst!==Gm&&(n.blendDst=this.blendDst),this.blendEquation!==wo&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Bh&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==YS&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Nf&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Nf&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Nf&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const l in s){const u=s[l];delete u.metadata,a.push(u)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class cd extends oa{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new cn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const gc=jk();function jk(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const h=u-127;h<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):h<-14?(n[u]=1024>>-h-14,n[u|256]=1024>>-h-14|32768,r[u]=-h-1,r[u|256]=-h-1):h<=15?(n[u]=h+15<<10,n[u|256]=h+15<<10|32768,r[u]=13,r[u|256]=13):h<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),l=new Uint32Array(64);for(let u=1;u<1024;++u){let h=u<<13,m=0;for(;(h&8388608)===0;)h<<=1,m-=8388608;h&=-8388609,m+=947912704,s[u]=h|m}for(let u=1024;u<2048;++u)s[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(l[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:l}}function fo(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=ri(i,-65504,65504),gc.floatView[0]=i;const e=gc.uint32View[0],t=e>>23&511;return gc.baseTable[t]+((e&8388607)>>gc.shiftTable[t])}function M2(i){const e=i>>10;return gc.uint32View[0]=gc.mantissaTable[gc.offsetTable[e]+(i&1023)]+gc.exponentTable[e],gc.floatView[0]}const is=new me,E2=new bt;class wr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=s_,this.updateRanges=[],this.gpuType=$r,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;rt.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Oc);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new me(-1/0,-1/0,-1/0),new me(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const h in u)u[h]!==void 0&&(e[h]=u[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const h=n[u];e.data.attributes[u]=h.toJSON(e.data)}const r={};let s=!1;for(const u in this.morphAttributes){const h=this.morphAttributes[u],m=[];for(let v=0,x=h.length;v0&&(r[u]=m,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const h in r){const m=r[h];this.setAttribute(h,m.clone(t))}const s=e.morphAttributes;for(const h in s){const m=[],v=s[h];for(let x=0,S=v.length;x0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s(e.far-e.near)**2))&&(uN.copy(s).invert(),gf.copy(e.ray).applyMatrix4(uN),!(n.boundingBox!==null&&gf.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,gf)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,l=s.index,u=s.attributes.position,h=s.attributes.uv,m=s.attributes.uv1,v=s.attributes.normal,x=s.groups,S=s.drawRange;if(l!==null)if(Array.isArray(a))for(let T=0,N=x.length;Tt.far?null:{distance:h,point:L2.clone(),object:i}}function U2(i,e,t,n,r,s,a,l,u,h){i.getVertexPosition(l,N2),i.getVertexPosition(u,R2),i.getVertexPosition(h,D2);const m=Wk(i,e,t,n,N2,R2,D2,hN);if(m){const v=new me;yl.getBarycoord(hN,N2,R2,D2,v),r&&(m.uv=yl.getInterpolatedAttribute(r,l,u,h,v,new bt)),s&&(m.uv1=yl.getInterpolatedAttribute(s,l,u,h,v,new bt)),a&&(m.normal=yl.getInterpolatedAttribute(a,l,u,h,v,new me),m.normal.dot(n.direction)>0&&m.normal.multiplyScalar(-1));const x={a:l,b:u,c:h,normal:new me,materialIndex:0};yl.getNormal(N2,R2,D2,x.normal),m.face=x,m.barycoord=v}return m}class Vh extends Hi{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const u=[],h=[],m=[],v=[];let x=0,S=0;T("z","y","x",-1,-1,n,t,e,a,s,0),T("z","y","x",1,-1,n,t,-e,a,s,1),T("x","z","y",1,1,e,n,t,r,a,2),T("x","z","y",1,-1,e,n,-t,r,a,3),T("x","y","z",1,-1,e,t,n,r,s,4),T("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(u),this.setAttribute("position",new Si(h,3)),this.setAttribute("normal",new Si(m,3)),this.setAttribute("uv",new Si(v,2));function T(N,C,E,O,U,I,j,z,G,H,q){const V=I/G,Q=j/H,J=I/2,ne=j/2,oe=z/2,ie=G+1,Z=H+1;let te=0,de=0;const Se=new me;for(let Te=0;Te0?1:-1,m.push(Se.x,Se.y,Se.z),v.push(Me/G),v.push(1-Te/H),te+=1}}for(let Te=0;Te0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class gy extends pr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new jn,this.projectionMatrix=new jn,this.projectionMatrixInverse=new jn,this.coordinateSystem=Ga}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const mh=new me,fN=new bt,dN=new bt;class va extends gy{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=y0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Tm*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return y0*2*Math.atan(Math.tan(Tm*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){mh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(mh.x,mh.y).multiplyScalar(-e/mh.z),mh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(mh.x,mh.y).multiplyScalar(-e/mh.z)}getViewSize(e,t){return this.getViewBounds(e,fN,dN),t.subVectors(dN,fN)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Tm*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,h=a.fullHeight;s+=a.offsetX*r/u,t-=a.offsetY*n/h,r*=a.width/u,n*=a.height/h}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const hA=-90,fA=1;class $7 extends pr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new va(hA,fA,e,t);r.layers=this.layers,this.add(r);const s=new va(hA,fA,e,t);s.layers=this.layers,this.add(s);const a=new va(hA,fA,e,t);a.layers=this.layers,this.add(a);const l=new va(hA,fA,e,t);l.layers=this.layers,this.add(l);const u=new va(hA,fA,e,t);u.layers=this.layers,this.add(u);const h=new va(hA,fA,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,l,u]=t;for(const h of t)this.remove(h);if(e===Ga)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===cu)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,l,u,h,m]=this.children,v=e.getRenderTarget(),x=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),T=e.xr.enabled;e.xr.enabled=!1;const N=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,l),e.setRenderTarget(n,3,r),e.render(t,u),e.setRenderTarget(n,4,r),e.render(t,h),n.texture.generateMipmaps=N,e.setRenderTarget(n,5,r),e.render(t,m),e.setRenderTarget(v,x,S),e.xr.enabled=T,n.texture.needsPMREMUpdate=!0}}class vy extends ms{constructor(e,t,n,r,s,a,l,u,h,m){e=e!==void 0?e:[],t=t!==void 0?t:Xo,super(e,t,n,r,s,a,l,u,h,m),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class X7 extends Fh{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new vy(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:ps}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new Vh(5,5,5),s=new Qa({name:"CubemapFromEquirect",uniforms:b0(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:or,blending:$a});s.uniforms.tEquirect.value=t;const a=new Oi(r,s),l=t.minFilter;return t.minFilter===za&&(t.minFilter=ps),new $7(1,10,this).update(e,a),t.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class ZT extends pr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new aa,this.environmentIntensity=1,this.environmentRotation=new aa,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class JT{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=s_,this.updateRanges=[],this.version=0,this.uuid=nu()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Jk.getNormalMatrix(e),r=this.coplanarPoint(_3).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const vf=new ud,B2=new me;class Og{constructor(e=new jl,t=new jl,n=new jl,r=new jl,s=new jl,a=new jl){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(s),l[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ga){const n=this.planes,r=e.elements,s=r[0],a=r[1],l=r[2],u=r[3],h=r[4],m=r[5],v=r[6],x=r[7],S=r[8],T=r[9],N=r[10],C=r[11],E=r[12],O=r[13],U=r[14],I=r[15];if(n[0].setComponents(u-s,x-h,C-S,I-E).normalize(),n[1].setComponents(u+s,x+h,C+S,I+E).normalize(),n[2].setComponents(u+a,x+m,C+T,I+O).normalize(),n[3].setComponents(u-a,x-m,C-T,I-O).normalize(),n[4].setComponents(u-l,x-v,C-N,I-U).normalize(),t===Ga)n[5].setComponents(u+l,x+v,C+N,I+U).normalize();else if(t===cu)n[5].setComponents(l,v,N,U).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),vf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),vf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(vf)}intersectsSprite(e){return vf.center.set(0,0,0),vf.radius=.7071067811865476,vf.applyMatrix4(e.matrixWorld),this.intersectsSphere(vf)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,B2.y=r.normal.y>0?e.max.y:e.min.y,B2.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(B2)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class q0 extends oa{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new cn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const a_=new me,o_=new me,AN=new jn,Qp=new Ug,O2=new ud,y3=new me,pN=new me;class _y extends pr{constructor(e=new Hi,t=new q0){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sn)return;y3.applyMatrix4(i.matrixWorld);const u=e.ray.origin.distanceTo(y3);if(!(ue.far))return{distance:u,point:pN.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const mN=new me,gN=new me;class Y7 extends _y{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}let qa=class extends pr{constructor(){super(),this.isGroup=!0,this.type="Group"}};class Q7 extends ms{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=dr,this.minFilter=dr,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ic extends ms{constructor(e,t,n,r,s,a,l,u,h,m=tu){if(m!==tu&&m!==uu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&m===tu&&(n=Nr),n===void 0&&m===uu&&(n=lu),super(null,r,s,a,l,u,m,n,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:dr,this.minFilter=u!==void 0?u:dr,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Nl{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let l=0,u=s-1,h;for(;l<=u;)if(r=Math.floor(l+(u-l)/2),h=n[r]-a,h<0)l=r+1;else if(h>0)u=r-1;else{u=r;break}if(r=u,n[r]===a)return r/(s-1);const m=n[r],x=n[r+1]-m,S=(a-m)/x;return(r+S)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),l=this.getPoint(s),u=t||(a.isVector2?new bt:new me);return u.copy(l).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new me,r=[],s=[],a=[],l=new me,u=new jn;for(let S=0;S<=e;S++){const T=S/e;r[S]=this.getTangentAt(T,new me)}s[0]=new me,a[0]=new me;let h=Number.MAX_VALUE;const m=Math.abs(r[0].x),v=Math.abs(r[0].y),x=Math.abs(r[0].z);m<=h&&(h=m,n.set(1,0,0)),v<=h&&(h=v,n.set(0,1,0)),x<=h&&n.set(0,0,1),l.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],l),a[0].crossVectors(r[0],s[0]);for(let S=1;S<=e;S++){if(s[S]=s[S-1].clone(),a[S]=a[S-1].clone(),l.crossVectors(r[S-1],r[S]),l.length()>Number.EPSILON){l.normalize();const T=Math.acos(ri(r[S-1].dot(r[S]),-1,1));s[S].applyMatrix4(u.makeRotationAxis(l,T))}a[S].crossVectors(r[S],s[S])}if(t===!0){let S=Math.acos(ri(s[0].dot(s[e]),-1,1));S/=e,r[0].dot(l.crossVectors(s[0],s[e]))>0&&(S=-S);for(let T=1;T<=e;T++)s[T].applyMatrix4(u.makeRotationAxis(r[T],S*T)),a[T].crossVectors(r[T],s[T])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class tM extends Nl{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,l=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=l,this.aRotation=u}getPoint(e,t=new bt){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(l)/s)+1)*s:u===0&&l===s-1&&(l=s-2,u=1);let h,m;this.closed||l>0?h=r[(l-1)%s]:(z2.subVectors(r[0],r[1]).add(r[0]),h=z2);const v=r[l%s],x=r[(l+1)%s];if(this.closed||l+2r.length-2?r.length-1:a+1],v=r[a>r.length-3?r.length-1:a+2];return n.set(yN(l,u.x,h.x,m.x,v.x),yN(l,u.y,h.y,m.y,v.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[s]-n,l=this.curves[s],u=l.getLength(),h=u===0?0:1-a/u;return l.getPointAt(h,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const v=h.getPoint(0);v.equals(this.currentPoint)||this.lineTo(v.x,v.y)}this.curves.push(h);const m=h.getPoint(1);return this.currentPoint.copy(m),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class yy extends Hi{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],l=[],u=[],h=new me,m=new bt;a.push(0,0,0),l.push(0,0,1),u.push(.5,.5);for(let v=0,x=3;v<=t;v++,x+=3){const S=n+v/t*r;h.x=e*Math.cos(S),h.y=e*Math.sin(S),a.push(h.x,h.y,h.z),l.push(0,0,1),m.x=(a[x]/e+1)/2,m.y=(a[x+1]/e+1)/2,u.push(m.x,m.y)}for(let v=1;v<=t;v++)s.push(v,v+1,0);this.setIndex(s),this.setAttribute("position",new Si(a,3)),this.setAttribute("normal",new Si(l,3)),this.setAttribute("uv",new Si(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yy(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class iM extends Hi{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:l,thetaLength:u};const h=this;r=Math.floor(r),s=Math.floor(s);const m=[],v=[],x=[],S=[];let T=0;const N=[],C=n/2;let E=0;O(),a===!1&&(e>0&&U(!0),t>0&&U(!1)),this.setIndex(m),this.setAttribute("position",new Si(v,3)),this.setAttribute("normal",new Si(x,3)),this.setAttribute("uv",new Si(S,2));function O(){const I=new me,j=new me;let z=0;const G=(t-e)/n;for(let H=0;H<=s;H++){const q=[],V=H/s,Q=V*(t-e)+e;for(let J=0;J<=r;J++){const ne=J/r,oe=ne*u+l,ie=Math.sin(oe),Z=Math.cos(oe);j.x=Q*ie,j.y=-V*n+C,j.z=Q*Z,v.push(j.x,j.y,j.z),I.set(ie,G,Z).normalize(),x.push(I.x,I.y,I.z),S.push(ne,1-V),q.push(T++)}N.push(q)}for(let H=0;H0||q!==0)&&(m.push(V,Q,ne),z+=3),(t>0||q!==s-1)&&(m.push(Q,J,ne),z+=3)}h.addGroup(E,z,0),E+=z}function U(I){const j=T,z=new bt,G=new me;let H=0;const q=I===!0?e:t,V=I===!0?1:-1;for(let J=1;J<=r;J++)v.push(0,C*V,0),x.push(0,V,0),S.push(.5,.5),T++;const Q=T;for(let J=0;J<=r;J++){const oe=J/r*u+l,ie=Math.cos(oe),Z=Math.sin(oe);G.x=q*Z,G.y=C*V,G.z=q*ie,v.push(G.x,G.y,G.z),x.push(0,V,0),z.x=ie*.5+.5,z.y=Z*.5*V+.5,S.push(z.x,z.y),T++}for(let J=0;J80*t){l=h=i[0],u=m=i[1];for(let T=t;Th&&(h=v),x>m&&(m=x);S=Math.max(h-l,m-u),S=S!==0?32767/S:0}return rg(s,a,t,l,u,S,0),a}};function iD(i,e,t,n,r){let s,a;if(r===Cz(i,e,t,n)>0)for(s=e;s=e;s-=n)a=xN(s,i[s],i[s+1],a);return a&&xy(a,a.next)&&(ag(a),a=a.next),a}function rd(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(xy(t,t.next)||Rr(t.prev,t,t.next)===0)){if(ag(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function rg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&bz(i,n,r,s);let l=i,u,h;for(;i.prev!==i.next;){if(u=i.prev,h=i.next,s?Az(i,n,r,s):dz(i)){e.push(u.i/t|0),e.push(i.i/t|0),e.push(h.i/t|0),ag(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=pz(rd(i),e,t),rg(i,e,t,n,r,s,2)):a===2&&mz(i,e,t,n,r,s):rg(rd(i),e,t,n,r,s,1);break}}}function dz(i){const e=i.prev,t=i,n=i.next;if(Rr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=rs?r>a?r:a:s>a?s:a,S=l>u?l>h?l:h:u>h?u:h;let T=n.next;for(;T!==e;){if(T.x>=m&&T.x<=x&&T.y>=v&&T.y<=S&&FA(r,l,s,u,a,h,T.x,T.y)&&Rr(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function Az(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Rr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=lu?l>h?l:h:u>h?u:h,C=m>v?m>x?m:x:v>x?v:x,E=ZS(S,T,e,t,n),O=ZS(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&FA(l,m,u,v,h,x,U.x,U.y)&&Rr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&FA(l,m,u,v,h,x,I.x,I.y)&&Rr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&FA(l,m,u,v,h,x,U.x,U.y)&&Rr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&FA(l,m,u,v,h,x,I.x,I.y)&&Rr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function pz(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!xy(r,s)&&rD(r,n,n.next,s)&&sg(r,s)&&sg(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),ag(n),ag(n.next),n=i=s),n=n.next}while(n!==i);return rd(n)}function mz(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&Tz(a,l)){let u=sD(a,l);a=rd(a,a.next),u=rd(u,u.next),rg(a,e,t,n,r,s,0),rg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function gz(i,e,t,n){const r=[];let s,a,l,u,h;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const x=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=s&&x>n&&(n=x,r=t.x=t.x&&t.x>=u&&s!==t.x&&FA(ar.x||t.x===r.x&&xz(r,t)))&&(r=t,m=v)),t=t.next;while(t!==l);return r}function xz(i,e){return Rr(i.prev,i,e.prev)<0&&Rr(e.next,i,i.next)<0}function bz(i,e,t,n){let r=i;do r.z===0&&(r.z=ZS(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Sz(r)}function Sz(i){let e,t,n,r,s,a,l,u,h=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,l=0,e=0;e0||u>0&&n;)l!==0&&(u===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,l--):(r=n,n=n.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,h*=2}while(a>1);return i}function ZS(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function wz(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function Tz(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Mz(i,e)&&(sg(i,e)&&sg(e,i)&&Ez(i,e)&&(Rr(i.prev,i,e.prev)||Rr(i,e.prev,e))||xy(i,e)&&Rr(i.prev,i,i.next)>0&&Rr(e.prev,e,e.next)>0)}function Rr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function xy(i,e){return i.x===e.x&&i.y===e.y}function rD(i,e,t,n){const r=q2(Rr(i,e,t)),s=q2(Rr(i,e,n)),a=q2(Rr(t,n,i)),l=q2(Rr(t,n,e));return!!(r!==s&&a!==l||r===0&&G2(i,t,e)||s===0&&G2(i,n,e)||a===0&&G2(t,i,n)||l===0&&G2(t,e,n))}function G2(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function q2(i){return i>0?1:i<0?-1:0}function Mz(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&rD(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function sg(i,e){return Rr(i.prev,i,i.next)<0?Rr(i,e,i.next)>=0&&Rr(i,i.prev,e)>=0:Rr(i,e,i.prev)<0||Rr(i,i.next,e)<0}function Ez(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function sD(i,e){const t=new JS(i.i,i.x,i.y),n=new JS(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function xN(i,e,t,n){const r=new JS(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ag(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function JS(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Cz(i,e,t,n){let r=0;for(let s=e,a=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function SN(i,e){for(let t=0;tNumber.EPSILON){const Oe=Math.sqrt(k),pe=Math.sqrt(pt*pt+Ae*Ae),le=ft.x-Xt/Oe,Ne=ft.y+_t/Oe,De=fe.x-Ae/pe,Je=fe.y+pt/pe,we=((De-le)*Ae-(Je-Ne)*pt)/(_t*Ae-Xt*pt);Wt=le+_t*we-We.x,yt=Ne+Xt*we-We.y;const Ue=Wt*Wt+yt*yt;if(Ue<=2)return new bt(Wt,yt);Gt=Math.sqrt(Ue/2)}else{let Oe=!1;_t>Number.EPSILON?pt>Number.EPSILON&&(Oe=!0):_t<-Number.EPSILON?pt<-Number.EPSILON&&(Oe=!0):Math.sign(Xt)===Math.sign(Ae)&&(Oe=!0),Oe?(Wt=-Xt,yt=_t,Gt=Math.sqrt(k)):(Wt=_t,yt=Xt,Gt=Math.sqrt(k/2))}return new bt(Wt/Gt,yt/Gt)}const Se=[];for(let We=0,ft=oe.length,fe=ft-1,Wt=We+1;We=0;We--){const ft=We/C,fe=S*Math.cos(ft*Math.PI/2),Wt=T*Math.sin(ft*Math.PI/2)+N;for(let yt=0,Gt=oe.length;yt=0;){const Wt=fe;let yt=fe-1;yt<0&&(yt=We.length-1);for(let Gt=0,_t=m+C*2;Gt<_t;Gt++){const Xt=Z*Gt,pt=Z*(Gt+1),Ae=ft+Wt+Xt,k=ft+yt+Xt,be=ft+yt+pt,Oe=ft+Wt+pt;Et(Ae,k,be,Oe)}}}function He(We,ft,fe){u.push(We),u.push(ft),u.push(fe)}function Rt(We,ft,fe){zt(We),zt(ft),zt(fe);const Wt=r.length/3,yt=O.generateTopUV(n,r,Wt-3,Wt-2,Wt-1);Pt(yt[0]),Pt(yt[1]),Pt(yt[2])}function Et(We,ft,fe,Wt){zt(We),zt(ft),zt(Wt),zt(ft),zt(fe),zt(Wt);const yt=r.length/3,Gt=O.generateSideWallUV(n,r,yt-6,yt-3,yt-2,yt-1);Pt(Gt[0]),Pt(Gt[1]),Pt(Gt[3]),Pt(Gt[1]),Pt(Gt[2]),Pt(Gt[3])}function zt(We){r.push(u[We*3+0]),r.push(u[We*3+1]),r.push(u[We*3+2])}function Pt(We){s.push(We.x),s.push(We.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return Rz(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s0)&&S.push(U,I,z),(E!==n-1||u0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class oD extends oa{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new cn(16777215),this.specular=new cn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Uz extends oa{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new cn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Bz extends oa{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Fc extends oa{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new cn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Oz extends oa{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=QF,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Iz extends oa{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Fz extends oa{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new cn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class kz extends q0{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const TN={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class zz{constructor(e,t,n){const r=this;let s=!1,a=0,l=0,u;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(m){l++,s===!1&&r.onStart!==void 0&&r.onStart(m,a,l),s=!0},this.itemEnd=function(m){a++,r.onProgress!==void 0&&r.onProgress(m,a,l),a===l&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(m){r.onError!==void 0&&r.onError(m)},this.resolveURL=function(m){return u?u(m):m},this.setURLModifier=function(m){return u=m,this},this.addHandler=function(m,v){return h.push(m,v),this},this.removeHandler=function(m){const v=h.indexOf(m);return v!==-1&&h.splice(v,2),this},this.getHandler=function(m){for(let v=0,x=h.length;vNumber.EPSILON){if(V<0&&(G=O[z],q=-q,H=O[j],V=-V),E.yH.y)continue;if(E.y===G.y){if(E.x===G.x)return!0}else{const Q=V*(E.x-G.x)-q*(E.y-G.y);if(Q===0)return!0;if(Q<0)continue;I=!I}}else{if(E.y!==G.y)continue;if(H.x<=E.x&&E.x<=G.x||G.x<=E.x&&E.x<=H.x)return!0}}return I}const r=QA.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,l,u;const h=[];if(s.length===1)return l=s[0],u=new kv,u.curves=l.curves,h.push(u),h;let m=!r(s[0].getPoints());m=e?!m:m;const v=[],x=[];let S=[],T=0,N;x[T]=void 0,S[T]=[];for(let E=0,O=s.length;E1){let E=!1,O=0;for(let U=0,I=x.length;U0&&E===!1&&(S=v)}let C;for(let E=0,O=x.length;ES.start-T.start);let x=0;for(let S=1;S 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,yG=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,xG=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,bG=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,SG=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,wG=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,TG=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec3 vColor; +#endif`,MG=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif +#ifdef USE_BATCHING_COLOR + vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); + vColor.xyz *= batchingColor.xyz; +#endif`,EG=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,CG=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,NG=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,RG=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,DG=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,PG=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,LG=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,UG="gl_FragColor = linearToOutputTexel( gl_FragColor );",BG=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,OG=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,IG=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,FG=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,kG=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,zG=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,GG=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,qG=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,VG=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,jG=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,HG=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,WG=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,$G=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,XG=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,YG=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,QG=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,KG=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,ZG=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,JG=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,eq=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,tq=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,nq=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,iq=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,rq=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,sq=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,aq=`#if defined( USE_LOGDEPTHBUF ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,oq=`#if defined( USE_LOGDEPTHBUF ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,lq=`#ifdef USE_LOGDEPTHBUF + varying float vFragDepth; + varying float vIsPerspective; +#endif`,uq=`#ifdef USE_LOGDEPTHBUF + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,cq=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,hq=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,fq=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,dq=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,Aq=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,pq=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,mq=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,gq=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,vq=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,_q=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,yq=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,xq=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,bq=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,Sq=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,wq=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,Tq=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,Mq=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,Eq=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,Cq=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,Nq=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,Rq=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,Dq=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Pq=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,Lq=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,Uq=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,Bq=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Oq=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,Iq=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,Fq=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,kq=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + + float lightToPositionLength = length( lightToPosition ); + if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { + float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + shadow = ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } +#endif`,zq=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,Gq=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,qq=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,Vq=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,jq=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,Hq=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,Wq=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,$q=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,Xq=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Yq=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Qq=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,Kq=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Zq=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Jq=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,eV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,tV=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,nV=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const iV=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,rV=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,sV=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,aV=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,oV=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,lV=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,uV=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,cV=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,hV=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,fV=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,dV=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,AV=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,pV=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,mV=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,gV=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,vV=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,_V=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,yV=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,xV=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,bV=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,SV=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,wV=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,TV=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,MV=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,EV=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,CV=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,NV=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,RV=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,DV=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,PV=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,LV=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,UV=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,BV=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,OV=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,ei={alphahash_fragment:rG,alphahash_pars_fragment:sG,alphamap_fragment:aG,alphamap_pars_fragment:oG,alphatest_fragment:lG,alphatest_pars_fragment:uG,aomap_fragment:cG,aomap_pars_fragment:hG,batching_pars_vertex:fG,batching_vertex:dG,begin_vertex:AG,beginnormal_vertex:pG,bsdfs:mG,iridescence_fragment:gG,bumpmap_pars_fragment:vG,clipping_planes_fragment:_G,clipping_planes_pars_fragment:yG,clipping_planes_pars_vertex:xG,clipping_planes_vertex:bG,color_fragment:SG,color_pars_fragment:wG,color_pars_vertex:TG,color_vertex:MG,common:EG,cube_uv_reflection_fragment:CG,defaultnormal_vertex:NG,displacementmap_pars_vertex:RG,displacementmap_vertex:DG,emissivemap_fragment:PG,emissivemap_pars_fragment:LG,colorspace_fragment:UG,colorspace_pars_fragment:BG,envmap_fragment:OG,envmap_common_pars_fragment:IG,envmap_pars_fragment:FG,envmap_pars_vertex:kG,envmap_physical_pars_fragment:QG,envmap_vertex:zG,fog_vertex:GG,fog_pars_vertex:qG,fog_fragment:VG,fog_pars_fragment:jG,gradientmap_pars_fragment:HG,lightmap_pars_fragment:WG,lights_lambert_fragment:$G,lights_lambert_pars_fragment:XG,lights_pars_begin:YG,lights_toon_fragment:KG,lights_toon_pars_fragment:ZG,lights_phong_fragment:JG,lights_phong_pars_fragment:eq,lights_physical_fragment:tq,lights_physical_pars_fragment:nq,lights_fragment_begin:iq,lights_fragment_maps:rq,lights_fragment_end:sq,logdepthbuf_fragment:aq,logdepthbuf_pars_fragment:oq,logdepthbuf_pars_vertex:lq,logdepthbuf_vertex:uq,map_fragment:cq,map_pars_fragment:hq,map_particle_fragment:fq,map_particle_pars_fragment:dq,metalnessmap_fragment:Aq,metalnessmap_pars_fragment:pq,morphinstance_vertex:mq,morphcolor_vertex:gq,morphnormal_vertex:vq,morphtarget_pars_vertex:_q,morphtarget_vertex:yq,normal_fragment_begin:xq,normal_fragment_maps:bq,normal_pars_fragment:Sq,normal_pars_vertex:wq,normal_vertex:Tq,normalmap_pars_fragment:Mq,clearcoat_normal_fragment_begin:Eq,clearcoat_normal_fragment_maps:Cq,clearcoat_pars_fragment:Nq,iridescence_pars_fragment:Rq,opaque_fragment:Dq,packing:Pq,premultiplied_alpha_fragment:Lq,project_vertex:Uq,dithering_fragment:Bq,dithering_pars_fragment:Oq,roughnessmap_fragment:Iq,roughnessmap_pars_fragment:Fq,shadowmap_pars_fragment:kq,shadowmap_pars_vertex:zq,shadowmap_vertex:Gq,shadowmask_pars_fragment:qq,skinbase_vertex:Vq,skinning_pars_vertex:jq,skinning_vertex:Hq,skinnormal_vertex:Wq,specularmap_fragment:$q,specularmap_pars_fragment:Xq,tonemapping_fragment:Yq,tonemapping_pars_fragment:Qq,transmission_fragment:Kq,transmission_pars_fragment:Zq,uv_pars_fragment:Jq,uv_pars_vertex:eV,uv_vertex:tV,worldpos_vertex:nV,background_vert:iV,background_frag:rV,backgroundCube_vert:sV,backgroundCube_frag:aV,cube_vert:oV,cube_frag:lV,depth_vert:uV,depth_frag:cV,distanceRGBA_vert:hV,distanceRGBA_frag:fV,equirect_vert:dV,equirect_frag:AV,linedashed_vert:pV,linedashed_frag:mV,meshbasic_vert:gV,meshbasic_frag:vV,meshlambert_vert:_V,meshlambert_frag:yV,meshmatcap_vert:xV,meshmatcap_frag:bV,meshnormal_vert:SV,meshnormal_frag:wV,meshphong_vert:TV,meshphong_frag:MV,meshphysical_vert:EV,meshphysical_frag:CV,meshtoon_vert:NV,meshtoon_frag:RV,points_vert:DV,points_frag:PV,shadow_vert:LV,shadow_frag:UV,sprite_vert:BV,sprite_frag:OV},nn={common:{diffuse:{value:new cn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xn},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xn}},envmap:{envMap:{value:null},envMapRotation:{value:new Xn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xn},normalScale:{value:new bt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new cn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new cn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0},uvTransform:{value:new Xn}},sprite:{diffuse:{value:new cn(16777215)},opacity:{value:1},center:{value:new bt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xn},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0}}},Fa={basic:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.fog]),vertexShader:ei.meshbasic_vert,fragmentShader:ei.meshbasic_frag},lambert:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,nn.lights,{emissive:{value:new cn(0)}}]),vertexShader:ei.meshlambert_vert,fragmentShader:ei.meshlambert_frag},phong:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,nn.lights,{emissive:{value:new cn(0)},specular:{value:new cn(1118481)},shininess:{value:30}}]),vertexShader:ei.meshphong_vert,fragmentShader:ei.meshphong_frag},standard:{uniforms:ga([nn.common,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.roughnessmap,nn.metalnessmap,nn.fog,nn.lights,{emissive:{value:new cn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ei.meshphysical_vert,fragmentShader:ei.meshphysical_frag},toon:{uniforms:ga([nn.common,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.gradientmap,nn.fog,nn.lights,{emissive:{value:new cn(0)}}]),vertexShader:ei.meshtoon_vert,fragmentShader:ei.meshtoon_frag},matcap:{uniforms:ga([nn.common,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,{matcap:{value:null}}]),vertexShader:ei.meshmatcap_vert,fragmentShader:ei.meshmatcap_frag},points:{uniforms:ga([nn.points,nn.fog]),vertexShader:ei.points_vert,fragmentShader:ei.points_frag},dashed:{uniforms:ga([nn.common,nn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ei.linedashed_vert,fragmentShader:ei.linedashed_frag},depth:{uniforms:ga([nn.common,nn.displacementmap]),vertexShader:ei.depth_vert,fragmentShader:ei.depth_frag},normal:{uniforms:ga([nn.common,nn.bumpmap,nn.normalmap,nn.displacementmap,{opacity:{value:1}}]),vertexShader:ei.meshnormal_vert,fragmentShader:ei.meshnormal_frag},sprite:{uniforms:ga([nn.sprite,nn.fog]),vertexShader:ei.sprite_vert,fragmentShader:ei.sprite_frag},background:{uniforms:{uvTransform:{value:new Xn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ei.background_vert,fragmentShader:ei.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xn}},vertexShader:ei.backgroundCube_vert,fragmentShader:ei.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ei.cube_vert,fragmentShader:ei.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ei.equirect_vert,fragmentShader:ei.equirect_frag},distanceRGBA:{uniforms:ga([nn.common,nn.displacementmap,{referencePosition:{value:new me},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ei.distanceRGBA_vert,fragmentShader:ei.distanceRGBA_frag},shadow:{uniforms:ga([nn.lights,nn.fog,{color:{value:new cn(0)},opacity:{value:1}}]),vertexShader:ei.shadow_vert,fragmentShader:ei.shadow_frag}};Fa.physical={uniforms:ga([Fa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xn},clearcoatNormalScale:{value:new bt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xn},sheen:{value:0},sheenColor:{value:new cn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xn},transmissionSamplerSize:{value:new bt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xn},attenuationDistance:{value:0},attenuationColor:{value:new cn(0)},specularColor:{value:new cn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xn},anisotropyVector:{value:new bt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xn}}]),vertexShader:ei.meshphysical_vert,fragmentShader:ei.meshphysical_frag};const j2={r:0,b:0,g:0},_f=new aa,IV=new jn;function FV(i,e,t,n,r,s,a){const l=new cn(0);let u=s===!0?0:1,h,m,v=null,x=0,S=null;function T(U){let I=U.isScene===!0?U.background:null;return I&&I.isTexture&&(I=(U.backgroundBlurriness>0?t:e).get(I)),I}function N(U){let I=!1;const j=T(U);j===null?E(l,u):j&&j.isColor&&(E(j,1),I=!0);const z=i.xr.getEnvironmentBlendMode();z==="additive"?n.buffers.color.setClear(0,0,0,1,a):z==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function C(U,I){const j=T(I);j&&(j.isCubeTexture||j.mapping===ed)?(m===void 0&&(m=new Oi(new Vh(1,1,1),new Qa({name:"BackgroundCubeMaterial",uniforms:b0(Fa.backgroundCube.uniforms),vertexShader:Fa.backgroundCube.vertexShader,fragmentShader:Fa.backgroundCube.fragmentShader,side:or,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(z,G,H){this.matrixWorld.copyPosition(H.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(m)),_f.copy(I.backgroundRotation),_f.x*=-1,_f.y*=-1,_f.z*=-1,j.isCubeTexture&&j.isRenderTargetTexture===!1&&(_f.y*=-1,_f.z*=-1),m.material.uniforms.envMap.value=j,m.material.uniforms.flipEnvMap.value=j.isCubeTexture&&j.isRenderTargetTexture===!1?-1:1,m.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,m.material.uniforms.backgroundRotation.value.setFromMatrix4(IV.makeRotationFromEuler(_f)),m.material.toneMapped=li.getTransfer(j.colorSpace)!==Fi,(v!==j||x!==j.version||S!==i.toneMapping)&&(m.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),m.layers.enableAll(),U.unshift(m,m.geometry,m.material,0,0,null)):j&&j.isTexture&&(h===void 0&&(h=new Oi(new by(2,2),new Qa({name:"BackgroundMaterial",uniforms:b0(Fa.background.uniforms),vertexShader:Fa.background.vertexShader,fragmentShader:Fa.background.fragmentShader,side:El,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=j,h.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,h.material.toneMapped=li.getTransfer(j.colorSpace)!==Fi,j.matrixAutoUpdate===!0&&j.updateMatrix(),h.material.uniforms.uvTransform.value.copy(j.matrix),(v!==j||x!==j.version||S!==i.toneMapping)&&(h.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),h.layers.enableAll(),U.unshift(h,h.geometry,h.material,0,0,null))}function E(U,I){U.getRGB(j2,W7(i)),n.buffers.color.setClear(j2.r,j2.g,j2.b,I,a)}function O(){m!==void 0&&(m.geometry.dispose(),m.material.dispose()),h!==void 0&&(h.geometry.dispose(),h.material.dispose())}return{getClearColor:function(){return l},setClearColor:function(U,I=1){l.set(U),u=I,E(l,u)},getClearAlpha:function(){return u},setClearAlpha:function(U){u=U,E(l,u)},render:N,addToRenderList:C,dispose:O}}function kV(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=x(null);let s=r,a=!1;function l(V,Q,J,ne,oe){let ie=!1;const Z=v(ne,J,Q);s!==Z&&(s=Z,h(s.object)),ie=S(V,ne,J,oe),ie&&T(V,ne,J,oe),oe!==null&&e.update(oe,i.ELEMENT_ARRAY_BUFFER),(ie||a)&&(a=!1,I(V,Q,J,ne),oe!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(oe).buffer))}function u(){return i.createVertexArray()}function h(V){return i.bindVertexArray(V)}function m(V){return i.deleteVertexArray(V)}function v(V,Q,J){const ne=J.wireframe===!0;let oe=n[V.id];oe===void 0&&(oe={},n[V.id]=oe);let ie=oe[Q.id];ie===void 0&&(ie={},oe[Q.id]=ie);let Z=ie[ne];return Z===void 0&&(Z=x(u()),ie[ne]=Z),Z}function x(V){const Q=[],J=[],ne=[];for(let oe=0;oe=0){const Te=oe[de];let ae=ie[de];if(ae===void 0&&(de==="instanceMatrix"&&V.instanceMatrix&&(ae=V.instanceMatrix),de==="instanceColor"&&V.instanceColor&&(ae=V.instanceColor)),Te===void 0||Te.attribute!==ae||ae&&Te.data!==ae.data)return!0;Z++}return s.attributesNum!==Z||s.index!==ne}function T(V,Q,J,ne){const oe={},ie=Q.attributes;let Z=0;const te=J.getAttributes();for(const de in te)if(te[de].location>=0){let Te=ie[de];Te===void 0&&(de==="instanceMatrix"&&V.instanceMatrix&&(Te=V.instanceMatrix),de==="instanceColor"&&V.instanceColor&&(Te=V.instanceColor));const ae={};ae.attribute=Te,Te&&Te.data&&(ae.data=Te.data),oe[de]=ae,Z++}s.attributes=oe,s.attributesNum=Z,s.index=ne}function N(){const V=s.newAttributes;for(let Q=0,J=V.length;Q=0){let Se=oe[te];if(Se===void 0&&(te==="instanceMatrix"&&V.instanceMatrix&&(Se=V.instanceMatrix),te==="instanceColor"&&V.instanceColor&&(Se=V.instanceColor)),Se!==void 0){const Te=Se.normalized,ae=Se.itemSize,Me=e.get(Se);if(Me===void 0)continue;const Ve=Me.buffer,Ce=Me.type,Fe=Me.bytesPerElement,et=Ce===i.INT||Ce===i.UNSIGNED_INT||Se.gpuType===Ns;if(Se.isInterleavedBufferAttribute){const He=Se.data,Rt=He.stride,Et=Se.offset;if(He.isInstancedInterleavedBuffer){for(let zt=0;zt0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";G="mediump"}return G==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const m=u(h);m!==h&&(console.warn("THREE.WebGLRenderer:",h,"not supported, using",m,"instead."),h=m);const v=t.logarithmicDepthBuffer===!0,x=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),S=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),T=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),N=i.getParameter(i.MAX_TEXTURE_SIZE),C=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),E=i.getParameter(i.MAX_VERTEX_ATTRIBS),O=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),U=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),j=T>0,z=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:l,precision:h,logarithmicDepthBuffer:v,reverseDepthBuffer:x,maxTextures:S,maxVertexTextures:T,maxTextureSize:N,maxCubemapSize:C,maxAttributes:E,maxVertexUniforms:O,maxVaryings:U,maxFragmentUniforms:I,vertexTextures:j,maxSamples:z}}function qV(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new jl,l=new Xn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(v,x){const S=v.length!==0||x||n!==0||r;return r=x,n=v.length,S},this.beginShadows=function(){s=!0,m(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(v,x){t=m(v,x,0)},this.setState=function(v,x,S){const T=v.clippingPlanes,N=v.clipIntersection,C=v.clipShadows,E=i.get(v);if(!r||T===null||T.length===0||s&&!C)s?m(null):h();else{const O=s?0:n,U=O*4;let I=E.clippingState||null;u.value=I,I=m(T,x,U,S);for(let j=0;j!==U;++j)I[j]=t[j];E.clippingState=I,this.numIntersection=N?this.numPlanes:0,this.numPlanes+=O}};function h(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function m(v,x,S,T){const N=v!==null?v.length:0;let C=null;if(N!==0){if(C=u.value,T!==!0||C===null){const E=S+N*4,O=x.matrixWorldInverse;l.getNormalMatrix(O),(C===null||C.length0){const h=new X7(u.height);return h.fromEquirectangularTexture(i,a),e.set(a,h),a.addEventListener("dispose",r),t(h.texture,a.mapping)}else return null}}return a}function r(a){const l=a.target;l.removeEventListener("dispose",r);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const kA=4,BN=[.125,.215,.35,.446,.526,.582],Bf=20,M3=new Ig,ON=new cn;let E3=null,C3=0,N3=0,R3=!1;const Rf=(1+Math.sqrt(5))/2,dA=1/Rf,IN=[new me(-Rf,dA,0),new me(Rf,dA,0),new me(-dA,0,Rf),new me(dA,0,Rf),new me(0,Rf,-dA),new me(0,Rf,dA),new me(-1,1,-1),new me(1,1,-1),new me(-1,1,1),new me(1,1,1)];let FN=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){E3=this._renderer.getRenderTarget(),C3=this._renderer.getActiveCubeFace(),N3=this._renderer.getActiveMipmapLevel(),R3=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=GN(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zN(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?U:0,U,U),m.setRenderTarget(r),N&&m.render(T,l),m.render(e,l)}T.geometry.dispose(),T.material.dispose(),m.toneMapping=x,m.autoClear=v,e.background=C}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Xo||e.mapping===Yo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=GN()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zN());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new Oi(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const u=this._cubeSize;H2(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,M3)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sBf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Bf}`);const E=[];let O=0;for(let G=0;GU-kA?r-U+kA:0),z=4*(this._cubeSize-I);H2(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,M3)}};function jV(i){const e=[],t=[],n=[];let r=i;const s=i-kA+1+BN.length;for(let a=0;ai-kA?u=BN[a-i+kA-1]:a===0&&(u=0),n.push(u);const h=1/(l-2),m=-h,v=1+h,x=[m,m,v,m,v,v,m,m,v,v,m,v],S=6,T=6,N=3,C=2,E=1,O=new Float32Array(N*T*S),U=new Float32Array(C*T*S),I=new Float32Array(E*T*S);for(let z=0;z2?0:-1,q=[G,H,0,G+2/3,H,0,G+2/3,H+1,0,G,H,0,G+2/3,H+1,0,G,H+1,0];O.set(q,N*T*z),U.set(x,C*T*z);const V=[z,z,z,z,z,z];I.set(V,E*T*z)}const j=new Hi;j.setAttribute("position",new wr(O,N)),j.setAttribute("uv",new wr(U,C)),j.setAttribute("faceIndex",new wr(I,E)),e.push(j),r>kA&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function kN(i,e,t){const n=new Fh(i,e,t);return n.texture.mapping=ed,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function H2(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function HV(i,e,t){const n=new Float32Array(Bf),r=new me(0,1,0);return new Qa({name:"SphericalGaussianBlur",defines:{n:Bf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:cM(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:$a,depthTest:!1,depthWrite:!1})}function zN(){return new Qa({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:cM(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:$a,depthTest:!1,depthWrite:!1})}function GN(){return new Qa({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:cM(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:$a,depthTest:!1,depthWrite:!1})}function cM(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function WV(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const u=l.mapping,h=u===Oh||u===Ih,m=u===Xo||u===Yo;if(h||m){let v=e.get(l);const x=v!==void 0?v.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==x)return t===null&&(t=new FN(i)),v=h?t.fromEquirectangular(l,v):t.fromCubemap(l,v),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),v.texture;if(v!==void 0)return v.texture;{const S=l.image;return h&&S&&S.height>0||m&&S&&r(S)?(t===null&&(t=new FN(i)),v=h?t.fromEquirectangular(l):t.fromCubemap(l),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),l.addEventListener("dispose",s),v.texture):null}}}return l}function r(l){let u=0;const h=6;for(let m=0;me.maxTextureSize&&(z=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const G=new Float32Array(j*z*4*v),H=new XT(G,j,z,v);H.type=$r,H.needsUpdate=!0;const q=I*4;for(let Q=0;Q0)return i;const r=e*t;let s=VN[r];if(s===void 0&&(s=new Float32Array(r),VN[r]=s),e!==0){n.toArray(s,0);for(let a=1,l=0;a!==e;++a)l+=t,i[a].toArray(s,l)}return s}function gs(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t":" "} ${l}: ${t[a]}`)}return n.join(` +`)}const QN=new Xn;function Wj(i){li._getMatrix(QN,li.workingColorSpace,i);const e=`mat3( ${QN.elements.map(t=>t.toFixed(4))} )`;switch(li.getTransfer(i)){case r_:return[e,"LinearTransferOETF"];case Fi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function KN(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+` + +`+r+` + +`+Hj(i.getShaderSource(e),a)}else return r}function $j(i,e){const t=Wj(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}function Xj(i,e){let t;switch(e){case U7:t="Linear";break;case B7:t="Reinhard";break;case O7:t="Cineon";break;case I7:t="ACESFilmic";break;case F7:t="AgX";break;case k7:t="Neutral";break;case HF:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const W2=new me;function Yj(){li.getLuminanceCoefficients(W2);const i=W2.x.toFixed(4),e=W2.y.toFixed(4),t=W2.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Qj(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(gm).join(` +`)}function Kj(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` +`)}function Zj(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function tw(i){return i.replace(Jj,tH)}const eH=new Map;function tH(i,e){let t=ei[e];if(t===void 0){const n=eH.get(e);if(n!==void 0)t=ei[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return tw(t)}const nH=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function e5(i){return i.replace(nH,iH)}function iH(i,e,t,n){let r="";for(let s=parseInt(e);s0&&(C+=` +`),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(gm).join(` +`),E.length>0&&(E+=` +`)):(C=[t5(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+m:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(gm).join(` +`),E=[t5(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+m:"",t.envMap?"#define "+v:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ya?"#define TONE_MAPPING":"",t.toneMapping!==Ya?ei.tonemapping_pars_fragment:"",t.toneMapping!==Ya?Xj("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ei.colorspace_pars_fragment,$j("linearToOutputTexel",t.outputColorSpace),Yj(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(gm).join(` +`)),a=tw(a),a=ZN(a,t),a=JN(a,t),l=tw(l),l=ZN(l,t),l=JN(l,t),a=e5(a),l=e5(l),t.isRawShaderMaterial!==!0&&(O=`#version 300 es +`,C=[S,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+C,E=["#define varying in",t.glslVersion===Y8?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Y8?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+E);const U=O+C+a,I=O+E+l,j=YN(r,r.VERTEX_SHADER,U),z=YN(r,r.FRAGMENT_SHADER,I);r.attachShader(N,j),r.attachShader(N,z),t.index0AttributeName!==void 0?r.bindAttribLocation(N,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(N,0,"position"),r.linkProgram(N);function G(Q){if(i.debug.checkShaderErrors){const J=r.getProgramInfoLog(N).trim(),ne=r.getShaderInfoLog(j).trim(),oe=r.getShaderInfoLog(z).trim();let ie=!0,Z=!0;if(r.getProgramParameter(N,r.LINK_STATUS)===!1)if(ie=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,N,j,z);else{const te=KN(r,j,"vertex"),de=KN(r,z,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(N,r.VALIDATE_STATUS)+` + +Material Name: `+Q.name+` +Material Type: `+Q.type+` + +Program Info Log: `+J+` +`+te+` +`+de)}else J!==""?console.warn("THREE.WebGLProgram: Program Info Log:",J):(ne===""||oe==="")&&(Z=!1);Z&&(Q.diagnostics={runnable:ie,programLog:J,vertexShader:{log:ne,prefix:C},fragmentShader:{log:oe,prefix:E}})}r.deleteShader(j),r.deleteShader(z),H=new zv(r,N),q=Zj(r,N)}let H;this.getUniforms=function(){return H===void 0&&G(this),H};let q;this.getAttributes=function(){return q===void 0&&G(this),q};let V=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return V===!1&&(V=r.getProgramParameter(N,Vj)),V},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(N),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=jj++,this.cacheKey=e,this.usedTimes=1,this.program=N,this.vertexShader=j,this.fragmentShader=z,this}let cH=0;class hH{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new fH(e),t.set(e,n)),n}}class fH{constructor(e){this.id=cH++,this.code=e,this.usedTimes=0}}function dH(i,e,t,n,r,s,a){const l=new YT,u=new hH,h=new Set,m=[],v=r.logarithmicDepthBuffer,x=r.vertexTextures;let S=r.precision;const T={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function N(q){return h.add(q),q===0?"uv":`uv${q}`}function C(q,V,Q,J,ne){const oe=J.fog,ie=ne.geometry,Z=q.isMeshStandardMaterial?J.environment:null,te=(q.isMeshStandardMaterial?t:e).get(q.envMap||Z),de=te&&te.mapping===ed?te.image.height:null,Se=T[q.type];q.precision!==null&&(S=r.getMaxPrecision(q.precision),S!==q.precision&&console.warn("THREE.WebGLProgram.getParameters:",q.precision,"not supported, using",S,"instead."));const Te=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,ae=Te!==void 0?Te.length:0;let Me=0;ie.morphAttributes.position!==void 0&&(Me=1),ie.morphAttributes.normal!==void 0&&(Me=2),ie.morphAttributes.color!==void 0&&(Me=3);let Ve,Ce,Fe,et;if(Se){const Kt=Fa[Se];Ve=Kt.vertexShader,Ce=Kt.fragmentShader}else Ve=q.vertexShader,Ce=q.fragmentShader,u.update(q),Fe=u.getVertexShaderID(q),et=u.getFragmentShaderID(q);const He=i.getRenderTarget(),Rt=i.state.buffers.depth.getReversed(),Et=ne.isInstancedMesh===!0,zt=ne.isBatchedMesh===!0,Pt=!!q.map,We=!!q.matcap,ft=!!te,fe=!!q.aoMap,Wt=!!q.lightMap,yt=!!q.bumpMap,Gt=!!q.normalMap,_t=!!q.displacementMap,Xt=!!q.emissiveMap,pt=!!q.metalnessMap,Ae=!!q.roughnessMap,k=q.anisotropy>0,be=q.clearcoat>0,Oe=q.dispersion>0,pe=q.iridescence>0,le=q.sheen>0,Ne=q.transmission>0,De=k&&!!q.anisotropyMap,Je=be&&!!q.clearcoatMap,we=be&&!!q.clearcoatNormalMap,Ue=be&&!!q.clearcoatRoughnessMap,ut=pe&&!!q.iridescenceMap,Dt=pe&&!!q.iridescenceThicknessMap,Bt=le&&!!q.sheenColorMap,ct=le&&!!q.sheenRoughnessMap,jt=!!q.specularMap,Jt=!!q.specularColorMap,In=!!q.specularIntensityMap,ge=Ne&&!!q.transmissionMap,Ot=Ne&&!!q.thicknessMap,ot=!!q.gradientMap,Tt=!!q.alphaMap,Ht=q.alphaTest>0,Yt=!!q.alphaHash,pn=!!q.extensions;let $e=Ya;q.toneMapped&&(He===null||He.isXRRenderTarget===!0)&&($e=i.toneMapping);const St={shaderID:Se,shaderType:q.type,shaderName:q.name,vertexShader:Ve,fragmentShader:Ce,defines:q.defines,customVertexShaderID:Fe,customFragmentShaderID:et,isRawShaderMaterial:q.isRawShaderMaterial===!0,glslVersion:q.glslVersion,precision:S,batching:zt,batchingColor:zt&&ne._colorsTexture!==null,instancing:Et,instancingColor:Et&&ne.instanceColor!==null,instancingMorph:Et&&ne.morphTexture!==null,supportsVertexTextures:x,outputColorSpace:He===null?i.outputColorSpace:He.isXRRenderTarget===!0?He.texture.colorSpace:Mo,alphaToCoverage:!!q.alphaToCoverage,map:Pt,matcap:We,envMap:ft,envMapMode:ft&&te.mapping,envMapCubeUVHeight:de,aoMap:fe,lightMap:Wt,bumpMap:yt,normalMap:Gt,displacementMap:x&&_t,emissiveMap:Xt,normalMapObjectSpace:Gt&&q.normalMapType===z7,normalMapTangentSpace:Gt&&q.normalMapType===Mc,metalnessMap:pt,roughnessMap:Ae,anisotropy:k,anisotropyMap:De,clearcoat:be,clearcoatMap:Je,clearcoatNormalMap:we,clearcoatRoughnessMap:Ue,dispersion:Oe,iridescence:pe,iridescenceMap:ut,iridescenceThicknessMap:Dt,sheen:le,sheenColorMap:Bt,sheenRoughnessMap:ct,specularMap:jt,specularColorMap:Jt,specularIntensityMap:In,transmission:Ne,transmissionMap:ge,thicknessMap:Ot,gradientMap:ot,opaque:q.transparent===!1&&q.blending===Xa&&q.alphaToCoverage===!1,alphaMap:Tt,alphaTest:Ht,alphaHash:Yt,combine:q.combine,mapUv:Pt&&N(q.map.channel),aoMapUv:fe&&N(q.aoMap.channel),lightMapUv:Wt&&N(q.lightMap.channel),bumpMapUv:yt&&N(q.bumpMap.channel),normalMapUv:Gt&&N(q.normalMap.channel),displacementMapUv:_t&&N(q.displacementMap.channel),emissiveMapUv:Xt&&N(q.emissiveMap.channel),metalnessMapUv:pt&&N(q.metalnessMap.channel),roughnessMapUv:Ae&&N(q.roughnessMap.channel),anisotropyMapUv:De&&N(q.anisotropyMap.channel),clearcoatMapUv:Je&&N(q.clearcoatMap.channel),clearcoatNormalMapUv:we&&N(q.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ue&&N(q.clearcoatRoughnessMap.channel),iridescenceMapUv:ut&&N(q.iridescenceMap.channel),iridescenceThicknessMapUv:Dt&&N(q.iridescenceThicknessMap.channel),sheenColorMapUv:Bt&&N(q.sheenColorMap.channel),sheenRoughnessMapUv:ct&&N(q.sheenRoughnessMap.channel),specularMapUv:jt&&N(q.specularMap.channel),specularColorMapUv:Jt&&N(q.specularColorMap.channel),specularIntensityMapUv:In&&N(q.specularIntensityMap.channel),transmissionMapUv:ge&&N(q.transmissionMap.channel),thicknessMapUv:Ot&&N(q.thicknessMap.channel),alphaMapUv:Tt&&N(q.alphaMap.channel),vertexTangents:!!ie.attributes.tangent&&(Gt||k),vertexColors:q.vertexColors,vertexAlphas:q.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,pointsUvs:ne.isPoints===!0&&!!ie.attributes.uv&&(Pt||Tt),fog:!!oe,useFog:q.fog===!0,fogExp2:!!oe&&oe.isFogExp2,flatShading:q.flatShading===!0,sizeAttenuation:q.sizeAttenuation===!0,logarithmicDepthBuffer:v,reverseDepthBuffer:Rt,skinning:ne.isSkinnedMesh===!0,morphTargets:ie.morphAttributes.position!==void 0,morphNormals:ie.morphAttributes.normal!==void 0,morphColors:ie.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:Me,numDirLights:V.directional.length,numPointLights:V.point.length,numSpotLights:V.spot.length,numSpotLightMaps:V.spotLightMap.length,numRectAreaLights:V.rectArea.length,numHemiLights:V.hemi.length,numDirLightShadows:V.directionalShadowMap.length,numPointLightShadows:V.pointShadowMap.length,numSpotLightShadows:V.spotShadowMap.length,numSpotLightShadowsWithMaps:V.numSpotLightShadowsWithMaps,numLightProbes:V.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:q.dithering,shadowMapEnabled:i.shadowMap.enabled&&Q.length>0,shadowMapType:i.shadowMap.type,toneMapping:$e,decodeVideoTexture:Pt&&q.map.isVideoTexture===!0&&li.getTransfer(q.map.colorSpace)===Fi,decodeVideoTextureEmissive:Xt&&q.emissiveMap.isVideoTexture===!0&&li.getTransfer(q.emissiveMap.colorSpace)===Fi,premultipliedAlpha:q.premultipliedAlpha,doubleSided:q.side===as,flipSided:q.side===or,useDepthPacking:q.depthPacking>=0,depthPacking:q.depthPacking||0,index0AttributeName:q.index0AttributeName,extensionClipCullDistance:pn&&q.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pn&&q.extensions.multiDraw===!0||zt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:q.customProgramCacheKey()};return St.vertexUv1s=h.has(1),St.vertexUv2s=h.has(2),St.vertexUv3s=h.has(3),h.clear(),St}function E(q){const V=[];if(q.shaderID?V.push(q.shaderID):(V.push(q.customVertexShaderID),V.push(q.customFragmentShaderID)),q.defines!==void 0)for(const Q in q.defines)V.push(Q),V.push(q.defines[Q]);return q.isRawShaderMaterial===!1&&(O(V,q),U(V,q),V.push(i.outputColorSpace)),V.push(q.customProgramCacheKey),V.join()}function O(q,V){q.push(V.precision),q.push(V.outputColorSpace),q.push(V.envMapMode),q.push(V.envMapCubeUVHeight),q.push(V.mapUv),q.push(V.alphaMapUv),q.push(V.lightMapUv),q.push(V.aoMapUv),q.push(V.bumpMapUv),q.push(V.normalMapUv),q.push(V.displacementMapUv),q.push(V.emissiveMapUv),q.push(V.metalnessMapUv),q.push(V.roughnessMapUv),q.push(V.anisotropyMapUv),q.push(V.clearcoatMapUv),q.push(V.clearcoatNormalMapUv),q.push(V.clearcoatRoughnessMapUv),q.push(V.iridescenceMapUv),q.push(V.iridescenceThicknessMapUv),q.push(V.sheenColorMapUv),q.push(V.sheenRoughnessMapUv),q.push(V.specularMapUv),q.push(V.specularColorMapUv),q.push(V.specularIntensityMapUv),q.push(V.transmissionMapUv),q.push(V.thicknessMapUv),q.push(V.combine),q.push(V.fogExp2),q.push(V.sizeAttenuation),q.push(V.morphTargetsCount),q.push(V.morphAttributeCount),q.push(V.numDirLights),q.push(V.numPointLights),q.push(V.numSpotLights),q.push(V.numSpotLightMaps),q.push(V.numHemiLights),q.push(V.numRectAreaLights),q.push(V.numDirLightShadows),q.push(V.numPointLightShadows),q.push(V.numSpotLightShadows),q.push(V.numSpotLightShadowsWithMaps),q.push(V.numLightProbes),q.push(V.shadowMapType),q.push(V.toneMapping),q.push(V.numClippingPlanes),q.push(V.numClipIntersection),q.push(V.depthPacking)}function U(q,V){l.disableAll(),V.supportsVertexTextures&&l.enable(0),V.instancing&&l.enable(1),V.instancingColor&&l.enable(2),V.instancingMorph&&l.enable(3),V.matcap&&l.enable(4),V.envMap&&l.enable(5),V.normalMapObjectSpace&&l.enable(6),V.normalMapTangentSpace&&l.enable(7),V.clearcoat&&l.enable(8),V.iridescence&&l.enable(9),V.alphaTest&&l.enable(10),V.vertexColors&&l.enable(11),V.vertexAlphas&&l.enable(12),V.vertexUv1s&&l.enable(13),V.vertexUv2s&&l.enable(14),V.vertexUv3s&&l.enable(15),V.vertexTangents&&l.enable(16),V.anisotropy&&l.enable(17),V.alphaHash&&l.enable(18),V.batching&&l.enable(19),V.dispersion&&l.enable(20),V.batchingColor&&l.enable(21),q.push(l.mask),l.disableAll(),V.fog&&l.enable(0),V.useFog&&l.enable(1),V.flatShading&&l.enable(2),V.logarithmicDepthBuffer&&l.enable(3),V.reverseDepthBuffer&&l.enable(4),V.skinning&&l.enable(5),V.morphTargets&&l.enable(6),V.morphNormals&&l.enable(7),V.morphColors&&l.enable(8),V.premultipliedAlpha&&l.enable(9),V.shadowMapEnabled&&l.enable(10),V.doubleSided&&l.enable(11),V.flipSided&&l.enable(12),V.useDepthPacking&&l.enable(13),V.dithering&&l.enable(14),V.transmission&&l.enable(15),V.sheen&&l.enable(16),V.opaque&&l.enable(17),V.pointsUvs&&l.enable(18),V.decodeVideoTexture&&l.enable(19),V.decodeVideoTextureEmissive&&l.enable(20),V.alphaToCoverage&&l.enable(21),q.push(l.mask)}function I(q){const V=T[q.type];let Q;if(V){const J=Fa[V];Q=my.clone(J.uniforms)}else Q=q.uniforms;return Q}function j(q,V){let Q;for(let J=0,ne=m.length;J0?n.push(E):S.transparent===!0?r.push(E):t.push(E)}function u(v,x,S,T,N,C){const E=a(v,x,S,T,N,C);S.transmission>0?n.unshift(E):S.transparent===!0?r.unshift(E):t.unshift(E)}function h(v,x){t.length>1&&t.sort(v||pH),n.length>1&&n.sort(x||n5),r.length>1&&r.sort(x||n5)}function m(){for(let v=e,x=i.length;v=s.length?(a=new i5,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function gH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new me,color:new cn};break;case"SpotLight":t={position:new me,direction:new me,color:new cn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new me,color:new cn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new me,skyColor:new cn,groundColor:new cn};break;case"RectAreaLight":t={color:new cn,position:new me,halfWidth:new me,halfHeight:new me};break}return i[e.id]=t,t}}}function vH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let _H=0;function yH(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function xH(i){const e=new gH,t=vH(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)n.probe.push(new me);const r=new me,s=new jn,a=new jn;function l(h){let m=0,v=0,x=0;for(let q=0;q<9;q++)n.probe[q].set(0,0,0);let S=0,T=0,N=0,C=0,E=0,O=0,U=0,I=0,j=0,z=0,G=0;h.sort(yH);for(let q=0,V=h.length;q0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=nn.LTC_FLOAT_1,n.rectAreaLTC2=nn.LTC_FLOAT_2):(n.rectAreaLTC1=nn.LTC_HALF_1,n.rectAreaLTC2=nn.LTC_HALF_2)),n.ambient[0]=m,n.ambient[1]=v,n.ambient[2]=x;const H=n.hash;(H.directionalLength!==S||H.pointLength!==T||H.spotLength!==N||H.rectAreaLength!==C||H.hemiLength!==E||H.numDirectionalShadows!==O||H.numPointShadows!==U||H.numSpotShadows!==I||H.numSpotMaps!==j||H.numLightProbes!==G)&&(n.directional.length=S,n.spot.length=N,n.rectArea.length=C,n.point.length=T,n.hemi.length=E,n.directionalShadow.length=O,n.directionalShadowMap.length=O,n.pointShadow.length=U,n.pointShadowMap.length=U,n.spotShadow.length=I,n.spotShadowMap.length=I,n.directionalShadowMatrix.length=O,n.pointShadowMatrix.length=U,n.spotLightMatrix.length=I+j-z,n.spotLightMap.length=j,n.numSpotLightShadowsWithMaps=z,n.numLightProbes=G,H.directionalLength=S,H.pointLength=T,H.spotLength=N,H.rectAreaLength=C,H.hemiLength=E,H.numDirectionalShadows=O,H.numPointShadows=U,H.numSpotShadows=I,H.numSpotMaps=j,H.numLightProbes=G,n.version=_H++)}function u(h,m){let v=0,x=0,S=0,T=0,N=0;const C=m.matrixWorldInverse;for(let E=0,O=h.length;E=a.length?(l=new r5(i),a.push(l)):l=a[s],l}function n(){e=new WeakMap}return{get:t,dispose:n}}const SH=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,wH=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function TH(i,e,t){let n=new Og;const r=new bt,s=new bt,a=new On,l=new Oz({depthPacking:KF}),u=new Iz,h={},m=t.maxTextureSize,v={[El]:or,[or]:El,[as]:as},x=new Qa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bt},radius:{value:4}},vertexShader:SH,fragmentShader:wH}),S=x.clone();S.defines.HORIZONTAL_PASS=1;const T=new Hi;T.setAttribute("position",new wr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const N=new Oi(T,x),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ST;let E=this.type;this.render=function(z,G,H){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||z.length===0)return;const q=i.getRenderTarget(),V=i.getActiveCubeFace(),Q=i.getActiveMipmapLevel(),J=i.state;J.setBlending($a),J.buffers.color.setClear(1,1,1,1),J.buffers.depth.setTest(!0),J.setScissorTest(!1);const ne=E!==vo&&this.type===vo,oe=E===vo&&this.type!==vo;for(let ie=0,Z=z.length;iem||r.y>m)&&(r.x>m&&(s.x=Math.floor(m/Se.x),r.x=s.x*Se.x,de.mapSize.x=s.x),r.y>m&&(s.y=Math.floor(m/Se.y),r.y=s.y*Se.y,de.mapSize.y=s.y)),de.map===null||ne===!0||oe===!0){const ae=this.type!==vo?{minFilter:dr,magFilter:dr}:{};de.map!==null&&de.map.dispose(),de.map=new Fh(r.x,r.y,ae),de.map.texture.name=te.name+".shadowMap",de.camera.updateProjectionMatrix()}i.setRenderTarget(de.map),i.clear();const Te=de.getViewportCount();for(let ae=0;ae0||G.map&&G.alphaTest>0){const J=V.uuid,ne=G.uuid;let oe=h[J];oe===void 0&&(oe={},h[J]=oe);let ie=oe[ne];ie===void 0&&(ie=V.clone(),oe[ne]=ie,G.addEventListener("dispose",j)),V=ie}if(V.visible=G.visible,V.wireframe=G.wireframe,q===vo?V.side=G.shadowSide!==null?G.shadowSide:G.side:V.side=G.shadowSide!==null?G.shadowSide:v[G.side],V.alphaMap=G.alphaMap,V.alphaTest=G.alphaTest,V.map=G.map,V.clipShadows=G.clipShadows,V.clippingPlanes=G.clippingPlanes,V.clipIntersection=G.clipIntersection,V.displacementMap=G.displacementMap,V.displacementScale=G.displacementScale,V.displacementBias=G.displacementBias,V.wireframeLinewidth=G.wireframeLinewidth,V.linewidth=G.linewidth,H.isPointLight===!0&&V.isMeshDistanceMaterial===!0){const J=i.properties.get(V);J.light=H}return V}function I(z,G,H,q,V){if(z.visible===!1)return;if(z.layers.test(G.layers)&&(z.isMesh||z.isLine||z.isPoints)&&(z.castShadow||z.receiveShadow&&V===vo)&&(!z.frustumCulled||n.intersectsObject(z))){z.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,z.matrixWorld);const ne=e.update(z),oe=z.material;if(Array.isArray(oe)){const ie=ne.groups;for(let Z=0,te=ie.length;Z=1):de.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(de)[1]),Z=te>=2);let Se=null,Te={};const ae=i.getParameter(i.SCISSOR_BOX),Me=i.getParameter(i.VIEWPORT),Ve=new On().fromArray(ae),Ce=new On().fromArray(Me);function Fe(ge,Ot,ot,Tt){const Ht=new Uint8Array(4),Yt=i.createTexture();i.bindTexture(ge,Yt),i.texParameteri(ge,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(ge,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let pn=0;pn"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new bt,m=new WeakMap;let v;const x=new WeakMap;let S=!1;try{S=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function T(Ae,k){return S?new OffscreenCanvas(Ae,k):ig("canvas")}function N(Ae,k,be){let Oe=1;const pe=pt(Ae);if((pe.width>be||pe.height>be)&&(Oe=be/Math.max(pe.width,pe.height)),Oe<1)if(typeof HTMLImageElement<"u"&&Ae instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Ae instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Ae instanceof ImageBitmap||typeof VideoFrame<"u"&&Ae instanceof VideoFrame){const le=Math.floor(Oe*pe.width),Ne=Math.floor(Oe*pe.height);v===void 0&&(v=T(le,Ne));const De=k?T(le,Ne):v;return De.width=le,De.height=Ne,De.getContext("2d").drawImage(Ae,0,0,le,Ne),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+pe.width+"x"+pe.height+") to ("+le+"x"+Ne+")."),De}else return"data"in Ae&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+pe.width+"x"+pe.height+")."),Ae;return Ae}function C(Ae){return Ae.generateMipmaps}function E(Ae){i.generateMipmap(Ae)}function O(Ae){return Ae.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:Ae.isWebGL3DRenderTarget?i.TEXTURE_3D:Ae.isWebGLArrayRenderTarget||Ae.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function U(Ae,k,be,Oe,pe=!1){if(Ae!==null){if(i[Ae]!==void 0)return i[Ae];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Ae+"'")}let le=k;if(k===i.RED&&(be===i.FLOAT&&(le=i.R32F),be===i.HALF_FLOAT&&(le=i.R16F),be===i.UNSIGNED_BYTE&&(le=i.R8)),k===i.RED_INTEGER&&(be===i.UNSIGNED_BYTE&&(le=i.R8UI),be===i.UNSIGNED_SHORT&&(le=i.R16UI),be===i.UNSIGNED_INT&&(le=i.R32UI),be===i.BYTE&&(le=i.R8I),be===i.SHORT&&(le=i.R16I),be===i.INT&&(le=i.R32I)),k===i.RG&&(be===i.FLOAT&&(le=i.RG32F),be===i.HALF_FLOAT&&(le=i.RG16F),be===i.UNSIGNED_BYTE&&(le=i.RG8)),k===i.RG_INTEGER&&(be===i.UNSIGNED_BYTE&&(le=i.RG8UI),be===i.UNSIGNED_SHORT&&(le=i.RG16UI),be===i.UNSIGNED_INT&&(le=i.RG32UI),be===i.BYTE&&(le=i.RG8I),be===i.SHORT&&(le=i.RG16I),be===i.INT&&(le=i.RG32I)),k===i.RGB_INTEGER&&(be===i.UNSIGNED_BYTE&&(le=i.RGB8UI),be===i.UNSIGNED_SHORT&&(le=i.RGB16UI),be===i.UNSIGNED_INT&&(le=i.RGB32UI),be===i.BYTE&&(le=i.RGB8I),be===i.SHORT&&(le=i.RGB16I),be===i.INT&&(le=i.RGB32I)),k===i.RGBA_INTEGER&&(be===i.UNSIGNED_BYTE&&(le=i.RGBA8UI),be===i.UNSIGNED_SHORT&&(le=i.RGBA16UI),be===i.UNSIGNED_INT&&(le=i.RGBA32UI),be===i.BYTE&&(le=i.RGBA8I),be===i.SHORT&&(le=i.RGBA16I),be===i.INT&&(le=i.RGBA32I)),k===i.RGB&&be===i.UNSIGNED_INT_5_9_9_9_REV&&(le=i.RGB9_E5),k===i.RGBA){const Ne=pe?r_:li.getTransfer(Oe);be===i.FLOAT&&(le=i.RGBA32F),be===i.HALF_FLOAT&&(le=i.RGBA16F),be===i.UNSIGNED_BYTE&&(le=Ne===Fi?i.SRGB8_ALPHA8:i.RGBA8),be===i.UNSIGNED_SHORT_4_4_4_4&&(le=i.RGBA4),be===i.UNSIGNED_SHORT_5_5_5_1&&(le=i.RGB5_A1)}return(le===i.R16F||le===i.R32F||le===i.RG16F||le===i.RG32F||le===i.RGBA16F||le===i.RGBA32F)&&e.get("EXT_color_buffer_float"),le}function I(Ae,k){let be;return Ae?k===null||k===Nr||k===lu?be=i.DEPTH24_STENCIL8:k===$r?be=i.DEPTH32F_STENCIL8:k===bl&&(be=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):k===null||k===Nr||k===lu?be=i.DEPTH_COMPONENT24:k===$r?be=i.DEPTH_COMPONENT32F:k===bl&&(be=i.DEPTH_COMPONENT16),be}function j(Ae,k){return C(Ae)===!0||Ae.isFramebufferTexture&&Ae.minFilter!==dr&&Ae.minFilter!==ps?Math.log2(Math.max(k.width,k.height))+1:Ae.mipmaps!==void 0&&Ae.mipmaps.length>0?Ae.mipmaps.length:Ae.isCompressedTexture&&Array.isArray(Ae.image)?k.mipmaps.length:1}function z(Ae){const k=Ae.target;k.removeEventListener("dispose",z),H(k),k.isVideoTexture&&m.delete(k)}function G(Ae){const k=Ae.target;k.removeEventListener("dispose",G),V(k)}function H(Ae){const k=n.get(Ae);if(k.__webglInit===void 0)return;const be=Ae.source,Oe=x.get(be);if(Oe){const pe=Oe[k.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&q(Ae),Object.keys(Oe).length===0&&x.delete(be)}n.remove(Ae)}function q(Ae){const k=n.get(Ae);i.deleteTexture(k.__webglTexture);const be=Ae.source,Oe=x.get(be);delete Oe[k.__cacheKey],a.memory.textures--}function V(Ae){const k=n.get(Ae);if(Ae.depthTexture&&(Ae.depthTexture.dispose(),n.remove(Ae.depthTexture)),Ae.isWebGLCubeRenderTarget)for(let Oe=0;Oe<6;Oe++){if(Array.isArray(k.__webglFramebuffer[Oe]))for(let pe=0;pe=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Ae+" texture units while this GPU supports only "+r.maxTextures),Q+=1,Ae}function oe(Ae){const k=[];return k.push(Ae.wrapS),k.push(Ae.wrapT),k.push(Ae.wrapR||0),k.push(Ae.magFilter),k.push(Ae.minFilter),k.push(Ae.anisotropy),k.push(Ae.internalFormat),k.push(Ae.format),k.push(Ae.type),k.push(Ae.generateMipmaps),k.push(Ae.premultiplyAlpha),k.push(Ae.flipY),k.push(Ae.unpackAlignment),k.push(Ae.colorSpace),k.join()}function ie(Ae,k){const be=n.get(Ae);if(Ae.isVideoTexture&&_t(Ae),Ae.isRenderTargetTexture===!1&&Ae.version>0&&be.__version!==Ae.version){const Oe=Ae.image;if(Oe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Oe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(be,Ae,k);return}}t.bindTexture(i.TEXTURE_2D,be.__webglTexture,i.TEXTURE0+k)}function Z(Ae,k){const be=n.get(Ae);if(Ae.version>0&&be.__version!==Ae.version){Ce(be,Ae,k);return}t.bindTexture(i.TEXTURE_2D_ARRAY,be.__webglTexture,i.TEXTURE0+k)}function te(Ae,k){const be=n.get(Ae);if(Ae.version>0&&be.__version!==Ae.version){Ce(be,Ae,k);return}t.bindTexture(i.TEXTURE_3D,be.__webglTexture,i.TEXTURE0+k)}function de(Ae,k){const be=n.get(Ae);if(Ae.version>0&&be.__version!==Ae.version){Fe(be,Ae,k);return}t.bindTexture(i.TEXTURE_CUBE_MAP,be.__webglTexture,i.TEXTURE0+k)}const Se={[td]:i.REPEAT,[Yl]:i.CLAMP_TO_EDGE,[nd]:i.MIRRORED_REPEAT},Te={[dr]:i.NEAREST,[i_]:i.NEAREST_MIPMAP_NEAREST,[Ql]:i.NEAREST_MIPMAP_LINEAR,[ps]:i.LINEAR,[XA]:i.LINEAR_MIPMAP_NEAREST,[za]:i.LINEAR_MIPMAP_LINEAR},ae={[GT]:i.NEVER,[WT]:i.ALWAYS,[Ay]:i.LESS,[py]:i.LEQUAL,[qT]:i.EQUAL,[HT]:i.GEQUAL,[VT]:i.GREATER,[jT]:i.NOTEQUAL};function Me(Ae,k){if(k.type===$r&&e.has("OES_texture_float_linear")===!1&&(k.magFilter===ps||k.magFilter===XA||k.magFilter===Ql||k.magFilter===za||k.minFilter===ps||k.minFilter===XA||k.minFilter===Ql||k.minFilter===za)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(Ae,i.TEXTURE_WRAP_S,Se[k.wrapS]),i.texParameteri(Ae,i.TEXTURE_WRAP_T,Se[k.wrapT]),(Ae===i.TEXTURE_3D||Ae===i.TEXTURE_2D_ARRAY)&&i.texParameteri(Ae,i.TEXTURE_WRAP_R,Se[k.wrapR]),i.texParameteri(Ae,i.TEXTURE_MAG_FILTER,Te[k.magFilter]),i.texParameteri(Ae,i.TEXTURE_MIN_FILTER,Te[k.minFilter]),k.compareFunction&&(i.texParameteri(Ae,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(Ae,i.TEXTURE_COMPARE_FUNC,ae[k.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(k.magFilter===dr||k.minFilter!==Ql&&k.minFilter!==za||k.type===$r&&e.has("OES_texture_float_linear")===!1)return;if(k.anisotropy>1||n.get(k).__currentAnisotropy){const be=e.get("EXT_texture_filter_anisotropic");i.texParameterf(Ae,be.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),n.get(k).__currentAnisotropy=k.anisotropy}}}function Ve(Ae,k){let be=!1;Ae.__webglInit===void 0&&(Ae.__webglInit=!0,k.addEventListener("dispose",z));const Oe=k.source;let pe=x.get(Oe);pe===void 0&&(pe={},x.set(Oe,pe));const le=oe(k);if(le!==Ae.__cacheKey){pe[le]===void 0&&(pe[le]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,be=!0),pe[le].usedTimes++;const Ne=pe[Ae.__cacheKey];Ne!==void 0&&(pe[Ae.__cacheKey].usedTimes--,Ne.usedTimes===0&&q(k)),Ae.__cacheKey=le,Ae.__webglTexture=pe[le].texture}return be}function Ce(Ae,k,be){let Oe=i.TEXTURE_2D;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(Oe=i.TEXTURE_2D_ARRAY),k.isData3DTexture&&(Oe=i.TEXTURE_3D);const pe=Ve(Ae,k),le=k.source;t.bindTexture(Oe,Ae.__webglTexture,i.TEXTURE0+be);const Ne=n.get(le);if(le.version!==Ne.__version||pe===!0){t.activeTexture(i.TEXTURE0+be);const De=li.getPrimaries(li.workingColorSpace),Je=k.colorSpace===To?null:li.getPrimaries(k.colorSpace),we=k.colorSpace===To||De===Je?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,k.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,k.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,we);let Ue=N(k.image,!1,r.maxTextureSize);Ue=Xt(k,Ue);const ut=s.convert(k.format,k.colorSpace),Dt=s.convert(k.type);let Bt=U(k.internalFormat,ut,Dt,k.colorSpace,k.isVideoTexture);Me(Oe,k);let ct;const jt=k.mipmaps,Jt=k.isVideoTexture!==!0,In=Ne.__version===void 0||pe===!0,ge=le.dataReady,Ot=j(k,Ue);if(k.isDepthTexture)Bt=I(k.format===uu,k.type),In&&(Jt?t.texStorage2D(i.TEXTURE_2D,1,Bt,Ue.width,Ue.height):t.texImage2D(i.TEXTURE_2D,0,Bt,Ue.width,Ue.height,0,ut,Dt,null));else if(k.isDataTexture)if(jt.length>0){Jt&&In&&t.texStorage2D(i.TEXTURE_2D,Ot,Bt,jt[0].width,jt[0].height);for(let ot=0,Tt=jt.length;ot0){const Ht=UN(ct.width,ct.height,k.format,k.type);for(const Yt of k.layerUpdates){const pn=ct.data.subarray(Yt*Ht/ct.data.BYTES_PER_ELEMENT,(Yt+1)*Ht/ct.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,Yt,ct.width,ct.height,1,ut,pn)}k.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,0,ct.width,ct.height,Ue.depth,ut,ct.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,ot,Bt,ct.width,ct.height,Ue.depth,0,ct.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Jt?ge&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,0,ct.width,ct.height,Ue.depth,ut,Dt,ct.data):t.texImage3D(i.TEXTURE_2D_ARRAY,ot,Bt,ct.width,ct.height,Ue.depth,0,ut,Dt,ct.data)}else{Jt&&In&&t.texStorage2D(i.TEXTURE_2D,Ot,Bt,jt[0].width,jt[0].height);for(let ot=0,Tt=jt.length;ot0){const ot=UN(Ue.width,Ue.height,k.format,k.type);for(const Tt of k.layerUpdates){const Ht=Ue.data.subarray(Tt*ot/Ue.data.BYTES_PER_ELEMENT,(Tt+1)*ot/Ue.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Tt,Ue.width,Ue.height,1,ut,Dt,Ht)}k.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Ue.width,Ue.height,Ue.depth,ut,Dt,Ue.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Bt,Ue.width,Ue.height,Ue.depth,0,ut,Dt,Ue.data);else if(k.isData3DTexture)Jt?(In&&t.texStorage3D(i.TEXTURE_3D,Ot,Bt,Ue.width,Ue.height,Ue.depth),ge&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Ue.width,Ue.height,Ue.depth,ut,Dt,Ue.data)):t.texImage3D(i.TEXTURE_3D,0,Bt,Ue.width,Ue.height,Ue.depth,0,ut,Dt,Ue.data);else if(k.isFramebufferTexture){if(In)if(Jt)t.texStorage2D(i.TEXTURE_2D,Ot,Bt,Ue.width,Ue.height);else{let ot=Ue.width,Tt=Ue.height;for(let Ht=0;Ht>=1,Tt>>=1}}else if(jt.length>0){if(Jt&&In){const ot=pt(jt[0]);t.texStorage2D(i.TEXTURE_2D,Ot,Bt,ot.width,ot.height)}for(let ot=0,Tt=jt.length;ot0&&Ot++;const Tt=pt(ut[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Ot,jt,Tt.width,Tt.height)}for(let Tt=0;Tt<6;Tt++)if(Ue){Jt?ge&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Tt,0,0,0,ut[Tt].width,ut[Tt].height,Bt,ct,ut[Tt].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Tt,0,jt,ut[Tt].width,ut[Tt].height,0,Bt,ct,ut[Tt].data);for(let Ht=0;Ht>le),Dt=Math.max(1,k.height>>le);pe===i.TEXTURE_3D||pe===i.TEXTURE_2D_ARRAY?t.texImage3D(pe,le,Je,ut,Dt,k.depth,0,Ne,De,null):t.texImage2D(pe,le,Je,ut,Dt,0,Ne,De,null)}t.bindFramebuffer(i.FRAMEBUFFER,Ae),Gt(k)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Oe,pe,Ue.__webglTexture,0,yt(k)):(pe===i.TEXTURE_2D||pe>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&pe<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Oe,pe,Ue.__webglTexture,le),t.bindFramebuffer(i.FRAMEBUFFER,null)}function He(Ae,k,be){if(i.bindRenderbuffer(i.RENDERBUFFER,Ae),k.depthBuffer){const Oe=k.depthTexture,pe=Oe&&Oe.isDepthTexture?Oe.type:null,le=I(k.stencilBuffer,pe),Ne=k.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,De=yt(k);Gt(k)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,De,le,k.width,k.height):be?i.renderbufferStorageMultisample(i.RENDERBUFFER,De,le,k.width,k.height):i.renderbufferStorage(i.RENDERBUFFER,le,k.width,k.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ne,i.RENDERBUFFER,Ae)}else{const Oe=k.textures;for(let pe=0;pe{delete k.__boundDepthTexture,delete k.__depthDisposeCallback,Oe.removeEventListener("dispose",pe)};Oe.addEventListener("dispose",pe),k.__depthDisposeCallback=pe}k.__boundDepthTexture=Oe}if(Ae.depthTexture&&!k.__autoAllocateDepthBuffer){if(be)throw new Error("target.depthTexture not supported in Cube render targets");Rt(k.__webglFramebuffer,Ae)}else if(be){k.__webglDepthbuffer=[];for(let Oe=0;Oe<6;Oe++)if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer[Oe]),k.__webglDepthbuffer[Oe]===void 0)k.__webglDepthbuffer[Oe]=i.createRenderbuffer(),He(k.__webglDepthbuffer[Oe],Ae,!1);else{const pe=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,le=k.__webglDepthbuffer[Oe];i.bindRenderbuffer(i.RENDERBUFFER,le),i.framebufferRenderbuffer(i.FRAMEBUFFER,pe,i.RENDERBUFFER,le)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer),k.__webglDepthbuffer===void 0)k.__webglDepthbuffer=i.createRenderbuffer(),He(k.__webglDepthbuffer,Ae,!1);else{const Oe=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pe=k.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,pe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Oe,i.RENDERBUFFER,pe)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function zt(Ae,k,be){const Oe=n.get(Ae);k!==void 0&&et(Oe.__webglFramebuffer,Ae,Ae.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),be!==void 0&&Et(Ae)}function Pt(Ae){const k=Ae.texture,be=n.get(Ae),Oe=n.get(k);Ae.addEventListener("dispose",G);const pe=Ae.textures,le=Ae.isWebGLCubeRenderTarget===!0,Ne=pe.length>1;if(Ne||(Oe.__webglTexture===void 0&&(Oe.__webglTexture=i.createTexture()),Oe.__version=k.version,a.memory.textures++),le){be.__webglFramebuffer=[];for(let De=0;De<6;De++)if(k.mipmaps&&k.mipmaps.length>0){be.__webglFramebuffer[De]=[];for(let Je=0;Je0){be.__webglFramebuffer=[];for(let De=0;De0&&Gt(Ae)===!1){be.__webglMultisampledFramebuffer=i.createFramebuffer(),be.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,be.__webglMultisampledFramebuffer);for(let De=0;De0)for(let Je=0;Je0)for(let Je=0;Je0){if(Gt(Ae)===!1){const k=Ae.textures,be=Ae.width,Oe=Ae.height;let pe=i.COLOR_BUFFER_BIT;const le=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ne=n.get(Ae),De=k.length>1;if(De)for(let Je=0;Je0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function _t(Ae){const k=a.render.frame;m.get(Ae)!==k&&(m.set(Ae,k),Ae.update())}function Xt(Ae,k){const be=Ae.colorSpace,Oe=Ae.format,pe=Ae.type;return Ae.isCompressedTexture===!0||Ae.isVideoTexture===!0||be!==Mo&&be!==To&&(li.getTransfer(be)===Fi?(Oe!==ks||pe!==ra)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",be)),k}function pt(Ae){return typeof HTMLImageElement<"u"&&Ae instanceof HTMLImageElement?(h.width=Ae.naturalWidth||Ae.width,h.height=Ae.naturalHeight||Ae.height):typeof VideoFrame<"u"&&Ae instanceof VideoFrame?(h.width=Ae.displayWidth,h.height=Ae.displayHeight):(h.width=Ae.width,h.height=Ae.height),h}this.allocateTextureUnit=ne,this.resetTextureUnits=J,this.setTexture2D=ie,this.setTexture2DArray=Z,this.setTexture3D=te,this.setTextureCube=de,this.rebindTextures=zt,this.setupRenderTarget=Pt,this.updateRenderTargetMipmap=We,this.updateMultisampleRenderTarget=Wt,this.setupDepthRenderbuffer=Et,this.setupFrameBufferTexture=et,this.useMultisampledRTT=Gt}function NH(i,e){function t(n,r=To){let s;const a=li.getTransfer(r);if(n===ra)return i.UNSIGNED_BYTE;if(n===hy)return i.UNSIGNED_SHORT_4_4_4_4;if(n===fy)return i.UNSIGNED_SHORT_5_5_5_1;if(n===dy)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Hf)return i.BYTE;if(n===Wf)return i.SHORT;if(n===bl)return i.UNSIGNED_SHORT;if(n===Ns)return i.INT;if(n===Nr)return i.UNSIGNED_INT;if(n===$r)return i.FLOAT;if(n===Gs)return i.HALF_FLOAT;if(n===IT)return i.ALPHA;if(n===Pg)return i.RGB;if(n===ks)return i.RGBA;if(n===FT)return i.LUMINANCE;if(n===kT)return i.LUMINANCE_ALPHA;if(n===tu)return i.DEPTH_COMPONENT;if(n===uu)return i.DEPTH_STENCIL;if(n===Lg)return i.RED;if(n===k0)return i.RED_INTEGER;if(n===id)return i.RG;if(n===z0)return i.RG_INTEGER;if(n===G0)return i.RGBA_INTEGER;if(n===$f||n===Dh||n===Ph||n===Lh)if(a===Fi)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===$f)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Dh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ph)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Lh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===$f)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Dh)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ph)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Lh)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ym||n===Qm||n===Km||n===Zm)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Ym)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Qm)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Km)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Zm)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Jm||n===r0||n===s0)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Jm||n===r0)return a===Fi?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===s0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===a0||n===o0||n===l0||n===u0||n===c0||n===h0||n===f0||n===d0||n===A0||n===p0||n===m0||n===g0||n===v0||n===_0)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===a0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===o0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===l0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===u0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===c0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===h0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===f0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===d0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===A0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===p0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===m0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===g0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===v0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===_0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Xf||n===$S||n===XS)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Xf)return a===Fi?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===$S)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===XS)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===zT||n===eg||n===tg||n===ng)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Xf)return s.COMPRESSED_RED_RGTC1_EXT;if(n===eg)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===tg)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ng)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===lu?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const RH={type:"move"};class P3{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new qa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new me,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new me),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new me,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new me),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const l=this._targetRay,u=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const N of e.hand.values()){const C=t.getJointPose(N,n),E=this._getHandJoint(h,N);C!==null&&(E.matrix.fromArray(C.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=C.radius),E.visible=C!==null}const m=h.joints["index-finger-tip"],v=h.joints["thumb-tip"],x=m.position.distanceTo(v.position),S=.02,T=.005;h.inputState.pinching&&x>S+T?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&x<=S-T&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(RH)))}return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=s!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new qa;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const DH=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,PH=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class LH{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new ms,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Qa({vertexShader:DH,fragmentShader:PH,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Oi(new by(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class UH extends Bc{constructor(e,t){super();const n=this;let r=null,s=1,a=null,l="local-floor",u=1,h=null,m=null,v=null,x=null,S=null,T=null;const N=new LH,C=t.getContextAttributes();let E=null,O=null;const U=[],I=[],j=new bt;let z=null;const G=new va;G.viewport=new On;const H=new va;H.viewport=new On;const q=[G,H],V=new Zz;let Q=null,J=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ce){let Fe=U[Ce];return Fe===void 0&&(Fe=new P3,U[Ce]=Fe),Fe.getTargetRaySpace()},this.getControllerGrip=function(Ce){let Fe=U[Ce];return Fe===void 0&&(Fe=new P3,U[Ce]=Fe),Fe.getGripSpace()},this.getHand=function(Ce){let Fe=U[Ce];return Fe===void 0&&(Fe=new P3,U[Ce]=Fe),Fe.getHandSpace()};function ne(Ce){const Fe=I.indexOf(Ce.inputSource);if(Fe===-1)return;const et=U[Fe];et!==void 0&&(et.update(Ce.inputSource,Ce.frame,h||a),et.dispatchEvent({type:Ce.type,data:Ce.inputSource}))}function oe(){r.removeEventListener("select",ne),r.removeEventListener("selectstart",ne),r.removeEventListener("selectend",ne),r.removeEventListener("squeeze",ne),r.removeEventListener("squeezestart",ne),r.removeEventListener("squeezeend",ne),r.removeEventListener("end",oe),r.removeEventListener("inputsourceschange",ie);for(let Ce=0;Ce=0&&(I[He]=null,U[He].disconnect(et))}for(let Fe=0;Fe=I.length){I.push(et),He=Et;break}else if(I[Et]===null){I[Et]=et,He=Et;break}if(He===-1)break}const Rt=U[He];Rt&&Rt.connect(et)}}const Z=new me,te=new me;function de(Ce,Fe,et){Z.setFromMatrixPosition(Fe.matrixWorld),te.setFromMatrixPosition(et.matrixWorld);const He=Z.distanceTo(te),Rt=Fe.projectionMatrix.elements,Et=et.projectionMatrix.elements,zt=Rt[14]/(Rt[10]-1),Pt=Rt[14]/(Rt[10]+1),We=(Rt[9]+1)/Rt[5],ft=(Rt[9]-1)/Rt[5],fe=(Rt[8]-1)/Rt[0],Wt=(Et[8]+1)/Et[0],yt=zt*fe,Gt=zt*Wt,_t=He/(-fe+Wt),Xt=_t*-fe;if(Fe.matrixWorld.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.translateX(Xt),Ce.translateZ(_t),Ce.matrixWorld.compose(Ce.position,Ce.quaternion,Ce.scale),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert(),Rt[10]===-1)Ce.projectionMatrix.copy(Fe.projectionMatrix),Ce.projectionMatrixInverse.copy(Fe.projectionMatrixInverse);else{const pt=zt+_t,Ae=Pt+_t,k=yt-Xt,be=Gt+(He-Xt),Oe=We*Pt/Ae*pt,pe=ft*Pt/Ae*pt;Ce.projectionMatrix.makePerspective(k,be,Oe,pe,pt,Ae),Ce.projectionMatrixInverse.copy(Ce.projectionMatrix).invert()}}function Se(Ce,Fe){Fe===null?Ce.matrixWorld.copy(Ce.matrix):Ce.matrixWorld.multiplyMatrices(Fe.matrixWorld,Ce.matrix),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert()}this.updateCamera=function(Ce){if(r===null)return;let Fe=Ce.near,et=Ce.far;N.texture!==null&&(N.depthNear>0&&(Fe=N.depthNear),N.depthFar>0&&(et=N.depthFar)),V.near=H.near=G.near=Fe,V.far=H.far=G.far=et,(Q!==V.near||J!==V.far)&&(r.updateRenderState({depthNear:V.near,depthFar:V.far}),Q=V.near,J=V.far),G.layers.mask=Ce.layers.mask|2,H.layers.mask=Ce.layers.mask|4,V.layers.mask=G.layers.mask|H.layers.mask;const He=Ce.parent,Rt=V.cameras;Se(V,He);for(let Et=0;Et0&&(C.alphaTest.value=E.alphaTest);const O=e.get(E),U=O.envMap,I=O.envMapRotation;U&&(C.envMap.value=U,yf.copy(I),yf.x*=-1,yf.y*=-1,yf.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(yf.y*=-1,yf.z*=-1),C.envMapRotation.value.setFromMatrix4(BH.makeRotationFromEuler(yf)),C.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,C.reflectivity.value=E.reflectivity,C.ior.value=E.ior,C.refractionRatio.value=E.refractionRatio),E.lightMap&&(C.lightMap.value=E.lightMap,C.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,C.lightMapTransform)),E.aoMap&&(C.aoMap.value=E.aoMap,C.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,C.aoMapTransform))}function a(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform))}function l(C,E){C.dashSize.value=E.dashSize,C.totalSize.value=E.dashSize+E.gapSize,C.scale.value=E.scale}function u(C,E,O,U){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.size.value=E.size*O,C.scale.value=U*.5,E.map&&(C.map.value=E.map,t(E.map,C.uvTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function h(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.rotation.value=E.rotation,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function m(C,E){C.specular.value.copy(E.specular),C.shininess.value=Math.max(E.shininess,1e-4)}function v(C,E){E.gradientMap&&(C.gradientMap.value=E.gradientMap)}function x(C,E){C.metalness.value=E.metalness,E.metalnessMap&&(C.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,C.metalnessMapTransform)),C.roughness.value=E.roughness,E.roughnessMap&&(C.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,C.roughnessMapTransform)),E.envMap&&(C.envMapIntensity.value=E.envMapIntensity)}function S(C,E,O){C.ior.value=E.ior,E.sheen>0&&(C.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),C.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(C.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,C.sheenColorMapTransform)),E.sheenRoughnessMap&&(C.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,C.sheenRoughnessMapTransform))),E.clearcoat>0&&(C.clearcoat.value=E.clearcoat,C.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(C.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,C.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(C.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,C.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(C.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,C.clearcoatNormalMapTransform),C.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===or&&C.clearcoatNormalScale.value.negate())),E.dispersion>0&&(C.dispersion.value=E.dispersion),E.iridescence>0&&(C.iridescence.value=E.iridescence,C.iridescenceIOR.value=E.iridescenceIOR,C.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],C.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(C.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,C.iridescenceMapTransform)),E.iridescenceThicknessMap&&(C.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,C.iridescenceThicknessMapTransform))),E.transmission>0&&(C.transmission.value=E.transmission,C.transmissionSamplerMap.value=O.texture,C.transmissionSamplerSize.value.set(O.width,O.height),E.transmissionMap&&(C.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,C.transmissionMapTransform)),C.thickness.value=E.thickness,E.thicknessMap&&(C.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,C.thicknessMapTransform)),C.attenuationDistance.value=E.attenuationDistance,C.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(C.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(C.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,C.anisotropyMapTransform))),C.specularIntensity.value=E.specularIntensity,C.specularColor.value.copy(E.specularColor),E.specularColorMap&&(C.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,C.specularColorMapTransform)),E.specularIntensityMap&&(C.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,C.specularIntensityMapTransform))}function T(C,E){E.matcap&&(C.matcap.value=E.matcap)}function N(C,E){const O=e.get(E).light;C.referencePosition.value.setFromMatrixPosition(O.matrixWorld),C.nearDistance.value=O.shadow.camera.near,C.farDistance.value=O.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function IH(i,e,t,n){let r={},s={},a=[];const l=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(O,U){const I=U.program;n.uniformBlockBinding(O,I)}function h(O,U){let I=r[O.id];I===void 0&&(T(O),I=m(O),r[O.id]=I,O.addEventListener("dispose",C));const j=U.program;n.updateUBOMapping(O,j);const z=e.render.frame;s[O.id]!==z&&(x(O),s[O.id]=z)}function m(O){const U=v();O.__bindingPointIndex=U;const I=i.createBuffer(),j=O.__size,z=O.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,j,z),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,U,I),I}function v(){for(let O=0;O0&&(I+=j-z),O.__size=I,O.__cache={},this}function N(O){const U={boundary:0,storage:0};return typeof O=="number"||typeof O=="boolean"?(U.boundary=4,U.storage=4):O.isVector2?(U.boundary=8,U.storage=8):O.isVector3||O.isColor?(U.boundary=16,U.storage=12):O.isVector4?(U.boundary=16,U.storage=16):O.isMatrix3?(U.boundary=48,U.storage=48):O.isMatrix4?(U.boundary=64,U.storage=64):O.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",O),U}function C(O){const U=O.target;U.removeEventListener("dispose",C);const I=a.indexOf(U.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[U.id]),delete r[U.id],delete s[U.id]}function E(){for(const O in r)i.deleteBuffer(r[O]);a=[],r={},s={}}return{bind:u,update:h,dispose:E}}class FH{constructor(e={}){const{canvas:t=q7(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:l=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:h=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:v=!1,reverseDepthBuffer:x=!1}=e;this.isWebGLRenderer=!0;let S;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");S=n.getContextAttributes().alpha}else S=a;const T=new Uint32Array(4),N=new Int32Array(4);let C=null,E=null;const O=[],U=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=bn,this.toneMapping=Ya,this.toneMappingExposure=1;const I=this;let j=!1,z=0,G=0,H=null,q=-1,V=null;const Q=new On,J=new On;let ne=null;const oe=new cn(0);let ie=0,Z=t.width,te=t.height,de=1,Se=null,Te=null;const ae=new On(0,0,Z,te),Me=new On(0,0,Z,te);let Ve=!1;const Ce=new Og;let Fe=!1,et=!1;this.transmissionResolutionScale=1;const He=new jn,Rt=new jn,Et=new me,zt=new On,Pt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let We=!1;function ft(){return H===null?de:1}let fe=n;function Wt(ce,Ge){return t.getContext(ce,Ge)}try{const ce={alpha:!0,depth:r,stencil:s,antialias:l,premultipliedAlpha:u,preserveDrawingBuffer:h,powerPreference:m,failIfMajorPerformanceCaveat:v};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${F0}`),t.addEventListener("webglcontextlost",Tt,!1),t.addEventListener("webglcontextrestored",Ht,!1),t.addEventListener("webglcontextcreationerror",Yt,!1),fe===null){const Ge="webgl2";if(fe=Wt(Ge,ce),fe===null)throw Wt(Ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ce){throw console.error("THREE.WebGLRenderer: "+ce.message),ce}let yt,Gt,_t,Xt,pt,Ae,k,be,Oe,pe,le,Ne,De,Je,we,Ue,ut,Dt,Bt,ct,jt,Jt,In,ge;function Ot(){yt=new $V(fe),yt.init(),Jt=new NH(fe,yt),Gt=new GV(fe,yt,e,Jt),_t=new EH(fe,yt),Gt.reverseDepthBuffer&&x&&_t.buffers.depth.setReversed(!0),Xt=new QV(fe),pt=new AH,Ae=new CH(fe,yt,_t,pt,Gt,Jt,Xt),k=new VV(I),be=new WV(I),Oe=new iG(fe),In=new kV(fe,Oe),pe=new XV(fe,Oe,Xt,In),le=new ZV(fe,pe,Oe,Xt),Bt=new KV(fe,Gt,Ae),Ue=new qV(pt),Ne=new dH(I,k,be,yt,Gt,In,Ue),De=new OH(I,pt),Je=new mH,we=new bH(yt),Dt=new FV(I,k,be,_t,le,S,u),ut=new TH(I,le,Gt),ge=new IH(fe,Xt,Gt,_t),ct=new zV(fe,yt,Xt),jt=new YV(fe,yt,Xt),Xt.programs=Ne.programs,I.capabilities=Gt,I.extensions=yt,I.properties=pt,I.renderLists=Je,I.shadowMap=ut,I.state=_t,I.info=Xt}Ot();const ot=new UH(I,fe);this.xr=ot,this.getContext=function(){return fe},this.getContextAttributes=function(){return fe.getContextAttributes()},this.forceContextLoss=function(){const ce=yt.get("WEBGL_lose_context");ce&&ce.loseContext()},this.forceContextRestore=function(){const ce=yt.get("WEBGL_lose_context");ce&&ce.restoreContext()},this.getPixelRatio=function(){return de},this.setPixelRatio=function(ce){ce!==void 0&&(de=ce,this.setSize(Z,te,!1))},this.getSize=function(ce){return ce.set(Z,te)},this.setSize=function(ce,Ge,rt=!0){if(ot.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Z=ce,te=Ge,t.width=Math.floor(ce*de),t.height=Math.floor(Ge*de),rt===!0&&(t.style.width=ce+"px",t.style.height=Ge+"px"),this.setViewport(0,0,ce,Ge)},this.getDrawingBufferSize=function(ce){return ce.set(Z*de,te*de).floor()},this.setDrawingBufferSize=function(ce,Ge,rt){Z=ce,te=Ge,de=rt,t.width=Math.floor(ce*rt),t.height=Math.floor(Ge*rt),this.setViewport(0,0,ce,Ge)},this.getCurrentViewport=function(ce){return ce.copy(Q)},this.getViewport=function(ce){return ce.copy(ae)},this.setViewport=function(ce,Ge,rt,it){ce.isVector4?ae.set(ce.x,ce.y,ce.z,ce.w):ae.set(ce,Ge,rt,it),_t.viewport(Q.copy(ae).multiplyScalar(de).round())},this.getScissor=function(ce){return ce.copy(Me)},this.setScissor=function(ce,Ge,rt,it){ce.isVector4?Me.set(ce.x,ce.y,ce.z,ce.w):Me.set(ce,Ge,rt,it),_t.scissor(J.copy(Me).multiplyScalar(de).round())},this.getScissorTest=function(){return Ve},this.setScissorTest=function(ce){_t.setScissorTest(Ve=ce)},this.setOpaqueSort=function(ce){Se=ce},this.setTransparentSort=function(ce){Te=ce},this.getClearColor=function(ce){return ce.copy(Dt.getClearColor())},this.setClearColor=function(){Dt.setClearColor.apply(Dt,arguments)},this.getClearAlpha=function(){return Dt.getClearAlpha()},this.setClearAlpha=function(){Dt.setClearAlpha.apply(Dt,arguments)},this.clear=function(ce=!0,Ge=!0,rt=!0){let it=0;if(ce){let qe=!1;if(H!==null){const qt=H.texture.format;qe=qt===G0||qt===z0||qt===k0}if(qe){const qt=H.texture.type,Qt=qt===ra||qt===Nr||qt===bl||qt===lu||qt===hy||qt===fy,he=Dt.getClearColor(),X=Dt.getClearAlpha(),tt=he.r,en=he.g,sn=he.b;Qt?(T[0]=tt,T[1]=en,T[2]=sn,T[3]=X,fe.clearBufferuiv(fe.COLOR,0,T)):(N[0]=tt,N[1]=en,N[2]=sn,N[3]=X,fe.clearBufferiv(fe.COLOR,0,N))}else it|=fe.COLOR_BUFFER_BIT}Ge&&(it|=fe.DEPTH_BUFFER_BIT),rt&&(it|=fe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),fe.clear(it)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Tt,!1),t.removeEventListener("webglcontextrestored",Ht,!1),t.removeEventListener("webglcontextcreationerror",Yt,!1),Dt.dispose(),Je.dispose(),we.dispose(),pt.dispose(),k.dispose(),be.dispose(),le.dispose(),In.dispose(),ge.dispose(),Ne.dispose(),ot.dispose(),ot.removeEventListener("sessionstart",Ze),ot.removeEventListener("sessionend",dt),Vt.stop()};function Tt(ce){ce.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),j=!0}function Ht(){console.log("THREE.WebGLRenderer: Context Restored."),j=!1;const ce=Xt.autoReset,Ge=ut.enabled,rt=ut.autoUpdate,it=ut.needsUpdate,qe=ut.type;Ot(),Xt.autoReset=ce,ut.enabled=Ge,ut.autoUpdate=rt,ut.needsUpdate=it,ut.type=qe}function Yt(ce){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ce.statusMessage)}function pn(ce){const Ge=ce.target;Ge.removeEventListener("dispose",pn),$e(Ge)}function $e(ce){St(ce),pt.remove(ce)}function St(ce){const Ge=pt.get(ce).programs;Ge!==void 0&&(Ge.forEach(function(rt){Ne.releaseProgram(rt)}),ce.isShaderMaterial&&Ne.releaseShaderCache(ce))}this.renderBufferDirect=function(ce,Ge,rt,it,qe,qt){Ge===null&&(Ge=Pt);const Qt=qe.isMesh&&qe.matrixWorld.determinant()<0,he=lr(ce,Ge,rt,it,qe);_t.setMaterial(it,Qt);let X=rt.index,tt=1;if(it.wireframe===!0){if(X=pe.getWireframeAttribute(rt),X===void 0)return;tt=2}const en=rt.drawRange,sn=rt.attributes.position;let Tn=en.start*tt,Rn=(en.start+en.count)*tt;qt!==null&&(Tn=Math.max(Tn,qt.start*tt),Rn=Math.min(Rn,(qt.start+qt.count)*tt)),X!==null?(Tn=Math.max(Tn,0),Rn=Math.min(Rn,X.count)):sn!=null&&(Tn=Math.max(Tn,0),Rn=Math.min(Rn,sn.count));const xi=Rn-Tn;if(xi<0||xi===1/0)return;In.setup(qe,it,he,rt,X);let K,hn=ct;if(X!==null&&(K=Oe.get(X),hn=jt,hn.setIndex(K)),qe.isMesh)it.wireframe===!0?(_t.setLineWidth(it.wireframeLinewidth*ft()),hn.setMode(fe.LINES)):hn.setMode(fe.TRIANGLES);else if(qe.isLine){let Zt=it.linewidth;Zt===void 0&&(Zt=1),_t.setLineWidth(Zt*ft()),qe.isLineSegments?hn.setMode(fe.LINES):qe.isLineLoop?hn.setMode(fe.LINE_LOOP):hn.setMode(fe.LINE_STRIP)}else qe.isPoints?hn.setMode(fe.POINTS):qe.isSprite&&hn.setMode(fe.TRIANGLES);if(qe.isBatchedMesh)if(qe._multiDrawInstances!==null)hn.renderMultiDrawInstances(qe._multiDrawStarts,qe._multiDrawCounts,qe._multiDrawCount,qe._multiDrawInstances);else if(yt.get("WEBGL_multi_draw"))hn.renderMultiDraw(qe._multiDrawStarts,qe._multiDrawCounts,qe._multiDrawCount);else{const Zt=qe._multiDrawStarts,gr=qe._multiDrawCounts,ui=qe._multiDrawCount,vr=X?Oe.get(X).bytesPerElement:1,Ps=pt.get(it).currentProgram.getUniforms();for(let ys=0;ys{function qt(){if(it.forEach(function(Qt){pt.get(Qt).currentProgram.isReady()&&it.delete(Qt)}),it.size===0){qe(ce);return}setTimeout(qt,10)}yt.get("KHR_parallel_shader_compile")!==null?qt():setTimeout(qt,10)})};let wn=null;function qn(ce){wn&&wn(ce)}function Ze(){Vt.stop()}function dt(){Vt.start()}const Vt=new fD;Vt.setAnimationLoop(qn),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(ce){wn=ce,ot.setAnimationLoop(ce),ce===null?Vt.stop():Vt.start()},ot.addEventListener("sessionstart",Ze),ot.addEventListener("sessionend",dt),this.render=function(ce,Ge){if(Ge!==void 0&&Ge.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(j===!0)return;if(ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),Ge.parent===null&&Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),ot.enabled===!0&&ot.isPresenting===!0&&(ot.cameraAutoUpdate===!0&&ot.updateCamera(Ge),Ge=ot.getCamera()),ce.isScene===!0&&ce.onBeforeRender(I,ce,Ge,H),E=we.get(ce,U.length),E.init(Ge),U.push(E),Rt.multiplyMatrices(Ge.projectionMatrix,Ge.matrixWorldInverse),Ce.setFromProjectionMatrix(Rt),et=this.localClippingEnabled,Fe=Ue.init(this.clippingPlanes,et),C=Je.get(ce,O.length),C.init(),O.push(C),ot.enabled===!0&&ot.isPresenting===!0){const qt=I.xr.getDepthSensingMesh();qt!==null&&xt(qt,Ge,-1/0,I.sortObjects)}xt(ce,Ge,0,I.sortObjects),C.finish(),I.sortObjects===!0&&C.sort(Se,Te),We=ot.enabled===!1||ot.isPresenting===!1||ot.hasDepthSensing()===!1,We&&Dt.addToRenderList(C,ce),this.info.render.frame++,Fe===!0&&Ue.beginShadows();const rt=E.state.shadowsArray;ut.render(rt,ce,Ge),Fe===!0&&Ue.endShadows(),this.info.autoReset===!0&&this.info.reset();const it=C.opaque,qe=C.transmissive;if(E.setupLights(),Ge.isArrayCamera){const qt=Ge.cameras;if(qe.length>0)for(let Qt=0,he=qt.length;Qt0&&ee(it,qe,ce,Ge),We&&Dt.render(ce),A(C,ce,Ge);H!==null&&G===0&&(Ae.updateMultisampleRenderTarget(H),Ae.updateRenderTargetMipmap(H)),ce.isScene===!0&&ce.onAfterRender(I,ce,Ge),In.resetDefaultState(),q=-1,V=null,U.pop(),U.length>0?(E=U[U.length-1],Fe===!0&&Ue.setGlobalState(I.clippingPlanes,E.state.camera)):E=null,O.pop(),O.length>0?C=O[O.length-1]:C=null};function xt(ce,Ge,rt,it){if(ce.visible===!1)return;if(ce.layers.test(Ge.layers)){if(ce.isGroup)rt=ce.renderOrder;else if(ce.isLOD)ce.autoUpdate===!0&&ce.update(Ge);else if(ce.isLight)E.pushLight(ce),ce.castShadow&&E.pushShadow(ce);else if(ce.isSprite){if(!ce.frustumCulled||Ce.intersectsSprite(ce)){it&&zt.setFromMatrixPosition(ce.matrixWorld).applyMatrix4(Rt);const Qt=le.update(ce),he=ce.material;he.visible&&C.push(ce,Qt,he,rt,zt.z,null)}}else if((ce.isMesh||ce.isLine||ce.isPoints)&&(!ce.frustumCulled||Ce.intersectsObject(ce))){const Qt=le.update(ce),he=ce.material;if(it&&(ce.boundingSphere!==void 0?(ce.boundingSphere===null&&ce.computeBoundingSphere(),zt.copy(ce.boundingSphere.center)):(Qt.boundingSphere===null&&Qt.computeBoundingSphere(),zt.copy(Qt.boundingSphere.center)),zt.applyMatrix4(ce.matrixWorld).applyMatrix4(Rt)),Array.isArray(he)){const X=Qt.groups;for(let tt=0,en=X.length;tt0&&Vn(qe,Ge,rt),qt.length>0&&Vn(qt,Ge,rt),Qt.length>0&&Vn(Qt,Ge,rt),_t.buffers.depth.setTest(!0),_t.buffers.depth.setMask(!0),_t.buffers.color.setMask(!0),_t.setPolygonOffset(!1)}function ee(ce,Ge,rt,it){if((rt.isScene===!0?rt.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[it.id]===void 0&&(E.state.transmissionRenderTarget[it.id]=new Fh(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")||yt.has("EXT_color_buffer_float")?Gs:ra,minFilter:za,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:li.workingColorSpace}));const qt=E.state.transmissionRenderTarget[it.id],Qt=it.viewport||Q;qt.setSize(Qt.z*I.transmissionResolutionScale,Qt.w*I.transmissionResolutionScale);const he=I.getRenderTarget();I.setRenderTarget(qt),I.getClearColor(oe),ie=I.getClearAlpha(),ie<1&&I.setClearColor(16777215,.5),I.clear(),We&&Dt.render(rt);const X=I.toneMapping;I.toneMapping=Ya;const tt=it.viewport;if(it.viewport!==void 0&&(it.viewport=void 0),E.setupLightsView(it),Fe===!0&&Ue.setGlobalState(I.clippingPlanes,it),Vn(ce,rt,it),Ae.updateMultisampleRenderTarget(qt),Ae.updateRenderTargetMipmap(qt),yt.has("WEBGL_multisampled_render_to_texture")===!1){let en=!1;for(let sn=0,Tn=Ge.length;sn0),sn=!!rt.morphAttributes.position,Tn=!!rt.morphAttributes.normal,Rn=!!rt.morphAttributes.color;let xi=Ya;it.toneMapped&&(H===null||H.isXRRenderTarget===!0)&&(xi=I.toneMapping);const K=rt.morphAttributes.position||rt.morphAttributes.normal||rt.morphAttributes.color,hn=K!==void 0?K.length:0,Zt=pt.get(it),gr=E.state.lights;if(Fe===!0&&(et===!0||ce!==V)){const _r=ce===V&&it.id===q;Ue.setState(it,ce,_r)}let ui=!1;it.version===Zt.__version?(Zt.needsLights&&Zt.lightsStateVersion!==gr.state.version||Zt.outputColorSpace!==he||qe.isBatchedMesh&&Zt.batching===!1||!qe.isBatchedMesh&&Zt.batching===!0||qe.isBatchedMesh&&Zt.batchingColor===!0&&qe.colorTexture===null||qe.isBatchedMesh&&Zt.batchingColor===!1&&qe.colorTexture!==null||qe.isInstancedMesh&&Zt.instancing===!1||!qe.isInstancedMesh&&Zt.instancing===!0||qe.isSkinnedMesh&&Zt.skinning===!1||!qe.isSkinnedMesh&&Zt.skinning===!0||qe.isInstancedMesh&&Zt.instancingColor===!0&&qe.instanceColor===null||qe.isInstancedMesh&&Zt.instancingColor===!1&&qe.instanceColor!==null||qe.isInstancedMesh&&Zt.instancingMorph===!0&&qe.morphTexture===null||qe.isInstancedMesh&&Zt.instancingMorph===!1&&qe.morphTexture!==null||Zt.envMap!==X||it.fog===!0&&Zt.fog!==qt||Zt.numClippingPlanes!==void 0&&(Zt.numClippingPlanes!==Ue.numPlanes||Zt.numIntersection!==Ue.numIntersection)||Zt.vertexAlphas!==tt||Zt.vertexTangents!==en||Zt.morphTargets!==sn||Zt.morphNormals!==Tn||Zt.morphColors!==Rn||Zt.toneMapping!==xi||Zt.morphTargetsCount!==hn)&&(ui=!0):(ui=!0,Zt.__version=it.version);let vr=Zt.currentProgram;ui===!0&&(vr=$n(it,Ge,qe));let Ps=!1,ys=!1,Vr=!1;const Di=vr.getUniforms(),sr=Zt.uniforms;if(_t.useProgram(vr.program)&&(Ps=!0,ys=!0,Vr=!0),it.id!==q&&(q=it.id,ys=!0),Ps||V!==ce){_t.buffers.depth.getReversed()?(He.copy(ce.projectionMatrix),Nk(He),Rk(He),Di.setValue(fe,"projectionMatrix",He)):Di.setValue(fe,"projectionMatrix",ce.projectionMatrix),Di.setValue(fe,"viewMatrix",ce.matrixWorldInverse);const Jr=Di.map.cameraPosition;Jr!==void 0&&Jr.setValue(fe,Et.setFromMatrixPosition(ce.matrixWorld)),Gt.logarithmicDepthBuffer&&Di.setValue(fe,"logDepthBufFC",2/(Math.log(ce.far+1)/Math.LN2)),(it.isMeshPhongMaterial||it.isMeshToonMaterial||it.isMeshLambertMaterial||it.isMeshBasicMaterial||it.isMeshStandardMaterial||it.isShaderMaterial)&&Di.setValue(fe,"isOrthographic",ce.isOrthographicCamera===!0),V!==ce&&(V=ce,ys=!0,Vr=!0)}if(qe.isSkinnedMesh){Di.setOptional(fe,qe,"bindMatrix"),Di.setOptional(fe,qe,"bindMatrixInverse");const _r=qe.skeleton;_r&&(_r.boneTexture===null&&_r.computeBoneTexture(),Di.setValue(fe,"boneTexture",_r.boneTexture,Ae))}qe.isBatchedMesh&&(Di.setOptional(fe,qe,"batchingTexture"),Di.setValue(fe,"batchingTexture",qe._matricesTexture,Ae),Di.setOptional(fe,qe,"batchingIdTexture"),Di.setValue(fe,"batchingIdTexture",qe._indirectTexture,Ae),Di.setOptional(fe,qe,"batchingColorTexture"),qe._colorsTexture!==null&&Di.setValue(fe,"batchingColorTexture",qe._colorsTexture,Ae));const bi=rt.morphAttributes;if((bi.position!==void 0||bi.normal!==void 0||bi.color!==void 0)&&Bt.update(qe,rt,vr),(ys||Zt.receiveShadow!==qe.receiveShadow)&&(Zt.receiveShadow=qe.receiveShadow,Di.setValue(fe,"receiveShadow",qe.receiveShadow)),it.isMeshGouraudMaterial&&it.envMap!==null&&(sr.envMap.value=X,sr.flipEnvMap.value=X.isCubeTexture&&X.isRenderTargetTexture===!1?-1:1),it.isMeshStandardMaterial&&it.envMap===null&&Ge.environment!==null&&(sr.envMapIntensity.value=Ge.environmentIntensity),ys&&(Di.setValue(fe,"toneMappingExposure",I.toneMappingExposure),Zt.needsLights&&an(sr,Vr),qt&&it.fog===!0&&De.refreshFogUniforms(sr,qt),De.refreshMaterialUniforms(sr,it,de,te,E.state.transmissionRenderTarget[ce.id]),zv.upload(fe,dn(Zt),sr,Ae)),it.isShaderMaterial&&it.uniformsNeedUpdate===!0&&(zv.upload(fe,dn(Zt),sr,Ae),it.uniformsNeedUpdate=!1),it.isSpriteMaterial&&Di.setValue(fe,"center",qe.center),Di.setValue(fe,"modelViewMatrix",qe.modelViewMatrix),Di.setValue(fe,"normalMatrix",qe.normalMatrix),Di.setValue(fe,"modelMatrix",qe.matrixWorld),it.isShaderMaterial||it.isRawShaderMaterial){const _r=it.uniformsGroups;for(let Jr=0,Gc=_r.length;Jr0&&Ae.useMultisampledRTT(ce)===!1?qe=pt.get(ce).__webglMultisampledFramebuffer:Array.isArray(en)?qe=en[rt]:qe=en,Q.copy(ce.viewport),J.copy(ce.scissor),ne=ce.scissorTest}else Q.copy(ae).multiplyScalar(de).floor(),J.copy(Me).multiplyScalar(de).floor(),ne=Ve;if(rt!==0&&(qe=Er),_t.bindFramebuffer(fe.FRAMEBUFFER,qe)&&it&&_t.drawBuffers(ce,qe),_t.viewport(Q),_t.scissor(J),_t.setScissorTest(ne),qt){const X=pt.get(ce.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,X.__webglTexture,rt)}else if(Qt){const X=pt.get(ce.texture),tt=Ge;fe.framebufferTextureLayer(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,X.__webglTexture,rt,tt)}else if(ce!==null&&rt!==0){const X=pt.get(ce.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_2D,X.__webglTexture,rt)}q=-1},this.readRenderTargetPixels=function(ce,Ge,rt,it,qe,qt,Qt){if(!(ce&&ce.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let he=pt.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&Qt!==void 0&&(he=he[Qt]),he){_t.bindFramebuffer(fe.FRAMEBUFFER,he);try{const X=ce.texture,tt=X.format,en=X.type;if(!Gt.textureFormatReadable(tt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Gt.textureTypeReadable(en)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ge>=0&&Ge<=ce.width-it&&rt>=0&&rt<=ce.height-qe&&fe.readPixels(Ge,rt,it,qe,Jt.convert(tt),Jt.convert(en),qt)}finally{const X=H!==null?pt.get(H).__webglFramebuffer:null;_t.bindFramebuffer(fe.FRAMEBUFFER,X)}}},this.readRenderTargetPixelsAsync=async function(ce,Ge,rt,it,qe,qt,Qt){if(!(ce&&ce.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let he=pt.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&Qt!==void 0&&(he=he[Qt]),he){const X=ce.texture,tt=X.format,en=X.type;if(!Gt.textureFormatReadable(tt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Gt.textureTypeReadable(en))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(Ge>=0&&Ge<=ce.width-it&&rt>=0&&rt<=ce.height-qe){_t.bindFramebuffer(fe.FRAMEBUFFER,he);const sn=fe.createBuffer();fe.bindBuffer(fe.PIXEL_PACK_BUFFER,sn),fe.bufferData(fe.PIXEL_PACK_BUFFER,qt.byteLength,fe.STREAM_READ),fe.readPixels(Ge,rt,it,qe,Jt.convert(tt),Jt.convert(en),0);const Tn=H!==null?pt.get(H).__webglFramebuffer:null;_t.bindFramebuffer(fe.FRAMEBUFFER,Tn);const Rn=fe.fenceSync(fe.SYNC_GPU_COMMANDS_COMPLETE,0);return fe.flush(),await Ck(fe,Rn,4),fe.bindBuffer(fe.PIXEL_PACK_BUFFER,sn),fe.getBufferSubData(fe.PIXEL_PACK_BUFFER,0,qt),fe.deleteBuffer(sn),fe.deleteSync(Rn),qt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(ce,Ge=null,rt=0){ce.isTexture!==!0&&(Uf("WebGLRenderer: copyFramebufferToTexture function signature has changed."),Ge=arguments[0]||null,ce=arguments[1]);const it=Math.pow(2,-rt),qe=Math.floor(ce.image.width*it),qt=Math.floor(ce.image.height*it),Qt=Ge!==null?Ge.x:0,he=Ge!==null?Ge.y:0;Ae.setTexture2D(ce,0),fe.copyTexSubImage2D(fe.TEXTURE_2D,rt,0,0,Qt,he,qe,qt),_t.unbindTexture()};const Wi=fe.createFramebuffer(),No=fe.createFramebuffer();this.copyTextureToTexture=function(ce,Ge,rt=null,it=null,qe=0,qt=null){ce.isTexture!==!0&&(Uf("WebGLRenderer: copyTextureToTexture function signature has changed."),it=arguments[0]||null,ce=arguments[1],Ge=arguments[2],qt=arguments[3]||0,rt=null),qt===null&&(qe!==0?(Uf("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),qt=qe,qe=0):qt=0);let Qt,he,X,tt,en,sn,Tn,Rn,xi;const K=ce.isCompressedTexture?ce.mipmaps[qt]:ce.image;if(rt!==null)Qt=rt.max.x-rt.min.x,he=rt.max.y-rt.min.y,X=rt.isBox3?rt.max.z-rt.min.z:1,tt=rt.min.x,en=rt.min.y,sn=rt.isBox3?rt.min.z:0;else{const bi=Math.pow(2,-qe);Qt=Math.floor(K.width*bi),he=Math.floor(K.height*bi),ce.isDataArrayTexture?X=K.depth:ce.isData3DTexture?X=Math.floor(K.depth*bi):X=1,tt=0,en=0,sn=0}it!==null?(Tn=it.x,Rn=it.y,xi=it.z):(Tn=0,Rn=0,xi=0);const hn=Jt.convert(Ge.format),Zt=Jt.convert(Ge.type);let gr;Ge.isData3DTexture?(Ae.setTexture3D(Ge,0),gr=fe.TEXTURE_3D):Ge.isDataArrayTexture||Ge.isCompressedArrayTexture?(Ae.setTexture2DArray(Ge,0),gr=fe.TEXTURE_2D_ARRAY):(Ae.setTexture2D(Ge,0),gr=fe.TEXTURE_2D),fe.pixelStorei(fe.UNPACK_FLIP_Y_WEBGL,Ge.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ge.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,Ge.unpackAlignment);const ui=fe.getParameter(fe.UNPACK_ROW_LENGTH),vr=fe.getParameter(fe.UNPACK_IMAGE_HEIGHT),Ps=fe.getParameter(fe.UNPACK_SKIP_PIXELS),ys=fe.getParameter(fe.UNPACK_SKIP_ROWS),Vr=fe.getParameter(fe.UNPACK_SKIP_IMAGES);fe.pixelStorei(fe.UNPACK_ROW_LENGTH,K.width),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,K.height),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,tt),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,en),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,sn);const Di=ce.isDataArrayTexture||ce.isData3DTexture,sr=Ge.isDataArrayTexture||Ge.isData3DTexture;if(ce.isDepthTexture){const bi=pt.get(ce),_r=pt.get(Ge),Jr=pt.get(bi.__renderTarget),Gc=pt.get(_r.__renderTarget);_t.bindFramebuffer(fe.READ_FRAMEBUFFER,Jr.__webglFramebuffer),_t.bindFramebuffer(fe.DRAW_FRAMEBUFFER,Gc.__webglFramebuffer);for(let xs=0;xs=-1&&AA.z<=1&&T.layers.test(C.layers)===!0,O=T.element;O.style.display=E===!0?"":"none",E===!0&&(T.onBeforeRender(t,N,C),O.style.transform="translate("+-100*T.center.x+"%,"+-100*T.center.y+"%)translate("+(AA.x*s+s)+"px,"+(-AA.y*a+a)+"px)",O.parentNode!==u&&u.appendChild(O),T.onAfterRender(t,N,C));const U={distanceToCameraSquared:v(C,T)};l.objects.set(T,U)}for(let E=0,O=T.children.length;E=e||G<0||v&&H>=s}function E(){var z=L3();if(C(z))return O(z);l=setTimeout(E,N(z))}function O(z){return l=void 0,x&&n?S(z):(n=r=void 0,a)}function U(){l!==void 0&&clearTimeout(l),h=0,n=u=r=l=void 0}function I(){return l===void 0?a:O(L3())}function j(){var z=L3(),G=C(z);if(n=arguments,r=this,u=z,G){if(l===void 0)return T(u);if(v)return clearTimeout(l),l=setTimeout(E,e),S(u)}return l===void 0&&(l=setTimeout(E,e)),a}return j.cancel=U,j.flush=I,j}function f5(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),vm=function(){return performance.now()},wy=(function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=vm()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(i[t],i[t-1],t-n):s(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},_D=(function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i})(),rw=new wy,la=(function(){function i(e,t){t===void 0&&(t=rw),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=os.Linear.None,this._interpolationFunction=iw.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=_D.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=vm()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,s){for(var a in n){var l=e[a],u=Array.isArray(l),h=u?"array":typeof l,m=!u&&Array.isArray(n[a]);if(!(h==="undefined"||h==="function")){if(m){var v=n[a];if(v.length===0)continue;for(var x=[l],S=0,T=v.length;S"u"||s)&&(t[a]=l),u||(t[a]*=1),m?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=vm()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=vm()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;ea)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,eh)return 1;var C=Math.trunc(l/u),E=l-C*u,O=Math.min(E/n._duration,1);return O===0&&l===n._duration?1:O},v=m(),x=this._easingFunction(v);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,x),this._onUpdateCallback&&this._onUpdateCallback(this._object,v),this._duration===0||l>=this._duration)if(this._repeat>0){var S=Math.min(Math.trunc((l-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=S);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*S,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var T=0,N=this._chainedTweens.length;T=(T=(u+v)/2))?u=T:v=T,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C,s=a,!(a=a[G=z<<2|j<<1|I]))return s[G]=l,i;if(E=+i._x.call(null,a.data),O=+i._y.call(null,a.data),U=+i._z.call(null,a.data),e===E&&t===O&&n===U)return l.next=a,s?s[G]=l:i._root=l,i;do s=s?s[G]=new Array(8):i._root=new Array(8),(I=e>=(T=(u+v)/2))?u=T:v=T,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C;while((G=z<<2|j<<1|I)===(H=(U>=C)<<2|(O>=N)<<1|E>=T));return s[H]=a,s[G]=l,i}function bW(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),n=new Float64Array(e),r=new Float64Array(e);let s=1/0,a=1/0,l=1/0,u=-1/0,h=-1/0,m=-1/0;for(let v=0,x,S,T,N;vu&&(u=S),Th&&(h=T),Nm&&(m=N));if(s>u||a>h||l>m)return this;this.cover(s,a,l).cover(u,h,m);for(let v=0;vi||i>=a||r>e||e>=l||s>t||t>=u;)switch(x=(tT||(h=U.y0)>N||(m=U.z0)>C||(v=U.x1)=G)<<2|(e>=z)<<1|i>=j)&&(U=E[E.length-1],E[E.length-1]=E[E.length-1-I],E[E.length-1-I]=U)}else{var H=i-+this._x.call(null,O.data),q=e-+this._y.call(null,O.data),V=t-+this._z.call(null,O.data),Q=H*H+q*q+V*V;if(QMath.sqrt((i-n)**2+(e-r)**2+(t-s)**2);function CW(i,e,t,n){const r=[],s=i-n,a=e-n,l=t-n,u=i+n,h=e+n,m=t+n;return this.visit((v,x,S,T,N,C,E)=>{if(!v.length)do{const O=v.data;EW(i,e,t,this._x(O),this._y(O),this._z(O))<=n&&r.push(O)}while(v=v.next);return x>u||S>h||T>m||N=(N=(a+h)/2))?a=N:h=N,(U=S>=(C=(l+m)/2))?l=C:m=C,(I=T>=(E=(u+v)/2))?u=E:v=E,e=t,!(t=t[j=I<<2|U<<1|O]))return this;if(!t.length)break;(e[j+1&7]||e[j+2&7]||e[j+3&7]||e[j+4&7]||e[j+5&7]||e[j+6&7]||e[j+7&7])&&(n=e,z=j)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[j]=s:delete e[j],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[z]=t:this._root=t),this):(this._root=s,this)}function RW(i){for(var e=0,t=i.length;ee?1:i>=e?0:NaN}function GW(i,e){return i==null||e==null?NaN:ei?1:e>=i?0:NaN}function bD(i){let e,t,n;i.length!==2?(e=Gv,t=(l,u)=>Gv(i(l),u),n=(l,u)=>i(l)-u):(e=i===Gv||i===GW?i:qW,t=i,n=i);function r(l,u,h=0,m=l.length){if(h>>1;t(l[v],u)<0?h=v+1:m=v}while(h>>1;t(l[v],u)<=0?h=v+1:m=v}while(hh&&n(l[v-1],u)>-n(l[v],u)?v-1:v}return{left:r,center:a,right:s}}function qW(){return 0}function VW(i){return i===null?NaN:+i}const jW=bD(Gv),SD=jW.right;bD(VW).center;function h_(i,e){let t,n;if(e===void 0)for(const r of i)r!=null&&(t===void 0?r>=r&&(t=n=r):(t>r&&(t=r),n=s&&(t=n=s):(t>s&&(t=s),n0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,s=r-(a-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(r=s*2,n=a+r,r==n-a&&(a=n))}return a}}const HW=Math.sqrt(50),WW=Math.sqrt(10),$W=Math.sqrt(2);function f_(i,e,t){const n=(e-i)/Math.max(0,t),r=Math.floor(Math.log10(n)),s=n/Math.pow(10,r),a=s>=HW?10:s>=WW?5:s>=$W?2:1;let l,u,h;return r<0?(h=Math.pow(10,-r)/a,l=Math.round(i*h),u=Math.round(e*h),l/he&&--u,h=-h):(h=Math.pow(10,r)*a,l=Math.round(i/h),u=Math.round(e/h),l*he&&--u),u0))return[];if(i===e)return[i];const n=e=r))return[];const l=s-r+1,u=new Array(l);if(n)if(a<0)for(let h=0;h=n)&&(t=n);return t}function KW(i,e){let t=0,n=0;if(e===void 0)for(let r of i)r!=null&&(r=+r)>=r&&(++t,n+=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*ZW(i){for(const e of i)yield*e}function og(i){return Array.from(ZW(i))}function zA(i,e,t){i=+i,e=+e,t=(r=arguments.length)<2?(e=i,i=0,1):r<3?1:+t;for(var n=-1,r=Math.max(0,Math.ceil((e-i)/t))|0,s=new Array(r);++n>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?$2(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?$2(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=t$.exec(i))?new Va(e[1],e[2],e[3],1):(e=n$.exec(i))?new Va(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=i$.exec(i))?$2(e[1],e[2],e[3],e[4]):(e=r$.exec(i))?$2(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=s$.exec(i))?y5(e[1],e[2]/100,e[3]/100,1):(e=a$.exec(i))?y5(e[1],e[2]/100,e[3]/100,e[4]):A5.hasOwnProperty(i)?g5(A5[i]):i==="transparent"?new Va(NaN,NaN,NaN,0):null}function g5(i){return new Va(i>>16&255,i>>8&255,i&255,1)}function $2(i,e,t,n){return n<=0&&(i=e=t=NaN),new Va(i,e,t,n)}function u$(i){return i instanceof Fg||(i=sd(i)),i?(i=i.rgb(),new Va(i.r,i.g,i.b,i.opacity)):new Va}function aw(i,e,t,n){return arguments.length===1?u$(i):new Va(i,e,t,n??1)}function Va(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}fM(Va,aw,TD(Fg,{brighter(i){return i=i==null?d_:Math.pow(d_,i),new Va(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?lg:Math.pow(lg,i),new Va(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new Va(Yf(this.r),Yf(this.g),Yf(this.b),A_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:v5,formatHex:v5,formatHex8:c$,formatRgb:_5,toString:_5}));function v5(){return`#${Gf(this.r)}${Gf(this.g)}${Gf(this.b)}`}function c$(){return`#${Gf(this.r)}${Gf(this.g)}${Gf(this.b)}${Gf((isNaN(this.opacity)?1:this.opacity)*255)}`}function _5(){const i=A_(this.opacity);return`${i===1?"rgb(":"rgba("}${Yf(this.r)}, ${Yf(this.g)}, ${Yf(this.b)}${i===1?")":`, ${i})`}`}function A_(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function Yf(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function Gf(i){return i=Yf(i),(i<16?"0":"")+i.toString(16)}function y5(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new xl(i,e,t,n)}function MD(i){if(i instanceof xl)return new xl(i.h,i.s,i.l,i.opacity);if(i instanceof Fg||(i=sd(i)),!i)return new xl;if(i instanceof xl)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,r=Math.min(e,t,n),s=Math.max(e,t,n),a=NaN,l=s-r,u=(s+r)/2;return l?(e===s?a=(t-n)/l+(t0&&u<1?0:a,new xl(a,l,u,i.opacity)}function h$(i,e,t,n){return arguments.length===1?MD(i):new xl(i,e,t,n??1)}function xl(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}fM(xl,h$,TD(Fg,{brighter(i){return i=i==null?d_:Math.pow(d_,i),new xl(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?lg:Math.pow(lg,i),new xl(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,r=2*t-n;return new Va(U3(i>=240?i-240:i+120,r,n),U3(i,r,n),U3(i<120?i+240:i-120,r,n),this.opacity)},clamp(){return new xl(x5(this.h),X2(this.s),X2(this.l),A_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=A_(this.opacity);return`${i===1?"hsl(":"hsla("}${x5(this.h)}, ${X2(this.s)*100}%, ${X2(this.l)*100}%${i===1?")":`, ${i})`}`}}));function x5(i){return i=(i||0)%360,i<0?i+360:i}function X2(i){return Math.max(0,Math.min(1,i||0))}function U3(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const dM=i=>()=>i;function f$(i,e){return function(t){return i+t*e}}function d$(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function A$(i){return(i=+i)==1?ED:function(e,t){return t-e?d$(e,t,i):dM(isNaN(e)?t:e)}}function ED(i,e){var t=e-i;return t?f$(i,t):dM(isNaN(i)?e:i)}const b5=(function i(e){var t=A$(e);function n(r,s){var a=t((r=aw(r)).r,(s=aw(s)).r),l=t(r.g,s.g),u=t(r.b,s.b),h=ED(r.opacity,s.opacity);return function(m){return r.r=a(m),r.g=l(m),r.b=u(m),r.opacity=h(m),r+""}}return n.gamma=i,n})(1);function CD(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),r;return function(s){for(r=0;rt&&(s=e.slice(t,s),l[a]?l[a]+=s:l[++a]=s),(n=n[0])===(r=r[0])?l[a]?l[a]+=r:l[++a]=r:(l[++a]=null,u.push({i:a,x:cg(n,r)})),t=B3.lastIndex;return te&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function T$(i,e,t){var n=i[0],r=i[1],s=e[0],a=e[1];return r2?M$:T$,u=h=null,v}function v(x){return x==null||isNaN(x=+x)?s:(u||(u=l(i.map(n),e,t)))(n(a(x)))}return v.invert=function(x){return a(r((h||(h=l(e,i.map(n),cg)))(x)))},v.domain=function(x){return arguments.length?(i=Array.from(x,S$),m()):i.slice()},v.range=function(x){return arguments.length?(e=Array.from(x),m()):e.slice()},v.rangeRound=function(x){return e=Array.from(x),t=x$,m()},v.clamp=function(x){return arguments.length?(a=x?!0:GA,m()):a!==GA},v.interpolate=function(x){return arguments.length?(t=x,m()):t},v.unknown=function(x){return arguments.length?(s=x,v):s},function(x,S){return n=x,r=S,m()}}function N$(){return C$()(GA,GA)}function R$(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function p_(i,e){if(!isFinite(i)||i===0)return null;var t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"),n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function S0(i){return i=p_(Math.abs(i)),i?i[1]:NaN}function D$(i,e){return function(t,n){for(var r=t.length,s=[],a=0,l=i[0],u=0;r>0&&l>0&&(u+l+1>n&&(l=Math.max(1,n-u)),s.push(t.substring(r-=l,r+l)),!((u+=l+1)>n));)l=i[a=(a+1)%i.length];return s.reverse().join(e)}}function P$(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var L$=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function m_(i){if(!(e=L$.exec(i)))throw new Error("invalid format: "+i);var e;return new pM({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}m_.prototype=pM.prototype;function pM(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}pM.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function U$(i){e:for(var e=i.length,t=1,n=-1,r;t0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(r+1):i}var g_;function B$(i,e){var t=p_(i,e);if(!t)return g_=void 0,i.toPrecision(e);var n=t[0],r=t[1],s=r-(g_=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+p_(i,Math.max(0,e+s-1))[0]}function w5(i,e){var t=p_(i,e);if(!t)return i+"";var n=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}const T5={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:R$,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>w5(i*100,e),r:w5,s:B$,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function M5(i){return i}var E5=Array.prototype.map,C5=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function O$(i){var e=i.grouping===void 0||i.thousands===void 0?M5:D$(E5.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",r=i.decimal===void 0?".":i.decimal+"",s=i.numerals===void 0?M5:P$(E5.call(i.numerals,String)),a=i.percent===void 0?"%":i.percent+"",l=i.minus===void 0?"−":i.minus+"",u=i.nan===void 0?"NaN":i.nan+"";function h(v,x){v=m_(v);var S=v.fill,T=v.align,N=v.sign,C=v.symbol,E=v.zero,O=v.width,U=v.comma,I=v.precision,j=v.trim,z=v.type;z==="n"?(U=!0,z="g"):T5[z]||(I===void 0&&(I=12),j=!0,z="g"),(E||S==="0"&&T==="=")&&(E=!0,S="0",T="=");var G=(x&&x.prefix!==void 0?x.prefix:"")+(C==="$"?t:C==="#"&&/[boxX]/.test(z)?"0"+z.toLowerCase():""),H=(C==="$"?n:/[%p]/.test(z)?a:"")+(x&&x.suffix!==void 0?x.suffix:""),q=T5[z],V=/[defgprs%]/.test(z);I=I===void 0?6:/[gprs]/.test(z)?Math.max(1,Math.min(21,I)):Math.max(0,Math.min(20,I));function Q(J){var ne=G,oe=H,ie,Z,te;if(z==="c")oe=q(J)+oe,J="";else{J=+J;var de=J<0||1/J<0;if(J=isNaN(J)?u:q(Math.abs(J),I),j&&(J=U$(J)),de&&+J==0&&N!=="+"&&(de=!1),ne=(de?N==="("?N:l:N==="-"||N==="("?"":N)+ne,oe=(z==="s"&&!isNaN(J)&&g_!==void 0?C5[8+g_/3]:"")+oe+(de&&N==="("?")":""),V){for(ie=-1,Z=J.length;++iete||te>57){oe=(te===46?r+J.slice(ie+1):J.slice(ie))+oe,J=J.slice(0,ie);break}}}U&&!E&&(J=e(J,1/0));var Se=ne.length+J.length+oe.length,Te=Se>1)+ne+J+oe+Te.slice(Se);break;default:J=Te+ne+J+oe;break}return s(J)}return Q.toString=function(){return v+""},Q}function m(v,x){var S=Math.max(-8,Math.min(8,Math.floor(S0(x)/3)))*3,T=Math.pow(10,-S),N=h((v=m_(v),v.type="f",v),{suffix:C5[8+S/3]});return function(C){return N(T*C)}}return{format:h,formatPrefix:m}}var Y2,DD,PD;I$({thousands:",",grouping:[3],currency:["$",""]});function I$(i){return Y2=O$(i),DD=Y2.format,PD=Y2.formatPrefix,Y2}function F$(i){return Math.max(0,-S0(Math.abs(i)))}function k$(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(S0(e)/3)))*3-S0(Math.abs(i)))}function z$(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,S0(e)-S0(i))+1}function G$(i,e,t,n){var r=YW(i,e,t),s;switch(n=m_(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(s=k$(r,a))&&(n.precision=s),PD(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=z$(r,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=F$(r))&&(n.precision=s-(n.type==="%")*2);break}}return DD(n)}function LD(i){var e=i.domain;return i.ticks=function(t){var n=e();return XW(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var r=e();return G$(r[0],r[r.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),r=0,s=n.length-1,a=n[r],l=n[s],u,h,m=10;for(l0;){if(h=sw(a,l,t),h===u)return n[r]=a,n[s]=l,e(n);if(h>0)a=Math.floor(a/h)*h,l=Math.ceil(l/h)*h;else if(h<0)a=Math.ceil(a*h)/h,l=Math.floor(l*h)/h;else break;u=h}return i},i}function Ec(){var i=N$();return i.copy=function(){return E$(i,Ec())},wD.apply(i,arguments),LD(i)}function UD(){var i=0,e=1,t=1,n=[.5],r=[0,1],s;function a(u){return u!=null&&u<=u?r[SD(n,u,0,t)]:s}function l(){var u=-1;for(n=new Array(t);++u=t?[n[t-1],e]:[n[h-1],n[h]]},a.unknown=function(u){return arguments.length&&(s=u),a},a.thresholds=function(){return n.slice()},a.copy=function(){return UD().domain([i,e]).range(r).unknown(s)},wD.apply(LD(a),arguments)}var di=1e-6,v_=1e-12,Mi=Math.PI,ja=Mi/2,__=Mi/4,Eo=Mi*2,Fr=180/Mi,Yn=Mi/180,Zi=Math.abs,mM=Math.atan,Qo=Math.atan2,ni=Math.cos,Q2=Math.ceil,q$=Math.exp,uw=Math.hypot,V$=Math.log,Hn=Math.sin,j$=Math.sign||function(i){return i>0?1:i<0?-1:0},Cc=Math.sqrt,H$=Math.tan;function W$(i){return i>1?0:i<-1?Mi:Math.acos(i)}function Nc(i){return i>1?ja:i<-1?-ja:Math.asin(i)}function N5(i){return(i=Hn(i/2))*i}function na(){}function y_(i,e){i&&D5.hasOwnProperty(i.type)&&D5[i.type](i,e)}var R5={Feature:function(i,e){y_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n=0?1:-1,r=n*t,s=ni(e),a=Hn(e),l=dw*a,u=fw*s+l*ni(r),h=l*n*Hn(r);x_.add(Qo(h,u)),hw=i,fw=s,dw=a}function b_(i){return[Qo(i[1],i[0]),Nc(i[2])]}function ad(i){var e=i[0],t=i[1],n=ni(t);return[n*ni(e),n*Hn(e),Hn(t)]}function K2(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function w0(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function O3(i,e){i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}function Z2(i,e){return[i[0]*e,i[1]*e,i[2]*e]}function S_(i){var e=Cc(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);i[0]/=e,i[1]/=e,i[2]/=e}var Cr,ka,Or,bo,Df,FD,kD,ZA,Nm,wh,Dc,Ac={point:Aw,lineStart:U5,lineEnd:B5,polygonStart:function(){Ac.point=GD,Ac.lineStart=Q$,Ac.lineEnd=K$,Nm=new bc,Rc.polygonStart()},polygonEnd:function(){Rc.polygonEnd(),Ac.point=Aw,Ac.lineStart=U5,Ac.lineEnd=B5,x_<0?(Cr=-(Or=180),ka=-(bo=90)):Nm>di?bo=90:Nm<-di&&(ka=-90),Dc[0]=Cr,Dc[1]=Or},sphere:function(){Cr=-(Or=180),ka=-(bo=90)}};function Aw(i,e){wh.push(Dc=[Cr=i,Or=i]),ebo&&(bo=e)}function zD(i,e){var t=ad([i*Yn,e*Yn]);if(ZA){var n=w0(ZA,t),r=[n[1],-n[0],0],s=w0(r,n);S_(s),s=b_(s);var a=i-Df,l=a>0?1:-1,u=s[0]*Fr*l,h,m=Zi(a)>180;m^(l*Dfbo&&(bo=h)):(u=(u+360)%360-180,m^(l*Dfbo&&(bo=e))),m?i_o(Cr,Or)&&(Or=i):_o(i,Or)>_o(Cr,Or)&&(Cr=i):Or>=Cr?(iOr&&(Or=i)):i>Df?_o(Cr,i)>_o(Cr,Or)&&(Or=i):_o(i,Or)>_o(Cr,Or)&&(Cr=i)}else wh.push(Dc=[Cr=i,Or=i]);ebo&&(bo=e),ZA=t,Df=i}function U5(){Ac.point=zD}function B5(){Dc[0]=Cr,Dc[1]=Or,Ac.point=Aw,ZA=null}function GD(i,e){if(ZA){var t=i-Df;Nm.add(Zi(t)>180?t+(t>0?360:-360):t)}else FD=i,kD=e;Rc.point(i,e),zD(i,e)}function Q$(){Rc.lineStart()}function K$(){GD(FD,kD),Rc.lineEnd(),Zi(Nm)>di&&(Cr=-(Or=180)),Dc[0]=Cr,Dc[1]=Or,ZA=null}function _o(i,e){return(e-=i)<0?e+360:e}function Z$(i,e){return i[0]-e[0]}function O5(i,e){return i[0]<=i[1]?i[0]<=e&&e<=i[1]:e_o(n[0],n[1])&&(n[1]=r[1]),_o(r[0],n[1])>_o(n[0],n[1])&&(n[0]=r[0])):s.push(n=r);for(a=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=r,++e)r=s[e],(l=_o(n[1],r[0]))>a&&(a=l,Cr=r[0],Or=n[1])}return wh=Dc=null,Cr===1/0||ka===1/0?[[NaN,NaN],[NaN,NaN]]:[[Cr,ka],[Or,bo]]}var _m,w_,T_,M_,E_,C_,N_,R_,pw,mw,gw,VD,jD,_a,ya,xa,Sl={sphere:na,point:gM,lineStart:I5,lineEnd:F5,polygonStart:function(){Sl.lineStart=tX,Sl.lineEnd=nX},polygonEnd:function(){Sl.lineStart=I5,Sl.lineEnd=F5}};function gM(i,e){i*=Yn,e*=Yn;var t=ni(e);kg(t*ni(i),t*Hn(i),Hn(e))}function kg(i,e,t){++_m,T_+=(i-T_)/_m,M_+=(e-M_)/_m,E_+=(t-E_)/_m}function I5(){Sl.point=J$}function J$(i,e){i*=Yn,e*=Yn;var t=ni(e);_a=t*ni(i),ya=t*Hn(i),xa=Hn(e),Sl.point=eX,kg(_a,ya,xa)}function eX(i,e){i*=Yn,e*=Yn;var t=ni(e),n=t*ni(i),r=t*Hn(i),s=Hn(e),a=Qo(Cc((a=ya*s-xa*r)*a+(a=xa*n-_a*s)*a+(a=_a*r-ya*n)*a),_a*n+ya*r+xa*s);w_+=a,C_+=a*(_a+(_a=n)),N_+=a*(ya+(ya=r)),R_+=a*(xa+(xa=s)),kg(_a,ya,xa)}function F5(){Sl.point=gM}function tX(){Sl.point=iX}function nX(){HD(VD,jD),Sl.point=gM}function iX(i,e){VD=i,jD=e,i*=Yn,e*=Yn,Sl.point=HD;var t=ni(e);_a=t*ni(i),ya=t*Hn(i),xa=Hn(e),kg(_a,ya,xa)}function HD(i,e){i*=Yn,e*=Yn;var t=ni(e),n=t*ni(i),r=t*Hn(i),s=Hn(e),a=ya*s-xa*r,l=xa*n-_a*s,u=_a*r-ya*n,h=uw(a,l,u),m=Nc(h),v=h&&-m/h;pw.add(v*a),mw.add(v*l),gw.add(v*u),w_+=m,C_+=m*(_a+(_a=n)),N_+=m*(ya+(ya=r)),R_+=m*(xa+(xa=s)),kg(_a,ya,xa)}function k5(i){_m=w_=T_=M_=E_=C_=N_=R_=0,pw=new bc,mw=new bc,gw=new bc,Ty(i,Sl);var e=+pw,t=+mw,n=+gw,r=uw(e,t,n);return rMi&&(i-=Math.round(i/Eo)*Eo),[i,e]}_w.invert=_w;function WD(i,e,t){return(i%=Eo)?e||t?vw(G5(i),q5(e,t)):G5(i):e||t?q5(e,t):_w}function z5(i){return function(e,t){return e+=i,Zi(e)>Mi&&(e-=Math.round(e/Eo)*Eo),[e,t]}}function G5(i){var e=z5(i);return e.invert=z5(-i),e}function q5(i,e){var t=ni(i),n=Hn(i),r=ni(e),s=Hn(e);function a(l,u){var h=ni(u),m=ni(l)*h,v=Hn(l)*h,x=Hn(u),S=x*t+m*n;return[Qo(v*r-S*s,m*t-x*n),Nc(S*r+v*s)]}return a.invert=function(l,u){var h=ni(u),m=ni(l)*h,v=Hn(l)*h,x=Hn(u),S=x*r-v*s;return[Qo(v*r+x*s,m*t+S*n),Nc(S*t-m*n)]},a}function rX(i){i=WD(i[0]*Yn,i[1]*Yn,i.length>2?i[2]*Yn:0);function e(t){return t=i(t[0]*Yn,t[1]*Yn),t[0]*=Fr,t[1]*=Fr,t}return e.invert=function(t){return t=i.invert(t[0]*Yn,t[1]*Yn),t[0]*=Fr,t[1]*=Fr,t},e}function sX(i,e,t,n,r,s){if(t){var a=ni(e),l=Hn(e),u=n*t;r==null?(r=e+n*Eo,s=e-u/2):(r=V5(a,r),s=V5(a,s),(n>0?rs)&&(r+=n*Eo));for(var h,m=r;n>0?m>s:m1&&i.push(i.pop().concat(i.shift()))},result:function(){var t=i;return i=[],e=null,t}}}function qv(i,e){return Zi(i[0]-e[0])=0;--l)r.point((v=m[l])[0],v[1]);else n(x.x,x.p.x,-1,r);x=x.p}x=x.o,m=x.z,S=!S}while(!x.v);r.lineEnd()}}}function j5(i){if(e=i.length){for(var e,t=0,n=i[0],r;++t=0?1:-1,V=q*H,Q=V>Mi,J=C*z;if(u.add(Qo(J*q*Hn(V),E*G+J*ni(V))),a+=Q?H+q*Eo:H,Q^T>=t^I>=t){var ne=w0(ad(S),ad(U));S_(ne);var oe=w0(s,ne);S_(oe);var ie=(Q^H>=0?-1:1)*Nc(oe[2]);(n>ie||n===ie&&(ne[0]||ne[1]))&&(l+=Q^H>=0?1:-1)}}return(a<-di||a0){for(u||(r.polygonStart(),u=!0),r.lineStart(),z=0;z1&&I&2&&j.push(j.pop().concat(j.shift())),m.push(j.filter(aX))}}return x}}function aX(i){return i.length>1}function oX(i,e){return((i=i.x)[0]<0?i[1]-ja-di:ja-i[1])-((e=e.x)[0]<0?e[1]-ja-di:ja-e[1])}const H5=QD(function(){return!0},lX,cX,[-Mi,-ja]);function lX(i){var e=NaN,t=NaN,n=NaN,r;return{lineStart:function(){i.lineStart(),r=1},point:function(s,a){var l=s>0?Mi:-Mi,u=Zi(s-e);Zi(u-Mi)0?ja:-ja),i.point(n,t),i.lineEnd(),i.lineStart(),i.point(l,t),i.point(s,t),r=0):n!==l&&u>=Mi&&(Zi(e-n)di?mM((Hn(e)*(s=ni(n))*Hn(t)-Hn(n)*(r=ni(e))*Hn(i))/(r*s*a)):(e+n)/2}function cX(i,e,t,n){var r;if(i==null)r=t*ja,n.point(-Mi,r),n.point(0,r),n.point(Mi,r),n.point(Mi,0),n.point(Mi,-r),n.point(0,-r),n.point(-Mi,-r),n.point(-Mi,0),n.point(-Mi,r);else if(Zi(i[0]-e[0])>di){var s=i[0]0,r=Zi(e)>di;function s(m,v,x,S){sX(S,i,t,x,m,v)}function a(m,v){return ni(m)*ni(v)>e}function l(m){var v,x,S,T,N;return{lineStart:function(){T=S=!1,N=1},point:function(C,E){var O=[C,E],U,I=a(C,E),j=n?I?0:h(C,E):I?h(C+(C<0?Mi:-Mi),E):0;if(!v&&(T=S=I)&&m.lineStart(),I!==S&&(U=u(v,O),(!U||qv(v,U)||qv(O,U))&&(O[2]=1)),I!==S)N=0,I?(m.lineStart(),U=u(O,v),m.point(U[0],U[1])):(U=u(v,O),m.point(U[0],U[1],2),m.lineEnd()),v=U;else if(r&&v&&n^I){var z;!(j&x)&&(z=u(O,v,!0))&&(N=0,n?(m.lineStart(),m.point(z[0][0],z[0][1]),m.point(z[1][0],z[1][1]),m.lineEnd()):(m.point(z[1][0],z[1][1]),m.lineEnd(),m.lineStart(),m.point(z[0][0],z[0][1],3)))}I&&(!v||!qv(v,O))&&m.point(O[0],O[1]),v=O,S=I,x=j},lineEnd:function(){S&&m.lineEnd(),v=null},clean:function(){return N|(T&&S)<<1}}}function u(m,v,x){var S=ad(m),T=ad(v),N=[1,0,0],C=w0(S,T),E=K2(C,C),O=C[0],U=E-O*O;if(!U)return!x&&m;var I=e*E/U,j=-e*O/U,z=w0(N,C),G=Z2(N,I),H=Z2(C,j);O3(G,H);var q=z,V=K2(G,q),Q=K2(q,q),J=V*V-Q*(K2(G,G)-1);if(!(J<0)){var ne=Cc(J),oe=Z2(q,(-V-ne)/Q);if(O3(oe,G),oe=b_(oe),!x)return oe;var ie=m[0],Z=v[0],te=m[1],de=v[1],Se;Z0^oe[1]<(Zi(oe[0]-ie)Mi^(ie<=oe[0]&&oe[0]<=Z)){var Ve=Z2(q,(-V+ne)/Q);return O3(Ve,G),[oe,b_(Ve)]}}}function h(m,v){var x=n?i:Mi-i,S=0;return m<-x?S|=1:m>x&&(S|=2),v<-x?S|=4:v>x&&(S|=8),S}return QD(a,l,s,n?[0,-i]:[-Mi,i-Mi])}function fX(i,e,t,n,r,s){var a=i[0],l=i[1],u=e[0],h=e[1],m=0,v=1,x=u-a,S=h-l,T;if(T=t-a,!(!x&&T>0)){if(T/=x,x<0){if(T0){if(T>v)return;T>m&&(m=T)}if(T=r-a,!(!x&&T<0)){if(T/=x,x<0){if(T>v)return;T>m&&(m=T)}else if(x>0){if(T0)){if(T/=S,S<0){if(T0){if(T>v)return;T>m&&(m=T)}if(T=s-l,!(!S&&T<0)){if(T/=S,S<0){if(T>v)return;T>m&&(m=T)}else if(S>0){if(T0&&(i[0]=a+m*x,i[1]=l+m*S),v<1&&(e[0]=a+v*x,e[1]=l+v*S),!0}}}}}var ym=1e9,ev=-ym;function dX(i,e,t,n){function r(h,m){return i<=h&&h<=t&&e<=m&&m<=n}function s(h,m,v,x){var S=0,T=0;if(h==null||(S=a(h,v))!==(T=a(m,v))||u(h,m)<0^v>0)do x.point(S===0||S===3?i:t,S>1?n:e);while((S=(S+v+4)%4)!==T);else x.point(m[0],m[1])}function a(h,m){return Zi(h[0]-i)0?0:3:Zi(h[0]-t)0?2:1:Zi(h[1]-e)0?1:0:m>0?3:2}function l(h,m){return u(h.x,m.x)}function u(h,m){var v=a(h,1),x=a(m,1);return v!==x?v-x:v===0?m[1]-h[1]:v===1?h[0]-m[0]:v===2?h[1]-m[1]:m[0]-h[0]}return function(h){var m=h,v=$D(),x,S,T,N,C,E,O,U,I,j,z,G={point:H,lineStart:J,lineEnd:ne,polygonStart:V,polygonEnd:Q};function H(ie,Z){r(ie,Z)&&m.point(ie,Z)}function q(){for(var ie=0,Z=0,te=S.length;Zn&&(Ce-Me)*(n-Ve)>(Fe-Ve)*(i-Me)&&++ie:Fe<=n&&(Ce-Me)*(n-Ve)<(Fe-Ve)*(i-Me)&&--ie;return ie}function V(){m=v,x=[],S=[],z=!0}function Q(){var ie=q(),Z=z&&ie,te=(x=og(x)).length;(Z||te)&&(h.polygonStart(),Z&&(h.lineStart(),s(null,null,1,h),h.lineEnd()),te&&XD(x,l,ie,s,h),h.polygonEnd()),m=h,x=S=T=null}function J(){G.point=oe,S&&S.push(T=[]),j=!0,I=!1,O=U=NaN}function ne(){x&&(oe(N,C),E&&I&&v.rejoin(),x.push(v.result())),G.point=H,I&&m.lineEnd()}function oe(ie,Z){var te=r(ie,Z);if(S&&T.push([ie,Z]),j)N=ie,C=Z,E=te,j=!1,te&&(m.lineStart(),m.point(ie,Z));else if(te&&I)m.point(ie,Z);else{var de=[O=Math.max(ev,Math.min(ym,O)),U=Math.max(ev,Math.min(ym,U))],Se=[ie=Math.max(ev,Math.min(ym,ie)),Z=Math.max(ev,Math.min(ym,Z))];fX(de,Se,i,e,t,n)?(I||(m.lineStart(),m.point(de[0],de[1])),m.point(Se[0],Se[1]),te||m.lineEnd(),z=!1):te&&(m.lineStart(),m.point(ie,Z),z=!1)}O=ie,U=Z,I=te}return G}}var yw,xw,Vv,jv,T0={sphere:na,point:na,lineStart:AX,lineEnd:na,polygonStart:na,polygonEnd:na};function AX(){T0.point=mX,T0.lineEnd=pX}function pX(){T0.point=T0.lineEnd=na}function mX(i,e){i*=Yn,e*=Yn,xw=i,Vv=Hn(e),jv=ni(e),T0.point=gX}function gX(i,e){i*=Yn,e*=Yn;var t=Hn(e),n=ni(e),r=Zi(i-xw),s=ni(r),a=Hn(r),l=n*a,u=jv*t-Vv*n*s,h=Vv*t+jv*n*s;yw.add(Qo(Cc(l*l+u*u),h)),xw=i,Vv=t,jv=n}function vX(i){return yw=new bc,Ty(i,T0),+yw}var bw=[null,null],_X={type:"LineString",coordinates:bw};function kh(i,e){return bw[0]=i,bw[1]=e,vX(_X)}var W5={Feature:function(i,e){return D_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n0&&(r=kh(i[s],i[s-1]),r>0&&t<=r&&n<=r&&(t+n-r)*(1-Math.pow((t-n)/r,2))di}).map(x)).concat(zA(Q2(s/h)*h,r,h).filter(function(U){return Zi(U%v)>di}).map(S))}return E.lines=function(){return O().map(function(U){return{type:"LineString",coordinates:U}})},E.outline=function(){return{type:"Polygon",coordinates:[T(n).concat(N(a).slice(1),T(t).reverse().slice(1),N(l).reverse().slice(1))]}},E.extent=function(U){return arguments.length?E.extentMajor(U).extentMinor(U):E.extentMinor()},E.extentMajor=function(U){return arguments.length?(n=+U[0][0],t=+U[1][0],l=+U[0][1],a=+U[1][1],n>t&&(U=n,n=t,t=U),l>a&&(U=l,l=a,a=U),E.precision(C)):[[n,l],[t,a]]},E.extentMinor=function(U){return arguments.length?(e=+U[0][0],i=+U[1][0],s=+U[0][1],r=+U[1][1],e>i&&(U=e,e=i,i=U),s>r&&(U=s,s=r,r=U),E.precision(C)):[[e,s],[i,r]]},E.step=function(U){return arguments.length?E.stepMajor(U).stepMinor(U):E.stepMinor()},E.stepMajor=function(U){return arguments.length?(m=+U[0],v=+U[1],E):[m,v]},E.stepMinor=function(U){return arguments.length?(u=+U[0],h=+U[1],E):[u,h]},E.precision=function(U){return arguments.length?(C=+U,x=K5(s,r,90),S=Z5(e,i,C),T=K5(l,a,90),N=Z5(n,t,C),E):C},E.extentMajor([[-180,-90+di],[180,90-di]]).extentMinor([[-180,-80-di],[180,80+di]])}function SX(){return bX()()}function vM(i,e){var t=i[0]*Yn,n=i[1]*Yn,r=e[0]*Yn,s=e[1]*Yn,a=ni(n),l=Hn(n),u=ni(s),h=Hn(s),m=a*ni(t),v=a*Hn(t),x=u*ni(r),S=u*Hn(r),T=2*Nc(Cc(N5(s-n)+a*u*N5(r-t))),N=Hn(T),C=T?function(E){var O=Hn(E*=T)/N,U=Hn(T-E)/N,I=U*m+O*x,j=U*v+O*S,z=U*l+O*h;return[Qo(j,I)*Fr,Qo(z,Cc(I*I+j*j))*Fr]}:function(){return[t*Fr,n*Fr]};return C.distance=T,C}const J5=i=>i;var M0=1/0,P_=M0,hg=-M0,L_=hg,eR={point:wX,lineStart:na,lineEnd:na,polygonStart:na,polygonEnd:na,result:function(){var i=[[M0,P_],[hg,L_]];return hg=L_=-(P_=M0=1/0),i}};function wX(i,e){ihg&&(hg=i),eL_&&(L_=e)}function _M(i){return function(e){var t=new Sw;for(var n in i)t[n]=i[n];return t.stream=e,t}}function Sw(){}Sw.prototype={constructor:Sw,point:function(i,e){this.stream.point(i,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function yM(i,e,t){var n=i.clipExtent&&i.clipExtent();return i.scale(150).translate([0,0]),n!=null&&i.clipExtent(null),Ty(t,i.stream(eR)),e(eR.result()),n!=null&&i.clipExtent(n),i}function ZD(i,e,t){return yM(i,function(n){var r=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(r/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),l=+e[0][0]+(r-a*(n[1][0]+n[0][0]))/2,u=+e[0][1]+(s-a*(n[1][1]+n[0][1]))/2;i.scale(150*a).translate([l,u])},t)}function TX(i,e,t){return ZD(i,[[0,0],e],t)}function MX(i,e,t){return yM(i,function(n){var r=+e,s=r/(n[1][0]-n[0][0]),a=(r-s*(n[1][0]+n[0][0]))/2,l=-s*n[0][1];i.scale(150*s).translate([a,l])},t)}function EX(i,e,t){return yM(i,function(n){var r=+e,s=r/(n[1][1]-n[0][1]),a=-s*n[0][0],l=(r-s*(n[1][1]+n[0][1]))/2;i.scale(150*s).translate([a,l])},t)}var tR=16,CX=ni(30*Yn);function nR(i,e){return+e?RX(i,e):NX(i)}function NX(i){return _M({point:function(e,t){e=i(e,t),this.stream.point(e[0],e[1])}})}function RX(i,e){function t(n,r,s,a,l,u,h,m,v,x,S,T,N,C){var E=h-n,O=m-r,U=E*E+O*O;if(U>4*e&&N--){var I=a+x,j=l+S,z=u+T,G=Cc(I*I+j*j+z*z),H=Nc(z/=G),q=Zi(Zi(z)-1)e||Zi((E*ne+O*oe)/U-.5)>.3||a*x+l*S+u*T2?ie[2]%360*Yn:0,ne()):[l*Fr,u*Fr,h*Fr]},Q.angle=function(ie){return arguments.length?(v=ie%360*Yn,ne()):v*Fr},Q.reflectX=function(ie){return arguments.length?(x=ie?-1:1,ne()):x<0},Q.reflectY=function(ie){return arguments.length?(S=ie?-1:1,ne()):S<0},Q.precision=function(ie){return arguments.length?(z=nR(G,j=ie*ie),oe()):Cc(j)},Q.fitExtent=function(ie,Z){return ZD(Q,ie,Z)},Q.fitSize=function(ie,Z){return TX(Q,ie,Z)},Q.fitWidth=function(ie,Z){return MX(Q,ie,Z)},Q.fitHeight=function(ie,Z){return EX(Q,ie,Z)};function ne(){var ie=iR(t,0,0,x,S,v).apply(null,e(s,a)),Z=iR(t,n-ie[0],r-ie[1],x,S,v);return m=WD(l,u,h),G=vw(e,Z),H=vw(m,G),z=nR(G,j),oe()}function oe(){return q=V=null,Q}return function(){return e=i.apply(this,arguments),Q.invert=e.invert&&J,ne()}}function OX(i){return function(e,t){var n=Cc(e*e+t*t),r=i(n),s=Hn(r),a=ni(r);return[Qo(e*s,n*a),Nc(n&&t*s/n)]}}function xM(i,e){return[i,V$(H$((ja+e)/2))]}xM.invert=function(i,e){return[i,2*mM(q$(e))-ja]};function JD(i,e){var t=ni(e),n=1+ni(i)*t;return[t*Hn(i)/n,Hn(e)/n]}JD.invert=OX(function(i){return 2*mM(i)});function IX(){return UX(JD).scale(250).clipAngle(142)}function ww(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=Ec().domain([1,0]).range([t,n]).clamp(!0),s=Ec().domain([F3(t),F3(n)]).range([1,0]).clamp(!0),a=function(v){return s(F3(r(v)))},l=e.array,u=0,h=l.length;u2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,l=[],u=Math.pow(2,e),h=360/u,m=180/u,v=s===void 0?u-1:s,x=a===void 0?u-1:a,S=n,T=Math.min(u-1,v);S<=T;S++)for(var N=r,C=Math.min(u-1,x);N<=C;N++){var E=N,O=m;if(t){E=N===0?N:sR(N/u)*u;var U=N+1===u?N+1:sR((N+1)/u)*u;O=(U-E)*180/u}var I=-180+(S+.5)*h,j=90-(E*180/u+O/2),z=O;l.push({x:S,y:N,lng:I,lat:j,latLen:z})}return l},tY=6,nY=7,iY=3,rY=90,Hl=new WeakMap,Mh=new WeakMap,k3=new WeakMap,tv=new WeakMap,Go=new WeakMap,B_=new WeakMap,JA=new WeakMap,bf=new WeakMap,nv=new WeakSet,sY=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.tileUrl,a=r.minLevel,l=a===void 0?0:a,u=r.maxLevel,h=u===void 0?17:u,m=r.mercatorProjection,v=m===void 0?!0:m;return qX(this,e),n=GX(this,e),VX(n,nv),gh(n,Hl,void 0),gh(n,Mh,void 0),gh(n,k3,void 0),gh(n,tv,void 0),gh(n,Go,{}),gh(n,B_,void 0),gh(n,JA,void 0),gh(n,bf,void 0),pA(n,"minLevel",void 0),pA(n,"maxLevel",void 0),pA(n,"thresholds",nP(new Array(30)).map(function(x,S){return 8/Math.pow(2,S)})),pA(n,"curvatureResolution",5),pA(n,"tileMargin",0),pA(n,"clearTiles",function(){Object.values(hi(Go,n)).forEach(function(x){x.forEach(function(S){S.obj&&(n.remove(S.obj),rR(S.obj),delete S.obj)})}),vh(Go,n,{})}),vh(Hl,n,t),n.tileUrl=s,vh(Mh,n,v),n.minLevel=l,n.maxLevel=h,n.level=0,n.add(vh(bf,n,new Oi(new bu(hi(Hl,n)*.99,180,90),new cd({color:0})))),hi(bf,n).visible=!1,hi(bf,n).material.polygonOffset=!0,hi(bf,n).material.polygonOffsetUnits=3,hi(bf,n).material.polygonOffsetFactor=1,n}return WX(e,i),HX(e,[{key:"tileUrl",get:function(){return hi(k3,this)},set:function(n){vh(k3,this,n),this.updatePov(hi(JA,this))}},{key:"level",get:function(){return hi(tv,this)},set:function(n){var r,s=this;hi(Go,this)[n]||Rm(nv,this,aY).call(this,n);var a=hi(tv,this);if(vh(tv,this,n),!(n===a||a===void 0)){if(hi(bf,this).visible=n>0,hi(Go,this)[n].forEach(function(u){return u.obj&&(u.obj.material.depthWrite=!0)}),an)for(var l=n+1;l<=a;l++)hi(Go,this)[l]&&hi(Go,this)[l].forEach(function(u){u.obj&&(s.remove(u.obj),rR(u.obj),delete u.obj)});Rm(nv,this,oR).call(this)}}},{key:"updatePov",value:function(n){var r=this;if(!(!n||!(n instanceof gy))){vh(JA,this,n);var s;if(vh(B_,this,function(m){if(!m.hullPnts){var v=360/Math.pow(2,r.level),x=m.lng,S=m.lat,T=m.latLen,N=x-v/2,C=x+v/2,E=S-T/2,O=S+T/2;m.hullPnts=[[S,x],[E,N],[O,N],[E,C],[O,C]].map(function(U){var I=Hv(U,2),j=I[0],z=I[1];return oP(j,z,hi(Hl,r))}).map(function(U){var I=U.x,j=U.y,z=U.z;return new me(I,j,z)})}return s||(s=new Og,n.updateMatrix(),n.updateMatrixWorld(),s.setFromProjectionMatrix(new jn().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse))),m.hullPnts.some(function(U){return s.containsPoint(U.clone().applyMatrix4(r.matrixWorld))})}),this.tileUrl){var a=n.position.clone(),l=a.distanceTo(this.getWorldPosition(new me)),u=(l-hi(Hl,this))/hi(Hl,this),h=this.thresholds.findIndex(function(m){return m&&m<=u});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,h<0?this.thresholds.length:h)),Rm(nv,this,oR).call(this)}}}}])})(qa);function aY(i){var e=this;if(i>nY){hi(Go,this)[i]=[];return}var t=hi(Go,this)[i]=Mw(i,hi(Mh,this));t.forEach(function(n){return n.centroid=oP(n.lat,n.lng,hi(Hl,e))}),t.octree=xD().x(function(n){return n.centroid.x}).y(function(n){return n.centroid.y}).z(function(n){return n.centroid.z}).addAll(t)}function oR(){var i=this;if(!(!this.tileUrl||this.level===void 0||!hi(Go,this).hasOwnProperty(this.level))&&!(!hi(B_,this)&&this.level>tY)){var e=hi(Go,this)[this.level];if(hi(JA,this)){var t=this.worldToLocal(hi(JA,this).position.clone());if(e.octree){var n,r=this.worldToLocal(hi(JA,this).position.clone()),s=(r.length()-hi(Hl,this))*iY;e=(n=e.octree).findAllWithinRadius.apply(n,nP(r).concat([s]))}else{var a=JX(t),l=(a.r/hi(Hl,this)-1)*rY,u=l/Math.cos(xf(a.lat)),h=[a.lng-u,a.lng+u],m=[a.lat+l,a.lat-l],v=aR(this.level,hi(Mh,this),h[0],m[0]),x=Hv(v,2),S=x[0],T=x[1],N=aR(this.level,hi(Mh,this),h[1],m[1]),C=Hv(N,2),E=C[0],O=C[1];!e.record&&(e.record={});var U=e.record;if(!U.hasOwnProperty("".concat(Math.round((S+E)/2),"_").concat(Math.round((T+O)/2))))e=Mw(this.level,hi(Mh,this),S,T,E,O).map(function(H){var q="".concat(H.x,"_").concat(H.y);return U.hasOwnProperty(q)?U[q]:(U[q]=H,e.push(H),H)});else{for(var I=[],j=S;j<=E;j++)for(var z=T;z<=O;z++){var G="".concat(j,"_").concat(z);U.hasOwnProperty(G)||(U[G]=Mw(this.level,hi(Mh,this),j,z,j,z)[0],e.push(U[G])),I.push(U[G])}e=I}}}e.filter(function(H){return!H.obj}).filter(hi(B_,this)||function(){return!0}).forEach(function(H){var q=H.x,V=H.y,Q=H.lng,J=H.lat,ne=H.latLen,oe=360/Math.pow(2,i.level);if(!H.obj){var ie=oe*(1-i.tileMargin),Z=ne*(1-i.tileMargin),te=xf(Q),de=xf(-J),Se=new Oi(new bu(hi(Hl,i),Math.ceil(ie/i.curvatureResolution),Math.ceil(Z/i.curvatureResolution),xf(90-ie/2)+te,xf(ie),xf(90-Z/2)+de,xf(Z)),new Fc);if(hi(Mh,i)){var Te=[J+ne/2,J-ne/2].map(function(Ce){return .5-Ce/180}),ae=Hv(Te,2),Me=ae[0],Ve=ae[1];eY(Se.geometry.attributes.uv,Me,Ve)}H.obj=Se}H.loading||(H.loading=!0,new oM().load(i.tileUrl(q,V,i.level),function(Ce){var Fe=H.obj;Fe&&(Ce.colorSpace=bn,Fe.material.map=Ce,Fe.material.color=null,Fe.material.needsUpdate=!0,i.add(Fe)),H.loading=!1}))})}}function oY(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=uP(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let l,u,h;if(n&&(s=fY(i,e,s,t)),i.length>80*t){l=i[0],u=i[1];let m=l,v=u;for(let x=t;xm&&(m=S),T>v&&(v=T)}h=Math.max(m-l,v-u),h=h!==0?32767/h:0}return fg(s,a,t,l,u,h,0),a}function uP(i,e,t,n,r){let s;if(r===SY(i,e,t,n)>0)for(let a=e;a=e;a-=n)s=lR(a/n|0,i[a],i[a+1],s);return s&&E0(s,s.next)&&(Ag(s),s=s.next),s}function od(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(E0(t,t.next)||Dr(t.prev,t,t.next)===0)){if(Ag(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function fg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&gY(i,n,r,s);let l=i;for(;i.prev!==i.next;){const u=i.prev,h=i.next;if(s?uY(i,n,r,s):lY(i)){e.push(u.i,i.i,h.i),Ag(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=cY(od(i),e),fg(i,e,t,n,r,s,2)):a===2&&hY(i,e,t,n,r,s):fg(od(i),e,t,n,r,s,1);break}}}function lY(i){const e=i.prev,t=i,n=i.next;if(Dr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=Math.min(r,s,a),v=Math.min(l,u,h),x=Math.max(r,s,a),S=Math.max(l,u,h);let T=n.next;for(;T!==e;){if(T.x>=m&&T.x<=x&&T.y>=v&&T.y<=S&&xm(r,l,s,u,a,h,T.x,T.y)&&Dr(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function uY(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Dr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=Math.min(l,u,h),T=Math.min(m,v,x),N=Math.max(l,u,h),C=Math.max(m,v,x),E=Ew(S,T,e,t,n),O=Ew(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&xm(l,m,u,v,h,x,U.x,U.y)&&Dr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&xm(l,m,u,v,h,x,I.x,I.y)&&Dr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&xm(l,m,u,v,h,x,U.x,U.y)&&Dr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&xm(l,m,u,v,h,x,I.x,I.y)&&Dr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function cY(i,e){let t=i;do{const n=t.prev,r=t.next.next;!E0(n,r)&&hP(n,t,t.next,r)&&dg(n,r)&&dg(r,n)&&(e.push(n.i,t.i,r.i),Ag(t),Ag(t.next),t=i=r),t=t.next}while(t!==i);return od(t)}function hY(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&yY(a,l)){let u=fP(a,l);a=od(a,a.next),u=od(u,u.next),fg(a,e,t,n,r,s,0),fg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function fY(i,e,t,n){const r=[];for(let s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const v=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=n&&v>s&&(s=v,a=t.x=t.x&&t.x>=u&&n!==t.x&&cP(ra.x||t.x===a.x&&mY(a,t)))&&(a=t,m=v)}t=t.next}while(t!==l);return a}function mY(i,e){return Dr(i.prev,i,e.prev)<0&&Dr(e.next,i,i.next)<0}function gY(i,e,t,n){let r=i;do r.z===0&&(r.z=Ew(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,vY(r)}function vY(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,l=0;for(let h=0;h0||u>0&&a;)l!==0&&(u===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,l--):(r=a,a=a.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function Ew(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function _Y(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function xm(i,e,t,n,r,s,a,l){return!(i===a&&e===l)&&cP(i,e,t,n,r,s,a,l)}function yY(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!xY(i,e)&&(dg(i,e)&&dg(e,i)&&bY(i,e)&&(Dr(i.prev,i,e.prev)||Dr(i,e.prev,e))||E0(i,e)&&Dr(i.prev,i,i.next)>0&&Dr(e.prev,e,e.next)>0)}function Dr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function E0(i,e){return i.x===e.x&&i.y===e.y}function hP(i,e,t,n){const r=rv(Dr(i,e,t)),s=rv(Dr(i,e,n)),a=rv(Dr(t,n,i)),l=rv(Dr(t,n,e));return!!(r!==s&&a!==l||r===0&&iv(i,t,e)||s===0&&iv(i,n,e)||a===0&&iv(t,i,n)||l===0&&iv(t,e,n))}function iv(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function rv(i){return i>0?1:i<0?-1:0}function xY(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&hP(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function dg(i,e){return Dr(i.prev,i,i.next)<0?Dr(i,e,i.next)>=0&&Dr(i,i.prev,e)>=0:Dr(i,e,i.prev)<0||Dr(i,i.next,e)<0}function bY(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function fP(i,e){const t=Cw(i.i,i.x,i.y),n=Cw(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function lR(i,e,t,n){const r=Cw(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Ag(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Cw(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function SY(i,e,t,n){let r=0;for(let s=e,a=t-n;si.length)&&(e=i.length);for(var t=0,n=Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,l=!1;return{s:function(){t=t.call(i)},n:function(){var u=t.next();return a=u.done,u},e:function(u){l=!0,s=u},f:function(){try{a||t.return==null||t.return()}finally{if(l)throw s}}}}function I_(i){return I_=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},I_(i)}function DY(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&Rw(i,e)}function dP(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dP=function(){return!!i})()}function PY(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function LY(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,a,l=[],u=!0,h=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=s.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(m){h=!0,r=m}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function UY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BY(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function OY(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return MY(i)}function Rw(i,e){return Rw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Rw(i,e)}function Jp(i,e){return wY(i)||LY(i,e)||bM(i,e)||UY()}function IY(i){return TY(i)||PY(i)||bM(i)||BY()}function bM(i,e){if(i){if(typeof i=="string")return Nw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Nw(i,e):void 0}}var uR=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(s){if(r){var a=kh(s,r)*180/Math.PI;if(a>t)for(var l=vM(r,s),u=r.length>2||s.length>2?cg(r[2]||0,s[2]||0):null,h=u?function(x){return[].concat(IY(l(x)),[u(x)])}:l,m=1/Math.ceil(a/t),v=m;v<1;)n.push(h(v)),v+=m}n.push(r=s)}),n},Dw=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:Hi,Float32BufferAttribute:Si},FY=new Dw.BufferGeometry().setAttribute?"setAttribute":"addAttribute",AP=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;CY(this,e),n=EY(this,e),n.type="GeoJsonGeometry",n.parameters={geoJson:t,radius:r,resolution:s};var a=({Point:m,MultiPoint:v,LineString:x,MultiLineString:S,Polygon:T,MultiPolygon:N}[t.type]||function(){return[]})(t.coordinates,r),l=[],u=[],h=0;a.forEach(function(C){var E=l.length;em({indices:l,vertices:u},C),n.addGroup(E,l.length-E,h++)}),l.length&&n.setIndex(l),u.length&&n[FY]("position",new Dw.Float32BufferAttribute(u,3));function m(C,E){var O=z3(C[1],C[0],E+(C[2]||0)),U=[];return[{vertices:O,indices:U}]}function v(C,E){var O={vertices:[],indices:[]};return C.map(function(U){return m(U,E)}).forEach(function(U){var I=Jp(U,1),j=I[0];em(O,j)}),[O]}function x(C,E){for(var O=uR(C,s).map(function(H){var q=Jp(H,3),V=q[0],Q=q[1],J=q[2],ne=J===void 0?0:J;return z3(Q,V,E+ne)}),U=O_([O]),I=U.vertices,j=Math.round(I.length/3),z=[],G=1;G2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function kY(i,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!i.hasAttribute("position")||!i.hasAttribute("normal")||!i.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(a){if(a.normalized||a.isInterleavedBufferAttribute){const l=new Float32Array(a.count*a.itemSize);for(let u=0,h=0;u2&&(l[h++]=a.getZ(u));return l}return a.array instanceof Float32Array?a.array:new Float32Array(a.array)}const r=i.index?i.toNonIndexed():i,s=e.generateTangents(n(r.attributes.position),n(r.attributes.normal),n(r.attributes.uv));if(t)for(let a=3;a=2&&a.setY(l,i.getY(l)),n>=3&&a.setZ(l,i.getZ(l)),n>=4&&a.setW(l,i.getW(l));return a}function VY(i){const e=i.attributes,t=i.morphTargets,n=new Map;for(const r in e){const s=e[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,F_(s)),e[r]=n.get(s))}for(const r in t){const s=t[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,F_(s)),t[r]=n.get(s))}}function jY(i){let e=0;for(const n in i.attributes){const r=i.getAttribute(n);e+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const t=i.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function HY(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=i.getIndex(),r=i.getAttribute("position"),s=n?n.count:r.count;let a=0;const l=Object.keys(i.attributes),u={},h={},m=[],v=["getX","getY","getZ","getW"],x=["setX","setY","setZ","setW"];for(let O=0,U=l.length;O{const q=new G.array.constructor(G.count*G.itemSize);h[I][H]=new G.constructor(q,G.itemSize,G.normalized)}))}const S=e*.5,T=Math.log10(1/e),N=Math.pow(10,T),C=S*N;for(let O=0;Oa.materialIndex!==l.materialIndex?a.materialIndex-l.materialIndex:a.start-l.start),i.getIndex()===null){const a=i.getAttribute("position"),l=[];for(let u=0;ut&&u.add(Q)}u.normalize(),T.setXYZ(E+j,u.x,u.y,u.z)}}return m.setAttribute("normal",T),m}const SM=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:kY,computeMorphedAttributes:$Y,deepCloneAttribute:GY,deinterleaveAttribute:F_,deinterleaveGeometry:VY,estimateBytesUsed:jY,interleaveAttributes:qY,mergeAttributes:Pw,mergeGeometries:zY,mergeGroups:XY,mergeVertices:HY,toCreasedNormals:YY,toTrianglesDrawMode:WY},Symbol.toStringTag,{value:"Module"}));var Ut=(function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}});function k_(i){"@babel/helpers - typeof";return k_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k_(i)}var QY=/^\s+/,KY=/\s+$/;function Sn(i,e){if(i=i||"",e=e||{},i instanceof Sn)return i;if(!(this instanceof Sn))return new Sn(i,e);var t=ZY(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}Sn.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,r,s,a,l;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),n<=.03928?a=n/12.92:a=Math.pow((n+.055)/1.055,2.4),r<=.03928?l=r/12.92:l=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*a+.0722*l},setAlpha:function(e){return this._a=pP(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=fR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=fR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=hR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=hR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return dR(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return nQ(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(br(this._r,255)*100)+"%",g:Math.round(br(this._g,255)*100)+"%",b:Math.round(br(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(br(this._r,255)*100)+"%, "+Math.round(br(this._g,255)*100)+"%, "+Math.round(br(this._b,255)*100)+"%)":"rgba("+Math.round(br(this._r,255)*100)+"%, "+Math.round(br(this._g,255)*100)+"%, "+Math.round(br(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:AQ[dR(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+AR(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=Sn(e);n="#"+AR(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return Sn(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(aQ,arguments)},brighten:function(){return this._applyModification(oQ,arguments)},darken:function(){return this._applyModification(lQ,arguments)},desaturate:function(){return this._applyModification(iQ,arguments)},saturate:function(){return this._applyModification(rQ,arguments)},greyscale:function(){return this._applyModification(sQ,arguments)},spin:function(){return this._applyModification(uQ,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(fQ,arguments)},complement:function(){return this._applyCombination(cQ,arguments)},monochromatic:function(){return this._applyCombination(dQ,arguments)},splitcomplement:function(){return this._applyCombination(hQ,arguments)},triad:function(){return this._applyCombination(pR,[3])},tetrad:function(){return this._applyCombination(pR,[4])}};Sn.fromRatio=function(i,e){if(k_(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=bm(i[n]));i=t}return Sn(i,e)};function ZY(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,s=null,a=!1,l=!1;return typeof i=="string"&&(i=vQ(i)),k_(i)=="object"&&(fc(i.r)&&fc(i.g)&&fc(i.b)?(e=JY(i.r,i.g,i.b),a=!0,l=String(i.r).substr(-1)==="%"?"prgb":"rgb"):fc(i.h)&&fc(i.s)&&fc(i.v)?(n=bm(i.s),r=bm(i.v),e=tQ(i.h,n,r),a=!0,l="hsv"):fc(i.h)&&fc(i.s)&&fc(i.l)&&(n=bm(i.s),s=bm(i.l),e=eQ(i.h,n,s),a=!0,l="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=pP(t),{ok:a,format:i.format||l,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function JY(i,e,t){return{r:br(i,255)*255,g:br(e,255)*255,b:br(t,255)*255}}function hR(i,e,t){i=br(i,255),e=br(e,255),t=br(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=(n+r)/2;if(n==r)s=a=0;else{var u=n-r;switch(a=l>.5?u/(2-n-r):u/(n+r),n){case i:s=(e-t)/u+(e1&&(v-=1),v<1/6?h+(m-h)*6*v:v<1/2?m:v<2/3?h+(m-h)*(2/3-v)*6:h}if(e===0)n=r=s=t;else{var l=t<.5?t*(1+e):t+e-t*e,u=2*t-l;n=a(u,l,i+1/3),r=a(u,l,i),s=a(u,l,i-1/3)}return{r:n*255,g:r*255,b:s*255}}function fR(i,e,t){i=br(i,255),e=br(e,255),t=br(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=n,u=n-r;if(a=n===0?0:u/n,n==r)s=0;else{switch(n){case i:s=(e-t)/u+(e>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(Sn(n));return s}function dQ(i,e){e=e||6;for(var t=Sn(i).toHsv(),n=t.h,r=t.s,s=t.v,a=[],l=1/e;e--;)a.push(Sn({h:n,s:r,v:s})),s=(s+l)%1;return a}Sn.mix=function(i,e,t){t=t===0?0:t||50;var n=Sn(i).toRgb(),r=Sn(e).toRgb(),s=t/100,a={r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a};return Sn(a)};Sn.readability=function(i,e){var t=Sn(i),n=Sn(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)};Sn.isReadable=function(i,e,t){var n=Sn.readability(i,e),r,s;switch(s=!1,r=_Q(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=n>=4.5;break;case"AAlarge":s=n>=3;break;case"AAAsmall":s=n>=7;break}return s};Sn.mostReadable=function(i,e,t){var n=null,r=0,s,a,l,u;t=t||{},a=t.includeFallbackColors,l=t.level,u=t.size;for(var h=0;hr&&(r=s,n=Sn(e[h]));return Sn.isReadable(i,n,{level:l,size:u})||!a?n:(t.includeFallbackColors=!1,Sn.mostReadable(i,["#fff","#000"],t))};var Lw=Sn.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},AQ=Sn.hexNames=pQ(Lw);function pQ(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function pP(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function br(i,e){mQ(i)&&(i="100%");var t=gQ(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function My(i){return Math.min(1,Math.max(0,i))}function mo(i){return parseInt(i,16)}function mQ(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function gQ(i){return typeof i=="string"&&i.indexOf("%")!=-1}function wl(i){return i.length==1?"0"+i:""+i}function bm(i){return i<=1&&(i=i*100+"%"),i}function mP(i){return Math.round(parseFloat(i)*255).toString(16)}function mR(i){return mo(i)/255}var _l=(function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function fc(i){return!!_l.CSS_UNIT.exec(i)}function vQ(i){i=i.replace(QY,"").replace(KY,"").toLowerCase();var e=!1;if(Lw[i])i=Lw[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=_l.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=_l.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=_l.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=_l.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=_l.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=_l.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=_l.hex8.exec(i))?{r:mo(t[1]),g:mo(t[2]),b:mo(t[3]),a:mR(t[4]),format:e?"name":"hex8"}:(t=_l.hex6.exec(i))?{r:mo(t[1]),g:mo(t[2]),b:mo(t[3]),format:e?"name":"hex"}:(t=_l.hex4.exec(i))?{r:mo(t[1]+""+t[1]),g:mo(t[2]+""+t[2]),b:mo(t[3]+""+t[3]),a:mR(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=_l.hex3.exec(i))?{r:mo(t[1]+""+t[1]),g:mo(t[2]+""+t[2]),b:mo(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function _Q(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function Uw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},l.prototype.update=function(u,h){h===void 0&&(h=!0),this._currentTick++,this._currentTime+=u,this._tickDeltaTime=u,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),h&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},l.prototype.getTimer=function(){return Date.now()},l})();Object.defineProperty(n,"__esModule",{value:!0}),n.default=a},function(t,n,r){(function(s,a){t.exports=a()})(this,function(){return(function(s){function a(u){if(l[u])return l[u].exports;var h=l[u]={exports:{},id:u,loaded:!1};return s[u].call(h.exports,h,h.exports,a),h.loaded=!0,h.exports}var l={};return a.m=s,a.c=l,a.p="",a(0)})([function(s,a){var l=(function(){function u(){this.functions=[]}return u.prototype.add=function(h){return this.functions.indexOf(h)===-1&&(this.functions.push(h),!0)},u.prototype.remove=function(h){var m=this.functions.indexOf(h);return m>-1&&(this.functions.splice(m,1),!0)},u.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},u.prototype.dispatch=function(){for(var h=[],m=0;mh==m>-h?(s=h,h=e[++v]):(s=m,m=n[++x]);let S=0;if(vh==m>-h?(a=h+s,l=s-(a-h),h=e[++v]):(a=m+s,l=s-(a-m),m=n[++x]),s=a,l!==0&&(r[S++]=l);vh==m>-h?(a=s+h,u=a-s,l=s-(a-u)+(h-u),h=e[++v]):(a=s+m,u=a-s,l=s-(a-u)+(m-u),m=n[++x]),s=a,l!==0&&(r[S++]=l);for(;v=oe||-ne>=oe||(v=i-q,l=i-(q+v)+(v-r),v=t-V,h=t-(V+v)+(v-r),v=e-Q,u=e-(Q+v)+(v-s),v=n-J,m=n-(J+v)+(v-s),l===0&&u===0&&h===0&&m===0)||(oe=qQ*a+FQ*Math.abs(ne),ne+=q*m+J*l-(Q*h+V*u),ne>=oe||-ne>=oe))return ne;I=l*J,x=ea*l,S=x-(x-l),T=l-S,x=ea*J,N=x-(x-J),C=J-N,j=T*C-(I-S*N-T*N-S*C),z=u*V,x=ea*u,S=x-(x-u),T=u-S,x=ea*V,N=x-(x-V),C=V-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const ie=j3(4,_A,4,ma,vR);I=q*m,x=ea*q,S=x-(x-q),T=q-S,x=ea*m,N=x-(x-m),C=m-N,j=T*C-(I-S*N-T*N-S*C),z=Q*h,x=ea*Q,S=x-(x-Q),T=Q-S,x=ea*h,N=x-(x-h),C=h-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const Z=j3(ie,vR,4,ma,_R);I=l*m,x=ea*l,S=x-(x-l),T=l-S,x=ea*m,N=x-(x-m),C=m-N,j=T*C-(I-S*N-T*N-S*C),z=u*h,x=ea*u,S=x-(x-u),T=u-S,x=ea*h,N=x-(x-h),C=h-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const te=j3(Z,_R,4,ma,yR);return yR[te-1]}function Sm(i,e,t,n,r,s){const a=(e-s)*(t-r),l=(i-r)*(n-s),u=a-l,h=Math.abs(a+l);return Math.abs(u)>=zQ*h?u:-VQ(i,e,t,n,r,s,h)}const xR=Math.pow(2,-52),av=new Uint32Array(512);class pg{static from(e,t=XQ,n=YQ){const r=e.length,s=new Float64Array(r*2);for(let a=0;a>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:s}=this,a=e.length>>1;let l=1/0,u=1/0,h=-1/0,m=-1/0;for(let q=0;qh&&(h=V),Q>m&&(m=Q),this._ids[q]=q}const v=(l+h)/2,x=(u+m)/2;let S,T,N;for(let q=0,V=1/0;q0&&(T=q,V=Q)}let O=e[2*T],U=e[2*T+1],I=1/0;for(let q=0;qJ&&(q[V++]=ne,J=oe)}this.hull=q.subarray(0,V),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Sm(C,E,O,U,j,z)<0){const q=T,V=O,Q=U;T=N,O=j,U=z,N=q,j=V,z=Q}const G=$Q(C,E,O,U,j,z);this._cx=G.x,this._cy=G.y;for(let q=0;q0&&Math.abs(ne-V)<=xR&&Math.abs(oe-Q)<=xR||(V=ne,Q=oe,J===S||J===T||J===N))continue;let ie=0;for(let Te=0,ae=this._hashKey(ne,oe);Te=0;)if(Z=te,Z===ie){Z=-1;break}if(Z===-1)continue;let de=this._addTriangle(Z,J,n[Z],-1,-1,r[Z]);r[J]=this._legalize(de+2),r[Z]=de,H++;let Se=n[Z];for(;te=n[Se],Sm(ne,oe,e[2*Se],e[2*Se+1],e[2*te],e[2*te+1])<0;)de=this._addTriangle(Se,J,te,r[J],-1,r[Se]),r[J]=this._legalize(de+2),n[Se]=Se,H--,Se=te;if(Z===ie)for(;te=t[Z],Sm(ne,oe,e[2*te],e[2*te+1],e[2*Z],e[2*Z+1])<0;)de=this._addTriangle(te,J,Z,-1,r[Z],r[te]),this._legalize(de+2),r[te]=de,n[Z]=Z,H--,Z=te;this._hullStart=t[J]=Z,n[Z]=t[Se]=J,n[J]=Se,s[this._hashKey(ne,oe)]=J,s[this._hashKey(e[2*Z],e[2*Z+1])]=Z}this.hull=new Uint32Array(H);for(let q=0,V=this._hullStart;q0?3-t:1+t)/4}function H3(i,e,t,n){const r=i-t,s=e-n;return r*r+s*s}function HQ(i,e,t,n,r,s,a,l){const u=i-a,h=e-l,m=t-a,v=n-l,x=r-a,S=s-l,T=u*u+h*h,N=m*m+v*v,C=x*x+S*S;return u*(v*C-N*S)-h*(m*C-N*x)+T*(m*S-v*x)<0}function WQ(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=(h*m-l*v)*x,T=(a*v-u*m)*x;return S*S+T*T}function $Q(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=i+(h*m-l*v)*x,T=e+(a*v-u*m)*x;return{x:S,y:T}}function qA(i,e,t,n){if(n-t<=20)for(let r=t+1;r<=n;r++){const s=i[r],a=e[s];let l=r-1;for(;l>=t&&e[i[l]]>a;)i[l+1]=i[l--];i[l+1]=s}else{const r=t+n>>1;let s=t+1,a=n;nm(i,r,s),e[i[t]]>e[i[n]]&&nm(i,t,n),e[i[s]]>e[i[n]]&&nm(i,s,n),e[i[t]]>e[i[s]]&&nm(i,t,s);const l=i[s],u=e[l];for(;;){do s++;while(e[i[s]]u);if(a=a-t?(qA(i,e,s,n),qA(i,e,t,a-1)):(qA(i,e,t,a-1),qA(i,e,s,n))}}function nm(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function XQ(i){return i[0]}function YQ(i){return i[1]}function QQ(i,e){var t,n,r=0,s,a,l,u,h,m,v,x=i[0],S=i[1],T=e.length;for(t=0;t=0||a<=0&&u>=0)return 0}else if(h>=0&&l<=0||h<=0&&l>=0){if(s=Sm(a,u,l,h,0,0),s===0)return 0;(s>0&&h>0&&l<=0||s<0&&h<=0&&l>0)&&r++}m=v,l=h,a=u}}return r%2!==0}function KQ(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return[...i.geometry.coordinates];if(i.type==="Point")return[...i.coordinates]}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return[...i];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ZQ(i){return i.type==="Feature"?i.geometry:i}function JQ(i,e,t={}){if(!i)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=KQ(i),r=ZQ(e),s=r.type,a=e.bbox;let l=r.coordinates;if(a&&eK(n,a)===!1)return!1;s==="Polygon"&&(l=[l]);let u=!1;for(var h=0;h=i[0]&&e[3]>=i[1]}var tK=JQ;const bR=1e-6;class qf{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const r=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${r},${s}`:(Math.abs(this._x1-r)>bR||Math.abs(this._y1-s)>bR)&&(this._+="L"+r+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=s}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class Bw{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class nK{constructor(e,[t,n,r,s]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this;let s,a;const l=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let N=0,C=0,E=n.length,O,U;N1;)s-=2;for(let a=2;a0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function oK(i,e,t){return[i+Math.sin(i+e)*t,e+Math.cos(i-e)*t]}class wM{static from(e,t=rK,n=sK,r){return new wM("length"in e?lK(e,t,n,r):Float64Array.from(uK(e,t,n,r)))}constructor(e){this._delaunator=new pg(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&aK(e)){this.collinear=Int32Array.from({length:t.length/2},(x,S)=>S).sort((x,S)=>t[2*x]-t[2*S]||t[2*x+1]-t[2*S+1]);const u=this.collinear[0],h=this.collinear[this.collinear.length-1],m=[t[2*u],t[2*u+1],t[2*h],t[2*h+1]],v=1e-8*Math.hypot(m[3]-m[1],m[2]-m[0]);for(let x=0,S=t.length/2;x0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new nK(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:s,triangles:a,collinear:l}=this;if(l){const v=l.indexOf(e);v>0&&(yield l[v-1]),v=0&&s!==n&&s!==r;)n=s;return s}_step(e,t,n){const{inedges:r,hull:s,_hullIndex:a,halfedges:l,triangles:u,points:h}=this;if(r[e]===-1||!h.length)return(e+1)%(h.length>>1);let m=e,v=yA(t-h[e*2],2)+yA(n-h[e*2+1],2);const x=r[e];let S=x;do{let T=u[S];const N=yA(t-h[T*2],2)+yA(n-h[T*2+1],2);if(N0?1:i<0?-1:0},_P=Math.sqrt;function AK(i){return i>1?SR:i<-1?-SR:Math.asin(i)}function yP(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function yo(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function z_(i,e){return[i[0]+e[0],i[1]+e[1],i[2]+e[2]]}function G_(i){var e=_P(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);return[i[0]/e,i[1]/e,i[2]/e]}function MM(i){return[cK(i[1],i[0])*wR,AK(hK(-1,fK(1,i[2])))*wR]}function ru(i){const e=i[0]*TR,t=i[1]*TR,n=MR(t);return[n*MR(e),n*ER(e),ER(t)]}function EM(i){return i=i.map(e=>ru(e)),yP(i[0],yo(i[2],i[1]))}function pK(i){const e=gK(i),t=_K(e),n=vK(t,i),r=xK(t,i.length),s=mK(r,i),a=yK(t,i),{polygons:l,centers:u}=bK(a,t,i),h=SK(l),m=TK(t,i),v=wK(n,t);return{delaunay:e,edges:n,triangles:t,centers:u,neighbors:r,polygons:l,mesh:h,hull:m,urquhart:v,find:s}}function mK(i,e){function t(n,r){let s=n[0]-r[0],a=n[1]-r[1],l=n[2]-r[2];return s*s+a*a+l*l}return function(r,s,a){a===void 0&&(a=0);let l,u,h=a;const m=ru([r,s]);do l=a,a=null,u=t(m,ru(e[l])),i[l].forEach(v=>{let x=t(m,ru(e[v]));if(x1e32?r.push(v):S>s&&(s=S)}const a=1e6*_P(s);r.forEach(v=>i[v]=[a,0]),i.push([0,a]),i.push([-a,0]),i.push([0,-a]);const l=wM.from(i);l.projection=n;const{triangles:u,halfedges:h,inedges:m}=l;for(let v=0,x=h.length;vi.length-3-1&&(u[v]=e);return l}function vK(i,e){const t=new Set;return e.length===2?[[0,1]]:(i.forEach(n=>{if(n[0]!==n[1]&&!(EM(n.map(r=>e[r]))<0))for(let r=0,s;r<3;r++)s=(r+1)%3,t.add(h_([n[r],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function _K(i){const{triangles:e}=i;if(!e)return[];const t=[];for(let n=0,r=e.length/3;n{const n=t.map(s=>e[s]).map(ru),r=z_(z_(yo(n[1],n[0]),yo(n[2],n[1])),yo(n[0],n[2]));return MM(G_(r))})}function xK(i,e){const t=[];return i.forEach(n=>{for(let r=0;r<3;r++){const s=n[r],a=n[(r+1)%3];t[s]=t[s]||[],t[s].push(a)}}),i.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function bK(i,e,t){const n=[],r=i.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:r};if(t.length===2){const l=ru(t[0]),u=ru(t[1]),h=G_(z_(l,u)),m=G_(yo(l,u)),v=yo(h,m),x=[h,yo(h,v),yo(yo(h,v),v),yo(yo(yo(h,v),v),v)].map(MM).map(a);return n.push(x),n.push(x.slice().reverse()),{polygons:n,centers:r}}}e.forEach((l,u)=>{for(let h=0;h<3;h++){const m=l[h],v=l[(h+1)%3],x=l[(h+2)%3];n[m]=n[m]||[],n[m].push([v,x,u,[m,v,x]])}});const s=n.map(l=>{const u=[l[0][2]];let h=l[0][1];for(let m=1;m2)return u;if(u.length==2){const m=CR(t[l[0][3][0]],t[l[0][3][1]],r[u[0]]),v=CR(t[l[0][3][2]],t[l[0][3][0]],r[u[0]]),x=a(m),S=a(v);return[u[0],S,u[1],x]}});function a(l){let u=-1;return r.slice(e.length,1/0).forEach((h,m)=>{h[0]===l[0]&&h[1]===l[1]&&(u=m+e.length)}),u<0&&(u=r.length,r.push(l)),u}return{polygons:s,centers:r}}function CR(i,e,t){i=ru(i),e=ru(e),t=ru(t);const n=dK(yP(yo(e,i),t));return MM(G_(z_(i,e)).map(r=>n*r))}function SK(i){const e=[];return i.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let r of t)r>n&&e.push([n,r]),n=r}),e}function wK(i,e){return function(t){const n=new Map,r=new Map;return i.forEach((s,a)=>{const l=s.join("-");n.set(l,t[a]),r.set(l,!0)}),e.forEach(s=>{let a=0,l=-1;for(let u=0;u<3;u++){let h=h_([s[u],s[(u+1)%3]]).join("-");n.get(h)>a&&(a=n.get(h),l=h)}r.set(l,!1)}),i.map(s=>r.get(s.join("-")))}}function TK(i,e){const t=new Set,n=[];i.map(l=>{if(!(EM(l.map(u=>e[u>e.length?0:u]))>1e-12))for(let u=0;u<3;u++){let h=[l[u],l[(u+1)%3]],m=`${h[0]}-${h[1]}`;t.has(m)?t.delete(m):t.add(`${h[1]}-${h[0]}`)}});const r=new Map;let s;if(t.forEach(l=>{l=l.split("-").map(Number),r.set(l[0],l[1]),s=l[0]}),s===void 0)return n;let a=s;do{n.push(a);let l=r.get(a);r.set(a,-1),a=l}while(a>-1&&a!==s);return n}function MK(i){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(r=>[e._vx(r),e._vy(r),r]).filter(r=>isFinite(r[0]+r[1]));e.points=n.map(r=>[r[0],r[1]]),e.valid=n.map(r=>r[2]),e.delaunay=pK(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return k5(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return k5(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((r,s)=>n.features.push({type:"Feature",geometry:r?{type:"Polygon",coordinates:[[...r,r[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,r)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[r],n)).filter(n=>EM(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>kh(e.points[s[0]],e.points[s[1]])),r=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[a],urquhart:!!r[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:r}=e.delaunay,s=[];for(const a of r)if(a)for(let l=a.length,u=a[l-1],h=a[0],m=0;mu&&s.push([n[u],n[h]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,r){if(e._found=e.delaunay.find(t,n,e._found),!r||kh([t,n],e.points[e._found])r[s]),r[n[0]]]]}},i?e(i):e}function Ow(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,n=t===void 0?1/0:t,r=zK(i,n),s=og(r),a=GK(i,n),l=[].concat(W3(s),W3(a)),u={type:"Polygon",coordinates:i},h=qD(u),m=Wl(h,2),v=Wl(m[0],2),x=v[0],S=v[1],T=Wl(m[1],2),N=T[0],C=T[1],E=x>N||C>=89||S<=-89,O=[];if(E){var U=MK(l).triangles(),I=new Map(l.map(function(te,de){var Se=Wl(te,2),Te=Se[0],ae=Se[1];return["".concat(Te,"-").concat(ae),de]}));U.features.forEach(function(te){var de,Se=te.geometry.coordinates[0].slice(0,3).reverse(),Te=[];if(Se.forEach(function(Me){var Ve=Wl(Me,2),Ce=Ve[0],Fe=Ve[1],et="".concat(Ce,"-").concat(Fe);I.has(et)&&Te.push(I.get(et))}),Te.length===3){if(Te.some(function(Me){return Mee)for(var l=vM(r,s),u=1/Math.ceil(a/e),h=u;h<1;)n.push(l(h)),h+=u}n.push(r=s)}),n})}function GK(i,e){var t={type:"Polygon",coordinates:i},n=qD(t),r=Wl(n,2),s=Wl(r[0],2),a=s[0],l=s[1],u=Wl(r[1],2),h=u[0],m=u[1];if(Math.min(Math.abs(h-a),Math.abs(m-l))h||m>=89||l<=-89;return qK(e,{minLng:a,maxLng:h,minLat:l,maxLat:m}).filter(function(x){return Fw(x,t,v)})}function qK(i){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,n=e.maxLng,r=e.minLat,s=e.maxLat,a=Math.round(Math.pow(360/i,2)/Math.PI),l=(1+Math.sqrt(5))/2,u=function(E){return E/l*360%360-180},h=function(E){return Math.acos(2*E/a-1)/Math.PI*180-90},m=function(E){return a*(Math.cos((E+90)*Math.PI/180)+1)/2},v=[s!==void 0?Math.ceil(m(s)):0,r!==void 0?Math.floor(m(r)):a-1],x=t===void 0&&n===void 0?function(){return!0}:t===void 0?function(C){return C<=n}:n===void 0?function(C){return C>=t}:n>=t?function(C){return C>=t&&C<=n}:function(C){return C>=t||C<=n},S=[],T=v[0];T<=v[1];T++){var N=u(T);x(N)&&S.push([N,h(T)])}return S}function Fw(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?xX(e,i):tK(i,e)}var $v=window.THREE?window.THREE:{BufferGeometry:Hi,Float32BufferAttribute:Si},NR=new $v.BufferGeometry().setAttribute?"setAttribute":"addAttribute",CM=(function(i){function e(t,n,r,s,a,l,u){var h;DK(this,e),h=RK(this,e),h.type="ConicPolygonGeometry",h.parameters={polygonGeoJson:t,bottomHeight:n,topHeight:r,closedBottom:s,closedTop:a,includeSides:l,curvatureResolution:u},n=n||0,r=r||1,s=s!==void 0?s:!0,a=a!==void 0?a:!0,l=l!==void 0?l:!0,u=u||5;var m=kK(t,{resolution:u}),v=m.contour,x=m.triangles,S=og(x.uvs),T=[],N=[],C=[],E=0,O=function(G){var H=Math.round(T.length/3),q=C.length;T=T.concat(G.vertices),N=N.concat(G.uvs),C=C.concat(H?G.indices.map(function(V){return V+H}):G.indices),h.addGroup(q,C.length-q,E++)};l&&O(I()),s&&O(j(n,!1)),a&&O(j(r,!0)),h.setIndex(C),h[NR]("position",new $v.Float32BufferAttribute(T,3)),h[NR]("uv",new $v.Float32BufferAttribute(N,2)),h.computeVertexNormals();function U(z,G){var H=typeof G=="function"?G:function(){return G},q=z.map(function(V){return V.map(function(Q){var J=Wl(Q,2),ne=J[0],oe=J[1];return VK(oe,ne,H(ne,oe))})});return O_(q)}function I(){for(var z=U(v,n),G=z.vertices,H=z.holes,q=U(v,r),V=q.vertices,Q=og([V,G]),J=Math.round(V.length/3),ne=new Set(H),oe=0,ie=[],Z=0;Z=0;Te--)for(var ae=0;ae1&&arguments[1]!==void 0?arguments[1]:!0;return{indices:G?x.indices:x.indices.slice().reverse(),vertices:U([x.points],z).vertices,uvs:S}}return h}return LK(e,i),PK(e)})($v.BufferGeometry);function VK(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function kw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(l){return{keyAccessor:l,isProp:!(l instanceof Function)}}),s=i.reduce(function(l,u){var h=l,m=u;return r.forEach(function(v,x){var S=v.keyAccessor,T=v.isProp,N;if(T){var C=m,E=C[S],O=QK(C,[S].map(tZ));N=E,m=O}else N=S(m,x);x+11&&arguments[1]!==void 0?arguments[1]:1;h===r.length?Object.keys(u).forEach(function(m){return u[m]=t(u[m])}):Object.values(u).forEach(function(m){return l(m,h+1)})})(s);var a=s;return n&&(a=[],(function l(u){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];h.length===r.length?a.push({keys:h,vals:u}):Object.entries(u).forEach(function(m){var v=ZK(m,2),x=v[0],S=v[1];return l(S,[].concat(JK(h),[x]))})})(s),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a}),_i=(function(i){i=i||{};var e=typeof i<"u"?i:{},t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r="";function s(Ze){return e.locateFile?e.locateFile(Ze,r):r+Ze}var a;typeof document<"u"&&document.currentScript&&(r=document.currentScript.src),r.indexOf("blob:")!==0?r=r.substr(0,r.lastIndexOf("/")+1):r="",a=function(dt,Vt,xt){var A=new XMLHttpRequest;A.open("GET",dt,!0),A.responseType="arraybuffer",A.onload=function(){if(A.status==200||A.status==0&&A.response){Vt(A.response);return}var Vn=jt(dt);if(Vn){Vt(Vn.buffer);return}xt()},A.onerror=xt,A.send(null)};var l=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&e.arguments;var h=0,m=function(Ze){h=Ze},v=function(){return h},x=8;function S(Ze,dt,Vt,xt){switch(Vt=Vt||"i8",Vt.charAt(Vt.length-1)==="*"&&(Vt="i32"),Vt){case"i1":J[Ze>>0]=dt;break;case"i8":J[Ze>>0]=dt;break;case"i16":oe[Ze>>1]=dt;break;case"i32":ie[Ze>>2]=dt;break;case"i64":pe=[dt>>>0,(Oe=dt,+ft(Oe)>=1?Oe>0?(yt(+Wt(Oe/4294967296),4294967295)|0)>>>0:~~+fe((Oe-+(~~Oe>>>0))/4294967296)>>>0:0)],ie[Ze>>2]=pe[0],ie[Ze+4>>2]=pe[1];break;case"float":Z[Ze>>2]=dt;break;case"double":te[Ze>>3]=dt;break;default:qn("invalid type for setValue: "+Vt)}}function T(Ze,dt,Vt){switch(dt=dt||"i8",dt.charAt(dt.length-1)==="*"&&(dt="i32"),dt){case"i1":return J[Ze>>0];case"i8":return J[Ze>>0];case"i16":return oe[Ze>>1];case"i32":return ie[Ze>>2];case"i64":return ie[Ze>>2];case"float":return Z[Ze>>2];case"double":return te[Ze>>3];default:qn("invalid type for getValue: "+dt)}return null}var N=!1;function C(Ze,dt){Ze||qn("Assertion failed: "+dt)}function E(Ze){var dt=e["_"+Ze];return C(dt,"Cannot call unknown function "+Ze+", make sure it is exported"),dt}function O(Ze,dt,Vt,xt,A){var ee={string:function(mn){var Er=0;if(mn!=null&&mn!==0){var Wi=(mn.length<<2)+1;Er=ot(Wi),H(mn,Er,Wi)}return Er},array:function(mn){var Er=ot(mn.length);return q(mn,Er),Er}};function Vn(mn){return dt==="string"?z(mn):dt==="boolean"?!!mn:mn}var Wn=E(Ze),$n=[],dn=0;if(xt)for(var Fn=0;Fn=xt);)++A;if(A-dt>16&&Ze.subarray&&I)return I.decode(Ze.subarray(dt,A));for(var ee="";dt>10,56320|dn&1023)}}return ee}function z(Ze,dt){return Ze?j(ne,Ze,dt):""}function G(Ze,dt,Vt,xt){if(!(xt>0))return 0;for(var A=Vt,ee=Vt+xt-1,Vn=0;Vn=55296&&Wn<=57343){var $n=Ze.charCodeAt(++Vn);Wn=65536+((Wn&1023)<<10)|$n&1023}if(Wn<=127){if(Vt>=ee)break;dt[Vt++]=Wn}else if(Wn<=2047){if(Vt+1>=ee)break;dt[Vt++]=192|Wn>>6,dt[Vt++]=128|Wn&63}else if(Wn<=65535){if(Vt+2>=ee)break;dt[Vt++]=224|Wn>>12,dt[Vt++]=128|Wn>>6&63,dt[Vt++]=128|Wn&63}else{if(Vt+3>=ee)break;dt[Vt++]=240|Wn>>18,dt[Vt++]=128|Wn>>12&63,dt[Vt++]=128|Wn>>6&63,dt[Vt++]=128|Wn&63}}return dt[Vt]=0,Vt-A}function H(Ze,dt,Vt){return G(Ze,ne,dt,Vt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function q(Ze,dt){J.set(Ze,dt)}function V(Ze,dt){return Ze%dt>0&&(Ze+=dt-Ze%dt),Ze}var Q,J,ne,oe,ie,Z,te;function de(Ze){Q=Ze,e.HEAP8=J=new Int8Array(Ze),e.HEAP16=oe=new Int16Array(Ze),e.HEAP32=ie=new Int32Array(Ze),e.HEAPU8=ne=new Uint8Array(Ze),e.HEAPU16=new Uint16Array(Ze),e.HEAPU32=new Uint32Array(Ze),e.HEAPF32=Z=new Float32Array(Ze),e.HEAPF64=te=new Float64Array(Ze)}var Se=5271536,Te=28624,ae=e.TOTAL_MEMORY||33554432;e.buffer?Q=e.buffer:Q=new ArrayBuffer(ae),ae=Q.byteLength,de(Q),ie[Te>>2]=Se;function Me(Ze){for(;Ze.length>0;){var dt=Ze.shift();if(typeof dt=="function"){dt();continue}var Vt=dt.func;typeof Vt=="number"?dt.arg===void 0?e.dynCall_v(Vt):e.dynCall_vi(Vt,dt.arg):Vt(dt.arg===void 0?null:dt.arg)}}var Ve=[],Ce=[],Fe=[],et=[];function He(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Pt(e.preRun.shift());Me(Ve)}function Rt(){Me(Ce)}function Et(){Me(Fe)}function zt(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)We(e.postRun.shift());Me(et)}function Pt(Ze){Ve.unshift(Ze)}function We(Ze){et.unshift(Ze)}var ft=Math.abs,fe=Math.ceil,Wt=Math.floor,yt=Math.min,Gt=0,_t=null;function Xt(Ze){Gt++,e.monitorRunDependencies&&e.monitorRunDependencies(Gt)}function pt(Ze){if(Gt--,e.monitorRunDependencies&&e.monitorRunDependencies(Gt),Gt==0&&_t){var dt=_t;_t=null,dt()}}e.preloadedImages={},e.preloadedAudios={};var Ae=null,k="data:application/octet-stream;base64,";function be(Ze){return String.prototype.startsWith?Ze.startsWith(k):Ze.indexOf(k)===0}var Oe,pe;Ae="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var le=28640;function Ne(Ze,dt,Vt,xt){qn("Assertion failed: "+z(Ze)+", at: "+[dt?z(dt):"unknown filename",Vt,xt?z(xt):"unknown function"])}function De(){return J.length}function Je(Ze,dt,Vt){ne.set(ne.subarray(dt,dt+Vt),Ze)}function we(Ze){return e.___errno_location&&(ie[e.___errno_location()>>2]=Ze),Ze}function Ue(Ze){qn("OOM")}function ut(Ze){try{var dt=new ArrayBuffer(Ze);return dt.byteLength!=Ze?void 0:(new Int8Array(dt).set(J),Ot(dt),de(dt),1)}catch{}}function Dt(Ze){var dt=De(),Vt=16777216,xt=2147483648-Vt;if(Ze>xt)return!1;for(var A=16777216,ee=Math.max(dt,A);ee>4,A=(Wn&15)<<4|$n>>2,ee=($n&3)<<6|dn,Vt=Vt+String.fromCharCode(xt),$n!==64&&(Vt=Vt+String.fromCharCode(A)),dn!==64&&(Vt=Vt+String.fromCharCode(ee));while(Fn13780509?(f=ku(15,f)|0,f|0):(p=((d|0)<0)<<31>>31,y=ur(d|0,p|0,3,0)|0,_=X()|0,p=tn(d|0,p|0,1,0)|0,p=ur(y|0,_|0,p|0,X()|0)|0,p=tn(p|0,X()|0,1,0)|0,d=X()|0,A[f>>2]=p,A[f+4>>2]=d,f=0,f|0)}function ys(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,Vr(d,f,p,_,0)|0}function Vr(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0;if(B=K,K=K+16|0,M=B,!(Di(d,f,p,_,y)|0))return _=0,K=B,_|0;do if((p|0)>=0){if((p|0)>13780509){if(w=ku(15,M)|0,w|0)break;R=M,M=A[R>>2]|0,R=A[R+4>>2]|0}else w=((p|0)<0)<<31>>31,F=ur(p|0,w|0,3,0)|0,R=X()|0,w=tn(p|0,w|0,1,0)|0,w=ur(F|0,R|0,w|0,X()|0)|0,w=tn(w|0,X()|0,1,0)|0,R=X()|0,A[M>>2]=w,A[M+4>>2]=R,M=w;if(ao(_|0,0,M<<3|0)|0,y|0){ao(y|0,0,M<<2|0)|0,w=sr(d,f,p,_,y,M,R,0)|0;break}w=Ys(M,4)|0,w?(F=sr(d,f,p,_,w,M,R,0)|0,vn(w),w=F):w=13}else w=2;while(!1);return F=w,K=B,F|0}function Di(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0;if(Pe=K,K=K+16|0,ve=Pe,ye=Pe+8|0,_e=ve,A[_e>>2]=d,A[_e+4>>2]=f,(p|0)<0)return ye=2,K=Pe,ye|0;if(w=_,A[w>>2]=d,A[w+4>>2]=f,w=(y|0)!=0,w&&(A[y>>2]=0),wi(d,f)|0)return ye=9,K=Pe,ye|0;A[ye>>2]=0;e:do if((p|0)>=1)if(w)for(W=1,F=0,se=0,_e=1,w=d;;){if(!(F|se)){if(w=bi(w,f,4,ye,ve)|0,w|0)break e;if(f=ve,w=A[f>>2]|0,f=A[f+4>>2]|0,wi(w,f)|0){w=9;break e}}if(w=bi(w,f,A[26800+(se<<2)>>2]|0,ye,ve)|0,w|0)break e;if(f=ve,w=A[f>>2]|0,f=A[f+4>>2]|0,d=_+(W<<3)|0,A[d>>2]=w,A[d+4>>2]=f,A[y+(W<<2)>>2]=_e,d=F+1|0,M=(d|0)==(_e|0),R=se+1|0,B=(R|0)==6,wi(w,f)|0){w=9;break e}if(_e=_e+(B&M&1)|0,(_e|0)>(p|0)){w=0;break}else W=W+1|0,F=M?0:d,se=M?B?0:R:se}else for(W=1,F=0,se=0,_e=1,w=d;;){if(!(F|se)){if(w=bi(w,f,4,ye,ve)|0,w|0)break e;if(f=ve,w=A[f>>2]|0,f=A[f+4>>2]|0,wi(w,f)|0){w=9;break e}}if(w=bi(w,f,A[26800+(se<<2)>>2]|0,ye,ve)|0,w|0)break e;if(f=ve,w=A[f>>2]|0,f=A[f+4>>2]|0,d=_+(W<<3)|0,A[d>>2]=w,A[d+4>>2]=f,d=F+1|0,M=(d|0)==(_e|0),R=se+1|0,B=(R|0)==6,wi(w,f)|0){w=9;break e}if(_e=_e+(B&M&1)|0,(_e|0)>(p|0)){w=0;break}else W=W+1|0,F=M?0:d,se=M?B?0:R:se}else w=0;while(!1);return ye=w,K=Pe,ye|0}function sr(d,f,p,_,y,w,M,R){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0,R=R|0;var B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0;if(Pe=K,K=K+16|0,ve=Pe+8|0,ye=Pe,B=Yu(d|0,f|0,w|0,M|0)|0,W=X()|0,se=_+(B<<3)|0,ze=se,nt=A[ze>>2]|0,ze=A[ze+4>>2]|0,F=(nt|0)==(d|0)&(ze|0)==(f|0),!((nt|0)==0&(ze|0)==0|F))do B=tn(B|0,W|0,1,0)|0,B=Kc(B|0,X()|0,w|0,M|0)|0,W=X()|0,se=_+(B<<3)|0,nt=se,ze=A[nt>>2]|0,nt=A[nt+4>>2]|0,F=(ze|0)==(d|0)&(nt|0)==(f|0);while(!((ze|0)==0&(nt|0)==0|F));if(B=y+(B<<2)|0,F&&(A[B>>2]|0)<=(R|0)||(nt=se,A[nt>>2]=d,A[nt+4>>2]=f,A[B>>2]=R,(R|0)>=(p|0)))return nt=0,K=Pe,nt|0;switch(F=R+1|0,A[ve>>2]=0,B=bi(d,f,2,ve,ye)|0,B|0){case 9:{_e=9;break}case 0:{B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B||(_e=9);break}}e:do if((_e|0)==9){switch(A[ve>>2]=0,B=bi(d,f,3,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ve>>2]=0,B=bi(d,f,1,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ve>>2]=0,B=bi(d,f,5,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ve>>2]=0,B=bi(d,f,4,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ve>>2]=0,B=bi(d,f,6,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}return nt=0,K=Pe,nt|0}while(!1);return nt=B,K=Pe,nt|0}function bi(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0;if(p>>>0>6)return y=1,y|0;if(se=(A[_>>2]|0)%6|0,A[_>>2]=se,(se|0)>0){w=0;do p=Nu(p)|0,w=w+1|0;while((w|0)<(A[_>>2]|0))}if(se=Ct(d|0,f|0,45)|0,X()|0,W=se&127,W>>>0>121)return y=5,y|0;B=Hs(d,f)|0,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15;e:do if(!w)F=8;else{for(;;){if(M=(15-w|0)*3|0,R=Ct(d|0,f|0,M|0)|0,X()|0,R=R&7,(R|0)==7){f=5;break}if(ye=(bs(w)|0)==0,w=w+-1|0,_e=It(7,0,M|0)|0,f=f&~(X()|0),ve=It(A[(ye?432:16)+(R*28|0)+(p<<2)>>2]|0,0,M|0)|0,M=X()|0,p=A[(ye?640:224)+(R*28|0)+(p<<2)>>2]|0,d=ve|d&~_e,f=M|f,!p){p=0;break e}if(!w){F=8;break e}}return f|0}while(!1);(F|0)==8&&(ye=A[848+(W*28|0)+(p<<2)>>2]|0,ve=It(ye|0,0,45)|0,d=ve|d,f=X()|0|f&-1040385,p=A[4272+(W*28|0)+(p<<2)>>2]|0,(ye&127|0)==127&&(ye=It(A[848+(W*28|0)+20>>2]|0,0,45)|0,f=X()|0|f&-1040385,p=A[4272+(W*28|0)+20>>2]|0,d=Uu(ye|d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+1)),R=Ct(d|0,f|0,45)|0,X()|0,R=R&127;e:do if(Ji(R)|0){t:do if((Hs(d,f)|0)==1){if((W|0)!=(R|0))if(wu(R,A[7696+(W*28|0)>>2]|0)|0){d=lp(d,f)|0,M=1,f=X()|0;break}else tt(27795,26864,533,26872);switch(B|0){case 3:{d=Uu(d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+1,M=0;break t}case 5:{d=lp(d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+5,M=0;break t}case 0:return ye=9,ye|0;default:return ye=1,ye|0}}else M=0;while(!1);if((p|0)>0){w=0;do d=op(d,f)|0,f=X()|0,w=w+1|0;while((w|0)!=(p|0))}if((W|0)!=(R|0)){if(!(qc(R)|0)){if((M|0)!=0|(Hs(d,f)|0)!=5)break;A[_>>2]=(A[_>>2]|0)+1;break}switch(se&127){case 8:case 118:break e}(Hs(d,f)|0)!=3&&(A[_>>2]=(A[_>>2]|0)+1)}}else if((p|0)>0){w=0;do d=Uu(d,f)|0,f=X()|0,w=w+1|0;while((w|0)!=(p|0))}while(!1);return A[_>>2]=((A[_>>2]|0)+p|0)%6|0,ye=y,A[ye>>2]=d,A[ye+4>>2]=f,ye=0,ye|0}function _r(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,Jr(d,f,p,_)|0?(ao(_|0,0,p*48|0)|0,_=Gc(d,f,p,_)|0,_|0):(_=0,_|0)}function Jr(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0;if(ye=K,K=K+16|0,_e=ye,ve=ye+8|0,se=_e,A[se>>2]=d,A[se+4>>2]=f,(p|0)<0)return ve=2,K=ye,ve|0;if(!p)return ve=_,A[ve>>2]=d,A[ve+4>>2]=f,ve=0,K=ye,ve|0;A[ve>>2]=0;e:do if(wi(d,f)|0)d=9;else{y=0,se=d;do{if(d=bi(se,f,4,ve,_e)|0,d|0)break e;if(f=_e,se=A[f>>2]|0,f=A[f+4>>2]|0,y=y+1|0,wi(se,f)|0){d=9;break e}}while((y|0)<(p|0));W=_,A[W>>2]=se,A[W+4>>2]=f,W=p+-1|0,F=0,d=1;do{if(y=26800+(F<<2)|0,(F|0)==5)for(M=A[y>>2]|0,w=0,y=d;;){if(d=_e,d=bi(A[d>>2]|0,A[d+4>>2]|0,M,ve,_e)|0,d|0)break e;if((w|0)!=(W|0))if(B=_e,R=A[B>>2]|0,B=A[B+4>>2]|0,d=_+(y<<3)|0,A[d>>2]=R,A[d+4>>2]=B,!(wi(R,B)|0))d=y+1|0;else{d=9;break e}else d=y;if(w=w+1|0,(w|0)>=(p|0))break;y=d}else for(M=_e,B=A[y>>2]|0,R=0,y=d,w=A[M>>2]|0,M=A[M+4>>2]|0;;){if(d=bi(w,M,B,ve,_e)|0,d|0)break e;if(M=_e,w=A[M>>2]|0,M=A[M+4>>2]|0,d=_+(y<<3)|0,A[d>>2]=w,A[d+4>>2]=M,d=y+1|0,wi(w,M)|0){d=9;break e}if(R=R+1|0,(R|0)>=(p|0))break;y=d}F=F+1|0}while(F>>>0<6);d=_e,d=(se|0)==(A[d>>2]|0)&&(f|0)==(A[d+4>>2]|0)?0:9}while(!1);return ve=d,K=ye,ve|0}function Gc(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;if(se=K,K=K+16|0,M=se,!p)return A[_>>2]=d,A[_+4>>2]=f,_=0,K=se,_|0;do if((p|0)>=0){if((p|0)>13780509){if(y=ku(15,M)|0,y|0)break;w=M,y=A[w>>2]|0,w=A[w+4>>2]|0}else y=((p|0)<0)<<31>>31,W=ur(p|0,y|0,3,0)|0,w=X()|0,y=tn(p|0,y|0,1,0)|0,y=ur(W|0,w|0,y|0,X()|0)|0,y=tn(y|0,X()|0,1,0)|0,w=X()|0,W=M,A[W>>2]=y,A[W+4>>2]=w;if(F=Ys(y,8)|0,!F)y=13;else{if(W=Ys(y,4)|0,!W){vn(F),y=13;break}if(y=sr(d,f,p,F,W,y,w,0)|0,y|0){vn(F),vn(W);break}if(f=A[M>>2]|0,M=A[M+4>>2]|0,(M|0)>0|(M|0)==0&f>>>0>0){y=0,R=0,B=0;do d=F+(R<<3)|0,w=A[d>>2]|0,d=A[d+4>>2]|0,!((w|0)==0&(d|0)==0)&&(A[W+(R<<2)>>2]|0)==(p|0)&&(_e=_+(y<<3)|0,A[_e>>2]=w,A[_e+4>>2]=d,y=y+1|0),R=tn(R|0,B|0,1,0)|0,B=X()|0;while((B|0)<(M|0)|(B|0)==(M|0)&R>>>0>>0)}vn(F),vn(W),y=0}}else y=2;while(!1);return _e=y,K=se,_e|0}function xs(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;for(R=K,K=K+16|0,w=R,M=R+8|0,y=(wi(d,f)|0)==0,y=y?1:2;;){if(A[M>>2]=0,F=(bi(d,f,y,M,w)|0)==0,B=w,F&((A[B>>2]|0)==(p|0)?(A[B+4>>2]|0)==(_|0):0)){d=4;break}if(y=y+1|0,y>>>0>=7){y=7,d=4;break}}return(d|0)==4?(K=R,y|0):0}function ux(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;if(R=K,K=K+48|0,y=R+16|0,w=R+8|0,M=R,p=Ma(p)|0,p|0)return M=p,K=R,M|0;if(F=d,B=A[F+4>>2]|0,p=w,A[p>>2]=A[F>>2],A[p+4>>2]=B,da(w,y),p=Jh(y,f,M)|0,!p){if(f=A[w>>2]|0,w=A[d+8>>2]|0,(w|0)>0){y=A[d+12>>2]|0,p=0;do f=(A[y+(p<<3)>>2]|0)+f|0,p=p+1|0;while((p|0)<(w|0))}p=M,y=A[p>>2]|0,p=A[p+4>>2]|0,w=((f|0)<0)<<31>>31,(p|0)<(w|0)|(p|0)==(w|0)&y>>>0>>0?(p=M,A[p>>2]=f,A[p+4>>2]=w,p=w):f=y,B=tn(f|0,p|0,12,0)|0,F=X()|0,p=M,A[p>>2]=B,A[p+4>>2]=F,p=_,A[p>>2]=B,A[p+4>>2]=F,p=0}return F=p,K=R,F|0}function Y0(d,f,p,_,y,w,M){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0;var R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0,xn=0,si=0,Cn=0,Ti=0,ws=0,cl=0;if(si=K,K=K+64|0,En=si+48|0,fn=si+32|0,kt=si+24|0,Ft=si+8|0,un=si,B=A[d>>2]|0,(B|0)<=0)return xn=0,K=si,xn|0;for(on=d+4|0,kn=En+8|0,Dn=fn+8|0,Zn=Ft+8|0,R=0,je=0;;){F=A[on>>2]|0,Xe=F+(je<<4)|0,A[En>>2]=A[Xe>>2],A[En+4>>2]=A[Xe+4>>2],A[En+8>>2]=A[Xe+8>>2],A[En+12>>2]=A[Xe+12>>2],(je|0)==(B+-1|0)?(A[fn>>2]=A[F>>2],A[fn+4>>2]=A[F+4>>2],A[fn+8>>2]=A[F+8>>2],A[fn+12>>2]=A[F+12>>2]):(Xe=F+(je+1<<4)|0,A[fn>>2]=A[Xe>>2],A[fn+4>>2]=A[Xe+4>>2],A[fn+8>>2]=A[Xe+8>>2],A[fn+12>>2]=A[Xe+12>>2]),B=s1(En,fn,_,kt)|0;e:do if(B)F=0,R=B;else if(B=kt,F=A[B>>2]|0,B=A[B+4>>2]|0,(B|0)>0|(B|0)==0&F>>>0>0){nt=0,Xe=0;t:for(;;){if(Ti=1/(+(F>>>0)+4294967296*+(B|0)),cl=+ee[En>>3],B=Lr(F|0,B|0,nt|0,Xe|0)|0,ws=+(B>>>0)+4294967296*+(X()|0),Cn=+(nt>>>0)+4294967296*+(Xe|0),ee[Ft>>3]=Ti*(cl*ws)+Ti*(+ee[fn>>3]*Cn),ee[Zn>>3]=Ti*(+ee[kn>>3]*ws)+Ti*(+ee[Dn>>3]*Cn),B=Ed(Ft,_,un)|0,B|0){R=B;break}ze=un,Pe=A[ze>>2]|0,ze=A[ze+4>>2]|0,_e=Yu(Pe|0,ze|0,f|0,p|0)|0,W=X()|0,B=M+(_e<<3)|0,se=B,F=A[se>>2]|0,se=A[se+4>>2]|0;n:do if((F|0)==0&(se|0)==0)Le=B,xn=16;else for(ve=0,ye=0;;){if((ve|0)>(p|0)|(ve|0)==(p|0)&ye>>>0>f>>>0){R=1;break t}if((F|0)==(Pe|0)&(se|0)==(ze|0))break n;if(B=tn(_e|0,W|0,1,0)|0,_e=Kc(B|0,X()|0,f|0,p|0)|0,W=X()|0,ye=tn(ye|0,ve|0,1,0)|0,ve=X()|0,B=M+(_e<<3)|0,se=B,F=A[se>>2]|0,se=A[se+4>>2]|0,(F|0)==0&(se|0)==0){Le=B,xn=16;break}}while(!1);if((xn|0)==16&&(xn=0,!((Pe|0)==0&(ze|0)==0))&&(ye=Le,A[ye>>2]=Pe,A[ye+4>>2]=ze,ye=w+(A[y>>2]<<3)|0,A[ye>>2]=Pe,A[ye+4>>2]=ze,ye=y,ye=tn(A[ye>>2]|0,A[ye+4>>2]|0,1,0)|0,Pe=X()|0,ze=y,A[ze>>2]=ye,A[ze+4>>2]=Pe),nt=tn(nt|0,Xe|0,1,0)|0,Xe=X()|0,B=kt,F=A[B>>2]|0,B=A[B+4>>2]|0,!((B|0)>(Xe|0)|(B|0)==(Xe|0)&F>>>0>nt>>>0)){F=1;break e}}F=0}else F=1;while(!1);if(je=je+1|0,!F){xn=21;break}if(B=A[d>>2]|0,(je|0)>=(B|0)){R=0,xn=21;break}}return(xn|0)==21?(K=si,R|0):0}function i1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0,xn=0,si=0,Cn=0,Ti=0,ws=0;if(ws=K,K=K+112|0,xn=ws+80|0,B=ws+72|0,si=ws,Cn=ws+56|0,y=Ma(p)|0,y|0)return Ti=y,K=ws,Ti|0;if(F=d+8|0,Ti=Oo((A[F>>2]<<5)+32|0)|0,!Ti)return Ti=13,K=ws,Ti|0;if(Ea(d,Ti),y=Ma(p)|0,!y){if(fn=d,kt=A[fn+4>>2]|0,y=B,A[y>>2]=A[fn>>2],A[y+4>>2]=kt,da(B,xn),y=Jh(xn,f,si)|0,y)fn=0,kt=0;else{if(y=A[B>>2]|0,w=A[F>>2]|0,(w|0)>0){M=A[d+12>>2]|0,p=0;do y=(A[M+(p<<3)>>2]|0)+y|0,p=p+1|0;while((p|0)!=(w|0));p=y}else p=y;y=si,w=A[y>>2]|0,y=A[y+4>>2]|0,M=((p|0)<0)<<31>>31,(y|0)<(M|0)|(y|0)==(M|0)&w>>>0

>>0?(y=si,A[y>>2]=p,A[y+4>>2]=M,y=M):p=w,fn=tn(p|0,y|0,12,0)|0,kt=X()|0,y=si,A[y>>2]=fn,A[y+4>>2]=kt,y=0}if(!y){if(p=Ys(fn,8)|0,!p)return vn(Ti),Ti=13,K=ws,Ti|0;if(R=Ys(fn,8)|0,!R)return vn(Ti),vn(p),Ti=13,K=ws,Ti|0;Zn=xn,A[Zn>>2]=0,A[Zn+4>>2]=0,Zn=d,En=A[Zn+4>>2]|0,y=B,A[y>>2]=A[Zn>>2],A[y+4>>2]=En,y=Y0(B,fn,kt,f,xn,p,R)|0;e:do if(y)vn(p),vn(R),vn(Ti);else{t:do if((A[F>>2]|0)>0){for(M=d+12|0,w=0;y=Y0((A[M>>2]|0)+(w<<3)|0,fn,kt,f,xn,p,R)|0,w=w+1|0,!(y|0);)if((w|0)>=(A[F>>2]|0))break t;vn(p),vn(R),vn(Ti);break e}while(!1);(kt|0)>0|(kt|0)==0&fn>>>0>0&&ao(R|0,0,fn<<3|0)|0,En=xn,Zn=A[En+4>>2]|0;t:do if((Zn|0)>0|(Zn|0)==0&(A[En>>2]|0)>>>0>0){on=p,kn=R,Dn=p,Zn=R,En=p,y=p,Le=p,Ft=R,un=R,p=R;n:for(;;){for(ze=0,nt=0,Xe=0,je=0,w=0,M=0;;){R=si,B=R+56|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));if(f=on+(ze<<3)|0,F=A[f>>2]|0,f=A[f+4>>2]|0,Di(F,f,1,si,0)|0){R=si,B=R+56|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));R=Ys(7,4)|0,R|0&&(sr(F,f,1,si,R,7,0,0)|0,vn(R))}for(Pe=0;;){ye=si+(Pe<<3)|0,ve=A[ye>>2]|0,ye=A[ye+4>>2]|0;i:do if((ve|0)==0&(ye|0)==0)R=w,B=M;else{if(W=Yu(ve|0,ye|0,fn|0,kt|0)|0,F=X()|0,R=_+(W<<3)|0,f=R,B=A[f>>2]|0,f=A[f+4>>2]|0,!((B|0)==0&(f|0)==0)){se=0,_e=0;do{if((se|0)>(kt|0)|(se|0)==(kt|0)&_e>>>0>fn>>>0)break n;if((B|0)==(ve|0)&(f|0)==(ye|0)){R=w,B=M;break i}R=tn(W|0,F|0,1,0)|0,W=Kc(R|0,X()|0,fn|0,kt|0)|0,F=X()|0,_e=tn(_e|0,se|0,1,0)|0,se=X()|0,R=_+(W<<3)|0,f=R,B=A[f>>2]|0,f=A[f+4>>2]|0}while(!((B|0)==0&(f|0)==0))}if((ve|0)==0&(ye|0)==0){R=w,B=M;break}Dl(ve,ye,Cn)|0,Ca(d,Ti,Cn)|0&&(_e=tn(w|0,M|0,1,0)|0,M=X()|0,se=R,A[se>>2]=ve,A[se+4>>2]=ye,w=kn+(w<<3)|0,A[w>>2]=ve,A[w+4>>2]=ye,w=_e),R=w,B=M}while(!1);if(Pe=Pe+1|0,Pe>>>0>=7)break;w=R,M=B}if(ze=tn(ze|0,nt|0,1,0)|0,nt=X()|0,Xe=tn(Xe|0,je|0,1,0)|0,je=X()|0,M=xn,w=A[M>>2]|0,M=A[M+4>>2]|0,(je|0)<(M|0)|(je|0)==(M|0)&Xe>>>0>>0)w=R,M=B;else break}if((M|0)>0|(M|0)==0&w>>>0>0){w=0,M=0;do je=on+(w<<3)|0,A[je>>2]=0,A[je+4>>2]=0,w=tn(w|0,M|0,1,0)|0,M=X()|0,je=xn,Xe=A[je+4>>2]|0;while((M|0)<(Xe|0)|((M|0)==(Xe|0)?w>>>0<(A[je>>2]|0)>>>0:0))}if(je=xn,A[je>>2]=R,A[je+4>>2]=B,(B|0)>0|(B|0)==0&R>>>0>0)Pe=p,ze=un,nt=En,Xe=Ft,je=kn,p=Le,un=y,Ft=Dn,Le=Pe,y=ze,En=Zn,Zn=nt,Dn=Xe,kn=on,on=je;else break t}vn(Dn),vn(Zn),vn(Ti),y=1;break e}else y=R;while(!1);vn(Ti),vn(p),vn(y),y=0}while(!1);return Ti=y,K=ws,Ti|0}}return vn(Ti),Ti=y,K=ws,Ti|0}function Q0(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+176|0,B=W,(f|0)<1)return Bo(p,0,0),F=0,K=W,F|0;for(R=d,R=Ct(A[R>>2]|0,A[R+4>>2]|0,52)|0,X()|0,Bo(p,(f|0)>6?f:6,R&15),R=0;_=d+(R<<3)|0,_=Pl(A[_>>2]|0,A[_+4>>2]|0,B)|0,!(_|0);){if(_=A[B>>2]|0,(_|0)>0){M=0;do w=B+8+(M<<4)|0,M=M+1|0,_=B+8+(((M|0)%(_|0)|0)<<4)|0,y=$u(p,_,w)|0,y?Wu(p,y)|0:Fd(p,w,_)|0,_=A[B>>2]|0;while((M|0)<(_|0))}if(R=R+1|0,(R|0)>=(f|0)){_=0,F=13;break}}return(F|0)==13?(K=W,_|0):(Od(p),F=_,K=W,F|0)}function cx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(w=K,K=K+32|0,_=w,y=w+16|0,d=Q0(d,f,y)|0,d|0)return p=d,K=w,p|0;if(A[p>>2]=0,A[p+4>>2]=0,A[p+8>>2]=0,d=Id(y)|0,d|0)do{f=T1(p)|0;do Dd(f,d)|0,M=d+16|0,A[_>>2]=A[M>>2],A[_+4>>2]=A[M+4>>2],A[_+8>>2]=A[M+8>>2],A[_+12>>2]=A[M+12>>2],Wu(y,d)|0,d=hs(y,_)|0;while((d|0)!=0);d=Id(y)|0}while((d|0)!=0);return Od(y),d=Rx(p)|0,d?(Gu(p),M=d,K=w,M|0):(M=0,K=w,M|0)}function Ji(d){return d=d|0,d>>>0>121?(d=0,d|0):(d=A[7696+(d*28|0)+16>>2]|0,d|0)}function qc(d){return d=d|0,(d|0)==4|(d|0)==117|0}function Ro(d){return d=d|0,A[11120+((A[d>>2]|0)*216|0)+((A[d+4>>2]|0)*72|0)+((A[d+8>>2]|0)*24|0)+(A[d+12>>2]<<3)>>2]|0}function K0(d){return d=d|0,A[11120+((A[d>>2]|0)*216|0)+((A[d+4>>2]|0)*72|0)+((A[d+8>>2]|0)*24|0)+(A[d+12>>2]<<3)+4>>2]|0}function Z0(d,f){d=d|0,f=f|0,d=7696+(d*28|0)|0,A[f>>2]=A[d>>2],A[f+4>>2]=A[d+4>>2],A[f+8>>2]=A[d+8>>2],A[f+12>>2]=A[d+12>>2]}function Vc(d,f){d=d|0,f=f|0;var p=0,_=0;if(f>>>0>20)return f=-1,f|0;do if((A[11120+(f*216|0)>>2]|0)!=(d|0))if((A[11120+(f*216|0)+8>>2]|0)!=(d|0))if((A[11120+(f*216|0)+16>>2]|0)!=(d|0))if((A[11120+(f*216|0)+24>>2]|0)!=(d|0))if((A[11120+(f*216|0)+32>>2]|0)!=(d|0))if((A[11120+(f*216|0)+40>>2]|0)!=(d|0))if((A[11120+(f*216|0)+48>>2]|0)!=(d|0))if((A[11120+(f*216|0)+56>>2]|0)!=(d|0))if((A[11120+(f*216|0)+64>>2]|0)!=(d|0))if((A[11120+(f*216|0)+72>>2]|0)!=(d|0))if((A[11120+(f*216|0)+80>>2]|0)!=(d|0))if((A[11120+(f*216|0)+88>>2]|0)!=(d|0))if((A[11120+(f*216|0)+96>>2]|0)!=(d|0))if((A[11120+(f*216|0)+104>>2]|0)!=(d|0))if((A[11120+(f*216|0)+112>>2]|0)!=(d|0))if((A[11120+(f*216|0)+120>>2]|0)!=(d|0))if((A[11120+(f*216|0)+128>>2]|0)!=(d|0))if((A[11120+(f*216|0)+136>>2]|0)==(d|0))d=2,p=1,_=2;else{if((A[11120+(f*216|0)+144>>2]|0)==(d|0)){d=0,p=2,_=0;break}if((A[11120+(f*216|0)+152>>2]|0)==(d|0)){d=0,p=2,_=1;break}if((A[11120+(f*216|0)+160>>2]|0)==(d|0)){d=0,p=2,_=2;break}if((A[11120+(f*216|0)+168>>2]|0)==(d|0)){d=1,p=2,_=0;break}if((A[11120+(f*216|0)+176>>2]|0)==(d|0)){d=1,p=2,_=1;break}if((A[11120+(f*216|0)+184>>2]|0)==(d|0)){d=1,p=2,_=2;break}if((A[11120+(f*216|0)+192>>2]|0)==(d|0)){d=2,p=2,_=0;break}if((A[11120+(f*216|0)+200>>2]|0)==(d|0)){d=2,p=2,_=1;break}if((A[11120+(f*216|0)+208>>2]|0)==(d|0)){d=2,p=2,_=2;break}else d=-1;return d|0}else d=2,p=1,_=1;else d=2,p=1,_=0;else d=1,p=1,_=2;else d=1,p=1,_=1;else d=1,p=1,_=0;else d=0,p=1,_=2;else d=0,p=1,_=1;else d=0,p=1,_=0;else d=2,p=0,_=2;else d=2,p=0,_=1;else d=2,p=0,_=0;else d=1,p=0,_=2;else d=1,p=0,_=1;else d=1,p=0,_=0;else d=0,p=0,_=2;else d=0,p=0,_=1;else d=0,p=0,_=0;while(!1);return f=A[11120+(f*216|0)+(p*72|0)+(d*24|0)+(_<<3)+4>>2]|0,f|0}function wu(d,f){return d=d|0,f=f|0,(A[7696+(d*28|0)+20>>2]|0)==(f|0)?(f=1,f|0):(f=(A[7696+(d*28|0)+24>>2]|0)==(f|0),f|0)}function vd(d,f){return d=d|0,f=f|0,A[848+(d*28|0)+(f<<2)>>2]|0}function Xh(d,f){return d=d|0,f=f|0,(A[848+(d*28|0)>>2]|0)==(f|0)?(f=0,f|0):(A[848+(d*28|0)+4>>2]|0)==(f|0)?(f=1,f|0):(A[848+(d*28|0)+8>>2]|0)==(f|0)?(f=2,f|0):(A[848+(d*28|0)+12>>2]|0)==(f|0)?(f=3,f|0):(A[848+(d*28|0)+16>>2]|0)==(f|0)?(f=4,f|0):(A[848+(d*28|0)+20>>2]|0)==(f|0)?(f=5,f|0):((A[848+(d*28|0)+24>>2]|0)==(f|0)?6:7)|0}function r1(){return 122}function Yh(d){d=d|0;var f=0,p=0,_=0;f=0;do It(f|0,0,45)|0,_=X()|0|134225919,p=d+(f<<3)|0,A[p>>2]=-1,A[p+4>>2]=_,f=f+1|0;while((f|0)!=122);return 0}function el(d){d=d|0;var f=0,p=0,_=0;return _=+ee[d+16>>3],p=+ee[d+24>>3],f=_-p,+(_>3]<+ee[d+24>>3]|0}function Qh(d){return d=d|0,+(+ee[d>>3]-+ee[d+8>>3])}function Do(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;return p=+ee[f>>3],!(p>=+ee[d+8>>3])||!(p<=+ee[d>>3])?(f=0,f|0):(_=+ee[d+16>>3],p=+ee[d+24>>3],y=+ee[f+8>>3],f=y>=p,d=y<=_&1,_>3]<+ee[f+8>>3]||+ee[d+8>>3]>+ee[f>>3]?(_=0,_|0):(w=+ee[d+16>>3],p=d+24|0,W=+ee[p>>3],M=w>3],y=f+24|0,B=+ee[y>>3],R=F>3],f)||(W=+Ws(+ee[p>>3],d),W>+Ws(+ee[_>>3],f))?(R=0,R|0):(R=1,R|0))}function yd(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0;w=+ee[d+16>>3],B=+ee[d+24>>3],d=w>3],M=+ee[f+24>>3],y=R>2]=d?y|f?1:2:0,A[_>>2]=y?d?1:f?2:1:0}function J0(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;return+ee[d>>3]<+ee[f>>3]||+ee[d+8>>3]>+ee[f+8>>3]?(_=0,_|0):(_=d+16|0,B=+ee[_>>3],w=+ee[d+24>>3],M=B>3],y=f+24|0,F=+ee[y>>3],R=W>3],f)?(W=+Ws(+ee[_>>3],d),R=W>=+Ws(+ee[p>>3],f),R|0):(R=0,R|0))}function Zh(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;y=K,K=K+176|0,_=y,A[_>>2]=4,R=+ee[f>>3],ee[_+8>>3]=R,w=+ee[f+16>>3],ee[_+16>>3]=w,ee[_+24>>3]=R,R=+ee[f+24>>3],ee[_+32>>3]=R,M=+ee[f+8>>3],ee[_+40>>3]=M,ee[_+48>>3]=R,ee[_+56>>3]=M,ee[_+64>>3]=w,f=_+72|0,p=f+96|0;do A[f>>2]=0,f=f+4|0;while((f|0)<(p|0));Ol(d|0,_|0,168)|0,K=y}function Jh(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0;ye=K,K=K+288|0,W=ye+264|0,se=ye+96|0,F=ye,R=F,B=R+96|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));return f=Iu(f,F)|0,f|0?(ve=f,K=ye,ve|0):(B=F,F=A[B>>2]|0,B=A[B+4>>2]|0,Dl(F,B,W)|0,Pl(F,B,se)|0,M=+Xc(W,se+8|0),ee[W>>3]=+ee[d>>3],B=W+8|0,ee[B>>3]=+ee[d+16>>3],ee[se>>3]=+ee[d+8>>3],F=se+8|0,ee[F>>3]=+ee[d+24>>3],y=+Xc(W,se),ze=+ee[B>>3]-+ee[F>>3],w=+dn(+ze),Pe=+ee[W>>3]-+ee[se>>3],_=+dn(+Pe),!(ze==0|Pe==0)&&(ze=+lf(+w,+_),ze=+rt(+(y*y/+uf(+(ze/+uf(+w,+_)),3)/(M*(M*2.59807621135)*.8))),ee[Vn>>3]=ze,_e=~~ze>>>0,ve=+dn(ze)>=1?ze>0?~~+qe(+$n(ze/4294967296),4294967295)>>>0:~~+rt((ze-+(~~ze>>>0))/4294967296)>>>0:0,(A[Vn+4>>2]&2146435072|0)!=2146435072)?(se=(_e|0)==0&(ve|0)==0,f=p,A[f>>2]=se?1:_e,A[f+4>>2]=se?0:ve,f=0):f=1,ve=f,K=ye,ve|0)}function s1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;F=K,K=K+288|0,M=F+264|0,R=F+96|0,B=F,y=B,w=y+96|0;do A[y>>2]=0,y=y+4|0;while((y|0)<(w|0));return p=Iu(p,B)|0,p|0?(_=p,K=F,_|0):(p=B,y=A[p>>2]|0,p=A[p+4>>2]|0,Dl(y,p,M)|0,Pl(y,p,R)|0,W=+Xc(M,R+8|0),W=+rt(+(+Xc(d,f)/(W*2))),ee[Vn>>3]=W,p=~~W>>>0,y=+dn(W)>=1?W>0?~~+qe(+$n(W/4294967296),4294967295)>>>0:~~+rt((W-+(~~W>>>0))/4294967296)>>>0:0,(A[Vn+4>>2]&2146435072|0)==2146435072?(_=1,K=F,_|0):(B=(p|0)==0&(y|0)==0,A[_>>2]=B?1:p,A[_+4>>2]=B?0:y,_=0,K=F,_|0))}function js(d,f){d=d|0,f=+f;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;w=d+16|0,M=+ee[w>>3],p=d+24|0,y=+ee[p>>3],_=M-y,_=M>3],R=d+8|0,B=+ee[R>>3],W=F-B,_=(_*f-_)*.5,f=(W*f-W)*.5,F=F+f,ee[d>>3]=F>1.5707963267948966?1.5707963267948966:F,f=B-f,ee[R>>3]=f<-1.5707963267948966?-1.5707963267948966:f,f=M+_,f=f>3.141592653589793?f+-6.283185307179586:f,ee[w>>3]=f<-3.141592653589793?f+6.283185307179586:f,f=y-_,f=f>3.141592653589793?f+-6.283185307179586:f,ee[p>>3]=f<-3.141592653589793?f+6.283185307179586:f}function Tu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0,A[d>>2]=f,A[d+4>>2]=p,A[d+8>>2]=_}function xd(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;se=f+8|0,A[se>>2]=0,B=+ee[d>>3],M=+dn(+B),F=+ee[d+8>>3],R=+dn(+F)*1.1547005383792515,M=M+R*.5,p=~~M,d=~~R,M=M-+(p|0),R=R-+(d|0);do if(M<.5)if(M<.3333333333333333)if(A[f>>2]=p,R<(M+1)*.5){A[f+4>>2]=d;break}else{d=d+1|0,A[f+4>>2]=d;break}else if(_e=1-M,d=(!(R<_e)&1)+d|0,A[f+4>>2]=d,_e<=R&R>2]=p;break}else{A[f>>2]=p;break}else{if(!(M<.6666666666666666))if(p=p+1|0,A[f>>2]=p,R>2]=d;break}else{d=d+1|0,A[f+4>>2]=d;break}if(R<1-M){if(A[f+4>>2]=d,M*2+-1>2]=p;break}}else d=d+1|0,A[f+4>>2]=d;p=p+1|0,A[f>>2]=p}while(!1);do if(B<0)if(d&1){W=(d+1|0)/2|0,W=Lr(p|0,((p|0)<0)<<31>>31|0,W|0,((W|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-((+(W>>>0)+4294967296*+(X()|0))*2+1)),A[f>>2]=p;break}else{W=(d|0)/2|0,W=Lr(p|0,((p|0)<0)<<31>>31|0,W|0,((W|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-(+(W>>>0)+4294967296*+(X()|0))*2),A[f>>2]=p;break}while(!1);W=f+4|0,F<0&&(p=p-((d<<1|1|0)/2|0)|0,A[f>>2]=p,d=0-d|0,A[W>>2]=d),_=d-p|0,(p|0)<0?(y=0-p|0,A[W>>2]=_,A[se>>2]=y,A[f>>2]=0,d=_,p=0):y=0,(d|0)<0&&(p=p-d|0,A[f>>2]=p,y=y-d|0,A[se>>2]=y,A[W>>2]=0,d=0),w=p-y|0,_=d-y|0,(y|0)<0&&(A[f>>2]=w,A[W>>2]=_,A[se>>2]=0,d=_,p=w,y=0),_=(d|0)<(p|0)?d:p,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(A[f>>2]=p-_,A[W>>2]=d-_,A[se>>2]=y-_)}function Pr(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,(f|0)<0&&(p=p-f|0,A[M>>2]=p,w=d+8|0,A[w>>2]=(A[w>>2]|0)-f,A[d>>2]=0,f=0),(p|0)<0?(f=f-p|0,A[d>>2]=f,w=d+8|0,y=(A[w>>2]|0)-p|0,A[w>>2]=y,A[M>>2]=0,p=0):(y=d+8|0,w=y,y=A[y>>2]|0),(y|0)<0&&(f=f-y|0,A[d>>2]=f,p=p-y|0,A[M>>2]=p,A[w>>2]=0,y=0),_=(p|0)<(f|0)?p:f,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(A[d>>2]=f-_,A[M>>2]=p-_,A[w>>2]=y-_)}function Mu(d,f){d=d|0,f=f|0;var p=0,_=0;_=A[d+8>>2]|0,p=+((A[d+4>>2]|0)-_|0),ee[f>>3]=+((A[d>>2]|0)-_|0)-p*.5,ee[f+8>>3]=p*.8660254037844386}function us(d,f,p){d=d|0,f=f|0,p=p|0,A[p>>2]=(A[f>>2]|0)+(A[d>>2]|0),A[p+4>>2]=(A[f+4>>2]|0)+(A[d+4>>2]|0),A[p+8>>2]=(A[f+8>>2]|0)+(A[d+8>>2]|0)}function ef(d,f,p){d=d|0,f=f|0,p=p|0,A[p>>2]=(A[d>>2]|0)-(A[f>>2]|0),A[p+4>>2]=(A[d+4>>2]|0)-(A[f+4>>2]|0),A[p+8>>2]=(A[d+8>>2]|0)-(A[f+8>>2]|0)}function jc(d,f){d=d|0,f=f|0;var p=0,_=0;p=it(A[d>>2]|0,f)|0,A[d>>2]=p,p=d+4|0,_=it(A[p>>2]|0,f)|0,A[p>>2]=_,d=d+8|0,f=it(A[d>>2]|0,f)|0,A[d>>2]=f}function Eu(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=A[d>>2]|0,R=(M|0)<0,_=(A[d+4>>2]|0)-(R?M:0)|0,w=(_|0)<0,y=(w?0-_|0:0)+((A[d+8>>2]|0)-(R?M:0))|0,p=(y|0)<0,d=p?0:y,f=(w?0:_)-(p?y:0)|0,y=(R?0:M)-(w?_:0)-(p?y:0)|0,p=(f|0)<(y|0)?f:y,p=(d|0)<(p|0)?d:p,_=(p|0)>0,d=d-(_?p:0)|0,f=f-(_?p:0)|0;e:do switch(y-(_?p:0)|0){case 0:switch(f|0){case 0:return R=(d|0)==0?0:(d|0)==1?1:7,R|0;case 1:return R=(d|0)==0?2:(d|0)==1?3:7,R|0;default:break e}case 1:switch(f|0){case 0:return R=(d|0)==0?4:(d|0)==1?5:7,R|0;case 1:{if(!d)d=6;else break e;return d|0}default:break e}}while(!1);return R=7,R|0}function a1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0;if(B=d+8|0,M=A[B>>2]|0,R=(A[d>>2]|0)-M|0,F=d+4|0,M=(A[F>>2]|0)-M|0,R>>>0>715827881|M>>>0>715827881){if(_=(R|0)>0,y=2147483647-R|0,w=-2147483648-R|0,(_?(y|0)<(R|0):(w|0)>(R|0))||(p=R<<1,_?(2147483647-p|0)<(R|0):(-2147483648-p|0)>(R|0))||((M|0)>0?(2147483647-M|0)<(M|0):(-2147483648-M|0)>(M|0))||(f=R*3|0,p=M<<1,(_?(y|0)<(p|0):(w|0)>(p|0))||((R|0)>-1?(f|-2147483648|0)>=(M|0):(f^-2147483648|0)<(M|0))))return F=1,F|0}else p=M<<1,f=R*3|0;return _=ol(+(f-M|0)*.14285714285714285)|0,A[d>>2]=_,y=ol(+(p+R|0)*.14285714285714285)|0,A[F>>2]=y,A[B>>2]=0,p=(y|0)<(_|0),f=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((f|0)>0?(2147483647-f|0)<(p|0):(-2147483648-f|0)>(p|0)))&&tt(27795,26892,354,26903),((f|0)>-1?(f|-2147483648|0)>=(p|0):(f^-2147483648|0)<(p|0))&&tt(27795,26892,354,26903)),f=y-_|0,(_|0)<0?(p=0-_|0,A[F>>2]=f,A[B>>2]=p,A[d>>2]=0,_=0):(f=y,p=0),(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[B>>2]=p,A[F>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[F>>2]=y,A[B>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(F=0,F|0):(A[d>>2]=y-_,A[F>>2]=f-_,A[B>>2]=p-_,F=0,F|0)}function hx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(M=d+8|0,y=A[M>>2]|0,w=(A[d>>2]|0)-y|0,R=d+4|0,y=(A[R>>2]|0)-y|0,w>>>0>715827881|y>>>0>715827881){if(p=(w|0)>0,(p?(2147483647-w|0)<(w|0):(-2147483648-w|0)>(w|0))||(f=w<<1,_=(y|0)>0,_?(2147483647-y|0)<(y|0):(-2147483648-y|0)>(y|0)))return R=1,R|0;if(B=y<<1,(_?(2147483647-B|0)<(y|0):(-2147483648-B|0)>(y|0))||(p?(2147483647-f|0)<(y|0):(-2147483648-f|0)>(y|0))||(p=y*3|0,(y|0)>-1?(p|-2147483648|0)>=(w|0):(p^-2147483648|0)<(w|0)))return B=1,B|0}else p=y*3|0,f=w<<1;return _=ol(+(f+y|0)*.14285714285714285)|0,A[d>>2]=_,y=ol(+(p-w|0)*.14285714285714285)|0,A[R>>2]=y,A[M>>2]=0,p=(y|0)<(_|0),f=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((f|0)>0?(2147483647-f|0)<(p|0):(-2147483648-f|0)>(p|0)))&&tt(27795,26892,402,26917),((f|0)>-1?(f|-2147483648|0)>=(p|0):(f^-2147483648|0)<(p|0))&&tt(27795,26892,402,26917)),f=y-_|0,(_|0)<0?(p=0-_|0,A[R>>2]=f,A[M>>2]=p,A[d>>2]=0,_=0):(f=y,p=0),(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(B=0,B|0):(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_,B=0,B|0)}function fx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=d+8|0,p=A[M>>2]|0,f=(A[d>>2]|0)-p|0,R=d+4|0,p=(A[R>>2]|0)-p|0,_=ol(+((f*3|0)-p|0)*.14285714285714285)|0,A[d>>2]=_,f=ol(+((p<<1)+f|0)*.14285714285714285)|0,A[R>>2]=f,A[M>>2]=0,p=f-_|0,(_|0)<0?(w=0-_|0,A[R>>2]=p,A[M>>2]=w,A[d>>2]=0,f=p,_=0,p=w):p=0,(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_)}function o1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=d+8|0,p=A[M>>2]|0,f=(A[d>>2]|0)-p|0,R=d+4|0,p=(A[R>>2]|0)-p|0,_=ol(+((f<<1)+p|0)*.14285714285714285)|0,A[d>>2]=_,f=ol(+((p*3|0)-f|0)*.14285714285714285)|0,A[R>>2]=f,A[M>>2]=0,p=f-_|0,(_|0)<0?(w=0-_|0,A[R>>2]=p,A[M>>2]=w,A[d>>2]=0,f=p,_=0,p=w):p=0,(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_)}function Hc(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,R=d+8|0,_=A[R>>2]|0,y=p+(f*3|0)|0,A[d>>2]=y,p=_+(p*3|0)|0,A[M>>2]=p,f=(_*3|0)+f|0,A[R>>2]=f,_=p-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=_,A[R>>2]=f,A[d>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function Cu(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=(f*3|0)+y|0,y=p+(y*3|0)|0,A[d>>2]=y,A[M>>2]=_,f=(p*3|0)+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,A[d>>2]=y,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=y-f|0,_=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=_,A[R>>2]=0,y=w,f=0):_=p,p=(_|0)<(y|0)?_:y,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=y-p,A[M>>2]=_-p,A[R>>2]=f-p)}function l1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;(f+-1|0)>>>0>=6||(y=(A[15440+(f*12|0)>>2]|0)+(A[d>>2]|0)|0,A[d>>2]=y,R=d+4|0,_=(A[15440+(f*12|0)+4>>2]|0)+(A[R>>2]|0)|0,A[R>>2]=_,M=d+8|0,f=(A[15440+(f*12|0)+8>>2]|0)+(A[M>>2]|0)|0,A[M>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[R>>2]=p,A[M>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[M>>2]=f,A[R>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[R>>2]=y-p,A[M>>2]=f-p))}function u1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=f+y|0,y=p+y|0,A[d>>2]=y,A[M>>2]=_,f=p+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function bd(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,_=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,y=_+f|0,A[d>>2]=y,_=p+_|0,A[M>>2]=_,f=p+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function Nu(d){switch(d=d|0,d|0){case 1:{d=5;break}case 5:{d=4;break}case 4:{d=6;break}case 6:{d=2;break}case 2:{d=3;break}case 3:{d=1;break}}return d|0}function tl(d){switch(d=d|0,d|0){case 1:{d=3;break}case 3:{d=2;break}case 2:{d=6;break}case 6:{d=4;break}case 4:{d=5;break}case 5:{d=1;break}}return d|0}function c1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,R=d+8|0,_=A[R>>2]|0,y=p+(f<<1)|0,A[d>>2]=y,p=_+(p<<1)|0,A[M>>2]=p,f=(_<<1)+f|0,A[R>>2]=f,_=p-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=_,A[R>>2]=f,A[d>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function h1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=(f<<1)+y|0,y=p+(y<<1)|0,A[d>>2]=y,A[M>>2]=_,f=(p<<1)+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,A[d>>2]=y,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=y-f|0,_=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=_,A[R>>2]=0,y=w,f=0):_=p,p=(_|0)<(y|0)?_:y,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=y-p,A[M>>2]=_-p,A[R>>2]=f-p)}function ep(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;return M=(A[d>>2]|0)-(A[f>>2]|0)|0,R=(M|0)<0,_=(A[d+4>>2]|0)-(A[f+4>>2]|0)-(R?M:0)|0,w=(_|0)<0,y=(R?0-M|0:0)+(A[d+8>>2]|0)-(A[f+8>>2]|0)+(w?0-_|0:0)|0,d=(y|0)<0,f=d?0:y,p=(w?0:_)-(d?y:0)|0,y=(R?0:M)-(w?_:0)-(d?y:0)|0,d=(p|0)<(y|0)?p:y,d=(f|0)<(d|0)?f:d,_=(d|0)>0,f=f-(_?d:0)|0,p=p-(_?d:0)|0,d=y-(_?d:0)|0,d=(d|0)>-1?d:0-d|0,p=(p|0)>-1?p:0-p|0,f=(f|0)>-1?f:0-f|0,f=(p|0)>(f|0)?p:f,((d|0)>(f|0)?d:f)|0}function dx(d,f){d=d|0,f=f|0;var p=0;p=A[d+8>>2]|0,A[f>>2]=(A[d>>2]|0)-p,A[f+4>>2]=(A[d+4>>2]|0)-p}function tp(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;return _=A[d>>2]|0,A[f>>2]=_,y=A[d+4>>2]|0,M=f+4|0,A[M>>2]=y,R=f+8|0,A[R>>2]=0,p=(y|0)<(_|0),d=p?_:y,p=p?y:_,(p|0)<0&&((p|0)==-2147483648||((d|0)>0?(2147483647-d|0)<(p|0):(-2147483648-d|0)>(p|0))||((d|0)>-1?(d|-2147483648|0)>=(p|0):(d^-2147483648|0)<(p|0)))?(f=1,f|0):(d=y-_|0,(_|0)<0?(p=0-_|0,A[M>>2]=d,A[R>>2]=p,A[f>>2]=0,_=0):(d=y,p=0),(d|0)<0&&(_=_-d|0,A[f>>2]=_,p=p-d|0,A[R>>2]=p,A[M>>2]=0,d=0),w=_-p|0,y=d-p|0,(p|0)<0?(A[f>>2]=w,A[M>>2]=y,A[R>>2]=0,d=y,y=w,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(f=0,f|0):(A[f>>2]=y-_,A[M>>2]=d-_,A[R>>2]=p-_,f=0,f|0))}function f1(d){d=d|0;var f=0,p=0,_=0,y=0;f=d+8|0,y=A[f>>2]|0,p=y-(A[d>>2]|0)|0,A[d>>2]=p,_=d+4|0,d=(A[_>>2]|0)-y|0,A[_>>2]=d,A[f>>2]=0-(d+p)}function Ax(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;p=A[d>>2]|0,f=0-p|0,A[d>>2]=f,M=d+8|0,A[M>>2]=0,R=d+4|0,_=A[R>>2]|0,y=_+p|0,(p|0)>0?(A[R>>2]=y,A[M>>2]=p,A[d>>2]=0,f=0,_=y):p=0,(_|0)<0?(w=f-_|0,A[d>>2]=w,p=p-_|0,A[M>>2]=p,A[R>>2]=0,y=w-p|0,f=0-p|0,(p|0)<0?(A[d>>2]=y,A[R>>2]=f,A[M>>2]=0,_=f,p=0):(_=0,y=w)):y=f,f=(_|0)<(y|0)?_:y,f=(p|0)<(f|0)?p:f,!((f|0)<=0)&&(A[d>>2]=y-f,A[R>>2]=_-f,A[M>>2]=p-f)}function px(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0;if(se=K,K=K+64|0,W=se,R=se+56|0,!(!0&(f&2013265920|0)==134217728&(!0&(_&2013265920|0)==134217728)))return y=5,K=se,y|0;if((d|0)==(p|0)&(f|0)==(_|0))return A[y>>2]=0,y=0,K=se,y|0;if(M=Ct(d|0,f|0,52)|0,X()|0,M=M&15,F=Ct(p|0,_|0,52)|0,X()|0,(M|0)!=(F&15|0))return y=12,K=se,y|0;if(w=M+-1|0,M>>>0>1){Lu(d,f,w,W)|0,Lu(p,_,w,R)|0,F=W,B=A[F>>2]|0,F=A[F+4>>2]|0;e:do if((B|0)==(A[R>>2]|0)&&(F|0)==(A[R+4>>2]|0)){M=(M^15)*3|0,w=Ct(d|0,f|0,M|0)|0,X()|0,w=w&7,M=Ct(p|0,_|0,M|0)|0,X()|0,M=M&7;do if((w|0)==0|(M|0)==0)A[y>>2]=1,w=0;else if((w|0)==7)w=5;else{if((w|0)==1|(M|0)==1&&wi(B,F)|0){w=5;break}if((A[15536+(w<<2)>>2]|0)!=(M|0)&&(A[15568+(w<<2)>>2]|0)!=(M|0))break e;A[y>>2]=1,w=0}while(!1);return y=w,K=se,y|0}while(!1)}w=W,M=w+56|0;do A[w>>2]=0,w=w+4|0;while((w|0)<(M|0));return ys(d,f,1,W)|0,f=W,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0))&&(f=W+8|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+16|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+24|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+32|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+40|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))?(w=W+48|0,w=((A[w>>2]|0)==(p|0)?(A[w+4>>2]|0)==(_|0):0)&1):w=1,A[y>>2]=w,y=0,K=se,y|0}function d1(d,f,p,_,y){return d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,p=xs(d,f,p,_)|0,(p|0)==7?(y=11,y|0):(_=It(p|0,0,56)|0,f=f&-2130706433|(X()|0)|268435456,A[y>>2]=d|_,A[y+4>>2]=f,y=0,y|0)}function mx(d,f,p){return d=d|0,f=f|0,p=p|0,!0&(f&2013265920|0)==268435456?(A[p>>2]=d,A[p+4>>2]=f&-2130706433|134217728,p=0,p|0):(p=6,p|0)}function gx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return y=K,K=K+16|0,_=y,A[_>>2]=0,!0&(f&2013265920|0)==268435456?(w=Ct(d|0,f|0,56)|0,X()|0,_=bi(d,f&-2130706433|134217728,w&7,_,p)|0,K=y,_|0):(_=6,K=y,_|0)}function A1(d,f){d=d|0,f=f|0;var p=0;switch(p=Ct(d|0,f|0,56)|0,X()|0,p&7){case 0:case 7:return p=0,p|0}return p=f&-2130706433|134217728,!(!0&(f&2013265920|0)==268435456)||!0&(f&117440512|0)==16777216&(wi(d,p)|0)!=0?(p=0,p|0):(p=Td(d,p)|0,p|0)}function vx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;return y=K,K=K+16|0,_=y,!0&(f&2013265920|0)==268435456?(w=f&-2130706433|134217728,M=p,A[M>>2]=d,A[M+4>>2]=w,A[_>>2]=0,f=Ct(d|0,f|0,56)|0,X()|0,_=bi(d,w,f&7,_,p+8|0)|0,K=y,_|0):(_=6,K=y,_|0)}function _x(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;return y=(wi(d,f)|0)==0,f=f&-2130706433,_=p,A[_>>2]=y?d:0,A[_+4>>2]=y?f|285212672:0,_=p+8|0,A[_>>2]=d,A[_+4>>2]=f|301989888,_=p+16|0,A[_>>2]=d,A[_+4>>2]=f|318767104,_=p+24|0,A[_>>2]=d,A[_+4>>2]=f|335544320,_=p+32|0,A[_>>2]=d,A[_+4>>2]=f|352321536,p=p+40|0,A[p>>2]=d,A[p+4>>2]=f|369098752,0}function Sd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;return M=K,K=K+16|0,y=M,w=f&-2130706433|134217728,!0&(f&2013265920|0)==268435456?(_=Ct(d|0,f|0,56)|0,X()|0,_=yp(d,w,_&7)|0,(_|0)==-1?(A[p>>2]=0,w=6,K=M,w|0):(Bu(d,w,y)|0&&tt(27795,26932,282,26947),f=Ct(d|0,f|0,52)|0,X()|0,f=f&15,wi(d,w)|0?np(y,f,_,2,p):wd(y,f,_,2,p),w=0,K=M,w|0)):(w=6,K=M,w|0)}function yx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;_=K,K=K+16|0,y=_,xx(d,f,p,y),xd(y,p+4|0),K=_}function xx(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0;if(R=K,K=K+16|0,B=R,bx(d,p,B),w=+Wi(+(1-+ee[B>>3]*.5)),w<1e-16){A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,A[_+12>>2]=0,K=R;return}if(B=A[p>>2]|0,y=+ee[15920+(B*24|0)>>3],y=+$c(y-+$c(+Cx(15600+(B<<4)|0,d))),bs(f)|0?M=+$c(y+-.3334731722518321):M=y,y=+Er(+w)*2.618033988749896,(f|0)>0){d=0;do y=y*2.6457513110645907,d=d+1|0;while((d|0)!=(f|0))}w=+an(+M)*y,ee[_>>3]=w,M=+mn(+M)*y,ee[_+8>>3]=M,K=R}function bx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(w=K,K=K+32|0,y=w,ju(d,y),A[f>>2]=0,ee[p>>3]=5,_=+tr(16400,y),_<+ee[p>>3]&&(A[f>>2]=0,ee[p>>3]=_),_=+tr(16424,y),_<+ee[p>>3]&&(A[f>>2]=1,ee[p>>3]=_),_=+tr(16448,y),_<+ee[p>>3]&&(A[f>>2]=2,ee[p>>3]=_),_=+tr(16472,y),_<+ee[p>>3]&&(A[f>>2]=3,ee[p>>3]=_),_=+tr(16496,y),_<+ee[p>>3]&&(A[f>>2]=4,ee[p>>3]=_),_=+tr(16520,y),_<+ee[p>>3]&&(A[f>>2]=5,ee[p>>3]=_),_=+tr(16544,y),_<+ee[p>>3]&&(A[f>>2]=6,ee[p>>3]=_),_=+tr(16568,y),_<+ee[p>>3]&&(A[f>>2]=7,ee[p>>3]=_),_=+tr(16592,y),_<+ee[p>>3]&&(A[f>>2]=8,ee[p>>3]=_),_=+tr(16616,y),_<+ee[p>>3]&&(A[f>>2]=9,ee[p>>3]=_),_=+tr(16640,y),_<+ee[p>>3]&&(A[f>>2]=10,ee[p>>3]=_),_=+tr(16664,y),_<+ee[p>>3]&&(A[f>>2]=11,ee[p>>3]=_),_=+tr(16688,y),_<+ee[p>>3]&&(A[f>>2]=12,ee[p>>3]=_),_=+tr(16712,y),_<+ee[p>>3]&&(A[f>>2]=13,ee[p>>3]=_),_=+tr(16736,y),_<+ee[p>>3]&&(A[f>>2]=14,ee[p>>3]=_),_=+tr(16760,y),_<+ee[p>>3]&&(A[f>>2]=15,ee[p>>3]=_),_=+tr(16784,y),_<+ee[p>>3]&&(A[f>>2]=16,ee[p>>3]=_),_=+tr(16808,y),_<+ee[p>>3]&&(A[f>>2]=17,ee[p>>3]=_),_=+tr(16832,y),_<+ee[p>>3]&&(A[f>>2]=18,ee[p>>3]=_),_=+tr(16856,y),!(_<+ee[p>>3])){K=w;return}A[f>>2]=19,ee[p>>3]=_,K=w}function Ru(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0;if(w=+Bl(d),w<1e-16){f=15600+(f<<4)|0,A[y>>2]=A[f>>2],A[y+4>>2]=A[f+4>>2],A[y+8>>2]=A[f+8>>2],A[y+12>>2]=A[f+12>>2];return}if(M=+Ge(+ +ee[d+8>>3],+ +ee[d>>3]),(p|0)>0){d=0;do w=w*.37796447300922725,d=d+1|0;while((d|0)!=(p|0))}R=w*.3333333333333333,_?(p=(bs(p)|0)==0,w=+ce(+((p?R:R*.37796447300922725)*.381966011250105))):(w=+ce(+(w*.381966011250105)),bs(p)|0&&(M=+$c(M+.3334731722518321))),Nx(15600+(f<<4)|0,+$c(+ee[15920+(f*24|0)>>3]-M),w,y)}function tf(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;_=K,K=K+16|0,y=_,Mu(d+4|0,y),Ru(y,A[d>>2]|0,f,0,p),K=_}function np(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0,xn=0,si=0,Cn=0;if(xn=K,K=K+272|0,w=xn+256|0,Xe=xn+240|0,En=xn,fn=xn+224|0,kt=xn+208|0,je=xn+176|0,Le=xn+160|0,Ft=xn+192|0,un=xn+144|0,on=xn+128|0,kn=xn+112|0,Dn=xn+96|0,Zn=xn+80|0,A[w>>2]=f,A[Xe>>2]=A[d>>2],A[Xe+4>>2]=A[d+4>>2],A[Xe+8>>2]=A[d+8>>2],A[Xe+12>>2]=A[d+12>>2],ip(Xe,w,En),A[y>>2]=0,Xe=_+p+((_|0)==5&1)|0,(Xe|0)<=(p|0)){K=xn;return}B=A[w>>2]|0,F=fn+4|0,W=je+4|0,se=p+5|0,_e=16880+(B<<2)|0,ve=16960+(B<<2)|0,ye=on+8|0,Pe=kn+8|0,ze=Dn+8|0,nt=kt+4|0,R=p;e:for(;;){M=En+(((R|0)%5|0)<<4)|0,A[kt>>2]=A[M>>2],A[kt+4>>2]=A[M+4>>2],A[kt+8>>2]=A[M+8>>2],A[kt+12>>2]=A[M+12>>2];do;while((Du(kt,B,0,1)|0)==2);if((R|0)>(p|0)&(bs(f)|0)!=0){if(A[je>>2]=A[kt>>2],A[je+4>>2]=A[kt+4>>2],A[je+8>>2]=A[kt+8>>2],A[je+12>>2]=A[kt+12>>2],Mu(F,Le),_=A[je>>2]|0,w=A[17040+(_*80|0)+(A[fn>>2]<<2)>>2]|0,A[je>>2]=A[18640+(_*80|0)+(w*20|0)>>2],M=A[18640+(_*80|0)+(w*20|0)+16>>2]|0,(M|0)>0){d=0;do u1(W),d=d+1|0;while((d|0)<(M|0))}switch(M=18640+(_*80|0)+(w*20|0)+4|0,A[Ft>>2]=A[M>>2],A[Ft+4>>2]=A[M+4>>2],A[Ft+8>>2]=A[M+8>>2],jc(Ft,(A[_e>>2]|0)*3|0),us(W,Ft,W),Pr(W),Mu(W,un),si=+(A[ve>>2]|0),ee[on>>3]=si*3,ee[ye>>3]=0,Cn=si*-1.5,ee[kn>>3]=Cn,ee[Pe>>3]=si*2.598076211353316,ee[Dn>>3]=Cn,ee[ze>>3]=si*-2.598076211353316,A[17040+((A[je>>2]|0)*80|0)+(A[kt>>2]<<2)>>2]|0){case 1:{d=kn,_=on;break}case 3:{d=Dn,_=kn;break}case 2:{d=on,_=Dn;break}default:{d=12;break e}}vp(Le,un,_,d,Zn),Ru(Zn,A[je>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1}if((R|0)<(se|0)&&(Mu(nt,je),Ru(je,A[kt>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1),A[fn>>2]=A[kt>>2],A[fn+4>>2]=A[kt+4>>2],A[fn+8>>2]=A[kt+8>>2],A[fn+12>>2]=A[kt+12>>2],R=R+1|0,(R|0)>=(Xe|0)){d=3;break}}if((d|0)==3){K=xn;return}else(d|0)==12&&tt(26970,27017,572,27027)}function ip(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;B=K,K=K+128|0,_=B+64|0,y=B,w=_,M=20240,R=w+60|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));w=y,M=20304,R=w+60|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));R=(bs(A[f>>2]|0)|0)==0,_=R?_:y,y=d+4|0,c1(y),h1(y),bs(A[f>>2]|0)|0&&(Cu(y),A[f>>2]=(A[f>>2]|0)+1),A[p>>2]=A[d>>2],f=p+4|0,us(y,_,f),Pr(f),A[p+16>>2]=A[d>>2],f=p+20|0,us(y,_+12|0,f),Pr(f),A[p+32>>2]=A[d>>2],f=p+36|0,us(y,_+24|0,f),Pr(f),A[p+48>>2]=A[d>>2],f=p+52|0,us(y,_+36|0,f),Pr(f),A[p+64>>2]=A[d>>2],p=p+68|0,us(y,_+48|0,p),Pr(p),K=B}function Du(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0;if(ye=K,K=K+32|0,_e=ye+12|0,R=ye,ve=d+4|0,se=A[16960+(f<<2)>>2]|0,W=(_|0)!=0,se=W?se*3|0:se,y=A[ve>>2]|0,F=d+8|0,M=A[F>>2]|0,W){if(w=d+12|0,_=A[w>>2]|0,y=M+y+_|0,(y|0)==(se|0))return ve=1,K=ye,ve|0;B=w}else B=d+12|0,_=A[B>>2]|0,y=M+y+_|0;if((y|0)<=(se|0))return ve=0,K=ye,ve|0;do if((_|0)>0){if(_=A[d>>2]|0,(M|0)>0){w=18640+(_*80|0)+60|0,_=d;break}_=18640+(_*80|0)+40|0,p?(Tu(_e,se,0,0),ef(ve,_e,R),bd(R),us(R,_e,ve),w=_,_=d):(w=_,_=d)}else w=18640+((A[d>>2]|0)*80|0)+20|0,_=d;while(!1);if(A[_>>2]=A[w>>2],y=w+16|0,(A[y>>2]|0)>0){_=0;do u1(ve),_=_+1|0;while((_|0)<(A[y>>2]|0))}return d=w+4|0,A[_e>>2]=A[d>>2],A[_e+4>>2]=A[d+4>>2],A[_e+8>>2]=A[d+8>>2],f=A[16880+(f<<2)>>2]|0,jc(_e,W?f*3|0:f),us(ve,_e,ve),Pr(ve),W?_=((A[F>>2]|0)+(A[ve>>2]|0)+(A[B>>2]|0)|0)==(se|0)?1:2:_=2,ve=_,K=ye,ve|0}function p1(d,f){d=d|0,f=f|0;var p=0;do p=Du(d,f,0,1)|0;while((p|0)==2);return p|0}function wd(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0;if(Dn=K,K=K+240|0,w=Dn+224|0,Ft=Dn+208|0,un=Dn,on=Dn+192|0,kn=Dn+176|0,ze=Dn+160|0,nt=Dn+144|0,Xe=Dn+128|0,je=Dn+112|0,Le=Dn+96|0,A[w>>2]=f,A[Ft>>2]=A[d>>2],A[Ft+4>>2]=A[d+4>>2],A[Ft+8>>2]=A[d+8>>2],A[Ft+12>>2]=A[d+12>>2],rp(Ft,w,un),A[y>>2]=0,Pe=_+p+((_|0)==6&1)|0,(Pe|0)<=(p|0)){K=Dn;return}B=A[w>>2]|0,F=p+6|0,W=16960+(B<<2)|0,se=nt+8|0,_e=Xe+8|0,ve=je+8|0,ye=on+4|0,M=0,R=p,_=-1;e:for(;;){if(w=(R|0)%6|0,d=un+(w<<4)|0,A[on>>2]=A[d>>2],A[on+4>>2]=A[d+4>>2],A[on+8>>2]=A[d+8>>2],A[on+12>>2]=A[d+12>>2],d=M,M=Du(on,B,0,1)|0,(R|0)>(p|0)&(bs(f)|0)!=0&&(d|0)!=1&&(A[on>>2]|0)!=(_|0)){switch(Mu(un+(((w+5|0)%6|0)<<4)+4|0,kn),Mu(un+(w<<4)+4|0,ze),Zn=+(A[W>>2]|0),ee[nt>>3]=Zn*3,ee[se>>3]=0,En=Zn*-1.5,ee[Xe>>3]=En,ee[_e>>3]=Zn*2.598076211353316,ee[je>>3]=En,ee[ve>>3]=Zn*-2.598076211353316,w=A[Ft>>2]|0,A[17040+(w*80|0)+(((_|0)==(w|0)?A[on>>2]|0:_)<<2)>>2]|0){case 1:{d=Xe,_=nt;break}case 3:{d=je,_=Xe;break}case 2:{d=nt,_=je;break}default:{d=8;break e}}vp(kn,ze,_,d,Le),!(_p(kn,Le)|0)&&!(_p(ze,Le)|0)&&(Ru(Le,A[Ft>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1)}if((R|0)<(F|0)&&(Mu(ye,kn),Ru(kn,A[on>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1),R=R+1|0,(R|0)>=(Pe|0)){d=3;break}else _=A[on>>2]|0}if((d|0)==3){K=Dn;return}else(d|0)==8&&tt(27054,27017,737,27099)}function rp(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;B=K,K=K+160|0,_=B+80|0,y=B,w=_,M=20368,R=w+72|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));w=y,M=20448,R=w+72|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));R=(bs(A[f>>2]|0)|0)==0,_=R?_:y,y=d+4|0,c1(y),h1(y),bs(A[f>>2]|0)|0&&(Cu(y),A[f>>2]=(A[f>>2]|0)+1),A[p>>2]=A[d>>2],f=p+4|0,us(y,_,f),Pr(f),A[p+16>>2]=A[d>>2],f=p+20|0,us(y,_+12|0,f),Pr(f),A[p+32>>2]=A[d>>2],f=p+36|0,us(y,_+24|0,f),Pr(f),A[p+48>>2]=A[d>>2],f=p+52|0,us(y,_+36|0,f),Pr(f),A[p+64>>2]=A[d>>2],f=p+68|0,us(y,_+48|0,f),Pr(f),A[p+80>>2]=A[d>>2],p=p+84|0,us(y,_+60|0,p),Pr(p),K=B}function Wc(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,52)|0,X()|0,f&15|0}function m1(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,45)|0,X()|0,f&127|0}function Sx(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,(p+-1|0)>>>0>14?(_=4,_|0):(p=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,A[_>>2]=p&7,_=0,_|0)}function wx(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;if(d>>>0>15)return _=4,_|0;if(f>>>0>121)return _=17,_|0;M=It(d|0,0,52)|0,y=X()|0,R=It(f|0,0,45)|0,y=y|(X()|0)|134225919;e:do if((d|0)>=1){for(R=1,M=(xt[20528+f>>0]|0)!=0,w=-1;;){if(f=A[p+(R+-1<<2)>>2]|0,f>>>0>6){y=18,f=10;break}if(!((f|0)==0|M^1))if((f|0)==1){y=19,f=10;break}else M=0;if(F=(15-R|0)*3|0,B=It(7,0,F|0)|0,y=y&~(X()|0),f=It(f|0,((f|0)<0)<<31>>31|0,F|0)|0,w=f|w&~B,y=X()|0|y,(R|0)<(d|0))R=R+1|0;else break e}if((f|0)==10)return y|0}else w=-1;while(!1);return F=_,A[F>>2]=w,A[F+4>>2]=y,F=0,F|0}function Td(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return!(!0&(f&-16777216|0)==134217728)||(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0,p=p&127,p>>>0>121)?(d=0,d|0):(M=(_^15)*3|0,y=Ct(d|0,f|0,M|0)|0,M=It(y|0,X()|0,M|0)|0,y=X()|0,w=Lr(-1227133514,-1171,M|0,y|0)|0,!((M&613566756&w|0)==0&(y&4681&(X()|0)|0)==0)||(M=(_*3|0)+19|0,w=It(~d|0,~f|0,M|0)|0,M=Ct(w|0,X()|0,M|0)|0,!((_|0)==15|(M|0)==0&(X()|0)==0))?(M=0,M|0):!(xt[20528+p>>0]|0)||(f=f&8191,(d|0)==0&(f|0)==0)?(M=1,M|0):(M=of(d|0,f|0)|0,X()|0,((63-M|0)%3|0|0)!=0|0))}function g1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return!0&(f&-16777216|0)==134217728&&(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0,p=p&127,p>>>0<=121)&&(M=(_^15)*3|0,y=Ct(d|0,f|0,M|0)|0,M=It(y|0,X()|0,M|0)|0,y=X()|0,w=Lr(-1227133514,-1171,M|0,y|0)|0,(M&613566756&w|0)==0&(y&4681&(X()|0)|0)==0)&&(M=(_*3|0)+19|0,w=It(~d|0,~f|0,M|0)|0,M=Ct(w|0,X()|0,M|0)|0,(_|0)==15|(M|0)==0&(X()|0)==0)&&(!(xt[20528+p>>0]|0)||(p=f&8191,(d|0)==0&(p|0)==0)||(M=of(d|0,p|0)|0,X()|0,(63-M|0)%3|0|0))||A1(d,f)|0?(M=1,M|0):(M=(al(d,f)|0)!=0&1,M|0)}function Pu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0;if(y=It(f|0,0,52)|0,w=X()|0,p=It(p|0,0,45)|0,p=w|(X()|0)|134225919,(f|0)<1){w=-1,_=p,f=d,A[f>>2]=w,d=d+4|0,A[d>>2]=_;return}for(w=1,y=-1;M=(15-w|0)*3|0,R=It(7,0,M|0)|0,p=p&~(X()|0),M=It(_|0,0,M|0)|0,y=y&~R|M,p=p|(X()|0),(w|0)!=(f|0);)w=w+1|0;R=d,M=R,A[M>>2]=y,R=R+4|0,A[R>>2]=p}function Lu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;if(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,p>>>0>15)return _=4,_|0;if((w|0)<(p|0))return _=12,_|0;if((w|0)==(p|0))return A[_>>2]=d,A[_+4>>2]=f,_=0,_|0;if(y=It(p|0,0,52)|0,y=y|d,d=X()|0|f&-15728641,(w|0)>(p|0))do f=It(7,0,(14-p|0)*3|0)|0,p=p+1|0,y=f|y,d=X()|0|d;while((p|0)<(w|0));return A[_>>2]=y,A[_+4>>2]=d,_=0,_|0}function nf(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,!((p|0)<16&(w|0)<=(p|0)))return _=4,_|0;y=p-w|0,p=Ct(d|0,f|0,45)|0,X()|0;e:do if(!(Ji(p&127)|0))p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,y=X()|0;else{t:do if(w|0){for(p=1;M=It(7,0,(15-p|0)*3|0)|0,!!((M&d|0)==0&((X()|0)&f|0)==0);)if(p>>>0>>0)p=p+1|0;else break t;p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,y=X()|0;break e}while(!1);p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,p=ur(p|0,X()|0,5,0)|0,p=tn(p|0,X()|0,-5,-1)|0,p=Io(p|0,X()|0,6,0)|0,p=tn(p|0,X()|0,1,0)|0,y=X()|0}while(!1);return M=_,A[M>>2]=p,A[M+4>>2]=y,M=0,M|0}function wi(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;if(y=Ct(d|0,f|0,45)|0,X()|0,!(Ji(y&127)|0))return y=0,y|0;y=Ct(d|0,f|0,52)|0,X()|0,y=y&15;e:do if(!y)p=0;else for(_=1;;){if(p=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,p=p&7,p|0)break e;if(_>>>0>>0)_=_+1|0;else{p=0;break}}while(!1);return y=(p|0)==0&1,y|0}function v1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0;if(M=K,K=K+16|0,w=M,nl(w,d,f,p),f=w,d=A[f>>2]|0,f=A[f+4>>2]|0,(d|0)==0&(f|0)==0)return K=M,0;y=0,p=0;do R=_+(y<<3)|0,A[R>>2]=d,A[R+4>>2]=f,y=tn(y|0,p|0,1,0)|0,p=X()|0,rf(w),R=w,d=A[R>>2]|0,f=A[R+4>>2]|0;while(!((d|0)==0&(f|0)==0));return K=M,0}function sp(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,(_|0)<(p|0)?(p=f,_=d,he(p|0),_|0):(p=It(-1,-1,((_-p|0)*3|0)+3|0)|0,_=It(~p|0,~(X()|0)|0,(15-_|0)*3|0)|0,p=~(X()|0)&f,_=~_&d,he(p|0),_|0)}function Md(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0;return y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,(p|0)<16&(y|0)<=(p|0)?((y|0)<(p|0)&&(y=It(-1,-1,((p+-1-y|0)*3|0)+3|0)|0,y=It(~y|0,~(X()|0)|0,(15-p|0)*3|0)|0,f=~(X()|0)&f,d=~y&d),y=It(p|0,0,52)|0,p=f&-15728641|(X()|0),A[_>>2]=d|y,A[_+4>>2]=p,_=0,_|0):(_=4,_|0)}function ap(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0;if((p|0)==0&(_|0)==0)return kt=0,kt|0;if(y=d,w=A[y>>2]|0,y=A[y+4>>2]|0,!0&(y&15728640|0)==0){if(!((_|0)>0|(_|0)==0&p>>>0>0)||(kt=f,A[kt>>2]=w,A[kt+4>>2]=y,(p|0)==1&(_|0)==0))return kt=0,kt|0;y=1,w=0;do En=d+(y<<3)|0,fn=A[En+4>>2]|0,kt=f+(y<<3)|0,A[kt>>2]=A[En>>2],A[kt+4>>2]=fn,y=tn(y|0,w|0,1,0)|0,w=X()|0;while((w|0)<(_|0)|(w|0)==(_|0)&y>>>0

>>0);return y=0,y|0}if(Zn=p<<3,fn=Oo(Zn)|0,!fn)return kt=13,kt|0;if(Ol(fn|0,d|0,Zn|0)|0,En=Ys(p,8)|0,!En)return vn(fn),kt=13,kt|0;e:for(;;){y=fn,F=A[y>>2]|0,y=A[y+4>>2]|0,kn=Ct(F|0,y|0,52)|0,X()|0,kn=kn&15,Dn=kn+-1|0,on=(kn|0)!=0,un=(_|0)>0|(_|0)==0&p>>>0>0;t:do if(on&un){if(Xe=It(Dn|0,0,52)|0,je=X()|0,Dn>>>0>15){if(!((F|0)==0&(y|0)==0)){kt=16;break e}for(w=0,d=0;;){if(w=tn(w|0,d|0,1,0)|0,d=X()|0,!((d|0)<(_|0)|(d|0)==(_|0)&w>>>0

>>0))break t;if(M=fn+(w<<3)|0,Ft=A[M>>2]|0,M=A[M+4>>2]|0,!((Ft|0)==0&(M|0)==0)){y=M,kt=16;break e}}}for(R=F,d=y,w=0,M=0;;){if(!((R|0)==0&(d|0)==0)){if(!(!0&(d&117440512|0)==0)){kt=21;break e}if(W=Ct(R|0,d|0,52)|0,X()|0,W=W&15,(W|0)<(Dn|0)){y=12,kt=27;break e}if((W|0)!=(Dn|0)&&(R=R|Xe,d=d&-15728641|je,W>>>0>=kn>>>0)){B=Dn;do Ft=It(7,0,(14-B|0)*3|0)|0,B=B+1|0,R=Ft|R,d=X()|0|d;while(B>>>0>>0)}if(_e=Yu(R|0,d|0,p|0,_|0)|0,ve=X()|0,B=En+(_e<<3)|0,W=B,se=A[W>>2]|0,W=A[W+4>>2]|0,!((se|0)==0&(W|0)==0)){ze=0,nt=0;do{if((ze|0)>(_|0)|(ze|0)==(_|0)&nt>>>0>p>>>0){kt=31;break e}if((se|0)==(R|0)&(W&-117440513|0)==(d|0)){ye=Ct(se|0,W|0,56)|0,X()|0,ye=ye&7,Pe=ye+1|0,Ft=Ct(se|0,W|0,45)|0,X()|0;n:do if(!(Ji(Ft&127)|0))W=7;else{if(se=Ct(se|0,W|0,52)|0,X()|0,se=se&15,!se){W=6;break}for(W=1;;){if(Ft=It(7,0,(15-W|0)*3|0)|0,!((Ft&R|0)==0&((X()|0)&d|0)==0)){W=7;break n}if(W>>>0>>0)W=W+1|0;else{W=6;break}}}while(!1);if((ye+2|0)>>>0>W>>>0){kt=41;break e}Ft=It(Pe|0,0,56)|0,d=X()|0|d&-117440513,Le=B,A[Le>>2]=0,A[Le+4>>2]=0,R=Ft|R}else _e=tn(_e|0,ve|0,1,0)|0,_e=Kc(_e|0,X()|0,p|0,_|0)|0,ve=X()|0;nt=tn(nt|0,ze|0,1,0)|0,ze=X()|0,B=En+(_e<<3)|0,W=B,se=A[W>>2]|0,W=A[W+4>>2]|0}while(!((se|0)==0&(W|0)==0))}Ft=B,A[Ft>>2]=R,A[Ft+4>>2]=d}if(w=tn(w|0,M|0,1,0)|0,M=X()|0,!((M|0)<(_|0)|(M|0)==(_|0)&w>>>0

>>0))break t;d=fn+(w<<3)|0,R=A[d>>2]|0,d=A[d+4>>2]|0}}while(!1);if(Ft=tn(p|0,_|0,5,0)|0,Le=X()|0,Le>>>0<0|(Le|0)==0&Ft>>>0<11){kt=85;break}if(Ft=Io(p|0,_|0,6,0)|0,X()|0,Ft=Ys(Ft,8)|0,!Ft){kt=48;break}do if(un){for(Pe=0,d=0,ye=0,ze=0;;){if(W=En+(Pe<<3)|0,M=W,w=A[M>>2]|0,M=A[M+4>>2]|0,(w|0)==0&(M|0)==0)Le=ye;else{se=Ct(w|0,M|0,56)|0,X()|0,se=se&7,R=se+1|0,_e=M&-117440513,Le=Ct(w|0,M|0,45)|0,X()|0;t:do if(Ji(Le&127)|0){if(ve=Ct(w|0,M|0,52)|0,X()|0,ve=ve&15,ve|0)for(B=1;;){if(Le=It(7,0,(15-B|0)*3|0)|0,!((w&Le|0)==0&(_e&(X()|0)|0)==0))break t;if(B>>>0>>0)B=B+1|0;else break}M=It(R|0,0,56)|0,w=M|w,M=X()|0|_e,R=W,A[R>>2]=w,A[R+4>>2]=M,R=se+2|0}while(!1);(R|0)==7?(Le=Ft+(d<<3)|0,A[Le>>2]=w,A[Le+4>>2]=M&-117440513,d=tn(d|0,ye|0,1,0)|0,Le=X()|0):Le=ye}if(Pe=tn(Pe|0,ze|0,1,0)|0,ze=X()|0,(ze|0)<(_|0)|(ze|0)==(_|0)&Pe>>>0

>>0)ye=Le;else break}if(un){if(nt=Dn>>>0>15,Xe=It(Dn|0,0,52)|0,je=X()|0,!on){for(w=0,B=0,R=0,M=0;(F|0)==0&(y|0)==0||(Dn=f+(w<<3)|0,A[Dn>>2]=F,A[Dn+4>>2]=y,w=tn(w|0,B|0,1,0)|0,B=X()|0),R=tn(R|0,M|0,1,0)|0,M=X()|0,!!((M|0)<(_|0)|(M|0)==(_|0)&R>>>0

>>0);)y=fn+(R<<3)|0,F=A[y>>2]|0,y=A[y+4>>2]|0;y=Le;break}for(w=0,B=0,M=0,R=0;;){do if(!((F|0)==0&(y|0)==0)){if(ve=Ct(F|0,y|0,52)|0,X()|0,ve=ve&15,nt|(ve|0)<(Dn|0)){kt=80;break e}if((ve|0)!=(Dn|0)){if(W=F|Xe,se=y&-15728641|je,ve>>>0>=kn>>>0){_e=Dn;do on=It(7,0,(14-_e|0)*3|0)|0,_e=_e+1|0,W=on|W,se=X()|0|se;while(_e>>>0>>0)}}else W=F,se=y;ye=Yu(W|0,se|0,p|0,_|0)|0,_e=0,ve=0,ze=X()|0;do{if((_e|0)>(_|0)|(_e|0)==(_|0)&ve>>>0>p>>>0){kt=81;break e}if(on=En+(ye<<3)|0,Pe=A[on+4>>2]|0,(Pe&-117440513|0)==(se|0)&&(A[on>>2]|0)==(W|0)){kt=65;break}on=tn(ye|0,ze|0,1,0)|0,ye=Kc(on|0,X()|0,p|0,_|0)|0,ze=X()|0,ve=tn(ve|0,_e|0,1,0)|0,_e=X()|0,on=En+(ye<<3)|0}while(!((A[on>>2]|0)==(W|0)&&(A[on+4>>2]|0)==(se|0)));if((kt|0)==65&&(kt=0,!0&(Pe&117440512|0)==100663296))break;on=f+(w<<3)|0,A[on>>2]=F,A[on+4>>2]=y,w=tn(w|0,B|0,1,0)|0,B=X()|0}while(!1);if(M=tn(M|0,R|0,1,0)|0,R=X()|0,!((R|0)<(_|0)|(R|0)==(_|0)&M>>>0

>>0))break;y=fn+(M<<3)|0,F=A[y>>2]|0,y=A[y+4>>2]|0}y=Le}else w=0,y=Le}else w=0,d=0,y=0;while(!1);if(ao(En|0,0,Zn|0)|0,Ol(fn|0,Ft|0,d<<3|0)|0,vn(Ft),(d|0)==0&(y|0)==0){kt=89;break}else f=f+(w<<3)|0,_=y,p=d}if((kt|0)==16)!0&(y&117440512|0)==0?(y=4,kt=27):kt=21;else if((kt|0)==31)tt(27795,27122,620,27132);else{if((kt|0)==41)return vn(fn),vn(En),kt=10,kt|0;if((kt|0)==48)return vn(fn),vn(En),kt=13,kt|0;(kt|0)==80?tt(27795,27122,711,27132):(kt|0)==81?tt(27795,27122,723,27132):(kt|0)==85&&(Ol(f|0,fn|0,p<<3|0)|0,kt=89)}return(kt|0)==21?(vn(fn),vn(En),kt=5,kt|0):(kt|0)==27?(vn(fn),vn(En),kt=y,kt|0):(kt|0)==89?(vn(fn),vn(En),kt=0,kt|0):0}function _1(d,f,p,_,y,w,M){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0;var R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0;if(Pe=K,K=K+16|0,ye=Pe,!((p|0)>0|(p|0)==0&f>>>0>0))return ye=0,K=Pe,ye|0;if((M|0)>=16)return ye=12,K=Pe,ye|0;_e=0,ve=0,se=0,R=0;e:for(;;){if(F=d+(_e<<3)|0,B=A[F>>2]|0,F=A[F+4>>2]|0,W=Ct(B|0,F|0,52)|0,X()|0,(W&15|0)>(M|0)){R=12,B=11;break}if(nl(ye,B,F,M),W=ye,F=A[W>>2]|0,W=A[W+4>>2]|0,(F|0)==0&(W|0)==0)B=se;else{B=se;do{if(!((R|0)<(w|0)|(R|0)==(w|0)&B>>>0>>0)){B=10;break e}se=_+(B<<3)|0,A[se>>2]=F,A[se+4>>2]=W,B=tn(B|0,R|0,1,0)|0,R=X()|0,rf(ye),se=ye,F=A[se>>2]|0,W=A[se+4>>2]|0}while(!((F|0)==0&(W|0)==0))}if(_e=tn(_e|0,ve|0,1,0)|0,ve=X()|0,(ve|0)<(p|0)|(ve|0)==(p|0)&_e>>>0>>0)se=B;else{R=0,B=11;break}}return(B|0)==10?(ye=14,K=Pe,ye|0):(B|0)==11?(K=Pe,R|0):0}function y1(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;_e=K,K=K+16|0,se=_e;e:do if((p|0)>0|(p|0)==0&f>>>0>0){for(F=0,M=0,w=0,W=0;;){if(B=d+(F<<3)|0,R=A[B>>2]|0,B=A[B+4>>2]|0,!((R|0)==0&(B|0)==0)&&(B=(nf(R,B,_,se)|0)==0,R=se,M=tn(A[R>>2]|0,A[R+4>>2]|0,M|0,w|0)|0,w=X()|0,!B)){w=12;break}if(F=tn(F|0,W|0,1,0)|0,W=X()|0,!((W|0)<(p|0)|(W|0)==(p|0)&F>>>0>>0))break e}return K=_e,w|0}else M=0,w=0;while(!1);return A[y>>2]=M,A[y+4>>2]=w,y=0,K=_e,y|0}function x1(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,52)|0,X()|0,f&1|0}function Hs(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,!y)return y=0,y|0;for(_=1;;){if(p=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,p=p&7,p|0){_=5;break}if(_>>>0>>0)_=_+1|0;else{p=0,_=5;break}}return(_|0)==5?p|0:0}function op(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(B=Ct(d|0,f|0,52)|0,X()|0,B=B&15,!B)return R=f,B=d,he(R|0),B|0;for(R=1,p=0;;){w=(15-R|0)*3|0,_=It(7,0,w|0)|0,y=X()|0,M=Ct(d|0,f|0,w|0)|0,X()|0,w=It(Nu(M&7)|0,0,w|0)|0,M=X()|0,d=w|d&~_,f=M|f&~y;e:do if(!p)if((w&_|0)==0&(M&y|0)==0)p=0;else if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(M=(15-p|0)*3|0,y=Ct(d|0,f|0,M|0)|0,X()|0,w=It(7,0,M|0)|0,f=f&~(X()|0),M=It(Nu(y&7)|0,0,M|0)|0,d=d&~w|M,f=f|(X()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return he(f|0),d|0}function Uu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)return p=f,_=d,he(p|0),_|0;for(p=1;w=(15-p|0)*3|0,M=Ct(d|0,f|0,w|0)|0,X()|0,y=It(7,0,w|0)|0,f=f&~(X()|0),w=It(Nu(M&7)|0,0,w|0)|0,d=w|d&~y,f=X()|0|f,p>>>0<_>>>0;)p=p+1|0;return he(f|0),d|0}function Tx(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(B=Ct(d|0,f|0,52)|0,X()|0,B=B&15,!B)return R=f,B=d,he(R|0),B|0;for(R=1,p=0;;){w=(15-R|0)*3|0,_=It(7,0,w|0)|0,y=X()|0,M=Ct(d|0,f|0,w|0)|0,X()|0,w=It(tl(M&7)|0,0,w|0)|0,M=X()|0,d=w|d&~_,f=M|f&~y;e:do if(!p)if((w&_|0)==0&(M&y|0)==0)p=0;else if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(y=(15-p|0)*3|0,w=It(7,0,y|0)|0,M=f&~(X()|0),f=Ct(d|0,f|0,y|0)|0,X()|0,f=It(tl(f&7)|0,0,y|0)|0,d=d&~w|f,f=M|(X()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return he(f|0),d|0}function lp(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)return p=f,_=d,he(p|0),_|0;for(p=1;M=(15-p|0)*3|0,w=It(7,0,M|0)|0,y=f&~(X()|0),f=Ct(d|0,f|0,M|0)|0,X()|0,f=It(tl(f&7)|0,0,M|0)|0,d=f|d&~w,f=X()|0|y,p>>>0<_>>>0;)p=p+1|0;return he(f|0),d|0}function ha(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(B=K,K=K+64|0,R=B+40|0,_=B+24|0,y=B+12|0,w=B,It(f|0,0,52)|0,p=X()|0|134225919,!f)return(A[d+4>>2]|0)>2||(A[d+8>>2]|0)>2||(A[d+12>>2]|0)>2?(M=0,R=0,he(M|0),K=B,R|0):(It(Ro(d)|0,0,45)|0,M=X()|0|p,R=-1,he(M|0),K=B,R|0);if(A[R>>2]=A[d>>2],A[R+4>>2]=A[d+4>>2],A[R+8>>2]=A[d+8>>2],A[R+12>>2]=A[d+12>>2],M=R+4|0,(f|0)>0)for(d=-1;A[_>>2]=A[M>>2],A[_+4>>2]=A[M+4>>2],A[_+8>>2]=A[M+8>>2],f&1?(fx(M),A[y>>2]=A[M>>2],A[y+4>>2]=A[M+4>>2],A[y+8>>2]=A[M+8>>2],Hc(y)):(o1(M),A[y>>2]=A[M>>2],A[y+4>>2]=A[M+4>>2],A[y+8>>2]=A[M+8>>2],Cu(y)),ef(_,y,w),Pr(w),W=(15-f|0)*3|0,F=It(7,0,W|0)|0,p=p&~(X()|0),W=It(Eu(w)|0,0,W|0)|0,d=W|d&~F,p=X()|0|p,(f|0)>1;)f=f+-1|0;else d=-1;e:do if((A[M>>2]|0)<=2&&(A[R+8>>2]|0)<=2&&(A[R+12>>2]|0)<=2){if(_=Ro(R)|0,f=It(_|0,0,45)|0,f=f|d,d=X()|0|p&-1040385,w=K0(R)|0,!(Ji(_)|0)){if((w|0)<=0)break;for(y=0;;){if(_=Ct(f|0,d|0,52)|0,X()|0,_=_&15,_)for(p=1;W=(15-p|0)*3|0,R=Ct(f|0,d|0,W|0)|0,X()|0,F=It(7,0,W|0)|0,d=d&~(X()|0),W=It(Nu(R&7)|0,0,W|0)|0,f=f&~F|W,d=d|(X()|0),p>>>0<_>>>0;)p=p+1|0;if(y=y+1|0,(y|0)==(w|0))break e}}y=Ct(f|0,d|0,52)|0,X()|0,y=y&15;t:do if(y){p=1;n:for(;;){switch(W=Ct(f|0,d|0,(15-p|0)*3|0)|0,X()|0,W&7){case 1:break n;case 0:break;default:break t}if(p>>>0>>0)p=p+1|0;else break t}if(wu(_,A[R>>2]|0)|0)for(p=1;R=(15-p|0)*3|0,F=It(7,0,R|0)|0,W=d&~(X()|0),d=Ct(f|0,d|0,R|0)|0,X()|0,d=It(tl(d&7)|0,0,R|0)|0,f=f&~F|d,d=W|(X()|0),p>>>0>>0;)p=p+1|0;else for(p=1;W=(15-p|0)*3|0,R=Ct(f|0,d|0,W|0)|0,X()|0,F=It(7,0,W|0)|0,d=d&~(X()|0),W=It(Nu(R&7)|0,0,W|0)|0,f=f&~F|W,d=d|(X()|0),p>>>0>>0;)p=p+1|0}while(!1);if((w|0)>0){p=0;do f=op(f,d)|0,d=X()|0,p=p+1|0;while((p|0)!=(w|0))}}else f=0,d=0;while(!1);return F=d,W=f,he(F|0),K=B,W|0}function bs(d){return d=d|0,(d|0)%2|0|0}function Ed(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;return y=K,K=K+16|0,_=y,f>>>0>15?(_=4,K=y,_|0):(A[d+4>>2]&2146435072|0)==2146435072||(A[d+8+4>>2]&2146435072|0)==2146435072?(_=3,K=y,_|0):(yx(d,f,_),f=ha(_,f)|0,_=X()|0,A[p>>2]=f,A[p+4>>2]=_,(f|0)==0&(_|0)==0&&tt(27795,27122,1050,27145),_=0,K=y,_|0)}function Cd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(y=p+4|0,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,M=Ct(d|0,f|0,45)|0,X()|0,_=(w|0)==0,Ji(M&127)|0){if(_)return M=1,M|0;_=1}else{if(_)return M=0,M|0;(A[y>>2]|0)==0&&(A[p+8>>2]|0)==0?_=(A[p+12>>2]|0)!=0&1:_=1}for(p=1;p&1?Hc(y):Cu(y),M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,l1(y,M&7),p>>>0>>0;)p=p+1|0;return _|0}function Bu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+16|0,B=W,F=Ct(d|0,f|0,45)|0,X()|0,F=F&127,F>>>0>121)return A[p>>2]=0,A[p+4>>2]=0,A[p+8>>2]=0,A[p+12>>2]=0,F=5,K=W,F|0;e:do if((Ji(F)|0)!=0&&(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,(w|0)!=0)){_=1;t:for(;;){switch(R=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,R&7){case 5:break t;case 0:break;default:{_=f;break e}}if(_>>>0>>0)_=_+1|0;else{_=f;break e}}for(y=1,_=f;f=(15-y|0)*3|0,M=It(7,0,f|0)|0,R=_&~(X()|0),_=Ct(d|0,_|0,f|0)|0,X()|0,_=It(tl(_&7)|0,0,f|0)|0,d=d&~M|_,_=R|(X()|0),y>>>0>>0;)y=y+1|0}else _=f;while(!1);if(R=7696+(F*28|0)|0,A[p>>2]=A[R>>2],A[p+4>>2]=A[R+4>>2],A[p+8>>2]=A[R+8>>2],A[p+12>>2]=A[R+12>>2],!(Cd(d,_,p)|0))return F=0,K=W,F|0;if(M=p+4|0,A[B>>2]=A[M>>2],A[B+4>>2]=A[M+4>>2],A[B+8>>2]=A[M+8>>2],w=Ct(d|0,_|0,52)|0,X()|0,R=w&15,w&1?(Cu(M),w=R+1|0):w=R,!(Ji(F)|0))_=0;else{e:do if(!R)_=0;else for(f=1;;){if(y=Ct(d|0,_|0,(15-f|0)*3|0)|0,X()|0,y=y&7,y|0){_=y;break e}if(f>>>0>>0)f=f+1|0;else{_=0;break}}while(!1);_=(_|0)==4&1}if(!(Du(p,w,_,0)|0))(w|0)!=(R|0)&&(A[M>>2]=A[B>>2],A[M+4>>2]=A[B+4>>2],A[M+8>>2]=A[B+8>>2]);else{if(Ji(F)|0)do;while((Du(p,w,0,0)|0)!=0);(w|0)!=(R|0)&&o1(M)}return F=0,K=W,F|0}function Dl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return w=K,K=K+16|0,_=w,y=Bu(d,f,_)|0,y|0?(K=w,y|0):(y=Ct(d|0,f|0,52)|0,X()|0,tf(_,y&15,p),y=0,K=w,y|0)}function Pl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0;if(M=K,K=K+16|0,w=M,_=Bu(d,f,w)|0,_|0)return w=_,K=M,w|0;_=Ct(d|0,f|0,45)|0,X()|0,_=(Ji(_&127)|0)==0,y=Ct(d|0,f|0,52)|0,X()|0,y=y&15;e:do if(!_){if(y|0)for(_=1;;){if(R=It(7,0,(15-_|0)*3|0)|0,!((R&d|0)==0&((X()|0)&f|0)==0))break e;if(_>>>0>>0)_=_+1|0;else break}return np(w,y,0,5,p),R=0,K=M,R|0}while(!1);return wd(w,y,0,6,p),R=0,K=M,R|0}function Mx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(y=Ct(d|0,f|0,45)|0,X()|0,!(Ji(y&127)|0))return y=2,A[p>>2]=y,0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,!y)return y=5,A[p>>2]=y,0;for(_=1;;){if(w=It(7,0,(15-_|0)*3|0)|0,!((w&d|0)==0&((X()|0)&f|0)==0)){_=2,d=6;break}if(_>>>0>>0)_=_+1|0;else{_=5,d=6;break}}return(d|0)==6&&(A[p>>2]=_),0}function Ou(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0;se=K,K=K+128|0,F=se+112|0,w=se+96|0,W=se,y=Ct(d|0,f|0,52)|0,X()|0,R=y&15,A[F>>2]=R,M=Ct(d|0,f|0,45)|0,X()|0,M=M&127;e:do if(Ji(M)|0){if(R|0)for(_=1;;){if(B=It(7,0,(15-_|0)*3|0)|0,!((B&d|0)==0&((X()|0)&f|0)==0)){y=0;break e}if(_>>>0>>0)_=_+1|0;else break}if(y&1)y=1;else return B=It(R+1|0,0,52)|0,W=X()|0|f&-15728641,F=It(7,0,(14-R|0)*3|0)|0,W=Ou((B|d)&~F,W&~(X()|0),p)|0,K=se,W|0}else y=0;while(!1);if(_=Bu(d,f,w)|0,!_){y?(ip(w,F,W),B=5):(rp(w,F,W),B=6);e:do if(Ji(M)|0)if(!R)d=5;else for(_=1;;){if(M=It(7,0,(15-_|0)*3|0)|0,!((M&d|0)==0&((X()|0)&f|0)==0)){d=2;break e}if(_>>>0>>0)_=_+1|0;else{d=5;break}}else d=2;while(!1);ao(p|0,-1,d<<2|0)|0;e:do if(y)for(w=0;;){if(M=W+(w<<4)|0,p1(M,A[F>>2]|0)|0,M=A[M>>2]|0,R=A[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=d>>>0){_=1;break e}_=p+(y<<2)|0,R=A[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(A[_>>2]=M,w=w+1|0,w>>>0>=B>>>0){_=0;break}}else for(w=0;;){if(M=W+(w<<4)|0,Du(M,A[F>>2]|0,0,1)|0,M=A[M>>2]|0,R=A[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=d>>>0){_=1;break e}_=p+(y<<2)|0,R=A[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(A[_>>2]=M,w=w+1|0,w>>>0>=B>>>0){_=0;break}}while(!1)}return W=_,K=se,W|0}function up(){return 12}function Iu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(d>>>0>15)return R=4,R|0;if(It(d|0,0,52)|0,R=X()|0|134225919,!d){p=0,_=0;do Ji(_)|0&&(It(_|0,0,45)|0,M=R|(X()|0),d=f+(p<<3)|0,A[d>>2]=-1,A[d+4>>2]=M,p=p+1|0),_=_+1|0;while((_|0)!=122);return p=0,p|0}p=0,M=0;do{if(Ji(M)|0){for(It(M|0,0,45)|0,_=1,y=-1,w=R|(X()|0);B=It(7,0,(15-_|0)*3|0)|0,y=y&~B,w=w&~(X()|0),(_|0)!=(d|0);)_=_+1|0;B=f+(p<<3)|0,A[B>>2]=y,A[B+4>>2]=w,p=p+1|0}M=M+1|0}while((M|0)!=122);return p=0,p|0}function cp(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0;if(Xe=K,K=K+16|0,ze=Xe,nt=Ct(d|0,f|0,52)|0,X()|0,nt=nt&15,p>>>0>15)return nt=4,K=Xe,nt|0;if((nt|0)<(p|0))return nt=12,K=Xe,nt|0;if((nt|0)!=(p|0))if(w=It(p|0,0,52)|0,w=w|d,R=X()|0|f&-15728641,(nt|0)>(p|0)){B=p;do Pe=It(7,0,(14-B|0)*3|0)|0,B=B+1|0,w=Pe|w,R=X()|0|R;while((B|0)<(nt|0));Pe=w}else Pe=w;else Pe=d,R=f;ye=Ct(Pe|0,R|0,45)|0,X()|0;e:do if(Ji(ye&127)|0){if(B=Ct(Pe|0,R|0,52)|0,X()|0,B=B&15,B|0)for(w=1;;){if(ye=It(7,0,(15-w|0)*3|0)|0,!((ye&Pe|0)==0&((X()|0)&R|0)==0)){F=33;break e}if(w>>>0>>0)w=w+1|0;else break}if(ye=_,A[ye>>2]=0,A[ye+4>>2]=0,(nt|0)>(p|0)){for(ye=f&-15728641,ve=nt;;){if(_e=ve,ve=ve+-1|0,ve>>>0>15|(nt|0)<(ve|0)){F=19;break}if((nt|0)!=(ve|0))if(w=It(ve|0,0,52)|0,w=w|d,B=X()|0|ye,(nt|0)<(_e|0))se=w;else{F=ve;do se=It(7,0,(14-F|0)*3|0)|0,F=F+1|0,w=se|w,B=X()|0|B;while((F|0)<(nt|0));se=w}else se=d,B=f;if(W=Ct(se|0,B|0,45)|0,X()|0,!(Ji(W&127)|0))w=0;else{W=Ct(se|0,B|0,52)|0,X()|0,W=W&15;t:do if(!W)w=0;else for(F=1;;){if(w=Ct(se|0,B|0,(15-F|0)*3|0)|0,X()|0,w=w&7,w|0)break t;if(F>>>0>>0)F=F+1|0;else{w=0;break}}while(!1);w=(w|0)==0&1}if(B=Ct(d|0,f|0,(15-_e|0)*3|0)|0,X()|0,B=B&7,(B|0)==7){y=5,F=42;break}if(w=(w|0)!=0,(B|0)==1&w){y=5,F=42;break}if(se=B+(((B|0)!=0&w)<<31>>31)|0,se|0&&(F=nt-_e|0,F=Lo(7,0,F,((F|0)<0)<<31>>31)|0,W=X()|0,w?(w=ur(F|0,W|0,5,0)|0,w=tn(w|0,X()|0,-5,-1)|0,w=Io(w|0,X()|0,6,0)|0,w=tn(w|0,X()|0,1,0)|0,B=X()|0):(w=F,B=W),_e=se+-1|0,_e=ur(F|0,W|0,_e|0,((_e|0)<0)<<31>>31|0)|0,_e=tn(w|0,B|0,_e|0,X()|0)|0,se=X()|0,W=_,W=tn(_e|0,se|0,A[W>>2]|0,A[W+4>>2]|0)|0,se=X()|0,_e=_,A[_e>>2]=W,A[_e+4>>2]=se),(ve|0)<=(p|0)){F=37;break}}if((F|0)==19)tt(27795,27122,1367,27158);else if((F|0)==37){M=_,y=A[M+4>>2]|0,M=A[M>>2]|0;break}else if((F|0)==42)return K=Xe,y|0}else y=0,M=0}else F=33;while(!1);e:do if((F|0)==33)if(ye=_,A[ye>>2]=0,A[ye+4>>2]=0,(nt|0)>(p|0)){for(w=nt;;){if(y=Ct(d|0,f|0,(15-w|0)*3|0)|0,X()|0,y=y&7,(y|0)==7){y=5;break}if(M=nt-w|0,M=Lo(7,0,M,((M|0)<0)<<31>>31)|0,y=ur(M|0,X()|0,y|0,0)|0,M=X()|0,ye=_,M=tn(A[ye>>2]|0,A[ye+4>>2]|0,y|0,M|0)|0,y=X()|0,ye=_,A[ye>>2]=M,A[ye+4>>2]=y,w=w+-1|0,(w|0)<=(p|0))break e}return K=Xe,y|0}else y=0,M=0;while(!1);return nf(Pe,R,nt,ze)|0&&tt(27795,27122,1327,27173),nt=ze,ze=A[nt+4>>2]|0,((y|0)>-1|(y|0)==-1&M>>>0>4294967295)&((ze|0)>(y|0)|((ze|0)==(y|0)?(A[nt>>2]|0)>>>0>M>>>0:0))?(nt=0,K=Xe,nt|0):(tt(27795,27122,1407,27158),0)}function b1(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0;if(se=K,K=K+16|0,M=se,y>>>0>15)return w=4,K=se,w|0;if(R=Ct(p|0,_|0,52)|0,X()|0,R=R&15,(R|0)>(y|0))return w=12,K=se,w|0;if(nf(p,_,y,M)|0&&tt(27795,27122,1327,27173),W=M,F=A[W+4>>2]|0,!(((f|0)>-1|(f|0)==-1&d>>>0>4294967295)&((F|0)>(f|0)|((F|0)==(f|0)?(A[W>>2]|0)>>>0>d>>>0:0))))return w=2,K=se,w|0;W=y-R|0,y=It(y|0,0,52)|0,B=X()|0|_&-15728641,F=w,A[F>>2]=y|p,A[F+4>>2]=B,F=Ct(p|0,_|0,45)|0,X()|0;e:do if(Ji(F&127)|0){if(R|0)for(M=1;;){if(F=It(7,0,(15-M|0)*3|0)|0,!((F&p|0)==0&((X()|0)&_|0)==0))break e;if(M>>>0>>0)M=M+1|0;else break}if((W|0)<1)return w=0,K=se,w|0;for(F=R^15,_=-1,B=1,M=1;;){R=W-B|0,R=Lo(7,0,R,((R|0)<0)<<31>>31)|0,p=X()|0;do if(M)if(M=ur(R|0,p|0,5,0)|0,M=tn(M|0,X()|0,-5,-1)|0,M=Io(M|0,X()|0,6,0)|0,y=X()|0,(f|0)>(y|0)|(f|0)==(y|0)&d>>>0>M>>>0){f=tn(d|0,f|0,-1,-1)|0,f=Lr(f|0,X()|0,M|0,y|0)|0,M=X()|0,_e=w,ye=A[_e>>2]|0,_e=A[_e+4>>2]|0,Pe=(F+_|0)*3|0,ve=It(7,0,Pe|0)|0,_e=_e&~(X()|0),_=Io(f|0,M|0,R|0,p|0)|0,d=X()|0,y=tn(_|0,d|0,2,0)|0,Pe=It(y|0,X()|0,Pe|0)|0,_e=X()|0|_e,y=w,A[y>>2]=Pe|ye&~ve,A[y+4>>2]=_e,d=ur(_|0,d|0,R|0,p|0)|0,d=Lr(f|0,M|0,d|0,X()|0)|0,M=0,f=X()|0;break}else{Pe=w,ve=A[Pe>>2]|0,Pe=A[Pe+4>>2]|0,ye=It(7,0,(F+_|0)*3|0)|0,Pe=Pe&~(X()|0),M=w,A[M>>2]=ve&~ye,A[M+4>>2]=Pe,M=1;break}else ve=w,y=A[ve>>2]|0,ve=A[ve+4>>2]|0,_=(F+_|0)*3|0,_e=It(7,0,_|0)|0,ve=ve&~(X()|0),Pe=Io(d|0,f|0,R|0,p|0)|0,M=X()|0,_=It(Pe|0,M|0,_|0)|0,ve=X()|0|ve,ye=w,A[ye>>2]=_|y&~_e,A[ye+4>>2]=ve,M=ur(Pe|0,M|0,R|0,p|0)|0,d=Lr(d|0,f|0,M|0,X()|0)|0,M=0,f=X()|0;while(!1);if((W|0)>(B|0))_=~B,B=B+1|0;else{f=0;break}}return K=se,f|0}while(!1);if((W|0)<1)return Pe=0,K=se,Pe|0;for(y=R^15,M=1;;)if(ye=W-M|0,ye=Lo(7,0,ye,((ye|0)<0)<<31>>31)|0,Pe=X()|0,B=w,p=A[B>>2]|0,B=A[B+4>>2]|0,R=(y-M|0)*3|0,_=It(7,0,R|0)|0,B=B&~(X()|0),_e=Io(d|0,f|0,ye|0,Pe|0)|0,ve=X()|0,R=It(_e|0,ve|0,R|0)|0,B=X()|0|B,F=w,A[F>>2]=R|p&~_,A[F+4>>2]=B,Pe=ur(_e|0,ve|0,ye|0,Pe|0)|0,d=Lr(d|0,f|0,Pe|0,X()|0)|0,f=X()|0,(W|0)<=(M|0)){f=0;break}else M=M+1|0;return K=se,f|0}function nl(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;y=Ct(f|0,p|0,52)|0,X()|0,y=y&15,(f|0)==0&(p|0)==0|((_|0)>15|(y|0)>(_|0))?(w=-1,f=-1,p=0,y=0):(f=sp(f,p,y+1|0,_)|0,M=(X()|0)&-15728641,p=It(_|0,0,52)|0,p=f|p,M=M|(X()|0),f=(wi(p,M)|0)==0,w=y,f=f?-1:_,y=M),M=d,A[M>>2]=p,A[M+4>>2]=y,A[d+8>>2]=w,A[d+12>>2]=f}function Fu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,w=_+8|0,A[w>>2]=y,(d|0)==0&(f|0)==0|((p|0)>15|(y|0)>(p|0))){p=_,A[p>>2]=0,A[p+4>>2]=0,A[w>>2]=-1,A[_+12>>2]=-1;return}if(d=sp(d,f,y+1|0,p)|0,w=(X()|0)&-15728641,y=It(p|0,0,52)|0,y=d|y,w=w|(X()|0),d=_,A[d>>2]=y,A[d+4>>2]=w,d=_+12|0,wi(y,w)|0){A[d>>2]=p;return}else{A[d>>2]=-1;return}}function rf(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0;if(p=d,f=A[p>>2]|0,p=A[p+4>>2]|0,!((f|0)==0&(p|0)==0)&&(_=Ct(f|0,p|0,52)|0,X()|0,_=_&15,R=It(1,0,(_^15)*3|0)|0,f=tn(R|0,X()|0,f|0,p|0)|0,p=X()|0,R=d,A[R>>2]=f,A[R+4>>2]=p,R=d+8|0,M=A[R>>2]|0,!((_|0)<(M|0)))){for(B=d+12|0,w=_;;){if((w|0)==(M|0)){_=5;break}if(F=(w|0)==(A[B>>2]|0),y=(15-w|0)*3|0,_=Ct(f|0,p|0,y|0)|0,X()|0,_=_&7,F&((_|0)==1&!0)){_=7;break}if(!((_|0)==7&!0)){_=10;break}if(F=It(1,0,y|0)|0,f=tn(f|0,p|0,F|0,X()|0)|0,p=X()|0,F=d,A[F>>2]=f,A[F+4>>2]=p,(w|0)>(M|0))w=w+-1|0;else{_=10;break}}if((_|0)==5){F=d,A[F>>2]=0,A[F+4>>2]=0,A[R>>2]=-1,A[B>>2]=-1;return}else if((_|0)==7){M=It(1,0,y|0)|0,M=tn(f|0,p|0,M|0,X()|0)|0,R=X()|0,F=d,A[F>>2]=M,A[F+4>>2]=R,A[B>>2]=w+-1;return}else if((_|0)==10)return}}function $c(d){d=+d;var f=0;return f=d<0?d+6.283185307179586:d,+(d>=6.283185307179586?f+-6.283185307179586:f)}function wa(d,f){return d=d|0,f=f|0,+dn(+(+ee[d>>3]-+ee[f>>3]))<17453292519943298e-27?(f=+dn(+(+ee[d+8>>3]-+ee[f+8>>3]))<17453292519943298e-27,f|0):(f=0,f|0)}function Ws(d,f){switch(d=+d,f=f|0,f|0){case 1:{d=d<0?d+6.283185307179586:d;break}case 2:{d=d>0?d+-6.283185307179586:d;break}}return+d}function S1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+ee[f>>3],_=+ee[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+ee[f+8>>3]-+ee[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2)}function Xc(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+ee[f>>3],_=+ee[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+ee[f+8>>3]-+ee[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2*6371.007180918475)}function Ex(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+ee[f>>3],_=+ee[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+ee[f+8>>3]-+ee[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2*6371.007180918475*1e3)}function Cx(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return w=+ee[f>>3],_=+an(+w),y=+ee[f+8>>3]-+ee[d+8>>3],M=_*+mn(+y),p=+ee[d>>3],+ +Ge(+M,+(+mn(+w)*+an(+p)-+an(+y)*(_*+mn(+p))))}function Nx(d,f,p,_){d=d|0,f=+f,p=+p,_=_|0;var y=0,w=0,M=0,R=0;if(p<1e-16){A[_>>2]=A[d>>2],A[_+4>>2]=A[d+4>>2],A[_+8>>2]=A[d+8>>2],A[_+12>>2]=A[d+12>>2];return}w=f<0?f+6.283185307179586:f,w=f>=6.283185307179586?w+-6.283185307179586:w;do if(w<1e-16)f=+ee[d>>3]+p,ee[_>>3]=f,y=_;else{if(y=+dn(+(w+-3.141592653589793))<1e-16,f=+ee[d>>3],y){f=f-p,ee[_>>3]=f,y=_;break}if(M=+an(+p),p=+mn(+p),f=M*+mn(+f)+ +an(+w)*(p*+an(+f)),f=f>1?1:f,f=+No(+(f<-1?-1:f)),ee[_>>3]=f,+dn(+(f+-1.5707963267948966))<1e-16){ee[_>>3]=1.5707963267948966,ee[_+8>>3]=0;return}if(+dn(+(f+1.5707963267948966))<1e-16){ee[_>>3]=-1.5707963267948966,ee[_+8>>3]=0;return}if(R=1/+an(+f),w=p*+mn(+w)*R,p=+ee[d>>3],f=R*((M-+mn(+f)*+mn(+p))/+an(+p)),M=w>1?1:w,f=f>1?1:f,f=+ee[d+8>>3]+ +Ge(+(M<-1?-1:M),+(f<-1?-1:f)),f>3.141592653589793)do f=f+-6.283185307179586;while(f>3.141592653589793);if(f<-3.141592653589793)do f=f+6.283185307179586;while(f<-3.141592653589793);ee[_+8>>3]=f;return}while(!1);if(+dn(+(f+-1.5707963267948966))<1e-16){ee[y>>3]=1.5707963267948966,ee[_+8>>3]=0;return}if(+dn(+(f+1.5707963267948966))<1e-16){ee[y>>3]=-1.5707963267948966,ee[_+8>>3]=0;return}if(f=+ee[d+8>>3],f>3.141592653589793)do f=f+-6.283185307179586;while(f>3.141592653589793);if(f<-3.141592653589793)do f=f+6.283185307179586;while(f<-3.141592653589793);ee[_+8>>3]=f}function hp(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(ee[f>>3]=+ee[20656+(d<<3)>>3],f=0,f|0)}function w1(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(ee[f>>3]=+ee[20784+(d<<3)>>3],f=0,f|0)}function fp(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(ee[f>>3]=+ee[20912+(d<<3)>>3],f=0,f|0)}function ro(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(ee[f>>3]=+ee[21040+(d<<3)>>3],f=0,f|0)}function ku(d,f){d=d|0,f=f|0;var p=0;return d>>>0>15?(f=4,f|0):(p=Lo(7,0,d,((d|0)<0)<<31>>31)|0,p=ur(p|0,X()|0,120,0)|0,d=X()|0,A[f>>2]=p|2,A[f+4>>2]=d,f=0,f|0)}function fa(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;return _e=+ee[f>>3],W=+ee[d>>3],B=+mn(+((_e-W)*.5)),w=+ee[f+8>>3],F=+ee[d+8>>3],M=+mn(+((w-F)*.5)),R=+an(+W),se=+an(+_e),M=B*B+M*(se*R*M),M=+Ge(+ +Fn(+M),+ +Fn(+(1-M)))*2,B=+ee[p>>3],_e=+mn(+((B-_e)*.5)),_=+ee[p+8>>3],w=+mn(+((_-w)*.5)),y=+an(+B),w=_e*_e+w*(se*y*w),w=+Ge(+ +Fn(+w),+ +Fn(+(1-w)))*2,B=+mn(+((W-B)*.5)),_=+mn(+((F-_)*.5)),_=B*B+_*(R*y*_),_=+Ge(+ +Fn(+_),+ +Fn(+(1-_)))*2,y=(M+w+_)*.5,+(+ce(+ +Fn(+(+Er(+(y*.5))*+Er(+((y-M)*.5))*+Er(+((y-w)*.5))*+Er(+((y-_)*.5)))))*4)}function Ll(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0;if(R=K,K=K+192|0,w=R+168|0,M=R,y=Dl(d,f,w)|0,y|0)return p=y,K=R,p|0;if(Pl(d,f,M)|0&&tt(27795,27190,415,27199),f=A[M>>2]|0,(f|0)>0){if(_=+fa(M+8|0,M+8+(((f|0)!=1&1)<<4)|0,w)+0,(f|0)!=1){d=1;do y=d,d=d+1|0,_=_+ +fa(M+8+(y<<4)|0,M+8+(((d|0)%(f|0)|0)<<4)|0,w);while((d|0)<(f|0))}}else _=0;return ee[p>>3]=_,p=0,K=R,p|0}function dp(d,f,p){return d=d|0,f=f|0,p=p|0,d=Ll(d,f,p)|0,d|0||(ee[p>>3]=+ee[p>>3]*6371.007180918475*6371.007180918475),d|0}function Nd(d,f,p){return d=d|0,f=f|0,p=p|0,d=Ll(d,f,p)|0,d|0||(ee[p>>3]=+ee[p>>3]*6371.007180918475*6371.007180918475*1e3*1e3),d|0}function Rd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,K=R,M|0;if(ee[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,K=R,M|0;f=d+-1|0,d=0,_=+ee[M+8>>3],y=+ee[M+16>>3],w=0;do d=d+1|0,F=_,_=+ee[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+ee[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+_)*+an(+F)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)<(f|0));return ee[p>>3]=w,M=0,K=R,M|0}function Ap(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,w=+ee[p>>3],w=w*6371.007180918475,ee[p>>3]=w,K=R,M|0;if(ee[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,w=0,w=w*6371.007180918475,ee[p>>3]=w,K=R,M|0;f=d+-1|0,d=0,_=+ee[M+8>>3],y=+ee[M+16>>3],w=0;do d=d+1|0,F=_,_=+ee[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+ee[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+F)*+an(+_)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)!=(f|0));return ee[p>>3]=w,M=0,W=w,W=W*6371.007180918475,ee[p>>3]=W,K=R,M|0}function zu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,w=+ee[p>>3],w=w*6371.007180918475,w=w*1e3,ee[p>>3]=w,K=R,M|0;if(ee[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,w=0,w=w*6371.007180918475,w=w*1e3,ee[p>>3]=w,K=R,M|0;f=d+-1|0,d=0,_=+ee[M+8>>3],y=+ee[M+16>>3],w=0;do d=d+1|0,F=_,_=+ee[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+ee[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+F)*+an(+_)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)!=(f|0));return ee[p>>3]=w,M=0,W=w,W=W*6371.007180918475,W=W*1e3,ee[p>>3]=W,K=R,M|0}function T1(d){d=d|0;var f=0,p=0,_=0;return f=Ys(1,12)|0,f||tt(27280,27235,49,27293),p=d+4|0,_=A[p>>2]|0,_|0?(_=_+8|0,A[_>>2]=f,A[p>>2]=f,f|0):(A[d>>2]|0&&tt(27310,27235,61,27333),_=d,A[_>>2]=f,A[p>>2]=f,f|0)}function Dd(d,f){d=d|0,f=f|0;var p=0,_=0;return _=Oo(24)|0,_||tt(27347,27235,78,27361),A[_>>2]=A[f>>2],A[_+4>>2]=A[f+4>>2],A[_+8>>2]=A[f+8>>2],A[_+12>>2]=A[f+12>>2],A[_+16>>2]=0,f=d+4|0,p=A[f>>2]|0,p|0?(A[p+16>>2]=_,A[f>>2]=_,_|0):(A[d>>2]|0&&tt(27376,27235,82,27361),A[d>>2]=_,A[f>>2]=_,_|0)}function Gu(d){d=d|0;var f=0,p=0,_=0,y=0;if(d)for(_=1;;){if(f=A[d>>2]|0,f|0)do{if(p=A[f>>2]|0,p|0)do y=p,p=A[p+16>>2]|0,vn(y);while((p|0)!=0);y=f,f=A[f+8>>2]|0,vn(y)}while((f|0)!=0);if(f=d,d=A[d+8>>2]|0,_||vn(f),d)_=0;else break}}function Rx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0,xn=0,si=0,Cn=0;if(y=d+8|0,A[y>>2]|0)return Cn=1,Cn|0;if(_=A[d>>2]|0,!_)return Cn=0,Cn|0;f=_,p=0;do p=p+1|0,f=A[f+8>>2]|0;while((f|0)!=0);if(p>>>0<2)return Cn=0,Cn|0;xn=Oo(p<<2)|0,xn||tt(27396,27235,317,27415),kt=Oo(p<<5)|0,kt||tt(27437,27235,321,27415),A[d>>2]=0,un=d+4|0,A[un>>2]=0,A[y>>2]=0,p=0,fn=0,Ft=0,se=0;e:for(;;){if(W=A[_>>2]|0,W){w=0,M=W;do{if(B=+ee[M+8>>3],f=M,M=A[M+16>>2]|0,F=(M|0)==0,y=F?W:M,R=+ee[y+8>>3],+dn(+(B-R))>3.141592653589793){Cn=14;break}w=w+(R-B)*(+ee[f>>3]+ +ee[y>>3])}while(!F);if((Cn|0)==14){Cn=0,w=0,f=W;do Le=+ee[f+8>>3],En=f+16|0,Zn=A[En>>2]|0,Zn=(Zn|0)==0?W:Zn,je=+ee[Zn+8>>3],w=w+(+ee[f>>3]+ +ee[Zn>>3])*((je<0?je+6.283185307179586:je)-(Le<0?Le+6.283185307179586:Le)),f=A[((f|0)==0?_:En)>>2]|0;while((f|0)!=0)}w>0?(A[xn+(fn<<2)>>2]=_,fn=fn+1|0,y=Ft,f=se):Cn=19}else Cn=19;if((Cn|0)==19){Cn=0;do if(p){if(f=p+8|0,A[f>>2]|0){Cn=21;break e}if(p=Ys(1,12)|0,!p){Cn=23;break e}A[f>>2]=p,y=p+4|0,M=p,f=se}else if(se){y=un,M=se+8|0,f=_,p=d;break}else if(A[d>>2]|0){Cn=27;break e}else{y=un,M=d,f=_,p=d;break}while(!1);if(A[M>>2]=_,A[y>>2]=_,M=kt+(Ft<<5)|0,F=A[_>>2]|0,F){for(W=kt+(Ft<<5)+8|0,ee[W>>3]=17976931348623157e292,se=kt+(Ft<<5)+24|0,ee[se>>3]=17976931348623157e292,ee[M>>3]=-17976931348623157e292,_e=kt+(Ft<<5)+16|0,ee[_e>>3]=-17976931348623157e292,nt=17976931348623157e292,Xe=-17976931348623157e292,y=0,ve=F,B=17976931348623157e292,Pe=17976931348623157e292,ze=-17976931348623157e292,R=-17976931348623157e292;w=+ee[ve>>3],Le=+ee[ve+8>>3],ve=A[ve+16>>2]|0,ye=(ve|0)==0,je=+ee[(ye?F:ve)+8>>3],w>3]=w,B=w),Le>3]=Le,Pe=Le),w>ze?ee[M>>3]=w:w=ze,Le>R&&(ee[_e>>3]=Le,R=Le),nt=Le>0&LeXe?Le:Xe,y=y|+dn(+(Le-je))>3.141592653589793,!ye;)ze=w;y&&(ee[_e>>3]=Xe,ee[se>>3]=nt)}else A[M>>2]=0,A[M+4>>2]=0,A[M+8>>2]=0,A[M+12>>2]=0,A[M+16>>2]=0,A[M+20>>2]=0,A[M+24>>2]=0,A[M+28>>2]=0;y=Ft+1|0}if(En=_+8|0,_=A[En>>2]|0,A[En>>2]=0,_)Ft=y,se=f;else{Cn=45;break}}if((Cn|0)==21)tt(27213,27235,35,27247);else if((Cn|0)==23)tt(27267,27235,37,27247);else if((Cn|0)==27)tt(27310,27235,61,27333);else if((Cn|0)==45){e:do if((fn|0)>0){for(En=(y|0)==0,Dn=y<<2,Zn=(d|0)==0,kn=0,f=0;;){if(on=A[xn+(kn<<2)>>2]|0,En)Cn=73;else{if(Ft=Oo(Dn)|0,!Ft){Cn=50;break}if(un=Oo(Dn)|0,!un){Cn=52;break}t:do if(Zn)p=0;else{for(y=0,p=0,M=d;_=kt+(y<<5)|0,$s(A[M>>2]|0,_,A[on>>2]|0)|0?(A[Ft+(p<<2)>>2]=M,A[un+(p<<2)>>2]=_,ye=p+1|0):ye=p,M=A[M+8>>2]|0,M;)y=y+1|0,p=ye;if((ye|0)>0)if(_=A[Ft>>2]|0,(ye|0)==1)p=_;else for(_e=0,ve=-1,p=_,se=_;;){for(F=A[se>>2]|0,_=0,M=0;y=A[A[Ft+(M<<2)>>2]>>2]|0,(y|0)==(F|0)?W=_:W=_+(($s(y,A[un+(M<<2)>>2]|0,A[F>>2]|0)|0)&1)|0,M=M+1|0,(M|0)!=(ye|0);)_=W;if(y=(W|0)>(ve|0),p=y?se:p,_=_e+1|0,(_|0)==(ye|0))break t;_e=_,ve=y?W:ve,se=A[Ft+(_<<2)>>2]|0}else p=0}while(!1);if(vn(Ft),vn(un),p){if(y=p+4|0,_=A[y>>2]|0,_)p=_+8|0;else if(A[p>>2]|0){Cn=70;break}A[p>>2]=on,A[y>>2]=on}else Cn=73}if((Cn|0)==73){if(Cn=0,f=A[on>>2]|0,f|0)do un=f,f=A[f+16>>2]|0,vn(un);while((f|0)!=0);vn(on),f=1}if(kn=kn+1|0,(kn|0)>=(fn|0)){si=f;break e}}(Cn|0)==50?tt(27452,27235,249,27471):(Cn|0)==52?tt(27490,27235,252,27471):(Cn|0)==70&&tt(27310,27235,61,27333)}else si=0;while(!1);return vn(xn),vn(kt),Cn=si,Cn|0}return 0}function $s(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(!(Do(f,p)|0)||(f=_d(f)|0,_=+ee[p>>3],y=+ee[p+8>>3],y=f&y<0?y+6.283185307179586:y,d=A[d>>2]|0,!d))return d=0,d|0;if(f){f=0,F=y,p=d;e:for(;;){for(;M=+ee[p>>3],y=+ee[p+8>>3],p=p+16|0,W=A[p>>2]|0,W=(W|0)==0?d:W,w=+ee[W>>3],R=+ee[W+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=A[p>>2]|0,!p){p=22;break e}if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,F=R==F|M==F?F+-2220446049250313e-31:F,B=R+(M-R)*((_-w)/(B-w)),(B<0?B+6.283185307179586:B)>F&&(f=f^1),p=A[p>>2]|0,!p){p=22;break}}if((p|0)==22)return f|0}else{f=0,F=y,p=d;e:for(;;){for(;M=+ee[p>>3],y=+ee[p+8>>3],p=p+16|0,W=A[p>>2]|0,W=(W|0)==0?d:W,w=+ee[W>>3],R=+ee[W+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=A[p>>2]|0,!p){p=22;break e}if(F=M==F|y==F?F+-2220446049250313e-31:F,M+(y-M)*((_-w)/(B-w))>F&&(f=f^1),p=A[p>>2]|0,!p){p=22;break}}if((p|0)==22)return f|0}return 0}function so(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0;if(Xe=K,K=K+32|0,nt=Xe+16|0,ze=Xe,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,ve=Ct(p|0,_|0,52)|0,X()|0,(w|0)!=(ve&15|0))return nt=12,K=Xe,nt|0;if(F=Ct(d|0,f|0,45)|0,X()|0,F=F&127,W=Ct(p|0,_|0,45)|0,X()|0,W=W&127,F>>>0>121|W>>>0>121)return nt=5,K=Xe,nt|0;if(ve=(F|0)!=(W|0),ve){if(R=Xh(F,W)|0,(R|0)==7)return nt=1,K=Xe,nt|0;B=Xh(W,F)|0,(B|0)==7?tt(27514,27538,161,27548):(ye=R,M=B)}else ye=0,M=0;se=Ji(F)|0,_e=Ji(W)|0,A[nt>>2]=0,A[nt+4>>2]=0,A[nt+8>>2]=0,A[nt+12>>2]=0;do if(ye){if(W=A[4272+(F*28|0)+(ye<<2)>>2]|0,R=(W|0)>0,_e)if(R){F=0,B=p,R=_;do B=Tx(B,R)|0,R=X()|0,M=tl(M)|0,(M|0)==1&&(M=tl(1)|0),F=F+1|0;while((F|0)!=(W|0));W=M,F=B,B=R}else W=M,F=p,B=_;else if(R){F=0,B=p,R=_;do B=lp(B,R)|0,R=X()|0,M=tl(M)|0,F=F+1|0;while((F|0)!=(W|0));W=M,F=B,B=R}else W=M,F=p,B=_;if(Cd(F,B,nt)|0,ve||tt(27563,27538,191,27548),R=(se|0)!=0,M=(_e|0)!=0,R&M&&tt(27590,27538,192,27548),R){if(M=Hs(d,f)|0,(M|0)==7){w=5;break}if(xt[22e3+(M*7|0)+ye>>0]|0){w=1;break}B=A[21168+(M*28|0)+(ye<<2)>>2]|0,F=B}else if(M){if(M=Hs(F,B)|0,(M|0)==7){w=5;break}if(xt[22e3+(M*7|0)+W>>0]|0){w=1;break}F=0,B=A[21168+(W*28|0)+(M<<2)>>2]|0}else F=0,B=0;if((F|B|0)<0)w=5;else{if((B|0)>0){R=nt+4|0,M=0;do bd(R),M=M+1|0;while((M|0)!=(B|0))}if(A[ze>>2]=0,A[ze+4>>2]=0,A[ze+8>>2]=0,l1(ze,ye),w|0)for(;bs(w)|0?Hc(ze):Cu(ze),(w|0)>1;)w=w+-1|0;if((F|0)>0){w=0;do bd(ze),w=w+1|0;while((w|0)!=(F|0))}Pe=nt+4|0,us(Pe,ze,Pe),Pr(Pe),Pe=51}}else if(Cd(p,_,nt)|0,(se|0)!=0&(_e|0)!=0)if((W|0)!=(F|0)&&tt(27621,27538,261,27548),M=Hs(d,f)|0,w=Hs(p,_)|0,(M|0)==7|(w|0)==7)w=5;else if(xt[22e3+(M*7|0)+w>>0]|0)w=1;else if(M=A[21168+(M*28|0)+(w<<2)>>2]|0,(M|0)>0){R=nt+4|0,w=0;do bd(R),w=w+1|0;while((w|0)!=(M|0));Pe=51}else Pe=51;else Pe=51;while(!1);return(Pe|0)==51&&(w=nt+4|0,A[y>>2]=A[w>>2],A[y+4>>2]=A[w+4>>2],A[y+8>>2]=A[w+8>>2],w=0),nt=w,K=Xe,nt|0}function Po(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0;if(Pe=K,K=K+48|0,F=Pe+36|0,M=Pe+24|0,R=Pe+12|0,B=Pe,y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,_e=Ct(d|0,f|0,45)|0,X()|0,_e=_e&127,_e>>>0>121)return _=5,K=Pe,_|0;if(W=Ji(_e)|0,It(y|0,0,52)|0,ze=X()|0|134225919,w=_,A[w>>2]=-1,A[w+4>>2]=ze,!y)return y=Eu(p)|0,(y|0)==7||(y=vd(_e,y)|0,(y|0)==127)?(ze=1,K=Pe,ze|0):(ve=It(y|0,0,45)|0,ye=X()|0,_e=_,ye=A[_e+4>>2]&-1040385|ye,ze=_,A[ze>>2]=A[_e>>2]|ve,A[ze+4>>2]=ye,ze=0,K=Pe,ze|0);for(A[F>>2]=A[p>>2],A[F+4>>2]=A[p+4>>2],A[F+8>>2]=A[p+8>>2],p=y;;){if(w=p,p=p+-1|0,A[M>>2]=A[F>>2],A[M+4>>2]=A[F+4>>2],A[M+8>>2]=A[F+8>>2],bs(w)|0){if(y=a1(F)|0,y|0){p=13;break}A[R>>2]=A[F>>2],A[R+4>>2]=A[F+4>>2],A[R+8>>2]=A[F+8>>2],Hc(R)}else{if(y=hx(F)|0,y|0){p=13;break}A[R>>2]=A[F>>2],A[R+4>>2]=A[F+4>>2],A[R+8>>2]=A[F+8>>2],Cu(R)}if(ef(M,R,B),Pr(B),y=_,Xe=A[y>>2]|0,y=A[y+4>>2]|0,je=(15-w|0)*3|0,nt=It(7,0,je|0)|0,y=y&~(X()|0),je=It(Eu(B)|0,0,je|0)|0,y=X()|0|y,ze=_,A[ze>>2]=je|Xe&~nt,A[ze+4>>2]=y,(w|0)<=1){p=14;break}}e:do if((p|0)!=13&&(p|0)==14)if((A[F>>2]|0)<=1&&(A[F+4>>2]|0)<=1&&(A[F+8>>2]|0)<=1){p=Eu(F)|0,y=vd(_e,p)|0,(y|0)==127?B=0:B=Ji(y)|0;t:do if(p){if(W){if(y=Hs(d,f)|0,(y|0)==7){y=5;break e}if(w=A[21376+(y*28|0)+(p<<2)>>2]|0,(w|0)>0){y=p,p=0;do y=Nu(y)|0,p=p+1|0;while((p|0)!=(w|0))}else y=p;if((y|0)==1){y=9;break e}p=vd(_e,y)|0,(p|0)==127&&tt(27648,27538,411,27678),Ji(p)|0?tt(27693,27538,412,27678):(ye=p,ve=w,se=y)}else ye=y,ve=0,se=p;if(R=A[4272+(_e*28|0)+(se<<2)>>2]|0,(R|0)<=-1&&tt(27724,27538,419,27678),!B){if((ve|0)<0){y=5;break e}if(ve|0){w=_,y=0,p=A[w>>2]|0,w=A[w+4>>2]|0;do p=Uu(p,w)|0,w=X()|0,je=_,A[je>>2]=p,A[je+4>>2]=w,y=y+1|0;while((y|0)<(ve|0))}if((R|0)<=0){y=ye,p=58;break}for(w=_,y=0,p=A[w>>2]|0,w=A[w+4>>2]|0;;)if(p=Uu(p,w)|0,w=X()|0,je=_,A[je>>2]=p,A[je+4>>2]=w,y=y+1|0,(y|0)==(R|0)){y=ye,p=58;break t}}if(M=Xh(ye,_e)|0,(M|0)==7&&tt(27514,27538,428,27678),y=_,p=A[y>>2]|0,y=A[y+4>>2]|0,(R|0)>0){w=0;do p=Uu(p,y)|0,y=X()|0,je=_,A[je>>2]=p,A[je+4>>2]=y,w=w+1|0;while((w|0)!=(R|0))}if(y=Hs(p,y)|0,(y|0)==7&&tt(27795,27538,440,27678),p=qc(ye)|0,p=A[(p?21792:21584)+(M*28|0)+(y<<2)>>2]|0,(p|0)<0&&tt(27795,27538,454,27678),!p)y=ye,p=58;else{M=_,y=0,w=A[M>>2]|0,M=A[M+4>>2]|0;do w=op(w,M)|0,M=X()|0,je=_,A[je>>2]=w,A[je+4>>2]=M,y=y+1|0;while((y|0)<(p|0));y=ye,p=58}}else if((W|0)!=0&(B|0)!=0){if(p=Hs(d,f)|0,w=_,w=Hs(A[w>>2]|0,A[w+4>>2]|0)|0,(p|0)==7|(w|0)==7){y=5;break e}if(w=A[21376+(p*28|0)+(w<<2)>>2]|0,(w|0)<0){y=5;break e}if(!w)p=59;else{R=_,p=0,M=A[R>>2]|0,R=A[R+4>>2]|0;do M=Uu(M,R)|0,R=X()|0,je=_,A[je>>2]=M,A[je+4>>2]=R,p=p+1|0;while((p|0)<(w|0));p=58}}else p=58;while(!1);if((p|0)==58&&B&&(p=59),(p|0)==59&&(je=_,(Hs(A[je>>2]|0,A[je+4>>2]|0)|0)==1)){y=9;break}je=_,nt=A[je>>2]|0,je=A[je+4>>2]&-1040385,Xe=It(y|0,0,45)|0,je=je|(X()|0),y=_,A[y>>2]=nt|Xe,A[y+4>>2]=je,y=0}else y=1;while(!1);return je=y,K=Pe,je|0}function M1(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0;return R=K,K=K+16|0,M=R,y?d=15:(d=so(d,f,p,_,M)|0,d||(dx(M,w),d=0)),K=R,d|0}function Pd(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0;return M=K,K=K+16|0,w=M,_?p=15:(p=tp(p,w)|0,p||(p=Po(d,f,w,y)|0)),K=M,p|0}function qu(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0;return B=K,K=K+32|0,M=B+12|0,R=B,w=so(d,f,d,f,M)|0,w|0?(R=w,K=B,R|0):(d=so(d,f,p,_,R)|0,d|0?(R=d,K=B,R|0):(M=ep(M,R)|0,R=y,A[R>>2]=M,A[R+4>>2]=((M|0)<0)<<31>>31,R=0,K=B,R|0))}function pp(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0;return B=K,K=K+32|0,M=B+12|0,R=B,w=so(d,f,d,f,M)|0,!w&&(w=so(d,f,p,_,R)|0,!w)?(_=ep(M,R)|0,_=tn(_|0,((_|0)<0)<<31>>31|0,1,0)|0,M=X()|0,R=y,A[R>>2]=_,A[R+4>>2]=M,R=0,K=B,R|0):(R=w,K=B,R|0)}function E1(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0;if(on=K,K=K+48|0,Ft=on+24|0,M=on+12|0,un=on,w=so(d,f,d,f,Ft)|0,!w&&(w=so(d,f,p,_,M)|0,!w)){je=ep(Ft,M)|0,Le=((je|0)<0)<<31>>31,A[Ft>>2]=0,A[Ft+4>>2]=0,A[Ft+8>>2]=0,A[M>>2]=0,A[M+4>>2]=0,A[M+8>>2]=0,so(d,f,d,f,Ft)|0&&tt(27795,27538,692,27747),so(d,f,p,_,M)|0&&tt(27795,27538,697,27747),f1(Ft),f1(M),W=(je|0)==0?0:1/+(je|0),p=A[Ft>>2]|0,Pe=W*+((A[M>>2]|0)-p|0),ze=Ft+4|0,_=A[ze>>2]|0,nt=W*+((A[M+4>>2]|0)-_|0),Xe=Ft+8|0,w=A[Xe>>2]|0,W=W*+((A[M+8>>2]|0)-w|0),A[un>>2]=p,se=un+4|0,A[se>>2]=_,_e=un+8|0,A[_e>>2]=w;e:do if((je|0)<0)w=0;else for(ve=0,ye=0;;){B=+(ye>>>0)+4294967296*+(ve|0),kn=Pe*B+ +(p|0),R=nt*B+ +(_|0),B=W*B+ +(w|0),p=~~+ll(+kn),M=~~+ll(+R),w=~~+ll(+B),kn=+dn(+(+(p|0)-kn)),R=+dn(+(+(M|0)-R)),B=+dn(+(+(w|0)-B));do if(kn>R&kn>B)p=0-(M+w)|0,_=M;else if(F=0-p|0,R>B){_=F-w|0;break}else{_=M,w=F-M|0;break}while(!1);if(A[un>>2]=p,A[se>>2]=_,A[_e>>2]=w,Ax(un),w=Po(d,f,un,y+(ye<<3)|0)|0,w|0)break e;if(!((ve|0)<(Le|0)|(ve|0)==(Le|0)&ye>>>0>>0)){w=0;break e}p=tn(ye|0,ve|0,1,0)|0,_=X()|0,ve=_,ye=p,p=A[Ft>>2]|0,_=A[ze>>2]|0,w=A[Xe>>2]|0}while(!1);return un=w,K=on,un|0}return un=w,K=on,un|0}function Lo(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if((p|0)==0&(_|0)==0)return y=0,w=1,he(y|0),w|0;w=d,y=f,d=1,f=0;do M=(p&1|0)==0&!0,d=ur((M?1:w)|0,(M?0:y)|0,d|0,f|0)|0,f=X()|0,p=N1(p|0,_|0,1)|0,_=X()|0,w=ur(w|0,y|0,w|0,y|0)|0,y=X()|0;while(!((p|0)==0&(_|0)==0));return he(f|0),d|0}function Ld(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;R=K,K=K+16|0,w=R,M=Ct(d|0,f|0,52)|0,X()|0,M=M&15;do if(M){if(y=Dl(d,f,w)|0,!y){F=+ee[w>>3],B=1/+an(+F),W=+ee[25968+(M<<3)>>3],ee[p>>3]=F+W,ee[p+8>>3]=F-W,F=+ee[w+8>>3],B=W*B,ee[p+16>>3]=B+F,ee[p+24>>3]=F-B;break}return M=y,K=R,M|0}else{if(y=Ct(d|0,f|0,45)|0,X()|0,y=y&127,y>>>0>121)return M=5,K=R,M|0;w=22064+(y<<5)|0,A[p>>2]=A[w>>2],A[p+4>>2]=A[w+4>>2],A[p+8>>2]=A[w+8>>2],A[p+12>>2]=A[w+12>>2],A[p+16>>2]=A[w+16>>2],A[p+20>>2]=A[w+20>>2],A[p+24>>2]=A[w+24>>2],A[p+28>>2]=A[w+28>>2];break}while(!1);return js(p,_?1.4:1.1),_=26096+(M<<3)|0,(A[_>>2]|0)==(d|0)&&(A[_+4>>2]|0)==(f|0)&&(ee[p>>3]=1.5707963267948966),M=26224+(M<<3)|0,(A[M>>2]|0)==(d|0)&&(A[M+4>>2]|0)==(f|0)&&(ee[p+8>>3]=-1.5707963267948966),+ee[p>>3]!=1.5707963267948966&&+ee[p+8>>3]!=-1.5707963267948966?(M=0,K=R,M|0):(ee[p+16>>3]=3.141592653589793,ee[p+24>>3]=-3.141592653589793,M=0,K=R,M|0)}function Ta(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;F=K,K=K+48|0,M=F+32|0,w=F+40|0,R=F,Pu(M,0,0,0),B=A[M>>2]|0,M=A[M+4>>2]|0;do if(p>>>0<=15){if(y=Ma(_)|0,y|0){_=R,A[_>>2]=0,A[_+4>>2]=0,A[R+8>>2]=y,A[R+12>>2]=-1,_=R+16|0,B=R+29|0,A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,xt[_+12>>0]=0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}if(y=Ys((A[f+8>>2]|0)+1|0,32)|0,y){Ea(f,y),W=R,A[W>>2]=B,A[W+4>>2]=M,A[R+8>>2]=0,A[R+12>>2]=p,A[R+16>>2]=_,A[R+20>>2]=f,A[R+24>>2]=y,xt[R+28>>0]=0,B=R+29|0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}else{_=R,A[_>>2]=0,A[_+4>>2]=0,A[R+8>>2]=13,A[R+12>>2]=-1,_=R+16|0,B=R+29|0,A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,xt[_+12>>0]=0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}}else B=R,A[B>>2]=0,A[B+4>>2]=0,A[R+8>>2]=4,A[R+12>>2]=-1,B=R+16|0,W=R+29|0,A[B>>2]=0,A[B+4>>2]=0,A[B+8>>2]=0,xt[B+12>>0]=0,xt[W>>0]=xt[w>>0]|0,xt[W+1>>0]=xt[w+1>>0]|0,xt[W+2>>0]=xt[w+2>>0]|0;while(!1);il(R),A[d>>2]=A[R>>2],A[d+4>>2]=A[R+4>>2],A[d+8>>2]=A[R+8>>2],A[d+12>>2]=A[R+12>>2],A[d+16>>2]=A[R+16>>2],A[d+20>>2]=A[R+20>>2],A[d+24>>2]=A[R+24>>2],A[d+28>>2]=A[R+28>>2],K=F}function il(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0;if(Le=K,K=K+336|0,ve=Le+168|0,ye=Le,_=d,p=A[_>>2]|0,_=A[_+4>>2]|0,(p|0)==0&(_|0)==0){K=Le;return}if(f=d+28|0,xt[f>>0]|0?(p=Vu(p,_)|0,_=X()|0):xt[f>>0]=1,je=d+20|0,!(A[A[je>>2]>>2]|0)){f=d+24|0,p=A[f>>2]|0,p|0&&vn(p),Xe=d,A[Xe>>2]=0,A[Xe+4>>2]=0,A[d+8>>2]=0,A[je>>2]=0,A[d+12>>2]=-1,A[d+16>>2]=0,A[f>>2]=0,K=Le;return}Xe=d+16|0,f=A[Xe>>2]|0,y=f&15;e:do if((p|0)==0&(_|0)==0)nt=d+24|0;else{Pe=d+12|0,se=(y|0)==3,W=f&255,B=(y|1|0)==3,_e=d+24|0,F=(y+-1|0)>>>0<3,M=(y|2|0)==3,R=ye+8|0;t:for(;;){if(w=Ct(p|0,_|0,52)|0,X()|0,w=w&15,(w|0)==(A[Pe>>2]|0)){switch(W&15){case 0:case 2:case 3:{if(y=Dl(p,_,ve)|0,y|0){ze=15;break t}if(Ca(A[je>>2]|0,A[_e>>2]|0,ve)|0){ze=19;break t}break}}if(B&&(y=A[(A[je>>2]|0)+4>>2]|0,A[ve>>2]=A[y>>2],A[ve+4>>2]=A[y+4>>2],A[ve+8>>2]=A[y+8>>2],A[ve+12>>2]=A[y+12>>2],Do(26832,ve)|0)){if(Ed(A[(A[je>>2]|0)+4>>2]|0,w,ye)|0){ze=25;break}if(y=ye,(A[y>>2]|0)==(p|0)&&(A[y+4>>2]|0)==(_|0)){ze=29;break}}if(F){if(y=Pl(p,_,ve)|0,y|0){ze=32;break}if(Ld(p,_,ye,0)|0){ze=36;break}if(M&&Uo(A[je>>2]|0,A[_e>>2]|0,ve,ye)|0){ze=42;break}if(B&&Bd(A[je>>2]|0,A[_e>>2]|0,ve,ye)|0){ze=42;break}}if(se){if(f=Ld(p,_,ve,1)|0,y=A[_e>>2]|0,f|0){ze=45;break}if(Kh(y,ve)|0){if(Zh(ye,ve),J0(ve,A[_e>>2]|0)|0){ze=53;break}if(Ca(A[je>>2]|0,A[_e>>2]|0,R)|0){ze=53;break}if(Bd(A[je>>2]|0,A[_e>>2]|0,ye,ve)|0){ze=53;break}}}}do if((w|0)<(A[Pe>>2]|0)){if(f=Ld(p,_,ve,1)|0,y=A[_e>>2]|0,f|0){ze=58;break t}if(!(Kh(y,ve)|0)){ze=73;break}if(J0(A[_e>>2]|0,ve)|0&&(Zh(ye,ve),Uo(A[je>>2]|0,A[_e>>2]|0,ye,ve)|0)){ze=65;break t}if(p=Md(p,_,w+1|0,ye)|0,p|0){ze=67;break t}_=ye,p=A[_>>2]|0,_=A[_+4>>2]|0}else ze=73;while(!1);if((ze|0)==73&&(ze=0,p=Vu(p,_)|0,_=X()|0),(p|0)==0&(_|0)==0){nt=_e;break e}}switch(ze|0){case 15:{f=A[_e>>2]|0,f|0&&vn(f),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=y,ze=20;break}case 19:{A[d>>2]=p,A[d+4>>2]=_,ze=20;break}case 25:{tt(27795,27761,470,27772);break}case 29:{A[d>>2]=p,A[d+4>>2]=_,K=Le;return}case 32:{f=A[_e>>2]|0,f|0&&vn(f),nt=d,A[nt>>2]=0,A[nt+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=y,K=Le;return}case 36:{tt(27795,27761,493,27772);break}case 42:{A[d>>2]=p,A[d+4>>2]=_,K=Le;return}case 45:{y|0&&vn(y),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=f,ze=55;break}case 53:{A[d>>2]=p,A[d+4>>2]=_,ze=55;break}case 58:{y|0&&vn(y),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=f,ze=71;break}case 65:{A[d>>2]=p,A[d+4>>2]=_,ze=71;break}case 67:{f=A[_e>>2]|0,f|0&&vn(f),nt=d,A[nt>>2]=0,A[nt+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=p,K=Le;return}}if((ze|0)==20){K=Le;return}else if((ze|0)==55){K=Le;return}else if((ze|0)==71){K=Le;return}}while(!1);f=A[nt>>2]|0,f|0&&vn(f),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[d+8>>2]=0,A[je>>2]=0,A[d+12>>2]=-1,A[Xe>>2]=0,A[nt>>2]=0,K=Le}function Vu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0;se=K,K=K+16|0,W=se,_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0;do if(_){for(;p=It(_+4095|0,0,52)|0,y=X()|0|f&-15728641,w=(15-_|0)*3|0,M=It(7,0,w|0)|0,R=X()|0,p=p|d|M,y=y|R,B=Ct(d|0,f|0,w|0)|0,X()|0,B=B&7,_=_+-1|0,!(B>>>0<6);)if(_)f=y,d=p;else{F=4;break}if((F|0)==4){p=Ct(p|0,y|0,45)|0,X()|0;break}return W=(B|0)==0&(wi(p,y)|0)!=0,W=It((W?2:1)+B|0,0,w|0)|0,F=X()|0|f&~R,W=W|d&~M,he(F|0),K=se,W|0}while(!1);return p=p&127,p>>>0>120?(F=0,W=0,he(F|0),K=se,W|0):(Pu(W,0,p+1|0,0),F=A[W+4>>2]|0,W=A[W>>2]|0,he(F|0),K=se,W|0)}function Ud(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0;ze=K,K=K+160|0,se=ze+80|0,R=ze+64|0,_e=ze+112|0,Pe=ze,Ta(se,d,f,p),F=se,nl(R,A[F>>2]|0,A[F+4>>2]|0,f),F=R,B=A[F>>2]|0,F=A[F+4>>2]|0,M=A[se+8>>2]|0,ve=_e+4|0,A[ve>>2]=A[se>>2],A[ve+4>>2]=A[se+4>>2],A[ve+8>>2]=A[se+8>>2],A[ve+12>>2]=A[se+12>>2],A[ve+16>>2]=A[se+16>>2],A[ve+20>>2]=A[se+20>>2],A[ve+24>>2]=A[se+24>>2],A[ve+28>>2]=A[se+28>>2],ve=Pe,A[ve>>2]=B,A[ve+4>>2]=F,ve=Pe+8|0,A[ve>>2]=M,d=Pe+12|0,f=_e,p=d+36|0;do A[d>>2]=A[f>>2],d=d+4|0,f=f+4|0;while((d|0)<(p|0));if(_e=Pe+48|0,A[_e>>2]=A[R>>2],A[_e+4>>2]=A[R+4>>2],A[_e+8>>2]=A[R+8>>2],A[_e+12>>2]=A[R+12>>2],(B|0)==0&(F|0)==0)return Pe=M,K=ze,Pe|0;p=Pe+16|0,W=Pe+24|0,se=Pe+28|0,M=0,R=0,f=B,d=F;do{if(!((M|0)<(y|0)|(M|0)==(y|0)&R>>>0<_>>>0)){ye=4;break}if(F=R,R=tn(R|0,M|0,1,0)|0,M=X()|0,F=w+(F<<3)|0,A[F>>2]=f,A[F+4>>2]=d,rf(_e),d=_e,f=A[d>>2]|0,d=A[d+4>>2]|0,(f|0)==0&(d|0)==0){if(il(p),f=p,d=A[f>>2]|0,f=A[f+4>>2]|0,(d|0)==0&(f|0)==0){ye=10;break}Fu(d,f,A[se>>2]|0,_e),d=_e,f=A[d>>2]|0,d=A[d+4>>2]|0}F=Pe,A[F>>2]=f,A[F+4>>2]=d}while(!((f|0)==0&(d|0)==0));return(ye|0)==4?(d=Pe+40|0,f=A[d>>2]|0,f|0&&vn(f),ye=Pe+16|0,A[ye>>2]=0,A[ye+4>>2]=0,A[W>>2]=0,A[Pe+36>>2]=0,A[se>>2]=-1,A[Pe+32>>2]=0,A[d>>2]=0,Fu(0,0,0,_e),A[Pe>>2]=0,A[Pe+4>>2]=0,A[ve>>2]=0,Pe=14,K=ze,Pe|0):((ye|0)==10&&(A[Pe>>2]=0,A[Pe+4>>2]=0,A[ve>>2]=A[W>>2]),Pe=A[ve>>2]|0,K=ze,Pe|0)}function sf(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0;if(se=K,K=K+48|0,B=se+32|0,R=se+40|0,F=se,!(A[d>>2]|0))return W=_,A[W>>2]=0,A[W+4>>2]=0,W=0,K=se,W|0;Pu(B,0,0,0),M=B,y=A[M>>2]|0,M=A[M+4>>2]|0;do if(f>>>0>15)W=F,A[W>>2]=0,A[W+4>>2]=0,A[F+8>>2]=4,A[F+12>>2]=-1,W=F+16|0,p=F+29|0,A[W>>2]=0,A[W+4>>2]=0,A[W+8>>2]=0,xt[W+12>>0]=0,xt[p>>0]=xt[R>>0]|0,xt[p+1>>0]=xt[R+1>>0]|0,xt[p+2>>0]=xt[R+2>>0]|0,p=4,W=9;else{if(p=Ma(p)|0,p|0){B=F,A[B>>2]=0,A[B+4>>2]=0,A[F+8>>2]=p,A[F+12>>2]=-1,B=F+16|0,W=F+29|0,A[B>>2]=0,A[B+4>>2]=0,A[B+8>>2]=0,xt[B+12>>0]=0,xt[W>>0]=xt[R>>0]|0,xt[W+1>>0]=xt[R+1>>0]|0,xt[W+2>>0]=xt[R+2>>0]|0,W=9;break}if(p=Ys((A[d+8>>2]|0)+1|0,32)|0,!p){W=F,A[W>>2]=0,A[W+4>>2]=0,A[F+8>>2]=13,A[F+12>>2]=-1,W=F+16|0,p=F+29|0,A[W>>2]=0,A[W+4>>2]=0,A[W+8>>2]=0,xt[W+12>>0]=0,xt[p>>0]=xt[R>>0]|0,xt[p+1>>0]=xt[R+1>>0]|0,xt[p+2>>0]=xt[R+2>>0]|0,p=13,W=9;break}Ea(d,p),ve=F,A[ve>>2]=y,A[ve+4>>2]=M,M=F+8|0,A[M>>2]=0,A[F+12>>2]=f,A[F+20>>2]=d,A[F+24>>2]=p,xt[F+28>>0]=0,y=F+29|0,xt[y>>0]=xt[R>>0]|0,xt[y+1>>0]=xt[R+1>>0]|0,xt[y+2>>0]=xt[R+2>>0]|0,A[F+16>>2]=3,_e=+Qh(p),_e=_e*+el(p),w=+dn(+ +ee[p>>3]),w=_e/+an(+ +uf(+w,+ +dn(+ +ee[p+8>>3])))*6371.007180918475*6371.007180918475,y=F+12|0,p=A[y>>2]|0;e:do if((p|0)>0)do{if(hp(p+-1|0,B)|0,!(w/+ee[B>>3]>10))break e;ve=A[y>>2]|0,p=ve+-1|0,A[y>>2]=p}while((ve|0)>1);while(!1);if(il(F),y=_,A[y>>2]=0,A[y+4>>2]=0,y=F,p=A[y>>2]|0,y=A[y+4>>2]|0,!((p|0)==0&(y|0)==0))do nf(p,y,f,B)|0,R=B,d=_,R=tn(A[d>>2]|0,A[d+4>>2]|0,A[R>>2]|0,A[R+4>>2]|0)|0,d=X()|0,ve=_,A[ve>>2]=R,A[ve+4>>2]=d,il(F),ve=F,p=A[ve>>2]|0,y=A[ve+4>>2]|0;while(!((p|0)==0&(y|0)==0));p=A[M>>2]|0}while(!1);return ve=p,K=se,ve|0}function Ss(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;if(!(Do(f,p)|0)||(f=_d(f)|0,_=+ee[p>>3],y=+ee[p+8>>3],y=f&y<0?y+6.283185307179586:y,_e=A[d>>2]|0,(_e|0)<=0))return _e=0,_e|0;if(se=A[d+4>>2]|0,f){f=0,W=y,p=-1,d=0;e:for(;;){for(F=d;M=+ee[se+(F<<4)>>3],y=+ee[se+(F<<4)+8>>3],d=(p+2|0)%(_e|0)|0,w=+ee[se+(d<<4)>>3],R=+ee[se+(d<<4)+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(_e|0)){p=22;break e}else d=F,F=p,p=d;if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,W=R==W|M==W?W+-2220446049250313e-31:W,B=R+(M-R)*((_-w)/(B-w)),(B<0?B+6.283185307179586:B)>W&&(f=f^1),d=F+1|0,(d|0)>=(_e|0)){p=22;break}else p=F}if((p|0)==22)return f|0}else{f=0,W=y,p=-1,d=0;e:for(;;){for(F=d;M=+ee[se+(F<<4)>>3],y=+ee[se+(F<<4)+8>>3],d=(p+2|0)%(_e|0)|0,w=+ee[se+(d<<4)>>3],R=+ee[se+(d<<4)+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(_e|0)){p=22;break e}else d=F,F=p,p=d;if(W=M==W|y==W?W+-2220446049250313e-31:W,M+(y-M)*((_-w)/(B-w))>W&&(f=f^1),d=F+1|0,(d|0)>=(_e|0)){p=22;break}else p=F}if((p|0)==22)return f|0}return 0}function da(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0;if(ye=A[d>>2]|0,!ye){A[f>>2]=0,A[f+4>>2]=0,A[f+8>>2]=0,A[f+12>>2]=0,A[f+16>>2]=0,A[f+20>>2]=0,A[f+24>>2]=0,A[f+28>>2]=0;return}if(Pe=f+8|0,ee[Pe>>3]=17976931348623157e292,ze=f+24|0,ee[ze>>3]=17976931348623157e292,ee[f>>3]=-17976931348623157e292,nt=f+16|0,ee[nt>>3]=-17976931348623157e292,!((ye|0)<=0)){for(_e=A[d+4>>2]|0,F=17976931348623157e292,W=-17976931348623157e292,se=0,d=-1,w=17976931348623157e292,M=17976931348623157e292,B=-17976931348623157e292,_=-17976931348623157e292,ve=0;p=+ee[_e+(ve<<4)>>3],R=+ee[_e+(ve<<4)+8>>3],d=d+2|0,y=+ee[_e+(((d|0)==(ye|0)?0:d)<<4)+8>>3],p>3]=p,w=p),R>3]=R,M=R),p>B?ee[f>>3]=p:p=B,R>_&&(ee[nt>>3]=R,_=R),F=R>0&RW?R:W,se=se|+dn(+(R-y))>3.141592653589793,d=ve+1|0,(d|0)!=(ye|0);)Xe=ve,B=p,ve=d,d=Xe;se&&(ee[nt>>3]=W,ee[ze>>3]=F)}}function Ma(d){return d=d|0,(d>>>0<4?0:15)|0}function Ea(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0;if(ye=A[d>>2]|0,ye){if(Pe=f+8|0,ee[Pe>>3]=17976931348623157e292,ze=f+24|0,ee[ze>>3]=17976931348623157e292,ee[f>>3]=-17976931348623157e292,nt=f+16|0,ee[nt>>3]=-17976931348623157e292,(ye|0)>0){for(y=A[d+4>>2]|0,_e=17976931348623157e292,ve=-17976931348623157e292,_=0,p=-1,B=17976931348623157e292,F=17976931348623157e292,se=-17976931348623157e292,M=-17976931348623157e292,Xe=0;w=+ee[y+(Xe<<4)>>3],W=+ee[y+(Xe<<4)+8>>3],un=p+2|0,R=+ee[y+(((un|0)==(ye|0)?0:un)<<4)+8>>3],w>3]=w,B=w),W>3]=W,F=W),w>se?ee[f>>3]=w:w=se,W>M&&(ee[nt>>3]=W,M=W),_e=W>0&W<_e?W:_e,ve=W<0&W>ve?W:ve,_=_|+dn(+(W-R))>3.141592653589793,p=Xe+1|0,(p|0)!=(ye|0);)un=Xe,se=w,Xe=p,p=un;_&&(ee[nt>>3]=ve,ee[ze>>3]=_e)}}else A[f>>2]=0,A[f+4>>2]=0,A[f+8>>2]=0,A[f+12>>2]=0,A[f+16>>2]=0,A[f+20>>2]=0,A[f+24>>2]=0,A[f+28>>2]=0;if(un=d+8|0,p=A[un>>2]|0,!((p|0)<=0)){Ft=d+12|0,Le=0;do if(y=A[Ft>>2]|0,_=Le,Le=Le+1|0,ze=f+(Le<<5)|0,nt=A[y+(_<<3)>>2]|0,nt){if(Xe=f+(Le<<5)+8|0,ee[Xe>>3]=17976931348623157e292,d=f+(Le<<5)+24|0,ee[d>>3]=17976931348623157e292,ee[ze>>3]=-17976931348623157e292,je=f+(Le<<5)+16|0,ee[je>>3]=-17976931348623157e292,(nt|0)>0){for(ye=A[y+(_<<3)+4>>2]|0,_e=17976931348623157e292,ve=-17976931348623157e292,y=0,_=-1,Pe=0,B=17976931348623157e292,F=17976931348623157e292,W=-17976931348623157e292,M=-17976931348623157e292;w=+ee[ye+(Pe<<4)>>3],se=+ee[ye+(Pe<<4)+8>>3],_=_+2|0,R=+ee[ye+(((_|0)==(nt|0)?0:_)<<4)+8>>3],w>3]=w,B=w),se>3]=se,F=se),w>W?ee[ze>>3]=w:w=W,se>M&&(ee[je>>3]=se,M=se),_e=se>0&se<_e?se:_e,ve=se<0&se>ve?se:ve,y=y|+dn(+(se-R))>3.141592653589793,_=Pe+1|0,(_|0)!=(nt|0);)on=Pe,Pe=_,W=w,_=on;y&&(ee[je>>3]=ve,ee[d>>3]=_e)}}else A[ze>>2]=0,A[ze+4>>2]=0,A[ze+8>>2]=0,A[ze+12>>2]=0,A[ze+16>>2]=0,A[ze+20>>2]=0,A[ze+24>>2]=0,A[ze+28>>2]=0,p=A[un>>2]|0;while((Le|0)<(p|0))}}function Ca(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(!(Ss(d,f,p)|0))return y=0,y|0;if(y=d+8|0,(A[y>>2]|0)<=0)return y=1,y|0;for(_=d+12|0,d=0;;){if(w=d,d=d+1|0,Ss((A[_>>2]|0)+(w<<3)|0,f+(d<<5)|0,p)|0){d=0,_=6;break}if((d|0)>=(A[y>>2]|0)){d=1,_=6;break}}return(_|0)==6?d|0:0}function Uo(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(F=K,K=K+16|0,R=F,M=p+8|0,!(Ss(d,f,M)|0))return B=0,K=F,B|0;B=d+8|0;e:do if((A[B>>2]|0)>0){for(w=d+12|0,y=0;;){if(W=y,y=y+1|0,Ss((A[w>>2]|0)+(W<<3)|0,f+(y<<5)|0,M)|0){y=0;break}if((y|0)>=(A[B>>2]|0))break e}return K=F,y|0}while(!1);if(af(d,f,p,_)|0)return W=0,K=F,W|0;A[R>>2]=A[p>>2],A[R+4>>2]=M,y=A[B>>2]|0;e:do if((y|0)>0)for(d=d+12|0,M=0,w=y;;){if(y=A[d>>2]|0,(A[y+(M<<3)>>2]|0)>0){if(Ss(R,_,A[y+(M<<3)+4>>2]|0)|0){y=0;break e}if(y=M+1|0,af((A[d>>2]|0)+(M<<3)|0,f+(y<<5)|0,p,_)|0){y=0;break e}w=A[B>>2]|0}else y=M+1|0;if((y|0)<(w|0))M=y;else{y=1;break}}else y=1;while(!1);return W=y,K=F,W|0}function af(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0;if(un=K,K=K+176|0,Xe=un+172|0,y=un+168|0,je=un,!(Kh(f,_)|0))return d=0,K=un,d|0;if(yd(f,_,Xe,y),Ol(je|0,p|0,168)|0,(A[p>>2]|0)>0){f=0;do on=je+8+(f<<4)+8|0,nt=+Ws(+ee[on>>3],A[y>>2]|0),ee[on>>3]=nt,f=f+1|0;while((f|0)<(A[p>>2]|0))}Pe=+ee[_>>3],ze=+ee[_+8>>3],nt=+Ws(+ee[_+16>>3],A[y>>2]|0),ve=+Ws(+ee[_+24>>3],A[y>>2]|0);e:do if((A[d>>2]|0)>0){if(_=d+4|0,y=A[je>>2]|0,(y|0)<=0){for(f=0;;)if(f=f+1|0,(f|0)>=(A[d>>2]|0)){f=0;break e}}for(p=0;;){if(f=A[_>>2]|0,_e=+ee[f+(p<<4)>>3],ye=+Ws(+ee[f+(p<<4)+8>>3],A[Xe>>2]|0),f=A[_>>2]|0,p=p+1|0,on=(p|0)%(A[d>>2]|0)|0,w=+ee[f+(on<<4)>>3],M=+Ws(+ee[f+(on<<4)+8>>3],A[Xe>>2]|0),!(_e>=Pe)|!(w>=Pe)&&!(_e<=ze)|!(w<=ze)&&!(ye<=ve)|!(M<=ve)&&!(ye>=nt)|!(M>=nt)){se=w-_e,F=M-ye,f=0;do if(kn=f,f=f+1|0,on=(f|0)==(y|0)?0:f,w=+ee[je+8+(kn<<4)+8>>3],M=+ee[je+8+(on<<4)+8>>3]-w,R=+ee[je+8+(kn<<4)>>3],B=+ee[je+8+(on<<4)>>3]-R,W=se*M-F*B,W!=0&&(Le=ye-w,Ft=_e-R,B=(Le*B-M*Ft)/W,!(B<0|B>1))&&(W=(se*Le-F*Ft)/W,W>=0&W<=1)){f=1;break e}while((f|0)<(y|0))}if((p|0)>=(A[d>>2]|0)){f=0;break}}}else f=0;while(!1);return kn=f,K=un,kn|0}function Bd(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if(af(d,f,p,_)|0)return w=1,w|0;if(w=d+8|0,(A[w>>2]|0)<=0)return w=0,w|0;for(y=d+12|0,d=0;;){if(M=d,d=d+1|0,af((A[y>>2]|0)+(M<<3)|0,f+(d<<5)|0,p,_)|0){d=1,y=6;break}if((d|0)>=(A[w>>2]|0)){d=0,y=6;break}}return(y|0)==6?d|0:0}function mp(){return 8}function C1(){return 16}function cs(){return 168}function er(){return 8}function Ai(){return 16}function Ul(){return 12}function Na(){return 8}function gp(d){return d=d|0,+(+((A[d>>2]|0)>>>0)+4294967296*+(A[d+4>>2]|0))}function Bl(d){d=d|0;var f=0,p=0;return p=+ee[d>>3],f=+ee[d+8>>3],+ +Fn(+(p*p+f*f))}function vp(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;F=+ee[d>>3],B=+ee[f>>3]-F,R=+ee[d+8>>3],M=+ee[f+8>>3]-R,se=+ee[p>>3],w=+ee[_>>3]-se,_e=+ee[p+8>>3],W=+ee[_+8>>3]-_e,w=(w*(R-_e)-(F-se)*W)/(B*W-M*w),ee[y>>3]=F+B*w,ee[y+8>>3]=R+M*w}function _p(d,f){return d=d|0,f=f|0,+dn(+(+ee[d>>3]-+ee[f>>3]))<11920928955078125e-23?(f=+dn(+(+ee[d+8>>3]-+ee[f+8>>3]))<11920928955078125e-23,f|0):(f=0,f|0)}function tr(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;return y=+ee[d>>3]-+ee[f>>3],_=+ee[d+8>>3]-+ee[f+8>>3],p=+ee[d+16>>3]-+ee[f+16>>3],+(y*y+_*_+p*p)}function ju(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;p=+ee[d>>3],_=+an(+p),p=+mn(+p),ee[f+16>>3]=p,p=+ee[d+8>>3],y=_*+an(+p),ee[f>>3]=y,p=_*+mn(+p),ee[f+8>>3]=p}function yp(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(w=K,K=K+16|0,y=w,_=wi(d,f)|0,(p+-1|0)>>>0>5||(_=(_|0)!=0,(p|0)==1&_))return y=-1,K=w,y|0;do if(rl(d,f,y)|0)_=-1;else if(_){_=((A[26352+(p<<2)>>2]|0)+5-(A[y>>2]|0)|0)%5|0;break}else{_=((A[26384+(p<<2)>>2]|0)+6-(A[y>>2]|0)|0)%6|0;break}while(!1);return y=_,K=w,y|0}function rl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+32|0,R=W+16|0,B=W,_=Bu(d,f,R)|0,_|0)return p=_,K=W,p|0;w=m1(d,f)|0,F=Hs(d,f)|0,Z0(w,B),_=Vc(w,A[R>>2]|0)|0;do if(Ji(w)|0){do switch(w|0){case 4:{y=0;break}case 14:{y=1;break}case 24:{y=2;break}case 38:{y=3;break}case 49:{y=4;break}case 58:{y=5;break}case 63:{y=6;break}case 72:{y=7;break}case 83:{y=8;break}case 97:{y=9;break}case 107:{y=10;break}case 117:{y=11;break}default:tt(27795,27797,75,27806)}while(!1);if(M=A[26416+(y*24|0)+8>>2]|0,f=A[26416+(y*24|0)+16>>2]|0,d=A[R>>2]|0,(d|0)!=(A[B>>2]|0)&&(B=qc(w)|0,d=A[R>>2]|0,B|(d|0)==(f|0)&&(_=(_+1|0)%6|0)),(F|0)==3&(d|0)==(f|0)){_=(_+5|0)%6|0;break}(F|0)==5&(d|0)==(M|0)&&(_=(_+1|0)%6|0)}while(!1);return A[p>>2]=_,p=0,K=W,p|0}function Xs(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0;if(je=K,K=K+32|0,Xe=je+24|0,ze=je+20|0,ye=je+8|0,ve=je+16|0,_e=je,B=(wi(d,f)|0)==0,B=B?6:5,W=Ct(d|0,f|0,52)|0,X()|0,W=W&15,B>>>0<=p>>>0)return _=2,K=je,_|0;se=(W|0)==0,!se&&(Pe=It(7,0,(W^15)*3|0)|0,(Pe&d|0)==0&((X()|0)&f|0)==0)?y=p:w=4;e:do if((w|0)==4){if(y=(wi(d,f)|0)!=0,((y?4:5)|0)<(p|0)||rl(d,f,Xe)|0||(w=(A[Xe>>2]|0)+p|0,y?y=26704+(((w|0)%5|0)<<2)|0:y=26736+(((w|0)%6|0)<<2)|0,Pe=A[y>>2]|0,(Pe|0)==7))return _=1,K=je,_|0;A[ze>>2]=0,y=bi(d,f,Pe,ze,ye)|0;do if(!y){if(R=ye,F=A[R>>2]|0,R=A[R+4>>2]|0,M=R>>>0>>0|(R|0)==(f|0)&F>>>0>>0,w=M?F:d,M=M?R:f,!se&&(se=It(7,0,(W^15)*3|0)|0,(F&se|0)==0&(R&(X()|0)|0)==0))y=p;else{if(R=(p+-1+B|0)%(B|0)|0,y=wi(d,f)|0,(R|0)<0&&tt(27795,27797,248,27822),B=(y|0)!=0,((B?4:5)|0)<(R|0)&&tt(27795,27797,248,27822),rl(d,f,Xe)|0&&tt(27795,27797,248,27822),y=(A[Xe>>2]|0)+R|0,B?y=26704+(((y|0)%5|0)<<2)|0:y=26736+(((y|0)%6|0)<<2)|0,R=A[y>>2]|0,(R|0)==7&&tt(27795,27797,248,27822),A[ve>>2]=0,y=bi(d,f,R,ve,_e)|0,y|0)break;F=_e,B=A[F>>2]|0,F=A[F+4>>2]|0;do if(F>>>0>>0|(F|0)==(M|0)&B>>>0>>0){if(wi(B,F)|0?w=xs(B,F,d,f)|0:w=A[26800+((((A[ve>>2]|0)+(A[26768+(R<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=wi(B,F)|0,(w+-1|0)>>>0>5){y=-1,w=B,M=F;break}if(y=(y|0)!=0,(w|0)==1&y){y=-1,w=B,M=F;break}do if(rl(B,F,Xe)|0)y=-1;else if(y){y=((A[26352+(w<<2)>>2]|0)+5-(A[Xe>>2]|0)|0)%5|0;break}else{y=((A[26384+(w<<2)>>2]|0)+6-(A[Xe>>2]|0)|0)%6|0;break}while(!1);w=B,M=F}else y=p;while(!1);R=ye,F=A[R>>2]|0,R=A[R+4>>2]|0}if((w|0)==(F|0)&(M|0)==(R|0)){if(B=(wi(F,R)|0)!=0,B?d=xs(F,R,d,f)|0:d=A[26800+((((A[ze>>2]|0)+(A[26768+(Pe<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=wi(F,R)|0,(d+-1|0)>>>0<=5&&(nt=(y|0)!=0,!((d|0)==1&nt)))do if(rl(F,R,Xe)|0)y=-1;else if(nt){y=((A[26352+(d<<2)>>2]|0)+5-(A[Xe>>2]|0)|0)%5|0;break}else{y=((A[26384+(d<<2)>>2]|0)+6-(A[Xe>>2]|0)|0)%6|0;break}while(!1);else y=-1;y=y+1|0,y=(y|0)==6|B&(y|0)==5?0:y}f=M,d=w;break e}while(!1);return _=y,K=je,_|0}while(!1);return nt=It(y|0,0,56)|0,Xe=X()|0|f&-2130706433|536870912,A[_>>2]=nt|d,A[_+4>>2]=Xe,_=0,K=je,_|0}function Hu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return w=(wi(d,f)|0)==0,_=Xs(d,f,0,p)|0,y=(_|0)==0,w?!y||(_=Xs(d,f,1,p+8|0)|0,_|0)||(_=Xs(d,f,2,p+16|0)|0,_|0)||(_=Xs(d,f,3,p+24|0)|0,_|0)||(_=Xs(d,f,4,p+32|0)|0,_)?(w=_,w|0):Xs(d,f,5,p+40|0)|0:!y||(_=Xs(d,f,1,p+8|0)|0,_|0)||(_=Xs(d,f,2,p+16|0)|0,_|0)||(_=Xs(d,f,3,p+24|0)|0,_|0)||(_=Xs(d,f,4,p+32|0)|0,_|0)?(w=_,w|0):(w=p+40|0,A[w>>2]=0,A[w+4>>2]=0,w=0,w|0)}function sl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;return B=K,K=K+192|0,y=B,w=B+168|0,M=Ct(d|0,f|0,56)|0,X()|0,M=M&7,R=f&-2130706433|134217728,_=Bu(d,R,w)|0,_|0?(R=_,K=B,R|0):(f=Ct(d|0,f|0,52)|0,X()|0,f=f&15,wi(d,R)|0?np(w,f,M,1,y):wd(w,f,M,1,y),R=y+8|0,A[p>>2]=A[R>>2],A[p+4>>2]=A[R+4>>2],A[p+8>>2]=A[R+8>>2],A[p+12>>2]=A[R+12>>2],R=0,K=B,R|0)}function al(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=K,K=K+16|0,p=y,!(!0&(f&2013265920|0)==536870912)||(_=f&-2130706433|134217728,!(Td(d,_)|0))?(_=0,K=y,_|0):(w=Ct(d|0,f|0,56)|0,X()|0,w=(Xs(d,_,w&7,p)|0)==0,_=p,_=w&((A[_>>2]|0)==(d|0)?(A[_+4>>2]|0)==(f|0):0)&1,K=y,_|0)}function Bo(d,f,p){d=d|0,f=f|0,p=p|0;var _=0;(f|0)>0?(_=Ys(f,4)|0,A[d>>2]=_,_||tt(27835,27858,40,27872)):A[d>>2]=0,A[d+4>>2]=f,A[d+8>>2]=0,A[d+12>>2]=p}function Od(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=d+4|0,w=d+12|0,M=d+8|0;e:for(;;){for(p=A[y>>2]|0,f=0;;){if((f|0)>=(p|0))break e;if(_=A[d>>2]|0,R=A[_+(f<<2)>>2]|0,!R)f=f+1|0;else break}f=_+(~~(+dn(+(+lr(10,+ +(15-(A[w>>2]|0)|0))*(+ee[R>>3]+ +ee[R+8>>3])))%+(p|0))>>>0<<2)|0,p=A[f>>2]|0;t:do if(p|0){if(_=R+32|0,(p|0)==(R|0))A[f>>2]=A[_>>2];else{if(p=p+32|0,f=A[p>>2]|0,!f)break;for(;(f|0)!=(R|0);)if(p=f+32|0,f=A[p>>2]|0,!f)break t;A[p>>2]=A[_>>2]}vn(R),A[M>>2]=(A[M>>2]|0)+-1}while(!1)}vn(A[d>>2]|0)}function Id(d){d=d|0;var f=0,p=0,_=0;for(_=A[d+4>>2]|0,p=0;;){if((p|0)>=(_|0)){f=0,p=4;break}if(f=A[(A[d>>2]|0)+(p<<2)>>2]|0,!f)p=p+1|0;else{p=4;break}}return(p|0)==4?f|0:0}function Wu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;if(p=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+ee[f>>3]+ +ee[f+8>>3])))%+(A[d+4>>2]|0))>>>0,p=(A[d>>2]|0)+(p<<2)|0,_=A[p>>2]|0,!_)return w=1,w|0;w=f+32|0;do if((_|0)!=(f|0)){if(p=A[_+32>>2]|0,!p)return w=1,w|0;for(y=p;;){if((y|0)==(f|0)){y=8;break}if(p=A[y+32>>2]|0,p)_=y,y=p;else{p=1,y=10;break}}if((y|0)==8){A[_+32>>2]=A[w>>2];break}else if((y|0)==10)return p|0}else A[p>>2]=A[w>>2];while(!1);return vn(f),w=d+8|0,A[w>>2]=(A[w>>2]|0)+-1,w=0,w|0}function Fd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;w=Oo(40)|0,w||tt(27888,27858,98,27901),A[w>>2]=A[f>>2],A[w+4>>2]=A[f+4>>2],A[w+8>>2]=A[f+8>>2],A[w+12>>2]=A[f+12>>2],y=w+16|0,A[y>>2]=A[p>>2],A[y+4>>2]=A[p+4>>2],A[y+8>>2]=A[p+8>>2],A[y+12>>2]=A[p+12>>2],A[w+32>>2]=0,y=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+ee[f>>3]+ +ee[f+8>>3])))%+(A[d+4>>2]|0))>>>0,y=(A[d>>2]|0)+(y<<2)|0,_=A[y>>2]|0;do if(!_)A[y>>2]=w;else{for(;!(wa(_,f)|0&&wa(_+16|0,p)|0);)if(y=A[_+32>>2]|0,_=(y|0)==0?_:y,!(A[_+32>>2]|0)){M=10;break}if((M|0)==10){A[_+32>>2]=w;break}return vn(w),M=_,M|0}while(!1);return M=d+8|0,A[M>>2]=(A[M>>2]|0)+1,M=w,M|0}function $u(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;if(y=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+ee[f>>3]+ +ee[f+8>>3])))%+(A[d+4>>2]|0))>>>0,y=A[(A[d>>2]|0)+(y<<2)>>2]|0,!y)return p=0,p|0;if(!p){for(d=y;;){if(wa(d,f)|0){_=10;break}if(d=A[d+32>>2]|0,!d){d=0,_=10;break}}if((_|0)==10)return d|0}for(d=y;;){if(wa(d,f)|0&&wa(d+16|0,p)|0){_=10;break}if(d=A[d+32>>2]|0,!d){d=0,_=10;break}}return(_|0)==10?d|0:0}function hs(d,f){d=d|0,f=f|0;var p=0;if(p=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+ee[f>>3]+ +ee[f+8>>3])))%+(A[d+4>>2]|0))>>>0,d=A[(A[d>>2]|0)+(p<<2)>>2]|0,!d)return p=0,p|0;for(;;){if(wa(d,f)|0){f=5;break}if(d=A[d+32>>2]|0,!d){d=0,f=5;break}}return(f|0)==5?d|0:0}function kd(){return 27920}function ol(d){return d=+d,~~+cf(+d)|0}function Oo(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0;Ft=K,K=K+16|0,_e=Ft;do if(d>>>0<245){if(F=d>>>0<11?16:d+11&-8,d=F>>>3,se=A[6981]|0,p=se>>>d,p&3|0)return f=(p&1^1)+d|0,d=27964+(f<<1<<2)|0,p=d+8|0,_=A[p>>2]|0,y=_+8|0,w=A[y>>2]|0,(w|0)==(d|0)?A[6981]=se&~(1<>2]=d,A[p>>2]=w),Le=f<<3,A[_+4>>2]=Le|3,Le=_+Le+4|0,A[Le>>2]=A[Le>>2]|1,Le=y,K=Ft,Le|0;if(W=A[6983]|0,F>>>0>W>>>0){if(p|0)return f=2<>>12&16,f=f>>>R,p=f>>>5&8,f=f>>>p,w=f>>>2&4,f=f>>>w,d=f>>>1&2,f=f>>>d,_=f>>>1&1,_=(p|R|w|d|_)+(f>>>_)|0,f=27964+(_<<1<<2)|0,d=f+8|0,w=A[d>>2]|0,R=w+8|0,p=A[R>>2]|0,(p|0)==(f|0)?(d=se&~(1<<_),A[6981]=d):(A[p+12>>2]=f,A[d>>2]=p,d=se),Le=_<<3,M=Le-F|0,A[w+4>>2]=F|3,y=w+F|0,A[y+4>>2]=M|1,A[w+Le>>2]=M,W|0&&(_=A[6986]|0,f=W>>>3,p=27964+(f<<1<<2)|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=_,A[f+12>>2]=_,A[_+8>>2]=f,A[_+12>>2]=p),A[6983]=M,A[6986]=y,Le=R,K=Ft,Le|0;if(w=A[6982]|0,w){for(p=(w&0-w)+-1|0,y=p>>>12&16,p=p>>>y,_=p>>>5&8,p=p>>>_,M=p>>>2&4,p=p>>>M,R=p>>>1&2,p=p>>>R,B=p>>>1&1,B=A[28228+((_|y|M|R|B)+(p>>>B)<<2)>>2]|0,p=B,R=B,B=(A[B+4>>2]&-8)-F|0;d=A[p+16>>2]|0,!(!d&&(d=A[p+20>>2]|0,!d));)M=(A[d+4>>2]&-8)-F|0,y=M>>>0>>0,p=d,R=y?d:R,B=y?M:B;if(M=R+F|0,M>>>0>R>>>0){y=A[R+24>>2]|0,f=A[R+12>>2]|0;do if((f|0)==(R|0)){if(d=R+20|0,f=A[d>>2]|0,!f&&(d=R+16|0,f=A[d>>2]|0,!f)){p=0;break}for(;;)if(_=f+20|0,p=A[_>>2]|0,p)f=p,d=_;else if(_=f+16|0,p=A[_>>2]|0,p)f=p,d=_;else break;A[d>>2]=0,p=f}else p=A[R+8>>2]|0,A[p+12>>2]=f,A[f+8>>2]=p,p=f;while(!1);do if(y|0){if(f=A[R+28>>2]|0,d=28228+(f<<2)|0,(R|0)==(A[d>>2]|0)){if(A[d>>2]=p,!p){A[6982]=w&~(1<>2]|0)==(R|0)?Le:y+20|0)>>2]=p,!p)break;A[p+24>>2]=y,f=A[R+16>>2]|0,f|0&&(A[p+16>>2]=f,A[f+24>>2]=p),f=A[R+20>>2]|0,f|0&&(A[p+20>>2]=f,A[f+24>>2]=p)}while(!1);return B>>>0<16?(Le=B+F|0,A[R+4>>2]=Le|3,Le=R+Le+4|0,A[Le>>2]=A[Le>>2]|1):(A[R+4>>2]=F|3,A[M+4>>2]=B|1,A[M+B>>2]=B,W|0&&(_=A[6986]|0,f=W>>>3,p=27964+(f<<1<<2)|0,f=1<>2]|0):(A[6981]=f|se,f=p,d=p+8|0),A[d>>2]=_,A[f+12>>2]=_,A[_+8>>2]=f,A[_+12>>2]=p),A[6983]=B,A[6986]=M),Le=R+8|0,K=Ft,Le|0}else se=F}else se=F}else se=F}else if(d>>>0<=4294967231)if(d=d+11|0,F=d&-8,_=A[6982]|0,_){y=0-F|0,d=d>>>8,d?F>>>0>16777215?B=31:(se=(d+1048320|0)>>>16&8,Pe=d<>>16&4,Pe=Pe<>>16&2,B=14-(R|se|B)+(Pe<>>15)|0,B=F>>>(B+7|0)&1|B<<1):B=0,p=A[28228+(B<<2)>>2]|0;e:do if(!p)p=0,d=0,Pe=61;else for(d=0,R=F<<((B|0)==31?0:25-(B>>>1)|0),w=0;;){if(M=(A[p+4>>2]&-8)-F|0,M>>>0>>0)if(M)d=p,y=M;else{d=p,y=0,Pe=65;break e}if(Pe=A[p+20>>2]|0,p=A[p+16+(R>>>31<<2)>>2]|0,w=(Pe|0)==0|(Pe|0)==(p|0)?w:Pe,p)R=R<<1;else{p=w,Pe=61;break}}while(!1);if((Pe|0)==61){if((p|0)==0&(d|0)==0){if(d=2<>>12&16,se=se>>>M,w=se>>>5&8,se=se>>>w,R=se>>>2&4,se=se>>>R,B=se>>>1&2,se=se>>>B,p=se>>>1&1,d=0,p=A[28228+((w|M|R|B|p)+(se>>>p)<<2)>>2]|0}p?Pe=65:(R=d,M=y)}if((Pe|0)==65)for(w=p;;)if(se=(A[w+4>>2]&-8)-F|0,p=se>>>0>>0,y=p?se:y,d=p?w:d,p=A[w+16>>2]|0,p||(p=A[w+20>>2]|0),p)w=p;else{R=d,M=y;break}if((R|0)!=0&&M>>>0<((A[6983]|0)-F|0)>>>0&&(W=R+F|0,W>>>0>R>>>0)){w=A[R+24>>2]|0,f=A[R+12>>2]|0;do if((f|0)==(R|0)){if(d=R+20|0,f=A[d>>2]|0,!f&&(d=R+16|0,f=A[d>>2]|0,!f)){f=0;break}for(;;)if(y=f+20|0,p=A[y>>2]|0,p)f=p,d=y;else if(y=f+16|0,p=A[y>>2]|0,p)f=p,d=y;else break;A[d>>2]=0}else Le=A[R+8>>2]|0,A[Le+12>>2]=f,A[f+8>>2]=Le;while(!1);do if(w){if(d=A[R+28>>2]|0,p=28228+(d<<2)|0,(R|0)==(A[p>>2]|0)){if(A[p>>2]=f,!f){_=_&~(1<>2]|0)==(R|0)?Le:w+20|0)>>2]=f,!f)break;A[f+24>>2]=w,d=A[R+16>>2]|0,d|0&&(A[f+16>>2]=d,A[d+24>>2]=f),d=A[R+20>>2]|0,d&&(A[f+20>>2]=d,A[d+24>>2]=f)}while(!1);e:do if(M>>>0<16)Le=M+F|0,A[R+4>>2]=Le|3,Le=R+Le+4|0,A[Le>>2]=A[Le>>2]|1;else{if(A[R+4>>2]=F|3,A[W+4>>2]=M|1,A[W+M>>2]=M,f=M>>>3,M>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=W,A[f+12>>2]=W,A[W+8>>2]=f,A[W+12>>2]=p;break}if(f=M>>>8,f?M>>>0>16777215?p=31:(je=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,p=14-(Xe|je|p)+(Le<

>>15)|0,p=M>>>(p+7|0)&1|p<<1):p=0,f=28228+(p<<2)|0,A[W+28>>2]=p,d=W+16|0,A[d+4>>2]=0,A[d>>2]=0,d=1<>2]=W,A[W+24>>2]=f,A[W+12>>2]=W,A[W+8>>2]=W;break}f=A[f>>2]|0;t:do if((A[f+4>>2]&-8|0)!=(M|0)){for(_=M<<((p|0)==31?0:25-(p>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(M|0)){f=d;break t}else _=_<<1,f=d;A[p>>2]=W,A[W+24>>2]=f,A[W+12>>2]=W,A[W+8>>2]=W;break e}while(!1);je=f+8|0,Le=A[je>>2]|0,A[Le+12>>2]=W,A[je>>2]=W,A[W+8>>2]=Le,A[W+12>>2]=f,A[W+24>>2]=0}while(!1);return Le=R+8|0,K=Ft,Le|0}else se=F}else se=F;else se=-1;while(!1);if(p=A[6983]|0,p>>>0>=se>>>0)return f=p-se|0,d=A[6986]|0,f>>>0>15?(Le=d+se|0,A[6986]=Le,A[6983]=f,A[Le+4>>2]=f|1,A[d+p>>2]=f,A[d+4>>2]=se|3):(A[6983]=0,A[6986]=0,A[d+4>>2]=p|3,Le=d+p+4|0,A[Le>>2]=A[Le>>2]|1),Le=d+8|0,K=Ft,Le|0;if(M=A[6984]|0,M>>>0>se>>>0)return Xe=M-se|0,A[6984]=Xe,Le=A[6987]|0,je=Le+se|0,A[6987]=je,A[je+4>>2]=Xe|1,A[Le+4>>2]=se|3,Le=Le+8|0,K=Ft,Le|0;if(A[7099]|0?d=A[7101]|0:(A[7101]=4096,A[7100]=4096,A[7102]=-1,A[7103]=-1,A[7104]=0,A[7092]=0,A[7099]=_e&-16^1431655768,d=4096),R=se+48|0,B=se+47|0,w=d+B|0,y=0-d|0,F=w&y,F>>>0<=se>>>0||(d=A[7091]|0,d|0&&(W=A[7089]|0,_e=W+F|0,_e>>>0<=W>>>0|_e>>>0>d>>>0)))return Le=0,K=Ft,Le|0;e:do if(A[7092]&4)f=0,Pe=143;else{p=A[6987]|0;t:do if(p){for(_=28372;_e=A[_>>2]|0,!(_e>>>0<=p>>>0&&(_e+(A[_+4>>2]|0)|0)>>>0>p>>>0);)if(d=A[_+8>>2]|0,d)_=d;else{Pe=128;break t}if(f=w-M&y,f>>>0<2147483647)if(d=ul(f|0)|0,(d|0)==((A[_>>2]|0)+(A[_+4>>2]|0)|0)){if((d|0)!=-1){M=f,w=d,Pe=145;break e}}else _=d,Pe=136;else f=0}else Pe=128;while(!1);do if((Pe|0)==128)if(p=ul(0)|0,(p|0)!=-1&&(f=p,ve=A[7100]|0,ye=ve+-1|0,f=((ye&f|0)==0?0:(ye+f&0-ve)-f|0)+F|0,ve=A[7089]|0,ye=f+ve|0,f>>>0>se>>>0&f>>>0<2147483647)){if(_e=A[7091]|0,_e|0&&ye>>>0<=ve>>>0|ye>>>0>_e>>>0){f=0;break}if(d=ul(f|0)|0,(d|0)==(p|0)){M=f,w=p,Pe=145;break e}else _=d,Pe=136}else f=0;while(!1);do if((Pe|0)==136){if(p=0-f|0,!(R>>>0>f>>>0&(f>>>0<2147483647&(_|0)!=-1)))if((_|0)==-1){f=0;break}else{M=f,w=_,Pe=145;break e}if(d=A[7101]|0,d=B-f+d&0-d,d>>>0>=2147483647){M=f,w=_,Pe=145;break e}if((ul(d|0)|0)==-1){ul(p|0)|0,f=0;break}else{M=d+f|0,w=_,Pe=145;break e}}while(!1);A[7092]=A[7092]|4,Pe=143}while(!1);if((Pe|0)==143&&F>>>0<2147483647&&(Xe=ul(F|0)|0,ye=ul(0)|0,ze=ye-Xe|0,nt=ze>>>0>(se+40|0)>>>0,!((Xe|0)==-1|nt^1|Xe>>>0>>0&((Xe|0)!=-1&(ye|0)!=-1)^1))&&(M=nt?ze:f,w=Xe,Pe=145),(Pe|0)==145){f=(A[7089]|0)+M|0,A[7089]=f,f>>>0>(A[7090]|0)>>>0&&(A[7090]=f),B=A[6987]|0;e:do if(B){for(f=28372;;){if(d=A[f>>2]|0,p=A[f+4>>2]|0,(w|0)==(d+p|0)){Pe=154;break}if(_=A[f+8>>2]|0,_)f=_;else break}if((Pe|0)==154&&(je=f+4|0,(A[f+12>>2]&8|0)==0)&&w>>>0>B>>>0&d>>>0<=B>>>0){A[je>>2]=p+M,Le=(A[6984]|0)+M|0,Xe=B+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,je=B+Xe|0,Xe=Le-Xe|0,A[6987]=je,A[6984]=Xe,A[je+4>>2]=Xe|1,A[B+Le+4>>2]=40,A[6988]=A[7103];break}for(w>>>0<(A[6985]|0)>>>0&&(A[6985]=w),p=w+M|0,f=28372;;){if((A[f>>2]|0)==(p|0)){Pe=162;break}if(d=A[f+8>>2]|0,d)f=d;else break}if((Pe|0)==162&&(A[f+12>>2]&8|0)==0){A[f>>2]=w,W=f+4|0,A[W>>2]=(A[W>>2]|0)+M,W=w+8|0,W=w+((W&7|0)==0?0:0-W&7)|0,f=p+8|0,f=p+((f&7|0)==0?0:0-f&7)|0,F=W+se|0,R=f-W-se|0,A[W+4>>2]=se|3;t:do if((B|0)==(f|0))Le=(A[6984]|0)+R|0,A[6984]=Le,A[6987]=F,A[F+4>>2]=Le|1;else{if((A[6986]|0)==(f|0)){Le=(A[6983]|0)+R|0,A[6983]=Le,A[6986]=F,A[F+4>>2]=Le|1,A[F+Le>>2]=Le;break}if(d=A[f+4>>2]|0,(d&3|0)==1){M=d&-8,_=d>>>3;n:do if(d>>>0<256)if(d=A[f+8>>2]|0,p=A[f+12>>2]|0,(p|0)==(d|0)){A[6981]=A[6981]&~(1<<_);break}else{A[d+12>>2]=p,A[p+8>>2]=d;break}else{w=A[f+24>>2]|0,d=A[f+12>>2]|0;do if((d|0)==(f|0)){if(p=f+16|0,_=p+4|0,d=A[_>>2]|0,d)p=_;else if(d=A[p>>2]|0,!d){d=0;break}for(;;)if(y=d+20|0,_=A[y>>2]|0,_)d=_,p=y;else if(y=d+16|0,_=A[y>>2]|0,_)d=_,p=y;else break;A[p>>2]=0}else Le=A[f+8>>2]|0,A[Le+12>>2]=d,A[d+8>>2]=Le;while(!1);if(!w)break;p=A[f+28>>2]|0,_=28228+(p<<2)|0;do if((A[_>>2]|0)!=(f|0)){if(Le=w+16|0,A[((A[Le>>2]|0)==(f|0)?Le:w+20|0)>>2]=d,!d)break n}else{if(A[_>>2]=d,d|0)break;A[6982]=A[6982]&~(1<>2]=w,p=f+16|0,_=A[p>>2]|0,_|0&&(A[d+16>>2]=_,A[_+24>>2]=d),p=A[p+4>>2]|0,!p)break;A[d+20>>2]=p,A[p+24>>2]=d}while(!1);f=f+M|0,y=M+R|0}else y=R;if(f=f+4|0,A[f>>2]=A[f>>2]&-2,A[F+4>>2]=y|1,A[F+y>>2]=y,f=y>>>3,y>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=F,A[f+12>>2]=F,A[F+8>>2]=f,A[F+12>>2]=p;break}f=y>>>8;do if(!f)_=0;else{if(y>>>0>16777215){_=31;break}je=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,_=14-(Xe|je|_)+(Le<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1}while(!1);if(f=28228+(_<<2)|0,A[F+28>>2]=_,d=F+16|0,A[d+4>>2]=0,A[d>>2]=0,d=A[6982]|0,p=1<<_,!(d&p)){A[6982]=d|p,A[f>>2]=F,A[F+24>>2]=f,A[F+12>>2]=F,A[F+8>>2]=F;break}f=A[f>>2]|0;n:do if((A[f+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(y|0)){f=d;break n}else _=_<<1,f=d;A[p>>2]=F,A[F+24>>2]=f,A[F+12>>2]=F,A[F+8>>2]=F;break t}while(!1);je=f+8|0,Le=A[je>>2]|0,A[Le+12>>2]=F,A[je>>2]=F,A[F+8>>2]=Le,A[F+12>>2]=f,A[F+24>>2]=0}while(!1);return Le=W+8|0,K=Ft,Le|0}for(f=28372;d=A[f>>2]|0,!(d>>>0<=B>>>0&&(Le=d+(A[f+4>>2]|0)|0,Le>>>0>B>>>0));)f=A[f+8>>2]|0;y=Le+-47|0,d=y+8|0,d=y+((d&7|0)==0?0:0-d&7)|0,y=B+16|0,d=d>>>0>>0?B:d,f=d+8|0,p=M+-40|0,Xe=w+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,je=w+Xe|0,Xe=p-Xe|0,A[6987]=je,A[6984]=Xe,A[je+4>>2]=Xe|1,A[w+p+4>>2]=40,A[6988]=A[7103],p=d+4|0,A[p>>2]=27,A[f>>2]=A[7093],A[f+4>>2]=A[7094],A[f+8>>2]=A[7095],A[f+12>>2]=A[7096],A[7093]=w,A[7094]=M,A[7096]=0,A[7095]=f,f=d+24|0;do je=f,f=f+4|0,A[f>>2]=7;while((je+8|0)>>>0>>0);if((d|0)!=(B|0)){if(w=d-B|0,A[p>>2]=A[p>>2]&-2,A[B+4>>2]=w|1,A[d>>2]=w,f=w>>>3,w>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=B,A[f+12>>2]=B,A[B+8>>2]=f,A[B+12>>2]=p;break}if(f=w>>>8,f?w>>>0>16777215?_=31:(je=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,_=14-(Xe|je|_)+(Le<<_>>>15)|0,_=w>>>(_+7|0)&1|_<<1):_=0,p=28228+(_<<2)|0,A[B+28>>2]=_,A[B+20>>2]=0,A[y>>2]=0,f=A[6982]|0,d=1<<_,!(f&d)){A[6982]=f|d,A[p>>2]=B,A[B+24>>2]=p,A[B+12>>2]=B,A[B+8>>2]=B;break}f=A[p>>2]|0;t:do if((A[f+4>>2]&-8|0)!=(w|0)){for(_=w<<((_|0)==31?0:25-(_>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(w|0)){f=d;break t}else _=_<<1,f=d;A[p>>2]=B,A[B+24>>2]=f,A[B+12>>2]=B,A[B+8>>2]=B;break e}while(!1);je=f+8|0,Le=A[je>>2]|0,A[Le+12>>2]=B,A[je>>2]=B,A[B+8>>2]=Le,A[B+12>>2]=f,A[B+24>>2]=0}}else Le=A[6985]|0,(Le|0)==0|w>>>0>>0&&(A[6985]=w),A[7093]=w,A[7094]=M,A[7096]=0,A[6990]=A[7099],A[6989]=-1,A[6994]=27964,A[6993]=27964,A[6996]=27972,A[6995]=27972,A[6998]=27980,A[6997]=27980,A[7e3]=27988,A[6999]=27988,A[7002]=27996,A[7001]=27996,A[7004]=28004,A[7003]=28004,A[7006]=28012,A[7005]=28012,A[7008]=28020,A[7007]=28020,A[7010]=28028,A[7009]=28028,A[7012]=28036,A[7011]=28036,A[7014]=28044,A[7013]=28044,A[7016]=28052,A[7015]=28052,A[7018]=28060,A[7017]=28060,A[7020]=28068,A[7019]=28068,A[7022]=28076,A[7021]=28076,A[7024]=28084,A[7023]=28084,A[7026]=28092,A[7025]=28092,A[7028]=28100,A[7027]=28100,A[7030]=28108,A[7029]=28108,A[7032]=28116,A[7031]=28116,A[7034]=28124,A[7033]=28124,A[7036]=28132,A[7035]=28132,A[7038]=28140,A[7037]=28140,A[7040]=28148,A[7039]=28148,A[7042]=28156,A[7041]=28156,A[7044]=28164,A[7043]=28164,A[7046]=28172,A[7045]=28172,A[7048]=28180,A[7047]=28180,A[7050]=28188,A[7049]=28188,A[7052]=28196,A[7051]=28196,A[7054]=28204,A[7053]=28204,A[7056]=28212,A[7055]=28212,Le=M+-40|0,Xe=w+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,je=w+Xe|0,Xe=Le-Xe|0,A[6987]=je,A[6984]=Xe,A[je+4>>2]=Xe|1,A[w+Le+4>>2]=40,A[6988]=A[7103];while(!1);if(f=A[6984]|0,f>>>0>se>>>0)return Xe=f-se|0,A[6984]=Xe,Le=A[6987]|0,je=Le+se|0,A[6987]=je,A[je+4>>2]=Xe|1,A[Le+4>>2]=se|3,Le=Le+8|0,K=Ft,Le|0}return Le=kd()|0,A[Le>>2]=12,Le=0,K=Ft,Le|0}function vn(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(d){p=d+-8|0,y=A[6985]|0,d=A[d+-4>>2]|0,f=d&-8,B=p+f|0;do if(d&1)R=p,M=p;else{if(_=A[p>>2]|0,!(d&3)||(M=p+(0-_)|0,w=_+f|0,M>>>0>>0))return;if((A[6986]|0)==(M|0)){if(d=B+4|0,f=A[d>>2]|0,(f&3|0)!=3){R=M,f=w;break}A[6983]=w,A[d>>2]=f&-2,A[M+4>>2]=w|1,A[M+w>>2]=w;return}if(p=_>>>3,_>>>0<256)if(d=A[M+8>>2]|0,f=A[M+12>>2]|0,(f|0)==(d|0)){A[6981]=A[6981]&~(1<>2]=f,A[f+8>>2]=d,R=M,f=w;break}y=A[M+24>>2]|0,d=A[M+12>>2]|0;do if((d|0)==(M|0)){if(f=M+16|0,p=f+4|0,d=A[p>>2]|0,d)f=p;else if(d=A[f>>2]|0,!d){d=0;break}for(;;)if(_=d+20|0,p=A[_>>2]|0,p)d=p,f=_;else if(_=d+16|0,p=A[_>>2]|0,p)d=p,f=_;else break;A[f>>2]=0}else R=A[M+8>>2]|0,A[R+12>>2]=d,A[d+8>>2]=R;while(!1);if(y){if(f=A[M+28>>2]|0,p=28228+(f<<2)|0,(A[p>>2]|0)==(M|0)){if(A[p>>2]=d,!d){A[6982]=A[6982]&~(1<>2]|0)==(M|0)?R:y+20|0)>>2]=d,!d){R=M,f=w;break}A[d+24>>2]=y,f=M+16|0,p=A[f>>2]|0,p|0&&(A[d+16>>2]=p,A[p+24>>2]=d),f=A[f+4>>2]|0,f?(A[d+20>>2]=f,A[f+24>>2]=d,R=M,f=w):(R=M,f=w)}else R=M,f=w}while(!1);if(!(M>>>0>=B>>>0)&&(d=B+4|0,_=A[d>>2]|0,!!(_&1))){if(_&2)A[d>>2]=_&-2,A[R+4>>2]=f|1,A[M+f>>2]=f,y=f;else{if((A[6987]|0)==(B|0)){if(B=(A[6984]|0)+f|0,A[6984]=B,A[6987]=R,A[R+4>>2]=B|1,(R|0)!=(A[6986]|0))return;A[6986]=0,A[6983]=0;return}if((A[6986]|0)==(B|0)){B=(A[6983]|0)+f|0,A[6983]=B,A[6986]=M,A[R+4>>2]=B|1,A[M+B>>2]=B;return}y=(_&-8)+f|0,p=_>>>3;do if(_>>>0<256)if(f=A[B+8>>2]|0,d=A[B+12>>2]|0,(d|0)==(f|0)){A[6981]=A[6981]&~(1<>2]=d,A[d+8>>2]=f;break}else{w=A[B+24>>2]|0,d=A[B+12>>2]|0;do if((d|0)==(B|0)){if(f=B+16|0,p=f+4|0,d=A[p>>2]|0,d)f=p;else if(d=A[f>>2]|0,!d){p=0;break}for(;;)if(_=d+20|0,p=A[_>>2]|0,p)d=p,f=_;else if(_=d+16|0,p=A[_>>2]|0,p)d=p,f=_;else break;A[f>>2]=0,p=d}else p=A[B+8>>2]|0,A[p+12>>2]=d,A[d+8>>2]=p,p=d;while(!1);if(w|0){if(d=A[B+28>>2]|0,f=28228+(d<<2)|0,(A[f>>2]|0)==(B|0)){if(A[f>>2]=p,!p){A[6982]=A[6982]&~(1<>2]|0)==(B|0)?_:w+20|0)>>2]=p,!p)break;A[p+24>>2]=w,d=B+16|0,f=A[d>>2]|0,f|0&&(A[p+16>>2]=f,A[f+24>>2]=p),d=A[d+4>>2]|0,d|0&&(A[p+20>>2]=d,A[d+24>>2]=p)}}while(!1);if(A[R+4>>2]=y|1,A[M+y>>2]=y,(R|0)==(A[6986]|0)){A[6983]=y;return}}if(d=y>>>3,y>>>0<256){p=27964+(d<<1<<2)|0,f=A[6981]|0,d=1<>2]|0):(A[6981]=f|d,d=p,f=p+8|0),A[f>>2]=R,A[d+12>>2]=R,A[R+8>>2]=d,A[R+12>>2]=p;return}d=y>>>8,d?y>>>0>16777215?_=31:(M=(d+1048320|0)>>>16&8,B=d<>>16&4,B=B<>>16&2,_=14-(w|M|_)+(B<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1):_=0,d=28228+(_<<2)|0,A[R+28>>2]=_,A[R+20>>2]=0,A[R+16>>2]=0,f=A[6982]|0,p=1<<_;e:do if(!(f&p))A[6982]=f|p,A[d>>2]=R,A[R+24>>2]=d,A[R+12>>2]=R,A[R+8>>2]=R;else{d=A[d>>2]|0;t:do if((A[d+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=d+16+(_>>>31<<2)|0,f=A[p>>2]|0,!!f;)if((A[f+4>>2]&-8|0)==(y|0)){d=f;break t}else _=_<<1,d=f;A[p>>2]=R,A[R+24>>2]=d,A[R+12>>2]=R,A[R+8>>2]=R;break e}while(!1);M=d+8|0,B=A[M>>2]|0,A[B+12>>2]=R,A[M>>2]=R,A[R+8>>2]=B,A[R+12>>2]=d,A[R+24>>2]=0}while(!1);if(B=(A[6989]|0)+-1|0,A[6989]=B,!(B|0)){for(d=28380;d=A[d>>2]|0,d;)d=d+8|0;A[6989]=-1}}}}function Ys(d,f){d=d|0,f=f|0;var p=0;return d?(p=it(f,d)|0,(f|d)>>>0>65535&&(p=((p>>>0)/(d>>>0)|0|0)==(f|0)?p:-1)):p=0,d=Oo(p)|0,!d||!(A[d+-4>>2]&3)||ao(d|0,0,p|0)|0,d|0}function tn(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,p=d+p>>>0,he(f+_+(p>>>0>>0|0)>>>0|0),p|0|0}function Lr(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,_=f-_-(p>>>0>d>>>0|0)>>>0,he(_|0),d-p>>>0|0|0}function Yc(d){return d=d|0,(d?31-(Qt(d^d-1)|0)|0:32)|0}function Xu(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0;if(W=d,B=f,F=B,M=p,_e=_,R=_e,!F)return w=(y|0)!=0,R?w?(A[y>>2]=d|0,A[y+4>>2]=f&0,_e=0,y=0,he(_e|0),y|0):(_e=0,y=0,he(_e|0),y|0):(w&&(A[y>>2]=(W>>>0)%(M>>>0),A[y+4>>2]=0),_e=0,y=(W>>>0)/(M>>>0)>>>0,he(_e|0),y|0);w=(R|0)==0;do if(M){if(!w){if(w=(Qt(R|0)|0)-(Qt(F|0)|0)|0,w>>>0<=31){se=w+1|0,R=31-w|0,f=w-31>>31,M=se,d=W>>>(se>>>0)&f|F<>>(se>>>0)&f,w=0,R=W<>2]=d|0,A[y+4>>2]=B|f&0,_e=0,y=0,he(_e|0),y|0):(_e=0,y=0,he(_e|0),y|0)}if(w=M-1|0,w&M|0){R=(Qt(M|0)|0)+33-(Qt(F|0)|0)|0,ye=64-R|0,se=32-R|0,B=se>>31,ve=R-32|0,f=ve>>31,M=R,d=se-1>>31&F>>>(ve>>>0)|(F<>>(R>>>0))&f,f=f&F>>>(R>>>0),w=W<>>(ve>>>0))&B|W<>31;break}return y|0&&(A[y>>2]=w&W,A[y+4>>2]=0),(M|0)==1?(ve=B|f&0,ye=d|0|0,he(ve|0),ye|0):(ye=Yc(M|0)|0,ve=F>>>(ye>>>0)|0,ye=F<<32-ye|W>>>(ye>>>0)|0,he(ve|0),ye|0)}else{if(w)return y|0&&(A[y>>2]=(F>>>0)%(M>>>0),A[y+4>>2]=0),ve=0,ye=(F>>>0)/(M>>>0)>>>0,he(ve|0),ye|0;if(!W)return y|0&&(A[y>>2]=0,A[y+4>>2]=(F>>>0)%(R>>>0)),ve=0,ye=(F>>>0)/(R>>>0)>>>0,he(ve|0),ye|0;if(w=R-1|0,!(w&R))return y|0&&(A[y>>2]=d|0,A[y+4>>2]=w&F|f&0),ve=0,ye=F>>>((Yc(R|0)|0)>>>0),he(ve|0),ye|0;if(w=(Qt(R|0)|0)-(Qt(F|0)|0)|0,w>>>0<=30){f=w+1|0,R=31-w|0,M=f,d=F<>>(f>>>0),f=F>>>(f>>>0),w=0,R=W<>2]=d|0,A[y+4>>2]=B|f&0,ve=0,ye=0,he(ve|0),ye|0):(ve=0,ye=0,he(ve|0),ye|0)}while(!1);if(!M)F=R,B=0,R=0;else{se=p|0|0,W=_e|_&0,F=tn(se|0,W|0,-1,-1)|0,p=X()|0,B=R,R=0;do _=B,B=w>>>31|B<<1,w=R|w<<1,_=d<<1|_>>>31|0,_e=d>>>31|f<<1|0,Lr(F|0,p|0,_|0,_e|0)|0,ye=X()|0,ve=ye>>31|((ye|0)<0?-1:0)<<1,R=ve&1,d=Lr(_|0,_e|0,ve&se|0,(((ye|0)<0?-1:0)>>31|((ye|0)<0?-1:0)<<1)&W|0)|0,f=X()|0,M=M-1|0;while((M|0)!=0);F=B,B=0}return M=0,y|0&&(A[y>>2]=d,A[y+4>>2]=f),ve=(w|0)>>>31|(F|M)<<1|(M<<1|w>>>31)&0|B,ye=(w<<1|0)&-2|R,he(ve|0),ye|0}function Io(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;return F=f>>31|((f|0)<0?-1:0)<<1,B=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,w=_>>31|((_|0)<0?-1:0)<<1,y=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,R=Lr(F^d|0,B^f|0,F|0,B|0)|0,M=X()|0,d=w^F,f=y^B,Lr((Xu(R,M,Lr(w^p|0,y^_|0,w|0,y|0)|0,X()|0,0)|0)^d|0,(X()|0)^f|0,d|0,f|0)|0}function Qc(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return w=d&65535,y=f&65535,p=it(y,w)|0,_=d>>>16,d=(p>>>16)+(it(y,_)|0)|0,y=f>>>16,f=it(y,w)|0,he((d>>>16)+(it(y,_)|0)+(((d&65535)+f|0)>>>16)|0),d+f<<16|p&65535|0|0}function ur(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;return y=d,w=p,p=Qc(y,w)|0,d=X()|0,he((it(f,w)|0)+(it(_,y)|0)+d|d&0|0),p|0|0|0}function Kc(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;return y=K,K=K+16|0,R=y|0,M=f>>31|((f|0)<0?-1:0)<<1,w=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,F=_>>31|((_|0)<0?-1:0)<<1,B=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,d=Lr(M^d|0,w^f|0,M|0,w|0)|0,f=X()|0,Xu(d,f,Lr(F^p|0,B^_|0,F|0,B|0)|0,X()|0,R)|0,_=Lr(A[R>>2]^M|0,A[R+4>>2]^w|0,M|0,w|0)|0,p=X()|0,K=y,he(p|0),_|0}function Yu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;return w=K,K=K+16|0,y=w|0,Xu(d,f,p,_,y)|0,K=w,he(A[y+4>>2]|0),A[y>>2]|0|0}function N1(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f>>p|0),d>>>p|(f&(1<>p-32|0)}function Ct(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f>>>p|0),d>>>p|(f&(1<>>p-32|0)}function It(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f<>>32-p|0),d<=0?+$n(d+.5):+rt(d-.5)}function Ol(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if((p|0)>=8192)return Tn(d|0,f|0,p|0)|0,d|0;if(w=d|0,y=d+p|0,(d&3)==(f&3)){for(;d&3;){if(!p)return w|0;xt[d>>0]=xt[f>>0]|0,d=d+1|0,f=f+1|0,p=p-1|0}for(p=y&-4|0,_=p-64|0;(d|0)<=(_|0);)A[d>>2]=A[f>>2],A[d+4>>2]=A[f+4>>2],A[d+8>>2]=A[f+8>>2],A[d+12>>2]=A[f+12>>2],A[d+16>>2]=A[f+16>>2],A[d+20>>2]=A[f+20>>2],A[d+24>>2]=A[f+24>>2],A[d+28>>2]=A[f+28>>2],A[d+32>>2]=A[f+32>>2],A[d+36>>2]=A[f+36>>2],A[d+40>>2]=A[f+40>>2],A[d+44>>2]=A[f+44>>2],A[d+48>>2]=A[f+48>>2],A[d+52>>2]=A[f+52>>2],A[d+56>>2]=A[f+56>>2],A[d+60>>2]=A[f+60>>2],d=d+64|0,f=f+64|0;for(;(d|0)<(p|0);)A[d>>2]=A[f>>2],d=d+4|0,f=f+4|0}else for(p=y-4|0;(d|0)<(p|0);)xt[d>>0]=xt[f>>0]|0,xt[d+1>>0]=xt[f+1>>0]|0,xt[d+2>>0]=xt[f+2>>0]|0,xt[d+3>>0]=xt[f+3>>0]|0,d=d+4|0,f=f+4|0;for(;(d|0)<(y|0);)xt[d>>0]=xt[f>>0]|0,d=d+1|0,f=f+1|0;return w|0}function ao(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(w=d+p|0,f=f&255,(p|0)>=67){for(;d&3;)xt[d>>0]=f,d=d+1|0;for(_=w&-4|0,M=f|f<<8|f<<16|f<<24,y=_-64|0;(d|0)<=(y|0);)A[d>>2]=M,A[d+4>>2]=M,A[d+8>>2]=M,A[d+12>>2]=M,A[d+16>>2]=M,A[d+20>>2]=M,A[d+24>>2]=M,A[d+28>>2]=M,A[d+32>>2]=M,A[d+36>>2]=M,A[d+40>>2]=M,A[d+44>>2]=M,A[d+48>>2]=M,A[d+52>>2]=M,A[d+56>>2]=M,A[d+60>>2]=M,d=d+64|0;for(;(d|0)<(_|0);)A[d>>2]=M,d=d+4|0}for(;(d|0)<(w|0);)xt[d>>0]=f,d=d+1|0;return w-p|0}function cf(d){return d=+d,d>=0?+$n(d+.5):+rt(d-.5)}function ul(d){d=d|0;var f=0,p=0,_=0;return _=sn()|0,p=A[Wn>>2]|0,f=p+d|0,(d|0)>0&(f|0)<(p|0)|(f|0)<0?(xi(f|0)|0,en(12),-1):(f|0)>(_|0)&&!(Rn(f|0)|0)?(en(12),-1):(A[Wn>>2]=f,p|0)}return{___divdi3:Io,___muldi3:ur,___remdi3:Kc,___uremdi3:Yu,_areNeighborCells:px,_bitshift64Ashr:N1,_bitshift64Lshr:Ct,_bitshift64Shl:It,_calloc:Ys,_cellAreaKm2:dp,_cellAreaM2:Nd,_cellAreaRads2:Ll,_cellToBoundary:Pl,_cellToCenterChild:Md,_cellToChildPos:cp,_cellToChildren:v1,_cellToChildrenSize:nf,_cellToLatLng:Dl,_cellToLocalIj:M1,_cellToParent:Lu,_cellToVertex:Xs,_cellToVertexes:Hu,_cellsToDirectedEdge:d1,_cellsToLinkedMultiPolygon:cx,_childPosToCell:b1,_compactCells:ap,_constructCell:wx,_destroyLinkedMultiPolygon:Gu,_directedEdgeToBoundary:Sd,_directedEdgeToCells:vx,_edgeLengthKm:Ap,_edgeLengthM:zu,_edgeLengthRads:Rd,_emscripten_replace_memory:hn,_free:vn,_getBaseCellNumber:m1,_getDirectedEdgeDestination:gx,_getDirectedEdgeOrigin:mx,_getHexagonAreaAvgKm2:hp,_getHexagonAreaAvgM2:w1,_getHexagonEdgeLengthAvgKm:fp,_getHexagonEdgeLengthAvgM:ro,_getIcosahedronFaces:Ou,_getIndexDigit:Sx,_getNumCells:ku,_getPentagons:Iu,_getRes0Cells:Yh,_getResolution:Wc,_greatCircleDistanceKm:Xc,_greatCircleDistanceM:Ex,_greatCircleDistanceRads:S1,_gridDisk:ys,_gridDiskDistances:Vr,_gridDistance:qu,_gridPathCells:E1,_gridPathCellsSize:pp,_gridRing:_r,_gridRingUnsafe:Jr,_i64Add:tn,_i64Subtract:Lr,_isPentagon:wi,_isResClassIII:x1,_isValidCell:Td,_isValidDirectedEdge:A1,_isValidIndex:g1,_isValidVertex:al,_latLngToCell:Ed,_llvm_ctlz_i64:of,_llvm_maxnum_f64:lf,_llvm_minnum_f64:uf,_llvm_round_f64:ll,_localIjToCell:Pd,_malloc:Oo,_maxFaceCount:Mx,_maxGridDiskSize:Ps,_maxPolygonToCellsSize:ux,_maxPolygonToCellsSizeExperimental:sf,_memcpy:Ol,_memset:ao,_originToDirectedEdges:_x,_pentagonCount:up,_polygonToCells:i1,_polygonToCellsExperimental:Ud,_readInt64AsDoubleFromPointer:gp,_res0CellCount:r1,_round:cf,_sbrk:ul,_sizeOfCellBoundary:cs,_sizeOfCoordIJ:Na,_sizeOfGeoLoop:er,_sizeOfGeoPolygon:Ai,_sizeOfH3Index:mp,_sizeOfLatLng:C1,_sizeOfLinkedGeoPolygon:Ul,_uncompactCells:_1,_uncompactCellsSize:y1,_vertexToLatLng:sl,establishStackSpace:vr,stackAlloc:Zt,stackRestore:ui,stackSave:gr}})(Jt,In,Q);e.___divdi3=ge.___divdi3,e.___muldi3=ge.___muldi3,e.___remdi3=ge.___remdi3,e.___uremdi3=ge.___uremdi3,e._areNeighborCells=ge._areNeighborCells,e._bitshift64Ashr=ge._bitshift64Ashr,e._bitshift64Lshr=ge._bitshift64Lshr,e._bitshift64Shl=ge._bitshift64Shl,e._calloc=ge._calloc,e._cellAreaKm2=ge._cellAreaKm2,e._cellAreaM2=ge._cellAreaM2,e._cellAreaRads2=ge._cellAreaRads2,e._cellToBoundary=ge._cellToBoundary,e._cellToCenterChild=ge._cellToCenterChild,e._cellToChildPos=ge._cellToChildPos,e._cellToChildren=ge._cellToChildren,e._cellToChildrenSize=ge._cellToChildrenSize,e._cellToLatLng=ge._cellToLatLng,e._cellToLocalIj=ge._cellToLocalIj,e._cellToParent=ge._cellToParent,e._cellToVertex=ge._cellToVertex,e._cellToVertexes=ge._cellToVertexes,e._cellsToDirectedEdge=ge._cellsToDirectedEdge,e._cellsToLinkedMultiPolygon=ge._cellsToLinkedMultiPolygon,e._childPosToCell=ge._childPosToCell,e._compactCells=ge._compactCells,e._constructCell=ge._constructCell,e._destroyLinkedMultiPolygon=ge._destroyLinkedMultiPolygon,e._directedEdgeToBoundary=ge._directedEdgeToBoundary,e._directedEdgeToCells=ge._directedEdgeToCells,e._edgeLengthKm=ge._edgeLengthKm,e._edgeLengthM=ge._edgeLengthM,e._edgeLengthRads=ge._edgeLengthRads;var Ot=e._emscripten_replace_memory=ge._emscripten_replace_memory;e._free=ge._free,e._getBaseCellNumber=ge._getBaseCellNumber,e._getDirectedEdgeDestination=ge._getDirectedEdgeDestination,e._getDirectedEdgeOrigin=ge._getDirectedEdgeOrigin,e._getHexagonAreaAvgKm2=ge._getHexagonAreaAvgKm2,e._getHexagonAreaAvgM2=ge._getHexagonAreaAvgM2,e._getHexagonEdgeLengthAvgKm=ge._getHexagonEdgeLengthAvgKm,e._getHexagonEdgeLengthAvgM=ge._getHexagonEdgeLengthAvgM,e._getIcosahedronFaces=ge._getIcosahedronFaces,e._getIndexDigit=ge._getIndexDigit,e._getNumCells=ge._getNumCells,e._getPentagons=ge._getPentagons,e._getRes0Cells=ge._getRes0Cells,e._getResolution=ge._getResolution,e._greatCircleDistanceKm=ge._greatCircleDistanceKm,e._greatCircleDistanceM=ge._greatCircleDistanceM,e._greatCircleDistanceRads=ge._greatCircleDistanceRads,e._gridDisk=ge._gridDisk,e._gridDiskDistances=ge._gridDiskDistances,e._gridDistance=ge._gridDistance,e._gridPathCells=ge._gridPathCells,e._gridPathCellsSize=ge._gridPathCellsSize,e._gridRing=ge._gridRing,e._gridRingUnsafe=ge._gridRingUnsafe,e._i64Add=ge._i64Add,e._i64Subtract=ge._i64Subtract,e._isPentagon=ge._isPentagon,e._isResClassIII=ge._isResClassIII,e._isValidCell=ge._isValidCell,e._isValidDirectedEdge=ge._isValidDirectedEdge,e._isValidIndex=ge._isValidIndex,e._isValidVertex=ge._isValidVertex,e._latLngToCell=ge._latLngToCell,e._llvm_ctlz_i64=ge._llvm_ctlz_i64,e._llvm_maxnum_f64=ge._llvm_maxnum_f64,e._llvm_minnum_f64=ge._llvm_minnum_f64,e._llvm_round_f64=ge._llvm_round_f64,e._localIjToCell=ge._localIjToCell,e._malloc=ge._malloc,e._maxFaceCount=ge._maxFaceCount,e._maxGridDiskSize=ge._maxGridDiskSize,e._maxPolygonToCellsSize=ge._maxPolygonToCellsSize,e._maxPolygonToCellsSizeExperimental=ge._maxPolygonToCellsSizeExperimental,e._memcpy=ge._memcpy,e._memset=ge._memset,e._originToDirectedEdges=ge._originToDirectedEdges,e._pentagonCount=ge._pentagonCount,e._polygonToCells=ge._polygonToCells,e._polygonToCellsExperimental=ge._polygonToCellsExperimental,e._readInt64AsDoubleFromPointer=ge._readInt64AsDoubleFromPointer,e._res0CellCount=ge._res0CellCount,e._round=ge._round,e._sbrk=ge._sbrk,e._sizeOfCellBoundary=ge._sizeOfCellBoundary,e._sizeOfCoordIJ=ge._sizeOfCoordIJ,e._sizeOfGeoLoop=ge._sizeOfGeoLoop,e._sizeOfGeoPolygon=ge._sizeOfGeoPolygon,e._sizeOfH3Index=ge._sizeOfH3Index,e._sizeOfLatLng=ge._sizeOfLatLng,e._sizeOfLinkedGeoPolygon=ge._sizeOfLinkedGeoPolygon,e._uncompactCells=ge._uncompactCells,e._uncompactCellsSize=ge._uncompactCellsSize,e._vertexToLatLng=ge._vertexToLatLng,e.establishStackSpace=ge.establishStackSpace;var ot=e.stackAlloc=ge.stackAlloc,Tt=e.stackRestore=ge.stackRestore,Ht=e.stackSave=ge.stackSave;if(e.asm=ge,e.cwrap=U,e.setValue=S,e.getValue=T,Ae){be(Ae)||(Ae=s(Ae));{Xt();var Yt=function(Ze){Ze.byteLength&&(Ze=new Uint8Array(Ze)),ne.set(Ze,x),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,pt()},pn=function(){a(Ae,Yt,function(){throw"could not load memory initializer "+Ae})},$e=jt(Ae);if($e)Yt($e.buffer);else if(e.memoryInitializerRequest){var St=function(){var Ze=e.memoryInitializerRequest,dt=Ze.response;if(Ze.status!==200&&Ze.status!==0){var Vt=jt(e.memoryInitializerRequestURL);if(Vt)dt=Vt.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+Ze.status+", retrying "+Ae),pn();return}}Yt(dt)};e.memoryInitializerRequest.response?setTimeout(St,0):e.memoryInitializerRequest.addEventListener("load",St)}else pn()}}var Kt;_t=function Ze(){Kt||wn(),Kt||(_t=Ze)};function wn(Ze){if(Gt>0||(He(),Gt>0))return;function dt(){Kt||(Kt=!0,!N&&(Rt(),Et(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),zt()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),dt()},1)):dt()}e.run=wn;function qn(Ze){throw e.onAbort&&e.onAbort(Ze),Ze+="",l(Ze),u(Ze),N=!0,"abort("+Ze+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=qn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return wn(),i})(typeof _i=="object"?_i:{}),Un="number",Pn=Un,xA=Un,zn=Un,Gn=Un,Es=Un,ln=Un,iZ=[["sizeOfH3Index",Un],["sizeOfLatLng",Un],["sizeOfCellBoundary",Un],["sizeOfGeoLoop",Un],["sizeOfGeoPolygon",Un],["sizeOfLinkedGeoPolygon",Un],["sizeOfCoordIJ",Un],["readInt64AsDoubleFromPointer",Un],["isValidCell",xA,[zn,Gn]],["isValidIndex",xA,[zn,Gn]],["latLngToCell",Pn,[Un,Un,Es,ln]],["cellToLatLng",Pn,[zn,Gn,ln]],["cellToBoundary",Pn,[zn,Gn,ln]],["maxGridDiskSize",Pn,[Un,ln]],["gridDisk",Pn,[zn,Gn,Un,ln]],["gridDiskDistances",Pn,[zn,Gn,Un,ln,ln]],["gridRing",Pn,[zn,Gn,Un,ln]],["gridRingUnsafe",Pn,[zn,Gn,Un,ln]],["maxPolygonToCellsSize",Pn,[ln,Es,Un,ln]],["polygonToCells",Pn,[ln,Es,Un,ln]],["maxPolygonToCellsSizeExperimental",Pn,[ln,Es,Un,ln]],["polygonToCellsExperimental",Pn,[ln,Es,Un,Un,Un,ln]],["cellsToLinkedMultiPolygon",Pn,[ln,Un,ln]],["destroyLinkedMultiPolygon",null,[ln]],["compactCells",Pn,[ln,ln,Un,Un]],["uncompactCells",Pn,[ln,Un,Un,ln,Un,Es]],["uncompactCellsSize",Pn,[ln,Un,Un,Es,ln]],["isPentagon",xA,[zn,Gn]],["isResClassIII",xA,[zn,Gn]],["getBaseCellNumber",Un,[zn,Gn]],["getResolution",Un,[zn,Gn]],["getIndexDigit",Un,[zn,Gn,Un]],["constructCell",Pn,[Un,Un,ln,ln]],["maxFaceCount",Pn,[zn,Gn,ln]],["getIcosahedronFaces",Pn,[zn,Gn,ln]],["cellToParent",Pn,[zn,Gn,Es,ln]],["cellToChildren",Pn,[zn,Gn,Es,ln]],["cellToCenterChild",Pn,[zn,Gn,Es,ln]],["cellToChildrenSize",Pn,[zn,Gn,Es,ln]],["cellToChildPos",Pn,[zn,Gn,Es,ln]],["childPosToCell",Pn,[Un,Un,zn,Gn,Es,ln]],["areNeighborCells",Pn,[zn,Gn,zn,Gn,ln]],["cellsToDirectedEdge",Pn,[zn,Gn,zn,Gn,ln]],["getDirectedEdgeOrigin",Pn,[zn,Gn,ln]],["getDirectedEdgeDestination",Pn,[zn,Gn,ln]],["isValidDirectedEdge",xA,[zn,Gn]],["directedEdgeToCells",Pn,[zn,Gn,ln]],["originToDirectedEdges",Pn,[zn,Gn,ln]],["directedEdgeToBoundary",Pn,[zn,Gn,ln]],["gridDistance",Pn,[zn,Gn,zn,Gn,ln]],["gridPathCells",Pn,[zn,Gn,zn,Gn,ln]],["gridPathCellsSize",Pn,[zn,Gn,zn,Gn,ln]],["cellToLocalIj",Pn,[zn,Gn,zn,Gn,Un,ln]],["localIjToCell",Pn,[zn,Gn,ln,Un,ln]],["getHexagonAreaAvgM2",Pn,[Es,ln]],["getHexagonAreaAvgKm2",Pn,[Es,ln]],["getHexagonEdgeLengthAvgM",Pn,[Es,ln]],["getHexagonEdgeLengthAvgKm",Pn,[Es,ln]],["greatCircleDistanceM",Un,[ln,ln]],["greatCircleDistanceKm",Un,[ln,ln]],["greatCircleDistanceRads",Un,[ln,ln]],["cellAreaM2",Pn,[zn,Gn,ln]],["cellAreaKm2",Pn,[zn,Gn,ln]],["cellAreaRads2",Pn,[zn,Gn,ln]],["edgeLengthM",Pn,[zn,Gn,ln]],["edgeLengthKm",Pn,[zn,Gn,ln]],["edgeLengthRads",Pn,[zn,Gn,ln]],["getNumCells",Pn,[Es,ln]],["getRes0Cells",Pn,[ln]],["res0CellCount",Un],["getPentagons",Pn,[Un,ln]],["pentagonCount",Un],["cellToVertex",Pn,[zn,Gn,Un,ln]],["cellToVertexes",Pn,[zn,Gn,ln]],["vertexToLatLng",Pn,[zn,Gn,ln]],["isValidVertex",xA,[zn,Gn]]],rZ=0,sZ=1,aZ=2,oZ=3,wP=4,lZ=5,uZ=6,cZ=7,hZ=8,fZ=9,dZ=10,AZ=11,pZ=12,mZ=13,gZ=14,vZ=15,_Z=16,yZ=17,xZ=18,bZ=19,Kr={};Kr[rZ]="Success";Kr[sZ]="The operation failed but a more specific error is not available";Kr[aZ]="Argument was outside of acceptable range";Kr[oZ]="Latitude or longitude arguments were outside of acceptable range";Kr[wP]="Resolution argument was outside of acceptable range";Kr[lZ]="Cell argument was not valid";Kr[uZ]="Directed edge argument was not valid";Kr[cZ]="Undirected edge argument was not valid";Kr[hZ]="Vertex argument was not valid";Kr[fZ]="Pentagon distortion was encountered";Kr[dZ]="Duplicate input";Kr[AZ]="Cell arguments were not neighbors";Kr[pZ]="Cell arguments had incompatible resolutions";Kr[mZ]="Memory allocation failed";Kr[gZ]="Bounds of provided memory were insufficient";Kr[vZ]="Mode or flags argument was not valid";Kr[_Z]="Index argument was not valid";Kr[yZ]="Base cell number was outside of acceptable range";Kr[xZ]="Child indexing digits invalid";Kr[bZ]="Child indexing digits refer to a deleted subsequence";var SZ=1e3,TP=1001,MP=1002,Ey={};Ey[SZ]="Unknown unit";Ey[TP]="Array length out of bounds";Ey[MP]="Got unexpected null value for H3 index";var wZ="Unknown error";function EP(i,e,t){var n=t&&"value"in t,r=new Error((i[e]||wZ)+" (code: "+e+(n?", value: "+t.value:"")+")");return r.code=e,r}function CP(i,e){var t=arguments.length===2?{value:e}:{};return EP(Kr,i,t)}function NP(i,e){var t=arguments.length===2?{value:e}:{};return EP(Ey,i,t)}function mg(i){if(i!==0)throw CP(i)}var Ka={};iZ.forEach(function(e){Ka[e[0]]=_i.cwrap.apply(_i,e)});var VA=16,gg=4,N0=8,TZ=8,V_=Ka.sizeOfH3Index(),NM=Ka.sizeOfLatLng(),MZ=Ka.sizeOfCellBoundary(),EZ=Ka.sizeOfGeoPolygon(),Dm=Ka.sizeOfGeoLoop();Ka.sizeOfLinkedGeoPolygon();Ka.sizeOfCoordIJ();function CZ(i){if(typeof i!="number"||i<0||i>15||Math.floor(i)!==i)throw CP(wP,i);return i}function NZ(i){if(!i)throw NP(MP);return i}var RZ=Math.pow(2,32)-1;function DZ(i){if(i>RZ)throw NP(TP,i);return i}var PZ=/[^0-9a-fA-F]/;function RP(i){if(Array.isArray(i)&&i.length===2&&Number.isInteger(i[0])&&Number.isInteger(i[1]))return i;if(typeof i!="string"||PZ.test(i))return[0,0];var e=parseInt(i.substring(0,i.length-8),VA),t=parseInt(i.substring(i.length-8),VA);return[t,e]}function RR(i){if(i>=0)return i.toString(VA);i=i&2147483647;var e=DP(8,i.toString(VA)),t=(parseInt(e[0],VA)+8).toString(VA);return e=t+e.substring(1),e}function LZ(i,e){return RR(e)+DP(8,RR(i))}function DP(i,e){for(var t=i-e.length,n="",r=0;r0){l=_i._calloc(t,Dm);for(var u=0;u0){for(var a=_i.getValue(i+n,"i32"),l=0;l0){const{width:a,height:l}=e.context;t.bufferWidth=a,t.bufferHeight=l}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){const{object:t,material:n,geometry:r}=e,s=this.getRenderObjectData(e);if(s.worldMatrix.equals(t.matrixWorld)!==!0)return s.worldMatrix.copy(t.matrixWorld),!1;const a=s.material;for(const N in a){const C=a[N],E=n[N];if(C.equals!==void 0){if(C.equals(E)===!1)return C.copy(E),!1}else if(E.isTexture===!0){if(C.id!==E.id||C.version!==E.version)return C.id=E.id,C.version=E.version,!1}else if(C!==E)return a[N]=E,!1}if(a.transmission>0){const{width:N,height:C}=e.context;if(s.bufferWidth!==N||s.bufferHeight!==C)return s.bufferWidth=N,s.bufferHeight=C,!1}const l=s.geometry,u=r.attributes,h=l.attributes,m=Object.keys(h),v=Object.keys(u);if(m.length!==v.length)return s.geometry.attributes=this.getAttributesData(u),!1;for(const N of m){const C=h[N],E=u[N];if(E===void 0)return delete h[N],!1;if(C.version!==E.version)return C.version=E.version,!1}const x=r.index,S=l.indexVersion,T=x?x.version:null;if(S!==T)return l.indexVersion=T,!1;if(l.drawRange.start!==r.drawRange.start||l.drawRange.count!==r.drawRange.count)return l.drawRange.start=r.drawRange.start,l.drawRange.count=r.drawRange.count,!1;if(s.morphTargetInfluences){let N=!1;for(let C=0;C>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const OP=i=>vg(i),Cy=i=>vg(i),RM=(...i)=>vg(i);function IP(i,e=!1){const t=[];i.isNode===!0&&(t.push(i.id),i=i.getSelf());for(const{property:n,childNode:r}of H_(i))t.push(t,vg(n.slice(0,-4)),r.getCacheKey(e));return vg(t)}function*H_(i,e=!1){for(const t in i){if(t.startsWith("_")===!0)continue;const n=i[t];if(Array.isArray(n)===!0)for(let r=0;re.charCodeAt(0)).buffer}const zw={VERTEX:"vertex",FRAGMENT:"fragment"},Qn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},$Z={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ia={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},HP=["fragment","vertex"],Gw=["setup","analyze","generate"],qw=[...HP,"compute"],fd=["x","y","z","w"];let XZ=0;class Nn extends Bc{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Qn.NONE,this.updateBeforeType=Qn.NONE,this.updateAfterType=Qn.NONE,this.uuid=x0.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:XZ++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Qn.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Qn.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Qn.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of H_(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=RM(IP(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e){if(e.increaseUsage(this)===1){const n=e.getNodeProperties(this);for(const r of Object.values(n))r&&r.isNode===!0&&r.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){a.initialized=!0;const l=this.setup(e),u=l&&l.isNode===!0;for(const h of Object.values(a))h&&h.isNode===!0&&h.build(e);u&&l.build(e),a.outputNode=l}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const l=this.getNodeType(e),u=e.getDataFromNode(this);r=u.snippet,r===void 0?(r=this.generate(e)||"",u.snippet=r):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,l,t)}else r=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return H_(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(s)?[]:{}),n[r][s]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const s of e.inputNodes[n])r.push(t[s]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const s in e.inputNodes[n]){const a=e.inputNodes[n][s];r[s]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}if(r){const l=a(e.textures),u=a(e.images),h=a(e.nodes);l.length>0&&(s.textures=l),u.length>0&&(s.images=u),h.length>0&&(s.nodes=h)}return s}}class dd extends Nn{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),n=this.indexNode.build(e,"uint");return`${t}[ ${n} ]`}}class WP extends Nn{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),s=n.build(e,r);return e.format(s,r,t)}}class Zr extends Nn{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),l=e.getVarFromNode(this,null,r),u=e.getPropertyName(l);return e.addLineFlowCode(`${u} = ${a}`,this),s.snippet=a,s.propertyName=u,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class YZ extends Zr{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=this.nodes,s=e.getComponentType(n),a=[];for(const u of r){let h=u.build(e);const m=e.getComponentType(u.getNodeType(e));m!==s&&(h=e.format(h,m,s)),a.push(h)}const l=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(l,n,t)}}const QZ=fd.join("");class Vw extends Nn{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(fd.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===QZ.slice(0,this.components.length)?s=e.format(u,a,t):s=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class KZ extends Zr{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,s=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),l=e.getTypeFromLength(n.length,a),u=r.build(e,l),h=t.build(e,s),m=e.getTypeLength(s),v=[];for(let x=0;xi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),UR=i=>$P(i).split("").sort().join(""),XP={setup(i,e){const t=e.shift();return i(Gg(t),...e)},get(i,e,t){if(typeof e=="string"&&i[e]===void 0){if(i.isStackNode!==!0&&e==="assign")return(...n)=>(R0.assign(t,...n),t);if(jA.has(e)){const n=jA.get(e);return i.isStackNode?(...r)=>t.add(n(...r)):(...r)=>n(t,...r)}else{if(e==="self")return i;if(e.endsWith("Assign")&&jA.has(e.slice(0,e.length-6))){const n=jA.get(e.slice(0,e.length-6));return i.isStackNode?(...r)=>t.assign(r[0],n(...r)):(...r)=>t.assign(n(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=$P(e),wt(new Vw(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=UR(e.slice(3).toLowerCase()),n=>wt(new KZ(i,e,n));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=UR(e.slice(4).toLowerCase()),()=>wt(new ZZ(wt(i),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),wt(new Vw(i,e));if(/^\d+$/.test(e)===!0)return wt(new dd(t,new Rl(Number(e),"uint")))}}}return Reflect.get(i,e,t)},set(i,e,t,n){return typeof e=="string"&&i[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(i,e,t,n)}},$3=new WeakMap,BR=new WeakMap,JZ=function(i,e=null){const t=Rh(i);if(t==="node"){let n=$3.get(i);return n===void 0&&(n=new Proxy(i,XP),$3.set(i,n),$3.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return wt(jw(i,e));if(t==="shader")return Ke(i)}return i},eJ=function(i,e=null){for(const t in i)i[t]=wt(i[t],e);return i},tJ=function(i,e=null){const t=i.length;for(let n=0;nwt(n!==null?Object.assign(s,n):s);return e===null?(...s)=>r(new i(...Qf(s))):t!==null?(t=wt(t),(...s)=>r(new i(e,...Qf(s),t))):(...s)=>r(new i(e,...Qf(s)))},iJ=function(i,...e){return wt(new i(...Qf(e)))};class rJ extends Nn{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=BR.get(e.constructor);a===void 0&&(a=new WeakMap,BR.set(e.constructor,a));let l=a.get(t);l===void 0&&(l=wt(e.buildFunctionNode(t)),a.set(t,l)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(l),s=wt(l.call(n))}else{const a=t.jsFunc,l=n!==null?a(n,e):a(e);s=wt(l)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class sJ extends Nn{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Gg(e),wt(new rJ(this,e))}setup(){return this.call()}}const aJ=[!1,!0],oJ=[0,1,2,3],lJ=[-1,-2],YP=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],PM=new Map;for(const i of aJ)PM.set(i,new Rl(i));const LM=new Map;for(const i of oJ)LM.set(i,new Rl(i,"uint"));const UM=new Map([...LM].map(i=>new Rl(i.value,"int")));for(const i of lJ)UM.set(i,new Rl(i,"int"));const Ny=new Map([...UM].map(i=>new Rl(i.value)));for(const i of YP)Ny.set(i,new Rl(i));for(const i of YP)Ny.set(-i,new Rl(-i));const Ry={bool:PM,uint:LM,ints:UM,float:Ny},OR=new Map([...PM,...Ny]),jw=(i,e)=>OR.has(i)?OR.get(i):i.isNode===!0?i:new Rl(i,e),uJ=i=>{try{return i.getNodeType()}catch{return}},ls=function(i,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>typeof r!="object"))&&(t=[GP(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return wt(e.get(t[0]));if(t.length===1){const r=jw(t[0],i);return uJ(r)===i?wt(r):wt(new WP(r,i))}const n=t.map(r=>jw(r));return wt(new YZ(n,i))}},_g=i=>typeof i=="object"&&i!==null?i.value:i,QP=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Pm(i,e){return new Proxy(new sJ(i,e),XP)}const wt=(i,e=null)=>JZ(i,e),Gg=(i,e=null)=>new eJ(i,e),Qf=(i,e=null)=>new tJ(i,e),gt=(...i)=>new nJ(...i),$t=(...i)=>new iJ(...i),Ke=(i,e)=>{const t=new Pm(i,e),n=(...r)=>{let s;return Gg(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return n.shaderNode=t,n.setLayout=r=>(t.setLayout(r),n),n.once=()=>(t.once=!0,n),n},cJ=(...i)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),Ke(...i));mt("toGlobal",i=>(i.global=!0,i));const yg=i=>{R0=i},BM=()=>R0,ii=(...i)=>R0.If(...i);function KP(i){return R0&&R0.add(i),i}mt("append",KP);const ZP=new ls("color"),xe=new ls("float",Ry.float),Ee=new ls("int",Ry.ints),rn=new ls("uint",Ry.uint),Pc=new ls("bool",Ry.bool),Lt=new ls("vec2"),As=new ls("ivec2"),JP=new ls("uvec2"),eL=new ls("bvec2"),Ie=new ls("vec3"),tL=new ls("ivec3"),j0=new ls("uvec3"),OM=new ls("bvec3"),_n=new ls("vec4"),nL=new ls("ivec4"),iL=new ls("uvec4"),rL=new ls("bvec4"),Dy=new ls("mat2"),ua=new ls("mat3"),Kf=new ls("mat4"),hJ=(i="")=>wt(new Rl(i,"string")),fJ=i=>wt(new Rl(i,"ArrayBuffer"));mt("toColor",ZP);mt("toFloat",xe);mt("toInt",Ee);mt("toUint",rn);mt("toBool",Pc);mt("toVec2",Lt);mt("toIVec2",As);mt("toUVec2",JP);mt("toBVec2",eL);mt("toVec3",Ie);mt("toIVec3",tL);mt("toUVec3",j0);mt("toBVec3",OM);mt("toVec4",_n);mt("toIVec4",nL);mt("toUVec4",iL);mt("toBVec4",rL);mt("toMat2",Dy);mt("toMat3",ua);mt("toMat4",Kf);const sL=gt(dd),aL=(i,e)=>wt(new WP(wt(i),e)),dJ=(i,e)=>wt(new Vw(wt(i),e));mt("element",sL);mt("convert",aL);class oL extends Nn{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const lL=i=>new oL(i),IM=(i,e=0)=>new oL(i,!0,e),uL=IM("frame"),Ln=IM("render"),FM=lL("object");class qg extends DM{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=FM}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(r=>{const s=e(r,n);s!==void 0&&(this.value=s)},t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),l=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(l);return e.context.label!==void 0&&delete e.context.label,e.format(u,n,t)}}const yn=(i,e)=>{const t=QP(e||i),n=i&&i.isNode===!0?i.node&&i.node.value||i.value:i;return wt(new qg(n,t))};class Ii extends Nn{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const cL=(i,e)=>wt(new Ii(i,e)),xg=(i,e)=>wt(new Ii(i,e,!0)),Ri=$t(Ii,"vec4","DiffuseColor"),Hw=$t(Ii,"vec3","EmissiveColor"),$l=$t(Ii,"float","Roughness"),bg=$t(Ii,"float","Metalness"),W_=$t(Ii,"float","Clearcoat"),Sg=$t(Ii,"float","ClearcoatRoughness"),Vf=$t(Ii,"vec3","Sheen"),Py=$t(Ii,"float","SheenRoughness"),Ly=$t(Ii,"float","Iridescence"),kM=$t(Ii,"float","IridescenceIOR"),zM=$t(Ii,"float","IridescenceThickness"),$_=$t(Ii,"float","AlphaT"),Th=$t(Ii,"float","Anisotropy"),Lm=$t(Ii,"vec3","AnisotropyT"),Zf=$t(Ii,"vec3","AnisotropyB"),Oa=$t(Ii,"color","SpecularColor"),wg=$t(Ii,"float","SpecularF90"),X_=$t(Ii,"float","Shininess"),Tg=$t(Ii,"vec4","Output"),Xv=$t(Ii,"float","dashSize"),Ww=$t(Ii,"float","gapSize"),AJ=$t(Ii,"float","pointWidth"),Um=$t(Ii,"float","IOR"),Y_=$t(Ii,"float","Transmission"),GM=$t(Ii,"float","Thickness"),qM=$t(Ii,"float","AttenuationDistance"),VM=$t(Ii,"color","AttenuationColor"),jM=$t(Ii,"float","Dispersion");class pJ extends Zr{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return fd.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:r}=this,s=this.needsSplitAssign(e),a=n.getNodeType(e),l=n.context({assign:!0}).build(e),u=r.build(e,a),h=r.getNodeType(e),m=e.getDataFromNode(this);let v;if(m.initialized===!0)t!=="void"&&(v=l);else if(s){const x=e.getVarFromNode(this,null,a),S=e.getPropertyName(x);e.addLineFlowCode(`${S} = ${u}`,this);const T=n.node.context({assign:!0}).build(e);for(let N=0;N{const m=h.type,v=m==="pointer";let x;return v?x="&"+u.build(e):x=u.build(e,m),x};if(Array.isArray(s))for(let u=0;u(e=e.length>1||e[0]&&e[0].isNode===!0?Qf(e):Gg(e[0]),wt(new mJ(wt(i),e)));mt("call",fL);class Tr extends Zr{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let s=new Tr(e,t,n);for(let a=0;a>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="=="||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="<"||n===">"||n==="<="||n===">="){const u=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(l));return u>1?`bvec${u}`:"bool"}else return a==="float"&&e.isMatrix(l)?l:e.isMatrix(a)&&e.isVector(l)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(l)?e.getVectorFromMatrix(l):e.getTypeLength(l)>e.getTypeLength(a)?l:a}generate(e,t){const n=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let l=null,u=null;a!=="void"?(l=r.getNodeType(e),u=typeof s<"u"?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="?e.isVector(l)?u=l:l!==u&&(l=u="float"):n===">>"||n==="<<"?(l=a,u=e.changeComponentType(u,"uint")):e.isMatrix(l)&&e.isVector(u)?u=e.getVectorFromMatrix(l):e.isVector(l)&&e.isMatrix(u)?l=e.getVectorFromMatrix(u):l=u=a):l=u=a;const h=r.build(e,l),m=typeof s<"u"?s.build(e,u):null,v=e.getTypeLength(t),x=e.getFunctionOperator(n);if(t!=="void")return n==="<"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} < ${m} )`,a,t):n==="<="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} <= ${m} )`,a,t):n===">"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} > ${m} )`,a,t):n===">="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} >= ${m} )`,a,t):n==="!"||n==="~"?e.format(`(${n}${h})`,l,t):x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`( ${h} ${n} ${m} )`,a,t);if(l!=="void")return x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`${h} ${n} ${m}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Qr=gt(Tr,"+"),yi=gt(Tr,"-"),Kn=gt(Tr,"*"),Cl=gt(Tr,"/"),HM=gt(Tr,"%"),dL=gt(Tr,"=="),AL=gt(Tr,"!="),pL=gt(Tr,"<"),WM=gt(Tr,">"),mL=gt(Tr,"<="),gL=gt(Tr,">="),vL=gt(Tr,"&&"),_L=gt(Tr,"||"),yL=gt(Tr,"!"),xL=gt(Tr,"^^"),bL=gt(Tr,"&"),SL=gt(Tr,"~"),wL=gt(Tr,"|"),TL=gt(Tr,"^"),ML=gt(Tr,"<<"),EL=gt(Tr,">>");mt("add",Qr);mt("sub",yi);mt("mul",Kn);mt("div",Cl);mt("modInt",HM);mt("equal",dL);mt("notEqual",AL);mt("lessThan",pL);mt("greaterThan",WM);mt("lessThanEqual",mL);mt("greaterThanEqual",gL);mt("and",vL);mt("or",_L);mt("not",yL);mt("xor",xL);mt("bitAnd",bL);mt("bitNot",SL);mt("bitOr",wL);mt("bitXor",TL);mt("shiftLeft",ML);mt("shiftRight",EL);const CL=(...i)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),HM(...i));mt("remainder",CL);class Qe extends Zr{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),l=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>l?t:a>l?n:l>s?r:t}getNodeType(e){const t=this.method;return t===Qe.LENGTH||t===Qe.DISTANCE||t===Qe.DOT?"float":t===Qe.CROSS?"vec3":t===Qe.ALL?"bool":t===Qe.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===Qe.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){let n=this.method;const r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,l=this.bNode,u=this.cNode,h=e.renderer.coordinateSystem;if(n===Qe.TRANSFORM_DIRECTION){let m=a,v=l;e.isMatrix(m.getNodeType(e))?v=_n(Ie(v),0):m=_n(Ie(m),0);const x=Kn(m,v).xyz;return Lc(x).build(e,t)}else{if(n===Qe.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(n===Qe.ONE_MINUS)return yi(1,a).build(e,t);if(n===Qe.RECIPROCAL)return Cl(1,a).build(e,t);if(n===Qe.DIFFERENCE)return rr(yi(a,l)).build(e,t);{const m=[];return n===Qe.CROSS||n===Qe.MOD?m.push(a.build(e,r),l.build(e,r)):h===Ga&&n===Qe.STEP?m.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),l.build(e,s)):h===Ga&&(n===Qe.MIN||n===Qe.MAX)||n===Qe.MOD?m.push(a.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):n===Qe.REFRACT?m.push(a.build(e,s),l.build(e,s),u.build(e,"float")):n===Qe.MIX?m.push(a.build(e,s),l.build(e,s),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":s)):(h===cu&&n===Qe.ATAN&&l!==null&&(n="atan2"),m.push(a.build(e,s)),l!==null&&m.push(l.build(e,s)),u!==null&&m.push(u.build(e,s))),e.format(`${e.getMethod(n,r)}( ${m.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Qe.ALL="all";Qe.ANY="any";Qe.RADIANS="radians";Qe.DEGREES="degrees";Qe.EXP="exp";Qe.EXP2="exp2";Qe.LOG="log";Qe.LOG2="log2";Qe.SQRT="sqrt";Qe.INVERSE_SQRT="inversesqrt";Qe.FLOOR="floor";Qe.CEIL="ceil";Qe.NORMALIZE="normalize";Qe.FRACT="fract";Qe.SIN="sin";Qe.COS="cos";Qe.TAN="tan";Qe.ASIN="asin";Qe.ACOS="acos";Qe.ATAN="atan";Qe.ABS="abs";Qe.SIGN="sign";Qe.LENGTH="length";Qe.NEGATE="negate";Qe.ONE_MINUS="oneMinus";Qe.DFDX="dFdx";Qe.DFDY="dFdy";Qe.ROUND="round";Qe.RECIPROCAL="reciprocal";Qe.TRUNC="trunc";Qe.FWIDTH="fwidth";Qe.TRANSPOSE="transpose";Qe.BITCAST="bitcast";Qe.EQUALS="equals";Qe.MIN="min";Qe.MAX="max";Qe.MOD="mod";Qe.STEP="step";Qe.REFLECT="reflect";Qe.DISTANCE="distance";Qe.DIFFERENCE="difference";Qe.DOT="dot";Qe.CROSS="cross";Qe.POW="pow";Qe.TRANSFORM_DIRECTION="transformDirection";Qe.MIX="mix";Qe.CLAMP="clamp";Qe.REFRACT="refract";Qe.SMOOTHSTEP="smoothstep";Qe.FACEFORWARD="faceforward";const NL=xe(1e-6),gJ=xe(1e6),Q_=xe(Math.PI),vJ=xe(Math.PI*2),$M=gt(Qe,Qe.ALL),RL=gt(Qe,Qe.ANY),DL=gt(Qe,Qe.RADIANS),PL=gt(Qe,Qe.DEGREES),XM=gt(Qe,Qe.EXP),D0=gt(Qe,Qe.EXP2),Uy=gt(Qe,Qe.LOG),su=gt(Qe,Qe.LOG2),Su=gt(Qe,Qe.SQRT),YM=gt(Qe,Qe.INVERSE_SQRT),au=gt(Qe,Qe.FLOOR),By=gt(Qe,Qe.CEIL),Lc=gt(Qe,Qe.NORMALIZE),kc=gt(Qe,Qe.FRACT),So=gt(Qe,Qe.SIN),pc=gt(Qe,Qe.COS),LL=gt(Qe,Qe.TAN),UL=gt(Qe,Qe.ASIN),BL=gt(Qe,Qe.ACOS),QM=gt(Qe,Qe.ATAN),rr=gt(Qe,Qe.ABS),Mg=gt(Qe,Qe.SIGN),wc=gt(Qe,Qe.LENGTH),OL=gt(Qe,Qe.NEGATE),IL=gt(Qe,Qe.ONE_MINUS),KM=gt(Qe,Qe.DFDX),ZM=gt(Qe,Qe.DFDY),FL=gt(Qe,Qe.ROUND),kL=gt(Qe,Qe.RECIPROCAL),JM=gt(Qe,Qe.TRUNC),zL=gt(Qe,Qe.FWIDTH),GL=gt(Qe,Qe.TRANSPOSE),_J=gt(Qe,Qe.BITCAST),qL=gt(Qe,Qe.EQUALS),Za=gt(Qe,Qe.MIN),Gr=gt(Qe,Qe.MAX),eE=gt(Qe,Qe.MOD),Oy=gt(Qe,Qe.STEP),VL=gt(Qe,Qe.REFLECT),jL=gt(Qe,Qe.DISTANCE),HL=gt(Qe,Qe.DIFFERENCE),jh=gt(Qe,Qe.DOT),Iy=gt(Qe,Qe.CROSS),Tl=gt(Qe,Qe.POW),tE=gt(Qe,Qe.POW,2),WL=gt(Qe,Qe.POW,3),$L=gt(Qe,Qe.POW,4),XL=gt(Qe,Qe.TRANSFORM_DIRECTION),YL=i=>Kn(Mg(i),Tl(rr(i),1/3)),QL=i=>jh(i,i),Ui=gt(Qe,Qe.MIX),du=(i,e=0,t=1)=>wt(new Qe(Qe.CLAMP,wt(i),wt(e),wt(t))),KL=i=>du(i),nE=gt(Qe,Qe.REFRACT),Uc=gt(Qe,Qe.SMOOTHSTEP),iE=gt(Qe,Qe.FACEFORWARD),ZL=Ke(([i])=>{const n=43758.5453,r=jh(i.xy,Lt(12.9898,78.233)),s=eE(r,Q_);return kc(So(s).mul(n))}),JL=(i,e,t)=>Ui(e,t,i),e9=(i,e,t)=>Uc(e,t,i),t9=(i,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),QM(i,e)),yJ=iE,xJ=YM;mt("all",$M);mt("any",RL);mt("equals",qL);mt("radians",DL);mt("degrees",PL);mt("exp",XM);mt("exp2",D0);mt("log",Uy);mt("log2",su);mt("sqrt",Su);mt("inverseSqrt",YM);mt("floor",au);mt("ceil",By);mt("normalize",Lc);mt("fract",kc);mt("sin",So);mt("cos",pc);mt("tan",LL);mt("asin",UL);mt("acos",BL);mt("atan",QM);mt("abs",rr);mt("sign",Mg);mt("length",wc);mt("lengthSq",QL);mt("negate",OL);mt("oneMinus",IL);mt("dFdx",KM);mt("dFdy",ZM);mt("round",FL);mt("reciprocal",kL);mt("trunc",JM);mt("fwidth",zL);mt("atan2",t9);mt("min",Za);mt("max",Gr);mt("mod",eE);mt("step",Oy);mt("reflect",VL);mt("distance",jL);mt("dot",jh);mt("cross",Iy);mt("pow",Tl);mt("pow2",tE);mt("pow3",WL);mt("pow4",$L);mt("transformDirection",XL);mt("mix",JL);mt("clamp",du);mt("refract",nE);mt("smoothstep",e9);mt("faceForward",iE);mt("difference",HL);mt("saturate",KL);mt("cbrt",YL);mt("transpose",GL);mt("rand",ZL);class bJ extends Nn{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:l}=e.getNodeProperties(this),u=t!=="void",h=u?cL(n).build(e):"";r.nodeProperty=h;const m=s.build(e,"bool");e.addFlowCode(` +${e.tab}if ( ${m} ) { + +`).addFlowTab();let v=a.build(e,n);if(v&&(u?v=h+" = "+v+";":v="return "+v+";"),e.removeFlowTab().addFlowCode(e.tab+" "+v+` + +`+e.tab+"}"),l!==null){e.addFlowCode(` else { + +`).addFlowTab();let x=l.build(e,n);x&&(u?x=h+" = "+x+";":x="return "+x+";"),e.removeFlowTab().addFlowCode(e.tab+" "+x+` + +`+e.tab+`} + +`)}else e.addFlowCode(` + +`);return e.format(h,n,t)}}const zs=gt(bJ);mt("select",zs);const n9=(...i)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),zs(...i));mt("cond",n9);class i9 extends Nn{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(n),r}}const Fy=gt(i9),r9=(i,e)=>Fy(i,{label:e});mt("context",Fy);mt("label",r9);class Yv extends Nn{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const s9=gt(Yv);mt("toVar",(...i)=>s9(...i).append());const a9=i=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),s9(i));mt("temp",a9);class SJ extends Nn{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,s),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e),r=e.shaderStage==="fragment"&&t.reassignPosition===!0&&e.context.needsPositionReassign;if(t.propertyName===void 0||r){const s=this.getNodeType(e),a=e.getPropertyName(n,zw.VERTEX);e.flowNodeFromShaderStage(zw.VERTEX,this.node,s,a),t.propertyName=a,r?t.reassignPosition=!1:t.reassignPosition===void 0&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(n)}}const to=gt(SJ),o9=i=>to(i);mt("varying",to);mt("vertexStage",o9);const l9=Ke(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return Ui(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),u9=Ke(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return Ui(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Vg="WorkingColorSpace",rE="OutputColorSpace";class jg extends Zr{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===Vg?li.workingColorSpace:t===rE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return li.enabled===!1||n===r||!n||!r||(li.getTransfer(n)===Fi&&(s=_n(l9(s.rgb),s.a)),li.getPrimaries(n)!==li.getPrimaries(r)&&(s=_n(ua(li._getMatrix(new Xn,n,r)).mul(s.rgb),s.a)),li.getTransfer(r)===Fi&&(s=_n(u9(s.rgb),s.a))),s}}const c9=i=>wt(new jg(wt(i),Vg,rE)),h9=i=>wt(new jg(wt(i),rE,Vg)),f9=(i,e)=>wt(new jg(wt(i),Vg,e)),sE=(i,e)=>wt(new jg(wt(i),e,Vg)),wJ=(i,e,t)=>wt(new jg(wt(i),e,t));mt("toOutputColorSpace",c9);mt("toWorkingColorSpace",h9);mt("workingToColorSpace",f9);mt("colorSpaceToWorking",sE);let TJ=class extends dd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class d9 extends Nn{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=Qn.OBJECT}setGroup(e){return this.group=e,this}element(e){return wt(new TJ(this,wt(e)))}setNodeType(e){const t=yn(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rwt(new d9(i,e,t));class EJ extends d9{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Ln)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const A9=(i,e,t=null)=>wt(new EJ(i,e,t));class CJ extends Zr{static get type(){return"ToneMappingNode"}constructor(e,t=m9,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return RM(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Ya)return t;let r=null;const s=e.renderer.library.getToneMappingFunction(n);return s!==null?r=_n(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const p9=(i,e,t)=>wt(new CJ(i,wt(e),wt(t))),m9=A9("toneMappingExposure","float");mt("toneMapping",(i,e,t)=>p9(e,t,i));class NJ extends DM{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=s_,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,l=n.isInterleavedBuffer===!0?n:new JT(n,s),u=new Kl(l,r,a);l.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=to(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Hg=(i,e=null,t=0,n=0)=>wt(new NJ(i,e,t,n)),g9=(i,e=null,t=0,n=0)=>Hg(i,e,t,n).setUsage(IA),K_=(i,e=null,t=0,n=0)=>Hg(i,e,t,n).setInstanced(!0),$w=(i,e=null,t=0,n=0)=>g9(i,e,t,n).setInstanced(!0);mt("toAttribute",i=>Hg(i.value));class RJ extends Nn{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Qn.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let r=1;rwt(new RJ(wt(i),e,t));mt("compute",v9);class DJ extends Nn{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(n),s}}const Bm=(i,e)=>wt(new DJ(wt(i),e));mt("cache",Bm);class PJ extends Nn{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const _9=gt(PJ);mt("bypass",_9);class y9 extends Nn{static get type(){return"RemapNode"}constructor(e,t,n,r=xe(0),s=xe(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:s,doClamp:a}=this;let l=e.sub(t).div(n.sub(t));return a===!0&&(l=l.clamp()),l.mul(s.sub(r)).add(r)}}const x9=gt(y9,null,null,{doClamp:!1}),b9=gt(y9);mt("remap",x9);mt("remapClamp",b9);class Qv extends Nn{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,n,t)}}const zh=gt(Qv),S9=i=>(i?zs(i,zh("discard")):zh("discard")).append(),LJ=()=>zh("return").append();mt("discard",S9);class UJ extends Zr{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Ya,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||To;return n!==Ya&&(t=t.toneMapping(n)),r!==To&&r!==li.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const w9=(i,e=null,t=null)=>wt(new UJ(wt(i),e,t));mt("renderOutput",w9);function BJ(i){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class T9 extends Nn{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(s),l=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(l.name,a,n):to(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Au=(i,e)=>wt(new T9(i,e)),Mr=(i=0)=>Au("uv"+(i>0?i:""),"vec2");class OJ extends Nn{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const Uh=gt(OJ);class IJ extends qg{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Qn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:s}=n;this.value=Math.log2(Math.max(r,s))}}}const M9=gt(IJ);class pu extends qg{static get type(){return"TextureNode"}constructor(e,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Qn.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Nr?"uvec4":this.value.type===Ns?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Mr(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=yn(this.value.matrix)),this._matrixUniform.mul(Ie(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Qn.RENDER:Qn.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Ee(Uh(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this)),r||(r=this.getDefaultUV()),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,n,r,s,a,l,u){const h=this.value;let m;return r?m=e.generateTextureLevel(h,t,n,r,a):s?m=e.generateTextureBias(h,t,n,s,a):u?m=e.generateTextureGrad(h,t,n,u,a):l?m=e.generateTextureCompare(h,t,n,l,a):this.sampler===!1?m=e.generateTextureLoad(h,t,n,a):m=e.generateTexture(h,t,n,a),m}generate(e,t){const n=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let l=a.propertyName;if(l===void 0){const{uvNode:m,levelNode:v,biasNode:x,compareNode:S,depthNode:T,gradNode:N}=r,C=this.generateUV(e,m),E=v?v.build(e,"float"):null,O=x?x.build(e,"float"):null,U=T?T.build(e,"int"):null,I=S?S.build(e,"float"):null,j=N?[N[0].build(e,"vec2"),N[1].build(e,"vec2")]:null,z=e.getVarFromNode(this);l=e.getPropertyName(z);const G=this.generateSnippet(e,s,C,E,O,U,I,j);e.addLineFlowCode(`${l} = ${G}`,this),a.snippet=G,a.propertyName=l}let u=l;const h=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=sE(zh(u,h),n.colorSpace).setup(e).build(e,h)),e.format(u,h,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}blur(e){const t=this.clone();return t.biasNode=wt(e).mul(M9(t)),t.referenceNode=this.getSelf(),wt(t)}level(e){const t=this.clone();return t.levelNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}size(e){return Uh(this,e)}bias(e){const t=this.clone();return t.biasNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}compare(e){const t=this.clone();return t.compareNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}grad(e,t){const n=this.clone();return n.gradNode=[wt(e),wt(t)],n.referenceNode=this.getSelf(),wt(n)}depth(e){const t=this.clone();return t.depthNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const fi=gt(pu),Ir=(...i)=>fi(...i).setSampler(!1),FJ=i=>(i.isNode===!0?i:fi(i)).convert("sampler"),Eh=yn("float").label("cameraNear").setGroup(Ln).onRenderUpdate(({camera:i})=>i.near),Ch=yn("float").label("cameraFar").setGroup(Ln).onRenderUpdate(({camera:i})=>i.far),Ad=yn("mat4").label("cameraProjectionMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.projectionMatrix),kJ=yn("mat4").label("cameraProjectionMatrixInverse").setGroup(Ln).onRenderUpdate(({camera:i})=>i.projectionMatrixInverse),no=yn("mat4").label("cameraViewMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.matrixWorldInverse),zJ=yn("mat4").label("cameraWorldMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.matrixWorld),GJ=yn("mat3").label("cameraNormalMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.normalMatrix),E9=yn(new me).label("cameraPosition").setGroup(Ln).onRenderUpdate(({camera:i},e)=>e.value.setFromMatrixPosition(i.matrixWorld));class Ni extends Nn{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Qn.OBJECT,this._uniformNode=new qg(null)}getNodeType(){const e=this.scope;if(e===Ni.WORLD_MATRIX)return"mat4";if(e===Ni.POSITION||e===Ni.VIEW_POSITION||e===Ni.DIRECTION||e===Ni.SCALE)return"vec3"}update(e){const t=this.object3d,n=this._uniformNode,r=this.scope;if(r===Ni.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===Ni.POSITION)n.value=n.value||new me,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===Ni.SCALE)n.value=n.value||new me,n.value.setFromMatrixScale(t.matrixWorld);else if(r===Ni.DIRECTION)n.value=n.value||new me,t.getWorldDirection(n.value);else if(r===Ni.VIEW_POSITION){const s=e.camera;n.value=n.value||new me,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===Ni.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===Ni.POSITION||t===Ni.VIEW_POSITION||t===Ni.DIRECTION||t===Ni.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Ni.WORLD_MATRIX="worldMatrix";Ni.POSITION="position";Ni.SCALE="scale";Ni.VIEW_POSITION="viewPosition";Ni.DIRECTION="direction";const qJ=gt(Ni,Ni.DIRECTION),VJ=gt(Ni,Ni.WORLD_MATRIX),C9=gt(Ni,Ni.POSITION),jJ=gt(Ni,Ni.SCALE),HJ=gt(Ni,Ni.VIEW_POSITION);class mu extends Ni{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const WJ=$t(mu,mu.DIRECTION),Ho=$t(mu,mu.WORLD_MATRIX),$J=$t(mu,mu.POSITION),XJ=$t(mu,mu.SCALE),YJ=$t(mu,mu.VIEW_POSITION),N9=yn(new Xn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),QJ=yn(new jn).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),H0=Ke(i=>i.renderer.nodes.modelViewMatrix||R9).once()().toVar("modelViewMatrix"),R9=no.mul(Ho),KJ=Ke(i=>(i.context.isHighPrecisionModelViewMatrix=!0,yn("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),ZJ=Ke(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return yn("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),ky=Au("position","vec3"),zr=ky.varying("positionLocal"),Z_=ky.varying("positionPrevious"),Tc=Ho.mul(zr).xyz.varying("v_positionWorld").context({needsPositionReassign:!0}),aE=zr.transformDirection(Ho).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection").context({needsPositionReassign:!0}),Xr=Ke(i=>i.context.setupPositionView(),"vec3").once()().varying("v_positionView").context({needsPositionReassign:!0}),hr=Xr.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class JJ extends Nn{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===Ga&&n.side===or?"false":e.getFrontFacing()}}const D9=$t(JJ),Wg=xe(D9).mul(2).sub(1),zy=Au("normal","vec3"),Ja=Ke(i=>i.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),Ie(0,1,0)):zy,"vec3").once()().toVar("normalLocal"),P9=Xr.dFdx().cross(Xr.dFdy()).normalize().toVar("normalFlat"),Ko=Ke(i=>{let e;return i.material.flatShading===!0?e=P9:e=to(oE(Ja),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Gy=to(Ko.transformDirection(no),"v_normalWorld").normalize().toVar("normalWorld"),kr=Ke(i=>i.context.setupNormal(),"vec3").once()().mul(Wg).toVar("transformedNormalView"),qy=kr.transformDirection(no).toVar("transformedNormalWorld"),HA=Ke(i=>i.context.setupClearcoatNormal(),"vec3").once()().mul(Wg).toVar("transformedClearcoatNormalView"),L9=Ke(([i,e=Ho])=>{const t=ua(e),n=i.div(Ie(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),oE=Ke(([i],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const n=N9.mul(i);return no.transformDirection(n)}),U9=yn(0).onReference(({material:i})=>i).onRenderUpdate(({material:i})=>i.refractionRatio),B9=hr.negate().reflect(kr),O9=hr.negate().refract(kr,U9),I9=B9.transformDirection(no).toVar("reflectVector"),F9=O9.transformDirection(no).toVar("reflectVector");class eee extends pu{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Xo?I9:e.mapping===Yo?F9:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Ie(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem===cu||!n.isRenderTargetTexture?Ie(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const P0=gt(eee);class lE extends qg{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const $g=(i,e,t)=>wt(new lE(i,e,t));class tee extends dd{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class k9 extends lE{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Rh(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Qn.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;rwt(new k9(i,e)),nee=(i,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),wt(new k9(i,e)));class iee extends dd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class Vy extends Nn{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Qn.OBJECT}element(e){return wt(new iee(this,wt(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=$g(null,e,this.count):Array.isArray(this.getValueFromReference())?t=vc(null,e):e==="texture"?t=fi(null):e==="cubeTexture"?t=P0(null):t=yn(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rwt(new Vy(i,e,t)),Xw=(i,e,t,n)=>wt(new Vy(i,e,n,t));class ree extends Vy{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const _c=(i,e,t=null)=>wt(new ree(i,e,t)),jy=Ke(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),Au("tangent","vec4")))(),Xg=jy.xyz.toVar("tangentLocal"),Yg=H0.mul(_n(Xg,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),z9=Yg.transformDirection(no).varying("v_tangentWorld").normalize().toVar("tangentWorld"),uE=Yg.toVar("transformedTangentView"),see=uE.transformDirection(no).normalize().toVar("transformedTangentWorld"),Qg=i=>i.mul(jy.w).xyz,aee=to(Qg(zy.cross(jy)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),oee=to(Qg(Ja.cross(Xg)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),G9=to(Qg(Ko.cross(Yg)),"v_bitangentView").normalize().toVar("bitangentView"),lee=to(Qg(Gy.cross(z9)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),q9=Qg(kr.cross(uE)).normalize().toVar("transformedBitangentView"),uee=q9.transformDirection(no).normalize().toVar("transformedBitangentWorld"),jf=ua(Yg,G9,Ko),V9=hr.mul(jf),cee=(i,e)=>i.sub(V9.mul(e)),j9=(()=>{let i=Zf.cross(hr);return i=i.cross(Zf).normalize(),i=Ui(i,kr,Th.mul($l.oneMinus()).oneMinus().pow2().pow2()).normalize(),i})(),hee=Ke(i=>{const{eye_pos:e,surf_norm:t,mapN:n,uv:r}=i,s=e.dFdx(),a=e.dFdy(),l=r.dFdx(),u=r.dFdy(),h=t,m=a.cross(h),v=h.cross(s),x=m.mul(l.x).add(v.mul(u.x)),S=m.mul(l.y).add(v.mul(u.y)),T=x.dot(x).max(S.dot(S)),N=Wg.mul(T.inverseSqrt());return Qr(x.mul(n.x,N),S.mul(n.y,N),h.mul(n.z)).normalize()});class fee extends Zr{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Mc}setup(e){const{normalMapType:t,scaleNode:n}=this;let r=this.node.mul(2).sub(1);n!==null&&(r=Ie(r.xy.mul(n),r.z));let s=null;return t===z7?s=oE(r):t===Mc&&(e.hasGeometryAttribute("tangent")===!0?s=jf.mul(r).normalize():s=hee({eye_pos:Xr,surf_norm:Ko,mapN:r,uv:Mr()})),s}}const Yw=gt(fee),dee=Ke(({textureNode:i,bumpScale:e})=>{const t=r=>i.cache().context({getUV:s=>r(s.uvNode||Mr()),forceUVContext:!0}),n=xe(t(r=>r));return Lt(xe(t(r=>r.add(r.dFdx()))).sub(n),xe(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),Aee=Ke(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,l=s.cross(a),u=a.cross(r),h=r.dot(l).mul(Wg),m=h.sign().mul(n.x.mul(l).add(n.y.mul(u)));return h.abs().mul(t).sub(m).normalize()});class pee extends Zr{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=dee({textureNode:this.textureNode,bumpScale:e});return Aee({surf_pos:Xr,surf_norm:Ko,dHdxy:t})}}const H9=gt(pee),IR=new Map;class At extends Nn{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=IR.get(e);return n===void 0&&(n=_c(e,t),IR.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let r=null;if(n===At.COLOR){const s=t.color!==void 0?this.getColor(n):Ie();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(n===At.OPACITY){const s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(n===At.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=xe(1);else if(n===At.SPECULAR_INTENSITY){const s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s}else if(n===At.SPECULAR_COLOR){const s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(n).rgb):r=s}else if(n===At.ROUGHNESS){const s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).g):r=s}else if(n===At.METALNESS){const s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(n).b):r=s}else if(n===At.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(n)):r=a}else if(n===At.NORMAL)t.normalMap?(r=Yw(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=H9(this.getTexture("bump").r,this.getFloat("bumpScale")):r=Ko;else if(n===At.CLEARCOAT){const s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=Yw(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=Ko;else if(n===At.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(n===At.SHEEN_ROUGHNESS){const s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s,r=r.clamp(.07,1)}else if(n===At.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(n);r=Dy(UA.x,UA.y,UA.y.negate(),UA.x).mul(s.rg.mul(2).sub(Lt(1)).normalize().mul(s.b))}else r=UA;else if(n===At.IRIDESCENCE_THICKNESS){const s=zi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=zi("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(n).g).add(a)}else r=s}else if(n===At.TRANSMISSION){const s=this.getFloat(n);t.transmissionMap?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.THICKNESS){const s=this.getFloat(n);t.thicknessMap?r=s.mul(this.getTexture(n).g):r=s}else if(n===At.IOR)r=this.getFloat(n);else if(n===At.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===At.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(n,s)}return r}}At.ALPHA_TEST="alphaTest";At.COLOR="color";At.OPACITY="opacity";At.SHININESS="shininess";At.SPECULAR="specular";At.SPECULAR_STRENGTH="specularStrength";At.SPECULAR_INTENSITY="specularIntensity";At.SPECULAR_COLOR="specularColor";At.REFLECTIVITY="reflectivity";At.ROUGHNESS="roughness";At.METALNESS="metalness";At.NORMAL="normal";At.CLEARCOAT="clearcoat";At.CLEARCOAT_ROUGHNESS="clearcoatRoughness";At.CLEARCOAT_NORMAL="clearcoatNormal";At.EMISSIVE="emissive";At.ROTATION="rotation";At.SHEEN="sheen";At.SHEEN_ROUGHNESS="sheenRoughness";At.ANISOTROPY="anisotropy";At.IRIDESCENCE="iridescence";At.IRIDESCENCE_IOR="iridescenceIOR";At.IRIDESCENCE_THICKNESS="iridescenceThickness";At.IOR="ior";At.TRANSMISSION="transmission";At.THICKNESS="thickness";At.ATTENUATION_DISTANCE="attenuationDistance";At.ATTENUATION_COLOR="attenuationColor";At.LINE_SCALE="scale";At.LINE_DASH_SIZE="dashSize";At.LINE_GAP_SIZE="gapSize";At.LINE_WIDTH="linewidth";At.LINE_DASH_OFFSET="dashOffset";At.POINT_WIDTH="pointWidth";At.DISPERSION="dispersion";At.LIGHT_MAP="light";At.AO="ao";const W9=$t(At,At.ALPHA_TEST),$9=$t(At,At.COLOR),X9=$t(At,At.SHININESS),Y9=$t(At,At.EMISSIVE),cE=$t(At,At.OPACITY),Q9=$t(At,At.SPECULAR),Qw=$t(At,At.SPECULAR_INTENSITY),K9=$t(At,At.SPECULAR_COLOR),Om=$t(At,At.SPECULAR_STRENGTH),Kv=$t(At,At.REFLECTIVITY),Z9=$t(At,At.ROUGHNESS),J9=$t(At,At.METALNESS),eU=$t(At,At.NORMAL).context({getUV:null}),tU=$t(At,At.CLEARCOAT),nU=$t(At,At.CLEARCOAT_ROUGHNESS),iU=$t(At,At.CLEARCOAT_NORMAL).context({getUV:null}),rU=$t(At,At.ROTATION),sU=$t(At,At.SHEEN),aU=$t(At,At.SHEEN_ROUGHNESS),oU=$t(At,At.ANISOTROPY),lU=$t(At,At.IRIDESCENCE),uU=$t(At,At.IRIDESCENCE_IOR),cU=$t(At,At.IRIDESCENCE_THICKNESS),hU=$t(At,At.TRANSMISSION),fU=$t(At,At.THICKNESS),dU=$t(At,At.IOR),AU=$t(At,At.ATTENUATION_DISTANCE),pU=$t(At,At.ATTENUATION_COLOR),mU=$t(At,At.LINE_SCALE),gU=$t(At,At.LINE_DASH_SIZE),vU=$t(At,At.LINE_GAP_SIZE),mee=$t(At,At.LINE_WIDTH),_U=$t(At,At.LINE_DASH_OFFSET),gee=$t(At,At.POINT_WIDTH),yU=$t(At,At.DISPERSION),hE=$t(At,At.LIGHT_MAP),xU=$t(At,At.AO),UA=yn(new bt).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),fE=Ke(i=>i.context.setupModelViewProjection(),"vec4").once()().varying("v_modelViewProjection");class fr extends Nn{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===fr.VERTEX)r=e.getVertexIndex();else if(n===fr.INSTANCE)r=e.getInstanceIndex();else if(n===fr.DRAW)r=e.getDrawIndex();else if(n===fr.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===fr.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===fr.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=to(this).build(e,t),s}}fr.VERTEX="vertex";fr.INSTANCE="instance";fr.SUBGROUP="subgroup";fr.INVOCATION_LOCAL="invocationLocal";fr.INVOCATION_SUBGROUP="invocationSubgroup";fr.DRAW="draw";const bU=$t(fr,fr.VERTEX),Kg=$t(fr,fr.INSTANCE),vee=$t(fr,fr.SUBGROUP),_ee=$t(fr,fr.INVOCATION_SUBGROUP),yee=$t(fr,fr.INVOCATION_LOCAL),SU=$t(fr,fr.DRAW);class wU extends Nn{static get type(){return"InstanceNode"}constructor(e,t,n){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Qn.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:n,instanceColor:r}=this;let{instanceMatrixNode:s,instanceColorNode:a}=this;if(s===null){if(t<=1e3)s=$g(n.array,"mat4",Math.max(t,1)).element(Kg);else{const u=new u_(n.array,16,1);this.buffer=u;const h=n.usage===IA?$w:K_,m=[h(u,"vec4",16,0),h(u,"vec4",16,4),h(u,"vec4",16,8),h(u,"vec4",16,12)];s=Kf(...m)}this.instanceMatrixNode=s}if(r&&a===null){const u=new Bg(r.array,3),h=r.usage===IA?$w:K_;this.bufferColor=u,a=Ie(h(u,"vec3",3,0)),this.instanceColorNode=a}const l=s.mul(zr).xyz;if(zr.assign(l),e.hasGeometryAttribute("normal")){const u=L9(Ja,s);Ja.assign(u)}this.instanceColorNode!==null&&xg("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==IA&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==IA&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const xee=gt(wU);class bee extends wU{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const TU=gt(bee);class See extends Nn{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Kg:this.batchingIdNode=SU);const n=Ke(([T])=>{const N=Uh(Ir(this.batchMesh._indirectTexture),0),C=Ee(T).modInt(Ee(N)),E=Ee(T).div(Ee(N));return Ir(this.batchMesh._indirectTexture,As(C,E)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Ee(this.batchingIdNode)),r=this.batchMesh._matricesTexture,s=Uh(Ir(r),0),a=xe(n).mul(4).toInt().toVar(),l=a.modInt(s),u=a.div(Ee(s)),h=Kf(Ir(r,As(l,u)),Ir(r,As(l.add(1),u)),Ir(r,As(l.add(2),u)),Ir(r,As(l.add(3),u))),m=this.batchMesh._colorsTexture;if(m!==null){const N=Ke(([C])=>{const E=Uh(Ir(m),0).x,O=C,U=O.modInt(E),I=O.div(E);return Ir(m,As(U,I)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);xg("vec3","vBatchColor").assign(N)}const v=ua(h);zr.assign(h.mul(zr));const x=Ja.div(Ie(v[0].dot(v[0]),v[1].dot(v[1]),v[2].dot(v[2]))),S=v.mul(x).xyz;Ja.assign(S),e.hasGeometryAttribute("tangent")&&Xg.mulAssign(v)}}const MU=gt(See),FR=new WeakMap;class EU extends Nn{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=Qn.OBJECT,this.skinIndexNode=Au("skinIndex","uvec4"),this.skinWeightNode=Au("skinWeight","vec4");let n,r,s;t?(n=zi("bindMatrix","mat4"),r=zi("bindMatrixInverse","mat4"),s=Xw("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=yn(e.bindMatrix,"mat4"),r=yn(e.bindMatrixInverse,"mat4"),s=$g(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=zr){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w),v=s.mul(t),x=Qr(l.mul(r.x).mul(v),u.mul(r.y).mul(v),h.mul(r.z).mul(v),m.mul(r.w).mul(v));return a.mul(x).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Ja){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w);let v=Qr(r.x.mul(l),r.y.mul(u),r.z.mul(h),r.w.mul(m));return v=a.mul(v).mul(s),v.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Xw("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Z_)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||qP(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Z_.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(zr.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();Ja.assign(n),e.hasGeometryAttribute("tangent")&&Xg.assign(n)}}generate(e,t){if(t!=="void")return zr.build(e,t)}update(e){const n=(this.useReference?e.object:this.skinnedMesh).skeleton;FR.get(n)!==e.frameId&&(FR.set(n,e.frameId),this.previousBoneMatricesNode!==null&&n.previousBoneMatrices.set(n.boneMatrices),n.update())}}const wee=i=>wt(new EU(i)),CU=i=>wt(new EU(i,!0));class Tee extends Nn{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let s=0,a=this.params.length-1;sNumber(v)?T=">=":T="<"));const C={start:m,end:v},E=C.start,O=C.end;let U="",I="",j="";N||(S==="int"||S==="uint"?T.includes("<")?N="++":N="--":T.includes("<")?N="+= 1.":N="-= 1."),U+=e.getVar(S,x)+" = "+E,I+=x+" "+T+" "+O,j+=x+" "+N;const z=`for ( ${U}; ${I}; ${j} )`;e.addFlowCode((l===0?` +`:"")+e.tab+z+` { + +`).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(` +`+e.tab+s);for(let l=0,u=this.params.length-1;lwt(new Tee(Qf(i,"int"))).append(),Mee=()=>zh("continue").append(),NU=()=>zh("break").append(),Eee=(...i)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),Bi(...i)),X3=new WeakMap,po=new On,kR=Ke(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const a=Ee(bU).mul(t).add(s),l=a.div(n),u=a.sub(l.mul(n));return Ir(i,As(u,l)).depth(r).mul(e)});function Cee(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let a=X3.get(i);if(a===void 0||a.count!==s){let O=function(){C.dispose(),X3.delete(i),i.removeEventListener("dispose",O)};var l=O;a!==void 0&&a.texture.dispose();const u=i.morphAttributes.position||[],h=i.morphAttributes.normal||[],m=i.morphAttributes.color||[];let v=0;e===!0&&(v=1),t===!0&&(v=2),n===!0&&(v=3);let x=i.attributes.position.count*v,S=1;const T=4096;x>T&&(S=Math.ceil(x/T),x=T);const N=new Float32Array(x*S*4*s),C=new XT(N,x,S,s);C.type=$r,C.needsUpdate=!0;const E=v*4;for(let U=0;U{const x=xe(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?x.assign(Ir(this.mesh.morphTexture,As(Ee(v).add(1),Ee(Kg))).r):x.assign(zi("morphTargetInfluences","float").element(v).toVar()),n===!0&&zr.addAssign(kR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:Ee(0)})),r===!0&&Ja.addAssign(kR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:Ee(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const RU=gt(Nee);class W0 extends Nn{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Ree extends W0{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Dee extends i9{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=Ie().toVar("directDiffuse"),r=Ie().toVar("directSpecular"),s=Ie().toVar("indirectDiffuse"),a=Ie().toVar("indirectSpecular"),l={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:Ie().toVar("radiance"),irradiance:Ie().toVar("irradiance"),iblIrradiance:Ie().toVar("iblIrradiance"),ambientOcclusion:xe(1).toVar("ambientOcclusion"),reflectedLight:l,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const DU=gt(Dee);class Pee extends W0{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let im,rm;class ss extends Nn{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ss.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Qn.NONE;return(this.scope===ss.SIZE||this.scope===ss.VIEWPORT)&&(e=Qn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ss.VIEWPORT?t!==null?rm.copy(t.viewport):(e.getViewport(rm),rm.multiplyScalar(e.getPixelRatio())):t!==null?(im.width=t.width,im.height=t.height):e.getDrawingBufferSize(im)}setup(){const e=this.scope;let t=null;return e===ss.SIZE?t=yn(im||(im=new bt)):e===ss.VIEWPORT?t=yn(rm||(rm=new On)):t=Lt(Zg.div(Eg)),t}generate(e){if(this.scope===ss.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(Eg).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}ss.COORDINATE="coordinate";ss.VIEWPORT="viewport";ss.SIZE="size";ss.UV="uv";const gu=$t(ss,ss.UV),Eg=$t(ss,ss.SIZE),Zg=$t(ss,ss.COORDINATE),dE=$t(ss,ss.VIEWPORT),PU=dE.zw,LU=Zg.sub(dE.xy),Lee=LU.div(PU),Uee=Ke(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),Eg),"vec2").once()(),Bee=Ke(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),gu),"vec2").once()(),Oee=Ke(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),gu.flipY()),"vec2").once()(),sm=new bt;class Hy extends pu{static get type(){return"ViewportTextureNode"}constructor(e=gu,t=null,n=null){n===null&&(n=new Q7,n.minFilter=za),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Qn.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(sm);const n=this.value;(n.image.width!==sm.width||n.image.height!==sm.height)&&(n.image.width=sm.width,n.image.height=sm.height,n.needsUpdate=!0);const r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Iee=gt(Hy),AE=gt(Hy,null,null,{generateMipmaps:!0});let Y3=null;class Fee extends Hy{static get type(){return"ViewportDepthTextureNode"}constructor(e=gu,t=null){Y3===null&&(Y3=new Ic),super(e,t,Y3)}}const pE=gt(Fee);class Ha extends Nn{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Ha.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===Ha.DEPTH_BASE)n!==null&&(r=BU().assign(n));else if(t===Ha.DEPTH)e.isPerspectiveCamera?r=UU(Xr.z,Eh,Ch):r=e0(Xr.z,Eh,Ch);else if(t===Ha.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const s=mE(n,Eh,Ch);r=e0(s,Eh,Ch)}else r=n;else r=e0(Xr.z,Eh,Ch);return r}}Ha.DEPTH_BASE="depthBase";Ha.DEPTH="depth";Ha.LINEAR_DEPTH="linearDepth";const e0=(i,e,t)=>i.add(e).div(e.sub(t)),kee=(i,e,t)=>e.sub(t).mul(i).sub(e),UU=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),mE=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),gE=(i,e,t)=>{e=e.max(1e-6).toVar();const n=su(i.negate().div(e)),r=su(t.div(e));return n.div(r)},zee=(i,e,t)=>{const n=i.mul(Uy(t.div(e)));return xe(Math.E).pow(n).mul(e).negate()},BU=gt(Ha,Ha.DEPTH_BASE),vE=$t(Ha,Ha.DEPTH),J_=gt(Ha,Ha.LINEAR_DEPTH),Gee=J_(pE());vE.assign=i=>BU(i);class qee extends Nn{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Vee=gt(qee);class $o extends Nn{static get type(){return"ClippingNode"}constructor(e=$o.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===$o.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===$o.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return Ke(()=>{const n=xe().toVar("distanceToPlane"),r=xe().toVar("distanceToGradient"),s=xe(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=vc(t);Bi(a,({i:h})=>{const m=u.element(h);n.assign(Xr.dot(m.xyz).negate().add(m.w)),r.assign(n.fwidth().div(2)),s.mulAssign(Uc(r.negate(),r,n))})}const l=e.length;if(l>0){const u=vc(e),h=xe(1).toVar("intersectionClipOpacity");Bi(l,({i:m})=>{const v=u.element(m);n.assign(Xr.dot(v.xyz).negate().add(v.w)),r.assign(n.fwidth().div(2)),h.mulAssign(Uc(r.negate(),r,n).oneMinus())}),s.mulAssign(h.oneMinus())}Ri.a.mulAssign(s),Ri.a.equal(0).discard()})()}setupDefault(e,t){return Ke(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const s=vc(t);Bi(n,({i:a})=>{const l=s.element(a);Xr.dot(l.xyz).greaterThan(l.w).discard()})}const r=e.length;if(r>0){const s=vc(e),a=Pc(!0).toVar("clipped");Bi(r,({i:l})=>{const u=s.element(l);a.assign(Xr.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Ke(()=>{const r=vc(e),s=Vee(t.getClipDistance());Bi(n,({i:a})=>{const l=r.element(a),u=Xr.dot(l.xyz).sub(l.w).negate();s.element(a).assign(u)})})()}}$o.ALPHA_TO_COVERAGE="alphaToCoverage";$o.DEFAULT="default";$o.HARDWARE="hardware";const jee=()=>wt(new $o),Hee=()=>wt(new $o($o.ALPHA_TO_COVERAGE)),Wee=()=>wt(new $o($o.HARDWARE)),$ee=.05,zR=Ke(([i])=>kc(Kn(1e4,So(Kn(17,i.x).add(Kn(.1,i.y)))).mul(Qr(.1,rr(So(Kn(13,i.y).add(i.x))))))),GR=Ke(([i])=>zR(Lt(zR(i.xy),i.z))),Xee=Ke(([i])=>{const e=Gr(wc(KM(i.xyz)),wc(ZM(i.xyz))),t=xe(1).div(xe($ee).mul(e)).toVar("pixScale"),n=Lt(D0(au(su(t))),D0(By(su(t)))),r=Lt(GR(au(n.x.mul(i.xyz))),GR(au(n.y.mul(i.xyz)))),s=kc(su(t)),a=Qr(Kn(s.oneMinus(),r.x),Kn(s,r.y)),l=Za(s,s.oneMinus()),u=Ie(a.mul(a).div(Kn(2,l).mul(yi(1,l))),a.sub(Kn(.5,l)).div(yi(1,l)),yi(1,yi(1,a).mul(yi(1,a)).div(Kn(2,l).mul(yi(1,l))))),h=a.lessThan(l.oneMinus()).select(a.lessThan(l).select(u.x,u.y),u.z);return du(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class qr extends oa{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+IP(this)}build(e){this.setup(e)}setupObserver(e){return new HZ(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const r=this.vertexNode||this.setupVertex(e);e.stack.outputNode=r,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let s;const a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);a!==null&&e.stack.add(a);const u=_n(l,Ri.a).max(0);if(s=this.setupOutput(e,u),Tg.assign(s),this.outputNode!==null&&(s=this.outputNode),n!==null){const h=t.getMRT(),m=this.mrtNode;h!==null?(s=h,m!==null&&(s=h.merge(m))):m!==null&&(s=m)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=_n(l)),s=this.setupOutput(e,l)}e.stack.outputNode=s,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=Hee():e.stack.add(jee())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Wee()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=gE(Xr.z,Eh,Ch):r=e0(Xr.z,Eh,Ch))}r!==null&&vE.assign(r).append()}setupPositionView(){return H0.mul(zr).xyz}setupModelViewProjection(){return Ad.mul(Xr)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),fE}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&RU(t).append(),t.isSkinnedMesh===!0&&CU(t).append(),this.displacementMap){const r=_c("displacementMap","texture"),s=_c("displacementScale","float"),a=_c("displacementBias","float");zr.addAssign(Ja.normalize().mul(r.x.mul(s).add(a)))}return t.isBatchedMesh&&MU(t).append(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&TU(t).append(),this.positionNode!==null&&zr.assign(this.positionNode.context({isPositionNodeInput:!0})),zr}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?_n(this.colorNode):$9;this.vertexColors===!0&&t.hasAttribute("color")&&(n=_n(n.xyz.mul(Au("color","vec3")),n.a)),e.instanceColor&&(n=xg("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=xg("vec3","vBatchColor").mul(n)),Ri.assign(n);const r=this.opacityNode?xe(this.opacityNode):cE;if(Ri.a.assign(Ri.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?xe(this.alphaTestNode):W9;Ri.a.lessThanEqual(s).discard()}this.alphaHash===!0&&Ri.a.lessThan(Xee(zr)).discard(),this.transparent===!1&&this.blending===Xa&&this.alphaToCoverage===!1&&Ri.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Ie(0):Ri.rgb}setupNormal(){return this.normalNode?Ie(this.normalNode):eU}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?_c("envMap","cubeTexture"):_c("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Pee(hE)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:xU;t.push(new Ree(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:s}=this,l=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(l&&l.getScope().hasLights){const h=this.setupLightingModel(e);u=DU(l,h,n,r)}else n!==null&&(u=Ie(r!==null?Ui(u,n,r):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Hw.assign(Ie(s||Y9)),u=u.add(Hw)),u}setupOutput(e,t){if(this.fog===!0){const n=e.fogNode;n&&(Tg.assign(t),t=_n(n))}return t}setDefaultValues(e){for(const n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=oa.prototype.toJSON.call(this,e),r=H_(this);n.inputNodes={};for(const{property:a,childNode:l}of r)n.inputNodes[a]=l.toJSON(e).uuid;function s(a){const l=[];for(const u in a){const h=a[u];delete h.metadata,l.push(h)}return l}if(t){const a=s(e.textures),l=s(e.images),u=s(e.nodes);a.length>0&&(n.textures=a),l.length>0&&(n.images=l),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const Yee=new q0;class Qee extends qr{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Yee),this.setValues(e)}}const Kee=new kz;class Zee extends qr{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Kee),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?xe(this.offsetNode):_U,t=this.dashScaleNode?xe(this.dashScaleNode):mU,n=this.dashSizeNode?xe(this.dashSizeNode):gU,r=this.gapSizeNode?xe(this.gapSizeNode):vU;Xv.assign(n),Ww.assign(r);const s=to(Au("lineDistance").mul(t));(e?s.add(e):s).mod(Xv.add(Ww)).greaterThan(Xv).discard()}}let Q3=null;class Jee extends Hy{static get type(){return"ViewportSharedTextureNode"}constructor(e=gu,t=null){Q3===null&&(Q3=new Q7),super(e,t,Q3)}updateReference(){return this}}const ete=gt(Jee),OU=i=>wt(i).mul(.5).add(.5),tte=i=>wt(i).mul(2).sub(1),nte=new Bz;class ite extends qr{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(nte),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?xe(this.opacityNode):cE;Ri.assign(_n(OU(kr),e))}}class rte extends Zr{static get type(){return"EquirectUVNode"}constructor(e=aE){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Lt(t,n)}}const _E=gt(rte);class IU extends X7{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new Vh(5,5,5),a=_E(aE),l=new qr;l.colorNode=fi(t,a,0),l.side=or,l.blending=$a;const u=new Oi(s,l),h=new ZT;h.add(u),t.minFilter===za&&(t.minFilter=ps);const m=new $7(1,10,this),v=e.getMRT();return e.setMRT(null),m.update(e,h),e.setMRT(v),t.minFilter=n,t.currentGenerateMipmaps=r,u.geometry.dispose(),u.material.dispose(),this}}const Im=new WeakMap;class ste extends Zr{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=P0();const t=new vy;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Qn.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:n[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===Oh||a===Ih){if(Im.has(s)){const l=Im.get(s);qR(l,s.mapping),this._cubeTexture=l}else{const l=s.image;if(ate(l)){const u=new IU(l.height);u.fromEquirectangularTexture(t,s),qR(u.texture,s.mapping),this._cubeTexture=u.texture,Im.set(s,u.texture),s.addEventListener("dispose",FU)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function ate(i){return i==null?!1:i.height>0}function FU(i){const e=i.target;e.removeEventListener("dispose",FU);const t=Im.get(e);t!==void 0&&(Im.delete(e),t.dispose())}function qR(i,e){e===Oh?i.mapping=Xo:e===Ih&&(i.mapping=Yo)}const kU=gt(ste);class yE extends W0{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=kU(this.envNode)}}class ote extends W0{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=xe(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Wy{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class zU extends Wy{constructor(){super()}indirect(e,t,n){const r=e.ambientOcclusion,s=e.reflectedLight,a=n.context.irradianceLightMap;s.indirectDiffuse.assign(_n(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(_n(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Ri.rgb)}finish(e,t,n){const r=n.material,s=e.outgoingLight,a=n.context.environment;if(a)switch(r.combine){case Dg:s.rgb.assign(Ui(s.rgb,s.rgb.mul(a.rgb),Om.mul(Kv)));break;case P7:s.rgb.assign(Ui(s.rgb,a.rgb,Om.mul(Kv)));break;case L7:s.rgb.addAssign(a.rgb.mul(Om.mul(Kv)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const lte=new cd;class ute extends qr{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lte),this.setValues(e)}setupNormal(){return Ko}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ote(hE)),t}setupOutgoingLight(){return Ri.rgb}setupLightingModel(){return new zU}}const L0=Ke(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),ld=Ke(i=>i.diffuseColor.mul(1/Math.PI)),cte=()=>xe(.25),hte=Ke(({dotNH:i})=>X_.mul(xe(.5)).add(1).mul(xe(1/Math.PI)).mul(i.pow(X_))),fte=Ke(({lightDirection:i})=>{const e=i.add(hr).normalize(),t=kr.dot(e).clamp(),n=hr.dot(e).clamp(),r=L0({f0:Oa,f90:1,dotVH:n}),s=cte(),a=hte({dotNH:t});return r.mul(s).mul(a)});class GU extends zU{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=kr.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(ld({diffuseColor:Ri.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(fte({lightDirection:e})).mul(Om))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(ld({diffuseColor:Ri}))),n.indirectDiffuse.mulAssign(e)}}const dte=new Fc;class Ate extends qr{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(dte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightingModel(){return new GU(!1)}}const pte=new oD;class mte extends qr{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(pte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightingModel(){return new GU}setupVariants(){const e=(this.shininessNode?xe(this.shininessNode):X9).max(1e-4);X_.assign(e);const t=this.specularNode||Q9;Oa.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const qU=Ke(i=>{if(i.geometry.hasAttribute("normal")===!1)return xe(0);const e=Ko.dFdx().abs().max(Ko.dFdy().abs());return e.x.max(e.y).max(e.z)}),xE=Ke(i=>{const{roughness:e}=i,t=qU();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),VU=Ke(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Cl(.5,r.add(s).max(NL))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),gte=Ke(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:s,dotNV:a,dotNL:l})=>{const u=l.mul(Ie(i.mul(t),e.mul(n),a).length()),h=a.mul(Ie(i.mul(r),e.mul(s),l).length());return Cl(.5,u.add(h)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),jU=Ke(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),vte=xe(1/Math.PI),_te=Ke(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const s=i.mul(e),a=Ie(e.mul(n),i.mul(r),s.mul(t)),l=a.dot(a),u=s.div(l);return vte.mul(s.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),Kw=Ke(i=>{const{lightDirection:e,f0:t,f90:n,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:l}=i,u=i.normalView||kr,h=r.pow2(),m=e.add(hr).normalize(),v=u.dot(e).clamp(),x=u.dot(hr).clamp(),S=u.dot(m).clamp(),T=hr.dot(m).clamp();let N=L0({f0:t,f90:n,dotVH:T}),C,E;if(_g(a)&&(N=Ly.mix(N,s)),_g(l)){const O=Lm.dot(e),U=Lm.dot(hr),I=Lm.dot(m),j=Zf.dot(e),z=Zf.dot(hr),G=Zf.dot(m);C=gte({alphaT:$_,alphaB:h,dotTV:U,dotBV:z,dotTL:O,dotBL:j,dotNV:x,dotNL:v}),E=_te({alphaT:$_,alphaB:h,dotNH:S,dotTH:I,dotBH:G})}else C=VU({alpha:h,dotNL:v,dotNV:x}),E=jU({alpha:h,dotNH:S});return N.mul(C).mul(E)}),bE=Ke(({roughness:i,dotNV:e})=>{const t=_n(-1,-.0275,-.572,.022),n=_n(1,.0425,1.04,-.04),r=i.mul(t).add(n),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return Lt(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),HU=Ke(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,s=bE({dotNV:e,roughness:r});return t.mul(s.x).add(n.mul(s.y))}),WU=Ke(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),s=n.mul(r,r).clamp(0,.9999);return i.sub(Ie(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),yte=Ke(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=xe(1).div(t),s=e.pow2().oneMinus().max(.0078125);return xe(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),xte=Ke(({dotNV:i,dotNL:e})=>xe(1).div(xe(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),bte=Ke(({lightDirection:i})=>{const e=i.add(hr).normalize(),t=kr.dot(i).clamp(),n=kr.dot(hr).clamp(),r=kr.dot(e).clamp(),s=yte({roughness:Py,dotNH:r}),a=xte({dotNV:n,dotNL:t});return Vf.mul(s).mul(a)}),Ste=Ke(({N:i,V:e,roughness:t})=>{const s=.0078125,a=i.dot(e).saturate(),l=Lt(t,a.oneMinus().sqrt());return l.assign(l.mul(.984375).add(s)),l}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),wte=Ke(({f:i})=>{const e=i.length();return Gr(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),ov=Ke(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=r.div(s),l=t.greaterThan(0).select(a,Gr(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return i.cross(e).mul(l)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),VR=Ke(({N:i,V:e,P:t,mInv:n,p0:r,p1:s,p2:a,p3:l})=>{const u=s.sub(r).toVar(),h=l.sub(r).toVar(),m=u.cross(h),v=Ie().toVar();return ii(m.dot(t.sub(r)).greaterThanEqual(0),()=>{const x=e.sub(i.mul(e.dot(i))).normalize(),S=i.cross(x).negate(),T=n.mul(ua(x,S,i).transpose()).toVar(),N=T.mul(r.sub(t)).normalize().toVar(),C=T.mul(s.sub(t)).normalize().toVar(),E=T.mul(a.sub(t)).normalize().toVar(),O=T.mul(l.sub(t)).normalize().toVar(),U=Ie(0).toVar();U.addAssign(ov({v1:N,v2:C})),U.addAssign(ov({v1:C,v2:E})),U.addAssign(ov({v1:E,v2:O})),U.addAssign(ov({v1:O,v2:N})),v.assign(Ie(wte({f:U})))}),v}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),$y=1/6,$U=i=>Kn($y,Kn(i,Kn(i,i.negate().add(3)).sub(3)).add(1)),Zw=i=>Kn($y,Kn(i,Kn(i,Kn(3,i).sub(6))).add(4)),XU=i=>Kn($y,Kn(i,Kn(i,Kn(-3,i).add(3)).add(3)).add(1)),Jw=i=>Kn($y,Tl(i,3)),jR=i=>$U(i).add(Zw(i)),HR=i=>XU(i).add(Jw(i)),WR=i=>Qr(-1,Zw(i).div($U(i).add(Zw(i)))),$R=i=>Qr(1,Jw(i).div(XU(i).add(Jw(i)))),XR=(i,e,t)=>{const n=i.uvNode,r=Kn(n,e.zw).add(.5),s=au(r),a=kc(r),l=jR(a.x),u=HR(a.x),h=WR(a.x),m=$R(a.x),v=WR(a.y),x=$R(a.y),S=Lt(s.x.add(h),s.y.add(v)).sub(.5).mul(e.xy),T=Lt(s.x.add(m),s.y.add(v)).sub(.5).mul(e.xy),N=Lt(s.x.add(h),s.y.add(x)).sub(.5).mul(e.xy),C=Lt(s.x.add(m),s.y.add(x)).sub(.5).mul(e.xy),E=jR(a.y).mul(Qr(l.mul(i.sample(S).level(t)),u.mul(i.sample(T).level(t)))),O=HR(a.y).mul(Qr(l.mul(i.sample(N).level(t)),u.mul(i.sample(C).level(t))));return E.add(O)},YU=Ke(([i,e=xe(3)])=>{const t=Lt(i.size(Ee(e))),n=Lt(i.size(Ee(e.add(1)))),r=Cl(1,t),s=Cl(1,n),a=XR(i,_n(r,t),au(e)),l=XR(i,_n(s,n),By(e));return kc(e).mix(a,l)}),YR=Ke(([i,e,t,n,r])=>{const s=Ie(nE(e.negate(),Lc(i),Cl(1,n))),a=Ie(wc(r[0].xyz),wc(r[1].xyz),wc(r[2].xyz));return Lc(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Tte=Ke(([i,e])=>i.mul(du(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Mte=AE(),Ete=AE(),QR=Ke(([i,e,t],{material:n})=>{const s=(n.side===or?Mte:Ete).sample(i),a=su(Eg.x).mul(Tte(e,t));return YU(s,a)}),KR=Ke(([i,e,t])=>(ii(t.notEqual(0),()=>{const n=Uy(e).negate().div(t);return XM(n.negate().mul(i))}),Ie(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Cte=Ke(([i,e,t,n,r,s,a,l,u,h,m,v,x,S,T])=>{let N,C;if(T){N=_n().toVar(),C=Ie().toVar();const j=m.sub(1).mul(T.mul(.025)),z=Ie(m.sub(j),m,m.add(j));Bi({start:0,end:3},({i:G})=>{const H=z.element(G),q=YR(i,e,v,H,l),V=a.add(q),Q=h.mul(u.mul(_n(V,1))),J=Lt(Q.xy.div(Q.w)).toVar();J.addAssign(1),J.divAssign(2),J.assign(Lt(J.x,J.y.oneMinus()));const ne=QR(J,t,H);N.element(G).assign(ne.element(G)),N.a.addAssign(ne.a),C.element(G).assign(n.element(G).mul(KR(wc(q),x,S).element(G)))}),N.a.divAssign(3)}else{const j=YR(i,e,v,m,l),z=a.add(j),G=h.mul(u.mul(_n(z,1))),H=Lt(G.xy.div(G.w)).toVar();H.addAssign(1),H.divAssign(2),H.assign(Lt(H.x,H.y.oneMinus())),N=QR(H,t,m),C=n.mul(KR(wc(j),x,S))}const E=C.rgb.mul(N.rgb),O=i.dot(e).clamp(),U=Ie(HU({dotNV:O,specularColor:r,specularF90:s,roughness:t})),I=C.r.add(C.g,C.b).div(3);return _n(U.oneMinus().mul(E),N.a.oneMinus().mul(I).oneMinus())}),Nte=ua(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Rte=i=>{const e=i.sqrt();return Ie(1).add(e).div(Ie(1).sub(e))},ZR=(i,e)=>i.sub(e).div(i.add(e)).pow2(),Dte=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=Ie(54856e-17,44201e-17,52481e-17),r=Ie(1681e3,1795300,2208400),s=Ie(43278e5,93046e5,66121e5),a=xe(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let l=n.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return l=Ie(l.x.add(a),l.y,l.z).div(10685e-11),Nte.mul(l)},Pte=Ke(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const s=Ui(i,e,Uc(0,.03,n)),l=i.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();ii(l.lessThan(0),()=>Ie(1));const u=l.sqrt(),h=ZR(s,i),m=L0({f0:h,f90:1,dotVH:t}),v=m.oneMinus(),x=s.lessThan(i).select(Math.PI,0),S=xe(Math.PI).sub(x),T=Rte(r.clamp(0,.9999)),N=ZR(T,s.toVec3()),C=L0({f0:N,f90:1,dotVH:u}),E=Ie(T.x.lessThan(s).select(Math.PI,0),T.y.lessThan(s).select(Math.PI,0),T.z.lessThan(s).select(Math.PI,0)),O=s.mul(n,u,2),U=Ie(S).add(E),I=m.mul(C).clamp(1e-5,.9999),j=I.sqrt(),z=v.pow2().mul(C).div(Ie(1).sub(I)),H=m.add(z).toVar(),q=z.sub(v).toVar();return Bi({start:1,end:2,condition:"<=",name:"m"},({m:V})=>{q.mulAssign(j);const Q=Dte(xe(V).mul(O),xe(V).mul(U)).mul(2);H.addAssign(q.mul(Q))}),H.max(Ie(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Lte=Ke(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.pow2(),s=zs(t.lessThan(.25),xe(-339.2).mul(r).add(xe(161.4).mul(t)).sub(25.9),xe(-8.48).mul(r).add(xe(14.3).mul(t)).sub(9.95)),a=zs(t.lessThan(.25),xe(44).mul(r).sub(xe(23.7).mul(t)).add(3.26),xe(1.97).mul(r).sub(xe(3.27).mul(t)).add(.72));return zs(t.lessThan(.25),0,xe(.1).mul(t).sub(.025)).add(s.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),K3=Ie(.04),Z3=xe(1);class QU extends Wy{constructor(e=!1,t=!1,n=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Ie().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Ie().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Ie().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=Ie().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Ie().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=kr.dot(hr).clamp();this.iridescenceFresnel=Pte({outsideIOR:xe(1),eta2:kM,cosTheta1:t,thinFilmThickness:zM,baseF0:Oa}),this.iridescenceF0=WU({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Tc,n=E9.sub(Tc).normalize(),r=qy;e.backdrop=Cte(r,n,$l,Ri,Oa,wg,t,Ho,no,Ad,Um,GM,VM,qM,this.dispersion?jM:null),e.backdropAlpha=Y_,Ri.a.mulAssign(Ui(1,e.backdrop.a,Y_))}}computeMultiscattering(e,t,n){const r=kr.dot(hr).clamp(),s=bE({roughness:$l,dotNV:r}),l=(this.iridescenceF0?Ly.mix(Oa,this.iridescenceF0):Oa).mul(s.x).add(n.mul(s.y)),h=s.x.add(s.y).oneMinus(),m=Oa.add(Oa.oneMinus().mul(.047619)),v=l.mul(m).div(h.mul(m).oneMinus());e.addAssign(l),t.addAssign(v.mul(h))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=kr.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(s.mul(bte({lightDirection:e}))),this.clearcoat===!0){const l=HA.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(l.mul(Kw({lightDirection:e,f0:K3,f90:Z3,roughness:Sg,normalView:HA})))}n.directDiffuse.addAssign(s.mul(ld({diffuseColor:Ri.rgb}))),n.directSpecular.addAssign(s.mul(Kw({lightDirection:e,f0:Oa,f90:1,roughness:$l,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:l}){const u=t.add(n).sub(r),h=t.sub(n).sub(r),m=t.sub(n).add(r),v=t.add(n).add(r),x=kr,S=hr,T=Xr.toVar(),N=Ste({N:x,V:S,roughness:$l}),C=a.sample(N).toVar(),E=l.sample(N).toVar(),O=ua(Ie(C.x,0,C.y),Ie(0,1,0),Ie(C.z,0,C.w)).toVar(),U=Oa.mul(E.x).add(Oa.oneMinus().mul(E.y)).toVar();s.directSpecular.addAssign(e.mul(U).mul(VR({N:x,V:S,P:T,mInv:O,p0:u,p1:h,p2:m,p3:v}))),s.directDiffuse.addAssign(e.mul(Ri).mul(VR({N:x,V:S,P:T,mInv:ua(1,0,0,0,1,0,0,0,1),p0:u,p1:h,p2:m,p3:v})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(ld({diffuseColor:Ri})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Vf,Lte({normal:kr,viewDir:hr,roughness:Py}))),this.clearcoat===!0){const h=HA.dot(hr).clamp(),m=HU({dotNV:h,specularColor:K3,specularF90:Z3,roughness:Sg});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const r=Ie().toVar("singleScattering"),s=Ie().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,wg);const l=r.add(s),u=Ri.mul(l.r.max(l.g).max(l.b).oneMinus());n.indirectSpecular.addAssign(e.mul(r)),n.indirectSpecular.addAssign(s.mul(a)),n.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const r=kr.dot(hr).clamp().add(e),s=$l.mul(-16).oneMinus().negate().exp2(),a=e.sub(r.pow(s).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(a)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=HA.dot(hr).clamp(),r=L0({dotVH:n,f0:K3,f90:Z3}),s=t.mul(W_.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(W_));t.assign(s)}if(this.sheen===!0){const n=Vf.r.max(Vf.g).max(Vf.b).mul(.157).oneMinus(),r=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const JR=xe(1),eT=xe(-2),lv=xe(.8),J3=xe(-1),uv=xe(.4),eS=xe(2),cv=xe(.305),tS=xe(3),e6=xe(.21),Ute=xe(4),t6=xe(4),Bte=xe(16),Ote=Ke(([i])=>{const e=Ie(rr(i)).toVar(),t=xe(-1).toVar();return ii(e.x.greaterThan(e.z),()=>{ii(e.x.greaterThan(e.y),()=>{t.assign(zs(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(zs(i.y.greaterThan(0),1,4))})}).Else(()=>{ii(e.z.greaterThan(e.y),()=>{t.assign(zs(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(zs(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Ite=Ke(([i,e])=>{const t=Lt().toVar();return ii(e.equal(0),()=>{t.assign(Lt(i.z,i.y).div(rr(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Lt(i.x.negate(),i.z.negate()).div(rr(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Lt(i.x.negate(),i.y).div(rr(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Lt(i.z.negate(),i.y).div(rr(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Lt(i.x.negate(),i.z).div(rr(i.y)))}).Else(()=>{t.assign(Lt(i.x,i.y).div(rr(i.z)))}),Kn(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Fte=Ke(([i])=>{const e=xe(0).toVar();return ii(i.greaterThanEqual(lv),()=>{e.assign(JR.sub(i).mul(J3.sub(eT)).div(JR.sub(lv)).add(eT))}).ElseIf(i.greaterThanEqual(uv),()=>{e.assign(lv.sub(i).mul(eS.sub(J3)).div(lv.sub(uv)).add(J3))}).ElseIf(i.greaterThanEqual(cv),()=>{e.assign(uv.sub(i).mul(tS.sub(eS)).div(uv.sub(cv)).add(eS))}).ElseIf(i.greaterThanEqual(e6),()=>{e.assign(cv.sub(i).mul(Ute.sub(tS)).div(cv.sub(e6)).add(tS))}).Else(()=>{e.assign(xe(-2).mul(su(Kn(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),KU=Ke(([i,e])=>{const t=i.toVar();t.assign(Kn(2,t).sub(1));const n=Ie(t,1).toVar();return ii(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ZU=Ke(([i,e,t,n,r,s])=>{const a=xe(t),l=Ie(e),u=du(Fte(a),eT,s),h=kc(u),m=au(u),v=Ie(tT(i,l,m,n,r,s)).toVar();return ii(h.notEqual(0),()=>{const x=Ie(tT(i,l,m.add(1),n,r,s)).toVar();v.assign(Ui(v,x,h))}),v}),tT=Ke(([i,e,t,n,r,s])=>{const a=xe(t).toVar(),l=Ie(e),u=xe(Ote(l)).toVar(),h=xe(Gr(t6.sub(a),0)).toVar();a.assign(Gr(a,t6));const m=xe(D0(a)).toVar(),v=Lt(Ite(l,u).mul(m.sub(2)).add(1)).toVar();return ii(u.greaterThan(2),()=>{v.y.addAssign(m),u.subAssign(3)}),v.x.addAssign(u.mul(m)),v.x.addAssign(h.mul(Kn(3,Bte))),v.y.addAssign(Kn(4,D0(s).sub(m))),v.x.mulAssign(n),v.y.mulAssign(r),i.sample(v).grad(Lt(),Lt())}),nS=Ke(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:l})=>{const u=pc(n),h=t.mul(u).add(r.cross(t).mul(So(n))).add(r.mul(r.dot(t).mul(u.oneMinus())));return tT(i,h,e,s,a,l)}),JU=Ke(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:s,dTheta:a,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})=>{const x=Ie(zs(e,t,Iy(t,n))).toVar();ii($M(x.equals(Ie(0))),()=>{x.assign(Ie(n.z,0,n.x.negate()))}),x.assign(Lc(x));const S=Ie().toVar();return S.addAssign(r.element(Ee(0)).mul(nS({theta:0,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),Bi({start:Ee(1),end:i},({i:T})=>{ii(T.greaterThanEqual(s),()=>{NU()});const N=xe(a.mul(xe(T))).toVar();S.addAssign(r.element(T).mul(nS({theta:N.mul(-1),axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),S.addAssign(r.element(T).mul(nS({theta:N,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})))}),_n(S,1)});let ey=null;const n6=new WeakMap;function kte(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function zte(i){let e=n6.get(i);if((e!==void 0?e.pmremVersion:-1)!==i.pmremVersion){const n=i.image;if(i.isCubeTexture)if(qte(n))e=ey.fromCubemap(i,e);else return null;else if(Vte(n))e=ey.fromEquirectangular(i,e);else return null;e.pmremVersion=i.pmremVersion,n6.set(i,e)}return e.texture}class Gte extends Zr{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new ms;r.isRenderTargetTexture=!0,this._texture=fi(r),this._width=yn(0),this._height=yn(0),this._maxMip=yn(0),this.updateBeforeType=Qn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=kte(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(n.isPMREMTexture===!0?e=n:e=zte(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ey===null&&(ey=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===Ga&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=Ie(t.x.negate(),t.yz)),t=Ie(t.x,t.y.negate(),t.z);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ZU(this._texture,t,r,this._width,this._height,this._maxMip)}}function qte(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n0}const SE=gt(Gte),i6=new WeakMap;class jte extends W0{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const S=n.isTextureNode?n.value:t[n.property];let T=i6.get(S);T===void 0&&(T=SE(S),i6.set(S,T)),n=T}const s=t.envMap?zi("envMapIntensity","float",e.material):zi("environmentIntensity","float",e.scene),l=t.useAnisotropy===!0||t.anisotropy>0?j9:kr,u=n.context(r6($l,l)).mul(s),h=n.context(Hte(qy)).mul(Math.PI).mul(s),m=Bm(u),v=Bm(h);e.context.radiance.addAssign(m),e.context.iblIrradiance.addAssign(v);const x=e.context.lightingModel.clearcoatRadiance;if(x){const S=n.context(r6(Sg,HA)).mul(s),T=Bm(S);x.addAssign(T)}}}const r6=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=hr.negate().reflect(e),t=i.mul(i).mix(t,e).normalize(),t=t.transformDirection(no)),t),getTextureLevel:()=>i}},Hte=i=>({getUV:()=>i,getTextureLevel:()=>xe(1)}),Wte=new aD;class eB extends qr{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Wte),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new jte(t):null}setupLightingModel(){return new QU}setupSpecular(){const e=Ui(Ie(.04),Ri.rgb,bg);Oa.assign(e),wg.assign(1)}setupVariants(){const e=this.metalnessNode?xe(this.metalnessNode):J9;bg.assign(e);let t=this.roughnessNode?xe(this.roughnessNode):Z9;t=xE({roughness:t}),$l.assign(t),this.setupSpecular(),Ri.assign(_n(Ri.rgb.mul(e.oneMinus()),Ri.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const $te=new Lz;class Xte extends eB{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues($te),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?xe(this.iorNode):dU;Um.assign(e),Oa.assign(Ui(Za(tE(Um.sub(1).div(Um.add(1))).mul(K9),Ie(1)).mul(Qw),Ri.rgb,bg)),wg.assign(Ui(Qw,1,bg))}setupLightingModel(){return new QU(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?xe(this.clearcoatNode):tU,n=this.clearcoatRoughnessNode?xe(this.clearcoatRoughnessNode):nU;W_.assign(t),Sg.assign(xE({roughness:n}))}if(this.useSheen){const t=this.sheenNode?Ie(this.sheenNode):sU,n=this.sheenRoughnessNode?xe(this.sheenRoughnessNode):aU;Vf.assign(t),Py.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?xe(this.iridescenceNode):lU,n=this.iridescenceIORNode?xe(this.iridescenceIORNode):uU,r=this.iridescenceThicknessNode?xe(this.iridescenceThicknessNode):cU;Ly.assign(t),kM.assign(n),zM.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?Lt(this.anisotropyNode):oU).toVar();Th.assign(t.length()),ii(Th.equal(0),()=>{t.assign(Lt(1,0))}).Else(()=>{t.divAssign(Lt(Th)),Th.assign(Th.saturate())}),$_.assign(Th.pow2().mix($l.pow2(),1)),Lm.assign(jf[0].mul(t.x).add(jf[1].mul(t.y))),Zf.assign(jf[1].mul(t.x).sub(jf[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?xe(this.transmissionNode):hU,n=this.thicknessNode?xe(this.thicknessNode):fU,r=this.attenuationDistanceNode?xe(this.attenuationDistanceNode):AU,s=this.attenuationColorNode?Ie(this.attenuationColorNode):pU;if(Y_.assign(t),GM.assign(n),qM.assign(r),VM.assign(s),this.useDispersion){const a=this.dispersionNode?xe(this.dispersionNode):yU;jM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Ie(this.clearcoatNormalNode):iU}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const Yte=Ke(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=Lt(n.mul(.5).add(.5),0);if(t.material.gradientMap){const s=_c("gradientMap","texture").context({getUV:()=>r});return Ie(s.r)}else{const s=r.fwidth().mul(.5);return Ui(Ie(.7),Ie(1),Uc(xe(.7).sub(s.x),xe(.7).add(s.x),r.x))}});class Qte extends Wy{direct({lightDirection:e,lightColor:t,reflectedLight:n},r,s){const a=Yte({normal:zy,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(a.mul(ld({diffuseColor:Ri.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(ld({diffuseColor:Ri}))),n.indirectDiffuse.mulAssign(e)}}const Kte=new Uz;class Zte extends qr{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Kte),this.setValues(e)}setupLightingModel(){return new Qte}}class Jte extends Zr{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=Ie(hr.z,0,hr.x.negate()).normalize(),t=hr.cross(e);return Lt(e.dot(kr),t.dot(kr)).mul(.495).add(.5)}}const tB=$t(Jte),ene=new Fz;class tne extends qr{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(ene),this.setValues(e)}setupVariants(e){const t=tB;let n;e.material.matcap?n=_c("matcap","texture").context({getUV:()=>t}):n=Ie(Ui(.2,.8,t.y)),Ri.rgb.mulAssign(n.rgb)}}const nne=new eM;class ine extends qr{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.setDefaultValues(nne),this.setValues(e)}}class rne extends Zr{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),a=t.sin();return Dy(s,a,a.negate(),s).mul(n)}else{const s=t,a=Kf(_n(1,0,0,0),_n(0,pc(s.x),So(s.x).negate(),0),_n(0,So(s.x),pc(s.x),0),_n(0,0,0,1)),l=Kf(_n(pc(s.y),0,So(s.y),0),_n(0,1,0,0),_n(So(s.y).negate(),0,pc(s.y),0),_n(0,0,0,1)),u=Kf(_n(pc(s.z),So(s.z).negate(),0,0),_n(So(s.z),pc(s.z),0,0),_n(0,0,1,0),_n(0,0,0,1));return a.mul(l).mul(u).mul(_n(n,1)).xyz}}}const wE=gt(rne),sne=new Qk;class ane extends qr{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(sne),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:l}=this,u=H0.mul(Ie(s||0));let h=Lt(Ho[0].xyz.length(),Ho[1].xyz.length());if(l!==null&&(h=h.mul(l)),r===!1)if(n.isPerspectiveCamera)h=h.mul(u.z.negate());else{const S=xe(2).div(Ad.element(1).element(1));h=h.mul(S.mul(2))}let m=ky.xy;if(t.center&&t.center.isVector2===!0){const S=MJ("center","vec2",t);m=m.sub(S.sub(.5))}m=m.mul(h);const v=xe(a||rU),x=wE(m,v);return _n(u.xy.add(x),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class one extends Wy{constructor(){super(),this.shadowNode=xe(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Ri.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Ri.rgb)}}const lne=new Pz;class une extends qr{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lne),this.setValues(e)}setupLightingModel(){return new one}}const cne=Ke(({texture:i,uv:e})=>{const n=Ie().toVar();return ii(e.x.lessThan(1e-4),()=>{n.assign(Ie(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(Ie(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(Ie(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(Ie(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(Ie(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(Ie(0,0,-1))}).Else(()=>{const s=i.sample(e.add(Ie(-.01,0,0))).r.sub(i.sample(e.add(Ie(.01,0,0))).r),a=i.sample(e.add(Ie(0,-.01,0))).r.sub(i.sample(e.add(Ie(0,.01,0))).r),l=i.sample(e.add(Ie(0,0,-.01))).r.sub(i.sample(e.add(Ie(0,0,.01))).r);n.assign(Ie(s,a,l))}),n.normalize()});class hne extends pu{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Ie(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Ee(Uh(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return cne({texture:this,uv:e})}}const fne=gt(hne);class dne{constructor(e,t){this.nodes=e,this.info=t,this._context=self,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class vu{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const s of e){const a=s.node&&s.node.attribute?s.node.attribute:t.getAttribute(s.name);if(a===void 0)continue;n.push(a);const l=a.isInterleavedBufferAttribute?a.data:a;r.add(l)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:s}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),l=this.getIndex(),u=l!==null,h=n.isInstancedBufferGeometry?n.instanceCount:e.count>1?e.count:1;if(h===0)return null;if(a.instanceCount=h,e.isBatchedMesh===!0)return a;let m=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(m=2);let v=s.start*m,x=(s.start+s.count)*m;r!==null&&(v=Math.max(v,r.start*m),x=Math.min(x,(r.start+r.count)*m));const S=n.attributes.position;let T=1/0;u?T=l.count:S!=null&&(T=S.count),v=Math.max(v,0),x=Math.min(x,T);const N=x-v;return N<0||N===1/0?null:(a.vertexCount=N,a.firstVertex=v,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const r of pne(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const s=t[r];let a;if(s!==null){const l=typeof s;l==="number"?a=s!==0?"1":"0":l==="object"?(a="{",s.isTexture&&(a+=s.mapping),a+="}"):a=String(s)}else a=String(s);n+=a+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(n+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",OP(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const bA=[];class gne{constructor(e,t,n,r,s,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=s,this.info=a,this.chainMaps={}}get(e,t,n,r,s,a,l,u){const h=this.getChainMap(u);bA[0]=e,bA[1]=t,bA[2]=a,bA[3]=s;let m=h.get(bA);return m===void 0?(m=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,s,a,l,u),h.set(bA,m)):(m.updateClipping(l),m.needsGeometryUpdate&&m.setGeometry(e.geometry),(m.version!==t.version||m.needsUpdate)&&(m.initialCacheKey!==m.getCacheKey()?(m.dispose(),m=this.get(e,t,n,r,s,a,l,u)):m.version=t.version)),m}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new vu)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,s,a,l,u,h,m,v){const x=this.getChainMap(v),S=new mne(e,t,n,r,s,a,l,u,h,m);return S.onDispose=()=>{this.pipelines.delete(S),this.bindings.delete(S),this.nodes.delete(S),x.delete(S.getChainArray())},S}}class Hh{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Zl={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Nh=16,vne=211,_ne=212;class yne extends Hh{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==void 0&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===Zl.VERTEX?this.backend.createAttribute(e):t===Zl.INDEX?this.backend.createIndexAttribute(e):t===Zl.STORAGE?this.backend.createStorageAttribute(e):t===Zl.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version=0;--e)if(i[e]>=65535)return!0;return!1}function nB(i){return i.index!==null?i.index.version:i.attributes.position.version}function s6(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const s=t.array;for(let a=0,l=s.length;a{this.info.memory.geometries--;const s=t.index,a=e.getAttributes();s!==null&&this.attributes.delete(s);for(const u of a)this.attributes.delete(u);const l=this.wireframes.get(t);l!==void 0&&this.attributes.delete(l),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,Zl.STORAGE):this.updateAttribute(s,Zl.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,Zl.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Zl.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const s=this.wireframes;let a=s.get(t);a===void 0?(a=s6(t),s.set(t,a)):a.version!==nB(t)&&(this.attributes.delete(a),a=s6(t),s.set(t,a)),r=a}return r}}class Sne{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){this[e].timestampCalls===0&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class iB{constructor(e){this.cacheKey=e,this.usedTimes=0}}class wne extends iB{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class Tne extends iB{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Mne=0;class iS{constructor(e,t,n,r=null,s=null){this.id=Mne++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=s,this.usedTimes=0}}class Ene extends Hh{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let l=this.programs.compute.get(a.computeShader);l===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),l=new iS(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,l),n.createProgram(l));const u=this._getComputeCacheKey(e,l);let h=this.caches.get(u);h===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),h=this._getComputePipeline(e,l,u,t)),h.usedTimes++,l.usedTimes++,r.version=e.version,r.pipeline=h}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),l=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),u=new iS(a.vertexShader,"vertex",l),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let h=this.programs.fragment.get(a.fragmentShader);h===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),h=new iS(a.fragmentShader,"fragment",l),this.programs.fragment.set(a.fragmentShader,h),n.createProgram(h));const m=this._getRenderCacheKey(e,u,h);let v=this.caches.get(m);v===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),v=this._getRenderPipeline(e,u,h,m,t)):e.pipeline=v,v.usedTimes++,u.usedTimes++,h.usedTimes++,r.pipeline=v}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new Tne(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,n,r,s){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new wne(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,s)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Cne extends Hh{constructor(e,t,n,r,s,a){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?Zl.INDIRECT:Zl.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,s=!0,a=0,l=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const h=this.textures.get(u.texture);u.needsBindingsUpdate(h.generation)&&(r=!0);const m=u.update(),v=u.texture;m&&this.textures.updateTexture(v);const x=n.get(v);if(x.externalTexture!==void 0||h.isDefaultTexture?s=!1:(a=a*10+v.id,l+=v.version),n.isWebGPUBackend===!0&&x.texture===void 0&&x.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,m,v,u.textureNode.value,r),this.textures.updateTexture(v),r=!0),v.isStorageTexture===!0){const S=this.get(v);u.store===!0?S.needsMipmap=!0:this.textures.needsMipmaps(v)&&S.needsMipmap===!0&&(this.backend.generateMipmaps(v),S.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,s?a:0,l)}}function Nne(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function a6(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function o6(i){return(i.transmission>0||i.transmissionNode)&&i.side===as&&i.forceSinglePass===!1}class Rne{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,s,a,l){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:s,group:a,clippingContext:l},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=s,u.group=a,u.clippingContext=l),this.renderItemsIndex++,u}push(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(o6(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);n.transparent===!0||n.transmission>0?(o6(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Nne),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||a6),this.transparent.length>1&&this.transparent.sort(t||a6)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,h=l.height>>t;let m=e.depthTexture||s[t];const v=e.depthBuffer===!0||e.stencilBuffer===!0;let x=!1;m===void 0&&v&&(m=new Ic,m.format=e.stencilBuffer?uu:tu,m.type=e.stencilBuffer?lu:Nr,m.image.width=u,m.image.height=h,s[t]=m),(n.width!==l.width||l.height!==n.height)&&(x=!0,m&&(m.needsUpdate=!0,m.image.width=u,m.image.height=h)),n.width=l.width,n.height=l.height,n.textures=a,n.depthTexture=m||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(x=!0,m&&(m.needsUpdate=!0),n.sampleCount=r);const S={sampleCount:r};for(let T=0;T{e.removeEventListener("dispose",T);for(let N=0;N0){const m=e.image;if(m===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(m.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const v=[];for(const x of e.images)v.push(x);t.images=v}else t.image=m;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&s.generateMipmaps(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const h=()=>{e.removeEventListener("dispose",h),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",h)}n.version=e.version}getSize(e,t=Bne){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return this.isEnvironmentTexture(e)||e.isCompressedTexture===!0||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===Oh||t===Ih||t===Xo||t===Yo}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class TE extends cn{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class sB extends Ii{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const Ine=(i,e)=>wt(new sB(i,e));class Fne extends Nn{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new Pm(t);return this._currentCond=zs(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Pm(t),r=zs(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Pm(e),this}build(e,...t){const n=BM();yg(this);for(const r of this.nodes)r.build(e,"void");return yg(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const Zv=gt(Fne);class aB extends Nn{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,n=[];for(let r=0;r{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),nT=(i,e)=>Tl(Kn(4,i.mul(yi(1,i))),e),qne=(i,e)=>i.lessThan(.5)?nT(i.mul(2),e).div(2):yi(1,nT(Kn(yi(1,i),2),e).div(2)),Vne=(i,e,t)=>Tl(Cl(Tl(i,e),Qr(Tl(i,e),Tl(yi(1,i),t))),1/e),jne=(i,e)=>So(Q_.mul(e.mul(i).sub(1))).div(Q_.mul(e.mul(i).sub(1))),mc=Ke(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Hne=Ke(([i])=>Ie(mc(i.z.add(mc(i.y.mul(1)))),mc(i.z.add(mc(i.x.mul(1)))),mc(i.y.add(mc(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Wne=Ke(([i,e,t])=>{const n=Ie(i).toVar(),r=xe(1.4).toVar(),s=xe(0).toVar(),a=Ie(n).toVar();return Bi({start:xe(0),end:xe(3),type:"float",condition:"<="},()=>{const l=Ie(Hne(a.mul(2))).toVar();n.addAssign(l.add(t.mul(xe(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const u=xe(mc(n.z.add(mc(n.x.add(mc(n.y)))))).toVar();s.addAssign(u.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class $ne extends Nn{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let r=null,s=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=u.inputs;if(t.length===h.length){let m=0;for(let v=0;vs&&(r=a,s=m)}}this._candidateFnCall=n=r(...t)}return n}}const Xne=gt($ne),Vs=i=>(...e)=>Xne(i,...e),pd=yn(0).setGroup(Ln).onRenderUpdate(i=>i.time),uB=yn(0).setGroup(Ln).onRenderUpdate(i=>i.deltaTime),Yne=yn(0,"uint").setGroup(Ln).onRenderUpdate(i=>i.frameId),Qne=(i=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),pd.mul(i)),Kne=(i=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),pd.mul(i)),Zne=(i=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),uB.mul(i)),Jne=(i=pd)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),eie=(i=pd)=>i.fract().round(),tie=(i=pd)=>i.add(.5).fract().mul(2).sub(1).abs(),nie=(i=pd)=>i.fract(),iie=Ke(([i,e,t=Lt(.5)])=>wE(i.sub(t),e).add(t)),rie=Ke(([i,e,t=Lt(.5)])=>{const n=i.sub(t),r=n.dot(n),a=r.mul(r).mul(e);return i.add(n.mul(a))}),sie=Ke(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=Ho.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=Ho;const r=no.mul(n);return _g(e)&&(r[0][0]=Ho[0].length(),r[0][1]=0,r[0][2]=0),_g(t)&&(r[1][0]=0,r[1][1]=Ho[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,Ad.mul(r).mul(zr)}),aie=Ke(([i=null])=>{const e=J_();return J_(pE(i)).sub(e).lessThan(0).select(gu,i)});class oie extends Nn{static get type(){return"SpriteSheetUVNode"}constructor(e,t=Mr(),n=xe(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:s}=n,a=e.mod(r.mul(s)).floor(),l=a.mod(r),u=s.sub(a.add(1).div(r).ceil()),h=n.reciprocal(),m=Lt(l,u);return t.add(m).mul(h)}}const lie=gt(oie);class uie extends Nn{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,n=null,r=xe(1),s=zr,a=Ja){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:s,normalNode:a}=this;let l=a.abs().normalize();l=l.div(l.dot(Ie(1)));const u=s.yz.mul(r),h=s.zx.mul(r),m=s.xy.mul(r),v=e.value,x=t!==null?t.value:v,S=n!==null?n.value:v,T=fi(v,u).mul(l.x),N=fi(x,h).mul(l.y),C=fi(S,m).mul(l.z);return Qr(T,N,C)}}const cB=gt(uie),cie=(...i)=>cB(...i),SA=new jl,Sf=new me,wA=new me,rS=new me,am=new jn,hv=new me(0,0,-1),kl=new On,om=new me,fv=new me,lm=new On,dv=new bt,ty=new qh,hie=gu.flipX();ty.depthTexture=new Ic(1,1);let sS=!1;class ME extends pu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||ty.texture,hie),this._reflectorBaseNode=e.reflector||new fie(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=wt(new ME({defaultTexture:ty.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}}class fie extends Nn{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new pr,resolution:r=1,generateMipmaps:s=!1,bounces:a=!0,depth:l=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=s,this.bounces=a,this.depth=l,this.updateBeforeType=a?Qn.RENDER:Qn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const n=this.resolution;t.getDrawingBufferSize(dv),e.setSize(Math.round(dv.width*n),Math.round(dv.height*n))}setup(e){return this._updateResolution(ty,e.renderer),super.setup(e)}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new qh(0,0,{type:Gs}),this.generateMipmaps===!0&&(t.texture.minFilter=WF,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Ic),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&sS)return!1;sS=!0;const{scene:t,camera:n,renderer:r,material:s}=e,{target:a}=this,l=this.getVirtualCamera(n),u=this.getRenderTarget(l);if(r.getDrawingBufferSize(dv),this._updateResolution(u,r),wA.setFromMatrixPosition(a.matrixWorld),rS.setFromMatrixPosition(n.matrixWorld),am.extractRotation(a.matrixWorld),Sf.set(0,0,1),Sf.applyMatrix4(am),om.subVectors(wA,rS),om.dot(Sf)>0)return;om.reflect(Sf).negate(),om.add(wA),am.extractRotation(n.matrixWorld),hv.set(0,0,-1),hv.applyMatrix4(am),hv.add(rS),fv.subVectors(wA,hv),fv.reflect(Sf).negate(),fv.add(wA),l.coordinateSystem=n.coordinateSystem,l.position.copy(om),l.up.set(0,1,0),l.up.applyMatrix4(am),l.up.reflect(Sf),l.lookAt(fv),l.near=n.near,l.far=n.far,l.updateMatrixWorld(),l.projectionMatrix.copy(n.projectionMatrix),SA.setFromNormalAndCoplanarPoint(Sf,wA),SA.applyMatrix4(l.matrixWorldInverse),kl.set(SA.normal.x,SA.normal.y,SA.normal.z,SA.constant);const h=l.projectionMatrix;lm.x=(Math.sign(kl.x)+h.elements[8])/h.elements[0],lm.y=(Math.sign(kl.y)+h.elements[9])/h.elements[5],lm.z=-1,lm.w=(1+h.elements[10])/h.elements[14],kl.multiplyScalar(1/kl.dot(lm));const m=0;h.elements[2]=kl.x,h.elements[6]=kl.y,h.elements[10]=r.coordinateSystem===cu?kl.z-m:kl.z+1-m,h.elements[14]=kl.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),s.visible=!1;const v=r.getRenderTarget(),x=r.getMRT(),S=r.autoClear;r.setMRT(null),r.setRenderTarget(u),r.autoClear=!0,r.render(t,l),r.setMRT(x),r.setRenderTarget(v),r.autoClear=S,s.visible=!0,sS=!1}}const die=i=>wt(new ME(i)),aS=new Ig(-1,1,1,-1,0,1);class Aie extends Hi{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Si([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Si(t,2))}}const pie=new Aie;class EE extends Oi{constructor(e=null){super(pie,e),this.camera=aS,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,aS)}render(e){e.render(this,aS)}}const mie=new bt;class gie extends pu{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:Gs}){const s=new qh(t,n,r);super(s.texture,Mr()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new EE(new qr),this.updateBeforeType=Qn.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const n=e.getSize(mie);this.setSize(n.width,n.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new pu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const hB=(i,...e)=>wt(new gie(wt(i),...e)),vie=(i,...e)=>i.isTextureNode?i:i.isPassNode?i.getTextureNode():hB(i,...e),BA=Ke(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===cu?(i=Lt(i.x,i.y.oneMinus()).mul(2).sub(1),r=_n(Ie(i,e),1)):r=_n(Ie(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const s=_n(t.mul(r));return s.xyz.div(s.w)}),_ie=Ke(([i,e])=>{const t=e.mul(_n(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Lt(n.x,n.y.oneMinus())}),yie=Ke(([i,e,t])=>{const n=Uh(Ir(e)),r=As(i.mul(n)).toVar(),s=Ir(e,r).toVar(),a=Ir(e,r.sub(As(2,0))).toVar(),l=Ir(e,r.sub(As(1,0))).toVar(),u=Ir(e,r.add(As(1,0))).toVar(),h=Ir(e,r.add(As(2,0))).toVar(),m=Ir(e,r.add(As(0,2))).toVar(),v=Ir(e,r.add(As(0,1))).toVar(),x=Ir(e,r.sub(As(0,1))).toVar(),S=Ir(e,r.sub(As(0,2))).toVar(),T=rr(yi(xe(2).mul(l).sub(a),s)).toVar(),N=rr(yi(xe(2).mul(u).sub(h),s)).toVar(),C=rr(yi(xe(2).mul(v).sub(m),s)).toVar(),E=rr(yi(xe(2).mul(x).sub(S),s)).toVar(),O=BA(i,s,t).toVar(),U=T.lessThan(N).select(O.sub(BA(i.sub(Lt(xe(1).div(n.x),0)),l,t)),O.negate().add(BA(i.add(Lt(xe(1).div(n.x),0)),u,t))),I=C.lessThan(E).select(O.sub(BA(i.add(Lt(0,xe(1).div(n.y))),v,t)),O.negate().add(BA(i.sub(Lt(0,xe(1).div(n.y))),x,t)));return Lc(Iy(U,I))});class Jv extends Bg{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class xie extends wr{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}class bie extends dd{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}const Sie=gt(bie);class wie extends lE{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t=FP(e.itemSize),n=e.count),super(e,t,n),this.isStorageBufferNode=!0,this.access=ia.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Sie(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(ia.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Hg(this.value),this._varying=to(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}generate(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const Xy=(i,e=null,t=0)=>wt(new wie(i,e,t)),Tie=(i,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Xy(i,e,t).setPBO(!0)),Mie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new xie(i,t,n);return Xy(r,e,i)},Eie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new Jv(i,t,n);return Xy(r,e,i)};class Cie extends T9{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new On(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const Nie=i=>wt(new Cie(i));class Rie extends Nn{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Die=$t(Rie),um=new aa,oS=new jn;class Wa extends Nn{static get type(){return"SceneNode"}constructor(e=Wa.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let r;return t===Wa.BACKGROUND_BLURRINESS?r=zi("backgroundBlurriness","float",n):t===Wa.BACKGROUND_INTENSITY?r=zi("backgroundIntensity","float",n):t===Wa.BACKGROUND_ROTATION?r=yn("mat4").label("backgroundRotation").setGroup(Ln).onRenderUpdate(()=>{const s=n.background;return s!==null&&s.isTexture&&s.mapping!==OT?(um.copy(n.backgroundRotation),um.x*=-1,um.y*=-1,um.z*=-1,oS.makeRotationFromEuler(um)):oS.identity(),oS}):console.error("THREE.SceneNode: Unknown scope:",t),r}}Wa.BACKGROUND_BLURRINESS="backgroundBlurriness";Wa.BACKGROUND_INTENSITY="backgroundIntensity";Wa.BACKGROUND_ROTATION="backgroundRotation";const fB=$t(Wa,Wa.BACKGROUND_BLURRINESS),iT=$t(Wa,Wa.BACKGROUND_INTENSITY),dB=$t(Wa,Wa.BACKGROUND_ROTATION);class Pie extends pu{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=ia.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(ia.READ_WRITE)}toReadOnly(){return this.setAccess(ia.READ_ONLY)}toWriteOnly(){return this.setAccess(ia.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:r}=t,s=super.generate(e,"property"),a=n.build(e,"uvec2"),l=r.build(e,"vec4"),u=e.generateTextureStore(e,s,a,l);e.addLineFlowCode(u,this)}}const AB=gt(Pie),Lie=(i,e,t)=>{const n=AB(i,e,t);return t!==null&&n.append(),n};class Uie extends Vy{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Bie=(i,e,t)=>wt(new Uie(i,e,t)),l6=new WeakMap;class Oie extends Zr{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Qn.OBJECT,this.updateAfterType=Qn.OBJECT,this.previousModelWorldMatrix=yn(new jn),this.previousProjectionMatrix=yn(new jn).setGroup(Ln),this.previousCameraViewMatrix=yn(new jn)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=u6(n);this.previousModelWorldMatrix.value.copy(r);const s=pB(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new jn,s.previousCameraViewMatrix=new jn,s.currentProjectionMatrix=new jn,s.currentCameraViewMatrix=new jn,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){u6(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Ad:yn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(H0).mul(zr),r=this.previousProjectionMatrix.mul(t).mul(Z_),s=n.xy.div(n.w),a=r.xy.div(r.w);return yi(s,a)}}function pB(i){let e=l6.get(i);return e===void 0&&(e={},l6.set(i,e)),e}function u6(i,e=0){const t=pB(i);let n=t[e];return n===void 0&&(t[e]=n=new jn),n}const Iie=$t(Oie),mB=Ke(([i,e])=>Za(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),gB=Ke(([i,e])=>Za(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vB=Ke(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_B=Ke(([i,e])=>Ui(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Oy(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Fie=Ke(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return _n(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kie=(...i)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),mB(i)),zie=(...i)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),gB(i)),Gie=(...i)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),vB(i)),qie=(...i)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),_B(i)),Vie=Ke(([i])=>CE(i.rgb)),jie=Ke(([i,e=xe(1)])=>e.mix(CE(i.rgb),i.rgb)),Hie=Ke(([i,e=xe(1)])=>{const t=Qr(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),r=n.sub(t).mul(e).mul(-3);return Ui(i.rgb,n,r)}),Wie=Ke(([i,e=xe(1)])=>{const t=Ie(.57735,.57735,.57735),n=e.cos();return Ie(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(jh(t,i.rgb).mul(n.oneMinus())))))}),CE=(i,e=Ie(li.getLuminanceCoefficients(new me)))=>jh(i,e),$ie=Ke(([i,e=Ie(1),t=Ie(0),n=Ie(1),r=xe(1),s=Ie(li.getLuminanceCoefficients(new me,Mo))])=>{const a=i.rgb.dot(Ie(s)),l=Gr(i.rgb.mul(e).add(t),0).toVar(),u=l.pow(n).toVar();return ii(l.r.greaterThan(0),()=>{l.r.assign(u.r)}),ii(l.g.greaterThan(0),()=>{l.g.assign(u.g)}),ii(l.b.greaterThan(0),()=>{l.b.assign(u.b)}),l.assign(a.add(l.sub(a).mul(r))),_n(l.rgb,i.a)});class Xie extends Zr{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const Yie=gt(Xie),Qie=new bt;class yB extends pu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class c6 extends yB{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class _u extends Zr{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new Ic;s.isRenderTargetTexture=!0,s.name="depth";const a=new qh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Gs,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=yn(0),this._cameraFar=yn(0),this._mrt=null,this.isPassNode=!0,this.updateBeforeType=Qn.FRAME}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=wt(new c6(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=wt(new c6(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=mE(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=e0(s,n,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.scope===_u.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(Qie);this.setSize(s.width,s.height);const a=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const u in this._previousTextures)this.toggleTexture(u);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(a),t.setMRT(l)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}_u.COLOR="color";_u.DEPTH="depth";const Kie=(i,e,t)=>wt(new _u(_u.COLOR,i,e,t)),Zie=(i,e)=>wt(new yB(i,e)),Jie=(i,e,t)=>wt(new _u(_u.DEPTH,i,e,t));class ere extends _u{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,s){super(_u.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,l,u,h,m,v)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const x=this._getOutlineMaterial(u);t.renderObject(r,s,a,l,x,h,m,v)}t.renderObject(r,s,a,l,u,h,m,v)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new qr;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=or;const t=Ja.negate(),n=Ad.mul(H0),r=xe(1),s=n.mul(_n(zr,1)),a=n.mul(_n(zr.add(t),1)),l=Lc(s.sub(a));return e.vertexNode=s.add(l.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=_n(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const tre=(i,e,t=new cn(0,0,0),n=.003,r=1)=>wt(new ere(i,e,wt(t),wt(n),wt(r))),xB=Ke(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bB=Ke(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SB=Ke(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),nre=Ke(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),wB=Ke(([i,e])=>{const t=ua(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=ua(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=nre(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ire=ua(Ie(1.6605,-.1246,-.0182),Ie(-.5876,1.1329,-.1006),Ie(-.0728,-.0083,1.1187)),rre=ua(Ie(.6274,.0691,.0164),Ie(.3293,.9195,.088),Ie(.0433,.0113,.8956)),sre=Ke(([i])=>{const e=Ie(i).toVar(),t=Ie(e.mul(e)).toVar(),n=Ie(t.mul(t)).toVar();return xe(15.5).mul(n.mul(t)).sub(Kn(40.14,n.mul(e))).add(Kn(31.96,n).sub(Kn(6.868,t.mul(e))).add(Kn(.4298,t).add(Kn(.1191,e).sub(.00232))))}),TB=Ke(([i,e])=>{const t=Ie(i).toVar(),n=ua(Ie(.856627153315983,.137318972929847,.11189821299995),Ie(.0951212405381588,.761241990602591,.0767994186031903),Ie(.0482516061458583,.101439036467562,.811302368396859)),r=ua(Ie(1.1271005818144368,-.1413297634984383,-.14132976349843826),Ie(-.11060664309660323,1.157823702216272,-.11060664309660294),Ie(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=xe(-12.47393),a=xe(4.026069);return t.mulAssign(e),t.assign(rre.mul(t)),t.assign(n.mul(t)),t.assign(Gr(t,1e-10)),t.assign(su(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(du(t,0,1)),t.assign(sre(t)),t.assign(r.mul(t)),t.assign(Tl(Gr(Ie(0),t),Ie(2.2))),t.assign(ire.mul(t)),t.assign(du(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MB=Ke(([i,e])=>{const t=xe(.76),n=xe(.15);i=i.mul(e);const r=Za(i.r,Za(i.g,i.b)),s=zs(r.lessThan(.08),r.sub(Kn(6.25,r.mul(r))),.04);i.subAssign(s);const a=Gr(i.r,Gr(i.g,i.b));ii(a.lessThan(t),()=>i);const l=yi(1,t),u=yi(1,l.mul(l).div(a.add(l.sub(t))));i.mulAssign(u.div(a));const h=yi(1,Cl(1,n.mul(a.sub(u)).add(1)));return Ui(i,Ie(u),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class rs extends Nn{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.includes=t,this.language=n}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Yy=gt(rs),are=(i,e)=>Yy(i,e,"js"),ore=(i,e)=>Yy(i,e,"wgsl"),lre=(i,e)=>Yy(i,e,"glsl");class EB extends rs{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,s=n.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const l=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(l);return a.code=u+` +`,t==="property"?l:e.format(`${l}()`,s,t)}}const CB=(i,e=[],t="")=>{for(let s=0;sn.call(...s);return r.functionNode=n,r},ure=(i,e)=>CB(i,e,"glsl"),cre=(i,e)=>CB(i,e,"wgsl");class hre extends Nn{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Bc,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:xe()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=VP(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=jP(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const e_=gt(hre);class NB extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class fre{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const t_=new NB;class dre extends Nn{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new NB,this._output=e_(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=e_(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=e_(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r.constructor.name==="AsyncFunction"?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(h,m)=>this.setOutput(h,m),n=new fre(this),r=t_.get("THREE"),s=t_.get("TSL"),a=this.getMethod(),l=[n,this._local,t_,e,t,r,s];this._object=a(...l);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const h of u.elements){const m=h.id||h.name;h.inputType&&(this.getParameter(m)===void 0&&this.setParameter(m,null),this.getParameter(m).inputType=h.inputType),h.outputType&&(this.getOutput(m)===void 0&&this.setOutput(m,null),this.getOutput(m).outputType=h.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:xe()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),r="var "+n+`; var output = {}; +`,s=` +return { ...output, `+n+" };",a=r+this.codeNode.code+s;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[OP(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Cy(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Are=gt(dre);function RB(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Xr.z).negate()}const NE=Ke(([i,e],t)=>{const n=RB(t);return Uc(i,e,n)}),RE=Ke(([i],e)=>{const t=RB(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Cg=Ke(([i,e])=>_n(e.toFloat().mix(Tg.rgb,i.toVec3()),Tg.a));function pre(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Cg(i,NE(e,t))}function mre(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Cg(i,RE(e))}let wf=null,Tf=null;class gre extends Nn{static get type(){return"RangeNode"}constructor(e=xe(),t=xe()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Rh(this.minNode.value)),n=e.getTypeLength(Rh(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Rh(r)),l=e.getTypeLength(Rh(s));wf=wf||new On,Tf=Tf||new On,wf.setScalar(0),Tf.setScalar(0),a===1?wf.setScalar(r):r.isColor?wf.set(r.r,r.g,r.b,1):wf.set(r.x,r.y,r.z||0,r.w||0),l===1?Tf.setScalar(s):s.isColor?Tf.set(s.r,s.g,s.b,1):Tf.set(s.x,s.y,s.z||0,s.w||0);const u=4,h=u*t.count,m=new Float32Array(h);for(let x=0;xwt(new _re(i,e)),yre=Qy("numWorkgroups","uvec3"),xre=Qy("workgroupId","uvec3"),bre=Qy("localId","uvec3"),Sre=Qy("subgroupSize","uint");class wre extends Nn{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier +`):e.addLineFlowCode(`${t}Barrier()`,this)}}const DE=gt(wre),Tre=()=>DE("workgroup").append(),Mre=()=>DE("storage").append(),Ere=()=>DE("texture").append();class Cre extends dd{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}class Nre extends Nn{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return wt(new Cre(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const Rre=(i,e)=>wt(new Nre("Workgroup",i,e));class Rs extends Zr{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,l=[];l.push(`&${s.build(e,r)}`),l.push(a.build(e,r));const u=`${e.getMethod(t,n)}( ${l.join(", ")} )`;if(this.storeNode!==null){const h=this.storeNode.build(e,r);e.addLineFlowCode(`${h} = ${u}`,this)}else e.addLineFlowCode(u,this)}}Rs.ATOMIC_LOAD="atomicLoad";Rs.ATOMIC_STORE="atomicStore";Rs.ATOMIC_ADD="atomicAdd";Rs.ATOMIC_SUB="atomicSub";Rs.ATOMIC_MAX="atomicMax";Rs.ATOMIC_MIN="atomicMin";Rs.ATOMIC_AND="atomicAnd";Rs.ATOMIC_OR="atomicOr";Rs.ATOMIC_XOR="atomicXor";const Dre=gt(Rs),zc=(i,e,t,n=null)=>{const r=Dre(i,e,t,n);return r.append(),r},Pre=(i,e,t=null)=>zc(Rs.ATOMIC_STORE,i,e,t),Lre=(i,e,t=null)=>zc(Rs.ATOMIC_ADD,i,e,t),Ure=(i,e,t=null)=>zc(Rs.ATOMIC_SUB,i,e,t),Bre=(i,e,t=null)=>zc(Rs.ATOMIC_MAX,i,e,t),Ore=(i,e,t=null)=>zc(Rs.ATOMIC_MIN,i,e,t),Ire=(i,e,t=null)=>zc(Rs.ATOMIC_AND,i,e,t),Fre=(i,e,t=null)=>zc(Rs.ATOMIC_OR,i,e,t),kre=(i,e,t=null)=>zc(Rs.ATOMIC_XOR,i,e,t);let Av;function Jg(i){Av=Av||new WeakMap;let e=Av.get(i);return e===void 0&&Av.set(i,e={}),e}function PE(i){const e=Jg(i);return e.shadowMatrix||(e.shadowMatrix=yn("mat4").setGroup(Ln).onRenderUpdate(()=>(i.castShadow!==!0&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function DB(i){const e=Jg(i);if(e.projectionUV===void 0){const t=PE(i).mul(Tc);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function LE(i){const e=Jg(i);return e.position||(e.position=yn(new me).setGroup(Ln).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function PB(i){const e=Jg(i);return e.targetPosition||(e.targetPosition=yn(new me).setGroup(Ln).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function Ky(i){const e=Jg(i);return e.viewPosition||(e.viewPosition=yn(new me).setGroup(Ln).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new me,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const UE=i=>no.transformDirection(LE(i).sub(PB(i))),zre=i=>i.sort((e,t)=>e.id-t.id),Gre=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},lS=new WeakMap;class BE extends Nn{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Ie().toVar("totalDiffuse"),this.totalSpecularNode=Ie().toVar("totalSpecular"),this.outgoingLightNode=Ie().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let n=0;n0}}const qre=(i=[])=>wt(new BE).setLights(i);class Vre extends Nn{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Qn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({material:e}){OE.assign(e.shadowPositionNode||Tc)}dispose(){this.updateBeforeType=Qn.NONE}}const OE=Ie().toVar("shadowPositionWorld");function jre(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new cn),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function Hre(i,e){return e=jre(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function Wre(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function $re(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function Xre(i,e){return e=$re(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function Yre(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function Qre(i,e,t){return t=Hre(i,t),t=Xre(e,t),t}function Kre(i,e,t){Wre(i,t),Yre(e,t)}const h6=new WeakMap,Zre=Ke(([i,e,t])=>{let n=Tc.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),Jre=i=>{const e=i.shadow.camera,t=zi("near","float",e).setGroup(Ln),n=zi("far","float",e).setGroup(Ln),r=C9(i);return Zre(r,t,n)},ese=i=>{let e=h6.get(i);if(e===void 0){const t=i.isPointLight?Jre(i):null;e=new qr,e.colorNode=_n(0,0,0,1),e.depthNode=t,e.isShadowNodeMaterial=!0,e.name="ShadowMaterial",e.fog=!1,h6.set(i,e)}return e},LB=Ke(({depthTexture:i,shadowCoord:e})=>fi(i,e.xy).compare(e.z)),UB=Ke(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(N,C)=>fi(i,N).compare(C),r=zi("mapSize","vec2",t).setGroup(Ln),s=zi("radius","float",t).setGroup(Ln),a=Lt(1).div(r),l=a.x.negate().mul(s),u=a.y.negate().mul(s),h=a.x.mul(s),m=a.y.mul(s),v=l.div(2),x=u.div(2),S=h.div(2),T=m.div(2);return Qr(n(e.xy.add(Lt(l,u)),e.z),n(e.xy.add(Lt(0,u)),e.z),n(e.xy.add(Lt(h,u)),e.z),n(e.xy.add(Lt(v,x)),e.z),n(e.xy.add(Lt(0,x)),e.z),n(e.xy.add(Lt(S,x)),e.z),n(e.xy.add(Lt(l,0)),e.z),n(e.xy.add(Lt(v,0)),e.z),n(e.xy,e.z),n(e.xy.add(Lt(S,0)),e.z),n(e.xy.add(Lt(h,0)),e.z),n(e.xy.add(Lt(v,T)),e.z),n(e.xy.add(Lt(0,T)),e.z),n(e.xy.add(Lt(S,T)),e.z),n(e.xy.add(Lt(l,m)),e.z),n(e.xy.add(Lt(0,m)),e.z),n(e.xy.add(Lt(h,m)),e.z)).mul(1/17)}),BB=Ke(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(m,v)=>fi(i,m).compare(v),r=zi("mapSize","vec2",t).setGroup(Ln),s=Lt(1).div(r),a=s.x,l=s.y,u=e.xy,h=kc(u.mul(r).add(.5));return u.subAssign(h.mul(s)),Qr(n(u,e.z),n(u.add(Lt(a,0)),e.z),n(u.add(Lt(0,l)),e.z),n(u.add(s),e.z),Ui(n(u.add(Lt(a.negate(),0)),e.z),n(u.add(Lt(a.mul(2),0)),e.z),h.x),Ui(n(u.add(Lt(a.negate(),l)),e.z),n(u.add(Lt(a.mul(2),l)),e.z),h.x),Ui(n(u.add(Lt(0,l.negate())),e.z),n(u.add(Lt(0,l.mul(2))),e.z),h.y),Ui(n(u.add(Lt(a,l.negate())),e.z),n(u.add(Lt(a,l.mul(2))),e.z),h.y),Ui(Ui(n(u.add(Lt(a.negate(),l.negate())),e.z),n(u.add(Lt(a.mul(2),l.negate())),e.z),h.x),Ui(n(u.add(Lt(a.negate(),l.mul(2))),e.z),n(u.add(Lt(a.mul(2),l.mul(2))),e.z),h.x),h.y)).mul(1/9)}),OB=Ke(({depthTexture:i,shadowCoord:e})=>{const t=xe(1).toVar(),n=fi(i).sample(e.xy).rg,r=Oy(e.z,n.x);return ii(r.notEqual(xe(1)),()=>{const s=e.z.sub(n.x),a=Gr(0,n.y.mul(n.y));let l=a.div(a.add(s.mul(s)));l=du(yi(l,.3).div(.95-.3)),t.assign(du(Gr(r,l)))}),t}),tse=Ke(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=xe(0).toVar(),s=xe(0).toVar(),a=i.lessThanEqual(xe(1)).select(xe(0),xe(2).div(i.sub(1))),l=i.lessThanEqual(xe(1)).select(xe(0),xe(-1));Bi({start:Ee(0),end:Ee(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(xe(h).mul(a)),v=n.sample(Qr(Zg.xy,Lt(0,m).mul(e)).div(t)).x;r.addAssign(v),s.addAssign(v.mul(v))}),r.divAssign(i),s.divAssign(i);const u=Su(s.sub(r.mul(r)));return Lt(r,u)}),nse=Ke(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=xe(0).toVar(),s=xe(0).toVar(),a=i.lessThanEqual(xe(1)).select(xe(0),xe(2).div(i.sub(1))),l=i.lessThanEqual(xe(1)).select(xe(0),xe(-1));Bi({start:Ee(0),end:Ee(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(xe(h).mul(a)),v=n.sample(Qr(Zg.xy,Lt(m,0).mul(e)).div(t));r.addAssign(v.x),s.addAssign(Qr(v.y.mul(v.y),v.x.mul(v.x)))}),r.divAssign(i),s.divAssign(i);const u=Su(s.sub(r.mul(r)));return Lt(r,u)}),ise=[LB,UB,BB,OB];let uS;const pv=new EE;class IB extends Vre{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s}){const a=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:n,shadowCoord:r,shadow:s});return a.select(l,xe(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,s=zi("bias","float",n).setGroup(Ln);let a=t,l;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),l=a.z,r.coordinateSystem===cu&&(l=l.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const h=zi("near","float",n.camera).setGroup(Ln),m=zi("far","float",n.camera).setGroup(Ln);l=gE(u.negate(),h,m)}return a=Ie(a.x,a.y.oneMinus(),l.add(s)),a}getShadowFilterFn(e){return ise[e]}setupShadow(e){const{renderer:t}=e,{light:n,shadow:r}=this,s=t.shadowMap.type,a=new Ic(r.mapSize.width,r.mapSize.height);a.compareFunction=Ay;const l=e.createRenderTarget(r.mapSize.width,r.mapSize.height);if(l.depthTexture=a,r.camera.updateProjectionMatrix(),s===vo){a.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:id,type:Gs}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:id,type:Gs});const E=fi(a),O=fi(this.vsmShadowMapVertical.texture),U=zi("blurSamples","float",r).setGroup(Ln),I=zi("radius","float",r).setGroup(Ln),j=zi("mapSize","vec2",r).setGroup(Ln);let z=this.vsmMaterialVertical||(this.vsmMaterialVertical=new qr);z.fragmentNode=tse({samples:U,radius:I,size:j,shadowPass:E}).context(e.getSharedContext()),z.name="VSMVertical",z=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new qr),z.fragmentNode=nse({samples:U,radius:I,size:j,shadowPass:O}).context(e.getSharedContext()),z.name="VSMHorizontal"}const u=zi("intensity","float",r).setGroup(Ln),h=zi("normalBias","float",r).setGroup(Ln),m=PE(n).mul(OE.add(qy.mul(h))),v=this.setupShadowCoord(e,m),x=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(x===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const S=s===vo?this.vsmShadowMapHorizontal.texture:a,T=this.setupShadowFilter(e,{filterFn:x,shadowTexture:l.texture,depthTexture:S,shadowCoord:v,shadow:r}),N=fi(l.texture,v),C=Ui(1,T.rgb.mix(N,1),u.mul(N.a)).toVar();return this.shadowMap=l,this.shadow.map=l,C}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Ke(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height),s.render(a,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:s,scene:a,camera:l}=e,u=s.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h,r.camera.layers.mask=l.layers.mask;const m=s.getRenderObjectFunction(),v=s.getMRT(),x=v?v.has("velocity"):!1;uS=Qre(s,a,uS),a.overrideMaterial=ese(n),s.setRenderObjectFunction((S,T,N,C,E,O,...U)=>{(S.castShadow===!0||S.receiveShadow&&u===vo)&&(x&&(qP(S).useVelocity=!0),S.onBeforeShadow(s,S,l,r.camera,C,T.overrideMaterial,O),s.renderObject(S,T,N,C,E,O,...U),S.onAfterShadow(s,S,l,r.camera,C,T.overrideMaterial,O))}),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(m),n.isPointLight!==!0&&u===vo&&this.vsmPass(s),Kre(s,a,uS)}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),pv.material=this.vsmMaterialVertical,pv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),pv.material=this.vsmMaterialHorizontal,pv.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const FB=(i,e)=>wt(new IB(i,e));class md extends W0{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new cn,this.colorNode=e&&e.colorNode||yn(this.color).setGroup(Ln),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Qn.FRAME}customCacheKey(){return RM(this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return FB(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let s;r!==void 0?s=wt(r):s=this.setupShadowNode(e),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const IE=Ke(i=>{const{lightDistance:e,cutoffDistance:t,decayExponent:n}=i,r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),rse=new cn,Vl=Ke(([i,e])=>{const t=i.toVar(),n=rr(t),r=Cl(1,Gr(n.x,Gr(n.y,n.z)));n.mulAssign(r),t.mulAssign(r.mul(e.mul(2).oneMinus()));const s=Lt(t.xy).toVar(),l=e.mul(1.5).oneMinus();return ii(n.z.greaterThanEqual(l),()=>{ii(t.z.greaterThan(0),()=>{s.x.assign(yi(4,t.x))})}).ElseIf(n.x.greaterThanEqual(l),()=>{const u=Mg(t.x);s.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(l),()=>{const u=Mg(t.y);s.x.assign(t.x.add(u.mul(2)).add(2)),s.y.assign(t.z.mul(u).sub(2))}),Lt(.125,.25).mul(s).add(Lt(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),sse=Ke(({depthTexture:i,bd3D:e,dp:t,texelSize:n})=>fi(i,Vl(e,n.y)).compare(t)),ase=Ke(({depthTexture:i,bd3D:e,dp:t,texelSize:n,shadow:r})=>{const s=zi("radius","float",r).setGroup(Ln),a=Lt(-1,1).mul(s).mul(n.y);return fi(i,Vl(e.add(a.xyy),n.y)).compare(t).add(fi(i,Vl(e.add(a.yyy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.xyx),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yyx),n.y)).compare(t)).add(fi(i,Vl(e,n.y)).compare(t)).add(fi(i,Vl(e.add(a.xxy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yxy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.xxx),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),ose=Ke(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),s=r.length(),a=yn("float").setGroup(Ln).onRenderUpdate(()=>n.camera.near),l=yn("float").setGroup(Ln).onRenderUpdate(()=>n.camera.far),u=zi("bias","float",n).setGroup(Ln),h=yn(n.mapSize).setGroup(Ln),m=xe(1).toVar();return ii(s.sub(l).lessThanEqual(0).and(s.sub(a).greaterThanEqual(0)),()=>{const v=s.sub(a).div(l.sub(a)).toVar();v.addAssign(u);const x=r.normalize(),S=Lt(1).div(h.mul(Lt(4,2)));m.assign(i({depthTexture:e,bd3D:x,dp:v,texelSize:S,shadow:n}))}),m}),f6=new On,TA=new bt,cm=new bt;class lse extends IB{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===kF?sse:ase}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a}){return ose({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e,l=t.getFrameExtents();cm.copy(t.mapSize),cm.multiply(l),n.setSize(cm.width,cm.height),TA.copy(t.mapSize);const u=s.autoClear,h=s.getClearColor(rse),m=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha),s.clear();const v=t.getViewportCount();for(let x=0;xwt(new lse(i,e)),kB=Ke(({color:i,lightViewPosition:e,cutoffDistance:t,decayExponent:n},r)=>{const s=r.context.lightingModel,a=e.sub(Xr),l=a.normalize(),u=a.length(),h=IE({lightDistance:u,cutoffDistance:t,decayExponent:n}),m=i.mul(h),v=r.context.reflectedLight;s.direct({lightDirection:l,lightColor:m,reflectedLight:v},r.stack,r)});class cse extends md{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=yn(0).setGroup(Ln),this.decayExponentNode=yn(2).setGroup(Ln)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return use(this.light)}setup(e){super.setup(e),kB({color:this.colorNode,lightViewPosition:Ky(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const hse=Ke(([i=Mr()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),Fm=Ke(([i,e,t])=>{const n=xe(t).toVar(),r=xe(e).toVar(),s=Pc(i).toVar();return zs(s,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ny=Ke(([i,e])=>{const t=Pc(e).toVar(),n=xe(i).toVar();return zs(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Yr=Ke(([i])=>{const e=xe(i).toVar();return Ee(au(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),mr=Ke(([i,e])=>{const t=xe(i).toVar();return e.assign(Yr(t)),t.sub(xe(e))}),fse=Ke(([i,e,t,n,r,s])=>{const a=xe(s).toVar(),l=xe(r).toVar(),u=xe(n).toVar(),h=xe(t).toVar(),m=xe(e).toVar(),v=xe(i).toVar(),x=xe(yi(1,l)).toVar();return yi(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),dse=Ke(([i,e,t,n,r,s])=>{const a=xe(s).toVar(),l=xe(r).toVar(),u=Ie(n).toVar(),h=Ie(t).toVar(),m=Ie(e).toVar(),v=Ie(i).toVar(),x=xe(yi(1,l)).toVar();return yi(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),zB=Vs([fse,dse]),Ase=Ke(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=xe(m).toVar(),x=xe(h).toVar(),S=xe(u).toVar(),T=xe(l).toVar(),N=xe(a).toVar(),C=xe(s).toVar(),E=xe(r).toVar(),O=xe(n).toVar(),U=xe(t).toVar(),I=xe(e).toVar(),j=xe(i).toVar(),z=xe(yi(1,S)).toVar(),G=xe(yi(1,x)).toVar();return xe(yi(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(T.mul(S))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),pse=Ke(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=xe(m).toVar(),x=xe(h).toVar(),S=xe(u).toVar(),T=Ie(l).toVar(),N=Ie(a).toVar(),C=Ie(s).toVar(),E=Ie(r).toVar(),O=Ie(n).toVar(),U=Ie(t).toVar(),I=Ie(e).toVar(),j=Ie(i).toVar(),z=xe(yi(1,S)).toVar(),G=xe(yi(1,x)).toVar();return xe(yi(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(T.mul(S))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),GB=Vs([Ase,pse]),mse=Ke(([i,e,t])=>{const n=xe(t).toVar(),r=xe(e).toVar(),s=rn(i).toVar(),a=rn(s.bitAnd(rn(7))).toVar(),l=xe(Fm(a.lessThan(rn(4)),r,n)).toVar(),u=xe(Kn(2,Fm(a.lessThan(rn(4)),n,r))).toVar();return ny(l,Pc(a.bitAnd(rn(1)))).add(ny(u,Pc(a.bitAnd(rn(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),gse=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=xe(e).toVar(),l=rn(i).toVar(),u=rn(l.bitAnd(rn(15))).toVar(),h=xe(Fm(u.lessThan(rn(8)),a,s)).toVar(),m=xe(Fm(u.lessThan(rn(4)),s,Fm(u.equal(rn(12)).or(u.equal(rn(14))),a,r))).toVar();return ny(h,Pc(u.bitAnd(rn(1)))).add(ny(m,Pc(u.bitAnd(rn(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Cs=Vs([mse,gse]),vse=Ke(([i,e,t])=>{const n=xe(t).toVar(),r=xe(e).toVar(),s=j0(i).toVar();return Ie(Cs(s.x,r,n),Cs(s.y,r,n),Cs(s.z,r,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),_se=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=xe(e).toVar(),l=j0(i).toVar();return Ie(Cs(l.x,a,s,r),Cs(l.y,a,s,r),Cs(l.z,a,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),qo=Vs([vse,_se]),yse=Ke(([i])=>{const e=xe(i).toVar();return Kn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),xse=Ke(([i])=>{const e=xe(i).toVar();return Kn(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bse=Ke(([i])=>{const e=Ie(i).toVar();return Kn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),qB=Vs([yse,bse]),Sse=Ke(([i])=>{const e=Ie(i).toVar();return Kn(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),VB=Vs([xse,Sse]),xo=Ke(([i,e])=>{const t=Ee(e).toVar(),n=rn(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(Ee(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),jB=Ke(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(xo(t,Ee(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(xo(i,Ee(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(xo(e,Ee(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(xo(t,Ee(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(xo(i,Ee(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(xo(e,Ee(4))),e.addAssign(i)}),e1=Ke(([i,e,t])=>{const n=rn(t).toVar(),r=rn(e).toVar(),s=rn(i).toVar();return n.bitXorAssign(r),n.subAssign(xo(r,Ee(14))),s.bitXorAssign(n),s.subAssign(xo(n,Ee(11))),r.bitXorAssign(s),r.subAssign(xo(s,Ee(25))),n.bitXorAssign(r),n.subAssign(xo(r,Ee(16))),s.bitXorAssign(n),s.subAssign(xo(n,Ee(4))),r.bitXorAssign(s),r.subAssign(xo(s,Ee(14))),n.bitXorAssign(r),n.subAssign(xo(r,Ee(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),sa=Ke(([i])=>{const e=rn(i).toVar();return xe(e).div(xe(rn(Ee(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ou=Ke(([i])=>{const e=xe(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),wse=Ke(([i])=>{const e=Ee(i).toVar(),t=rn(rn(1)).toVar(),n=rn(rn(Ee(3735928559)).add(t.shiftLeft(rn(2))).add(rn(13))).toVar();return e1(n.add(rn(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),Tse=Ke(([i,e])=>{const t=Ee(e).toVar(),n=Ee(i).toVar(),r=rn(rn(2)).toVar(),s=rn().toVar(),a=rn().toVar(),l=rn().toVar();return s.assign(a.assign(l.assign(rn(Ee(3735928559)).add(r.shiftLeft(rn(2))).add(rn(13))))),s.addAssign(rn(n)),a.addAssign(rn(t)),e1(s,a,l)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Mse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=Ee(e).toVar(),s=Ee(i).toVar(),a=rn(rn(3)).toVar(),l=rn().toVar(),u=rn().toVar(),h=rn().toVar();return l.assign(u.assign(h.assign(rn(Ee(3735928559)).add(a.shiftLeft(rn(2))).add(rn(13))))),l.addAssign(rn(s)),u.addAssign(rn(r)),h.addAssign(rn(n)),e1(l,u,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Ese=Ke(([i,e,t,n])=>{const r=Ee(n).toVar(),s=Ee(t).toVar(),a=Ee(e).toVar(),l=Ee(i).toVar(),u=rn(rn(4)).toVar(),h=rn().toVar(),m=rn().toVar(),v=rn().toVar();return h.assign(m.assign(v.assign(rn(Ee(3735928559)).add(u.shiftLeft(rn(2))).add(rn(13))))),h.addAssign(rn(l)),m.addAssign(rn(a)),v.addAssign(rn(s)),jB(h,m,v),h.addAssign(rn(r)),e1(h,m,v)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Cse=Ke(([i,e,t,n,r])=>{const s=Ee(r).toVar(),a=Ee(n).toVar(),l=Ee(t).toVar(),u=Ee(e).toVar(),h=Ee(i).toVar(),m=rn(rn(5)).toVar(),v=rn().toVar(),x=rn().toVar(),S=rn().toVar();return v.assign(x.assign(S.assign(rn(Ee(3735928559)).add(m.shiftLeft(rn(2))).add(rn(13))))),v.addAssign(rn(h)),x.addAssign(rn(u)),S.addAssign(rn(l)),jB(v,x,S),v.addAssign(rn(a)),x.addAssign(rn(s)),e1(v,x,S)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Gi=Vs([wse,Tse,Mse,Ese,Cse]),Nse=Ke(([i,e])=>{const t=Ee(e).toVar(),n=Ee(i).toVar(),r=rn(Gi(n,t)).toVar(),s=j0().toVar();return s.x.assign(r.bitAnd(Ee(255))),s.y.assign(r.shiftRight(Ee(8)).bitAnd(Ee(255))),s.z.assign(r.shiftRight(Ee(16)).bitAnd(Ee(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Rse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=Ee(e).toVar(),s=Ee(i).toVar(),a=rn(Gi(s,r,n)).toVar(),l=j0().toVar();return l.x.assign(a.bitAnd(Ee(255))),l.y.assign(a.shiftRight(Ee(8)).bitAnd(Ee(255))),l.z.assign(a.shiftRight(Ee(16)).bitAnd(Ee(255))),l}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Vo=Vs([Nse,Rse]),Dse=Ke(([i])=>{const e=Lt(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=xe(mr(e.x,t)).toVar(),s=xe(mr(e.y,n)).toVar(),a=xe(ou(r)).toVar(),l=xe(ou(s)).toVar(),u=xe(zB(Cs(Gi(t,n),r,s),Cs(Gi(t.add(Ee(1)),n),r.sub(1),s),Cs(Gi(t,n.add(Ee(1))),r,s.sub(1)),Cs(Gi(t.add(Ee(1)),n.add(Ee(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Pse=Ke(([i])=>{const e=Ie(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=Ee().toVar(),s=xe(mr(e.x,t)).toVar(),a=xe(mr(e.y,n)).toVar(),l=xe(mr(e.z,r)).toVar(),u=xe(ou(s)).toVar(),h=xe(ou(a)).toVar(),m=xe(ou(l)).toVar(),v=xe(GB(Cs(Gi(t,n,r),s,a,l),Cs(Gi(t.add(Ee(1)),n,r),s.sub(1),a,l),Cs(Gi(t,n.add(Ee(1)),r),s,a.sub(1),l),Cs(Gi(t.add(Ee(1)),n.add(Ee(1)),r),s.sub(1),a.sub(1),l),Cs(Gi(t,n,r.add(Ee(1))),s,a,l.sub(1)),Cs(Gi(t.add(Ee(1)),n,r.add(Ee(1))),s.sub(1),a,l.sub(1)),Cs(Gi(t,n.add(Ee(1)),r.add(Ee(1))),s,a.sub(1),l.sub(1)),Cs(Gi(t.add(Ee(1)),n.add(Ee(1)),r.add(Ee(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),FE=Vs([Dse,Pse]),Lse=Ke(([i])=>{const e=Lt(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=xe(mr(e.x,t)).toVar(),s=xe(mr(e.y,n)).toVar(),a=xe(ou(r)).toVar(),l=xe(ou(s)).toVar(),u=Ie(zB(qo(Vo(t,n),r,s),qo(Vo(t.add(Ee(1)),n),r.sub(1),s),qo(Vo(t,n.add(Ee(1))),r,s.sub(1)),qo(Vo(t.add(Ee(1)),n.add(Ee(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Use=Ke(([i])=>{const e=Ie(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=Ee().toVar(),s=xe(mr(e.x,t)).toVar(),a=xe(mr(e.y,n)).toVar(),l=xe(mr(e.z,r)).toVar(),u=xe(ou(s)).toVar(),h=xe(ou(a)).toVar(),m=xe(ou(l)).toVar(),v=Ie(GB(qo(Vo(t,n,r),s,a,l),qo(Vo(t.add(Ee(1)),n,r),s.sub(1),a,l),qo(Vo(t,n.add(Ee(1)),r),s,a.sub(1),l),qo(Vo(t.add(Ee(1)),n.add(Ee(1)),r),s.sub(1),a.sub(1),l),qo(Vo(t,n,r.add(Ee(1))),s,a,l.sub(1)),qo(Vo(t.add(Ee(1)),n,r.add(Ee(1))),s.sub(1),a,l.sub(1)),qo(Vo(t,n.add(Ee(1)),r.add(Ee(1))),s,a.sub(1),l.sub(1)),qo(Vo(t.add(Ee(1)),n.add(Ee(1)),r.add(Ee(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),kE=Vs([Lse,Use]),Bse=Ke(([i])=>{const e=xe(i).toVar(),t=Ee(Yr(e)).toVar();return sa(Gi(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Ose=Ke(([i])=>{const e=Lt(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar();return sa(Gi(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Ise=Ke(([i])=>{const e=Ie(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar();return sa(Gi(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Fse=Ke(([i])=>{const e=_n(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar(),s=Ee(Yr(e.w)).toVar();return sa(Gi(t,n,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),kse=Vs([Bse,Ose,Ise,Fse]),zse=Ke(([i])=>{const e=xe(i).toVar(),t=Ee(Yr(e)).toVar();return Ie(sa(Gi(t,Ee(0))),sa(Gi(t,Ee(1))),sa(Gi(t,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Gse=Ke(([i])=>{const e=Lt(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar();return Ie(sa(Gi(t,n,Ee(0))),sa(Gi(t,n,Ee(1))),sa(Gi(t,n,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),qse=Ke(([i])=>{const e=Ie(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar();return Ie(sa(Gi(t,n,r,Ee(0))),sa(Gi(t,n,r,Ee(1))),sa(Gi(t,n,r,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Vse=Ke(([i])=>{const e=_n(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar(),s=Ee(Yr(e.w)).toVar();return Ie(sa(Gi(t,n,r,s,Ee(0))),sa(Gi(t,n,r,s,Ee(1))),sa(Gi(t,n,r,s,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),HB=Vs([zse,Gse,qse,Vse]),iy=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=xe(0).toVar(),h=xe(1).toVar();return Bi(a,()=>{u.addAssign(h.mul(FE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),WB=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=Ie(0).toVar(),h=xe(1).toVar();return Bi(a,()=>{u.addAssign(h.mul(kE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),jse=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar();return Lt(iy(l,a,s,r),iy(l.add(Ie(Ee(19),Ee(193),Ee(17))),a,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Hse=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=Ie(WB(l,a,s,r)).toVar(),h=xe(iy(l.add(Ie(Ee(19),Ee(193),Ee(17))),a,s,r)).toVar();return _n(u,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Wse=Ke(([i,e,t,n,r,s,a])=>{const l=Ee(a).toVar(),u=xe(s).toVar(),h=Ee(r).toVar(),m=Ee(n).toVar(),v=Ee(t).toVar(),x=Ee(e).toVar(),S=Lt(i).toVar(),T=Ie(HB(Lt(x.add(m),v.add(h)))).toVar(),N=Lt(T.x,T.y).toVar();N.subAssign(.5),N.mulAssign(u),N.addAssign(.5);const C=Lt(Lt(xe(x),xe(v)).add(N)).toVar(),E=Lt(C.sub(S)).toVar();return ii(l.equal(Ee(2)),()=>rr(E.x).add(rr(E.y))),ii(l.equal(Ee(3)),()=>Gr(rr(E.x),rr(E.y))),jh(E,E)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$se=Ke(([i,e,t,n,r,s,a,l,u])=>{const h=Ee(u).toVar(),m=xe(l).toVar(),v=Ee(a).toVar(),x=Ee(s).toVar(),S=Ee(r).toVar(),T=Ee(n).toVar(),N=Ee(t).toVar(),C=Ee(e).toVar(),E=Ie(i).toVar(),O=Ie(HB(Ie(C.add(S),N.add(x),T.add(v)))).toVar();O.subAssign(.5),O.mulAssign(m),O.addAssign(.5);const U=Ie(Ie(xe(C),xe(N),xe(T)).add(O)).toVar(),I=Ie(U.sub(E)).toVar();return ii(h.equal(Ee(2)),()=>rr(I.x).add(rr(I.y)).add(rr(I.z))),ii(h.equal(Ee(3)),()=>Gr(Gr(rr(I.x),rr(I.y)),rr(I.z))),jh(I,I)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$0=Vs([Wse,$se]),Xse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Lt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Lt(mr(s.x,a),mr(s.y,l)).toVar(),h=xe(1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=xe($0(u,m,v,a,l,r,n)).toVar();h.assign(Za(h,x))})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Yse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Lt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Lt(mr(s.x,a),mr(s.y,l)).toVar(),h=Lt(1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=xe($0(u,m,v,a,l,r,n)).toVar();ii(x.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.y.assign(x)})})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Qse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Lt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Lt(mr(s.x,a),mr(s.y,l)).toVar(),h=Ie(1e6,1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=xe($0(u,m,v,a,l,r,n)).toVar();ii(x.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(x)}).ElseIf(x.lessThan(h.z),()=>{h.z.assign(x)})})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Kse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=xe(1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=xe($0(h,v,x,S,a,l,u,r,n)).toVar();m.assign(Za(m,T))})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Zse=Vs([Xse,Kse]),Jse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=Lt(1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=xe($0(h,v,x,S,a,l,u,r,n)).toVar();ii(T.lessThan(m.x),()=>{m.y.assign(m.x),m.x.assign(T)}).ElseIf(T.lessThan(m.y),()=>{m.y.assign(T)})})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),eae=Vs([Yse,Jse]),tae=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=Ie(1e6,1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=xe($0(h,v,x,S,a,l,u,r,n)).toVar();ii(T.lessThan(m.x),()=>{m.z.assign(m.y),m.y.assign(m.x),m.x.assign(T)}).ElseIf(T.lessThan(m.y),()=>{m.z.assign(m.y),m.y.assign(T)}).ElseIf(T.lessThan(m.z),()=>{m.z.assign(T)})})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nae=Vs([Qse,tae]),iae=Ke(([i])=>{const e=i.y,t=i.z,n=Ie().toVar();return ii(e.lessThan(1e-4),()=>{n.assign(Ie(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(au(r)).mul(6).toVar();const s=Ee(JM(r)),a=r.sub(xe(s)),l=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),h=t.mul(e.mul(a.oneMinus()).oneMinus());ii(s.equal(Ee(0)),()=>{n.assign(Ie(t,h,l))}).ElseIf(s.equal(Ee(1)),()=>{n.assign(Ie(u,t,l))}).ElseIf(s.equal(Ee(2)),()=>{n.assign(Ie(l,t,h))}).ElseIf(s.equal(Ee(3)),()=>{n.assign(Ie(l,u,t))}).ElseIf(s.equal(Ee(4)),()=>{n.assign(Ie(h,l,t))}).Else(()=>{n.assign(Ie(t,l,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),rae=Ke(([i])=>{const e=Ie(i).toVar(),t=xe(e.x).toVar(),n=xe(e.y).toVar(),r=xe(e.z).toVar(),s=xe(Za(t,Za(n,r))).toVar(),a=xe(Gr(t,Gr(n,r))).toVar(),l=xe(a.sub(s)).toVar(),u=xe().toVar(),h=xe().toVar(),m=xe().toVar();return m.assign(a),ii(a.greaterThan(0),()=>{h.assign(l.div(a))}).Else(()=>{h.assign(0)}),ii(h.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{ii(t.greaterThanEqual(a),()=>{u.assign(n.sub(r).div(l))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(Qr(2,r.sub(t).div(l)))}).Else(()=>{u.assign(Qr(4,t.sub(n).div(l)))}),u.mulAssign(1/6),ii(u.lessThan(0),()=>{u.addAssign(1)})}),Ie(u,h,m)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),sae=Ke(([i])=>{const e=Ie(i).toVar(),t=OM(WM(e,Ie(.04045))).toVar(),n=Ie(e.div(12.92)).toVar(),r=Ie(Tl(Gr(e.add(Ie(.055)),Ie(0)).div(1.055),Ie(2.4))).toVar();return Ui(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),$B=(i,e)=>{i=xe(i),e=xe(e);const t=Lt(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Uc(i.sub(t),i.add(t),e)},XB=(i,e,t,n)=>Ui(i,e,t[n].clamp()),aae=(i,e,t=Mr())=>XB(i,e,t,"x"),oae=(i,e,t=Mr())=>XB(i,e,t,"y"),YB=(i,e,t,n,r)=>Ui(i,e,$B(t,n[r])),lae=(i,e,t,n=Mr())=>YB(i,e,t,n,"x"),uae=(i,e,t,n=Mr())=>YB(i,e,t,n,"y"),cae=(i=1,e=0,t=Mr())=>t.mul(i).add(e),hae=(i,e=1)=>(i=xe(i),i.abs().pow(e).mul(i.sign())),fae=(i,e=1,t=.5)=>xe(i).sub(t).mul(e).add(t),dae=(i=Mr(),e=1,t=0)=>FE(i.convert("vec2|vec3")).mul(e).add(t),Aae=(i=Mr(),e=1,t=0)=>kE(i.convert("vec2|vec3")).mul(e).add(t),pae=(i=Mr(),e=1,t=0)=>(i=i.convert("vec2|vec3"),_n(kE(i),FE(i.add(Lt(19,73)))).mul(e).add(t)),mae=(i=Mr(),e=1)=>Zse(i.convert("vec2|vec3"),e,Ee(1)),gae=(i=Mr(),e=1)=>eae(i.convert("vec2|vec3"),e,Ee(1)),vae=(i=Mr(),e=1)=>nae(i.convert("vec2|vec3"),e,Ee(1)),_ae=(i=Mr())=>kse(i.convert("vec2|vec3")),yae=(i=Mr(),e=3,t=2,n=.5,r=1)=>iy(i,Ee(e),t,n).mul(r),xae=(i=Mr(),e=3,t=2,n=.5,r=1)=>jse(i,Ee(e),t,n).mul(r),bae=(i=Mr(),e=3,t=2,n=.5,r=1)=>WB(i,Ee(e),t,n).mul(r),Sae=(i=Mr(),e=3,t=2,n=.5,r=1)=>Hse(i,Ee(e),t,n).mul(r),wae=Ke(([i,e,t])=>{const n=Lc(i).toVar("nDir"),r=yi(xe(.5).mul(e.sub(t)),Tc).div(n).toVar("rbmax"),s=yi(xe(-.5).mul(e.sub(t)),Tc).div(n).toVar("rbmin"),a=Ie().toVar("rbminmax");a.x=n.x.greaterThan(xe(0)).select(r.x,s.x),a.y=n.y.greaterThan(xe(0)).select(r.y,s.y),a.z=n.z.greaterThan(xe(0)).select(r.z,s.z);const l=Za(Za(a.x,a.y),a.z).toVar("correction");return Tc.add(n.mul(l)).toVar("boxIntersection").sub(t)}),QB=Ke(([i,e])=>{const t=i.x,n=i.y,r=i.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(Kn(t,t).sub(Kn(n,n)))),s});var $=Object.freeze({__proto__:null,BRDF_GGX:Kw,BRDF_Lambert:ld,BasicShadowFilter:LB,Break:NU,Continue:Mee,DFGApprox:bE,D_GGX:jU,Discard:S9,EPSILON:NL,F_Schlick:L0,Fn:Ke,INFINITY:gJ,If:ii,Loop:Bi,NodeAccess:ia,NodeShaderStage:zw,NodeType:$Z,NodeUpdateType:Qn,PCFShadowFilter:UB,PCFSoftShadowFilter:BB,PI:Q_,PI2:vJ,Return:LJ,Schlick_to_F0:WU,ScriptableNodeResources:t_,ShaderNode:Pm,TBNViewMatrix:jf,VSMShadowFilter:OB,V_GGX_SmithCorrelated:VU,abs:rr,acesFilmicToneMapping:wB,acos:BL,add:Qr,addMethodChaining:mt,addNodeElement:BJ,agxToneMapping:TB,all:$M,alphaT:$_,and:vL,anisotropy:Th,anisotropyB:Zf,anisotropyT:Lm,any:RL,append:KP,arrayBuffer:fJ,asin:UL,assign:hL,atan:QM,atan2:t9,atomicAdd:Lre,atomicAnd:Ire,atomicFunc:zc,atomicMax:Bre,atomicMin:Ore,atomicOr:Fre,atomicStore:Pre,atomicSub:Ure,atomicXor:kre,attenuationColor:VM,attenuationDistance:qM,attribute:Au,attributeArray:Mie,backgroundBlurriness:fB,backgroundIntensity:iT,backgroundRotation:dB,batch:MU,billboarding:sie,bitAnd:bL,bitNot:SL,bitOr:wL,bitXor:TL,bitangentGeometry:aee,bitangentLocal:oee,bitangentView:G9,bitangentWorld:lee,bitcast:_J,blendBurn:mB,blendColor:Fie,blendDodge:gB,blendOverlay:_B,blendScreen:vB,blur:JU,bool:Pc,buffer:$g,bufferAttribute:Hg,bumpMap:H9,burn:kie,bvec2:eL,bvec3:OM,bvec4:rL,bypass:_9,cache:Bm,call:fL,cameraFar:Ch,cameraNear:Eh,cameraNormalMatrix:GJ,cameraPosition:E9,cameraProjectionMatrix:Ad,cameraProjectionMatrixInverse:kJ,cameraViewMatrix:no,cameraWorldMatrix:zJ,cbrt:YL,cdl:$ie,ceil:By,checker:hse,cineonToneMapping:SB,clamp:du,clearcoat:W_,clearcoatRoughness:Sg,code:Yy,color:ZP,colorSpaceToWorking:sE,colorToDirection:tte,compute:v9,cond:n9,context:Fy,convert:aL,convertColorSpace:wJ,convertToTexture:vie,cos:pc,cross:Iy,cubeTexture:P0,dFdx:KM,dFdy:ZM,dashSize:Xv,defaultBuildStages:Gw,defaultShaderStages:HP,defined:_g,degrees:PL,deltaTime:uB,densityFog:mre,densityFogFactor:RE,depth:vE,depthPass:Jie,difference:HL,diffuseColor:Ri,directPointLight:kB,directionToColor:OU,dispersion:jM,distance:jL,div:Cl,dodge:zie,dot:jh,drawIndex:SU,dynamicBufferAttribute:g9,element:sL,emissive:Hw,equal:dL,equals:qL,equirectUV:_E,exp:XM,exp2:D0,expression:zh,faceDirection:Wg,faceForward:iE,faceforward:yJ,float:xe,floor:au,fog:Cg,fract:kc,frameGroup:uL,frameId:Yne,frontFacing:D9,fwidth:zL,gain:qne,gapSize:Ww,getConstNodeType:QP,getCurrentStack:BM,getDirection:KU,getDistanceAttenuation:IE,getGeometryRoughness:qU,getNormalFromDepth:yie,getParallaxCorrectNormal:wae,getRoughness:xE,getScreenPosition:_ie,getShIrradianceAt:QB,getTextureIndex:oB,getViewPosition:BA,glsl:lre,glslFn:ure,grayscale:Vie,greaterThan:WM,greaterThanEqual:gL,hash:Gne,highpModelNormalViewMatrix:ZJ,highpModelViewMatrix:KJ,hue:Wie,instance:xee,instanceIndex:Kg,instancedArray:Eie,instancedBufferAttribute:K_,instancedDynamicBufferAttribute:$w,instancedMesh:TU,int:Ee,inverseSqrt:YM,inversesqrt:xJ,invocationLocalIndex:yee,invocationSubgroupIndex:_ee,ior:Um,iridescence:Ly,iridescenceIOR:kM,iridescenceThickness:zM,ivec2:As,ivec3:tL,ivec4:nL,js:are,label:r9,length:wc,lengthSq:QL,lessThan:pL,lessThanEqual:mL,lightPosition:LE,lightProjectionUV:DB,lightShadowMatrix:PE,lightTargetDirection:UE,lightTargetPosition:PB,lightViewPosition:Ky,lightingContext:DU,lights:qre,linearDepth:J_,linearToneMapping:xB,localId:bre,log:Uy,log2:su,logarithmicDepthToViewZ:zee,loop:Eee,luminance:CE,mat2:Dy,mat3:ua,mat4:Kf,matcapUV:tB,materialAO:xU,materialAlphaTest:W9,materialAnisotropy:oU,materialAnisotropyVector:UA,materialAttenuationColor:pU,materialAttenuationDistance:AU,materialClearcoat:tU,materialClearcoatNormal:iU,materialClearcoatRoughness:nU,materialColor:$9,materialDispersion:yU,materialEmissive:Y9,materialIOR:dU,materialIridescence:lU,materialIridescenceIOR:uU,materialIridescenceThickness:cU,materialLightMap:hE,materialLineDashOffset:_U,materialLineDashSize:gU,materialLineGapSize:vU,materialLineScale:mU,materialLineWidth:mee,materialMetalness:J9,materialNormal:eU,materialOpacity:cE,materialPointWidth:gee,materialReference:_c,materialReflectivity:Kv,materialRefractionRatio:U9,materialRotation:rU,materialRoughness:Z9,materialSheen:sU,materialSheenRoughness:aU,materialShininess:X9,materialSpecular:Q9,materialSpecularColor:K9,materialSpecularIntensity:Qw,materialSpecularStrength:Om,materialThickness:fU,materialTransmission:hU,max:Gr,maxMipLevel:M9,mediumpModelViewMatrix:R9,metalness:bg,min:Za,mix:Ui,mixElement:JL,mod:eE,modInt:HM,modelDirection:WJ,modelNormalMatrix:N9,modelPosition:$J,modelScale:XJ,modelViewMatrix:H0,modelViewPosition:YJ,modelViewProjection:fE,modelWorldMatrix:Ho,modelWorldMatrixInverse:QJ,morphReference:RU,mrt:lB,mul:Kn,mx_aastep:$B,mx_cell_noise_float:_ae,mx_contrast:fae,mx_fractal_noise_float:yae,mx_fractal_noise_vec2:xae,mx_fractal_noise_vec3:bae,mx_fractal_noise_vec4:Sae,mx_hsvtorgb:iae,mx_noise_float:dae,mx_noise_vec3:Aae,mx_noise_vec4:pae,mx_ramplr:aae,mx_ramptb:oae,mx_rgbtohsv:rae,mx_safepower:hae,mx_splitlr:lae,mx_splittb:uae,mx_srgb_texture_to_lin_rec709:sae,mx_transform_uv:cae,mx_worley_noise_float:mae,mx_worley_noise_vec2:gae,mx_worley_noise_vec3:vae,negate:OL,neutralToneMapping:MB,nodeArray:Qf,nodeImmutable:$t,nodeObject:wt,nodeObjects:Gg,nodeProxy:gt,normalFlat:P9,normalGeometry:zy,normalLocal:Ja,normalMap:Yw,normalView:Ko,normalWorld:Gy,normalize:Lc,not:yL,notEqual:AL,numWorkgroups:yre,objectDirection:qJ,objectGroup:FM,objectPosition:C9,objectScale:jJ,objectViewPosition:HJ,objectWorldMatrix:VJ,oneMinus:IL,or:_L,orthographicDepthToViewZ:kee,oscSawtooth:nie,oscSine:Jne,oscSquare:eie,oscTriangle:tie,output:Tg,outputStruct:kne,overlay:qie,overloadingFn:Vs,parabola:nT,parallaxDirection:V9,parallaxUV:cee,parameter:Ine,pass:Kie,passTexture:Zie,pcurve:Vne,perspectiveDepthToViewZ:mE,pmremTexture:SE,pointUV:Die,pointWidth:AJ,positionGeometry:ky,positionLocal:zr,positionPrevious:Z_,positionView:Xr,positionViewDirection:hr,positionWorld:Tc,positionWorldDirection:aE,posterize:Yie,pow:Tl,pow2:tE,pow3:WL,pow4:$L,property:cL,radians:DL,rand:ZL,range:vre,rangeFog:pre,rangeFogFactor:NE,reciprocal:kL,reference:zi,referenceBuffer:Xw,reflect:VL,reflectVector:I9,reflectView:B9,reflector:die,refract:nE,refractVector:F9,refractView:O9,reinhardToneMapping:bB,remainder:CL,remap:x9,remapClamp:b9,renderGroup:Ln,renderOutput:w9,rendererReference:A9,rotate:wE,rotateUV:iie,roughness:$l,round:FL,rtt:hB,sRGBTransferEOTF:l9,sRGBTransferOETF:u9,sampler:FJ,saturate:KL,saturation:jie,screen:Gie,screenCoordinate:Zg,screenSize:Eg,screenUV:gu,scriptable:Are,scriptableValue:e_,select:zs,setCurrentStack:yg,shaderStages:qw,shadow:FB,shadowPositionWorld:OE,sharedUniformGroup:IM,sheen:Vf,sheenRoughness:Py,shiftLeft:ML,shiftRight:EL,shininess:X_,sign:Mg,sin:So,sinc:jne,skinning:wee,skinningReference:CU,smoothstep:Uc,smoothstepElement:e9,specularColor:Oa,specularF90:wg,spherizeUV:rie,split:dJ,spritesheetUV:lie,sqrt:Su,stack:Zv,step:Oy,storage:Xy,storageBarrier:Mre,storageObject:Tie,storageTexture:AB,string:hJ,sub:yi,subgroupIndex:vee,subgroupSize:Sre,tan:LL,tangentGeometry:jy,tangentLocal:Xg,tangentView:Yg,tangentWorld:z9,temp:a9,texture:fi,texture3D:fne,textureBarrier:Ere,textureBicubic:YU,textureCubeUV:ZU,textureLoad:Ir,textureSize:Uh,textureStore:Lie,thickness:GM,time:pd,timerDelta:Zne,timerGlobal:Kne,timerLocal:Qne,toOutputColorSpace:c9,toWorkingColorSpace:h9,toneMapping:p9,toneMappingExposure:m9,toonOutlinePass:tre,transformDirection:XL,transformNormal:L9,transformNormalToView:oE,transformedBentNormalView:j9,transformedBitangentView:q9,transformedBitangentWorld:uee,transformedClearcoatNormalView:HA,transformedNormalView:kr,transformedNormalWorld:qy,transformedTangentView:uE,transformedTangentWorld:see,transmission:Y_,transpose:GL,triNoise3D:Wne,triplanarTexture:cie,triplanarTextures:cB,trunc:JM,tslFn:cJ,uint:rn,uniform:yn,uniformArray:vc,uniformGroup:lL,uniforms:nee,userData:Bie,uv:Mr,uvec2:JP,uvec3:j0,uvec4:iL,varying:to,varyingProperty:xg,vec2:Lt,vec3:Ie,vec4:_n,vectorComponents:fd,velocity:Iie,vertexColor:Nie,vertexIndex:bU,vertexStage:o9,vibrance:Hie,viewZToLogarithmicDepth:gE,viewZToOrthographicDepth:e0,viewZToPerspectiveDepth:UU,viewport:dE,viewportBottomLeft:Oee,viewportCoordinate:LU,viewportDepthTexture:pE,viewportLinearDepth:Gee,viewportMipTexture:AE,viewportResolution:Uee,viewportSafeUV:aie,viewportSharedTexture:ete,viewportSize:PU,viewportTexture:Iee,viewportTopLeft:Bee,viewportUV:Lee,wgsl:ore,wgslFn:cre,workgroupArray:Rre,workgroupBarrier:Tre,workgroupId:xre,workingToColorSpace:f9,xor:xL});const dc=new TE;class Tae extends Hh{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(s===null)r._clearColor.getRGB(dc,Mo),dc.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(dc,Mo),dc.a=1,a=!0;else if(s.isNode===!0){const l=this.get(e),u=s;dc.copy(r._clearColor);let h=l.backgroundMesh;if(h===void 0){const v=Fy(_n(u).mul(iT),{getUV:()=>dB.mul(Gy),getTextureLevel:()=>fB});let x=fE;x=x.setZ(x.w);const S=new qr;S.name="Background.material",S.side=or,S.depthTest=!1,S.depthWrite=!1,S.fog=!1,S.lights=!1,S.vertexNode=x,S.colorNode=v,l.backgroundMeshNode=v,l.backgroundMesh=h=new Oi(new bu(1,32,32),S),h.frustumCulled=!1,h.name="Background.mesh",h.onBeforeRender=function(T,N,C){this.matrixWorld.copyPosition(C.matrixWorld)}}const m=u.getCacheKey();l.backgroundCacheKey!==m&&(l.backgroundMeshNode.node=_n(u).mul(iT),l.backgroundMeshNode.needsUpdate=!0,h.material.needsUpdate=!0,l.backgroundCacheKey=m),t.unshift(h,h.geometry,h.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",s);if(r.autoClear===!0||a===!0){const l=n.clearColorValue;l.r=dc.r,l.g=dc.g,l.b=dc.b,l.a=dc.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(l.r*=l.a,l.g*=l.a,l.b*=l.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let Mae=0;class rT{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=Mae++}}class Eae{constructor(e,t,n,r,s,a,l,u,h,m=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=m,this.nodeAttributes=r,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=l,this.updateAfterNodes=u,this.monitor=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new rT(t.name,[],t.index,t);e.push(r);for(const s of t.bindings)r.bindings.push(s.clone())}else e.push(t);return e}}class d6{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class Cae{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class KB{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Nae extends KB{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Rae{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Dae=0;class cS{constructor(e=null){this.id=Dae++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Pae extends Nn{static get type(){return"StructTypeNode"}constructor(e,t){super(),this.name=e,this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class gd{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class Lae extends gd{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Uae extends gd{constructor(e,t=new bt){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Bae extends gd{constructor(e,t=new me){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Oae extends gd{constructor(e,t=new On){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Iae extends gd{constructor(e,t=new cn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Fae extends gd{constructor(e,t=new Xn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kae extends gd{constructor(e,t=new jn){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class zae extends Lae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Gae extends Uae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qae extends Bae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vae extends Oae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jae extends Iae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Hae extends Fae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Wae extends kae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const WA=4,A6=[.125,.215,.35,.446,.526,.582],Of=20,hS=new Ig(-1,1,1,-1,0,1),$ae=new va(90,1),p6=new cn;let fS=null,dS=0,AS=0;const Pf=(1+Math.sqrt(5))/2,MA=1/Pf,m6=[new me(-Pf,MA,0),new me(Pf,MA,0),new me(-MA,0,Pf),new me(MA,0,Pf),new me(0,Pf,-MA),new me(0,Pf,MA),new me(-1,1,-1),new me(1,1,-1),new me(-1,1,1),new me(1,1,1)],Xae=[3,1,5,0,4,2],pS=KU(Mr(),Au("faceIndex")).normalize(),zE=Ie(pS.x,pS.y,pS.z);class Yae{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,s=null){if(this._setSize(256),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const l=s||this._allocateTargets();return this.fromSceneAsync(e,t,n,r,l),l}fS=this._renderer.getRenderTarget(),dS=this._renderer.getActiveCubeFace(),AS=this._renderer.getActiveMipmapLevel();const a=s||this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,n,r,a),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}async fromSceneAsync(e,t=0,n=.1,r=100,s=null){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=v6(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_6(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Xo||e.mapping===Yo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?N:0,N,N),u.render(e,s)}u.autoClear=h,e.background=x}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Xo||e.mapping===Yo;r?this._cubemapMaterial===null&&(this._cubemapMaterial=v6(e)):this._equirectMaterial===null&&(this._equirectMaterial=_6(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const l=this._cubeSize;mv(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,hS)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sOf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Of}`);const E=[];let O=0;for(let G=0;GU-WA?r-U+WA:0),z=4*(this._cubeSize-I);mv(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,hS)}}function Qae(i){const e=[],t=[],n=[],r=[];let s=i;const a=i-WA+1+A6.length;for(let l=0;li-WA?h=A6[l-i+WA-1]:l===0&&(h=0),n.push(h);const m=1/(u-2),v=-m,x=1+m,S=[v,v,x,v,x,x,v,v,x,x,v,x],T=6,N=6,C=3,E=2,O=1,U=new Float32Array(C*N*T),I=new Float32Array(E*N*T),j=new Float32Array(O*N*T);for(let G=0;G2?0:-1,V=[H,q,0,H+2/3,q,0,H+2/3,q+1,0,H,q,0,H+2/3,q+1,0,H,q+1,0],Q=Xae[G];U.set(V,C*N*Q),I.set(S,E*N*Q);const J=[Q,Q,Q,Q,Q,Q];j.set(J,O*N*Q)}const z=new Hi;z.setAttribute("position",new wr(U,C)),z.setAttribute("uv",new wr(I,E)),z.setAttribute("faceIndex",new wr(j,O)),e.push(z),r.push(new Oi(z,null)),s>WA&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:r}}function g6(i,e,t){const n=new qh(i,e,t);return n.texture.mapping=ed,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function mv(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function GE(i){const e=new qr;return e.depthTest=!1,e.depthWrite=!1,e.blending=$a,e.name=`PMREM_${i}`,e}function Kae(i,e,t){const n=vc(new Array(Of).fill(0)),r=yn(new me(0,1,0)),s=yn(0),a=xe(Of),l=yn(0),u=yn(1),h=fi(null),m=yn(0),v=xe(1/e),x=xe(1/t),S=xe(i),T={n:a,latitudinal:l,weights:n,poleAxis:r,outputDirection:zE,dTheta:s,samples:u,envMap:h,mipInt:m,CUBEUV_TEXEL_WIDTH:v,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:S},N=GE("blur");return N.uniforms=T,N.fragmentNode=JU({...T,latitudinal:l.equal(1)}),N}function v6(i){const e=GE("cubemap");return e.fragmentNode=P0(i,zE),e}function _6(i){const e=GE("equirect");return e.fragmentNode=fi(i,_E(zE),0),e}const y6=new WeakMap,Zae=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),gv=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class ZB{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=Zv(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new cS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=y6.get(this.renderer);return e===void 0&&(e=new vu,y6.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new qh(e,t,n)}createCubeRenderTarget(e,t){return new IU(e,t)}createPMREMGenerator(){return new Yae(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let s=!0;for(const l of t)r.push(l),s=s&&l.groupNode.shared!==!0;let a;return s?(a=n.get(r),a===void 0&&(a=new rT(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new rT(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of qw)for(const s in n[r]){const a=n[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${gv(t.r)}, ${gv(t.g)}, ${gv(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const s of n)if(s.name===e)return s;const r=new d6(e,t);return n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Ns)return"int";if(t===Nr)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const n=FP(e);return(t==="float"?"":t[0])+n}getTypeFromArray(e){return Zae.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof H7)&&s!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Zv(this.stack),this.stacks.push(BM()||this.stack),yg(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,yg(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);return r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let r=n.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new d6("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e,n);let s=r.structType;if(s===void 0){const a=this.structs.index++;s=new Pae("StructType"+a,t),this.structs[n].push(s),r.structType=s}return s}getUniformFromNode(e,t,n=this.shaderStage,r=null){const s=this.getDataFromNode(e,n,this.globalCache);let a=s.uniform;if(a===void 0){const l=this.uniforms.index++;a=new Cae(r||"nodeUniform"+l,t,e),this.uniforms[n].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const l=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+l.length),a=new KB(t,n),l.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,l=a.length;t===null&&(t="nodeVarying"+l),s=new Nae(t,n),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[n]||(this.codes[n]=[]),l=a.length;s=new Rae("nodeCode"+l,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const l of n)this.addLineFlowCode(l)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; +`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){const t=new EB,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const l=Object.values(this);return{next:()=>({value:l[a],done:a++>=l.length})}}};for(const a of t.inputs)n[a.name]=new sB(a.type,a.name);e.layout=null;const r=e.call(n),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,s=this.cache,a=this.buildStage,l=this.stack,u={code:""};this.flow=u,this.vars={},this.cache=new cS,this.stack=Zv();for(const h of Gw)this.setBuildStage(h),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.cache=s,this.stack=l,this.setBuildStage(a),u}getFunctionOperator(){return null}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const s=this.shaderStage;this.setShaderStage(e);const a=this.flowChildNode(t,n);return r!==null&&(a.code+=`${this.tab+r} = ${a.result}; +`),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(s),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+` +`;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new qr),r.build(this)}else this.addFlow("compute",e);for(const r of Gw){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of qw){this.setShaderStage(s);const a=this.flowNodes[s];for(const l of a)r==="generate"?this.flowNode(l):l.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new zae(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Gae(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new qae(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new Vae(e);if(t==="color")return new jae(e);if(t==="mat3")return new Hae(e);if(t==="mat4")return new Wae(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),s=this.getTypeLength(n);return r===16&&s===9?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&s===4?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:r>4||s>4||s===0?e:r===s?`${this.getType(n)}( ${e} )`:r>s?this.format(`${e}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(t)),n):s===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${F0} - Node System +`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class x6{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.frameId&&e.update(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.renderId&&e.update(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class qE{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}qE.isNodeFunctionInput=!0;class Jae extends md{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,r=UE(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:s},e.stack,e)}}const mS=new jn,vv=new jn;let hm=null;class eoe extends md{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=yn(new me).setGroup(Ln),this.halfWidth=yn(new me).setGroup(Ln),this.updateType=Qn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;vv.identity(),mS.copy(t.matrixWorld),mS.premultiply(n),vv.extractRotation(mS),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(vv),this.halfHeight.value.applyMatrix4(vv)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=fi(hm.LTC_FLOAT_1),n=fi(hm.LTC_FLOAT_2)):(t=fi(hm.LTC_HALF_1),n=fi(hm.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,l=Ky(s),u=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:l,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:u,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){hm=e}}class JB extends md{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=yn(0).setGroup(Ln),this.penumbraCosNode=yn(0).setGroup(Ln),this.cutoffDistanceNode=yn(0).setGroup(Ln),this.decayExponentNode=yn(0).setGroup(Ln)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return Uc(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,l=Ky(a).sub(Xr),u=l.normalize(),h=u.dot(UE(a)),m=this.getSpotAttenuation(h),v=l.length(),x=IE({lightDistance:v,cutoffDistance:r,decayExponent:s});let S=n.mul(m).mul(x);if(a.map){const N=DB(a),C=fi(a.map,N.xy).onRenderUpdate(()=>a.map);S=N.mul(2).sub(1).abs().lessThan(1).all().select(S.mul(C),S)}const T=e.context.reflectedLight;t.direct({lightDirection:u,lightColor:S,reflectedLight:T},e.stack,e)}}class toe extends JB{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);n=fi(t,Lt(r,0),0).r}else n=super.getSpotAttenuation(e);return n}}class noe extends md{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class ioe extends md{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=LE(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=yn(new cn).setGroup(Ln)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,a=Ko.dot(r).mul(.5).add(.5),l=Ui(n,t,a);e.context.irradiance.addAssign(l)}}class roe extends md{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new me);this.lightProbe=vc(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=QB(Gy,this.lightProbe);e.context.irradiance.addAssign(t)}}class eO{parseFunction(){console.warn("Abstract function.")}}class VE{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn("Abstract function.")}}VE.isNodeFunction=!0;const soe=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,aoe=/[a-z_0-9]+/ig,b6="#pragma main",ooe=i=>{i=i.trim();const e=i.indexOf(b6),t=e!==-1?i.slice(e+b6.length):i,n=t.match(soe);if(n!==null&&n.length===5){const r=n[4],s=[];let a=null;for(;(a=aoe.exec(r))!==null;)s.push(a);const l=[];let u=0;for(;u0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Oh||n.mapping===Ih||n.mapping===ed){if(e.backgroundBlurriness>0||n.mapping===ed)return SE(n);{let a;return n.isCubeTexture===!0?a=P0(n):a=fi(n),kU(a)}}else{if(n.isTexture===!0)return fi(n,gu.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=s.get(t);return(a===void 0||r)&&(a=n(),s.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const s=zi("color","color",n).setGroup(Ln),a=zi("density","float",n).setGroup(Ln);return Cg(s,RE(a))}else if(n.isFog){const s=zi("color","color",n).setGroup(Ln),a=zi("near","float",n).setGroup(Ln),l=zi("far","float",n).setGroup(Ln);return Cg(s,NE(a,l))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return P0(n);if(n.isTexture===!0)return fi(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,s=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=s,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return S6.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=fi(e,gu).renderOutput(t.toneMapping,t.currentColorSpace);return S6.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new x6,this.nodeBuilderCache=new Map,this.cacheLib={}}}const gS=new jl;class ry{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Xn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const r=e.length;for(let s=0;s{await this.compileAsync(v,x);const T=this._renderLists.get(v,x),N=this._renderContexts.get(v,x,this._renderTarget),C=v.overrideMaterial||S.material,E=this._objects.get(S,C,v,x,T.lightsNode,N,N.clippingContext),{fragmentShader:O,vertexShader:U}=E.getNodeBuilderState();return{fragmentShader:O,vertexShader:U}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),await n.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new coe(this,n),this._animation=new dne(this._nodes,this.info),this._attributes=new yne(n),this._background=new Tae(this,this._nodes),this._geometries=new bne(this._attributes,this.info),this._textures=new One(this,n,this.info),this._pipelines=new Ene(n,this._nodes),this._bindings=new Cne(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new gne(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new Dne(this.lighting),this._bundles=new foe,this._renderContexts=new Une,this._animation.start(),this._initialized=!0,e()}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,s=r.renderId,a=this._currentRenderContext,l=this._currentRenderObjectFunction,u=this._compilationPromises,h=e.isScene===!0?e:w6;n===null&&(n=e);const m=this._renderTarget,v=this._renderContexts.get(n,t,m),x=this._activeMipmapLevel,S=[];this._currentRenderContext=v,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=S,r.renderId++,r.update(),v.depth=this.depth,v.stencil=this.stencil,v.clippingContext||(v.clippingContext=new ry),v.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,m);const T=this._renderLists.get(e,t);if(T.begin(),this._projectObject(e,t,0,T,v.clippingContext),n!==e&&n.traverseVisible(function(U){U.isLight&&U.layers.test(t.layers)&&T.pushLight(U)}),T.finish(),m!==null){this._textures.updateRenderTarget(m,x);const U=this._textures.get(m);v.textures=U.textures,v.depthTexture=U.depthTexture}else v.textures=null,v.depthTexture=null;this._background.update(h,T,v);const N=T.opaque,C=T.transparent,E=T.transparentDoublePass,O=T.lightsNode;this.opaque===!0&&N.length>0&&this._renderObjects(N,t,h,O),this.transparent===!0&&C.length>0&&this._renderTransparents(C,E,t,h,O),r.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=l,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(S)}async renderAsync(e,t){this._initialized===!1&&await this.init();const n=this._renderScene(e,t);await this.backend.resolveTimestampAsync(n,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: + +Message: ${e.message}`;e.reason&&(t+=` +Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:s,renderList:a}=e,l=this._currentRenderContext,u=this._bundles.get(r,s),h=this.backend.get(u);h.renderContexts===void 0&&(h.renderContexts=new Set);const m=r.version!==h.version,v=h.renderContexts.has(l)===!1||m;if(h.renderContexts.add(l),v){this.backend.beginBundle(l),(h.renderObjects===void 0||m)&&(h.renderObjects=[]),this._currentRenderBundle=u;const x=a.opaque;this.opaque===!0&&x.length>0&&this._renderObjects(x,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(l,u),h.version=r.version}else{const{renderObjects:x}=h;for(let S=0,T=x.length;S>=x,T.viewportValue.height>>=x,T.viewportValue.minDepth=U,T.viewportValue.maxDepth=I,T.viewport=T.viewportValue.equals(vS)===!1,T.scissorValue.copy(E).multiplyScalar(O).floor(),T.scissor=this._scissorTest&&T.scissorValue.equals(vS)===!1,T.scissorValue.width>>=x,T.scissorValue.height>>=x,T.clippingContext||(T.clippingContext=new ry),T.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,S),yv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_S.setFromProjectionMatrix(yv,N);const j=this._renderLists.get(e,t);if(j.begin(),this._projectObject(e,t,0,j,T.clippingContext),j.finish(),this.sortObjects===!0&&j.sort(this._opaqueSort,this._transparentSort),S!==null){this._textures.updateRenderTarget(S,x);const Q=this._textures.get(S);T.textures=Q.textures,T.depthTexture=Q.depthTexture,T.width=Q.width,T.height=Q.height,T.renderTarget=S,T.depth=S.depthBuffer,T.stencil=S.stencilBuffer}else T.textures=null,T.depthTexture=null,T.width=this.domElement.width,T.height=this.domElement.height,T.depth=this.depth,T.stencil=this.stencil;T.width>>=x,T.height>>=x,T.activeCubeFace=v,T.activeMipmapLevel=x,T.occlusionQueryCount=j.occlusionQueryCount,this._background.update(h,j,T),this.backend.beginRender(T);const{bundles:z,lightsNode:G,transparentDoublePass:H,transparent:q,opaque:V}=j;if(z.length>0&&this._renderBundles(z,h,G),this.opaque===!0&&V.length>0&&this._renderObjects(V,t,h,G),this.transparent===!0&&q.length>0&&this._renderTransparents(q,H,t,h,G),this.backend.finishRender(T),s.renderId=a,this._currentRenderContext=l,this._currentRenderObjectFunction=u,r!==null){this.setRenderTarget(m,v,x);const Q=this._quad;this._nodes.hasOutputChange(S.texture)&&(Q.material.fragmentNode=this._nodes.getOutputNode(S.texture),Q.material.needsUpdate=!0),this._renderScene(Q,Q.camera,!1)}return h.onAfterRender(this,e,t,S),T}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,n=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){const s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,s=0,a=1){const l=this._viewport;e.isVector4?l.copy(e):l.set(e,t,n,r),l.minDepth=s,l.maxDepth=a}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);const r=this._renderTarget||this._getFrameBufferTarget();let s=null;if(r!==null){this._textures.updateRenderTarget(r);const a=this._textures.get(r);s=this._renderContexts.get(null,null,r),s.textures=a.textures,s.depthTexture=a.depthTexture,s.width=a.width,s.height=a.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer}if(this.backend.clear(e,t,n,s),r!==null&&this._renderTarget===null){const a=this._quad;this._nodes.hasOutputChange(r.texture)&&(a.material.fragmentNode=this._nodes.getOutputNode(r.texture),a.material.needsUpdate=!0),this._renderScene(a,a.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){this._initialized===!1&&await this.init(),this.clear(e,t,n)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this._renderTarget!==null?Ya:this.toneMapping}get currentColorSpace(){return this._renderTarget!==null?Mo:this.outputColorSpace}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(this.isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,n=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const r=this.backend,s=this._pipelines,a=this._bindings,l=this._nodes,u=Array.isArray(e)?e:[e];if(u[0]===void 0||u[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");r.beginCompute(e);for(const h of u){if(s.has(h)===!1){const x=()=>{h.removeEventListener("dispose",x),s.delete(h),a.delete(h),l.delete(h)};h.addEventListener("dispose",x);const S=h.onInitFunction;S!==null&&S.call(h,{renderer:this})}l.updateForCompute(h),a.updateForCompute(h);const m=a.getForCompute(h),v=s.getForCompute(h,m);r.compute(e,h,m,v)}r.finishCompute(e),t.renderId=n}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e),await this.backend.resolveTimestampAsync(e,"compute")}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=_h.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=_h.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=_h.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n!==null?r=n.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,r=null,s=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,s)}async readRenderTargetPixelsAsync(e,t,n,r,s,a=0,l=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,s,l)}_projectObject(e,t,n,r,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||_S.intersectsSprite(e)){this.sortObjects===!0&&_h.setFromMatrixPosition(e.matrixWorld).applyMatrix4(yv);const{geometry:u,material:h}=e;h.visible&&r.push(e,u,h,n,_h.z,null,s)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||_S.intersectsObject(e))){const{geometry:u,material:h}=e;if(this.sortObjects===!0&&(u.boundingSphere===null&&u.computeBoundingSphere(),_h.copy(u.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(yv)),Array.isArray(h)){const m=u.groups;for(let v=0,x=m.length;v0){for(const{material:a}of t)a.side=or;this._renderObjects(t,n,r,s,"backSide");for(const{material:a}of t)a.side=El;this._renderObjects(e,n,r,s);for(const{material:a}of t)a.side=as}else this._renderObjects(e,n,r,s)}_renderObjects(e,t,n,r,s=null){for(let a=0,l=e.length;a0,S.isShadowNodeMaterial&&(S.side=s.shadowSide===null?s.side:s.shadowSide,s.depthNode&&s.depthNode.isNode&&(x=S.depthNode,S.depthNode=s.depthNode),s.castShadowNode&&s.castShadowNode.isNode&&(v=S.colorNode,S.colorNode=s.castShadowNode)),s=S}s.transparent===!0&&s.side===as&&s.forceSinglePass===!1?(s.side=or,this._handleObjectFunction(e,s,t,n,l,a,u,"backSide"),s.side=El,this._handleObjectFunction(e,s,t,n,l,a,u,h),s.side=as):this._handleObjectFunction(e,s,t,n,l,a,u,h),m!==void 0&&(t.overrideMaterial.positionNode=m),x!==void 0&&(t.overrideMaterial.depthNode=x),v!==void 0&&(t.overrideMaterial.colorNode=v),e.onAfterRender(this,t,n,r,s,a)}_renderObjectDirect(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a;const m=this._nodes.needsRefresh(h);m&&(this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h)),this._pipelines.updateForRender(h),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(h),h.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(h,this.info),m&&this._nodes.updateAfter(h)}_createObjectPipeline(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a,this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h),this._pipelines.getForRender(h,this._compilationPromises),this._nodes.updateAfter(h)}get compile(){return this.compileAsync}}class jE{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function moe(i){return i+(Nh-i%Nh)%Nh}class nO extends jE{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return moe(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class iO extends nO{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let goe=0;class rO extends iO{constructor(e,t){super("UniformBuffer_"+goe++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class voe extends iO{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=0;for(let t=0,n=this.uniforms.length;t0?x:"";l=`${m.name} { + ${v} ${a.name}[${S}]; +}; +`}else l=`${this.getVectorType(a.type)} ${this.getPropertyName(a,e)};`,u=!0;const h=a.node.precision;if(h!==null&&(l=Toe[h]+" "+l),u){l=" "+l;const m=a.groupNode.name;(r[m]||(r[m]=[])).push(l)}else l="uniform "+l,n.push(l)}let s="";for(const a in r){const l=r[a];s+=this._getGLSLUniformStruct(e+"_"+a,l.join(` +`))+` +`}return s+=n.join(` +`),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ns){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let r=0;for(const s of n)t+=`layout( location = ${r++} ) in ${s.type} ${s.name}; +`}return t}getStructMembers(e){const t=[],n=e.getMemberTypes();for(let r=0;rn*r,1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:r,behavior:s}of n.values())t.push(`#extension ${r} : ${s}`);return t.join(` +`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=T6[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const r=this.renderer.backend.extensions;r.has(n)&&(r.get(n),t=!0)}T6[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let n=0;n0&&(n+=` +`),n+=` // flow -> ${h} + `),n+=`${u.code} + `,l===s&&t!=="compute"&&(n+=`// result + `,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(l.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);let l=a.uniformGPU;if(l===void 0){const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture")l=new Zy(s.name,s.node,u),m.push(l);else if(t==="cubeTexture")l=new aO(s.name,s.node,u),m.push(l);else if(t==="texture3D")l=new oO(s.name,s.node,u),m.push(l);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;const v=new rO(e,u);v.name=e.name,m.push(v),l=v}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new sO(n+"_"+h,u),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}}let yS=null,EA=null;class lO{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return yS=yS||new bt,this.renderer.getDrawingBufferSize(yS)}setScissorTest(){}getClearColor(){const e=this.renderer;return EA=EA||new TE,e.getClearColor(EA),EA.getRGB(EA,this.renderer.currentColorSpace),EA}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:q7(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${F0} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let Eoe=0;class Coe{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class Noe{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,a=e.usage||r.STATIC_DRAW,l=e.isInterleavedBufferAttribute?e.data:e,u=n.get(l);let h=u.bufferGPU;h===void 0&&(h=this._createBuffer(r,t,s,a),u.bufferGPU=h,u.bufferType=t,u.version=l.version);let m;if(s instanceof Float32Array)m=r.FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?m=r.HALF_FLOAT:m=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)m=r.SHORT;else if(s instanceof Uint32Array)m=r.UNSIGNED_INT;else if(s instanceof Int32Array)m=r.INT;else if(s instanceof Int8Array)m=r.BYTE;else if(s instanceof Uint8Array)m=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)m=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let v={bufferGPU:h,bufferType:t,type:m,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:m===r.INT||m===r.UNSIGNED_INT||e.gpuType===Ns,id:Eoe++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const x=this._createBuffer(r,t,s,a);v=new Coe(v,x)}n.set(e,v)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,a=t.get(s),l=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(l,a.bufferGPU),u.length===0)n.bufferSubData(l,0,r);else{for(let h=0,m=u.length;h1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u{function s(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}}let C6=!1,xv,bS,N6;class Poe{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},C6===!1&&(this._init(this.gl),C6=!0)}_init(e){xv={[td]:e.REPEAT,[Yl]:e.CLAMP_TO_EDGE,[nd]:e.MIRRORED_REPEAT},bS={[dr]:e.NEAREST,[i_]:e.NEAREST_MIPMAP_NEAREST,[Ql]:e.NEAREST_MIPMAP_LINEAR,[ps]:e.LINEAR,[XA]:e.LINEAR_MIPMAP_NEAREST,[za]:e.LINEAR_MIPMAP_LINEAR},N6={[GT]:e.NEVER,[WT]:e.ALWAYS,[Ay]:e.LESS,[py]:e.LEQUAL,[qT]:e.EQUAL,[HT]:e.GEQUAL,[VT]:e.GREATER,[jT]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===dr||e===i_||e===Ql?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,s=!1){const{gl:a,extensions:l}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;return t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB&&(n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=r===bn&&s===!1?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5)),t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA&&(n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=r===bn&&s===!1?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)),t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_INT&&(u=a.DEPTH24_STENCIL8),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&l.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:r,backend:s}=this;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),n.texParameteri(e,n.TEXTURE_WRAP_S,xv[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,xv[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&n.texParameteri(e,n.TEXTURE_WRAP_R,xv[t.wrapR]),n.texParameteri(e,n.TEXTURE_MAG_FILTER,bS[t.magFilter]);const a=t.mipmaps!==void 0&&t.mipmaps.length>0,l=t.minFilter===ps&&a?za:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,bS[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,N6[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===dr||t.minFilter!==Ql&&t.minFilter!==za||t.type===$r&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const u=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,s=this.getGLTextureType(e);let a=r[s];a===void 0&&(a=t.createTexture(),n.state.bindTexture(s,a),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=a),n.set(e,{textureGPU:a,glTextureType:s,isDefault:!0})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:s,width:a,height:l,depth:u}=t,h=r.utils.convert(e.format,e.colorSpace),m=r.utils.convert(e.type),v=this.getInternalFormat(e.internalFormat,h,m,e.colorSpace,e.isVideoTexture),x=n.createTexture(),S=this.getGLTextureType(e);r.state.bindTexture(S,x),this.setTextureParameters(S,e),e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,v,a,l,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,v,a,l,u):e.isVideoTexture||n.texStorage2D(S,s,v,a,l),r.set(e,{textureGPU:x,glTextureType:S,glFormat:h,glType:m,glInternalFormat:v})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:s,glTextureType:a,glFormat:l,glType:u}=r.get(t),{width:h,height:m}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,h,m,l,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:s}=t,{textureGPU:a,glTextureType:l,glFormat:u,glType:h,glInternalFormat:m}=this.backend.get(e);if(e.isRenderTargetTexture||a===void 0)return;const v=x=>x.isDataTexture?x.image.data:typeof HTMLImageElement<"u"&&x instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&x instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&x instanceof ImageBitmap||x instanceof OffscreenCanvas?x:x.data;if(this.backend.state.bindTexture(l,a),this.setTextureParameters(l,e),e.isCompressedTexture){const x=e.mipmaps,S=t.image;for(let T=0;T0,x=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(v){const S=l!==0||u!==0;let T,N;if(e.isDepthTexture===!0?(T=r.DEPTH_BUFFER_BIT,N=r.DEPTH_ATTACHMENT,t.stencil&&(T|=r.STENCIL_BUFFER_BIT)):(T=r.COLOR_BUFFER_BIT,N=r.COLOR_ATTACHMENT0),S){const C=this.backend.get(t.renderTarget),E=C.framebuffers[t.getCacheKey()],O=C.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,E),s.bindFramebuffer(r.READ_FRAMEBUFFER,O);const U=x-u-m;r.blitFramebuffer(l,U,l+h,U+m,l,U,l+h,U+m,T,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,E),s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,U,h,m),s.unbindTexture()}else{const C=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,C),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,N,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,h,m,0,0,h,m,T,r.NEAREST),r.deleteFramebuffer(C)}}else s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,x-m-u,h,m),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:n}=this,r=t.renderTarget,{samples:s,depthTexture:a,depthBuffer:l,stencilBuffer:u,width:h,height:m}=r;if(n.bindRenderbuffer(n.RENDERBUFFER,e),l&&!u){let v=n.DEPTH_COMPONENT24;s>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(v=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,s,v,h,m)):n.renderbufferStorage(n.RENDERBUFFER,v,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else l&&u&&(s>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,s,n.DEPTH24_STENCIL8,h,m):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,n,r,s,a){const{backend:l,gl:u}=this,{textureGPU:h,glFormat:m,glType:v}=this.backend.get(e),x=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,x);const S=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,S,h,0);const T=this._getTypedArrayType(v),N=this._getBytesPerTexel(v,m),E=r*s*N,O=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.bufferData(u.PIXEL_PACK_BUFFER,E,u.STREAM_READ),u.readPixels(t,n,r,s,m,v,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await l.utils._clientWaitAsync();const U=new T(E/T.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,U),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(x),U}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}}class Loe{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class Uoe{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const R6={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class Boe{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:r,object:s,type:a,info:l,index:u}=this;u!==0?n.drawElements(r,t,a,e):n.drawArrays(r,e,t),l.update(s,t,r,1)}renderInstances(e,t,n){const{gl:r,mode:s,type:a,index:l,object:u,info:h}=this;n!==0&&(l!==0?r.drawElementsInstanced(s,t,a,e,n):r.drawArraysInstanced(s,e,t,n),h.update(u,t,s,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:s,object:a,info:l}=this;if(n===0)return;const u=r.get("WEBGL_multi_draw");if(u===null)for(let h=0;h0)){const n=t.queryQueue.shift();this.initTimestampQuery(n)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const n=this.get(e);n.gpuQueries||(n.gpuQueries=[]);for(let r=0;r0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),s=r.previousContext,a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const l=e.textures;if(l!==null)for(let u=0;u0){const m=u.framebuffers[e.getCacheKey()],v=t.COLOR_BUFFER_BIT,x=u.msaaFrameBuffer,S=e.textures;n.bindFramebuffer(t.READ_FRAMEBUFFER,x),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,m);for(let T=0;T{let u=0;for(let h=0;h0&&s.add(r[h]),n[h]=null,a.deleteQuery(m),u++)}u1?E.renderInstances(I,O,U):E.render(I,O),u.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new Moe(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,s=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,r),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:s,vertexProgram:a}=r,l=n.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU;if(n.attachShader(l,u),n.attachShader(l,h),n.linkProgram(l),this.set(r,{programGPU:l,fragmentShader:u,vertexShader:h}),t!==null&&this.parallel){const m=new Promise(v=>{const x=this.parallel,S=()=>{n.getProgramParameter(l,x.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),v()):requestAnimationFrame(S)};S()});t.push(m);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(` +`),r=[],s=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let l=s;l":" "} ${u}: ${n[l]}`)}return r.join(` +`)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),s=e.getShaderInfoLog(t).trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const l=parseInt(a[1]);return n.toUpperCase()+` + +`+s+` + +`+this._handleSource(e.getShaderSource(t),l)}else return s}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,s=r.getProgramInfoLog(e).trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,n,t);else{const a=this._getShaderErrors(r,n,"vertex"),l=this._getShaderErrors(r,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+` + +Program Info Log: `+s+` +`+a+` +`+l)}else s!==""&&console.warn("THREE.WebGLProgram: Program Info Log:",s)}}_completeCompile(e,t){const{state:n,gl:r}=this,s=this.get(t),{programGPU:a,fragmentShader:l,vertexShader:u}=s;r.getProgramParameter(a,r.LINK_STATUS)===!1&&this._logProgramError(a,l,u),n.useProgram(a);const h=e.getBindings();this._setupBindings(h,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){const{state:n,gl:r}=this,s={stage:"fragment",code:`#version 300 es +precision highp float; +void main() {}`};this.createProgram(s);const{computeProgram:a}=e,l=r.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU,m=a.transforms,v=[],x=[];for(let C=0;CR6[r]===e),n=this.extensions;for(let r=0;r0){if(S===void 0){const E=[];S=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,S);const O=[],U=e.textures;for(let I=0;I, + @location( 0 ) vTex : vec2 +}; + +@vertex +fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct { + + var Varys : VarysStruct; + + var pos = array< vec2, 4 >( + vec2( -1.0, 1.0 ), + vec2( 1.0, 1.0 ), + vec2( -1.0, -1.0 ), + vec2( 1.0, -1.0 ) + ); + + var tex = array< vec2, 4 >( + vec2( 0.0, 0.0 ), + vec2( 1.0, 0.0 ), + vec2( 0.0, 1.0 ), + vec2( 1.0, 1.0 ) + ); + + Varys.vTex = tex[ vertexIndex ]; + Varys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 ); + + return Varys; + +} +`,n=` +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img : texture_2d; + +@fragment +fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { + + return textureSample( img, imgSampler, vTex ); + +} +`,r=` +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img : texture_2d; + +@fragment +fn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 { + + return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) ); + +} +`;this.mipmapSampler=e.createSampler({minFilter:If.Linear}),this.flipYSampler=e.createSampler({minFilter:If.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:r})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:$A.TriangleStrip,stripIndexFormat:U0.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:$A.TriangleStrip,stripIndexFormat:U0.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const r=t.format,{width:s,height:a}=t.size,l=this.getTransferPipeline(r),u=this.getFlipYPipeline(r),h=this.device.createTexture({size:{width:s,height:a,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),m=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Ia.TwoD,baseArrayLayer:n}),v=h.createView({baseMipLevel:0,mipLevelCount:1,dimension:Ia.TwoD,baseArrayLayer:0}),x=this.device.createCommandEncoder({}),S=(T,N,C)=>{const E=T.getBindGroupLayout(0),O=this.device.createBindGroup({layout:E,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:N}]}),U=x.beginRenderPass({colorAttachments:[{view:C,loadOp:Wr.Clear,storeOp:ta.Store,clearValue:[0,0,0,0]}]});U.setPipeline(T),U.setBindGroup(0,O),U.draw(4,1,0,0),U.end()};S(l,m,v),S(u,v,m),this.device.queue.submit([x.finish()]),h.destroy()}generateMipmaps(e,t,n=0){const r=this.get(e);r.useCount===void 0&&(r.useCount=0,r.layers=[]);const s=r.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,s),this.device.queue.submit([a.finish()]),r.useCount!==0&&(r.layers[n]=s),r.useCount++}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),s=r.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:Ia.TwoD,baseArrayLayer:n});const l=[];for(let u=1;u1;for(let l=0;l]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,$oe=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,U6={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},Xoe=i=>{i=i.trim();const e=i.match(Woe);if(e!==null&&e.length===4){const t=e[2],n=[];let r=null;for(;(r=$oe.exec(t))!==null;)n.push({name:r[1],type:r[2]});const s=[];for(let m=0;m "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class Qoe extends eO{parseFunction(e){return new Yoe(e)}}const NA=typeof self<"u"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Koe={[ia.READ_ONLY]:"read",[ia.WRITE_ONLY]:"write",[ia.READ_WRITE]:"read_write"},B6={[td]:"repeat",[Yl]:"clamp",[nd]:"mirror"},Sv={vertex:NA?NA.VERTEX:1,fragment:NA?NA.FRAGMENT:2,compute:NA?NA.COMPUTE:4},O6={instance:!0,swizzleAssign:!1,storageBuffer:!0},Zoe={"^^":"tsl_xor"},Joe={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},I6={},jo={tsl_xor:new rs("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new rs("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new rs("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new rs("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new rs("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new rs("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new rs("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new rs("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new rs("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new rs("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new rs("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new rs("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new rs(` +fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { + + let res = vec2f( iRes ); + + let uvScaled = coord * res; + let uvWrapping = ( ( uvScaled % res ) + res ) % res; + + // https://www.shadertoy.com/view/WtyXRy + + let uv = uvWrapping - 0.5; + let iuv = floor( uv ); + let f = fract( uv ); + + let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); + let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); + let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); + let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); + + return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); + +} +`)},wm={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};typeof navigator<"u"&&/Windows/g.test(navigator.userAgent)&&(jo.pow_float=new rs("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),jo.pow_vec2=new rs("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[jo.pow_float]),jo.pow_vec3=new rs("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[jo.pow_float]),jo.pow_vec4=new rs("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[jo.pow_float]),wm.pow_float="tsl_pow_float",wm.pow_vec2="tsl_pow_vec2",wm.pow_vec3="tsl_pow_vec3",wm.pow_vec4="tsl_pow_vec4");let uO="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(uO+=`diagnostic( off, derivative_uniformity ); +`);class ele extends ZB{constructor(e,t){super(e,t,new Qoe),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==To}_generateTextureSample(e,t,n,r,s=this.shaderStage){return s==="fragment"?r?`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n):this.generateTextureLod(e,t,n,r,"0")}_generateVideoSample(e,t,n=this.shaderStage){if(n==="fragment")return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${n} shader.`)}_generateTextureSampleLevel(e,t,n,r,s,a=this.shaderStage){return(a==="fragment"||a==="compute")&&this.isUnfilterable(e)===!1?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,r):this.generateTextureLod(e,t,n,s,r)}generateWrapFunction(e){const t=`tsl_coord_${B6[e.wrapS]}S_${B6[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=I6[t];if(n===void 0){const r=[],s=e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${s} ) -> ${s} { + + return ${s}( +`;const l=(u,h)=>{u===td?(r.push(jo.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${h} )`):u===Yl?(r.push(jo.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${h} )`):u===nd?(r.push(jo.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${h} )`):(a+=` coord.${h}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};l(e.wrapS,"x"),a+=`, +`,l(e.wrapT,"y"),e.isData3DTexture&&(a+=`, +`,l(e.wrapR,"z")),a+=` + ); + +} +`,I6[t]=n=new rs(a,r)}return n.build(this),t}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let s=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,l;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),h=u>1;e.isData3DTexture?l="vec3":l="vec2",h||e.isVideoTexture||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,s=new Yv(new Qv(`textureDimensions( ${a} )`,l)),r.dimensionsSnippet[n]=s,(e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new Yv(new Qv(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new Yv(new Qv("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,n,r="0u"){this._include("biquadraticTexture");const s=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,r);return`tsl_biquadraticTexture( ${t}, ${s}( ${n} ), ${a}, u32( ${r} ) )`}generateTextureLod(e,t,n,r,s="0u"){const a=this.generateWrapFunction(e),l=this.generateTextureDimension(e,t,s),u=e.isData3DTexture?"vec3":"vec2",h=`${u}(${a}(${n}) * ${u}(${l}))`;return this.generateTextureLoad(e,t,h,r,s)}generateTextureLoad(e,t,n,r,s="0u"){return e.isVideoTexture===!0||e.isStorageTexture===!0?`textureLoad( ${t}, ${n} )`:r?`textureLoad( ${t}, ${n}, ${r}, u32( ${s} ) )`:`textureLoad( ${t}, ${n}, u32( ${s} ) )`}generateTextureStore(e,t,n,r){return`textureStore( ${t}, ${n}, ${r} )`}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===$r||this.isSampleCompare(e)===!1&&e.minFilter===dr&&e.magFilter===dr||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,s=this.shaderStage){let a=null;return e.isVideoTexture===!0?a=this._generateVideoSample(t,n,s):this.isUnfilterable(e)?a=this.generateTextureLod(e,t,n,r,"0",s):a=this._generateTextureSample(e,t,n,r,s),a}generateTextureGrad(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,n,r,s,a=this.shaderStage){let l=null;return e.isVideoTexture===!0?l=this._generateVideoSample(t,n,a):l=this._generateTextureSampleLevel(e,t,n,r,s,a),l}generateTextureBias(e,t,n,r,s,a=this.shaderStage){if(a==="fragment")return`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const n=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="storageTexture"||r==="texture3D"?n:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?`NodeBuffer_${e.id}.${n}`:e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=Zoe[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?ia.READ_ONLY:e.access}getStorageAccess(e,t){return Koe[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let l;const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let v=null;const x=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?v=new Zy(s.name,s.node,u,x):t==="cubeTexture"?v=new aO(s.name,s.node,u,x):t==="texture3D"&&(v=new oO(s.name,s.node,u,x)),v.store=e.isStorageTextureNode===!0,v.setVisibility(Sv[n]),(n==="fragment"||n==="compute")&&this.isUnfilterable(e.value)===!1&&v.store===!1){const S=new Foe(`${s.name}_sampler`,s.node,u);S.setVisibility(Sv[n]),m.push(S,v),l=[S,v]}else m.push(v),l=[v]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const v=t==="buffer"?rO:Goe,x=new v(e,u);x.setVisibility(Sv[n]),m.push(x),l=x}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new sO(h,u),x.setVisibility(Sv[n]),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}getBuiltin(e,t,n,r=this.shaderStage){const s=this.builtins[r]||(this.builtins[r]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:n}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const a of t.inputs)r.push(a.name+" : "+this.getType(a.type));let s=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} { +${n.vars} +${n.code} +`;return n.result&&(s+=` return ${n.result}; +`),s+=` +} +`,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],n=this.directives[e];if(n!==void 0)for(const r of n)t.push(`enable ${r};`);return t.join(` +`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],n=this.builtins[e];if(n!==void 0)for(const{name:r,property:s,type:a}of n.values())t.push(`@builtin( ${r} ) ${s} : ${a}`);return t.join(`, + `)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:r,bufferType:s,bufferCount:a}of this.scopedArrays.values()){const l=this.getType(s);t.push(`var<${r}> ${n}: array< ${l}, ${a} >;`)}return t.join(` +`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","id","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const n=this.getBuiltins("attribute");n&&t.push(n);const r=this.getAttributesArray();for(let s=0,a=r.length;s`)}const r=this.getBuiltins("output");return r&&t.push(" "+r),t.join(`, +`)}getStructs(e){const t=[],n=this.structs[e];for(let r=0,s=n.length;r output : ${l}; + +`)}return t.join(` + +`)}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(` ${this.getVar(r.type,r.name)};`);return` +${t.join(` +`)} +`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4","vertex"),e==="vertex"||e==="fragment"){const s=this.varyings,a=this.vars[e];for(let l=0;l1&&(S="_multisampled"),v.isCubeTexture===!0)x="texture_cube";else if(v.isDataArrayTexture===!0||v.isCompressedArrayTexture===!0)x="texture_2d_array";else if(v.isDepthTexture===!0)x=`texture_depth${S}_2d`;else if(v.isVideoTexture===!0)x="texture_external";else if(v.isData3DTexture===!0)x="texture_3d";else if(u.node.isStorageTextureNode===!0){const N=aT(v),C=this.getStorageAccess(u.node,e);x=`texture_storage_2d<${N}, ${C}>`}else{const N=this.getComponentTypeFromTexture(v).charAt(0);x=`texture${S}_2d<${N}32>`}n.push(`@binding( ${m.binding++} ) @group( ${m.group} ) var ${u.name} : ${x};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const v=u.node,x=this.getType(v.bufferType),S=v.bufferCount,T=S>0&&u.type==="buffer"?", "+S:"",N=v.isAtomic?`atomic<${x}>`:`${x}`,C=` ${u.name} : array< ${N}${T} > +`,E=v.isStorageBufferNode?`storage, ${this.getStorageAccess(v,e)}`:"uniform";r.push(this._getWGSLStructBinding("NodeBuffer_"+v.id,C,E,m.binding++,m.group))}else{const v=this.getType(this.getVectorType(u.type)),x=u.groupNode.name;(a[x]||(a[x]={index:m.binding++,id:m.group,snippets:[]})).snippets.push(` ${u.name} : ${v}`)}}for(const u in a){const h=a[u];s.push(this._getWGSLStructBinding(u,h.snippets.join(`, +`),"uniform",h.index,h.id))}let l=n.join(` +`);return l+=r.join(` +`),l+=s.join(` +`),l}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code + +`;r+=this.flowCode[t];const s=this.flowNodes[t],a=s[s.length-1],l=a.outputNode,u=l!==void 0&&l.isOutputStructNode===!0;for(const h of s){const m=this.getFlowData(h),v=h.name;if(v&&(r.length>0&&(r+=` +`),r+=` // flow -> ${v} + `),r+=`${m.code} + `,h===a&&t!=="compute"){if(r+=`// result + + `,t==="vertex")r+=`varyings.Vertex = ${m.result};`;else if(t==="fragment")if(u)n.returnType=l.nodeType,r+=`return ${m.result};`;else{let x=" @location(0) color: vec4";const S=this.getBuiltins("output");S&&(x+=`, + `+S),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",x),n.structs+=` +var output : OutputStruct; + +`,r+=`output.color = ${m.result}; + + return output;`}}}n.flow=r}this.material!==null?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getType(e){return Joe[e]||e}isAvailable(e){let t=O6[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),O6[e]=t),t}_getWGSLMethod(e){return jo[e]!==void 0&&this._include(e),wm[e]}_include(e){const t=jo[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} +// directives +${e.directives} + +// uniforms +${e.uniforms} + +// varyings +${e.varyings} +var varyings : VaryingsStruct; + +// codes +${e.codes} + +@vertex +fn main( ${e.attributes} ) -> VaryingsStruct { + + // vars + ${e.vars} + + // flow + ${e.flow} + + return varyings; + +} +`}_getWGSLFragmentCode(e){return`${this.getSignature()} +// global +${uO} + +// uniforms +${e.uniforms} + +// structs +${e.structs} + +// codes +${e.codes} + +@fragment +fn main( ${e.varyings} ) -> ${e.returnType} { + + // vars + ${e.vars} + + // flow + ${e.flow} + +} +`}_getWGSLComputeCode(e,t){return`${this.getSignature()} +// directives +${e.directives} + +// system +var instanceIndex : u32; + +// locals +${e.scopedArrays} + +// uniforms +${e.uniforms} + +// codes +${e.codes} + +@compute @workgroup_size( ${t} ) +fn main( ${e.attributes} ) { + + // system + instanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t}); + + // vars + ${e.vars} + + // flow + ${e.flow} + +} +`}_getWGSLStruct(e,t){return` +struct ${e} { +${t} +};`}_getWGSLStructBinding(e,t,n,r=0,s=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)} +@binding( ${r} ) @group( ${s} ) +var<${n}> ${e} : ${a};`}}class tle{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=Be.Depth24PlusStencil8:e.depth&&(t=Be.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,a=s.getRenderTarget();t=a?a.samples:s.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return $A.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return $A.LineList;if(e.isLine)return $A.LineStrip;if(e.isMesh)return $A.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?Be.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const nle=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),ile=new Map([[H7,["float16"]]]),rle=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class sle{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let a=s.buffer;if(a===void 0){const l=r.device;let u=n.array;if(e.normalized===!1&&(u.constructor===Int16Array||u.constructor===Uint16Array)){const m=new Uint32Array(u.length);for(let v=0;v1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=CA.UnfilterableFloat)),a.texture.isDepthTexture)u.sampleType=CA.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const m=a.texture.type;m===Ns?u.sampleType=CA.SInt:m===Nr?u.sampleType=CA.UInt:m===$r&&(this.backend.hasFeature("float32-filterable")?u.sampleType=CA.Float:u.sampleType=CA.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=Ia.Cube:a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=Ia.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=Ia.ThreeD),l.texture=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);r.push(l)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){const{backend:s,bindGroupLayoutCache:a}=this,l=s.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let h;n>0&&(l.groups===void 0&&(l.groups=[],l.versions=[]),l.versions[n]===r&&(h=l.groups[n])),h===void 0&&(h=this.createBindGroup(e,u),n>0&&(l.groups[n]=h,l.versions[n]=r)),l.group=h,l.layout=u}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,s=t.get(e).buffer;n.queue.writeBuffer(s,0,r,0)}createBindGroup(e,t){const n=this.backend,r=n.device;let s=0;const a=[];for(const l of e.bindings){if(l.isUniformBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.byteLength,m=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,v=r.createBuffer({label:"bindingBuffer_"+l.name,size:h,usage:m});u.buffer=v}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isStorageBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.attribute;u.buffer=n.get(h).buffer}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isSampler){const u=n.get(l.texture);a.push({binding:s,resource:u.sampler})}else if(l.isSampledTexture){const u=n.get(l.texture);let h;if(u.externalTexture!==void 0)h=r.importExternalTexture({source:u.externalTexture});else{const m=l.store?1:u.texture.mipLevelCount,v=`view-${u.texture.width}-${u.texture.height}-${m}`;if(h=u[v],h===void 0){const x=Ooe.All;let S;l.isSampledCubeTexture?S=Ia.Cube:l.isSampledTexture3D?S=Ia.ThreeD:l.texture.isDataArrayTexture||l.texture.isCompressedArrayTexture?S=Ia.TwoDArray:S=Ia.TwoD,h=u[v]=u.texture.createView({aspect:x,dimension:S,mipLevelCount:m})}}a.push({binding:s,resource:h})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}}class ole{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:s,pipeline:a}=e,{vertexProgram:l,fragmentProgram:u}=a,h=this.backend,m=h.device,v=h.utils,x=h.get(a),S=[];for(const ne of e.getBindings()){const oe=h.get(ne);S.push(oe.layout)}const T=h.attributeUtils.createShaderVertexBuffers(e);let N;r.transparent===!0&&r.blending!==$a&&(N=this._getBlending(r));let C={};r.stencilWrite===!0&&(C={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const E=this._getColorWriteMask(r),O=[];if(e.context.textures!==null){const ne=e.context.textures;for(let oe=0;oe1},layout:m.createPipelineLayout({bindGroupLayouts:S})},V={},Q=e.context.depth,J=e.context.stencil;if((Q===!0||J===!0)&&(Q===!0&&(V.format=G,V.depthWriteEnabled=r.depthWrite,V.depthCompare=z),J===!0&&(V.stencilFront=C,V.stencilBack={},V.stencilReadMask=r.stencilFuncMask,V.stencilWriteMask=r.stencilWriteMask),q.depthStencil=V),t===null)x.pipeline=m.createRenderPipeline(q);else{const ne=new Promise(oe=>{m.createRenderPipelineAsync(q).then(ie=>{x.pipeline=ie,oe()})});t.push(ne)}}createBundleEncoder(e){const t=this.backend,{utils:n,device:r}=t,s=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormat(e),l=this._getSampleCount(e),u={label:"renderBundleEncoder",colorFormats:[a],depthStencilFormat:s,sampleCount:l};return r.createRenderBundleEncoder(u)}createComputePipeline(e,t){const n=this.backend,r=n.device,s=n.get(e.computeProgram).module,a=n.get(e),l=[];for(const u of t){const h=n.get(u);l.push(h.layout)}a.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:l})})}_getBlending(e){let t,n;const r=e.blending,s=e.blendSrc,a=e.blendDst,l=e.blendEquation;if(r===wT){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,h=e.blendDstAlpha!==null?e.blendDstAlpha:a,m=e.blendEquationAlpha!==null?e.blendEquationAlpha:l;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(l)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(h),operation:this._getBlendOperation(m)}}else{const u=e.premultipliedAlpha,h=(m,v,x,S)=>{t={srcFactor:m,dstFactor:v,operation:Mf.Add},n={srcFactor:x,dstFactor:S,operation:Mf.Add}};if(u)switch(r){case Xa:h(Jn.One,Jn.OneMinusSrcAlpha,Jn.One,Jn.OneMinusSrcAlpha);break;case t0:h(Jn.One,Jn.One,Jn.One,Jn.One);break;case n0:h(Jn.Zero,Jn.OneMinusSrc,Jn.Zero,Jn.One);break;case i0:h(Jn.Zero,Jn.Src,Jn.Zero,Jn.SrcAlpha);break}else switch(r){case Xa:h(Jn.SrcAlpha,Jn.OneMinusSrcAlpha,Jn.One,Jn.OneMinusSrcAlpha);break;case t0:h(Jn.SrcAlpha,Jn.One,Jn.SrcAlpha,Jn.One);break;case n0:h(Jn.Zero,Jn.OneMinusSrc,Jn.Zero,Jn.One);break;case i0:h(Jn.Zero,Jn.Src,Jn.Zero,Jn.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case ET:t=Jn.Zero;break;case CT:t=Jn.One;break;case NT:t=Jn.Src;break;case RT:t=Jn.OneMinusSrc;break;case zm:t=Jn.SrcAlpha;break;case Gm:t=Jn.OneMinusSrcAlpha;break;case LT:t=Jn.Dst;break;case UT:t=Jn.OneMinusDstColor;break;case DT:t=Jn.DstAlpha;break;case PT:t=Jn.OneMinusDstAlpha;break;case BT:t=Jn.SrcAlphaSaturated;break;case vne:t=Jn.Constant;break;case _ne:t=Jn.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case sk:t=Bs.Never;break;case YS:t=Bs.Always;break;case ak:t=Bs.Less;break;case lk:t=Bs.LessEqual;break;case ok:t=Bs.Equal;break;case hk:t=Bs.GreaterEqual;break;case uk:t=Bs.Greater;break;case ck:t=Bs.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Nf:t=yh.Keep;break;case ZF:t=yh.Zero;break;case JF:t=yh.Replace;break;case rk:t=yh.Invert;break;case ek:t=yh.IncrementClamp;break;case tk:t=yh.DecrementClamp;break;case nk:t=yh.IncrementWrap;break;case ik:t=yh.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case wo:t=Mf.Add;break;case TT:t=Mf.Subtract;break;case MT:t=Mf.ReverseSubtract;break;case R7:t=Mf.Min;break;case D7:t=Mf.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},s=this.backend.utils;switch(r.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?U0.Uint16:U0.Uint32),n.side){case El:r.frontFace=SS.CCW,r.cullMode=wS.Back;break;case or:r.frontFace=SS.CCW,r.cullMode=wS.Front;break;case as:r.frontFace=SS.CCW,r.cullMode=wS.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?P6.All:P6.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Bs.Always;else{const n=e.depthFunc;switch(n){case qm:t=Bs.Never;break;case Vm:t=Bs.Always;break;case jm:t=Bs.Less;break;case Bh:t=Bs.LessEqual;break;case Hm:t=Bs.Equal;break;case Wm:t=Bs.GreaterEqual;break;case $m:t=Bs.Greater;break;case Xm:t=Bs.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class lle extends lO{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.trackTimestamp=e.trackTimestamp===!0,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new tle(this),this.attributeUtils=new sle(this),this.bindingUtils=new ale(this),this.pipelineUtils=new ole(this),this.textureUtils=new Hoe(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===void 0){const a={powerPreference:t.powerPreference},l=typeof navigator<"u"?await navigator.gpu.requestAdapter(a):null;if(l===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const u=Object.values(sT),h=[];for(const v of u)l.features.has(v)&&h.push(v);const m={requiredFeatures:h,requiredLimits:t.requiredLimits};n=await l.requestDevice(m)}else n=t.device;n.lost.then(a=>{const l={api:"WebGPU",message:a.message||"Unknown reason",reason:a.reason||null,originalEvent:a};e.onDeviceLost(l)});const r=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=r;const s=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(sT.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s}),this.updateSize()}get coordinateSystem(){return cu}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let s=r.descriptors;if(s===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==n.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples||r.loadOp!==t.loadOp){s={},r.descriptors=s;const u=()=>{n.removeEventListener("dispose",u),this.delete(n)};n.addEventListener("dispose",u)}const a=e.getCacheKey();let l=s[a];if(l===void 0){const u=e.textures,h=[];let m;for(let v=0;v0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:Wr.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=s;const l=a.depthStencilAttachment;if(e.textures!==null){const m=a.colorAttachments;for(let v=0;v0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),n>0){const r=n*8;let s=this.occludedResolveCache.get(r);s===void 0&&(s=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,s));const a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const r=e.textures;for(let s=0;sl?(h.x=Math.min(t.dispatchCount,l),h.y=Math.ceil(t.dispatchCount/l)):h.x=t.dispatchCount,s.dispatchWorkgroups(h.x,h.y,h.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:n,context:r,pipeline:s}=e,a=e.getBindings(),l=this.get(r),u=this.get(s).pipeline,h=l.currentSets,m=l.currentPass,v=e.getDrawParameters();if(v===null)return;h.pipeline!==u&&(m.setPipeline(u),h.pipeline=u);const x=h.bindingGroups;for(let C=0,E=a.length;C1?0:I;T===!0?m.drawIndexed(E[I],j,C[I]/S.array.BYTES_PER_ELEMENT,0,z):m.draw(E[I],j,C[I],z)}}else if(T===!0){const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndexedIndirect(I,0)}else m.drawIndexed(C,E,O,0,0);t.update(n,C,E)}else{const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndirect(I,0)}else m.draw(C,E,O,0);t.update(n,C,E)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,s=this.utils,a=s.getSampleCountRenderContext(e.context),l=s.getCurrentColorSpace(e.context),u=s.getCurrentColorFormat(e.context),h=s.getCurrentDepthStencilFormat(e.context),m=s.getPrimitiveTopology(n,r);let v=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==l||t.colorFormat!==u||t.depthStencilFormat!==h||t.primitiveTopology!==m||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=l,t.colorFormat=u,t.depthStencilFormat=h,t.primitiveTopology=m,t.clippingContextCacheKey=e.clippingContextCacheKey,v=!0),v}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,s=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(s),r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const n=this.get(e);if(!n.timeStampQuerySet){const r=e.isComputeNode?"compute":"render",s=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${r}_${e.id}`});Object.assign(t,{timestampWrites:{querySet:s,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}),n.timeStampQuerySet=s}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const n=this.get(e),r=2*BigInt64Array.BYTES_PER_ELEMENT;n.currentTimestampQueryBuffers===void 0&&(n.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:s,resultBuffer:a}=n.currentTimestampQueryBuffers;t.resolveQuerySet(n.timeStampQuerySet,0,2,s,0),a.mapState==="unmapped"&&t.copyBufferToBuffer(s,0,a,0,r)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const n=this.get(e);if(n.currentTimestampQueryBuffers===void 0)return;const{resultBuffer:r}=n.currentTimestampQueryBuffers;r.mapState==="unmapped"&&r.mapAsync(GPUMapMode.READ).then(()=>{const s=new BigUint64Array(r.getMappedRange()),a=Number(s[1]-s[0])/1e6;this.renderer.info.updateTimestamp(t,a),r.unmap()})}createNodeBuilder(e,t){return new ele(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),s=n.currentPass.finish();this.get(t).bundleGPU=s,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,s=0){let a=0,l=0,u=0,h=0,m=0,v=0,x=e.image.width,S=e.image.height;n!==null&&(h=n.x,m=n.y,v=n.z||0,x=n.width,S=n.height),r!==null&&(a=r.x,l=r.y,u=r.z||0);const T=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),N=this.get(e).texture,C=this.get(t).texture;T.copyTextureToTexture({texture:N,mipLevel:s,origin:{x:h,y:m,z:v}},{texture:C,mipLevel:s,origin:{x:a,y:l,z:u}},[x,S,1]),this.device.queue.submit([T.finish()])}copyFramebufferToTexture(e,t,n){const r=this.get(t);let s=null;t.renderTarget?e.isDepthTexture?s=this.get(t.depthTexture).texture:s=this.get(t.textures[0]).texture:e.isDepthTexture?s=this.textureUtils.getDepthBuffer(t.depth,t.stencil):s=this.context.getCurrentTexture();const a=this.get(e).texture;if(s.format!==a.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,a.format);return}let l;if(r.currentPass?(r.currentPass.end(),l=r.encoder):l=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),l.copyTextureToTexture({texture:s,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),r.currentPass){const{descriptor:u}=r;for(let h=0;h(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new D6(e)));const n=new t(e);super(n,e),this.library=new cle,this.isWebGPURenderer=!0}}/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */$.BRDF_GGX;$.BRDF_Lambert;$.BasicShadowFilter;$.Break;$.Continue;$.DFGApprox;$.D_GGX;$.Discard;$.EPSILON;$.F_Schlick;const hle=$.Fn;$.INFINITY;const fle=$.If,dle=$.Loop;$.NodeShaderStage;$.NodeType;$.NodeUpdateType;$.NodeAccess;$.PCFShadowFilter;$.PCFSoftShadowFilter;$.PI;$.PI2;$.Return;$.Schlick_to_F0;$.ScriptableNodeResources;$.ShaderNode;$.TBNViewMatrix;$.VSMShadowFilter;$.V_GGX_SmithCorrelated;$.abs;$.acesFilmicToneMapping;$.acos;$.add;$.addNodeElement;$.agxToneMapping;$.all;$.alphaT;$.and;$.anisotropy;$.anisotropyB;$.anisotropyT;$.any;$.append;$.arrayBuffer;const Ale=$.asin;$.assign;$.atan;$.atan2;$.atomicAdd;$.atomicAnd;$.atomicFunc;$.atomicMax;$.atomicMin;$.atomicOr;$.atomicStore;$.atomicSub;$.atomicXor;$.attenuationColor;$.attenuationDistance;$.attribute;$.attributeArray;$.backgroundBlurriness;$.backgroundIntensity;$.backgroundRotation;$.batch;$.billboarding;$.bitAnd;$.bitNot;$.bitOr;$.bitXor;$.bitangentGeometry;$.bitangentLocal;$.bitangentView;$.bitangentWorld;$.bitcast;$.blendBurn;$.blendColor;$.blendDodge;$.blendOverlay;$.blendScreen;$.blur;$.bool;$.buffer;$.bufferAttribute;$.bumpMap;$.burn;$.bvec2;$.bvec3;$.bvec4;$.bypass;$.cache;$.call;$.cameraFar;$.cameraNear;$.cameraNormalMatrix;$.cameraPosition;$.cameraProjectionMatrix;$.cameraProjectionMatrixInverse;$.cameraViewMatrix;$.cameraWorldMatrix;$.cbrt;$.cdl;$.ceil;$.checker;$.cineonToneMapping;$.clamp;$.clearcoat;$.clearcoatRoughness;$.code;$.color;$.colorSpaceToWorking;$.colorToDirection;$.compute;$.cond;$.context;$.convert;$.convertColorSpace;$.convertToTexture;const ple=$.cos;$.cross;$.cubeTexture;$.dFdx;$.dFdy;$.dashSize;$.defaultBuildStages;$.defaultShaderStages;$.defined;$.degrees;$.deltaTime;$.densityFog;$.densityFogFactor;$.depth;$.depthPass;$.difference;$.diffuseColor;$.directPointLight;$.directionToColor;$.dispersion;$.distance;$.div;$.dodge;$.dot;$.drawIndex;$.dynamicBufferAttribute;$.element;$.emissive;$.equal;$.equals;$.equirectUV;const mle=$.exp;$.exp2;$.expression;$.faceDirection;$.faceForward;$.faceforward;const gle=$.float;$.floor;$.fog;$.fract;$.frameGroup;$.frameId;$.frontFacing;$.fwidth;$.gain;$.gapSize;$.getConstNodeType;$.getCurrentStack;$.getDirection;$.getDistanceAttenuation;$.getGeometryRoughness;$.getNormalFromDepth;$.getParallaxCorrectNormal;$.getRoughness;$.getScreenPosition;$.getShIrradianceAt;$.getTextureIndex;$.getViewPosition;$.glsl;$.glslFn;$.grayscale;$.greaterThan;$.greaterThanEqual;$.hash;$.highpModelNormalViewMatrix;$.highpModelViewMatrix;$.hue;$.instance;const vle=$.instanceIndex;$.instancedArray;$.instancedBufferAttribute;$.instancedDynamicBufferAttribute;$.instancedMesh;$.int;$.inverseSqrt;$.inversesqrt;$.invocationLocalIndex;$.invocationSubgroupIndex;$.ior;$.iridescence;$.iridescenceIOR;$.iridescenceThickness;$.ivec2;$.ivec3;$.ivec4;$.js;$.label;$.length;$.lengthSq;$.lessThan;$.lessThanEqual;$.lightPosition;$.lightTargetDirection;$.lightTargetPosition;$.lightViewPosition;$.lightingContext;$.lights;$.linearDepth;$.linearToneMapping;$.localId;$.log;$.log2;$.logarithmicDepthToViewZ;$.loop;$.luminance;$.mediumpModelViewMatrix;$.mat2;$.mat3;$.mat4;$.matcapUV;$.materialAO;$.materialAlphaTest;$.materialAnisotropy;$.materialAnisotropyVector;$.materialAttenuationColor;$.materialAttenuationDistance;$.materialClearcoat;$.materialClearcoatNormal;$.materialClearcoatRoughness;$.materialColor;$.materialDispersion;$.materialEmissive;$.materialIOR;$.materialIridescence;$.materialIridescenceIOR;$.materialIridescenceThickness;$.materialLightMap;$.materialLineDashOffset;$.materialLineDashSize;$.materialLineGapSize;$.materialLineScale;$.materialLineWidth;$.materialMetalness;$.materialNormal;$.materialOpacity;$.materialPointWidth;$.materialReference;$.materialReflectivity;$.materialRefractionRatio;$.materialRotation;$.materialRoughness;$.materialSheen;$.materialSheenRoughness;$.materialShininess;$.materialSpecular;$.materialSpecularColor;$.materialSpecularIntensity;$.materialSpecularStrength;$.materialThickness;$.materialTransmission;$.max;$.maxMipLevel;$.metalness;$.min;$.mix;$.mixElement;$.mod;$.modInt;$.modelDirection;$.modelNormalMatrix;$.modelPosition;$.modelScale;$.modelViewMatrix;$.modelViewPosition;$.modelViewProjection;$.modelWorldMatrix;$.modelWorldMatrixInverse;$.morphReference;$.mrt;$.mul;$.mx_aastep;$.mx_cell_noise_float;$.mx_contrast;$.mx_fractal_noise_float;$.mx_fractal_noise_vec2;$.mx_fractal_noise_vec3;$.mx_fractal_noise_vec4;$.mx_hsvtorgb;$.mx_noise_float;$.mx_noise_vec3;$.mx_noise_vec4;$.mx_ramplr;$.mx_ramptb;$.mx_rgbtohsv;$.mx_safepower;$.mx_splitlr;$.mx_splittb;$.mx_srgb_texture_to_lin_rec709;$.mx_transform_uv;$.mx_worley_noise_float;$.mx_worley_noise_vec2;$.mx_worley_noise_vec3;const _le=$.negate;$.neutralToneMapping;$.nodeArray;$.nodeImmutable;$.nodeObject;$.nodeObjects;$.nodeProxy;$.normalFlat;$.normalGeometry;$.normalLocal;$.normalMap;$.normalView;$.normalWorld;$.normalize;$.not;$.notEqual;$.numWorkgroups;$.objectDirection;$.objectGroup;$.objectPosition;$.objectScale;$.objectViewPosition;$.objectWorldMatrix;$.oneMinus;$.or;$.orthographicDepthToViewZ;$.oscSawtooth;$.oscSine;$.oscSquare;$.oscTriangle;$.output;$.outputStruct;$.overlay;$.overloadingFn;$.parabola;$.parallaxDirection;$.parallaxUV;$.parameter;$.pass;$.passTexture;$.pcurve;$.perspectiveDepthToViewZ;$.pmremTexture;$.pointUV;$.pointWidth;$.positionGeometry;$.positionLocal;$.positionPrevious;$.positionView;$.positionViewDirection;$.positionWorld;$.positionWorldDirection;$.posterize;$.pow;$.pow2;$.pow3;$.pow4;$.property;$.radians;$.rand;$.range;$.rangeFog;$.rangeFogFactor;$.reciprocal;$.reference;$.referenceBuffer;$.reflect;$.reflectVector;$.reflectView;$.reflector;$.refract;$.refractVector;$.refractView;$.reinhardToneMapping;$.remainder;$.remap;$.remapClamp;$.renderGroup;$.renderOutput;$.rendererReference;$.rotate;$.rotateUV;$.roughness;$.round;$.rtt;$.sRGBTransferEOTF;$.sRGBTransferOETF;$.sampler;$.saturate;$.saturation;$.screen;$.screenCoordinate;$.screenSize;$.screenUV;$.scriptable;$.scriptableValue;$.select;$.setCurrentStack;$.shaderStages;$.shadow;$.shadowPositionWorld;$.sharedUniformGroup;$.sheen;$.sheenRoughness;$.shiftLeft;$.shiftRight;$.shininess;$.sign;const yle=$.sin;$.sinc;$.skinning;$.skinningReference;$.smoothstep;$.smoothstepElement;$.specularColor;$.specularF90;$.spherizeUV;$.split;$.spritesheetUV;const xle=$.sqrt;$.stack;$.step;const ble=$.storage;$.storageBarrier;$.storageObject;$.storageTexture;$.string;$.sub;$.subgroupIndex;$.subgroupSize;$.tan;$.tangentGeometry;$.tangentLocal;$.tangentView;$.tangentWorld;$.temp;$.texture;$.texture3D;$.textureBarrier;$.textureBicubic;$.textureCubeUV;$.textureLoad;$.textureSize;$.textureStore;$.thickness;$.threshold;$.time;$.timerDelta;$.timerGlobal;$.timerLocal;$.toOutputColorSpace;$.toWorkingColorSpace;$.toneMapping;$.toneMappingExposure;$.toonOutlinePass;$.transformDirection;$.transformNormal;$.transformNormalToView;$.transformedBentNormalView;$.transformedBitangentView;$.transformedBitangentWorld;$.transformedClearcoatNormalView;$.transformedNormalView;$.transformedNormalWorld;$.transformedTangentView;$.transformedTangentWorld;$.transmission;$.transpose;$.tri;$.tri3;$.triNoise3D;$.triplanarTexture;$.triplanarTextures;$.trunc;$.tslFn;$.uint;const Sle=$.uniform;$.uniformArray;$.uniformGroup;$.uniforms;$.userData;$.uv;$.uvec2;$.uvec3;$.uvec4;$.varying;$.varyingProperty;$.vec2;$.vec3;$.vec4;$.vectorComponents;$.velocity;$.vertexColor;$.vertexIndex;$.vibrance;$.viewZToLogarithmicDepth;$.viewZToOrthographicDepth;$.viewZToPerspectiveDepth;$.viewport;$.viewportBottomLeft;$.viewportCoordinate;$.viewportDepthTexture;$.viewportLinearDepth;$.viewportMipTexture;$.viewportResolution;$.viewportSafeUV;$.viewportSharedTexture;$.viewportSize;$.viewportTexture;$.viewportTopLeft;$.viewportUV;$.wgsl;$.wgslFn;$.workgroupArray;$.workgroupBarrier;$.workgroupId;$.workingToColorSpace;$.xor;const F6=new Oc,wv=new me;class hO extends Kz{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Si(e,3)),this.setAttribute("uv",new Si(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u_(t,6,1);return this.setAttribute("instanceStart",new Kl(n,3,0)),this.setAttribute("instanceEnd",new Kl(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u_(t,6,1);return this.setAttribute("instanceColorStart",new Kl(n,3,0)),this.setAttribute("instanceColorEnd",new Kl(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Dz(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Oc);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),F6.setFromBufferAttribute(t),this.boundingBox.union(F6))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ud),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let s=0,a=e.count;s + #include + #include + #include + #include + + uniform float linewidth; + uniform vec2 resolution; + + attribute vec3 instanceStart; + attribute vec3 instanceEnd; + + attribute vec3 instanceColorStart; + attribute vec3 instanceColorEnd; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #ifdef USE_DASH + + uniform float dashScale; + attribute float instanceDistanceStart; + attribute float instanceDistanceEnd; + varying float vLineDistance; + + #endif + + void trimSegment( const in vec4 start, inout vec4 end ) { + + // trim end segment so it terminates between the camera plane and the near plane + + // conservative estimate of the near plane + float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column + float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column + float nearEstimate = - 0.5 * b / a; + + float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); + + end.xyz = mix( start.xyz, end.xyz, alpha ); + + } + + void main() { + + #ifdef USE_COLOR + + vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; + + #endif + + #ifdef USE_DASH + + vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; + vUv = uv; + + #endif + + float aspect = resolution.x / resolution.y; + + // camera space + vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); + vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); + + #ifdef WORLD_UNITS + + worldStart = start.xyz; + worldEnd = end.xyz; + + #else + + vUv = uv; + + #endif + + // special case for perspective projection, and segments that terminate either in, or behind, the camera plane + // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space + // but we need to perform ndc-space calculations in the shader, so we must address this issue directly + // perhaps there is a more elegant solution -- WestLangley + + bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column + + if ( perspective ) { + + if ( start.z < 0.0 && end.z >= 0.0 ) { + + trimSegment( start, end ); + + } else if ( end.z < 0.0 && start.z >= 0.0 ) { + + trimSegment( end, start ); + + } + + } + + // clip space + vec4 clipStart = projectionMatrix * start; + vec4 clipEnd = projectionMatrix * end; + + // ndc space + vec3 ndcStart = clipStart.xyz / clipStart.w; + vec3 ndcEnd = clipEnd.xyz / clipEnd.w; + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize( dir ); + + #ifdef WORLD_UNITS + + vec3 worldDir = normalize( end.xyz - start.xyz ); + vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); + vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); + vec3 worldFwd = cross( worldDir, worldUp ); + worldPos = position.y < 0.5 ? start: end; + + // height offset + float hw = linewidth * 0.5; + worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; + + // don't extend the line if we're rendering dashes because we + // won't be rendering the endcaps + #ifndef USE_DASH + + // cap extension + worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; + + // add width to the box + worldPos.xyz += worldFwd * hw; + + // endcaps + if ( position.y > 1.0 || position.y < 0.0 ) { + + worldPos.xyz -= worldFwd * 2.0 * hw; + + } + + #endif + + // project the worldpos + vec4 clip = projectionMatrix * worldPos; + + // shift the depth of the projected points so the line + // segments overlap neatly + vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; + clip.z = clipPose.z * clip.w; + + #else + + vec2 offset = vec2( dir.y, - dir.x ); + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if ( position.x < 0.0 ) offset *= - 1.0; + + // endcaps + if ( position.y < 0.0 ) { + + offset += - dir; + + } else if ( position.y > 1.0 ) { + + offset += dir; + + } + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... + offset /= resolution.y; + + // select end + vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; + + // back to clip space + offset *= clip.w; + + clip.xy += offset; + + #endif + + gl_Position = clip; + + vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation + + #include + #include + #include + + } + `,fragmentShader:` + uniform vec3 diffuse; + uniform float opacity; + uniform float linewidth; + + #ifdef USE_DASH + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + #endif + + varying float vLineDistance; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #include + #include + #include + #include + #include + + vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { + + float mua; + float mub; + + vec3 p13 = p1 - p3; + vec3 p43 = p4 - p3; + + vec3 p21 = p2 - p1; + + float d1343 = dot( p13, p43 ); + float d4321 = dot( p43, p21 ); + float d1321 = dot( p13, p21 ); + float d4343 = dot( p43, p43 ); + float d2121 = dot( p21, p21 ); + + float denom = d2121 * d4343 - d4321 * d4321; + + float numer = d1343 * d4321 - d1321 * d4343; + + mua = numer / denom; + mua = clamp( mua, 0.0, 1.0 ); + mub = ( d1343 + d4321 * ( mua ) ) / d4343; + mub = clamp( mub, 0.0, 1.0 ); + + return vec2( mua, mub ); + + } + + void main() { + + #include + + #ifdef USE_DASH + + if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps + + if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX + + #endif + + float alpha = opacity; + + #ifdef WORLD_UNITS + + // Find the closest points on the view ray and the line segment + vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; + vec3 lineDir = worldEnd - worldStart; + vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); + + vec3 p1 = worldStart + lineDir * params.x; + vec3 p2 = rayEnd * params.y; + vec3 delta = p1 - p2; + float len = length( delta ); + float norm = len / linewidth; + + #ifndef USE_DASH + + #ifdef USE_ALPHA_TO_COVERAGE + + float dnorm = fwidth( norm ); + alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); + + #else + + if ( norm > 0.5 ) { + + discard; + + } + + #endif + + #endif + + #else + + #ifdef USE_ALPHA_TO_COVERAGE + + // artifacts appear on some hardware if a derivative is taken within a conditional + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + float dlen = fwidth( len2 ); + + if ( abs( vUv.y ) > 1.0 ) { + + alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); + + } + + #else + + if ( abs( vUv.y ) > 1.0 ) { + + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + + if ( len2 > 1.0 ) discard; + + } + + #endif + + #endif + + vec4 diffuseColor = vec4( diffuse, alpha ); + + #include + #include + + gl_FragColor = vec4( diffuseColor.rgb, alpha ); + + #include + #include + #include + #include + + } + `};class HE extends Qa{constructor(e){super({type:"LineMaterial",uniforms:my.clone(Fa.line.uniforms),vertexShader:Fa.line.vertexShader,fragmentShader:Fa.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const CS=new On,k6=new me,z6=new me,Os=new On,Is=new On,zl=new On,NS=new me,RS=new jn,Fs=new eG,G6=new me,Tv=new Oc,Mv=new ud,Gl=new On;let Xl,Jf;function q6(i,e,t){return Gl.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),Gl.multiplyScalar(1/Gl.w),Gl.x=Jf/t.width,Gl.y=Jf/t.height,Gl.applyMatrix4(i.projectionMatrixInverse),Gl.multiplyScalar(1/Gl.w),Math.abs(Math.max(Gl.x,Gl.y))}function wle(i,e){const t=i.matrixWorld,n=i.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,r.count);for(let l=0,u=a;lv&&Is.z>v)continue;if(Os.z>v){const U=Os.z-Is.z,I=(Os.z-v)/U;Os.lerp(Is,I)}else if(Is.z>v){const U=Is.z-Os.z,I=(Is.z-v)/U;Is.lerp(Os,I)}Os.applyMatrix4(n),Is.applyMatrix4(n),Os.multiplyScalar(1/Os.w),Is.multiplyScalar(1/Is.w),Os.x*=s.x/2,Os.y*=s.y/2,Is.x*=s.x/2,Is.y*=s.y/2,Fs.start.copy(Os),Fs.start.z=0,Fs.end.copy(Is),Fs.end.z=0;const N=Fs.closestPointToPointParameter(NS,!0);Fs.at(N,G6);const C=x0.lerp(Os.z,Is.z,N),E=C>=-1&&C<=1,O=NS.distanceTo(G6)i.length)&&(e=i.length);for(var t=0,n=Array(e);t3?(Z=Se===ie)&&(H=te[(G=te[4])?5:(G=3,3)],te[4]=te[5]=i):te[0]<=de&&((Z=oe<2&&deie||ie>Se)&&(te[4]=oe,te[5]=ie,J.n=Se,G=0))}if(Z||oe>1)return a;throw Q=!0,ie}return function(oe,ie,Z){if(q>1)throw TypeError("Generator is already running");for(Q&&ie===1&&ne(ie,Z),G=ie,H=Z;(e=G<2?i:H)||!Q;){z||(G?G<3?(G>1&&(J.n=-1),ne(G,H)):J.n=H:J.v=H);try{if(q=2,z){if(G||(oe="next"),e=z[oe]){if(!(e=e.call(z,H)))throw TypeError("iterator result is not an object");if(!e.done)return e;H=e.value,G<2&&(G=0)}else G===1&&(e=z.return)&&e.call(z),G<2&&(H=TypeError("The iterator does not provide a '"+oe+"' method"),G=1);z=i}else if((e=(Q=J.n<0)?H:U.call(I,J))!==a)break}catch(te){z=i,G=1,H=te}finally{q=1}}return{value:e,done:Q}}})(S,N,C),!0),O}var a={};function l(){}function u(){}function h(){}e=Object.getPrototypeOf;var m=[][n]?e(e([][n]())):(go(e={},n,function(){return this}),e),v=h.prototype=l.prototype=Object.create(m);function x(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,go(S,r,"GeneratorFunction")),S.prototype=Object.create(v),S}return u.prototype=h,go(v,"constructor",h),go(h,"constructor",u),u.displayName="GeneratorFunction",go(h,r,"GeneratorFunction"),go(v),go(v,r,"Generator"),go(v,n,function(){return this}),go(v,"toString",function(){return"[object Generator]"}),(uT=function(){return{w:s,m:x}})()}function go(i,e,t,n){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}go=function(s,a,l,u){function h(m,v){go(s,m,function(x){return this._invoke(m,v,x)})}a?r?r(s,a,{value:l,enumerable:!u,configurable:!u,writable:!u}):s[a]=l:(h("next",0),h("throw",1),h("return",2))},go(i,e,t,n)}function cT(i,e){return cT=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},cT(i,e)}function Ar(i,e){return Dle(i)||Fle(i,e)||pO(i,e)||kle()}function jle(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=B0(i))!==null;);return i}function LS(i,e,t,n){var r=lT(B0(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function ji(i){return Ple(i)||Ile(i)||pO(i)||zle()}function Hle(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function AO(i){var e=Hle(i,"string");return typeof e=="symbol"?e:e+""}function pO(i,e){if(i){if(typeof i=="string")return oT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?oT(i,e):void 0}}var mO=function(e){e instanceof Array?e.forEach(mO):(e.map&&e.map.dispose(),e.dispose())},XE=function(e){e.geometry&&e.geometry.dispose(),e.material&&mO(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(XE)},Ki=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),XE(t)}};function Sa(i,e){var t=new e;return{linkProp:function(r){return{default:t[r](),onChange:function(a,l){l[i][r](a)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var a=s[i],l=arguments.length,u=new Array(l>1?l-1:0),h=1;h2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180,s=ar*(1+t),a=Math.sin(n);return{x:s*a*Math.cos(r),y:s*Math.cos(n),z:s*a*Math.sin(r)}}function gO(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),a=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),altitude:r/ar-1}}function Ff(i){return i*Math.PI/180}var Ng=window.THREE?window.THREE:{BackSide:or,BufferAttribute:wr,Color:cn,Mesh:Oi,ShaderMaterial:Qa},Wle=` +uniform float hollowRadius; + +varying vec3 vVertexWorldPosition; +varying vec3 vVertexNormal; +varying float vCameraDistanceToObjCenter; +varying float vVertexAngularDistanceToHollowRadius; + +void main() { + vVertexNormal = normalize(normalMatrix * normal); + vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; + + vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); + vCameraDistanceToObjCenter = length(objCenterViewPosition); + + float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter); + float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition))); + vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle; + + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); +}`,$le=` +uniform vec3 color; +uniform float coefficient; +uniform float power; +uniform float hollowRadius; + +varying vec3 vVertexNormal; +varying vec3 vVertexWorldPosition; +varying float vCameraDistanceToObjCenter; +varying float vVertexAngularDistanceToHollowRadius; + +void main() { + if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius + if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius + + vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition; + vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz; + viewCameraToVertex = normalize(viewCameraToVertex); + float intensity = pow( + coefficient + dot(vVertexNormal, viewCameraToVertex), + power + ); + gl_FragColor = vec4(color, intensity); +}`;function Xle(i,e,t,n){return new Ng.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:Wle,fragmentShader:$le,uniforms:{coefficient:{value:i},color:{value:new Ng.Color(e)},power:{value:t},hollowRadius:{value:n}}})}function Yle(i,e){for(var t=i.clone(),n=new Float32Array(i.attributes.position.count*3),r=0,s=n.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.color,a=s===void 0?"gold":s,l=r.size,u=l===void 0?2:l,h=r.coefficient,m=h===void 0?.5:h,v=r.power,x=v===void 0?1:v,S=r.hollowRadius,T=S===void 0?0:S,N=r.backside,C=N===void 0?!0:N;ex(this,e),n=Jy(this,e);var E=Yle(t,u),O=Xle(m,a,x,T);return C&&(O.side=Ng.BackSide),n.geometry=E,n.material=O,n}return nx(e,i),tx(e)})(Ng.Mesh),ql=window.THREE?window.THREE:{Color:cn,Group:qa,LineBasicMaterial:q0,LineSegments:Y7,Mesh:Oi,MeshPhongMaterial:oD,SphereGeometry:bu,SRGBColorSpace:bn,TextureLoader:oM},vO=_s({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){Ki(e.globeObj),Ki(e.tileEngine),Ki(e.graticulesObj)}},stateInit:function(){var e=new ql.MeshPhongMaterial({color:0}),t=new ql.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new sY(ar),r=new ql.Group;r.__globeObjType="globe",r.add(t),r.add(n);var s=new ql.LineSegments(new AP(SX(),ar,2),new ql.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:r,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){Ki(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var r;(r=e.globeObj.geometry)===null||r===void 0||r.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new ql.SphereGeometry(ar,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new ql.TextureLoader().load(e.globeImageUrl,function(l){l.colorSpace=ql.SRGBColorSpace,n.map=l,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new ql.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new ql.TextureLoader().load(e.bumpImageUrl,function(l){n.bumpMap=l,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),Ki(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new Qle(e.globeObj.geometry,{color:e.atmosphereColor,size:ar*e.atmosphereAltitude,hollowRadius:ar,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType="atmosphere",e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),yu=function(e){return isNaN(e)?parseInt(Sn(e).toHex(),16):e},Ml=function(e){return e&&isNaN(e)?sd(e).opacity:1},Gh=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,s=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var l=a.slice(1),u=Ar(l,4),h=u[0],m=u[1],v=u[2],x=u[3];r=new cn("rgb(".concat(+h,",").concat(+m,",").concat(+v,")")),s=Math.min(+x,1)}else r=new cn(e);n&&r.convertLinearToSRGB();var S=r.toArray();return t?[].concat(ji(S),[s]):S};function Kle(i,e,t){return i.opacity=e,i.transparent=e<1,i.depthWrite=e>=1,i}var $6=window.THREE?window.THREE:{BufferAttribute:wr};function xu(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(e===1)return new $6.BufferAttribute(new t(i),e);for(var n=new $6.BufferAttribute(new t(i.length*e),e),r=0,s=i.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.dataBindAttr,a=s===void 0?"__data":s,l=r.objBindAttr,u=l===void 0?"__threeObj":l,h=r.removeDelay,m=h===void 0?0:h;return ex(this,e),n=Jy(this,e),Ds(n,"scene",void 0),DS(n,US,void 0),DS(n,Ev,void 0),DS(n,Cv,void 0),n.scene=t,PS(US,n,a),PS(Ev,n,u),PS(Cv,n,m),n.onRemoveObj(function(){}),n}return nx(e,i),tx(e,[{key:"onCreateObj",value:function(n){var r=this;return LS(e,"onCreateObj",this)([function(s){var a=n(s);return s[dm(Ev,r)]=a,a[dm(US,r)]=s,r.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return LS(e,"onRemoveObj",this)([function(s,a){var l=LS(e,"getData",r)([s]);n(s,a);var u=function(){r.scene.remove(s),Ki(s),delete l[dm(Ev,r)]};dm(Cv,r)?setTimeout(u,dm(Cv,r)):u()}]),this}}])})(UQ),ml=window.THREE?window.THREE:{BufferGeometry:Hi,CylinderGeometry:iM,Matrix4:jn,Mesh:Oi,MeshLambertMaterial:Fc,Object3D:pr,Vector3:me},X6=Object.assign({},SM),Y6=X6.BufferGeometryUtils||X6,_O=_s({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var n=Ut(e.pointLat),r=Ut(e.pointLng),s=Ut(e.pointAltitude),a=Ut(e.pointRadius),l=Ut(e.pointColor),u=new ml.CylinderGeometry(1,1,1,e.pointResolution);u.applyMatrix4(new ml.Matrix4().makeRotationX(Math.PI/2)),u.applyMatrix4(new ml.Matrix4().makeTranslation(0,0,-.5));var h=2*Math.PI*ar/360,m={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&Ki(e.scene),e.dataMapper.scene=e.pointsMerge?new ml.Object3D:e.scene,e.dataMapper.onCreateObj(S).onUpdateObj(T).digest(e.pointsData),e.pointsMerge){var v=e.pointsData.length?(Y6.mergeGeometries||Y6.mergeBufferGeometries)(e.pointsData.map(function(N){var C=e.dataMapper.getObj(N),E=C.geometry.clone();C.updateMatrix(),E.applyMatrix4(C.matrix);var O=Gh(l(N));return E.setAttribute("color",xu(Array(E.getAttribute("position").count).fill(O),4)),E})):new ml.BufferGeometry,x=new ml.Mesh(v,new ml.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));x.__globeObjType="points",x.__data=e.pointsData,e.dataMapper.clear(),Ki(e.scene),e.scene.add(x)}function S(){var N=new ml.Mesh(u);return N.__globeObjType="point",N}function T(N,C){var E=function(H){var q=N.__currentTargetD=H,V=q.r,Q=q.alt,J=q.lat,ne=q.lng;Object.assign(N.position,Zo(J,ne));var oe=e.pointsMerge?new ml.Vector3(0,0,0):e.scene.localToWorld(new ml.Vector3(0,0,0));N.lookAt(oe),N.scale.x=N.scale.y=Math.min(30,V)*h,N.scale.z=Math.max(Q*ar,.1)},O={alt:+s(C),r:+a(C),lat:+n(C),lng:+r(C)},U=N.__currentTargetD||Object.assign({},O,{alt:-.001});if(Object.keys(O).some(function(G){return U[G]!==O[G]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?E(O):e.tweenGroup.add(new la(U).to(O,e.pointsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(E).start())),!e.pointsMerge){var I=l(C),j=I?Ml(I):0,z=!!j;N.visible=z,z&&(m.hasOwnProperty(I)||(m[I]=new ml.MeshLambertMaterial({color:yu(I),transparent:j<1,opacity:j})),N.material=m[I])}}}}),yO=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` + `.concat(ei.common,` + `).concat(ei.logdepthbuf_pars_vertex,` + + uniform float dashTranslate; + + attribute vec4 color; + varying vec4 vColor; + + attribute float relDistance; + varying float vRelDistance; + + void main() { + // pass through colors and distances + vColor = color; + vRelDistance = relDistance + dashTranslate; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + + `).concat(ei.logdepthbuf_vertex,` + } + `),fragmentShader:` + `.concat(ei.logdepthbuf_pars_fragment,` + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + varying vec4 vColor; + varying float vRelDistance; + + void main() { + // ignore pixels in the gap + if (vRelDistance < dashOffset) discard; + if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard; + + // set px color: [r, g, b, a], interpolated between vertices + gl_FragColor = vColor; + + `).concat(ei.logdepthbuf_fragment,` + } + `)}},hT=function(e){return e.uniforms.uSurfaceRadius={type:"float",value:0},e.vertexShader=(`attribute float surfaceRadius; +varying float vSurfaceRadius; +varying vec3 vPos; +`+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join(` +`)),e.fragmentShader=(`uniform float uSurfaceRadius; +varying float vSurfaceRadius; +varying vec3 vPos; +`+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;"].join(` +`)),e},Jle=function(e){return e.vertexShader=` + attribute float r; + + const float PI = 3.1415926535897932384626433832795; + float toRad(in float a) { + return a * PI / 180.0; + } + + vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r] + float phi = toRad(90.0 - c.x); + float theta = toRad(90.0 - c.y); + float r = c.z; + return vec3( // x,y,z + r * sin(phi) * cos(theta), + r * cos(phi), + r * sin(phi) * sin(theta) + ); + } + + vec2 Cartesian2Polar(in vec3 p) { + float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z); + float phi = acos(p.y / r); + float theta = atan(p.z, p.x); + return vec2( // lat,lng + 90.0 - phi * 180.0 / PI, + 90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0) + ); + } + `.concat(e.vertexShader.replace("}",` + vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r)); + gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); + } + `),` + `),e},YE=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},eue=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(r){return r};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(r){n(r),t(r.uniforms)}}},tue=["stroke"],gl=window.THREE?window.THREE:{BufferGeometry:Hi,CubicBezierCurve3:Z7,Curve:Nl,Group:qa,Line:_y,Mesh:Oi,NormalBlending:Xa,ShaderMaterial:Qa,TubeGeometry:sM,Vector3:me},nue=C0.default||C0,xO=_s({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new nue,sharedMaterial:new gl.ShaderMaterial(ki(ki({},yO()),{},{transparent:!0,blending:gl.NormalBlending}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var n=new gl.Group;return n.__globeObjType="arc",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Ar(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r,u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l})})},update:function(e){var t=Ut(e.arcStartLat),n=Ut(e.arcStartLng),r=Ut(e.arcStartAltitude),s=Ut(e.arcEndLat),a=Ut(e.arcEndLng),l=Ut(e.arcEndAltitude),u=Ut(e.arcAltitude),h=Ut(e.arcAltitudeAutoScale),m=Ut(e.arcStroke),v=Ut(e.arcColor),x=Ut(e.arcDashLength),S=Ut(e.arcDashGap),T=Ut(e.arcDashInitialGap),N=Ut(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(U,I){var j=m(I),z=j!=null;if(!U.children.length||z!==(U.children[0].type==="Mesh")){Ki(U);var G=z?new gl.Mesh:new gl.Line(new gl.BufferGeometry);G.material=e.sharedMaterial.clone(),U.add(G)}var H=U.children[0];Object.assign(H.material.uniforms,{dashSize:{value:x(I)},gapSize:{value:S(I)},dashOffset:{value:T(I)}});var q=N(I);H.__dashAnimateStep=q>0?1e3/q:0;var V=E(v(I),e.arcCurveResolution,z?e.arcCircularResolution+1:1),Q=O(e.arcCurveResolution,z?e.arcCircularResolution+1:1,!0);H.geometry.setAttribute("color",V),H.geometry.setAttribute("relDistance",Q);var J=function(Z){var te=U.__currentTargetD=Z,de=te.stroke,Se=Gle(te,tue),Te=C(Se);z?(H.geometry&&H.geometry.dispose(),H.geometry=new gl.TubeGeometry(Te,e.arcCurveResolution,de/2,e.arcCircularResolution),H.geometry.setAttribute("color",V),H.geometry.setAttribute("relDistance",Q)):H.geometry.setFromPoints(Te.getPoints(e.arcCurveResolution))},ne={stroke:j,alt:u(I),altAutoScale:+h(I),startLat:+t(I),startLng:+n(I),startAlt:+r(I),endLat:+s(I),endLng:+a(I),endAlt:+l(I)},oe=U.__currentTargetD||Object.assign({},ne,{altAutoScale:-.001});Object.keys(ne).some(function(ie){return oe[ie]!==ne[ie]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?J(ne):e.tweenGroup.add(new la(oe).to(ne,e.arcsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start()))}).digest(e.arcsData);function C(U){var I=U.alt,j=U.altAutoScale,z=U.startLat,G=U.startLng,H=U.startAlt,q=U.endLat,V=U.endLng,Q=U.endAlt,J=function(et){var He=Ar(et,3),Rt=He[0],Et=He[1],zt=He[2],Pt=Zo(Et,Rt,zt),We=Pt.x,ft=Pt.y,fe=Pt.z;return new gl.Vector3(We,ft,fe)},ne=[G,z],oe=[V,q],ie=I;if(ie==null&&(ie=kh(ne,oe)/2*j+Math.max(H,Q)),ie||H||Q){var Z=vM(ne,oe),te=function(et,He){return He+(He-et)*(et2&&arguments[2]!==void 0?arguments[2]:1,z=I+1,G;if(U instanceof Array||U instanceof Function){var H=U instanceof Array?Ec().domain(U.map(function(ie,Z){return Z/(U.length-1)})).range(U):U;G=function(Z){return Gh(H(Z),!0,!0)}}else{var q=Gh(U,!0,!0);G=function(){return q}}for(var V=[],Q=0,J=z;Q1&&arguments[1]!==void 0?arguments[1]:1,j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,z=U+1,G=[],H=0,q=z;H=H?j:z}),4)),I})):new xh.BufferGeometry,T=new xh.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:xh.DoubleSide});T.onBeforeCompile=function(O){T.userData.shader=hT(O)};var N=new xh.Mesh(S,T);N.__globeObjType="hexBinPoints",N.__data=v,e.dataMapper.clear(),Ki(e.scene),e.scene.add(N)}function C(O){var U=new xh.Mesh;U.__hexCenter=LP(O.h3Idx),U.__hexGeoJson=UP(O.h3Idx,!0).reverse();var I=U.__hexCenter[1];return U.__hexGeoJson.forEach(function(j){var z=j[0];Math.abs(I-z)>170&&(j[0]+=I>z?360:-360)}),U.__globeObjType="hexbin",U}function E(O,U){var I=function(te,de,Se){return te-(te-de)*Se},j=Math.max(0,Math.min(1,+h(U))),z=Ar(O.__hexCenter,2),G=z[0],H=z[1],q=j===0?O.__hexGeoJson:O.__hexGeoJson.map(function(Z){var te=Ar(Z,2),de=te[0],Se=te[1];return[[de,H],[Se,G]].map(function(Te){var ae=Ar(Te,2),Me=ae[0],Ve=ae[1];return I(Me,Ve,j)})}),V=e.hexTopCurvatureResolution;O.geometry&&O.geometry.dispose(),O.geometry=new CM([q],0,ar,!1,!0,!0,V);var Q={alt:+a(U)},J=function(te){var de=O.__currentTargetD=te,Se=de.alt;O.scale.x=O.scale.y=O.scale.z=1+Se;var Te=ar/(Se+1);O.geometry.setAttribute("surfaceRadius",xu(Array(O.geometry.getAttribute("position").count).fill(Te),1))},ne=O.__currentTargetD||Object.assign({},Q,{alt:-.001});if(Object.keys(Q).some(function(Z){return ne[Z]!==Q[Z]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?J(Q):e.tweenGroup.add(new la(ne).to(Q,e.hexTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start())),!e.hexBinMerge){var oe=u(U),ie=l(U);[oe,ie].forEach(function(Z){if(!x.hasOwnProperty(Z)){var te=Ml(Z);x[Z]=YE(new xh.MeshLambertMaterial({color:yu(Z),transparent:te<1,opacity:te,side:xh.DoubleSide}),hT)}}),O.material=[oe,ie].map(function(Z){return x[Z]})}}}}),SO=function(e){return e*e},yc=function(e){return e*Math.PI/180};function iue(i,e){var t=Math.sqrt,n=Math.cos,r=function(m){return SO(Math.sin(m/2))},s=yc(i[1]),a=yc(e[1]),l=yc(i[0]),u=yc(e[0]);return 2*Math.asin(t(r(a-s)+n(s)*n(a)*r(u-l)))}var rue=Math.sqrt(2*Math.PI);function sue(i,e){return Math.exp(-SO(i/e)/2)/(e*rue)}var aue=function(e){var t=Ar(e,2),n=t[0],r=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},l=a.lngAccessor,u=l===void 0?function(C){return C[0]}:l,h=a.latAccessor,m=h===void 0?function(C){return C[1]}:h,v=a.weightAccessor,x=v===void 0?function(){return 1}:v,S=a.bandwidth,T=[n,r],N=S*Math.PI/180;return JW(s.map(function(C){var E=x(C);if(!E)return 0;var O=iue(T,[u(C),m(C)]);return sue(O,N)*E}))},oue=(function(){var i=Ule(uT().m(function e(t){var n,r,s,a,l,u,h,m,v,x,S,T,N,C,E,O,U,I,j,z,G,H,q,V,Q,J,ne,oe,ie,Z,te,de,Se,Te,ae,Me,Ve,Ce,Fe,et,He=arguments,Rt,Et,zt;return uT().w(function(Pt){for(;;)switch(Pt.n){case 0:if(r=He.length>1&&He[1]!==void 0?He[1]:[],s=He.length>2&&He[2]!==void 0?He[2]:{},a=s.lngAccessor,l=a===void 0?function(We){return We[0]}:a,u=s.latAccessor,h=u===void 0?function(We){return We[1]}:u,m=s.weightAccessor,v=m===void 0?function(){return 1}:m,x=s.bandwidth,(n=navigator)!==null&&n!==void 0&&n.gpu){Pt.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),Pt.a(2,t.map(function(We){return aue(We,r,{lngAccessor:l,latAccessor:h,weightAccessor:v,bandwidth:x})}));case 1:return S=4,T=hle,N=fle,C=Sle,E=ble,O=gle,U=vle,I=dle,j=xle,z=yle,G=ple,H=Ale,q=mle,V=_le,Q=E(new Jv(new Float32Array(t.flat().map(yc)),2),"vec2",t.length),J=E(new Jv(new Float32Array(r.map(function(We){return[yc(l(We)),yc(h(We)),v(We)]}).flat()),3),"vec3",r.length),ne=new Jv(t.length,1),oe=E(ne,"float",t.length),ie=O(Math.PI),Z=j(ie.mul(2)),te=function(ft){return ft.mul(ft)},de=function(ft){return te(z(ft.div(2)))},Se=function(ft,fe){var Wt=O(ft[1]),yt=O(fe[1]),Gt=O(ft[0]),_t=O(fe[0]);return O(2).mul(H(j(de(yt.sub(Wt)).add(G(Wt).mul(G(yt)).mul(de(_t.sub(Gt)))))))},Te=function(ft,fe){return q(V(te(ft.div(fe)).div(2))).div(fe.mul(Z))},ae=C(yc(x)),Me=C(yc(x*S)),Ve=C(r.length),Ce=T(function(){var We=Q.element(U),ft=oe.element(U);ft.assign(0),I(Ve,function(fe){var Wt=fe.i,yt=J.element(Wt),Gt=yt.z;N(Gt,function(){var _t=Se(yt.xy,We.xy);N(_t&&_t.lessThan(Me),function(){ft.addAssign(Te(_t,ae).mul(Gt))})})})}),Fe=Ce().compute(t.length),et=new cO,Pt.n=2,et.computeAsync(Fe);case 2:return Rt=Array,Et=Float32Array,Pt.n=3,et.getArrayBufferAsync(ne);case 3:return zt=Pt.v,Pt.a(2,Rt.from.call(Rt,new Et(zt)))}},e)}));return function(t){return i.apply(this,arguments)}})(),Nv=window.THREE?window.THREE:{Mesh:Oi,MeshLambertMaterial:Fc,SphereGeometry:bu},lue=3.5,uue=.1,Z6=100,cue=function(e){var t=sd(VZ(e));return t.opacity=Math.cbrt(e),t.formatRgb()},wO=_s({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return cue}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var s=new Nv.Mesh(new Nv.SphereGeometry(ar),YE(new Nv.MeshLambertMaterial({vertexColors:!0,transparent:!0}),Jle));return s.__globeObjType="heatmap",s})},update:function(e){var t=Ut(e.heatmapPoints),n=Ut(e.heatmapPointLat),r=Ut(e.heatmapPointLng),s=Ut(e.heatmapPointWeight),a=Ut(e.heatmapBandwidth),l=Ut(e.heatmapColorFn),u=Ut(e.heatmapColorSaturation),h=Ut(e.heatmapBaseAltitude),m=Ut(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(v,x){var S=a(x),T=l(x),N=u(x),C=h(x),E=m(x),O=t(x).map(function(G){var H=n(G),q=r(G),V=Zo(H,q),Q=V.x,J=V.y,ne=V.z;return{x:Q,y:J,z:ne,lat:H,lng:q,weight:s(G)}}),U=Math.max(uue,S/lue),I=Math.ceil(360/(U||-1));v.geometry.parameters.widthSegments!==I&&(v.geometry.dispose(),v.geometry=new Nv.SphereGeometry(ar,I,I/2));var j=Zle(v.geometry.getAttribute("position")),z=j.map(function(G){var H=Ar(G,3),q=H[0],V=H[1],Q=H[2],J=gO({x:q,y:V,z:Q}),ne=J.lng,oe=J.lat;return[ne,oe]});oue(z,O,{latAccessor:function(H){return H.lat},lngAccessor:function(H){return H.lng},weightAccessor:function(H){return H.weight},bandwidth:S}).then(function(G){var H=ji(new Array(Z6)).map(function(J,ne){return Gh(T(ne/(Z6-1)))}),q=function(ne){var oe=v.__currentTargetD=ne,ie=oe.kdeVals,Z=oe.topAlt,te=oe.saturation,de=QW(ie.map(Math.abs))||1e-15,Se=UD([0,de/te],H);v.geometry.setAttribute("color",xu(ie.map(function(ae){return Se(Math.abs(ae))}),4));var Te=Ec([0,de],[ar*(1+C),ar*(1+(Z||C))]);v.geometry.setAttribute("r",xu(ie.map(Te)))},V={kdeVals:G,topAlt:E,saturation:N},Q=v.__currentTargetD||Object.assign({},V,{kdeVals:G.map(function(){return 0}),topAlt:E&&C,saturation:.5});Q.kdeVals.length!==G.length&&(Q.kdeVals=G.slice()),Object.keys(V).some(function(J){return Q[J]!==V[J]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?q(V):e.tweenGroup.add(new la(Q).to(V,e.heatmapsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(q).start()))})}).digest(e.heatmapsData)}}),bh=window.THREE?window.THREE:{DoubleSide:as,Group:qa,LineBasicMaterial:q0,LineSegments:Y7,Mesh:Oi,MeshBasicMaterial:cd},TO=_s({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjPolygon"}).id(function(s){return s.id}).onCreateObj(function(){var s=new bh.Group;return s.__defaultSideMaterial=YE(new bh.MeshBasicMaterial({side:bh.DoubleSide,depthWrite:!0}),hT),s.__defaultCapMaterial=new bh.MeshBasicMaterial({side:bh.DoubleSide,depthWrite:!0}),s.add(new bh.Mesh(void 0,[s.__defaultSideMaterial,s.__defaultCapMaterial])),s.add(new bh.LineSegments(void 0,new bh.LineBasicMaterial)),s.__globeObjType="polygon",s})},update:function(e){var t=Ut(e.polygonGeoJsonGeometry),n=Ut(e.polygonAltitude),r=Ut(e.polygonCapCurvatureResolution),s=Ut(e.polygonCapColor),a=Ut(e.polygonCapMaterial),l=Ut(e.polygonSideColor),u=Ut(e.polygonSideMaterial),h=Ut(e.polygonStrokeColor),m=[];e.polygonsData.forEach(function(v){var x={data:v,capColor:s(v),capMaterial:a(v),sideColor:l(v),sideMaterial:u(v),strokeColor:h(v),altitude:+n(v),capCurvatureResolution:+r(v)},S=t(v),T=v.__id||"".concat(Math.round(Math.random()*1e9));v.__id=T,S.type==="Polygon"?m.push(ki({id:"".concat(T,"_0"),coords:S.coordinates},x)):S.type==="MultiPolygon"?m.push.apply(m,ji(S.coordinates.map(function(N,C){return ki({id:"".concat(T,"_").concat(C),coords:N},x)}))):console.warn("Unsupported GeoJson geometry type: ".concat(S.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(v,x){var S=x.coords,T=x.capColor,N=x.capMaterial,C=x.sideColor,E=x.sideMaterial,O=x.strokeColor,U=x.altitude,I=x.capCurvatureResolution,j=Ar(v.children,2),z=j[0],G=j[1],H=!!O;G.visible=H;var q=!!(T||N),V=!!(C||E);hue(z.geometry.parameters||{},{polygonGeoJson:S,curvatureResolution:I,closedTop:q,includeSides:V})||(z.geometry&&z.geometry.dispose(),z.geometry=new CM(S,0,ar,!1,q,V,I)),H&&(!G.geometry.parameters||G.geometry.parameters.geoJson.coordinates!==S||G.geometry.parameters.resolution!==I)&&(G.geometry&&G.geometry.dispose(),G.geometry=new AP({type:"Polygon",coordinates:S},ar,I));var Q=V?0:-1,J=q?V?1:0:-1;if(Q>=0&&(z.material[Q]=E||v.__defaultSideMaterial),J>=0&&(z.material[J]=N||v.__defaultCapMaterial),[[!E&&C,Q],[!N&&T,J]].forEach(function(de){var Se=Ar(de,2),Te=Se[0],ae=Se[1];if(!(!Te||ae<0)){var Me=z.material[ae],Ve=Ml(Te);Me.color.set(yu(Te)),Me.transparent=Ve<1,Me.opacity=Ve}}),H){var ne=G.material,oe=Ml(O);ne.color.set(yu(O)),ne.transparent=oe<1,ne.opacity=oe}var ie={alt:U},Z=function(Se){var Te=v.__currentTargetD=Se,ae=Te.alt;z.scale.x=z.scale.y=z.scale.z=1+ae,H&&(G.scale.x=G.scale.y=G.scale.z=1+ae+1e-4),eue(v.__defaultSideMaterial,function(Me){return Me.uSurfaceRadius.value=ar/(ae+1)})},te=v.__currentTargetD||Object.assign({},ie,{alt:-.001});Object.keys(ie).some(function(de){return te[de]!==ie[de]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||te.alt===ie.alt?Z(ie):e.tweenGroup.add(new la(te).to(ie,e.polygonsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(Z).start()))}).digest(m)}});function hue(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(n,r){return n===r}};return Object.entries(e).every(function(n){var r=Ar(n,2),s=r[0],a=r[1];return i.hasOwnProperty(s)&&t(s)(i[s],a)})}var RA=window.THREE?window.THREE:{BufferGeometry:Hi,DoubleSide:as,Mesh:Oi,MeshLambertMaterial:Fc,Vector3:me},J6=Object.assign({},SM),e7=J6.BufferGeometryUtils||J6,MO=_s({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var s=new RA.Mesh(void 0,new RA.MeshLambertMaterial({side:RA.DoubleSide}));return s.__globeObjType="hexPolygon",s})},update:function(e){var t=Ut(e.hexPolygonGeoJsonGeometry),n=Ut(e.hexPolygonColor),r=Ut(e.hexPolygonAltitude),s=Ut(e.hexPolygonResolution),a=Ut(e.hexPolygonMargin),l=Ut(e.hexPolygonUseDots),u=Ut(e.hexPolygonCurvatureResolution),h=Ut(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(m,v){var x=t(v),S=s(v),T=r(v),N=Math.max(0,Math.min(1,+a(v))),C=l(v),E=u(v),O=h(v),U=n(v),I=Ml(U);m.material.color.set(yu(U)),m.material.transparent=I<1,m.material.opacity=I;var j={alt:T,margin:N,curvatureResolution:E},z={geoJson:x,h3Res:S},G=m.__currentTargetD||Object.assign({},j,{alt:-.001}),H=m.__currentMemD||z;if(Object.keys(j).some(function(J){return G[J]!==j[J]})||Object.keys(z).some(function(J){return H[J]!==z[J]})){m.__currentMemD=z;var q=[];x.type==="Polygon"?PR(x.coordinates,S,!0).forEach(function(J){return q.push(J)}):x.type==="MultiPolygon"?x.coordinates.forEach(function(J){return PR(J,S,!0).forEach(function(ne){return q.push(ne)})}):console.warn("Unsupported GeoJson geometry type: ".concat(x.type,". Skipping geometry..."));var V=q.map(function(J){var ne=LP(J),oe=UP(J,!0).reverse(),ie=ne[1];return oe.forEach(function(Z){var te=Z[0];Math.abs(ie-te)>170&&(Z[0]+=ie>te?360:-360)}),{h3Idx:J,hexCenter:ne,hexGeoJson:oe}}),Q=function(ne){var oe=m.__currentTargetD=ne,ie=oe.alt,Z=oe.margin,te=oe.curvatureResolution;m.geometry&&m.geometry.dispose(),m.geometry=V.length?(e7.mergeGeometries||e7.mergeBufferGeometries)(V.map(function(de){var Se=Ar(de.hexCenter,2),Te=Se[0],ae=Se[1];if(C){var Me=Zo(Te,ae,ie),Ve=Zo(de.hexGeoJson[0][1],de.hexGeoJson[0][0],ie),Ce=.85*(1-Z)*new RA.Vector3(Me.x,Me.y,Me.z).distanceTo(new RA.Vector3(Ve.x,Ve.y,Ve.z)),Fe=new yy(Ce,O);return Fe.rotateX(Ff(-Te)),Fe.rotateY(Ff(ae)),Fe.translate(Me.x,Me.y,Me.z),Fe}else{var et=function(Et,zt,Pt){return Et-(Et-zt)*Pt},He=Z===0?de.hexGeoJson:de.hexGeoJson.map(function(Rt){var Et=Ar(Rt,2),zt=Et[0],Pt=Et[1];return[[zt,ae],[Pt,Te]].map(function(We){var ft=Ar(We,2),fe=ft[0],Wt=ft[1];return et(fe,Wt,Z)})});return new CM([He],ar,ar*(1+ie),!1,!0,!1,te)}})):new RA.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?Q(j):e.tweenGroup.add(new la(G).to(j,e.hexPolygonsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(Q).start())}}).digest(e.hexPolygonsData)}}),fue=window.THREE?window.THREE:{Vector3:me};function due(i,e){var t=function(a,l){var u=a[a.length-1];return[].concat(ji(a),ji(Array(l-a.length).fill(u)))},n=Math.max(i.length,e.length),r=p$.apply(void 0,ji([i,e].map(function(s){return s.map(function(a){var l=a.x,u=a.y,h=a.z;return[l,u,h]})}).map(function(s){return t(s,n)})));return function(s){return s===0?i:s===1?e:r(s).map(function(a){var l=Ar(a,3),u=l[0],h=l[1],m=l[2];return new fue.Vector3(u,h,m)})}}var Ef=window.THREE?window.THREE:{BufferGeometry:Hi,Color:cn,Group:qa,Line:_y,NormalBlending:Xa,ShaderMaterial:Qa,Vector3:me},Aue=C0.default||C0,EO=_s({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new Aue,sharedMaterial:new Ef.ShaderMaterial(ki(ki({},yO()),{},{transparent:!0,blending:Ef.NormalBlending}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var n=new Ef.Group;return n.__globeObjType="path",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Ar(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r;if(a.type==="Line"){var u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l}else if(a.type==="Line2"){for(var h=a.material.dashOffset-l,m=a.material.dashSize+a.material.gapSize;h<=-m;)h+=m;a.material.dashOffset=h}})})},update:function(e){var t=Ut(e.pathPoints),n=Ut(e.pathPointLat),r=Ut(e.pathPointLng),s=Ut(e.pathPointAlt),a=Ut(e.pathStroke),l=Ut(e.pathColor),u=Ut(e.pathDashLength),h=Ut(e.pathDashGap),m=Ut(e.pathDashInitialGap),v=Ut(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(C,E){var O=a(E),U=O!=null;if(!C.children.length||U===(C.children[0].type==="Line")){Ki(C);var I=U?new Ele(new fO,new HE):new Ef.Line(new Ef.BufferGeometry,e.sharedMaterial.clone());C.add(I)}var j=C.children[0],z=S(t(E),n,r,s,e.pathResolution),G=v(E);if(j.__dashAnimateStep=G>0?1e3/G:0,U){j.material.resolution=e.rendererSize;{var V=u(E),Q=h(E),J=m(E);j.material.dashed=Q>0,j.material.dashed?j.material.defines.USE_DASH="":delete j.material.defines.USE_DASH,j.material.dashed&&(j.material.dashScale=1/x(z),j.material.dashSize=V,j.material.gapSize=Q,j.material.dashOffset=-J)}{var ne=l(E);if(ne instanceof Array){var oe=T(l(E),z.length-1,1,!1);j.geometry.setColors(oe.array),j.material.vertexColors=!0}else{var ie=ne,Z=Ml(ie);j.material.color=new Ef.Color(yu(ie)),j.material.transparent=Z<1,j.material.opacity=Z,j.material.vertexColors=!1}}j.material.needsUpdate=!0}else{Object.assign(j.material.uniforms,{dashSize:{value:u(E)},gapSize:{value:h(E)},dashOffset:{value:m(E)}});var H=T(l(E),z.length),q=N(z.length,1,!0);j.geometry.setAttribute("color",H),j.geometry.setAttribute("relDistance",q)}var te=due(C.__currentTargetD&&C.__currentTargetD.points||[z[0]],z),de=function(Me){var Ve=C.__currentTargetD=Me,Ce=Ve.stroke,Fe=Ve.interpolK,et=C.__currentTargetD.points=te(Fe);if(U){var He;j.geometry.setPositions((He=[]).concat.apply(He,ji(et.map(function(Rt){var Et=Rt.x,zt=Rt.y,Pt=Rt.z;return[Et,zt,Pt]})))),j.material.linewidth=Ce,j.material.dashed&&j.computeLineDistances()}else j.geometry.setFromPoints(et),j.geometry.computeBoundingSphere()},Se={stroke:O,interpolK:1},Te=Object.assign({},C.__currentTargetD||Se,{interpolK:0});Object.keys(Se).some(function(ae){return Te[ae]!==Se[ae]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?de(Se):e.tweenGroup.add(new la(Te).to(Se,e.pathTransitionDuration).easing(os.Quadratic.InOut).onUpdate(de).start()))}).digest(e.pathsData);function x(C){var E=0,O;return C.forEach(function(U){O&&(E+=O.distanceTo(U)),O=U}),E}function S(C,E,O,U,I){var j=function(q,V,Q){for(var J=[],ne=1;ne<=Q;ne++)J.push(q+(V-q)*ne/(Q+1));return J},z=function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Q=[],J=null;return q.forEach(function(ne){if(J){for(;Math.abs(J[1]-ne[1])>180;)J[1]+=360*(J[1]V)for(var ie=Math.floor(oe/V),Z=j(J[0],ne[0],ie),te=j(J[1],ne[1],ie),de=j(J[2],ne[2],ie),Se=0,Te=Z.length;Se2&&arguments[2]!==void 0?arguments[2]:1,U=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,I=E+1,j;if(C instanceof Array||C instanceof Function){var z=C instanceof Array?Ec().domain(C.map(function(ne,oe){return oe/(C.length-1)})).range(C):C;j=function(oe){return Gh(z(oe),U,!0)}}else{var G=Gh(C,U,!0);j=function(){return G}}for(var H=[],q=0,V=I;q1&&arguments[1]!==void 0?arguments[1]:1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,U=C+1,I=[],j=0,z=U;j0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;ex(this,e),t=Jy(this,e),t.type="CircleLineGeometry",t.parameters={radius:n,segmentCount:r};for(var s=[],a=0;a<=r;a++){var l=(a/r-.25)*Math.PI*2;s.push({x:Math.cos(l)*n,y:Math.sin(l)*n,z:0})}return t.setFromPoints(s),t}return nx(e,i),tx(e)})(pue.BufferGeometry),PA=window.THREE?window.THREE:{Color:cn,Group:qa,Line:_y,LineBasicMaterial:q0,Vector3:me},gue=C0.default||C0,RO=_s({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var s=new PA.Group;return s.__globeObjType="ring",s}),t.ticker=new gue,t.ticker.onTick.add(function(s){if(t.ringsData.length){var a=Ut(t.ringColor),l=Ut(t.ringAltitude),u=Ut(t.ringMaxRadius),h=Ut(t.ringPropagationSpeed),m=Ut(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(v){var x=Ar(v,2),S=x[1];return S}).forEach(function(v){var x=Ar(v,2),S=x[0],T=x[1];if((T.__nextRingTime||0)<=s){var N=m(S)/1e3;T.__nextRingTime=s+(N<=0?1/0:N);var C=new PA.Line(new mue(1,t.ringResolution),new PA.LineBasicMaterial),E=a(S),O=E instanceof Array||E instanceof Function,U;O?E instanceof Array?(U=Ec().domain(E.map(function(Q,J){return J/(E.length-1)})).range(E),C.material.transparent=E.some(function(Q){return Ml(Q)<1})):(U=E,C.material.transparent=!0):(C.material.color=new PA.Color(yu(E)),Kle(C.material,Ml(E)));var I=ar*(1+l(S)),j=u(S),z=j*Math.PI/180,G=h(S),H=G<=0,q=function(J){var ne=J.t,oe=(H?1-ne:ne)*z;if(C.scale.x=C.scale.y=I*Math.sin(oe),C.position.z=I*(1-Math.cos(oe)),O){var ie=U(ne);C.material.color=new PA.Color(yu(ie)),C.material.transparent&&(C.material.opacity=Ml(ie))}};if(G===0)q({t:0}),T.add(C);else{var V=Math.abs(j/G)*1e3;t.tweenGroup.add(new la({t:0}).to({t:1},V).onUpdate(q).onStart(function(){return T.add(C)}).onComplete(function(){T.remove(C),XE(C)}).start())}}})}})},update:function(e){var t=Ut(e.ringLat),n=Ut(e.ringLng),r=Ut(e.ringAltitude),s=e.scene.localToWorld(new PA.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(a,l){var u=t(l),h=n(l),m=r(l);Object.assign(a.position,Zo(u,h,m)),a.lookAt(s)}).digest(e.ringsData)}}),vue={0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},_ue="normal",yue=1189,xue=-100,bue="normal",Sue={yMin:-334,xMin:-111,yMax:1189,xMax:1672},wue=1e3,Tue={postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r +\r +Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r +\r +The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r +\r +The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r +\r +This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r +\r +The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r +\r +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},Mue=-334,Eue="Helvetiker",Cue=1522,Nue=50,Rue={glyphs:vue,cssFontWeight:_ue,ascender:yue,underlinePosition:xue,cssFontStyle:bue,boundingBox:Sue,resolution:wue,original_font_information:Tue,descender:Mue,familyName:Eue,lineHeight:Cue,underlineThickness:Nue},vl=ki(ki({},window.THREE?window.THREE:{BoxGeometry:Vh,CircleGeometry:yy,DoubleSide:as,Group:qa,Mesh:Oi,MeshLambertMaterial:Fc,TextGeometry:V6,Vector3:me}),{},{Font:Cle,TextGeometry:V6}),DO=_s({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:Rue,onChange:function(e,t){t.font=new vl.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r;var s=new vl.CircleGeometry(1,32);t.dataMapper=new io(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var a=new vl.MeshLambertMaterial;a.side=as;var l=new vl.Group;l.add(new vl.Mesh(s,a));var u=new vl.Mesh(void 0,a);l.add(u);var h=new vl.Mesh;return h.visible=!1,u.add(h),l.__globeObjType="label",l})},update:function(e){var t=Ut(e.labelLat),n=Ut(e.labelLng),r=Ut(e.labelAltitude),s=Ut(e.labelText),a=Ut(e.labelSize),l=Ut(e.labelRotation),u=Ut(e.labelColor),h=Ut(e.labelIncludeDot),m=Ut(e.labelDotRadius),v=Ut(e.labelDotOrientation),x=new Set(["right","top","bottom"]),S=2*Math.PI*ar/360;e.dataMapper.onUpdateObj(function(T,N){var C=Ar(T.children,2),E=C[0],O=C[1],U=Ar(O.children,1),I=U[0],j=u(N),z=Ml(j);O.material.color.set(yu(j)),O.material.transparent=z<1,O.material.opacity=z;var G=h(N),H=v(N);!G||!x.has(H)&&(H="bottom");var q=G?+m(N)*S:1e-12;E.scale.x=E.scale.y=q;var V=+a(N)*S;if(O.geometry&&O.geometry.dispose(),O.geometry=new vl.TextGeometry(s(N),{font:e.font,size:V,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),I.geometry&&I.geometry.dispose(),O.geometry.computeBoundingBox(),I.geometry=WE(vl.BoxGeometry,ji(new vl.Vector3().subVectors(O.geometry.boundingBox.max,O.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),H!=="right"&&O.geometry.center(),G){var Q=q+V/2;H==="right"&&(O.position.x=Q),O.position.y={right:-V/2,top:Q+V/2,bottom:-Q-V/2}[H]}var J=function(Z){var te=T.__currentTargetD=Z,de=te.lat,Se=te.lng,Te=te.alt,ae=te.rot,Me=te.scale;Object.assign(T.position,Zo(de,Se,Te)),T.lookAt(e.scene.localToWorld(new vl.Vector3(0,0,0))),T.rotateY(Math.PI),T.rotateZ(-ae*Math.PI/180),T.scale.x=T.scale.y=T.scale.z=Me},ne={lat:+t(N),lng:+n(N),alt:+r(N),rot:+l(N),scale:1},oe=T.__currentTargetD||Object.assign({},ne,{scale:1e-12});Object.keys(ne).some(function(ie){return oe[ie]!==ne[ie]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?J(ne):e.tweenGroup.add(new la(oe).to(ne,e.labelsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start()))}).digest(e.labelsData)}}),Due=ki(ki({},window.THREE?window.THREE:{}),{},{CSS2DObject:kH}),PO=_s({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){if(e.dataMapper){var n=t?[t]:e.dataMapper.entries().map(function(r){var s=Ar(r,2),a=s[1];return a}).filter(function(r){return r});n.forEach(function(r){var s=!e.isBehindGlobe||!e.isBehindGlobe(r.position);e.htmlElementVisibilityModifier?(r.visible=!0,e.htmlElementVisibilityModifier(r.element,s)):r.visible=s})}}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(s){var a=Ut(t.htmlElement)(s),l=new Due.CSS2DObject(a);return l.__globeObjType="html",l})},update:function(e,t){var n=this,r=Ut(e.htmlLat),s=Ut(e.htmlLng),a=Ut(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(l,u){var h=function(x){var S=l.__currentTargetD=x,T=S.alt,N=S.lat,C=S.lng;Object.assign(l.position,Zo(N,C,T)),n.updateObjVisibility(l)},m={lat:+r(u),lng:+s(u),alt:+a(u)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!l.__currentTargetD?h(m):e.tweenGroup.add(new la(l.__currentTargetD).to(m,e.htmlTransitionDuration).easing(os.Quadratic.InOut).onUpdate(h).start())}).digest(e.htmlElementsData)}}),Dv=window.THREE?window.THREE:{Group:qa,Mesh:Oi,MeshLambertMaterial:Fc,SphereGeometry:bu},LO=_s({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new Dv.Mesh(new Dv.SphereGeometry(1,16,8),new Dv.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(n){var r=Ut(t.objectThreeObject)(n);t.objectThreeObject===r&&(r=r.clone());var s=new Dv.Group;return s.add(r),s.__globeObjType="object",s})},update:function(e,t){var n=Ut(e.objectLat),r=Ut(e.objectLng),s=Ut(e.objectAltitude),a=Ut(e.objectFacesSurface),l=Ut(e.objectRotation);t.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(u,h){var m=+n(h),v=+r(h),x=+s(h);Object.assign(u.position,Zo(m,v,x)),a(h)?u.setRotationFromEuler(new aa(Ff(-m),Ff(v),0,"YXZ")):u.rotation.set(0,0,0);var S=u.children[0],T=l(h);T&&S.setRotationFromEuler(new aa(Ff(T.x||0),Ff(T.y||0),Ff(T.z||0)))}).digest(e.objectsData)}}),UO=_s({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(n){var r=Ut(t.customThreeObject)(n,ar);return r&&(t.customThreeObject===r&&(r=r.clone()),r.__globeObjType="custom"),r})},update:function(e,t){e.customThreeObjectUpdate||Ki(e.scene);var n=Ut(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(r,s){return n(r,s,ar)}).digest(e.customLayerData)}}),Pv=window.THREE?window.THREE:{Camera:gy,Group:qa,Vector2:bt,Vector3:me},Pue=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],BO=Sa("globeLayer",vO),Lue=Object.assign.apply(Object,ji(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(i){return Ds({},i,BO.linkProp(i))}))),Uue=Object.assign.apply(Object,ji(["globeMaterial","globeTileEngineClearCache"].map(function(i){return Ds({},i,BO.linkMethod(i))}))),Bue=Sa("pointsLayer",_O),Oue=Object.assign.apply(Object,ji(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(i){return Ds({},i,Bue.linkProp(i))}))),Iue=Sa("arcsLayer",xO),Fue=Object.assign.apply(Object,ji(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(i){return Ds({},i,Iue.linkProp(i))}))),kue=Sa("hexBinLayer",bO),zue=Object.assign.apply(Object,ji(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(i){return Ds({},i,kue.linkProp(i))}))),Gue=Sa("heatmapsLayer",wO),que=Object.assign.apply(Object,ji(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(i){return Ds({},i,Gue.linkProp(i))}))),Vue=Sa("hexedPolygonsLayer",MO),jue=Object.assign.apply(Object,ji(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(i){return Ds({},i,Vue.linkProp(i))}))),Hue=Sa("polygonsLayer",TO),Wue=Object.assign.apply(Object,ji(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(i){return Ds({},i,Hue.linkProp(i))}))),$ue=Sa("pathsLayer",EO),Xue=Object.assign.apply(Object,ji(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(i){return Ds({},i,$ue.linkProp(i))}))),Yue=Sa("tilesLayer",CO),Que=Object.assign.apply(Object,ji(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(i){return Ds({},i,Yue.linkProp(i))}))),Kue=Sa("particlesLayer",NO),Zue=Object.assign.apply(Object,ji(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(i){return Ds({},i,Kue.linkProp(i))}))),Jue=Sa("ringsLayer",RO),ece=Object.assign.apply(Object,ji(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(i){return Ds({},i,Jue.linkProp(i))}))),tce=Sa("labelsLayer",DO),nce=Object.assign.apply(Object,ji(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(i){return Ds({},i,tce.linkProp(i))}))),ice=Sa("htmlElementsLayer",PO),rce=Object.assign.apply(Object,ji(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(i){return Ds({},i,ice.linkProp(i))}))),sce=Sa("objectsLayer",LO),ace=Object.assign.apply(Object,ji(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(i){return Ds({},i,sce.linkProp(i))}))),oce=Sa("customLayer",UO),lce=Object.assign.apply(Object,ji(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(i){return Ds({},i,oce.linkProp(i))}))),uce=_s({props:ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new Pv.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},Lue),Oue),Fue),zue),que),Wue),jue),Xue),Que),Zue),ece),nce),rce),ace),lce),methods:ki({getGlobeRadius:W6,getCoords:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=(function(r){function s(){var a;ex(this,s);for(var l=arguments.length,u=new Array(l),h=0;ht7&&(this.dispatchEvent(BS),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>t7||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(BS),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Li.NONE,this.keyState=Li.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(BS),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Sh.copy(this._panEnd).sub(this._panStart),Sh.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Sh.x*=e,Sh.y*=t}Sh.multiplyScalar(this._eye.length()*this.panSpeed),Uv.copy(this._eye).cross(this.object.up).setLength(Sh.x),Uv.add(fce.copy(this.object.up).setLength(Sh.y)),this.object.position.add(Uv),this.target.add(Uv),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Sh.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Ov.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Ov.length();e?(this._eye.copy(this.object.position).sub(this.target),n7.copy(this._eye).normalize(),Bv.copy(this.object.up).normalize(),IS.crossVectors(Bv,n7).normalize(),Bv.setLength(this._moveCurr.y-this._movePrev.y),IS.setLength(this._moveCurr.x-this._movePrev.x),Ov.copy(Bv.add(IS)),OS.crossVectors(Ov,this._eye).normalize(),e*=this.rotateSpeed,LA.setFromAxisAngle(OS,e),this._eye.applyQuaternion(LA),this.object.up.applyQuaternion(LA),this._lastAxis.copy(OS),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),LA.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(LA),this.object.up.applyQuaternion(LA)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Li.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=x0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=x0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Lv.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Lv}_getMouseOnCircle(e,t){return Lv.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Lv}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=Ba),r<-Math.PI?r+=Ba:r>Math.PI&&(r-=Ba),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(ds.setFromSpherical(this._spherical),ds.applyQuaternion(this._quatInverse),t.copy(this.target).add(ds),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=ds.length();a=this._clampDistance(l*this._scale);const u=l-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),s=!!u}else if(this.object.isOrthographicCamera){const l=new me(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=u!==this.object.zoom;const h=new me(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(l),this.object.updateMatrixWorld(),a=ds.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Iv.origin.copy(this.object.position),Iv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Iv.direction))FS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>FS||this._lastTargetPosition.distanceToSquared(this.target)>FS?(this.dispatchEvent(i7),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ba/60*this.autoRotateSpeed*e:Ba/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ds.setFromMatrixColumn(t,0),ds.multiplyScalar(-e),this._panOffset.add(ds)}_panUp(e,t){this.screenSpacePanning===!0?ds.setFromMatrixColumn(t,1):(ds.setFromMatrixColumn(t,0),ds.crossVectors(this.object.up,ds)),ds.multiplyScalar(e),this._panOffset.add(ds)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;ds.copy(r).sub(this.target);let s=ds.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,l=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ba*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ba*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ba*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ba*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;ts7||8*(1-this._lastQuaternion.dot(t.quaternion))>s7)&&(this.dispatchEvent(qce),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function jce(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function Hce(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function Wce(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function $ce(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function Xce(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function Yce(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Qce(i){this.enabled!==!1&&i.preventDefault()}const Kce={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + uniform float opacity; + + uniform sampler2D tDiffuse; + + varying vec2 vUv; + + void main() { + + vec4 texel = texture2D( tDiffuse, vUv ); + gl_FragColor = opacity * texel; + + + }`};class ix{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Zce=new Ig(-1,1,1,-1,0,1);class Jce extends Hi{constructor(){super(),this.setAttribute("position",new Si([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Si([0,2,0,0,2,0],2))}}const ehe=new Jce;class the{constructor(e){this._mesh=new Oi(ehe,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Zce)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class nhe extends ix{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof Qa?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=my.clone(e.uniforms),this.material=new Qa({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new the(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class o7 extends ix{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,l;this.inverse?(a=0,l=1):(a=1,l=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),s.buffers.stencil.setClear(l),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class ihe extends ix{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class rhe{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new bt);this._width=n.width,this._height=n.height,t=new Fh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Gs}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new nhe(Kce),this.copyPass.material.blending=$a,this.clock=new hD}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&r<1?(l=s,u=a):r>=1&&r<2?(l=a,u=s):r>=2&&r<3?(u=s,h=a):r>=3&&r<4?(u=a,h=s):r>=4&&r<5?(l=a,h=s):r>=5&&r<6&&(l=s,h=a);var m=t-s/2,v=l+m,x=u+m,S=h+m;return n(v,x,S)}var l7={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function hhe(i){if(typeof i!="string")return i;var e=i.toLowerCase();return l7[e]?"#"+l7[e]:i}var fhe=/^#[a-fA-F0-9]{6}$/,dhe=/^#[a-fA-F0-9]{8}$/,Ahe=/^#[a-fA-F0-9]{3}$/,phe=/^#[a-fA-F0-9]{4}$/,zS=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,mhe=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,ghe=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,vhe=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function O0(i){if(typeof i!="string")throw new Jl(3);var e=hhe(i);if(e.match(fhe))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(dhe)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(Ahe))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(phe)){var n=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:n}}var r=zS.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var s=mhe.exec(e.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var a=ghe.exec(e);if(a){var l=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,h=parseInt(""+a[3],10)/100,m="rgb("+sy(l,u,h)+")",v=zS.exec(m);if(!v)throw new Jl(4,e,m);return{red:parseInt(""+v[1],10),green:parseInt(""+v[2],10),blue:parseInt(""+v[3],10)}}var x=vhe.exec(e.substring(0,50));if(x){var S=parseInt(""+x[1],10),T=parseInt(""+x[2],10)/100,N=parseInt(""+x[3],10)/100,C="rgb("+sy(S,T,N)+")",E=zS.exec(C);if(!E)throw new Jl(4,e,C);return{red:parseInt(""+E[1],10),green:parseInt(""+E[2],10),blue:parseInt(""+E[3],10),alpha:parseFloat(""+x[4])>1?parseFloat(""+x[4])/100:parseFloat(""+x[4])}}throw new Jl(5)}function _he(i){var e=i.red/255,t=i.green/255,n=i.blue/255,r=Math.max(e,t,n),s=Math.min(e,t,n),a=(r+s)/2;if(r===s)return i.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:i.alpha}:{hue:0,saturation:0,lightness:a};var l,u=r-s,h=a>.5?u/(2-r-s):u/(r+s);switch(r){case e:l=(t-n)/u+(t=1?kO(i.hue,i.saturation,i.lightness):"rgba("+sy(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new Jl(2)}function zO(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return AT("#"+Lf(i)+Lf(e)+Lf(t));if(typeof i=="object"&&e===void 0&&t===void 0)return AT("#"+Lf(i.red)+Lf(i.green)+Lf(i.blue));throw new Jl(6)}function rx(i,e,t,n){if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?zO(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")";throw new Jl(7)}var whe=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},The=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},Mhe=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Ehe=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function $h(i){if(typeof i!="object")throw new Jl(8);if(The(i))return rx(i);if(whe(i))return zO(i);if(Ehe(i))return She(i);if(Mhe(i))return bhe(i);throw new Jl(8)}function GO(i,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?i.apply(this,r):GO(i,e,r)}}function Co(i){return GO(i,i.length,[])}function Che(i,e){if(e==="transparent")return e;var t=Wh(e);return $h(eo({},t,{hue:t.hue+parseFloat(i)}))}Co(Che);function X0(i,e,t){return Math.max(i,Math.min(e,t))}function Nhe(i,e){if(e==="transparent")return e;var t=Wh(e);return $h(eo({},t,{lightness:X0(0,1,t.lightness-parseFloat(i))}))}Co(Nhe);function Rhe(i,e){if(e==="transparent")return e;var t=Wh(e);return $h(eo({},t,{saturation:X0(0,1,t.saturation-parseFloat(i))}))}Co(Rhe);function Dhe(i,e){if(e==="transparent")return e;var t=Wh(e);return $h(eo({},t,{lightness:X0(0,1,t.lightness+parseFloat(i))}))}Co(Dhe);function Phe(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=O0(e),r=eo({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),s=O0(t),a=eo({},s,{alpha:typeof s.alpha=="number"?s.alpha:1}),l=r.alpha-a.alpha,u=parseFloat(i)*2-1,h=u*l===-1?u:u+l,m=1+u*l,v=(h/m+1)/2,x=1-v,S={red:Math.floor(r.red*v+a.red*x),green:Math.floor(r.green*v+a.green*x),blue:Math.floor(r.blue*v+a.blue*x),alpha:r.alpha*parseFloat(i)+a.alpha*(1-parseFloat(i))};return rx(S)}var Lhe=Co(Phe),qO=Lhe;function Uhe(i,e){if(e==="transparent")return e;var t=O0(e),n=typeof t.alpha=="number"?t.alpha:1,r=eo({},t,{alpha:X0(0,1,(n*100+parseFloat(i)*100)/100)});return rx(r)}var Bhe=Co(Uhe),Ohe=Bhe;function Ihe(i,e){if(e==="transparent")return e;var t=Wh(e);return $h(eo({},t,{saturation:X0(0,1,t.saturation+parseFloat(i))}))}Co(Ihe);function Fhe(i,e){return e==="transparent"?e:$h(eo({},Wh(e),{hue:parseFloat(i)}))}Co(Fhe);function khe(i,e){return e==="transparent"?e:$h(eo({},Wh(e),{lightness:parseFloat(i)}))}Co(khe);function zhe(i,e){return e==="transparent"?e:$h(eo({},Wh(e),{saturation:parseFloat(i)}))}Co(zhe);function Ghe(i,e){return e==="transparent"?e:qO(parseFloat(i),"rgb(0, 0, 0)",e)}Co(Ghe);function qhe(i,e){return e==="transparent"?e:qO(parseFloat(i),"rgb(255, 255, 255)",e)}Co(qhe);function Vhe(i,e){if(e==="transparent")return e;var t=O0(e),n=typeof t.alpha=="number"?t.alpha:1,r=eo({},t,{alpha:X0(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return rx(r)}Co(Vhe);var pT="http://www.w3.org/1999/xhtml";const u7={svg:"http://www.w3.org/2000/svg",xhtml:pT,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function VO(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),u7.hasOwnProperty(e)?{space:u7[e],local:i}:i}function jhe(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===pT&&e.documentElement.namespaceURI===pT?e.createElement(i):e.createElementNS(t,i)}}function Hhe(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function jO(i){var e=VO(i);return(e.local?Hhe:jhe)(e)}function Whe(){}function HO(i){return i==null?Whe:function(){return this.querySelector(i)}}function $he(i){typeof i!="function"&&(i=HO(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r=U&&(U=O+1);!(j=C[U])&&++U=0;)(a=n[r])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function yfe(i){i||(i=xfe);function e(v,x){return v&&x?i(v.__data__,x.__data__):!v-!x}for(var t=this._groups,n=t.length,r=new Array(n),s=0;se?1:i>=e?0:NaN}function bfe(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function Sfe(){return Array.from(this)}function wfe(){for(var i=this._groups,e=0,t=i.length;e1?this.each((e==null?Bfe:typeof e=="function"?Ife:Ofe)(i,e,t??"")):kfe(this.node(),i)}function kfe(i,e){return i.style.getPropertyValue(e)||XO(i).getComputedStyle(i,null).getPropertyValue(e)}function zfe(i){return function(){delete this[i]}}function Gfe(i,e){return function(){this[i]=e}}function qfe(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function Vfe(i,e){return arguments.length>1?this.each((e==null?zfe:typeof e=="function"?qfe:Gfe)(i,e)):this.node()[i]}function YO(i){return i.trim().split(/^|\s+/)}function JE(i){return i.classList||new QO(i)}function QO(i){this._node=i,this._names=YO(i.getAttribute("class")||"")}QO.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function KO(i,e){for(var t=JE(i),n=-1,r=e.length;++n=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function gde(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,r=e.length,s;t2&&(a.children=arguments.length>3?t1.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(s in i.defaultProps)a[s]===void 0&&(a[s]=i.defaultProps[s]);return km(i,a,n,r,null)}function km(i,e,t,n,r){var s={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++eI,__i:-1,__u:0};return r==null&&Sr.vnode!=null&&Sr.vnode(s),s}function ax(i){return i.children}function n_(i,e){this.props=i,this.context=e}function I0(i,e){if(e==null)return i.__?I0(i.__,i.__i+1):null;for(var t;ee&&kf.sort(iI),i=kf.shift(),e=kf.length,Dde(i);uy.__r=0}function aI(i,e,t,n,r,s,a,l,u,h,m){var v,x,S,T,N,C,E,O=n&&n.__k||ly,U=e.length;for(u=Pde(t,e,O,u,U),v=0;v0?a=i.__k[s]=km(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):i.__k[s]=a,u=s+x,a.__=i,a.__b=i.__b+1,l=null,(h=a.__i=Lde(a,t,u,v))!=-1&&(v--,(l=t[h])&&(l.__u|=2)),l==null||l.__v==null?(h==-1&&(r>m?x--:ru?x--:x++,a.__u|=4))):i.__k[s]=null;if(v)for(s=0;s(m?1:0)){for(r=t-1,s=t+1;r>=0||s=0?r--:s++])!=null&&(2&h.__u)==0&&l==h.key&&u==h.type)return a}return-1}function f7(i,e,t){e[0]=="-"?i.setProperty(e,t??""):i[e]=t==null?"":typeof t!="number"||Nde.test(e)?t:t+"px"}function Fv(i,e,t,n,r){var s,a;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||f7(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||f7(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(rI,"$1")),a=e.toLowerCase(),e=a in i||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+s]=t,t?n?t.u=n.u:(t.u=e4,i.addEventListener(e,s?gT:mT,s)):i.removeEventListener(e,s?gT:mT,s);else{if(r=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function d7(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=e4++;else if(e.t0?i:sx(i)?i.map(uI):eu({},i)}function Ude(i,e,t,n,r,s,a,l,u){var h,m,v,x,S,T,N,C=t.props||oy,E=e.props,O=e.type;if(O=="svg"?r="http://www.w3.org/2000/svg":O=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(h=0;h2&&(l.children=arguments.length>3?t1.call(arguments,2):t),km(i.type,l,n||i.key,r||i.ref,null)}t1=ly.slice,Sr={__e:function(i,e,t,n){for(var r,s,a;e=e.__;)if((r=e.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(i)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(i,n||{}),a=r.__d),a)return r.__E=r}catch(l){i=l}throw i}},eI=0,tI=function(i){return i!=null&&i.constructor===void 0},n_.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=eu({},this.state),typeof i=="function"&&(i=i(eu({},t),this.props)),i&&eu(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),h7(this))},n_.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),h7(this))},n_.prototype.render=ax,kf=[],nI=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,iI=function(i,e){return i.__v.__b-e.__v.__b},uy.__r=0,rI=/(PointerCapture)$|Capture$/i,e4=0,mT=d7(!1),gT=d7(!0);function A7(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var Yde=`.float-tooltip-kap { + position: absolute; + width: max-content; /* prevent shrinking near right edge */ + max-width: max(50%, 150px); + padding: 3px 5px; + border-radius: 3px; + font: 12px sans-serif; + color: #eee; + background: rgba(0,0,0,0.6); + pointer-events: none; +} +`;Xde(Yde);var Qde=_s({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.style,s=r===void 0?{}:r,a=!!e&&cy(e)==="object"&&!!e.node&&typeof e.node=="function",l=Mde(a?e.node():e);l.style("position")==="static"&&l.style("position","relative"),t.tooltipEl=l.append("div").attr("class","float-tooltip-kap"),Object.entries(s).forEach(function(h){var m=qde(h,2),v=m[0],x=m[1];return t.tooltipEl.style(v,x)}),t.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,l.on("mousemove.".concat(u),function(h){t.mouseInside=!0;var m=Cde(h),v=l.node(),x=v.offsetWidth,S=v.offsetHeight,T=[t.offsetX===null||t.offsetX===void 0?"-".concat(m[0]/x*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?S>130&&S-m[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",m[0]+"px").style("top",m[1]+"px").style("transform","translate(".concat(T.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseover.".concat(u),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),l.on("mouseout.".concat(u),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):Wde(e.content)?(e.tooltipEl.text(""),$de(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function Kde(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var Zde=`.scene-nav-info { + position: absolute; + bottom: 5px; + width: 100%; + text-align: center; + color: slategrey; + opacity: 0.7; + font-size: 10px; + font-family: sans-serif; + pointer-events: none; + user-select: none; +} + +.scene-container canvas:focus { + outline: none; +}`;Kde(Zde);function yT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,l){return e.hoverOrderComparator(a.object,l.object)});var s=r.find(function(a){return e.hoverFilter(a.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Ut(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var a=t,l=n||{x:0,y:0,z:0};if(!r)m(a),v(l);else{var u=Object.assign({},s.position),h=x();e.tweenGroup.add(new la(u).to(a,r).easing(os.Quadratic.Out).onUpdate(m).start()),e.tweenGroup.add(new la(h).to(l,r/3).easing(os.Quadratic.Out).onUpdate(v).start())}return this}return Object.assign({},s.position,{lookAt:x()});function m(S){var T=S.x,N=S.y,C=S.z;T!==void 0&&(s.position.x=T),N!==void 0&&(s.position.y=N),C!==void 0&&(s.position.z=C)}function v(S){var T=new xr.Vector3(S.x,S.y,S.z);e.controls.enabled&&e.controls.target?e.controls.target=T:s.lookAt(T)}function x(){return Object.assign(new xr.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var a=new xr.Vector3(0,0,0),l=Math.max.apply(Math,Cf(Object.entries(t).map(function(S){var T=aAe(S,2),N=T[0],C=T[1];return Math.max.apply(Math,Cf(C.map(function(E){return Math.abs(a[N]-E)})))})))*2,u=(1-r*2/e.height)*s.fov,h=l/Math.atan(u*Math.PI/180),m=h/s.aspect,v=Math.max(h,m);if(v>0){var x=a.clone().sub(s.position).normalize().multiplyScalar(-v);this.cameraPosition(x,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new xr.Box3(new xr.Vector3(0,0,0),new xr.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,Cf(["x","y","z"].map(function(s){return tAe({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new xr.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new xr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new xr.Raycaster;return a.setFromCamera(s,e.camera),Object.assign({},a.ray.at(r,new xr.Vector3))},intersectingObjects:function(e,t,n){var r=new xr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new xr.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new xr.Scene,camera:new xr.PerspectiveCamera,clock:new xr.Clock,tweenGroup:new wy,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,a=n.useWebGPU,l=a===void 0?!1:a,u=n.rendererConfig,h=u===void 0?{}:u,m=n.extraRenderers,v=m===void 0?[]:m,x=n.waitForLoadComplete,S=x===void 0?!0:x;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new Qde(t.container),t.pointerPos=new xr.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(T){return t.container.addEventListener(T,function(N){if(T==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&N.type==="pointermove"&&(N.pressure>0||t.isPointerPressed)&&(N.pointerType==="mouse"||N.movementX===void 0||[N.movementX,N.movementY].some(function(O){return Math.abs(O)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var C=E(t.container);t.pointerPos.x=N.pageX-C.left,t.pointerPos.y=N.pageY-C.top}function E(O){var U=O.getBoundingClientRect(),I=window.pageXOffset||document.documentElement.scrollLeft,j=window.pageYOffset||document.documentElement.scrollTop;return{top:U.top+j,left:U.left+I}}},{passive:!0})}),t.container.addEventListener("pointerup",function(T){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){T.button===0&&t.onClick(t.hoverObj||null,T,t.intersection),T.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,T,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(T){t.onRightClick&&T.preventDefault()}),t.renderer=new(l?cO:xr.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},h)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=v,t.extraRenderers.forEach(function(T){T.domElement.style.position="absolute",T.domElement.style.top="0px",T.domElement.style.pointerEvents="none",t.container.appendChild(T.domElement)}),t.postProcessingComposer=new rhe(t.renderer),t.postProcessingComposer.addPass(new she(t.scene,t.camera)),t.controls=new{trackball:dce,orbit:Nce,fly:Vce}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Cf(t.extraRenderers)).forEach(function(T){return T.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new xr.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!S,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Cf(e.extraRenderers)).forEach(function(S){return S.setSize(r,s)}),e.camera.aspect=r/s;var a=e.viewOffset.slice(0,2);a.some(function(S){return S})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(Cf(a),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var l,u=e.width,h=e.height,m=e.viewOffset.slice(0,2);m.some(function(S){return S})?(l=e.camera).setViewOffset.apply(l,[u,h].concat(Cf(m),[u,h])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new xr.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var v=O0(e.backgroundColor).alpha;v===void 0&&(v=1),e.renderer.setClearColor(new xr.Color(Ohe(1,e.backgroundColor)),v)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new xr.TextureLoader().load(e.backgroundImageUrl,function(S){S.colorSpace=xr.SRGBColorSpace,e.skysphere.material=new xr.MeshBasicMaterial({map:S,side:xr.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&x()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&x())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(S){return e.scene.remove(S)}),e.lights.forEach(function(S){return e.scene.add(S)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(S){return e.scene.remove(S)}),e.objects.forEach(function(S){return e.scene.add(S)}));function x(){e.loadComplete=e.scene.visible=!0}}});function uAe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var cAe=`.scene-container .clickable { + cursor: pointer; +}`;uAe(cAe);function xT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1?l-1:0),h=1;h1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=a();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(u){return s[u]=+s[u]}),!n)l(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new la(r).to(s,n).easing(os.Cubic.InOut).onUpdate(l).start())}return this;function a(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(u){var h=u.lat,m=u.lng,v=u.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(h,m,v)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;slocalStorage.getItem("radio-theme")||"default"),[a,l]=re.useState([]),[u,h]=re.useState(null),[m,v]=re.useState([]),[x,S]=re.useState(!1),[T,N]=re.useState({}),[C,E]=re.useState([]),[O,U]=re.useState(""),[I,j]=re.useState(""),[z,G]=re.useState(""),[H,q]=re.useState([]),[V,Q]=re.useState(!1),[J,ne]=re.useState([]),[oe,ie]=re.useState(!1),[Z,te]=re.useState(!1),[de,Se]=re.useState(.5),[Te,ae]=re.useState(null),[Me,Ve]=re.useState(!1),[Ce,Fe]=re.useState(!1),et=re.useRef(void 0),He=re.useRef(void 0),Rt=re.useRef(O);re.useEffect(()=>{fetch("/api/radio/places").then(k=>k.json()).then(l).catch(console.error),fetch("/api/radio/guilds").then(k=>k.json()).then(k=>{if(E(k),k.length>0){U(k[0].id);const be=k[0].voiceChannels.find(Oe=>Oe.members>0)??k[0].voiceChannels[0];be&&j(be.id)}}).catch(console.error),fetch("/api/radio/favorites").then(k=>k.json()).then(ne).catch(console.error)},[]),re.useEffect(()=>{Rt.current=O},[O]),re.useEffect(()=>{i!=null&&i.guildId&&"playing"in i&&i.type!=="radio_voicestats"?N(k=>{if(i.playing)return{...k,[i.guildId]:i.playing};const be={...k};return delete be[i.guildId],be}):i!=null&&i.playing&&!(i!=null&&i.guildId)&&N(i.playing),i!=null&&i.favorites&&ne(i.favorites),i!=null&&i.volumes&&O&&i.volumes[O]!=null&&Se(i.volumes[O]),(i==null?void 0:i.volume)!=null&&(i==null?void 0:i.guildId)===O&&Se(i.volume),(i==null?void 0:i.type)==="radio_voicestats"&&i.guildId===Rt.current&&ae({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})},[i,O]),re.useEffect(()=>{if(localStorage.setItem("radio-theme",r),t.current&&e.current){const be=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim();t.current.pointColor(()=>`rgba(${be}, 0.85)`).atmosphereColor(`rgba(${be}, 0.25)`)}},[r]);const Et=re.useRef(u);Et.current=u;const zt=re.useRef(oe);zt.current=oe;const Pt=re.useCallback(()=>{var be;const k=(be=t.current)==null?void 0:be.controls();k&&(k.autoRotate=!1),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{var pe;if(Et.current||zt.current)return;const Oe=(pe=t.current)==null?void 0:pe.controls();Oe&&(Oe.autoRotate=!0)},5e3)},[]);re.useEffect(()=>{var be;const k=(be=t.current)==null?void 0:be.controls();k&&(u||oe?(k.autoRotate=!1,n.current&&clearTimeout(n.current)):k.autoRotate=!0)},[u,oe]);const We=re.useRef(void 0);We.current=k=>{h(k),ie(!1),S(!0),v([]),Pt(),t.current&&t.current.pointOfView({lat:k.geo[1],lng:k.geo[0],altitude:.4},800),fetch(`/api/radio/place/${k.id}/channels`).then(be=>be.json()).then(be=>{v(be),S(!1)}).catch(()=>S(!1))},re.useEffect(()=>{const k=e.current;if(!k)return;k.clientWidth>0&&k.clientHeight>0&&Fe(!0);const be=new ResizeObserver(Oe=>{for(const pe of Oe){const{width:le,height:Ne}=pe.contentRect;le>0&&Ne>0&&Fe(!0)}});return be.observe(k),()=>be.disconnect()},[]),re.useEffect(()=>{if(!e.current||a.length===0)return;const k=e.current.clientWidth,be=e.current.clientHeight;if(t.current){t.current.pointsData(a),k>0&&be>0&&t.current.width(k).height(be);return}if(k===0||be===0)return;const pe=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim()||"230, 126, 34",le=new wAe(e.current).backgroundColor("rgba(0,0,0,0)").atmosphereColor(`rgba(${pe}, 0.25)`).atmosphereAltitude(.12).globeImageUrl("/nasa-blue-marble.jpg").pointsData(a).pointLat(Bt=>Bt.geo[1]).pointLng(Bt=>Bt.geo[0]).pointColor(()=>`rgba(${pe}, 0.85)`).pointRadius(Bt=>Math.max(.12,Math.min(.45,.06+(Bt.size??1)*.005))).pointAltitude(.001).pointResolution(24).pointLabel(Bt=>`

${Bt.title}
${Bt.country}
`).onPointClick(Bt=>{var ct;return(ct=We.current)==null?void 0:ct.call(We,Bt)}).width(e.current.clientWidth).height(e.current.clientHeight);le.renderer().setPixelRatio(window.devicePixelRatio),le.pointOfView({lat:48,lng:10,altitude:qS});const Ne=le.controls();Ne&&(Ne.autoRotate=!0,Ne.autoRotateSpeed=.3);let De=qS;const Je=()=>{const ct=le.pointOfView().altitude;if(Math.abs(ct-De)/De<.05)return;De=ct;const jt=Math.sqrt(ct/qS);le.pointRadius(Jt=>Math.max(.12,Math.min(.45,.06+(Jt.size??1)*.005))*Math.max(.15,Math.min(2.5,jt)))};Ne.addEventListener("change",Je),t.current=le;const we=e.current,Ue=()=>Pt();we.addEventListener("mousedown",Ue),we.addEventListener("touchstart",Ue),we.addEventListener("wheel",Ue);const ut=()=>{if(e.current&&t.current){const Bt=e.current.clientWidth,ct=e.current.clientHeight;Bt>0&&ct>0&&t.current.width(Bt).height(ct)}};window.addEventListener("resize",ut);const Dt=new ResizeObserver(()=>ut());return Dt.observe(we),()=>{Ne.removeEventListener("change",Je),we.removeEventListener("mousedown",Ue),we.removeEventListener("touchstart",Ue),we.removeEventListener("wheel",Ue),window.removeEventListener("resize",ut),Dt.disconnect()}},[a,Pt,Ce]);const ft=re.useCallback(async(k,be,Oe,pe)=>{if(!(!O||!I)){te(!0);try{(await(await fetch("/api/radio/play",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,voiceChannelId:I,stationId:k,stationName:be,placeName:Oe??(u==null?void 0:u.title)??"",country:pe??(u==null?void 0:u.country)??""})})).json()).ok&&(N(De=>{var Je,we;return{...De,[O]:{stationId:k,stationName:be,placeName:Oe??(u==null?void 0:u.title)??"",country:pe??(u==null?void 0:u.country)??"",startedAt:new Date().toISOString(),channelName:((we=(Je=C.find(Ue=>Ue.id===O))==null?void 0:Je.voiceChannels.find(Ue=>Ue.id===I))==null?void 0:we.name)??""}}}),Pt())}catch(le){console.error(le)}te(!1)}},[O,I,u,C]),fe=re.useCallback(async()=>{O&&(await fetch("/api/radio/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O})}),N(k=>{const be={...k};return delete be[O],be}))},[O]),Wt=re.useCallback(k=>{if(G(k),et.current&&clearTimeout(et.current),!k.trim()){q([]),Q(!1);return}et.current=setTimeout(async()=>{try{const Oe=await(await fetch(`/api/radio/search?q=${encodeURIComponent(k)}`)).json();q(Oe),Q(!0)}catch{q([])}},350)},[]),yt=re.useCallback(k=>{var be,Oe,pe;if(Q(!1),G(""),q([]),k.type==="channel"){const le=(be=k.url.match(/\/listen\/[^/]+\/([^/]+)/))==null?void 0:be[1];le&&ft(le,k.title,k.subtitle,"")}else if(k.type==="place"){const le=(Oe=k.url.match(/\/visit\/[^/]+\/([^/]+)/))==null?void 0:Oe[1],Ne=a.find(De=>De.id===le);Ne&&((pe=We.current)==null||pe.call(We,Ne))}},[a,ft]),Gt=re.useCallback(async(k,be)=>{try{const pe=await(await fetch("/api/radio/favorites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stationId:k,stationName:be,placeName:(u==null?void 0:u.title)??"",country:(u==null?void 0:u.country)??"",placeId:(u==null?void 0:u.id)??""})})).json();pe.favorites&&ne(pe.favorites)}catch{}},[u]),_t=re.useCallback(k=>{Se(k),O&&(He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{fetch("/api/radio/volume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,volume:k})}).catch(console.error)},100))},[O]),Xt=k=>J.some(be=>be.stationId===k),pt=O?T[O]:null,Ae=C.find(k=>k.id===O);return P.jsxs("div",{className:"radio-container","data-theme":r,children:[P.jsxs("header",{className:"radio-topbar",children:[P.jsxs("div",{className:"radio-topbar-left",children:[P.jsx("span",{className:"radio-topbar-logo",children:"🌍"}),P.jsx("span",{className:"radio-topbar-title",children:"World Radio"}),C.length>1&&P.jsx("select",{className:"radio-sel",value:O,onChange:k=>{U(k.target.value);const be=C.find(pe=>pe.id===k.target.value),Oe=(be==null?void 0:be.voiceChannels.find(pe=>pe.members>0))??(be==null?void 0:be.voiceChannels[0]);j((Oe==null?void 0:Oe.id)??"")},children:C.map(k=>P.jsx("option",{value:k.id,children:k.name},k.id))}),P.jsxs("select",{className:"radio-sel",value:I,onChange:k=>j(k.target.value),children:[P.jsx("option",{value:"",children:"Voice Channel..."}),Ae==null?void 0:Ae.voiceChannels.map(k=>P.jsxs("option",{value:k.id,children:["🔊"," ",k.name,k.members>0?` (${k.members})`:""]},k.id))]})]}),pt&&P.jsxs("div",{className:"radio-topbar-np",children:[P.jsxs("div",{className:"radio-eq radio-eq-np",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),P.jsxs("div",{className:"radio-np-info",children:[P.jsx("span",{className:"radio-np-name",children:pt.stationName}),P.jsxs("span",{className:"radio-np-loc",children:[pt.placeName,pt.country?`, ${pt.country}`:""]})]})]}),P.jsxs("div",{className:"radio-topbar-right",children:[pt&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"radio-volume",children:[P.jsx("span",{className:"radio-volume-icon",children:de===0?"🔇":de<.4?"🔉":"🔊"}),P.jsx("input",{type:"range",className:"radio-volume-slider",min:0,max:1,step:.01,value:de,onChange:k=>_t(Number(k.target.value))}),P.jsxs("span",{className:"radio-volume-val",children:[Math.round(de*100),"%"]})]}),P.jsxs("div",{className:"radio-conn",onClick:()=>Ve(!0),title:"Verbindungsdetails",children:[P.jsx("span",{className:"radio-conn-dot"}),"Verbunden",(Te==null?void 0:Te.voicePing)!=null&&P.jsxs("span",{className:"radio-conn-ping",children:[Te.voicePing,"ms"]})]}),P.jsxs("button",{className:"radio-topbar-stop",onClick:fe,children:["⏹"," Stop"]})]}),P.jsx("div",{className:"radio-theme-inline",children:TAe.map(k=>P.jsx("div",{className:`radio-theme-dot ${r===k.id?"active":""}`,style:{background:k.color},title:k.label,onClick:()=>s(k.id)},k.id))})]})]}),P.jsxs("div",{className:"radio-globe-wrap",children:[P.jsx("div",{className:"radio-globe",ref:e}),P.jsxs("div",{className:"radio-search",children:[P.jsxs("div",{className:"radio-search-wrap",children:[P.jsx("span",{className:"radio-search-icon",children:"🔍"}),P.jsx("input",{className:"radio-search-input",type:"text",placeholder:"Sender oder Stadt suchen...",value:z,onChange:k=>Wt(k.target.value),onFocus:()=>{H.length&&Q(!0)}}),z&&P.jsx("button",{className:"radio-search-clear",onClick:()=>{G(""),q([]),Q(!1)},children:"✕"})]}),V&&H.length>0&&P.jsx("div",{className:"radio-search-results",children:H.slice(0,12).map(k=>P.jsxs("button",{className:"radio-search-result",onClick:()=>yt(k),children:[P.jsx("span",{className:"radio-search-result-icon",children:k.type==="channel"?"📻":k.type==="place"?"📍":"🌍"}),P.jsxs("div",{className:"radio-search-result-text",children:[P.jsx("span",{className:"radio-search-result-title",children:k.title}),P.jsx("span",{className:"radio-search-result-sub",children:k.subtitle})]})]},k.id+k.url))})]}),!u&&!oe&&P.jsxs("button",{className:"radio-fab",onClick:()=>{ie(!0),h(null)},title:"Favoriten",children:["⭐",J.length>0&&P.jsx("span",{className:"radio-fab-badge",children:J.length})]}),oe&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("h3",{children:["⭐"," Favoriten"]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>ie(!1),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:J.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Noch keine Favoriten"}):J.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.stationId?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.stationName}),P.jsxs("span",{className:"radio-station-loc",children:[k.placeName,", ",k.country]})]}),P.jsxs("div",{className:"radio-station-btns",children:[P.jsx("button",{className:"radio-btn-play",onClick:()=>ft(k.stationId,k.stationName,k.placeName,k.country),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:"radio-btn-fav active",onClick:()=>Gt(k.stationId,k.stationName),children:"★"})]})]},k.stationId))})]}),u&&!oe&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("div",{children:[P.jsx("h3",{children:u.title}),P.jsx("span",{className:"radio-panel-sub",children:u.country})]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>h(null),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:x?P.jsxs("div",{className:"radio-panel-loading",children:[P.jsx("div",{className:"radio-spinner"}),"Sender werden geladen..."]}):m.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Keine Sender gefunden"}):m.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.id?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.title}),(pt==null?void 0:pt.stationId)===k.id&&P.jsxs("span",{className:"radio-station-live",children:[P.jsxs("span",{className:"radio-eq",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),"Live"]})]}),P.jsxs("div",{className:"radio-station-btns",children:[(pt==null?void 0:pt.stationId)===k.id?P.jsx("button",{className:"radio-btn-stop",onClick:fe,children:"⏹"}):P.jsx("button",{className:"radio-btn-play",onClick:()=>ft(k.id,k.title),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:`radio-btn-fav ${Xt(k.id)?"active":""}`,onClick:()=>Gt(k.id,k.title),children:Xt(k.id)?"★":"☆"})]})]},k.id))})]}),P.jsxs("div",{className:"radio-counter",children:["📻"," ",a.length.toLocaleString("de-DE")," Sender weltweit"]}),P.jsx("a",{className:"radio-attribution",href:"https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/",target:"_blank",rel:"noreferrer",children:"Imagery © NASA Blue Marble"})]}),Me&&(()=>{const k=Te!=null&&Te.connectedSince?Math.floor((Date.now()-new Date(Te.connectedSince).getTime())/1e3):0,be=Math.floor(k/3600),Oe=Math.floor(k%3600/60),pe=k%60,le=be>0?`${be}h ${String(Oe).padStart(2,"0")}m ${String(pe).padStart(2,"0")}s`:Oe>0?`${Oe}m ${String(pe).padStart(2,"0")}s`:`${pe}s`,Ne=De=>De==null?"var(--text-faint)":De<80?"var(--success)":De<150?"#f0a830":"#e04040";return P.jsx("div",{className:"radio-modal-overlay",onClick:()=>Ve(!1),children:P.jsxs("div",{className:"radio-modal",onClick:De=>De.stopPropagation(),children:[P.jsxs("div",{className:"radio-modal-header",children:[P.jsx("span",{children:"📡"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"radio-modal-close",onClick:()=>Ve(!1),children:"✕"})]}),P.jsxs("div",{className:"radio-modal-body",children:[P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Voice Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:Ne((Te==null?void 0:Te.voicePing)??null)}}),(Te==null?void 0:Te.voicePing)!=null?`${Te.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Gateway Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:Ne((Te==null?void 0:Te.gatewayPing)??null)}}),Te&&Te.gatewayPing>=0?`${Te.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Status"}),P.jsx("span",{className:"radio-modal-value",style:{color:(Te==null?void 0:Te.status)==="ready"?"var(--success)":"#f0a830"},children:(Te==null?void 0:Te.status)==="ready"?"Verbunden":(Te==null?void 0:Te.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Kanal"}),P.jsx("span",{className:"radio-modal-value",children:(Te==null?void 0:Te.channelName)||"---"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Verbunden seit"}),P.jsx("span",{className:"radio-modal-value",children:le||"---"})]})]})]})})})()]})}function EAe(i,e,t=365){const n=new Date(Date.now()+t*24*60*60*1e3).toUTCString();document.cookie=`${encodeURIComponent(i)}=${encodeURIComponent(e)}; expires=${n}; path=/; SameSite=Lax`}function CAe(i){const e=`${encodeURIComponent(i)}=`,t=document.cookie.split(";");for(const n of t){const r=n.trim();if(r.startsWith(e))return decodeURIComponent(r.slice(e.length))}return null}const ca="/api/soundboard";async function NAe(i,e,t,n){const r=new URL(`${ca}/sounds`,window.location.origin);i&&r.searchParams.set("q",i),e!==void 0&&r.searchParams.set("folder",e),r.searchParams.set("fuzzy","0");const s=await fetch(r.toString());if(!s.ok)throw new Error("Fehler beim Laden der Sounds");return s.json()}async function RAe(){const i=await fetch(`${ca}/analytics`);if(!i.ok)throw new Error("Fehler beim Laden der Analytics");return i.json()}async function DAe(){const i=await fetch(`${ca}/categories`,{credentials:"include"});if(!i.ok)throw new Error("Fehler beim Laden der Kategorien");return i.json()}async function PAe(){const i=await fetch(`${ca}/channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channels");return i.json()}async function LAe(){const i=await fetch(`${ca}/selected-channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channel-Auswahl");const e=await i.json();return(e==null?void 0:e.selected)||{}}async function UAe(i,e){if(!(await fetch(`${ca}/selected-channel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Channel-Auswahl setzen fehlgeschlagen")}async function BAe(i,e,t,n,r){const s=await fetch(`${ca}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({soundName:i,guildId:e,channelId:t,volume:n,relativePath:r})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error((a==null?void 0:a.error)||"Play fehlgeschlagen")}}async function OAe(i,e,t,n,r){const s=await fetch(`${ca}/play-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,guildId:e,channelId:t,volume:n,filename:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error((a==null?void 0:a.error)||"Play-URL fehlgeschlagen");return a}async function IAe(i,e){const t=await fetch(`${ca}/download-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,filename:e})}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error((n==null?void 0:n.error)||"Download fehlgeschlagen");return n}async function FAe(i,e){if(!(await fetch(`${ca}/party/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Partymode Start fehlgeschlagen")}async function kAe(i){if(!(await fetch(`${ca}/party/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i})})).ok)throw new Error("Partymode Stop fehlgeschlagen")}async function g7(i,e){const t=await fetch(`${ca}/volume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,volume:e})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error((n==null?void 0:n.error)||"Volume aendern fehlgeschlagen")}}async function zAe(i){const e=new URL(`${ca}/volume`,window.location.origin);e.searchParams.set("guildId",i);const t=await fetch(e.toString());if(!t.ok)throw new Error("Fehler beim Laden der Lautstaerke");const n=await t.json();return typeof(n==null?void 0:n.volume)=="number"?n.volume:1}async function GAe(i){if(!(await fetch(`${ca}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}function qAe(i,e,t){return new Promise((n,r)=>{const s=new FormData;s.append("files",i),e&&s.append("customName",e);const a=new XMLHttpRequest;a.open("POST",`${ca}/upload`),a.upload.onprogress=l=>{l.lengthComputable&&t(Math.round(l.loaded/l.total*100))},a.onload=()=>{var l,u;if(a.status===200)try{const h=JSON.parse(a.responseText);n(((u=(l=h.files)==null?void 0:l[0])==null?void 0:u.name)??i.name)}catch{n(i.name)}else try{r(new Error(JSON.parse(a.responseText).error))}catch{r(new Error(`HTTP ${a.status}`))}},a.onerror=()=>r(new Error("Netzwerkfehler")),a.send(s)})}const VAe=[{id:"default",color:"#5865f2",label:"Discord"},{id:"purple",color:"#9b59b6",label:"Midnight"},{id:"forest",color:"#2ecc71",label:"Forest"},{id:"sunset",color:"#e67e22",label:"Sunset"},{id:"ocean",color:"#3498db",label:"Ocean"}],v7=["#3b82f6","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#06b6d4","#ef4444","#a855f7","#84cc16","#d946ef","#0ea5e9","#f43f5e","#10b981"];function jAe({data:i,isAdmin:e}){var qe,qt,Qt;const[t,n]=re.useState([]),[r,s]=re.useState(0),[a,l]=re.useState([]),[u,h]=re.useState([]),[m,v]=re.useState({totalSounds:0,totalPlays:0,mostPlayed:[]}),[x,S]=re.useState("all"),[T,N]=re.useState(""),[C,E]=re.useState(""),[O,U]=re.useState(""),[I,j]=re.useState(!1),[z,G]=re.useState(null),[H,q]=re.useState([]),[V,Q]=re.useState(""),J=re.useRef(""),[ne,oe]=re.useState(!1),[ie,Z]=re.useState(1),[te,de]=re.useState(""),[Se,Te]=re.useState({}),[ae,Me]=re.useState(()=>localStorage.getItem("jb-theme")||"default"),[Ve,Ce]=re.useState(()=>parseInt(localStorage.getItem("jb-card-size")||"110")),[Fe,et]=re.useState(!1),[He,Rt]=re.useState([]),Et=re.useRef(!1),zt=re.useRef(void 0),Pt=e??!1,[We,ft]=re.useState(!1),[fe,Wt]=re.useState([]),[yt,Gt]=re.useState(!1),_t=re.useRef(0);re.useRef(void 0);const[Xt,pt]=re.useState([]),[Ae,k]=re.useState(0),[be,Oe]=re.useState(""),[pe,le]=re.useState("naming"),[Ne,De]=re.useState(0),[Je,we]=re.useState(null),[Ue,ut]=re.useState(!1),[Dt,Bt]=re.useState(null),[ct,jt]=re.useState(""),[Jt,In]=re.useState(null),[ge,Ot]=re.useState(0);re.useEffect(()=>{Et.current=Fe},[Fe]),re.useEffect(()=>{J.current=V},[V]),re.useEffect(()=>{const he=sn=>{var Tn;Array.from(((Tn=sn.dataTransfer)==null?void 0:Tn.items)??[]).some(Rn=>Rn.kind==="file")&&(_t.current++,ft(!0))},X=()=>{_t.current=Math.max(0,_t.current-1),_t.current===0&&ft(!1)},tt=sn=>sn.preventDefault(),en=sn=>{var Rn;sn.preventDefault(),_t.current=0,ft(!1);const Tn=Array.from(((Rn=sn.dataTransfer)==null?void 0:Rn.files)??[]).filter(xi=>/\.(mp3|wav)$/i.test(xi.name));Tn.length&&xt(Tn)};return window.addEventListener("dragenter",he),window.addEventListener("dragleave",X),window.addEventListener("dragover",tt),window.addEventListener("drop",en),()=>{window.removeEventListener("dragenter",he),window.removeEventListener("dragleave",X),window.removeEventListener("dragover",tt),window.removeEventListener("drop",en)}},[Pt]);const ot=re.useCallback((he,X="info")=>{Bt({msg:he,type:X}),setTimeout(()=>Bt(null),3e3)},[]);re.useCallback(he=>he.relativePath??he.fileName,[]);const Tt=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","music.youtube.com","instagram.com","www.instagram.com"],Ht=re.useCallback(he=>{const X=he.trim();return!X||/^https?:\/\//i.test(X)?X:"https://"+X},[]),Yt=re.useCallback(he=>{try{const X=new URL(Ht(he)),tt=X.hostname.toLowerCase();return!!(X.pathname.toLowerCase().endsWith(".mp3")||Tt.some(en=>tt===en||tt.endsWith("."+en)))}catch{return!1}},[Ht]),pn=re.useCallback(he=>{try{const X=new URL(Ht(he)),tt=X.hostname.toLowerCase();return tt.includes("youtube")||tt==="youtu.be"?"youtube":tt.includes("instagram")?"instagram":X.pathname.toLowerCase().endsWith(".mp3")?"mp3":null}catch{return null}},[Ht]),$e=V?V.split(":")[0]:"",St=V?V.split(":")[1]:"",Kt=re.useMemo(()=>H.find(he=>`${he.guildId}:${he.channelId}`===V),[H,V]);re.useEffect(()=>{const he=()=>{const tt=new Date,en=String(tt.getHours()).padStart(2,"0"),sn=String(tt.getMinutes()).padStart(2,"0"),Tn=String(tt.getSeconds()).padStart(2,"0");jt(`${en}:${sn}:${Tn}`)};he();const X=setInterval(he,1e3);return()=>clearInterval(X)},[]),re.useEffect(()=>{(async()=>{try{const[he,X]=await Promise.all([PAe(),LAe()]);if(q(he),he.length){const tt=he[0].guildId,en=X[tt],sn=en&&he.find(Tn=>Tn.guildId===tt&&Tn.channelId===en);Q(sn?`${tt}:${en}`:`${he[0].guildId}:${he[0].channelId}`)}}catch(he){ot((he==null?void 0:he.message)||"Channel-Fehler","error")}try{const he=await DAe();h(he.categories||[])}catch{}})()},[]),re.useEffect(()=>{localStorage.setItem("jb-theme",ae)},[ae]);const wn=re.useRef(null);re.useEffect(()=>{const he=wn.current;if(!he)return;he.style.setProperty("--card-size",Ve+"px");const X=Ve/110;he.style.setProperty("--card-emoji",Math.round(28*X)+"px"),he.style.setProperty("--card-font",Math.max(9,Math.round(11*X))+"px"),localStorage.setItem("jb-card-size",String(Ve))},[Ve]),re.useEffect(()=>{var he,X,tt,en,sn,Tn,Rn,xi;if(i){if(i.soundboard){const K=i.soundboard;Array.isArray(K.party)&&Rt(K.party);try{const hn=K.selected||{},Zt=(he=J.current)==null?void 0:he.split(":")[0];Zt&&hn[Zt]&&Q(`${Zt}:${hn[Zt]}`)}catch{}try{const hn=K.volumes||{},Zt=(X=J.current)==null?void 0:X.split(":")[0];Zt&&typeof hn[Zt]=="number"&&Z(hn[Zt])}catch{}try{const hn=K.nowplaying||{},Zt=(tt=J.current)==null?void 0:tt.split(":")[0];Zt&&typeof hn[Zt]=="string"&&de(hn[Zt])}catch{}try{const hn=K.voicestats||{},Zt=(en=J.current)==null?void 0:en.split(":")[0];Zt&&hn[Zt]&&we(hn[Zt])}catch{}}if(i.type==="soundboard_party")Rt(K=>{const hn=new Set(K);return i.active?hn.add(i.guildId):hn.delete(i.guildId),Array.from(hn)});else if(i.type==="soundboard_channel"){const K=(sn=J.current)==null?void 0:sn.split(":")[0];i.guildId===K&&Q(`${i.guildId}:${i.channelId}`)}else if(i.type==="soundboard_volume"){const K=(Tn=J.current)==null?void 0:Tn.split(":")[0];i.guildId===K&&typeof i.volume=="number"&&Z(i.volume)}else if(i.type==="soundboard_nowplaying"){const K=(Rn=J.current)==null?void 0:Rn.split(":")[0];i.guildId===K&&de(i.name||"")}else if(i.type==="soundboard_voicestats"){const K=(xi=J.current)==null?void 0:xi.split(":")[0];i.guildId===K&&we({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})}}},[i]),re.useEffect(()=>{et($e?He.includes($e):!1)},[V,He,$e]),re.useEffect(()=>{(async()=>{try{let he="__all__";x==="recent"?he="__recent__":T&&(he=T);const X=await NAe(C,he,void 0,!1);n(X.items),s(X.total),l(X.folders)}catch(he){ot((he==null?void 0:he.message)||"Sounds-Fehler","error")}})()},[x,T,C,ge,ot]),re.useEffect(()=>{qn()},[ge]),re.useEffect(()=>{const he=CAe("favs");if(he)try{Te(JSON.parse(he))}catch{}},[]),re.useEffect(()=>{try{EAe("favs",JSON.stringify(Se))}catch{}},[Se]),re.useEffect(()=>{V&&(async()=>{try{const he=await zAe($e);Z(he)}catch{}})()},[V]),re.useEffect(()=>{const he=()=>{oe(!1),In(null)};return document.addEventListener("click",he),()=>document.removeEventListener("click",he)},[]);async function qn(){try{const he=await RAe();v(he)}catch{}}async function Ze(he){if(!V)return ot("Bitte einen Voice-Channel auswaehlen","error");try{await BAe(he.name,$e,St,ie,he.relativePath),de(he.name),qn()}catch(X){ot((X==null?void 0:X.message)||"Play fehlgeschlagen","error")}}function dt(){var en;const he=Ht(O);if(!he)return ot("Bitte einen Link eingeben","error");if(!Yt(he))return ot("Nur YouTube, Instagram oder direkte MP3-Links","error");const X=pn(he);let tt="";if(X==="mp3")try{tt=((en=new URL(he).pathname.split("/").pop())==null?void 0:en.replace(/\.mp3$/i,""))??""}catch{}G({url:he,type:X,filename:tt,phase:"input"})}async function Vt(){if(z){G(he=>he?{...he,phase:"downloading"}:null);try{let he;const X=z.filename.trim()||void 0;V&&$e&&St?he=(await OAe(z.url,$e,St,ie,X)).saved:he=(await IAe(z.url,X)).saved,G(tt=>tt?{...tt,phase:"done",savedName:he}:null),U(""),Ot(tt=>tt+1),qn(),setTimeout(()=>G(null),2500)}catch(he){G(X=>X?{...X,phase:"error",error:(he==null?void 0:he.message)||"Fehler"}:null)}}}async function xt(he){if(!Pt){ot("Admin-Login erforderlich zum Hochladen","error");return}if(he.length===0)return;pt(he),k(0);const X=he[0].name.replace(/\.(mp3|wav)$/i,"");Oe(X),le("naming"),De(0)}async function A(){if(Xt.length===0)return;const he=Xt[Ae],X=be.trim()||he.name.replace(/\.(mp3|wav)$/i,"");le("uploading"),De(0);try{await qAe(he,X,tt=>De(tt)),le("done"),setTimeout(()=>{const tt=Ae+1;if(tten+1),qn(),ot(`${Xt.length} Sound${Xt.length>1?"s":""} hochgeladen`,"info")},800)}catch(tt){ot((tt==null?void 0:tt.message)||"Upload fehlgeschlagen","error"),pt([])}}function ee(){const he=Ae+1;if(he0&&(Ot(X=>X+1),qn())}async function Vn(){if(V){de("");try{await fetch(`${ca}/stop?guildId=${encodeURIComponent($e)}`,{method:"POST"})}catch{}}}async function Wn(){if(!lr.length||!V)return;const he=lr[Math.floor(Math.random()*lr.length)];Ze(he)}async function $n(){if(Fe){await Vn();try{await kAe($e)}catch{}}else{if(!V)return ot("Bitte einen Channel auswaehlen","error");try{await FAe($e,St)}catch{}}}async function dn(he){const X=`${he.guildId}:${he.channelId}`;Q(X),oe(!1);try{await UAe(he.guildId,he.channelId)}catch{}}function Fn(he){Te(X=>({...X,[he]:!X[he]}))}const lr=re.useMemo(()=>x==="favorites"?t.filter(he=>Se[he.relativePath??he.fileName]):t,[t,x,Se]),an=re.useMemo(()=>Object.values(Se).filter(Boolean).length,[Se]),mn=re.useMemo(()=>a.filter(he=>!["__all__","__recent__","__top3__"].includes(he.key)),[a]),Er=re.useMemo(()=>{const he={};return mn.forEach((X,tt)=>{he[X.key]=v7[tt%v7.length]}),he},[mn]),Wi=re.useMemo(()=>{const he=new Set,X=new Set;return lr.forEach((tt,en)=>{const sn=tt.name.charAt(0).toUpperCase();he.has(sn)||(he.add(sn),X.add(en))}),X},[lr]),No=re.useMemo(()=>{const he={};return H.forEach(X=>{he[X.guildName]||(he[X.guildName]=[]),he[X.guildName].push(X)}),he},[H]),ce=m.mostPlayed.slice(0,10),Ge=m.totalSounds||r,rt=ct.slice(0,5),it=ct.slice(5);return P.jsxs("div",{className:"sb-app","data-theme":ae,ref:wn,children:[Fe&&P.jsx("div",{className:"party-overlay active"}),P.jsxs("header",{className:"topbar",children:[P.jsxs("div",{className:"topbar-left",children:[P.jsx("div",{className:"sb-app-logo",children:P.jsx("span",{className:"material-icons",style:{fontSize:16,color:"white"},children:"music_note"})}),P.jsx("span",{className:"sb-app-title",children:"Soundboard"}),P.jsxs("div",{className:"channel-dropdown",onClick:he=>he.stopPropagation(),children:[P.jsxs("button",{className:`channel-btn ${ne?"open":""}`,onClick:()=>oe(!ne),children:[P.jsx("span",{className:"material-icons cb-icon",children:"headset"}),V&&P.jsx("span",{className:"channel-status"}),P.jsx("span",{className:"channel-label",children:Kt?`${Kt.channelName}${Kt.members?` (${Kt.members})`:""}`:"Channel..."}),P.jsx("span",{className:"material-icons chevron",children:"expand_more"})]}),ne&&P.jsxs("div",{className:"channel-menu visible",children:[Object.entries(No).map(([he,X])=>P.jsxs(FF.Fragment,{children:[P.jsx("div",{className:"channel-menu-header",children:he}),X.map(tt=>P.jsxs("div",{className:`channel-option ${`${tt.guildId}:${tt.channelId}`===V?"active":""}`,onClick:()=>dn(tt),children:[P.jsx("span",{className:"material-icons co-icon",children:"volume_up"}),tt.channelName,tt.members?` (${tt.members})`:""]},`${tt.guildId}:${tt.channelId}`))]},he)),H.length===0&&P.jsx("div",{className:"channel-option",style:{color:"var(--text-faint)",cursor:"default"},children:"Keine Channels verfuegbar"})]})]})]}),P.jsx("div",{className:"clock-wrap",children:P.jsxs("div",{className:"clock",children:[rt,P.jsx("span",{className:"clock-seconds",children:it})]})}),P.jsxs("div",{className:"topbar-right",children:[te&&P.jsxs("div",{className:"now-playing",children:[P.jsxs("div",{className:"np-waves active",children:[P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"})]}),P.jsx("span",{className:"np-label",children:"Last Played:"})," ",P.jsx("span",{className:"np-name",children:te})]}),V&&P.jsxs("div",{className:"connection",onClick:()=>ut(!0),style:{cursor:"pointer"},title:"Verbindungsdetails",children:[P.jsx("span",{className:"conn-dot"}),"Verbunden",(Je==null?void 0:Je.voicePing)!=null&&P.jsxs("span",{className:"conn-ping",children:[Je.voicePing,"ms"]})]})]})]}),P.jsxs("div",{className:"toolbar",children:[P.jsxs("div",{className:"cat-tabs",children:[P.jsxs("button",{className:`cat-tab ${x==="all"?"active":""}`,onClick:()=>{S("all"),N("")},children:["Alle",P.jsx("span",{className:"tab-count",children:r})]}),P.jsx("button",{className:`cat-tab ${x==="recent"?"active":""}`,onClick:()=>{S("recent"),N("")},children:"Neu hinzugefuegt"}),P.jsxs("button",{className:`cat-tab ${x==="favorites"?"active":""}`,onClick:()=>{S("favorites"),N("")},children:["Favoriten",an>0&&P.jsx("span",{className:"tab-count",children:an})]})]}),P.jsxs("div",{className:"search-wrap",children:[P.jsx("span",{className:"material-icons search-icon",children:"search"}),P.jsx("input",{className:"search-input",type:"text",placeholder:"Suchen...",value:C,onChange:he=>E(he.target.value)}),C&&P.jsx("button",{className:"search-clear",onClick:()=>E(""),children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsxs("div",{className:"url-import-wrap",children:[P.jsx("span",{className:"material-icons url-import-icon",children:pn(O)==="youtube"?"smart_display":pn(O)==="instagram"?"photo_camera":"link"}),P.jsx("input",{className:"url-import-input",type:"text",placeholder:"YouTube / Instagram / MP3-Link...",value:O,onChange:he=>U(he.target.value),onKeyDown:he=>{he.key==="Enter"&&dt()}}),O&&P.jsx("span",{className:`url-import-tag ${Yt(O)?"valid":"invalid"}`,children:pn(O)==="youtube"?"YT":pn(O)==="instagram"?"IG":pn(O)==="mp3"?"MP3":"?"}),P.jsx("button",{className:"url-import-btn",onClick:()=>{dt()},disabled:I||!!O&&!Yt(O),title:"Sound herunterladen",children:I?"Laedt...":"Download"})]}),P.jsx("div",{className:"toolbar-spacer"}),P.jsxs("div",{className:"volume-control",children:[P.jsx("span",{className:"material-icons vol-icon",onClick:()=>{const he=ie>0?0:.5;Z(he),$e&&g7($e,he).catch(()=>{})},children:ie===0?"volume_off":ie<.5?"volume_down":"volume_up"}),P.jsx("input",{type:"range",className:"vol-slider",min:0,max:1,step:.01,value:ie,onChange:he=>{const X=parseFloat(he.target.value);Z(X),$e&&(zt.current&&clearTimeout(zt.current),zt.current=setTimeout(()=>{g7($e,X).catch(()=>{})},120))},style:{"--vol":`${Math.round(ie*100)}%`}}),P.jsxs("span",{className:"vol-pct",children:[Math.round(ie*100),"%"]})]}),P.jsxs("button",{className:"tb-btn random",onClick:Wn,title:"Zufaelliger Sound",children:[P.jsx("span",{className:"material-icons tb-icon",children:"shuffle"}),"Random"]}),P.jsxs("button",{className:`tb-btn party ${Fe?"active":""}`,onClick:$n,title:"Party Mode",children:[P.jsx("span",{className:"material-icons tb-icon",children:Fe?"celebration":"auto_awesome"}),Fe?"Party!":"Party"]}),P.jsxs("button",{className:"tb-btn stop",onClick:Vn,title:"Alle stoppen",children:[P.jsx("span",{className:"material-icons tb-icon",children:"stop"}),"Stop"]}),P.jsxs("div",{className:"size-control",title:"Button-Groesse",children:[P.jsx("span",{className:"material-icons sc-icon",children:"grid_view"}),P.jsx("input",{type:"range",className:"size-slider",min:80,max:160,value:Ve,onChange:he=>Ce(parseInt(he.target.value))})]}),P.jsx("div",{className:"theme-selector",children:VAe.map(he=>P.jsx("div",{className:`theme-dot ${ae===he.id?"active":""}`,style:{background:he.color},title:he.label,onClick:()=>Me(he.id)},he.id))})]}),P.jsxs("div",{className:"analytics-strip",children:[P.jsxs("div",{className:"analytics-card",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"library_music"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Sounds gesamt"}),P.jsx("strong",{className:"analytics-value",children:Ge})]})]}),P.jsxs("div",{className:"analytics-card analytics-wide",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"leaderboard"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Most Played"}),P.jsx("div",{className:"analytics-top-list",children:ce.length===0?P.jsx("span",{className:"analytics-muted",children:"Noch keine Plays"}):ce.map((he,X)=>P.jsxs("span",{className:"analytics-chip",children:[X+1,". ",he.name," (",he.count,")"]},he.relativePath))})]})]})]}),x==="all"&&mn.length>0&&P.jsx("div",{className:"category-strip",children:mn.map(he=>{const X=Er[he.key]||"#888",tt=T===he.key;return P.jsxs("button",{className:`cat-chip ${tt?"active":""}`,onClick:()=>N(tt?"":he.key),style:tt?{borderColor:X,color:X}:void 0,children:[P.jsx("span",{className:"cat-dot",style:{background:X}}),he.name.replace(/\s*\(\d+\)\s*$/,""),P.jsx("span",{className:"cat-count",children:he.count})]},he.key)})}),P.jsx("main",{className:"main",children:lr.length===0?P.jsxs("div",{className:"empty-state visible",children:[P.jsx("div",{className:"empty-emoji",children:x==="favorites"?"⭐":"🔇"}),P.jsx("div",{className:"empty-title",children:x==="favorites"?"Noch keine Favoriten":C?`Kein Sound fuer "${C}" gefunden`:"Keine Sounds vorhanden"}),P.jsx("div",{className:"empty-desc",children:x==="favorites"?"Klick den Stern auf einem Sound!":"Hier gibt's noch nichts zu hoeren."})]}):P.jsx("div",{className:"sound-grid",children:lr.map((he,X)=>{var hn;const tt=he.relativePath??he.fileName,en=!!Se[tt],sn=te===he.name,Tn=he.isRecent||((hn=he.badges)==null?void 0:hn.includes("new")),Rn=he.name.charAt(0).toUpperCase(),xi=Wi.has(X),K=he.folder&&Er[he.folder]||"var(--accent)";return P.jsxs("div",{className:`sound-card ${sn?"playing":""} ${xi?"has-initial":""}`,style:{animationDelay:`${Math.min(X*20,400)}ms`},onClick:Zt=>{const gr=Zt.currentTarget,ui=gr.getBoundingClientRect(),vr=document.createElement("div");vr.className="ripple";const Ps=Math.max(ui.width,ui.height);vr.style.width=vr.style.height=Ps+"px",vr.style.left=Zt.clientX-ui.left-Ps/2+"px",vr.style.top=Zt.clientY-ui.top-Ps/2+"px",gr.appendChild(vr),setTimeout(()=>vr.remove(),500),Ze(he)},onContextMenu:Zt=>{Zt.preventDefault(),Zt.stopPropagation(),In({x:Math.min(Zt.clientX,window.innerWidth-170),y:Math.min(Zt.clientY,window.innerHeight-140),sound:he})},title:`${he.name}${he.folder?` (${he.folder})`:""}`,children:[Tn&&P.jsx("span",{className:"new-badge",children:"NEU"}),P.jsx("span",{className:`fav-star ${en?"active":""}`,onClick:Zt=>{Zt.stopPropagation(),Fn(tt)},children:P.jsx("span",{className:"material-icons fav-icon",children:en?"star":"star_border"})}),xi&&P.jsx("span",{className:"sound-emoji",style:{color:K},children:Rn}),P.jsx("span",{className:"sound-name",children:he.name}),he.folder&&P.jsx("span",{className:"sound-duration",children:he.folder}),P.jsxs("div",{className:"playing-indicator",children:[P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"})]})]},tt)})})}),Jt&&P.jsxs("div",{className:"ctx-menu visible",style:{left:Jt.x,top:Jt.y},onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"ctx-item",onClick:()=>{Ze(Jt.sound),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"play_arrow"}),"Abspielen"]}),P.jsxs("div",{className:"ctx-item",onClick:()=>{Fn(Jt.sound.relativePath??Jt.sound.fileName),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:Se[Jt.sound.relativePath??Jt.sound.fileName]?"star":"star_border"}),"Favorit"]}),Pt&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"ctx-sep"}),P.jsxs("div",{className:"ctx-item danger",onClick:async()=>{const he=Jt.sound.relativePath??Jt.sound.fileName;if(!window.confirm(`Sound "${Jt.sound.name}" loeschen?`)){In(null);return}try{await GAe([he]),ot("Sound geloescht"),Ot(X=>X+1)}catch(X){ot((X==null?void 0:X.message)||"Loeschen fehlgeschlagen","error")}In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"delete"}),"Loeschen"]})]})]}),Ue&&(()=>{const he=Je!=null&&Je.connectedSince?Math.floor((Date.now()-new Date(Je.connectedSince).getTime())/1e3):0,X=Math.floor(he/3600),tt=Math.floor(he%3600/60),en=he%60,sn=X>0?`${X}h ${String(tt).padStart(2,"0")}m ${String(en).padStart(2,"0")}s`:tt>0?`${tt}m ${String(en).padStart(2,"0")}s`:`${en}s`,Tn=Rn=>Rn==null?"var(--muted)":Rn<80?"var(--green)":Rn<150?"#f0a830":"#e04040";return P.jsx("div",{className:"conn-modal-overlay",onClick:()=>ut(!1),children:P.jsxs("div",{className:"conn-modal",onClick:Rn=>Rn.stopPropagation(),children:[P.jsxs("div",{className:"conn-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20,color:"var(--green)"},children:"cell_tower"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"conn-modal-close",onClick:()=>ut(!1),children:P.jsx("span",{className:"material-icons",children:"close"})})]}),P.jsxs("div",{className:"conn-modal-body",children:[P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Voice Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((Je==null?void 0:Je.voicePing)??null)}}),(Je==null?void 0:Je.voicePing)!=null?`${Je.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Gateway Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((Je==null?void 0:Je.gatewayPing)??null)}}),Je&&Je.gatewayPing>=0?`${Je.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Status"}),P.jsx("span",{className:"conn-stat-value",style:{color:(Je==null?void 0:Je.status)==="ready"?"var(--green)":"#f0a830"},children:(Je==null?void 0:Je.status)==="ready"?"Verbunden":(Je==null?void 0:Je.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Kanal"}),P.jsx("span",{className:"conn-stat-value",children:(Je==null?void 0:Je.channelName)||"---"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Verbunden seit"}),P.jsx("span",{className:"conn-stat-value",children:sn||"---"})]})]})]})})})(),Dt&&P.jsxs("div",{className:`toast ${Dt.type}`,children:[P.jsx("span",{className:"material-icons toast-icon",children:Dt.type==="error"?"error_outline":"check_circle"}),Dt.msg]}),We&&P.jsx("div",{className:"drop-overlay",children:P.jsxs("div",{className:"drop-zone",children:[P.jsx("span",{className:"material-icons drop-icon",children:"cloud_upload"}),P.jsx("div",{className:"drop-title",children:"MP3 & WAV hier ablegen"}),P.jsx("div",{className:"drop-sub",children:"Mehrere Dateien gleichzeitig moeglich"})]})}),yt&&fe.length>0&&P.jsxs("div",{className:"upload-queue",children:[P.jsxs("div",{className:"uq-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),P.jsx("span",{children:fe.every(he=>he.status==="done"||he.status==="error")?`${fe.filter(he=>he.status==="done").length} von ${fe.length} hochgeladen`:`Lade hoch… (${fe.filter(he=>he.status==="done").length}/${fe.length})`}),P.jsx("button",{className:"uq-close",onClick:()=>{Gt(!1),Wt([])},children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsx("div",{className:"uq-list",children:fe.map(he=>P.jsxs("div",{className:`uq-item uq-${he.status}`,children:[P.jsx("span",{className:"material-icons uq-file-icon",children:"audio_file"}),P.jsxs("div",{className:"uq-info",children:[P.jsx("div",{className:"uq-name",title:he.savedName??he.file.name,children:he.savedName??he.file.name}),P.jsxs("div",{className:"uq-size",children:[(he.file.size/1024).toFixed(0)," KB"]})]}),(he.status==="waiting"||he.status==="uploading")&&P.jsx("div",{className:"uq-progress-wrap",children:P.jsx("div",{className:"uq-progress-bar",style:{width:`${he.progress}%`}})}),P.jsx("span",{className:`material-icons uq-status-icon uq-status-${he.status}`,children:he.status==="done"?"check_circle":he.status==="error"?"error":he.status==="uploading"?"sync":"schedule"}),he.status==="error"&&P.jsx("div",{className:"uq-error",children:he.error})]},he.id))})]}),Xt.length>0&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>pe==="naming"&&ee(),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:"upload_file"}),P.jsxs("span",{children:[pe==="naming"?"Sound benennen":pe==="uploading"?"Wird hochgeladen...":"Gespeichert!",Xt.length>1&&` (${Ae+1}/${Xt.length})`]}),pe==="naming"&&P.jsx("button",{className:"dl-modal-close",onClick:ee,children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:"dl-modal-tag mp3",children:"Datei"}),P.jsx("span",{className:"dl-modal-url-text",title:(qe=Xt[Ae])==null?void 0:qe.name,children:(qt=Xt[Ae])==null?void 0:qt.name}),P.jsxs("span",{style:{marginLeft:"auto",opacity:.5,fontSize:12},children:[((((Qt=Xt[Ae])==null?void 0:Qt.size)??0)/1024).toFixed(0)," KB"]})]}),pe==="naming"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:"Dateiname eingeben...",value:be,onChange:he=>Oe(he.target.value),onKeyDown:he=>{he.key==="Enter"&&A()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]})]}),pe==="uploading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsxs("span",{children:["Upload: ",Ne,"%"]})]}),pe==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsx("span",{children:"Erfolgreich hochgeladen!"})]})]}),pe==="naming"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:ee,children:Xt.length>1?"Überspringen":"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void A(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),"Hochladen"]})]})]})}),z&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>z.phase!=="downloading"&&G(null),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:z.type==="youtube"?"smart_display":z.type==="instagram"?"photo_camera":"audio_file"}),P.jsx("span",{children:z.phase==="input"?"Sound herunterladen":z.phase==="downloading"?"Wird heruntergeladen...":z.phase==="done"?"Fertig!":"Fehler"}),z.phase!=="downloading"&&P.jsx("button",{className:"dl-modal-close",onClick:()=>G(null),children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:`dl-modal-tag ${z.type??""}`,children:z.type==="youtube"?"YouTube":z.type==="instagram"?"Instagram":"MP3"}),P.jsx("span",{className:"dl-modal-url-text",title:z.url,children:z.url.length>60?z.url.slice(0,57)+"...":z.url})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:z.type==="mp3"?"Dateiname...":"Wird automatisch erkannt...",value:z.filename,onChange:he=>G(X=>X?{...X,filename:he.target.value}:null),onKeyDown:he=>{he.key==="Enter"&&Vt()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]}),P.jsx("span",{className:"dl-modal-hint",children:"Leer lassen = automatischer Name"})]}),z.phase==="downloading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsx("span",{children:z.type==="youtube"||z.type==="instagram"?"Audio wird extrahiert...":"MP3 wird heruntergeladen..."})]}),z.phase==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsxs("span",{children:["Gespeichert als ",P.jsx("b",{children:z.savedName})]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-error",children:[P.jsx("span",{className:"material-icons",style:{color:"#e74c3c"},children:"error"}),P.jsx("span",{children:z.error})]})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void Vt(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"download"}),"Herunterladen"]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Schliessen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>G(he=>he?{...he,phase:"input",error:void 0}:null),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"refresh"}),"Nochmal"]})]})]})})]})}const _7={IRON:"#6b6b6b",BRONZE:"#8c6239",SILVER:"#8c8c8c",GOLD:"#d4a017",PLATINUM:"#28b29e",EMERALD:"#1e9e5e",DIAMOND:"#576cce",MASTER:"#9d48e0",GRANDMASTER:"#e44c3e",CHALLENGER:"#f4c874"},HAe={SOLORANKED:"Ranked Solo",FLEXRANKED:"Ranked Flex",NORMAL:"Normal",ARAM:"ARAM",ARENA:"Arena",URF:"URF",BOT:"Co-op vs AI"},WAe="https://ddragon.leagueoflegends.com/cdn/15.5.1/img";function mm(i){return`${WAe}/champion/${i}.png`}function y7(i){const e=Math.floor((Date.now()-new Date(i).getTime())/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function $Ae(i){const e=Math.floor(i/60),t=i%60;return`${e}:${String(t).padStart(2,"0")}`}function x7(i,e,t){return e===0?"Perfect":((i+t)/e).toFixed(2)}function b7(i,e){const t=i+e;return t>0?Math.round(i/t*100):0}function XAe(i,e){if(!i)return"Unranked";const t=["","I","II","III","IV"];return`${i.charAt(0)}${i.slice(1).toLowerCase()}${e?" "+(t[e]??e):""}`}function YAe({data:i}){var _t,Xt,pt,Ae;const[e,t]=re.useState(""),[n,r]=re.useState("EUW"),[s,a]=re.useState([]),[l,u]=re.useState(null),[h,m]=re.useState([]),[v,x]=re.useState(!1),[S,T]=re.useState(null),[N,C]=re.useState([]),[E,O]=re.useState(null),[U,I]=re.useState({}),[j,z]=re.useState(!1),[G,H]=re.useState(!1),[q,V]=re.useState(null),[Q,J]=re.useState("aram"),[ne,oe]=re.useState("EUW"),[ie,Z]=re.useState([]),[te,de]=re.useState(!1),[Se,Te]=re.useState(null),[ae,Me]=re.useState([]),[Ve,Ce]=re.useState(""),[Fe,et]=re.useState(!1),He=re.useRef(null),Rt=re.useRef(null);re.useEffect(()=>{fetch("/api/lolstats/regions").then(k=>k.json()).then(a).catch(()=>{}),fetch("/api/lolstats/recent").then(k=>k.json()).then(C).catch(()=>{}),fetch("/api/lolstats/modes").then(k=>k.json()).then(Me).catch(()=>{})},[]),re.useEffect(()=>{Q&&(de(!0),Te(null),et(!1),fetch(`/api/lolstats/tierlist?mode=${Q}®ion=${ne}`).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>Z(k.champions??[])).catch(k=>Te(k.message)).finally(()=>de(!1)))},[Q,ne]),re.useEffect(()=>{i&&(i.recentSearches&&C(i.recentSearches),i.regions&&!s.length&&a(i.regions))},[i]);const Et=re.useCallback(async(k,be,Oe)=>{H(!0);try{const pe=`gameName=${encodeURIComponent(k)}&tagLine=${encodeURIComponent(be)}®ion=${Oe}`,le=await fetch(`/api/lolstats/renew?${pe}`,{method:"POST"});if(le.ok){const Ne=await le.json();return Ne.last_updated_at&&V(Ne.last_updated_at),Ne.renewed??!1}}catch{}return H(!1),!1},[]),zt=re.useCallback(async(k,be,Oe,pe=!1)=>{var Je,we;let le=k??"",Ne=be??"";const De=Oe??n;if(!le){const Ue=e.split("#");le=((Je=Ue[0])==null?void 0:Je.trim())??"",Ne=((we=Ue[1])==null?void 0:we.trim())??""}if(!le||!Ne){T("Bitte im Format Name#Tag eingeben");return}x(!0),T(null),u(null),m([]),O(null),I({}),Rt.current={gameName:le,tagLine:Ne,region:De},pe||Et(le,Ne,De).finally(()=>H(!1));try{const Ue=`gameName=${encodeURIComponent(le)}&tagLine=${encodeURIComponent(Ne)}®ion=${De}`,[ut,Dt]=await Promise.all([fetch(`/api/lolstats/profile?${Ue}`),fetch(`/api/lolstats/matches?${Ue}&limit=10`)]);if(!ut.ok){const ct=await ut.json();throw new Error(ct.error??`Fehler ${ut.status}`)}const Bt=await ut.json();if(u(Bt),Bt.updated_at&&V(Bt.updated_at),Dt.ok){const ct=await Dt.json();m(Array.isArray(ct)?ct:[])}}catch(Ue){T(Ue.message)}x(!1)},[e,n,Et]),Pt=re.useCallback(async()=>{const k=Rt.current;if(!(!k||G)){H(!0);try{await Et(k.gameName,k.tagLine,k.region),await new Promise(be=>setTimeout(be,1500)),await zt(k.gameName,k.tagLine,k.region,!0)}finally{H(!1)}}},[Et,zt,G]),We=re.useCallback(async()=>{if(!(!l||j)){z(!0);try{const k=`gameName=${encodeURIComponent(l.game_name)}&tagLine=${encodeURIComponent(l.tagline)}®ion=${n}&limit=20`,be=await fetch(`/api/lolstats/matches?${k}`);if(be.ok){const Oe=await be.json();m(Array.isArray(Oe)?Oe:[])}}catch{}z(!1)}},[l,n,j]),ft=re.useCallback(async k=>{var be;if(E===k.id){O(null);return}if(O(k.id),!(((be=k.participants)==null?void 0:be.length)>=10||U[k.id]))try{const Oe=`region=${n}&createdAt=${encodeURIComponent(k.created_at)}`,pe=await fetch(`/api/lolstats/match/${encodeURIComponent(k.id)}?${Oe}`);if(pe.ok){const le=await pe.json();I(Ne=>({...Ne,[k.id]:le}))}}catch{}},[E,U,n]),fe=re.useCallback(k=>{t(`${k.game_name}#${k.tag_line}`),r(k.region),zt(k.game_name,k.tag_line,k.region)},[zt]),Wt=re.useCallback(k=>{var Oe,pe,le;if(!l)return((Oe=k.participants)==null?void 0:Oe[0])??null;const be=l.game_name.toLowerCase();return((pe=k.participants)==null?void 0:pe.find(Ne=>{var De,Je;return((Je=(De=Ne.summoner)==null?void 0:De.game_name)==null?void 0:Je.toLowerCase())===be}))??((le=k.participants)==null?void 0:le[0])??null},[l]),yt=k=>{var we,Ue,ut;const be=Wt(k);if(!be)return null;const Oe=((we=be.stats)==null?void 0:we.result)==="WIN",pe=x7(be.stats.kill,be.stats.death,be.stats.assist),le=(be.stats.minion_kill??0)+(be.stats.neutral_minion_kill??0),Ne=k.game_length_second>0?(le/(k.game_length_second/60)).toFixed(1):"0",De=E===k.id,Je=U[k.id]??(((Ue=k.participants)==null?void 0:Ue.length)>=10?k:null);return P.jsxs("div",{children:[P.jsxs("div",{className:`lol-match ${Oe?"win":"loss"}`,onClick:()=>ft(k),children:[P.jsx("div",{className:"lol-match-result",children:Oe?"W":"L"}),P.jsxs("div",{className:"lol-match-champ",children:[P.jsx("img",{src:mm(be.champion_name),alt:be.champion_name,title:be.champion_name}),P.jsx("span",{className:"lol-match-champ-level",children:be.stats.champion_level})]}),P.jsxs("div",{className:"lol-match-kda",children:[P.jsxs("div",{className:"lol-match-kda-nums",children:[be.stats.kill,"/",be.stats.death,"/",be.stats.assist]}),P.jsxs("div",{className:`lol-match-kda-ratio ${pe==="Perfect"?"perfect":Number(pe)>=4?"great":""}`,children:[pe," KDA"]})]}),P.jsxs("div",{className:"lol-match-stats",children:[P.jsxs("span",{children:[le," CS (",Ne,"/m)"]}),P.jsxs("span",{children:[be.stats.ward_place," wards"]})]}),P.jsx("div",{className:"lol-match-items",children:(be.items_names??[]).slice(0,7).map((Dt,Bt)=>Dt?P.jsx("img",{src:mm("Aatrox"),alt:Dt,title:Dt,style:{background:"var(--bg-deep)"},onError:ct=>{ct.target.style.display="none"}},Bt):P.jsx("div",{className:"lol-match-item-empty"},Bt))}),P.jsxs("div",{className:"lol-match-meta",children:[P.jsx("div",{className:"lol-match-duration",children:$Ae(k.game_length_second)}),P.jsx("div",{className:"lol-match-queue",children:HAe[k.game_type]??k.game_type}),P.jsxs("div",{className:"lol-match-ago",children:[y7(k.created_at)," ago"]})]})]}),De&&Je&&P.jsx("div",{className:"lol-match-detail",children:Gt(Je,(ut=be.summoner)==null?void 0:ut.game_name)})]},k.id)},Gt=(k,be)=>{var De,Je,we,Ue,ut;const Oe=((De=k.participants)==null?void 0:De.filter(Dt=>Dt.team_key==="BLUE"))??[],pe=((Je=k.participants)==null?void 0:Je.filter(Dt=>Dt.team_key==="RED"))??[],le=(ut=(Ue=(we=k.teams)==null?void 0:we.find(Dt=>Dt.key==="BLUE"))==null?void 0:Ue.game_stat)==null?void 0:ut.is_win,Ne=(Dt,Bt,ct)=>P.jsxs("div",{className:"lol-match-detail-team",children:[P.jsxs("div",{className:`lol-match-detail-team-header ${Bt?"win":"loss"}`,children:[ct," — ",Bt?"Victory":"Defeat"]}),Dt.map((jt,Jt)=>{var Ot,ot,Tt,Ht,Yt,pn,$e,St,Kt,wn,qn,Ze;const In=((ot=(Ot=jt.summoner)==null?void 0:Ot.game_name)==null?void 0:ot.toLowerCase())===(be==null?void 0:be.toLowerCase()),ge=(((Tt=jt.stats)==null?void 0:Tt.minion_kill)??0)+(((Ht=jt.stats)==null?void 0:Ht.neutral_minion_kill)??0);return P.jsxs("div",{className:`lol-detail-row ${In?"me":""}`,children:[P.jsx("img",{className:"lol-detail-champ",src:mm(jt.champion_name),alt:jt.champion_name}),P.jsx("span",{className:"lol-detail-name",title:`${(Yt=jt.summoner)==null?void 0:Yt.game_name}#${(pn=jt.summoner)==null?void 0:pn.tagline}`,children:(($e=jt.summoner)==null?void 0:$e.game_name)??jt.champion_name}),P.jsxs("span",{className:"lol-detail-kda",children:[(St=jt.stats)==null?void 0:St.kill,"/",(Kt=jt.stats)==null?void 0:Kt.death,"/",(wn=jt.stats)==null?void 0:wn.assist]}),P.jsxs("span",{className:"lol-detail-cs",children:[ge," CS"]}),P.jsxs("span",{className:"lol-detail-dmg",children:[((((qn=jt.stats)==null?void 0:qn.total_damage_dealt_to_champions)??0)/1e3).toFixed(1),"k"]}),P.jsxs("span",{className:"lol-detail-gold",children:[((((Ze=jt.stats)==null?void 0:Ze.gold_earned)??0)/1e3).toFixed(1),"k"]})]},Jt)})]});return P.jsxs(P.Fragment,{children:[Ne(Oe,le,"Blue Team"),Ne(pe,le===void 0?void 0:!le,"Red Team")]})};return P.jsxs("div",{className:"lol-container",children:[P.jsxs("div",{className:"lol-search",children:[P.jsx("input",{ref:He,className:"lol-search-input",placeholder:"Summoner Name#Tag",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>k.key==="Enter"&&zt()}),P.jsx("select",{className:"lol-search-region",value:n,onChange:k=>r(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("button",{className:"lol-search-btn",onClick:()=>zt(),disabled:v,children:v?"...":"Search"})]}),N.length>0&&P.jsx("div",{className:"lol-recent",children:N.map((k,be)=>P.jsxs("button",{className:"lol-recent-chip",onClick:()=>fe(k),children:[k.profile_image_url&&P.jsx("img",{src:k.profile_image_url,alt:""}),k.game_name,"#",k.tag_line,k.tier&&P.jsx("span",{className:"lol-recent-tier",style:{color:_7[k.tier]},children:k.tier})]},be))}),S&&P.jsx("div",{className:"lol-error",children:S}),v&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Profil..."]}),l&&!v&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-profile",children:[P.jsx("img",{className:"lol-profile-icon",src:l.profile_image_url,alt:""}),P.jsxs("div",{className:"lol-profile-info",children:[P.jsxs("h2",{children:[l.game_name,P.jsxs("span",{children:["#",l.tagline]})]}),P.jsxs("div",{className:"lol-profile-level",children:["Level ",l.level]}),((_t=l.ladder_rank)==null?void 0:_t.rank)&&P.jsxs("div",{className:"lol-profile-ladder",children:["Ladder Rank #",l.ladder_rank.rank.toLocaleString()," / ",(Xt=l.ladder_rank.total)==null?void 0:Xt.toLocaleString()]}),q&&P.jsxs("div",{className:"lol-profile-updated",children:["Updated ",y7(q)," ago"]})]}),P.jsxs("button",{className:`lol-update-btn ${G?"renewing":""}`,onClick:Pt,disabled:G,title:"Refresh data from Riot servers",children:[P.jsx("span",{className:"lol-update-icon",children:G?"⟳":"↻"}),G?"Updating...":"Update"]})]}),P.jsx("div",{className:"lol-ranked-row",children:(l.league_stats??[]).filter(k=>k.game_type==="SOLORANKED"||k.game_type==="FLEXRANKED").map(k=>{const be=k.tier_info,Oe=!!(be!=null&&be.tier),pe=_7[(be==null?void 0:be.tier)??""]??"var(--text-normal)";return P.jsxs("div",{className:`lol-ranked-card ${Oe?"has-rank":""}`,style:{"--tier-color":pe},children:[P.jsx("div",{className:"lol-ranked-type",children:k.game_type==="SOLORANKED"?"Ranked Solo/Duo":"Ranked Flex"}),Oe?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-ranked-tier",style:{color:pe},children:[XAe(be.tier,be.division),P.jsxs("span",{className:"lol-ranked-lp",children:[be.lp," LP"]})]}),P.jsxs("div",{className:"lol-ranked-record",children:[k.win,"W ",k.lose,"L",P.jsxs("span",{className:"lol-ranked-wr",children:["(",b7(k.win??0,k.lose??0),"%)"]}),k.is_hot_streak&&P.jsx("span",{className:"lol-ranked-streak",children:"🔥"})]})]}):P.jsx("div",{className:"lol-ranked-tier",children:"Unranked"})]},k.game_type)})}),((Ae=(pt=l.most_champions)==null?void 0:pt.champion_stats)==null?void 0:Ae.length)>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Top Champions"}),P.jsx("div",{className:"lol-champs",children:l.most_champions.champion_stats.slice(0,7).map(k=>{const be=b7(k.win,k.lose),Oe=k.play>0?x7(k.kill/k.play,k.death/k.play,k.assist/k.play):"0";return P.jsxs("div",{className:"lol-champ-card",children:[P.jsx("img",{className:"lol-champ-icon",src:mm(k.champion_name),alt:k.champion_name}),P.jsxs("div",{children:[P.jsx("div",{className:"lol-champ-name",children:k.champion_name}),P.jsxs("div",{className:"lol-champ-stats",children:[k.play," games · ",be,"% WR"]}),P.jsxs("div",{className:"lol-champ-kda",children:[Oe," KDA"]})]})]},k.champion_name)})})]}),h.length>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Match History"}),P.jsx("div",{className:"lol-matches",children:h.map(k=>yt(k))}),h.length<20&&P.jsx("button",{className:"lol-load-more",onClick:We,disabled:j,children:j?"Laden...":"Mehr laden"})]})]}),!l&&!v&&!S&&P.jsxs("div",{className:"lol-empty",children:[P.jsx("div",{className:"lol-empty-icon",children:"⚔️"}),P.jsx("h3",{children:"League of Legends Stats"}),P.jsx("p",{children:"Gib einen Summoner Name#Tag ein und wähle die Region"})]}),P.jsxs("div",{className:"lol-tier-section",children:[P.jsx("div",{className:"lol-section-title",children:"Champion Tier List"}),P.jsxs("div",{className:"lol-tier-controls",children:[P.jsx("div",{className:"lol-tier-modes",children:ae.map(k=>P.jsx("button",{className:`lol-tier-mode-btn ${Q===k.key?"active":""}`,onClick:()=>J(k.key),children:k.label},k.key))}),P.jsx("select",{className:"lol-search-region",value:ne,onChange:k=>oe(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("input",{className:"lol-tier-filter",placeholder:"Filter champion...",value:Ve,onChange:k=>Ce(k.target.value)})]}),te&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Tier List..."]}),Se&&P.jsx("div",{className:"lol-error",children:Se}),!te&&!Se&&ie.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-tier-table",children:[P.jsxs("div",{className:"lol-tier-header",children:[P.jsx("span",{className:"lol-tier-col-rank",children:"#"}),P.jsx("span",{className:"lol-tier-col-champ",children:"Champion"}),P.jsx("span",{className:"lol-tier-col-tier",children:"Tier"}),P.jsx("span",{className:"lol-tier-col-wr",children:Q==="arena"?"Win":"Win %"}),P.jsx("span",{className:"lol-tier-col-pr",children:"Pick %"}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:"Ban %"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?"Avg Place":"KDA"})]}),ie.filter(k=>!Ve||k.champion_name.toLowerCase().includes(Ve.toLowerCase())).slice(0,Fe?void 0:50).map(k=>{var Oe,pe;const be=["OP","1","2","3","4","5"];return P.jsxs("div",{className:`lol-tier-row tier-${k.tier}`,children:[P.jsx("span",{className:"lol-tier-col-rank",children:k.rank}),P.jsxs("span",{className:"lol-tier-col-champ",children:[P.jsx("img",{src:mm(k.champion_name),alt:k.champion_name}),k.champion_name]}),P.jsx("span",{className:`lol-tier-col-tier tier-badge-${k.tier}`,children:be[k.tier]??k.tier}),P.jsx("span",{className:"lol-tier-col-wr",children:k.win_rate!=null?`${(k.win_rate*100).toFixed(1)}%`:"-"}),P.jsxs("span",{className:"lol-tier-col-pr",children:[(k.pick_rate*100).toFixed(1),"%"]}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:k.ban_rate!=null?`${(k.ban_rate*100).toFixed(1)}%`:"-"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?((Oe=k.average_placement)==null?void 0:Oe.toFixed(1))??"-":((pe=k.kda)==null?void 0:pe.toFixed(2))??"-"})]},k.champion_id)})]}),!Fe&&ie.length>50&&P.jsxs("button",{className:"lol-load-more",onClick:()=>et(!0),children:["Alle ",ie.length," Champions anzeigen"]})]})]})]})}const S7={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function VS(i){const e=Math.max(0,Math.floor((Date.now()-new Date(i).getTime())/1e3)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}const jS=[{label:"Niedrig · 4 Mbit · 60fps",fps:60,bitrate:4e6},{label:"Mittel · 8 Mbit · 60fps",fps:60,bitrate:8e6},{label:"Hoch · 14 Mbit · 60fps",fps:60,bitrate:14e6},{label:"Ultra · 25 Mbit · 60fps",fps:60,bitrate:25e6},{label:"Max · 50 Mbit · 165fps",fps:165,bitrate:5e7}];function QAe({data:i,isAdmin:e}){var De,Je;const[t,n]=re.useState([]),[r,s]=re.useState(()=>localStorage.getItem("streaming_name")||""),[a,l]=re.useState("Screen Share"),[u,h]=re.useState(""),[m,v]=re.useState(1),[x,S]=re.useState(null),[T,N]=re.useState(null),[C,E]=re.useState(null),[O,U]=re.useState(!1),[I,j]=re.useState(!1),[z,G]=re.useState(null),[,H]=re.useState(0),[q,V]=re.useState(null),[Q,J]=re.useState(null),ne=re.useRef(null),oe=re.useRef(""),ie=re.useRef(null),Z=re.useRef(null),te=re.useRef(null),de=re.useRef(new Map),Se=re.useRef(null),Te=re.useRef(null),ae=re.useRef(new Map),Me=re.useRef(null),Ve=re.useRef(1e3),Ce=re.useRef(!1),Fe=re.useRef(null),et=re.useRef(jS[1]);re.useEffect(()=>{Ce.current=O},[O]),re.useEffect(()=>{Fe.current=z},[z]),re.useEffect(()=>{et.current=jS[m]},[m]),re.useEffect(()=>{var we,Ue;(Ue=(we=window.electronAPI)==null?void 0:we.setStreaming)==null||Ue.call(we,O||z!==null)},[O,z]),re.useEffect(()=>{if(!(t.length>0||O))return;const Ue=setInterval(()=>H(ut=>ut+1),1e3);return()=>clearInterval(Ue)},[t.length,O]),re.useEffect(()=>{i!=null&&i.streams&&n(i.streams)},[i]),re.useEffect(()=>{r&&localStorage.setItem("streaming_name",r)},[r]),re.useEffect(()=>{if(!q)return;const we=()=>V(null);return document.addEventListener("click",we),()=>document.removeEventListener("click",we)},[q]);const He=re.useCallback(we=>{var Ue;((Ue=ne.current)==null?void 0:Ue.readyState)===WebSocket.OPEN&&ne.current.send(JSON.stringify(we))},[]),Rt=re.useCallback((we,Ue,ut)=>{if(we.remoteDescription)we.addIceCandidate(new RTCIceCandidate(ut)).catch(()=>{});else{let Dt=ae.current.get(Ue);Dt||(Dt=[],ae.current.set(Ue,Dt)),Dt.push(ut)}},[]),Et=re.useCallback((we,Ue)=>{const ut=ae.current.get(Ue);if(ut){for(const Dt of ut)we.addIceCandidate(new RTCIceCandidate(Dt)).catch(()=>{});ae.current.delete(Ue)}},[]),zt=re.useCallback((we,Ue)=>{we.srcObject=Ue;const ut=we.play();ut&&ut.catch(()=>{we.muted=!0,we.play().catch(()=>{})})},[]),Pt=re.useCallback(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),Se.current&&(Se.current.close(),Se.current=null),Te.current=null,te.current&&(te.current.srcObject=null)},[]),We=re.useRef(()=>{});We.current=we=>{var Ue,ut,Dt;switch(we.type){case"welcome":oe.current=we.clientId,we.streams&&n(we.streams);break;case"broadcast_started":E(we.streamId),U(!0),Ce.current=!0,j(!1),(Ue=window.electronAPI)!=null&&Ue.showNotification&&window.electronAPI.showNotification("Stream gestartet","Dein Stream ist jetzt live!");break;case"stream_available":n(ct=>ct.some(jt=>jt.id===we.streamId)?ct:[...ct,{id:we.streamId,broadcasterName:we.broadcasterName,title:we.title,startedAt:new Date().toISOString(),viewerCount:0,hasPassword:!!we.hasPassword}]);const Bt=`${we.broadcasterName} streamt: ${we.title}`;(ut=window.electronAPI)!=null&&ut.showNotification?window.electronAPI.showNotification("Neuer Stream",Bt):Notification.permission==="granted"&&new Notification("Neuer Stream",{body:Bt,icon:"/assets/icon.png"});break;case"stream_ended":n(ct=>ct.filter(jt=>jt.id!==we.streamId)),((Dt=Fe.current)==null?void 0:Dt.streamId)===we.streamId&&(Pt(),G(null));break;case"viewer_joined":{const ct=we.viewerId,jt=de.current.get(ct);jt&&(jt.close(),de.current.delete(ct)),ae.current.delete(ct);const Jt=new RTCPeerConnection(S7);de.current.set(ct,Jt);const In=ie.current;if(In)for(const Ot of In.getTracks())Jt.addTrack(Ot,In);Jt.onicecandidate=Ot=>{Ot.candidate&&He({type:"ice_candidate",targetId:ct,candidate:Ot.candidate.toJSON()})};const ge=Jt.getSenders().find(Ot=>{var ot;return((ot=Ot.track)==null?void 0:ot.kind)==="video"});if(ge){const Ot=ge.getParameters();(!Ot.encodings||Ot.encodings.length===0)&&(Ot.encodings=[{}]),Ot.encodings[0].maxFramerate=et.current.fps,Ot.encodings[0].maxBitrate=et.current.bitrate,ge.setParameters(Ot).catch(()=>{})}Jt.createOffer().then(Ot=>Jt.setLocalDescription(Ot)).then(()=>He({type:"offer",targetId:ct,sdp:Jt.localDescription})).catch(console.error);break}case"viewer_left":{const ct=de.current.get(we.viewerId);ct&&(ct.close(),de.current.delete(we.viewerId)),ae.current.delete(we.viewerId);break}case"offer":{const ct=we.fromId;Se.current&&(Se.current.close(),Se.current=null),ae.current.delete(ct);const jt=new RTCPeerConnection(S7);Se.current=jt,jt.ontrack=Jt=>{const In=Jt.streams[0];if(!In)return;Te.current=In;const ge=te.current;ge&&zt(ge,In),G(Ot=>Ot&&{...Ot,phase:"connected"})},jt.onicecandidate=Jt=>{Jt.candidate&&He({type:"ice_candidate",targetId:ct,candidate:Jt.candidate.toJSON()})},jt.oniceconnectionstatechange=()=>{(jt.iceConnectionState==="failed"||jt.iceConnectionState==="disconnected")&&G(Jt=>Jt&&{...Jt,phase:"error",error:"Verbindung verloren"})},jt.setRemoteDescription(new RTCSessionDescription(we.sdp)).then(()=>(Et(jt,ct),jt.createAnswer())).then(Jt=>jt.setLocalDescription(Jt)).then(()=>He({type:"answer",targetId:ct,sdp:jt.localDescription})).catch(console.error);break}case"answer":{const ct=de.current.get(we.fromId);ct&&ct.setRemoteDescription(new RTCSessionDescription(we.sdp)).then(()=>Et(ct,we.fromId)).catch(console.error);break}case"ice_candidate":{if(!we.candidate)break;const ct=de.current.get(we.fromId);ct?Rt(ct,we.fromId,we.candidate):Se.current&&Rt(Se.current,we.fromId,we.candidate);break}case"error":we.code==="WRONG_PASSWORD"?N(ct=>ct&&{...ct,error:we.message}):S(we.message),j(!1);break}};const ft=re.useCallback(()=>{if(ne.current&&ne.current.readyState===WebSocket.OPEN)return;const we=location.protocol==="https:"?"wss":"ws",Ue=new WebSocket(`${we}://${location.host}/ws/streaming`);ne.current=Ue,Ue.onopen=()=>{Ve.current=1e3},Ue.onmessage=ut=>{let Dt;try{Dt=JSON.parse(ut.data)}catch{return}We.current(Dt)},Ue.onclose=()=>{ne.current=null,Me.current=setTimeout(()=>{Ve.current=Math.min(Ve.current*2,1e4),ft()},Ve.current)},Ue.onerror=()=>{Ue.close()}},[]);re.useEffect(()=>(ft(),()=>{Me.current&&clearTimeout(Me.current)}),[ft]);const fe=re.useCallback(async()=>{var we,Ue;if(!r.trim()){S("Bitte gib einen Namen ein.");return}if(!((we=navigator.mediaDevices)!=null&&we.getDisplayMedia)){S("Dein Browser unterstützt keine Bildschirmfreigabe.");return}S(null),j(!0);try{const ut=et.current,Dt=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:ut.fps}},audio:!0});ie.current=Dt,Z.current&&(Z.current.srcObject=Dt),(Ue=Dt.getVideoTracks()[0])==null||Ue.addEventListener("ended",()=>{Wt()}),ft();const Bt=()=>{var ct;((ct=ne.current)==null?void 0:ct.readyState)===WebSocket.OPEN?He({type:"start_broadcast",name:r.trim(),title:a.trim()||"Screen Share",password:u.trim()||void 0}):setTimeout(Bt,100)};Bt()}catch(ut){j(!1),ut.name==="NotAllowedError"?S("Bildschirmfreigabe wurde abgelehnt."):S(`Fehler: ${ut.message}`)}},[r,a,u,ft,He]),Wt=re.useCallback(()=>{var we;He({type:"stop_broadcast"}),(we=ie.current)==null||we.getTracks().forEach(Ue=>Ue.stop()),ie.current=null,Z.current&&(Z.current.srcObject=null);for(const Ue of de.current.values())Ue.close();de.current.clear(),U(!1),Ce.current=!1,E(null),h("")},[He]),yt=re.useCallback(we=>{S(null),G({streamId:we,phase:"connecting"}),ft();const Ue=()=>{var ut;((ut=ne.current)==null?void 0:ut.readyState)===WebSocket.OPEN?He({type:"join_viewer",name:r.trim()||"Viewer",streamId:we}):setTimeout(Ue,100)};Ue()},[r,ft,He]),Gt=re.useCallback(we=>{we.hasPassword?N({streamId:we.id,streamTitle:we.title,broadcasterName:we.broadcasterName,password:"",error:null}):yt(we.id)},[yt]),_t=re.useCallback(()=>{if(!T)return;if(!T.password.trim()){N(Dt=>Dt&&{...Dt,error:"Passwort eingeben."});return}const{streamId:we,password:Ue}=T;N(null),S(null),G({streamId:we,phase:"connecting"}),ft();const ut=()=>{var Dt;((Dt=ne.current)==null?void 0:Dt.readyState)===WebSocket.OPEN?He({type:"join_viewer",name:r.trim()||"Viewer",streamId:we,password:Ue.trim()}):setTimeout(ut,100)};ut()},[T,r,ft,He]),Xt=re.useCallback(()=>{He({type:"leave_viewer"}),Pt(),G(null)},[Pt,He]);re.useEffect(()=>{const we=ut=>{(Ce.current||Fe.current)&&ut.preventDefault()},Ue=()=>{oe.current&&navigator.sendBeacon("/api/streaming/disconnect",JSON.stringify({clientId:oe.current}))};return window.addEventListener("beforeunload",we),window.addEventListener("pagehide",Ue),()=>{window.removeEventListener("beforeunload",we),window.removeEventListener("pagehide",Ue)}},[]);const pt=re.useRef(null),[Ae,k]=re.useState(!1),be=re.useCallback(()=>{const we=pt.current;we&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):we.requestFullscreen().catch(()=>{}))},[]);re.useEffect(()=>{const we=()=>k(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",we),()=>document.removeEventListener("fullscreenchange",we)},[]),re.useEffect(()=>()=>{var we;(we=ie.current)==null||we.getTracks().forEach(Ue=>Ue.stop());for(const Ue of de.current.values())Ue.close();Se.current&&Se.current.close(),ne.current&&ne.current.close(),Me.current&&clearTimeout(Me.current)},[]),re.useEffect(()=>{z&&Te.current&&te.current&&!te.current.srcObject&&zt(te.current,Te.current)},[z,zt]);const Oe=re.useRef(null);re.useEffect(()=>{const Ue=new URLSearchParams(location.search).get("viewStream");if(Ue){Oe.current=Ue;const ut=new URL(location.href);ut.searchParams.delete("viewStream"),window.history.replaceState({},"",ut.toString())}},[]),re.useEffect(()=>{const we=Oe.current;if(!we||t.length===0)return;const Ue=t.find(ut=>ut.id===we);Ue&&(Oe.current=null,Gt(Ue))},[t,Gt]);const pe=re.useCallback(we=>{const Ue=new URL(location.href);return Ue.searchParams.set("viewStream",we),Ue.hash="",Ue.toString()},[]),le=re.useCallback(we=>{navigator.clipboard.writeText(pe(we)).then(()=>{J(we),setTimeout(()=>J(null),2e3)}).catch(()=>{})},[pe]),Ne=re.useCallback(we=>{window.open(pe(we),"_blank","noopener"),V(null)},[pe]);if(z){const we=t.find(Ue=>Ue.id===z.streamId);return P.jsxs("div",{className:"stream-viewer-overlay",ref:pt,children:[P.jsxs("div",{className:"stream-viewer-header",children:[P.jsxs("div",{className:"stream-viewer-header-left",children:[P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("div",{children:[P.jsx("div",{className:"stream-viewer-title",children:(we==null?void 0:we.title)||"Stream"}),P.jsxs("div",{className:"stream-viewer-subtitle",children:[(we==null?void 0:we.broadcasterName)||"..."," ",we?` · ${we.viewerCount} Zuschauer`:""]})]})]}),P.jsxs("div",{className:"stream-viewer-header-right",children:[P.jsx("button",{className:"stream-viewer-fullscreen",onClick:be,title:Ae?"Vollbild verlassen":"Vollbild",children:Ae?"✖":"⛶"}),P.jsx("button",{className:"stream-viewer-close",onClick:Xt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"stream-viewer-video",children:[z.phase==="connecting"?P.jsxs("div",{className:"stream-viewer-connecting",children:[P.jsx("div",{className:"stream-viewer-spinner"}),"Verbindung wird hergestellt..."]}):z.phase==="error"?P.jsxs("div",{className:"stream-viewer-connecting",children:[z.error||"Verbindungsfehler",P.jsx("button",{className:"stream-btn",onClick:Xt,children:"Zurück"})]}):null,P.jsx("video",{ref:te,autoPlay:!0,playsInline:!0,style:z.phase==="connected"?{}:{display:"none"}})]})]})}return P.jsxs("div",{className:"stream-container",children:[x&&P.jsxs("div",{className:"stream-error",children:[x,P.jsx("button",{className:"stream-error-dismiss",onClick:()=>S(null),children:"×"})]}),P.jsxs("div",{className:"stream-topbar",children:[P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Name"}),P.jsx("input",{className:"stream-input stream-input-name",placeholder:"Dein Name",value:r,onChange:we=>s(we.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field stream-field-grow",children:[P.jsx("span",{className:"stream-field-label",children:"Titel"}),P.jsx("input",{className:"stream-input stream-input-title",placeholder:"Stream-Titel",value:a,onChange:we=>l(we.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Passwort"}),P.jsx("input",{className:"stream-input stream-input-password",type:"password",placeholder:"optional",value:u,onChange:we=>h(we.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsxs("span",{className:"stream-field-label",children:["Qualit","ä","t"]}),P.jsx("select",{className:"stream-select-quality",value:m,onChange:we=>v(Number(we.target.value)),disabled:O,children:jS.map((we,Ue)=>P.jsx("option",{value:Ue,children:we.label},we.label))})]}),O?P.jsxs("button",{className:"stream-btn stream-btn-stop",onClick:Wt,children:["⏹"," Stream beenden"]}):P.jsx("button",{className:"stream-btn",onClick:fe,disabled:I,children:I?"Starte...":"🖥️ Stream starten"})]}),t.length===0&&!O?P.jsxs("div",{className:"stream-empty",children:[P.jsx("div",{className:"stream-empty-icon",children:"📺"}),P.jsx("h3",{children:"Keine aktiven Streams"}),P.jsx("p",{children:"Starte einen Stream, um deinen Bildschirm zu teilen."})]}):P.jsxs("div",{className:"stream-grid",children:[O&&P.jsxs("div",{className:"stream-tile own broadcasting",children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("video",{ref:Z,autoPlay:!0,playsInline:!0,muted:!0}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",((De=t.find(we=>we.id===C))==null?void 0:De.viewerCount)??0]})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsxs("div",{className:"stream-tile-name",children:[r," (Du)"]}),P.jsx("div",{className:"stream-tile-title",children:a})]}),P.jsx("span",{className:"stream-tile-time",children:C&&((Je=t.find(we=>we.id===C))!=null&&Je.startedAt)?VS(t.find(we=>we.id===C).startedAt):"0:00"})]})]}),t.filter(we=>we.id!==C).map(we=>P.jsxs("div",{className:"stream-tile",onClick:()=>Gt(we),children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("span",{className:"stream-tile-icon",children:"🖥️"}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",we.viewerCount]}),we.hasPassword&&P.jsx("span",{className:"stream-tile-lock",children:"🔒"})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsx("div",{className:"stream-tile-name",children:we.broadcasterName}),P.jsx("div",{className:"stream-tile-title",children:we.title})]}),P.jsx("span",{className:"stream-tile-time",children:VS(we.startedAt)}),P.jsxs("div",{className:"stream-tile-menu-wrap",children:[P.jsx("button",{className:"stream-tile-menu",onClick:Ue=>{Ue.stopPropagation(),V(q===we.id?null:we.id)},children:"⋮"}),q===we.id&&P.jsxs("div",{className:"stream-tile-dropdown",onClick:Ue=>Ue.stopPropagation(),children:[P.jsxs("div",{className:"stream-tile-dropdown-header",children:[P.jsx("div",{className:"stream-tile-dropdown-name",children:we.broadcasterName}),P.jsx("div",{className:"stream-tile-dropdown-title",children:we.title}),P.jsxs("div",{className:"stream-tile-dropdown-detail",children:["👥"," ",we.viewerCount," Zuschauer · ",VS(we.startedAt)]})]}),P.jsx("div",{className:"stream-tile-dropdown-divider"}),P.jsxs("button",{className:"stream-tile-dropdown-item",onClick:()=>Ne(we.id),children:["🗗"," In neuem Fenster öffnen"]}),P.jsx("button",{className:"stream-tile-dropdown-item",onClick:()=>{le(we.id),V(null)},children:Q===we.id?"✅ Kopiert!":"🔗 Link teilen"})]})]})]})]},we.id))]}),T&&P.jsx("div",{className:"stream-pw-overlay",onClick:()=>N(null),children:P.jsxs("div",{className:"stream-pw-modal",onClick:we=>we.stopPropagation(),children:[P.jsx("h3",{children:T.broadcasterName}),P.jsx("p",{children:T.streamTitle}),T.error&&P.jsx("div",{className:"stream-pw-modal-error",children:T.error}),P.jsx("input",{className:"stream-input",type:"password",placeholder:"Stream-Passwort",value:T.password,onChange:we=>N(Ue=>Ue&&{...Ue,password:we.target.value,error:null}),onKeyDown:we=>{we.key==="Enter"&&_t()},autoFocus:!0}),P.jsxs("div",{className:"stream-pw-actions",children:[P.jsx("button",{className:"stream-pw-cancel",onClick:()=>N(null),children:"Abbrechen"}),P.jsx("button",{className:"stream-btn",onClick:_t,children:"Beitreten"})]})]})})]})}function w7(i){const e=Math.floor(i),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function KAe(i){const e=i.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(e)return{type:"youtube",videoId:e[1]};const t=i.match(/(?:dailymotion\.com\/video\/|dai\.ly\/)([a-zA-Z0-9]+)/);return t?{type:"dailymotion",videoId:t[1]}:/\.(mp4|webm|ogg)(\?|$)/i.test(i)||i.startsWith("http")?{type:"direct",url:i}:null}function ZAe({data:i}){var pn;const[e,t]=re.useState([]),[n,r]=re.useState(()=>localStorage.getItem("wt_name")||""),[s,a]=re.useState(""),[l,u]=re.useState(""),[h,m]=re.useState(null),[v,x]=re.useState(null),[S,T]=re.useState(null),[N,C]=re.useState(""),[E,O]=re.useState(()=>{const $e=localStorage.getItem("wt_volume");return $e?parseFloat($e):1}),[U,I]=re.useState(!1),[j,z]=re.useState(0),[G,H]=re.useState(0),[q,V]=re.useState(null),[Q,J]=re.useState(!1),[ne,oe]=re.useState([]),[ie,Z]=re.useState(""),[te,de]=re.useState(null),[Se,Te]=re.useState("synced"),[ae,Me]=re.useState(!0),[Ve,Ce]=re.useState(()=>localStorage.getItem("wt_yt_quality")||"hd1080"),Fe=re.useRef(null),et=re.useRef(""),He=re.useRef(null),Rt=re.useRef(1e3),Et=re.useRef(null),zt=re.useRef(null),Pt=re.useRef(null),We=re.useRef(null),ft=re.useRef(null),fe=re.useRef(null),Wt=re.useRef(!1),yt=re.useRef(!1),Gt=re.useRef(null),_t=re.useRef(null),Xt=re.useRef(Ve),pt=re.useRef(null),Ae=re.useRef(!1),k=re.useRef(0),be=re.useRef(0);re.useEffect(()=>{Et.current=h},[h]);const Oe=h!=null&&et.current===h.hostId;re.useEffect(()=>{Xt.current=Ve,localStorage.setItem("wt_yt_quality",Ve),Pt.current&&typeof Pt.current.setPlaybackQuality=="function"&&Pt.current.setPlaybackQuality(Ve)},[Ve]),re.useEffect(()=>{i!=null&&i.rooms&&t(i.rooms)},[i]),re.useEffect(()=>{var $e;($e=_t.current)==null||$e.scrollIntoView({behavior:"smooth"})},[ne]),re.useEffect(()=>{const St=new URLSearchParams(window.location.search).get("wt");if(St&&n.trim()){const Kt=setTimeout(()=>ut(St),1500);return()=>clearTimeout(Kt)}},[]),re.useEffect(()=>{n&&localStorage.setItem("wt_name",n)},[n]),re.useEffect(()=>{var $e;localStorage.setItem("wt_volume",String(E)),Pt.current&&typeof Pt.current.setVolume=="function"&&Pt.current.setVolume(E*100),We.current&&(We.current.volume=E),($e=pt.current)!=null&&$e.contentWindow&&fe.current==="dailymotion"&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com")},[E]),re.useEffect(()=>{if(window.YT){Wt.current=!0;return}const $e=document.createElement("script");$e.src="https://www.youtube.com/iframe_api",document.head.appendChild($e);const St=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{Wt.current=!0,St&&St()}},[]);const pe=re.useCallback($e=>{var St;((St=Fe.current)==null?void 0:St.readyState)===WebSocket.OPEN&&Fe.current.send(JSON.stringify($e))},[]),le=re.useCallback(()=>fe.current==="youtube"&&Pt.current&&typeof Pt.current.getCurrentTime=="function"?Pt.current.getCurrentTime():fe.current==="direct"&&We.current?We.current.currentTime:fe.current==="dailymotion"?k.current:null,[]);re.useCallback(()=>fe.current==="youtube"&&Pt.current&&typeof Pt.current.getDuration=="function"?Pt.current.getDuration()||0:fe.current==="direct"&&We.current?We.current.duration||0:fe.current==="dailymotion"?be.current:0,[]);const Ne=re.useCallback(()=>{if(Pt.current){try{Pt.current.destroy()}catch{}Pt.current=null}We.current&&(We.current.pause(),We.current.removeAttribute("src"),We.current.load()),pt.current&&(pt.current.src="",Ae.current=!1,k.current=0,be.current=0),fe.current=null,Gt.current&&(clearInterval(Gt.current),Gt.current=null)},[]),De=re.useCallback($e=>{Ne(),V(null);const St=KAe($e);if(St)if(St.type==="youtube"){if(fe.current="youtube",!Wt.current||!ft.current)return;const Kt=ft.current,wn=document.createElement("div");wn.id="wt-yt-player-"+Date.now(),Kt.innerHTML="",Kt.appendChild(wn),Pt.current=new window.YT.Player(wn.id,{videoId:St.videoId,playerVars:{autoplay:1,controls:0,modestbranding:1,rel:0},events:{onReady:qn=>{qn.target.setVolume(E*100),qn.target.setPlaybackQuality(Xt.current),z(qn.target.getDuration()||0),Gt.current=setInterval(()=>{Pt.current&&typeof Pt.current.getCurrentTime=="function"&&(H(Pt.current.getCurrentTime()),z(Pt.current.getDuration()||0))},500)},onStateChange:qn=>{if(qn.data===window.YT.PlayerState.ENDED){const Ze=Et.current;Ze&&et.current===Ze.hostId&&pe({type:"skip"})}},onError:qn=>{const Ze=qn.data;V(Ze===101||Ze===150?"Embedding deaktiviert — Video kann nur auf YouTube angesehen werden.":Ze===100?"Video nicht gefunden oder entfernt.":"Wiedergabefehler — Video wird übersprungen."),setTimeout(()=>{const dt=Et.current;dt&&et.current===dt.hostId&&pe({type:"skip"})},3e3)}}})}else St.type==="dailymotion"?(fe.current="dailymotion",pt.current&&(pt.current.src=`https://www.dailymotion.com/embed/video/${St.videoId}?api=postMessage&autoplay=1&controls=0&mute=0&queue-enable=0`)):(fe.current="direct",We.current&&(We.current.src=St.url,We.current.volume=E,We.current.play().catch(()=>{})))},[Ne,E,pe]);re.useEffect(()=>{const $e=We.current;if(!$e)return;const St=()=>{const wn=Et.current;wn&&et.current===wn.hostId&&pe({type:"skip"})},Kt=()=>{H($e.currentTime),z($e.duration||0)};return $e.addEventListener("ended",St),$e.addEventListener("timeupdate",Kt),()=>{$e.removeEventListener("ended",St),$e.removeEventListener("timeupdate",Kt)}},[pe]),re.useEffect(()=>{const $e=St=>{var Ze;if(St.origin!=="https://www.dailymotion.com"||typeof St.data!="string")return;const Kt=new URLSearchParams(St.data),wn=Kt.get("method"),qn=Kt.get("value");if(wn==="timeupdate"&&qn){const dt=parseFloat(qn);k.current=dt,H(dt)}else if(wn==="durationchange"&&qn){const dt=parseFloat(qn);be.current=dt,z(dt)}else if(wn==="ended"){const dt=Et.current;dt&&et.current===dt.hostId&&pe({type:"skip"})}else wn==="apiready"&&(Ae.current=!0,(Ze=pt.current)!=null&&Ze.contentWindow&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com"))};return window.addEventListener("message",$e),()=>window.removeEventListener("message",$e)},[pe,E]);const Je=re.useRef(()=>{});Je.current=$e=>{var St,Kt,wn,qn,Ze,dt,Vt,xt,A,ee,Vn,Wn,$n,dn,Fn,lr;switch($e.type){case"welcome":et.current=$e.clientId,$e.rooms&&t($e.rooms);break;case"room_created":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]});break}case"room_joined":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]}),(St=an.currentVideo)!=null&&St.url&&setTimeout(()=>De(an.currentVideo.url),100);break}case"playback_state":{const an=Et.current;if(!an)break;const mn=$e.currentVideo,Er=(Kt=an.currentVideo)==null?void 0:Kt.url;if(mn!=null&&mn.url&&mn.url!==Er?De(mn.url):!mn&&Er&&Ne(),fe.current==="youtube"&&Pt.current){const Wi=(qn=(wn=Pt.current).getPlayerState)==null?void 0:qn.call(wn);$e.playing&&Wi!==((dt=(Ze=window.YT)==null?void 0:Ze.PlayerState)==null?void 0:dt.PLAYING)?(xt=(Vt=Pt.current).playVideo)==null||xt.call(Vt):!$e.playing&&Wi===((ee=(A=window.YT)==null?void 0:A.PlayerState)==null?void 0:ee.PLAYING)&&((Wn=(Vn=Pt.current).pauseVideo)==null||Wn.call(Vn))}else fe.current==="direct"&&We.current?$e.playing&&We.current.paused?We.current.play().catch(()=>{}):!$e.playing&&!We.current.paused&&We.current.pause():fe.current==="dailymotion"&&(($n=pt.current)!=null&&$n.contentWindow)&&($e.playing?pt.current.contentWindow.postMessage("play","https://www.dailymotion.com"):pt.current.contentWindow.postMessage("pause","https://www.dailymotion.com"));if($e.currentTime!==void 0&&!yt.current){const Wi=le();Wi!==null&&Math.abs(Wi-$e.currentTime)>2&&(fe.current==="youtube"&&Pt.current?(Fn=(dn=Pt.current).seekTo)==null||Fn.call(dn,$e.currentTime,!0):fe.current==="direct"&&We.current?We.current.currentTime=$e.currentTime:fe.current==="dailymotion"&&((lr=pt.current)!=null&&lr.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e.currentTime}`,"https://www.dailymotion.com"))}if($e.currentTime!==void 0){const Wi=le();if(Wi!==null){const No=Math.abs(Wi-$e.currentTime);No<1.5?Te("synced"):No<5?Te("drifting"):Te("desynced")}}m(Wi=>Wi&&{...Wi,currentVideo:mn||null,playing:$e.playing,currentTime:$e.currentTime??Wi.currentTime});break}case"queue_updated":m(an=>an&&{...an,queue:$e.queue});break;case"members_updated":m(an=>an&&{...an,members:$e.members,hostId:$e.hostId});break;case"vote_updated":de($e.votes);break;case"chat":oe(an=>{const mn=[...an,{sender:$e.sender,text:$e.text,timestamp:$e.timestamp}];return mn.length>100?mn.slice(-100):mn});break;case"chat_history":oe($e.messages||[]);break;case"error":$e.code==="WRONG_PASSWORD"?x(an=>an&&{...an,error:$e.message}):T($e.message);break}};const we=re.useCallback(()=>{if(Fe.current&&(Fe.current.readyState===WebSocket.OPEN||Fe.current.readyState===WebSocket.CONNECTING))return;const $e=location.protocol==="https:"?"wss":"ws",St=new WebSocket(`${$e}://${location.host}/ws/watch-together`);Fe.current=St,St.onopen=()=>{Rt.current=1e3},St.onmessage=Kt=>{let wn;try{wn=JSON.parse(Kt.data)}catch{return}Je.current(wn)},St.onclose=()=>{Fe.current===St&&(Fe.current=null),Et.current&&(He.current=setTimeout(()=>{Rt.current=Math.min(Rt.current*2,1e4),we()},Rt.current))},St.onerror=()=>{St.close()}},[]),Ue=re.useCallback(()=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}if(!s.trim()){T("Bitte gib einen Raumnamen ein.");return}T(null),we();const $e=Date.now(),St=()=>{var Kt;((Kt=Fe.current)==null?void 0:Kt.readyState)===WebSocket.OPEN?pe({type:"create_room",name:s.trim(),userName:n.trim(),password:l.trim()||void 0}):Date.now()-$e>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(St,100)};St()},[n,s,l,we,pe]),ut=re.useCallback(($e,St)=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}T(null),we();const Kt=Date.now(),wn=()=>{var qn;((qn=Fe.current)==null?void 0:qn.readyState)===WebSocket.OPEN?pe({type:"join_room",userName:n.trim(),roomId:$e,password:(St==null?void 0:St.trim())||void 0}):Date.now()-Kt>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(wn,100)};wn()},[n,we,pe]),Dt=re.useCallback(()=>{pe({type:"leave_room"}),Ne(),m(null),C(""),z(0),H(0),oe([]),de(null),Te("synced")},[pe,Ne]),Bt=re.useCallback(async()=>{const $e=N.trim();if(!$e)return;C(""),J(!0);let St="";try{const Kt=await fetch(`/api/watch-together/video-info?url=${encodeURIComponent($e)}`);Kt.ok&&(St=(await Kt.json()).title||"")}catch{}pe({type:"add_to_queue",url:$e,title:St||void 0}),J(!1)},[N,pe]),ct=re.useCallback(()=>{const $e=ie.trim();$e&&(Z(""),pe({type:"chat_message",text:$e}))},[ie,pe]);re.useCallback(()=>{pe({type:"vote_skip"})},[pe]),re.useCallback(()=>{pe({type:"vote_pause"})},[pe]);const jt=re.useCallback(()=>{pe({type:"clear_watched"})},[pe]),Jt=re.useCallback(()=>{if(!h)return;const $e=`${window.location.origin}${window.location.pathname}?wt=${h.id}`;navigator.clipboard.writeText($e).catch(()=>{})},[h]),In=re.useCallback($e=>{pe({type:"remove_from_queue",index:$e})},[pe]),ge=re.useCallback(()=>{const $e=Et.current;$e&&pe({type:$e.playing?"pause":"resume"})},[pe]),Ot=re.useCallback(()=>{pe({type:"skip"})},[pe]),ot=re.useCallback($e=>{var St,Kt,wn;yt.current=!0,pe({type:"seek",time:$e}),fe.current==="youtube"&&Pt.current?(Kt=(St=Pt.current).seekTo)==null||Kt.call(St,$e,!0):fe.current==="direct"&&We.current?We.current.currentTime=$e:fe.current==="dailymotion"&&((wn=pt.current)!=null&&wn.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e}`,"https://www.dailymotion.com"),H($e),setTimeout(()=>{yt.current=!1},3e3)},[pe]);re.useEffect(()=>{if(!Oe||!(h!=null&&h.playing))return;const $e=setInterval(()=>{const St=le();St!==null&&pe({type:"report_time",time:St})},2e3);return()=>clearInterval($e)},[Oe,h==null?void 0:h.playing,pe,le]);const Tt=re.useCallback(()=>{const $e=zt.current;$e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):$e.requestFullscreen().catch(()=>{}))},[]);re.useEffect(()=>{const $e=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$e),()=>document.removeEventListener("fullscreenchange",$e)},[]),re.useEffect(()=>{const $e=Kt=>{Et.current&&Kt.preventDefault()},St=()=>{et.current&&navigator.sendBeacon("/api/watch-together/disconnect",JSON.stringify({clientId:et.current}))};return window.addEventListener("beforeunload",$e),window.addEventListener("pagehide",St),()=>{window.removeEventListener("beforeunload",$e),window.removeEventListener("pagehide",St)}},[]),re.useEffect(()=>()=>{Ne(),Fe.current&&Fe.current.close(),He.current&&clearTimeout(He.current)},[Ne]);const Ht=re.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(Kt=>Kt&&{...Kt,error:"Passwort eingeben."});return}const{roomId:$e,password:St}=v;x(null),ut($e,St)},[v,ut]),Yt=re.useCallback($e=>{$e.hasPassword?x({roomId:$e.id,roomName:$e.name,password:"",error:null}):ut($e.id)},[ut]);if(h){const $e=h.members.find(St=>St.id===h.hostId);return P.jsxs("div",{className:"wt-room-overlay",ref:zt,children:[P.jsxs("div",{className:"wt-room-header",children:[P.jsxs("div",{className:"wt-room-header-left",children:[P.jsx("span",{className:"wt-room-name",children:h.name}),P.jsxs("span",{className:"wt-room-members",children:[h.members.length," Mitglieder"]}),$e&&P.jsxs("span",{className:"wt-host-badge",children:["Host: ",$e.name]})]}),P.jsxs("div",{className:"wt-room-header-right",children:[P.jsx("div",{className:`wt-sync-dot wt-sync-${Se}`,title:Se==="synced"?"Synchron":Se==="drifting"?"Leichte Verzögerung":"Nicht synchron"}),P.jsx("button",{className:"wt-header-btn",onClick:Jt,title:"Link kopieren",children:"Link"}),P.jsx("button",{className:"wt-header-btn",onClick:()=>Me(St=>!St),title:ae?"Chat ausblenden":"Chat einblenden",children:"Chat"}),P.jsx("button",{className:"wt-fullscreen-btn",onClick:Tt,title:U?"Vollbild verlassen":"Vollbild",children:U?"✖":"⛶"}),P.jsx("button",{className:"wt-leave-btn",onClick:Dt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"wt-room-body",children:[P.jsxs("div",{className:"wt-player-section",children:[P.jsxs("div",{className:"wt-player-wrap",children:[P.jsx("div",{ref:ft,className:"wt-yt-container",style:fe.current==="youtube"?{}:{display:"none"}}),P.jsx("video",{ref:We,className:"wt-video-element",style:fe.current==="direct"?{}:{display:"none"},playsInline:!0}),P.jsx("iframe",{ref:pt,className:"wt-dm-container",style:fe.current==="dailymotion"?{}:{display:"none"},allow:"autoplay; fullscreen",allowFullScreen:!0}),q&&P.jsxs("div",{className:"wt-player-error",children:[P.jsx("div",{className:"wt-error-icon",children:"⚠️"}),P.jsx("p",{children:q}),((pn=h.currentVideo)==null?void 0:pn.url)&&P.jsx("a",{className:"wt-yt-link",href:h.currentVideo.url,target:"_blank",rel:"noopener noreferrer",children:"Auf YouTube öffnen ↗"}),P.jsx("p",{className:"wt-skip-info",children:"Wird in 3 Sekunden übersprungen..."})]}),!h.currentVideo&&P.jsxs("div",{className:"wt-player-placeholder",children:[P.jsx("div",{className:"wt-placeholder-icon",children:"🎬"}),P.jsx("p",{children:"Fuege ein Video zur Warteschlange hinzu"})]})]}),P.jsxs("div",{className:"wt-controls",children:[P.jsx("button",{className:"wt-ctrl-btn",onClick:ge,disabled:!h.currentVideo,title:h.playing?"Pause":"Abspielen",children:h.playing?"⏸":"▶"}),P.jsxs("button",{className:"wt-ctrl-btn wt-next-btn",onClick:Ot,disabled:!h.currentVideo&&h.queue.length===0,title:"Nächstes Video",children:["⏭"," Weiter"]}),P.jsx("input",{className:"wt-seek",type:"range",min:0,max:j||0,step:.5,value:G,onChange:St=>ot(parseFloat(St.target.value)),disabled:!h.currentVideo}),P.jsxs("span",{className:"wt-time",children:[w7(G)," / ",w7(j)]}),P.jsxs("div",{className:"wt-volume",children:[P.jsx("span",{className:"wt-volume-icon",children:E===0?"🔇":E<.5?"🔉":"🔊"}),P.jsx("input",{className:"wt-volume-slider",type:"range",min:0,max:1,step:.01,value:E,onChange:St=>O(parseFloat(St.target.value))})]}),fe.current==="youtube"&&P.jsxs("select",{className:"wt-quality-select",value:Ve,onChange:St=>Ce(St.target.value),title:"Videoqualität",children:[P.jsx("option",{value:"highres",children:"4K+"}),P.jsx("option",{value:"hd2160",children:"2160p"}),P.jsx("option",{value:"hd1440",children:"1440p"}),P.jsx("option",{value:"hd1080",children:"1080p"}),P.jsx("option",{value:"hd720",children:"720p"}),P.jsx("option",{value:"large",children:"480p"}),P.jsx("option",{value:"medium",children:"360p"}),P.jsx("option",{value:"small",children:"240p"})]})]})]}),P.jsxs("div",{className:"wt-queue-panel",children:[P.jsxs("div",{className:"wt-queue-header",children:[P.jsxs("span",{children:["Warteschlange (",h.queue.length,")"]}),h.queue.some(St=>St.watched)&&P.jsx("button",{className:"wt-queue-clear-btn",onClick:jt,title:"Gesehene entfernen",children:"Gesehene entfernen"})]}),P.jsx("div",{className:"wt-queue-list",children:h.queue.length===0?P.jsx("div",{className:"wt-queue-empty",children:"Keine Videos in der Warteschlange"}):h.queue.map((St,Kt)=>{var qn,Ze;const wn=((qn=h.currentVideo)==null?void 0:qn.url)===St.url;return P.jsxs("div",{className:`wt-queue-item${wn?" playing":""}${St.watched&&!wn?" watched":""} clickable`,onClick:()=>pe({type:"play_video",index:Kt}),title:"Klicken zum Abspielen",children:[P.jsxs("div",{className:"wt-queue-item-info",children:[St.watched&&!wn&&P.jsx("span",{className:"wt-queue-item-check",children:"✓"}),St.url.match(/youtu/)&&P.jsx("img",{className:"wt-queue-thumb",src:`https://img.youtube.com/vi/${(Ze=St.url.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/))==null?void 0:Ze[1]}/default.jpg`,alt:""}),P.jsxs("div",{className:"wt-queue-item-text",children:[P.jsx("div",{className:"wt-queue-item-title",children:St.title||St.url}),P.jsx("div",{className:"wt-queue-item-by",children:St.addedBy})]})]}),Oe&&P.jsx("button",{className:"wt-queue-item-remove",onClick:dt=>{dt.stopPropagation(),In(Kt)},title:"Entfernen",children:"×"})]},Kt)})}),P.jsxs("div",{className:"wt-queue-add",children:[P.jsx("input",{className:"wt-input wt-queue-input",placeholder:"Video-URL eingeben",value:N,onChange:St=>C(St.target.value),onKeyDown:St=>{St.key==="Enter"&&Bt()}}),P.jsx("button",{className:"wt-btn wt-queue-add-btn",onClick:Bt,disabled:Q,children:Q?"Laden...":"Hinzufuegen"})]})]}),ae&&P.jsxs("div",{className:"wt-chat-panel",children:[P.jsx("div",{className:"wt-chat-header",children:"Chat"}),P.jsxs("div",{className:"wt-chat-messages",children:[ne.length===0?P.jsx("div",{className:"wt-chat-empty",children:"Noch keine Nachrichten"}):ne.map((St,Kt)=>P.jsxs("div",{className:"wt-chat-msg",children:[P.jsx("span",{className:"wt-chat-sender",children:St.sender}),P.jsx("span",{className:"wt-chat-text",children:St.text})]},Kt)),P.jsx("div",{ref:_t})]}),P.jsxs("div",{className:"wt-chat-input-row",children:[P.jsx("input",{className:"wt-input wt-chat-input",placeholder:"Nachricht...",value:ie,onChange:St=>Z(St.target.value),onKeyDown:St=>{St.key==="Enter"&&ct()},maxLength:500}),P.jsx("button",{className:"wt-btn wt-chat-send-btn",onClick:ct,children:"Senden"})]})]})]})]})}return P.jsxs("div",{className:"wt-container",children:[S&&P.jsxs("div",{className:"wt-error",children:[S,P.jsx("button",{className:"wt-error-dismiss",onClick:()=>T(null),children:"×"})]}),P.jsxs("div",{className:"wt-topbar",children:[P.jsx("input",{className:"wt-input wt-input-name",placeholder:"Dein Name",value:n,onChange:$e=>r($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-room",placeholder:"Raumname",value:s,onChange:$e=>a($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-password",type:"password",placeholder:"Passwort (optional)",value:l,onChange:$e=>u($e.target.value)}),P.jsx("button",{className:"wt-btn",onClick:Ue,children:"Raum erstellen"})]}),e.length===0?P.jsxs("div",{className:"wt-empty",children:[P.jsx("div",{className:"wt-empty-icon",children:"🎬"}),P.jsx("h3",{children:"Keine aktiven Raeume"}),P.jsx("p",{children:"Erstelle einen Raum, um gemeinsam Videos zu schauen."})]}):P.jsx("div",{className:"wt-grid",children:e.map($e=>P.jsxs("div",{className:"wt-tile",onClick:()=>Yt($e),children:[P.jsxs("div",{className:"wt-tile-preview",children:[P.jsx("span",{className:"wt-tile-icon",children:"🎬"}),P.jsxs("span",{className:"wt-tile-members",children:["👥"," ",$e.memberCount]}),$e.hasPassword&&P.jsx("span",{className:"wt-tile-lock",children:"🔒"}),$e.playing&&P.jsx("span",{className:"wt-tile-playing",children:"▶"})]}),P.jsxs("div",{className:"wt-tile-info",children:[P.jsxs("div",{className:"wt-tile-meta",children:[P.jsx("div",{className:"wt-tile-name",children:$e.name}),P.jsx("div",{className:"wt-tile-host",children:$e.hostName})]}),$e.memberNames&&$e.memberNames.length>0&&P.jsxs("div",{className:"wt-tile-members-list",children:[$e.memberNames.slice(0,5).join(", "),$e.memberNames.length>5&&` +${$e.memberNames.length-5}`]})]})]},$e.id))}),v&&P.jsx("div",{className:"wt-modal-overlay",onClick:()=>x(null),children:P.jsxs("div",{className:"wt-modal",onClick:$e=>$e.stopPropagation(),children:[P.jsx("h3",{children:v.roomName}),P.jsx("p",{children:"Raum-Passwort"}),v.error&&P.jsx("div",{className:"wt-modal-error",children:v.error}),P.jsx("input",{className:"wt-input",type:"password",placeholder:"Passwort",value:v.password,onChange:$e=>x(St=>St&&{...St,password:$e.target.value,error:null}),onKeyDown:$e=>{$e.key==="Enter"&&Ht()},autoFocus:!0}),P.jsxs("div",{className:"wt-modal-actions",children:[P.jsx("button",{className:"wt-modal-cancel",onClick:()=>x(null),children:"Abbrechen"}),P.jsx("button",{className:"wt-btn",onClick:Ht,children:"Beitreten"})]})]})})]})}function HS(i,e){return`https://media.steampowered.com/steamcommunity/public/images/apps/${i}/${e}.jpg`}function T7(i){if(i==null||i===0)return"—";if(i<60)return`${i} Min`;const e=Math.floor(i/60),t=i%60;return t>0?`${e}h ${t}m`:`${e}h`}function JAe(i){try{return new Date(i).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function e0e({data:i,isAdmin:e}){const[t,n]=re.useState([]),[r,s]=re.useState("overview"),[a,l]=re.useState(null),[u,h]=re.useState(new Set),[m,v]=re.useState(null),[x,S]=re.useState(null),[T,N]=re.useState(""),[C,E]=re.useState(null),[O,U]=re.useState(!1),[I,j]=re.useState(null),[z,G]=re.useState(new Set),[H,q]=re.useState("playtime"),V=re.useRef(null),Q=re.useRef(null),[J,ne]=re.useState("");re.useEffect(()=>{i!=null&&i.profiles&&n(i.profiles)},[i]);const oe=re.useCallback(async()=>{try{const le=await fetch("/api/game-library/profiles");if(le.ok){const Ne=await le.json();n(Ne.profiles||[])}}catch{}},[]),ie=re.useCallback(()=>{const le=window.open("/api/game-library/steam/login","_blank","width=800,height=600"),Ne=setInterval(()=>{le&&le.closed&&(clearInterval(Ne),setTimeout(oe,1e3))},500)},[oe]),Z=navigator.userAgent.includes("GamingHubDesktop"),[te,de]=re.useState(!1),[Se,Te]=re.useState(""),[ae,Me]=re.useState("idle"),[Ve,Ce]=re.useState(""),Fe=re.useCallback(()=>{const le=a?`?linkTo=${a}`:"";if(Z){const Ne=window.open(`/api/game-library/gog/login${le}`,"_blank","width=800,height=700"),De=setInterval(()=>{Ne&&Ne.closed&&(clearInterval(De),setTimeout(oe,1e3))},500)}else window.open(`/api/game-library/gog/login${le}`,"_blank","width=800,height=700"),Te(""),Me("idle"),Ce(""),de(!0)},[oe,a,Z]),et=re.useCallback(async()=>{let le=Se.trim();const Ne=le.match(/[?&]code=([^&]+)/);if(Ne&&(le=Ne[1]),!!le){Me("loading"),Ce("Verbinde mit GOG...");try{const De=await fetch("/api/game-library/gog/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:le,linkTo:a||""})}),Je=await De.json();De.ok&&Je.ok?(Me("success"),Ce(`${Je.profileName}: ${Je.gameCount} Spiele geladen!`),oe(),setTimeout(()=>de(!1),2e3)):(Me("error"),Ce(Je.error||"Unbekannter Fehler"))}catch{Me("error"),Ce("Verbindung fehlgeschlagen.")}}},[Se,a,oe]);re.useEffect(()=>{const le=()=>oe();return window.addEventListener("gog-connected",le),()=>window.removeEventListener("gog-connected",le)},[oe]),re.useEffect(()=>{const le=()=>oe();return window.addEventListener("focus",le),()=>window.removeEventListener("focus",le)},[oe]);const He=re.useCallback(async le=>{var Ne,De;s("user"),l(le),v(null),ne(""),U(!0);try{const Je=await fetch(`/api/game-library/profile/${le}/games`);if(Je.ok){const we=await Je.json(),Ue=we.games||we;v(Ue);const ut=t.find(Bt=>Bt.id===le),Dt=(De=(Ne=ut==null?void 0:ut.platforms)==null?void 0:Ne.steam)==null?void 0:De.steamId;Dt&&Ue.filter(ct=>!ct.igdb).length>0&&(j(le),fetch(`/api/game-library/igdb/enrich/${Dt}`).then(ct=>ct.ok?ct.json():null).then(()=>fetch(`/api/game-library/profile/${le}/games`)).then(ct=>ct.ok?ct.json():null).then(ct=>{ct&&v(ct.games||ct)}).catch(()=>{}).finally(()=>j(null)))}}catch{}finally{U(!1)}},[t]),Rt=re.useCallback(async(le,Ne)=>{var we,Ue;Ne&&Ne.stopPropagation();const De=t.find(ut=>ut.id===le),Je=(Ue=(we=De==null?void 0:De.platforms)==null?void 0:we.steam)==null?void 0:Ue.steamId;try{Je&&await fetch(`/api/game-library/user/${Je}?refresh=true`),await oe(),r==="user"&&a===le&&He(le)}catch{}},[oe,r,a,He,t]),Et=re.useCallback(async le=>{var Je,we;const Ne=t.find(Ue=>Ue.id===le),De=(we=(Je=Ne==null?void 0:Ne.platforms)==null?void 0:Je.steam)==null?void 0:we.steamId;if(De){j(le);try{(await fetch(`/api/game-library/igdb/enrich/${De}`)).ok&&r==="user"&&a===le&&He(le)}catch{}finally{j(null)}}},[r,a,He,t]),zt=re.useCallback(le=>{h(Ne=>{const De=new Set(Ne);return De.has(le)?De.delete(le):De.add(le),De})},[]),Pt=re.useCallback(async()=>{if(!(u.size<2)){s("common"),S(null),U(!0);try{const le=Array.from(u).join(","),Ne=await fetch(`/api/game-library/common-games?users=${le}`);if(Ne.ok){const De=await Ne.json();S(De.games||De)}else console.error("[GameLibrary] common-games error:",Ne.status,await Ne.text().catch(()=>"")),S([])}catch(le){console.error("[GameLibrary] common-games fetch failed:",le)}finally{U(!1)}}},[u]),We=re.useCallback(le=>{if(N(le),V.current&&clearTimeout(V.current),le.length<2){E(null);return}V.current=setTimeout(async()=>{try{const Ne=await fetch(`/api/game-library/search?q=${encodeURIComponent(le)}`);if(Ne.ok){const De=await Ne.json();E(De.results||De)}}catch{}},300)},[]),ft=re.useCallback(le=>{G(Ne=>{const De=new Set(Ne);return De.has(le)?De.delete(le):De.add(le),De})},[]),fe=re.useCallback(async(le,Ne)=>{if(confirm(`${Ne==="steam"?"Steam":"GOG"}-Verknuepfung wirklich trennen?`))try{const De=await fetch(`/api/game-library/profile/${le}/${Ne}`,{method:"DELETE"});if(De.ok&&(oe(),(await De.json()).ok)){const we=t.find(ut=>ut.id===le);(Ne==="steam"?we==null?void 0:we.platforms.gog:we==null?void 0:we.platforms.steam)||Wt()}}catch{}},[oe,t]);re.useCallback(async le=>{const Ne=t.find(De=>De.id===le);if(confirm(`Profil "${Ne==null?void 0:Ne.displayName}" wirklich komplett loeschen?`))try{(await fetch(`/api/game-library/profile/${le}`,{method:"DELETE"})).ok&&(oe(),Wt())}catch{}},[oe,t]);const Wt=re.useCallback(()=>{s("overview"),l(null),v(null),S(null),ne(""),G(new Set),q("playtime")},[]),yt=Wt,Gt=re.useCallback(le=>t.find(Ne=>Ne.id===le),[t]),_t=re.useCallback(le=>typeof le.playtime_forever=="number"?le.playtime_forever:Array.isArray(le.owners)?Math.max(...le.owners.map(Ne=>Ne.playtime_forever||0)):0,[]),Xt=re.useCallback(le=>[...le].sort((Ne,De)=>{var Je,we;if(H==="rating"){const Ue=((Je=Ne.igdb)==null?void 0:Je.rating)??-1;return(((we=De.igdb)==null?void 0:we.rating)??-1)-Ue}return H==="name"?Ne.name.localeCompare(De.name):_t(De)-_t(Ne)}),[H,_t]),pt=re.useCallback(le=>{var Ne,De;return z.size===0?!0:(De=(Ne=le.igdb)==null?void 0:Ne.genres)!=null&&De.length?le.igdb.genres.some(Je=>z.has(Je)):!1},[z]),Ae=re.useCallback(le=>{var De;const Ne=new Map;for(const Je of le)if((De=Je.igdb)!=null&&De.genres)for(const we of Je.igdb.genres)Ne.set(we,(Ne.get(we)||0)+1);return[...Ne.entries()].sort((Je,we)=>we[1]-Je[1]).map(([Je])=>Je)},[]),k=m?Xt(m.filter(le=>!J||le.name.toLowerCase().includes(J.toLowerCase())).filter(pt)):null,be=m?Ae(m):[],Oe=x?Ae(x):[],pe=x?Xt(x.filter(pt)):null;return P.jsxs("div",{className:"gl-container",children:[P.jsxs("div",{className:"gl-login-bar",children:[!a&&P.jsx("button",{className:"gl-connect-btn gl-steam-btn",onClick:ie,children:"🎮 Steam verbinden"}),P.jsx("div",{className:"gl-login-bar-spacer"})]}),t.length>0&&P.jsx("div",{className:"gl-profile-chips",children:t.map(le=>P.jsxs("div",{className:`gl-profile-chip${a===le.id?" selected":""}`,onClick:()=>He(le.id),children:[P.jsx("img",{className:"gl-profile-chip-avatar",src:le.avatarUrl,alt:le.displayName}),P.jsxs("div",{className:"gl-profile-chip-info",children:[P.jsx("span",{className:"gl-profile-chip-name",children:le.displayName}),P.jsxs("span",{className:"gl-profile-chip-platforms",children:[le.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:`Steam: ${le.platforms.steam.gameCount} Spiele`,children:"S"}),le.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:`GOG: ${le.platforms.gog.gameCount} Spiele`,children:"G"})]})]}),P.jsxs("span",{className:"gl-profile-chip-count",children:["(",le.totalGames,")"]})]},le.id))}),r==="overview"&&P.jsx(P.Fragment,{children:t.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"🎮"}),P.jsx("h3",{children:"Keine Konten verbunden"}),P.jsx("p",{children:"Klicke oben auf “Steam verbinden” oder “GOG verbinden”, um deine Spielebibliothek hinzuzufuegen."})]}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"gl-section-title",children:"Verbundene Spieler"}),P.jsx("div",{className:"gl-users-grid",children:t.map(le=>P.jsxs("div",{className:"gl-user-card",onClick:()=>He(le.id),children:[P.jsx("img",{className:"gl-user-card-avatar",src:le.avatarUrl,alt:le.displayName}),P.jsx("span",{className:"gl-user-card-name",children:le.displayName}),P.jsxs("div",{className:"gl-profile-card-platforms",children:[le.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:"Steam",children:"S"}),le.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:"GOG",children:"G"})]}),P.jsxs("span",{className:"gl-user-card-games",children:[le.totalGames," Spiele"]}),P.jsxs("span",{className:"gl-user-card-updated",children:["Aktualisiert: ",JAe(le.lastUpdated)]})]},le.id))}),t.length>=2&&P.jsxs("div",{className:"gl-common-finder",children:[P.jsx("h3",{children:"Gemeinsame Spiele finden"}),P.jsx("div",{className:"gl-common-users",children:t.map(le=>P.jsxs("label",{className:`gl-common-check${u.has(le.id)?" checked":""}`,children:[P.jsx("input",{type:"checkbox",checked:u.has(le.id),onChange:()=>zt(le.id)}),P.jsx("img",{className:"gl-common-check-avatar",src:le.avatarUrl,alt:le.displayName}),le.displayName,P.jsxs("span",{className:"gl-profile-chip-platforms",style:{marginLeft:4},children:[le.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",children:"S"}),le.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",children:"G"})]})]},le.id))}),P.jsx("button",{className:"gl-common-find-btn",disabled:u.size<2,onClick:Pt,children:"Finden"})]}),P.jsx("div",{className:"gl-search",children:P.jsx("input",{className:"gl-search-input",type:"text",placeholder:"Spiel suchen...",value:T,onChange:le=>We(le.target.value)})}),C&&C.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"gl-search-results-title",children:[C.length," Ergebnis",C.length!==1?"se":""]}),P.jsx("div",{className:"gl-game-list",children:C.map(le=>P.jsxs("div",{className:"gl-game-item",children:[le.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(le.appid,le.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"}),P.jsx("span",{className:"gl-game-name",children:le.name}),P.jsx("div",{className:"gl-game-owners",children:le.owners.map(Ne=>{const De=t.find(Je=>{var we;return((we=Je.platforms.steam)==null?void 0:we.steamId)===Ne.steamId});return De?P.jsx("img",{className:"gl-game-owner-avatar",src:De.avatarUrl,alt:Ne.personaName,title:Ne.personaName},Ne.steamId):null})})]},le.appid))})]}),C&&C.length===0&&P.jsx("p",{className:"gl-search-results-title",children:"Keine Ergebnisse gefunden."})]})}),r==="user"&&(()=>{const le=a?Gt(a):null;return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:yt,children:"← Zurueck"}),le&&P.jsxs(P.Fragment,{children:[P.jsx("img",{className:"gl-detail-avatar",src:le.avatarUrl,alt:le.displayName}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsxs("div",{className:"gl-detail-name",children:[le.displayName,P.jsxs("span",{className:"gl-game-count",children:[le.totalGames," Spiele"]})]}),P.jsxs("div",{className:"gl-detail-sub",children:[le.platforms.steam&&P.jsxs("span",{className:"gl-platform-detail steam",children:[P.jsx("span",{className:"gl-platform-badge steam",children:"Steam ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:Ne=>{Ne.stopPropagation(),fe(le.id,"steam")},title:"Steam trennen",children:"✕"})]}),le.platforms.gog?P.jsxs("span",{className:"gl-platform-detail gog",children:[P.jsx("span",{className:"gl-platform-badge gog",children:"GOG ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:Ne=>{Ne.stopPropagation(),fe(le.id,"gog")},title:"GOG trennen",children:"✕"})]}):P.jsx("button",{className:"gl-link-gog-btn",onClick:Fe,children:"🟣 GOG verknuepfen"})]})]}),P.jsx("button",{className:"gl-refresh-btn",onClick:()=>Rt(le.id),title:"Aktualisieren",children:"↻"}),le.platforms.steam&&P.jsxs("button",{className:`gl-enrich-btn ${I===a?"enriching":""}`,onClick:()=>Et(a),disabled:I===a,title:I===a?"IGDB-Daten werden geladen...":"Mit IGDB-Daten anreichern (erneut)",children:[I===a?"⏳":"🌐"," IGDB"]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Bibliothek wird geladen..."}):k?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-filter-bar",children:[P.jsx("input",{ref:Q,className:"gl-search-input",type:"text",placeholder:"Bibliothek durchsuchen...",value:J,onChange:Ne=>ne(Ne.target.value)}),P.jsxs("select",{className:"gl-sort-select",value:H,onChange:Ne=>q(Ne.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})]}),be.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),be.map(Ne=>P.jsx("button",{className:`gl-genre-chip${z.has(Ne)?" active":""}`,onClick:()=>ft(Ne),children:Ne},Ne))]}),P.jsxs("p",{className:"gl-filter-count",children:[k.length," Spiele"]}),k.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Spiele gefunden."}):P.jsx("div",{className:"gl-game-list",children:k.map((Ne,De)=>{var Je,we,Ue;return P.jsxs("div",{className:`gl-game-item ${Ne.igdb?"enriched":""}`,children:[P.jsx("span",{className:`gl-game-platform-icon ${Ne.platform||"steam"}`,children:Ne.platform==="gog"?"G":"S"}),P.jsx("div",{className:"gl-game-visual",children:(Je=Ne.igdb)!=null&&Je.coverUrl?P.jsx("img",{className:"gl-game-cover",src:Ne.igdb.coverUrl,alt:""}):Ne.img_icon_url&&Ne.appid?P.jsx("img",{className:"gl-game-icon",src:HS(Ne.appid,Ne.img_icon_url),alt:""}):Ne.image?P.jsx("img",{className:"gl-game-icon",src:Ne.image,alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:Ne.name}),((we=Ne.igdb)==null?void 0:we.genres)&&Ne.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:Ne.igdb.genres.slice(0,3).map(ut=>P.jsx("span",{className:"gl-genre-tag",children:ut},ut))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Ue=Ne.igdb)==null?void 0:Ue.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${Ne.igdb.rating>=75?"high":Ne.igdb.rating>=50?"mid":"low"}`,children:Math.round(Ne.igdb.rating)}),P.jsx("span",{className:"gl-game-playtime",children:T7(Ne.playtime_forever)})]})]},Ne.appid??Ne.gogId??De)})})]}):null]})})(),r==="common"&&(()=>{const le=Array.from(u).map(De=>Gt(De)).filter(Boolean),Ne=le.map(De=>De.displayName).join(", ");return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:yt,children:"← Zurueck"}),P.jsx("div",{className:"gl-detail-avatars",children:le.map(De=>P.jsx("img",{src:De.avatarUrl,alt:De.displayName},De.id))}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsx("div",{className:"gl-detail-name",children:"Gemeinsame Spiele"}),P.jsxs("div",{className:"gl-detail-sub",children:["von ",Ne]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Gemeinsame Spiele werden gesucht..."}):x?x.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"😔"}),P.jsx("h3",{children:"Keine gemeinsamen Spiele"}),P.jsx("p",{children:"Die ausgewaehlten Spieler besitzen leider keine gemeinsamen Spiele."})]}):P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"gl-filter-bar",children:P.jsxs("select",{className:"gl-sort-select",value:H,onChange:De=>q(De.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})}),Oe.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),Oe.map(De=>P.jsx("button",{className:`gl-genre-chip${z.has(De)?" active":""}`,onClick:()=>ft(De),children:De},De))]}),P.jsxs("p",{className:"gl-section-title",children:[pe.length," gemeinsame",pe.length!==1?" Spiele":"s Spiel",z.size>0?` (von ${x.length})`:""]}),P.jsx("div",{className:"gl-game-list",children:pe.map(De=>{var Je,we,Ue;return P.jsxs("div",{className:`gl-game-item ${De.igdb?"enriched":""}`,children:[P.jsx("div",{className:"gl-game-visual",children:(Je=De.igdb)!=null&&Je.coverUrl?P.jsx("img",{className:"gl-game-cover",src:De.igdb.coverUrl,alt:""}):De.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(De.appid,De.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:De.name}),((we=De.igdb)==null?void 0:we.genres)&&De.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:De.igdb.genres.slice(0,3).map(ut=>P.jsx("span",{className:"gl-genre-tag",children:ut},ut))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Ue=De.igdb)==null?void 0:Ue.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${De.igdb.rating>=75?"high":De.igdb.rating>=50?"mid":"low"}`,children:Math.round(De.igdb.rating)}),P.jsx("div",{className:"gl-common-playtimes",children:De.owners.map(ut=>P.jsxs("span",{className:"gl-common-pt",children:[ut.personaName,": ",T7(ut.playtime_forever)]},ut.steamId))})]})]},De.appid)})})]}):null]})})(),te&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>de(!1),children:P.jsxs("div",{className:"gl-dialog",onClick:le=>le.stopPropagation(),children:[P.jsx("h3",{children:"🟣 GOG verbinden"}),P.jsxs("p",{className:"gl-dialog-hint",children:["Nach dem GOG-Login wirst du auf eine Seite weitergeleitet. Kopiere die ",P.jsx("strong",{children:"komplette URL"})," aus der Adressleiste und füge sie hier ein:"]}),P.jsx("input",{className:"gl-dialog-input",type:"text",placeholder:"https://embed.gog.com/on_login_success?code=...",value:Se,onChange:le=>Te(le.target.value),onKeyDown:le=>{le.key==="Enter"&&et()},disabled:ae==="loading"||ae==="success",autoFocus:!0}),Ve&&P.jsx("p",{className:`gl-dialog-status ${ae}`,children:Ve}),P.jsxs("div",{className:"gl-dialog-actions",children:[P.jsx("button",{onClick:()=>de(!1),className:"gl-dialog-cancel",children:"Abbrechen"}),P.jsx("button",{onClick:et,className:"gl-dialog-submit",disabled:!Se.trim()||ae==="loading"||ae==="success",children:ae==="loading"?"Verbinde...":"Verbinden"})]})]})})]})}const lx="/api/soundboard";async function t0e(){const i=new URL(`${lx}/sounds`,window.location.origin);i.searchParams.set("folder","__all__"),i.searchParams.set("fuzzy","0");const e=await fetch(i.toString());if(!e.ok)throw new Error("Fehler beim Laden der Sounds");return e.json()}async function n0e(i){if(!(await fetch(`${lx}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}async function i0e(i,e){const t=await fetch(`${lx}/admin/sounds/rename`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({from:i,to:e})});if(!t.ok)throw new Error("Umbenennen fehlgeschlagen");const n=await t.json();return n==null?void 0:n.to}function r0e(i,e){return new Promise((t,n)=>{const r=new FormData;r.append("files",i);const s=new XMLHttpRequest;s.open("POST",`${lx}/upload`),s.upload.onprogress=a=>{a.lengthComputable&&e(Math.round(a.loaded/a.total*100))},s.onload=()=>{var a,l;if(s.status===200)try{const u=JSON.parse(s.responseText);t(((l=(a=u.files)==null?void 0:a[0])==null?void 0:l.name)??i.name)}catch{t(i.name)}else try{n(new Error(JSON.parse(s.responseText).error))}catch{n(new Error(`HTTP ${s.status}`))}},s.onerror=()=>n(new Error("Netzwerkfehler")),s.send(r)})}function s0e({onClose:i}){var be,Oe;const[e,t]=re.useState("soundboard"),[n,r]=re.useState(null),s=re.useCallback((pe,le="info")=>{r({msg:pe,type:le}),setTimeout(()=>r(null),3e3)},[]);re.useEffect(()=>{const pe=le=>{le.key==="Escape"&&i()};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},[i]);const[a,l]=re.useState([]),[u,h]=re.useState(!1),[m,v]=re.useState(""),[x,S]=re.useState({}),[T,N]=re.useState(""),[C,E]=re.useState(""),[O,U]=re.useState(null),I=re.useCallback(pe=>pe.relativePath??pe.fileName,[]),j=re.useCallback(async()=>{h(!0);try{const pe=await t0e();l(pe.items||[])}catch(pe){s((pe==null?void 0:pe.message)||"Sounds konnten nicht geladen werden","error")}finally{h(!1)}},[s]),[z,G]=re.useState(!1);re.useEffect(()=>{e==="soundboard"&&!z&&(G(!0),j())},[e,z,j]);const H=re.useMemo(()=>{const pe=m.trim().toLowerCase();return pe?a.filter(le=>{const Ne=I(le).toLowerCase();return le.name.toLowerCase().includes(pe)||(le.folder||"").toLowerCase().includes(pe)||Ne.includes(pe)}):a},[m,a,I]),q=re.useMemo(()=>Object.keys(x).filter(pe=>x[pe]),[x]),V=re.useMemo(()=>H.filter(pe=>!!x[I(pe)]).length,[H,x,I]),Q=H.length>0&&V===H.length;function J(pe){S(le=>({...le,[pe]:!le[pe]}))}function ne(pe){N(I(pe)),E(pe.name)}function oe(){N(""),E("")}async function ie(){if(!T)return;const pe=C.trim().replace(/\.(mp3|wav)$/i,"");if(!pe){s("Bitte einen gueltigen Namen eingeben","error");return}try{await i0e(T,pe),s("Sound umbenannt"),oe(),await j()}catch(le){s((le==null?void 0:le.message)||"Umbenennen fehlgeschlagen","error")}}async function Z(pe){if(pe.length!==0)try{await n0e(pe),s(pe.length===1?"Sound geloescht":`${pe.length} Sounds geloescht`),S({}),oe(),await j()}catch(le){s((le==null?void 0:le.message)||"Loeschen fehlgeschlagen","error")}}async function te(pe){U(0);try{await r0e(pe,le=>U(le)),s(`"${pe.name}" hochgeladen`),await j()}catch(le){s((le==null?void 0:le.message)||"Upload fehlgeschlagen","error")}finally{U(null)}}const[de,Se]=re.useState([]),[Te,ae]=re.useState([]),[Me,Ve]=re.useState(!1),[Ce,Fe]=re.useState(!1),[et,He]=re.useState({online:!1,botTag:null}),Rt=re.useCallback(async()=>{Ve(!0);try{const[pe,le,Ne]=await Promise.all([fetch("/api/notifications/status"),fetch("/api/notifications/channels",{credentials:"include"}),fetch("/api/notifications/config",{credentials:"include"})]);if(pe.ok){const De=await pe.json();He(De)}if(le.ok){const De=await le.json();Se(De.channels||[])}if(Ne.ok){const De=await Ne.json();ae(De.channels||[])}}catch{}finally{Ve(!1)}},[]),[Et,zt]=re.useState(!1);re.useEffect(()=>{e==="streaming"&&!Et&&(zt(!0),Rt())},[e,Et,Rt]);const Pt=re.useCallback((pe,le,Ne,De,Je)=>{ae(we=>{const Ue=we.find(ut=>ut.channelId===pe);if(Ue){const Dt=Ue.events.includes(Je)?Ue.events.filter(Bt=>Bt!==Je):[...Ue.events,Je];return Dt.length===0?we.filter(Bt=>Bt.channelId!==pe):we.map(Bt=>Bt.channelId===pe?{...Bt,events:Dt}:Bt)}else return[...we,{channelId:pe,channelName:le,guildId:Ne,guildName:De,events:[Je]}]})},[]),We=re.useCallback((pe,le)=>{const Ne=Te.find(De=>De.channelId===pe);return(Ne==null?void 0:Ne.events.includes(le))??!1},[Te]),ft=re.useCallback(async()=>{Fe(!0);try{await fetch("/api/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channels:Te}),credentials:"include"}),s("Konfiguration gespeichert")}catch{s("Speichern fehlgeschlagen","error")}finally{Fe(!1)}},[Te,s]),[fe,Wt]=re.useState([]),[yt,Gt]=re.useState(!1),_t=re.useCallback(async()=>{Gt(!0);try{const pe=await fetch("/api/game-library/admin/profiles",{credentials:"include"});if(pe.ok){const le=await pe.json();Wt(le.profiles||[])}}catch{}finally{Gt(!1)}},[]),[Xt,pt]=re.useState(!1);re.useEffect(()=>{e==="game-library"&&!Xt&&(pt(!0),_t())},[e,Xt,_t]);const Ae=re.useCallback(async(pe,le)=>{if(confirm(`Profil "${le}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`))try{(await fetch(`/api/game-library/admin/profile/${pe}`,{method:"DELETE",credentials:"include"})).ok&&(s("Profil geloescht"),_t())}catch{s("Loeschen fehlgeschlagen","error")}},[_t,s]),k=[{id:"soundboard",icon:"🎵",label:"Soundboard"},{id:"streaming",icon:"📺",label:"Streaming"},{id:"game-library",icon:"🎮",label:"Game Library"}];return P.jsx("div",{className:"ap-overlay",onClick:pe=>{pe.target===pe.currentTarget&&i()},children:P.jsxs("div",{className:"ap-modal",children:[P.jsxs("div",{className:"ap-sidebar",children:[P.jsxs("div",{className:"ap-sidebar-title",children:["⚙️"," Admin"]}),P.jsx("nav",{className:"ap-nav",children:k.map(pe=>P.jsxs("button",{className:`ap-nav-item ${e===pe.id?"active":""}`,onClick:()=>t(pe.id),children:[P.jsx("span",{className:"ap-nav-icon",children:pe.icon}),P.jsx("span",{className:"ap-nav-label",children:pe.label})]},pe.id))})]}),P.jsxs("div",{className:"ap-content",children:[P.jsxs("div",{className:"ap-header",children:[P.jsxs("h2",{className:"ap-title",children:[(be=k.find(pe=>pe.id===e))==null?void 0:be.icon," ",(Oe=k.find(pe=>pe.id===e))==null?void 0:Oe.label]}),P.jsx("button",{className:"ap-close",onClick:i,children:"✕"})]}),P.jsxs("div",{className:"ap-body",children:[e==="soundboard"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsx("input",{type:"text",className:"ap-search",value:m,onChange:pe=>v(pe.target.value),placeholder:"Nach Name, Ordner oder Pfad filtern..."}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{j()},disabled:u,children:["↻"," Aktualisieren"]})]}),P.jsxs("label",{className:"ap-upload-zone",children:[P.jsx("input",{type:"file",accept:".mp3,.wav",style:{display:"none"},onChange:pe=>{var Ne;const le=(Ne=pe.target.files)==null?void 0:Ne[0];le&&te(le),pe.target.value=""}}),O!==null?P.jsxs("span",{className:"ap-upload-progress",children:["Upload: ",O,"%"]}):P.jsxs("span",{className:"ap-upload-text",children:["⬆️"," Datei hochladen (MP3 / WAV)"]})]}),P.jsxs("div",{className:"ap-bulk-row",children:[P.jsxs("label",{className:"ap-select-all",children:[P.jsx("input",{type:"checkbox",checked:Q,onChange:pe=>{const le=pe.target.checked,Ne={...x};H.forEach(De=>{Ne[I(De)]=le}),S(Ne)}}),P.jsxs("span",{children:["Alle sichtbaren (",V,"/",H.length,")"]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger",disabled:q.length===0,onClick:async()=>{window.confirm(`Wirklich ${q.length} Sound(s) loeschen?`)&&await Z(q)},children:["🗑️"," Ausgewaehlte loeschen"]})]}),P.jsx("div",{className:"ap-list-wrap",children:u?P.jsx("div",{className:"ap-empty",children:"Lade Sounds..."}):H.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Sounds gefunden."}):P.jsx("div",{className:"ap-list",children:H.map(pe=>{const le=I(pe),Ne=T===le;return P.jsxs("div",{className:"ap-item",children:[P.jsx("label",{className:"ap-item-check",children:P.jsx("input",{type:"checkbox",checked:!!x[le],onChange:()=>J(le)})}),P.jsxs("div",{className:"ap-item-main",children:[P.jsx("div",{className:"ap-item-name",children:pe.name}),P.jsxs("div",{className:"ap-item-meta",children:[pe.folder?`Ordner: ${pe.folder}`:"Root"," · ",le]}),Ne&&P.jsxs("div",{className:"ap-rename-row",children:[P.jsx("input",{className:"ap-rename-input",value:C,onChange:De=>E(De.target.value),onKeyDown:De=>{De.key==="Enter"&&ie(),De.key==="Escape"&&oe()},placeholder:"Neuer Name...",autoFocus:!0}),P.jsx("button",{className:"ap-btn ap-btn-primary ap-btn-sm",onClick:()=>{ie()},children:"Speichern"}),P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:oe,children:"Abbrechen"})]})]}),!Ne&&P.jsxs("div",{className:"ap-item-actions",children:[P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:()=>ne(pe),children:"Umbenennen"}),P.jsx("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:async()=>{window.confirm(`Sound "${pe.name}" loeschen?`)&&await Z([le])},children:"Loeschen"})]})]},le)})})})]}),e==="streaming"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:`ap-status-dot ${et.online?"online":""}`}),et.online?P.jsxs(P.Fragment,{children:["Bot online: ",P.jsx("b",{children:et.botTag})]}):P.jsx(P.Fragment,{children:"Bot offline"})]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{Rt()},disabled:Me,children:["↻"," Aktualisieren"]})]}),Me?P.jsx("div",{className:"ap-empty",children:"Lade Kanaele..."}):de.length===0?P.jsx("div",{className:"ap-empty",children:et.online?"Keine Text-Kanaele gefunden. Bot hat moeglicherweise keinen Zugriff.":"Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren."}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"ap-hint",children:"Waehle die Kanaele, in die Benachrichtigungen gesendet werden sollen:"}),P.jsx("div",{className:"ap-channel-list",children:de.map(pe=>P.jsxs("div",{className:"ap-channel-row",children:[P.jsxs("div",{className:"ap-channel-info",children:[P.jsxs("span",{className:"ap-channel-name",children:["#",pe.channelName]}),P.jsx("span",{className:"ap-channel-guild",children:pe.guildName})]}),P.jsxs("div",{className:"ap-channel-toggles",children:[P.jsxs("label",{className:`ap-toggle ${We(pe.channelId,"stream_start")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:We(pe.channelId,"stream_start"),onChange:()=>Pt(pe.channelId,pe.channelName,pe.guildId,pe.guildName,"stream_start")}),"🔴"," Stream Start"]}),P.jsxs("label",{className:`ap-toggle ${We(pe.channelId,"stream_end")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:We(pe.channelId,"stream_end"),onChange:()=>Pt(pe.channelId,pe.channelName,pe.guildId,pe.guildName,"stream_end")}),"⏹️"," Stream Ende"]})]})]},pe.channelId))}),P.jsx("div",{className:"ap-save-row",children:P.jsx("button",{className:"ap-btn ap-btn-primary",onClick:ft,disabled:Ce,children:Ce?"Speichern...":"💾 Speichern"})})]})]}),e==="game-library"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:"ap-status-dot online"}),"Eingeloggt als Admin"]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{_t()},disabled:yt,children:["↻"," Aktualisieren"]})]}),yt?P.jsx("div",{className:"ap-empty",children:"Lade Profile..."}):fe.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Profile vorhanden."}):P.jsx("div",{className:"ap-profile-list",children:fe.map(pe=>P.jsxs("div",{className:"ap-profile-row",children:[P.jsx("img",{className:"ap-profile-avatar",src:pe.avatarUrl,alt:pe.displayName}),P.jsxs("div",{className:"ap-profile-info",children:[P.jsx("span",{className:"ap-profile-name",children:pe.displayName}),P.jsxs("span",{className:"ap-profile-details",children:[pe.steamName&&P.jsxs("span",{className:"ap-platform-badge steam",children:["Steam: ",pe.steamGames]}),pe.gogName&&P.jsxs("span",{className:"ap-platform-badge gog",children:["GOG: ",pe.gogGames]}),P.jsxs("span",{className:"ap-profile-total",children:[pe.totalGames," Spiele"]})]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:()=>Ae(pe.id,pe.displayName),children:["🗑️"," Entfernen"]})]},pe.id))})]})]})]}),n&&P.jsxs("div",{className:`ap-toast ${n.type}`,children:[n.type==="error"?"❌":"✅"," ",n.msg]})]})})}const M7={radio:MAe,soundboard:jAe,lolstats:YAe,streaming:QAe,"watch-together":ZAe,"game-library":e0e};function a0e(){var Z;const[i,e]=re.useState(!1),[t,n]=re.useState([]),[r,s]=re.useState(()=>localStorage.getItem("hub_activeTab")??""),a=te=>{s(te),localStorage.setItem("hub_activeTab",te)},[l,u]=re.useState(!1),[h,m]=re.useState({}),[v,x]=re.useState(!1),[S,T]=re.useState(!1),[N,C]=re.useState(!1),[E,O]=re.useState(""),[U,I]=re.useState(""),j=!!((Z=window.electronAPI)!=null&&Z.isElectron),z=j?window.electronAPI.version:null,[G,H]=re.useState("idle"),[q,V]=re.useState(""),Q=re.useRef(null);re.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]),re.useEffect(()=>{fetch("/api/soundboard/admin/status",{credentials:"include"}).then(te=>te.json()).then(te=>x(!!te.authenticated)).catch(()=>{})},[]),re.useEffect(()=>{if(!S)return;const te=de=>{de.key==="Escape"&&T(!1)};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[S]);async function J(){I("");try{(await fetch("/api/soundboard/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:E}),credentials:"include"})).ok?(x(!0),O(""),T(!1)):I("Falsches Passwort")}catch{I("Verbindung fehlgeschlagen")}}async function ne(){await fetch("/api/soundboard/admin/logout",{method:"POST",credentials:"include"}),x(!1)}re.useEffect(()=>{var Se;if(!j)return;const te=window.electronAPI;te.onUpdateAvailable(()=>H("downloading")),te.onUpdateReady(()=>H("ready")),te.onUpdateNotAvailable(()=>H("upToDate")),te.onUpdateError(Te=>{H("error"),V(Te||"Unbekannter Fehler")});const de=(Se=te.getUpdateStatus)==null?void 0:Se.call(te);de==="downloading"?H("downloading"):de==="ready"?H("ready"):de==="checking"&&H("checking")},[j]),re.useEffect(()=>{fetch("/api/plugins").then(te=>te.json()).then(te=>{if(n(te),new URLSearchParams(location.search).has("viewStream")&&te.some(ae=>ae.name==="streaming")){a("streaming");return}const Se=localStorage.getItem("hub_activeTab"),Te=te.some(ae=>ae.name===Se);te.length>0&&!Te&&a(te[0].name)}).catch(()=>{})},[]),re.useEffect(()=>{let te=null,de;function Se(){te=new EventSource("/api/events"),Q.current=te,te.onopen=()=>e(!0),te.onmessage=Te=>{try{const ae=JSON.parse(Te.data);ae.type==="snapshot"?m(Me=>({...Me,...ae})):ae.plugin&&m(Me=>({...Me,[ae.plugin]:{...Me[ae.plugin]||{},...ae}}))}catch{}},te.onerror=()=>{e(!1),te==null||te.close(),de=setTimeout(Se,3e3)}}return Se(),()=>{te==null||te.close(),clearTimeout(de)}},[]);const oe="1.0.0-dev";re.useEffect(()=>{if(!l)return;const te=de=>{de.key==="Escape"&&u(!1)};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[l]);const ie={radio:"🌍",soundboard:"🎵",lolstats:"⚔️",stats:"📊",events:"📅",games:"🎲",gamevote:"🎮",streaming:"📺","watch-together":"🎬","game-library":"🎮"};return P.jsxs("div",{className:"hub-app",children:[P.jsxs("header",{className:"hub-header",children:[P.jsxs("div",{className:"hub-header-left",children:[P.jsx("span",{className:"hub-logo",children:"🎮"}),P.jsx("span",{className:"hub-title",children:"Gaming Hub"}),P.jsx("span",{className:`hub-conn-dot ${i?"online":""}`})]}),P.jsx("nav",{className:"hub-tabs",children:t.filter(te=>te.name in M7).map(te=>P.jsxs("button",{className:`hub-tab ${r===te.name?"active":""}`,onClick:()=>a(te.name),title:te.description,children:[P.jsx("span",{className:"hub-tab-icon",children:ie[te.name]??"📦"}),P.jsx("span",{className:"hub-tab-label",children:te.name})]},te.name))}),P.jsxs("div",{className:"hub-header-right",children:[!window.electronAPI&&P.jsxs("a",{className:"hub-download-btn",href:"/downloads/GamingHub-Setup.exe",download:!0,title:"Desktop App herunterladen",children:[P.jsx("span",{className:"hub-download-icon",children:"⬇️"}),P.jsx("span",{className:"hub-download-label",children:"Desktop App"})]}),P.jsx("button",{className:`hub-admin-btn ${v?"active":""}`,onClick:()=>v?C(!0):T(!0),onContextMenu:te=>{v&&(te.preventDefault(),ne())},title:v?"Admin Panel (Rechtsklick = Abmelden)":"Admin Login",children:v?"🔓":"🔒"}),P.jsx("button",{className:"hub-refresh-btn",onClick:()=>window.location.reload(),title:"Seite neu laden",children:"🔄"}),P.jsxs("span",{className:"hub-version hub-version-clickable",onClick:()=>{var te;if(j){const de=window.electronAPI,Se=(te=de.getUpdateStatus)==null?void 0:te.call(de);Se==="downloading"?H("downloading"):Se==="ready"?H("ready"):Se==="checking"&&H("checking")}u(!0)},title:"Versionsinformationen",children:["v",oe]})]})]}),l&&P.jsx("div",{className:"hub-version-overlay",onClick:()=>u(!1),children:P.jsxs("div",{className:"hub-version-modal",onClick:te=>te.stopPropagation(),children:[P.jsxs("div",{className:"hub-version-modal-header",children:[P.jsx("span",{children:"Versionsinformationen"}),P.jsx("button",{className:"hub-version-modal-close",onClick:()=>u(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-version-modal-body",children:[P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Hub-Version"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",oe]})]}),j&&P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Desktop-App"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",z]})]}),P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Server"}),P.jsxs("span",{className:"hub-version-modal-value",children:[P.jsx("span",{className:`hub-version-modal-dot ${i?"online":""}`}),i?"Verbunden":"Getrennt"]})]}),j&&P.jsxs("div",{className:"hub-version-modal-update",children:[G==="idle"&&P.jsxs("button",{className:"hub-version-modal-update-btn",onClick:()=>{H("checking"),V(""),window.electronAPI.checkForUpdates()},children:["🔄"," Nach Updates suchen"]}),G==="checking"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Suche nach Updates…"]}),G==="downloading"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Update wird heruntergeladen…"]}),G==="ready"&&P.jsxs("button",{className:"hub-version-modal-update-btn ready",onClick:()=>window.electronAPI.installUpdate(),children:["✅"," Jetzt installieren & neu starten"]}),G==="upToDate"&&P.jsxs("div",{className:"hub-version-modal-update-status success",children:["✅"," App ist aktuell",P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut prüfen"})]}),G==="error"&&P.jsxs("div",{className:"hub-version-modal-update-status error",children:["❌"," ",q,P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut versuchen"})]})]})]})]})}),S&&P.jsx("div",{className:"hub-admin-overlay",onClick:()=>T(!1),children:P.jsxs("div",{className:"hub-admin-modal",onClick:te=>te.stopPropagation(),children:[P.jsxs("div",{className:"hub-admin-modal-header",children:[P.jsxs("span",{children:["🔒"," Admin Login"]}),P.jsx("button",{className:"hub-admin-modal-close",onClick:()=>T(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-admin-modal-body",children:[P.jsx("input",{type:"password",className:"hub-admin-input",placeholder:"Admin-Passwort...",value:E,onChange:te=>O(te.target.value),onKeyDown:te=>te.key==="Enter"&&J(),autoFocus:!0}),U&&P.jsx("p",{className:"hub-admin-error",children:U}),P.jsx("button",{className:"hub-admin-submit",onClick:J,children:"Login"})]})]})}),N&&v&&P.jsx(s0e,{onClose:()=>C(!1)}),P.jsx("main",{className:"hub-content",children:t.length===0?P.jsxs("div",{className:"hub-empty",children:[P.jsx("span",{className:"hub-empty-icon",children:"📦"}),P.jsx("h2",{children:"Keine Plugins geladen"}),P.jsx("p",{children:"Plugins werden im Server konfiguriert."})]}):t.map(te=>{const de=M7[te.name];if(!de)return null;const Se=r===te.name;return P.jsx("div",{className:`hub-tab-panel ${Se?"active":""}`,style:Se?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{display:"none"},children:P.jsx(de,{data:h[te.name]||{},isAdmin:v})},te.name)})})]})}IF.createRoot(document.getElementById("root")).render(P.jsx(a0e,{})); diff --git a/web/dist/assets/index-TtdZJHkE.css b/web/dist/assets/index-Bg-1_rjZ.css similarity index 92% rename from web/dist/assets/index-TtdZJHkE.css rename to web/dist/assets/index-Bg-1_rjZ.css index 76d2ca9..2792e27 100644 --- a/web/dist/assets/index-TtdZJHkE.css +++ b/web/dist/assets/index-Bg-1_rjZ.css @@ -1 +1 @@ -@import"https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap";@import"https://fonts.googleapis.com/icon?family=Material+Icons";.sb-app{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--bg-modifier-hover: rgba(79, 84, 92, .16);--bg-modifier-active: rgba(79, 84, 92, .24);--bg-modifier-selected: rgba(79, 84, 92, .32);--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #5865f2;--accent-rgb: 88, 101, 242;--accent-hover: #4752c4;--accent-glow: rgba(88, 101, 242, .45);--green: #23a55a;--red: #f23f42;--yellow: #f0b232;--white: #ffffff;--font: "DM Sans", "Outfit", "gg sans", "Noto Sans", Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;--radius: 8px;--radius-lg: 12px;--shadow-low: 0 1px 3px rgba(0, 0, 0, .24);--shadow-med: 0 4px 12px rgba(0, 0, 0, .32);--shadow-high: 0 8px 24px rgba(0, 0, 0, .4);--transition: .15s cubic-bezier(.4, 0, .2, 1);--card-size: 110px;--card-emoji: 28px;--card-font: 11px;color-scheme:dark}.sb-app[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad;--accent-glow: rgba(155, 89, 182, .45)}.sb-app[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60;--accent-glow: rgba(46, 204, 113, .4)}.sb-app[data-theme=sunset]{--bg-deep: #1a1210;--bg-primary: #231815;--bg-secondary: #2f201c;--bg-tertiary: #3d2a24;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--accent-glow: rgba(230, 126, 34, .4)}.sb-app[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9;--accent-glow: rgba(52, 152, 219, .4)}.sb-app{display:flex;flex-direction:column;height:100%;position:relative}.topbar{display:flex;align-items:center;padding:0 20px;height:52px;background:var(--bg-secondary);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px;transition:background .4s ease}.topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.sb-app-logo{width:28px;height:28px;background:var(--accent);border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .4s ease}.sb-app-title{font-size:16px;font-weight:700;color:var(--white);letter-spacing:-.02em}.clock-wrap{flex:1;display:flex;justify-content:center}.clock{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:.02em;font-variant-numeric:tabular-nums;opacity:.9}.clock-seconds{font-size:14px;color:var(--text-faint);font-weight:500}.topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0}.channel-dropdown{position:relative;flex-shrink:0}.channel-btn{display:flex;align-items:center;gap:8px;padding:5px 12px 5px 10px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-normal);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.channel-btn:hover{background:var(--bg-modifier-selected);border-color:#ffffff1f}.channel-btn.open{border-color:var(--accent)}.channel-btn .cb-icon{font-size:16px;color:var(--text-muted)}.channel-btn .chevron{font-size:12px;color:var(--text-faint);transition:transform var(--transition);margin-left:2px}.channel-btn.open .chevron{transform:rotate(180deg)}.channel-status{width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0}.channel-menu{position:absolute;top:calc(100% + 6px);left:0;min-width:220px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:6px;z-index:100;animation:ctx-in .1s ease-out}.channel-menu-header{padding:6px 8px 4px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-faint)}.channel-option{display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:4px;font-size:13px;color:var(--text-muted);cursor:pointer;transition:all var(--transition)}.channel-option:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.channel-option.active{background:var(--accent);color:var(--white)}.channel-option .co-icon{font-size:16px;opacity:.7}.connection{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:#23a55a1f;font-size:12px;color:var(--green);font-weight:600}.conn-dot{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 6px #23a55a99;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 6px #23a55a80}50%{box-shadow:0 0 12px #23a55acc}}.conn-ping{font-size:10px;opacity:.7;margin-left:2px}.conn-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fadeIn .15s ease}.conn-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:slideUp .2s ease}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.conn-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.conn-modal-close{margin-left:auto;background:none;border:none;color:var(--muted);cursor:pointer;padding:4px;border-radius:6px;display:flex;transition:all .15s}.conn-modal-close:hover{background:#ffffff14;color:var(--fg)}.conn-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.conn-stat{display:flex;justify-content:space-between;align-items:center}.conn-stat-label{color:var(--muted);font-size:13px}.conn-stat-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.conn-ping-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.admin-btn-icon{width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition);font-size:18px}.admin-btn-icon:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.admin-btn-icon.active{color:var(--accent)}.toolbar{display:flex;align-items:center;gap:10px;padding:10px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0;flex-wrap:wrap;transition:background .4s ease}.cat-tabs{display:flex;gap:4px;flex-shrink:0}.cat-tab{display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.cat-tab:hover{background:var(--bg-modifier-selected);color:var(--text-normal)}.cat-tab.active{background:var(--accent);color:var(--white)}.tab-count{font-size:10px;font-weight:700;background:#ffffff26;padding:0 6px;border-radius:8px;line-height:1.6}.search-wrap{position:relative;flex:1;max-width:280px;min-width:140px}.search-wrap .search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);font-size:15px;color:var(--text-faint);pointer-events:none}.search-input{width:100%;height:32px;padding:0 28px 0 32px;border:1px solid rgba(255,255,255,.06);border-radius:20px;background:var(--bg-secondary);color:var(--text-normal);font-family:var(--font);font-size:13px;outline:none;transition:all var(--transition)}.search-input::placeholder{color:var(--text-faint)}.search-input:focus{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.search-clear{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:20px;height:20px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition)}.search-clear:hover{background:var(--bg-tertiary);color:var(--text-normal)}.toolbar-spacer{flex:1}.url-import-wrap{display:flex;align-items:center;gap:6px;min-width:240px;max-width:460px;flex:1;padding:4px 6px 4px 8px;border-radius:20px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.url-import-icon{font-size:15px;color:var(--text-faint);flex-shrink:0}.url-import-input{flex:1;min-width:0;height:26px;border:none;background:transparent;color:var(--text-normal);font-size:12px;font-family:var(--font);outline:none}.url-import-input::placeholder{color:var(--text-faint)}.url-import-btn{height:24px;padding:0 10px;border-radius:14px;border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.45);background:rgba(var(--accent-rgb, 88, 101, 242),.12);color:var(--accent);font-size:11px;font-weight:700;white-space:nowrap;transition:all var(--transition)}.url-import-btn:hover{background:var(--accent);border-color:var(--accent);color:var(--white)}.url-import-btn:disabled{opacity:.5;pointer-events:none}.url-import-tag{flex-shrink:0;padding:1px 6px;border-radius:8px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.url-import-tag.valid{background:#2ecc712e;color:#2ecc71}.url-import-tag.invalid{background:#e74c3c2e;color:#e74c3c}.tb-btn{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.tb-btn:hover{background:var(--bg-modifier-selected);color:var(--text-normal);border-color:#ffffff1f}.tb-btn .tb-icon{font-size:15px}.tb-btn.random{border-color:#5865f24d;color:var(--accent)}.tb-btn.random:hover{background:var(--accent);color:var(--white);border-color:var(--accent)}.tb-btn.party{border-color:#f0b2324d;color:var(--yellow)}.tb-btn.party:hover{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow)}.tb-btn.party.active{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow);animation:party-btn .6s ease-in-out infinite alternate}@keyframes party-btn{0%{box-shadow:0 0 8px #f0b23266}to{box-shadow:0 0 20px #f0b232b3}}.tb-btn.stop{border-color:#f23f424d;color:var(--red)}.tb-btn.stop:hover{background:var(--red);color:var(--white);border-color:var(--red)}.size-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.size-control .sc-icon{font-size:14px;color:var(--text-faint)}.size-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:70px;height:3px;border-radius:2px;background:var(--bg-modifier-selected);outline:none;cursor:pointer}.size-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.size-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.size-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.theme-selector{display:flex;align-items:center;gap:4px;padding:4px 8px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:all var(--transition);border:2px solid transparent}.theme-dot:hover{transform:scale(1.2)}.theme-dot.active{border-color:var(--white);box-shadow:0 0 6px #ffffff4d}.analytics-strip{display:flex;align-items:stretch;gap:8px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0}.analytics-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:12px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.analytics-card.analytics-wide{flex:1;min-width:0}.analytics-icon{font-size:18px;color:var(--accent);flex-shrink:0}.analytics-copy{display:flex;flex-direction:column;gap:4px;min-width:0}.analytics-label{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--text-faint)}.analytics-value{font-size:18px;line-height:1;font-weight:800;color:var(--text-normal)}.analytics-top-list{display:flex;align-items:center;gap:6px;overflow-x:auto;scrollbar-width:none}.analytics-top-list::-webkit-scrollbar{display:none}.analytics-chip{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:999px;background:rgba(var(--accent-rgb, 88, 101, 242),.15);color:var(--accent);font-size:11px;font-weight:600;white-space:nowrap}.analytics-muted{color:var(--text-muted);font-size:12px}.category-strip{display:flex;align-items:center;gap:6px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);overflow-x:auto;flex-shrink:0;scrollbar-width:none;transition:background .4s ease}.category-strip::-webkit-scrollbar{display:none}.cat-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;font-size:12px;font-weight:600;color:var(--text-muted);background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06);white-space:nowrap;cursor:pointer;transition:all var(--transition);flex-shrink:0}.cat-chip:hover{border-color:#ffffff1f;color:var(--text-normal);background:var(--bg-tertiary)}.cat-chip.active{background:#5865f21a}.cat-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.cat-count{font-size:10px;font-weight:700;opacity:.5}.main{flex:1;overflow-y:auto;padding:16px 20px;background:var(--bg-primary);transition:background .4s ease}.sound-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--card-size),1fr));gap:8px}.sound-card{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:12px 6px 8px;background:var(--bg-secondary);border-radius:var(--radius-lg);cursor:pointer;transition:all var(--transition);border:2px solid transparent;-webkit-user-select:none;user-select:none;overflow:hidden;aspect-ratio:1;opacity:0;animation:card-enter .35s ease-out forwards}.sound-card:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;opacity:0;transition:opacity var(--transition);background:radial-gradient(ellipse at center,var(--accent-glow) 0%,transparent 70%);pointer-events:none}.sound-card:hover{background:var(--bg-tertiary);transform:translateY(-3px);box-shadow:var(--shadow-med),0 0 20px var(--accent-glow);border-color:#5865f233}.sound-card:hover:before{opacity:1}.sound-card:active{transform:translateY(0);transition-duration:50ms}.sound-card.playing{border-color:var(--accent);animation:card-enter .35s ease-out forwards,playing-glow 1.2s ease-in-out infinite alternate}@keyframes playing-glow{0%{box-shadow:0 0 4px var(--accent-glow)}to{box-shadow:0 0 16px var(--accent-glow)}}@keyframes card-enter{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.ripple{position:absolute;border-radius:50%;background:#5865f24d;transform:scale(0);animation:ripple-expand .5s ease-out forwards;pointer-events:none}@keyframes ripple-expand{to{transform:scale(3);opacity:0}}.sound-emoji{font-size:var(--card-emoji);font-weight:800;line-height:1;z-index:1;transition:transform var(--transition);opacity:.7;font-family:Syne,DM Sans,sans-serif}.sound-card:hover .sound-emoji{transform:scale(1.15);opacity:1}.sound-card.playing .sound-emoji{animation:emoji-bounce .4s ease;opacity:1}@keyframes emoji-bounce{0%,to{transform:scale(1)}40%{transform:scale(1.3)}70%{transform:scale(.95)}}.sound-name{font-size:var(--card-font);font-weight:600;text-align:center;color:var(--text-normal);z-index:1;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 4px}.sound-duration{font-size:9px;color:var(--text-faint);z-index:1;font-weight:500}.fav-star{position:absolute;top:4px;right:4px;opacity:0;transition:all var(--transition);cursor:pointer;z-index:2;color:var(--text-faint);padding:2px;line-height:1}.fav-star .fav-icon{font-size:14px}.sound-card:hover .fav-star{opacity:.6}.fav-star:hover{opacity:1!important;color:var(--yellow);transform:scale(1.2)}.fav-star.active{opacity:1!important;color:var(--yellow)}.new-badge{position:absolute;top:4px;left:4px;font-size:8px;font-weight:700;background:var(--green);color:#fff;padding:1px 5px;border-radius:6px;text-transform:uppercase;letter-spacing:.03em;z-index:2}.playing-indicator{position:absolute;bottom:3px;left:50%;transform:translate(-50%);display:none;gap:2px;align-items:flex-end;height:10px}.sound-card.playing .playing-indicator{display:flex}.wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .6s ease-in-out infinite alternate}.wave-bar:nth-child(1){height:3px;animation-delay:0ms}.wave-bar:nth-child(2){height:7px;animation-delay:.15s}.wave-bar:nth-child(3){height:5px;animation-delay:.3s}.wave-bar:nth-child(4){height:9px;animation-delay:.1s}@keyframes wave{0%{height:2px}to{height:10px}}.empty-state{display:none;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:60px 20px;text-align:center}.empty-state.visible{display:flex}.empty-emoji{font-size:42px}.empty-title{font-size:15px;font-weight:700;color:var(--text-normal)}.empty-desc{font-size:13px;color:var(--text-muted);max-width:260px}.now-playing{display:flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;background:rgba(var(--accent-rgb, 88, 101, 242),.12);border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.2);font-size:12px;color:var(--text-muted);max-width:none;min-width:0;animation:np-fade-in .3s ease}@keyframes np-fade-in{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}.np-name{color:var(--accent);font-weight:600;white-space:nowrap}.np-waves{display:none;gap:1.5px;align-items:flex-end;height:12px;flex-shrink:0}.np-waves.active{display:flex}.np-wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .5s ease-in-out infinite alternate}.np-wave-bar:nth-child(1){height:3px;animation-delay:0ms}.np-wave-bar:nth-child(2){height:8px;animation-delay:.12s}.np-wave-bar:nth-child(3){height:5px;animation-delay:.24s}.np-wave-bar:nth-child(4){height:10px;animation-delay:80ms}.volume-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.vol-icon{font-size:16px;color:var(--text-faint);cursor:pointer;transition:color var(--transition);-webkit-user-select:none;user-select:none}.vol-icon:hover{color:var(--text-normal)}.vol-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:80px;height:3px;border-radius:2px;background:linear-gradient(to right,var(--accent) 0%,var(--accent) var(--vol, 80%),var(--bg-modifier-selected) var(--vol, 80%));outline:none;cursor:pointer}.vol-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.vol-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.vol-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.vol-pct{font-size:11px;color:var(--text-faint);min-width:28px;text-align:right;font-variant-numeric:tabular-nums}.party-overlay{position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;z-index:50;opacity:0;transition:opacity .3s ease}.party-overlay.active{opacity:1;animation:party-hue 2s linear infinite}.party-overlay:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(45deg,#ff00000a,#00ff000a,#0000ff0a,#ffff000a);background-size:400% 400%;animation:party-grad 3s ease infinite}@keyframes party-grad{0%{background-position:0% 50%}50%{background-position:100% 50%}to{background-position:0% 50%}}@keyframes party-hue{to{filter:hue-rotate(360deg)}}.ctx-menu{position:fixed;min-width:160px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.06);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:4px;z-index:1000;animation:ctx-in .1s ease-out}@keyframes ctx-in{0%{opacity:0;transform:scale(.96) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.ctx-item{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:4px;font-size:13px;color:var(--text-normal);cursor:pointer;transition:all var(--transition)}.ctx-item:hover{background:var(--accent);color:var(--white)}.ctx-item.danger{color:var(--red)}.ctx-item.danger:hover{background:var(--red);color:var(--white)}.ctx-item .ctx-icon{font-size:15px}.ctx-sep{height:1px;background:#ffffff0f;margin:3px 8px}.toast{position:fixed;bottom:64px;left:50%;transform:translate(-50%);padding:10px 20px;border-radius:20px;font-size:13px;font-weight:600;z-index:100;display:flex;align-items:center;gap:8px;box-shadow:var(--shadow-high);animation:toast-in .3s cubic-bezier(.175,.885,.32,1.275);pointer-events:none}.toast .toast-icon{font-size:16px}.toast.error{background:var(--red);color:#fff}.toast.info{background:var(--green);color:#fff}@keyframes toast-in{0%{transform:translate(-50%,16px);opacity:0}to{transform:translate(-50%);opacity:1}}.admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:60;display:flex;align-items:center;justify-content:center;animation:fade-in .2s ease}.admin-panel{background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius-lg);padding:28px;width:92%;max-width:920px;max-height:min(88vh,860px);display:flex;flex-direction:column;box-shadow:var(--shadow-high)}.admin-panel h3{font-size:18px;font-weight:700;margin-bottom:16px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.admin-close{width:28px;height:28px;border-radius:6px;display:flex;align-items:center;justify-content:center;color:var(--text-muted);transition:all var(--transition)}.admin-close:hover{background:var(--bg-tertiary);color:var(--text-normal)}.admin-field{margin-bottom:16px}.admin-field label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.admin-field input{width:100%;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:10px 12px;font-size:14px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-field input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.admin-btn-action{padding:10px 20px;border-radius:8px;font-size:13px;font-weight:600;font-family:var(--font);cursor:pointer;transition:all var(--transition);line-height:1}.admin-btn-action.primary{background:var(--accent);color:#fff;border:none}.admin-btn-action.primary:hover{background:var(--accent-hover)}.admin-btn-action.outline{background:transparent;border:1px solid rgba(255,255,255,.08);color:var(--text-muted)}.admin-btn-action.outline:hover{border-color:#ffffff1f;color:var(--text-normal)}.admin-btn-action.danger{background:var(--red);color:var(--white);border:1px solid var(--red)}.admin-btn-action.danger:hover{filter:brightness(1.06)}.admin-btn-action.danger.ghost{background:transparent;color:var(--red);border:1px solid rgba(242,63,66,.5)}.admin-btn-action.danger.ghost:hover{background:#f23f4224}.admin-btn-action:disabled{opacity:.5;pointer-events:none}.admin-shell{display:flex;flex-direction:column;gap:12px;min-height:0}.admin-header-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.admin-status{font-size:13px;color:var(--text-muted)}.admin-actions-inline{display:flex;align-items:center;gap:8px}.admin-search-field{margin-bottom:0}.admin-bulk-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border-radius:10px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);flex-wrap:wrap}.admin-select-all{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted)}.admin-select-all input,.admin-item-check input{accent-color:var(--accent)}.admin-list-wrap{min-height:260px;max-height:52vh;overflow-y:auto;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:var(--bg-primary)}.admin-list{display:flex;flex-direction:column;gap:6px;padding:6px}.admin-empty{padding:24px 12px;text-align:center;color:var(--text-muted);font-size:13px}.admin-item{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px;border-radius:8px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06)}.admin-item-main{min-width:0}.admin-item-name{font-size:14px;font-weight:600;color:var(--text-normal);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-meta{margin-top:3px;font-size:11px;color:var(--text-faint);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-actions{display:flex;align-items:center;gap:6px}.admin-item-actions .admin-btn-action,.admin-rename-row .admin-btn-action{padding:8px 12px;font-size:12px}.admin-rename-row{display:flex;align-items:center;gap:6px;margin-top:8px}.admin-rename-row input{flex:1;min-width:120px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:8px 10px;font-size:13px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-rename-row input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}@media(max-width:700px){.toolbar{gap:6px;padding:8px 12px}.cat-tabs{overflow-x:auto;scrollbar-width:none}.cat-tabs::-webkit-scrollbar{display:none}.search-wrap,.url-import-wrap{max-width:100%;min-width:100%;order:-1}.size-control,.theme-selector{display:none}.main{padding:12px}.topbar{padding:0 12px;gap:8px}.channel-label{max-width:100px;overflow:hidden;text-overflow:ellipsis}.clock{font-size:16px}.clock-seconds{font-size:11px}.tb-btn span:not(.tb-icon){display:none}.analytics-strip{padding:8px 12px;flex-direction:column;gap:6px}.analytics-card.analytics-wide{width:100%}.admin-panel{width:96%;padding:16px;max-height:92vh}.admin-item{grid-template-columns:24px minmax(0,1fr)}.admin-item-actions{grid-column:1 / -1;justify-content:flex-end}.admin-rename-row{flex-wrap:wrap}}@media(max-width:480px){.connection,.sb-app-title{display:none}.now-playing{max-width:none}.toolbar .tb-btn{padding:6px 8px}.url-import-btn{padding:0 8px}}.drop-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000c7;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);z-index:300;display:flex;align-items:center;justify-content:center;animation:fade-in .12s ease;pointer-events:none}.drop-zone{display:flex;flex-direction:column;align-items:center;gap:14px;padding:64px 72px;border-radius:24px;border:2.5px dashed rgba(var(--accent-rgb),.55);background:rgba(var(--accent-rgb),.07);animation:drop-pulse 2.2s ease-in-out infinite}@keyframes drop-pulse{0%,to{border-color:rgba(var(--accent-rgb),.45);box-shadow:0 0 rgba(var(--accent-rgb),0)}50%{border-color:rgba(var(--accent-rgb),.9);box-shadow:0 0 60px 12px rgba(var(--accent-rgb),.12)}}.drop-icon{font-size:64px;color:var(--accent);animation:drop-bounce 1.8s ease-in-out infinite}@keyframes drop-bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-8px)}}.drop-title{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:-.3px}.drop-sub{font-size:13px;color:var(--text-muted)}.upload-queue{position:fixed;bottom:24px;right:24px;width:340px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.09);border-radius:14px;box-shadow:0 8px 40px #00000073;z-index:200;animation:slide-up .2s cubic-bezier(.16,1,.3,1)}@keyframes slide-up{0%{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}.uq-header{display:flex;align-items:center;gap:8px;padding:12px 14px;background:rgba(var(--accent-rgb),.12);border-bottom:1px solid rgba(255,255,255,.06);font-size:13px;font-weight:600;color:var(--text-normal)}.uq-header .material-icons{color:var(--accent)}.uq-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition),color var(--transition)}.uq-close:hover{background:#ffffff24;color:var(--text-normal)}.uq-list{display:flex;flex-direction:column;max-height:260px;overflow-y:auto;padding:6px 0}.uq-item{display:grid;grid-template-columns:20px 1fr auto 18px;align-items:center;gap:8px;padding:8px 14px;position:relative}.uq-item+.uq-item{border-top:1px solid rgba(255,255,255,.04)}.uq-file-icon{font-size:18px;color:var(--text-faint)}.uq-info{min-width:0}.uq-name{font-size:12px;font-weight:500;color:var(--text-normal);white-space:nowrap;text-overflow:ellipsis}.uq-size{font-size:10px;color:var(--text-faint);margin-top:1px}.uq-progress-wrap{grid-column:1 / -1;height:3px;background:#ffffff12;border-radius:2px;margin-top:4px}.uq-item{flex-wrap:wrap}.uq-progress-wrap{width:100%;order:10}.uq-progress-bar{height:100%;background:var(--accent);border-radius:2px;transition:width .12s ease}.uq-status-icon{font-size:16px}.uq-status-waiting .uq-status-icon{color:var(--text-faint)}.uq-status-uploading .uq-status-icon{color:var(--accent);animation:spin 1s linear infinite}.uq-status-done .uq-status-icon{color:var(--green)}.uq-status-error .uq-status-icon{color:var(--red)}.uq-error{grid-column:2 / -1;font-size:10px;color:var(--red);margin-top:2px}.dl-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;display:flex;align-items:center;justify-content:center;z-index:300;animation:fade-in .15s ease}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.dl-modal{width:420px;max-width:92vw;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.1);border-radius:16px;box-shadow:0 12px 60px #00000080;animation:scale-in .2s cubic-bezier(.16,1,.3,1)}@keyframes scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.dl-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.06);font-size:14px;font-weight:700;color:var(--text-normal)}.dl-modal-header .material-icons{color:var(--accent)}.dl-modal-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition)}.dl-modal-close:hover{background:#ffffff24;color:var(--text-normal)}.dl-modal-body{padding:16px;display:flex;flex-direction:column;gap:14px}.dl-modal-url{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:8px;background:#0003;overflow:hidden}.dl-modal-tag{flex-shrink:0;padding:2px 8px;border-radius:6px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.dl-modal-tag.youtube{background:#ff00002e;color:#f44}.dl-modal-tag.instagram{background:#e1306c2e;color:#e1306c}.dl-modal-tag.mp3{background:#2ecc712e;color:#2ecc71}.dl-modal-url-text{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-modal-field{display:flex;flex-direction:column;gap:5px}.dl-modal-label{font-size:11px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.dl-modal-input-wrap{display:flex;align-items:center;border:1px solid rgba(255,255,255,.1);border-radius:8px;background:#00000026;overflow:hidden;transition:border-color var(--transition)}.dl-modal-input-wrap:focus-within{border-color:var(--accent)}.dl-modal-input{flex:1;border:none;background:transparent;padding:8px 10px;color:var(--text-normal);font-size:13px;font-family:var(--font);outline:none}.dl-modal-input::placeholder{color:var(--text-faint)}.dl-modal-ext{padding:0 10px;font-size:12px;font-weight:600;color:var(--text-faint);background:#ffffff0a;align-self:stretch;display:flex;align-items:center}.dl-modal-hint{font-size:10px;color:var(--text-faint)}.dl-modal-progress{display:flex;align-items:center;gap:12px;padding:20px 0;justify-content:center;font-size:13px;color:var(--text-muted)}.dl-modal-spinner{width:24px;height:24px;border-radius:50%;border:3px solid rgba(var(--accent-rgb),.2);border-top-color:var(--accent);animation:spin .8s linear infinite}.dl-modal-success{display:flex;align-items:center;gap:10px;padding:16px 0;justify-content:center;font-size:13px;color:var(--text-normal)}.dl-modal-check{color:#2ecc71;font-size:28px}.dl-modal-error{display:flex;align-items:center;gap:10px;padding:12px 0;justify-content:center;font-size:13px;color:#e74c3c}.dl-modal-actions{display:flex;justify-content:flex-end;gap:8px;padding:0 16px 14px}.dl-modal-cancel{padding:7px 14px;border-radius:8px;border:1px solid rgba(255,255,255,.1);background:transparent;color:var(--text-muted);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition)}.dl-modal-cancel:hover{background:#ffffff0f;color:var(--text-normal)}.dl-modal-submit{display:flex;align-items:center;gap:5px;padding:7px 16px;border-radius:8px;border:none;background:var(--accent);color:#fff;font-size:12px;font-weight:700;cursor:pointer;transition:filter var(--transition)}.dl-modal-submit:hover{filter:brightness(1.15)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.lol-container{max-width:920px;margin:0 auto;padding:16px;height:100%;overflow-y:auto}.lol-search{display:flex;gap:8px;margin-bottom:12px}.lol-search-input{flex:1;min-width:0;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:15px;outline:none;transition:border-color .2s}.lol-search-input:focus{border-color:var(--accent)}.lol-search-input::placeholder{color:var(--text-faint)}.lol-search-region{padding:10px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none}.lol-search-btn{padding:10px 20px;border:none;border-radius:8px;background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:opacity .2s;white-space:nowrap}.lol-search-btn:hover{opacity:.85}.lol-search-btn:disabled{opacity:.4;cursor:not-allowed}.lol-recent{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:16px}.lol-recent-chip{display:flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;cursor:pointer;transition:border-color .2s,color .2s}.lol-recent-chip:hover{border-color:var(--accent);color:var(--text-normal)}.lol-recent-chip img{width:18px;height:18px;border-radius:50%}.lol-recent-tier{font-size:10px;font-weight:600;opacity:.7;text-transform:uppercase}.lol-profile{display:flex;align-items:center;gap:16px;padding:16px;border-radius:12px;background:var(--bg-secondary);margin-bottom:12px}.lol-profile-icon{width:72px;height:72px;border-radius:12px;border:2px solid var(--bg-tertiary);object-fit:cover}.lol-profile-info h2{margin:0 0 2px;font-size:20px;color:var(--text-normal)}.lol-profile-info h2 span{color:var(--text-faint);font-weight:400;font-size:14px}.lol-profile-level{font-size:12px;color:var(--text-muted)}.lol-profile-ladder{font-size:11px;color:var(--text-faint)}.lol-profile-updated{font-size:10px;color:var(--text-faint);margin-top:2px}.lol-profile-info{flex:1;min-width:0}.lol-update-btn{display:flex;align-items:center;gap:6px;padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-primary);color:var(--text-muted);font-size:13px;font-weight:500;cursor:pointer;transition:border-color .2s,color .2s,background .2s;white-space:nowrap;flex-shrink:0}.lol-update-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-update-btn:disabled{opacity:.6;cursor:not-allowed}.lol-update-btn.renewing{border-color:var(--accent);color:var(--accent)}.lol-update-icon{font-size:16px;display:inline-block}.lol-update-btn.renewing .lol-update-icon{animation:lol-spin 1s linear infinite}.lol-ranked-row{display:flex;gap:10px;margin-bottom:12px}.lol-ranked-card{flex:1;padding:12px 14px;border-radius:10px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary)}.lol-ranked-card.has-rank{border-left-color:var(--tier-color, var(--accent))}.lol-ranked-type{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}.lol-ranked-tier{font-size:18px;font-weight:700;color:var(--tier-color, var(--text-normal))}.lol-ranked-lp{font-size:13px;color:var(--text-muted);margin-left:4px;font-weight:400}.lol-ranked-record{font-size:12px;color:var(--text-muted);margin-top:2px}.lol-ranked-wr{color:var(--text-faint);margin-left:4px}.lol-ranked-streak{color:#e74c3c;font-size:11px;margin-left:4px}.lol-section-title{font-size:13px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;margin:16px 0 8px;padding-left:2px}.lol-champs{display:flex;gap:8px;margin-bottom:12px;overflow-x:auto;padding-bottom:4px}.lol-champ-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:8px;background:var(--bg-secondary);min-width:180px;flex-shrink:0}.lol-champ-icon{width:36px;height:36px;border-radius:50%;object-fit:cover}.lol-champ-name{font-size:13px;font-weight:600;color:var(--text-normal)}.lol-champ-stats{font-size:11px;color:var(--text-muted)}.lol-champ-kda{font-size:11px;color:var(--text-faint)}.lol-matches{display:flex;flex-direction:column;gap:6px}.lol-match{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary);cursor:pointer;transition:background .15s}.lol-match:hover{background:var(--bg-tertiary)}.lol-match.win{border-left-color:#2ecc71}.lol-match.loss{border-left-color:#e74c3c}.lol-match-result{width:28px;font-size:11px;font-weight:700;text-align:center;flex-shrink:0}.lol-match.win .lol-match-result{color:#2ecc71}.lol-match.loss .lol-match-result{color:#e74c3c}.lol-match-champ{position:relative;flex-shrink:0}.lol-match-champ img{width:40px;height:40px;border-radius:50%;display:block}.lol-match-champ-level{position:absolute;bottom:-2px;right:-2px;background:var(--bg-deep);color:var(--text-muted);font-size:9px;font-weight:700;width:16px;height:16px;border-radius:50%;display:flex;align-items:center;justify-content:center}.lol-match-kda{min-width:80px;text-align:center;flex-shrink:0}.lol-match-kda-nums{font-size:14px;font-weight:600;color:var(--text-normal)}.lol-match-kda-ratio{font-size:11px;color:var(--text-faint)}.lol-match-kda-ratio.perfect{color:#f39c12}.lol-match-kda-ratio.great{color:#2ecc71}.lol-match-stats{display:flex;flex-direction:column;gap:1px;min-width:70px;flex-shrink:0}.lol-match-stats span{font-size:11px;color:var(--text-muted)}.lol-match-items{display:flex;gap:2px;flex-shrink:0}.lol-match-items img,.lol-match-item-empty{width:24px;height:24px;border-radius:4px;background:var(--bg-deep)}.lol-match-meta{margin-left:auto;text-align:right;flex-shrink:0}.lol-match-duration{font-size:12px;color:var(--text-muted)}.lol-match-queue,.lol-match-ago{font-size:10px;color:var(--text-faint)}.lol-match-detail{background:var(--bg-primary);border-radius:8px;padding:8px;margin-top:4px;margin-bottom:4px}.lol-match-detail-team{margin-bottom:6px}.lol-match-detail-team-header{font-size:11px;font-weight:600;padding:4px 8px;border-radius:4px;margin-bottom:4px}.lol-match-detail-team-header.win{background:#2ecc7126;color:#2ecc71}.lol-match-detail-team-header.loss{background:#e74c3c26;color:#e74c3c}.lol-detail-row{display:flex;align-items:center;gap:8px;padding:3px 8px;border-radius:4px;font-size:12px;color:var(--text-muted)}.lol-detail-row:hover{background:var(--bg-secondary)}.lol-detail-row.me{background:#ffffff0a;font-weight:600}.lol-detail-champ{width:24px;height:24px;border-radius:50%}.lol-detail-name{width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-normal)}.lol-detail-kda{width:70px;text-align:center}.lol-detail-cs{width:45px;text-align:center}.lol-detail-dmg,.lol-detail-gold{width:55px;text-align:center}.lol-detail-items{display:flex;gap:1px}.lol-detail-items img{width:20px;height:20px;border-radius:3px}.lol-loading{display:flex;align-items:center;justify-content:center;gap:10px;padding:40px;color:var(--text-muted);font-size:14px}.lol-spinner{width:20px;height:20px;border:2px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:lol-spin .8s linear infinite}@keyframes lol-spin{to{transform:rotate(360deg)}}.lol-error{padding:16px;border-radius:8px;background:#e74c3c1a;color:#e74c3c;font-size:13px;text-align:center;margin-bottom:12px}.lol-empty{text-align:center;padding:60px 20px;color:var(--text-faint)}.lol-empty-icon{font-size:48px;margin-bottom:12px}.lol-empty h3{margin:0 0 8px;color:var(--text-muted);font-size:16px}.lol-empty p{margin:0;font-size:13px}.lol-load-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--bg-tertiary);border-radius:8px;background:transparent;color:var(--text-muted);font-size:13px;cursor:pointer;transition:border-color .2s,color .2s}.lol-load-more:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-section{margin-top:24px;padding-top:16px;border-top:1px solid var(--bg-tertiary)}.lol-tier-controls{display:flex;gap:8px;align-items:center;margin-bottom:12px;flex-wrap:wrap}.lol-tier-modes{display:flex;gap:4px;flex-wrap:wrap}.lol-tier-mode-btn{padding:6px 14px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;font-weight:500;cursor:pointer;transition:all .2s;white-space:nowrap}.lol-tier-mode-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-mode-btn.active{background:var(--accent);border-color:var(--accent);color:#fff}.lol-tier-filter{padding:6px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:12px;outline:none;width:140px;margin-left:auto}.lol-tier-filter:focus{border-color:var(--accent)}.lol-tier-filter::placeholder{color:var(--text-faint)}.lol-tier-table{display:flex;flex-direction:column;gap:2px}.lol-tier-header{display:flex;align-items:center;gap:8px;padding:6px 10px;font-size:10px;font-weight:600;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px}.lol-tier-row{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:6px;background:var(--bg-secondary);font-size:13px;color:var(--text-muted);transition:background .15s}.lol-tier-row:hover{background:var(--bg-tertiary)}.lol-tier-row.tier-0{border-left:3px solid #f4c874}.lol-tier-row.tier-1{border-left:3px solid #d4a017}.lol-tier-row.tier-2{border-left:3px solid #576cce}.lol-tier-row.tier-3{border-left:3px solid #28b29e}.lol-tier-row.tier-4{border-left:3px solid var(--bg-tertiary)}.lol-tier-row.tier-5{border-left:3px solid var(--bg-tertiary);opacity:.7}.lol-tier-col-rank{width:32px;text-align:center;font-weight:600;flex-shrink:0}.lol-tier-col-champ{flex:1;display:flex;align-items:center;gap:8px;min-width:0;font-weight:500;color:var(--text-normal)}.lol-tier-col-champ img{width:28px;height:28px;border-radius:50%;flex-shrink:0}.lol-tier-col-tier{width:36px;text-align:center;font-weight:700;font-size:12px;flex-shrink:0}.lol-tier-col-wr,.lol-tier-col-pr,.lol-tier-col-br{width:60px;text-align:center;flex-shrink:0}.lol-tier-col-kda{width:50px;text-align:center;flex-shrink:0}.tier-badge-0{color:#f4c874}.tier-badge-1{color:#d4a017}.tier-badge-2{color:#576cce}.tier-badge-3{color:#28b29e}.tier-badge-4,.tier-badge-5{color:var(--text-faint)}@media(max-width:640px){.lol-search{flex-wrap:wrap}.lol-search-input{width:100%}.lol-match{flex-wrap:wrap;gap:6px}.lol-match-meta{margin-left:0;text-align:left}.lol-match-items,.lol-profile{flex-wrap:wrap}.lol-tier-controls{flex-direction:column;align-items:stretch}.lol-tier-filter{width:100%;margin-left:0}.lol-tier-col-br,.lol-tier-col-kda{display:none}}.stream-container{height:100%;overflow-y:auto;padding:16px}.stream-topbar{display:flex;align-items:flex-end;gap:10px;margin-bottom:16px;flex-wrap:wrap}.stream-field{display:flex;flex-direction:column;gap:4px}.stream-field-grow{flex:1;min-width:180px}.stream-field-label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:var(--text-faint);padding-left:2px}.stream-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0;width:100%;box-sizing:border-box}.stream-input:focus{border-color:var(--accent)}.stream-input::placeholder{color:var(--text-faint)}.stream-input-name{width:150px}.stream-input-title{width:100%}.stream-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.stream-btn:hover{background:var(--accent-hover)}.stream-btn:disabled{opacity:.5;cursor:not-allowed}.stream-btn-stop{background:var(--danger)}.stream-btn-stop:hover{background:#c93b3e}.stream-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.stream-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.stream-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.stream-tile.own{border:2px solid var(--accent)}.stream-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.stream-tile-preview video{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover}.stream-tile-preview .stream-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.stream-live-badge{position:absolute;top:8px;left:8px;background:var(--danger);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;letter-spacing:.5px;display:flex;align-items:center;gap:4px}.stream-live-dot{width:6px;height:6px;border-radius:50%;background:#fff;animation:stream-pulse 1.5s ease-in-out infinite}@keyframes stream-pulse{0%,to{opacity:1}50%{opacity:.3}}.stream-tile-viewers{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.stream-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.stream-tile-meta{min-width:0;flex:1}.stream-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-title{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-time{font-size:12px;color:var(--text-faint);white-space:nowrap}.stream-tile-menu-wrap{position:relative}.stream-tile-menu{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 6px;font-size:18px;line-height:1;border-radius:4px;transition:background var(--transition)}.stream-tile-menu:hover{background:var(--bg-tertiary);color:var(--text-normal)}.stream-tile-dropdown{position:absolute;bottom:calc(100% + 6px);right:0;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius-lg);min-width:220px;z-index:100;box-shadow:0 8px 24px #0006;overflow:hidden}.stream-tile-dropdown-header{padding:12px 14px}.stream-tile-dropdown-name{font-size:14px;font-weight:600;color:var(--text-normal)}.stream-tile-dropdown-title{font-size:12px;color:var(--text-muted);margin-top:2px}.stream-tile-dropdown-detail{font-size:11px;color:var(--text-faint);margin-top:6px}.stream-tile-dropdown-divider{height:1px;background:var(--bg-tertiary)}.stream-tile-dropdown-item{display:flex;align-items:center;gap:8px;width:100%;padding:10px 14px;border:none;background:none;color:var(--text-normal);font-size:13px;cursor:pointer;text-align:left;transition:background var(--transition)}.stream-tile-dropdown-item:hover{background:var(--bg-tertiary)}.stream-viewer-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.stream-viewer-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1}.stream-viewer-header-left{display:flex;align-items:center;gap:12px}.stream-viewer-title{font-weight:600;font-size:16px}.stream-viewer-subtitle{font-size:13px;color:var(--text-muted)}.stream-viewer-header-right{display:flex;align-items:center;gap:8px}.stream-viewer-fullscreen{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.stream-viewer-fullscreen:hover{background:#ffffff40}.stream-viewer-close{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.stream-viewer-close:hover{background:#fff3}.stream-viewer-video{flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden}.stream-viewer-video video{max-width:100%;max-height:100%;width:100%;height:100%;object-fit:contain}.stream-viewer-connecting{color:var(--text-muted);font-size:16px;display:flex;flex-direction:column;align-items:center;gap:12px}.stream-viewer-spinner{width:32px;height:32px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:stream-spin .8s linear infinite}@keyframes stream-spin{to{transform:rotate(360deg)}}.stream-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.stream-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.stream-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.stream-empty p{font-size:14px}.stream-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.stream-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.stream-tile.broadcasting .stream-tile-preview{border:2px solid var(--danger);border-bottom:none}.stream-input-password{width:180px}.stream-select-quality{width:210px;box-sizing:border-box;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none;transition:border-color var(--transition)}.stream-select-quality:focus{border-color:var(--accent)}.stream-select-quality:disabled{opacity:.5;cursor:not-allowed}.stream-select-quality option{background:var(--bg-secondary);color:var(--text-normal)}.stream-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.stream-pw-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.stream-pw-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.stream-pw-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.stream-pw-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.stream-pw-modal .stream-input{width:100%;margin-bottom:12px}.stream-pw-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.stream-pw-actions{display:flex;gap:8px;justify-content:flex-end}.stream-pw-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.stream-pw-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.stream-admin-btn{margin-left:auto;padding:8px;border:none;border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:18px;cursor:pointer;transition:all var(--transition);line-height:1}.stream-admin-btn:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;display:flex;align-items:center;justify-content:center;z-index:999;animation:fadeIn .15s ease}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.stream-admin-panel{background:var(--bg-secondary);border-radius:12px;width:560px;max-width:95vw;max-height:80vh;display:flex;flex-direction:column;box-shadow:0 8px 32px #0006;overflow:hidden}.stream-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-header h3{margin:0;font-size:16px;color:var(--text-normal)}.stream-admin-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:var(--radius)}.stream-admin-close:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-login{padding:24px 20px}.stream-admin-login p{margin:0 0 12px;color:var(--text-muted);font-size:14px}.stream-admin-login-row{display:flex;gap:8px}.stream-admin-login-row .stream-input{flex:1}.stream-admin-error{color:#ed4245;font-size:13px;margin-top:8px}.stream-admin-content{padding:16px 20px;overflow-y:auto}.stream-admin-toolbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;padding-bottom:12px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-status{font-size:13px;color:var(--text-muted)}.stream-admin-status b{color:var(--text-normal)}.stream-admin-logout{padding:4px 12px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:12px;cursor:pointer}.stream-admin-logout:hover{color:#ed4245;border-color:#ed4245}.stream-admin-loading,.stream-admin-empty{text-align:center;padding:32px 16px;color:var(--text-muted);font-size:14px}.stream-admin-hint{margin:0 0 12px;color:var(--text-muted);font-size:13px}.stream-admin-channel-list{display:flex;flex-direction:column;gap:8px;max-height:45vh;overflow-y:auto}.stream-admin-channel{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:var(--bg-deep);border-radius:var(--radius);gap:12px}.stream-admin-channel-info{display:flex;flex-direction:column;gap:2px;min-width:0}.stream-admin-channel-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-admin-channel-guild{font-size:11px;color:var(--text-faint)}.stream-admin-channel-events{display:flex;gap:6px;flex-shrink:0}.stream-admin-event-toggle{display:flex;align-items:center;gap:4px;padding:4px 10px;border-radius:14px;font-size:12px;color:var(--text-muted);background:var(--bg-secondary);cursor:pointer;transition:all var(--transition);white-space:nowrap}.stream-admin-event-toggle input{display:none}.stream-admin-event-toggle:hover{color:var(--text-normal)}.stream-admin-event-toggle.active{background:var(--accent);color:#fff}.stream-admin-actions{margin-top:16px;display:flex;justify-content:flex-end}.stream-admin-save{padding:8px 24px}.wt-container{height:100%;overflow-y:auto;padding:16px}.wt-topbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}.wt-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0}.wt-input:focus{border-color:var(--accent)}.wt-input::placeholder{color:var(--text-faint)}.wt-input-name{width:150px}.wt-input-room{flex:1;min-width:180px}.wt-input-password{width:170px}.wt-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.wt-btn:hover{background:var(--accent-hover)}.wt-btn:disabled{opacity:.5;cursor:not-allowed}.wt-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.wt-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.wt-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.wt-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.wt-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.wt-tile-members{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.wt-tile-playing{position:absolute;top:8px;left:8px;background:var(--accent);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.wt-tile-meta{min-width:0;flex:1}.wt-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-tile-host{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.wt-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.wt-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.wt-empty p{font-size:14px}.wt-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.wt-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.wt-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.wt-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.wt-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.wt-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.wt-modal .wt-input{width:100%;margin-bottom:12px}.wt-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.wt-modal-actions{display:flex;gap:8px;justify-content:flex-end}.wt-modal-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.wt-modal-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.wt-room-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.wt-room-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1;flex-shrink:0}.wt-room-header-left{display:flex;align-items:center;gap:12px}.wt-room-name{font-weight:600;font-size:16px}.wt-room-members{font-size:13px;color:var(--text-muted)}.wt-host-badge{font-size:11px;background:#ffffff1a;padding:2px 8px;border-radius:4px;color:var(--accent);font-weight:600}.wt-room-header-right{display:flex;align-items:center;gap:8px}.wt-fullscreen-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.wt-fullscreen-btn:hover{background:#ffffff40}.wt-leave-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.wt-leave-btn:hover{background:#fff3}.wt-room-body{display:flex;flex:1;overflow:hidden}.wt-player-section{flex:1;display:flex;flex-direction:column;min-width:0}.wt-player-wrap{position:relative;width:100%;flex:1;background:#000;display:flex;align-items:center;justify-content:center;overflow:hidden}.wt-yt-container{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}.wt-yt-container iframe{width:100%;height:100%}.wt-video-element{width:100%;height:100%;object-fit:contain}.wt-dm-container{width:100%;height:100%;border:none;position:absolute;top:0;left:0}.wt-player-placeholder{display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--text-muted);font-size:16px}.wt-placeholder-icon{font-size:48px;opacity:.3}.wt-controls{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#000c;flex-shrink:0}.wt-ctrl-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;transition:background var(--transition);flex-shrink:0}.wt-ctrl-btn:hover:not(:disabled){background:#ffffff40}.wt-ctrl-btn:disabled{opacity:.3;cursor:not-allowed}.wt-ctrl-status{color:var(--text-muted);font-size:16px;width:36px;text-align:center;flex-shrink:0}.wt-seek{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer;min-width:60px}.wt-seek::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-webkit-slider-runnable-track{height:4px;border-radius:2px}.wt-seek::-moz-range-track{height:4px;border-radius:2px;background:var(--bg-tertiary)}.wt-seek-readonly{flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);position:relative;overflow:hidden;min-width:60px}.wt-seek-progress{position:absolute;top:0;left:0;height:100%;background:var(--accent);border-radius:2px;transition:width .3s linear}.wt-time{font-variant-numeric:tabular-nums;color:#fff;font-size:13px;white-space:nowrap;flex-shrink:0}.wt-volume{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.wt-volume-icon{font-size:16px;width:20px;text-align:center;cursor:default}.wt-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer}.wt-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-quality-select{background:var(--bg-secondary, #2a2a3e);color:var(--text-primary, #e0e0e0);border:1px solid var(--border-color, #3a3a4e);border-radius:6px;padding:2px 6px;font-size:12px;cursor:pointer;outline:none;margin-left:4px}.wt-quality-select:hover{border-color:var(--accent, #7c5cff)}.wt-queue-panel{width:280px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-queue-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-list{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-queue-list::-webkit-scrollbar{width:4px}.wt-queue-list::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-queue-empty{padding:24px 16px;text-align:center;color:var(--text-faint);font-size:13px}.wt-queue-item{padding:10px 12px;border-bottom:1px solid var(--bg-tertiary);display:flex;align-items:center;gap:8px;transition:background var(--transition)}.wt-queue-item:hover{background:var(--bg-tertiary)}.wt-queue-item.playing{border-left:3px solid var(--accent);background:#e67e2214}.wt-queue-item-info{flex:1;min-width:0}.wt-queue-item-title{font-size:13px;font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-queue-item-by{font-size:11px;color:var(--text-faint);margin-top:2px}.wt-queue-item-remove{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:18px;padding:2px 6px;border-radius:4px;transition:all var(--transition);flex-shrink:0}.wt-queue-item-remove:hover{color:var(--danger);background:#ed42451f}.wt-queue-add{padding:12px;display:flex;gap:8px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-input{flex:1;font-size:13px;padding:8px 10px}.wt-queue-add-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-player-error{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:#000000d9;color:#fff;z-index:2;text-align:center;padding:20px}.wt-error-icon{font-size:48px}.wt-player-error p{font-size:15px;color:var(--text-muted);margin:0}.wt-yt-link{display:inline-block;padding:8px 20px;background:red;color:#fff;border-radius:var(--radius);text-decoration:none;font-weight:600;font-size:14px;transition:background var(--transition)}.wt-yt-link:hover{background:#c00}.wt-skip-info{font-size:12px!important;color:var(--text-faint)!important;font-style:italic}.wt-queue-item.clickable{cursor:pointer}.wt-queue-item.clickable:hover{background:#e67e221f}@media(max-width:768px){.wt-room-body{flex-direction:column}.wt-queue-panel{width:100%;max-height:40vh;border-left:none;border-top:1px solid var(--bg-tertiary)}.wt-player-wrap{min-height:200px}.wt-controls{flex-wrap:wrap;gap:8px;padding:10px 12px}.wt-volume{margin-left:0}.wt-volume-slider{width:80px}.wt-room-header{padding:10px 12px}.wt-room-name{font-size:14px}.wt-room-members,.wt-host-badge{font-size:11px}}@media(max-width:480px){.wt-topbar{gap:8px}.wt-input-name{width:100%}.wt-input-room{min-width:0}.wt-input-password{width:100%}.wt-volume-slider{width:60px}.wt-time{font-size:12px}.wt-host-badge{display:none}}.wt-queue-item.watched{opacity:.55;transition:opacity var(--transition),background var(--transition)}.wt-queue-item.watched:hover{opacity:.85}.wt-queue-item-check{color:#2ecc71;font-size:16px;font-weight:700;flex-shrink:0;line-height:1}.wt-queue-item-info{display:flex;align-items:center;gap:10px;min-width:0;flex:1}.wt-queue-thumb{width:48px;height:36px;object-fit:cover;border-radius:4px;flex-shrink:0}.wt-queue-item-text{min-width:0;flex:1}.wt-next-btn{display:flex;align-items:center;gap:4px;font-size:13px;padding:6px 12px;white-space:nowrap}.wt-sync-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.wt-sync-synced{background:#2ecc71;box-shadow:0 0 6px #2ecc7180}.wt-sync-drifting{background:#f1c40f;box-shadow:0 0 6px #f1c40f80}.wt-sync-desynced{background:#e74c3c;box-shadow:0 0 6px #e74c3c80}.wt-vote-btn{background:#ffffff14!important;border:1px solid rgba(255,255,255,.15)!important}.wt-vote-btn:hover:not(:disabled){background:#e67e2233!important;border-color:var(--accent)!important}.wt-vote-count{font-size:12px;color:var(--accent);font-weight:600;white-space:nowrap;padding:2px 8px;background:#e67e221f;border-radius:4px}.wt-header-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:13px;transition:background var(--transition)}.wt-header-btn:hover{background:#fff3}.wt-chat-panel{width:260px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-chat-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-messages{flex:1;overflow-y:auto;padding:8px 12px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-chat-messages::-webkit-scrollbar{width:4px}.wt-chat-messages::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-chat-empty{padding:24px 8px;text-align:center;color:var(--text-faint);font-size:13px}.wt-chat-msg{margin-bottom:6px;font-size:13px;line-height:1.4;word-break:break-word}.wt-chat-sender{font-weight:600;color:var(--accent);margin-right:6px}.wt-chat-text{color:var(--text-normal)}.wt-chat-input-row{padding:10px 12px;display:flex;gap:6px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-input{flex:1;font-size:13px;padding:8px 10px}.wt-chat-send-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-queue-header{display:flex;align-items:center;justify-content:space-between}.wt-queue-clear-btn{background:none;border:none;color:var(--text-faint);font-size:11px;cursor:pointer;padding:2px 6px;border-radius:4px;transition:all var(--transition)}.wt-queue-clear-btn:hover{color:var(--danger);background:#ed42451f}.wt-tile-members-list{font-size:11px;color:var(--text-faint);padding:0 12px 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:768px){.wt-chat-panel{width:100%;max-height:30vh;border-left:none;border-top:1px solid var(--bg-tertiary)}}.gl-container{padding:20px;max-width:1200px;margin:0 auto}.gl-login-bar{display:flex;gap:10px;margin-bottom:12px}.gl-connect-btn{color:#c7d5e0;padding:10px 20px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:all var(--transition);white-space:nowrap}.gl-steam-btn{background:#1b2838;border:1px solid #2a475e}.gl-steam-btn:hover{background:#2a475e;color:#fff}.gl-gog-btn{background:#2c1a4e;border:1px solid #4a2d7a;color:#c7b3e8}.gl-gog-btn:hover{background:#3d2566;color:#fff}.gl-profile-chips{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}.gl-profile-chip{display:flex;align-items:center;gap:8px;padding:6px 12px;border-radius:20px;background:#ffffff0d;border:1px solid rgba(255,255,255,.1);cursor:pointer;transition:all .2s}.gl-profile-chip.selected{border-color:#e67e22;background:#e67e221a}.gl-profile-chip:hover{background:#ffffff1a}.gl-profile-chip-avatar{width:28px;height:28px;border-radius:50%}.gl-profile-chip-info{display:flex;flex-direction:column;gap:2px}.gl-profile-chip-name{font-size:13px;font-weight:600;color:#e0e0e0}.gl-profile-chip-platforms{display:flex;gap:4px}.gl-profile-chip-count{font-size:11px;color:#667}.gl-platform-badge{font-size:9px;font-weight:700;padding:1px 5px;border-radius:3px;text-transform:uppercase}.gl-platform-badge.steam{background:#1b2838cc;color:#66c0f4;border:1px solid #2a475e}.gl-platform-badge.gog{background:#2c1a4ecc;color:#b388ff;border:1px solid #4a2d7a}.gl-game-platform-icon{font-size:9px;font-weight:700;padding:1px 4px;border-radius:3px;margin-right:6px;flex-shrink:0}.gl-game-platform-icon.steam{background:#1b283899;color:#66c0f4}.gl-game-platform-icon.gog{background:#2c1a4e99;color:#b388ff}.gl-users-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;margin-bottom:32px}.gl-user-card{background:var(--bg-secondary);border-radius:var(--radius);padding:16px;display:flex;flex-direction:column;align-items:center;gap:10px;cursor:pointer;transition:all var(--transition);border:1px solid var(--bg-tertiary)}.gl-user-card:hover{border-color:var(--accent);transform:translateY(-2px)}.gl-user-card-avatar{width:64px;height:64px;border-radius:50%}.gl-user-card-name{font-weight:600;font-size:15px;color:var(--text-normal)}.gl-user-card-games{font-size:13px;color:var(--text-faint)}.gl-user-card-updated{font-size:11px;color:var(--text-faint)}.gl-profile-card-platforms{display:flex;gap:6px;margin-top:4px}.gl-common-finder{background:var(--bg-secondary);border-radius:var(--radius);padding:20px;margin-bottom:24px}.gl-common-finder h3{margin:0 0 12px;font-size:15px;color:var(--text-normal)}.gl-common-users{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}.gl-common-check{display:flex;align-items:center;gap:6px;background:var(--bg-tertiary);padding:6px 12px 6px 6px;border-radius:20px;cursor:pointer;transition:all var(--transition)}.gl-common-check.checked{background:#e67e2226}.gl-common-check input{accent-color:var(--accent)}.gl-common-check-avatar{width:24px;height:24px;border-radius:50%}.gl-common-find-btn{background:var(--accent);color:#fff;border:none;padding:10px 24px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:background var(--transition)}.gl-common-find-btn:hover{filter:brightness(1.1)}.gl-common-find-btn:disabled{opacity:.5;cursor:not-allowed}.gl-search{margin-bottom:24px}.gl-search-input{width:100%;padding:10px 14px;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);box-sizing:border-box}.gl-search-input:focus{border-color:var(--accent)}.gl-search-input::placeholder{color:var(--text-faint)}.gl-game-list{display:flex;flex-direction:column;gap:4px}.gl-game-item{display:flex;align-items:center;gap:12px;padding:8px 12px;background:var(--bg-secondary);border-radius:var(--radius);transition:background var(--transition)}.gl-game-item:hover{background:var(--bg-tertiary)}.gl-game-icon{width:32px;height:32px;border-radius:4px;flex-shrink:0;background:var(--bg-tertiary)}.gl-game-name{flex:1;font-size:14px;color:var(--text-normal)}.gl-game-playtime{font-size:12px;color:var(--text-faint);white-space:nowrap}.gl-game-owners{display:flex;gap:4px}.gl-game-owner-avatar{width:20px;height:20px;border-radius:50%;border:1px solid var(--bg-tertiary)}.gl-detail-header{display:flex;align-items:center;gap:16px;margin-bottom:24px}.gl-back-btn{background:var(--bg-secondary);border:none;color:var(--text-normal);padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.gl-back-btn:hover{background:var(--bg-tertiary)}.gl-detail-avatar{width:48px;height:48px;border-radius:50%}.gl-detail-info{flex:1}.gl-detail-name{font-size:18px;font-weight:600;color:var(--text-normal)}.gl-detail-sub{font-size:13px;color:var(--text-faint);display:flex;align-items:center;gap:6px;margin-top:4px}.gl-refresh-btn{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:16px;padding:4px;transition:color var(--transition)}.gl-refresh-btn:hover{color:var(--accent)}.gl-platform-detail{display:inline-flex;align-items:center;gap:2px}.gl-disconnect-btn{background:none;border:none;color:#666;cursor:pointer;font-size:10px;padding:0 3px;line-height:1;border-radius:3px;transition:all .2s}.gl-disconnect-btn:hover{color:#e74c3c;background:#e74c3c26}.gl-link-gog-btn{background:#a855f726;color:#a855f7;border:1px solid rgba(168,85,247,.3);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-link-gog-btn:hover{background:#a855f740}.gl-loading{text-align:center;padding:48px;color:var(--text-faint);font-size:14px}.gl-empty{text-align:center;padding:60px 20px}.gl-empty-icon{font-size:48px;margin-bottom:16px}.gl-empty h3{color:var(--text-normal);margin:0 0 8px}.gl-empty p{color:var(--text-faint);margin:0;font-size:14px}.gl-common-playtimes{display:flex;gap:8px;flex-wrap:wrap}.gl-common-pt{font-size:11px;color:var(--text-faint);background:var(--bg-tertiary);padding:2px 8px;border-radius:4px}.gl-section-title{font-size:14px;font-weight:600;color:var(--text-normal);margin:0 0 12px}.gl-game-count{font-size:12px;color:var(--text-faint);margin-left:8px;font-weight:400}.gl-detail-avatars{display:flex;gap:-8px}.gl-detail-avatars img{width:36px;height:36px;border-radius:50%;border:2px solid var(--bg-primary);margin-left:-8px}.gl-detail-avatars img:first-child{margin-left:0}.gl-search-results-title{font-size:13px;color:var(--text-faint);margin-bottom:8px}.gl-game-item.enriched{align-items:flex-start;min-height:60px}.gl-game-visual{flex-shrink:0}.gl-game-cover{width:45px;height:64px;object-fit:cover;border-radius:4px}.gl-game-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.gl-game-genres{display:flex;flex-wrap:wrap;gap:4px}.gl-genre-tag{font-size:10px;padding:1px 6px;border-radius:3px;background:#e67e2226;color:#e67e22}.gl-game-platforms{font-size:10px;color:var(--text-muted, #888)}.gl-platform-tag{margin-left:4px;padding:1px 5px;border-radius:3px;background:#3498db26;color:#3498db}.gl-game-meta{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}.gl-game-rating{font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;min-width:28px;text-align:center}.gl-game-rating.high{background:#2ecc7133;color:#2ecc71}.gl-game-rating.mid{background:#f1c40f33;color:#f1c40f}.gl-game-rating.low{background:#e74c3c33;color:#e74c3c}.gl-enrich-btn{background:#3498db26;border:1px solid rgba(52,152,219,.3);color:#3498db;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-enrich-btn:hover:not(:disabled){background:#3498db40}.gl-enrich-btn:disabled{opacity:.5;cursor:not-allowed}.gl-enrich-btn.enriching{animation:gl-pulse 1.5s ease-in-out infinite}@keyframes gl-pulse{0%,to{opacity:.5}50%{opacity:1}}.gl-filter-bar{display:flex;align-items:center;gap:10px;margin-bottom:8px}.gl-filter-bar .gl-search-input{flex:1}.gl-sort-select{background:#ffffff0f;color:#c7d5e0;border:1px solid rgba(255,255,255,.1);padding:10px 12px;border-radius:var(--radius);font-size:13px;cursor:pointer;min-width:120px}.gl-sort-select:focus{outline:none;border-color:#ffffff40}.gl-sort-select option{background:#1a1a2e;color:#c7d5e0}.gl-genre-filters{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px;padding:8px 0}.gl-genre-chip{background:#ffffff0f;color:#8899a6;border:1px solid rgba(255,255,255,.08);padding:5px 12px;border-radius:20px;font-size:12px;cursor:pointer;transition:all .2s;white-space:nowrap}.gl-genre-chip:hover{background:#ffffff1a;color:#c7d5e0}.gl-genre-chip.active{background:#e67e2233;color:#e67e22;border-color:#e67e2266}.gl-genre-chip.active.clear{background:#3498db33;color:#3498db;border-color:#3498db66}.gl-filter-count{color:#556;font-size:12px;margin:0 0 8px}@media(max-width:768px){.gl-container{padding:12px}.gl-users-grid{grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}.gl-login-bar{flex-direction:column}}.gl-dialog-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;display:flex;align-items:center;justify-content:center;z-index:1000;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.gl-dialog{background:#2a2a3e;border-radius:12px;padding:24px;max-width:500px;width:90%;box-shadow:0 8px 32px #00000080}.gl-dialog h3{margin:0 0 12px;font-size:1.2rem;color:#fff}.gl-dialog-hint{font-size:.85rem;color:#aaa;margin-bottom:14px;line-height:1.5}.gl-dialog-input{width:100%;padding:10px 12px;background:#1a1a2e;border:1px solid #444;border-radius:8px;color:#fff;font-size:.9rem;outline:none;transition:border-color .2s}.gl-dialog-input:focus{border-color:#a855f7}.gl-dialog-status{margin-top:8px;font-size:.85rem;padding:6px 10px;border-radius:6px}.gl-dialog-status.loading{color:#a855f7}.gl-dialog-status.success{color:#4caf50}.gl-dialog-status.error{color:#e74c3c}.gl-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.gl-dialog-cancel{padding:8px 18px;background:#3a3a4e;color:#ccc;border:none;border-radius:8px;cursor:pointer;font-size:.9rem}.gl-dialog-cancel:hover{background:#4a4a5e}.gl-dialog-submit{padding:8px 18px;background:#a855f7;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:.9rem;font-weight:600}.gl-dialog-submit:hover:not(:disabled){background:#9333ea}.gl-dialog-submit:disabled{opacity:.5;cursor:not-allowed}.gl-login-bar-spacer{flex:1}.gl-admin-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#888;padding:8px 12px;border-radius:var(--radius);cursor:pointer;font-size:16px;transition:all .2s}.gl-admin-btn:hover{background:#ffffff1a;color:#ccc}.gl-admin-panel{background:#2a2a3e;border-radius:12px;padding:0;max-width:600px;width:92%;box-shadow:0 8px 32px #00000080;max-height:80vh;display:flex;flex-direction:column}.gl-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid rgba(255,255,255,.08)}.gl-admin-header h3{margin:0;font-size:1.1rem;color:#fff}.gl-admin-close{background:none;border:none;color:#888;font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px}.gl-admin-close:hover{color:#fff;background:#ffffff1a}.gl-admin-login{padding:20px}.gl-admin-login p{color:#aaa;margin:0 0 12px;font-size:14px}.gl-admin-login-row{display:flex;gap:8px}.gl-admin-login-btn{background:#e67e22;color:#fff;border:none;padding:10px 20px;border-radius:8px;cursor:pointer;font-weight:600;white-space:nowrap}.gl-admin-login-btn:hover{background:#d35400}.gl-admin-content{padding:0;overflow-y:auto}.gl-admin-toolbar{display:flex;align-items:center;gap:10px;padding:12px 20px;border-bottom:1px solid rgba(255,255,255,.06)}.gl-admin-status-text{font-size:13px;color:#4caf50;flex:1}.gl-admin-refresh-btn,.gl-admin-logout-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#aaa;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;transition:all .2s}.gl-admin-refresh-btn:hover{background:#ffffff1a;color:#fff}.gl-admin-logout-btn:hover{background:#e74c3c26;color:#e74c3c;border-color:#e74c3c4d}.gl-admin-list{padding:8px 12px}.gl-admin-item{display:flex;align-items:center;gap:12px;padding:10px 8px;border-bottom:1px solid rgba(255,255,255,.04);transition:background .15s}.gl-admin-item:last-child{border-bottom:none}.gl-admin-item:hover{background:#ffffff08}.gl-admin-item-avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0}.gl-admin-item-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.gl-admin-item-name{font-size:14px;font-weight:600;color:#e0e0e0}.gl-admin-item-details{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.gl-admin-item-total{font-size:11px;color:#667}.gl-admin-delete-btn{background:#e74c3c1a;color:#e74c3c;border:1px solid rgba(231,76,60,.2);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;white-space:nowrap;transition:all .2s;flex-shrink:0}.gl-admin-delete-btn:hover{background:#e74c3c40;border-color:#e74c3c66}:root{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--success: #57d28f;--danger: #ed4245;--warning: #fee75c;--border: rgba(255, 255, 255, .06);--radius: 8px;--radius-lg: 12px;--transition: .15s ease;--font: "Segoe UI", system-ui, -apple-system, sans-serif;--header-height: 56px}*,*:before,*:after{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;font-family:var(--font);font-size:15px;color:var(--text-normal);background:var(--bg-deep);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;overflow:hidden}#root{height:100%}.hub-app{display:flex;flex-direction:column;height:100vh;overflow:hidden}.hub-header{position:sticky;top:0;z-index:100;display:flex;align-items:center;height:var(--header-height);min-height:var(--header-height);padding:0 16px;background:var(--bg-primary);border-bottom:1px solid var(--border);gap:16px}.hub-header-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.hub-logo{font-size:24px;line-height:1}.hub-title{font-size:18px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em;white-space:nowrap}.hub-conn-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);flex-shrink:0;transition:background var(--transition);box-shadow:0 0 0 2px #ed424540}.hub-conn-dot.online{background:var(--success);box-shadow:0 0 0 2px #57d28f40;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 0 2px #57d28f40}50%{box-shadow:0 0 0 6px #57d28f1a}}.hub-tabs{display:flex;align-items:center;gap:4px;flex:1;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;padding:0 4px}.hub-tabs::-webkit-scrollbar{display:none}.hub-tab{display:flex;align-items:center;gap:6px;padding:8px 14px;border:none;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:var(--radius);white-space:nowrap;transition:all var(--transition);position:relative;-webkit-user-select:none;user-select:none}.hub-tab:hover{color:var(--text-normal);background:var(--bg-secondary)}.hub-tab.active{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-tab.active:after{content:"";position:absolute;bottom:-1px;left:50%;transform:translate(-50%);width:calc(100% - 16px);height:2px;background:var(--accent);border-radius:1px}.hub-tab-icon{font-size:16px;line-height:1}.hub-tab-label{text-transform:capitalize}.hub-header-right{display:flex;align-items:center;gap:12px;flex-shrink:0}.hub-download-btn{display:flex;align-items:center;gap:6px;padding:4px 10px;font-size:12px;font-weight:500;font-family:var(--font);text-decoration:none;color:var(--text-muted);background:var(--bg-secondary);border-radius:var(--radius);cursor:pointer;transition:all var(--transition);white-space:nowrap}.hub-download-btn:hover{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-download-icon{font-size:14px;line-height:1}.hub-download-label{line-height:1}.hub-version{font-size:12px;color:var(--text-faint);font-weight:500;font-variant-numeric:tabular-nums;background:var(--bg-secondary);padding:4px 8px;border-radius:4px}.hub-check-update-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-secondary);font-size:14px;padding:2px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-check-update-btn:hover:not(:disabled){color:var(--accent);border-color:var(--accent)}.hub-check-update-btn:disabled{opacity:.4;cursor:default}.hub-update-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-update-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:32px 40px;text-align:center;min-width:320px;max-width:400px;box-shadow:0 8px 32px #00000080}.hub-update-icon{font-size:40px;margin-bottom:12px}.hub-update-modal h2{margin:0 0 8px;font-size:18px;color:var(--text-primary)}.hub-update-modal p{margin:0 0 20px;font-size:14px;color:var(--text-secondary)}.hub-update-progress{height:4px;border-radius:2px;background:var(--bg-deep);overflow:hidden}.hub-update-progress-bar{height:100%;width:40%;border-radius:2px;background:var(--accent);animation:hub-update-slide 1.5s ease-in-out infinite}@keyframes hub-update-slide{0%{transform:translate(-100%)}to{transform:translate(350%)}}.hub-update-btn{padding:8px 32px;font-size:14px;font-weight:600;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;cursor:pointer;transition:opacity var(--transition)}.hub-update-btn:hover{opacity:.85}.hub-update-btn-secondary{background:var(--bg-tertiary);color:var(--text-secondary);margin-top:4px}.hub-update-versions{display:flex;flex-direction:column;gap:2px;margin:8px 0;font-size:12px;color:var(--text-muted)}.hub-update-error-detail{font-size:11px;color:#ef4444;background:#ef44441a;border-radius:var(--radius);padding:6px 10px;word-break:break-word;max-width:300px}.hub-refresh-btn{background:none;border:none;color:var(--text-muted);font-size:1rem;cursor:pointer;padding:4px 6px;border-radius:var(--radius);transition:all var(--transition);line-height:1}.hub-refresh-btn:hover{color:var(--accent);background:#e67e221a}.hub-admin-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-muted);font-size:16px;padding:4px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-admin-btn:hover{color:var(--accent);border-color:var(--accent)}.hub-admin-btn.active{color:#4ade80;border-color:#4ade80}.hub-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-admin-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;width:340px;box-shadow:0 8px 32px #00000080}.hub-admin-modal-header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--border);font-weight:600}.hub-admin-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:16px}.hub-admin-modal-close:hover{color:var(--text)}.hub-admin-modal-body{padding:20px;display:flex;flex-direction:column;gap:12px}.hub-admin-input{width:100%;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text);font-size:14px;font-family:var(--font);box-sizing:border-box}.hub-admin-input:focus{outline:none;border-color:var(--accent)}.hub-admin-error{color:#ef4444;font-size:13px;margin:0}.hub-admin-submit{padding:8px 16px;background:var(--accent);color:#fff;border:none;border-radius:var(--radius);font-size:14px;font-weight:500;cursor:pointer;transition:opacity var(--transition)}.hub-admin-submit:hover{opacity:.9}.hub-version-clickable{cursor:pointer;transition:all var(--transition);padding:2px 8px;border-radius:var(--radius)}.hub-version-clickable:hover{color:var(--accent);background:#e67e221a}.hub-version-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-version-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:hub-modal-in .2s ease}@keyframes hub-modal-in{0%{opacity:0;transform:scale(.95) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.hub-version-modal-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.hub-version-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.hub-version-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.hub-version-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.hub-version-modal-row{display:flex;justify-content:space-between;align-items:center}.hub-version-modal-label{color:var(--text-muted);font-size:13px}.hub-version-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.hub-version-modal-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);flex-shrink:0}.hub-version-modal-dot.online{background:var(--success)}.hub-version-modal-link{color:var(--accent);text-decoration:none;font-weight:500;font-size:13px}.hub-version-modal-link:hover{text-decoration:underline}.hub-version-modal-hint{font-size:11px;color:var(--accent);padding:6px 10px;background:#e67e221a;border-radius:var(--radius);text-align:center}.hub-version-modal-update{margin-top:4px;padding-top:12px;border-top:1px solid var(--border)}.hub-version-modal-update-btn{width:100%;padding:10px 16px;border:none;border-radius:var(--radius);background:var(--bg-tertiary);color:var(--text-normal);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);display:flex;align-items:center;justify-content:center;gap:8px}.hub-version-modal-update-btn:hover{background:var(--bg-hover);color:var(--accent)}.hub-version-modal-update-btn.ready{background:#2ecc7126;color:#2ecc71}.hub-version-modal-update-btn.ready:hover{background:#2ecc7140}.hub-version-modal-update-status{display:flex;align-items:center;justify-content:center;gap:8px;font-size:13px;color:var(--text-muted);padding:8px 0;flex-wrap:wrap}.hub-version-modal-update-status.success{color:#2ecc71}.hub-version-modal-update-status.error{color:#e74c3c}.hub-version-modal-update-retry{background:none;border:none;color:var(--text-muted);font-size:11px;cursor:pointer;text-decoration:underline;padding:2px 4px;width:100%;margin-top:4px}.hub-version-modal-update-retry:hover{color:var(--text-normal)}@keyframes hub-spin{to{transform:rotate(360deg)}}.hub-update-spinner{width:14px;height:14px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:hub-spin .8s linear infinite;flex-shrink:0}.hub-content{flex:1;overflow-y:auto;overflow-x:hidden;background:var(--bg-deep);scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.hub-content::-webkit-scrollbar{width:6px}.hub-content::-webkit-scrollbar-track{background:transparent}.hub-content::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.hub-content::-webkit-scrollbar-thumb:hover{background:var(--text-faint)}.hub-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px;text-align:center;padding:32px;animation:fade-in .3s ease}.hub-empty-icon{font-size:64px;line-height:1;margin-bottom:20px;opacity:.6;filter:grayscale(30%)}.hub-empty h2{font-size:22px;font-weight:700;color:var(--text-normal);margin-bottom:8px}.hub-empty p{font-size:15px;color:var(--text-muted);max-width:360px;line-height:1.5}@keyframes fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}::selection{background:rgba(var(--accent-rgb),.3);color:var(--text-normal)}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(max-width:768px){:root{--header-height: 48px}.hub-header{padding:0 10px;gap:8px}.hub-title{font-size:15px}.hub-logo{font-size:20px}.hub-tab{padding:6px 10px;font-size:13px;gap:4px}.hub-tab-label{display:none}.hub-tab-icon{font-size:18px}.hub-version{font-size:11px}.hub-empty-icon{font-size:48px}.hub-empty h2{font-size:18px}.hub-empty p{font-size:14px}}@media(max-width:480px){.hub-header-right{display:none}.hub-header{padding:0 8px;gap:6px}.hub-title{font-size:14px}}.radio-container{display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;background:var(--bg-deep);--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--border: rgba(255, 255, 255, .06)}.radio-container[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad}.radio-container[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60}.radio-container[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9}.radio-container[data-theme=cherry]{--bg-deep: #1a0f14;--bg-primary: #22141a;--bg-secondary: #301c25;--bg-tertiary: #3e2530;--accent: #e74c6f;--accent-rgb: 231, 76, 111;--accent-hover: #c0392b}.radio-topbar{display:flex;align-items:center;padding:0 16px;height:52px;background:var(--bg-secondary, #2b2d31);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px}.radio-topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.radio-topbar-logo{font-size:20px}.radio-topbar-title{font-size:16px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em}.radio-topbar-np{flex:1;display:flex;align-items:center;gap:10px;min-width:0;justify-content:center}.radio-topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.radio-topbar-stop{display:flex;align-items:center;gap:4px;background:var(--danger);color:#fff;border:none;border-radius:var(--radius);padding:6px 14px;font-size:13px;font-family:var(--font);font-weight:600;cursor:pointer;transition:all var(--transition);flex-shrink:0}.radio-topbar-stop:hover{background:#c63639}.radio-theme-inline{display:flex;align-items:center;gap:4px;margin-left:4px}.radio-globe-wrap{position:relative;flex:1;overflow:hidden}.radio-globe{width:100%;height:100%}.radio-globe canvas{outline:none!important}.radio-search{position:absolute;top:16px;left:50%;transform:translate(-50%);z-index:20;width:min(440px,calc(100% - 32px))}.radio-search-wrap{display:flex;align-items:center;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);padding:0 14px;gap:8px;box-shadow:0 8px 32px #0006}.radio-search-icon{font-size:16px;opacity:.6;flex-shrink:0}.radio-search-input{flex:1;background:transparent;border:none;color:var(--text-normal);font-family:var(--font);font-size:14px;padding:12px 0;outline:none}.radio-search-input::placeholder{color:var(--text-faint)}.radio-search-clear{background:none;border:none;color:var(--text-muted);font-size:14px;cursor:pointer;padding:4px;border-radius:4px;transition:color var(--transition)}.radio-search-clear:hover{color:var(--text-normal)}.radio-search-results{margin-top:6px;background:#1e1f22f2;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);max-height:360px;overflow-y:auto;box-shadow:0 12px 40px #00000080;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-search-result{display:flex;align-items:center;gap:10px;width:100%;padding:10px 14px;background:none;border:none;border-bottom:1px solid var(--border);color:var(--text-normal);font-family:var(--font);font-size:14px;cursor:pointer;text-align:left;transition:background var(--transition)}.radio-search-result:last-child{border-bottom:none}.radio-search-result:hover{background:rgba(var(--accent-rgb),.08)}.radio-search-result-icon{font-size:18px;flex-shrink:0}.radio-search-result-text{display:flex;flex-direction:column;gap:2px;min-width:0}.radio-search-result-title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-search-result-sub{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-fab{position:absolute;top:16px;right:16px;z-index:20;display:flex;align-items:center;gap:4px;padding:10px 14px;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);color:var(--text-normal);font-size:16px;cursor:pointer;box-shadow:0 8px 32px #0006;transition:all var(--transition)}.radio-fab:hover,.radio-fab.active{background:rgba(var(--accent-rgb),.15);border-color:rgba(var(--accent-rgb),.3)}.radio-fab-badge{font-size:11px;font-weight:700;background:var(--accent);color:#fff;padding:1px 6px;border-radius:10px;min-width:18px;text-align:center}.radio-panel{position:absolute;top:0;right:0;width:340px;height:100%;z-index:15;background:#1e1f22f2;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border-left:1px solid var(--border);display:flex;flex-direction:column;animation:slide-in-right .2s ease;box-shadow:-8px 0 32px #0000004d}@keyframes slide-in-right{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}.radio-panel-header{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--border);flex-shrink:0}.radio-panel-header h3{font-size:16px;font-weight:700;color:var(--text-normal)}.radio-panel-sub{font-size:12px;color:var(--text-muted);display:block;margin-top:2px}.radio-panel-close{background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all var(--transition)}.radio-panel-close:hover{color:var(--text-normal);background:var(--bg-secondary)}.radio-panel-body{flex:1;overflow-y:auto;padding:8px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-panel-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:14px}.radio-panel-loading{display:flex;flex-direction:column;align-items:center;gap:12px;padding:40px 16px;color:var(--text-muted);font-size:14px}.radio-station{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);transition:background var(--transition);gap:10px}.radio-station:hover{background:var(--bg-secondary)}.radio-station.playing{background:rgba(var(--accent-rgb),.1);border:1px solid rgba(var(--accent-rgb),.2)}.radio-station-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.radio-station-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-loc{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-live{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--accent);font-weight:600}.radio-station-btns{display:flex;gap:4px;flex-shrink:0}.radio-btn-play,.radio-btn-stop{width:34px;height:34px;border:none;border-radius:50%;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-play{background:var(--accent);color:#fff}.radio-btn-play:hover:not(:disabled){background:var(--accent-hover);transform:scale(1.05)}.radio-btn-play:disabled{opacity:.4;cursor:not-allowed}.radio-btn-stop{background:var(--danger);color:#fff}.radio-btn-stop:hover{background:#c63639}.radio-btn-fav{width:34px;height:34px;border:none;border-radius:50%;font-size:16px;cursor:pointer;background:transparent;color:var(--text-faint);display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-fav:hover{color:var(--warning);background:#fee75c1a}.radio-btn-fav.active{color:var(--warning)}.radio-eq{display:flex;align-items:flex-end;gap:2px;height:14px}.radio-eq span{width:3px;background:var(--accent);border-radius:1px;animation:eq-bounce .8s ease-in-out infinite}.radio-eq span:nth-child(1){height:8px;animation-delay:0s}.radio-eq span:nth-child(2){height:14px;animation-delay:.15s}.radio-eq span:nth-child(3){height:10px;animation-delay:.3s}@keyframes eq-bounce{0%,to{transform:scaleY(.4)}50%{transform:scaleY(1)}}.radio-sel{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius);color:var(--text-normal);font-family:var(--font);font-size:13px;padding:6px 10px;cursor:pointer;outline:none;max-width:180px}.radio-sel:focus{border-color:var(--accent)}.radio-eq-np{flex-shrink:0}.radio-np-info{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}.radio-np-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-np-loc{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-volume{display:flex;align-items:center;gap:6px;flex-shrink:0}.radio-volume-icon{font-size:16px;width:20px;text-align:center;cursor:pointer}.radio-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary, #383a40);outline:none;cursor:pointer}.radio-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-val{font-size:11px;color:var(--text-muted);min-width:32px;text-align:right}.radio-theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:transform .15s ease,border-color .15s ease;border:2px solid transparent}.radio-theme-dot:hover{transform:scale(1.25)}.radio-theme-dot.active{border-color:#fff;box-shadow:0 0 6px #ffffff4d}.radio-counter{position:absolute;bottom:16px;left:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;pointer-events:none}.radio-attribution{position:absolute;right:16px;bottom:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;text-decoration:none;transition:color var(--transition),background var(--transition)}.radio-attribution:hover{color:var(--text-normal);background:#1e1f22eb}.radio-spinner{width:24px;height:24px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media(max-width:768px){.radio-panel{width:100%}.radio-fab{top:12px;right:12px;padding:8px 10px;font-size:14px}.radio-search{top:12px;width:calc(100% - 80px);left:calc(50% - 24px)}.radio-topbar{padding:0 12px;gap:8px}.radio-topbar-title{display:none}.radio-sel{max-width:140px;font-size:12px}}@media(max-width:480px){.radio-topbar-np,.radio-volume{display:none}.radio-sel{max-width:120px}}.radio-conn{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--success);cursor:pointer;padding:4px 10px;border-radius:20px;background:#57d28f14;transition:all var(--transition);flex-shrink:0;-webkit-user-select:none;user-select:none}.radio-conn:hover{background:#57d28f26}.radio-conn-dot{width:8px;height:8px;border-radius:50%;background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.radio-conn-ping{font-size:11px;color:var(--text-muted);font-weight:600;font-variant-numeric:tabular-nums}.radio-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fade-in .15s ease}.radio-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:radio-modal-in .2s ease}@keyframes radio-modal-in{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.radio-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.radio-modal-close{margin-left:auto;background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.radio-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.radio-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.radio-modal-stat{display:flex;justify-content:space-between;align-items:center}.radio-modal-label{color:var(--text-muted);font-size:13px}.radio-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.radio-modal-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0} +@import"https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap";@import"https://fonts.googleapis.com/icon?family=Material+Icons";.sb-app{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--bg-modifier-hover: rgba(79, 84, 92, .16);--bg-modifier-active: rgba(79, 84, 92, .24);--bg-modifier-selected: rgba(79, 84, 92, .32);--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #5865f2;--accent-rgb: 88, 101, 242;--accent-hover: #4752c4;--accent-glow: rgba(88, 101, 242, .45);--green: #23a55a;--red: #f23f42;--yellow: #f0b232;--white: #ffffff;--font: "DM Sans", "Outfit", "gg sans", "Noto Sans", Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;--radius: 8px;--radius-lg: 12px;--shadow-low: 0 1px 3px rgba(0, 0, 0, .24);--shadow-med: 0 4px 12px rgba(0, 0, 0, .32);--shadow-high: 0 8px 24px rgba(0, 0, 0, .4);--transition: .15s cubic-bezier(.4, 0, .2, 1);--card-size: 110px;--card-emoji: 28px;--card-font: 11px;color-scheme:dark}.sb-app[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad;--accent-glow: rgba(155, 89, 182, .45)}.sb-app[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60;--accent-glow: rgba(46, 204, 113, .4)}.sb-app[data-theme=sunset]{--bg-deep: #1a1210;--bg-primary: #231815;--bg-secondary: #2f201c;--bg-tertiary: #3d2a24;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--accent-glow: rgba(230, 126, 34, .4)}.sb-app[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9;--accent-glow: rgba(52, 152, 219, .4)}.sb-app{display:flex;flex-direction:column;height:100%;position:relative}.topbar{display:flex;align-items:center;padding:0 20px;height:52px;background:var(--bg-secondary);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px;transition:background .4s ease}.topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.sb-app-logo{width:28px;height:28px;background:var(--accent);border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .4s ease}.sb-app-title{font-size:16px;font-weight:700;color:var(--white);letter-spacing:-.02em}.clock-wrap{flex:1;display:flex;justify-content:center}.clock{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:.02em;font-variant-numeric:tabular-nums;opacity:.9}.clock-seconds{font-size:14px;color:var(--text-faint);font-weight:500}.topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0}.channel-dropdown{position:relative;flex-shrink:0}.channel-btn{display:flex;align-items:center;gap:8px;padding:5px 12px 5px 10px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-normal);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.channel-btn:hover{background:var(--bg-modifier-selected);border-color:#ffffff1f}.channel-btn.open{border-color:var(--accent)}.channel-btn .cb-icon{font-size:16px;color:var(--text-muted)}.channel-btn .chevron{font-size:12px;color:var(--text-faint);transition:transform var(--transition);margin-left:2px}.channel-btn.open .chevron{transform:rotate(180deg)}.channel-status{width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0}.channel-menu{position:absolute;top:calc(100% + 6px);left:0;min-width:220px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:6px;z-index:100;animation:ctx-in .1s ease-out}.channel-menu-header{padding:6px 8px 4px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-faint)}.channel-option{display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:4px;font-size:13px;color:var(--text-muted);cursor:pointer;transition:all var(--transition)}.channel-option:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.channel-option.active{background:var(--accent);color:var(--white)}.channel-option .co-icon{font-size:16px;opacity:.7}.connection{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:#23a55a1f;font-size:12px;color:var(--green);font-weight:600}.conn-dot{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 6px #23a55a99;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 6px #23a55a80}50%{box-shadow:0 0 12px #23a55acc}}.conn-ping{font-size:10px;opacity:.7;margin-left:2px}.conn-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fadeIn .15s ease}.conn-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:slideUp .2s ease}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.conn-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.conn-modal-close{margin-left:auto;background:none;border:none;color:var(--muted);cursor:pointer;padding:4px;border-radius:6px;display:flex;transition:all .15s}.conn-modal-close:hover{background:#ffffff14;color:var(--fg)}.conn-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.conn-stat{display:flex;justify-content:space-between;align-items:center}.conn-stat-label{color:var(--muted);font-size:13px}.conn-stat-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.conn-ping-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.admin-btn-icon{width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition);font-size:18px}.admin-btn-icon:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.admin-btn-icon.active{color:var(--accent)}.toolbar{display:flex;align-items:center;gap:10px;padding:10px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0;flex-wrap:wrap;transition:background .4s ease}.cat-tabs{display:flex;gap:4px;flex-shrink:0}.cat-tab{display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.cat-tab:hover{background:var(--bg-modifier-selected);color:var(--text-normal)}.cat-tab.active{background:var(--accent);color:var(--white)}.tab-count{font-size:10px;font-weight:700;background:#ffffff26;padding:0 6px;border-radius:8px;line-height:1.6}.search-wrap{position:relative;flex:1;max-width:280px;min-width:140px}.search-wrap .search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);font-size:15px;color:var(--text-faint);pointer-events:none}.search-input{width:100%;height:32px;padding:0 28px 0 32px;border:1px solid rgba(255,255,255,.06);border-radius:20px;background:var(--bg-secondary);color:var(--text-normal);font-family:var(--font);font-size:13px;outline:none;transition:all var(--transition)}.search-input::placeholder{color:var(--text-faint)}.search-input:focus{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.search-clear{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:20px;height:20px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition)}.search-clear:hover{background:var(--bg-tertiary);color:var(--text-normal)}.toolbar-spacer{flex:1}.url-import-wrap{display:flex;align-items:center;gap:6px;min-width:240px;max-width:460px;flex:1;padding:4px 6px 4px 8px;border-radius:20px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.url-import-icon{font-size:15px;color:var(--text-faint);flex-shrink:0}.url-import-input{flex:1;min-width:0;height:26px;border:none;background:transparent;color:var(--text-normal);font-size:12px;font-family:var(--font);outline:none}.url-import-input::placeholder{color:var(--text-faint)}.url-import-btn{height:24px;padding:0 10px;border-radius:14px;border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.45);background:rgba(var(--accent-rgb, 88, 101, 242),.12);color:var(--accent);font-size:11px;font-weight:700;white-space:nowrap;transition:all var(--transition)}.url-import-btn:hover{background:var(--accent);border-color:var(--accent);color:var(--white)}.url-import-btn:disabled{opacity:.5;pointer-events:none}.url-import-tag{flex-shrink:0;padding:1px 6px;border-radius:8px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.url-import-tag.valid{background:#2ecc712e;color:#2ecc71}.url-import-tag.invalid{background:#e74c3c2e;color:#e74c3c}.tb-btn{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.tb-btn:hover{background:var(--bg-modifier-selected);color:var(--text-normal);border-color:#ffffff1f}.tb-btn .tb-icon{font-size:15px}.tb-btn.random{border-color:#5865f24d;color:var(--accent)}.tb-btn.random:hover{background:var(--accent);color:var(--white);border-color:var(--accent)}.tb-btn.party{border-color:#f0b2324d;color:var(--yellow)}.tb-btn.party:hover{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow)}.tb-btn.party.active{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow);animation:party-btn .6s ease-in-out infinite alternate}@keyframes party-btn{0%{box-shadow:0 0 8px #f0b23266}to{box-shadow:0 0 20px #f0b232b3}}.tb-btn.stop{border-color:#f23f424d;color:var(--red)}.tb-btn.stop:hover{background:var(--red);color:var(--white);border-color:var(--red)}.size-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.size-control .sc-icon{font-size:14px;color:var(--text-faint)}.size-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:70px;height:3px;border-radius:2px;background:var(--bg-modifier-selected);outline:none;cursor:pointer}.size-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.size-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.size-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.theme-selector{display:flex;align-items:center;gap:4px;padding:4px 8px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:all var(--transition);border:2px solid transparent}.theme-dot:hover{transform:scale(1.2)}.theme-dot.active{border-color:var(--white);box-shadow:0 0 6px #ffffff4d}.analytics-strip{display:flex;align-items:stretch;gap:8px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0}.analytics-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:12px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.analytics-card.analytics-wide{flex:1;min-width:0}.analytics-icon{font-size:18px;color:var(--accent);flex-shrink:0}.analytics-copy{display:flex;flex-direction:column;gap:4px;min-width:0}.analytics-label{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--text-faint)}.analytics-value{font-size:18px;line-height:1;font-weight:800;color:var(--text-normal)}.analytics-top-list{display:flex;align-items:center;gap:6px;overflow-x:auto;scrollbar-width:none}.analytics-top-list::-webkit-scrollbar{display:none}.analytics-chip{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:999px;background:rgba(var(--accent-rgb, 88, 101, 242),.15);color:var(--accent);font-size:11px;font-weight:600;white-space:nowrap}.analytics-muted{color:var(--text-muted);font-size:12px}.category-strip{display:flex;align-items:center;gap:6px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);overflow-x:auto;flex-shrink:0;scrollbar-width:none;transition:background .4s ease}.category-strip::-webkit-scrollbar{display:none}.cat-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;font-size:12px;font-weight:600;color:var(--text-muted);background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06);white-space:nowrap;cursor:pointer;transition:all var(--transition);flex-shrink:0}.cat-chip:hover{border-color:#ffffff1f;color:var(--text-normal);background:var(--bg-tertiary)}.cat-chip.active{background:#5865f21a}.cat-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.cat-count{font-size:10px;font-weight:700;opacity:.5}.main{flex:1;overflow-y:auto;padding:16px 20px;background:var(--bg-primary);transition:background .4s ease}.sound-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--card-size),1fr));gap:8px}.sound-card{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:12px 6px 8px;background:var(--bg-secondary);border-radius:var(--radius-lg);cursor:pointer;transition:all var(--transition);border:2px solid transparent;-webkit-user-select:none;user-select:none;overflow:hidden;aspect-ratio:1;opacity:0;animation:card-enter .35s ease-out forwards}.sound-card:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;opacity:0;transition:opacity var(--transition);background:radial-gradient(ellipse at center,var(--accent-glow) 0%,transparent 70%);pointer-events:none}.sound-card:hover{background:var(--bg-tertiary);transform:translateY(-3px);box-shadow:var(--shadow-med),0 0 20px var(--accent-glow);border-color:#5865f233}.sound-card:hover:before{opacity:1}.sound-card:active{transform:translateY(0);transition-duration:50ms}.sound-card.playing{border-color:var(--accent);animation:card-enter .35s ease-out forwards,playing-glow 1.2s ease-in-out infinite alternate}@keyframes playing-glow{0%{box-shadow:0 0 4px var(--accent-glow)}to{box-shadow:0 0 16px var(--accent-glow)}}@keyframes card-enter{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.ripple{position:absolute;border-radius:50%;background:#5865f24d;transform:scale(0);animation:ripple-expand .5s ease-out forwards;pointer-events:none}@keyframes ripple-expand{to{transform:scale(3);opacity:0}}.sound-emoji{font-size:var(--card-emoji);font-weight:800;line-height:1;z-index:1;transition:transform var(--transition);opacity:.7;font-family:Syne,DM Sans,sans-serif}.sound-card:hover .sound-emoji{transform:scale(1.15);opacity:1}.sound-card.playing .sound-emoji{animation:emoji-bounce .4s ease;opacity:1}@keyframes emoji-bounce{0%,to{transform:scale(1)}40%{transform:scale(1.3)}70%{transform:scale(.95)}}.sound-name{font-size:var(--card-font);font-weight:600;text-align:center;color:var(--text-normal);z-index:1;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 4px}.sound-duration{font-size:9px;color:var(--text-faint);z-index:1;font-weight:500}.fav-star{position:absolute;top:4px;right:4px;opacity:0;transition:all var(--transition);cursor:pointer;z-index:2;color:var(--text-faint);padding:2px;line-height:1}.fav-star .fav-icon{font-size:14px}.sound-card:hover .fav-star{opacity:.6}.fav-star:hover{opacity:1!important;color:var(--yellow);transform:scale(1.2)}.fav-star.active{opacity:1!important;color:var(--yellow)}.new-badge{position:absolute;top:4px;left:4px;font-size:8px;font-weight:700;background:var(--green);color:#fff;padding:1px 5px;border-radius:6px;text-transform:uppercase;letter-spacing:.03em;z-index:2}.playing-indicator{position:absolute;bottom:3px;left:50%;transform:translate(-50%);display:none;gap:2px;align-items:flex-end;height:10px}.sound-card.playing .playing-indicator{display:flex}.wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .6s ease-in-out infinite alternate}.wave-bar:nth-child(1){height:3px;animation-delay:0ms}.wave-bar:nth-child(2){height:7px;animation-delay:.15s}.wave-bar:nth-child(3){height:5px;animation-delay:.3s}.wave-bar:nth-child(4){height:9px;animation-delay:.1s}@keyframes wave{0%{height:2px}to{height:10px}}.empty-state{display:none;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:60px 20px;text-align:center}.empty-state.visible{display:flex}.empty-emoji{font-size:42px}.empty-title{font-size:15px;font-weight:700;color:var(--text-normal)}.empty-desc{font-size:13px;color:var(--text-muted);max-width:260px}.now-playing{display:flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;background:rgba(var(--accent-rgb, 88, 101, 242),.12);border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.2);font-size:12px;color:var(--text-muted);max-width:none;min-width:0;animation:np-fade-in .3s ease}@keyframes np-fade-in{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}.np-name{color:var(--accent);font-weight:600;white-space:nowrap}.np-waves{display:none;gap:1.5px;align-items:flex-end;height:12px;flex-shrink:0}.np-waves.active{display:flex}.np-wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .5s ease-in-out infinite alternate}.np-wave-bar:nth-child(1){height:3px;animation-delay:0ms}.np-wave-bar:nth-child(2){height:8px;animation-delay:.12s}.np-wave-bar:nth-child(3){height:5px;animation-delay:.24s}.np-wave-bar:nth-child(4){height:10px;animation-delay:80ms}.volume-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.vol-icon{font-size:16px;color:var(--text-faint);cursor:pointer;transition:color var(--transition);-webkit-user-select:none;user-select:none}.vol-icon:hover{color:var(--text-normal)}.vol-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:80px;height:3px;border-radius:2px;background:linear-gradient(to right,var(--accent) 0%,var(--accent) var(--vol, 80%),var(--bg-modifier-selected) var(--vol, 80%));outline:none;cursor:pointer}.vol-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.vol-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.vol-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.vol-pct{font-size:11px;color:var(--text-faint);min-width:28px;text-align:right;font-variant-numeric:tabular-nums}.party-overlay{position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;z-index:50;opacity:0;transition:opacity .3s ease}.party-overlay.active{opacity:1;animation:party-hue 2s linear infinite}.party-overlay:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(45deg,#ff00000a,#00ff000a,#0000ff0a,#ffff000a);background-size:400% 400%;animation:party-grad 3s ease infinite}@keyframes party-grad{0%{background-position:0% 50%}50%{background-position:100% 50%}to{background-position:0% 50%}}@keyframes party-hue{to{filter:hue-rotate(360deg)}}.ctx-menu{position:fixed;min-width:160px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.06);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:4px;z-index:1000;animation:ctx-in .1s ease-out}@keyframes ctx-in{0%{opacity:0;transform:scale(.96) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.ctx-item{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:4px;font-size:13px;color:var(--text-normal);cursor:pointer;transition:all var(--transition)}.ctx-item:hover{background:var(--accent);color:var(--white)}.ctx-item.danger{color:var(--red)}.ctx-item.danger:hover{background:var(--red);color:var(--white)}.ctx-item .ctx-icon{font-size:15px}.ctx-sep{height:1px;background:#ffffff0f;margin:3px 8px}.toast{position:fixed;bottom:64px;left:50%;transform:translate(-50%);padding:10px 20px;border-radius:20px;font-size:13px;font-weight:600;z-index:100;display:flex;align-items:center;gap:8px;box-shadow:var(--shadow-high);animation:toast-in .3s cubic-bezier(.175,.885,.32,1.275);pointer-events:none}.toast .toast-icon{font-size:16px}.toast.error{background:var(--red);color:#fff}.toast.info{background:var(--green);color:#fff}@keyframes toast-in{0%{transform:translate(-50%,16px);opacity:0}to{transform:translate(-50%);opacity:1}}.admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:60;display:flex;align-items:center;justify-content:center;animation:fade-in .2s ease}.admin-panel{background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius-lg);padding:28px;width:92%;max-width:920px;max-height:min(88vh,860px);display:flex;flex-direction:column;box-shadow:var(--shadow-high)}.admin-panel h3{font-size:18px;font-weight:700;margin-bottom:16px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.admin-close{width:28px;height:28px;border-radius:6px;display:flex;align-items:center;justify-content:center;color:var(--text-muted);transition:all var(--transition)}.admin-close:hover{background:var(--bg-tertiary);color:var(--text-normal)}.admin-field{margin-bottom:16px}.admin-field label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.admin-field input{width:100%;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:10px 12px;font-size:14px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-field input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.admin-btn-action{padding:10px 20px;border-radius:8px;font-size:13px;font-weight:600;font-family:var(--font);cursor:pointer;transition:all var(--transition);line-height:1}.admin-btn-action.primary{background:var(--accent);color:#fff;border:none}.admin-btn-action.primary:hover{background:var(--accent-hover)}.admin-btn-action.outline{background:transparent;border:1px solid rgba(255,255,255,.08);color:var(--text-muted)}.admin-btn-action.outline:hover{border-color:#ffffff1f;color:var(--text-normal)}.admin-btn-action.danger{background:var(--red);color:var(--white);border:1px solid var(--red)}.admin-btn-action.danger:hover{filter:brightness(1.06)}.admin-btn-action.danger.ghost{background:transparent;color:var(--red);border:1px solid rgba(242,63,66,.5)}.admin-btn-action.danger.ghost:hover{background:#f23f4224}.admin-btn-action:disabled{opacity:.5;pointer-events:none}.admin-shell{display:flex;flex-direction:column;gap:12px;min-height:0}.admin-header-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.admin-status{font-size:13px;color:var(--text-muted)}.admin-actions-inline{display:flex;align-items:center;gap:8px}.admin-search-field{margin-bottom:0}.admin-bulk-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border-radius:10px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);flex-wrap:wrap}.admin-select-all{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted)}.admin-select-all input,.admin-item-check input{accent-color:var(--accent)}.admin-list-wrap{min-height:260px;max-height:52vh;overflow-y:auto;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:var(--bg-primary)}.admin-list{display:flex;flex-direction:column;gap:6px;padding:6px}.admin-empty{padding:24px 12px;text-align:center;color:var(--text-muted);font-size:13px}.admin-item{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px;border-radius:8px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06)}.admin-item-main{min-width:0}.admin-item-name{font-size:14px;font-weight:600;color:var(--text-normal);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-meta{margin-top:3px;font-size:11px;color:var(--text-faint);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-actions{display:flex;align-items:center;gap:6px}.admin-item-actions .admin-btn-action,.admin-rename-row .admin-btn-action{padding:8px 12px;font-size:12px}.admin-rename-row{display:flex;align-items:center;gap:6px;margin-top:8px}.admin-rename-row input{flex:1;min-width:120px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:8px 10px;font-size:13px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-rename-row input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}@media(max-width:700px){.toolbar{gap:6px;padding:8px 12px}.cat-tabs{overflow-x:auto;scrollbar-width:none}.cat-tabs::-webkit-scrollbar{display:none}.search-wrap,.url-import-wrap{max-width:100%;min-width:100%;order:-1}.size-control,.theme-selector{display:none}.main{padding:12px}.topbar{padding:0 12px;gap:8px}.channel-label{max-width:100px;overflow:hidden;text-overflow:ellipsis}.clock{font-size:16px}.clock-seconds{font-size:11px}.tb-btn span:not(.tb-icon){display:none}.analytics-strip{padding:8px 12px;flex-direction:column;gap:6px}.analytics-card.analytics-wide{width:100%}.admin-panel{width:96%;padding:16px;max-height:92vh}.admin-item{grid-template-columns:24px minmax(0,1fr)}.admin-item-actions{grid-column:1 / -1;justify-content:flex-end}.admin-rename-row{flex-wrap:wrap}}@media(max-width:480px){.connection,.sb-app-title{display:none}.now-playing{max-width:none}.toolbar .tb-btn{padding:6px 8px}.url-import-btn{padding:0 8px}}.drop-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000c7;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);z-index:300;display:flex;align-items:center;justify-content:center;animation:fade-in .12s ease;pointer-events:none}.drop-zone{display:flex;flex-direction:column;align-items:center;gap:14px;padding:64px 72px;border-radius:24px;border:2.5px dashed rgba(var(--accent-rgb),.55);background:rgba(var(--accent-rgb),.07);animation:drop-pulse 2.2s ease-in-out infinite}@keyframes drop-pulse{0%,to{border-color:rgba(var(--accent-rgb),.45);box-shadow:0 0 rgba(var(--accent-rgb),0)}50%{border-color:rgba(var(--accent-rgb),.9);box-shadow:0 0 60px 12px rgba(var(--accent-rgb),.12)}}.drop-icon{font-size:64px;color:var(--accent);animation:drop-bounce 1.8s ease-in-out infinite}@keyframes drop-bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-8px)}}.drop-title{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:-.3px}.drop-sub{font-size:13px;color:var(--text-muted)}.upload-queue{position:fixed;bottom:24px;right:24px;width:340px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.09);border-radius:14px;box-shadow:0 8px 40px #00000073;z-index:200;animation:slide-up .2s cubic-bezier(.16,1,.3,1)}@keyframes slide-up{0%{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}.uq-header{display:flex;align-items:center;gap:8px;padding:12px 14px;background:rgba(var(--accent-rgb),.12);border-bottom:1px solid rgba(255,255,255,.06);font-size:13px;font-weight:600;color:var(--text-normal)}.uq-header .material-icons{color:var(--accent)}.uq-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition),color var(--transition)}.uq-close:hover{background:#ffffff24;color:var(--text-normal)}.uq-list{display:flex;flex-direction:column;max-height:260px;overflow-y:auto;padding:6px 0}.uq-item{display:grid;grid-template-columns:20px 1fr auto 18px;align-items:center;gap:8px;padding:8px 14px;position:relative}.uq-item+.uq-item{border-top:1px solid rgba(255,255,255,.04)}.uq-file-icon{font-size:18px;color:var(--text-faint)}.uq-info{min-width:0}.uq-name{font-size:12px;font-weight:500;color:var(--text-normal);white-space:nowrap;text-overflow:ellipsis}.uq-size{font-size:10px;color:var(--text-faint);margin-top:1px}.uq-progress-wrap{grid-column:1 / -1;height:3px;background:#ffffff12;border-radius:2px;margin-top:4px}.uq-item{flex-wrap:wrap}.uq-progress-wrap{width:100%;order:10}.uq-progress-bar{height:100%;background:var(--accent);border-radius:2px;transition:width .12s ease}.uq-status-icon{font-size:16px}.uq-status-waiting .uq-status-icon{color:var(--text-faint)}.uq-status-uploading .uq-status-icon{color:var(--accent);animation:spin 1s linear infinite}.uq-status-done .uq-status-icon{color:var(--green)}.uq-status-error .uq-status-icon{color:var(--red)}.uq-error{grid-column:2 / -1;font-size:10px;color:var(--red);margin-top:2px}.dl-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;display:flex;align-items:center;justify-content:center;z-index:300;animation:fade-in .15s ease}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.dl-modal{width:420px;max-width:92vw;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.1);border-radius:16px;box-shadow:0 12px 60px #00000080;animation:scale-in .2s cubic-bezier(.16,1,.3,1)}@keyframes scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.dl-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.06);font-size:14px;font-weight:700;color:var(--text-normal)}.dl-modal-header .material-icons{color:var(--accent)}.dl-modal-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition)}.dl-modal-close:hover{background:#ffffff24;color:var(--text-normal)}.dl-modal-body{padding:16px;display:flex;flex-direction:column;gap:14px}.dl-modal-url{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:8px;background:#0003;overflow:hidden}.dl-modal-tag{flex-shrink:0;padding:2px 8px;border-radius:6px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.dl-modal-tag.youtube{background:#ff00002e;color:#f44}.dl-modal-tag.instagram{background:#e1306c2e;color:#e1306c}.dl-modal-tag.mp3{background:#2ecc712e;color:#2ecc71}.dl-modal-url-text{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-modal-field{display:flex;flex-direction:column;gap:5px}.dl-modal-label{font-size:11px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.dl-modal-input-wrap{display:flex;align-items:center;border:1px solid rgba(255,255,255,.1);border-radius:8px;background:#00000026;overflow:hidden;transition:border-color var(--transition)}.dl-modal-input-wrap:focus-within{border-color:var(--accent)}.dl-modal-input{flex:1;border:none;background:transparent;padding:8px 10px;color:var(--text-normal);font-size:13px;font-family:var(--font);outline:none}.dl-modal-input::placeholder{color:var(--text-faint)}.dl-modal-ext{padding:0 10px;font-size:12px;font-weight:600;color:var(--text-faint);background:#ffffff0a;align-self:stretch;display:flex;align-items:center}.dl-modal-hint{font-size:10px;color:var(--text-faint)}.dl-modal-progress{display:flex;align-items:center;gap:12px;padding:20px 0;justify-content:center;font-size:13px;color:var(--text-muted)}.dl-modal-spinner{width:24px;height:24px;border-radius:50%;border:3px solid rgba(var(--accent-rgb),.2);border-top-color:var(--accent);animation:spin .8s linear infinite}.dl-modal-success{display:flex;align-items:center;gap:10px;padding:16px 0;justify-content:center;font-size:13px;color:var(--text-normal)}.dl-modal-check{color:#2ecc71;font-size:28px}.dl-modal-error{display:flex;align-items:center;gap:10px;padding:12px 0;justify-content:center;font-size:13px;color:#e74c3c}.dl-modal-actions{display:flex;justify-content:flex-end;gap:8px;padding:0 16px 14px}.dl-modal-cancel{padding:7px 14px;border-radius:8px;border:1px solid rgba(255,255,255,.1);background:transparent;color:var(--text-muted);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition)}.dl-modal-cancel:hover{background:#ffffff0f;color:var(--text-normal)}.dl-modal-submit{display:flex;align-items:center;gap:5px;padding:7px 16px;border-radius:8px;border:none;background:var(--accent);color:#fff;font-size:12px;font-weight:700;cursor:pointer;transition:filter var(--transition)}.dl-modal-submit:hover{filter:brightness(1.15)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.lol-container{max-width:920px;margin:0 auto;padding:16px;height:100%;overflow-y:auto}.lol-search{display:flex;gap:8px;margin-bottom:12px}.lol-search-input{flex:1;min-width:0;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:15px;outline:none;transition:border-color .2s}.lol-search-input:focus{border-color:var(--accent)}.lol-search-input::placeholder{color:var(--text-faint)}.lol-search-region{padding:10px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none}.lol-search-btn{padding:10px 20px;border:none;border-radius:8px;background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:opacity .2s;white-space:nowrap}.lol-search-btn:hover{opacity:.85}.lol-search-btn:disabled{opacity:.4;cursor:not-allowed}.lol-recent{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:16px}.lol-recent-chip{display:flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;cursor:pointer;transition:border-color .2s,color .2s}.lol-recent-chip:hover{border-color:var(--accent);color:var(--text-normal)}.lol-recent-chip img{width:18px;height:18px;border-radius:50%}.lol-recent-tier{font-size:10px;font-weight:600;opacity:.7;text-transform:uppercase}.lol-profile{display:flex;align-items:center;gap:16px;padding:16px;border-radius:12px;background:var(--bg-secondary);margin-bottom:12px}.lol-profile-icon{width:72px;height:72px;border-radius:12px;border:2px solid var(--bg-tertiary);object-fit:cover}.lol-profile-info h2{margin:0 0 2px;font-size:20px;color:var(--text-normal)}.lol-profile-info h2 span{color:var(--text-faint);font-weight:400;font-size:14px}.lol-profile-level{font-size:12px;color:var(--text-muted)}.lol-profile-ladder{font-size:11px;color:var(--text-faint)}.lol-profile-updated{font-size:10px;color:var(--text-faint);margin-top:2px}.lol-profile-info{flex:1;min-width:0}.lol-update-btn{display:flex;align-items:center;gap:6px;padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-primary);color:var(--text-muted);font-size:13px;font-weight:500;cursor:pointer;transition:border-color .2s,color .2s,background .2s;white-space:nowrap;flex-shrink:0}.lol-update-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-update-btn:disabled{opacity:.6;cursor:not-allowed}.lol-update-btn.renewing{border-color:var(--accent);color:var(--accent)}.lol-update-icon{font-size:16px;display:inline-block}.lol-update-btn.renewing .lol-update-icon{animation:lol-spin 1s linear infinite}.lol-ranked-row{display:flex;gap:10px;margin-bottom:12px}.lol-ranked-card{flex:1;padding:12px 14px;border-radius:10px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary)}.lol-ranked-card.has-rank{border-left-color:var(--tier-color, var(--accent))}.lol-ranked-type{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}.lol-ranked-tier{font-size:18px;font-weight:700;color:var(--tier-color, var(--text-normal))}.lol-ranked-lp{font-size:13px;color:var(--text-muted);margin-left:4px;font-weight:400}.lol-ranked-record{font-size:12px;color:var(--text-muted);margin-top:2px}.lol-ranked-wr{color:var(--text-faint);margin-left:4px}.lol-ranked-streak{color:#e74c3c;font-size:11px;margin-left:4px}.lol-section-title{font-size:13px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;margin:16px 0 8px;padding-left:2px}.lol-champs{display:flex;gap:8px;margin-bottom:12px;overflow-x:auto;padding-bottom:4px}.lol-champ-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:8px;background:var(--bg-secondary);min-width:180px;flex-shrink:0}.lol-champ-icon{width:36px;height:36px;border-radius:50%;object-fit:cover}.lol-champ-name{font-size:13px;font-weight:600;color:var(--text-normal)}.lol-champ-stats{font-size:11px;color:var(--text-muted)}.lol-champ-kda{font-size:11px;color:var(--text-faint)}.lol-matches{display:flex;flex-direction:column;gap:6px}.lol-match{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary);cursor:pointer;transition:background .15s}.lol-match:hover{background:var(--bg-tertiary)}.lol-match.win{border-left-color:#2ecc71}.lol-match.loss{border-left-color:#e74c3c}.lol-match-result{width:28px;font-size:11px;font-weight:700;text-align:center;flex-shrink:0}.lol-match.win .lol-match-result{color:#2ecc71}.lol-match.loss .lol-match-result{color:#e74c3c}.lol-match-champ{position:relative;flex-shrink:0}.lol-match-champ img{width:40px;height:40px;border-radius:50%;display:block}.lol-match-champ-level{position:absolute;bottom:-2px;right:-2px;background:var(--bg-deep);color:var(--text-muted);font-size:9px;font-weight:700;width:16px;height:16px;border-radius:50%;display:flex;align-items:center;justify-content:center}.lol-match-kda{min-width:80px;text-align:center;flex-shrink:0}.lol-match-kda-nums{font-size:14px;font-weight:600;color:var(--text-normal)}.lol-match-kda-ratio{font-size:11px;color:var(--text-faint)}.lol-match-kda-ratio.perfect{color:#f39c12}.lol-match-kda-ratio.great{color:#2ecc71}.lol-match-stats{display:flex;flex-direction:column;gap:1px;min-width:70px;flex-shrink:0}.lol-match-stats span{font-size:11px;color:var(--text-muted)}.lol-match-items{display:flex;gap:2px;flex-shrink:0}.lol-match-items img,.lol-match-item-empty{width:24px;height:24px;border-radius:4px;background:var(--bg-deep)}.lol-match-meta{margin-left:auto;text-align:right;flex-shrink:0}.lol-match-duration{font-size:12px;color:var(--text-muted)}.lol-match-queue,.lol-match-ago{font-size:10px;color:var(--text-faint)}.lol-match-detail{background:var(--bg-primary);border-radius:8px;padding:8px;margin-top:4px;margin-bottom:4px}.lol-match-detail-team{margin-bottom:6px}.lol-match-detail-team-header{font-size:11px;font-weight:600;padding:4px 8px;border-radius:4px;margin-bottom:4px}.lol-match-detail-team-header.win{background:#2ecc7126;color:#2ecc71}.lol-match-detail-team-header.loss{background:#e74c3c26;color:#e74c3c}.lol-detail-row{display:flex;align-items:center;gap:8px;padding:3px 8px;border-radius:4px;font-size:12px;color:var(--text-muted)}.lol-detail-row:hover{background:var(--bg-secondary)}.lol-detail-row.me{background:#ffffff0a;font-weight:600}.lol-detail-champ{width:24px;height:24px;border-radius:50%}.lol-detail-name{width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-normal)}.lol-detail-kda{width:70px;text-align:center}.lol-detail-cs{width:45px;text-align:center}.lol-detail-dmg,.lol-detail-gold{width:55px;text-align:center}.lol-detail-items{display:flex;gap:1px}.lol-detail-items img{width:20px;height:20px;border-radius:3px}.lol-loading{display:flex;align-items:center;justify-content:center;gap:10px;padding:40px;color:var(--text-muted);font-size:14px}.lol-spinner{width:20px;height:20px;border:2px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:lol-spin .8s linear infinite}@keyframes lol-spin{to{transform:rotate(360deg)}}.lol-error{padding:16px;border-radius:8px;background:#e74c3c1a;color:#e74c3c;font-size:13px;text-align:center;margin-bottom:12px}.lol-empty{text-align:center;padding:60px 20px;color:var(--text-faint)}.lol-empty-icon{font-size:48px;margin-bottom:12px}.lol-empty h3{margin:0 0 8px;color:var(--text-muted);font-size:16px}.lol-empty p{margin:0;font-size:13px}.lol-load-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--bg-tertiary);border-radius:8px;background:transparent;color:var(--text-muted);font-size:13px;cursor:pointer;transition:border-color .2s,color .2s}.lol-load-more:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-section{margin-top:24px;padding-top:16px;border-top:1px solid var(--bg-tertiary)}.lol-tier-controls{display:flex;gap:8px;align-items:center;margin-bottom:12px;flex-wrap:wrap}.lol-tier-modes{display:flex;gap:4px;flex-wrap:wrap}.lol-tier-mode-btn{padding:6px 14px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;font-weight:500;cursor:pointer;transition:all .2s;white-space:nowrap}.lol-tier-mode-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-mode-btn.active{background:var(--accent);border-color:var(--accent);color:#fff}.lol-tier-filter{padding:6px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:12px;outline:none;width:140px;margin-left:auto}.lol-tier-filter:focus{border-color:var(--accent)}.lol-tier-filter::placeholder{color:var(--text-faint)}.lol-tier-table{display:flex;flex-direction:column;gap:2px}.lol-tier-header{display:flex;align-items:center;gap:8px;padding:6px 10px;font-size:10px;font-weight:600;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px}.lol-tier-row{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:6px;background:var(--bg-secondary);font-size:13px;color:var(--text-muted);transition:background .15s}.lol-tier-row:hover{background:var(--bg-tertiary)}.lol-tier-row.tier-0{border-left:3px solid #f4c874}.lol-tier-row.tier-1{border-left:3px solid #d4a017}.lol-tier-row.tier-2{border-left:3px solid #576cce}.lol-tier-row.tier-3{border-left:3px solid #28b29e}.lol-tier-row.tier-4{border-left:3px solid var(--bg-tertiary)}.lol-tier-row.tier-5{border-left:3px solid var(--bg-tertiary);opacity:.7}.lol-tier-col-rank{width:32px;text-align:center;font-weight:600;flex-shrink:0}.lol-tier-col-champ{flex:1;display:flex;align-items:center;gap:8px;min-width:0;font-weight:500;color:var(--text-normal)}.lol-tier-col-champ img{width:28px;height:28px;border-radius:50%;flex-shrink:0}.lol-tier-col-tier{width:36px;text-align:center;font-weight:700;font-size:12px;flex-shrink:0}.lol-tier-col-wr,.lol-tier-col-pr,.lol-tier-col-br{width:60px;text-align:center;flex-shrink:0}.lol-tier-col-kda{width:50px;text-align:center;flex-shrink:0}.tier-badge-0{color:#f4c874}.tier-badge-1{color:#d4a017}.tier-badge-2{color:#576cce}.tier-badge-3{color:#28b29e}.tier-badge-4,.tier-badge-5{color:var(--text-faint)}@media(max-width:640px){.lol-search{flex-wrap:wrap}.lol-search-input{width:100%}.lol-match{flex-wrap:wrap;gap:6px}.lol-match-meta{margin-left:0;text-align:left}.lol-match-items,.lol-profile{flex-wrap:wrap}.lol-tier-controls{flex-direction:column;align-items:stretch}.lol-tier-filter{width:100%;margin-left:0}.lol-tier-col-br,.lol-tier-col-kda{display:none}}.stream-container{height:100%;overflow-y:auto;padding:16px}.stream-topbar{display:flex;align-items:flex-end;gap:10px;margin-bottom:16px;flex-wrap:wrap}.stream-field{display:flex;flex-direction:column;gap:4px}.stream-field-grow{flex:1;min-width:180px}.stream-field-label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:var(--text-faint);padding-left:2px}.stream-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0;width:100%;box-sizing:border-box}.stream-input:focus{border-color:var(--accent)}.stream-input::placeholder{color:var(--text-faint)}.stream-input-name{width:150px}.stream-input-title{width:100%}.stream-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.stream-btn:hover{background:var(--accent-hover)}.stream-btn:disabled{opacity:.5;cursor:not-allowed}.stream-btn-stop{background:var(--danger)}.stream-btn-stop:hover{background:#c93b3e}.stream-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.stream-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.stream-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.stream-tile.own{border:2px solid var(--accent)}.stream-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.stream-tile-preview video{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover}.stream-tile-preview .stream-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.stream-live-badge{position:absolute;top:8px;left:8px;background:var(--danger);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;letter-spacing:.5px;display:flex;align-items:center;gap:4px}.stream-live-dot{width:6px;height:6px;border-radius:50%;background:#fff;animation:stream-pulse 1.5s ease-in-out infinite}@keyframes stream-pulse{0%,to{opacity:1}50%{opacity:.3}}.stream-tile-viewers{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.stream-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.stream-tile-meta{min-width:0;flex:1}.stream-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-title{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-time{font-size:12px;color:var(--text-faint);white-space:nowrap}.stream-tile-menu-wrap{position:relative}.stream-tile-menu{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 6px;font-size:18px;line-height:1;border-radius:4px;transition:background var(--transition)}.stream-tile-menu:hover{background:var(--bg-tertiary);color:var(--text-normal)}.stream-tile-dropdown{position:absolute;bottom:calc(100% + 6px);right:0;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius-lg);min-width:220px;z-index:100;box-shadow:0 8px 24px #0006;overflow:hidden}.stream-tile-dropdown-header{padding:12px 14px}.stream-tile-dropdown-name{font-size:14px;font-weight:600;color:var(--text-normal)}.stream-tile-dropdown-title{font-size:12px;color:var(--text-muted);margin-top:2px}.stream-tile-dropdown-detail{font-size:11px;color:var(--text-faint);margin-top:6px}.stream-tile-dropdown-divider{height:1px;background:var(--bg-tertiary)}.stream-tile-dropdown-item{display:flex;align-items:center;gap:8px;width:100%;padding:10px 14px;border:none;background:none;color:var(--text-normal);font-size:13px;cursor:pointer;text-align:left;transition:background var(--transition)}.stream-tile-dropdown-item:hover{background:var(--bg-tertiary)}.stream-viewer-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.stream-viewer-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1}.stream-viewer-header-left{display:flex;align-items:center;gap:12px}.stream-viewer-title{font-weight:600;font-size:16px}.stream-viewer-subtitle{font-size:13px;color:var(--text-muted)}.stream-viewer-header-right{display:flex;align-items:center;gap:8px}.stream-viewer-fullscreen{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.stream-viewer-fullscreen:hover{background:#ffffff40}.stream-viewer-close{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.stream-viewer-close:hover{background:#fff3}.stream-viewer-video{flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden}.stream-viewer-video video{max-width:100%;max-height:100%;width:100%;height:100%;object-fit:contain}.stream-viewer-connecting{color:var(--text-muted);font-size:16px;display:flex;flex-direction:column;align-items:center;gap:12px}.stream-viewer-spinner{width:32px;height:32px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:stream-spin .8s linear infinite}@keyframes stream-spin{to{transform:rotate(360deg)}}.stream-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.stream-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.stream-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.stream-empty p{font-size:14px}.stream-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.stream-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.stream-tile.broadcasting .stream-tile-preview{border:2px solid var(--danger);border-bottom:none}.stream-input-password{width:180px}.stream-select-quality{width:210px;box-sizing:border-box;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none;transition:border-color var(--transition)}.stream-select-quality:focus{border-color:var(--accent)}.stream-select-quality:disabled{opacity:.5;cursor:not-allowed}.stream-select-quality option{background:var(--bg-secondary);color:var(--text-normal)}.stream-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.stream-pw-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.stream-pw-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.stream-pw-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.stream-pw-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.stream-pw-modal .stream-input{width:100%;margin-bottom:12px}.stream-pw-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.stream-pw-actions{display:flex;gap:8px;justify-content:flex-end}.stream-pw-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.stream-pw-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.stream-admin-btn{margin-left:auto;padding:8px;border:none;border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:18px;cursor:pointer;transition:all var(--transition);line-height:1}.stream-admin-btn:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;display:flex;align-items:center;justify-content:center;z-index:999;animation:fadeIn .15s ease}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.stream-admin-panel{background:var(--bg-secondary);border-radius:12px;width:560px;max-width:95vw;max-height:80vh;display:flex;flex-direction:column;box-shadow:0 8px 32px #0006;overflow:hidden}.stream-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-header h3{margin:0;font-size:16px;color:var(--text-normal)}.stream-admin-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:var(--radius)}.stream-admin-close:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-login{padding:24px 20px}.stream-admin-login p{margin:0 0 12px;color:var(--text-muted);font-size:14px}.stream-admin-login-row{display:flex;gap:8px}.stream-admin-login-row .stream-input{flex:1}.stream-admin-error{color:#ed4245;font-size:13px;margin-top:8px}.stream-admin-content{padding:16px 20px;overflow-y:auto}.stream-admin-toolbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;padding-bottom:12px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-status{font-size:13px;color:var(--text-muted)}.stream-admin-status b{color:var(--text-normal)}.stream-admin-logout{padding:4px 12px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:12px;cursor:pointer}.stream-admin-logout:hover{color:#ed4245;border-color:#ed4245}.stream-admin-loading,.stream-admin-empty{text-align:center;padding:32px 16px;color:var(--text-muted);font-size:14px}.stream-admin-hint{margin:0 0 12px;color:var(--text-muted);font-size:13px}.stream-admin-channel-list{display:flex;flex-direction:column;gap:8px;max-height:45vh;overflow-y:auto}.stream-admin-channel{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:var(--bg-deep);border-radius:var(--radius);gap:12px}.stream-admin-channel-info{display:flex;flex-direction:column;gap:2px;min-width:0}.stream-admin-channel-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-admin-channel-guild{font-size:11px;color:var(--text-faint)}.stream-admin-channel-events{display:flex;gap:6px;flex-shrink:0}.stream-admin-event-toggle{display:flex;align-items:center;gap:4px;padding:4px 10px;border-radius:14px;font-size:12px;color:var(--text-muted);background:var(--bg-secondary);cursor:pointer;transition:all var(--transition);white-space:nowrap}.stream-admin-event-toggle input{display:none}.stream-admin-event-toggle:hover{color:var(--text-normal)}.stream-admin-event-toggle.active{background:var(--accent);color:#fff}.stream-admin-actions{margin-top:16px;display:flex;justify-content:flex-end}.stream-admin-save{padding:8px 24px}.wt-container{height:100%;overflow-y:auto;padding:16px}.wt-topbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}.wt-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0}.wt-input:focus{border-color:var(--accent)}.wt-input::placeholder{color:var(--text-faint)}.wt-input-name{width:150px}.wt-input-room{flex:1;min-width:180px}.wt-input-password{width:170px}.wt-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.wt-btn:hover{background:var(--accent-hover)}.wt-btn:disabled{opacity:.5;cursor:not-allowed}.wt-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.wt-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.wt-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.wt-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.wt-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.wt-tile-members{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.wt-tile-playing{position:absolute;top:8px;left:8px;background:var(--accent);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.wt-tile-meta{min-width:0;flex:1}.wt-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-tile-host{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.wt-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.wt-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.wt-empty p{font-size:14px}.wt-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.wt-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.wt-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.wt-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.wt-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.wt-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.wt-modal .wt-input{width:100%;margin-bottom:12px}.wt-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.wt-modal-actions{display:flex;gap:8px;justify-content:flex-end}.wt-modal-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.wt-modal-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.wt-room-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.wt-room-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1;flex-shrink:0}.wt-room-header-left{display:flex;align-items:center;gap:12px}.wt-room-name{font-weight:600;font-size:16px}.wt-room-members{font-size:13px;color:var(--text-muted)}.wt-host-badge{font-size:11px;background:#ffffff1a;padding:2px 8px;border-radius:4px;color:var(--accent);font-weight:600}.wt-room-header-right{display:flex;align-items:center;gap:8px}.wt-fullscreen-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.wt-fullscreen-btn:hover{background:#ffffff40}.wt-leave-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.wt-leave-btn:hover{background:#fff3}.wt-room-body{display:flex;flex:1;overflow:hidden}.wt-player-section{flex:1;display:flex;flex-direction:column;min-width:0}.wt-player-wrap{position:relative;width:100%;flex:1;background:#000;display:flex;align-items:center;justify-content:center;overflow:hidden}.wt-yt-container{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}.wt-yt-container iframe{width:100%;height:100%}.wt-video-element{width:100%;height:100%;object-fit:contain}.wt-dm-container{width:100%;height:100%;border:none;position:absolute;top:0;left:0}.wt-player-placeholder{display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--text-muted);font-size:16px}.wt-placeholder-icon{font-size:48px;opacity:.3}.wt-controls{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#000c;flex-shrink:0}.wt-ctrl-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;transition:background var(--transition);flex-shrink:0}.wt-ctrl-btn:hover:not(:disabled){background:#ffffff40}.wt-ctrl-btn:disabled{opacity:.3;cursor:not-allowed}.wt-ctrl-status{color:var(--text-muted);font-size:16px;width:36px;text-align:center;flex-shrink:0}.wt-seek{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer;min-width:60px}.wt-seek::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-webkit-slider-runnable-track{height:4px;border-radius:2px}.wt-seek::-moz-range-track{height:4px;border-radius:2px;background:var(--bg-tertiary)}.wt-seek-readonly{flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);position:relative;overflow:hidden;min-width:60px}.wt-seek-progress{position:absolute;top:0;left:0;height:100%;background:var(--accent);border-radius:2px;transition:width .3s linear}.wt-time{font-variant-numeric:tabular-nums;color:#fff;font-size:13px;white-space:nowrap;flex-shrink:0}.wt-volume{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.wt-volume-icon{font-size:16px;width:20px;text-align:center;cursor:default}.wt-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer}.wt-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-quality-select{background:var(--bg-secondary, #2a2a3e);color:var(--text-primary, #e0e0e0);border:1px solid var(--border-color, #3a3a4e);border-radius:6px;padding:2px 6px;font-size:12px;cursor:pointer;outline:none;margin-left:4px}.wt-quality-select:hover{border-color:var(--accent, #7c5cff)}.wt-queue-panel{width:280px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-queue-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-list{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-queue-list::-webkit-scrollbar{width:4px}.wt-queue-list::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-queue-empty{padding:24px 16px;text-align:center;color:var(--text-faint);font-size:13px}.wt-queue-item{padding:10px 12px;border-bottom:1px solid var(--bg-tertiary);display:flex;align-items:center;gap:8px;transition:background var(--transition)}.wt-queue-item:hover{background:var(--bg-tertiary)}.wt-queue-item.playing{border-left:3px solid var(--accent);background:#e67e2214}.wt-queue-item-info{flex:1;min-width:0}.wt-queue-item-title{font-size:13px;font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-queue-item-by{font-size:11px;color:var(--text-faint);margin-top:2px}.wt-queue-item-remove{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:18px;padding:2px 6px;border-radius:4px;transition:all var(--transition);flex-shrink:0}.wt-queue-item-remove:hover{color:var(--danger);background:#ed42451f}.wt-queue-add{padding:12px;display:flex;gap:8px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-input{flex:1;font-size:13px;padding:8px 10px}.wt-queue-add-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-player-error{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:#000000d9;color:#fff;z-index:2;text-align:center;padding:20px}.wt-error-icon{font-size:48px}.wt-player-error p{font-size:15px;color:var(--text-muted);margin:0}.wt-yt-link{display:inline-block;padding:8px 20px;background:red;color:#fff;border-radius:var(--radius);text-decoration:none;font-weight:600;font-size:14px;transition:background var(--transition)}.wt-yt-link:hover{background:#c00}.wt-skip-info{font-size:12px!important;color:var(--text-faint)!important;font-style:italic}.wt-queue-item.clickable{cursor:pointer}.wt-queue-item.clickable:hover{background:#e67e221f}@media(max-width:768px){.wt-room-body{flex-direction:column}.wt-queue-panel{width:100%;max-height:40vh;border-left:none;border-top:1px solid var(--bg-tertiary)}.wt-player-wrap{min-height:200px}.wt-controls{flex-wrap:wrap;gap:8px;padding:10px 12px}.wt-volume{margin-left:0}.wt-volume-slider{width:80px}.wt-room-header{padding:10px 12px}.wt-room-name{font-size:14px}.wt-room-members,.wt-host-badge{font-size:11px}}@media(max-width:480px){.wt-topbar{gap:8px}.wt-input-name{width:100%}.wt-input-room{min-width:0}.wt-input-password{width:100%}.wt-volume-slider{width:60px}.wt-time{font-size:12px}.wt-host-badge{display:none}}.wt-queue-item.watched{opacity:.55;transition:opacity var(--transition),background var(--transition)}.wt-queue-item.watched:hover{opacity:.85}.wt-queue-item-check{color:#2ecc71;font-size:16px;font-weight:700;flex-shrink:0;line-height:1}.wt-queue-item-info{display:flex;align-items:center;gap:10px;min-width:0;flex:1}.wt-queue-thumb{width:48px;height:36px;object-fit:cover;border-radius:4px;flex-shrink:0}.wt-queue-item-text{min-width:0;flex:1}.wt-next-btn{display:flex;align-items:center;gap:4px;font-size:13px;padding:6px 12px;white-space:nowrap}.wt-sync-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.wt-sync-synced{background:#2ecc71;box-shadow:0 0 6px #2ecc7180}.wt-sync-drifting{background:#f1c40f;box-shadow:0 0 6px #f1c40f80}.wt-sync-desynced{background:#e74c3c;box-shadow:0 0 6px #e74c3c80}.wt-vote-btn{background:#ffffff14!important;border:1px solid rgba(255,255,255,.15)!important}.wt-vote-btn:hover:not(:disabled){background:#e67e2233!important;border-color:var(--accent)!important}.wt-vote-count{font-size:12px;color:var(--accent);font-weight:600;white-space:nowrap;padding:2px 8px;background:#e67e221f;border-radius:4px}.wt-header-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:13px;transition:background var(--transition)}.wt-header-btn:hover{background:#fff3}.wt-chat-panel{width:260px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-chat-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-messages{flex:1;overflow-y:auto;padding:8px 12px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-chat-messages::-webkit-scrollbar{width:4px}.wt-chat-messages::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-chat-empty{padding:24px 8px;text-align:center;color:var(--text-faint);font-size:13px}.wt-chat-msg{margin-bottom:6px;font-size:13px;line-height:1.4;word-break:break-word}.wt-chat-sender{font-weight:600;color:var(--accent);margin-right:6px}.wt-chat-text{color:var(--text-normal)}.wt-chat-input-row{padding:10px 12px;display:flex;gap:6px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-input{flex:1;font-size:13px;padding:8px 10px}.wt-chat-send-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-queue-header{display:flex;align-items:center;justify-content:space-between}.wt-queue-clear-btn{background:none;border:none;color:var(--text-faint);font-size:11px;cursor:pointer;padding:2px 6px;border-radius:4px;transition:all var(--transition)}.wt-queue-clear-btn:hover{color:var(--danger);background:#ed42451f}.wt-tile-members-list{font-size:11px;color:var(--text-faint);padding:0 12px 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:768px){.wt-chat-panel{width:100%;max-height:30vh;border-left:none;border-top:1px solid var(--bg-tertiary)}}.gl-container{padding:20px;max-width:1200px;margin:0 auto}.gl-login-bar{display:flex;gap:10px;margin-bottom:12px}.gl-connect-btn{color:#c7d5e0;padding:10px 20px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:all var(--transition);white-space:nowrap}.gl-steam-btn{background:#1b2838;border:1px solid #2a475e}.gl-steam-btn:hover{background:#2a475e;color:#fff}.gl-gog-btn{background:#2c1a4e;border:1px solid #4a2d7a;color:#c7b3e8}.gl-gog-btn:hover{background:#3d2566;color:#fff}.gl-profile-chips{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}.gl-profile-chip{display:flex;align-items:center;gap:8px;padding:6px 12px;border-radius:20px;background:#ffffff0d;border:1px solid rgba(255,255,255,.1);cursor:pointer;transition:all .2s}.gl-profile-chip.selected{border-color:#e67e22;background:#e67e221a}.gl-profile-chip:hover{background:#ffffff1a}.gl-profile-chip-avatar{width:28px;height:28px;border-radius:50%}.gl-profile-chip-info{display:flex;flex-direction:column;gap:2px}.gl-profile-chip-name{font-size:13px;font-weight:600;color:#e0e0e0}.gl-profile-chip-platforms{display:flex;gap:4px}.gl-profile-chip-count{font-size:11px;color:#667}.gl-platform-badge{font-size:9px;font-weight:700;padding:1px 5px;border-radius:3px;text-transform:uppercase}.gl-platform-badge.steam{background:#1b2838cc;color:#66c0f4;border:1px solid #2a475e}.gl-platform-badge.gog{background:#2c1a4ecc;color:#b388ff;border:1px solid #4a2d7a}.gl-game-platform-icon{font-size:9px;font-weight:700;padding:1px 4px;border-radius:3px;margin-right:6px;flex-shrink:0}.gl-game-platform-icon.steam{background:#1b283899;color:#66c0f4}.gl-game-platform-icon.gog{background:#2c1a4e99;color:#b388ff}.gl-users-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;margin-bottom:32px}.gl-user-card{background:var(--bg-secondary);border-radius:var(--radius);padding:16px;display:flex;flex-direction:column;align-items:center;gap:10px;cursor:pointer;transition:all var(--transition);border:1px solid var(--bg-tertiary)}.gl-user-card:hover{border-color:var(--accent);transform:translateY(-2px)}.gl-user-card-avatar{width:64px;height:64px;border-radius:50%}.gl-user-card-name{font-weight:600;font-size:15px;color:var(--text-normal)}.gl-user-card-games{font-size:13px;color:var(--text-faint)}.gl-user-card-updated{font-size:11px;color:var(--text-faint)}.gl-profile-card-platforms{display:flex;gap:6px;margin-top:4px}.gl-common-finder{background:var(--bg-secondary);border-radius:var(--radius);padding:20px;margin-bottom:24px}.gl-common-finder h3{margin:0 0 12px;font-size:15px;color:var(--text-normal)}.gl-common-users{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}.gl-common-check{display:flex;align-items:center;gap:6px;background:var(--bg-tertiary);padding:6px 12px 6px 6px;border-radius:20px;cursor:pointer;transition:all var(--transition)}.gl-common-check.checked{background:#e67e2226}.gl-common-check input{accent-color:var(--accent)}.gl-common-check-avatar{width:24px;height:24px;border-radius:50%}.gl-common-find-btn{background:var(--accent);color:#fff;border:none;padding:10px 24px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:background var(--transition)}.gl-common-find-btn:hover{filter:brightness(1.1)}.gl-common-find-btn:disabled{opacity:.5;cursor:not-allowed}.gl-search{margin-bottom:24px}.gl-search-input{width:100%;padding:10px 14px;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);box-sizing:border-box}.gl-search-input:focus{border-color:var(--accent)}.gl-search-input::placeholder{color:var(--text-faint)}.gl-game-list{display:flex;flex-direction:column;gap:4px}.gl-game-item{display:flex;align-items:center;gap:12px;padding:8px 12px;background:var(--bg-secondary);border-radius:var(--radius);transition:background var(--transition)}.gl-game-item:hover{background:var(--bg-tertiary)}.gl-game-icon{width:32px;height:32px;border-radius:4px;flex-shrink:0;background:var(--bg-tertiary)}.gl-game-name{flex:1;font-size:14px;color:var(--text-normal)}.gl-game-playtime{font-size:12px;color:var(--text-faint);white-space:nowrap}.gl-game-owners{display:flex;gap:4px}.gl-game-owner-avatar{width:20px;height:20px;border-radius:50%;border:1px solid var(--bg-tertiary)}.gl-detail-header{display:flex;align-items:center;gap:16px;margin-bottom:24px}.gl-back-btn{background:var(--bg-secondary);border:none;color:var(--text-normal);padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.gl-back-btn:hover{background:var(--bg-tertiary)}.gl-detail-avatar{width:48px;height:48px;border-radius:50%}.gl-detail-info{flex:1}.gl-detail-name{font-size:18px;font-weight:600;color:var(--text-normal)}.gl-detail-sub{font-size:13px;color:var(--text-faint);display:flex;align-items:center;gap:6px;margin-top:4px}.gl-refresh-btn{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:16px;padding:4px;transition:color var(--transition)}.gl-refresh-btn:hover{color:var(--accent)}.gl-platform-detail{display:inline-flex;align-items:center;gap:2px}.gl-disconnect-btn{background:none;border:none;color:#666;cursor:pointer;font-size:10px;padding:0 3px;line-height:1;border-radius:3px;transition:all .2s}.gl-disconnect-btn:hover{color:#e74c3c;background:#e74c3c26}.gl-link-gog-btn{background:#a855f726;color:#a855f7;border:1px solid rgba(168,85,247,.3);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-link-gog-btn:hover{background:#a855f740}.gl-loading{text-align:center;padding:48px;color:var(--text-faint);font-size:14px}.gl-empty{text-align:center;padding:60px 20px}.gl-empty-icon{font-size:48px;margin-bottom:16px}.gl-empty h3{color:var(--text-normal);margin:0 0 8px}.gl-empty p{color:var(--text-faint);margin:0;font-size:14px}.gl-common-playtimes{display:flex;gap:8px;flex-wrap:wrap}.gl-common-pt{font-size:11px;color:var(--text-faint);background:var(--bg-tertiary);padding:2px 8px;border-radius:4px}.gl-section-title{font-size:14px;font-weight:600;color:var(--text-normal);margin:0 0 12px}.gl-game-count{font-size:12px;color:var(--text-faint);margin-left:8px;font-weight:400}.gl-detail-avatars{display:flex;gap:-8px}.gl-detail-avatars img{width:36px;height:36px;border-radius:50%;border:2px solid var(--bg-primary);margin-left:-8px}.gl-detail-avatars img:first-child{margin-left:0}.gl-search-results-title{font-size:13px;color:var(--text-faint);margin-bottom:8px}.gl-game-item.enriched{align-items:flex-start;min-height:60px}.gl-game-visual{flex-shrink:0}.gl-game-cover{width:45px;height:64px;object-fit:cover;border-radius:4px}.gl-game-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.gl-game-genres{display:flex;flex-wrap:wrap;gap:4px}.gl-genre-tag{font-size:10px;padding:1px 6px;border-radius:3px;background:#e67e2226;color:#e67e22}.gl-game-platforms{font-size:10px;color:var(--text-muted, #888)}.gl-platform-tag{margin-left:4px;padding:1px 5px;border-radius:3px;background:#3498db26;color:#3498db}.gl-game-meta{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}.gl-game-rating{font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;min-width:28px;text-align:center}.gl-game-rating.high{background:#2ecc7133;color:#2ecc71}.gl-game-rating.mid{background:#f1c40f33;color:#f1c40f}.gl-game-rating.low{background:#e74c3c33;color:#e74c3c}.gl-enrich-btn{background:#3498db26;border:1px solid rgba(52,152,219,.3);color:#3498db;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-enrich-btn:hover:not(:disabled){background:#3498db40}.gl-enrich-btn:disabled{opacity:.5;cursor:not-allowed}.gl-enrich-btn.enriching{animation:gl-pulse 1.5s ease-in-out infinite}@keyframes gl-pulse{0%,to{opacity:.5}50%{opacity:1}}.gl-filter-bar{display:flex;align-items:center;gap:10px;margin-bottom:8px}.gl-filter-bar .gl-search-input{flex:1}.gl-sort-select{background:#ffffff0f;color:#c7d5e0;border:1px solid rgba(255,255,255,.1);padding:10px 12px;border-radius:var(--radius);font-size:13px;cursor:pointer;min-width:120px}.gl-sort-select:focus{outline:none;border-color:#ffffff40}.gl-sort-select option{background:#1a1a2e;color:#c7d5e0}.gl-genre-filters{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px;padding:8px 0}.gl-genre-chip{background:#ffffff0f;color:#8899a6;border:1px solid rgba(255,255,255,.08);padding:5px 12px;border-radius:20px;font-size:12px;cursor:pointer;transition:all .2s;white-space:nowrap}.gl-genre-chip:hover{background:#ffffff1a;color:#c7d5e0}.gl-genre-chip.active{background:#e67e2233;color:#e67e22;border-color:#e67e2266}.gl-genre-chip.active.clear{background:#3498db33;color:#3498db;border-color:#3498db66}.gl-filter-count{color:#556;font-size:12px;margin:0 0 8px}@media(max-width:768px){.gl-container{padding:12px}.gl-users-grid{grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}.gl-login-bar{flex-direction:column}}.gl-dialog-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;display:flex;align-items:center;justify-content:center;z-index:1000;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.gl-dialog{background:#2a2a3e;border-radius:12px;padding:24px;max-width:500px;width:90%;box-shadow:0 8px 32px #00000080}.gl-dialog h3{margin:0 0 12px;font-size:1.2rem;color:#fff}.gl-dialog-hint{font-size:.85rem;color:#aaa;margin-bottom:14px;line-height:1.5}.gl-dialog-input{width:100%;padding:10px 12px;background:#1a1a2e;border:1px solid #444;border-radius:8px;color:#fff;font-size:.9rem;outline:none;transition:border-color .2s}.gl-dialog-input:focus{border-color:#a855f7}.gl-dialog-status{margin-top:8px;font-size:.85rem;padding:6px 10px;border-radius:6px}.gl-dialog-status.loading{color:#a855f7}.gl-dialog-status.success{color:#4caf50}.gl-dialog-status.error{color:#e74c3c}.gl-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.gl-dialog-cancel{padding:8px 18px;background:#3a3a4e;color:#ccc;border:none;border-radius:8px;cursor:pointer;font-size:.9rem}.gl-dialog-cancel:hover{background:#4a4a5e}.gl-dialog-submit{padding:8px 18px;background:#a855f7;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:.9rem;font-weight:600}.gl-dialog-submit:hover:not(:disabled){background:#9333ea}.gl-dialog-submit:disabled{opacity:.5;cursor:not-allowed}.gl-login-bar-spacer{flex:1}.gl-admin-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#888;padding:8px 12px;border-radius:var(--radius);cursor:pointer;font-size:16px;transition:all .2s}.gl-admin-btn:hover{background:#ffffff1a;color:#ccc}.gl-admin-panel{background:#2a2a3e;border-radius:12px;padding:0;max-width:600px;width:92%;box-shadow:0 8px 32px #00000080;max-height:80vh;display:flex;flex-direction:column}.gl-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid rgba(255,255,255,.08)}.gl-admin-header h3{margin:0;font-size:1.1rem;color:#fff}.gl-admin-close{background:none;border:none;color:#888;font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px}.gl-admin-close:hover{color:#fff;background:#ffffff1a}.gl-admin-login{padding:20px}.gl-admin-login p{color:#aaa;margin:0 0 12px;font-size:14px}.gl-admin-login-row{display:flex;gap:8px}.gl-admin-login-btn{background:#e67e22;color:#fff;border:none;padding:10px 20px;border-radius:8px;cursor:pointer;font-weight:600;white-space:nowrap}.gl-admin-login-btn:hover{background:#d35400}.gl-admin-content{padding:0;overflow-y:auto}.gl-admin-toolbar{display:flex;align-items:center;gap:10px;padding:12px 20px;border-bottom:1px solid rgba(255,255,255,.06)}.gl-admin-status-text{font-size:13px;color:#4caf50;flex:1}.gl-admin-refresh-btn,.gl-admin-logout-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#aaa;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;transition:all .2s}.gl-admin-refresh-btn:hover{background:#ffffff1a;color:#fff}.gl-admin-logout-btn:hover{background:#e74c3c26;color:#e74c3c;border-color:#e74c3c4d}.gl-admin-list{padding:8px 12px}.gl-admin-item{display:flex;align-items:center;gap:12px;padding:10px 8px;border-bottom:1px solid rgba(255,255,255,.04);transition:background .15s}.gl-admin-item:last-child{border-bottom:none}.gl-admin-item:hover{background:#ffffff08}.gl-admin-item-avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0}.gl-admin-item-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.gl-admin-item-name{font-size:14px;font-weight:600;color:#e0e0e0}.gl-admin-item-details{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.gl-admin-item-total{font-size:11px;color:#667}.gl-admin-delete-btn{background:#e74c3c1a;color:#e74c3c;border:1px solid rgba(231,76,60,.2);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;white-space:nowrap;transition:all .2s;flex-shrink:0}.gl-admin-delete-btn:hover{background:#e74c3c40;border-color:#e74c3c66}:root{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--success: #57d28f;--danger: #ed4245;--warning: #fee75c;--border: rgba(255, 255, 255, .06);--radius: 8px;--radius-lg: 12px;--transition: .15s ease;--font: "Segoe UI", system-ui, -apple-system, sans-serif;--header-height: 56px}*,*:before,*:after{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;font-family:var(--font);font-size:15px;color:var(--text-normal);background:var(--bg-deep);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;overflow:hidden}#root{height:100%}.hub-app{display:flex;flex-direction:column;height:100vh;overflow:hidden}.hub-header{position:sticky;top:0;z-index:100;display:flex;align-items:center;height:var(--header-height);min-height:var(--header-height);padding:0 16px;background:var(--bg-primary);border-bottom:1px solid var(--border);gap:16px}.hub-header-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.hub-logo{font-size:24px;line-height:1}.hub-title{font-size:18px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em;white-space:nowrap}.hub-conn-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);flex-shrink:0;transition:background var(--transition);box-shadow:0 0 0 2px #ed424540}.hub-conn-dot.online{background:var(--success);box-shadow:0 0 0 2px #57d28f40;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 0 2px #57d28f40}50%{box-shadow:0 0 0 6px #57d28f1a}}.hub-tabs{display:flex;align-items:center;gap:4px;flex:1;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;padding:0 4px}.hub-tabs::-webkit-scrollbar{display:none}.hub-tab{display:flex;align-items:center;gap:6px;padding:8px 14px;border:none;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:var(--radius);white-space:nowrap;transition:all var(--transition);position:relative;-webkit-user-select:none;user-select:none}.hub-tab:hover{color:var(--text-normal);background:var(--bg-secondary)}.hub-tab.active{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-tab.active:after{content:"";position:absolute;bottom:-1px;left:50%;transform:translate(-50%);width:calc(100% - 16px);height:2px;background:var(--accent);border-radius:1px}.hub-tab-icon{font-size:16px;line-height:1}.hub-tab-label{text-transform:capitalize}.hub-header-right{display:flex;align-items:center;gap:12px;flex-shrink:0}.hub-download-btn{display:flex;align-items:center;gap:6px;padding:4px 10px;font-size:12px;font-weight:500;font-family:var(--font);text-decoration:none;color:var(--text-muted);background:var(--bg-secondary);border-radius:var(--radius);cursor:pointer;transition:all var(--transition);white-space:nowrap}.hub-download-btn:hover{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-download-icon{font-size:14px;line-height:1}.hub-download-label{line-height:1}.hub-version{font-size:12px;color:var(--text-faint);font-weight:500;font-variant-numeric:tabular-nums;background:var(--bg-secondary);padding:4px 8px;border-radius:4px}.hub-check-update-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-secondary);font-size:14px;padding:2px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-check-update-btn:hover:not(:disabled){color:var(--accent);border-color:var(--accent)}.hub-check-update-btn:disabled{opacity:.4;cursor:default}.hub-update-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-update-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:32px 40px;text-align:center;min-width:320px;max-width:400px;box-shadow:0 8px 32px #00000080}.hub-update-icon{font-size:40px;margin-bottom:12px}.hub-update-modal h2{margin:0 0 8px;font-size:18px;color:var(--text-primary)}.hub-update-modal p{margin:0 0 20px;font-size:14px;color:var(--text-secondary)}.hub-update-progress{height:4px;border-radius:2px;background:var(--bg-deep);overflow:hidden}.hub-update-progress-bar{height:100%;width:40%;border-radius:2px;background:var(--accent);animation:hub-update-slide 1.5s ease-in-out infinite}@keyframes hub-update-slide{0%{transform:translate(-100%)}to{transform:translate(350%)}}.hub-update-btn{padding:8px 32px;font-size:14px;font-weight:600;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;cursor:pointer;transition:opacity var(--transition)}.hub-update-btn:hover{opacity:.85}.hub-update-btn-secondary{background:var(--bg-tertiary);color:var(--text-secondary);margin-top:4px}.hub-update-versions{display:flex;flex-direction:column;gap:2px;margin:8px 0;font-size:12px;color:var(--text-muted)}.hub-update-error-detail{font-size:11px;color:#ef4444;background:#ef44441a;border-radius:var(--radius);padding:6px 10px;word-break:break-word;max-width:300px}.hub-refresh-btn{background:none;border:none;color:var(--text-muted);font-size:1rem;cursor:pointer;padding:4px 6px;border-radius:var(--radius);transition:all var(--transition);line-height:1}.hub-refresh-btn:hover{color:var(--accent);background:#e67e221a}.hub-admin-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-muted);font-size:16px;padding:4px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-admin-btn:hover{color:var(--accent);border-color:var(--accent)}.hub-admin-btn.active{color:#4ade80;border-color:#4ade80}.hub-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-admin-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;width:340px;box-shadow:0 8px 32px #00000080}.hub-admin-modal-header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--border);font-weight:600}.hub-admin-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:16px}.hub-admin-modal-close:hover{color:var(--text)}.hub-admin-modal-body{padding:20px;display:flex;flex-direction:column;gap:12px}.hub-admin-input{width:100%;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text);font-size:14px;font-family:var(--font);box-sizing:border-box}.hub-admin-input:focus{outline:none;border-color:var(--accent)}.hub-admin-error{color:#ef4444;font-size:13px;margin:0}.hub-admin-submit{padding:8px 16px;background:var(--accent);color:#fff;border:none;border-radius:var(--radius);font-size:14px;font-weight:500;cursor:pointer;transition:opacity var(--transition)}.hub-admin-submit:hover{opacity:.9}.hub-version-clickable{cursor:pointer;transition:all var(--transition);padding:2px 8px;border-radius:var(--radius)}.hub-version-clickable:hover{color:var(--accent);background:#e67e221a}.hub-version-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-version-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:hub-modal-in .2s ease}@keyframes hub-modal-in{0%{opacity:0;transform:scale(.95) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.hub-version-modal-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.hub-version-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.hub-version-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.hub-version-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.hub-version-modal-row{display:flex;justify-content:space-between;align-items:center}.hub-version-modal-label{color:var(--text-muted);font-size:13px}.hub-version-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.hub-version-modal-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);flex-shrink:0}.hub-version-modal-dot.online{background:var(--success)}.hub-version-modal-link{color:var(--accent);text-decoration:none;font-weight:500;font-size:13px}.hub-version-modal-link:hover{text-decoration:underline}.hub-version-modal-hint{font-size:11px;color:var(--accent);padding:6px 10px;background:#e67e221a;border-radius:var(--radius);text-align:center}.hub-version-modal-update{margin-top:4px;padding-top:12px;border-top:1px solid var(--border)}.hub-version-modal-update-btn{width:100%;padding:10px 16px;border:none;border-radius:var(--radius);background:var(--bg-tertiary);color:var(--text-normal);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);display:flex;align-items:center;justify-content:center;gap:8px}.hub-version-modal-update-btn:hover{background:var(--bg-hover);color:var(--accent)}.hub-version-modal-update-btn.ready{background:#2ecc7126;color:#2ecc71}.hub-version-modal-update-btn.ready:hover{background:#2ecc7140}.hub-version-modal-update-status{display:flex;align-items:center;justify-content:center;gap:8px;font-size:13px;color:var(--text-muted);padding:8px 0;flex-wrap:wrap}.hub-version-modal-update-status.success{color:#2ecc71}.hub-version-modal-update-status.error{color:#e74c3c}.hub-version-modal-update-retry{background:none;border:none;color:var(--text-muted);font-size:11px;cursor:pointer;text-decoration:underline;padding:2px 4px;width:100%;margin-top:4px}.hub-version-modal-update-retry:hover{color:var(--text-normal)}@keyframes hub-spin{to{transform:rotate(360deg)}}.hub-update-spinner{width:14px;height:14px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:hub-spin .8s linear infinite;flex-shrink:0}.hub-content{flex:1;overflow-y:auto;overflow-x:hidden;background:var(--bg-deep);scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.hub-content::-webkit-scrollbar{width:6px}.hub-content::-webkit-scrollbar-track{background:transparent}.hub-content::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.hub-content::-webkit-scrollbar-thumb:hover{background:var(--text-faint)}.hub-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px;text-align:center;padding:32px;animation:fade-in .3s ease}.hub-empty-icon{font-size:64px;line-height:1;margin-bottom:20px;opacity:.6;filter:grayscale(30%)}.hub-empty h2{font-size:22px;font-weight:700;color:var(--text-normal);margin-bottom:8px}.hub-empty p{font-size:15px;color:var(--text-muted);max-width:360px;line-height:1.5}@keyframes fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}::selection{background:rgba(var(--accent-rgb),.3);color:var(--text-normal)}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(max-width:768px){:root{--header-height: 48px}.hub-header{padding:0 10px;gap:8px}.hub-title{font-size:15px}.hub-logo{font-size:20px}.hub-tab{padding:6px 10px;font-size:13px;gap:4px}.hub-tab-label{display:none}.hub-tab-icon{font-size:18px}.hub-version{font-size:11px}.hub-empty-icon{font-size:48px}.hub-empty h2{font-size:18px}.hub-empty p{font-size:14px}}@media(max-width:480px){.hub-header-right{display:none}.hub-header{padding:0 8px;gap:6px}.hub-title{font-size:14px}}.radio-container{display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;background:var(--bg-deep);--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--border: rgba(255, 255, 255, .06)}.radio-container[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad}.radio-container[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60}.radio-container[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9}.radio-container[data-theme=cherry]{--bg-deep: #1a0f14;--bg-primary: #22141a;--bg-secondary: #301c25;--bg-tertiary: #3e2530;--accent: #e74c6f;--accent-rgb: 231, 76, 111;--accent-hover: #c0392b}.radio-topbar{display:flex;align-items:center;padding:0 16px;height:52px;background:var(--bg-secondary, #2b2d31);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px}.radio-topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.radio-topbar-logo{font-size:20px}.radio-topbar-title{font-size:16px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em}.radio-topbar-np{flex:1;display:flex;align-items:center;gap:10px;min-width:0;justify-content:center}.radio-topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.radio-topbar-stop{display:flex;align-items:center;gap:4px;background:var(--danger);color:#fff;border:none;border-radius:var(--radius);padding:6px 14px;font-size:13px;font-family:var(--font);font-weight:600;cursor:pointer;transition:all var(--transition);flex-shrink:0}.radio-topbar-stop:hover{background:#c63639}.radio-theme-inline{display:flex;align-items:center;gap:4px;margin-left:4px}.radio-globe-wrap{position:relative;flex:1;overflow:hidden}.radio-globe{width:100%;height:100%}.radio-globe canvas{outline:none!important}.radio-search{position:absolute;top:16px;left:50%;transform:translate(-50%);z-index:20;width:min(440px,calc(100% - 32px))}.radio-search-wrap{display:flex;align-items:center;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);padding:0 14px;gap:8px;box-shadow:0 8px 32px #0006}.radio-search-icon{font-size:16px;opacity:.6;flex-shrink:0}.radio-search-input{flex:1;background:transparent;border:none;color:var(--text-normal);font-family:var(--font);font-size:14px;padding:12px 0;outline:none}.radio-search-input::placeholder{color:var(--text-faint)}.radio-search-clear{background:none;border:none;color:var(--text-muted);font-size:14px;cursor:pointer;padding:4px;border-radius:4px;transition:color var(--transition)}.radio-search-clear:hover{color:var(--text-normal)}.radio-search-results{margin-top:6px;background:#1e1f22f2;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);max-height:360px;overflow-y:auto;box-shadow:0 12px 40px #00000080;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-search-result{display:flex;align-items:center;gap:10px;width:100%;padding:10px 14px;background:none;border:none;border-bottom:1px solid var(--border);color:var(--text-normal);font-family:var(--font);font-size:14px;cursor:pointer;text-align:left;transition:background var(--transition)}.radio-search-result:last-child{border-bottom:none}.radio-search-result:hover{background:rgba(var(--accent-rgb),.08)}.radio-search-result-icon{font-size:18px;flex-shrink:0}.radio-search-result-text{display:flex;flex-direction:column;gap:2px;min-width:0}.radio-search-result-title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-search-result-sub{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-fab{position:absolute;top:16px;right:16px;z-index:20;display:flex;align-items:center;gap:4px;padding:10px 14px;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);color:var(--text-normal);font-size:16px;cursor:pointer;box-shadow:0 8px 32px #0006;transition:all var(--transition)}.radio-fab:hover,.radio-fab.active{background:rgba(var(--accent-rgb),.15);border-color:rgba(var(--accent-rgb),.3)}.radio-fab-badge{font-size:11px;font-weight:700;background:var(--accent);color:#fff;padding:1px 6px;border-radius:10px;min-width:18px;text-align:center}.radio-panel{position:absolute;top:0;right:0;width:340px;height:100%;z-index:15;background:#1e1f22f2;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border-left:1px solid var(--border);display:flex;flex-direction:column;animation:slide-in-right .2s ease;box-shadow:-8px 0 32px #0000004d}@keyframes slide-in-right{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}.radio-panel-header{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--border);flex-shrink:0}.radio-panel-header h3{font-size:16px;font-weight:700;color:var(--text-normal)}.radio-panel-sub{font-size:12px;color:var(--text-muted);display:block;margin-top:2px}.radio-panel-close{background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all var(--transition)}.radio-panel-close:hover{color:var(--text-normal);background:var(--bg-secondary)}.radio-panel-body{flex:1;overflow-y:auto;padding:8px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-panel-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:14px}.radio-panel-loading{display:flex;flex-direction:column;align-items:center;gap:12px;padding:40px 16px;color:var(--text-muted);font-size:14px}.radio-station{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);transition:background var(--transition);gap:10px}.radio-station:hover{background:var(--bg-secondary)}.radio-station.playing{background:rgba(var(--accent-rgb),.1);border:1px solid rgba(var(--accent-rgb),.2)}.radio-station-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.radio-station-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-loc{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-live{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--accent);font-weight:600}.radio-station-btns{display:flex;gap:4px;flex-shrink:0}.radio-btn-play,.radio-btn-stop{width:34px;height:34px;border:none;border-radius:50%;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-play{background:var(--accent);color:#fff}.radio-btn-play:hover:not(:disabled){background:var(--accent-hover);transform:scale(1.05)}.radio-btn-play:disabled{opacity:.4;cursor:not-allowed}.radio-btn-stop{background:var(--danger);color:#fff}.radio-btn-stop:hover{background:#c63639}.radio-btn-fav{width:34px;height:34px;border:none;border-radius:50%;font-size:16px;cursor:pointer;background:transparent;color:var(--text-faint);display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-fav:hover{color:var(--warning);background:#fee75c1a}.radio-btn-fav.active{color:var(--warning)}.radio-eq{display:flex;align-items:flex-end;gap:2px;height:14px}.radio-eq span{width:3px;background:var(--accent);border-radius:1px;animation:eq-bounce .8s ease-in-out infinite}.radio-eq span:nth-child(1){height:8px;animation-delay:0s}.radio-eq span:nth-child(2){height:14px;animation-delay:.15s}.radio-eq span:nth-child(3){height:10px;animation-delay:.3s}@keyframes eq-bounce{0%,to{transform:scaleY(.4)}50%{transform:scaleY(1)}}.radio-sel{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius);color:var(--text-normal);font-family:var(--font);font-size:13px;padding:6px 10px;cursor:pointer;outline:none;max-width:180px}.radio-sel:focus{border-color:var(--accent)}.radio-eq-np{flex-shrink:0}.radio-np-info{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}.radio-np-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-np-loc{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-volume{display:flex;align-items:center;gap:6px;flex-shrink:0}.radio-volume-icon{font-size:16px;width:20px;text-align:center;cursor:pointer}.radio-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary, #383a40);outline:none;cursor:pointer}.radio-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-val{font-size:11px;color:var(--text-muted);min-width:32px;text-align:right}.radio-theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:transform .15s ease,border-color .15s ease;border:2px solid transparent}.radio-theme-dot:hover{transform:scale(1.25)}.radio-theme-dot.active{border-color:#fff;box-shadow:0 0 6px #ffffff4d}.radio-counter{position:absolute;bottom:16px;left:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;pointer-events:none}.radio-attribution{position:absolute;right:16px;bottom:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;text-decoration:none;transition:color var(--transition),background var(--transition)}.radio-attribution:hover{color:var(--text-normal);background:#1e1f22eb}.radio-spinner{width:24px;height:24px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media(max-width:768px){.radio-panel{width:100%}.radio-fab{top:12px;right:12px;padding:8px 10px;font-size:14px}.radio-search{top:12px;width:calc(100% - 80px);left:calc(50% - 24px)}.radio-topbar{padding:0 12px;gap:8px}.radio-topbar-title{display:none}.radio-sel{max-width:140px;font-size:12px}}@media(max-width:480px){.radio-topbar-np,.radio-volume{display:none}.radio-sel{max-width:120px}}.radio-conn{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--success);cursor:pointer;padding:4px 10px;border-radius:20px;background:#57d28f14;transition:all var(--transition);flex-shrink:0;-webkit-user-select:none;user-select:none}.radio-conn:hover{background:#57d28f26}.radio-conn-dot{width:8px;height:8px;border-radius:50%;background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.radio-conn-ping{font-size:11px;color:var(--text-muted);font-weight:600;font-variant-numeric:tabular-nums}.radio-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fade-in .15s ease}.radio-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:radio-modal-in .2s ease}@keyframes radio-modal-in{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.radio-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.radio-modal-close{margin-left:auto;background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.radio-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.radio-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.radio-modal-stat{display:flex;justify-content:space-between;align-items:center}.radio-modal-label{color:var(--text-muted);font-size:13px}.radio-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.radio-modal-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.ap-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9998;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);animation:fade-in .15s ease}.ap-modal{display:flex;width:min(940px,calc(100vw - 40px));height:min(620px,calc(100vh - 60px));background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;overflow:hidden;box-shadow:0 24px 80px #00000080;animation:hub-modal-in .2s ease;position:relative}.ap-sidebar{width:210px;min-width:210px;background:var(--bg-deep);border-right:1px solid var(--border);display:flex;flex-direction:column;padding:0}.ap-sidebar-title{padding:18px 20px 14px;font-size:15px;font-weight:700;color:var(--text-normal);letter-spacing:-.01em;border-bottom:1px solid var(--border)}.ap-nav{display:flex;flex-direction:column;padding:8px;gap:2px}.ap-nav-item{display:flex;align-items:center;gap:10px;padding:10px 14px;border:none;border-left:3px solid transparent;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:0 var(--radius) var(--radius) 0;transition:all var(--transition);text-align:left}.ap-nav-item:hover{color:var(--text-normal);background:var(--bg-secondary)}.ap-nav-item.active{color:var(--accent);background:rgba(var(--accent-rgb),.1);border-left-color:var(--accent);font-weight:600}.ap-nav-icon{font-size:16px;line-height:1}.ap-nav-label{line-height:1}.ap-content{flex:1;display:flex;flex-direction:column;overflow:hidden}.ap-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--border);flex-shrink:0}.ap-title{font-size:16px;font-weight:700;color:var(--text-normal);margin:0}.ap-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:6px;transition:all var(--transition)}.ap-close:hover{color:var(--text-normal);background:#ffffff14}.ap-body{flex:1;overflow-y:auto;padding:16px 20px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.ap-body::-webkit-scrollbar{width:6px}.ap-body::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.ap-tab-content{display:flex;flex-direction:column;gap:12px;animation:fade-in .15s ease}.ap-toolbar{display:flex;align-items:center;gap:10px}.ap-search{flex:1;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:13px;font-family:var(--font)}.ap-search:focus{outline:none;border-color:var(--accent)}.ap-search::placeholder{color:var(--text-faint)}.ap-btn{display:inline-flex;align-items:center;gap:4px;padding:8px 14px;border:none;border-radius:var(--radius);font-family:var(--font);font-size:13px;font-weight:500;cursor:pointer;transition:all var(--transition);white-space:nowrap}.ap-btn:disabled{opacity:.5;cursor:default}.ap-btn-primary{background:var(--accent);color:#fff}.ap-btn-primary:hover:not(:disabled){background:var(--accent-hover)}.ap-btn-danger{background:#ed424526;color:var(--danger);border:1px solid rgba(237,66,69,.3)}.ap-btn-danger:hover:not(:disabled){background:#ed424540}.ap-btn-outline{background:var(--bg-secondary);color:var(--text-muted);border:1px solid var(--border)}.ap-btn-outline:hover:not(:disabled){color:var(--text-normal);border-color:var(--text-faint)}.ap-btn-sm{padding:5px 10px;font-size:12px}.ap-upload-zone{display:flex;align-items:center;justify-content:center;padding:14px;border:2px dashed var(--border);border-radius:var(--radius);background:var(--bg-secondary);cursor:pointer;transition:all var(--transition);color:var(--text-muted);font-size:13px}.ap-upload-zone:hover{border-color:var(--accent);color:var(--accent);background:rgba(var(--accent-rgb),.05)}.ap-upload-progress{color:var(--accent);font-weight:600}.ap-bulk-row{display:flex;align-items:center;justify-content:space-between;padding:6px 0}.ap-select-all{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted);cursor:pointer}.ap-select-all input[type=checkbox]{accent-color:var(--accent)}.ap-list-wrap{flex:1;min-height:0}.ap-list{display:flex;flex-direction:column;gap:2px}.ap-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-item:hover{background:var(--bg-tertiary)}.ap-item-check{flex-shrink:0;cursor:pointer}.ap-item-check input[type=checkbox]{accent-color:var(--accent)}.ap-item-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.ap-item-name{font-size:13px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ap-item-meta{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ap-item-actions{display:flex;gap:4px;flex-shrink:0}.ap-rename-row{display:flex;align-items:center;gap:6px;margin-top:4px}.ap-rename-input{flex:1;padding:5px 8px;border:1px solid var(--accent);border-radius:var(--radius);background:var(--bg-deep);color:var(--text-normal);font-size:12px;font-family:var(--font)}.ap-rename-input:focus{outline:none}.ap-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:13px}.ap-hint{font-size:13px;color:var(--text-muted);margin:0}.ap-status-badge{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--text-muted)}.ap-status-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);flex-shrink:0}.ap-status-dot.online{background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.ap-channel-list{display:flex;flex-direction:column;gap:2px}.ap-channel-row{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-channel-row:hover{background:var(--bg-tertiary)}.ap-channel-info{display:flex;flex-direction:column;gap:2px;min-width:0}.ap-channel-name{font-size:13px;font-weight:600;color:var(--text-normal)}.ap-channel-guild{font-size:11px;color:var(--text-faint)}.ap-channel-toggles{display:flex;gap:8px;flex-shrink:0}.ap-toggle{display:flex;align-items:center;gap:4px;font-size:12px;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:var(--radius);transition:all var(--transition)}.ap-toggle input[type=checkbox]{accent-color:var(--accent)}.ap-toggle.active{color:var(--accent);background:rgba(var(--accent-rgb),.08)}.ap-save-row{display:flex;justify-content:flex-end;padding-top:8px}.ap-profile-list{display:flex;flex-direction:column;gap:2px}.ap-profile-row{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-profile-row:hover{background:var(--bg-tertiary)}.ap-profile-avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0}.ap-profile-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.ap-profile-name{font-size:14px;font-weight:600;color:var(--text-normal)}.ap-profile-details{display:flex;align-items:center;gap:6px;font-size:11px}.ap-platform-badge{padding:1px 6px;border-radius:3px;font-weight:600;font-size:10px}.ap-platform-badge.steam{background:#4285f426;color:#64b5f6}.ap-platform-badge.gog{background:#ab47bc26;color:#ce93d8}.ap-profile-total{color:var(--text-faint)}.ap-toast{position:absolute;bottom:16px;left:50%;transform:translate(-50%);padding:8px 16px;border-radius:var(--radius);font-size:13px;font-weight:500;background:var(--bg-tertiary);color:var(--text-normal);box-shadow:0 4px 16px #0006;animation:fade-in .15s ease;z-index:10}.ap-toast.error{background:#ed424533;color:#f87171}@media(max-width:768px){.ap-modal{flex-direction:column;width:calc(100vw - 16px);height:calc(100vh - 32px)}.ap-sidebar{width:100%;min-width:100%;flex-direction:row;border-right:none;border-bottom:1px solid var(--border);overflow-x:auto}.ap-sidebar-title{display:none}.ap-nav{flex-direction:row;padding:4px 8px;gap:4px}.ap-nav-item{border-left:none;border-bottom:3px solid transparent;border-radius:var(--radius) var(--radius) 0 0;padding:8px 12px;white-space:nowrap}.ap-nav-item.active{border-left-color:transparent;border-bottom-color:var(--accent)}.ap-channel-toggles{flex-direction:column;gap:4px}} diff --git a/web/dist/index.html b/web/dist/index.html index 40f4a36..d42f932 100644 --- a/web/dist/index.html +++ b/web/dist/index.html @@ -5,8 +5,8 @@ Gaming Hub - - + +
diff --git a/web/src/AdminPanel.tsx b/web/src/AdminPanel.tsx new file mode 100644 index 0000000..7391c7e --- /dev/null +++ b/web/src/AdminPanel.tsx @@ -0,0 +1,660 @@ +import { useState, useEffect, useMemo, useCallback } from 'react'; + +/* ══════════════════════════════════════════════════════════════════ + TYPES + ══════════════════════════════════════════════════════════════════ */ + +type Sound = { + fileName: string; + name: string; + folder?: string; + relativePath?: string; +}; + +type SoundsResponse = { + items: Sound[]; + total: number; + folders: Array<{ key: string; name: string; count: number }>; +}; + +interface AdminPanelProps { + onClose: () => void; +} + +/* ══════════════════════════════════════════════════════════════════ + API HELPERS + ══════════════════════════════════════════════════════════════════ */ + +const SB_API = '/api/soundboard'; + +async function fetchAllSounds(): Promise { + const url = new URL(`${SB_API}/sounds`, window.location.origin); + url.searchParams.set('folder', '__all__'); + url.searchParams.set('fuzzy', '0'); + const res = await fetch(url.toString()); + if (!res.ok) throw new Error('Fehler beim Laden der Sounds'); + return res.json(); +} + +async function apiAdminDelete(paths: string[]): Promise { + const res = await fetch(`${SB_API}/admin/sounds/delete`, { + method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', + body: JSON.stringify({ paths }), + }); + if (!res.ok) throw new Error('Loeschen fehlgeschlagen'); +} + +async function apiAdminRename(from: string, to: string): Promise { + const res = await fetch(`${SB_API}/admin/sounds/rename`, { + method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', + body: JSON.stringify({ from, to }), + }); + if (!res.ok) throw new Error('Umbenennen fehlgeschlagen'); + const data = await res.json(); + return data?.to as string; +} + +function apiUploadFile( + file: File, + onProgress: (pct: number) => void, +): Promise { + return new Promise((resolve, reject) => { + const form = new FormData(); + form.append('files', file); + const xhr = new XMLHttpRequest(); + xhr.open('POST', `${SB_API}/upload`); + xhr.upload.onprogress = e => { + if (e.lengthComputable) onProgress(Math.round((e.loaded / e.total) * 100)); + }; + xhr.onload = () => { + if (xhr.status === 200) { + try { + const data = JSON.parse(xhr.responseText); + resolve(data.files?.[0]?.name ?? file.name); + } catch { resolve(file.name); } + } else { + try { reject(new Error(JSON.parse(xhr.responseText).error)); } + catch { reject(new Error(`HTTP ${xhr.status}`)); } + } + }; + xhr.onerror = () => reject(new Error('Netzwerkfehler')); + xhr.send(form); + }); +} + +/* ══════════════════════════════════════════════════════════════════ + COMPONENT + ══════════════════════════════════════════════════════════════════ */ + +type AdminTab = 'soundboard' | 'streaming' | 'game-library'; + +export default function AdminPanel({ onClose }: AdminPanelProps) { + const [activeTab, setActiveTab] = useState('soundboard'); + + // ── Toast ── + const [toast, setToast] = useState<{ msg: string; type: 'info' | 'error' } | null>(null); + const notify = useCallback((msg: string, type: 'info' | 'error' = 'info') => { + setToast({ msg, type }); + setTimeout(() => setToast(null), 3000); + }, []); + + // ── Escape key ── + useEffect(() => { + const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; + window.addEventListener('keydown', handler); + return () => window.removeEventListener('keydown', handler); + }, [onClose]); + + /* ════════════════════════════════════════════════════════════════ + SOUNDBOARD ADMIN STATE + ════════════════════════════════════════════════════════════════ */ + const [sbSounds, setSbSounds] = useState([]); + const [sbLoading, setSbLoading] = useState(false); + const [sbQuery, setSbQuery] = useState(''); + const [sbSelection, setSbSelection] = useState>({}); + const [sbRenameTarget, setSbRenameTarget] = useState(''); + const [sbRenameValue, setSbRenameValue] = useState(''); + const [sbUploadProgress, setSbUploadProgress] = useState(null); + + const soundKey = useCallback((s: Sound) => s.relativePath ?? s.fileName, []); + + const loadSbSounds = useCallback(async () => { + setSbLoading(true); + try { + const d = await fetchAllSounds(); + setSbSounds(d.items || []); + } catch (e: any) { + notify(e?.message || 'Sounds konnten nicht geladen werden', 'error'); + } finally { + setSbLoading(false); + } + }, [notify]); + + // Load on first tab switch + const [sbLoaded, setSbLoaded] = useState(false); + useEffect(() => { + if (activeTab === 'soundboard' && !sbLoaded) { + setSbLoaded(true); + void loadSbSounds(); + } + }, [activeTab, sbLoaded, loadSbSounds]); + + const sbFiltered = useMemo(() => { + const q = sbQuery.trim().toLowerCase(); + if (!q) return sbSounds; + return sbSounds.filter(s => { + const key = soundKey(s).toLowerCase(); + return s.name.toLowerCase().includes(q) + || (s.folder || '').toLowerCase().includes(q) + || key.includes(q); + }); + }, [sbQuery, sbSounds, soundKey]); + + const sbSelectedPaths = useMemo(() => + Object.keys(sbSelection).filter(k => sbSelection[k]), + [sbSelection]); + + const sbSelectedVisibleCount = useMemo(() => + sbFiltered.filter(s => !!sbSelection[soundKey(s)]).length, + [sbFiltered, sbSelection, soundKey]); + + const sbAllVisibleSelected = sbFiltered.length > 0 && sbSelectedVisibleCount === sbFiltered.length; + + function sbToggleSelection(path: string) { + setSbSelection(prev => ({ ...prev, [path]: !prev[path] })); + } + + function sbStartRename(sound: Sound) { + setSbRenameTarget(soundKey(sound)); + setSbRenameValue(sound.name); + } + + function sbCancelRename() { + setSbRenameTarget(''); + setSbRenameValue(''); + } + + async function sbSubmitRename() { + if (!sbRenameTarget) return; + const baseName = sbRenameValue.trim().replace(/\.(mp3|wav)$/i, ''); + if (!baseName) { + notify('Bitte einen gueltigen Namen eingeben', 'error'); + return; + } + try { + await apiAdminRename(sbRenameTarget, baseName); + notify('Sound umbenannt'); + sbCancelRename(); + await loadSbSounds(); + } catch (e: any) { + notify(e?.message || 'Umbenennen fehlgeschlagen', 'error'); + } + } + + async function sbDeletePaths(paths: string[]) { + if (paths.length === 0) return; + try { + await apiAdminDelete(paths); + notify(paths.length === 1 ? 'Sound geloescht' : `${paths.length} Sounds geloescht`); + setSbSelection({}); + sbCancelRename(); + await loadSbSounds(); + } catch (e: any) { + notify(e?.message || 'Loeschen fehlgeschlagen', 'error'); + } + } + + async function sbUpload(file: File) { + setSbUploadProgress(0); + try { + await apiUploadFile(file, pct => setSbUploadProgress(pct)); + notify(`"${file.name}" hochgeladen`); + await loadSbSounds(); + } catch (e: any) { + notify(e?.message || 'Upload fehlgeschlagen', 'error'); + } finally { + setSbUploadProgress(null); + } + } + + /* ════════════════════════════════════════════════════════════════ + STREAMING ADMIN STATE + ════════════════════════════════════════════════════════════════ */ + const [stAvailableChannels, setStAvailableChannels] = useState>([]); + const [stNotifyConfig, setStNotifyConfig] = useState>([]); + const [stConfigLoading, setStConfigLoading] = useState(false); + const [stConfigSaving, setStConfigSaving] = useState(false); + const [stNotifyStatus, setStNotifyStatus] = useState<{ online: boolean; botTag: string | null }>({ online: false, botTag: null }); + + const loadStreamingConfig = useCallback(async () => { + setStConfigLoading(true); + try { + const [statusResp, chResp, cfgResp] = await Promise.all([ + fetch('/api/notifications/status'), + fetch('/api/notifications/channels', { credentials: 'include' }), + fetch('/api/notifications/config', { credentials: 'include' }), + ]); + if (statusResp.ok) { + const d = await statusResp.json(); + setStNotifyStatus(d); + } + if (chResp.ok) { + const chData = await chResp.json(); + setStAvailableChannels(chData.channels || []); + } + if (cfgResp.ok) { + const cfgData = await cfgResp.json(); + setStNotifyConfig(cfgData.channels || []); + } + } catch { /* silent */ } + finally { setStConfigLoading(false); } + }, []); + + const [stLoaded, setStLoaded] = useState(false); + useEffect(() => { + if (activeTab === 'streaming' && !stLoaded) { + setStLoaded(true); + void loadStreamingConfig(); + } + }, [activeTab, stLoaded, loadStreamingConfig]); + + const stToggleEvent = useCallback((channelId: string, channelName: string, guildId: string, guildName: string, event: string) => { + setStNotifyConfig(prev => { + const existing = prev.find(c => c.channelId === channelId); + if (existing) { + const hasEvent = existing.events.includes(event); + const newEvents = hasEvent + ? existing.events.filter(e => e !== event) + : [...existing.events, event]; + if (newEvents.length === 0) { + return prev.filter(c => c.channelId !== channelId); + } + return prev.map(c => c.channelId === channelId ? { ...c, events: newEvents } : c); + } else { + return [...prev, { channelId, channelName, guildId, guildName, events: [event] }]; + } + }); + }, []); + + const stIsEnabled = useCallback((channelId: string, event: string): boolean => { + const ch = stNotifyConfig.find(c => c.channelId === channelId); + return ch?.events.includes(event) ?? false; + }, [stNotifyConfig]); + + const stSaveConfig = useCallback(async () => { + setStConfigSaving(true); + try { + await fetch('/api/notifications/config', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ channels: stNotifyConfig }), + credentials: 'include', + }); + notify('Konfiguration gespeichert'); + } catch { + notify('Speichern fehlgeschlagen', 'error'); + } finally { + setStConfigSaving(false); + } + }, [stNotifyConfig, notify]); + + /* ════════════════════════════════════════════════════════════════ + GAME LIBRARY ADMIN STATE + ════════════════════════════════════════════════════════════════ */ + const [glProfiles, setGlProfiles] = useState([]); + const [glLoading, setGlLoading] = useState(false); + + const loadGlProfiles = useCallback(async () => { + setGlLoading(true); + try { + const resp = await fetch('/api/game-library/admin/profiles', { credentials: 'include' }); + if (resp.ok) { + const d = await resp.json(); + setGlProfiles(d.profiles || []); + } + } catch { /* silent */ } + finally { setGlLoading(false); } + }, []); + + const [glLoaded, setGlLoaded] = useState(false); + useEffect(() => { + if (activeTab === 'game-library' && !glLoaded) { + setGlLoaded(true); + void loadGlProfiles(); + } + }, [activeTab, glLoaded, loadGlProfiles]); + + const glDeleteProfile = useCallback(async (profileId: string, displayName: string) => { + if (!confirm(`Profil "${displayName}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`)) return; + try { + const resp = await fetch(`/api/game-library/admin/profile/${profileId}`, { + method: 'DELETE', + credentials: 'include', + }); + if (resp.ok) { + notify('Profil geloescht'); + loadGlProfiles(); + } + } catch { + notify('Loeschen fehlgeschlagen', 'error'); + } + }, [loadGlProfiles, notify]); + + /* ════════════════════════════════════════════════════════════════ + TAB CONFIG + ════════════════════════════════════════════════════════════════ */ + + const tabs: { id: AdminTab; icon: string; label: string }[] = [ + { id: 'soundboard', icon: '\uD83C\uDFB5', label: 'Soundboard' }, + { id: 'streaming', icon: '\uD83D\uDCFA', label: 'Streaming' }, + { id: 'game-library', icon: '\uD83C\uDFAE', label: 'Game Library' }, + ]; + + /* ════════════════════════════════════════════════════════════════ + RENDER + ════════════════════════════════════════════════════════════════ */ + + return ( +
{ if (e.target === e.currentTarget) onClose(); }}> +
+ {/* ── Sidebar ── */} +
+
{'\u2699\uFE0F'} Admin
+ +
+ + {/* ── Content ── */} +
+
+

+ {tabs.find(t => t.id === activeTab)?.icon}{' '} + {tabs.find(t => t.id === activeTab)?.label} +

+ +
+ +
+ {/* ═══════════════════ SOUNDBOARD TAB ═══════════════════ */} + {activeTab === 'soundboard' && ( +
+
+ setSbQuery(e.target.value)} + placeholder="Nach Name, Ordner oder Pfad filtern..." + /> + +
+ + {/* Upload */} + + + {/* Bulk actions */} +
+ + +
+ + {/* Sound list */} +
+ {sbLoading ? ( +
Lade Sounds...
+ ) : sbFiltered.length === 0 ? ( +
Keine Sounds gefunden.
+ ) : ( +
+ {sbFiltered.map(sound => { + const key = soundKey(sound); + const editing = sbRenameTarget === key; + return ( +
+ +
+
{sound.name}
+
+ {sound.folder ? `Ordner: ${sound.folder}` : 'Root'} + {' \u00B7 '} + {key} +
+ {editing && ( +
+ setSbRenameValue(e.target.value)} + onKeyDown={e => { + if (e.key === 'Enter') void sbSubmitRename(); + if (e.key === 'Escape') sbCancelRename(); + }} + placeholder="Neuer Name..." + autoFocus + /> + + +
+ )} +
+ {!editing && ( +
+ + +
+ )} +
+ ); + })} +
+ )} +
+
+ )} + + {/* ═══════════════════ STREAMING TAB ═══════════════════ */} + {activeTab === 'streaming' && ( +
+
+ + + {stNotifyStatus.online + ? <>Bot online: {stNotifyStatus.botTag} + : <>Bot offline} + + +
+ + {stConfigLoading ? ( +
Lade Kanaele...
+ ) : stAvailableChannels.length === 0 ? ( +
+ {stNotifyStatus.online + ? 'Keine Text-Kanaele gefunden. Bot hat moeglicherweise keinen Zugriff.' + : 'Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren.'} +
+ ) : ( + <> +

+ Waehle die Kanaele, in die Benachrichtigungen gesendet werden sollen: +

+
+ {stAvailableChannels.map(ch => ( +
+
+ #{ch.channelName} + {ch.guildName} +
+
+ + +
+
+ ))} +
+
+ +
+ + )} +
+ )} + + {/* ═══════════════════ GAME LIBRARY TAB ═══════════════════ */} + {activeTab === 'game-library' && ( +
+
+ + + Eingeloggt als Admin + + +
+ + {glLoading ? ( +
Lade Profile...
+ ) : glProfiles.length === 0 ? ( +
Keine Profile vorhanden.
+ ) : ( +
+ {glProfiles.map((p: any) => ( +
+ {p.displayName} +
+ {p.displayName} + + {p.steamName && Steam: {p.steamGames}} + {p.gogName && GOG: {p.gogGames}} + {p.totalGames} Spiele + +
+ +
+ ))} +
+ )} +
+ )} +
+
+ + {/* ── Toast ── */} + {toast && ( +
+ {toast.type === 'error' ? '\u274C' : '\u2705'} {toast.msg} +
+ )} +
+
+ ); +} diff --git a/web/src/App.tsx b/web/src/App.tsx index ec899df..7f42823 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -5,6 +5,7 @@ import LolstatsTab from './plugins/lolstats/LolstatsTab'; import StreamingTab from './plugins/streaming/StreamingTab'; import WatchTogetherTab from './plugins/watch-together/WatchTogetherTab'; import GameLibraryTab from './plugins/game-library/GameLibraryTab'; +import AdminPanel from './AdminPanel'; interface PluginInfo { name: string; @@ -43,6 +44,7 @@ export default function App() { // Centralized admin login state const [isAdmin, setIsAdmin] = useState(false); const [showAdminLogin, setShowAdminLogin] = useState(false); + const [showAdminPanel, setShowAdminPanel] = useState(false); const [adminPwd, setAdminPwd] = useState(''); const [adminError, setAdminError] = useState(''); @@ -238,8 +240,9 @@ export default function App() { )} @@ -390,6 +393,10 @@ export default function App() {
)} + {showAdminPanel && isAdmin && ( + setShowAdminPanel(false)} /> + )} +
{plugins.length === 0 ? (
diff --git a/web/src/plugins/game-library/GameLibraryTab.tsx b/web/src/plugins/game-library/GameLibraryTab.tsx index bb279ff..3072cc6 100644 --- a/web/src/plugins/game-library/GameLibraryTab.tsx +++ b/web/src/plugins/game-library/GameLibraryTab.tsx @@ -109,11 +109,9 @@ export default function GameLibraryTab({ data, isAdmin: isAdminProp }: { data: a const filterInputRef = useRef(null); const [filterQuery, setFilterQuery] = useState(''); - // ── Admin state ── - const [showAdmin, setShowAdmin] = useState(false); - const isAdmin = isAdminProp ?? false; - const [adminProfiles, setAdminProfiles] = useState([]); - const [adminLoading, setAdminLoading] = useState(false); + // ── Admin (centralized in App.tsx) ── + const _isAdmin = isAdminProp ?? false; + void _isAdmin; // ── SSE data sync ── useEffect(() => { @@ -131,39 +129,6 @@ export default function GameLibraryTab({ data, isAdmin: isAdminProp }: { data: a } catch { /* silent */ } }, []); - // ── Admin: load profiles ── - const loadAdminProfiles = useCallback(async () => { - setAdminLoading(true); - try { - const resp = await fetch('/api/game-library/admin/profiles', { credentials: 'include' }); - if (resp.ok) { - const d = await resp.json(); - setAdminProfiles(d.profiles || []); - } - } catch { /* silent */ } - finally { setAdminLoading(false); } - }, []); - - // ── Admin: open panel ── - const openAdmin = useCallback(() => { - setShowAdmin(true); - if (isAdmin) loadAdminProfiles(); - }, [isAdmin, loadAdminProfiles]); - - // ── Admin: delete profile ── - const adminDeleteProfile = useCallback(async (profileId: string, displayName: string) => { - if (!confirm(`Profil "${displayName}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`)) return; - try { - const resp = await fetch(`/api/game-library/admin/profile/${profileId}`, { - method: 'DELETE', - credentials: 'include', - }); - if (resp.ok) { - loadAdminProfiles(); - fetchProfiles(); - } - } catch { /* silent */ } - }, [loadAdminProfiles, fetchProfiles]); // ── Steam login ── const connectSteam = useCallback(() => { @@ -513,11 +478,6 @@ export default function GameLibraryTab({ data, isAdmin: isAdminProp }: { data: a )}
- {isAdmin && ( - - )}
{/* ── Profile Chips ── */} @@ -944,54 +904,6 @@ export default function GameLibraryTab({ data, isAdmin: isAdminProp }: { data: a ); })()} - {/* ── Admin Panel ── */} - {showAdmin && ( -
setShowAdmin(false)}> -
e.stopPropagation()}> -
-

⚙️ Game Library Admin

- -
- -
-
- ✅ Eingeloggt als Admin - -
- - {adminLoading ? ( -
Lade Profile...
- ) : adminProfiles.length === 0 ? ( -

Keine Profile vorhanden.

- ) : ( -
- {adminProfiles.map((p: any) => ( -
- {p.displayName} -
- {p.displayName} - - {p.steamName && Steam: {p.steamGames}} - {p.gogName && GOG: {p.gogGames}} - {p.totalGames} Spiele - -
- -
- ))} -
- )} -
-
-
- )} - {/* ── GOG Code Dialog (browser fallback only) ── */} {gogDialogOpen && (
setGogDialogOpen(false)}> diff --git a/web/src/plugins/soundboard/SoundboardTab.tsx b/web/src/plugins/soundboard/SoundboardTab.tsx index 4e1af67..bf1274d 100644 --- a/web/src/plugins/soundboard/SoundboardTab.tsx +++ b/web/src/plugins/soundboard/SoundboardTab.tsx @@ -361,13 +361,6 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp }: Soundboard /* ── Admin ── */ const isAdmin = isAdminProp ?? false; - const [showAdmin, setShowAdmin] = useState(false); - const [adminSounds, setAdminSounds] = useState([]); - const [adminLoading, setAdminLoading] = useState(false); - const [adminQuery, setAdminQuery] = useState(''); - const [adminSelection, setAdminSelection] = useState>({}); - const [renameTarget, setRenameTarget] = useState(''); - const [renameValue, setRenameValue] = useState(''); /* ── Drag & Drop Upload ── */ const [isDragging, setIsDragging] = useState(false); @@ -636,13 +629,6 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp }: Soundboard return () => document.removeEventListener('click', handler); }, []); - useEffect(() => { - if (showAdmin && isAdmin) { - void loadAdminSounds(); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [showAdmin, isAdmin]); - /* ── Actions ── */ async function loadAnalytics() { try { @@ -801,64 +787,6 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp }: Soundboard setFavs(prev => ({ ...prev, [key]: !prev[key] })); } - async function loadAdminSounds() { - setAdminLoading(true); - try { - const d = await fetchSounds('', '__all__', undefined, false); - setAdminSounds(d.items || []); - } catch (e: any) { - notify(e?.message || 'Admin-Sounds konnten nicht geladen werden', 'error'); - } finally { - setAdminLoading(false); - } - } - - function toggleAdminSelection(path: string) { - setAdminSelection(prev => ({ ...prev, [path]: !prev[path] })); - } - - function startRename(sound: Sound) { - setRenameTarget(soundKey(sound)); - setRenameValue(sound.name); - } - - function cancelRename() { - setRenameTarget(''); - setRenameValue(''); - } - - async function submitRename() { - if (!renameTarget) return; - const baseName = renameValue.trim().replace(/\.(mp3|wav)$/i, ''); - if (!baseName) { - notify('Bitte einen gueltigen Namen eingeben', 'error'); - return; - } - try { - await apiAdminRename(renameTarget, baseName); - notify('Sound umbenannt'); - cancelRename(); - setRefreshKey(k => k + 1); - if (showAdmin) await loadAdminSounds(); - } catch (e: any) { - notify(e?.message || 'Umbenennen fehlgeschlagen', 'error'); - } - } - - async function deleteAdminPaths(paths: string[]) { - if (paths.length === 0) return; - try { - await apiAdminDelete(paths); - notify(paths.length === 1 ? 'Sound geloescht' : `${paths.length} Sounds geloescht`); - setAdminSelection({}); - cancelRename(); - setRefreshKey(k => k + 1); - if (showAdmin) await loadAdminSounds(); - } catch (e: any) { - notify(e?.message || 'Loeschen fehlgeschlagen', 'error'); - } - } - /* ── Computed ── */ const displaySounds = useMemo(() => { if (activeTab === 'favorites') return sounds.filter(s => favs[s.relativePath ?? s.fileName]); @@ -896,26 +824,6 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp }: Soundboard return groups; }, [channels]); - const adminFilteredSounds = useMemo(() => { - const q = adminQuery.trim().toLowerCase(); - if (!q) return adminSounds; - return adminSounds.filter(s => { - const key = soundKey(s).toLowerCase(); - return s.name.toLowerCase().includes(q) - || (s.folder || '').toLowerCase().includes(q) - || key.includes(q); - }); - }, [adminQuery, adminSounds, soundKey]); - - const selectedAdminPaths = useMemo(() => - Object.keys(adminSelection).filter(k => adminSelection[k]), - [adminSelection]); - - const selectedVisibleCount = useMemo(() => - adminFilteredSounds.filter(s => !!adminSelection[soundKey(s)]).length, - [adminFilteredSounds, adminSelection, soundKey]); - - const allVisibleSelected = adminFilteredSounds.length > 0 && selectedVisibleCount === adminFilteredSounds.length; const analyticsTop = analytics.mostPlayed.slice(0, 10); const totalSoundsDisplay = analytics.totalSounds || total; @@ -998,15 +906,6 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp }: Soundboard )}
)} - {isAdmin && ( - - )}
@@ -1316,7 +1215,14 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp }: Soundboard
{ const path = ctxMenu.sound.relativePath ?? ctxMenu.sound.fileName; - await deleteAdminPaths([path]); + if (!window.confirm(`Sound "${ctxMenu.sound.name}" loeschen?`)) { setCtxMenu(null); return; } + try { + await apiAdminDelete([path]); + notify('Sound geloescht'); + setRefreshKey(k => k + 1); + } catch (e: any) { + notify(e?.message || 'Loeschen fehlgeschlagen', 'error'); + } setCtxMenu(null); }}> delete @@ -1397,142 +1303,6 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp }: Soundboard
)} - {/* ═══ ADMIN PANEL ═══ */} - {showAdmin && ( -
{ if (e.target === e.currentTarget) setShowAdmin(false); }}> -
-

- Admin - -

-
-
-

Eingeloggt als Admin

-
- -
-
- -
- - setAdminQuery(e.target.value)} - placeholder="Nach Name, Ordner oder Pfad filtern..." - /> -
- -
- - - -
- -
- {adminLoading ? ( -
Lade Sounds...
- ) : adminFilteredSounds.length === 0 ? ( -
Keine Sounds gefunden.
- ) : ( -
- {adminFilteredSounds.map(sound => { - const key = soundKey(sound); - const editing = renameTarget === key; - return ( -
- - -
-
{sound.name}
-
- {sound.folder ? `Ordner: ${sound.folder}` : 'Root'} - {' \u00B7 '} - {key} -
- {editing && ( -
- setRenameValue(e.target.value)} - onKeyDown={e => { - if (e.key === 'Enter') void submitRename(); - if (e.key === 'Escape') cancelRename(); - }} - placeholder="Neuer Name..." - /> - - -
- )} -
- - {!editing && ( -
- - -
- )} -
- ); - })} -
- )} -
-
-
-
- )} - {/* ── Drag & Drop Overlay ── */} {isDragging && (
diff --git a/web/src/plugins/streaming/StreamingTab.tsx b/web/src/plugins/streaming/StreamingTab.tsx index 441fec6..a511798 100644 --- a/web/src/plugins/streaming/StreamingTab.tsx +++ b/web/src/plugins/streaming/StreamingTab.tsx @@ -72,14 +72,9 @@ export default function StreamingTab({ data, isAdmin: isAdminProp }: { data: any const [openMenu, setOpenMenu] = useState(null); const [copiedId, setCopiedId] = useState(null); - // ── Admin / Notification Config ── - const [showAdmin, setShowAdmin] = useState(false); - const isAdmin = isAdminProp ?? false; - const [availableChannels, setAvailableChannels] = useState>([]); - const [notifyConfig, setNotifyConfig] = useState>([]); - const [configLoading, setConfigLoading] = useState(false); - const [configSaving, setConfigSaving] = useState(false); - const [notifyStatus, setNotifyStatus] = useState<{ online: boolean; botTag: string | null }>({ online: false, botTag: null }); + // ── Admin ── + const _isAdmin = isAdminProp ?? false; + void _isAdmin; // kept for potential future use // ── Refs ── const wsRef = useRef(null); @@ -135,13 +130,6 @@ export default function StreamingTab({ data, isAdmin: isAdminProp }: { data: any return () => document.removeEventListener('click', handler); }, [openMenu]); - // Check bot status on mount - useEffect(() => { - fetch('/api/notifications/status') - .then(r => r.json()) - .then(d => setNotifyStatus(d)) - .catch(() => {}); - }, []); // ── Send via WS ── const wsSend = useCallback((d: Record) => { @@ -603,68 +591,6 @@ export default function StreamingTab({ data, isAdmin: isAdminProp }: { data: any setOpenMenu(null); }, [buildStreamLink]); - const loadNotifyConfig = useCallback(async () => { - setConfigLoading(true); - try { - const [chResp, cfgResp] = await Promise.all([ - fetch('/api/notifications/channels', { credentials: 'include' }), - fetch('/api/notifications/config', { credentials: 'include' }), - ]); - if (chResp.ok) { - const chData = await chResp.json(); - setAvailableChannels(chData.channels || []); - } - if (cfgResp.ok) { - const cfgData = await cfgResp.json(); - setNotifyConfig(cfgData.channels || []); - } - } catch { /* silent */ } - finally { setConfigLoading(false); } - }, []); - - const openAdmin = useCallback(() => { - setShowAdmin(true); - if (isAdmin) loadNotifyConfig(); - }, [isAdmin, loadNotifyConfig]); - - const toggleChannelEvent = useCallback((channelId: string, channelName: string, guildId: string, guildName: string, event: string) => { - setNotifyConfig(prev => { - const existing = prev.find(c => c.channelId === channelId); - if (existing) { - const hasEvent = existing.events.includes(event); - const newEvents = hasEvent - ? existing.events.filter(e => e !== event) - : [...existing.events, event]; - if (newEvents.length === 0) { - return prev.filter(c => c.channelId !== channelId); - } - return prev.map(c => c.channelId === channelId ? { ...c, events: newEvents } : c); - } else { - return [...prev, { channelId, channelName, guildId, guildName, events: [event] }]; - } - }); - }, []); - - const saveNotifyConfig = useCallback(async () => { - setConfigSaving(true); - try { - const resp = await fetch('/api/notifications/config', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ channels: notifyConfig }), - credentials: 'include', - }); - if (resp.ok) { - // brief visual feedback handled by configSaving state - } - } catch { /* silent */ } - finally { setConfigSaving(false); } - }, [notifyConfig]); - - const isChannelEventEnabled = useCallback((channelId: string, event: string): boolean => { - const ch = notifyConfig.find(c => c.channelId === channelId); - return ch?.events.includes(event) ?? false; - }, [notifyConfig]); // ── Render ── @@ -771,11 +697,6 @@ export default function StreamingTab({ data, isAdmin: isAdminProp }: { data: any {starting ? 'Starte...' : '\u{1F5A5}\uFE0F Stream starten'} )} - {isAdmin && ( - - )}
{streams.length === 0 && !isBroadcasting ? ( @@ -880,80 +801,6 @@ export default function StreamingTab({ data, isAdmin: isAdminProp }: { data: any
)} - {/* ── Notification Admin Modal ── */} - {showAdmin && ( -
setShowAdmin(false)}> -
e.stopPropagation()}> -
-

{'\uD83D\uDD14'} Benachrichtigungen

- -
- -
-
- - {notifyStatus.online - ? <>{'\u2705'} Bot online: {notifyStatus.botTag} - : <>{'\u26A0\uFE0F'} Bot offline — DISCORD_TOKEN_NOTIFICATIONS setzen} - -
- - {configLoading ? ( -
Lade Kan{'\u00E4'}le...
- ) : availableChannels.length === 0 ? ( -
- {notifyStatus.online - ? 'Keine Text-Kan\u00E4le gefunden. Bot hat m\u00F6glicherweise keinen Zugriff.' - : 'Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren.'} -
- ) : ( - <> -

- W{'\u00E4'}hle die Kan{'\u00E4'}le, in die Benachrichtigungen gesendet werden sollen: -

-
- {availableChannels.map(ch => ( -
-
- #{ch.channelName} - {ch.guildName} -
-
- - -
-
- ))} -
-
- -
- - )} -
-
-
- )}
); } diff --git a/web/src/styles.css b/web/src/styles.css index 77e8424..257d09f 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -1676,3 +1676,624 @@ html, body { border-radius: 50%; flex-shrink: 0; } + +/* ══════════════════════════════════════════════ + UNIFIED ADMIN PANEL (ap-*) + ══════════════════════════════════════════════ */ + +.ap-overlay { + position: fixed; + inset: 0; + z-index: 9998; + display: flex; + align-items: center; + justify-content: center; + background: rgba(0, 0, 0, 0.7); + backdrop-filter: blur(6px); + animation: fade-in 150ms ease; +} + +.ap-modal { + display: flex; + width: min(940px, calc(100vw - 40px)); + height: min(620px, calc(100vh - 60px)); + background: var(--bg-primary); + border: 1px solid var(--border); + border-radius: 16px; + overflow: hidden; + box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5); + animation: hub-modal-in 200ms ease; + position: relative; +} + +/* ── Sidebar ── */ +.ap-sidebar { + width: 210px; + min-width: 210px; + background: var(--bg-deep); + border-right: 1px solid var(--border); + display: flex; + flex-direction: column; + padding: 0; +} + +.ap-sidebar-title { + padding: 18px 20px 14px; + font-size: 15px; + font-weight: 700; + color: var(--text-normal); + letter-spacing: -0.01em; + border-bottom: 1px solid var(--border); +} + +.ap-nav { + display: flex; + flex-direction: column; + padding: 8px; + gap: 2px; +} + +.ap-nav-item { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 14px; + border: none; + border-left: 3px solid transparent; + background: transparent; + color: var(--text-muted); + font-family: var(--font); + font-size: 14px; + font-weight: 500; + cursor: pointer; + border-radius: 0 var(--radius) var(--radius) 0; + transition: all var(--transition); + text-align: left; +} + +.ap-nav-item:hover { + color: var(--text-normal); + background: var(--bg-secondary); +} + +.ap-nav-item.active { + color: var(--accent); + background: rgba(var(--accent-rgb), 0.1); + border-left-color: var(--accent); + font-weight: 600; +} + +.ap-nav-icon { + font-size: 16px; + line-height: 1; +} + +.ap-nav-label { + line-height: 1; +} + +/* ── Content Area ── */ +.ap-content { + flex: 1; + display: flex; + flex-direction: column; + overflow: hidden; +} + +.ap-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 16px 20px; + border-bottom: 1px solid var(--border); + flex-shrink: 0; +} + +.ap-title { + font-size: 16px; + font-weight: 700; + color: var(--text-normal); + margin: 0; +} + +.ap-close { + background: none; + border: none; + color: var(--text-muted); + font-size: 16px; + cursor: pointer; + padding: 4px 8px; + border-radius: 6px; + transition: all var(--transition); +} + +.ap-close:hover { + color: var(--text-normal); + background: rgba(255, 255, 255, 0.08); +} + +.ap-body { + flex: 1; + overflow-y: auto; + padding: 16px 20px; + scrollbar-width: thin; + scrollbar-color: var(--bg-tertiary) transparent; +} + +.ap-body::-webkit-scrollbar { + width: 6px; +} +.ap-body::-webkit-scrollbar-thumb { + background: var(--bg-tertiary); + border-radius: 3px; +} + +.ap-tab-content { + display: flex; + flex-direction: column; + gap: 12px; + animation: fade-in 150ms ease; +} + +/* ── Toolbar ── */ +.ap-toolbar { + display: flex; + align-items: center; + gap: 10px; +} + +.ap-search { + flex: 1; + padding: 8px 12px; + border: 1px solid var(--border); + border-radius: var(--radius); + background: var(--bg-secondary); + color: var(--text-normal); + font-size: 13px; + font-family: var(--font); +} + +.ap-search:focus { + outline: none; + border-color: var(--accent); +} + +.ap-search::placeholder { + color: var(--text-faint); +} + +/* ── Buttons ── */ +.ap-btn { + display: inline-flex; + align-items: center; + gap: 4px; + padding: 8px 14px; + border: none; + border-radius: var(--radius); + font-family: var(--font); + font-size: 13px; + font-weight: 500; + cursor: pointer; + transition: all var(--transition); + white-space: nowrap; +} + +.ap-btn:disabled { + opacity: 0.5; + cursor: default; +} + +.ap-btn-primary { + background: var(--accent); + color: #fff; +} +.ap-btn-primary:hover:not(:disabled) { + background: var(--accent-hover); +} + +.ap-btn-danger { + background: rgba(237, 66, 69, 0.15); + color: var(--danger); + border: 1px solid rgba(237, 66, 69, 0.3); +} +.ap-btn-danger:hover:not(:disabled) { + background: rgba(237, 66, 69, 0.25); +} + +.ap-btn-outline { + background: var(--bg-secondary); + color: var(--text-muted); + border: 1px solid var(--border); +} +.ap-btn-outline:hover:not(:disabled) { + color: var(--text-normal); + border-color: var(--text-faint); +} + +.ap-btn-sm { + padding: 5px 10px; + font-size: 12px; +} + +/* ── Upload Zone ── */ +.ap-upload-zone { + display: flex; + align-items: center; + justify-content: center; + padding: 14px; + border: 2px dashed var(--border); + border-radius: var(--radius); + background: var(--bg-secondary); + cursor: pointer; + transition: all var(--transition); + color: var(--text-muted); + font-size: 13px; +} + +.ap-upload-zone:hover { + border-color: var(--accent); + color: var(--accent); + background: rgba(var(--accent-rgb), 0.05); +} + +.ap-upload-progress { + color: var(--accent); + font-weight: 600; +} + +/* ── Bulk Row ── */ +.ap-bulk-row { + display: flex; + align-items: center; + justify-content: space-between; + padding: 6px 0; +} + +.ap-select-all { + display: flex; + align-items: center; + gap: 8px; + font-size: 12px; + color: var(--text-muted); + cursor: pointer; +} + +.ap-select-all input[type="checkbox"] { + accent-color: var(--accent); +} + +/* ── Sound List ── */ +.ap-list-wrap { + flex: 1; + min-height: 0; +} + +.ap-list { + display: flex; + flex-direction: column; + gap: 2px; +} + +.ap-item { + display: flex; + align-items: center; + gap: 10px; + padding: 8px 10px; + border-radius: var(--radius); + background: var(--bg-secondary); + transition: background var(--transition); +} + +.ap-item:hover { + background: var(--bg-tertiary); +} + +.ap-item-check { + flex-shrink: 0; + cursor: pointer; +} + +.ap-item-check input[type="checkbox"] { + accent-color: var(--accent); +} + +.ap-item-main { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: 2px; +} + +.ap-item-name { + font-size: 13px; + font-weight: 600; + color: var(--text-normal); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.ap-item-meta { + font-size: 11px; + color: var(--text-faint); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.ap-item-actions { + display: flex; + gap: 4px; + flex-shrink: 0; +} + +.ap-rename-row { + display: flex; + align-items: center; + gap: 6px; + margin-top: 4px; +} + +.ap-rename-input { + flex: 1; + padding: 5px 8px; + border: 1px solid var(--accent); + border-radius: var(--radius); + background: var(--bg-deep); + color: var(--text-normal); + font-size: 12px; + font-family: var(--font); +} + +.ap-rename-input:focus { + outline: none; +} + +/* ── Empty ── */ +.ap-empty { + text-align: center; + color: var(--text-muted); + padding: 40px 16px; + font-size: 13px; +} + +/* ── Hint ── */ +.ap-hint { + font-size: 13px; + color: var(--text-muted); + margin: 0; +} + +/* ── Status Badge ── */ +.ap-status-badge { + display: flex; + align-items: center; + gap: 6px; + font-size: 13px; + color: var(--text-muted); +} + +.ap-status-dot { + width: 8px; + height: 8px; + border-radius: 50%; + background: var(--danger); + flex-shrink: 0; +} + +.ap-status-dot.online { + background: var(--success); + animation: pulse-dot 2s ease-in-out infinite; +} + +/* ── Channel List (Streaming) ── */ +.ap-channel-list { + display: flex; + flex-direction: column; + gap: 2px; +} + +.ap-channel-row { + display: flex; + align-items: center; + justify-content: space-between; + padding: 10px 12px; + border-radius: var(--radius); + background: var(--bg-secondary); + transition: background var(--transition); +} + +.ap-channel-row:hover { + background: var(--bg-tertiary); +} + +.ap-channel-info { + display: flex; + flex-direction: column; + gap: 2px; + min-width: 0; +} + +.ap-channel-name { + font-size: 13px; + font-weight: 600; + color: var(--text-normal); +} + +.ap-channel-guild { + font-size: 11px; + color: var(--text-faint); +} + +.ap-channel-toggles { + display: flex; + gap: 8px; + flex-shrink: 0; +} + +.ap-toggle { + display: flex; + align-items: center; + gap: 4px; + font-size: 12px; + color: var(--text-muted); + cursor: pointer; + padding: 4px 8px; + border-radius: var(--radius); + transition: all var(--transition); +} + +.ap-toggle input[type="checkbox"] { + accent-color: var(--accent); +} + +.ap-toggle.active { + color: var(--accent); + background: rgba(var(--accent-rgb), 0.08); +} + +/* ── Save Row ── */ +.ap-save-row { + display: flex; + justify-content: flex-end; + padding-top: 8px; +} + +/* ── Profile List (Game Library) ── */ +.ap-profile-list { + display: flex; + flex-direction: column; + gap: 2px; +} + +.ap-profile-row { + display: flex; + align-items: center; + gap: 12px; + padding: 10px 12px; + border-radius: var(--radius); + background: var(--bg-secondary); + transition: background var(--transition); +} + +.ap-profile-row:hover { + background: var(--bg-tertiary); +} + +.ap-profile-avatar { + width: 36px; + height: 36px; + border-radius: 50%; + flex-shrink: 0; +} + +.ap-profile-info { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: 2px; +} + +.ap-profile-name { + font-size: 14px; + font-weight: 600; + color: var(--text-normal); +} + +.ap-profile-details { + display: flex; + align-items: center; + gap: 6px; + font-size: 11px; +} + +.ap-platform-badge { + padding: 1px 6px; + border-radius: 3px; + font-weight: 600; + font-size: 10px; +} + +.ap-platform-badge.steam { + background: rgba(66, 133, 244, 0.15); + color: #64b5f6; +} + +.ap-platform-badge.gog { + background: rgba(171, 71, 188, 0.15); + color: #ce93d8; +} + +.ap-profile-total { + color: var(--text-faint); +} + +/* ── Toast ── */ +.ap-toast { + position: absolute; + bottom: 16px; + left: 50%; + transform: translateX(-50%); + padding: 8px 16px; + border-radius: var(--radius); + font-size: 13px; + font-weight: 500; + background: var(--bg-tertiary); + color: var(--text-normal); + box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); + animation: fade-in 150ms ease; + z-index: 10; +} + +.ap-toast.error { + background: rgba(237, 66, 69, 0.2); + color: #f87171; +} + +/* ── Admin Panel Responsive ── */ +@media (max-width: 768px) { + .ap-modal { + flex-direction: column; + width: calc(100vw - 16px); + height: calc(100vh - 32px); + } + + .ap-sidebar { + width: 100%; + min-width: 100%; + flex-direction: row; + border-right: none; + border-bottom: 1px solid var(--border); + overflow-x: auto; + } + + .ap-sidebar-title { + display: none; + } + + .ap-nav { + flex-direction: row; + padding: 4px 8px; + gap: 4px; + } + + .ap-nav-item { + border-left: none; + border-bottom: 3px solid transparent; + border-radius: var(--radius) var(--radius) 0 0; + padding: 8px 12px; + white-space: nowrap; + } + + .ap-nav-item.active { + border-left-color: transparent; + border-bottom-color: var(--accent); + } + + .ap-channel-toggles { + flex-direction: column; + gap: 4px; + } +} From 354a9cd97762941ce1ad28ddd515600f46d7c529 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Mon, 9 Mar 2026 21:36:12 +0000 Subject: [PATCH 23/53] v1.8.6 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8decb92..f263cd1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.5 +1.8.6 From 8951f465363a7e8fa321cd4d0dc76fd4315ec063 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 22:42:36 +0100 Subject: [PATCH 24/53] =?UTF-8?q?Admin=20Panel:=20Logout-Button=20in=20Sid?= =?UTF-8?q?ebar=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- ...{index-Bg-1_rjZ.css => index-BrwtipcK.css} | 2 +- .../{index-BWeAEcYi.js => index-CUixApZu.js} | 84 +++++++++---------- web/dist/index.html | 4 +- web/src/AdminPanel.tsx | 6 +- web/src/App.tsx | 2 +- web/src/styles.css | 16 ++++ 6 files changed, 67 insertions(+), 47 deletions(-) rename web/dist/assets/{index-Bg-1_rjZ.css => index-BrwtipcK.css} (93%) rename web/dist/assets/{index-BWeAEcYi.js => index-CUixApZu.js} (85%) diff --git a/web/dist/assets/index-Bg-1_rjZ.css b/web/dist/assets/index-BrwtipcK.css similarity index 93% rename from web/dist/assets/index-Bg-1_rjZ.css rename to web/dist/assets/index-BrwtipcK.css index 2792e27..37daf6a 100644 --- a/web/dist/assets/index-Bg-1_rjZ.css +++ b/web/dist/assets/index-BrwtipcK.css @@ -1 +1 @@ -@import"https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap";@import"https://fonts.googleapis.com/icon?family=Material+Icons";.sb-app{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--bg-modifier-hover: rgba(79, 84, 92, .16);--bg-modifier-active: rgba(79, 84, 92, .24);--bg-modifier-selected: rgba(79, 84, 92, .32);--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #5865f2;--accent-rgb: 88, 101, 242;--accent-hover: #4752c4;--accent-glow: rgba(88, 101, 242, .45);--green: #23a55a;--red: #f23f42;--yellow: #f0b232;--white: #ffffff;--font: "DM Sans", "Outfit", "gg sans", "Noto Sans", Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;--radius: 8px;--radius-lg: 12px;--shadow-low: 0 1px 3px rgba(0, 0, 0, .24);--shadow-med: 0 4px 12px rgba(0, 0, 0, .32);--shadow-high: 0 8px 24px rgba(0, 0, 0, .4);--transition: .15s cubic-bezier(.4, 0, .2, 1);--card-size: 110px;--card-emoji: 28px;--card-font: 11px;color-scheme:dark}.sb-app[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad;--accent-glow: rgba(155, 89, 182, .45)}.sb-app[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60;--accent-glow: rgba(46, 204, 113, .4)}.sb-app[data-theme=sunset]{--bg-deep: #1a1210;--bg-primary: #231815;--bg-secondary: #2f201c;--bg-tertiary: #3d2a24;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--accent-glow: rgba(230, 126, 34, .4)}.sb-app[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9;--accent-glow: rgba(52, 152, 219, .4)}.sb-app{display:flex;flex-direction:column;height:100%;position:relative}.topbar{display:flex;align-items:center;padding:0 20px;height:52px;background:var(--bg-secondary);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px;transition:background .4s ease}.topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.sb-app-logo{width:28px;height:28px;background:var(--accent);border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .4s ease}.sb-app-title{font-size:16px;font-weight:700;color:var(--white);letter-spacing:-.02em}.clock-wrap{flex:1;display:flex;justify-content:center}.clock{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:.02em;font-variant-numeric:tabular-nums;opacity:.9}.clock-seconds{font-size:14px;color:var(--text-faint);font-weight:500}.topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0}.channel-dropdown{position:relative;flex-shrink:0}.channel-btn{display:flex;align-items:center;gap:8px;padding:5px 12px 5px 10px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-normal);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.channel-btn:hover{background:var(--bg-modifier-selected);border-color:#ffffff1f}.channel-btn.open{border-color:var(--accent)}.channel-btn .cb-icon{font-size:16px;color:var(--text-muted)}.channel-btn .chevron{font-size:12px;color:var(--text-faint);transition:transform var(--transition);margin-left:2px}.channel-btn.open .chevron{transform:rotate(180deg)}.channel-status{width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0}.channel-menu{position:absolute;top:calc(100% + 6px);left:0;min-width:220px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:6px;z-index:100;animation:ctx-in .1s ease-out}.channel-menu-header{padding:6px 8px 4px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-faint)}.channel-option{display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:4px;font-size:13px;color:var(--text-muted);cursor:pointer;transition:all var(--transition)}.channel-option:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.channel-option.active{background:var(--accent);color:var(--white)}.channel-option .co-icon{font-size:16px;opacity:.7}.connection{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:#23a55a1f;font-size:12px;color:var(--green);font-weight:600}.conn-dot{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 6px #23a55a99;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 6px #23a55a80}50%{box-shadow:0 0 12px #23a55acc}}.conn-ping{font-size:10px;opacity:.7;margin-left:2px}.conn-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fadeIn .15s ease}.conn-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:slideUp .2s ease}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.conn-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.conn-modal-close{margin-left:auto;background:none;border:none;color:var(--muted);cursor:pointer;padding:4px;border-radius:6px;display:flex;transition:all .15s}.conn-modal-close:hover{background:#ffffff14;color:var(--fg)}.conn-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.conn-stat{display:flex;justify-content:space-between;align-items:center}.conn-stat-label{color:var(--muted);font-size:13px}.conn-stat-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.conn-ping-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.admin-btn-icon{width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition);font-size:18px}.admin-btn-icon:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.admin-btn-icon.active{color:var(--accent)}.toolbar{display:flex;align-items:center;gap:10px;padding:10px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0;flex-wrap:wrap;transition:background .4s ease}.cat-tabs{display:flex;gap:4px;flex-shrink:0}.cat-tab{display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.cat-tab:hover{background:var(--bg-modifier-selected);color:var(--text-normal)}.cat-tab.active{background:var(--accent);color:var(--white)}.tab-count{font-size:10px;font-weight:700;background:#ffffff26;padding:0 6px;border-radius:8px;line-height:1.6}.search-wrap{position:relative;flex:1;max-width:280px;min-width:140px}.search-wrap .search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);font-size:15px;color:var(--text-faint);pointer-events:none}.search-input{width:100%;height:32px;padding:0 28px 0 32px;border:1px solid rgba(255,255,255,.06);border-radius:20px;background:var(--bg-secondary);color:var(--text-normal);font-family:var(--font);font-size:13px;outline:none;transition:all var(--transition)}.search-input::placeholder{color:var(--text-faint)}.search-input:focus{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.search-clear{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:20px;height:20px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition)}.search-clear:hover{background:var(--bg-tertiary);color:var(--text-normal)}.toolbar-spacer{flex:1}.url-import-wrap{display:flex;align-items:center;gap:6px;min-width:240px;max-width:460px;flex:1;padding:4px 6px 4px 8px;border-radius:20px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.url-import-icon{font-size:15px;color:var(--text-faint);flex-shrink:0}.url-import-input{flex:1;min-width:0;height:26px;border:none;background:transparent;color:var(--text-normal);font-size:12px;font-family:var(--font);outline:none}.url-import-input::placeholder{color:var(--text-faint)}.url-import-btn{height:24px;padding:0 10px;border-radius:14px;border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.45);background:rgba(var(--accent-rgb, 88, 101, 242),.12);color:var(--accent);font-size:11px;font-weight:700;white-space:nowrap;transition:all var(--transition)}.url-import-btn:hover{background:var(--accent);border-color:var(--accent);color:var(--white)}.url-import-btn:disabled{opacity:.5;pointer-events:none}.url-import-tag{flex-shrink:0;padding:1px 6px;border-radius:8px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.url-import-tag.valid{background:#2ecc712e;color:#2ecc71}.url-import-tag.invalid{background:#e74c3c2e;color:#e74c3c}.tb-btn{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.tb-btn:hover{background:var(--bg-modifier-selected);color:var(--text-normal);border-color:#ffffff1f}.tb-btn .tb-icon{font-size:15px}.tb-btn.random{border-color:#5865f24d;color:var(--accent)}.tb-btn.random:hover{background:var(--accent);color:var(--white);border-color:var(--accent)}.tb-btn.party{border-color:#f0b2324d;color:var(--yellow)}.tb-btn.party:hover{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow)}.tb-btn.party.active{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow);animation:party-btn .6s ease-in-out infinite alternate}@keyframes party-btn{0%{box-shadow:0 0 8px #f0b23266}to{box-shadow:0 0 20px #f0b232b3}}.tb-btn.stop{border-color:#f23f424d;color:var(--red)}.tb-btn.stop:hover{background:var(--red);color:var(--white);border-color:var(--red)}.size-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.size-control .sc-icon{font-size:14px;color:var(--text-faint)}.size-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:70px;height:3px;border-radius:2px;background:var(--bg-modifier-selected);outline:none;cursor:pointer}.size-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.size-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.size-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.theme-selector{display:flex;align-items:center;gap:4px;padding:4px 8px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:all var(--transition);border:2px solid transparent}.theme-dot:hover{transform:scale(1.2)}.theme-dot.active{border-color:var(--white);box-shadow:0 0 6px #ffffff4d}.analytics-strip{display:flex;align-items:stretch;gap:8px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0}.analytics-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:12px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.analytics-card.analytics-wide{flex:1;min-width:0}.analytics-icon{font-size:18px;color:var(--accent);flex-shrink:0}.analytics-copy{display:flex;flex-direction:column;gap:4px;min-width:0}.analytics-label{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--text-faint)}.analytics-value{font-size:18px;line-height:1;font-weight:800;color:var(--text-normal)}.analytics-top-list{display:flex;align-items:center;gap:6px;overflow-x:auto;scrollbar-width:none}.analytics-top-list::-webkit-scrollbar{display:none}.analytics-chip{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:999px;background:rgba(var(--accent-rgb, 88, 101, 242),.15);color:var(--accent);font-size:11px;font-weight:600;white-space:nowrap}.analytics-muted{color:var(--text-muted);font-size:12px}.category-strip{display:flex;align-items:center;gap:6px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);overflow-x:auto;flex-shrink:0;scrollbar-width:none;transition:background .4s ease}.category-strip::-webkit-scrollbar{display:none}.cat-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;font-size:12px;font-weight:600;color:var(--text-muted);background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06);white-space:nowrap;cursor:pointer;transition:all var(--transition);flex-shrink:0}.cat-chip:hover{border-color:#ffffff1f;color:var(--text-normal);background:var(--bg-tertiary)}.cat-chip.active{background:#5865f21a}.cat-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.cat-count{font-size:10px;font-weight:700;opacity:.5}.main{flex:1;overflow-y:auto;padding:16px 20px;background:var(--bg-primary);transition:background .4s ease}.sound-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--card-size),1fr));gap:8px}.sound-card{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:12px 6px 8px;background:var(--bg-secondary);border-radius:var(--radius-lg);cursor:pointer;transition:all var(--transition);border:2px solid transparent;-webkit-user-select:none;user-select:none;overflow:hidden;aspect-ratio:1;opacity:0;animation:card-enter .35s ease-out forwards}.sound-card:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;opacity:0;transition:opacity var(--transition);background:radial-gradient(ellipse at center,var(--accent-glow) 0%,transparent 70%);pointer-events:none}.sound-card:hover{background:var(--bg-tertiary);transform:translateY(-3px);box-shadow:var(--shadow-med),0 0 20px var(--accent-glow);border-color:#5865f233}.sound-card:hover:before{opacity:1}.sound-card:active{transform:translateY(0);transition-duration:50ms}.sound-card.playing{border-color:var(--accent);animation:card-enter .35s ease-out forwards,playing-glow 1.2s ease-in-out infinite alternate}@keyframes playing-glow{0%{box-shadow:0 0 4px var(--accent-glow)}to{box-shadow:0 0 16px var(--accent-glow)}}@keyframes card-enter{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.ripple{position:absolute;border-radius:50%;background:#5865f24d;transform:scale(0);animation:ripple-expand .5s ease-out forwards;pointer-events:none}@keyframes ripple-expand{to{transform:scale(3);opacity:0}}.sound-emoji{font-size:var(--card-emoji);font-weight:800;line-height:1;z-index:1;transition:transform var(--transition);opacity:.7;font-family:Syne,DM Sans,sans-serif}.sound-card:hover .sound-emoji{transform:scale(1.15);opacity:1}.sound-card.playing .sound-emoji{animation:emoji-bounce .4s ease;opacity:1}@keyframes emoji-bounce{0%,to{transform:scale(1)}40%{transform:scale(1.3)}70%{transform:scale(.95)}}.sound-name{font-size:var(--card-font);font-weight:600;text-align:center;color:var(--text-normal);z-index:1;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 4px}.sound-duration{font-size:9px;color:var(--text-faint);z-index:1;font-weight:500}.fav-star{position:absolute;top:4px;right:4px;opacity:0;transition:all var(--transition);cursor:pointer;z-index:2;color:var(--text-faint);padding:2px;line-height:1}.fav-star .fav-icon{font-size:14px}.sound-card:hover .fav-star{opacity:.6}.fav-star:hover{opacity:1!important;color:var(--yellow);transform:scale(1.2)}.fav-star.active{opacity:1!important;color:var(--yellow)}.new-badge{position:absolute;top:4px;left:4px;font-size:8px;font-weight:700;background:var(--green);color:#fff;padding:1px 5px;border-radius:6px;text-transform:uppercase;letter-spacing:.03em;z-index:2}.playing-indicator{position:absolute;bottom:3px;left:50%;transform:translate(-50%);display:none;gap:2px;align-items:flex-end;height:10px}.sound-card.playing .playing-indicator{display:flex}.wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .6s ease-in-out infinite alternate}.wave-bar:nth-child(1){height:3px;animation-delay:0ms}.wave-bar:nth-child(2){height:7px;animation-delay:.15s}.wave-bar:nth-child(3){height:5px;animation-delay:.3s}.wave-bar:nth-child(4){height:9px;animation-delay:.1s}@keyframes wave{0%{height:2px}to{height:10px}}.empty-state{display:none;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:60px 20px;text-align:center}.empty-state.visible{display:flex}.empty-emoji{font-size:42px}.empty-title{font-size:15px;font-weight:700;color:var(--text-normal)}.empty-desc{font-size:13px;color:var(--text-muted);max-width:260px}.now-playing{display:flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;background:rgba(var(--accent-rgb, 88, 101, 242),.12);border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.2);font-size:12px;color:var(--text-muted);max-width:none;min-width:0;animation:np-fade-in .3s ease}@keyframes np-fade-in{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}.np-name{color:var(--accent);font-weight:600;white-space:nowrap}.np-waves{display:none;gap:1.5px;align-items:flex-end;height:12px;flex-shrink:0}.np-waves.active{display:flex}.np-wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .5s ease-in-out infinite alternate}.np-wave-bar:nth-child(1){height:3px;animation-delay:0ms}.np-wave-bar:nth-child(2){height:8px;animation-delay:.12s}.np-wave-bar:nth-child(3){height:5px;animation-delay:.24s}.np-wave-bar:nth-child(4){height:10px;animation-delay:80ms}.volume-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.vol-icon{font-size:16px;color:var(--text-faint);cursor:pointer;transition:color var(--transition);-webkit-user-select:none;user-select:none}.vol-icon:hover{color:var(--text-normal)}.vol-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:80px;height:3px;border-radius:2px;background:linear-gradient(to right,var(--accent) 0%,var(--accent) var(--vol, 80%),var(--bg-modifier-selected) var(--vol, 80%));outline:none;cursor:pointer}.vol-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.vol-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.vol-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.vol-pct{font-size:11px;color:var(--text-faint);min-width:28px;text-align:right;font-variant-numeric:tabular-nums}.party-overlay{position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;z-index:50;opacity:0;transition:opacity .3s ease}.party-overlay.active{opacity:1;animation:party-hue 2s linear infinite}.party-overlay:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(45deg,#ff00000a,#00ff000a,#0000ff0a,#ffff000a);background-size:400% 400%;animation:party-grad 3s ease infinite}@keyframes party-grad{0%{background-position:0% 50%}50%{background-position:100% 50%}to{background-position:0% 50%}}@keyframes party-hue{to{filter:hue-rotate(360deg)}}.ctx-menu{position:fixed;min-width:160px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.06);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:4px;z-index:1000;animation:ctx-in .1s ease-out}@keyframes ctx-in{0%{opacity:0;transform:scale(.96) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.ctx-item{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:4px;font-size:13px;color:var(--text-normal);cursor:pointer;transition:all var(--transition)}.ctx-item:hover{background:var(--accent);color:var(--white)}.ctx-item.danger{color:var(--red)}.ctx-item.danger:hover{background:var(--red);color:var(--white)}.ctx-item .ctx-icon{font-size:15px}.ctx-sep{height:1px;background:#ffffff0f;margin:3px 8px}.toast{position:fixed;bottom:64px;left:50%;transform:translate(-50%);padding:10px 20px;border-radius:20px;font-size:13px;font-weight:600;z-index:100;display:flex;align-items:center;gap:8px;box-shadow:var(--shadow-high);animation:toast-in .3s cubic-bezier(.175,.885,.32,1.275);pointer-events:none}.toast .toast-icon{font-size:16px}.toast.error{background:var(--red);color:#fff}.toast.info{background:var(--green);color:#fff}@keyframes toast-in{0%{transform:translate(-50%,16px);opacity:0}to{transform:translate(-50%);opacity:1}}.admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:60;display:flex;align-items:center;justify-content:center;animation:fade-in .2s ease}.admin-panel{background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius-lg);padding:28px;width:92%;max-width:920px;max-height:min(88vh,860px);display:flex;flex-direction:column;box-shadow:var(--shadow-high)}.admin-panel h3{font-size:18px;font-weight:700;margin-bottom:16px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.admin-close{width:28px;height:28px;border-radius:6px;display:flex;align-items:center;justify-content:center;color:var(--text-muted);transition:all var(--transition)}.admin-close:hover{background:var(--bg-tertiary);color:var(--text-normal)}.admin-field{margin-bottom:16px}.admin-field label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.admin-field input{width:100%;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:10px 12px;font-size:14px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-field input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.admin-btn-action{padding:10px 20px;border-radius:8px;font-size:13px;font-weight:600;font-family:var(--font);cursor:pointer;transition:all var(--transition);line-height:1}.admin-btn-action.primary{background:var(--accent);color:#fff;border:none}.admin-btn-action.primary:hover{background:var(--accent-hover)}.admin-btn-action.outline{background:transparent;border:1px solid rgba(255,255,255,.08);color:var(--text-muted)}.admin-btn-action.outline:hover{border-color:#ffffff1f;color:var(--text-normal)}.admin-btn-action.danger{background:var(--red);color:var(--white);border:1px solid var(--red)}.admin-btn-action.danger:hover{filter:brightness(1.06)}.admin-btn-action.danger.ghost{background:transparent;color:var(--red);border:1px solid rgba(242,63,66,.5)}.admin-btn-action.danger.ghost:hover{background:#f23f4224}.admin-btn-action:disabled{opacity:.5;pointer-events:none}.admin-shell{display:flex;flex-direction:column;gap:12px;min-height:0}.admin-header-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.admin-status{font-size:13px;color:var(--text-muted)}.admin-actions-inline{display:flex;align-items:center;gap:8px}.admin-search-field{margin-bottom:0}.admin-bulk-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border-radius:10px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);flex-wrap:wrap}.admin-select-all{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted)}.admin-select-all input,.admin-item-check input{accent-color:var(--accent)}.admin-list-wrap{min-height:260px;max-height:52vh;overflow-y:auto;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:var(--bg-primary)}.admin-list{display:flex;flex-direction:column;gap:6px;padding:6px}.admin-empty{padding:24px 12px;text-align:center;color:var(--text-muted);font-size:13px}.admin-item{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px;border-radius:8px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06)}.admin-item-main{min-width:0}.admin-item-name{font-size:14px;font-weight:600;color:var(--text-normal);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-meta{margin-top:3px;font-size:11px;color:var(--text-faint);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-actions{display:flex;align-items:center;gap:6px}.admin-item-actions .admin-btn-action,.admin-rename-row .admin-btn-action{padding:8px 12px;font-size:12px}.admin-rename-row{display:flex;align-items:center;gap:6px;margin-top:8px}.admin-rename-row input{flex:1;min-width:120px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:8px 10px;font-size:13px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-rename-row input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}@media(max-width:700px){.toolbar{gap:6px;padding:8px 12px}.cat-tabs{overflow-x:auto;scrollbar-width:none}.cat-tabs::-webkit-scrollbar{display:none}.search-wrap,.url-import-wrap{max-width:100%;min-width:100%;order:-1}.size-control,.theme-selector{display:none}.main{padding:12px}.topbar{padding:0 12px;gap:8px}.channel-label{max-width:100px;overflow:hidden;text-overflow:ellipsis}.clock{font-size:16px}.clock-seconds{font-size:11px}.tb-btn span:not(.tb-icon){display:none}.analytics-strip{padding:8px 12px;flex-direction:column;gap:6px}.analytics-card.analytics-wide{width:100%}.admin-panel{width:96%;padding:16px;max-height:92vh}.admin-item{grid-template-columns:24px minmax(0,1fr)}.admin-item-actions{grid-column:1 / -1;justify-content:flex-end}.admin-rename-row{flex-wrap:wrap}}@media(max-width:480px){.connection,.sb-app-title{display:none}.now-playing{max-width:none}.toolbar .tb-btn{padding:6px 8px}.url-import-btn{padding:0 8px}}.drop-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000c7;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);z-index:300;display:flex;align-items:center;justify-content:center;animation:fade-in .12s ease;pointer-events:none}.drop-zone{display:flex;flex-direction:column;align-items:center;gap:14px;padding:64px 72px;border-radius:24px;border:2.5px dashed rgba(var(--accent-rgb),.55);background:rgba(var(--accent-rgb),.07);animation:drop-pulse 2.2s ease-in-out infinite}@keyframes drop-pulse{0%,to{border-color:rgba(var(--accent-rgb),.45);box-shadow:0 0 rgba(var(--accent-rgb),0)}50%{border-color:rgba(var(--accent-rgb),.9);box-shadow:0 0 60px 12px rgba(var(--accent-rgb),.12)}}.drop-icon{font-size:64px;color:var(--accent);animation:drop-bounce 1.8s ease-in-out infinite}@keyframes drop-bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-8px)}}.drop-title{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:-.3px}.drop-sub{font-size:13px;color:var(--text-muted)}.upload-queue{position:fixed;bottom:24px;right:24px;width:340px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.09);border-radius:14px;box-shadow:0 8px 40px #00000073;z-index:200;animation:slide-up .2s cubic-bezier(.16,1,.3,1)}@keyframes slide-up{0%{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}.uq-header{display:flex;align-items:center;gap:8px;padding:12px 14px;background:rgba(var(--accent-rgb),.12);border-bottom:1px solid rgba(255,255,255,.06);font-size:13px;font-weight:600;color:var(--text-normal)}.uq-header .material-icons{color:var(--accent)}.uq-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition),color var(--transition)}.uq-close:hover{background:#ffffff24;color:var(--text-normal)}.uq-list{display:flex;flex-direction:column;max-height:260px;overflow-y:auto;padding:6px 0}.uq-item{display:grid;grid-template-columns:20px 1fr auto 18px;align-items:center;gap:8px;padding:8px 14px;position:relative}.uq-item+.uq-item{border-top:1px solid rgba(255,255,255,.04)}.uq-file-icon{font-size:18px;color:var(--text-faint)}.uq-info{min-width:0}.uq-name{font-size:12px;font-weight:500;color:var(--text-normal);white-space:nowrap;text-overflow:ellipsis}.uq-size{font-size:10px;color:var(--text-faint);margin-top:1px}.uq-progress-wrap{grid-column:1 / -1;height:3px;background:#ffffff12;border-radius:2px;margin-top:4px}.uq-item{flex-wrap:wrap}.uq-progress-wrap{width:100%;order:10}.uq-progress-bar{height:100%;background:var(--accent);border-radius:2px;transition:width .12s ease}.uq-status-icon{font-size:16px}.uq-status-waiting .uq-status-icon{color:var(--text-faint)}.uq-status-uploading .uq-status-icon{color:var(--accent);animation:spin 1s linear infinite}.uq-status-done .uq-status-icon{color:var(--green)}.uq-status-error .uq-status-icon{color:var(--red)}.uq-error{grid-column:2 / -1;font-size:10px;color:var(--red);margin-top:2px}.dl-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;display:flex;align-items:center;justify-content:center;z-index:300;animation:fade-in .15s ease}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.dl-modal{width:420px;max-width:92vw;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.1);border-radius:16px;box-shadow:0 12px 60px #00000080;animation:scale-in .2s cubic-bezier(.16,1,.3,1)}@keyframes scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.dl-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.06);font-size:14px;font-weight:700;color:var(--text-normal)}.dl-modal-header .material-icons{color:var(--accent)}.dl-modal-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition)}.dl-modal-close:hover{background:#ffffff24;color:var(--text-normal)}.dl-modal-body{padding:16px;display:flex;flex-direction:column;gap:14px}.dl-modal-url{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:8px;background:#0003;overflow:hidden}.dl-modal-tag{flex-shrink:0;padding:2px 8px;border-radius:6px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.dl-modal-tag.youtube{background:#ff00002e;color:#f44}.dl-modal-tag.instagram{background:#e1306c2e;color:#e1306c}.dl-modal-tag.mp3{background:#2ecc712e;color:#2ecc71}.dl-modal-url-text{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-modal-field{display:flex;flex-direction:column;gap:5px}.dl-modal-label{font-size:11px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.dl-modal-input-wrap{display:flex;align-items:center;border:1px solid rgba(255,255,255,.1);border-radius:8px;background:#00000026;overflow:hidden;transition:border-color var(--transition)}.dl-modal-input-wrap:focus-within{border-color:var(--accent)}.dl-modal-input{flex:1;border:none;background:transparent;padding:8px 10px;color:var(--text-normal);font-size:13px;font-family:var(--font);outline:none}.dl-modal-input::placeholder{color:var(--text-faint)}.dl-modal-ext{padding:0 10px;font-size:12px;font-weight:600;color:var(--text-faint);background:#ffffff0a;align-self:stretch;display:flex;align-items:center}.dl-modal-hint{font-size:10px;color:var(--text-faint)}.dl-modal-progress{display:flex;align-items:center;gap:12px;padding:20px 0;justify-content:center;font-size:13px;color:var(--text-muted)}.dl-modal-spinner{width:24px;height:24px;border-radius:50%;border:3px solid rgba(var(--accent-rgb),.2);border-top-color:var(--accent);animation:spin .8s linear infinite}.dl-modal-success{display:flex;align-items:center;gap:10px;padding:16px 0;justify-content:center;font-size:13px;color:var(--text-normal)}.dl-modal-check{color:#2ecc71;font-size:28px}.dl-modal-error{display:flex;align-items:center;gap:10px;padding:12px 0;justify-content:center;font-size:13px;color:#e74c3c}.dl-modal-actions{display:flex;justify-content:flex-end;gap:8px;padding:0 16px 14px}.dl-modal-cancel{padding:7px 14px;border-radius:8px;border:1px solid rgba(255,255,255,.1);background:transparent;color:var(--text-muted);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition)}.dl-modal-cancel:hover{background:#ffffff0f;color:var(--text-normal)}.dl-modal-submit{display:flex;align-items:center;gap:5px;padding:7px 16px;border-radius:8px;border:none;background:var(--accent);color:#fff;font-size:12px;font-weight:700;cursor:pointer;transition:filter var(--transition)}.dl-modal-submit:hover{filter:brightness(1.15)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.lol-container{max-width:920px;margin:0 auto;padding:16px;height:100%;overflow-y:auto}.lol-search{display:flex;gap:8px;margin-bottom:12px}.lol-search-input{flex:1;min-width:0;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:15px;outline:none;transition:border-color .2s}.lol-search-input:focus{border-color:var(--accent)}.lol-search-input::placeholder{color:var(--text-faint)}.lol-search-region{padding:10px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none}.lol-search-btn{padding:10px 20px;border:none;border-radius:8px;background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:opacity .2s;white-space:nowrap}.lol-search-btn:hover{opacity:.85}.lol-search-btn:disabled{opacity:.4;cursor:not-allowed}.lol-recent{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:16px}.lol-recent-chip{display:flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;cursor:pointer;transition:border-color .2s,color .2s}.lol-recent-chip:hover{border-color:var(--accent);color:var(--text-normal)}.lol-recent-chip img{width:18px;height:18px;border-radius:50%}.lol-recent-tier{font-size:10px;font-weight:600;opacity:.7;text-transform:uppercase}.lol-profile{display:flex;align-items:center;gap:16px;padding:16px;border-radius:12px;background:var(--bg-secondary);margin-bottom:12px}.lol-profile-icon{width:72px;height:72px;border-radius:12px;border:2px solid var(--bg-tertiary);object-fit:cover}.lol-profile-info h2{margin:0 0 2px;font-size:20px;color:var(--text-normal)}.lol-profile-info h2 span{color:var(--text-faint);font-weight:400;font-size:14px}.lol-profile-level{font-size:12px;color:var(--text-muted)}.lol-profile-ladder{font-size:11px;color:var(--text-faint)}.lol-profile-updated{font-size:10px;color:var(--text-faint);margin-top:2px}.lol-profile-info{flex:1;min-width:0}.lol-update-btn{display:flex;align-items:center;gap:6px;padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-primary);color:var(--text-muted);font-size:13px;font-weight:500;cursor:pointer;transition:border-color .2s,color .2s,background .2s;white-space:nowrap;flex-shrink:0}.lol-update-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-update-btn:disabled{opacity:.6;cursor:not-allowed}.lol-update-btn.renewing{border-color:var(--accent);color:var(--accent)}.lol-update-icon{font-size:16px;display:inline-block}.lol-update-btn.renewing .lol-update-icon{animation:lol-spin 1s linear infinite}.lol-ranked-row{display:flex;gap:10px;margin-bottom:12px}.lol-ranked-card{flex:1;padding:12px 14px;border-radius:10px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary)}.lol-ranked-card.has-rank{border-left-color:var(--tier-color, var(--accent))}.lol-ranked-type{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}.lol-ranked-tier{font-size:18px;font-weight:700;color:var(--tier-color, var(--text-normal))}.lol-ranked-lp{font-size:13px;color:var(--text-muted);margin-left:4px;font-weight:400}.lol-ranked-record{font-size:12px;color:var(--text-muted);margin-top:2px}.lol-ranked-wr{color:var(--text-faint);margin-left:4px}.lol-ranked-streak{color:#e74c3c;font-size:11px;margin-left:4px}.lol-section-title{font-size:13px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;margin:16px 0 8px;padding-left:2px}.lol-champs{display:flex;gap:8px;margin-bottom:12px;overflow-x:auto;padding-bottom:4px}.lol-champ-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:8px;background:var(--bg-secondary);min-width:180px;flex-shrink:0}.lol-champ-icon{width:36px;height:36px;border-radius:50%;object-fit:cover}.lol-champ-name{font-size:13px;font-weight:600;color:var(--text-normal)}.lol-champ-stats{font-size:11px;color:var(--text-muted)}.lol-champ-kda{font-size:11px;color:var(--text-faint)}.lol-matches{display:flex;flex-direction:column;gap:6px}.lol-match{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary);cursor:pointer;transition:background .15s}.lol-match:hover{background:var(--bg-tertiary)}.lol-match.win{border-left-color:#2ecc71}.lol-match.loss{border-left-color:#e74c3c}.lol-match-result{width:28px;font-size:11px;font-weight:700;text-align:center;flex-shrink:0}.lol-match.win .lol-match-result{color:#2ecc71}.lol-match.loss .lol-match-result{color:#e74c3c}.lol-match-champ{position:relative;flex-shrink:0}.lol-match-champ img{width:40px;height:40px;border-radius:50%;display:block}.lol-match-champ-level{position:absolute;bottom:-2px;right:-2px;background:var(--bg-deep);color:var(--text-muted);font-size:9px;font-weight:700;width:16px;height:16px;border-radius:50%;display:flex;align-items:center;justify-content:center}.lol-match-kda{min-width:80px;text-align:center;flex-shrink:0}.lol-match-kda-nums{font-size:14px;font-weight:600;color:var(--text-normal)}.lol-match-kda-ratio{font-size:11px;color:var(--text-faint)}.lol-match-kda-ratio.perfect{color:#f39c12}.lol-match-kda-ratio.great{color:#2ecc71}.lol-match-stats{display:flex;flex-direction:column;gap:1px;min-width:70px;flex-shrink:0}.lol-match-stats span{font-size:11px;color:var(--text-muted)}.lol-match-items{display:flex;gap:2px;flex-shrink:0}.lol-match-items img,.lol-match-item-empty{width:24px;height:24px;border-radius:4px;background:var(--bg-deep)}.lol-match-meta{margin-left:auto;text-align:right;flex-shrink:0}.lol-match-duration{font-size:12px;color:var(--text-muted)}.lol-match-queue,.lol-match-ago{font-size:10px;color:var(--text-faint)}.lol-match-detail{background:var(--bg-primary);border-radius:8px;padding:8px;margin-top:4px;margin-bottom:4px}.lol-match-detail-team{margin-bottom:6px}.lol-match-detail-team-header{font-size:11px;font-weight:600;padding:4px 8px;border-radius:4px;margin-bottom:4px}.lol-match-detail-team-header.win{background:#2ecc7126;color:#2ecc71}.lol-match-detail-team-header.loss{background:#e74c3c26;color:#e74c3c}.lol-detail-row{display:flex;align-items:center;gap:8px;padding:3px 8px;border-radius:4px;font-size:12px;color:var(--text-muted)}.lol-detail-row:hover{background:var(--bg-secondary)}.lol-detail-row.me{background:#ffffff0a;font-weight:600}.lol-detail-champ{width:24px;height:24px;border-radius:50%}.lol-detail-name{width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-normal)}.lol-detail-kda{width:70px;text-align:center}.lol-detail-cs{width:45px;text-align:center}.lol-detail-dmg,.lol-detail-gold{width:55px;text-align:center}.lol-detail-items{display:flex;gap:1px}.lol-detail-items img{width:20px;height:20px;border-radius:3px}.lol-loading{display:flex;align-items:center;justify-content:center;gap:10px;padding:40px;color:var(--text-muted);font-size:14px}.lol-spinner{width:20px;height:20px;border:2px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:lol-spin .8s linear infinite}@keyframes lol-spin{to{transform:rotate(360deg)}}.lol-error{padding:16px;border-radius:8px;background:#e74c3c1a;color:#e74c3c;font-size:13px;text-align:center;margin-bottom:12px}.lol-empty{text-align:center;padding:60px 20px;color:var(--text-faint)}.lol-empty-icon{font-size:48px;margin-bottom:12px}.lol-empty h3{margin:0 0 8px;color:var(--text-muted);font-size:16px}.lol-empty p{margin:0;font-size:13px}.lol-load-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--bg-tertiary);border-radius:8px;background:transparent;color:var(--text-muted);font-size:13px;cursor:pointer;transition:border-color .2s,color .2s}.lol-load-more:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-section{margin-top:24px;padding-top:16px;border-top:1px solid var(--bg-tertiary)}.lol-tier-controls{display:flex;gap:8px;align-items:center;margin-bottom:12px;flex-wrap:wrap}.lol-tier-modes{display:flex;gap:4px;flex-wrap:wrap}.lol-tier-mode-btn{padding:6px 14px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;font-weight:500;cursor:pointer;transition:all .2s;white-space:nowrap}.lol-tier-mode-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-mode-btn.active{background:var(--accent);border-color:var(--accent);color:#fff}.lol-tier-filter{padding:6px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:12px;outline:none;width:140px;margin-left:auto}.lol-tier-filter:focus{border-color:var(--accent)}.lol-tier-filter::placeholder{color:var(--text-faint)}.lol-tier-table{display:flex;flex-direction:column;gap:2px}.lol-tier-header{display:flex;align-items:center;gap:8px;padding:6px 10px;font-size:10px;font-weight:600;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px}.lol-tier-row{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:6px;background:var(--bg-secondary);font-size:13px;color:var(--text-muted);transition:background .15s}.lol-tier-row:hover{background:var(--bg-tertiary)}.lol-tier-row.tier-0{border-left:3px solid #f4c874}.lol-tier-row.tier-1{border-left:3px solid #d4a017}.lol-tier-row.tier-2{border-left:3px solid #576cce}.lol-tier-row.tier-3{border-left:3px solid #28b29e}.lol-tier-row.tier-4{border-left:3px solid var(--bg-tertiary)}.lol-tier-row.tier-5{border-left:3px solid var(--bg-tertiary);opacity:.7}.lol-tier-col-rank{width:32px;text-align:center;font-weight:600;flex-shrink:0}.lol-tier-col-champ{flex:1;display:flex;align-items:center;gap:8px;min-width:0;font-weight:500;color:var(--text-normal)}.lol-tier-col-champ img{width:28px;height:28px;border-radius:50%;flex-shrink:0}.lol-tier-col-tier{width:36px;text-align:center;font-weight:700;font-size:12px;flex-shrink:0}.lol-tier-col-wr,.lol-tier-col-pr,.lol-tier-col-br{width:60px;text-align:center;flex-shrink:0}.lol-tier-col-kda{width:50px;text-align:center;flex-shrink:0}.tier-badge-0{color:#f4c874}.tier-badge-1{color:#d4a017}.tier-badge-2{color:#576cce}.tier-badge-3{color:#28b29e}.tier-badge-4,.tier-badge-5{color:var(--text-faint)}@media(max-width:640px){.lol-search{flex-wrap:wrap}.lol-search-input{width:100%}.lol-match{flex-wrap:wrap;gap:6px}.lol-match-meta{margin-left:0;text-align:left}.lol-match-items,.lol-profile{flex-wrap:wrap}.lol-tier-controls{flex-direction:column;align-items:stretch}.lol-tier-filter{width:100%;margin-left:0}.lol-tier-col-br,.lol-tier-col-kda{display:none}}.stream-container{height:100%;overflow-y:auto;padding:16px}.stream-topbar{display:flex;align-items:flex-end;gap:10px;margin-bottom:16px;flex-wrap:wrap}.stream-field{display:flex;flex-direction:column;gap:4px}.stream-field-grow{flex:1;min-width:180px}.stream-field-label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:var(--text-faint);padding-left:2px}.stream-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0;width:100%;box-sizing:border-box}.stream-input:focus{border-color:var(--accent)}.stream-input::placeholder{color:var(--text-faint)}.stream-input-name{width:150px}.stream-input-title{width:100%}.stream-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.stream-btn:hover{background:var(--accent-hover)}.stream-btn:disabled{opacity:.5;cursor:not-allowed}.stream-btn-stop{background:var(--danger)}.stream-btn-stop:hover{background:#c93b3e}.stream-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.stream-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.stream-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.stream-tile.own{border:2px solid var(--accent)}.stream-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.stream-tile-preview video{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover}.stream-tile-preview .stream-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.stream-live-badge{position:absolute;top:8px;left:8px;background:var(--danger);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;letter-spacing:.5px;display:flex;align-items:center;gap:4px}.stream-live-dot{width:6px;height:6px;border-radius:50%;background:#fff;animation:stream-pulse 1.5s ease-in-out infinite}@keyframes stream-pulse{0%,to{opacity:1}50%{opacity:.3}}.stream-tile-viewers{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.stream-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.stream-tile-meta{min-width:0;flex:1}.stream-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-title{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-time{font-size:12px;color:var(--text-faint);white-space:nowrap}.stream-tile-menu-wrap{position:relative}.stream-tile-menu{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 6px;font-size:18px;line-height:1;border-radius:4px;transition:background var(--transition)}.stream-tile-menu:hover{background:var(--bg-tertiary);color:var(--text-normal)}.stream-tile-dropdown{position:absolute;bottom:calc(100% + 6px);right:0;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius-lg);min-width:220px;z-index:100;box-shadow:0 8px 24px #0006;overflow:hidden}.stream-tile-dropdown-header{padding:12px 14px}.stream-tile-dropdown-name{font-size:14px;font-weight:600;color:var(--text-normal)}.stream-tile-dropdown-title{font-size:12px;color:var(--text-muted);margin-top:2px}.stream-tile-dropdown-detail{font-size:11px;color:var(--text-faint);margin-top:6px}.stream-tile-dropdown-divider{height:1px;background:var(--bg-tertiary)}.stream-tile-dropdown-item{display:flex;align-items:center;gap:8px;width:100%;padding:10px 14px;border:none;background:none;color:var(--text-normal);font-size:13px;cursor:pointer;text-align:left;transition:background var(--transition)}.stream-tile-dropdown-item:hover{background:var(--bg-tertiary)}.stream-viewer-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.stream-viewer-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1}.stream-viewer-header-left{display:flex;align-items:center;gap:12px}.stream-viewer-title{font-weight:600;font-size:16px}.stream-viewer-subtitle{font-size:13px;color:var(--text-muted)}.stream-viewer-header-right{display:flex;align-items:center;gap:8px}.stream-viewer-fullscreen{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.stream-viewer-fullscreen:hover{background:#ffffff40}.stream-viewer-close{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.stream-viewer-close:hover{background:#fff3}.stream-viewer-video{flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden}.stream-viewer-video video{max-width:100%;max-height:100%;width:100%;height:100%;object-fit:contain}.stream-viewer-connecting{color:var(--text-muted);font-size:16px;display:flex;flex-direction:column;align-items:center;gap:12px}.stream-viewer-spinner{width:32px;height:32px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:stream-spin .8s linear infinite}@keyframes stream-spin{to{transform:rotate(360deg)}}.stream-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.stream-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.stream-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.stream-empty p{font-size:14px}.stream-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.stream-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.stream-tile.broadcasting .stream-tile-preview{border:2px solid var(--danger);border-bottom:none}.stream-input-password{width:180px}.stream-select-quality{width:210px;box-sizing:border-box;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none;transition:border-color var(--transition)}.stream-select-quality:focus{border-color:var(--accent)}.stream-select-quality:disabled{opacity:.5;cursor:not-allowed}.stream-select-quality option{background:var(--bg-secondary);color:var(--text-normal)}.stream-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.stream-pw-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.stream-pw-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.stream-pw-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.stream-pw-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.stream-pw-modal .stream-input{width:100%;margin-bottom:12px}.stream-pw-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.stream-pw-actions{display:flex;gap:8px;justify-content:flex-end}.stream-pw-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.stream-pw-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.stream-admin-btn{margin-left:auto;padding:8px;border:none;border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:18px;cursor:pointer;transition:all var(--transition);line-height:1}.stream-admin-btn:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;display:flex;align-items:center;justify-content:center;z-index:999;animation:fadeIn .15s ease}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.stream-admin-panel{background:var(--bg-secondary);border-radius:12px;width:560px;max-width:95vw;max-height:80vh;display:flex;flex-direction:column;box-shadow:0 8px 32px #0006;overflow:hidden}.stream-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-header h3{margin:0;font-size:16px;color:var(--text-normal)}.stream-admin-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:var(--radius)}.stream-admin-close:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-login{padding:24px 20px}.stream-admin-login p{margin:0 0 12px;color:var(--text-muted);font-size:14px}.stream-admin-login-row{display:flex;gap:8px}.stream-admin-login-row .stream-input{flex:1}.stream-admin-error{color:#ed4245;font-size:13px;margin-top:8px}.stream-admin-content{padding:16px 20px;overflow-y:auto}.stream-admin-toolbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;padding-bottom:12px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-status{font-size:13px;color:var(--text-muted)}.stream-admin-status b{color:var(--text-normal)}.stream-admin-logout{padding:4px 12px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:12px;cursor:pointer}.stream-admin-logout:hover{color:#ed4245;border-color:#ed4245}.stream-admin-loading,.stream-admin-empty{text-align:center;padding:32px 16px;color:var(--text-muted);font-size:14px}.stream-admin-hint{margin:0 0 12px;color:var(--text-muted);font-size:13px}.stream-admin-channel-list{display:flex;flex-direction:column;gap:8px;max-height:45vh;overflow-y:auto}.stream-admin-channel{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:var(--bg-deep);border-radius:var(--radius);gap:12px}.stream-admin-channel-info{display:flex;flex-direction:column;gap:2px;min-width:0}.stream-admin-channel-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-admin-channel-guild{font-size:11px;color:var(--text-faint)}.stream-admin-channel-events{display:flex;gap:6px;flex-shrink:0}.stream-admin-event-toggle{display:flex;align-items:center;gap:4px;padding:4px 10px;border-radius:14px;font-size:12px;color:var(--text-muted);background:var(--bg-secondary);cursor:pointer;transition:all var(--transition);white-space:nowrap}.stream-admin-event-toggle input{display:none}.stream-admin-event-toggle:hover{color:var(--text-normal)}.stream-admin-event-toggle.active{background:var(--accent);color:#fff}.stream-admin-actions{margin-top:16px;display:flex;justify-content:flex-end}.stream-admin-save{padding:8px 24px}.wt-container{height:100%;overflow-y:auto;padding:16px}.wt-topbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}.wt-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0}.wt-input:focus{border-color:var(--accent)}.wt-input::placeholder{color:var(--text-faint)}.wt-input-name{width:150px}.wt-input-room{flex:1;min-width:180px}.wt-input-password{width:170px}.wt-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.wt-btn:hover{background:var(--accent-hover)}.wt-btn:disabled{opacity:.5;cursor:not-allowed}.wt-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.wt-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.wt-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.wt-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.wt-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.wt-tile-members{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.wt-tile-playing{position:absolute;top:8px;left:8px;background:var(--accent);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.wt-tile-meta{min-width:0;flex:1}.wt-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-tile-host{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.wt-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.wt-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.wt-empty p{font-size:14px}.wt-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.wt-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.wt-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.wt-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.wt-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.wt-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.wt-modal .wt-input{width:100%;margin-bottom:12px}.wt-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.wt-modal-actions{display:flex;gap:8px;justify-content:flex-end}.wt-modal-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.wt-modal-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.wt-room-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.wt-room-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1;flex-shrink:0}.wt-room-header-left{display:flex;align-items:center;gap:12px}.wt-room-name{font-weight:600;font-size:16px}.wt-room-members{font-size:13px;color:var(--text-muted)}.wt-host-badge{font-size:11px;background:#ffffff1a;padding:2px 8px;border-radius:4px;color:var(--accent);font-weight:600}.wt-room-header-right{display:flex;align-items:center;gap:8px}.wt-fullscreen-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.wt-fullscreen-btn:hover{background:#ffffff40}.wt-leave-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.wt-leave-btn:hover{background:#fff3}.wt-room-body{display:flex;flex:1;overflow:hidden}.wt-player-section{flex:1;display:flex;flex-direction:column;min-width:0}.wt-player-wrap{position:relative;width:100%;flex:1;background:#000;display:flex;align-items:center;justify-content:center;overflow:hidden}.wt-yt-container{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}.wt-yt-container iframe{width:100%;height:100%}.wt-video-element{width:100%;height:100%;object-fit:contain}.wt-dm-container{width:100%;height:100%;border:none;position:absolute;top:0;left:0}.wt-player-placeholder{display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--text-muted);font-size:16px}.wt-placeholder-icon{font-size:48px;opacity:.3}.wt-controls{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#000c;flex-shrink:0}.wt-ctrl-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;transition:background var(--transition);flex-shrink:0}.wt-ctrl-btn:hover:not(:disabled){background:#ffffff40}.wt-ctrl-btn:disabled{opacity:.3;cursor:not-allowed}.wt-ctrl-status{color:var(--text-muted);font-size:16px;width:36px;text-align:center;flex-shrink:0}.wt-seek{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer;min-width:60px}.wt-seek::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-webkit-slider-runnable-track{height:4px;border-radius:2px}.wt-seek::-moz-range-track{height:4px;border-radius:2px;background:var(--bg-tertiary)}.wt-seek-readonly{flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);position:relative;overflow:hidden;min-width:60px}.wt-seek-progress{position:absolute;top:0;left:0;height:100%;background:var(--accent);border-radius:2px;transition:width .3s linear}.wt-time{font-variant-numeric:tabular-nums;color:#fff;font-size:13px;white-space:nowrap;flex-shrink:0}.wt-volume{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.wt-volume-icon{font-size:16px;width:20px;text-align:center;cursor:default}.wt-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer}.wt-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-quality-select{background:var(--bg-secondary, #2a2a3e);color:var(--text-primary, #e0e0e0);border:1px solid var(--border-color, #3a3a4e);border-radius:6px;padding:2px 6px;font-size:12px;cursor:pointer;outline:none;margin-left:4px}.wt-quality-select:hover{border-color:var(--accent, #7c5cff)}.wt-queue-panel{width:280px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-queue-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-list{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-queue-list::-webkit-scrollbar{width:4px}.wt-queue-list::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-queue-empty{padding:24px 16px;text-align:center;color:var(--text-faint);font-size:13px}.wt-queue-item{padding:10px 12px;border-bottom:1px solid var(--bg-tertiary);display:flex;align-items:center;gap:8px;transition:background var(--transition)}.wt-queue-item:hover{background:var(--bg-tertiary)}.wt-queue-item.playing{border-left:3px solid var(--accent);background:#e67e2214}.wt-queue-item-info{flex:1;min-width:0}.wt-queue-item-title{font-size:13px;font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-queue-item-by{font-size:11px;color:var(--text-faint);margin-top:2px}.wt-queue-item-remove{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:18px;padding:2px 6px;border-radius:4px;transition:all var(--transition);flex-shrink:0}.wt-queue-item-remove:hover{color:var(--danger);background:#ed42451f}.wt-queue-add{padding:12px;display:flex;gap:8px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-input{flex:1;font-size:13px;padding:8px 10px}.wt-queue-add-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-player-error{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:#000000d9;color:#fff;z-index:2;text-align:center;padding:20px}.wt-error-icon{font-size:48px}.wt-player-error p{font-size:15px;color:var(--text-muted);margin:0}.wt-yt-link{display:inline-block;padding:8px 20px;background:red;color:#fff;border-radius:var(--radius);text-decoration:none;font-weight:600;font-size:14px;transition:background var(--transition)}.wt-yt-link:hover{background:#c00}.wt-skip-info{font-size:12px!important;color:var(--text-faint)!important;font-style:italic}.wt-queue-item.clickable{cursor:pointer}.wt-queue-item.clickable:hover{background:#e67e221f}@media(max-width:768px){.wt-room-body{flex-direction:column}.wt-queue-panel{width:100%;max-height:40vh;border-left:none;border-top:1px solid var(--bg-tertiary)}.wt-player-wrap{min-height:200px}.wt-controls{flex-wrap:wrap;gap:8px;padding:10px 12px}.wt-volume{margin-left:0}.wt-volume-slider{width:80px}.wt-room-header{padding:10px 12px}.wt-room-name{font-size:14px}.wt-room-members,.wt-host-badge{font-size:11px}}@media(max-width:480px){.wt-topbar{gap:8px}.wt-input-name{width:100%}.wt-input-room{min-width:0}.wt-input-password{width:100%}.wt-volume-slider{width:60px}.wt-time{font-size:12px}.wt-host-badge{display:none}}.wt-queue-item.watched{opacity:.55;transition:opacity var(--transition),background var(--transition)}.wt-queue-item.watched:hover{opacity:.85}.wt-queue-item-check{color:#2ecc71;font-size:16px;font-weight:700;flex-shrink:0;line-height:1}.wt-queue-item-info{display:flex;align-items:center;gap:10px;min-width:0;flex:1}.wt-queue-thumb{width:48px;height:36px;object-fit:cover;border-radius:4px;flex-shrink:0}.wt-queue-item-text{min-width:0;flex:1}.wt-next-btn{display:flex;align-items:center;gap:4px;font-size:13px;padding:6px 12px;white-space:nowrap}.wt-sync-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.wt-sync-synced{background:#2ecc71;box-shadow:0 0 6px #2ecc7180}.wt-sync-drifting{background:#f1c40f;box-shadow:0 0 6px #f1c40f80}.wt-sync-desynced{background:#e74c3c;box-shadow:0 0 6px #e74c3c80}.wt-vote-btn{background:#ffffff14!important;border:1px solid rgba(255,255,255,.15)!important}.wt-vote-btn:hover:not(:disabled){background:#e67e2233!important;border-color:var(--accent)!important}.wt-vote-count{font-size:12px;color:var(--accent);font-weight:600;white-space:nowrap;padding:2px 8px;background:#e67e221f;border-radius:4px}.wt-header-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:13px;transition:background var(--transition)}.wt-header-btn:hover{background:#fff3}.wt-chat-panel{width:260px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-chat-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-messages{flex:1;overflow-y:auto;padding:8px 12px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-chat-messages::-webkit-scrollbar{width:4px}.wt-chat-messages::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-chat-empty{padding:24px 8px;text-align:center;color:var(--text-faint);font-size:13px}.wt-chat-msg{margin-bottom:6px;font-size:13px;line-height:1.4;word-break:break-word}.wt-chat-sender{font-weight:600;color:var(--accent);margin-right:6px}.wt-chat-text{color:var(--text-normal)}.wt-chat-input-row{padding:10px 12px;display:flex;gap:6px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-input{flex:1;font-size:13px;padding:8px 10px}.wt-chat-send-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-queue-header{display:flex;align-items:center;justify-content:space-between}.wt-queue-clear-btn{background:none;border:none;color:var(--text-faint);font-size:11px;cursor:pointer;padding:2px 6px;border-radius:4px;transition:all var(--transition)}.wt-queue-clear-btn:hover{color:var(--danger);background:#ed42451f}.wt-tile-members-list{font-size:11px;color:var(--text-faint);padding:0 12px 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:768px){.wt-chat-panel{width:100%;max-height:30vh;border-left:none;border-top:1px solid var(--bg-tertiary)}}.gl-container{padding:20px;max-width:1200px;margin:0 auto}.gl-login-bar{display:flex;gap:10px;margin-bottom:12px}.gl-connect-btn{color:#c7d5e0;padding:10px 20px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:all var(--transition);white-space:nowrap}.gl-steam-btn{background:#1b2838;border:1px solid #2a475e}.gl-steam-btn:hover{background:#2a475e;color:#fff}.gl-gog-btn{background:#2c1a4e;border:1px solid #4a2d7a;color:#c7b3e8}.gl-gog-btn:hover{background:#3d2566;color:#fff}.gl-profile-chips{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}.gl-profile-chip{display:flex;align-items:center;gap:8px;padding:6px 12px;border-radius:20px;background:#ffffff0d;border:1px solid rgba(255,255,255,.1);cursor:pointer;transition:all .2s}.gl-profile-chip.selected{border-color:#e67e22;background:#e67e221a}.gl-profile-chip:hover{background:#ffffff1a}.gl-profile-chip-avatar{width:28px;height:28px;border-radius:50%}.gl-profile-chip-info{display:flex;flex-direction:column;gap:2px}.gl-profile-chip-name{font-size:13px;font-weight:600;color:#e0e0e0}.gl-profile-chip-platforms{display:flex;gap:4px}.gl-profile-chip-count{font-size:11px;color:#667}.gl-platform-badge{font-size:9px;font-weight:700;padding:1px 5px;border-radius:3px;text-transform:uppercase}.gl-platform-badge.steam{background:#1b2838cc;color:#66c0f4;border:1px solid #2a475e}.gl-platform-badge.gog{background:#2c1a4ecc;color:#b388ff;border:1px solid #4a2d7a}.gl-game-platform-icon{font-size:9px;font-weight:700;padding:1px 4px;border-radius:3px;margin-right:6px;flex-shrink:0}.gl-game-platform-icon.steam{background:#1b283899;color:#66c0f4}.gl-game-platform-icon.gog{background:#2c1a4e99;color:#b388ff}.gl-users-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;margin-bottom:32px}.gl-user-card{background:var(--bg-secondary);border-radius:var(--radius);padding:16px;display:flex;flex-direction:column;align-items:center;gap:10px;cursor:pointer;transition:all var(--transition);border:1px solid var(--bg-tertiary)}.gl-user-card:hover{border-color:var(--accent);transform:translateY(-2px)}.gl-user-card-avatar{width:64px;height:64px;border-radius:50%}.gl-user-card-name{font-weight:600;font-size:15px;color:var(--text-normal)}.gl-user-card-games{font-size:13px;color:var(--text-faint)}.gl-user-card-updated{font-size:11px;color:var(--text-faint)}.gl-profile-card-platforms{display:flex;gap:6px;margin-top:4px}.gl-common-finder{background:var(--bg-secondary);border-radius:var(--radius);padding:20px;margin-bottom:24px}.gl-common-finder h3{margin:0 0 12px;font-size:15px;color:var(--text-normal)}.gl-common-users{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}.gl-common-check{display:flex;align-items:center;gap:6px;background:var(--bg-tertiary);padding:6px 12px 6px 6px;border-radius:20px;cursor:pointer;transition:all var(--transition)}.gl-common-check.checked{background:#e67e2226}.gl-common-check input{accent-color:var(--accent)}.gl-common-check-avatar{width:24px;height:24px;border-radius:50%}.gl-common-find-btn{background:var(--accent);color:#fff;border:none;padding:10px 24px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:background var(--transition)}.gl-common-find-btn:hover{filter:brightness(1.1)}.gl-common-find-btn:disabled{opacity:.5;cursor:not-allowed}.gl-search{margin-bottom:24px}.gl-search-input{width:100%;padding:10px 14px;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);box-sizing:border-box}.gl-search-input:focus{border-color:var(--accent)}.gl-search-input::placeholder{color:var(--text-faint)}.gl-game-list{display:flex;flex-direction:column;gap:4px}.gl-game-item{display:flex;align-items:center;gap:12px;padding:8px 12px;background:var(--bg-secondary);border-radius:var(--radius);transition:background var(--transition)}.gl-game-item:hover{background:var(--bg-tertiary)}.gl-game-icon{width:32px;height:32px;border-radius:4px;flex-shrink:0;background:var(--bg-tertiary)}.gl-game-name{flex:1;font-size:14px;color:var(--text-normal)}.gl-game-playtime{font-size:12px;color:var(--text-faint);white-space:nowrap}.gl-game-owners{display:flex;gap:4px}.gl-game-owner-avatar{width:20px;height:20px;border-radius:50%;border:1px solid var(--bg-tertiary)}.gl-detail-header{display:flex;align-items:center;gap:16px;margin-bottom:24px}.gl-back-btn{background:var(--bg-secondary);border:none;color:var(--text-normal);padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.gl-back-btn:hover{background:var(--bg-tertiary)}.gl-detail-avatar{width:48px;height:48px;border-radius:50%}.gl-detail-info{flex:1}.gl-detail-name{font-size:18px;font-weight:600;color:var(--text-normal)}.gl-detail-sub{font-size:13px;color:var(--text-faint);display:flex;align-items:center;gap:6px;margin-top:4px}.gl-refresh-btn{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:16px;padding:4px;transition:color var(--transition)}.gl-refresh-btn:hover{color:var(--accent)}.gl-platform-detail{display:inline-flex;align-items:center;gap:2px}.gl-disconnect-btn{background:none;border:none;color:#666;cursor:pointer;font-size:10px;padding:0 3px;line-height:1;border-radius:3px;transition:all .2s}.gl-disconnect-btn:hover{color:#e74c3c;background:#e74c3c26}.gl-link-gog-btn{background:#a855f726;color:#a855f7;border:1px solid rgba(168,85,247,.3);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-link-gog-btn:hover{background:#a855f740}.gl-loading{text-align:center;padding:48px;color:var(--text-faint);font-size:14px}.gl-empty{text-align:center;padding:60px 20px}.gl-empty-icon{font-size:48px;margin-bottom:16px}.gl-empty h3{color:var(--text-normal);margin:0 0 8px}.gl-empty p{color:var(--text-faint);margin:0;font-size:14px}.gl-common-playtimes{display:flex;gap:8px;flex-wrap:wrap}.gl-common-pt{font-size:11px;color:var(--text-faint);background:var(--bg-tertiary);padding:2px 8px;border-radius:4px}.gl-section-title{font-size:14px;font-weight:600;color:var(--text-normal);margin:0 0 12px}.gl-game-count{font-size:12px;color:var(--text-faint);margin-left:8px;font-weight:400}.gl-detail-avatars{display:flex;gap:-8px}.gl-detail-avatars img{width:36px;height:36px;border-radius:50%;border:2px solid var(--bg-primary);margin-left:-8px}.gl-detail-avatars img:first-child{margin-left:0}.gl-search-results-title{font-size:13px;color:var(--text-faint);margin-bottom:8px}.gl-game-item.enriched{align-items:flex-start;min-height:60px}.gl-game-visual{flex-shrink:0}.gl-game-cover{width:45px;height:64px;object-fit:cover;border-radius:4px}.gl-game-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.gl-game-genres{display:flex;flex-wrap:wrap;gap:4px}.gl-genre-tag{font-size:10px;padding:1px 6px;border-radius:3px;background:#e67e2226;color:#e67e22}.gl-game-platforms{font-size:10px;color:var(--text-muted, #888)}.gl-platform-tag{margin-left:4px;padding:1px 5px;border-radius:3px;background:#3498db26;color:#3498db}.gl-game-meta{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}.gl-game-rating{font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;min-width:28px;text-align:center}.gl-game-rating.high{background:#2ecc7133;color:#2ecc71}.gl-game-rating.mid{background:#f1c40f33;color:#f1c40f}.gl-game-rating.low{background:#e74c3c33;color:#e74c3c}.gl-enrich-btn{background:#3498db26;border:1px solid rgba(52,152,219,.3);color:#3498db;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-enrich-btn:hover:not(:disabled){background:#3498db40}.gl-enrich-btn:disabled{opacity:.5;cursor:not-allowed}.gl-enrich-btn.enriching{animation:gl-pulse 1.5s ease-in-out infinite}@keyframes gl-pulse{0%,to{opacity:.5}50%{opacity:1}}.gl-filter-bar{display:flex;align-items:center;gap:10px;margin-bottom:8px}.gl-filter-bar .gl-search-input{flex:1}.gl-sort-select{background:#ffffff0f;color:#c7d5e0;border:1px solid rgba(255,255,255,.1);padding:10px 12px;border-radius:var(--radius);font-size:13px;cursor:pointer;min-width:120px}.gl-sort-select:focus{outline:none;border-color:#ffffff40}.gl-sort-select option{background:#1a1a2e;color:#c7d5e0}.gl-genre-filters{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px;padding:8px 0}.gl-genre-chip{background:#ffffff0f;color:#8899a6;border:1px solid rgba(255,255,255,.08);padding:5px 12px;border-radius:20px;font-size:12px;cursor:pointer;transition:all .2s;white-space:nowrap}.gl-genre-chip:hover{background:#ffffff1a;color:#c7d5e0}.gl-genre-chip.active{background:#e67e2233;color:#e67e22;border-color:#e67e2266}.gl-genre-chip.active.clear{background:#3498db33;color:#3498db;border-color:#3498db66}.gl-filter-count{color:#556;font-size:12px;margin:0 0 8px}@media(max-width:768px){.gl-container{padding:12px}.gl-users-grid{grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}.gl-login-bar{flex-direction:column}}.gl-dialog-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;display:flex;align-items:center;justify-content:center;z-index:1000;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.gl-dialog{background:#2a2a3e;border-radius:12px;padding:24px;max-width:500px;width:90%;box-shadow:0 8px 32px #00000080}.gl-dialog h3{margin:0 0 12px;font-size:1.2rem;color:#fff}.gl-dialog-hint{font-size:.85rem;color:#aaa;margin-bottom:14px;line-height:1.5}.gl-dialog-input{width:100%;padding:10px 12px;background:#1a1a2e;border:1px solid #444;border-radius:8px;color:#fff;font-size:.9rem;outline:none;transition:border-color .2s}.gl-dialog-input:focus{border-color:#a855f7}.gl-dialog-status{margin-top:8px;font-size:.85rem;padding:6px 10px;border-radius:6px}.gl-dialog-status.loading{color:#a855f7}.gl-dialog-status.success{color:#4caf50}.gl-dialog-status.error{color:#e74c3c}.gl-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.gl-dialog-cancel{padding:8px 18px;background:#3a3a4e;color:#ccc;border:none;border-radius:8px;cursor:pointer;font-size:.9rem}.gl-dialog-cancel:hover{background:#4a4a5e}.gl-dialog-submit{padding:8px 18px;background:#a855f7;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:.9rem;font-weight:600}.gl-dialog-submit:hover:not(:disabled){background:#9333ea}.gl-dialog-submit:disabled{opacity:.5;cursor:not-allowed}.gl-login-bar-spacer{flex:1}.gl-admin-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#888;padding:8px 12px;border-radius:var(--radius);cursor:pointer;font-size:16px;transition:all .2s}.gl-admin-btn:hover{background:#ffffff1a;color:#ccc}.gl-admin-panel{background:#2a2a3e;border-radius:12px;padding:0;max-width:600px;width:92%;box-shadow:0 8px 32px #00000080;max-height:80vh;display:flex;flex-direction:column}.gl-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid rgba(255,255,255,.08)}.gl-admin-header h3{margin:0;font-size:1.1rem;color:#fff}.gl-admin-close{background:none;border:none;color:#888;font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px}.gl-admin-close:hover{color:#fff;background:#ffffff1a}.gl-admin-login{padding:20px}.gl-admin-login p{color:#aaa;margin:0 0 12px;font-size:14px}.gl-admin-login-row{display:flex;gap:8px}.gl-admin-login-btn{background:#e67e22;color:#fff;border:none;padding:10px 20px;border-radius:8px;cursor:pointer;font-weight:600;white-space:nowrap}.gl-admin-login-btn:hover{background:#d35400}.gl-admin-content{padding:0;overflow-y:auto}.gl-admin-toolbar{display:flex;align-items:center;gap:10px;padding:12px 20px;border-bottom:1px solid rgba(255,255,255,.06)}.gl-admin-status-text{font-size:13px;color:#4caf50;flex:1}.gl-admin-refresh-btn,.gl-admin-logout-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#aaa;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;transition:all .2s}.gl-admin-refresh-btn:hover{background:#ffffff1a;color:#fff}.gl-admin-logout-btn:hover{background:#e74c3c26;color:#e74c3c;border-color:#e74c3c4d}.gl-admin-list{padding:8px 12px}.gl-admin-item{display:flex;align-items:center;gap:12px;padding:10px 8px;border-bottom:1px solid rgba(255,255,255,.04);transition:background .15s}.gl-admin-item:last-child{border-bottom:none}.gl-admin-item:hover{background:#ffffff08}.gl-admin-item-avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0}.gl-admin-item-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.gl-admin-item-name{font-size:14px;font-weight:600;color:#e0e0e0}.gl-admin-item-details{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.gl-admin-item-total{font-size:11px;color:#667}.gl-admin-delete-btn{background:#e74c3c1a;color:#e74c3c;border:1px solid rgba(231,76,60,.2);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;white-space:nowrap;transition:all .2s;flex-shrink:0}.gl-admin-delete-btn:hover{background:#e74c3c40;border-color:#e74c3c66}:root{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--success: #57d28f;--danger: #ed4245;--warning: #fee75c;--border: rgba(255, 255, 255, .06);--radius: 8px;--radius-lg: 12px;--transition: .15s ease;--font: "Segoe UI", system-ui, -apple-system, sans-serif;--header-height: 56px}*,*:before,*:after{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;font-family:var(--font);font-size:15px;color:var(--text-normal);background:var(--bg-deep);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;overflow:hidden}#root{height:100%}.hub-app{display:flex;flex-direction:column;height:100vh;overflow:hidden}.hub-header{position:sticky;top:0;z-index:100;display:flex;align-items:center;height:var(--header-height);min-height:var(--header-height);padding:0 16px;background:var(--bg-primary);border-bottom:1px solid var(--border);gap:16px}.hub-header-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.hub-logo{font-size:24px;line-height:1}.hub-title{font-size:18px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em;white-space:nowrap}.hub-conn-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);flex-shrink:0;transition:background var(--transition);box-shadow:0 0 0 2px #ed424540}.hub-conn-dot.online{background:var(--success);box-shadow:0 0 0 2px #57d28f40;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 0 2px #57d28f40}50%{box-shadow:0 0 0 6px #57d28f1a}}.hub-tabs{display:flex;align-items:center;gap:4px;flex:1;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;padding:0 4px}.hub-tabs::-webkit-scrollbar{display:none}.hub-tab{display:flex;align-items:center;gap:6px;padding:8px 14px;border:none;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:var(--radius);white-space:nowrap;transition:all var(--transition);position:relative;-webkit-user-select:none;user-select:none}.hub-tab:hover{color:var(--text-normal);background:var(--bg-secondary)}.hub-tab.active{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-tab.active:after{content:"";position:absolute;bottom:-1px;left:50%;transform:translate(-50%);width:calc(100% - 16px);height:2px;background:var(--accent);border-radius:1px}.hub-tab-icon{font-size:16px;line-height:1}.hub-tab-label{text-transform:capitalize}.hub-header-right{display:flex;align-items:center;gap:12px;flex-shrink:0}.hub-download-btn{display:flex;align-items:center;gap:6px;padding:4px 10px;font-size:12px;font-weight:500;font-family:var(--font);text-decoration:none;color:var(--text-muted);background:var(--bg-secondary);border-radius:var(--radius);cursor:pointer;transition:all var(--transition);white-space:nowrap}.hub-download-btn:hover{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-download-icon{font-size:14px;line-height:1}.hub-download-label{line-height:1}.hub-version{font-size:12px;color:var(--text-faint);font-weight:500;font-variant-numeric:tabular-nums;background:var(--bg-secondary);padding:4px 8px;border-radius:4px}.hub-check-update-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-secondary);font-size:14px;padding:2px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-check-update-btn:hover:not(:disabled){color:var(--accent);border-color:var(--accent)}.hub-check-update-btn:disabled{opacity:.4;cursor:default}.hub-update-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-update-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:32px 40px;text-align:center;min-width:320px;max-width:400px;box-shadow:0 8px 32px #00000080}.hub-update-icon{font-size:40px;margin-bottom:12px}.hub-update-modal h2{margin:0 0 8px;font-size:18px;color:var(--text-primary)}.hub-update-modal p{margin:0 0 20px;font-size:14px;color:var(--text-secondary)}.hub-update-progress{height:4px;border-radius:2px;background:var(--bg-deep);overflow:hidden}.hub-update-progress-bar{height:100%;width:40%;border-radius:2px;background:var(--accent);animation:hub-update-slide 1.5s ease-in-out infinite}@keyframes hub-update-slide{0%{transform:translate(-100%)}to{transform:translate(350%)}}.hub-update-btn{padding:8px 32px;font-size:14px;font-weight:600;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;cursor:pointer;transition:opacity var(--transition)}.hub-update-btn:hover{opacity:.85}.hub-update-btn-secondary{background:var(--bg-tertiary);color:var(--text-secondary);margin-top:4px}.hub-update-versions{display:flex;flex-direction:column;gap:2px;margin:8px 0;font-size:12px;color:var(--text-muted)}.hub-update-error-detail{font-size:11px;color:#ef4444;background:#ef44441a;border-radius:var(--radius);padding:6px 10px;word-break:break-word;max-width:300px}.hub-refresh-btn{background:none;border:none;color:var(--text-muted);font-size:1rem;cursor:pointer;padding:4px 6px;border-radius:var(--radius);transition:all var(--transition);line-height:1}.hub-refresh-btn:hover{color:var(--accent);background:#e67e221a}.hub-admin-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-muted);font-size:16px;padding:4px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-admin-btn:hover{color:var(--accent);border-color:var(--accent)}.hub-admin-btn.active{color:#4ade80;border-color:#4ade80}.hub-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-admin-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;width:340px;box-shadow:0 8px 32px #00000080}.hub-admin-modal-header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--border);font-weight:600}.hub-admin-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:16px}.hub-admin-modal-close:hover{color:var(--text)}.hub-admin-modal-body{padding:20px;display:flex;flex-direction:column;gap:12px}.hub-admin-input{width:100%;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text);font-size:14px;font-family:var(--font);box-sizing:border-box}.hub-admin-input:focus{outline:none;border-color:var(--accent)}.hub-admin-error{color:#ef4444;font-size:13px;margin:0}.hub-admin-submit{padding:8px 16px;background:var(--accent);color:#fff;border:none;border-radius:var(--radius);font-size:14px;font-weight:500;cursor:pointer;transition:opacity var(--transition)}.hub-admin-submit:hover{opacity:.9}.hub-version-clickable{cursor:pointer;transition:all var(--transition);padding:2px 8px;border-radius:var(--radius)}.hub-version-clickable:hover{color:var(--accent);background:#e67e221a}.hub-version-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-version-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:hub-modal-in .2s ease}@keyframes hub-modal-in{0%{opacity:0;transform:scale(.95) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.hub-version-modal-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.hub-version-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.hub-version-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.hub-version-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.hub-version-modal-row{display:flex;justify-content:space-between;align-items:center}.hub-version-modal-label{color:var(--text-muted);font-size:13px}.hub-version-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.hub-version-modal-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);flex-shrink:0}.hub-version-modal-dot.online{background:var(--success)}.hub-version-modal-link{color:var(--accent);text-decoration:none;font-weight:500;font-size:13px}.hub-version-modal-link:hover{text-decoration:underline}.hub-version-modal-hint{font-size:11px;color:var(--accent);padding:6px 10px;background:#e67e221a;border-radius:var(--radius);text-align:center}.hub-version-modal-update{margin-top:4px;padding-top:12px;border-top:1px solid var(--border)}.hub-version-modal-update-btn{width:100%;padding:10px 16px;border:none;border-radius:var(--radius);background:var(--bg-tertiary);color:var(--text-normal);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);display:flex;align-items:center;justify-content:center;gap:8px}.hub-version-modal-update-btn:hover{background:var(--bg-hover);color:var(--accent)}.hub-version-modal-update-btn.ready{background:#2ecc7126;color:#2ecc71}.hub-version-modal-update-btn.ready:hover{background:#2ecc7140}.hub-version-modal-update-status{display:flex;align-items:center;justify-content:center;gap:8px;font-size:13px;color:var(--text-muted);padding:8px 0;flex-wrap:wrap}.hub-version-modal-update-status.success{color:#2ecc71}.hub-version-modal-update-status.error{color:#e74c3c}.hub-version-modal-update-retry{background:none;border:none;color:var(--text-muted);font-size:11px;cursor:pointer;text-decoration:underline;padding:2px 4px;width:100%;margin-top:4px}.hub-version-modal-update-retry:hover{color:var(--text-normal)}@keyframes hub-spin{to{transform:rotate(360deg)}}.hub-update-spinner{width:14px;height:14px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:hub-spin .8s linear infinite;flex-shrink:0}.hub-content{flex:1;overflow-y:auto;overflow-x:hidden;background:var(--bg-deep);scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.hub-content::-webkit-scrollbar{width:6px}.hub-content::-webkit-scrollbar-track{background:transparent}.hub-content::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.hub-content::-webkit-scrollbar-thumb:hover{background:var(--text-faint)}.hub-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px;text-align:center;padding:32px;animation:fade-in .3s ease}.hub-empty-icon{font-size:64px;line-height:1;margin-bottom:20px;opacity:.6;filter:grayscale(30%)}.hub-empty h2{font-size:22px;font-weight:700;color:var(--text-normal);margin-bottom:8px}.hub-empty p{font-size:15px;color:var(--text-muted);max-width:360px;line-height:1.5}@keyframes fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}::selection{background:rgba(var(--accent-rgb),.3);color:var(--text-normal)}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(max-width:768px){:root{--header-height: 48px}.hub-header{padding:0 10px;gap:8px}.hub-title{font-size:15px}.hub-logo{font-size:20px}.hub-tab{padding:6px 10px;font-size:13px;gap:4px}.hub-tab-label{display:none}.hub-tab-icon{font-size:18px}.hub-version{font-size:11px}.hub-empty-icon{font-size:48px}.hub-empty h2{font-size:18px}.hub-empty p{font-size:14px}}@media(max-width:480px){.hub-header-right{display:none}.hub-header{padding:0 8px;gap:6px}.hub-title{font-size:14px}}.radio-container{display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;background:var(--bg-deep);--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--border: rgba(255, 255, 255, .06)}.radio-container[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad}.radio-container[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60}.radio-container[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9}.radio-container[data-theme=cherry]{--bg-deep: #1a0f14;--bg-primary: #22141a;--bg-secondary: #301c25;--bg-tertiary: #3e2530;--accent: #e74c6f;--accent-rgb: 231, 76, 111;--accent-hover: #c0392b}.radio-topbar{display:flex;align-items:center;padding:0 16px;height:52px;background:var(--bg-secondary, #2b2d31);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px}.radio-topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.radio-topbar-logo{font-size:20px}.radio-topbar-title{font-size:16px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em}.radio-topbar-np{flex:1;display:flex;align-items:center;gap:10px;min-width:0;justify-content:center}.radio-topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.radio-topbar-stop{display:flex;align-items:center;gap:4px;background:var(--danger);color:#fff;border:none;border-radius:var(--radius);padding:6px 14px;font-size:13px;font-family:var(--font);font-weight:600;cursor:pointer;transition:all var(--transition);flex-shrink:0}.radio-topbar-stop:hover{background:#c63639}.radio-theme-inline{display:flex;align-items:center;gap:4px;margin-left:4px}.radio-globe-wrap{position:relative;flex:1;overflow:hidden}.radio-globe{width:100%;height:100%}.radio-globe canvas{outline:none!important}.radio-search{position:absolute;top:16px;left:50%;transform:translate(-50%);z-index:20;width:min(440px,calc(100% - 32px))}.radio-search-wrap{display:flex;align-items:center;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);padding:0 14px;gap:8px;box-shadow:0 8px 32px #0006}.radio-search-icon{font-size:16px;opacity:.6;flex-shrink:0}.radio-search-input{flex:1;background:transparent;border:none;color:var(--text-normal);font-family:var(--font);font-size:14px;padding:12px 0;outline:none}.radio-search-input::placeholder{color:var(--text-faint)}.radio-search-clear{background:none;border:none;color:var(--text-muted);font-size:14px;cursor:pointer;padding:4px;border-radius:4px;transition:color var(--transition)}.radio-search-clear:hover{color:var(--text-normal)}.radio-search-results{margin-top:6px;background:#1e1f22f2;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);max-height:360px;overflow-y:auto;box-shadow:0 12px 40px #00000080;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-search-result{display:flex;align-items:center;gap:10px;width:100%;padding:10px 14px;background:none;border:none;border-bottom:1px solid var(--border);color:var(--text-normal);font-family:var(--font);font-size:14px;cursor:pointer;text-align:left;transition:background var(--transition)}.radio-search-result:last-child{border-bottom:none}.radio-search-result:hover{background:rgba(var(--accent-rgb),.08)}.radio-search-result-icon{font-size:18px;flex-shrink:0}.radio-search-result-text{display:flex;flex-direction:column;gap:2px;min-width:0}.radio-search-result-title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-search-result-sub{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-fab{position:absolute;top:16px;right:16px;z-index:20;display:flex;align-items:center;gap:4px;padding:10px 14px;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);color:var(--text-normal);font-size:16px;cursor:pointer;box-shadow:0 8px 32px #0006;transition:all var(--transition)}.radio-fab:hover,.radio-fab.active{background:rgba(var(--accent-rgb),.15);border-color:rgba(var(--accent-rgb),.3)}.radio-fab-badge{font-size:11px;font-weight:700;background:var(--accent);color:#fff;padding:1px 6px;border-radius:10px;min-width:18px;text-align:center}.radio-panel{position:absolute;top:0;right:0;width:340px;height:100%;z-index:15;background:#1e1f22f2;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border-left:1px solid var(--border);display:flex;flex-direction:column;animation:slide-in-right .2s ease;box-shadow:-8px 0 32px #0000004d}@keyframes slide-in-right{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}.radio-panel-header{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--border);flex-shrink:0}.radio-panel-header h3{font-size:16px;font-weight:700;color:var(--text-normal)}.radio-panel-sub{font-size:12px;color:var(--text-muted);display:block;margin-top:2px}.radio-panel-close{background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all var(--transition)}.radio-panel-close:hover{color:var(--text-normal);background:var(--bg-secondary)}.radio-panel-body{flex:1;overflow-y:auto;padding:8px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-panel-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:14px}.radio-panel-loading{display:flex;flex-direction:column;align-items:center;gap:12px;padding:40px 16px;color:var(--text-muted);font-size:14px}.radio-station{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);transition:background var(--transition);gap:10px}.radio-station:hover{background:var(--bg-secondary)}.radio-station.playing{background:rgba(var(--accent-rgb),.1);border:1px solid rgba(var(--accent-rgb),.2)}.radio-station-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.radio-station-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-loc{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-live{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--accent);font-weight:600}.radio-station-btns{display:flex;gap:4px;flex-shrink:0}.radio-btn-play,.radio-btn-stop{width:34px;height:34px;border:none;border-radius:50%;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-play{background:var(--accent);color:#fff}.radio-btn-play:hover:not(:disabled){background:var(--accent-hover);transform:scale(1.05)}.radio-btn-play:disabled{opacity:.4;cursor:not-allowed}.radio-btn-stop{background:var(--danger);color:#fff}.radio-btn-stop:hover{background:#c63639}.radio-btn-fav{width:34px;height:34px;border:none;border-radius:50%;font-size:16px;cursor:pointer;background:transparent;color:var(--text-faint);display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-fav:hover{color:var(--warning);background:#fee75c1a}.radio-btn-fav.active{color:var(--warning)}.radio-eq{display:flex;align-items:flex-end;gap:2px;height:14px}.radio-eq span{width:3px;background:var(--accent);border-radius:1px;animation:eq-bounce .8s ease-in-out infinite}.radio-eq span:nth-child(1){height:8px;animation-delay:0s}.radio-eq span:nth-child(2){height:14px;animation-delay:.15s}.radio-eq span:nth-child(3){height:10px;animation-delay:.3s}@keyframes eq-bounce{0%,to{transform:scaleY(.4)}50%{transform:scaleY(1)}}.radio-sel{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius);color:var(--text-normal);font-family:var(--font);font-size:13px;padding:6px 10px;cursor:pointer;outline:none;max-width:180px}.radio-sel:focus{border-color:var(--accent)}.radio-eq-np{flex-shrink:0}.radio-np-info{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}.radio-np-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-np-loc{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-volume{display:flex;align-items:center;gap:6px;flex-shrink:0}.radio-volume-icon{font-size:16px;width:20px;text-align:center;cursor:pointer}.radio-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary, #383a40);outline:none;cursor:pointer}.radio-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-val{font-size:11px;color:var(--text-muted);min-width:32px;text-align:right}.radio-theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:transform .15s ease,border-color .15s ease;border:2px solid transparent}.radio-theme-dot:hover{transform:scale(1.25)}.radio-theme-dot.active{border-color:#fff;box-shadow:0 0 6px #ffffff4d}.radio-counter{position:absolute;bottom:16px;left:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;pointer-events:none}.radio-attribution{position:absolute;right:16px;bottom:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;text-decoration:none;transition:color var(--transition),background var(--transition)}.radio-attribution:hover{color:var(--text-normal);background:#1e1f22eb}.radio-spinner{width:24px;height:24px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media(max-width:768px){.radio-panel{width:100%}.radio-fab{top:12px;right:12px;padding:8px 10px;font-size:14px}.radio-search{top:12px;width:calc(100% - 80px);left:calc(50% - 24px)}.radio-topbar{padding:0 12px;gap:8px}.radio-topbar-title{display:none}.radio-sel{max-width:140px;font-size:12px}}@media(max-width:480px){.radio-topbar-np,.radio-volume{display:none}.radio-sel{max-width:120px}}.radio-conn{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--success);cursor:pointer;padding:4px 10px;border-radius:20px;background:#57d28f14;transition:all var(--transition);flex-shrink:0;-webkit-user-select:none;user-select:none}.radio-conn:hover{background:#57d28f26}.radio-conn-dot{width:8px;height:8px;border-radius:50%;background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.radio-conn-ping{font-size:11px;color:var(--text-muted);font-weight:600;font-variant-numeric:tabular-nums}.radio-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fade-in .15s ease}.radio-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:radio-modal-in .2s ease}@keyframes radio-modal-in{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.radio-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.radio-modal-close{margin-left:auto;background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.radio-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.radio-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.radio-modal-stat{display:flex;justify-content:space-between;align-items:center}.radio-modal-label{color:var(--text-muted);font-size:13px}.radio-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.radio-modal-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.ap-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9998;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);animation:fade-in .15s ease}.ap-modal{display:flex;width:min(940px,calc(100vw - 40px));height:min(620px,calc(100vh - 60px));background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;overflow:hidden;box-shadow:0 24px 80px #00000080;animation:hub-modal-in .2s ease;position:relative}.ap-sidebar{width:210px;min-width:210px;background:var(--bg-deep);border-right:1px solid var(--border);display:flex;flex-direction:column;padding:0}.ap-sidebar-title{padding:18px 20px 14px;font-size:15px;font-weight:700;color:var(--text-normal);letter-spacing:-.01em;border-bottom:1px solid var(--border)}.ap-nav{display:flex;flex-direction:column;padding:8px;gap:2px}.ap-nav-item{display:flex;align-items:center;gap:10px;padding:10px 14px;border:none;border-left:3px solid transparent;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:0 var(--radius) var(--radius) 0;transition:all var(--transition);text-align:left}.ap-nav-item:hover{color:var(--text-normal);background:var(--bg-secondary)}.ap-nav-item.active{color:var(--accent);background:rgba(var(--accent-rgb),.1);border-left-color:var(--accent);font-weight:600}.ap-nav-icon{font-size:16px;line-height:1}.ap-nav-label{line-height:1}.ap-content{flex:1;display:flex;flex-direction:column;overflow:hidden}.ap-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--border);flex-shrink:0}.ap-title{font-size:16px;font-weight:700;color:var(--text-normal);margin:0}.ap-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:6px;transition:all var(--transition)}.ap-close:hover{color:var(--text-normal);background:#ffffff14}.ap-body{flex:1;overflow-y:auto;padding:16px 20px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.ap-body::-webkit-scrollbar{width:6px}.ap-body::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.ap-tab-content{display:flex;flex-direction:column;gap:12px;animation:fade-in .15s ease}.ap-toolbar{display:flex;align-items:center;gap:10px}.ap-search{flex:1;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:13px;font-family:var(--font)}.ap-search:focus{outline:none;border-color:var(--accent)}.ap-search::placeholder{color:var(--text-faint)}.ap-btn{display:inline-flex;align-items:center;gap:4px;padding:8px 14px;border:none;border-radius:var(--radius);font-family:var(--font);font-size:13px;font-weight:500;cursor:pointer;transition:all var(--transition);white-space:nowrap}.ap-btn:disabled{opacity:.5;cursor:default}.ap-btn-primary{background:var(--accent);color:#fff}.ap-btn-primary:hover:not(:disabled){background:var(--accent-hover)}.ap-btn-danger{background:#ed424526;color:var(--danger);border:1px solid rgba(237,66,69,.3)}.ap-btn-danger:hover:not(:disabled){background:#ed424540}.ap-btn-outline{background:var(--bg-secondary);color:var(--text-muted);border:1px solid var(--border)}.ap-btn-outline:hover:not(:disabled){color:var(--text-normal);border-color:var(--text-faint)}.ap-btn-sm{padding:5px 10px;font-size:12px}.ap-upload-zone{display:flex;align-items:center;justify-content:center;padding:14px;border:2px dashed var(--border);border-radius:var(--radius);background:var(--bg-secondary);cursor:pointer;transition:all var(--transition);color:var(--text-muted);font-size:13px}.ap-upload-zone:hover{border-color:var(--accent);color:var(--accent);background:rgba(var(--accent-rgb),.05)}.ap-upload-progress{color:var(--accent);font-weight:600}.ap-bulk-row{display:flex;align-items:center;justify-content:space-between;padding:6px 0}.ap-select-all{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted);cursor:pointer}.ap-select-all input[type=checkbox]{accent-color:var(--accent)}.ap-list-wrap{flex:1;min-height:0}.ap-list{display:flex;flex-direction:column;gap:2px}.ap-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-item:hover{background:var(--bg-tertiary)}.ap-item-check{flex-shrink:0;cursor:pointer}.ap-item-check input[type=checkbox]{accent-color:var(--accent)}.ap-item-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.ap-item-name{font-size:13px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ap-item-meta{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ap-item-actions{display:flex;gap:4px;flex-shrink:0}.ap-rename-row{display:flex;align-items:center;gap:6px;margin-top:4px}.ap-rename-input{flex:1;padding:5px 8px;border:1px solid var(--accent);border-radius:var(--radius);background:var(--bg-deep);color:var(--text-normal);font-size:12px;font-family:var(--font)}.ap-rename-input:focus{outline:none}.ap-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:13px}.ap-hint{font-size:13px;color:var(--text-muted);margin:0}.ap-status-badge{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--text-muted)}.ap-status-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);flex-shrink:0}.ap-status-dot.online{background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.ap-channel-list{display:flex;flex-direction:column;gap:2px}.ap-channel-row{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-channel-row:hover{background:var(--bg-tertiary)}.ap-channel-info{display:flex;flex-direction:column;gap:2px;min-width:0}.ap-channel-name{font-size:13px;font-weight:600;color:var(--text-normal)}.ap-channel-guild{font-size:11px;color:var(--text-faint)}.ap-channel-toggles{display:flex;gap:8px;flex-shrink:0}.ap-toggle{display:flex;align-items:center;gap:4px;font-size:12px;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:var(--radius);transition:all var(--transition)}.ap-toggle input[type=checkbox]{accent-color:var(--accent)}.ap-toggle.active{color:var(--accent);background:rgba(var(--accent-rgb),.08)}.ap-save-row{display:flex;justify-content:flex-end;padding-top:8px}.ap-profile-list{display:flex;flex-direction:column;gap:2px}.ap-profile-row{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-profile-row:hover{background:var(--bg-tertiary)}.ap-profile-avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0}.ap-profile-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.ap-profile-name{font-size:14px;font-weight:600;color:var(--text-normal)}.ap-profile-details{display:flex;align-items:center;gap:6px;font-size:11px}.ap-platform-badge{padding:1px 6px;border-radius:3px;font-weight:600;font-size:10px}.ap-platform-badge.steam{background:#4285f426;color:#64b5f6}.ap-platform-badge.gog{background:#ab47bc26;color:#ce93d8}.ap-profile-total{color:var(--text-faint)}.ap-toast{position:absolute;bottom:16px;left:50%;transform:translate(-50%);padding:8px 16px;border-radius:var(--radius);font-size:13px;font-weight:500;background:var(--bg-tertiary);color:var(--text-normal);box-shadow:0 4px 16px #0006;animation:fade-in .15s ease;z-index:10}.ap-toast.error{background:#ed424533;color:#f87171}@media(max-width:768px){.ap-modal{flex-direction:column;width:calc(100vw - 16px);height:calc(100vh - 32px)}.ap-sidebar{width:100%;min-width:100%;flex-direction:row;border-right:none;border-bottom:1px solid var(--border);overflow-x:auto}.ap-sidebar-title{display:none}.ap-nav{flex-direction:row;padding:4px 8px;gap:4px}.ap-nav-item{border-left:none;border-bottom:3px solid transparent;border-radius:var(--radius) var(--radius) 0 0;padding:8px 12px;white-space:nowrap}.ap-nav-item.active{border-left-color:transparent;border-bottom-color:var(--accent)}.ap-channel-toggles{flex-direction:column;gap:4px}} +@import"https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap";@import"https://fonts.googleapis.com/icon?family=Material+Icons";.sb-app{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--bg-modifier-hover: rgba(79, 84, 92, .16);--bg-modifier-active: rgba(79, 84, 92, .24);--bg-modifier-selected: rgba(79, 84, 92, .32);--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #5865f2;--accent-rgb: 88, 101, 242;--accent-hover: #4752c4;--accent-glow: rgba(88, 101, 242, .45);--green: #23a55a;--red: #f23f42;--yellow: #f0b232;--white: #ffffff;--font: "DM Sans", "Outfit", "gg sans", "Noto Sans", Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;--radius: 8px;--radius-lg: 12px;--shadow-low: 0 1px 3px rgba(0, 0, 0, .24);--shadow-med: 0 4px 12px rgba(0, 0, 0, .32);--shadow-high: 0 8px 24px rgba(0, 0, 0, .4);--transition: .15s cubic-bezier(.4, 0, .2, 1);--card-size: 110px;--card-emoji: 28px;--card-font: 11px;color-scheme:dark}.sb-app[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad;--accent-glow: rgba(155, 89, 182, .45)}.sb-app[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60;--accent-glow: rgba(46, 204, 113, .4)}.sb-app[data-theme=sunset]{--bg-deep: #1a1210;--bg-primary: #231815;--bg-secondary: #2f201c;--bg-tertiary: #3d2a24;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--accent-glow: rgba(230, 126, 34, .4)}.sb-app[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9;--accent-glow: rgba(52, 152, 219, .4)}.sb-app{display:flex;flex-direction:column;height:100%;position:relative}.topbar{display:flex;align-items:center;padding:0 20px;height:52px;background:var(--bg-secondary);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px;transition:background .4s ease}.topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.sb-app-logo{width:28px;height:28px;background:var(--accent);border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .4s ease}.sb-app-title{font-size:16px;font-weight:700;color:var(--white);letter-spacing:-.02em}.clock-wrap{flex:1;display:flex;justify-content:center}.clock{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:.02em;font-variant-numeric:tabular-nums;opacity:.9}.clock-seconds{font-size:14px;color:var(--text-faint);font-weight:500}.topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0}.channel-dropdown{position:relative;flex-shrink:0}.channel-btn{display:flex;align-items:center;gap:8px;padding:5px 12px 5px 10px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-normal);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.channel-btn:hover{background:var(--bg-modifier-selected);border-color:#ffffff1f}.channel-btn.open{border-color:var(--accent)}.channel-btn .cb-icon{font-size:16px;color:var(--text-muted)}.channel-btn .chevron{font-size:12px;color:var(--text-faint);transition:transform var(--transition);margin-left:2px}.channel-btn.open .chevron{transform:rotate(180deg)}.channel-status{width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0}.channel-menu{position:absolute;top:calc(100% + 6px);left:0;min-width:220px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:6px;z-index:100;animation:ctx-in .1s ease-out}.channel-menu-header{padding:6px 8px 4px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-faint)}.channel-option{display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:4px;font-size:13px;color:var(--text-muted);cursor:pointer;transition:all var(--transition)}.channel-option:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.channel-option.active{background:var(--accent);color:var(--white)}.channel-option .co-icon{font-size:16px;opacity:.7}.connection{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:#23a55a1f;font-size:12px;color:var(--green);font-weight:600}.conn-dot{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 6px #23a55a99;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 6px #23a55a80}50%{box-shadow:0 0 12px #23a55acc}}.conn-ping{font-size:10px;opacity:.7;margin-left:2px}.conn-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fadeIn .15s ease}.conn-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:slideUp .2s ease}@keyframes slideUp{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.conn-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.conn-modal-close{margin-left:auto;background:none;border:none;color:var(--muted);cursor:pointer;padding:4px;border-radius:6px;display:flex;transition:all .15s}.conn-modal-close:hover{background:#ffffff14;color:var(--fg)}.conn-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.conn-stat{display:flex;justify-content:space-between;align-items:center}.conn-stat-label{color:var(--muted);font-size:13px}.conn-stat-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.conn-ping-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.admin-btn-icon{width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition);font-size:18px}.admin-btn-icon:hover{background:var(--bg-modifier-hover);color:var(--text-normal)}.admin-btn-icon.active{color:var(--accent)}.toolbar{display:flex;align-items:center;gap:10px;padding:10px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0;flex-wrap:wrap;transition:background .4s ease}.cat-tabs{display:flex;gap:4px;flex-shrink:0}.cat-tab{display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.cat-tab:hover{background:var(--bg-modifier-selected);color:var(--text-normal)}.cat-tab.active{background:var(--accent);color:var(--white)}.tab-count{font-size:10px;font-weight:700;background:#ffffff26;padding:0 6px;border-radius:8px;line-height:1.6}.search-wrap{position:relative;flex:1;max-width:280px;min-width:140px}.search-wrap .search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);font-size:15px;color:var(--text-faint);pointer-events:none}.search-input{width:100%;height:32px;padding:0 28px 0 32px;border:1px solid rgba(255,255,255,.06);border-radius:20px;background:var(--bg-secondary);color:var(--text-normal);font-family:var(--font);font-size:13px;outline:none;transition:all var(--transition)}.search-input::placeholder{color:var(--text-faint)}.search-input:focus{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.search-clear{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:20px;height:20px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--text-faint);transition:all var(--transition)}.search-clear:hover{background:var(--bg-tertiary);color:var(--text-normal)}.toolbar-spacer{flex:1}.url-import-wrap{display:flex;align-items:center;gap:6px;min-width:240px;max-width:460px;flex:1;padding:4px 6px 4px 8px;border-radius:20px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.url-import-icon{font-size:15px;color:var(--text-faint);flex-shrink:0}.url-import-input{flex:1;min-width:0;height:26px;border:none;background:transparent;color:var(--text-normal);font-size:12px;font-family:var(--font);outline:none}.url-import-input::placeholder{color:var(--text-faint)}.url-import-btn{height:24px;padding:0 10px;border-radius:14px;border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.45);background:rgba(var(--accent-rgb, 88, 101, 242),.12);color:var(--accent);font-size:11px;font-weight:700;white-space:nowrap;transition:all var(--transition)}.url-import-btn:hover{background:var(--accent);border-color:var(--accent);color:var(--white)}.url-import-btn:disabled{opacity:.5;pointer-events:none}.url-import-tag{flex-shrink:0;padding:1px 6px;border-radius:8px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.url-import-tag.valid{background:#2ecc712e;color:#2ecc71}.url-import-tag.invalid{background:#e74c3c2e;color:#e74c3c}.tb-btn{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:var(--bg-tertiary);color:var(--text-muted);font-family:var(--font);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition);white-space:nowrap}.tb-btn:hover{background:var(--bg-modifier-selected);color:var(--text-normal);border-color:#ffffff1f}.tb-btn .tb-icon{font-size:15px}.tb-btn.random{border-color:#5865f24d;color:var(--accent)}.tb-btn.random:hover{background:var(--accent);color:var(--white);border-color:var(--accent)}.tb-btn.party{border-color:#f0b2324d;color:var(--yellow)}.tb-btn.party:hover{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow)}.tb-btn.party.active{background:var(--yellow);color:#1a1b1e;border-color:var(--yellow);animation:party-btn .6s ease-in-out infinite alternate}@keyframes party-btn{0%{box-shadow:0 0 8px #f0b23266}to{box-shadow:0 0 20px #f0b232b3}}.tb-btn.stop{border-color:#f23f424d;color:var(--red)}.tb-btn.stop:hover{background:var(--red);color:var(--white);border-color:var(--red)}.size-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.size-control .sc-icon{font-size:14px;color:var(--text-faint)}.size-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:70px;height:3px;border-radius:2px;background:var(--bg-modifier-selected);outline:none;cursor:pointer}.size-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.size-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.size-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.theme-selector{display:flex;align-items:center;gap:4px;padding:4px 8px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:all var(--transition);border:2px solid transparent}.theme-dot:hover{transform:scale(1.2)}.theme-dot.active{border-color:var(--white);box-shadow:0 0 6px #ffffff4d}.analytics-strip{display:flex;align-items:stretch;gap:8px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);flex-shrink:0}.analytics-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:12px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08)}.analytics-card.analytics-wide{flex:1;min-width:0}.analytics-icon{font-size:18px;color:var(--accent);flex-shrink:0}.analytics-copy{display:flex;flex-direction:column;gap:4px;min-width:0}.analytics-label{font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--text-faint)}.analytics-value{font-size:18px;line-height:1;font-weight:800;color:var(--text-normal)}.analytics-top-list{display:flex;align-items:center;gap:6px;overflow-x:auto;scrollbar-width:none}.analytics-top-list::-webkit-scrollbar{display:none}.analytics-chip{display:inline-flex;align-items:center;gap:4px;padding:3px 8px;border-radius:999px;background:rgba(var(--accent-rgb, 88, 101, 242),.15);color:var(--accent);font-size:11px;font-weight:600;white-space:nowrap}.analytics-muted{color:var(--text-muted);font-size:12px}.category-strip{display:flex;align-items:center;gap:6px;padding:8px 20px;background:var(--bg-primary);border-bottom:1px solid rgba(0,0,0,.12);overflow-x:auto;flex-shrink:0;scrollbar-width:none;transition:background .4s ease}.category-strip::-webkit-scrollbar{display:none}.cat-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;font-size:12px;font-weight:600;color:var(--text-muted);background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06);white-space:nowrap;cursor:pointer;transition:all var(--transition);flex-shrink:0}.cat-chip:hover{border-color:#ffffff1f;color:var(--text-normal);background:var(--bg-tertiary)}.cat-chip.active{background:#5865f21a}.cat-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.cat-count{font-size:10px;font-weight:700;opacity:.5}.main{flex:1;overflow-y:auto;padding:16px 20px;background:var(--bg-primary);transition:background .4s ease}.sound-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--card-size),1fr));gap:8px}.sound-card{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:12px 6px 8px;background:var(--bg-secondary);border-radius:var(--radius-lg);cursor:pointer;transition:all var(--transition);border:2px solid transparent;-webkit-user-select:none;user-select:none;overflow:hidden;aspect-ratio:1;opacity:0;animation:card-enter .35s ease-out forwards}.sound-card:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;opacity:0;transition:opacity var(--transition);background:radial-gradient(ellipse at center,var(--accent-glow) 0%,transparent 70%);pointer-events:none}.sound-card:hover{background:var(--bg-tertiary);transform:translateY(-3px);box-shadow:var(--shadow-med),0 0 20px var(--accent-glow);border-color:#5865f233}.sound-card:hover:before{opacity:1}.sound-card:active{transform:translateY(0);transition-duration:50ms}.sound-card.playing{border-color:var(--accent);animation:card-enter .35s ease-out forwards,playing-glow 1.2s ease-in-out infinite alternate}@keyframes playing-glow{0%{box-shadow:0 0 4px var(--accent-glow)}to{box-shadow:0 0 16px var(--accent-glow)}}@keyframes card-enter{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.ripple{position:absolute;border-radius:50%;background:#5865f24d;transform:scale(0);animation:ripple-expand .5s ease-out forwards;pointer-events:none}@keyframes ripple-expand{to{transform:scale(3);opacity:0}}.sound-emoji{font-size:var(--card-emoji);font-weight:800;line-height:1;z-index:1;transition:transform var(--transition);opacity:.7;font-family:Syne,DM Sans,sans-serif}.sound-card:hover .sound-emoji{transform:scale(1.15);opacity:1}.sound-card.playing .sound-emoji{animation:emoji-bounce .4s ease;opacity:1}@keyframes emoji-bounce{0%,to{transform:scale(1)}40%{transform:scale(1.3)}70%{transform:scale(.95)}}.sound-name{font-size:var(--card-font);font-weight:600;text-align:center;color:var(--text-normal);z-index:1;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 4px}.sound-duration{font-size:9px;color:var(--text-faint);z-index:1;font-weight:500}.fav-star{position:absolute;top:4px;right:4px;opacity:0;transition:all var(--transition);cursor:pointer;z-index:2;color:var(--text-faint);padding:2px;line-height:1}.fav-star .fav-icon{font-size:14px}.sound-card:hover .fav-star{opacity:.6}.fav-star:hover{opacity:1!important;color:var(--yellow);transform:scale(1.2)}.fav-star.active{opacity:1!important;color:var(--yellow)}.new-badge{position:absolute;top:4px;left:4px;font-size:8px;font-weight:700;background:var(--green);color:#fff;padding:1px 5px;border-radius:6px;text-transform:uppercase;letter-spacing:.03em;z-index:2}.playing-indicator{position:absolute;bottom:3px;left:50%;transform:translate(-50%);display:none;gap:2px;align-items:flex-end;height:10px}.sound-card.playing .playing-indicator{display:flex}.wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .6s ease-in-out infinite alternate}.wave-bar:nth-child(1){height:3px;animation-delay:0ms}.wave-bar:nth-child(2){height:7px;animation-delay:.15s}.wave-bar:nth-child(3){height:5px;animation-delay:.3s}.wave-bar:nth-child(4){height:9px;animation-delay:.1s}@keyframes wave{0%{height:2px}to{height:10px}}.empty-state{display:none;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:60px 20px;text-align:center}.empty-state.visible{display:flex}.empty-emoji{font-size:42px}.empty-title{font-size:15px;font-weight:700;color:var(--text-normal)}.empty-desc{font-size:13px;color:var(--text-muted);max-width:260px}.now-playing{display:flex;align-items:center;gap:6px;padding:4px 12px;border-radius:20px;background:rgba(var(--accent-rgb, 88, 101, 242),.12);border:1px solid rgba(var(--accent-rgb, 88, 101, 242),.2);font-size:12px;color:var(--text-muted);max-width:none;min-width:0;animation:np-fade-in .3s ease}@keyframes np-fade-in{0%{opacity:0;transform:translate(10px)}to{opacity:1;transform:translate(0)}}.np-name{color:var(--accent);font-weight:600;white-space:nowrap}.np-waves{display:none;gap:1.5px;align-items:flex-end;height:12px;flex-shrink:0}.np-waves.active{display:flex}.np-wave-bar{width:2px;background:var(--accent);border-radius:1px;animation:wave .5s ease-in-out infinite alternate}.np-wave-bar:nth-child(1){height:3px;animation-delay:0ms}.np-wave-bar:nth-child(2){height:8px;animation-delay:.12s}.np-wave-bar:nth-child(3){height:5px;animation-delay:.24s}.np-wave-bar:nth-child(4){height:10px;animation-delay:80ms}.volume-control{display:flex;align-items:center;gap:6px;padding:4px 10px;border-radius:20px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.06)}.vol-icon{font-size:16px;color:var(--text-faint);cursor:pointer;transition:color var(--transition);-webkit-user-select:none;user-select:none}.vol-icon:hover{color:var(--text-normal)}.vol-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:80px;height:3px;border-radius:2px;background:linear-gradient(to right,var(--accent) 0%,var(--accent) var(--vol, 80%),var(--bg-modifier-selected) var(--vol, 80%));outline:none;cursor:pointer}.vol-slider::-webkit-slider-thumb{-webkit-appearance:none;width:12px;height:12px;border-radius:50%;background:var(--accent);cursor:pointer;transition:transform var(--transition)}.vol-slider::-webkit-slider-thumb:hover{transform:scale(1.3)}.vol-slider::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:var(--accent);border:none;cursor:pointer}.vol-pct{font-size:11px;color:var(--text-faint);min-width:28px;text-align:right;font-variant-numeric:tabular-nums}.party-overlay{position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;z-index:50;opacity:0;transition:opacity .3s ease}.party-overlay.active{opacity:1;animation:party-hue 2s linear infinite}.party-overlay:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(45deg,#ff00000a,#00ff000a,#0000ff0a,#ffff000a);background-size:400% 400%;animation:party-grad 3s ease infinite}@keyframes party-grad{0%{background-position:0% 50%}50%{background-position:100% 50%}to{background-position:0% 50%}}@keyframes party-hue{to{filter:hue-rotate(360deg)}}.ctx-menu{position:fixed;min-width:160px;background:var(--bg-deep);border:1px solid rgba(255,255,255,.06);border-radius:var(--radius);box-shadow:var(--shadow-high);padding:4px;z-index:1000;animation:ctx-in .1s ease-out}@keyframes ctx-in{0%{opacity:0;transform:scale(.96) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.ctx-item{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:4px;font-size:13px;color:var(--text-normal);cursor:pointer;transition:all var(--transition)}.ctx-item:hover{background:var(--accent);color:var(--white)}.ctx-item.danger{color:var(--red)}.ctx-item.danger:hover{background:var(--red);color:var(--white)}.ctx-item .ctx-icon{font-size:15px}.ctx-sep{height:1px;background:#ffffff0f;margin:3px 8px}.toast{position:fixed;bottom:64px;left:50%;transform:translate(-50%);padding:10px 20px;border-radius:20px;font-size:13px;font-weight:600;z-index:100;display:flex;align-items:center;gap:8px;box-shadow:var(--shadow-high);animation:toast-in .3s cubic-bezier(.175,.885,.32,1.275);pointer-events:none}.toast .toast-icon{font-size:16px}.toast.error{background:var(--red);color:#fff}.toast.info{background:var(--green);color:#fff}@keyframes toast-in{0%{transform:translate(-50%,16px);opacity:0}to{transform:translate(-50%);opacity:1}}.admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);z-index:60;display:flex;align-items:center;justify-content:center;animation:fade-in .2s ease}.admin-panel{background:var(--bg-secondary);border:1px solid rgba(255,255,255,.08);border-radius:var(--radius-lg);padding:28px;width:92%;max-width:920px;max-height:min(88vh,860px);display:flex;flex-direction:column;box-shadow:var(--shadow-high)}.admin-panel h3{font-size:18px;font-weight:700;margin-bottom:16px;display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.admin-close{width:28px;height:28px;border-radius:6px;display:flex;align-items:center;justify-content:center;color:var(--text-muted);transition:all var(--transition)}.admin-close:hover{background:var(--bg-tertiary);color:var(--text-normal)}.admin-field{margin-bottom:16px}.admin-field label{display:block;font-size:12px;font-weight:600;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.admin-field input{width:100%;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:10px 12px;font-size:14px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-field input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}.admin-btn-action{padding:10px 20px;border-radius:8px;font-size:13px;font-weight:600;font-family:var(--font);cursor:pointer;transition:all var(--transition);line-height:1}.admin-btn-action.primary{background:var(--accent);color:#fff;border:none}.admin-btn-action.primary:hover{background:var(--accent-hover)}.admin-btn-action.outline{background:transparent;border:1px solid rgba(255,255,255,.08);color:var(--text-muted)}.admin-btn-action.outline:hover{border-color:#ffffff1f;color:var(--text-normal)}.admin-btn-action.danger{background:var(--red);color:var(--white);border:1px solid var(--red)}.admin-btn-action.danger:hover{filter:brightness(1.06)}.admin-btn-action.danger.ghost{background:transparent;color:var(--red);border:1px solid rgba(242,63,66,.5)}.admin-btn-action.danger.ghost:hover{background:#f23f4224}.admin-btn-action:disabled{opacity:.5;pointer-events:none}.admin-shell{display:flex;flex-direction:column;gap:12px;min-height:0}.admin-header-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.admin-status{font-size:13px;color:var(--text-muted)}.admin-actions-inline{display:flex;align-items:center;gap:8px}.admin-search-field{margin-bottom:0}.admin-bulk-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border-radius:10px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);flex-wrap:wrap}.admin-select-all{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted)}.admin-select-all input,.admin-item-check input{accent-color:var(--accent)}.admin-list-wrap{min-height:260px;max-height:52vh;overflow-y:auto;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:var(--bg-primary)}.admin-list{display:flex;flex-direction:column;gap:6px;padding:6px}.admin-empty{padding:24px 12px;text-align:center;color:var(--text-muted);font-size:13px}.admin-item{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:10px;border-radius:8px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.06)}.admin-item-main{min-width:0}.admin-item-name{font-size:14px;font-weight:600;color:var(--text-normal);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-meta{margin-top:3px;font-size:11px;color:var(--text-faint);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.admin-item-actions{display:flex;align-items:center;gap:6px}.admin-item-actions .admin-btn-action,.admin-rename-row .admin-btn-action{padding:8px 12px;font-size:12px}.admin-rename-row{display:flex;align-items:center;gap:6px;margin-top:8px}.admin-rename-row input{flex:1;min-width:120px;background:var(--bg-tertiary);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:8px 10px;font-size:13px;color:var(--text-normal);font-family:var(--font);transition:all var(--transition)}.admin-rename-row input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-glow)}@media(max-width:700px){.toolbar{gap:6px;padding:8px 12px}.cat-tabs{overflow-x:auto;scrollbar-width:none}.cat-tabs::-webkit-scrollbar{display:none}.search-wrap,.url-import-wrap{max-width:100%;min-width:100%;order:-1}.size-control,.theme-selector{display:none}.main{padding:12px}.topbar{padding:0 12px;gap:8px}.channel-label{max-width:100px;overflow:hidden;text-overflow:ellipsis}.clock{font-size:16px}.clock-seconds{font-size:11px}.tb-btn span:not(.tb-icon){display:none}.analytics-strip{padding:8px 12px;flex-direction:column;gap:6px}.analytics-card.analytics-wide{width:100%}.admin-panel{width:96%;padding:16px;max-height:92vh}.admin-item{grid-template-columns:24px minmax(0,1fr)}.admin-item-actions{grid-column:1 / -1;justify-content:flex-end}.admin-rename-row{flex-wrap:wrap}}@media(max-width:480px){.connection,.sb-app-title{display:none}.now-playing{max-width:none}.toolbar .tb-btn{padding:6px 8px}.url-import-btn{padding:0 8px}}.drop-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000c7;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);z-index:300;display:flex;align-items:center;justify-content:center;animation:fade-in .12s ease;pointer-events:none}.drop-zone{display:flex;flex-direction:column;align-items:center;gap:14px;padding:64px 72px;border-radius:24px;border:2.5px dashed rgba(var(--accent-rgb),.55);background:rgba(var(--accent-rgb),.07);animation:drop-pulse 2.2s ease-in-out infinite}@keyframes drop-pulse{0%,to{border-color:rgba(var(--accent-rgb),.45);box-shadow:0 0 rgba(var(--accent-rgb),0)}50%{border-color:rgba(var(--accent-rgb),.9);box-shadow:0 0 60px 12px rgba(var(--accent-rgb),.12)}}.drop-icon{font-size:64px;color:var(--accent);animation:drop-bounce 1.8s ease-in-out infinite}@keyframes drop-bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-8px)}}.drop-title{font-size:22px;font-weight:700;color:var(--text-normal);letter-spacing:-.3px}.drop-sub{font-size:13px;color:var(--text-muted)}.upload-queue{position:fixed;bottom:24px;right:24px;width:340px;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.09);border-radius:14px;box-shadow:0 8px 40px #00000073;z-index:200;animation:slide-up .2s cubic-bezier(.16,1,.3,1)}@keyframes slide-up{0%{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}.uq-header{display:flex;align-items:center;gap:8px;padding:12px 14px;background:rgba(var(--accent-rgb),.12);border-bottom:1px solid rgba(255,255,255,.06);font-size:13px;font-weight:600;color:var(--text-normal)}.uq-header .material-icons{color:var(--accent)}.uq-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition),color var(--transition)}.uq-close:hover{background:#ffffff24;color:var(--text-normal)}.uq-list{display:flex;flex-direction:column;max-height:260px;overflow-y:auto;padding:6px 0}.uq-item{display:grid;grid-template-columns:20px 1fr auto 18px;align-items:center;gap:8px;padding:8px 14px;position:relative}.uq-item+.uq-item{border-top:1px solid rgba(255,255,255,.04)}.uq-file-icon{font-size:18px;color:var(--text-faint)}.uq-info{min-width:0}.uq-name{font-size:12px;font-weight:500;color:var(--text-normal);white-space:nowrap;text-overflow:ellipsis}.uq-size{font-size:10px;color:var(--text-faint);margin-top:1px}.uq-progress-wrap{grid-column:1 / -1;height:3px;background:#ffffff12;border-radius:2px;margin-top:4px}.uq-item{flex-wrap:wrap}.uq-progress-wrap{width:100%;order:10}.uq-progress-bar{height:100%;background:var(--accent);border-radius:2px;transition:width .12s ease}.uq-status-icon{font-size:16px}.uq-status-waiting .uq-status-icon{color:var(--text-faint)}.uq-status-uploading .uq-status-icon{color:var(--accent);animation:spin 1s linear infinite}.uq-status-done .uq-status-icon{color:var(--green)}.uq-status-error .uq-status-icon{color:var(--red)}.uq-error{grid-column:2 / -1;font-size:10px;color:var(--red);margin-top:2px}.dl-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;display:flex;align-items:center;justify-content:center;z-index:300;animation:fade-in .15s ease}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.dl-modal{width:420px;max-width:92vw;background:var(--bg-secondary);border:1px solid rgba(255,255,255,.1);border-radius:16px;box-shadow:0 12px 60px #00000080;animation:scale-in .2s cubic-bezier(.16,1,.3,1)}@keyframes scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}.dl-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.06);font-size:14px;font-weight:700;color:var(--text-normal)}.dl-modal-header .material-icons{color:var(--accent)}.dl-modal-close{margin-left:auto;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;border:none;background:#ffffff0f;color:var(--text-muted);cursor:pointer;transition:background var(--transition)}.dl-modal-close:hover{background:#ffffff24;color:var(--text-normal)}.dl-modal-body{padding:16px;display:flex;flex-direction:column;gap:14px}.dl-modal-url{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:8px;background:#0003;overflow:hidden}.dl-modal-tag{flex-shrink:0;padding:2px 8px;border-radius:6px;font-size:10px;font-weight:800;letter-spacing:.5px;text-transform:uppercase}.dl-modal-tag.youtube{background:#ff00002e;color:#f44}.dl-modal-tag.instagram{background:#e1306c2e;color:#e1306c}.dl-modal-tag.mp3{background:#2ecc712e;color:#2ecc71}.dl-modal-url-text{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-modal-field{display:flex;flex-direction:column;gap:5px}.dl-modal-label{font-size:11px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.dl-modal-input-wrap{display:flex;align-items:center;border:1px solid rgba(255,255,255,.1);border-radius:8px;background:#00000026;overflow:hidden;transition:border-color var(--transition)}.dl-modal-input-wrap:focus-within{border-color:var(--accent)}.dl-modal-input{flex:1;border:none;background:transparent;padding:8px 10px;color:var(--text-normal);font-size:13px;font-family:var(--font);outline:none}.dl-modal-input::placeholder{color:var(--text-faint)}.dl-modal-ext{padding:0 10px;font-size:12px;font-weight:600;color:var(--text-faint);background:#ffffff0a;align-self:stretch;display:flex;align-items:center}.dl-modal-hint{font-size:10px;color:var(--text-faint)}.dl-modal-progress{display:flex;align-items:center;gap:12px;padding:20px 0;justify-content:center;font-size:13px;color:var(--text-muted)}.dl-modal-spinner{width:24px;height:24px;border-radius:50%;border:3px solid rgba(var(--accent-rgb),.2);border-top-color:var(--accent);animation:spin .8s linear infinite}.dl-modal-success{display:flex;align-items:center;gap:10px;padding:16px 0;justify-content:center;font-size:13px;color:var(--text-normal)}.dl-modal-check{color:#2ecc71;font-size:28px}.dl-modal-error{display:flex;align-items:center;gap:10px;padding:12px 0;justify-content:center;font-size:13px;color:#e74c3c}.dl-modal-actions{display:flex;justify-content:flex-end;gap:8px;padding:0 16px 14px}.dl-modal-cancel{padding:7px 14px;border-radius:8px;border:1px solid rgba(255,255,255,.1);background:transparent;color:var(--text-muted);font-size:12px;font-weight:600;cursor:pointer;transition:all var(--transition)}.dl-modal-cancel:hover{background:#ffffff0f;color:var(--text-normal)}.dl-modal-submit{display:flex;align-items:center;gap:5px;padding:7px 16px;border-radius:8px;border:none;background:var(--accent);color:#fff;font-size:12px;font-weight:700;cursor:pointer;transition:filter var(--transition)}.dl-modal-submit:hover{filter:brightness(1.15)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.lol-container{max-width:920px;margin:0 auto;padding:16px;height:100%;overflow-y:auto}.lol-search{display:flex;gap:8px;margin-bottom:12px}.lol-search-input{flex:1;min-width:0;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:15px;outline:none;transition:border-color .2s}.lol-search-input:focus{border-color:var(--accent)}.lol-search-input::placeholder{color:var(--text-faint)}.lol-search-region{padding:10px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none}.lol-search-btn{padding:10px 20px;border:none;border-radius:8px;background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:opacity .2s;white-space:nowrap}.lol-search-btn:hover{opacity:.85}.lol-search-btn:disabled{opacity:.4;cursor:not-allowed}.lol-recent{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:16px}.lol-recent-chip{display:flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;cursor:pointer;transition:border-color .2s,color .2s}.lol-recent-chip:hover{border-color:var(--accent);color:var(--text-normal)}.lol-recent-chip img{width:18px;height:18px;border-radius:50%}.lol-recent-tier{font-size:10px;font-weight:600;opacity:.7;text-transform:uppercase}.lol-profile{display:flex;align-items:center;gap:16px;padding:16px;border-radius:12px;background:var(--bg-secondary);margin-bottom:12px}.lol-profile-icon{width:72px;height:72px;border-radius:12px;border:2px solid var(--bg-tertiary);object-fit:cover}.lol-profile-info h2{margin:0 0 2px;font-size:20px;color:var(--text-normal)}.lol-profile-info h2 span{color:var(--text-faint);font-weight:400;font-size:14px}.lol-profile-level{font-size:12px;color:var(--text-muted)}.lol-profile-ladder{font-size:11px;color:var(--text-faint)}.lol-profile-updated{font-size:10px;color:var(--text-faint);margin-top:2px}.lol-profile-info{flex:1;min-width:0}.lol-update-btn{display:flex;align-items:center;gap:6px;padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-primary);color:var(--text-muted);font-size:13px;font-weight:500;cursor:pointer;transition:border-color .2s,color .2s,background .2s;white-space:nowrap;flex-shrink:0}.lol-update-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-update-btn:disabled{opacity:.6;cursor:not-allowed}.lol-update-btn.renewing{border-color:var(--accent);color:var(--accent)}.lol-update-icon{font-size:16px;display:inline-block}.lol-update-btn.renewing .lol-update-icon{animation:lol-spin 1s linear infinite}.lol-ranked-row{display:flex;gap:10px;margin-bottom:12px}.lol-ranked-card{flex:1;padding:12px 14px;border-radius:10px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary)}.lol-ranked-card.has-rank{border-left-color:var(--tier-color, var(--accent))}.lol-ranked-type{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}.lol-ranked-tier{font-size:18px;font-weight:700;color:var(--tier-color, var(--text-normal))}.lol-ranked-lp{font-size:13px;color:var(--text-muted);margin-left:4px;font-weight:400}.lol-ranked-record{font-size:12px;color:var(--text-muted);margin-top:2px}.lol-ranked-wr{color:var(--text-faint);margin-left:4px}.lol-ranked-streak{color:#e74c3c;font-size:11px;margin-left:4px}.lol-section-title{font-size:13px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px;margin:16px 0 8px;padding-left:2px}.lol-champs{display:flex;gap:8px;margin-bottom:12px;overflow-x:auto;padding-bottom:4px}.lol-champ-card{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:8px;background:var(--bg-secondary);min-width:180px;flex-shrink:0}.lol-champ-icon{width:36px;height:36px;border-radius:50%;object-fit:cover}.lol-champ-name{font-size:13px;font-weight:600;color:var(--text-normal)}.lol-champ-stats{font-size:11px;color:var(--text-muted)}.lol-champ-kda{font-size:11px;color:var(--text-faint)}.lol-matches{display:flex;flex-direction:column;gap:6px}.lol-match{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:8px;background:var(--bg-secondary);border-left:4px solid var(--bg-tertiary);cursor:pointer;transition:background .15s}.lol-match:hover{background:var(--bg-tertiary)}.lol-match.win{border-left-color:#2ecc71}.lol-match.loss{border-left-color:#e74c3c}.lol-match-result{width:28px;font-size:11px;font-weight:700;text-align:center;flex-shrink:0}.lol-match.win .lol-match-result{color:#2ecc71}.lol-match.loss .lol-match-result{color:#e74c3c}.lol-match-champ{position:relative;flex-shrink:0}.lol-match-champ img{width:40px;height:40px;border-radius:50%;display:block}.lol-match-champ-level{position:absolute;bottom:-2px;right:-2px;background:var(--bg-deep);color:var(--text-muted);font-size:9px;font-weight:700;width:16px;height:16px;border-radius:50%;display:flex;align-items:center;justify-content:center}.lol-match-kda{min-width:80px;text-align:center;flex-shrink:0}.lol-match-kda-nums{font-size:14px;font-weight:600;color:var(--text-normal)}.lol-match-kda-ratio{font-size:11px;color:var(--text-faint)}.lol-match-kda-ratio.perfect{color:#f39c12}.lol-match-kda-ratio.great{color:#2ecc71}.lol-match-stats{display:flex;flex-direction:column;gap:1px;min-width:70px;flex-shrink:0}.lol-match-stats span{font-size:11px;color:var(--text-muted)}.lol-match-items{display:flex;gap:2px;flex-shrink:0}.lol-match-items img,.lol-match-item-empty{width:24px;height:24px;border-radius:4px;background:var(--bg-deep)}.lol-match-meta{margin-left:auto;text-align:right;flex-shrink:0}.lol-match-duration{font-size:12px;color:var(--text-muted)}.lol-match-queue,.lol-match-ago{font-size:10px;color:var(--text-faint)}.lol-match-detail{background:var(--bg-primary);border-radius:8px;padding:8px;margin-top:4px;margin-bottom:4px}.lol-match-detail-team{margin-bottom:6px}.lol-match-detail-team-header{font-size:11px;font-weight:600;padding:4px 8px;border-radius:4px;margin-bottom:4px}.lol-match-detail-team-header.win{background:#2ecc7126;color:#2ecc71}.lol-match-detail-team-header.loss{background:#e74c3c26;color:#e74c3c}.lol-detail-row{display:flex;align-items:center;gap:8px;padding:3px 8px;border-radius:4px;font-size:12px;color:var(--text-muted)}.lol-detail-row:hover{background:var(--bg-secondary)}.lol-detail-row.me{background:#ffffff0a;font-weight:600}.lol-detail-champ{width:24px;height:24px;border-radius:50%}.lol-detail-name{width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-normal)}.lol-detail-kda{width:70px;text-align:center}.lol-detail-cs{width:45px;text-align:center}.lol-detail-dmg,.lol-detail-gold{width:55px;text-align:center}.lol-detail-items{display:flex;gap:1px}.lol-detail-items img{width:20px;height:20px;border-radius:3px}.lol-loading{display:flex;align-items:center;justify-content:center;gap:10px;padding:40px;color:var(--text-muted);font-size:14px}.lol-spinner{width:20px;height:20px;border:2px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:lol-spin .8s linear infinite}@keyframes lol-spin{to{transform:rotate(360deg)}}.lol-error{padding:16px;border-radius:8px;background:#e74c3c1a;color:#e74c3c;font-size:13px;text-align:center;margin-bottom:12px}.lol-empty{text-align:center;padding:60px 20px;color:var(--text-faint)}.lol-empty-icon{font-size:48px;margin-bottom:12px}.lol-empty h3{margin:0 0 8px;color:var(--text-muted);font-size:16px}.lol-empty p{margin:0;font-size:13px}.lol-load-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--bg-tertiary);border-radius:8px;background:transparent;color:var(--text-muted);font-size:13px;cursor:pointer;transition:border-color .2s,color .2s}.lol-load-more:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-section{margin-top:24px;padding-top:16px;border-top:1px solid var(--bg-tertiary)}.lol-tier-controls{display:flex;gap:8px;align-items:center;margin-bottom:12px;flex-wrap:wrap}.lol-tier-modes{display:flex;gap:4px;flex-wrap:wrap}.lol-tier-mode-btn{padding:6px 14px;border:1px solid var(--bg-tertiary);border-radius:16px;background:var(--bg-secondary);color:var(--text-muted);font-size:12px;font-weight:500;cursor:pointer;transition:all .2s;white-space:nowrap}.lol-tier-mode-btn:hover{border-color:var(--accent);color:var(--text-normal)}.lol-tier-mode-btn.active{background:var(--accent);border-color:var(--accent);color:#fff}.lol-tier-filter{padding:6px 12px;border:1px solid var(--bg-tertiary);border-radius:8px;background:var(--bg-secondary);color:var(--text-normal);font-size:12px;outline:none;width:140px;margin-left:auto}.lol-tier-filter:focus{border-color:var(--accent)}.lol-tier-filter::placeholder{color:var(--text-faint)}.lol-tier-table{display:flex;flex-direction:column;gap:2px}.lol-tier-header{display:flex;align-items:center;gap:8px;padding:6px 10px;font-size:10px;font-weight:600;color:var(--text-faint);text-transform:uppercase;letter-spacing:.5px}.lol-tier-row{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:6px;background:var(--bg-secondary);font-size:13px;color:var(--text-muted);transition:background .15s}.lol-tier-row:hover{background:var(--bg-tertiary)}.lol-tier-row.tier-0{border-left:3px solid #f4c874}.lol-tier-row.tier-1{border-left:3px solid #d4a017}.lol-tier-row.tier-2{border-left:3px solid #576cce}.lol-tier-row.tier-3{border-left:3px solid #28b29e}.lol-tier-row.tier-4{border-left:3px solid var(--bg-tertiary)}.lol-tier-row.tier-5{border-left:3px solid var(--bg-tertiary);opacity:.7}.lol-tier-col-rank{width:32px;text-align:center;font-weight:600;flex-shrink:0}.lol-tier-col-champ{flex:1;display:flex;align-items:center;gap:8px;min-width:0;font-weight:500;color:var(--text-normal)}.lol-tier-col-champ img{width:28px;height:28px;border-radius:50%;flex-shrink:0}.lol-tier-col-tier{width:36px;text-align:center;font-weight:700;font-size:12px;flex-shrink:0}.lol-tier-col-wr,.lol-tier-col-pr,.lol-tier-col-br{width:60px;text-align:center;flex-shrink:0}.lol-tier-col-kda{width:50px;text-align:center;flex-shrink:0}.tier-badge-0{color:#f4c874}.tier-badge-1{color:#d4a017}.tier-badge-2{color:#576cce}.tier-badge-3{color:#28b29e}.tier-badge-4,.tier-badge-5{color:var(--text-faint)}@media(max-width:640px){.lol-search{flex-wrap:wrap}.lol-search-input{width:100%}.lol-match{flex-wrap:wrap;gap:6px}.lol-match-meta{margin-left:0;text-align:left}.lol-match-items,.lol-profile{flex-wrap:wrap}.lol-tier-controls{flex-direction:column;align-items:stretch}.lol-tier-filter{width:100%;margin-left:0}.lol-tier-col-br,.lol-tier-col-kda{display:none}}.stream-container{height:100%;overflow-y:auto;padding:16px}.stream-topbar{display:flex;align-items:flex-end;gap:10px;margin-bottom:16px;flex-wrap:wrap}.stream-field{display:flex;flex-direction:column;gap:4px}.stream-field-grow{flex:1;min-width:180px}.stream-field-label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:var(--text-faint);padding-left:2px}.stream-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0;width:100%;box-sizing:border-box}.stream-input:focus{border-color:var(--accent)}.stream-input::placeholder{color:var(--text-faint)}.stream-input-name{width:150px}.stream-input-title{width:100%}.stream-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.stream-btn:hover{background:var(--accent-hover)}.stream-btn:disabled{opacity:.5;cursor:not-allowed}.stream-btn-stop{background:var(--danger)}.stream-btn-stop:hover{background:#c93b3e}.stream-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.stream-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.stream-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.stream-tile.own{border:2px solid var(--accent)}.stream-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.stream-tile-preview video{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover}.stream-tile-preview .stream-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.stream-live-badge{position:absolute;top:8px;left:8px;background:var(--danger);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;letter-spacing:.5px;display:flex;align-items:center;gap:4px}.stream-live-dot{width:6px;height:6px;border-radius:50%;background:#fff;animation:stream-pulse 1.5s ease-in-out infinite}@keyframes stream-pulse{0%,to{opacity:1}50%{opacity:.3}}.stream-tile-viewers{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.stream-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.stream-tile-meta{min-width:0;flex:1}.stream-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-title{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-tile-time{font-size:12px;color:var(--text-faint);white-space:nowrap}.stream-tile-menu-wrap{position:relative}.stream-tile-menu{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 6px;font-size:18px;line-height:1;border-radius:4px;transition:background var(--transition)}.stream-tile-menu:hover{background:var(--bg-tertiary);color:var(--text-normal)}.stream-tile-dropdown{position:absolute;bottom:calc(100% + 6px);right:0;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius-lg);min-width:220px;z-index:100;box-shadow:0 8px 24px #0006;overflow:hidden}.stream-tile-dropdown-header{padding:12px 14px}.stream-tile-dropdown-name{font-size:14px;font-weight:600;color:var(--text-normal)}.stream-tile-dropdown-title{font-size:12px;color:var(--text-muted);margin-top:2px}.stream-tile-dropdown-detail{font-size:11px;color:var(--text-faint);margin-top:6px}.stream-tile-dropdown-divider{height:1px;background:var(--bg-tertiary)}.stream-tile-dropdown-item{display:flex;align-items:center;gap:8px;width:100%;padding:10px 14px;border:none;background:none;color:var(--text-normal);font-size:13px;cursor:pointer;text-align:left;transition:background var(--transition)}.stream-tile-dropdown-item:hover{background:var(--bg-tertiary)}.stream-viewer-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.stream-viewer-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1}.stream-viewer-header-left{display:flex;align-items:center;gap:12px}.stream-viewer-title{font-weight:600;font-size:16px}.stream-viewer-subtitle{font-size:13px;color:var(--text-muted)}.stream-viewer-header-right{display:flex;align-items:center;gap:8px}.stream-viewer-fullscreen{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.stream-viewer-fullscreen:hover{background:#ffffff40}.stream-viewer-close{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.stream-viewer-close:hover{background:#fff3}.stream-viewer-video{flex:1;display:flex;align-items:center;justify-content:center;overflow:hidden}.stream-viewer-video video{max-width:100%;max-height:100%;width:100%;height:100%;object-fit:contain}.stream-viewer-connecting{color:var(--text-muted);font-size:16px;display:flex;flex-direction:column;align-items:center;gap:12px}.stream-viewer-spinner{width:32px;height:32px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:stream-spin .8s linear infinite}@keyframes stream-spin{to{transform:rotate(360deg)}}.stream-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.stream-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.stream-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.stream-empty p{font-size:14px}.stream-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.stream-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.stream-tile.broadcasting .stream-tile-preview{border:2px solid var(--danger);border-bottom:none}.stream-input-password{width:180px}.stream-select-quality{width:210px;box-sizing:border-box;padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;cursor:pointer;outline:none;transition:border-color var(--transition)}.stream-select-quality:focus{border-color:var(--accent)}.stream-select-quality:disabled{opacity:.5;cursor:not-allowed}.stream-select-quality option{background:var(--bg-secondary);color:var(--text-normal)}.stream-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.stream-pw-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.stream-pw-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.stream-pw-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.stream-pw-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.stream-pw-modal .stream-input{width:100%;margin-bottom:12px}.stream-pw-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.stream-pw-actions{display:flex;gap:8px;justify-content:flex-end}.stream-pw-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.stream-pw-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.stream-admin-btn{margin-left:auto;padding:8px;border:none;border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:18px;cursor:pointer;transition:all var(--transition);line-height:1}.stream-admin-btn:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;display:flex;align-items:center;justify-content:center;z-index:999;animation:fadeIn .15s ease}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.stream-admin-panel{background:var(--bg-secondary);border-radius:12px;width:560px;max-width:95vw;max-height:80vh;display:flex;flex-direction:column;box-shadow:0 8px 32px #0006;overflow:hidden}.stream-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-header h3{margin:0;font-size:16px;color:var(--text-normal)}.stream-admin-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:var(--radius)}.stream-admin-close:hover{color:var(--text-normal);background:var(--bg-tertiary)}.stream-admin-login{padding:24px 20px}.stream-admin-login p{margin:0 0 12px;color:var(--text-muted);font-size:14px}.stream-admin-login-row{display:flex;gap:8px}.stream-admin-login-row .stream-input{flex:1}.stream-admin-error{color:#ed4245;font-size:13px;margin-top:8px}.stream-admin-content{padding:16px 20px;overflow-y:auto}.stream-admin-toolbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;padding-bottom:12px;border-bottom:1px solid var(--bg-tertiary)}.stream-admin-status{font-size:13px;color:var(--text-muted)}.stream-admin-status b{color:var(--text-normal)}.stream-admin-logout{padding:4px 12px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);font-size:12px;cursor:pointer}.stream-admin-logout:hover{color:#ed4245;border-color:#ed4245}.stream-admin-loading,.stream-admin-empty{text-align:center;padding:32px 16px;color:var(--text-muted);font-size:14px}.stream-admin-hint{margin:0 0 12px;color:var(--text-muted);font-size:13px}.stream-admin-channel-list{display:flex;flex-direction:column;gap:8px;max-height:45vh;overflow-y:auto}.stream-admin-channel{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:var(--bg-deep);border-radius:var(--radius);gap:12px}.stream-admin-channel-info{display:flex;flex-direction:column;gap:2px;min-width:0}.stream-admin-channel-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.stream-admin-channel-guild{font-size:11px;color:var(--text-faint)}.stream-admin-channel-events{display:flex;gap:6px;flex-shrink:0}.stream-admin-event-toggle{display:flex;align-items:center;gap:4px;padding:4px 10px;border-radius:14px;font-size:12px;color:var(--text-muted);background:var(--bg-secondary);cursor:pointer;transition:all var(--transition);white-space:nowrap}.stream-admin-event-toggle input{display:none}.stream-admin-event-toggle:hover{color:var(--text-normal)}.stream-admin-event-toggle.active{background:var(--accent);color:#fff}.stream-admin-actions{margin-top:16px;display:flex;justify-content:flex-end}.stream-admin-save{padding:8px 24px}.wt-container{height:100%;overflow-y:auto;padding:16px}.wt-topbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}.wt-input{padding:10px 14px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);min-width:0}.wt-input:focus{border-color:var(--accent)}.wt-input::placeholder{color:var(--text-faint)}.wt-input-name{width:150px}.wt-input-room{flex:1;min-width:180px}.wt-input-password{width:170px}.wt-btn{padding:10px 20px;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;font-weight:600;font-size:14px;cursor:pointer;transition:background var(--transition);white-space:nowrap;display:flex;align-items:center;gap:6px}.wt-btn:hover{background:var(--accent-hover)}.wt-btn:disabled{opacity:.5;cursor:not-allowed}.wt-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.wt-tile{background:var(--bg-secondary);border-radius:var(--radius-lg);overflow:hidden;cursor:pointer;transition:transform var(--transition),box-shadow var(--transition);position:relative}.wt-tile:hover{transform:translateY(-2px);box-shadow:0 4px 20px #0006}.wt-tile-preview{position:relative;width:100%;padding-top:56.25%;background:var(--bg-deep);overflow:hidden}.wt-tile-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:48px;opacity:.3}.wt-tile-members{position:absolute;top:8px;right:8px;background:#0009;color:#fff;font-size:12px;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-lock{position:absolute;bottom:8px;right:8px;font-size:16px;opacity:.6}.wt-tile-playing{position:absolute;top:8px;left:8px;background:var(--accent);color:#fff;font-size:11px;font-weight:700;padding:2px 8px;border-radius:4px;display:flex;align-items:center;gap:4px}.wt-tile-info{padding:10px 12px;display:flex;align-items:center;justify-content:space-between;gap:8px}.wt-tile-meta{min-width:0;flex:1}.wt-tile-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-tile-host{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-empty{text-align:center;padding:60px 20px;color:var(--text-muted)}.wt-empty-icon{font-size:48px;margin-bottom:12px;opacity:.4}.wt-empty h3{font-size:18px;font-weight:600;color:var(--text-normal);margin-bottom:6px}.wt-empty p{font-size:14px}.wt-error{background:#ed42451f;color:var(--danger);padding:10px 14px;border-radius:var(--radius);font-size:14px;margin-bottom:12px;display:flex;align-items:center;gap:8px}.wt-error-dismiss{background:none;border:none;color:var(--danger);cursor:pointer;margin-left:auto;font-size:16px;padding:0 4px}.wt-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000000b3;display:flex;align-items:center;justify-content:center}.wt-modal{background:var(--bg-secondary);border-radius:var(--radius-lg);padding:24px;width:340px;max-width:90vw}.wt-modal h3{font-size:16px;font-weight:600;margin-bottom:4px}.wt-modal p{font-size:13px;color:var(--text-muted);margin-bottom:16px}.wt-modal .wt-input{width:100%;margin-bottom:12px}.wt-modal-error{color:var(--danger);font-size:13px;margin-bottom:8px}.wt-modal-actions{display:flex;gap:8px;justify-content:flex-end}.wt-modal-cancel{padding:8px 16px;border:1px solid var(--bg-tertiary);border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer;font-size:14px}.wt-modal-cancel:hover{color:var(--text-normal);border-color:var(--text-faint)}.wt-room-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;background:#000;display:flex;flex-direction:column}.wt-room-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:#000c;color:#fff;z-index:1;flex-shrink:0}.wt-room-header-left{display:flex;align-items:center;gap:12px}.wt-room-name{font-weight:600;font-size:16px}.wt-room-members{font-size:13px;color:var(--text-muted)}.wt-host-badge{font-size:11px;background:#ffffff1a;padding:2px 8px;border-radius:4px;color:var(--accent);font-weight:600}.wt-room-header-right{display:flex;align-items:center;gap:8px}.wt-fullscreen-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:background var(--transition)}.wt-fullscreen-btn:hover{background:#ffffff40}.wt-leave-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 16px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.wt-leave-btn:hover{background:#fff3}.wt-room-body{display:flex;flex:1;overflow:hidden}.wt-player-section{flex:1;display:flex;flex-direction:column;min-width:0}.wt-player-wrap{position:relative;width:100%;flex:1;background:#000;display:flex;align-items:center;justify-content:center;overflow:hidden}.wt-yt-container{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}.wt-yt-container iframe{width:100%;height:100%}.wt-video-element{width:100%;height:100%;object-fit:contain}.wt-dm-container{width:100%;height:100%;border:none;position:absolute;top:0;left:0}.wt-player-placeholder{display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--text-muted);font-size:16px}.wt-placeholder-icon{font-size:48px;opacity:.3}.wt-controls{display:flex;align-items:center;gap:12px;padding:12px 16px;background:#000c;flex-shrink:0}.wt-ctrl-btn{background:#ffffff1a;border:none;color:#fff;width:36px;height:36px;border-radius:var(--radius);cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;transition:background var(--transition);flex-shrink:0}.wt-ctrl-btn:hover:not(:disabled){background:#ffffff40}.wt-ctrl-btn:disabled{opacity:.3;cursor:not-allowed}.wt-ctrl-status{color:var(--text-muted);font-size:16px;width:36px;text-align:center;flex-shrink:0}.wt-seek{-webkit-appearance:none;-moz-appearance:none;appearance:none;flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer;min-width:60px}.wt-seek::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-seek::-webkit-slider-runnable-track{height:4px;border-radius:2px}.wt-seek::-moz-range-track{height:4px;border-radius:2px;background:var(--bg-tertiary)}.wt-seek-readonly{flex:1;height:4px;border-radius:2px;background:var(--bg-tertiary);position:relative;overflow:hidden;min-width:60px}.wt-seek-progress{position:absolute;top:0;left:0;height:100%;background:var(--accent);border-radius:2px;transition:width .3s linear}.wt-time{font-variant-numeric:tabular-nums;color:#fff;font-size:13px;white-space:nowrap;flex-shrink:0}.wt-volume{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.wt-volume-icon{font-size:16px;width:20px;text-align:center;cursor:default}.wt-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary);outline:none;cursor:pointer}.wt-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.wt-quality-select{background:var(--bg-secondary, #2a2a3e);color:var(--text-primary, #e0e0e0);border:1px solid var(--border-color, #3a3a4e);border-radius:6px;padding:2px 6px;font-size:12px;cursor:pointer;outline:none;margin-left:4px}.wt-quality-select:hover{border-color:var(--accent, #7c5cff)}.wt-queue-panel{width:280px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-queue-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-list{flex:1;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-queue-list::-webkit-scrollbar{width:4px}.wt-queue-list::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-queue-empty{padding:24px 16px;text-align:center;color:var(--text-faint);font-size:13px}.wt-queue-item{padding:10px 12px;border-bottom:1px solid var(--bg-tertiary);display:flex;align-items:center;gap:8px;transition:background var(--transition)}.wt-queue-item:hover{background:var(--bg-tertiary)}.wt-queue-item.playing{border-left:3px solid var(--accent);background:#e67e2214}.wt-queue-item-info{flex:1;min-width:0}.wt-queue-item-title{font-size:13px;font-weight:500;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wt-queue-item-by{font-size:11px;color:var(--text-faint);margin-top:2px}.wt-queue-item-remove{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:18px;padding:2px 6px;border-radius:4px;transition:all var(--transition);flex-shrink:0}.wt-queue-item-remove:hover{color:var(--danger);background:#ed42451f}.wt-queue-add{padding:12px;display:flex;gap:8px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-queue-input{flex:1;font-size:13px;padding:8px 10px}.wt-queue-add-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-player-error{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;background:#000000d9;color:#fff;z-index:2;text-align:center;padding:20px}.wt-error-icon{font-size:48px}.wt-player-error p{font-size:15px;color:var(--text-muted);margin:0}.wt-yt-link{display:inline-block;padding:8px 20px;background:red;color:#fff;border-radius:var(--radius);text-decoration:none;font-weight:600;font-size:14px;transition:background var(--transition)}.wt-yt-link:hover{background:#c00}.wt-skip-info{font-size:12px!important;color:var(--text-faint)!important;font-style:italic}.wt-queue-item.clickable{cursor:pointer}.wt-queue-item.clickable:hover{background:#e67e221f}@media(max-width:768px){.wt-room-body{flex-direction:column}.wt-queue-panel{width:100%;max-height:40vh;border-left:none;border-top:1px solid var(--bg-tertiary)}.wt-player-wrap{min-height:200px}.wt-controls{flex-wrap:wrap;gap:8px;padding:10px 12px}.wt-volume{margin-left:0}.wt-volume-slider{width:80px}.wt-room-header{padding:10px 12px}.wt-room-name{font-size:14px}.wt-room-members,.wt-host-badge{font-size:11px}}@media(max-width:480px){.wt-topbar{gap:8px}.wt-input-name{width:100%}.wt-input-room{min-width:0}.wt-input-password{width:100%}.wt-volume-slider{width:60px}.wt-time{font-size:12px}.wt-host-badge{display:none}}.wt-queue-item.watched{opacity:.55;transition:opacity var(--transition),background var(--transition)}.wt-queue-item.watched:hover{opacity:.85}.wt-queue-item-check{color:#2ecc71;font-size:16px;font-weight:700;flex-shrink:0;line-height:1}.wt-queue-item-info{display:flex;align-items:center;gap:10px;min-width:0;flex:1}.wt-queue-thumb{width:48px;height:36px;object-fit:cover;border-radius:4px;flex-shrink:0}.wt-queue-item-text{min-width:0;flex:1}.wt-next-btn{display:flex;align-items:center;gap:4px;font-size:13px;padding:6px 12px;white-space:nowrap}.wt-sync-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}.wt-sync-synced{background:#2ecc71;box-shadow:0 0 6px #2ecc7180}.wt-sync-drifting{background:#f1c40f;box-shadow:0 0 6px #f1c40f80}.wt-sync-desynced{background:#e74c3c;box-shadow:0 0 6px #e74c3c80}.wt-vote-btn{background:#ffffff14!important;border:1px solid rgba(255,255,255,.15)!important}.wt-vote-btn:hover:not(:disabled){background:#e67e2233!important;border-color:var(--accent)!important}.wt-vote-count{font-size:12px;color:var(--accent);font-weight:600;white-space:nowrap;padding:2px 8px;background:#e67e221f;border-radius:4px}.wt-header-btn{background:#ffffff1a;border:none;color:#fff;padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:13px;transition:background var(--transition)}.wt-header-btn:hover{background:#fff3}.wt-chat-panel{width:260px;background:var(--bg-secondary);border-left:1px solid var(--bg-tertiary);display:flex;flex-direction:column;flex-shrink:0}.wt-chat-header{padding:14px 16px;font-weight:600;font-size:14px;color:var(--text-normal);border-bottom:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-messages{flex:1;overflow-y:auto;padding:8px 12px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.wt-chat-messages::-webkit-scrollbar{width:4px}.wt-chat-messages::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:2px}.wt-chat-empty{padding:24px 8px;text-align:center;color:var(--text-faint);font-size:13px}.wt-chat-msg{margin-bottom:6px;font-size:13px;line-height:1.4;word-break:break-word}.wt-chat-sender{font-weight:600;color:var(--accent);margin-right:6px}.wt-chat-text{color:var(--text-normal)}.wt-chat-input-row{padding:10px 12px;display:flex;gap:6px;border-top:1px solid var(--bg-tertiary);flex-shrink:0}.wt-chat-input{flex:1;font-size:13px;padding:8px 10px}.wt-chat-send-btn{padding:8px 12px;font-size:13px;flex-shrink:0}.wt-queue-header{display:flex;align-items:center;justify-content:space-between}.wt-queue-clear-btn{background:none;border:none;color:var(--text-faint);font-size:11px;cursor:pointer;padding:2px 6px;border-radius:4px;transition:all var(--transition)}.wt-queue-clear-btn:hover{color:var(--danger);background:#ed42451f}.wt-tile-members-list{font-size:11px;color:var(--text-faint);padding:0 12px 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:768px){.wt-chat-panel{width:100%;max-height:30vh;border-left:none;border-top:1px solid var(--bg-tertiary)}}.gl-container{padding:20px;max-width:1200px;margin:0 auto}.gl-login-bar{display:flex;gap:10px;margin-bottom:12px}.gl-connect-btn{color:#c7d5e0;padding:10px 20px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:all var(--transition);white-space:nowrap}.gl-steam-btn{background:#1b2838;border:1px solid #2a475e}.gl-steam-btn:hover{background:#2a475e;color:#fff}.gl-gog-btn{background:#2c1a4e;border:1px solid #4a2d7a;color:#c7b3e8}.gl-gog-btn:hover{background:#3d2566;color:#fff}.gl-profile-chips{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}.gl-profile-chip{display:flex;align-items:center;gap:8px;padding:6px 12px;border-radius:20px;background:#ffffff0d;border:1px solid rgba(255,255,255,.1);cursor:pointer;transition:all .2s}.gl-profile-chip.selected{border-color:#e67e22;background:#e67e221a}.gl-profile-chip:hover{background:#ffffff1a}.gl-profile-chip-avatar{width:28px;height:28px;border-radius:50%}.gl-profile-chip-info{display:flex;flex-direction:column;gap:2px}.gl-profile-chip-name{font-size:13px;font-weight:600;color:#e0e0e0}.gl-profile-chip-platforms{display:flex;gap:4px}.gl-profile-chip-count{font-size:11px;color:#667}.gl-platform-badge{font-size:9px;font-weight:700;padding:1px 5px;border-radius:3px;text-transform:uppercase}.gl-platform-badge.steam{background:#1b2838cc;color:#66c0f4;border:1px solid #2a475e}.gl-platform-badge.gog{background:#2c1a4ecc;color:#b388ff;border:1px solid #4a2d7a}.gl-game-platform-icon{font-size:9px;font-weight:700;padding:1px 4px;border-radius:3px;margin-right:6px;flex-shrink:0}.gl-game-platform-icon.steam{background:#1b283899;color:#66c0f4}.gl-game-platform-icon.gog{background:#2c1a4e99;color:#b388ff}.gl-users-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;margin-bottom:32px}.gl-user-card{background:var(--bg-secondary);border-radius:var(--radius);padding:16px;display:flex;flex-direction:column;align-items:center;gap:10px;cursor:pointer;transition:all var(--transition);border:1px solid var(--bg-tertiary)}.gl-user-card:hover{border-color:var(--accent);transform:translateY(-2px)}.gl-user-card-avatar{width:64px;height:64px;border-radius:50%}.gl-user-card-name{font-weight:600;font-size:15px;color:var(--text-normal)}.gl-user-card-games{font-size:13px;color:var(--text-faint)}.gl-user-card-updated{font-size:11px;color:var(--text-faint)}.gl-profile-card-platforms{display:flex;gap:6px;margin-top:4px}.gl-common-finder{background:var(--bg-secondary);border-radius:var(--radius);padding:20px;margin-bottom:24px}.gl-common-finder h3{margin:0 0 12px;font-size:15px;color:var(--text-normal)}.gl-common-users{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}.gl-common-check{display:flex;align-items:center;gap:6px;background:var(--bg-tertiary);padding:6px 12px 6px 6px;border-radius:20px;cursor:pointer;transition:all var(--transition)}.gl-common-check.checked{background:#e67e2226}.gl-common-check input{accent-color:var(--accent)}.gl-common-check-avatar{width:24px;height:24px;border-radius:50%}.gl-common-find-btn{background:var(--accent);color:#fff;border:none;padding:10px 24px;border-radius:var(--radius);cursor:pointer;font-weight:600;transition:background var(--transition)}.gl-common-find-btn:hover{filter:brightness(1.1)}.gl-common-find-btn:disabled{opacity:.5;cursor:not-allowed}.gl-search{margin-bottom:24px}.gl-search-input{width:100%;padding:10px 14px;background:var(--bg-secondary);border:1px solid var(--bg-tertiary);border-radius:var(--radius);color:var(--text-normal);font-size:14px;outline:none;transition:border-color var(--transition);box-sizing:border-box}.gl-search-input:focus{border-color:var(--accent)}.gl-search-input::placeholder{color:var(--text-faint)}.gl-game-list{display:flex;flex-direction:column;gap:4px}.gl-game-item{display:flex;align-items:center;gap:12px;padding:8px 12px;background:var(--bg-secondary);border-radius:var(--radius);transition:background var(--transition)}.gl-game-item:hover{background:var(--bg-tertiary)}.gl-game-icon{width:32px;height:32px;border-radius:4px;flex-shrink:0;background:var(--bg-tertiary)}.gl-game-name{flex:1;font-size:14px;color:var(--text-normal)}.gl-game-playtime{font-size:12px;color:var(--text-faint);white-space:nowrap}.gl-game-owners{display:flex;gap:4px}.gl-game-owner-avatar{width:20px;height:20px;border-radius:50%;border:1px solid var(--bg-tertiary)}.gl-detail-header{display:flex;align-items:center;gap:16px;margin-bottom:24px}.gl-back-btn{background:var(--bg-secondary);border:none;color:var(--text-normal);padding:8px 14px;border-radius:var(--radius);cursor:pointer;font-size:14px;transition:background var(--transition)}.gl-back-btn:hover{background:var(--bg-tertiary)}.gl-detail-avatar{width:48px;height:48px;border-radius:50%}.gl-detail-info{flex:1}.gl-detail-name{font-size:18px;font-weight:600;color:var(--text-normal)}.gl-detail-sub{font-size:13px;color:var(--text-faint);display:flex;align-items:center;gap:6px;margin-top:4px}.gl-refresh-btn{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:16px;padding:4px;transition:color var(--transition)}.gl-refresh-btn:hover{color:var(--accent)}.gl-platform-detail{display:inline-flex;align-items:center;gap:2px}.gl-disconnect-btn{background:none;border:none;color:#666;cursor:pointer;font-size:10px;padding:0 3px;line-height:1;border-radius:3px;transition:all .2s}.gl-disconnect-btn:hover{color:#e74c3c;background:#e74c3c26}.gl-link-gog-btn{background:#a855f726;color:#a855f7;border:1px solid rgba(168,85,247,.3);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-link-gog-btn:hover{background:#a855f740}.gl-loading{text-align:center;padding:48px;color:var(--text-faint);font-size:14px}.gl-empty{text-align:center;padding:60px 20px}.gl-empty-icon{font-size:48px;margin-bottom:16px}.gl-empty h3{color:var(--text-normal);margin:0 0 8px}.gl-empty p{color:var(--text-faint);margin:0;font-size:14px}.gl-common-playtimes{display:flex;gap:8px;flex-wrap:wrap}.gl-common-pt{font-size:11px;color:var(--text-faint);background:var(--bg-tertiary);padding:2px 8px;border-radius:4px}.gl-section-title{font-size:14px;font-weight:600;color:var(--text-normal);margin:0 0 12px}.gl-game-count{font-size:12px;color:var(--text-faint);margin-left:8px;font-weight:400}.gl-detail-avatars{display:flex;gap:-8px}.gl-detail-avatars img{width:36px;height:36px;border-radius:50%;border:2px solid var(--bg-primary);margin-left:-8px}.gl-detail-avatars img:first-child{margin-left:0}.gl-search-results-title{font-size:13px;color:var(--text-faint);margin-bottom:8px}.gl-game-item.enriched{align-items:flex-start;min-height:60px}.gl-game-visual{flex-shrink:0}.gl-game-cover{width:45px;height:64px;object-fit:cover;border-radius:4px}.gl-game-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.gl-game-genres{display:flex;flex-wrap:wrap;gap:4px}.gl-genre-tag{font-size:10px;padding:1px 6px;border-radius:3px;background:#e67e2226;color:#e67e22}.gl-game-platforms{font-size:10px;color:var(--text-muted, #888)}.gl-platform-tag{margin-left:4px;padding:1px 5px;border-radius:3px;background:#3498db26;color:#3498db}.gl-game-meta{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}.gl-game-rating{font-size:11px;font-weight:700;padding:2px 6px;border-radius:4px;min-width:28px;text-align:center}.gl-game-rating.high{background:#2ecc7133;color:#2ecc71}.gl-game-rating.mid{background:#f1c40f33;color:#f1c40f}.gl-game-rating.low{background:#e74c3c33;color:#e74c3c}.gl-enrich-btn{background:#3498db26;border:1px solid rgba(52,152,219,.3);color:#3498db;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;transition:all .2s}.gl-enrich-btn:hover:not(:disabled){background:#3498db40}.gl-enrich-btn:disabled{opacity:.5;cursor:not-allowed}.gl-enrich-btn.enriching{animation:gl-pulse 1.5s ease-in-out infinite}@keyframes gl-pulse{0%,to{opacity:.5}50%{opacity:1}}.gl-filter-bar{display:flex;align-items:center;gap:10px;margin-bottom:8px}.gl-filter-bar .gl-search-input{flex:1}.gl-sort-select{background:#ffffff0f;color:#c7d5e0;border:1px solid rgba(255,255,255,.1);padding:10px 12px;border-radius:var(--radius);font-size:13px;cursor:pointer;min-width:120px}.gl-sort-select:focus{outline:none;border-color:#ffffff40}.gl-sort-select option{background:#1a1a2e;color:#c7d5e0}.gl-genre-filters{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px;padding:8px 0}.gl-genre-chip{background:#ffffff0f;color:#8899a6;border:1px solid rgba(255,255,255,.08);padding:5px 12px;border-radius:20px;font-size:12px;cursor:pointer;transition:all .2s;white-space:nowrap}.gl-genre-chip:hover{background:#ffffff1a;color:#c7d5e0}.gl-genre-chip.active{background:#e67e2233;color:#e67e22;border-color:#e67e2266}.gl-genre-chip.active.clear{background:#3498db33;color:#3498db;border-color:#3498db66}.gl-filter-count{color:#556;font-size:12px;margin:0 0 8px}@media(max-width:768px){.gl-container{padding:12px}.gl-users-grid{grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}.gl-login-bar{flex-direction:column}}.gl-dialog-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;display:flex;align-items:center;justify-content:center;z-index:1000;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.gl-dialog{background:#2a2a3e;border-radius:12px;padding:24px;max-width:500px;width:90%;box-shadow:0 8px 32px #00000080}.gl-dialog h3{margin:0 0 12px;font-size:1.2rem;color:#fff}.gl-dialog-hint{font-size:.85rem;color:#aaa;margin-bottom:14px;line-height:1.5}.gl-dialog-input{width:100%;padding:10px 12px;background:#1a1a2e;border:1px solid #444;border-radius:8px;color:#fff;font-size:.9rem;outline:none;transition:border-color .2s}.gl-dialog-input:focus{border-color:#a855f7}.gl-dialog-status{margin-top:8px;font-size:.85rem;padding:6px 10px;border-radius:6px}.gl-dialog-status.loading{color:#a855f7}.gl-dialog-status.success{color:#4caf50}.gl-dialog-status.error{color:#e74c3c}.gl-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px}.gl-dialog-cancel{padding:8px 18px;background:#3a3a4e;color:#ccc;border:none;border-radius:8px;cursor:pointer;font-size:.9rem}.gl-dialog-cancel:hover{background:#4a4a5e}.gl-dialog-submit{padding:8px 18px;background:#a855f7;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:.9rem;font-weight:600}.gl-dialog-submit:hover:not(:disabled){background:#9333ea}.gl-dialog-submit:disabled{opacity:.5;cursor:not-allowed}.gl-login-bar-spacer{flex:1}.gl-admin-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#888;padding:8px 12px;border-radius:var(--radius);cursor:pointer;font-size:16px;transition:all .2s}.gl-admin-btn:hover{background:#ffffff1a;color:#ccc}.gl-admin-panel{background:#2a2a3e;border-radius:12px;padding:0;max-width:600px;width:92%;box-shadow:0 8px 32px #00000080;max-height:80vh;display:flex;flex-direction:column}.gl-admin-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid rgba(255,255,255,.08)}.gl-admin-header h3{margin:0;font-size:1.1rem;color:#fff}.gl-admin-close{background:none;border:none;color:#888;font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px}.gl-admin-close:hover{color:#fff;background:#ffffff1a}.gl-admin-login{padding:20px}.gl-admin-login p{color:#aaa;margin:0 0 12px;font-size:14px}.gl-admin-login-row{display:flex;gap:8px}.gl-admin-login-btn{background:#e67e22;color:#fff;border:none;padding:10px 20px;border-radius:8px;cursor:pointer;font-weight:600;white-space:nowrap}.gl-admin-login-btn:hover{background:#d35400}.gl-admin-content{padding:0;overflow-y:auto}.gl-admin-toolbar{display:flex;align-items:center;gap:10px;padding:12px 20px;border-bottom:1px solid rgba(255,255,255,.06)}.gl-admin-status-text{font-size:13px;color:#4caf50;flex:1}.gl-admin-refresh-btn,.gl-admin-logout-btn{background:#ffffff0f;border:1px solid rgba(255,255,255,.1);color:#aaa;padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;transition:all .2s}.gl-admin-refresh-btn:hover{background:#ffffff1a;color:#fff}.gl-admin-logout-btn:hover{background:#e74c3c26;color:#e74c3c;border-color:#e74c3c4d}.gl-admin-list{padding:8px 12px}.gl-admin-item{display:flex;align-items:center;gap:12px;padding:10px 8px;border-bottom:1px solid rgba(255,255,255,.04);transition:background .15s}.gl-admin-item:last-child{border-bottom:none}.gl-admin-item:hover{background:#ffffff08}.gl-admin-item-avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0}.gl-admin-item-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.gl-admin-item-name{font-size:14px;font-weight:600;color:#e0e0e0}.gl-admin-item-details{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.gl-admin-item-total{font-size:11px;color:#667}.gl-admin-delete-btn{background:#e74c3c1a;color:#e74c3c;border:1px solid rgba(231,76,60,.2);padding:6px 12px;border-radius:6px;cursor:pointer;font-size:12px;font-weight:600;white-space:nowrap;transition:all .2s;flex-shrink:0}.gl-admin-delete-btn:hover{background:#e74c3c40;border-color:#e74c3c66}:root{--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--success: #57d28f;--danger: #ed4245;--warning: #fee75c;--border: rgba(255, 255, 255, .06);--radius: 8px;--radius-lg: 12px;--transition: .15s ease;--font: "Segoe UI", system-ui, -apple-system, sans-serif;--header-height: 56px}*,*:before,*:after{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;font-family:var(--font);font-size:15px;color:var(--text-normal);background:var(--bg-deep);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;overflow:hidden}#root{height:100%}.hub-app{display:flex;flex-direction:column;height:100vh;overflow:hidden}.hub-header{position:sticky;top:0;z-index:100;display:flex;align-items:center;height:var(--header-height);min-height:var(--header-height);padding:0 16px;background:var(--bg-primary);border-bottom:1px solid var(--border);gap:16px}.hub-header-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.hub-logo{font-size:24px;line-height:1}.hub-title{font-size:18px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em;white-space:nowrap}.hub-conn-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);flex-shrink:0;transition:background var(--transition);box-shadow:0 0 0 2px #ed424540}.hub-conn-dot.online{background:var(--success);box-shadow:0 0 0 2px #57d28f40;animation:pulse-dot 2s ease-in-out infinite}@keyframes pulse-dot{0%,to{box-shadow:0 0 0 2px #57d28f40}50%{box-shadow:0 0 0 6px #57d28f1a}}.hub-tabs{display:flex;align-items:center;gap:4px;flex:1;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;padding:0 4px}.hub-tabs::-webkit-scrollbar{display:none}.hub-tab{display:flex;align-items:center;gap:6px;padding:8px 14px;border:none;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:var(--radius);white-space:nowrap;transition:all var(--transition);position:relative;-webkit-user-select:none;user-select:none}.hub-tab:hover{color:var(--text-normal);background:var(--bg-secondary)}.hub-tab.active{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-tab.active:after{content:"";position:absolute;bottom:-1px;left:50%;transform:translate(-50%);width:calc(100% - 16px);height:2px;background:var(--accent);border-radius:1px}.hub-tab-icon{font-size:16px;line-height:1}.hub-tab-label{text-transform:capitalize}.hub-header-right{display:flex;align-items:center;gap:12px;flex-shrink:0}.hub-download-btn{display:flex;align-items:center;gap:6px;padding:4px 10px;font-size:12px;font-weight:500;font-family:var(--font);text-decoration:none;color:var(--text-muted);background:var(--bg-secondary);border-radius:var(--radius);cursor:pointer;transition:all var(--transition);white-space:nowrap}.hub-download-btn:hover{color:var(--accent);background:rgba(var(--accent-rgb),.1)}.hub-download-icon{font-size:14px;line-height:1}.hub-download-label{line-height:1}.hub-version{font-size:12px;color:var(--text-faint);font-weight:500;font-variant-numeric:tabular-nums;background:var(--bg-secondary);padding:4px 8px;border-radius:4px}.hub-check-update-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-secondary);font-size:14px;padding:2px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-check-update-btn:hover:not(:disabled){color:var(--accent);border-color:var(--accent)}.hub-check-update-btn:disabled{opacity:.4;cursor:default}.hub-update-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-update-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:32px 40px;text-align:center;min-width:320px;max-width:400px;box-shadow:0 8px 32px #00000080}.hub-update-icon{font-size:40px;margin-bottom:12px}.hub-update-modal h2{margin:0 0 8px;font-size:18px;color:var(--text-primary)}.hub-update-modal p{margin:0 0 20px;font-size:14px;color:var(--text-secondary)}.hub-update-progress{height:4px;border-radius:2px;background:var(--bg-deep);overflow:hidden}.hub-update-progress-bar{height:100%;width:40%;border-radius:2px;background:var(--accent);animation:hub-update-slide 1.5s ease-in-out infinite}@keyframes hub-update-slide{0%{transform:translate(-100%)}to{transform:translate(350%)}}.hub-update-btn{padding:8px 32px;font-size:14px;font-weight:600;border:none;border-radius:var(--radius);background:var(--accent);color:#fff;cursor:pointer;transition:opacity var(--transition)}.hub-update-btn:hover{opacity:.85}.hub-update-btn-secondary{background:var(--bg-tertiary);color:var(--text-secondary);margin-top:4px}.hub-update-versions{display:flex;flex-direction:column;gap:2px;margin:8px 0;font-size:12px;color:var(--text-muted)}.hub-update-error-detail{font-size:11px;color:#ef4444;background:#ef44441a;border-radius:var(--radius);padding:6px 10px;word-break:break-word;max-width:300px}.hub-refresh-btn{background:none;border:none;color:var(--text-muted);font-size:1rem;cursor:pointer;padding:4px 6px;border-radius:var(--radius);transition:all var(--transition);line-height:1}.hub-refresh-btn:hover{color:var(--accent);background:#e67e221a}.hub-admin-btn{background:none;border:1px solid var(--border);border-radius:var(--radius);color:var(--text-muted);font-size:16px;padding:4px 8px;cursor:pointer;transition:all var(--transition);line-height:1}.hub-admin-btn:hover{color:var(--accent);border-color:var(--accent)}.hub-admin-btn.active{color:#4ade80;border-color:#4ade80}.hub-admin-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-admin-modal{background:var(--bg-card);border:1px solid var(--border);border-radius:12px;width:340px;box-shadow:0 8px 32px #00000080}.hub-admin-modal-header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--border);font-weight:600}.hub-admin-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:16px}.hub-admin-modal-close:hover{color:var(--text)}.hub-admin-modal-body{padding:20px;display:flex;flex-direction:column;gap:12px}.hub-admin-input{width:100%;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text);font-size:14px;font-family:var(--font);box-sizing:border-box}.hub-admin-input:focus{outline:none;border-color:var(--accent)}.hub-admin-error{color:#ef4444;font-size:13px;margin:0}.hub-admin-submit{padding:8px 16px;background:var(--accent);color:#fff;border:none;border-radius:var(--radius);font-size:14px;font-weight:500;cursor:pointer;transition:opacity var(--transition)}.hub-admin-submit:hover{opacity:.9}.hub-version-clickable{cursor:pointer;transition:all var(--transition);padding:2px 8px;border-radius:var(--radius)}.hub-version-clickable:hover{color:var(--accent);background:#e67e221a}.hub-version-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.hub-version-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:hub-modal-in .2s ease}@keyframes hub-modal-in{0%{opacity:0;transform:scale(.95) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}.hub-version-modal-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.hub-version-modal-close{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.hub-version-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.hub-version-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.hub-version-modal-row{display:flex;justify-content:space-between;align-items:center}.hub-version-modal-label{color:var(--text-muted);font-size:13px}.hub-version-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.hub-version-modal-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);flex-shrink:0}.hub-version-modal-dot.online{background:var(--success)}.hub-version-modal-link{color:var(--accent);text-decoration:none;font-weight:500;font-size:13px}.hub-version-modal-link:hover{text-decoration:underline}.hub-version-modal-hint{font-size:11px;color:var(--accent);padding:6px 10px;background:#e67e221a;border-radius:var(--radius);text-align:center}.hub-version-modal-update{margin-top:4px;padding-top:12px;border-top:1px solid var(--border)}.hub-version-modal-update-btn{width:100%;padding:10px 16px;border:none;border-radius:var(--radius);background:var(--bg-tertiary);color:var(--text-normal);font-size:13px;font-weight:600;cursor:pointer;transition:all var(--transition);display:flex;align-items:center;justify-content:center;gap:8px}.hub-version-modal-update-btn:hover{background:var(--bg-hover);color:var(--accent)}.hub-version-modal-update-btn.ready{background:#2ecc7126;color:#2ecc71}.hub-version-modal-update-btn.ready:hover{background:#2ecc7140}.hub-version-modal-update-status{display:flex;align-items:center;justify-content:center;gap:8px;font-size:13px;color:var(--text-muted);padding:8px 0;flex-wrap:wrap}.hub-version-modal-update-status.success{color:#2ecc71}.hub-version-modal-update-status.error{color:#e74c3c}.hub-version-modal-update-retry{background:none;border:none;color:var(--text-muted);font-size:11px;cursor:pointer;text-decoration:underline;padding:2px 4px;width:100%;margin-top:4px}.hub-version-modal-update-retry:hover{color:var(--text-normal)}@keyframes hub-spin{to{transform:rotate(360deg)}}.hub-update-spinner{width:14px;height:14px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:hub-spin .8s linear infinite;flex-shrink:0}.hub-content{flex:1;overflow-y:auto;overflow-x:hidden;background:var(--bg-deep);scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.hub-content::-webkit-scrollbar{width:6px}.hub-content::-webkit-scrollbar-track{background:transparent}.hub-content::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.hub-content::-webkit-scrollbar-thumb:hover{background:var(--text-faint)}.hub-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px;text-align:center;padding:32px;animation:fade-in .3s ease}.hub-empty-icon{font-size:64px;line-height:1;margin-bottom:20px;opacity:.6;filter:grayscale(30%)}.hub-empty h2{font-size:22px;font-weight:700;color:var(--text-normal);margin-bottom:8px}.hub-empty p{font-size:15px;color:var(--text-muted);max-width:360px;line-height:1.5}@keyframes fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}::selection{background:rgba(var(--accent-rgb),.3);color:var(--text-normal)}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(max-width:768px){:root{--header-height: 48px}.hub-header{padding:0 10px;gap:8px}.hub-title{font-size:15px}.hub-logo{font-size:20px}.hub-tab{padding:6px 10px;font-size:13px;gap:4px}.hub-tab-label{display:none}.hub-tab-icon{font-size:18px}.hub-version{font-size:11px}.hub-empty-icon{font-size:48px}.hub-empty h2{font-size:18px}.hub-empty p{font-size:14px}}@media(max-width:480px){.hub-header-right{display:none}.hub-header{padding:0 8px;gap:6px}.hub-title{font-size:14px}}.radio-container{display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;background:var(--bg-deep);--bg-deep: #1a1b1e;--bg-primary: #1e1f22;--bg-secondary: #2b2d31;--bg-tertiary: #313338;--text-normal: #dbdee1;--text-muted: #949ba4;--text-faint: #6d6f78;--accent: #e67e22;--accent-rgb: 230, 126, 34;--accent-hover: #d35400;--border: rgba(255, 255, 255, .06)}.radio-container[data-theme=purple]{--bg-deep: #13111c;--bg-primary: #1a1726;--bg-secondary: #241f35;--bg-tertiary: #2e2845;--accent: #9b59b6;--accent-rgb: 155, 89, 182;--accent-hover: #8e44ad}.radio-container[data-theme=forest]{--bg-deep: #0f1a14;--bg-primary: #142119;--bg-secondary: #1c2e22;--bg-tertiary: #253a2c;--accent: #2ecc71;--accent-rgb: 46, 204, 113;--accent-hover: #27ae60}.radio-container[data-theme=ocean]{--bg-deep: #0a1628;--bg-primary: #0f1e33;--bg-secondary: #162a42;--bg-tertiary: #1e3652;--accent: #3498db;--accent-rgb: 52, 152, 219;--accent-hover: #2980b9}.radio-container[data-theme=cherry]{--bg-deep: #1a0f14;--bg-primary: #22141a;--bg-secondary: #301c25;--bg-tertiary: #3e2530;--accent: #e74c6f;--accent-rgb: 231, 76, 111;--accent-hover: #c0392b}.radio-topbar{display:flex;align-items:center;padding:0 16px;height:52px;background:var(--bg-secondary, #2b2d31);border-bottom:1px solid rgba(0,0,0,.24);z-index:10;flex-shrink:0;gap:16px}.radio-topbar-left{display:flex;align-items:center;gap:10px;flex-shrink:0}.radio-topbar-logo{font-size:20px}.radio-topbar-title{font-size:16px;font-weight:700;color:var(--text-normal);letter-spacing:-.02em}.radio-topbar-np{flex:1;display:flex;align-items:center;gap:10px;min-width:0;justify-content:center}.radio-topbar-right{display:flex;align-items:center;gap:6px;flex-shrink:0;margin-left:auto}.radio-topbar-stop{display:flex;align-items:center;gap:4px;background:var(--danger);color:#fff;border:none;border-radius:var(--radius);padding:6px 14px;font-size:13px;font-family:var(--font);font-weight:600;cursor:pointer;transition:all var(--transition);flex-shrink:0}.radio-topbar-stop:hover{background:#c63639}.radio-theme-inline{display:flex;align-items:center;gap:4px;margin-left:4px}.radio-globe-wrap{position:relative;flex:1;overflow:hidden}.radio-globe{width:100%;height:100%}.radio-globe canvas{outline:none!important}.radio-search{position:absolute;top:16px;left:50%;transform:translate(-50%);z-index:20;width:min(440px,calc(100% - 32px))}.radio-search-wrap{display:flex;align-items:center;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);padding:0 14px;gap:8px;box-shadow:0 8px 32px #0006}.radio-search-icon{font-size:16px;opacity:.6;flex-shrink:0}.radio-search-input{flex:1;background:transparent;border:none;color:var(--text-normal);font-family:var(--font);font-size:14px;padding:12px 0;outline:none}.radio-search-input::placeholder{color:var(--text-faint)}.radio-search-clear{background:none;border:none;color:var(--text-muted);font-size:14px;cursor:pointer;padding:4px;border-radius:4px;transition:color var(--transition)}.radio-search-clear:hover{color:var(--text-normal)}.radio-search-results{margin-top:6px;background:#1e1f22f2;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);max-height:360px;overflow-y:auto;box-shadow:0 12px 40px #00000080;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-search-result{display:flex;align-items:center;gap:10px;width:100%;padding:10px 14px;background:none;border:none;border-bottom:1px solid var(--border);color:var(--text-normal);font-family:var(--font);font-size:14px;cursor:pointer;text-align:left;transition:background var(--transition)}.radio-search-result:last-child{border-bottom:none}.radio-search-result:hover{background:rgba(var(--accent-rgb),.08)}.radio-search-result-icon{font-size:18px;flex-shrink:0}.radio-search-result-text{display:flex;flex-direction:column;gap:2px;min-width:0}.radio-search-result-title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-search-result-sub{font-size:12px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-fab{position:absolute;top:16px;right:16px;z-index:20;display:flex;align-items:center;gap:4px;padding:10px 14px;background:#1e1f22eb;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:var(--radius-lg);color:var(--text-normal);font-size:16px;cursor:pointer;box-shadow:0 8px 32px #0006;transition:all var(--transition)}.radio-fab:hover,.radio-fab.active{background:rgba(var(--accent-rgb),.15);border-color:rgba(var(--accent-rgb),.3)}.radio-fab-badge{font-size:11px;font-weight:700;background:var(--accent);color:#fff;padding:1px 6px;border-radius:10px;min-width:18px;text-align:center}.radio-panel{position:absolute;top:0;right:0;width:340px;height:100%;z-index:15;background:#1e1f22f2;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);border-left:1px solid var(--border);display:flex;flex-direction:column;animation:slide-in-right .2s ease;box-shadow:-8px 0 32px #0000004d}@keyframes slide-in-right{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}.radio-panel-header{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--border);flex-shrink:0}.radio-panel-header h3{font-size:16px;font-weight:700;color:var(--text-normal)}.radio-panel-sub{font-size:12px;color:var(--text-muted);display:block;margin-top:2px}.radio-panel-close{background:none;border:none;color:var(--text-muted);font-size:18px;cursor:pointer;padding:4px 8px;border-radius:4px;transition:all var(--transition)}.radio-panel-close:hover{color:var(--text-normal);background:var(--bg-secondary)}.radio-panel-body{flex:1;overflow-y:auto;padding:8px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.radio-panel-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:14px}.radio-panel-loading{display:flex;flex-direction:column;align-items:center;gap:12px;padding:40px 16px;color:var(--text-muted);font-size:14px}.radio-station{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);transition:background var(--transition);gap:10px}.radio-station:hover{background:var(--bg-secondary)}.radio-station.playing{background:rgba(var(--accent-rgb),.1);border:1px solid rgba(var(--accent-rgb),.2)}.radio-station-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.radio-station-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-loc{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-station-live{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--accent);font-weight:600}.radio-station-btns{display:flex;gap:4px;flex-shrink:0}.radio-btn-play,.radio-btn-stop{width:34px;height:34px;border:none;border-radius:50%;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-play{background:var(--accent);color:#fff}.radio-btn-play:hover:not(:disabled){background:var(--accent-hover);transform:scale(1.05)}.radio-btn-play:disabled{opacity:.4;cursor:not-allowed}.radio-btn-stop{background:var(--danger);color:#fff}.radio-btn-stop:hover{background:#c63639}.radio-btn-fav{width:34px;height:34px;border:none;border-radius:50%;font-size:16px;cursor:pointer;background:transparent;color:var(--text-faint);display:flex;align-items:center;justify-content:center;transition:all var(--transition)}.radio-btn-fav:hover{color:var(--warning);background:#fee75c1a}.radio-btn-fav.active{color:var(--warning)}.radio-eq{display:flex;align-items:flex-end;gap:2px;height:14px}.radio-eq span{width:3px;background:var(--accent);border-radius:1px;animation:eq-bounce .8s ease-in-out infinite}.radio-eq span:nth-child(1){height:8px;animation-delay:0s}.radio-eq span:nth-child(2){height:14px;animation-delay:.15s}.radio-eq span:nth-child(3){height:10px;animation-delay:.3s}@keyframes eq-bounce{0%,to{transform:scaleY(.4)}50%{transform:scaleY(1)}}.radio-sel{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius);color:var(--text-normal);font-family:var(--font);font-size:13px;padding:6px 10px;cursor:pointer;outline:none;max-width:180px}.radio-sel:focus{border-color:var(--accent)}.radio-eq-np{flex-shrink:0}.radio-np-info{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}.radio-np-name{font-size:14px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-np-loc{font-size:11px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.radio-volume{display:flex;align-items:center;gap:6px;flex-shrink:0}.radio-volume-icon{font-size:16px;width:20px;text-align:center;cursor:pointer}.radio-volume-slider{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100px;height:4px;border-radius:2px;background:var(--bg-tertiary, #383a40);outline:none;cursor:pointer}.radio-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-slider::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--accent, #e67e22);cursor:pointer;border:none;box-shadow:0 0 4px #0000004d}.radio-volume-val{font-size:11px;color:var(--text-muted);min-width:32px;text-align:right}.radio-theme-dot{width:16px;height:16px;border-radius:50%;cursor:pointer;transition:transform .15s ease,border-color .15s ease;border:2px solid transparent}.radio-theme-dot:hover{transform:scale(1.25)}.radio-theme-dot.active{border-color:#fff;box-shadow:0 0 6px #ffffff4d}.radio-counter{position:absolute;bottom:16px;left:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;pointer-events:none}.radio-attribution{position:absolute;right:16px;bottom:16px;z-index:10;font-size:12px;color:var(--text-faint);background:#1e1f22cc;padding:4px 10px;border-radius:20px;text-decoration:none;transition:color var(--transition),background var(--transition)}.radio-attribution:hover{color:var(--text-normal);background:#1e1f22eb}.radio-spinner{width:24px;height:24px;border:3px solid var(--bg-tertiary);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}@media(max-width:768px){.radio-panel{width:100%}.radio-fab{top:12px;right:12px;padding:8px 10px;font-size:14px}.radio-search{top:12px;width:calc(100% - 80px);left:calc(50% - 24px)}.radio-topbar{padding:0 12px;gap:8px}.radio-topbar-title{display:none}.radio-sel{max-width:140px;font-size:12px}}@media(max-width:480px){.radio-topbar-np,.radio-volume{display:none}.radio-sel{max-width:120px}}.radio-conn{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--success);cursor:pointer;padding:4px 10px;border-radius:20px;background:#57d28f14;transition:all var(--transition);flex-shrink:0;-webkit-user-select:none;user-select:none}.radio-conn:hover{background:#57d28f26}.radio-conn-dot{width:8px;height:8px;border-radius:50%;background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.radio-conn-ping{font-size:11px;color:var(--text-muted);font-weight:600;font-variant-numeric:tabular-nums}.radio-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:9000;display:flex;align-items:center;justify-content:center;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);animation:fade-in .15s ease}.radio-modal{background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;width:340px;box-shadow:0 20px 60px #0006;overflow:hidden;animation:radio-modal-in .2s ease}@keyframes radio-modal-in{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}.radio-modal-header{display:flex;align-items:center;gap:8px;padding:14px 16px;border-bottom:1px solid var(--border);font-weight:700;font-size:14px}.radio-modal-close{margin-left:auto;background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:6px;font-size:14px;transition:all var(--transition)}.radio-modal-close:hover{background:#ffffff14;color:var(--text-normal)}.radio-modal-body{padding:16px;display:flex;flex-direction:column;gap:12px}.radio-modal-stat{display:flex;justify-content:space-between;align-items:center}.radio-modal-label{color:var(--text-muted);font-size:13px}.radio-modal-value{font-weight:600;font-size:13px;display:flex;align-items:center;gap:6px}.radio-modal-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.ap-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9998;display:flex;align-items:center;justify-content:center;background:#000000b3;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);animation:fade-in .15s ease}.ap-modal{display:flex;width:min(940px,calc(100vw - 40px));height:min(620px,calc(100vh - 60px));background:var(--bg-primary);border:1px solid var(--border);border-radius:16px;overflow:hidden;box-shadow:0 24px 80px #00000080;animation:hub-modal-in .2s ease;position:relative}.ap-sidebar{width:210px;min-width:210px;background:var(--bg-deep);border-right:1px solid var(--border);display:flex;flex-direction:column;padding:0}.ap-sidebar-title{padding:18px 20px 14px;font-size:15px;font-weight:700;color:var(--text-normal);letter-spacing:-.01em;border-bottom:1px solid var(--border)}.ap-nav{display:flex;flex-direction:column;padding:8px;gap:2px}.ap-nav-item{display:flex;align-items:center;gap:10px;padding:10px 14px;border:none;border-left:3px solid transparent;background:transparent;color:var(--text-muted);font-family:var(--font);font-size:14px;font-weight:500;cursor:pointer;border-radius:0 var(--radius) var(--radius) 0;transition:all var(--transition);text-align:left}.ap-nav-item:hover{color:var(--text-normal);background:var(--bg-secondary)}.ap-nav-item.active{color:var(--accent);background:rgba(var(--accent-rgb),.1);border-left-color:var(--accent);font-weight:600}.ap-nav-icon{font-size:16px;line-height:1}.ap-nav-label{line-height:1}.ap-logout-btn{margin-top:auto;padding:10px 16px;background:transparent;border:none;border-top:1px solid var(--border);color:#e74c3c;font-size:.85rem;cursor:pointer;text-align:left;transition:background .15s}.ap-logout-btn:hover{background:#e74c3c1a}.ap-content{flex:1;display:flex;flex-direction:column;overflow:hidden}.ap-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--border);flex-shrink:0}.ap-title{font-size:16px;font-weight:700;color:var(--text-normal);margin:0}.ap-close{background:none;border:none;color:var(--text-muted);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:6px;transition:all var(--transition)}.ap-close:hover{color:var(--text-normal);background:#ffffff14}.ap-body{flex:1;overflow-y:auto;padding:16px 20px;scrollbar-width:thin;scrollbar-color:var(--bg-tertiary) transparent}.ap-body::-webkit-scrollbar{width:6px}.ap-body::-webkit-scrollbar-thumb{background:var(--bg-tertiary);border-radius:3px}.ap-tab-content{display:flex;flex-direction:column;gap:12px;animation:fade-in .15s ease}.ap-toolbar{display:flex;align-items:center;gap:10px}.ap-search{flex:1;padding:8px 12px;border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-secondary);color:var(--text-normal);font-size:13px;font-family:var(--font)}.ap-search:focus{outline:none;border-color:var(--accent)}.ap-search::placeholder{color:var(--text-faint)}.ap-btn{display:inline-flex;align-items:center;gap:4px;padding:8px 14px;border:none;border-radius:var(--radius);font-family:var(--font);font-size:13px;font-weight:500;cursor:pointer;transition:all var(--transition);white-space:nowrap}.ap-btn:disabled{opacity:.5;cursor:default}.ap-btn-primary{background:var(--accent);color:#fff}.ap-btn-primary:hover:not(:disabled){background:var(--accent-hover)}.ap-btn-danger{background:#ed424526;color:var(--danger);border:1px solid rgba(237,66,69,.3)}.ap-btn-danger:hover:not(:disabled){background:#ed424540}.ap-btn-outline{background:var(--bg-secondary);color:var(--text-muted);border:1px solid var(--border)}.ap-btn-outline:hover:not(:disabled){color:var(--text-normal);border-color:var(--text-faint)}.ap-btn-sm{padding:5px 10px;font-size:12px}.ap-upload-zone{display:flex;align-items:center;justify-content:center;padding:14px;border:2px dashed var(--border);border-radius:var(--radius);background:var(--bg-secondary);cursor:pointer;transition:all var(--transition);color:var(--text-muted);font-size:13px}.ap-upload-zone:hover{border-color:var(--accent);color:var(--accent);background:rgba(var(--accent-rgb),.05)}.ap-upload-progress{color:var(--accent);font-weight:600}.ap-bulk-row{display:flex;align-items:center;justify-content:space-between;padding:6px 0}.ap-select-all{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-muted);cursor:pointer}.ap-select-all input[type=checkbox]{accent-color:var(--accent)}.ap-list-wrap{flex:1;min-height:0}.ap-list{display:flex;flex-direction:column;gap:2px}.ap-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-item:hover{background:var(--bg-tertiary)}.ap-item-check{flex-shrink:0;cursor:pointer}.ap-item-check input[type=checkbox]{accent-color:var(--accent)}.ap-item-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.ap-item-name{font-size:13px;font-weight:600;color:var(--text-normal);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ap-item-meta{font-size:11px;color:var(--text-faint);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ap-item-actions{display:flex;gap:4px;flex-shrink:0}.ap-rename-row{display:flex;align-items:center;gap:6px;margin-top:4px}.ap-rename-input{flex:1;padding:5px 8px;border:1px solid var(--accent);border-radius:var(--radius);background:var(--bg-deep);color:var(--text-normal);font-size:12px;font-family:var(--font)}.ap-rename-input:focus{outline:none}.ap-empty{text-align:center;color:var(--text-muted);padding:40px 16px;font-size:13px}.ap-hint{font-size:13px;color:var(--text-muted);margin:0}.ap-status-badge{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--text-muted)}.ap-status-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);flex-shrink:0}.ap-status-dot.online{background:var(--success);animation:pulse-dot 2s ease-in-out infinite}.ap-channel-list{display:flex;flex-direction:column;gap:2px}.ap-channel-row{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-channel-row:hover{background:var(--bg-tertiary)}.ap-channel-info{display:flex;flex-direction:column;gap:2px;min-width:0}.ap-channel-name{font-size:13px;font-weight:600;color:var(--text-normal)}.ap-channel-guild{font-size:11px;color:var(--text-faint)}.ap-channel-toggles{display:flex;gap:8px;flex-shrink:0}.ap-toggle{display:flex;align-items:center;gap:4px;font-size:12px;color:var(--text-muted);cursor:pointer;padding:4px 8px;border-radius:var(--radius);transition:all var(--transition)}.ap-toggle input[type=checkbox]{accent-color:var(--accent)}.ap-toggle.active{color:var(--accent);background:rgba(var(--accent-rgb),.08)}.ap-save-row{display:flex;justify-content:flex-end;padding-top:8px}.ap-profile-list{display:flex;flex-direction:column;gap:2px}.ap-profile-row{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:var(--radius);background:var(--bg-secondary);transition:background var(--transition)}.ap-profile-row:hover{background:var(--bg-tertiary)}.ap-profile-avatar{width:36px;height:36px;border-radius:50%;flex-shrink:0}.ap-profile-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.ap-profile-name{font-size:14px;font-weight:600;color:var(--text-normal)}.ap-profile-details{display:flex;align-items:center;gap:6px;font-size:11px}.ap-platform-badge{padding:1px 6px;border-radius:3px;font-weight:600;font-size:10px}.ap-platform-badge.steam{background:#4285f426;color:#64b5f6}.ap-platform-badge.gog{background:#ab47bc26;color:#ce93d8}.ap-profile-total{color:var(--text-faint)}.ap-toast{position:absolute;bottom:16px;left:50%;transform:translate(-50%);padding:8px 16px;border-radius:var(--radius);font-size:13px;font-weight:500;background:var(--bg-tertiary);color:var(--text-normal);box-shadow:0 4px 16px #0006;animation:fade-in .15s ease;z-index:10}.ap-toast.error{background:#ed424533;color:#f87171}@media(max-width:768px){.ap-modal{flex-direction:column;width:calc(100vw - 16px);height:calc(100vh - 32px)}.ap-sidebar{width:100%;min-width:100%;flex-direction:row;border-right:none;border-bottom:1px solid var(--border);overflow-x:auto}.ap-sidebar-title{display:none}.ap-nav{flex-direction:row;padding:4px 8px;gap:4px}.ap-nav-item{border-left:none;border-bottom:3px solid transparent;border-radius:var(--radius) var(--radius) 0 0;padding:8px 12px;white-space:nowrap}.ap-nav-item.active{border-left-color:transparent;border-bottom-color:var(--accent)}.ap-channel-toggles{flex-direction:column;gap:4px}} diff --git a/web/dist/assets/index-BWeAEcYi.js b/web/dist/assets/index-CUixApZu.js similarity index 85% rename from web/dist/assets/index-BWeAEcYi.js rename to web/dist/assets/index-CUixApZu.js index c9b56e4..db5599a 100644 --- a/web/dist/assets/index-BWeAEcYi.js +++ b/web/dist/assets/index-CUixApZu.js @@ -14,7 +14,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var z8;function RF(){return z8||(z8=1,(function(i){function e(Z,te){var de=Z.length;Z.push(te);e:for(;0>>1,Te=Z[Se];if(0>>1;Ser(Ve,de))Cer(Fe,Ve)?(Z[Se]=Fe,Z[Ce]=de,Se=Ce):(Z[Se]=Ve,Z[Me]=de,Se=Me);else if(Cer(Fe,de))Z[Se]=Fe,Z[Ce]=de,Se=Ce;else break e}}return te}function r(Z,te){var de=Z.sortIndex-te.sortIndex;return de!==0?de:Z.id-te.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;i.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();i.unstable_now=function(){return a.now()-l}}var u=[],h=[],m=1,v=null,x=3,S=!1,T=!1,N=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function I(Z){for(var te=t(h);te!==null;){if(te.callback===null)n(h);else if(te.startTime<=Z)n(h),te.sortIndex=te.expirationTime,e(u,te);else break;te=t(h)}}function j(Z){if(N=!1,I(Z),!T)if(t(u)!==null)T=!0,z||(z=!0,J());else{var te=t(h);te!==null&&ie(j,te.startTime-Z)}}var z=!1,G=-1,H=5,q=-1;function V(){return C?!0:!(i.unstable_now()-qZ&&V());){var Se=v.callback;if(typeof Se=="function"){v.callback=null,x=v.priorityLevel;var Te=Se(v.expirationTime<=Z);if(Z=i.unstable_now(),typeof Te=="function"){v.callback=Te,I(Z),te=!0;break t}v===t(u)&&n(u),I(Z)}else n(u);v=t(u)}if(v!==null)te=!0;else{var ae=t(h);ae!==null&&ie(j,ae.startTime-Z),te=!1}}break e}finally{v=null,x=de,S=!1}te=void 0}}finally{te?J():z=!1}}}var J;if(typeof U=="function")J=function(){U(Q)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,oe=ne.port2;ne.port1.onmessage=Q,J=function(){oe.postMessage(null)}}else J=function(){E(Q,0)};function ie(Z,te){G=E(function(){Z(i.unstable_now())},te)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(Z){Z.callback=null},i.unstable_forceFrameRate=function(Z){0>Z||125Se?(Z.sortIndex=de,e(h,Z),t(u)===null&&Z===t(h)&&(N?(O(G),G=-1):N=!0,ie(j,de-Se))):(Z.sortIndex=Te,e(u,Z),T||S||(T=!0,z||(z=!0,J()))),Z},i.unstable_shouldYield=V,i.unstable_wrapCallback=function(Z){var te=x;return function(){var de=x;x=te;try{return Z.apply(this,arguments)}finally{x=de}}}})(Kb)),Kb}var G8;function DF(){return G8||(G8=1,Qb.exports=RF()),Qb.exports}var Zb={exports:{}},ti={};/** + */var z8;function RF(){return z8||(z8=1,(function(i){function e(Z,ne){var de=Z.length;Z.push(ne);e:for(;0>>1,Te=Z[be];if(0>>1;ber(Ve,de))Cer(Fe,Ve)?(Z[be]=Fe,Z[Ce]=de,be=Ce):(Z[be]=Ve,Z[Me]=de,be=Me);else if(Cer(Fe,de))Z[be]=Fe,Z[Ce]=de,be=Ce;else break e}}return ne}function r(Z,ne){var de=Z.sortIndex-ne.sortIndex;return de!==0?de:Z.id-ne.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;i.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();i.unstable_now=function(){return a.now()-l}}var u=[],h=[],m=1,v=null,x=3,S=!1,T=!1,N=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function I(Z){for(var ne=t(h);ne!==null;){if(ne.callback===null)n(h);else if(ne.startTime<=Z)n(h),ne.sortIndex=ne.expirationTime,e(u,ne);else break;ne=t(h)}}function j(Z){if(N=!1,I(Z),!T)if(t(u)!==null)T=!0,z||(z=!0,J());else{var ne=t(h);ne!==null&&re(j,ne.startTime-Z)}}var z=!1,G=-1,H=5,q=-1;function V(){return C?!0:!(i.unstable_now()-qZ&&V());){var be=v.callback;if(typeof be=="function"){v.callback=null,x=v.priorityLevel;var Te=be(v.expirationTime<=Z);if(Z=i.unstable_now(),typeof Te=="function"){v.callback=Te,I(Z),ne=!0;break t}v===t(u)&&n(u),I(Z)}else n(u);v=t(u)}if(v!==null)ne=!0;else{var ae=t(h);ae!==null&&re(j,ae.startTime-Z),ne=!1}}break e}finally{v=null,x=de,S=!1}ne=void 0}}finally{ne?J():z=!1}}}var J;if(typeof U=="function")J=function(){U(Q)};else if(typeof MessageChannel<"u"){var ie=new MessageChannel,le=ie.port2;ie.port1.onmessage=Q,J=function(){le.postMessage(null)}}else J=function(){E(Q,0)};function re(Z,ne){G=E(function(){Z(i.unstable_now())},ne)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(Z){Z.callback=null},i.unstable_forceFrameRate=function(Z){0>Z||125be?(Z.sortIndex=de,e(h,Z),t(u)===null&&Z===t(h)&&(N?(O(G),G=-1):N=!0,re(j,de-be))):(Z.sortIndex=Te,e(u,Z),T||S||(T=!0,z||(z=!0,J()))),Z},i.unstable_shouldYield=V,i.unstable_wrapCallback=function(Z){var ne=x;return function(){var de=x;x=ne;try{return Z.apply(this,arguments)}finally{x=de}}}})(Kb)),Kb}var G8;function DF(){return G8||(G8=1,Qb.exports=RF()),Qb.exports}var Zb={exports:{}},ti={};/** * @license React * react.production.js * @@ -22,7 +22,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var q8;function PF(){if(q8)return ti;q8=1;var i=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(ae){return ae===null||typeof ae!="object"?null:(ae=x&&ae[x]||ae["@@iterator"],typeof ae=="function"?ae:null)}var T={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,C={};function E(ae,Me,Ve){this.props=ae,this.context=Me,this.refs=C,this.updater=Ve||T}E.prototype.isReactComponent={},E.prototype.setState=function(ae,Me){if(typeof ae!="object"&&typeof ae!="function"&&ae!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,ae,Me,"setState")},E.prototype.forceUpdate=function(ae){this.updater.enqueueForceUpdate(this,ae,"forceUpdate")};function O(){}O.prototype=E.prototype;function U(ae,Me,Ve){this.props=ae,this.context=Me,this.refs=C,this.updater=Ve||T}var I=U.prototype=new O;I.constructor=U,N(I,E.prototype),I.isPureReactComponent=!0;var j=Array.isArray;function z(){}var G={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function q(ae,Me,Ve){var Ce=Ve.ref;return{$$typeof:i,type:ae,key:Me,ref:Ce!==void 0?Ce:null,props:Ve}}function V(ae,Me){return q(ae.type,Me,ae.props)}function Q(ae){return typeof ae=="object"&&ae!==null&&ae.$$typeof===i}function J(ae){var Me={"=":"=0",":":"=2"};return"$"+ae.replace(/[=:]/g,function(Ve){return Me[Ve]})}var ne=/\/+/g;function oe(ae,Me){return typeof ae=="object"&&ae!==null&&ae.key!=null?J(""+ae.key):Me.toString(36)}function ie(ae){switch(ae.status){case"fulfilled":return ae.value;case"rejected":throw ae.reason;default:switch(typeof ae.status=="string"?ae.then(z,z):(ae.status="pending",ae.then(function(Me){ae.status==="pending"&&(ae.status="fulfilled",ae.value=Me)},function(Me){ae.status==="pending"&&(ae.status="rejected",ae.reason=Me)})),ae.status){case"fulfilled":return ae.value;case"rejected":throw ae.reason}}throw ae}function Z(ae,Me,Ve,Ce,Fe){var et=typeof ae;(et==="undefined"||et==="boolean")&&(ae=null);var He=!1;if(ae===null)He=!0;else switch(et){case"bigint":case"string":case"number":He=!0;break;case"object":switch(ae.$$typeof){case i:case e:He=!0;break;case m:return He=ae._init,Z(He(ae._payload),Me,Ve,Ce,Fe)}}if(He)return Fe=Fe(ae),He=Ce===""?"."+oe(ae,0):Ce,j(Fe)?(Ve="",He!=null&&(Ve=He.replace(ne,"$&/")+"/"),Z(Fe,Me,Ve,"",function(zt){return zt})):Fe!=null&&(Q(Fe)&&(Fe=V(Fe,Ve+(Fe.key==null||ae&&ae.key===Fe.key?"":(""+Fe.key).replace(ne,"$&/")+"/")+He)),Me.push(Fe)),1;He=0;var Rt=Ce===""?".":Ce+":";if(j(ae))for(var Et=0;EtTe||(o.current=Se[Te],Se[Te]=null,Te--)}function Ve(o,c){Te++,Se[Te]=o.current,o.current=c}var Ce=ae(null),Fe=ae(null),et=ae(null),He=ae(null);function Rt(o,c){switch(Ve(et,c),Ve(Fe,o),Ve(Ce,null),c.nodeType){case 9:case 11:o=(o=c.documentElement)&&(o=o.namespaceURI)?o8(o):0;break;default:if(o=c.tagName,c=c.namespaceURI)c=o8(c),o=l8(c,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}Me(Ce),Ve(Ce,o)}function Et(){Me(Ce),Me(Fe),Me(et)}function zt(o){o.memoizedState!==null&&Ve(He,o);var c=Ce.current,g=l8(c,o.type);c!==g&&(Ve(Fe,o),Ve(Ce,g))}function Pt(o){Fe.current===o&&(Me(Ce),Me(Fe)),He.current===o&&(Me(He),zp._currentValue=de)}var We,ft;function fe(o){if(We===void 0)try{throw Error()}catch(g){var c=g.stack.trim().match(/\n( *(at )?)/);We=c&&c[1]||"",ft=-1Te||(o.current=be[Te],be[Te]=null,Te--)}function Ve(o,c){Te++,be[Te]=o.current,o.current=c}var Ce=ae(null),Fe=ae(null),tt=ae(null),je=ae(null);function Rt(o,c){switch(Ve(tt,c),Ve(Fe,o),Ve(Ce,null),c.nodeType){case 9:case 11:o=(o=c.documentElement)&&(o=o.namespaceURI)?o8(o):0;break;default:if(o=c.tagName,c=c.namespaceURI)c=o8(c),o=l8(c,o);else switch(o){case"svg":o=1;break;case"math":o=2;break;default:o=0}}Me(Ce),Ve(Ce,o)}function Et(){Me(Ce),Me(Fe),Me(tt)}function Ft(o){o.memoizedState!==null&&Ve(je,o);var c=Ce.current,g=l8(c,o.type);c!==g&&(Ve(Fe,o),Ve(Ce,g))}function Ut(o){Fe.current===o&&(Me(Ce),Me(Fe)),je.current===o&&(Me(je),zp._currentValue=de)}var Ke,ht;function fe(o){if(Ke===void 0)try{throw Error()}catch(g){var c=g.stack.trim().match(/\n( *(at )?)/);Ke=c&&c[1]||"",ht=-1)":-1D||Re[b]!==at[D]){var vt=` -`+Re[b].replace(" at new "," at ");return o.displayName&&vt.includes("")&&(vt=vt.replace("",o.displayName)),vt}while(1<=b&&0<=D);break}}}finally{Wt=!1,Error.prepareStackTrace=g}return(g=o?o.displayName||o.name:"")?fe(g):""}function Gt(o,c){switch(o.tag){case 26:case 27:case 5:return fe(o.type);case 16:return fe("Lazy");case 13:return o.child!==c&&c!==null?fe("Suspense Fallback"):fe("Suspense");case 19:return fe("SuspenseList");case 0:case 15:return yt(o.type,!1);case 11:return yt(o.type.render,!1);case 1:return yt(o.type,!0);case 31:return fe("Activity");default:return""}}function _t(o){try{var c="",g=null;do c+=Gt(o,g),g=o,o=o.return;while(o);return c}catch(b){return` +`);for(D=b=0;bD||Ne[b]!==at[D]){var vt=` +`+Ne[b].replace(" at new "," at ");return o.displayName&&vt.includes("")&&(vt=vt.replace("",o.displayName)),vt}while(1<=b&&0<=D);break}}}finally{$t=!1,Error.prepareStackTrace=g}return(g=o?o.displayName||o.name:"")?fe(g):""}function Gt(o,c){switch(o.tag){case 26:case 27:case 5:return fe(o.type);case 16:return fe("Lazy");case 13:return o.child!==c&&c!==null?fe("Suspense Fallback"):fe("Suspense");case 19:return fe("SuspenseList");case 0:case 15:return _t(o.type,!1);case 11:return _t(o.type.render,!1);case 1:return _t(o.type,!0);case 31:return fe("Activity");default:return""}}function yt(o){try{var c="",g=null;do c+=Gt(o,g),g=o,o=o.return;while(o);return c}catch(b){return` Error generating stack: `+b.message+` -`+b.stack}}var Xt=Object.prototype.hasOwnProperty,pt=i.unstable_scheduleCallback,Ae=i.unstable_cancelCallback,k=i.unstable_shouldYield,be=i.unstable_requestPaint,Oe=i.unstable_now,pe=i.unstable_getCurrentPriorityLevel,le=i.unstable_ImmediatePriority,Ne=i.unstable_UserBlockingPriority,De=i.unstable_NormalPriority,Je=i.unstable_LowPriority,we=i.unstable_IdlePriority,Ue=i.log,ut=i.unstable_setDisableYieldValue,Dt=null,Bt=null;function ct(o){if(typeof Ue=="function"&&ut(o),Bt&&typeof Bt.setStrictMode=="function")try{Bt.setStrictMode(Dt,o)}catch{}}var jt=Math.clz32?Math.clz32:ge,Jt=Math.log,In=Math.LN2;function ge(o){return o>>>=0,o===0?32:31-(Jt(o)/In|0)|0}var Ot=256,ot=262144,Tt=4194304;function Ht(o){var c=o&42;if(c!==0)return c;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function Yt(o,c,g){var b=o.pendingLanes;if(b===0)return 0;var D=0,L=o.suspendedLanes,Y=o.pingedLanes;o=o.warmLanes;var ue=b&134217727;return ue!==0?(b=ue&~L,b!==0?D=Ht(b):(Y&=ue,Y!==0?D=Ht(Y):g||(g=ue&~o,g!==0&&(D=Ht(g))))):(ue=b&~L,ue!==0?D=Ht(ue):Y!==0?D=Ht(Y):g||(g=b&~o,g!==0&&(D=Ht(g)))),D===0?0:c!==0&&c!==D&&(c&L)===0&&(L=D&-D,g=c&-c,L>=g||L===32&&(g&4194048)!==0)?c:D}function pn(o,c){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&c)===0}function $e(o,c){switch(o){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function St(){var o=Tt;return Tt<<=1,(Tt&62914560)===0&&(Tt=4194304),o}function Kt(o){for(var c=[],g=0;31>g;g++)c.push(o);return c}function wn(o,c){o.pendingLanes|=c,c!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function qn(o,c,g,b,D,L){var Y=o.pendingLanes;o.pendingLanes=g,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=g,o.entangledLanes&=g,o.errorRecoveryDisabledLanes&=g,o.shellSuspendCounter=0;var ue=o.entanglements,Re=o.expirationTimes,at=o.hiddenUpdates;for(g=Y&~g;0"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var ys=/[\n"\\]/g;function Vr(o){return o.replace(ys,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Di(o,c,g,b,D,L,Y,ue){o.name="",Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?o.type=Y:o.removeAttribute("type"),c!=null?Y==="number"?(c===0&&o.value===""||o.value!=c)&&(o.value=""+hn(c)):o.value!==""+hn(c)&&(o.value=""+hn(c)):Y!=="submit"&&Y!=="reset"||o.removeAttribute("value"),c!=null?bi(o,Y,hn(c)):g!=null?bi(o,Y,hn(g)):b!=null&&o.removeAttribute("value"),D==null&&L!=null&&(o.defaultChecked=!!L),D!=null&&(o.checked=D&&typeof D!="function"&&typeof D!="symbol"),ue!=null&&typeof ue!="function"&&typeof ue!="symbol"&&typeof ue!="boolean"?o.name=""+hn(ue):o.removeAttribute("name")}function sr(o,c,g,b,D,L,Y,ue){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(o.type=L),c!=null||g!=null){if(!(L!=="submit"&&L!=="reset"||c!=null)){ui(o);return}g=g!=null?""+hn(g):"",c=c!=null?""+hn(c):g,ue||c===o.value||(o.value=c),o.defaultValue=c}b=b??D,b=typeof b!="function"&&typeof b!="symbol"&&!!b,o.checked=ue?o.checked:!!b,o.defaultChecked=!!b,Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"&&(o.name=Y),ui(o)}function bi(o,c,g){c==="number"&&Ps(o.ownerDocument)===o||o.defaultValue===""+g||(o.defaultValue=""+g)}function _r(o,c,g,b){if(o=o.options,c){c={};for(var D=0;D"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_d=!1;if(el)try{var Qh={};Object.defineProperty(Qh,"passive",{get:function(){_d=!0}}),window.addEventListener("test",Qh,Qh),window.removeEventListener("test",Qh,Qh)}catch{_d=!1}var Do=null,Kh=null,yd=null;function J0(){if(yd)return yd;var o,c=Kh,g=c.length,b,D="value"in Do?Do.value:Do.textContent,L=D.length;for(o=0;o=tf),Du=" ",p1=!1;function wd(o,c){switch(o){case"keyup":return bx.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function rp(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Wc=!1;function m1(o,c){switch(o){case"compositionend":return rp(c);case"keypress":return c.which!==32?null:(p1=!0,Du);case"textInput":return o=c.data,o===Du&&p1?null:o;default:return null}}function Sx(o,c){if(Wc)return o==="compositionend"||!Ru&&wd(o,c)?(o=J0(),yd=Kh=Do=null,Wc=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:g,offset:c-o};o=b}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=Ed(g)}}function Bu(o,c){return o&&c?o===c?!0:o&&o.nodeType===3?!1:c&&c.nodeType===3?Bu(o,c.parentNode):"contains"in o?o.contains(c):o.compareDocumentPosition?!!(o.compareDocumentPosition(c)&16):!1:!1}function Dl(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var c=Ps(o.document);c instanceof o.HTMLIFrameElement;){try{var g=typeof c.contentWindow.location.href=="string"}catch{g=!1}if(g)o=c.contentWindow;else break;c=Ps(o.document)}return c}function Pl(o){var c=o&&o.nodeName&&o.nodeName.toLowerCase();return c&&(c==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||c==="textarea"||o.contentEditable==="true")}var Mx=el&&"documentMode"in document&&11>=document.documentMode,Ou=null,up=null,Iu=null,cp=!1;function b1(o,c,g){var b=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;cp||Ou==null||Ou!==Ps(b)||(b=Ou,"selectionStart"in b&&Pl(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Iu&&bs(Iu,b)||(Iu=b,b=i2(up,"onSelect"),0>=Y,D-=Y,Ea=1<<32-jt(c)+D|g<ci?(vi=gn,gn=null):vi=gn.sibling;var Ci=lt(Ye,gn,st[ci],Mt);if(Ci===null){gn===null&&(gn=vi);break}o&&gn&&Ci.alternate===null&&c(Ye,gn),ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci,gn=vi}if(ci===st.length)return g(Ye,gn),Ai&&Uo(Ye,ci),Mn;if(gn===null){for(;cici?(vi=gn,gn=null):vi=gn.sibling;var ch=lt(Ye,gn,Ci.value,Mt);if(ch===null){gn===null&&(gn=vi);break}o&&gn&&ch.alternate===null&&c(Ye,gn),ke=L(ch,ke,ci),Ei===null?Mn=ch:Ei.sibling=ch,Ei=ch,gn=vi}if(Ci.done)return g(Ye,gn),Ai&&Uo(Ye,ci),Mn;if(gn===null){for(;!Ci.done;ci++,Ci=st.next())Ci=Nt(Ye,Ci.value,Mt),Ci!==null&&(ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci);return Ai&&Uo(Ye,ci),Mn}for(gn=b(gn);!Ci.done;ci++,Ci=st.next())Ci=ht(gn,Ye,ci,Ci.value,Mt),Ci!==null&&(o&&Ci.alternate!==null&&gn.delete(Ci.key===null?ci:Ci.key),ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci);return o&&gn.forEach(function(EF){return c(Ye,EF)}),Ai&&Uo(Ye,ci),Mn}function Yi(Ye,ke,st,Mt){if(typeof st=="object"&&st!==null&&st.type===N&&st.key===null&&(st=st.props.children),typeof st=="object"&&st!==null){switch(st.$$typeof){case S:e:{for(var Mn=st.key;ke!==null;){if(ke.key===Mn){if(Mn=st.type,Mn===N){if(ke.tag===7){g(Ye,ke.sibling),Mt=D(ke,st.props.children),Mt.return=Ye,Ye=Mt;break e}}else if(ke.elementType===Mn||typeof Mn=="object"&&Mn!==null&&Mn.$$typeof===H&&f(Mn)===ke.type){g(Ye,ke.sibling),Mt=D(ke,st.props),B(Mt,st),Mt.return=Ye,Ye=Mt;break e}g(Ye,ke);break}else c(Ye,ke);ke=ke.sibling}st.type===N?(Mt=qu(st.props.children,Ye.mode,Mt,st.key),Mt.return=Ye,Ye=Mt):(Mt=Pd(st.type,st.key,st.props,null,Ye.mode,Mt),B(Mt,st),Mt.return=Ye,Ye=Mt)}return Y(Ye);case T:e:{for(Mn=st.key;ke!==null;){if(ke.key===Mn)if(ke.tag===4&&ke.stateNode.containerInfo===st.containerInfo&&ke.stateNode.implementation===st.implementation){g(Ye,ke.sibling),Mt=D(ke,st.children||[]),Mt.return=Ye,Ye=Mt;break e}else{g(Ye,ke);break}else c(Ye,ke);ke=ke.sibling}Mt=Lo(st,Ye.mode,Mt),Mt.return=Ye,Ye=Mt}return Y(Ye);case H:return st=f(st),Yi(Ye,ke,st,Mt)}if(ie(st))return An(Ye,ke,st,Mt);if(J(st)){if(Mn=J(st),typeof Mn!="function")throw Error(n(150));return st=Mn.call(st),Bn(Ye,ke,st,Mt)}if(typeof st.then=="function")return Yi(Ye,ke,R(st),Mt);if(st.$$typeof===U)return Yi(Ye,ke,kd(Ye,st),Mt);F(Ye,st)}return typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint"?(st=""+st,ke!==null&&ke.tag===6?(g(Ye,ke.sibling),Mt=D(ke,st),Mt.return=Ye,Ye=Mt):(g(Ye,ke),Mt=pp(st,Ye.mode,Mt),Mt.return=Ye,Ye=Mt),Y(Ye)):g(Ye,ke)}return function(Ye,ke,st,Mt){try{M=0;var Mn=Yi(Ye,ke,st,Mt);return w=null,Mn}catch(gn){if(gn===ll||gn===ao)throw gn;var Ei=$s(29,gn,null,Ye.mode);return Ei.lanes=Mt,Ei.return=Ye,Ei}finally{}}}var se=W(!0),_e=W(!1),ve=!1;function ye(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Pe(o,c){o=o.updateQueue,c.updateQueue===o&&(c.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function ze(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function nt(o,c,g){var b=o.updateQueue;if(b===null)return null;if(b=b.shared,(Pi&2)!==0){var D=b.pending;return D===null?c.next=c:(c.next=D.next,D.next=c),b.pending=c,c=Dd(o),T1(o,null,g),c}return Rd(o,b,c,g),Dd(o)}function Xe(o,c,g){if(c=c.updateQueue,c!==null&&(c=c.shared,(g&4194048)!==0)){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,dt(o,g)}}function je(o,c){var g=o.updateQueue,b=o.alternate;if(b!==null&&(b=b.updateQueue,g===b)){var D=null,L=null;if(g=g.firstBaseUpdate,g!==null){do{var Y={lane:g.lane,tag:g.tag,payload:g.payload,callback:null,next:null};L===null?D=L=Y:L=L.next=Y,g=g.next}while(g!==null);L===null?D=L=c:L=L.next=c}else D=L=c;g={baseState:b.baseState,firstBaseUpdate:D,lastBaseUpdate:L,shared:b.shared,callbacks:b.callbacks},o.updateQueue=g;return}o=g.lastBaseUpdate,o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=c}var Le=!1;function Ft(){if(Le){var o=ur;if(o!==null)throw o}}function un(o,c,g,b){Le=!1;var D=o.updateQueue;ve=!1;var L=D.firstBaseUpdate,Y=D.lastBaseUpdate,ue=D.shared.pending;if(ue!==null){D.shared.pending=null;var Re=ue,at=Re.next;Re.next=null,Y===null?L=at:Y.next=at,Y=Re;var vt=o.alternate;vt!==null&&(vt=vt.updateQueue,ue=vt.lastBaseUpdate,ue!==Y&&(ue===null?vt.firstBaseUpdate=at:ue.next=at,vt.lastBaseUpdate=Re))}if(L!==null){var Nt=D.baseState;Y=0,vt=at=Re=null,ue=L;do{var lt=ue.lane&-536870913,ht=lt!==ue.lane;if(ht?(gi<)===lt:(b<)===lt){lt!==0&<===Qc&&(Le=!0),vt!==null&&(vt=vt.next={lane:0,tag:ue.tag,payload:ue.payload,callback:null,next:null});e:{var An=o,Bn=ue;lt=c;var Yi=g;switch(Bn.tag){case 1:if(An=Bn.payload,typeof An=="function"){Nt=An.call(Yi,Nt,lt);break e}Nt=An;break e;case 3:An.flags=An.flags&-65537|128;case 0:if(An=Bn.payload,lt=typeof An=="function"?An.call(Yi,Nt,lt):An,lt==null)break e;Nt=v({},Nt,lt);break e;case 2:ve=!0}}lt=ue.callback,lt!==null&&(o.flags|=64,ht&&(o.flags|=8192),ht=D.callbacks,ht===null?D.callbacks=[lt]:ht.push(lt))}else ht={lane:lt,tag:ue.tag,payload:ue.payload,callback:ue.callback,next:null},vt===null?(at=vt=ht,Re=Nt):vt=vt.next=ht,Y|=lt;if(ue=ue.next,ue===null){if(ue=D.shared.pending,ue===null)break;ht=ue,ue=ht.next,ht.next=null,D.lastBaseUpdate=ht,D.shared.pending=null}}while(!0);vt===null&&(Re=Nt),D.baseState=Re,D.firstBaseUpdate=at,D.lastBaseUpdate=vt,L===null&&(D.shared.lanes=0),eh|=Y,o.lanes=Y,o.memoizedState=Nt}}function on(o,c){if(typeof o!="function")throw Error(n(191,o));o.call(c)}function kn(o,c){var g=o.callbacks;if(g!==null)for(o.callbacks=null,o=0;oL?L:8;var Y=Z.T,ue={};Z.T=ue,Wx(o,!1,c,g);try{var Re=D(),at=Z.S;if(at!==null&&at(ue,Re),Re!==null&&typeof Re=="object"&&typeof Re.then=="function"){var vt=N1(Re,b);Sp(o,c,vt,co(o))}else Sp(o,c,b,co(o))}catch(Nt){Sp(o,c,{then:function(){},status:"rejected",reason:Nt},co())}finally{te.p=L,Y!==null&&ue.types!==null&&(Y.types=ue.types),Z.T=Y}}function bI(){}function jx(o,c,g,b){if(o.tag!==5)throw Error(n(476));var D=L4(o).queue;P4(o,D,c,de,g===null?bI:function(){return U4(o),g(b)})}function L4(o){var c=o.memoizedState;if(c!==null)return c;c={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ku,lastRenderedState:de},next:null};var g={};return c.next={memoizedState:g,baseState:g,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ku,lastRenderedState:g},next:null},o.memoizedState=c,o=o.alternate,o!==null&&(o.memoizedState=c),c}function U4(o){var c=L4(o);c.next===null&&(c=o.alternate.memoizedState),Sp(o,c.next.queue,{},co())}function Hx(){return hs(zp)}function B4(){return Hr().memoizedState}function O4(){return Hr().memoizedState}function SI(o){for(var c=o.return;c!==null;){switch(c.tag){case 24:case 3:var g=co();o=ze(g);var b=nt(c,o,g);b!==null&&(Ua(b,c,g),Xe(b,c,g)),c={cache:Lr()},o.payload=c;return}c=c.return}}function wI(o,c,g){var b=co();g={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},F1(o)?F4(c,g):(g=Ap(o,c,g,b),g!==null&&(Ua(g,o,b),k4(g,c,b)))}function I4(o,c,g){var b=co();Sp(o,c,g,b)}function Sp(o,c,g,b){var D={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null};if(F1(o))F4(c,D);else{var L=o.alternate;if(o.lanes===0&&(L===null||L.lanes===0)&&(L=c.lastRenderedReducer,L!==null))try{var Y=c.lastRenderedState,ue=L(Y,g);if(D.hasEagerState=!0,D.eagerState=ue,ha(ue,Y))return Rd(o,c,D,0),nr===null&&Nd(),!1}catch{}finally{}if(g=Ap(o,c,D,b),g!==null)return Ua(g,o,b),k4(g,c,b),!0}return!1}function Wx(o,c,g,b){if(b={lane:2,revertLane:wb(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},F1(o)){if(c)throw Error(n(479))}else c=Ap(o,g,b,2),c!==null&&Ua(c,o,2)}function F1(o){var c=o.alternate;return o===ai||c!==null&&c===ai}function F4(o,c){zd=D1=!0;var g=o.pending;g===null?c.next=c:(c.next=g.next,g.next=c),o.pending=c}function k4(o,c,g){if((g&4194048)!==0){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,dt(o,g)}}var wp={readContext:hs,use:U1,useCallback:Ur,useContext:Ur,useEffect:Ur,useImperativeHandle:Ur,useLayoutEffect:Ur,useInsertionEffect:Ur,useMemo:Ur,useReducer:Ur,useRef:Ur,useState:Ur,useDebugValue:Ur,useDeferredValue:Ur,useTransition:Ur,useSyncExternalStore:Ur,useId:Ur,useHostTransitionStatus:Ur,useFormState:Ur,useActionState:Ur,useOptimistic:Ur,useMemoCache:Ur,useCacheRefresh:Ur};wp.useEffectEvent=Ur;var z4={readContext:hs,use:U1,useCallback:function(o,c){return Aa().memoizedState=[o,c===void 0?null:c],o},useContext:hs,useEffect:S4,useImperativeHandle:function(o,c,g){g=g!=null?g.concat([o]):null,O1(4194308,4,E4.bind(null,c,o),g)},useLayoutEffect:function(o,c){return O1(4194308,4,o,c)},useInsertionEffect:function(o,c){O1(4,2,o,c)},useMemo:function(o,c){var g=Aa();c=c===void 0?null:c;var b=o();if(hf){ct(!0);try{o()}finally{ct(!1)}}return g.memoizedState=[b,c],b},useReducer:function(o,c,g){var b=Aa();if(g!==void 0){var D=g(c);if(hf){ct(!0);try{g(c)}finally{ct(!1)}}}else D=c;return b.memoizedState=b.baseState=D,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:D},b.queue=o,o=o.dispatch=wI.bind(null,ai,o),[b.memoizedState,o]},useRef:function(o){var c=Aa();return o={current:o},c.memoizedState=o},useState:function(o){o=kx(o);var c=o.queue,g=I4.bind(null,ai,c);return c.dispatch=g,[o.memoizedState,g]},useDebugValue:qx,useDeferredValue:function(o,c){var g=Aa();return Vx(g,o,c)},useTransition:function(){var o=kx(!1);return o=P4.bind(null,ai,o.queue,!0,!1),Aa().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,c,g){var b=ai,D=Aa();if(Ai){if(g===void 0)throw Error(n(407));g=g()}else{if(g=c(),nr===null)throw Error(n(349));(gi&127)!==0||o4(b,c,g)}D.memoizedState=g;var L={value:g,getSnapshot:c};return D.queue=L,S4(u4.bind(null,b,L,o),[o]),b.flags|=2048,qd(9,{destroy:void 0},l4.bind(null,b,L,g,c),null),g},useId:function(){var o=Aa(),c=nr.identifierPrefix;if(Ai){var g=Ca,b=Ea;g=(b&~(1<<32-jt(b)-1)).toString(32)+g,c="_"+c+"R_"+g,g=P1++,0<\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof b.is=="string"?Y.createElement("select",{is:b.is}):Y.createElement("select"),b.multiple?L.multiple=!0:b.size&&(L.size=b.size);break;default:L=typeof b.is=="string"?Y.createElement(D,{is:b.is}):Y.createElement(D)}}L[$n]=c,L[dn]=b;e:for(Y=c.child;Y!==null;){if(Y.tag===5||Y.tag===6)L.appendChild(Y.stateNode);else if(Y.tag!==4&&Y.tag!==27&&Y.child!==null){Y.child.return=Y,Y=Y.child;continue}if(Y===c)break e;for(;Y.sibling===null;){if(Y.return===null||Y.return===c)break e;Y=Y.return}Y.sibling.return=Y.return,Y=Y.sibling}c.stateNode=L;e:switch(Us(L,D,b),D){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&Ju(c)}}return cr(c),ab(c,c.type,o===null?null:o.memoizedProps,c.pendingProps,g),null;case 6:if(o&&c.stateNode!=null)o.memoizedProps!==b&&Ju(c);else{if(typeof b!="string"&&c.stateNode===null)throw Error(n(166));if(o=et.current,tr(c)){if(o=c.stateNode,g=c.memoizedProps,b=null,D=cs,D!==null)switch(D.tag){case 27:case 5:b=D.memoizedProps}o[$n]=c,o=!!(o.nodeValue===g||b!==null&&b.suppressHydrationWarning===!0||s8(o.nodeValue,g)),o||Bl(c,!0)}else o=r2(o).createTextNode(b),o[$n]=c,c.stateNode=o}return cr(c),null;case 31:if(g=c.memoizedState,o===null||o.memoizedState!==null){if(b=tr(c),g!==null){if(o===null){if(!b)throw Error(n(318));if(o=c.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(557));o[$n]=c}else ju(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;cr(c),o=!1}else g=yp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=g),o=!0;if(!o)return c.flags&256?(oo(c),c):(oo(c),null);if((c.flags&128)!==0)throw Error(n(558))}return cr(c),null;case 13:if(b=c.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(D=tr(c),b!==null&&b.dehydrated!==null){if(o===null){if(!D)throw Error(n(318));if(D=c.memoizedState,D=D!==null?D.dehydrated:null,!D)throw Error(n(317));D[$n]=c}else ju(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;cr(c),D=!1}else D=yp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=D),D=!0;if(!D)return c.flags&256?(oo(c),c):(oo(c),null)}return oo(c),(c.flags&128)!==0?(c.lanes=g,c):(g=b!==null,o=o!==null&&o.memoizedState!==null,g&&(b=c.child,D=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(D=b.alternate.memoizedState.cachePool.pool),L=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(L=b.memoizedState.cachePool.pool),L!==D&&(b.flags|=2048)),g!==o&&g&&(c.child.flags|=8192),V1(c,c.updateQueue),cr(c),null);case 4:return Et(),o===null&&Cb(c.stateNode.containerInfo),cr(c),null;case 10:return Bo(c.type),cr(c),null;case 19:if(Me(jr),b=c.memoizedState,b===null)return cr(c),null;if(D=(c.flags&128)!==0,L=b.rendering,L===null)if(D)Mp(b,!1);else{if(Br!==0||o!==null&&(o.flags&128)!==0)for(o=c.child;o!==null;){if(L=R1(o),L!==null){for(c.flags|=128,Mp(b,!1),o=L.updateQueue,c.updateQueue=o,V1(c,o),c.subtreeFlags=0,o=g,g=c.child;g!==null;)M1(g,o),g=g.sibling;return Ve(jr,jr.current&1|2),Ai&&Uo(c,b.treeForkCount),c.child}o=o.sibling}b.tail!==null&&Oe()>X1&&(c.flags|=128,D=!0,Mp(b,!1),c.lanes=4194304)}else{if(!D)if(o=R1(L),o!==null){if(c.flags|=128,D=!0,o=o.updateQueue,c.updateQueue=o,V1(c,o),Mp(b,!0),b.tail===null&&b.tailMode==="hidden"&&!L.alternate&&!Ai)return cr(c),null}else 2*Oe()-b.renderingStartTime>X1&&g!==536870912&&(c.flags|=128,D=!0,Mp(b,!1),c.lanes=4194304);b.isBackwards?(L.sibling=c.child,c.child=L):(o=b.last,o!==null?o.sibling=L:c.child=L,b.last=L)}return b.tail!==null?(o=b.tail,b.rendering=o,b.tail=o.sibling,b.renderingStartTime=Oe(),o.sibling=null,g=jr.current,Ve(jr,D?g&1|2:g&1),Ai&&Uo(c,b.treeForkCount),o):(cr(c),null);case 22:case 23:return oo(c),kt(),b=c.memoizedState!==null,o!==null?o.memoizedState!==null!==b&&(c.flags|=8192):b&&(c.flags|=8192),b?(g&536870912)!==0&&(c.flags&128)===0&&(cr(c),c.subtreeFlags&6&&(c.flags|=8192)):cr(c),g=c.updateQueue,g!==null&&V1(c,g.retryQueue),g=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),b=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(b=c.memoizedState.cachePool.pool),b!==g&&(c.flags|=2048),o!==null&&Me(It),null;case 24:return g=null,o!==null&&(g=o.memoizedState.cache),c.memoizedState.cache!==g&&(c.flags|=2048),Bo(tn),cr(c),null;case 25:return null;case 30:return null}throw Error(n(156,c.tag))}function NI(o,c){switch(mp(c),c.tag){case 1:return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 3:return Bo(tn),Et(),o=c.flags,(o&65536)!==0&&(o&128)===0?(c.flags=o&-65537|128,c):null;case 26:case 27:case 5:return Pt(c),null;case 31:if(c.memoizedState!==null){if(oo(c),c.alternate===null)throw Error(n(340));ju()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 13:if(oo(c),o=c.memoizedState,o!==null&&o.dehydrated!==null){if(c.alternate===null)throw Error(n(340));ju()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 19:return Me(jr),null;case 4:return Et(),null;case 10:return Bo(c.type),null;case 22:case 23:return oo(c),kt(),o!==null&&Me(It),o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 24:return Bo(tn),null;case 25:return null;default:return null}}function cC(o,c){switch(mp(c),c.tag){case 3:Bo(tn),Et();break;case 26:case 27:case 5:Pt(c);break;case 4:Et();break;case 31:c.memoizedState!==null&&oo(c);break;case 13:oo(c);break;case 19:Me(jr);break;case 10:Bo(c.type);break;case 22:case 23:oo(c),kt(),o!==null&&Me(It);break;case 24:Bo(tn)}}function Ep(o,c){try{var g=c.updateQueue,b=g!==null?g.lastEffect:null;if(b!==null){var D=b.next;g=D;do{if((g.tag&o)===o){b=void 0;var L=g.create,Y=g.inst;b=L(),Y.destroy=b}g=g.next}while(g!==D)}}catch(ue){Vi(c,c.return,ue)}}function Zc(o,c,g){try{var b=c.updateQueue,D=b!==null?b.lastEffect:null;if(D!==null){var L=D.next;b=L;do{if((b.tag&o)===o){var Y=b.inst,ue=Y.destroy;if(ue!==void 0){Y.destroy=void 0,D=c;var Re=g,at=ue;try{at()}catch(vt){Vi(D,Re,vt)}}}b=b.next}while(b!==L)}}catch(vt){Vi(c,c.return,vt)}}function hC(o){var c=o.updateQueue;if(c!==null){var g=o.stateNode;try{kn(c,g)}catch(b){Vi(o,o.return,b)}}}function fC(o,c,g){g.props=ff(o.type,o.memoizedProps),g.state=o.memoizedState;try{g.componentWillUnmount()}catch(b){Vi(o,c,b)}}function Cp(o,c){try{var g=o.ref;if(g!==null){switch(o.tag){case 26:case 27:case 5:var b=o.stateNode;break;case 30:b=o.stateNode;break;default:b=o.stateNode}typeof g=="function"?o.refCleanup=g(b):g.current=b}}catch(D){Vi(o,c,D)}}function Il(o,c){var g=o.ref,b=o.refCleanup;if(g!==null)if(typeof b=="function")try{b()}catch(D){Vi(o,c,D)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof g=="function")try{g(null)}catch(D){Vi(o,c,D)}else g.current=null}function dC(o){var c=o.type,g=o.memoizedProps,b=o.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":g.autoFocus&&b.focus();break e;case"img":g.src?b.src=g.src:g.srcSet&&(b.srcset=g.srcSet)}}catch(D){Vi(o,o.return,D)}}function ob(o,c,g){try{var b=o.stateNode;KI(b,o.type,g,c),b[dn]=c}catch(D){Vi(o,o.return,D)}}function AC(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&sh(o.type)||o.tag===4}function lb(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||AC(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&sh(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function ub(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?(g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g).insertBefore(o,c):(c=g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g,c.appendChild(o),g=g._reactRootContainer,g!=null||c.onclick!==null||(c.onclick=Ro));else if(b!==4&&(b===27&&sh(o.type)&&(g=o.stateNode,c=null),o=o.child,o!==null))for(ub(o,c,g),o=o.sibling;o!==null;)ub(o,c,g),o=o.sibling}function j1(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?g.insertBefore(o,c):g.appendChild(o);else if(b!==4&&(b===27&&sh(o.type)&&(g=o.stateNode),o=o.child,o!==null))for(j1(o,c,g),o=o.sibling;o!==null;)j1(o,c,g),o=o.sibling}function pC(o){var c=o.stateNode,g=o.memoizedProps;try{for(var b=o.type,D=c.attributes;D.length;)c.removeAttributeNode(D[0]);Us(c,b,g),c[$n]=o,c[dn]=g}catch(L){Vi(o,o.return,L)}}var ec=!1,ns=!1,cb=!1,mC=typeof WeakSet=="function"?WeakSet:Set,Ts=null;function RI(o,c){if(o=o.containerInfo,Db=h2,o=Dl(o),Pl(o)){if("selectionStart"in o)var g={start:o.selectionStart,end:o.selectionEnd};else e:{g=(g=o.ownerDocument)&&g.defaultView||window;var b=g.getSelection&&g.getSelection();if(b&&b.rangeCount!==0){g=b.anchorNode;var D=b.anchorOffset,L=b.focusNode;b=b.focusOffset;try{g.nodeType,L.nodeType}catch{g=null;break e}var Y=0,ue=-1,Re=-1,at=0,vt=0,Nt=o,lt=null;t:for(;;){for(var ht;Nt!==g||D!==0&&Nt.nodeType!==3||(ue=Y+D),Nt!==L||b!==0&&Nt.nodeType!==3||(Re=Y+b),Nt.nodeType===3&&(Y+=Nt.nodeValue.length),(ht=Nt.firstChild)!==null;)lt=Nt,Nt=ht;for(;;){if(Nt===o)break t;if(lt===g&&++at===D&&(ue=Y),lt===L&&++vt===b&&(Re=Y),(ht=Nt.nextSibling)!==null)break;Nt=lt,lt=Nt.parentNode}Nt=ht}g=ue===-1||Re===-1?null:{start:ue,end:Re}}else g=null}g=g||{start:0,end:0}}else g=null;for(Pb={focusedElem:o,selectionRange:g},h2=!1,Ts=c;Ts!==null;)if(c=Ts,o=c.child,(c.subtreeFlags&1028)!==0&&o!==null)o.return=c,Ts=o;else for(;Ts!==null;){switch(c=Ts,L=c.alternate,o=c.flags,c.tag){case 0:if((o&4)!==0&&(o=c.updateQueue,o=o!==null?o.events:null,o!==null))for(g=0;g title"))),Us(L,b,g),L[$n]=o,qe(L),b=L;break e;case"link":var Y=b8("link","href",D).get(b+(g.href||""));if(Y){for(var ue=0;ueYi&&(Y=Yi,Yi=Bn,Bn=Y);var Ye=Cd(ue,Bn),ke=Cd(ue,Yi);if(Ye&&ke&&(ht.rangeCount!==1||ht.anchorNode!==Ye.node||ht.anchorOffset!==Ye.offset||ht.focusNode!==ke.node||ht.focusOffset!==ke.offset)){var st=Nt.createRange();st.setStart(Ye.node,Ye.offset),ht.removeAllRanges(),Bn>Yi?(ht.addRange(st),ht.extend(ke.node,ke.offset)):(st.setEnd(ke.node,ke.offset),ht.addRange(st))}}}}for(Nt=[],ht=ue;ht=ht.parentNode;)ht.nodeType===1&&Nt.push({element:ht,left:ht.scrollLeft,top:ht.scrollTop});for(typeof ue.focus=="function"&&ue.focus(),ue=0;ueg?32:g,Z.T=null,g=gb,gb=null;var L=nh,Y=sc;if(fs=0,$d=nh=null,sc=0,(Pi&6)!==0)throw Error(n(331));var ue=Pi;if(Pi|=4,EC(L.current),wC(L,L.current,Y,g),Pi=ue,Up(0,!1),Bt&&typeof Bt.onPostCommitFiberRoot=="function")try{Bt.onPostCommitFiberRoot(Dt,L)}catch{}return!0}finally{te.p=D,Z.T=b,HC(o,c)}}function $C(o,c,g){c=Ta(g,c),c=Qx(o.stateNode,c,2),o=nt(o,c,2),o!==null&&(wn(o,2),Fl(o))}function Vi(o,c,g){if(o.tag===3)$C(o,o,g);else for(;c!==null;){if(c.tag===3){$C(c,o,g);break}else if(c.tag===1){var b=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(th===null||!th.has(b))){o=Ta(g,o),g=X4(2),b=nt(c,g,2),b!==null&&(Y4(g,b,c,o),wn(b,2),Fl(b));break}}c=c.return}}function xb(o,c,g){var b=o.pingCache;if(b===null){b=o.pingCache=new LI;var D=new Set;b.set(c,D)}else D=b.get(c),D===void 0&&(D=new Set,b.set(c,D));D.has(g)||(db=!0,D.add(g),o=FI.bind(null,o,c,g),c.then(o,o))}function FI(o,c,g){var b=o.pingCache;b!==null&&b.delete(c),o.pingedLanes|=o.suspendedLanes&g,o.warmLanes&=~g,nr===o&&(gi&g)===g&&(Br===4||Br===3&&(gi&62914560)===gi&&300>Oe()-$1?(Pi&2)===0&&Xd(o,0):Ab|=g,Wd===gi&&(Wd=0)),Fl(o)}function XC(o,c){c===0&&(c=St()),o=zu(o,c),o!==null&&(wn(o,c),Fl(o))}function kI(o){var c=o.memoizedState,g=0;c!==null&&(g=c.retryLane),XC(o,g)}function zI(o,c){var g=0;switch(o.tag){case 31:case 13:var b=o.stateNode,D=o.memoizedState;D!==null&&(g=D.retryLane);break;case 19:b=o.stateNode;break;case 22:b=o.stateNode._retryCache;break;default:throw Error(n(314))}b!==null&&b.delete(c),XC(o,g)}function GI(o,c){return pt(o,c)}var e2=null,Qd=null,bb=!1,t2=!1,Sb=!1,rh=0;function Fl(o){o!==Qd&&o.next===null&&(Qd===null?e2=Qd=o:Qd=Qd.next=o),t2=!0,bb||(bb=!0,VI())}function Up(o,c){if(!Sb&&t2){Sb=!0;do for(var g=!1,b=e2;b!==null;){if(o!==0){var D=b.pendingLanes;if(D===0)var L=0;else{var Y=b.suspendedLanes,ue=b.pingedLanes;L=(1<<31-jt(42|o)+1)-1,L&=D&~(Y&~ue),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(g=!0,ZC(b,L))}else L=gi,L=Yt(b,b===nr?L:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(L&3)===0||pn(b,L)||(g=!0,ZC(b,L));b=b.next}while(g);Sb=!1}}function qI(){YC()}function YC(){t2=bb=!1;var o=0;rh!==0&&JI()&&(o=rh);for(var c=Oe(),g=null,b=e2;b!==null;){var D=b.next,L=QC(b,c);L===0?(b.next=null,g===null?e2=D:g.next=D,D===null&&(Qd=g)):(g=b,(o!==0||(L&3)!==0)&&(t2=!0)),b=D}fs!==0&&fs!==5||Up(o),rh!==0&&(rh=0)}function QC(o,c){for(var g=o.suspendedLanes,b=o.pingedLanes,D=o.expirationTimes,L=o.pendingLanes&-62914561;0ue)break;var vt=Re.transferSize,Nt=Re.initiatorType;vt&&a8(Nt)&&(Re=Re.responseEnd,Y+=vt*(Re"u"?null:document;function v8(o,c,g){var b=Kd;if(b&&typeof c=="string"&&c){var D=Vr(c);D='link[rel="'+o+'"][href="'+D+'"]',typeof g=="string"&&(D+='[crossorigin="'+g+'"]'),g8.has(D)||(g8.add(D),o={rel:o,crossOrigin:g,href:c},b.querySelector(D)===null&&(c=b.createElement("link"),Us(c,"link",o),qe(c),b.head.appendChild(c)))}}function lF(o){ac.D(o),v8("dns-prefetch",o,null)}function uF(o,c){ac.C(o,c),v8("preconnect",o,c)}function cF(o,c,g){ac.L(o,c,g);var b=Kd;if(b&&o&&c){var D='link[rel="preload"][as="'+Vr(c)+'"]';c==="image"&&g&&g.imageSrcSet?(D+='[imagesrcset="'+Vr(g.imageSrcSet)+'"]',typeof g.imageSizes=="string"&&(D+='[imagesizes="'+Vr(g.imageSizes)+'"]')):D+='[href="'+Vr(o)+'"]';var L=D;switch(c){case"style":L=Zd(o);break;case"script":L=Jd(o)}ko.has(L)||(o=v({rel:"preload",href:c==="image"&&g&&g.imageSrcSet?void 0:o,as:c},g),ko.set(L,o),b.querySelector(D)!==null||c==="style"&&b.querySelector(Fp(L))||c==="script"&&b.querySelector(kp(L))||(c=b.createElement("link"),Us(c,"link",o),qe(c),b.head.appendChild(c)))}}function hF(o,c){ac.m(o,c);var g=Kd;if(g&&o){var b=c&&typeof c.as=="string"?c.as:"script",D='link[rel="modulepreload"][as="'+Vr(b)+'"][href="'+Vr(o)+'"]',L=D;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=Jd(o)}if(!ko.has(L)&&(o=v({rel:"modulepreload",href:o},c),ko.set(L,o),g.querySelector(D)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(g.querySelector(kp(L)))return}b=g.createElement("link"),Us(b,"link",o),qe(b),g.head.appendChild(b)}}}function fF(o,c,g){ac.S(o,c,g);var b=Kd;if(b&&o){var D=it(b).hoistableStyles,L=Zd(o);c=c||"default";var Y=D.get(L);if(!Y){var ue={loading:0,preload:null};if(Y=b.querySelector(Fp(L)))ue.loading=5;else{o=v({rel:"stylesheet",href:o,"data-precedence":c},g),(g=ko.get(L))&&kb(o,g);var Re=Y=b.createElement("link");qe(Re),Us(Re,"link",o),Re._p=new Promise(function(at,vt){Re.onload=at,Re.onerror=vt}),Re.addEventListener("load",function(){ue.loading|=1}),Re.addEventListener("error",function(){ue.loading|=2}),ue.loading|=4,a2(Y,c,b)}Y={type:"stylesheet",instance:Y,count:1,state:ue},D.set(L,Y)}}}function dF(o,c){ac.X(o,c);var g=Kd;if(g&&o){var b=it(g).hoistableScripts,D=Jd(o),L=b.get(D);L||(L=g.querySelector(kp(D)),L||(o=v({src:o,async:!0},c),(c=ko.get(D))&&zb(o,c),L=g.createElement("script"),qe(L),Us(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function AF(o,c){ac.M(o,c);var g=Kd;if(g&&o){var b=it(g).hoistableScripts,D=Jd(o),L=b.get(D);L||(L=g.querySelector(kp(D)),L||(o=v({src:o,async:!0,type:"module"},c),(c=ko.get(D))&&zb(o,c),L=g.createElement("script"),qe(L),Us(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function _8(o,c,g,b){var D=(D=et.current)?s2(D):null;if(!D)throw Error(n(446));switch(o){case"meta":case"title":return null;case"style":return typeof g.precedence=="string"&&typeof g.href=="string"?(c=Zd(g.href),g=it(D).hoistableStyles,b=g.get(c),b||(b={type:"style",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(g.rel==="stylesheet"&&typeof g.href=="string"&&typeof g.precedence=="string"){o=Zd(g.href);var L=it(D).hoistableStyles,Y=L.get(o);if(Y||(D=D.ownerDocument||D,Y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(o,Y),(L=D.querySelector(Fp(o)))&&!L._p&&(Y.instance=L,Y.state.loading=5),ko.has(o)||(g={rel:"preload",as:"style",href:g.href,crossOrigin:g.crossOrigin,integrity:g.integrity,media:g.media,hrefLang:g.hrefLang,referrerPolicy:g.referrerPolicy},ko.set(o,g),L||pF(D,o,g,Y.state))),c&&b===null)throw Error(n(528,""));return Y}if(c&&b!==null)throw Error(n(529,""));return null;case"script":return c=g.async,g=g.src,typeof g=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=Jd(g),g=it(D).hoistableScripts,b=g.get(c),b||(b={type:"script",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,o))}}function Zd(o){return'href="'+Vr(o)+'"'}function Fp(o){return'link[rel="stylesheet"]['+o+"]"}function y8(o){return v({},o,{"data-precedence":o.precedence,precedence:null})}function pF(o,c,g,b){o.querySelector('link[rel="preload"][as="style"]['+c+"]")?b.loading=1:(c=o.createElement("link"),b.preload=c,c.addEventListener("load",function(){return b.loading|=1}),c.addEventListener("error",function(){return b.loading|=2}),Us(c,"link",g),qe(c),o.head.appendChild(c))}function Jd(o){return'[src="'+Vr(o)+'"]'}function kp(o){return"script[async]"+o}function x8(o,c,g){if(c.count++,c.instance===null)switch(c.type){case"style":var b=o.querySelector('style[data-href~="'+Vr(g.href)+'"]');if(b)return c.instance=b,qe(b),b;var D=v({},g,{"data-href":g.href,"data-precedence":g.precedence,href:null,precedence:null});return b=(o.ownerDocument||o).createElement("style"),qe(b),Us(b,"style",D),a2(b,g.precedence,o),c.instance=b;case"stylesheet":D=Zd(g.href);var L=o.querySelector(Fp(D));if(L)return c.state.loading|=4,c.instance=L,qe(L),L;b=y8(g),(D=ko.get(D))&&kb(b,D),L=(o.ownerDocument||o).createElement("link"),qe(L);var Y=L;return Y._p=new Promise(function(ue,Re){Y.onload=ue,Y.onerror=Re}),Us(L,"link",b),c.state.loading|=4,a2(L,g.precedence,o),c.instance=L;case"script":return L=Jd(g.src),(D=o.querySelector(kp(L)))?(c.instance=D,qe(D),D):(b=g,(D=ko.get(L))&&(b=v({},g),zb(b,D)),o=o.ownerDocument||o,D=o.createElement("script"),qe(D),Us(D,"link",b),o.head.appendChild(D),c.instance=D);case"void":return null;default:throw Error(n(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(b=c.instance,c.state.loading|=4,a2(b,g.precedence,o));return c.instance}function a2(o,c,g){for(var b=g.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),D=b.length?b[b.length-1]:null,L=D,Y=0;Y title"):null)}function mF(o,c,g){if(g===1||c.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;switch(c.rel){case"stylesheet":return o=c.disabled,typeof c.precedence=="string"&&o==null;default:return!0}case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function w8(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function gF(o,c,g,b){if(g.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(g.state.loading&4)===0){if(g.instance===null){var D=Zd(b.href),L=c.querySelector(Fp(D));if(L){c=L._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(o.count++,o=l2.bind(o),c.then(o,o)),g.state.loading|=4,g.instance=L,qe(L);return}L=c.ownerDocument||c,b=y8(b),(D=ko.get(D))&&kb(b,D),L=L.createElement("link"),qe(L);var Y=L;Y._p=new Promise(function(ue,Re){Y.onload=ue,Y.onerror=Re}),Us(L,"link",b),g.instance=L}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(g,c),(c=g.state.preload)&&(g.state.loading&3)===0&&(o.count++,g=l2.bind(o),c.addEventListener("load",g),c.addEventListener("error",g))}}var Gb=0;function vF(o,c){return o.stylesheets&&o.count===0&&c2(o,o.stylesheets),0Gb?50:800)+c);return o.unsuspend=g,function(){o.unsuspend=null,clearTimeout(b),clearTimeout(D)}}:null}function l2(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)c2(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var u2=null;function c2(o,c){o.stylesheets=null,o.unsuspend!==null&&(o.count++,u2=new Map,c.forEach(_F,o),u2=null,l2.call(o))}function _F(o,c){if(!(c.state.loading&4)){var g=u2.get(o);if(g)var b=g.get(null);else{g=new Map,u2.set(o,g);for(var D=o.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Yb.exports=BF(),Yb.exports}var IF=OF(),re=bT();const FF=E7(re);/** +`+b.stack}}var Ht=Object.prototype.hasOwnProperty,pt=i.unstable_scheduleCallback,Ae=i.unstable_cancelCallback,k=i.unstable_shouldYield,xe=i.unstable_requestPaint,Oe=i.unstable_now,Ue=i.unstable_getCurrentPriorityLevel,ee=i.unstable_ImmediatePriority,we=i.unstable_UserBlockingPriority,Re=i.unstable_NormalPriority,We=i.unstable_LowPriority,Se=i.unstable_IdlePriority,Le=i.log,ct=i.unstable_setDisableYieldValue,Dt=null,It=null;function lt(o){if(typeof Le=="function"&&ct(o),It&&typeof It.setStrictMode=="function")try{It.setStrictMode(Dt,o)}catch{}}var jt=Math.clz32?Math.clz32:me,Jt=Math.log,In=Math.LN2;function me(o){return o>>>=0,o===0?32:31-(Jt(o)/In|0)|0}var Bt=256,ot=262144,Tt=4194304;function Wt(o){var c=o&42;if(c!==0)return c;switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function Yt(o,c,g){var b=o.pendingLanes;if(b===0)return 0;var D=0,L=o.suspendedLanes,Y=o.pingedLanes;o=o.warmLanes;var ue=b&134217727;return ue!==0?(b=ue&~L,b!==0?D=Wt(b):(Y&=ue,Y!==0?D=Wt(Y):g||(g=ue&~o,g!==0&&(D=Wt(g))))):(ue=b&~L,ue!==0?D=Wt(ue):Y!==0?D=Wt(Y):g||(g=b&~o,g!==0&&(D=Wt(g)))),D===0?0:c!==0&&c!==D&&(c&L)===0&&(L=D&-D,g=c&-c,L>=g||L===32&&(g&4194048)!==0)?c:D}function pn(o,c){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&c)===0}function $e(o,c){switch(o){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function St(){var o=Tt;return Tt<<=1,(Tt&62914560)===0&&(Tt=4194304),o}function Kt(o){for(var c=[],g=0;31>g;g++)c.push(o);return c}function wn(o,c){o.pendingLanes|=c,c!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function qn(o,c,g,b,D,L){var Y=o.pendingLanes;o.pendingLanes=g,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=g,o.entangledLanes&=g,o.errorRecoveryDisabledLanes&=g,o.shellSuspendCounter=0;var ue=o.entanglements,Ne=o.expirationTimes,at=o.hiddenUpdates;for(g=Y&~g;0"u")return null;try{return o.activeElement||o.body}catch{return o.body}}var ys=/[\n"\\]/g;function Vr(o){return o.replace(ys,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Di(o,c,g,b,D,L,Y,ue){o.name="",Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?o.type=Y:o.removeAttribute("type"),c!=null?Y==="number"?(c===0&&o.value===""||o.value!=c)&&(o.value=""+hn(c)):o.value!==""+hn(c)&&(o.value=""+hn(c)):Y!=="submit"&&Y!=="reset"||o.removeAttribute("value"),c!=null?bi(o,Y,hn(c)):g!=null?bi(o,Y,hn(g)):b!=null&&o.removeAttribute("value"),D==null&&L!=null&&(o.defaultChecked=!!L),D!=null&&(o.checked=D&&typeof D!="function"&&typeof D!="symbol"),ue!=null&&typeof ue!="function"&&typeof ue!="symbol"&&typeof ue!="boolean"?o.name=""+hn(ue):o.removeAttribute("name")}function sr(o,c,g,b,D,L,Y,ue){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(o.type=L),c!=null||g!=null){if(!(L!=="submit"&&L!=="reset"||c!=null)){ui(o);return}g=g!=null?""+hn(g):"",c=c!=null?""+hn(c):g,ue||c===o.value||(o.value=c),o.defaultValue=c}b=b??D,b=typeof b!="function"&&typeof b!="symbol"&&!!b,o.checked=ue?o.checked:!!b,o.defaultChecked=!!b,Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"&&(o.name=Y),ui(o)}function bi(o,c,g){c==="number"&&Ps(o.ownerDocument)===o||o.defaultValue===""+g||(o.defaultValue=""+g)}function _r(o,c,g,b){if(o=o.options,c){c={};for(var D=0;D"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_d=!1;if(el)try{var Qh={};Object.defineProperty(Qh,"passive",{get:function(){_d=!0}}),window.addEventListener("test",Qh,Qh),window.removeEventListener("test",Qh,Qh)}catch{_d=!1}var Do=null,Kh=null,yd=null;function J0(){if(yd)return yd;var o,c=Kh,g=c.length,b,D="value"in Do?Do.value:Do.textContent,L=D.length;for(o=0;o=tf),Du=" ",p1=!1;function wd(o,c){switch(o){case"keyup":return bx.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function rp(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Wc=!1;function m1(o,c){switch(o){case"compositionend":return rp(c);case"keypress":return c.which!==32?null:(p1=!0,Du);case"textInput":return o=c.data,o===Du&&p1?null:o;default:return null}}function Sx(o,c){if(Wc)return o==="compositionend"||!Ru&&wd(o,c)?(o=J0(),yd=Kh=Do=null,Wc=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:g,offset:c-o};o=b}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=Ed(g)}}function Bu(o,c){return o&&c?o===c?!0:o&&o.nodeType===3?!1:c&&c.nodeType===3?Bu(o,c.parentNode):"contains"in o?o.contains(c):o.compareDocumentPosition?!!(o.compareDocumentPosition(c)&16):!1:!1}function Dl(o){o=o!=null&&o.ownerDocument!=null&&o.ownerDocument.defaultView!=null?o.ownerDocument.defaultView:window;for(var c=Ps(o.document);c instanceof o.HTMLIFrameElement;){try{var g=typeof c.contentWindow.location.href=="string"}catch{g=!1}if(g)o=c.contentWindow;else break;c=Ps(o.document)}return c}function Pl(o){var c=o&&o.nodeName&&o.nodeName.toLowerCase();return c&&(c==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||c==="textarea"||o.contentEditable==="true")}var Mx=el&&"documentMode"in document&&11>=document.documentMode,Ou=null,up=null,Iu=null,cp=!1;function b1(o,c,g){var b=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;cp||Ou==null||Ou!==Ps(b)||(b=Ou,"selectionStart"in b&&Pl(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Iu&&bs(Iu,b)||(Iu=b,b=i2(up,"onSelect"),0>=Y,D-=Y,Ea=1<<32-jt(c)+D|g<ci?(vi=gn,gn=null):vi=gn.sibling;var Ci=ut(Ye,gn,st[ci],Mt);if(Ci===null){gn===null&&(gn=vi);break}o&&gn&&Ci.alternate===null&&c(Ye,gn),ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci,gn=vi}if(ci===st.length)return g(Ye,gn),Ai&&Uo(Ye,ci),Mn;if(gn===null){for(;cici?(vi=gn,gn=null):vi=gn.sibling;var ch=ut(Ye,gn,Ci.value,Mt);if(ch===null){gn===null&&(gn=vi);break}o&&gn&&ch.alternate===null&&c(Ye,gn),ke=L(ch,ke,ci),Ei===null?Mn=ch:Ei.sibling=ch,Ei=ch,gn=vi}if(Ci.done)return g(Ye,gn),Ai&&Uo(Ye,ci),Mn;if(gn===null){for(;!Ci.done;ci++,Ci=st.next())Ci=Nt(Ye,Ci.value,Mt),Ci!==null&&(ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci);return Ai&&Uo(Ye,ci),Mn}for(gn=b(gn);!Ci.done;ci++,Ci=st.next())Ci=ft(gn,Ye,ci,Ci.value,Mt),Ci!==null&&(o&&Ci.alternate!==null&&gn.delete(Ci.key===null?ci:Ci.key),ke=L(Ci,ke,ci),Ei===null?Mn=Ci:Ei.sibling=Ci,Ei=Ci);return o&&gn.forEach(function(EF){return c(Ye,EF)}),Ai&&Uo(Ye,ci),Mn}function Yi(Ye,ke,st,Mt){if(typeof st=="object"&&st!==null&&st.type===N&&st.key===null&&(st=st.props.children),typeof st=="object"&&st!==null){switch(st.$$typeof){case S:e:{for(var Mn=st.key;ke!==null;){if(ke.key===Mn){if(Mn=st.type,Mn===N){if(ke.tag===7){g(Ye,ke.sibling),Mt=D(ke,st.props.children),Mt.return=Ye,Ye=Mt;break e}}else if(ke.elementType===Mn||typeof Mn=="object"&&Mn!==null&&Mn.$$typeof===H&&f(Mn)===ke.type){g(Ye,ke.sibling),Mt=D(ke,st.props),B(Mt,st),Mt.return=Ye,Ye=Mt;break e}g(Ye,ke);break}else c(Ye,ke);ke=ke.sibling}st.type===N?(Mt=qu(st.props.children,Ye.mode,Mt,st.key),Mt.return=Ye,Ye=Mt):(Mt=Pd(st.type,st.key,st.props,null,Ye.mode,Mt),B(Mt,st),Mt.return=Ye,Ye=Mt)}return Y(Ye);case T:e:{for(Mn=st.key;ke!==null;){if(ke.key===Mn)if(ke.tag===4&&ke.stateNode.containerInfo===st.containerInfo&&ke.stateNode.implementation===st.implementation){g(Ye,ke.sibling),Mt=D(ke,st.children||[]),Mt.return=Ye,Ye=Mt;break e}else{g(Ye,ke);break}else c(Ye,ke);ke=ke.sibling}Mt=Lo(st,Ye.mode,Mt),Mt.return=Ye,Ye=Mt}return Y(Ye);case H:return st=f(st),Yi(Ye,ke,st,Mt)}if(re(st))return An(Ye,ke,st,Mt);if(J(st)){if(Mn=J(st),typeof Mn!="function")throw Error(n(150));return st=Mn.call(st),Bn(Ye,ke,st,Mt)}if(typeof st.then=="function")return Yi(Ye,ke,R(st),Mt);if(st.$$typeof===U)return Yi(Ye,ke,kd(Ye,st),Mt);F(Ye,st)}return typeof st=="string"&&st!==""||typeof st=="number"||typeof st=="bigint"?(st=""+st,ke!==null&&ke.tag===6?(g(Ye,ke.sibling),Mt=D(ke,st),Mt.return=Ye,Ye=Mt):(g(Ye,ke),Mt=pp(st,Ye.mode,Mt),Mt.return=Ye,Ye=Mt),Y(Ye)):g(Ye,ke)}return function(Ye,ke,st,Mt){try{M=0;var Mn=Yi(Ye,ke,st,Mt);return w=null,Mn}catch(gn){if(gn===ll||gn===ao)throw gn;var Ei=$s(29,gn,null,Ye.mode);return Ei.lanes=Mt,Ei.return=Ye,Ei}finally{}}}var oe=W(!0),ve=W(!1),ge=!1;function _e(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function De(o,c){o=o.updateQueue,c.updateQueue===o&&(c.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,callbacks:null})}function ze(o){return{lane:o,tag:0,payload:null,callback:null,next:null}}function nt(o,c,g){var b=o.updateQueue;if(b===null)return null;if(b=b.shared,(Pi&2)!==0){var D=b.pending;return D===null?c.next=c:(c.next=D.next,D.next=c),b.pending=c,c=Dd(o),T1(o,null,g),c}return Rd(o,b,c,g),Dd(o)}function Xe(o,c,g){if(c=c.updateQueue,c!==null&&(c=c.shared,(g&4194048)!==0)){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,dt(o,g)}}function He(o,c){var g=o.updateQueue,b=o.alternate;if(b!==null&&(b=b.updateQueue,g===b)){var D=null,L=null;if(g=g.firstBaseUpdate,g!==null){do{var Y={lane:g.lane,tag:g.tag,payload:g.payload,callback:null,next:null};L===null?D=L=Y:L=L.next=Y,g=g.next}while(g!==null);L===null?D=L=c:L=L.next=c}else D=L=c;g={baseState:b.baseState,firstBaseUpdate:D,lastBaseUpdate:L,shared:b.shared,callbacks:b.callbacks},o.updateQueue=g;return}o=g.lastBaseUpdate,o===null?g.firstBaseUpdate=c:o.next=c,g.lastBaseUpdate=c}var Pe=!1;function kt(){if(Pe){var o=ur;if(o!==null)throw o}}function un(o,c,g,b){Pe=!1;var D=o.updateQueue;ge=!1;var L=D.firstBaseUpdate,Y=D.lastBaseUpdate,ue=D.shared.pending;if(ue!==null){D.shared.pending=null;var Ne=ue,at=Ne.next;Ne.next=null,Y===null?L=at:Y.next=at,Y=Ne;var vt=o.alternate;vt!==null&&(vt=vt.updateQueue,ue=vt.lastBaseUpdate,ue!==Y&&(ue===null?vt.firstBaseUpdate=at:ue.next=at,vt.lastBaseUpdate=Ne))}if(L!==null){var Nt=D.baseState;Y=0,vt=at=Ne=null,ue=L;do{var ut=ue.lane&-536870913,ft=ut!==ue.lane;if(ft?(gi&ut)===ut:(b&ut)===ut){ut!==0&&ut===Qc&&(Pe=!0),vt!==null&&(vt=vt.next={lane:0,tag:ue.tag,payload:ue.payload,callback:null,next:null});e:{var An=o,Bn=ue;ut=c;var Yi=g;switch(Bn.tag){case 1:if(An=Bn.payload,typeof An=="function"){Nt=An.call(Yi,Nt,ut);break e}Nt=An;break e;case 3:An.flags=An.flags&-65537|128;case 0:if(An=Bn.payload,ut=typeof An=="function"?An.call(Yi,Nt,ut):An,ut==null)break e;Nt=v({},Nt,ut);break e;case 2:ge=!0}}ut=ue.callback,ut!==null&&(o.flags|=64,ft&&(o.flags|=8192),ft=D.callbacks,ft===null?D.callbacks=[ut]:ft.push(ut))}else ft={lane:ut,tag:ue.tag,payload:ue.payload,callback:ue.callback,next:null},vt===null?(at=vt=ft,Ne=Nt):vt=vt.next=ft,Y|=ut;if(ue=ue.next,ue===null){if(ue=D.shared.pending,ue===null)break;ft=ue,ue=ft.next,ft.next=null,D.lastBaseUpdate=ft,D.shared.pending=null}}while(!0);vt===null&&(Ne=Nt),D.baseState=Ne,D.firstBaseUpdate=at,D.lastBaseUpdate=vt,L===null&&(D.shared.lanes=0),eh|=Y,o.lanes=Y,o.memoizedState=Nt}}function on(o,c){if(typeof o!="function")throw Error(n(191,o));o.call(c)}function kn(o,c){var g=o.callbacks;if(g!==null)for(o.callbacks=null,o=0;oL?L:8;var Y=Z.T,ue={};Z.T=ue,Wx(o,!1,c,g);try{var Ne=D(),at=Z.S;if(at!==null&&at(ue,Ne),Ne!==null&&typeof Ne=="object"&&typeof Ne.then=="function"){var vt=N1(Ne,b);Sp(o,c,vt,co(o))}else Sp(o,c,b,co(o))}catch(Nt){Sp(o,c,{then:function(){},status:"rejected",reason:Nt},co())}finally{ne.p=L,Y!==null&&ue.types!==null&&(Y.types=ue.types),Z.T=Y}}function bI(){}function jx(o,c,g,b){if(o.tag!==5)throw Error(n(476));var D=L4(o).queue;P4(o,D,c,de,g===null?bI:function(){return U4(o),g(b)})}function L4(o){var c=o.memoizedState;if(c!==null)return c;c={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ku,lastRenderedState:de},next:null};var g={};return c.next={memoizedState:g,baseState:g,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ku,lastRenderedState:g},next:null},o.memoizedState=c,o=o.alternate,o!==null&&(o.memoizedState=c),c}function U4(o){var c=L4(o);c.next===null&&(c=o.alternate.memoizedState),Sp(o,c.next.queue,{},co())}function Hx(){return hs(zp)}function B4(){return Hr().memoizedState}function O4(){return Hr().memoizedState}function SI(o){for(var c=o.return;c!==null;){switch(c.tag){case 24:case 3:var g=co();o=ze(g);var b=nt(c,o,g);b!==null&&(Ua(b,c,g),Xe(b,c,g)),c={cache:Lr()},o.payload=c;return}c=c.return}}function wI(o,c,g){var b=co();g={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},F1(o)?F4(c,g):(g=Ap(o,c,g,b),g!==null&&(Ua(g,o,b),k4(g,c,b)))}function I4(o,c,g){var b=co();Sp(o,c,g,b)}function Sp(o,c,g,b){var D={lane:b,revertLane:0,gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null};if(F1(o))F4(c,D);else{var L=o.alternate;if(o.lanes===0&&(L===null||L.lanes===0)&&(L=c.lastRenderedReducer,L!==null))try{var Y=c.lastRenderedState,ue=L(Y,g);if(D.hasEagerState=!0,D.eagerState=ue,ha(ue,Y))return Rd(o,c,D,0),nr===null&&Nd(),!1}catch{}finally{}if(g=Ap(o,c,D,b),g!==null)return Ua(g,o,b),k4(g,c,b),!0}return!1}function Wx(o,c,g,b){if(b={lane:2,revertLane:wb(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},F1(o)){if(c)throw Error(n(479))}else c=Ap(o,g,b,2),c!==null&&Ua(c,o,2)}function F1(o){var c=o.alternate;return o===ai||c!==null&&c===ai}function F4(o,c){zd=D1=!0;var g=o.pending;g===null?c.next=c:(c.next=g.next,g.next=c),o.pending=c}function k4(o,c,g){if((g&4194048)!==0){var b=c.lanes;b&=o.pendingLanes,g|=b,c.lanes=g,dt(o,g)}}var wp={readContext:hs,use:U1,useCallback:Ur,useContext:Ur,useEffect:Ur,useImperativeHandle:Ur,useLayoutEffect:Ur,useInsertionEffect:Ur,useMemo:Ur,useReducer:Ur,useRef:Ur,useState:Ur,useDebugValue:Ur,useDeferredValue:Ur,useTransition:Ur,useSyncExternalStore:Ur,useId:Ur,useHostTransitionStatus:Ur,useFormState:Ur,useActionState:Ur,useOptimistic:Ur,useMemoCache:Ur,useCacheRefresh:Ur};wp.useEffectEvent=Ur;var z4={readContext:hs,use:U1,useCallback:function(o,c){return Aa().memoizedState=[o,c===void 0?null:c],o},useContext:hs,useEffect:S4,useImperativeHandle:function(o,c,g){g=g!=null?g.concat([o]):null,O1(4194308,4,E4.bind(null,c,o),g)},useLayoutEffect:function(o,c){return O1(4194308,4,o,c)},useInsertionEffect:function(o,c){O1(4,2,o,c)},useMemo:function(o,c){var g=Aa();c=c===void 0?null:c;var b=o();if(hf){lt(!0);try{o()}finally{lt(!1)}}return g.memoizedState=[b,c],b},useReducer:function(o,c,g){var b=Aa();if(g!==void 0){var D=g(c);if(hf){lt(!0);try{g(c)}finally{lt(!1)}}}else D=c;return b.memoizedState=b.baseState=D,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:D},b.queue=o,o=o.dispatch=wI.bind(null,ai,o),[b.memoizedState,o]},useRef:function(o){var c=Aa();return o={current:o},c.memoizedState=o},useState:function(o){o=kx(o);var c=o.queue,g=I4.bind(null,ai,c);return c.dispatch=g,[o.memoizedState,g]},useDebugValue:qx,useDeferredValue:function(o,c){var g=Aa();return Vx(g,o,c)},useTransition:function(){var o=kx(!1);return o=P4.bind(null,ai,o.queue,!0,!1),Aa().memoizedState=o,[!1,o]},useSyncExternalStore:function(o,c,g){var b=ai,D=Aa();if(Ai){if(g===void 0)throw Error(n(407));g=g()}else{if(g=c(),nr===null)throw Error(n(349));(gi&127)!==0||o4(b,c,g)}D.memoizedState=g;var L={value:g,getSnapshot:c};return D.queue=L,S4(u4.bind(null,b,L,o),[o]),b.flags|=2048,qd(9,{destroy:void 0},l4.bind(null,b,L,g,c),null),g},useId:function(){var o=Aa(),c=nr.identifierPrefix;if(Ai){var g=Ca,b=Ea;g=(b&~(1<<32-jt(b)-1)).toString(32)+g,c="_"+c+"R_"+g,g=P1++,0<\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof b.is=="string"?Y.createElement("select",{is:b.is}):Y.createElement("select"),b.multiple?L.multiple=!0:b.size&&(L.size=b.size);break;default:L=typeof b.is=="string"?Y.createElement(D,{is:b.is}):Y.createElement(D)}}L[$n]=c,L[dn]=b;e:for(Y=c.child;Y!==null;){if(Y.tag===5||Y.tag===6)L.appendChild(Y.stateNode);else if(Y.tag!==4&&Y.tag!==27&&Y.child!==null){Y.child.return=Y,Y=Y.child;continue}if(Y===c)break e;for(;Y.sibling===null;){if(Y.return===null||Y.return===c)break e;Y=Y.return}Y.sibling.return=Y.return,Y=Y.sibling}c.stateNode=L;e:switch(Us(L,D,b),D){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&Ju(c)}}return cr(c),ab(c,c.type,o===null?null:o.memoizedProps,c.pendingProps,g),null;case 6:if(o&&c.stateNode!=null)o.memoizedProps!==b&&Ju(c);else{if(typeof b!="string"&&c.stateNode===null)throw Error(n(166));if(o=tt.current,tr(c)){if(o=c.stateNode,g=c.memoizedProps,b=null,D=cs,D!==null)switch(D.tag){case 27:case 5:b=D.memoizedProps}o[$n]=c,o=!!(o.nodeValue===g||b!==null&&b.suppressHydrationWarning===!0||s8(o.nodeValue,g)),o||Bl(c,!0)}else o=r2(o).createTextNode(b),o[$n]=c,c.stateNode=o}return cr(c),null;case 31:if(g=c.memoizedState,o===null||o.memoizedState!==null){if(b=tr(c),g!==null){if(o===null){if(!b)throw Error(n(318));if(o=c.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(557));o[$n]=c}else ju(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;cr(c),o=!1}else g=yp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=g),o=!0;if(!o)return c.flags&256?(oo(c),c):(oo(c),null);if((c.flags&128)!==0)throw Error(n(558))}return cr(c),null;case 13:if(b=c.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(D=tr(c),b!==null&&b.dehydrated!==null){if(o===null){if(!D)throw Error(n(318));if(D=c.memoizedState,D=D!==null?D.dehydrated:null,!D)throw Error(n(317));D[$n]=c}else ju(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;cr(c),D=!1}else D=yp(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=D),D=!0;if(!D)return c.flags&256?(oo(c),c):(oo(c),null)}return oo(c),(c.flags&128)!==0?(c.lanes=g,c):(g=b!==null,o=o!==null&&o.memoizedState!==null,g&&(b=c.child,D=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(D=b.alternate.memoizedState.cachePool.pool),L=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(L=b.memoizedState.cachePool.pool),L!==D&&(b.flags|=2048)),g!==o&&g&&(c.child.flags|=8192),V1(c,c.updateQueue),cr(c),null);case 4:return Et(),o===null&&Cb(c.stateNode.containerInfo),cr(c),null;case 10:return Bo(c.type),cr(c),null;case 19:if(Me(jr),b=c.memoizedState,b===null)return cr(c),null;if(D=(c.flags&128)!==0,L=b.rendering,L===null)if(D)Mp(b,!1);else{if(Br!==0||o!==null&&(o.flags&128)!==0)for(o=c.child;o!==null;){if(L=R1(o),L!==null){for(c.flags|=128,Mp(b,!1),o=L.updateQueue,c.updateQueue=o,V1(c,o),c.subtreeFlags=0,o=g,g=c.child;g!==null;)M1(g,o),g=g.sibling;return Ve(jr,jr.current&1|2),Ai&&Uo(c,b.treeForkCount),c.child}o=o.sibling}b.tail!==null&&Oe()>X1&&(c.flags|=128,D=!0,Mp(b,!1),c.lanes=4194304)}else{if(!D)if(o=R1(L),o!==null){if(c.flags|=128,D=!0,o=o.updateQueue,c.updateQueue=o,V1(c,o),Mp(b,!0),b.tail===null&&b.tailMode==="hidden"&&!L.alternate&&!Ai)return cr(c),null}else 2*Oe()-b.renderingStartTime>X1&&g!==536870912&&(c.flags|=128,D=!0,Mp(b,!1),c.lanes=4194304);b.isBackwards?(L.sibling=c.child,c.child=L):(o=b.last,o!==null?o.sibling=L:c.child=L,b.last=L)}return b.tail!==null?(o=b.tail,b.rendering=o,b.tail=o.sibling,b.renderingStartTime=Oe(),o.sibling=null,g=jr.current,Ve(jr,D?g&1|2:g&1),Ai&&Uo(c,b.treeForkCount),o):(cr(c),null);case 22:case 23:return oo(c),zt(),b=c.memoizedState!==null,o!==null?o.memoizedState!==null!==b&&(c.flags|=8192):b&&(c.flags|=8192),b?(g&536870912)!==0&&(c.flags&128)===0&&(cr(c),c.subtreeFlags&6&&(c.flags|=8192)):cr(c),g=c.updateQueue,g!==null&&V1(c,g.retryQueue),g=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),b=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(b=c.memoizedState.cachePool.pool),b!==g&&(c.flags|=2048),o!==null&&Me(Ot),null;case 24:return g=null,o!==null&&(g=o.memoizedState.cache),c.memoizedState.cache!==g&&(c.flags|=2048),Bo(tn),cr(c),null;case 25:return null;case 30:return null}throw Error(n(156,c.tag))}function NI(o,c){switch(mp(c),c.tag){case 1:return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 3:return Bo(tn),Et(),o=c.flags,(o&65536)!==0&&(o&128)===0?(c.flags=o&-65537|128,c):null;case 26:case 27:case 5:return Ut(c),null;case 31:if(c.memoizedState!==null){if(oo(c),c.alternate===null)throw Error(n(340));ju()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 13:if(oo(c),o=c.memoizedState,o!==null&&o.dehydrated!==null){if(c.alternate===null)throw Error(n(340));ju()}return o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 19:return Me(jr),null;case 4:return Et(),null;case 10:return Bo(c.type),null;case 22:case 23:return oo(c),zt(),o!==null&&Me(Ot),o=c.flags,o&65536?(c.flags=o&-65537|128,c):null;case 24:return Bo(tn),null;case 25:return null;default:return null}}function cC(o,c){switch(mp(c),c.tag){case 3:Bo(tn),Et();break;case 26:case 27:case 5:Ut(c);break;case 4:Et();break;case 31:c.memoizedState!==null&&oo(c);break;case 13:oo(c);break;case 19:Me(jr);break;case 10:Bo(c.type);break;case 22:case 23:oo(c),zt(),o!==null&&Me(Ot);break;case 24:Bo(tn)}}function Ep(o,c){try{var g=c.updateQueue,b=g!==null?g.lastEffect:null;if(b!==null){var D=b.next;g=D;do{if((g.tag&o)===o){b=void 0;var L=g.create,Y=g.inst;b=L(),Y.destroy=b}g=g.next}while(g!==D)}}catch(ue){Vi(c,c.return,ue)}}function Zc(o,c,g){try{var b=c.updateQueue,D=b!==null?b.lastEffect:null;if(D!==null){var L=D.next;b=L;do{if((b.tag&o)===o){var Y=b.inst,ue=Y.destroy;if(ue!==void 0){Y.destroy=void 0,D=c;var Ne=g,at=ue;try{at()}catch(vt){Vi(D,Ne,vt)}}}b=b.next}while(b!==L)}}catch(vt){Vi(c,c.return,vt)}}function hC(o){var c=o.updateQueue;if(c!==null){var g=o.stateNode;try{kn(c,g)}catch(b){Vi(o,o.return,b)}}}function fC(o,c,g){g.props=ff(o.type,o.memoizedProps),g.state=o.memoizedState;try{g.componentWillUnmount()}catch(b){Vi(o,c,b)}}function Cp(o,c){try{var g=o.ref;if(g!==null){switch(o.tag){case 26:case 27:case 5:var b=o.stateNode;break;case 30:b=o.stateNode;break;default:b=o.stateNode}typeof g=="function"?o.refCleanup=g(b):g.current=b}}catch(D){Vi(o,c,D)}}function Il(o,c){var g=o.ref,b=o.refCleanup;if(g!==null)if(typeof b=="function")try{b()}catch(D){Vi(o,c,D)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof g=="function")try{g(null)}catch(D){Vi(o,c,D)}else g.current=null}function dC(o){var c=o.type,g=o.memoizedProps,b=o.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":g.autoFocus&&b.focus();break e;case"img":g.src?b.src=g.src:g.srcSet&&(b.srcset=g.srcSet)}}catch(D){Vi(o,o.return,D)}}function ob(o,c,g){try{var b=o.stateNode;KI(b,o.type,g,c),b[dn]=c}catch(D){Vi(o,o.return,D)}}function AC(o){return o.tag===5||o.tag===3||o.tag===26||o.tag===27&&sh(o.type)||o.tag===4}function lb(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||AC(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.tag===27&&sh(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function ub(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?(g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g).insertBefore(o,c):(c=g.nodeType===9?g.body:g.nodeName==="HTML"?g.ownerDocument.body:g,c.appendChild(o),g=g._reactRootContainer,g!=null||c.onclick!==null||(c.onclick=Ro));else if(b!==4&&(b===27&&sh(o.type)&&(g=o.stateNode,c=null),o=o.child,o!==null))for(ub(o,c,g),o=o.sibling;o!==null;)ub(o,c,g),o=o.sibling}function j1(o,c,g){var b=o.tag;if(b===5||b===6)o=o.stateNode,c?g.insertBefore(o,c):g.appendChild(o);else if(b!==4&&(b===27&&sh(o.type)&&(g=o.stateNode),o=o.child,o!==null))for(j1(o,c,g),o=o.sibling;o!==null;)j1(o,c,g),o=o.sibling}function pC(o){var c=o.stateNode,g=o.memoizedProps;try{for(var b=o.type,D=c.attributes;D.length;)c.removeAttributeNode(D[0]);Us(c,b,g),c[$n]=o,c[dn]=g}catch(L){Vi(o,o.return,L)}}var ec=!1,ns=!1,cb=!1,mC=typeof WeakSet=="function"?WeakSet:Set,Ts=null;function RI(o,c){if(o=o.containerInfo,Db=h2,o=Dl(o),Pl(o)){if("selectionStart"in o)var g={start:o.selectionStart,end:o.selectionEnd};else e:{g=(g=o.ownerDocument)&&g.defaultView||window;var b=g.getSelection&&g.getSelection();if(b&&b.rangeCount!==0){g=b.anchorNode;var D=b.anchorOffset,L=b.focusNode;b=b.focusOffset;try{g.nodeType,L.nodeType}catch{g=null;break e}var Y=0,ue=-1,Ne=-1,at=0,vt=0,Nt=o,ut=null;t:for(;;){for(var ft;Nt!==g||D!==0&&Nt.nodeType!==3||(ue=Y+D),Nt!==L||b!==0&&Nt.nodeType!==3||(Ne=Y+b),Nt.nodeType===3&&(Y+=Nt.nodeValue.length),(ft=Nt.firstChild)!==null;)ut=Nt,Nt=ft;for(;;){if(Nt===o)break t;if(ut===g&&++at===D&&(ue=Y),ut===L&&++vt===b&&(Ne=Y),(ft=Nt.nextSibling)!==null)break;Nt=ut,ut=Nt.parentNode}Nt=ft}g=ue===-1||Ne===-1?null:{start:ue,end:Ne}}else g=null}g=g||{start:0,end:0}}else g=null;for(Pb={focusedElem:o,selectionRange:g},h2=!1,Ts=c;Ts!==null;)if(c=Ts,o=c.child,(c.subtreeFlags&1028)!==0&&o!==null)o.return=c,Ts=o;else for(;Ts!==null;){switch(c=Ts,L=c.alternate,o=c.flags,c.tag){case 0:if((o&4)!==0&&(o=c.updateQueue,o=o!==null?o.events:null,o!==null))for(g=0;g title"))),Us(L,b,g),L[$n]=o,qe(L),b=L;break e;case"link":var Y=b8("link","href",D).get(b+(g.href||""));if(Y){for(var ue=0;ueYi&&(Y=Yi,Yi=Bn,Bn=Y);var Ye=Cd(ue,Bn),ke=Cd(ue,Yi);if(Ye&&ke&&(ft.rangeCount!==1||ft.anchorNode!==Ye.node||ft.anchorOffset!==Ye.offset||ft.focusNode!==ke.node||ft.focusOffset!==ke.offset)){var st=Nt.createRange();st.setStart(Ye.node,Ye.offset),ft.removeAllRanges(),Bn>Yi?(ft.addRange(st),ft.extend(ke.node,ke.offset)):(st.setEnd(ke.node,ke.offset),ft.addRange(st))}}}}for(Nt=[],ft=ue;ft=ft.parentNode;)ft.nodeType===1&&Nt.push({element:ft,left:ft.scrollLeft,top:ft.scrollTop});for(typeof ue.focus=="function"&&ue.focus(),ue=0;ueg?32:g,Z.T=null,g=gb,gb=null;var L=nh,Y=sc;if(fs=0,$d=nh=null,sc=0,(Pi&6)!==0)throw Error(n(331));var ue=Pi;if(Pi|=4,EC(L.current),wC(L,L.current,Y,g),Pi=ue,Up(0,!1),It&&typeof It.onPostCommitFiberRoot=="function")try{It.onPostCommitFiberRoot(Dt,L)}catch{}return!0}finally{ne.p=D,Z.T=b,HC(o,c)}}function $C(o,c,g){c=Ta(g,c),c=Qx(o.stateNode,c,2),o=nt(o,c,2),o!==null&&(wn(o,2),Fl(o))}function Vi(o,c,g){if(o.tag===3)$C(o,o,g);else for(;c!==null;){if(c.tag===3){$C(c,o,g);break}else if(c.tag===1){var b=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(th===null||!th.has(b))){o=Ta(g,o),g=X4(2),b=nt(c,g,2),b!==null&&(Y4(g,b,c,o),wn(b,2),Fl(b));break}}c=c.return}}function xb(o,c,g){var b=o.pingCache;if(b===null){b=o.pingCache=new LI;var D=new Set;b.set(c,D)}else D=b.get(c),D===void 0&&(D=new Set,b.set(c,D));D.has(g)||(db=!0,D.add(g),o=FI.bind(null,o,c,g),c.then(o,o))}function FI(o,c,g){var b=o.pingCache;b!==null&&b.delete(c),o.pingedLanes|=o.suspendedLanes&g,o.warmLanes&=~g,nr===o&&(gi&g)===g&&(Br===4||Br===3&&(gi&62914560)===gi&&300>Oe()-$1?(Pi&2)===0&&Xd(o,0):Ab|=g,Wd===gi&&(Wd=0)),Fl(o)}function XC(o,c){c===0&&(c=St()),o=zu(o,c),o!==null&&(wn(o,c),Fl(o))}function kI(o){var c=o.memoizedState,g=0;c!==null&&(g=c.retryLane),XC(o,g)}function zI(o,c){var g=0;switch(o.tag){case 31:case 13:var b=o.stateNode,D=o.memoizedState;D!==null&&(g=D.retryLane);break;case 19:b=o.stateNode;break;case 22:b=o.stateNode._retryCache;break;default:throw Error(n(314))}b!==null&&b.delete(c),XC(o,g)}function GI(o,c){return pt(o,c)}var e2=null,Qd=null,bb=!1,t2=!1,Sb=!1,rh=0;function Fl(o){o!==Qd&&o.next===null&&(Qd===null?e2=Qd=o:Qd=Qd.next=o),t2=!0,bb||(bb=!0,VI())}function Up(o,c){if(!Sb&&t2){Sb=!0;do for(var g=!1,b=e2;b!==null;){if(o!==0){var D=b.pendingLanes;if(D===0)var L=0;else{var Y=b.suspendedLanes,ue=b.pingedLanes;L=(1<<31-jt(42|o)+1)-1,L&=D&~(Y&~ue),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(g=!0,ZC(b,L))}else L=gi,L=Yt(b,b===nr?L:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(L&3)===0||pn(b,L)||(g=!0,ZC(b,L));b=b.next}while(g);Sb=!1}}function qI(){YC()}function YC(){t2=bb=!1;var o=0;rh!==0&&JI()&&(o=rh);for(var c=Oe(),g=null,b=e2;b!==null;){var D=b.next,L=QC(b,c);L===0?(b.next=null,g===null?e2=D:g.next=D,D===null&&(Qd=g)):(g=b,(o!==0||(L&3)!==0)&&(t2=!0)),b=D}fs!==0&&fs!==5||Up(o),rh!==0&&(rh=0)}function QC(o,c){for(var g=o.suspendedLanes,b=o.pingedLanes,D=o.expirationTimes,L=o.pendingLanes&-62914561;0ue)break;var vt=Ne.transferSize,Nt=Ne.initiatorType;vt&&a8(Nt)&&(Ne=Ne.responseEnd,Y+=vt*(Ne"u"?null:document;function v8(o,c,g){var b=Kd;if(b&&typeof c=="string"&&c){var D=Vr(c);D='link[rel="'+o+'"][href="'+D+'"]',typeof g=="string"&&(D+='[crossorigin="'+g+'"]'),g8.has(D)||(g8.add(D),o={rel:o,crossOrigin:g,href:c},b.querySelector(D)===null&&(c=b.createElement("link"),Us(c,"link",o),qe(c),b.head.appendChild(c)))}}function lF(o){ac.D(o),v8("dns-prefetch",o,null)}function uF(o,c){ac.C(o,c),v8("preconnect",o,c)}function cF(o,c,g){ac.L(o,c,g);var b=Kd;if(b&&o&&c){var D='link[rel="preload"][as="'+Vr(c)+'"]';c==="image"&&g&&g.imageSrcSet?(D+='[imagesrcset="'+Vr(g.imageSrcSet)+'"]',typeof g.imageSizes=="string"&&(D+='[imagesizes="'+Vr(g.imageSizes)+'"]')):D+='[href="'+Vr(o)+'"]';var L=D;switch(c){case"style":L=Zd(o);break;case"script":L=Jd(o)}ko.has(L)||(o=v({rel:"preload",href:c==="image"&&g&&g.imageSrcSet?void 0:o,as:c},g),ko.set(L,o),b.querySelector(D)!==null||c==="style"&&b.querySelector(Fp(L))||c==="script"&&b.querySelector(kp(L))||(c=b.createElement("link"),Us(c,"link",o),qe(c),b.head.appendChild(c)))}}function hF(o,c){ac.m(o,c);var g=Kd;if(g&&o){var b=c&&typeof c.as=="string"?c.as:"script",D='link[rel="modulepreload"][as="'+Vr(b)+'"][href="'+Vr(o)+'"]',L=D;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=Jd(o)}if(!ko.has(L)&&(o=v({rel:"modulepreload",href:o},c),ko.set(L,o),g.querySelector(D)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(g.querySelector(kp(L)))return}b=g.createElement("link"),Us(b,"link",o),qe(b),g.head.appendChild(b)}}}function fF(o,c,g){ac.S(o,c,g);var b=Kd;if(b&&o){var D=it(b).hoistableStyles,L=Zd(o);c=c||"default";var Y=D.get(L);if(!Y){var ue={loading:0,preload:null};if(Y=b.querySelector(Fp(L)))ue.loading=5;else{o=v({rel:"stylesheet",href:o,"data-precedence":c},g),(g=ko.get(L))&&kb(o,g);var Ne=Y=b.createElement("link");qe(Ne),Us(Ne,"link",o),Ne._p=new Promise(function(at,vt){Ne.onload=at,Ne.onerror=vt}),Ne.addEventListener("load",function(){ue.loading|=1}),Ne.addEventListener("error",function(){ue.loading|=2}),ue.loading|=4,a2(Y,c,b)}Y={type:"stylesheet",instance:Y,count:1,state:ue},D.set(L,Y)}}}function dF(o,c){ac.X(o,c);var g=Kd;if(g&&o){var b=it(g).hoistableScripts,D=Jd(o),L=b.get(D);L||(L=g.querySelector(kp(D)),L||(o=v({src:o,async:!0},c),(c=ko.get(D))&&zb(o,c),L=g.createElement("script"),qe(L),Us(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function AF(o,c){ac.M(o,c);var g=Kd;if(g&&o){var b=it(g).hoistableScripts,D=Jd(o),L=b.get(D);L||(L=g.querySelector(kp(D)),L||(o=v({src:o,async:!0,type:"module"},c),(c=ko.get(D))&&zb(o,c),L=g.createElement("script"),qe(L),Us(L,"link",o),g.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},b.set(D,L))}}function _8(o,c,g,b){var D=(D=tt.current)?s2(D):null;if(!D)throw Error(n(446));switch(o){case"meta":case"title":return null;case"style":return typeof g.precedence=="string"&&typeof g.href=="string"?(c=Zd(g.href),g=it(D).hoistableStyles,b=g.get(c),b||(b={type:"style",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(g.rel==="stylesheet"&&typeof g.href=="string"&&typeof g.precedence=="string"){o=Zd(g.href);var L=it(D).hoistableStyles,Y=L.get(o);if(Y||(D=D.ownerDocument||D,Y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(o,Y),(L=D.querySelector(Fp(o)))&&!L._p&&(Y.instance=L,Y.state.loading=5),ko.has(o)||(g={rel:"preload",as:"style",href:g.href,crossOrigin:g.crossOrigin,integrity:g.integrity,media:g.media,hrefLang:g.hrefLang,referrerPolicy:g.referrerPolicy},ko.set(o,g),L||pF(D,o,g,Y.state))),c&&b===null)throw Error(n(528,""));return Y}if(c&&b!==null)throw Error(n(529,""));return null;case"script":return c=g.async,g=g.src,typeof g=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=Jd(g),g=it(D).hoistableScripts,b=g.get(c),b||(b={type:"script",instance:null,count:0,state:null},g.set(c,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,o))}}function Zd(o){return'href="'+Vr(o)+'"'}function Fp(o){return'link[rel="stylesheet"]['+o+"]"}function y8(o){return v({},o,{"data-precedence":o.precedence,precedence:null})}function pF(o,c,g,b){o.querySelector('link[rel="preload"][as="style"]['+c+"]")?b.loading=1:(c=o.createElement("link"),b.preload=c,c.addEventListener("load",function(){return b.loading|=1}),c.addEventListener("error",function(){return b.loading|=2}),Us(c,"link",g),qe(c),o.head.appendChild(c))}function Jd(o){return'[src="'+Vr(o)+'"]'}function kp(o){return"script[async]"+o}function x8(o,c,g){if(c.count++,c.instance===null)switch(c.type){case"style":var b=o.querySelector('style[data-href~="'+Vr(g.href)+'"]');if(b)return c.instance=b,qe(b),b;var D=v({},g,{"data-href":g.href,"data-precedence":g.precedence,href:null,precedence:null});return b=(o.ownerDocument||o).createElement("style"),qe(b),Us(b,"style",D),a2(b,g.precedence,o),c.instance=b;case"stylesheet":D=Zd(g.href);var L=o.querySelector(Fp(D));if(L)return c.state.loading|=4,c.instance=L,qe(L),L;b=y8(g),(D=ko.get(D))&&kb(b,D),L=(o.ownerDocument||o).createElement("link"),qe(L);var Y=L;return Y._p=new Promise(function(ue,Ne){Y.onload=ue,Y.onerror=Ne}),Us(L,"link",b),c.state.loading|=4,a2(L,g.precedence,o),c.instance=L;case"script":return L=Jd(g.src),(D=o.querySelector(kp(L)))?(c.instance=D,qe(D),D):(b=g,(D=ko.get(L))&&(b=v({},g),zb(b,D)),o=o.ownerDocument||o,D=o.createElement("script"),qe(D),Us(D,"link",b),o.head.appendChild(D),c.instance=D);case"void":return null;default:throw Error(n(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(b=c.instance,c.state.loading|=4,a2(b,g.precedence,o));return c.instance}function a2(o,c,g){for(var b=g.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),D=b.length?b[b.length-1]:null,L=D,Y=0;Y title"):null)}function mF(o,c,g){if(g===1||c.itemProp!=null)return!1;switch(o){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;switch(c.rel){case"stylesheet":return o=c.disabled,typeof c.precedence=="string"&&o==null;default:return!0}case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function w8(o){return!(o.type==="stylesheet"&&(o.state.loading&3)===0)}function gF(o,c,g,b){if(g.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(g.state.loading&4)===0){if(g.instance===null){var D=Zd(b.href),L=c.querySelector(Fp(D));if(L){c=L._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(o.count++,o=l2.bind(o),c.then(o,o)),g.state.loading|=4,g.instance=L,qe(L);return}L=c.ownerDocument||c,b=y8(b),(D=ko.get(D))&&kb(b,D),L=L.createElement("link"),qe(L);var Y=L;Y._p=new Promise(function(ue,Ne){Y.onload=ue,Y.onerror=Ne}),Us(L,"link",b),g.instance=L}o.stylesheets===null&&(o.stylesheets=new Map),o.stylesheets.set(g,c),(c=g.state.preload)&&(g.state.loading&3)===0&&(o.count++,g=l2.bind(o),c.addEventListener("load",g),c.addEventListener("error",g))}}var Gb=0;function vF(o,c){return o.stylesheets&&o.count===0&&c2(o,o.stylesheets),0Gb?50:800)+c);return o.unsuspend=g,function(){o.unsuspend=null,clearTimeout(b),clearTimeout(D)}}:null}function l2(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)c2(this,this.stylesheets);else if(this.unsuspend){var o=this.unsuspend;this.unsuspend=null,o()}}}var u2=null;function c2(o,c){o.stylesheets=null,o.unsuspend!==null&&(o.count++,u2=new Map,c.forEach(_F,o),u2=null,l2.call(o))}function _F(o,c){if(!(c.state.loading&4)){var g=u2.get(o);if(g)var b=g.get(null);else{g=new Map,u2.set(o,g);for(var D=o.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(e){console.error(e)}}return i(),Yb.exports=BF(),Yb.exports}var IF=OF(),se=bT();const FF=E7(se);/** * @license * Copyright 2010-2024 Three.js Authors * SPDX-License-Identifier: MIT - */const F0="172",Wo={ROTATE:0,DOLLY:1,PAN:2},OA={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},C7=0,WS=1,N7=2,kF=0,ST=1,zF=2,vo=3,El=0,or=1,as=2,$a=0,Xa=1,t0=2,n0=3,i0=4,wT=5,wo=100,TT=101,MT=102,R7=103,D7=104,ET=200,CT=201,NT=202,RT=203,zm=204,Gm=205,DT=206,PT=207,LT=208,UT=209,BT=210,GF=211,qF=212,VF=213,jF=214,qm=0,Vm=1,jm=2,Bh=3,Hm=4,Wm=5,$m=6,Xm=7,Dg=0,P7=1,L7=2,Ya=0,U7=1,B7=2,O7=3,I7=4,HF=5,F7=6,k7=7,OT=300,Xo=301,Yo=302,Oh=303,Ih=304,ed=306,td=1e3,Yl=1001,nd=1002,dr=1003,i_=1004,Ql=1005,ps=1006,XA=1007,za=1008,WF=1008,ra=1009,Hf=1010,Wf=1011,bl=1012,Ns=1013,Nr=1014,$r=1015,Gs=1016,hy=1017,fy=1018,lu=1020,dy=35902,IT=1021,Pg=1022,ks=1023,FT=1024,kT=1025,tu=1026,uu=1027,Lg=1028,k0=1029,id=1030,z0=1031,$F=1032,G0=1033,$f=33776,Dh=33777,Ph=33778,Lh=33779,Ym=35840,Qm=35841,Km=35842,Zm=35843,Jm=36196,r0=37492,s0=37496,a0=37808,o0=37809,l0=37810,u0=37811,c0=37812,h0=37813,f0=37814,d0=37815,A0=37816,p0=37817,m0=37818,g0=37819,v0=37820,_0=37821,Xf=36492,$S=36494,XS=36495,zT=36283,eg=36284,tg=36285,ng=36286,XF=0,YF=1,X8=2,QF=3200,KF=3201,Mc=0,z7=1,To="",bn="srgb",Mo="srgb-linear",r_="linear",Fi="srgb",ZF=0,Nf=7680,JF=7681,ek=7682,tk=7683,nk=34055,ik=34056,rk=5386,sk=512,ak=513,ok=514,lk=515,uk=516,ck=517,hk=518,YS=519,GT=512,Ay=513,qT=514,py=515,VT=516,jT=517,HT=518,WT=519,s_=35044,IA=35048,Y8="300 es",Ga=2e3,cu=2001;class Bc{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s>8&255]+Ks[i>>16&255]+Ks[i>>24&255]+"-"+Ks[e&255]+Ks[e>>8&255]+"-"+Ks[e>>16&15|64]+Ks[e>>24&255]+"-"+Ks[t&63|128]+Ks[t>>8&255]+"-"+Ks[t>>16&255]+Ks[t>>24&255]+Ks[n&255]+Ks[n>>8&255]+Ks[n>>16&255]+Ks[n>>24&255]).toLowerCase()}function ri(i,e,t){return Math.max(e,Math.min(t,i))}function $T(i,e){return(i%e+e)%e}function fk(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function dk(i,e,t){return i!==e?(t-i)/(e-i):0}function Mm(i,e,t){return(1-t)*i+t*e}function Ak(i,e,t,n){return Mm(i,e,1-Math.exp(-t*n))}function pk(i,e=1){return e-Math.abs($T(i,e*2)-e)}function mk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function gk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function vk(i,e){return i+Math.floor(Math.random()*(e-i+1))}function _k(i,e){return i+Math.random()*(e-i)}function yk(i){return i*(.5-Math.random())}function xk(i){i!==void 0&&(Q8=i);let e=Q8+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function bk(i){return i*Tm}function Sk(i){return i*y0}function wk(i){return(i&i-1)===0&&i!==0}function Tk(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Mk(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ek(i,e,t,n,r){const s=Math.cos,a=Math.sin,l=s(t/2),u=a(t/2),h=s((e+n)/2),m=a((e+n)/2),v=s((e-n)/2),x=a((e-n)/2),S=s((n-e)/2),T=a((n-e)/2);switch(r){case"XYX":i.set(l*m,u*v,u*x,l*h);break;case"YZY":i.set(u*x,l*m,u*v,l*h);break;case"ZXZ":i.set(u*v,u*x,l*m,l*h);break;case"XZX":i.set(l*m,u*T,u*S,l*h);break;case"YXY":i.set(u*S,l*m,u*T,l*h);break;case"ZYZ":i.set(u*T,u*S,l*m,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ba(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function oi(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const x0={DEG2RAD:Tm,RAD2DEG:y0,generateUUID:nu,clamp:ri,euclideanModulo:$T,mapLinear:fk,inverseLerp:dk,lerp:Mm,damp:Ak,pingpong:pk,smoothstep:mk,smootherstep:gk,randInt:vk,randFloat:_k,randFloatSpread:yk,seededRandom:xk,degToRad:bk,radToDeg:Sk,isPowerOfTwo:wk,ceilPowerOfTwo:Tk,floorPowerOfTwo:Mk,setQuaternionFromProperEuler:Ek,normalize:oi,denormalize:ba};class bt{constructor(e=0,t=0){bt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ri(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xn{constructor(e,t,n,r,s,a,l,u,h){Xn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h)}set(e,t,n,r,s,a,l,u,h){const m=this.elements;return m[0]=e,m[1]=r,m[2]=l,m[3]=t,m[4]=s,m[5]=u,m[6]=n,m[7]=a,m[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[3],u=n[6],h=n[1],m=n[4],v=n[7],x=n[2],S=n[5],T=n[8],N=r[0],C=r[3],E=r[6],O=r[1],U=r[4],I=r[7],j=r[2],z=r[5],G=r[8];return s[0]=a*N+l*O+u*j,s[3]=a*C+l*U+u*z,s[6]=a*E+l*I+u*G,s[1]=h*N+m*O+v*j,s[4]=h*C+m*U+v*z,s[7]=h*E+m*I+v*G,s[2]=x*N+S*O+T*j,s[5]=x*C+S*U+T*z,s[8]=x*E+S*I+T*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8];return t*a*m-t*l*h-n*s*m+n*l*u+r*s*h-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=m*a-l*h,x=l*u-m*s,S=h*s-a*u,T=t*v+n*x+r*S;if(T===0)return this.set(0,0,0,0,0,0,0,0,0);const N=1/T;return e[0]=v*N,e[1]=(r*h-m*n)*N,e[2]=(l*n-r*a)*N,e[3]=x*N,e[4]=(m*t-r*u)*N,e[5]=(r*s-l*t)*N,e[6]=S*N,e[7]=(n*u-h*t)*N,e[8]=(a*t-n*s)*N,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,l){const u=Math.cos(s),h=Math.sin(s);return this.set(n*u,n*h,-n*(u*a+h*l)+a+e,-r*h,r*u,-r*(-h*a+u*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(e3.makeScale(e,t)),this}rotate(e){return this.premultiply(e3.makeRotation(-e)),this}translate(e,t){return this.premultiply(e3.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const e3=new Xn;function G7(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ig(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function q7(){const i=ig("canvas");return i.style.display="block",i}const K8={};function Uf(i){i in K8||(K8[i]=!0,console.warn(i))}function Ck(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function Nk(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Rk(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const Z8=new Xn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),J8=new Xn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Dk(){const i={enabled:!0,workingColorSpace:Mo,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Fi&&(r.r=xc(r.r),r.g=xc(r.g),r.b=xc(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Fi&&(r.r=YA(r.r),r.g=YA(r.g),r.b=YA(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===To?r_:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Mo]:{primaries:e,whitePoint:n,transfer:r_,toXYZ:Z8,fromXYZ:J8,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:bn},outputColorSpaceConfig:{drawingBufferColorSpace:bn}},[bn]:{primaries:e,whitePoint:n,transfer:Fi,toXYZ:Z8,fromXYZ:J8,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:bn}}}),i}const li=Dk();function xc(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function YA(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let tA;class Pk{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{tA===void 0&&(tA=ig("canvas")),tA.width=e.width,tA.height=e.height;const n=tA.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=tA}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ig("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==OT)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case td:e.x=e.x-Math.floor(e.x);break;case Yl:e.x=e.x<0?0:1;break;case nd:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case td:e.y=e.y-Math.floor(e.y);break;case Yl:e.y=e.y<0?0:1;break;case nd:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ms.DEFAULT_IMAGE=null;ms.DEFAULT_MAPPING=OT;ms.DEFAULT_ANISOTROPY=1;class On{constructor(e=0,t=0,n=0,r=1){On.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const u=e.elements,h=u[0],m=u[4],v=u[8],x=u[1],S=u[5],T=u[9],N=u[2],C=u[6],E=u[10];if(Math.abs(m-x)<.01&&Math.abs(v-N)<.01&&Math.abs(T-C)<.01){if(Math.abs(m+x)<.1&&Math.abs(v+N)<.1&&Math.abs(T+C)<.1&&Math.abs(h+S+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const U=(h+1)/2,I=(S+1)/2,j=(E+1)/2,z=(m+x)/4,G=(v+N)/4,H=(T+C)/4;return U>I&&U>j?U<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(U),r=z/n,s=G/n):I>j?I<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(I),n=z/r,s=H/r):j<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(j),n=G/s,r=H/s),this.set(n,r,s,t),this}let O=Math.sqrt((C-T)*(C-T)+(v-N)*(v-N)+(x-m)*(x-m));return Math.abs(O)<.001&&(O=1),this.x=(C-T)/O,this.y=(v-N)/O,this.z=(x-m)/O,this.w=Math.acos((h+S+E-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this.z=ri(this.z,e.z,t.z),this.w=ri(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this.z=ri(this.z,e,t),this.w=ri(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class qh extends Bc{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new On(0,0,e,t),this.scissorTest=!1,this.viewport=new On(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ps,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new ms(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let l=0;l=0?1:-1,U=1-E*E;if(U>Number.EPSILON){const j=Math.sqrt(U),z=Math.atan2(j,E*O);C=Math.sin(C*z)/j,l=Math.sin(l*z)/j}const I=l*O;if(u=u*C+x*I,h=h*C+S*I,m=m*C+T*I,v=v*C+N*I,C===1-l){const j=1/Math.sqrt(u*u+h*h+m*m+v*v);u*=j,h*=j,m*=j,v*=j}}e[t]=u,e[t+1]=h,e[t+2]=m,e[t+3]=v}static multiplyQuaternionsFlat(e,t,n,r,s,a){const l=n[r],u=n[r+1],h=n[r+2],m=n[r+3],v=s[a],x=s[a+1],S=s[a+2],T=s[a+3];return e[t]=l*T+m*v+u*S-h*x,e[t+1]=u*T+m*x+h*v-l*S,e[t+2]=h*T+m*S+l*x-u*v,e[t+3]=m*T-l*v-u*x-h*S,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,l=Math.cos,u=Math.sin,h=l(n/2),m=l(r/2),v=l(s/2),x=u(n/2),S=u(r/2),T=u(s/2);switch(a){case"XYZ":this._x=x*m*v+h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v-x*S*T;break;case"YXZ":this._x=x*m*v+h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v+x*S*T;break;case"ZXY":this._x=x*m*v-h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v-x*S*T;break;case"ZYX":this._x=x*m*v-h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v+x*S*T;break;case"YZX":this._x=x*m*v+h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v-x*S*T;break;case"XZY":this._x=x*m*v-h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v+x*S*T;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],l=t[5],u=t[9],h=t[2],m=t[6],v=t[10],x=n+l+v;if(x>0){const S=.5/Math.sqrt(x+1);this._w=.25/S,this._x=(m-u)*S,this._y=(s-h)*S,this._z=(a-r)*S}else if(n>l&&n>v){const S=2*Math.sqrt(1+n-l-v);this._w=(m-u)/S,this._x=.25*S,this._y=(r+a)/S,this._z=(s+h)/S}else if(l>v){const S=2*Math.sqrt(1+l-n-v);this._w=(s-h)/S,this._x=(r+a)/S,this._y=.25*S,this._z=(u+m)/S}else{const S=2*Math.sqrt(1+v-n-l);this._w=(a-r)/S,this._x=(s+h)/S,this._y=(u+m)/S,this._z=.25*S}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ri(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,l=t._x,u=t._y,h=t._z,m=t._w;return this._x=n*m+a*l+r*h-s*u,this._y=r*m+a*u+s*l-n*h,this._z=s*m+a*h+n*u-r*l,this._w=a*m-n*l-r*u-s*h,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let l=a*e._w+n*e._x+r*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const u=1-l*l;if(u<=Number.EPSILON){const S=1-t;return this._w=S*a+t*this._w,this._x=S*n+t*this._x,this._y=S*r+t*this._y,this._z=S*s+t*this._z,this.normalize(),this}const h=Math.sqrt(u),m=Math.atan2(h,l),v=Math.sin((1-t)*m)/h,x=Math.sin(t*m)/h;return this._w=a*v+this._w*x,this._x=n*v+this._x*x,this._y=r*v+this._y*x,this._z=s*v+this._z*x,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class me{constructor(e=0,t=0,n=0){me.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(eN.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(eN.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,l=e.z,u=e.w,h=2*(a*r-l*n),m=2*(l*t-s*r),v=2*(s*n-a*t);return this.x=t+u*h+a*v-l*m,this.y=n+u*m+l*h-s*v,this.z=r+u*v+s*m-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this.z=ri(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this.z=ri(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,l=t.y,u=t.z;return this.x=r*u-s*l,this.y=s*a-n*u,this.z=n*l-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return n3.copy(this).projectOnVector(e),this.sub(n3)}reflect(e){return this.sub(n3.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ri(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const n3=new me,eN=new hu;class Oc{constructor(e=new me(1/0,1/0,1/0),t=new me(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,dl),dl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wp),_2.subVectors(this.max,Wp),nA.subVectors(e.a,Wp),iA.subVectors(e.b,Wp),rA.subVectors(e.c,Wp),hh.subVectors(iA,nA),fh.subVectors(rA,iA),pf.subVectors(nA,rA);let t=[0,-hh.z,hh.y,0,-fh.z,fh.y,0,-pf.z,pf.y,hh.z,0,-hh.x,fh.z,0,-fh.x,pf.z,0,-pf.x,-hh.y,hh.x,0,-fh.y,fh.x,0,-pf.y,pf.x,0];return!i3(t,nA,iA,rA,_2)||(t=[1,0,0,0,1,0,0,0,1],!i3(t,nA,iA,rA,_2))?!1:(y2.crossVectors(hh,fh),t=[y2.x,y2.y,y2.z],i3(t,nA,iA,rA,_2))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,dl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(dl).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const oc=[new me,new me,new me,new me,new me,new me,new me,new me],dl=new me,v2=new Oc,nA=new me,iA=new me,rA=new me,hh=new me,fh=new me,pf=new me,Wp=new me,_2=new me,y2=new me,mf=new me;function i3(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){mf.fromArray(i,s);const l=r.x*Math.abs(mf.x)+r.y*Math.abs(mf.y)+r.z*Math.abs(mf.z),u=e.dot(mf),h=t.dot(mf),m=n.dot(mf);if(Math.max(-Math.max(u,h,m),Math.min(u,h,m))>l)return!1}return!0}const Ok=new Oc,$p=new me,r3=new me;class ud{constructor(e=new me,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ok.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;$p.subVectors(e,this.center);const t=$p.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector($p,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(r3.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint($p.copy(e.center).add(r3)),this.expandByPoint($p.copy(e.center).sub(r3))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const lc=new me,s3=new me,x2=new me,dh=new me,a3=new me,b2=new me,o3=new me;class Ug{constructor(e=new me,t=new me(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,lc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=lc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(lc.copy(this.origin).addScaledVector(this.direction,t),lc.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){s3.copy(e).add(t).multiplyScalar(.5),x2.copy(t).sub(e).normalize(),dh.copy(this.origin).sub(s3);const s=e.distanceTo(t)*.5,a=-this.direction.dot(x2),l=dh.dot(this.direction),u=-dh.dot(x2),h=dh.lengthSq(),m=Math.abs(1-a*a);let v,x,S,T;if(m>0)if(v=a*u-l,x=a*l-u,T=s*m,v>=0)if(x>=-T)if(x<=T){const N=1/m;v*=N,x*=N,S=v*(v+a*x+2*l)+x*(a*v+x+2*u)+h}else x=s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x=-s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x<=-T?(v=Math.max(0,-(-a*s+l)),x=v>0?-s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h):x<=T?(v=0,x=Math.min(Math.max(-s,-u),s),S=x*(x+2*u)+h):(v=Math.max(0,-(a*s+l)),x=v>0?s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h);else x=a>0?-s:s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,v),r&&r.copy(s3).addScaledVector(x2,x),S}intersectSphere(e,t){lc.subVectors(e.center,this.origin);const n=lc.dot(this.direction),r=lc.dot(lc)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),l=n-a,u=n+a;return u<0?null:l<0?this.at(u,t):this.at(l,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,l,u;const h=1/this.direction.x,m=1/this.direction.y,v=1/this.direction.z,x=this.origin;return h>=0?(n=(e.min.x-x.x)*h,r=(e.max.x-x.x)*h):(n=(e.max.x-x.x)*h,r=(e.min.x-x.x)*h),m>=0?(s=(e.min.y-x.y)*m,a=(e.max.y-x.y)*m):(s=(e.max.y-x.y)*m,a=(e.min.y-x.y)*m),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a=0?(l=(e.min.z-x.z)*v,u=(e.max.z-x.z)*v):(l=(e.max.z-x.z)*v,u=(e.min.z-x.z)*v),n>u||l>r)||((l>n||n!==n)&&(n=l),(u=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,lc)!==null}intersectTriangle(e,t,n,r,s){a3.subVectors(t,e),b2.subVectors(n,e),o3.crossVectors(a3,b2);let a=this.direction.dot(o3),l;if(a>0){if(r)return null;l=1}else if(a<0)l=-1,a=-a;else return null;dh.subVectors(this.origin,e);const u=l*this.direction.dot(b2.crossVectors(dh,b2));if(u<0)return null;const h=l*this.direction.dot(a3.cross(dh));if(h<0||u+h>a)return null;const m=-l*dh.dot(o3);return m<0?null:this.at(m/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class jn{constructor(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C){jn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C)}set(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C){const E=this.elements;return E[0]=e,E[4]=t,E[8]=n,E[12]=r,E[1]=s,E[5]=a,E[9]=l,E[13]=u,E[2]=h,E[6]=m,E[10]=v,E[14]=x,E[3]=S,E[7]=T,E[11]=N,E[15]=C,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new jn().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/sA.setFromMatrixColumn(e,0).length(),s=1/sA.setFromMatrixColumn(e,1).length(),a=1/sA.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),l=Math.sin(n),u=Math.cos(r),h=Math.sin(r),m=Math.cos(s),v=Math.sin(s);if(e.order==="XYZ"){const x=a*m,S=a*v,T=l*m,N=l*v;t[0]=u*m,t[4]=-u*v,t[8]=h,t[1]=S+T*h,t[5]=x-N*h,t[9]=-l*u,t[2]=N-x*h,t[6]=T+S*h,t[10]=a*u}else if(e.order==="YXZ"){const x=u*m,S=u*v,T=h*m,N=h*v;t[0]=x+N*l,t[4]=T*l-S,t[8]=a*h,t[1]=a*v,t[5]=a*m,t[9]=-l,t[2]=S*l-T,t[6]=N+x*l,t[10]=a*u}else if(e.order==="ZXY"){const x=u*m,S=u*v,T=h*m,N=h*v;t[0]=x-N*l,t[4]=-a*v,t[8]=T+S*l,t[1]=S+T*l,t[5]=a*m,t[9]=N-x*l,t[2]=-a*h,t[6]=l,t[10]=a*u}else if(e.order==="ZYX"){const x=a*m,S=a*v,T=l*m,N=l*v;t[0]=u*m,t[4]=T*h-S,t[8]=x*h+N,t[1]=u*v,t[5]=N*h+x,t[9]=S*h-T,t[2]=-h,t[6]=l*u,t[10]=a*u}else if(e.order==="YZX"){const x=a*u,S=a*h,T=l*u,N=l*h;t[0]=u*m,t[4]=N-x*v,t[8]=T*v+S,t[1]=v,t[5]=a*m,t[9]=-l*m,t[2]=-h*m,t[6]=S*v+T,t[10]=x-N*v}else if(e.order==="XZY"){const x=a*u,S=a*h,T=l*u,N=l*h;t[0]=u*m,t[4]=-v,t[8]=h*m,t[1]=x*v+N,t[5]=a*m,t[9]=S*v-T,t[2]=T*v-S,t[6]=l*m,t[10]=N*v+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ik,e,Fk)}lookAt(e,t,n){const r=this.elements;return ho.subVectors(e,t),ho.lengthSq()===0&&(ho.z=1),ho.normalize(),Ah.crossVectors(n,ho),Ah.lengthSq()===0&&(Math.abs(n.z)===1?ho.x+=1e-4:ho.z+=1e-4,ho.normalize(),Ah.crossVectors(n,ho)),Ah.normalize(),S2.crossVectors(ho,Ah),r[0]=Ah.x,r[4]=S2.x,r[8]=ho.x,r[1]=Ah.y,r[5]=S2.y,r[9]=ho.y,r[2]=Ah.z,r[6]=S2.z,r[10]=ho.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[4],u=n[8],h=n[12],m=n[1],v=n[5],x=n[9],S=n[13],T=n[2],N=n[6],C=n[10],E=n[14],O=n[3],U=n[7],I=n[11],j=n[15],z=r[0],G=r[4],H=r[8],q=r[12],V=r[1],Q=r[5],J=r[9],ne=r[13],oe=r[2],ie=r[6],Z=r[10],te=r[14],de=r[3],Se=r[7],Te=r[11],ae=r[15];return s[0]=a*z+l*V+u*oe+h*de,s[4]=a*G+l*Q+u*ie+h*Se,s[8]=a*H+l*J+u*Z+h*Te,s[12]=a*q+l*ne+u*te+h*ae,s[1]=m*z+v*V+x*oe+S*de,s[5]=m*G+v*Q+x*ie+S*Se,s[9]=m*H+v*J+x*Z+S*Te,s[13]=m*q+v*ne+x*te+S*ae,s[2]=T*z+N*V+C*oe+E*de,s[6]=T*G+N*Q+C*ie+E*Se,s[10]=T*H+N*J+C*Z+E*Te,s[14]=T*q+N*ne+C*te+E*ae,s[3]=O*z+U*V+I*oe+j*de,s[7]=O*G+U*Q+I*ie+j*Se,s[11]=O*H+U*J+I*Z+j*Te,s[15]=O*q+U*ne+I*te+j*ae,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],l=e[5],u=e[9],h=e[13],m=e[2],v=e[6],x=e[10],S=e[14],T=e[3],N=e[7],C=e[11],E=e[15];return T*(+s*u*v-r*h*v-s*l*x+n*h*x+r*l*S-n*u*S)+N*(+t*u*S-t*h*x+s*a*x-r*a*S+r*h*m-s*u*m)+C*(+t*h*v-t*l*S-s*a*v+n*a*S+s*l*m-n*h*m)+E*(-r*l*m-t*u*v+t*l*x+r*a*v-n*a*x+n*u*m)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=e[9],x=e[10],S=e[11],T=e[12],N=e[13],C=e[14],E=e[15],O=v*C*h-N*x*h+N*u*S-l*C*S-v*u*E+l*x*E,U=T*x*h-m*C*h-T*u*S+a*C*S+m*u*E-a*x*E,I=m*N*h-T*v*h+T*l*S-a*N*S-m*l*E+a*v*E,j=T*v*u-m*N*u-T*l*x+a*N*x+m*l*C-a*v*C,z=t*O+n*U+r*I+s*j;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const G=1/z;return e[0]=O*G,e[1]=(N*x*s-v*C*s-N*r*S+n*C*S+v*r*E-n*x*E)*G,e[2]=(l*C*s-N*u*s+N*r*h-n*C*h-l*r*E+n*u*E)*G,e[3]=(v*u*s-l*x*s-v*r*h+n*x*h+l*r*S-n*u*S)*G,e[4]=U*G,e[5]=(m*C*s-T*x*s+T*r*S-t*C*S-m*r*E+t*x*E)*G,e[6]=(T*u*s-a*C*s-T*r*h+t*C*h+a*r*E-t*u*E)*G,e[7]=(a*x*s-m*u*s+m*r*h-t*x*h-a*r*S+t*u*S)*G,e[8]=I*G,e[9]=(T*v*s-m*N*s-T*n*S+t*N*S+m*n*E-t*v*E)*G,e[10]=(a*N*s-T*l*s+T*n*h-t*N*h-a*n*E+t*l*E)*G,e[11]=(m*l*s-a*v*s-m*n*h+t*v*h+a*n*S-t*l*S)*G,e[12]=j*G,e[13]=(m*N*r-T*v*r+T*n*x-t*N*x-m*n*C+t*v*C)*G,e[14]=(T*l*r-a*N*r-T*n*u+t*N*u+a*n*C-t*l*C)*G,e[15]=(a*v*r-m*l*r+m*n*u-t*v*u-a*n*x+t*l*x)*G,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,l=e.y,u=e.z,h=s*a,m=s*l;return this.set(h*a+n,h*l-r*u,h*u+r*l,0,h*l+r*u,m*l+n,m*u-r*a,0,h*u-r*l,m*u+r*a,s*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,l=t._z,u=t._w,h=s+s,m=a+a,v=l+l,x=s*h,S=s*m,T=s*v,N=a*m,C=a*v,E=l*v,O=u*h,U=u*m,I=u*v,j=n.x,z=n.y,G=n.z;return r[0]=(1-(N+E))*j,r[1]=(S+I)*j,r[2]=(T-U)*j,r[3]=0,r[4]=(S-I)*z,r[5]=(1-(x+E))*z,r[6]=(C+O)*z,r[7]=0,r[8]=(T+U)*G,r[9]=(C-O)*G,r[10]=(1-(x+N))*G,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=sA.set(r[0],r[1],r[2]).length();const a=sA.set(r[4],r[5],r[6]).length(),l=sA.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Al.copy(this);const h=1/s,m=1/a,v=1/l;return Al.elements[0]*=h,Al.elements[1]*=h,Al.elements[2]*=h,Al.elements[4]*=m,Al.elements[5]*=m,Al.elements[6]*=m,Al.elements[8]*=v,Al.elements[9]*=v,Al.elements[10]*=v,t.setFromRotationMatrix(Al),n.x=s,n.y=a,n.z=l,this}makePerspective(e,t,n,r,s,a,l=Ga){const u=this.elements,h=2*s/(t-e),m=2*s/(n-r),v=(t+e)/(t-e),x=(n+r)/(n-r);let S,T;if(l===Ga)S=-(a+s)/(a-s),T=-2*a*s/(a-s);else if(l===cu)S=-a/(a-s),T=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=h,u[4]=0,u[8]=v,u[12]=0,u[1]=0,u[5]=m,u[9]=x,u[13]=0,u[2]=0,u[6]=0,u[10]=S,u[14]=T,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,s,a,l=Ga){const u=this.elements,h=1/(t-e),m=1/(n-r),v=1/(a-s),x=(t+e)*h,S=(n+r)*m;let T,N;if(l===Ga)T=(a+s)*v,N=-2*v;else if(l===cu)T=s*v,N=-1*v;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=2*h,u[4]=0,u[8]=0,u[12]=-x,u[1]=0,u[5]=2*m,u[9]=0,u[13]=-S,u[2]=0,u[6]=0,u[10]=N,u[14]=-T,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const sA=new me,Al=new jn,Ik=new me(0,0,0),Fk=new me(1,1,1),Ah=new me,S2=new me,ho=new me,tN=new jn,nN=new hu;class aa{constructor(e=0,t=0,n=0,r=aa.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],l=r[8],u=r[1],h=r[5],m=r[9],v=r[2],x=r[6],S=r[10];switch(t){case"XYZ":this._y=Math.asin(ri(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-m,S),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(x,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ri(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(l,S),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-v,s),this._z=0);break;case"ZXY":this._x=Math.asin(ri(x,-1,1)),Math.abs(x)<.9999999?(this._y=Math.atan2(-v,S),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-ri(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(x,S),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(ri(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-m,h),this._y=Math.atan2(-v,s)):(this._x=0,this._y=Math.atan2(l,S));break;case"XZY":this._z=Math.asin(-ri(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(x,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-m,S),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return tN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(tN,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return nN.setFromEuler(this),this.setFromQuaternion(nN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}aa.DEFAULT_ORDER="XYZ";class YT{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(l,u){return l[u.uuid]===void 0&&(l[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const u=l.shapes;if(Array.isArray(u))for(let h=0,m=u.length;h0){r.children=[];for(let l=0;l0){r.animations=[];for(let l=0;l0&&(n.geometries=l),u.length>0&&(n.materials=u),h.length>0&&(n.textures=h),m.length>0&&(n.images=m),v.length>0&&(n.shapes=v),x.length>0&&(n.skeletons=x),S.length>0&&(n.animations=S),T.length>0&&(n.nodes=T)}return n.object=r,n;function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){pl.subVectors(r,t),cc.subVectors(n,t),u3.subVectors(e,t);const a=pl.dot(pl),l=pl.dot(cc),u=pl.dot(u3),h=cc.dot(cc),m=cc.dot(u3),v=a*h-l*l;if(v===0)return s.set(0,0,0),null;const x=1/v,S=(h*u-l*m)*x,T=(a*m-l*u)*x;return s.set(1-S-T,T,S)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,hc)===null?!1:hc.x>=0&&hc.y>=0&&hc.x+hc.y<=1}static getInterpolation(e,t,n,r,s,a,l,u){return this.getBarycoord(e,t,n,r,hc)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(s,hc.x),u.addScaledVector(a,hc.y),u.addScaledVector(l,hc.z),u)}static getInterpolatedAttribute(e,t,n,r,s,a){return d3.setScalar(0),A3.setScalar(0),p3.setScalar(0),d3.fromBufferAttribute(e,t),A3.fromBufferAttribute(e,n),p3.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(d3,s.x),a.addScaledVector(A3,s.y),a.addScaledVector(p3,s.z),a}static isFrontFacing(e,t,n,r){return pl.subVectors(n,t),cc.subVectors(e,t),pl.cross(cc).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return pl.subVectors(this.c,this.b),cc.subVectors(this.a,this.b),pl.cross(cc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yl.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return yl.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return yl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,l;lA.subVectors(r,n),uA.subVectors(s,n),c3.subVectors(e,n);const u=lA.dot(c3),h=uA.dot(c3);if(u<=0&&h<=0)return t.copy(n);h3.subVectors(e,r);const m=lA.dot(h3),v=uA.dot(h3);if(m>=0&&v<=m)return t.copy(r);const x=u*v-m*h;if(x<=0&&u>=0&&m<=0)return a=u/(u-m),t.copy(n).addScaledVector(lA,a);f3.subVectors(e,s);const S=lA.dot(f3),T=uA.dot(f3);if(T>=0&&S<=T)return t.copy(s);const N=S*h-u*T;if(N<=0&&h>=0&&T<=0)return l=h/(h-T),t.copy(n).addScaledVector(uA,l);const C=m*T-S*v;if(C<=0&&v-m>=0&&S-T>=0)return lN.subVectors(s,r),l=(v-m)/(v-m+(S-T)),t.copy(r).addScaledVector(lN,l);const E=1/(C+N+x);return a=N*E,l=x*E,t.copy(n).addScaledVector(lA,a).addScaledVector(uA,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const j7={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ph={h:0,s:0,l:0},T2={h:0,s:0,l:0};function m3(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let cn=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=bn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,li.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=li.workingColorSpace){return this.r=e,this.g=t,this.b=n,li.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=li.workingColorSpace){if(e=$T(e,1),t=ri(t,0,1),n=ri(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=m3(a,s,e+1/3),this.g=m3(a,s,e),this.b=m3(a,s,e-1/3)}return li.toWorkingColorSpace(this,r),this}setStyle(e,t=bn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],l=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=bn){const n=j7[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=xc(e.r),this.g=xc(e.g),this.b=xc(e.b),this}copyLinearToSRGB(e){return this.r=YA(e.r),this.g=YA(e.g),this.b=YA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=bn){return li.fromWorkingColorSpace(Zs.copy(this),e),Math.round(ri(Zs.r*255,0,255))*65536+Math.round(ri(Zs.g*255,0,255))*256+Math.round(ri(Zs.b*255,0,255))}getHexString(e=bn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=li.workingColorSpace){li.fromWorkingColorSpace(Zs.copy(this),t);const n=Zs.r,r=Zs.g,s=Zs.b,a=Math.max(n,r,s),l=Math.min(n,r,s);let u,h;const m=(l+a)/2;if(l===a)u=0,h=0;else{const v=a-l;switch(h=m<=.5?v/(a+l):v/(2-a-l),a){case n:u=(r-s)/v+(r0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Xa&&(n.blending=this.blending),this.side!==El&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==zm&&(n.blendSrc=this.blendSrc),this.blendDst!==Gm&&(n.blendDst=this.blendDst),this.blendEquation!==wo&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Bh&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==YS&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Nf&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Nf&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Nf&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const l in s){const u=s[l];delete u.metadata,a.push(u)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class cd extends oa{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new cn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const gc=jk();function jk(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const h=u-127;h<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):h<-14?(n[u]=1024>>-h-14,n[u|256]=1024>>-h-14|32768,r[u]=-h-1,r[u|256]=-h-1):h<=15?(n[u]=h+15<<10,n[u|256]=h+15<<10|32768,r[u]=13,r[u|256]=13):h<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),l=new Uint32Array(64);for(let u=1;u<1024;++u){let h=u<<13,m=0;for(;(h&8388608)===0;)h<<=1,m-=8388608;h&=-8388609,m+=947912704,s[u]=h|m}for(let u=1024;u<2048;++u)s[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(l[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:l}}function fo(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=ri(i,-65504,65504),gc.floatView[0]=i;const e=gc.uint32View[0],t=e>>23&511;return gc.baseTable[t]+((e&8388607)>>gc.shiftTable[t])}function M2(i){const e=i>>10;return gc.uint32View[0]=gc.mantissaTable[gc.offsetTable[e]+(i&1023)]+gc.exponentTable[e],gc.floatView[0]}const is=new me,E2=new bt;class wr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=s_,this.updateRanges=[],this.gpuType=$r,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;rt.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Oc);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new me(-1/0,-1/0,-1/0),new me(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const h in u)u[h]!==void 0&&(e[h]=u[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const h=n[u];e.data.attributes[u]=h.toJSON(e.data)}const r={};let s=!1;for(const u in this.morphAttributes){const h=this.morphAttributes[u],m=[];for(let v=0,x=h.length;v0&&(r[u]=m,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const h in r){const m=r[h];this.setAttribute(h,m.clone(t))}const s=e.morphAttributes;for(const h in s){const m=[],v=s[h];for(let x=0,S=v.length;x0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s(e.far-e.near)**2))&&(uN.copy(s).invert(),gf.copy(e.ray).applyMatrix4(uN),!(n.boundingBox!==null&&gf.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,gf)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,l=s.index,u=s.attributes.position,h=s.attributes.uv,m=s.attributes.uv1,v=s.attributes.normal,x=s.groups,S=s.drawRange;if(l!==null)if(Array.isArray(a))for(let T=0,N=x.length;Tt.far?null:{distance:h,point:L2.clone(),object:i}}function U2(i,e,t,n,r,s,a,l,u,h){i.getVertexPosition(l,N2),i.getVertexPosition(u,R2),i.getVertexPosition(h,D2);const m=Wk(i,e,t,n,N2,R2,D2,hN);if(m){const v=new me;yl.getBarycoord(hN,N2,R2,D2,v),r&&(m.uv=yl.getInterpolatedAttribute(r,l,u,h,v,new bt)),s&&(m.uv1=yl.getInterpolatedAttribute(s,l,u,h,v,new bt)),a&&(m.normal=yl.getInterpolatedAttribute(a,l,u,h,v,new me),m.normal.dot(n.direction)>0&&m.normal.multiplyScalar(-1));const x={a:l,b:u,c:h,normal:new me,materialIndex:0};yl.getNormal(N2,R2,D2,x.normal),m.face=x,m.barycoord=v}return m}class Vh extends Hi{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const u=[],h=[],m=[],v=[];let x=0,S=0;T("z","y","x",-1,-1,n,t,e,a,s,0),T("z","y","x",1,-1,n,t,-e,a,s,1),T("x","z","y",1,1,e,n,t,r,a,2),T("x","z","y",1,-1,e,n,-t,r,a,3),T("x","y","z",1,-1,e,t,n,r,s,4),T("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(u),this.setAttribute("position",new Si(h,3)),this.setAttribute("normal",new Si(m,3)),this.setAttribute("uv",new Si(v,2));function T(N,C,E,O,U,I,j,z,G,H,q){const V=I/G,Q=j/H,J=I/2,ne=j/2,oe=z/2,ie=G+1,Z=H+1;let te=0,de=0;const Se=new me;for(let Te=0;Te0?1:-1,m.push(Se.x,Se.y,Se.z),v.push(Me/G),v.push(1-Te/H),te+=1}}for(let Te=0;Te>8&255]+Ks[i>>16&255]+Ks[i>>24&255]+"-"+Ks[e&255]+Ks[e>>8&255]+"-"+Ks[e>>16&15|64]+Ks[e>>24&255]+"-"+Ks[t&63|128]+Ks[t>>8&255]+"-"+Ks[t>>16&255]+Ks[t>>24&255]+Ks[n&255]+Ks[n>>8&255]+Ks[n>>16&255]+Ks[n>>24&255]).toLowerCase()}function ri(i,e,t){return Math.max(e,Math.min(t,i))}function $T(i,e){return(i%e+e)%e}function fk(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function dk(i,e,t){return i!==e?(t-i)/(e-i):0}function Mm(i,e,t){return(1-t)*i+t*e}function Ak(i,e,t,n){return Mm(i,e,1-Math.exp(-t*n))}function pk(i,e=1){return e-Math.abs($T(i,e*2)-e)}function mk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function gk(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function vk(i,e){return i+Math.floor(Math.random()*(e-i+1))}function _k(i,e){return i+Math.random()*(e-i)}function yk(i){return i*(.5-Math.random())}function xk(i){i!==void 0&&(Q8=i);let e=Q8+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function bk(i){return i*Tm}function Sk(i){return i*y0}function wk(i){return(i&i-1)===0&&i!==0}function Tk(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Mk(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ek(i,e,t,n,r){const s=Math.cos,a=Math.sin,l=s(t/2),u=a(t/2),h=s((e+n)/2),m=a((e+n)/2),v=s((e-n)/2),x=a((e-n)/2),S=s((n-e)/2),T=a((n-e)/2);switch(r){case"XYX":i.set(l*m,u*v,u*x,l*h);break;case"YZY":i.set(u*x,l*m,u*v,l*h);break;case"ZXZ":i.set(u*v,u*x,l*m,l*h);break;case"XZX":i.set(l*m,u*T,u*S,l*h);break;case"YXY":i.set(u*S,l*m,u*T,l*h);break;case"ZYZ":i.set(u*T,u*S,l*m,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ba(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function oi(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const x0={DEG2RAD:Tm,RAD2DEG:y0,generateUUID:nu,clamp:ri,euclideanModulo:$T,mapLinear:fk,inverseLerp:dk,lerp:Mm,damp:Ak,pingpong:pk,smoothstep:mk,smootherstep:gk,randInt:vk,randFloat:_k,randFloatSpread:yk,seededRandom:xk,degToRad:bk,radToDeg:Sk,isPowerOfTwo:wk,ceilPowerOfTwo:Tk,floorPowerOfTwo:Mk,setQuaternionFromProperEuler:Ek,normalize:oi,denormalize:ba};class bt{constructor(e=0,t=0){bt.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ri(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xn{constructor(e,t,n,r,s,a,l,u,h){Xn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h)}set(e,t,n,r,s,a,l,u,h){const m=this.elements;return m[0]=e,m[1]=r,m[2]=l,m[3]=t,m[4]=s,m[5]=u,m[6]=n,m[7]=a,m[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[3],u=n[6],h=n[1],m=n[4],v=n[7],x=n[2],S=n[5],T=n[8],N=r[0],C=r[3],E=r[6],O=r[1],U=r[4],I=r[7],j=r[2],z=r[5],G=r[8];return s[0]=a*N+l*O+u*j,s[3]=a*C+l*U+u*z,s[6]=a*E+l*I+u*G,s[1]=h*N+m*O+v*j,s[4]=h*C+m*U+v*z,s[7]=h*E+m*I+v*G,s[2]=x*N+S*O+T*j,s[5]=x*C+S*U+T*z,s[8]=x*E+S*I+T*G,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8];return t*a*m-t*l*h-n*s*m+n*l*u+r*s*h-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=m*a-l*h,x=l*u-m*s,S=h*s-a*u,T=t*v+n*x+r*S;if(T===0)return this.set(0,0,0,0,0,0,0,0,0);const N=1/T;return e[0]=v*N,e[1]=(r*h-m*n)*N,e[2]=(l*n-r*a)*N,e[3]=x*N,e[4]=(m*t-r*u)*N,e[5]=(r*s-l*t)*N,e[6]=S*N,e[7]=(n*u-h*t)*N,e[8]=(a*t-n*s)*N,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,l){const u=Math.cos(s),h=Math.sin(s);return this.set(n*u,n*h,-n*(u*a+h*l)+a+e,-r*h,r*u,-r*(-h*a+u*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(e3.makeScale(e,t)),this}rotate(e){return this.premultiply(e3.makeRotation(-e)),this}translate(e,t){return this.premultiply(e3.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const e3=new Xn;function G7(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ig(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function q7(){const i=ig("canvas");return i.style.display="block",i}const K8={};function Uf(i){i in K8||(K8[i]=!0,console.warn(i))}function Ck(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function Nk(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function Rk(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const Z8=new Xn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),J8=new Xn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Dk(){const i={enabled:!0,workingColorSpace:Mo,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Fi&&(r.r=xc(r.r),r.g=xc(r.g),r.b=xc(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Fi&&(r.r=YA(r.r),r.g=YA(r.g),r.b=YA(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===To?r_:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Mo]:{primaries:e,whitePoint:n,transfer:r_,toXYZ:Z8,fromXYZ:J8,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:bn},outputColorSpaceConfig:{drawingBufferColorSpace:bn}},[bn]:{primaries:e,whitePoint:n,transfer:Fi,toXYZ:Z8,fromXYZ:J8,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:bn}}}),i}const li=Dk();function xc(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function YA(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let tA;class Pk{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{tA===void 0&&(tA=ig("canvas")),tA.width=e.width,tA.height=e.height;const n=tA.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=tA}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ig("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==OT)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case td:e.x=e.x-Math.floor(e.x);break;case Yl:e.x=e.x<0?0:1;break;case nd:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case td:e.y=e.y-Math.floor(e.y);break;case Yl:e.y=e.y<0?0:1;break;case nd:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ms.DEFAULT_IMAGE=null;ms.DEFAULT_MAPPING=OT;ms.DEFAULT_ANISOTROPY=1;class On{constructor(e=0,t=0,n=0,r=1){On.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const u=e.elements,h=u[0],m=u[4],v=u[8],x=u[1],S=u[5],T=u[9],N=u[2],C=u[6],E=u[10];if(Math.abs(m-x)<.01&&Math.abs(v-N)<.01&&Math.abs(T-C)<.01){if(Math.abs(m+x)<.1&&Math.abs(v+N)<.1&&Math.abs(T+C)<.1&&Math.abs(h+S+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const U=(h+1)/2,I=(S+1)/2,j=(E+1)/2,z=(m+x)/4,G=(v+N)/4,H=(T+C)/4;return U>I&&U>j?U<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(U),r=z/n,s=G/n):I>j?I<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(I),n=z/r,s=H/r):j<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(j),n=G/s,r=H/s),this.set(n,r,s,t),this}let O=Math.sqrt((C-T)*(C-T)+(v-N)*(v-N)+(x-m)*(x-m));return Math.abs(O)<.001&&(O=1),this.x=(C-T)/O,this.y=(v-N)/O,this.z=(x-m)/O,this.w=Math.acos((h+S+E-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this.z=ri(this.z,e.z,t.z),this.w=ri(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this.z=ri(this.z,e,t),this.w=ri(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class qh extends Bc{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new On(0,0,e,t),this.scissorTest=!1,this.viewport=new On(0,0,e,t);const r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ps,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new ms(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let l=0;l=0?1:-1,U=1-E*E;if(U>Number.EPSILON){const j=Math.sqrt(U),z=Math.atan2(j,E*O);C=Math.sin(C*z)/j,l=Math.sin(l*z)/j}const I=l*O;if(u=u*C+x*I,h=h*C+S*I,m=m*C+T*I,v=v*C+N*I,C===1-l){const j=1/Math.sqrt(u*u+h*h+m*m+v*v);u*=j,h*=j,m*=j,v*=j}}e[t]=u,e[t+1]=h,e[t+2]=m,e[t+3]=v}static multiplyQuaternionsFlat(e,t,n,r,s,a){const l=n[r],u=n[r+1],h=n[r+2],m=n[r+3],v=s[a],x=s[a+1],S=s[a+2],T=s[a+3];return e[t]=l*T+m*v+u*S-h*x,e[t+1]=u*T+m*x+h*v-l*S,e[t+2]=h*T+m*S+l*x-u*v,e[t+3]=m*T-l*v-u*x-h*S,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,l=Math.cos,u=Math.sin,h=l(n/2),m=l(r/2),v=l(s/2),x=u(n/2),S=u(r/2),T=u(s/2);switch(a){case"XYZ":this._x=x*m*v+h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v-x*S*T;break;case"YXZ":this._x=x*m*v+h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v+x*S*T;break;case"ZXY":this._x=x*m*v-h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v-x*S*T;break;case"ZYX":this._x=x*m*v-h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v+x*S*T;break;case"YZX":this._x=x*m*v+h*S*T,this._y=h*S*v+x*m*T,this._z=h*m*T-x*S*v,this._w=h*m*v-x*S*T;break;case"XZY":this._x=x*m*v-h*S*T,this._y=h*S*v-x*m*T,this._z=h*m*T+x*S*v,this._w=h*m*v+x*S*T;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],l=t[5],u=t[9],h=t[2],m=t[6],v=t[10],x=n+l+v;if(x>0){const S=.5/Math.sqrt(x+1);this._w=.25/S,this._x=(m-u)*S,this._y=(s-h)*S,this._z=(a-r)*S}else if(n>l&&n>v){const S=2*Math.sqrt(1+n-l-v);this._w=(m-u)/S,this._x=.25*S,this._y=(r+a)/S,this._z=(s+h)/S}else if(l>v){const S=2*Math.sqrt(1+l-n-v);this._w=(s-h)/S,this._x=(r+a)/S,this._y=.25*S,this._z=(u+m)/S}else{const S=2*Math.sqrt(1+v-n-l);this._w=(a-r)/S,this._x=(s+h)/S,this._y=(u+m)/S,this._z=.25*S}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ri(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,l=t._x,u=t._y,h=t._z,m=t._w;return this._x=n*m+a*l+r*h-s*u,this._y=r*m+a*u+s*l-n*h,this._z=s*m+a*h+n*u-r*l,this._w=a*m-n*l-r*u-s*h,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let l=a*e._w+n*e._x+r*e._y+s*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const u=1-l*l;if(u<=Number.EPSILON){const S=1-t;return this._w=S*a+t*this._w,this._x=S*n+t*this._x,this._y=S*r+t*this._y,this._z=S*s+t*this._z,this.normalize(),this}const h=Math.sqrt(u),m=Math.atan2(h,l),v=Math.sin((1-t)*m)/h,x=Math.sin(t*m)/h;return this._w=a*v+this._w*x,this._x=n*v+this._x*x,this._y=r*v+this._y*x,this._z=s*v+this._z*x,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class pe{constructor(e=0,t=0,n=0){pe.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(eN.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(eN.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,l=e.z,u=e.w,h=2*(a*r-l*n),m=2*(l*t-s*r),v=2*(s*n-a*t);return this.x=t+u*h+a*v-l*m,this.y=n+u*m+l*h-s*v,this.z=r+u*v+s*m-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ri(this.x,e.x,t.x),this.y=ri(this.y,e.y,t.y),this.z=ri(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ri(this.x,e,t),this.y=ri(this.y,e,t),this.z=ri(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(ri(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,l=t.y,u=t.z;return this.x=r*u-s*l,this.y=s*a-n*u,this.z=n*l-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return n3.copy(this).projectOnVector(e),this.sub(n3)}reflect(e){return this.sub(n3.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ri(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const n3=new pe,eN=new hu;class Oc{constructor(e=new pe(1/0,1/0,1/0),t=new pe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,dl),dl.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wp),_2.subVectors(this.max,Wp),nA.subVectors(e.a,Wp),iA.subVectors(e.b,Wp),rA.subVectors(e.c,Wp),hh.subVectors(iA,nA),fh.subVectors(rA,iA),pf.subVectors(nA,rA);let t=[0,-hh.z,hh.y,0,-fh.z,fh.y,0,-pf.z,pf.y,hh.z,0,-hh.x,fh.z,0,-fh.x,pf.z,0,-pf.x,-hh.y,hh.x,0,-fh.y,fh.x,0,-pf.y,pf.x,0];return!i3(t,nA,iA,rA,_2)||(t=[1,0,0,0,1,0,0,0,1],!i3(t,nA,iA,rA,_2))?!1:(y2.crossVectors(hh,fh),t=[y2.x,y2.y,y2.z],i3(t,nA,iA,rA,_2))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,dl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(dl).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const oc=[new pe,new pe,new pe,new pe,new pe,new pe,new pe,new pe],dl=new pe,v2=new Oc,nA=new pe,iA=new pe,rA=new pe,hh=new pe,fh=new pe,pf=new pe,Wp=new pe,_2=new pe,y2=new pe,mf=new pe;function i3(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){mf.fromArray(i,s);const l=r.x*Math.abs(mf.x)+r.y*Math.abs(mf.y)+r.z*Math.abs(mf.z),u=e.dot(mf),h=t.dot(mf),m=n.dot(mf);if(Math.max(-Math.max(u,h,m),Math.min(u,h,m))>l)return!1}return!0}const Ok=new Oc,$p=new pe,r3=new pe;class ud{constructor(e=new pe,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ok.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;$p.subVectors(e,this.center);const t=$p.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector($p,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(r3.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint($p.copy(e.center).add(r3)),this.expandByPoint($p.copy(e.center).sub(r3))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const lc=new pe,s3=new pe,x2=new pe,dh=new pe,a3=new pe,b2=new pe,o3=new pe;class Ug{constructor(e=new pe,t=new pe(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,lc)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=lc.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(lc.copy(this.origin).addScaledVector(this.direction,t),lc.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){s3.copy(e).add(t).multiplyScalar(.5),x2.copy(t).sub(e).normalize(),dh.copy(this.origin).sub(s3);const s=e.distanceTo(t)*.5,a=-this.direction.dot(x2),l=dh.dot(this.direction),u=-dh.dot(x2),h=dh.lengthSq(),m=Math.abs(1-a*a);let v,x,S,T;if(m>0)if(v=a*u-l,x=a*l-u,T=s*m,v>=0)if(x>=-T)if(x<=T){const N=1/m;v*=N,x*=N,S=v*(v+a*x+2*l)+x*(a*v+x+2*u)+h}else x=s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x=-s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;else x<=-T?(v=Math.max(0,-(-a*s+l)),x=v>0?-s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h):x<=T?(v=0,x=Math.min(Math.max(-s,-u),s),S=x*(x+2*u)+h):(v=Math.max(0,-(a*s+l)),x=v>0?s:Math.min(Math.max(-s,-u),s),S=-v*v+x*(x+2*u)+h);else x=a>0?-s:s,v=Math.max(0,-(a*x+l)),S=-v*v+x*(x+2*u)+h;return n&&n.copy(this.origin).addScaledVector(this.direction,v),r&&r.copy(s3).addScaledVector(x2,x),S}intersectSphere(e,t){lc.subVectors(e.center,this.origin);const n=lc.dot(this.direction),r=lc.dot(lc)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),l=n-a,u=n+a;return u<0?null:l<0?this.at(u,t):this.at(l,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,l,u;const h=1/this.direction.x,m=1/this.direction.y,v=1/this.direction.z,x=this.origin;return h>=0?(n=(e.min.x-x.x)*h,r=(e.max.x-x.x)*h):(n=(e.max.x-x.x)*h,r=(e.min.x-x.x)*h),m>=0?(s=(e.min.y-x.y)*m,a=(e.max.y-x.y)*m):(s=(e.max.y-x.y)*m,a=(e.min.y-x.y)*m),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a=0?(l=(e.min.z-x.z)*v,u=(e.max.z-x.z)*v):(l=(e.max.z-x.z)*v,u=(e.min.z-x.z)*v),n>u||l>r)||((l>n||n!==n)&&(n=l),(u=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,lc)!==null}intersectTriangle(e,t,n,r,s){a3.subVectors(t,e),b2.subVectors(n,e),o3.crossVectors(a3,b2);let a=this.direction.dot(o3),l;if(a>0){if(r)return null;l=1}else if(a<0)l=-1,a=-a;else return null;dh.subVectors(this.origin,e);const u=l*this.direction.dot(b2.crossVectors(dh,b2));if(u<0)return null;const h=l*this.direction.dot(a3.cross(dh));if(h<0||u+h>a)return null;const m=-l*dh.dot(o3);return m<0?null:this.at(m/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class jn{constructor(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C){jn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C)}set(e,t,n,r,s,a,l,u,h,m,v,x,S,T,N,C){const E=this.elements;return E[0]=e,E[4]=t,E[8]=n,E[12]=r,E[1]=s,E[5]=a,E[9]=l,E[13]=u,E[2]=h,E[6]=m,E[10]=v,E[14]=x,E[3]=S,E[7]=T,E[11]=N,E[15]=C,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new jn().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/sA.setFromMatrixColumn(e,0).length(),s=1/sA.setFromMatrixColumn(e,1).length(),a=1/sA.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),l=Math.sin(n),u=Math.cos(r),h=Math.sin(r),m=Math.cos(s),v=Math.sin(s);if(e.order==="XYZ"){const x=a*m,S=a*v,T=l*m,N=l*v;t[0]=u*m,t[4]=-u*v,t[8]=h,t[1]=S+T*h,t[5]=x-N*h,t[9]=-l*u,t[2]=N-x*h,t[6]=T+S*h,t[10]=a*u}else if(e.order==="YXZ"){const x=u*m,S=u*v,T=h*m,N=h*v;t[0]=x+N*l,t[4]=T*l-S,t[8]=a*h,t[1]=a*v,t[5]=a*m,t[9]=-l,t[2]=S*l-T,t[6]=N+x*l,t[10]=a*u}else if(e.order==="ZXY"){const x=u*m,S=u*v,T=h*m,N=h*v;t[0]=x-N*l,t[4]=-a*v,t[8]=T+S*l,t[1]=S+T*l,t[5]=a*m,t[9]=N-x*l,t[2]=-a*h,t[6]=l,t[10]=a*u}else if(e.order==="ZYX"){const x=a*m,S=a*v,T=l*m,N=l*v;t[0]=u*m,t[4]=T*h-S,t[8]=x*h+N,t[1]=u*v,t[5]=N*h+x,t[9]=S*h-T,t[2]=-h,t[6]=l*u,t[10]=a*u}else if(e.order==="YZX"){const x=a*u,S=a*h,T=l*u,N=l*h;t[0]=u*m,t[4]=N-x*v,t[8]=T*v+S,t[1]=v,t[5]=a*m,t[9]=-l*m,t[2]=-h*m,t[6]=S*v+T,t[10]=x-N*v}else if(e.order==="XZY"){const x=a*u,S=a*h,T=l*u,N=l*h;t[0]=u*m,t[4]=-v,t[8]=h*m,t[1]=x*v+N,t[5]=a*m,t[9]=S*v-T,t[2]=T*v-S,t[6]=l*m,t[10]=N*v+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ik,e,Fk)}lookAt(e,t,n){const r=this.elements;return ho.subVectors(e,t),ho.lengthSq()===0&&(ho.z=1),ho.normalize(),Ah.crossVectors(n,ho),Ah.lengthSq()===0&&(Math.abs(n.z)===1?ho.x+=1e-4:ho.z+=1e-4,ho.normalize(),Ah.crossVectors(n,ho)),Ah.normalize(),S2.crossVectors(ho,Ah),r[0]=Ah.x,r[4]=S2.x,r[8]=ho.x,r[1]=Ah.y,r[5]=S2.y,r[9]=ho.y,r[2]=Ah.z,r[6]=S2.z,r[10]=ho.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],l=n[4],u=n[8],h=n[12],m=n[1],v=n[5],x=n[9],S=n[13],T=n[2],N=n[6],C=n[10],E=n[14],O=n[3],U=n[7],I=n[11],j=n[15],z=r[0],G=r[4],H=r[8],q=r[12],V=r[1],Q=r[5],J=r[9],ie=r[13],le=r[2],re=r[6],Z=r[10],ne=r[14],de=r[3],be=r[7],Te=r[11],ae=r[15];return s[0]=a*z+l*V+u*le+h*de,s[4]=a*G+l*Q+u*re+h*be,s[8]=a*H+l*J+u*Z+h*Te,s[12]=a*q+l*ie+u*ne+h*ae,s[1]=m*z+v*V+x*le+S*de,s[5]=m*G+v*Q+x*re+S*be,s[9]=m*H+v*J+x*Z+S*Te,s[13]=m*q+v*ie+x*ne+S*ae,s[2]=T*z+N*V+C*le+E*de,s[6]=T*G+N*Q+C*re+E*be,s[10]=T*H+N*J+C*Z+E*Te,s[14]=T*q+N*ie+C*ne+E*ae,s[3]=O*z+U*V+I*le+j*de,s[7]=O*G+U*Q+I*re+j*be,s[11]=O*H+U*J+I*Z+j*Te,s[15]=O*q+U*ie+I*ne+j*ae,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],l=e[5],u=e[9],h=e[13],m=e[2],v=e[6],x=e[10],S=e[14],T=e[3],N=e[7],C=e[11],E=e[15];return T*(+s*u*v-r*h*v-s*l*x+n*h*x+r*l*S-n*u*S)+N*(+t*u*S-t*h*x+s*a*x-r*a*S+r*h*m-s*u*m)+C*(+t*h*v-t*l*S-s*a*v+n*a*S+s*l*m-n*h*m)+E*(-r*l*m-t*u*v+t*l*x+r*a*v-n*a*x+n*u*m)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],l=e[5],u=e[6],h=e[7],m=e[8],v=e[9],x=e[10],S=e[11],T=e[12],N=e[13],C=e[14],E=e[15],O=v*C*h-N*x*h+N*u*S-l*C*S-v*u*E+l*x*E,U=T*x*h-m*C*h-T*u*S+a*C*S+m*u*E-a*x*E,I=m*N*h-T*v*h+T*l*S-a*N*S-m*l*E+a*v*E,j=T*v*u-m*N*u-T*l*x+a*N*x+m*l*C-a*v*C,z=t*O+n*U+r*I+s*j;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const G=1/z;return e[0]=O*G,e[1]=(N*x*s-v*C*s-N*r*S+n*C*S+v*r*E-n*x*E)*G,e[2]=(l*C*s-N*u*s+N*r*h-n*C*h-l*r*E+n*u*E)*G,e[3]=(v*u*s-l*x*s-v*r*h+n*x*h+l*r*S-n*u*S)*G,e[4]=U*G,e[5]=(m*C*s-T*x*s+T*r*S-t*C*S-m*r*E+t*x*E)*G,e[6]=(T*u*s-a*C*s-T*r*h+t*C*h+a*r*E-t*u*E)*G,e[7]=(a*x*s-m*u*s+m*r*h-t*x*h-a*r*S+t*u*S)*G,e[8]=I*G,e[9]=(T*v*s-m*N*s-T*n*S+t*N*S+m*n*E-t*v*E)*G,e[10]=(a*N*s-T*l*s+T*n*h-t*N*h-a*n*E+t*l*E)*G,e[11]=(m*l*s-a*v*s-m*n*h+t*v*h+a*n*S-t*l*S)*G,e[12]=j*G,e[13]=(m*N*r-T*v*r+T*n*x-t*N*x-m*n*C+t*v*C)*G,e[14]=(T*l*r-a*N*r-T*n*u+t*N*u+a*n*C-t*l*C)*G,e[15]=(a*v*r-m*l*r+m*n*u-t*v*u-a*n*x+t*l*x)*G,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,l=e.y,u=e.z,h=s*a,m=s*l;return this.set(h*a+n,h*l-r*u,h*u+r*l,0,h*l+r*u,m*l+n,m*u-r*a,0,h*u-r*l,m*u+r*a,s*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,l=t._z,u=t._w,h=s+s,m=a+a,v=l+l,x=s*h,S=s*m,T=s*v,N=a*m,C=a*v,E=l*v,O=u*h,U=u*m,I=u*v,j=n.x,z=n.y,G=n.z;return r[0]=(1-(N+E))*j,r[1]=(S+I)*j,r[2]=(T-U)*j,r[3]=0,r[4]=(S-I)*z,r[5]=(1-(x+E))*z,r[6]=(C+O)*z,r[7]=0,r[8]=(T+U)*G,r[9]=(C-O)*G,r[10]=(1-(x+N))*G,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=sA.set(r[0],r[1],r[2]).length();const a=sA.set(r[4],r[5],r[6]).length(),l=sA.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Al.copy(this);const h=1/s,m=1/a,v=1/l;return Al.elements[0]*=h,Al.elements[1]*=h,Al.elements[2]*=h,Al.elements[4]*=m,Al.elements[5]*=m,Al.elements[6]*=m,Al.elements[8]*=v,Al.elements[9]*=v,Al.elements[10]*=v,t.setFromRotationMatrix(Al),n.x=s,n.y=a,n.z=l,this}makePerspective(e,t,n,r,s,a,l=Ga){const u=this.elements,h=2*s/(t-e),m=2*s/(n-r),v=(t+e)/(t-e),x=(n+r)/(n-r);let S,T;if(l===Ga)S=-(a+s)/(a-s),T=-2*a*s/(a-s);else if(l===cu)S=-a/(a-s),T=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=h,u[4]=0,u[8]=v,u[12]=0,u[1]=0,u[5]=m,u[9]=x,u[13]=0,u[2]=0,u[6]=0,u[10]=S,u[14]=T,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,t,n,r,s,a,l=Ga){const u=this.elements,h=1/(t-e),m=1/(n-r),v=1/(a-s),x=(t+e)*h,S=(n+r)*m;let T,N;if(l===Ga)T=(a+s)*v,N=-2*v;else if(l===cu)T=s*v,N=-1*v;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=2*h,u[4]=0,u[8]=0,u[12]=-x,u[1]=0,u[5]=2*m,u[9]=0,u[13]=-S,u[2]=0,u[6]=0,u[10]=N,u[14]=-T,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const sA=new pe,Al=new jn,Ik=new pe(0,0,0),Fk=new pe(1,1,1),Ah=new pe,S2=new pe,ho=new pe,tN=new jn,nN=new hu;class aa{constructor(e=0,t=0,n=0,r=aa.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],l=r[8],u=r[1],h=r[5],m=r[9],v=r[2],x=r[6],S=r[10];switch(t){case"XYZ":this._y=Math.asin(ri(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-m,S),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(x,h),this._z=0);break;case"YXZ":this._x=Math.asin(-ri(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(l,S),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-v,s),this._z=0);break;case"ZXY":this._x=Math.asin(ri(x,-1,1)),Math.abs(x)<.9999999?(this._y=Math.atan2(-v,S),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-ri(v,-1,1)),Math.abs(v)<.9999999?(this._x=Math.atan2(x,S),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-a,h));break;case"YZX":this._z=Math.asin(ri(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-m,h),this._y=Math.atan2(-v,s)):(this._x=0,this._y=Math.atan2(l,S));break;case"XZY":this._z=Math.asin(-ri(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(x,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-m,S),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return tN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(tN,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return nN.setFromEuler(this),this.setFromQuaternion(nN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}aa.DEFAULT_ORDER="XYZ";class YT{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(l,u){return l[u.uuid]===void 0&&(l[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const u=l.shapes;if(Array.isArray(u))for(let h=0,m=u.length;h0){r.children=[];for(let l=0;l0){r.animations=[];for(let l=0;l0&&(n.geometries=l),u.length>0&&(n.materials=u),h.length>0&&(n.textures=h),m.length>0&&(n.images=m),v.length>0&&(n.shapes=v),x.length>0&&(n.skeletons=x),S.length>0&&(n.animations=S),T.length>0&&(n.nodes=T)}return n.object=r,n;function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){pl.subVectors(r,t),cc.subVectors(n,t),u3.subVectors(e,t);const a=pl.dot(pl),l=pl.dot(cc),u=pl.dot(u3),h=cc.dot(cc),m=cc.dot(u3),v=a*h-l*l;if(v===0)return s.set(0,0,0),null;const x=1/v,S=(h*u-l*m)*x,T=(a*m-l*u)*x;return s.set(1-S-T,T,S)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,hc)===null?!1:hc.x>=0&&hc.y>=0&&hc.x+hc.y<=1}static getInterpolation(e,t,n,r,s,a,l,u){return this.getBarycoord(e,t,n,r,hc)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(s,hc.x),u.addScaledVector(a,hc.y),u.addScaledVector(l,hc.z),u)}static getInterpolatedAttribute(e,t,n,r,s,a){return d3.setScalar(0),A3.setScalar(0),p3.setScalar(0),d3.fromBufferAttribute(e,t),A3.fromBufferAttribute(e,n),p3.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(d3,s.x),a.addScaledVector(A3,s.y),a.addScaledVector(p3,s.z),a}static isFrontFacing(e,t,n,r){return pl.subVectors(n,t),cc.subVectors(e,t),pl.cross(cc).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return pl.subVectors(this.c,this.b),cc.subVectors(this.a,this.b),pl.cross(cc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yl.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return yl.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return yl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,l;lA.subVectors(r,n),uA.subVectors(s,n),c3.subVectors(e,n);const u=lA.dot(c3),h=uA.dot(c3);if(u<=0&&h<=0)return t.copy(n);h3.subVectors(e,r);const m=lA.dot(h3),v=uA.dot(h3);if(m>=0&&v<=m)return t.copy(r);const x=u*v-m*h;if(x<=0&&u>=0&&m<=0)return a=u/(u-m),t.copy(n).addScaledVector(lA,a);f3.subVectors(e,s);const S=lA.dot(f3),T=uA.dot(f3);if(T>=0&&S<=T)return t.copy(s);const N=S*h-u*T;if(N<=0&&h>=0&&T<=0)return l=h/(h-T),t.copy(n).addScaledVector(uA,l);const C=m*T-S*v;if(C<=0&&v-m>=0&&S-T>=0)return lN.subVectors(s,r),l=(v-m)/(v-m+(S-T)),t.copy(r).addScaledVector(lN,l);const E=1/(C+N+x);return a=N*E,l=x*E,t.copy(n).addScaledVector(lA,a).addScaledVector(uA,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const j7={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ph={h:0,s:0,l:0},T2={h:0,s:0,l:0};function m3(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}let cn=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=bn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,li.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=li.workingColorSpace){return this.r=e,this.g=t,this.b=n,li.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=li.workingColorSpace){if(e=$T(e,1),t=ri(t,0,1),n=ri(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=m3(a,s,e+1/3),this.g=m3(a,s,e),this.b=m3(a,s,e-1/3)}return li.toWorkingColorSpace(this,r),this}setStyle(e,t=bn){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],l=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=bn){const n=j7[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=xc(e.r),this.g=xc(e.g),this.b=xc(e.b),this}copyLinearToSRGB(e){return this.r=YA(e.r),this.g=YA(e.g),this.b=YA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=bn){return li.fromWorkingColorSpace(Zs.copy(this),e),Math.round(ri(Zs.r*255,0,255))*65536+Math.round(ri(Zs.g*255,0,255))*256+Math.round(ri(Zs.b*255,0,255))}getHexString(e=bn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=li.workingColorSpace){li.fromWorkingColorSpace(Zs.copy(this),t);const n=Zs.r,r=Zs.g,s=Zs.b,a=Math.max(n,r,s),l=Math.min(n,r,s);let u,h;const m=(l+a)/2;if(l===a)u=0,h=0;else{const v=a-l;switch(h=m<=.5?v/(a+l):v/(2-a-l),a){case n:u=(r-s)/v+(r0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Xa&&(n.blending=this.blending),this.side!==El&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==zm&&(n.blendSrc=this.blendSrc),this.blendDst!==Gm&&(n.blendDst=this.blendDst),this.blendEquation!==wo&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Bh&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==YS&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Nf&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Nf&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Nf&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const l in s){const u=s[l];delete u.metadata,a.push(u)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class cd extends oa{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new cn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const gc=jk();function jk(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const h=u-127;h<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):h<-14?(n[u]=1024>>-h-14,n[u|256]=1024>>-h-14|32768,r[u]=-h-1,r[u|256]=-h-1):h<=15?(n[u]=h+15<<10,n[u|256]=h+15<<10|32768,r[u]=13,r[u|256]=13):h<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),l=new Uint32Array(64);for(let u=1;u<1024;++u){let h=u<<13,m=0;for(;(h&8388608)===0;)h<<=1,m-=8388608;h&=-8388609,m+=947912704,s[u]=h|m}for(let u=1024;u<2048;++u)s[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(l[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:l}}function fo(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=ri(i,-65504,65504),gc.floatView[0]=i;const e=gc.uint32View[0],t=e>>23&511;return gc.baseTable[t]+((e&8388607)>>gc.shiftTable[t])}function M2(i){const e=i>>10;return gc.uint32View[0]=gc.mantissaTable[gc.offsetTable[e]+(i&1023)]+gc.exponentTable[e],gc.floatView[0]}const is=new pe,E2=new bt;class wr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=s_,this.updateRanges=[],this.gpuType=$r,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;rt.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Oc);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new pe(-1/0,-1/0,-1/0),new pe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const h in u)u[h]!==void 0&&(e[h]=u[h]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const h=n[u];e.data.attributes[u]=h.toJSON(e.data)}const r={};let s=!1;for(const u in this.morphAttributes){const h=this.morphAttributes[u],m=[];for(let v=0,x=h.length;v0&&(r[u]=m,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const r=e.attributes;for(const h in r){const m=r[h];this.setAttribute(h,m.clone(t))}const s=e.morphAttributes;for(const h in s){const m=[],v=s[h];for(let x=0,S=v.length;x0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s(e.far-e.near)**2))&&(uN.copy(s).invert(),gf.copy(e.ray).applyMatrix4(uN),!(n.boundingBox!==null&&gf.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,gf)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,l=s.index,u=s.attributes.position,h=s.attributes.uv,m=s.attributes.uv1,v=s.attributes.normal,x=s.groups,S=s.drawRange;if(l!==null)if(Array.isArray(a))for(let T=0,N=x.length;Tt.far?null:{distance:h,point:L2.clone(),object:i}}function U2(i,e,t,n,r,s,a,l,u,h){i.getVertexPosition(l,N2),i.getVertexPosition(u,R2),i.getVertexPosition(h,D2);const m=Wk(i,e,t,n,N2,R2,D2,hN);if(m){const v=new pe;yl.getBarycoord(hN,N2,R2,D2,v),r&&(m.uv=yl.getInterpolatedAttribute(r,l,u,h,v,new bt)),s&&(m.uv1=yl.getInterpolatedAttribute(s,l,u,h,v,new bt)),a&&(m.normal=yl.getInterpolatedAttribute(a,l,u,h,v,new pe),m.normal.dot(n.direction)>0&&m.normal.multiplyScalar(-1));const x={a:l,b:u,c:h,normal:new pe,materialIndex:0};yl.getNormal(N2,R2,D2,x.normal),m.face=x,m.barycoord=v}return m}class Vh extends Hi{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const u=[],h=[],m=[],v=[];let x=0,S=0;T("z","y","x",-1,-1,n,t,e,a,s,0),T("z","y","x",1,-1,n,t,-e,a,s,1),T("x","z","y",1,1,e,n,t,r,a,2),T("x","z","y",1,-1,e,n,-t,r,a,3),T("x","y","z",1,-1,e,t,n,r,s,4),T("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(u),this.setAttribute("position",new Si(h,3)),this.setAttribute("normal",new Si(m,3)),this.setAttribute("uv",new Si(v,2));function T(N,C,E,O,U,I,j,z,G,H,q){const V=I/G,Q=j/H,J=I/2,ie=j/2,le=z/2,re=G+1,Z=H+1;let ne=0,de=0;const be=new pe;for(let Te=0;Te0?1:-1,m.push(be.x,be.y,be.z),v.push(Me/G),v.push(1-Te/H),ne+=1}}for(let Te=0;Te0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class gy extends pr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new jn,this.projectionMatrix=new jn,this.projectionMatrixInverse=new jn,this.coordinateSystem=Ga}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const mh=new me,fN=new bt,dN=new bt;class va extends gy{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=y0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Tm*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return y0*2*Math.atan(Math.tan(Tm*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){mh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(mh.x,mh.y).multiplyScalar(-e/mh.z),mh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(mh.x,mh.y).multiplyScalar(-e/mh.z)}getViewSize(e,t){return this.getViewBounds(e,fN,dN),t.subVectors(dN,fN)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Tm*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,h=a.fullHeight;s+=a.offsetX*r/u,t-=a.offsetY*n/h,r*=a.width/u,n*=a.height/h}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const hA=-90,fA=1;class $7 extends pr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new va(hA,fA,e,t);r.layers=this.layers,this.add(r);const s=new va(hA,fA,e,t);s.layers=this.layers,this.add(s);const a=new va(hA,fA,e,t);a.layers=this.layers,this.add(a);const l=new va(hA,fA,e,t);l.layers=this.layers,this.add(l);const u=new va(hA,fA,e,t);u.layers=this.layers,this.add(u);const h=new va(hA,fA,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,l,u]=t;for(const h of t)this.remove(h);if(e===Ga)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===cu)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,l,u,h,m]=this.children,v=e.getRenderTarget(),x=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),T=e.xr.enabled;e.xr.enabled=!1;const N=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,l),e.setRenderTarget(n,3,r),e.render(t,u),e.setRenderTarget(n,4,r),e.render(t,h),n.texture.generateMipmaps=N,e.setRenderTarget(n,5,r),e.render(t,m),e.setRenderTarget(v,x,S),e.xr.enabled=T,n.texture.needsPMREMUpdate=!0}}class vy extends ms{constructor(e,t,n,r,s,a,l,u,h,m){e=e!==void 0?e:[],t=t!==void 0?t:Xo,super(e,t,n,r,s,a,l,u,h,m),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class X7 extends Fh{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new vy(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:ps}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` +}`;class Qa extends oa{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Xk,this.fragmentShader=Yk,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=b0(e.uniforms),this.uniformsGroups=$k(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class gy extends pr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new jn,this.projectionMatrix=new jn,this.projectionMatrixInverse=new jn,this.coordinateSystem=Ga}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const mh=new pe,fN=new bt,dN=new bt;class va extends gy{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=y0*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Tm*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return y0*2*Math.atan(Math.tan(Tm*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){mh.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(mh.x,mh.y).multiplyScalar(-e/mh.z),mh.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(mh.x,mh.y).multiplyScalar(-e/mh.z)}getViewSize(e,t){return this.getViewBounds(e,fN,dN),t.subVectors(dN,fN)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Tm*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,h=a.fullHeight;s+=a.offsetX*r/u,t-=a.offsetY*n/h,r*=a.width/u,n*=a.height/h}const l=this.filmOffset;l!==0&&(s+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const hA=-90,fA=1;class $7 extends pr{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new va(hA,fA,e,t);r.layers=this.layers,this.add(r);const s=new va(hA,fA,e,t);s.layers=this.layers,this.add(s);const a=new va(hA,fA,e,t);a.layers=this.layers,this.add(a);const l=new va(hA,fA,e,t);l.layers=this.layers,this.add(l);const u=new va(hA,fA,e,t);u.layers=this.layers,this.add(u);const h=new va(hA,fA,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,l,u]=t;for(const h of t)this.remove(h);if(e===Ga)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===cu)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const h of t)this.add(h),h.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,l,u,h,m]=this.children,v=e.getRenderTarget(),x=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),T=e.xr.enabled;e.xr.enabled=!1;const N=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,l),e.setRenderTarget(n,3,r),e.render(t,u),e.setRenderTarget(n,4,r),e.render(t,h),n.texture.generateMipmaps=N,e.setRenderTarget(n,5,r),e.render(t,m),e.setRenderTarget(v,x,S),e.xr.enabled=T,n.texture.needsPMREMUpdate=!0}}class vy extends ms{constructor(e,t,n,r,s,a,l,u,h,m){e=e!==void 0?e:[],t=t!==void 0?t:Xo,super(e,t,n,r,s,a,l,u,h,m),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class X7 extends Fh{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new vy(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:ps}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -89,7 +89,7 @@ Error generating stack: `+b.message+` gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},r=new Vh(5,5,5),s=new Qa({name:"CubemapFromEquirect",uniforms:b0(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:or,blending:$a});s.uniforms.tEquirect.value=t;const a=new Oi(r,s),l=t.minFilter;return t.minFilter===za&&(t.minFilter=ps),new $7(1,10,this).update(e,a),t.minFilter=l,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class ZT extends pr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new aa,this.environmentIntensity=1,this.environmentRotation=new aa,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class JT{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=s_,this.updateRanges=[],this.version=0,this.uuid=nu()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Jk.getNormalMatrix(e),r=this.coplanarPoint(_3).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const vf=new ud,B2=new me;class Og{constructor(e=new jl,t=new jl,n=new jl,r=new jl,s=new jl,a=new jl){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(s),l[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ga){const n=this.planes,r=e.elements,s=r[0],a=r[1],l=r[2],u=r[3],h=r[4],m=r[5],v=r[6],x=r[7],S=r[8],T=r[9],N=r[10],C=r[11],E=r[12],O=r[13],U=r[14],I=r[15];if(n[0].setComponents(u-s,x-h,C-S,I-E).normalize(),n[1].setComponents(u+s,x+h,C+S,I+E).normalize(),n[2].setComponents(u+a,x+m,C+T,I+O).normalize(),n[3].setComponents(u-a,x-m,C-T,I-O).normalize(),n[4].setComponents(u-l,x-v,C-N,I-U).normalize(),t===Ga)n[5].setComponents(u+l,x+v,C+N,I+U).normalize();else if(t===cu)n[5].setComponents(l,v,N,U).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),vf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),vf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(vf)}intersectsSprite(e){return vf.center.set(0,0,0),vf.radius=.7071067811865476,vf.applyMatrix4(e.matrixWorld),this.intersectsSphere(vf)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,B2.y=r.normal.y>0?e.max.y:e.min.y,B2.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(B2)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class q0 extends oa{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new cn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const a_=new me,o_=new me,AN=new jn,Qp=new Ug,O2=new ud,y3=new me,pN=new me;class _y extends pr{constructor(e=new Hi,t=new q0){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sn)return;y3.applyMatrix4(i.matrixWorld);const u=e.ray.origin.distanceTo(y3);if(!(ue.far))return{distance:u,point:pN.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const mN=new me,gN=new me;class Y7 extends _y{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}let qa=class extends pr{constructor(){super(),this.isGroup=!0,this.type="Group"}};class Q7 extends ms{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=dr,this.minFilter=dr,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ic extends ms{constructor(e,t,n,r,s,a,l,u,h,m=tu){if(m!==tu&&m!==uu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&m===tu&&(n=Nr),n===void 0&&m===uu&&(n=lu),super(null,r,s,a,l,u,m,n,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:dr,this.minFilter=u!==void 0?u:dr,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Nl{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let l=0,u=s-1,h;for(;l<=u;)if(r=Math.floor(l+(u-l)/2),h=n[r]-a,h<0)l=r+1;else if(h>0)u=r-1;else{u=r;break}if(r=u,n[r]===a)return r/(s-1);const m=n[r],x=n[r+1]-m,S=(a-m)/x;return(r+S)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),l=this.getPoint(s),u=t||(a.isVector2?new bt:new me);return u.copy(l).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new me,r=[],s=[],a=[],l=new me,u=new jn;for(let S=0;S<=e;S++){const T=S/e;r[S]=this.getTangentAt(T,new me)}s[0]=new me,a[0]=new me;let h=Number.MAX_VALUE;const m=Math.abs(r[0].x),v=Math.abs(r[0].y),x=Math.abs(r[0].z);m<=h&&(h=m,n.set(1,0,0)),v<=h&&(h=v,n.set(0,1,0)),x<=h&&n.set(0,0,1),l.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],l),a[0].crossVectors(r[0],s[0]);for(let S=1;S<=e;S++){if(s[S]=s[S-1].clone(),a[S]=a[S-1].clone(),l.crossVectors(r[S-1],r[S]),l.length()>Number.EPSILON){l.normalize();const T=Math.acos(ri(r[S-1].dot(r[S]),-1,1));s[S].applyMatrix4(u.makeRotationAxis(l,T))}a[S].crossVectors(r[S],s[S])}if(t===!0){let S=Math.acos(ri(s[0].dot(s[e]),-1,1));S/=e,r[0].dot(l.crossVectors(s[0],s[e]))>0&&(S=-S);for(let T=1;T<=e;T++)s[T].applyMatrix4(u.makeRotationAxis(r[T],S*T)),a[T].crossVectors(r[T],s[T])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class tM extends Nl{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,l=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=l,this.aRotation=u}getPoint(e,t=new bt){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(l)/s)+1)*s:u===0&&l===s-1&&(l=s-2,u=1);let h,m;this.closed||l>0?h=r[(l-1)%s]:(z2.subVectors(r[0],r[1]).add(r[0]),h=z2);const v=r[l%s],x=r[(l+1)%s];if(this.closed||l+2r.length-2?r.length-1:a+1],v=r[a>r.length-3?r.length-1:a+2];return n.set(yN(l,u.x,h.x,m.x,v.x),yN(l,u.y,h.y,m.y,v.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[s]-n,l=this.curves[s],u=l.getLength(),h=u===0?0:1-a/u;return l.getPointAt(h,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const v=h.getPoint(0);v.equals(this.currentPoint)||this.lineTo(v.x,v.y)}this.curves.push(h);const m=h.getPoint(1);return this.currentPoint.copy(m),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class yy extends Hi{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],l=[],u=[],h=new me,m=new bt;a.push(0,0,0),l.push(0,0,1),u.push(.5,.5);for(let v=0,x=3;v<=t;v++,x+=3){const S=n+v/t*r;h.x=e*Math.cos(S),h.y=e*Math.sin(S),a.push(h.x,h.y,h.z),l.push(0,0,1),m.x=(a[x]/e+1)/2,m.y=(a[x+1]/e+1)/2,u.push(m.x,m.y)}for(let v=1;v<=t;v++)s.push(v,v+1,0);this.setIndex(s),this.setAttribute("position",new Si(a,3)),this.setAttribute("normal",new Si(l,3)),this.setAttribute("uv",new Si(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yy(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class iM extends Hi{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:l,thetaLength:u};const h=this;r=Math.floor(r),s=Math.floor(s);const m=[],v=[],x=[],S=[];let T=0;const N=[],C=n/2;let E=0;O(),a===!1&&(e>0&&U(!0),t>0&&U(!1)),this.setIndex(m),this.setAttribute("position",new Si(v,3)),this.setAttribute("normal",new Si(x,3)),this.setAttribute("uv",new Si(S,2));function O(){const I=new me,j=new me;let z=0;const G=(t-e)/n;for(let H=0;H<=s;H++){const q=[],V=H/s,Q=V*(t-e)+e;for(let J=0;J<=r;J++){const ne=J/r,oe=ne*u+l,ie=Math.sin(oe),Z=Math.cos(oe);j.x=Q*ie,j.y=-V*n+C,j.z=Q*Z,v.push(j.x,j.y,j.z),I.set(ie,G,Z).normalize(),x.push(I.x,I.y,I.z),S.push(ne,1-V),q.push(T++)}N.push(q)}for(let H=0;H0||q!==0)&&(m.push(V,Q,ne),z+=3),(t>0||q!==s-1)&&(m.push(Q,J,ne),z+=3)}h.addGroup(E,z,0),E+=z}function U(I){const j=T,z=new bt,G=new me;let H=0;const q=I===!0?e:t,V=I===!0?1:-1;for(let J=1;J<=r;J++)v.push(0,C*V,0),x.push(0,V,0),S.push(.5,.5),T++;const Q=T;for(let J=0;J<=r;J++){const oe=J/r*u+l,ie=Math.cos(oe),Z=Math.sin(oe);G.x=q*Z,G.y=C*V,G.z=q*ie,v.push(G.x,G.y,G.z),x.push(0,V,0),z.x=ie*.5+.5,z.y=Z*.5*V+.5,S.push(z.x,z.y),T++}for(let J=0;J80*t){l=h=i[0],u=m=i[1];for(let T=t;Th&&(h=v),x>m&&(m=x);S=Math.max(h-l,m-u),S=S!==0?32767/S:0}return rg(s,a,t,l,u,S,0),a}};function iD(i,e,t,n,r){let s,a;if(r===Cz(i,e,t,n)>0)for(s=e;s=e;s-=n)a=xN(s,i[s],i[s+1],a);return a&&xy(a,a.next)&&(ag(a),a=a.next),a}function rd(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(xy(t,t.next)||Rr(t.prev,t,t.next)===0)){if(ag(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function rg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&bz(i,n,r,s);let l=i,u,h;for(;i.prev!==i.next;){if(u=i.prev,h=i.next,s?Az(i,n,r,s):dz(i)){e.push(u.i/t|0),e.push(i.i/t|0),e.push(h.i/t|0),ag(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=pz(rd(i),e,t),rg(i,e,t,n,r,s,2)):a===2&&mz(i,e,t,n,r,s):rg(rd(i),e,t,n,r,s,1);break}}}function dz(i){const e=i.prev,t=i,n=i.next;if(Rr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=rs?r>a?r:a:s>a?s:a,S=l>u?l>h?l:h:u>h?u:h;let T=n.next;for(;T!==e;){if(T.x>=m&&T.x<=x&&T.y>=v&&T.y<=S&&FA(r,l,s,u,a,h,T.x,T.y)&&Rr(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function Az(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Rr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=lu?l>h?l:h:u>h?u:h,C=m>v?m>x?m:x:v>x?v:x,E=ZS(S,T,e,t,n),O=ZS(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&FA(l,m,u,v,h,x,U.x,U.y)&&Rr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&FA(l,m,u,v,h,x,I.x,I.y)&&Rr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&FA(l,m,u,v,h,x,U.x,U.y)&&Rr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&FA(l,m,u,v,h,x,I.x,I.y)&&Rr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function pz(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!xy(r,s)&&rD(r,n,n.next,s)&&sg(r,s)&&sg(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),ag(n),ag(n.next),n=i=s),n=n.next}while(n!==i);return rd(n)}function mz(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&Tz(a,l)){let u=sD(a,l);a=rd(a,a.next),u=rd(u,u.next),rg(a,e,t,n,r,s,0),rg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function gz(i,e,t,n){const r=[];let s,a,l,u,h;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const x=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=s&&x>n&&(n=x,r=t.x=t.x&&t.x>=u&&s!==t.x&&FA(ar.x||t.x===r.x&&xz(r,t)))&&(r=t,m=v)),t=t.next;while(t!==l);return r}function xz(i,e){return Rr(i.prev,i,e.prev)<0&&Rr(e.next,i,i.next)<0}function bz(i,e,t,n){let r=i;do r.z===0&&(r.z=ZS(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Sz(r)}function Sz(i){let e,t,n,r,s,a,l,u,h=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,l=0,e=0;e0||u>0&&n;)l!==0&&(u===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,l--):(r=n,n=n.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,h*=2}while(a>1);return i}function ZS(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function wz(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function Tz(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Mz(i,e)&&(sg(i,e)&&sg(e,i)&&Ez(i,e)&&(Rr(i.prev,i,e.prev)||Rr(i,e.prev,e))||xy(i,e)&&Rr(i.prev,i,i.next)>0&&Rr(e.prev,e,e.next)>0)}function Rr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function xy(i,e){return i.x===e.x&&i.y===e.y}function rD(i,e,t,n){const r=q2(Rr(i,e,t)),s=q2(Rr(i,e,n)),a=q2(Rr(t,n,i)),l=q2(Rr(t,n,e));return!!(r!==s&&a!==l||r===0&&G2(i,t,e)||s===0&&G2(i,n,e)||a===0&&G2(t,i,n)||l===0&&G2(t,e,n))}function G2(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function q2(i){return i>0?1:i<0?-1:0}function Mz(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&rD(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function sg(i,e){return Rr(i.prev,i,i.next)<0?Rr(i,e,i.next)>=0&&Rr(i,i.prev,e)>=0:Rr(i,e,i.prev)<0||Rr(i,i.next,e)<0}function Ez(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function sD(i,e){const t=new JS(i.i,i.x,i.y),n=new JS(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function xN(i,e,t,n){const r=new JS(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ag(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function JS(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Cz(i,e,t,n){let r=0;for(let s=e,a=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function SN(i,e){for(let t=0;tNumber.EPSILON){const Oe=Math.sqrt(k),pe=Math.sqrt(pt*pt+Ae*Ae),le=ft.x-Xt/Oe,Ne=ft.y+_t/Oe,De=fe.x-Ae/pe,Je=fe.y+pt/pe,we=((De-le)*Ae-(Je-Ne)*pt)/(_t*Ae-Xt*pt);Wt=le+_t*we-We.x,yt=Ne+Xt*we-We.y;const Ue=Wt*Wt+yt*yt;if(Ue<=2)return new bt(Wt,yt);Gt=Math.sqrt(Ue/2)}else{let Oe=!1;_t>Number.EPSILON?pt>Number.EPSILON&&(Oe=!0):_t<-Number.EPSILON?pt<-Number.EPSILON&&(Oe=!0):Math.sign(Xt)===Math.sign(Ae)&&(Oe=!0),Oe?(Wt=-Xt,yt=_t,Gt=Math.sqrt(k)):(Wt=_t,yt=Xt,Gt=Math.sqrt(k/2))}return new bt(Wt/Gt,yt/Gt)}const Se=[];for(let We=0,ft=oe.length,fe=ft-1,Wt=We+1;We=0;We--){const ft=We/C,fe=S*Math.cos(ft*Math.PI/2),Wt=T*Math.sin(ft*Math.PI/2)+N;for(let yt=0,Gt=oe.length;yt=0;){const Wt=fe;let yt=fe-1;yt<0&&(yt=We.length-1);for(let Gt=0,_t=m+C*2;Gt<_t;Gt++){const Xt=Z*Gt,pt=Z*(Gt+1),Ae=ft+Wt+Xt,k=ft+yt+Xt,be=ft+yt+pt,Oe=ft+Wt+pt;Et(Ae,k,be,Oe)}}}function He(We,ft,fe){u.push(We),u.push(ft),u.push(fe)}function Rt(We,ft,fe){zt(We),zt(ft),zt(fe);const Wt=r.length/3,yt=O.generateTopUV(n,r,Wt-3,Wt-2,Wt-1);Pt(yt[0]),Pt(yt[1]),Pt(yt[2])}function Et(We,ft,fe,Wt){zt(We),zt(ft),zt(Wt),zt(ft),zt(fe),zt(Wt);const yt=r.length/3,Gt=O.generateSideWallUV(n,r,yt-6,yt-3,yt-2,yt-1);Pt(Gt[0]),Pt(Gt[1]),Pt(Gt[3]),Pt(Gt[1]),Pt(Gt[2]),Pt(Gt[3])}function zt(We){r.push(u[We*3+0]),r.push(u[We*3+1]),r.push(u[We*3+2])}function Pt(We){s.push(We.x),s.push(We.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return Rz(t,n,e)}static fromJSON(e,t){const n=[];for(let s=0,a=e.shapes.length;s0)&&S.push(U,I,z),(E!==n-1||u0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class oD extends oa{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new cn(16777215),this.specular=new cn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Uz extends oa{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new cn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Bz extends oa{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Fc extends oa{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new cn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Oz extends oa{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=QF,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Iz extends oa{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Fz extends oa{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new cn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class kz extends q0{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const TN={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class zz{constructor(e,t,n){const r=this;let s=!1,a=0,l=0,u;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(m){l++,s===!1&&r.onStart!==void 0&&r.onStart(m,a,l),s=!0},this.itemEnd=function(m){a++,r.onProgress!==void 0&&r.onProgress(m,a,l),a===l&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(m){r.onError!==void 0&&r.onError(m)},this.resolveURL=function(m){return u?u(m):m},this.setURLModifier=function(m){return u=m,this},this.addHandler=function(m,v){return h.push(m,v),this},this.removeHandler=function(m){const v=h.indexOf(m);return v!==-1&&h.splice(v,2),this},this.getHandler=function(m){for(let v=0,x=h.length;vNumber.EPSILON){if(V<0&&(G=O[z],q=-q,H=O[j],V=-V),E.yH.y)continue;if(E.y===G.y){if(E.x===G.x)return!0}else{const Q=V*(E.x-G.x)-q*(E.y-G.y);if(Q===0)return!0;if(Q<0)continue;I=!I}}else{if(E.y!==G.y)continue;if(H.x<=E.x&&E.x<=G.x||G.x<=E.x&&E.x<=H.x)return!0}}return I}const r=QA.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,l,u;const h=[];if(s.length===1)return l=s[0],u=new kv,u.curves=l.curves,h.push(u),h;let m=!r(s[0].getPoints());m=e?!m:m;const v=[],x=[];let S=[],T=0,N;x[T]=void 0,S[T]=[];for(let E=0,O=s.length;E1){let E=!1,O=0;for(let U=0,I=x.length;U0&&E===!1&&(S=v)}let C;for(let E=0,O=x.length;E0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class JT{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=s_,this.updateRanges=[],this.version=0,this.uuid=nu()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,s=this.stride;r1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Jk.getNormalMatrix(e),r=this.coplanarPoint(_3).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const vf=new ud,B2=new pe;class Og{constructor(e=new jl,t=new jl,n=new jl,r=new jl,s=new jl,a=new jl){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(s),l[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ga){const n=this.planes,r=e.elements,s=r[0],a=r[1],l=r[2],u=r[3],h=r[4],m=r[5],v=r[6],x=r[7],S=r[8],T=r[9],N=r[10],C=r[11],E=r[12],O=r[13],U=r[14],I=r[15];if(n[0].setComponents(u-s,x-h,C-S,I-E).normalize(),n[1].setComponents(u+s,x+h,C+S,I+E).normalize(),n[2].setComponents(u+a,x+m,C+T,I+O).normalize(),n[3].setComponents(u-a,x-m,C-T,I-O).normalize(),n[4].setComponents(u-l,x-v,C-N,I-U).normalize(),t===Ga)n[5].setComponents(u+l,x+v,C+N,I+U).normalize();else if(t===cu)n[5].setComponents(l,v,N,U).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),vf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),vf.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(vf)}intersectsSprite(e){return vf.center.set(0,0,0),vf.radius=.7071067811865476,vf.applyMatrix4(e.matrixWorld),this.intersectsSphere(vf)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,B2.y=r.normal.y>0?e.max.y:e.min.y,B2.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(B2)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class q0 extends oa{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new cn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const a_=new pe,o_=new pe,AN=new jn,Qp=new Ug,O2=new ud,y3=new pe,pN=new pe;class _y extends pr{constructor(e=new Hi,t=new q0){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sn)return;y3.applyMatrix4(i.matrixWorld);const u=e.ray.origin.distanceTo(y3);if(!(ue.far))return{distance:u,point:pN.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const mN=new pe,gN=new pe;class Y7 extends _y{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;sr.far)return;s.push({distance:h,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}let qa=class extends pr{constructor(){super(),this.isGroup=!0,this.type="Group"}};class Q7 extends ms{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=dr,this.minFilter=dr,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ic extends ms{constructor(e,t,n,r,s,a,l,u,h,m=tu){if(m!==tu&&m!==uu)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&m===tu&&(n=Nr),n===void 0&&m===uu&&(n=lu),super(null,r,s,a,l,u,m,n,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:dr,this.minFilter=u!==void 0?u:dr,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Nl{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let l=0,u=s-1,h;for(;l<=u;)if(r=Math.floor(l+(u-l)/2),h=n[r]-a,h<0)l=r+1;else if(h>0)u=r-1;else{u=r;break}if(r=u,n[r]===a)return r/(s-1);const m=n[r],x=n[r+1]-m,S=(a-m)/x;return(r+S)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),l=this.getPoint(s),u=t||(a.isVector2?new bt:new pe);return u.copy(l).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new pe,r=[],s=[],a=[],l=new pe,u=new jn;for(let S=0;S<=e;S++){const T=S/e;r[S]=this.getTangentAt(T,new pe)}s[0]=new pe,a[0]=new pe;let h=Number.MAX_VALUE;const m=Math.abs(r[0].x),v=Math.abs(r[0].y),x=Math.abs(r[0].z);m<=h&&(h=m,n.set(1,0,0)),v<=h&&(h=v,n.set(0,1,0)),x<=h&&n.set(0,0,1),l.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],l),a[0].crossVectors(r[0],s[0]);for(let S=1;S<=e;S++){if(s[S]=s[S-1].clone(),a[S]=a[S-1].clone(),l.crossVectors(r[S-1],r[S]),l.length()>Number.EPSILON){l.normalize();const T=Math.acos(ri(r[S-1].dot(r[S]),-1,1));s[S].applyMatrix4(u.makeRotationAxis(l,T))}a[S].crossVectors(r[S],s[S])}if(t===!0){let S=Math.acos(ri(s[0].dot(s[e]),-1,1));S/=e,r[0].dot(l.crossVectors(s[0],s[e]))>0&&(S=-S);for(let T=1;T<=e;T++)s[T].applyMatrix4(u.makeRotationAxis(r[T],S*T)),a[T].crossVectors(r[T],s[T])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class tM extends Nl{constructor(e=0,t=0,n=1,r=1,s=0,a=Math.PI*2,l=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=l,this.aRotation=u}getPoint(e,t=new bt){const n=t,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)r;)s-=r;s0?0:(Math.floor(Math.abs(l)/s)+1)*s:u===0&&l===s-1&&(l=s-2,u=1);let h,m;this.closed||l>0?h=r[(l-1)%s]:(z2.subVectors(r[0],r[1]).add(r[0]),h=z2);const v=r[l%s],x=r[(l+1)%s];if(this.closed||l+2r.length-2?r.length-1:a+1],v=r[a>r.length-3?r.length-1:a+2];return n.set(yN(l,u.x,h.x,m.x,v.x),yN(l,u.y,h.y,m.y,v.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const a=r[s]-n,l=this.curves[s],u=l.getLength(),h=u===0?0:1-a/u;return l.getPointAt(h,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const v=h.getPoint(0);v.equals(this.currentPoint)||this.lineTo(v.x,v.y)}this.curves.push(h);const m=h.getPoint(1);return this.currentPoint.copy(m),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class yy extends Hi{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],l=[],u=[],h=new pe,m=new bt;a.push(0,0,0),l.push(0,0,1),u.push(.5,.5);for(let v=0,x=3;v<=t;v++,x+=3){const S=n+v/t*r;h.x=e*Math.cos(S),h.y=e*Math.sin(S),a.push(h.x,h.y,h.z),l.push(0,0,1),m.x=(a[x]/e+1)/2,m.y=(a[x+1]/e+1)/2,u.push(m.x,m.y)}for(let v=1;v<=t;v++)s.push(v,v+1,0);this.setIndex(s),this.setAttribute("position",new Si(a,3)),this.setAttribute("normal",new Si(l,3)),this.setAttribute("uv",new Si(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yy(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class iM extends Hi{constructor(e=1,t=1,n=1,r=32,s=1,a=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:l,thetaLength:u};const h=this;r=Math.floor(r),s=Math.floor(s);const m=[],v=[],x=[],S=[];let T=0;const N=[],C=n/2;let E=0;O(),a===!1&&(e>0&&U(!0),t>0&&U(!1)),this.setIndex(m),this.setAttribute("position",new Si(v,3)),this.setAttribute("normal",new Si(x,3)),this.setAttribute("uv",new Si(S,2));function O(){const I=new pe,j=new pe;let z=0;const G=(t-e)/n;for(let H=0;H<=s;H++){const q=[],V=H/s,Q=V*(t-e)+e;for(let J=0;J<=r;J++){const ie=J/r,le=ie*u+l,re=Math.sin(le),Z=Math.cos(le);j.x=Q*re,j.y=-V*n+C,j.z=Q*Z,v.push(j.x,j.y,j.z),I.set(re,G,Z).normalize(),x.push(I.x,I.y,I.z),S.push(ie,1-V),q.push(T++)}N.push(q)}for(let H=0;H0||q!==0)&&(m.push(V,Q,ie),z+=3),(t>0||q!==s-1)&&(m.push(Q,J,ie),z+=3)}h.addGroup(E,z,0),E+=z}function U(I){const j=T,z=new bt,G=new pe;let H=0;const q=I===!0?e:t,V=I===!0?1:-1;for(let J=1;J<=r;J++)v.push(0,C*V,0),x.push(0,V,0),S.push(.5,.5),T++;const Q=T;for(let J=0;J<=r;J++){const le=J/r*u+l,re=Math.cos(le),Z=Math.sin(le);G.x=q*Z,G.y=C*V,G.z=q*re,v.push(G.x,G.y,G.z),x.push(0,V,0),z.x=re*.5+.5,z.y=Z*.5*V+.5,S.push(z.x,z.y),T++}for(let J=0;J80*t){l=h=i[0],u=m=i[1];for(let T=t;Th&&(h=v),x>m&&(m=x);S=Math.max(h-l,m-u),S=S!==0?32767/S:0}return rg(s,a,t,l,u,S,0),a}};function iD(i,e,t,n,r){let s,a;if(r===Cz(i,e,t,n)>0)for(s=e;s=e;s-=n)a=xN(s,i[s],i[s+1],a);return a&&xy(a,a.next)&&(ag(a),a=a.next),a}function rd(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(xy(t,t.next)||Rr(t.prev,t,t.next)===0)){if(ag(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function rg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&bz(i,n,r,s);let l=i,u,h;for(;i.prev!==i.next;){if(u=i.prev,h=i.next,s?Az(i,n,r,s):dz(i)){e.push(u.i/t|0),e.push(i.i/t|0),e.push(h.i/t|0),ag(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=pz(rd(i),e,t),rg(i,e,t,n,r,s,2)):a===2&&mz(i,e,t,n,r,s):rg(rd(i),e,t,n,r,s,1);break}}}function dz(i){const e=i.prev,t=i,n=i.next;if(Rr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=rs?r>a?r:a:s>a?s:a,S=l>u?l>h?l:h:u>h?u:h;let T=n.next;for(;T!==e;){if(T.x>=m&&T.x<=x&&T.y>=v&&T.y<=S&&FA(r,l,s,u,a,h,T.x,T.y)&&Rr(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function Az(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Rr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=lu?l>h?l:h:u>h?u:h,C=m>v?m>x?m:x:v>x?v:x,E=ZS(S,T,e,t,n),O=ZS(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&FA(l,m,u,v,h,x,U.x,U.y)&&Rr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&FA(l,m,u,v,h,x,I.x,I.y)&&Rr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&FA(l,m,u,v,h,x,U.x,U.y)&&Rr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&FA(l,m,u,v,h,x,I.x,I.y)&&Rr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function pz(i,e,t){let n=i;do{const r=n.prev,s=n.next.next;!xy(r,s)&&rD(r,n,n.next,s)&&sg(r,s)&&sg(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),ag(n),ag(n.next),n=i=s),n=n.next}while(n!==i);return rd(n)}function mz(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&Tz(a,l)){let u=sD(a,l);a=rd(a,a.next),u=rd(u,u.next),rg(a,e,t,n,r,s,0),rg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function gz(i,e,t,n){const r=[];let s,a,l,u,h;for(s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const x=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=s&&x>n&&(n=x,r=t.x=t.x&&t.x>=u&&s!==t.x&&FA(ar.x||t.x===r.x&&xz(r,t)))&&(r=t,m=v)),t=t.next;while(t!==l);return r}function xz(i,e){return Rr(i.prev,i,e.prev)<0&&Rr(e.next,i,i.next)<0}function bz(i,e,t,n){let r=i;do r.z===0&&(r.z=ZS(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,Sz(r)}function Sz(i){let e,t,n,r,s,a,l,u,h=1;do{for(t=i,i=null,s=null,a=0;t;){for(a++,n=t,l=0,e=0;e0||u>0&&n;)l!==0&&(u===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,l--):(r=n,n=n.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,h*=2}while(a>1);return i}function ZS(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function wz(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function Tz(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Mz(i,e)&&(sg(i,e)&&sg(e,i)&&Ez(i,e)&&(Rr(i.prev,i,e.prev)||Rr(i,e.prev,e))||xy(i,e)&&Rr(i.prev,i,i.next)>0&&Rr(e.prev,e,e.next)>0)}function Rr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function xy(i,e){return i.x===e.x&&i.y===e.y}function rD(i,e,t,n){const r=q2(Rr(i,e,t)),s=q2(Rr(i,e,n)),a=q2(Rr(t,n,i)),l=q2(Rr(t,n,e));return!!(r!==s&&a!==l||r===0&&G2(i,t,e)||s===0&&G2(i,n,e)||a===0&&G2(t,i,n)||l===0&&G2(t,e,n))}function G2(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function q2(i){return i>0?1:i<0?-1:0}function Mz(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&rD(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function sg(i,e){return Rr(i.prev,i,i.next)<0?Rr(i,e,i.next)>=0&&Rr(i,i.prev,e)>=0:Rr(i,e,i.prev)<0||Rr(i,i.next,e)<0}function Ez(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function sD(i,e){const t=new JS(i.i,i.x,i.y),n=new JS(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function xN(i,e,t,n){const r=new JS(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ag(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function JS(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Cz(i,e,t,n){let r=0;for(let s=e,a=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function SN(i,e){for(let t=0;tNumber.EPSILON){const Oe=Math.sqrt(k),Ue=Math.sqrt(pt*pt+Ae*Ae),ee=ht.x-Ht/Oe,we=ht.y+yt/Oe,Re=fe.x-Ae/Ue,We=fe.y+pt/Ue,Se=((Re-ee)*Ae-(We-we)*pt)/(yt*Ae-Ht*pt);$t=ee+yt*Se-Ke.x,_t=we+Ht*Se-Ke.y;const Le=$t*$t+_t*_t;if(Le<=2)return new bt($t,_t);Gt=Math.sqrt(Le/2)}else{let Oe=!1;yt>Number.EPSILON?pt>Number.EPSILON&&(Oe=!0):yt<-Number.EPSILON?pt<-Number.EPSILON&&(Oe=!0):Math.sign(Ht)===Math.sign(Ae)&&(Oe=!0),Oe?($t=-Ht,_t=yt,Gt=Math.sqrt(k)):($t=yt,_t=Ht,Gt=Math.sqrt(k/2))}return new bt($t/Gt,_t/Gt)}const be=[];for(let Ke=0,ht=le.length,fe=ht-1,$t=Ke+1;Ke=0;Ke--){const ht=Ke/C,fe=S*Math.cos(ht*Math.PI/2),$t=T*Math.sin(ht*Math.PI/2)+N;for(let _t=0,Gt=le.length;_t=0;){const $t=fe;let _t=fe-1;_t<0&&(_t=Ke.length-1);for(let Gt=0,yt=m+C*2;Gt0)&&S.push(U,I,z),(E!==n-1||u0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class oD extends oa{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new cn(16777215),this.specular=new cn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Uz extends oa{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new cn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Bz extends oa{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Fc extends oa{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new cn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new aa,this.combine=Dg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Oz extends oa{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=QF,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Iz extends oa{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Fz extends oa{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new cn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Mc,this.normalScale=new bt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class kz extends q0{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const TN={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class zz{constructor(e,t,n){const r=this;let s=!1,a=0,l=0,u;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(m){l++,s===!1&&r.onStart!==void 0&&r.onStart(m,a,l),s=!0},this.itemEnd=function(m){a++,r.onProgress!==void 0&&r.onProgress(m,a,l),a===l&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(m){r.onError!==void 0&&r.onError(m)},this.resolveURL=function(m){return u?u(m):m},this.setURLModifier=function(m){return u=m,this},this.addHandler=function(m,v){return h.push(m,v),this},this.removeHandler=function(m){const v=h.indexOf(m);return v!==-1&&h.splice(v,2),this},this.getHandler=function(m){for(let v=0,x=h.length;vNumber.EPSILON){if(V<0&&(G=O[z],q=-q,H=O[j],V=-V),E.yH.y)continue;if(E.y===G.y){if(E.x===G.x)return!0}else{const Q=V*(E.x-G.x)-q*(E.y-G.y);if(Q===0)return!0;if(Q<0)continue;I=!I}}else{if(E.y!==G.y)continue;if(H.x<=E.x&&E.x<=G.x||G.x<=E.x&&E.x<=H.x)return!0}}return I}const r=QA.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,l,u;const h=[];if(s.length===1)return l=s[0],u=new kv,u.curves=l.curves,h.push(u),h;let m=!r(s[0].getPoints());m=e?!m:m;const v=[],x=[];let S=[],T=0,N;x[T]=void 0,S[T]=[];for(let E=0,O=s.length;E1){let E=!1,O=0;for(let U=0,I=x.length;U0&&E===!1&&(S=v)}let C;for(let E=0,O=x.length;E #include #include -}`,ei={alphahash_fragment:rG,alphahash_pars_fragment:sG,alphamap_fragment:aG,alphamap_pars_fragment:oG,alphatest_fragment:lG,alphatest_pars_fragment:uG,aomap_fragment:cG,aomap_pars_fragment:hG,batching_pars_vertex:fG,batching_vertex:dG,begin_vertex:AG,beginnormal_vertex:pG,bsdfs:mG,iridescence_fragment:gG,bumpmap_pars_fragment:vG,clipping_planes_fragment:_G,clipping_planes_pars_fragment:yG,clipping_planes_pars_vertex:xG,clipping_planes_vertex:bG,color_fragment:SG,color_pars_fragment:wG,color_pars_vertex:TG,color_vertex:MG,common:EG,cube_uv_reflection_fragment:CG,defaultnormal_vertex:NG,displacementmap_pars_vertex:RG,displacementmap_vertex:DG,emissivemap_fragment:PG,emissivemap_pars_fragment:LG,colorspace_fragment:UG,colorspace_pars_fragment:BG,envmap_fragment:OG,envmap_common_pars_fragment:IG,envmap_pars_fragment:FG,envmap_pars_vertex:kG,envmap_physical_pars_fragment:QG,envmap_vertex:zG,fog_vertex:GG,fog_pars_vertex:qG,fog_fragment:VG,fog_pars_fragment:jG,gradientmap_pars_fragment:HG,lightmap_pars_fragment:WG,lights_lambert_fragment:$G,lights_lambert_pars_fragment:XG,lights_pars_begin:YG,lights_toon_fragment:KG,lights_toon_pars_fragment:ZG,lights_phong_fragment:JG,lights_phong_pars_fragment:eq,lights_physical_fragment:tq,lights_physical_pars_fragment:nq,lights_fragment_begin:iq,lights_fragment_maps:rq,lights_fragment_end:sq,logdepthbuf_fragment:aq,logdepthbuf_pars_fragment:oq,logdepthbuf_pars_vertex:lq,logdepthbuf_vertex:uq,map_fragment:cq,map_pars_fragment:hq,map_particle_fragment:fq,map_particle_pars_fragment:dq,metalnessmap_fragment:Aq,metalnessmap_pars_fragment:pq,morphinstance_vertex:mq,morphcolor_vertex:gq,morphnormal_vertex:vq,morphtarget_pars_vertex:_q,morphtarget_vertex:yq,normal_fragment_begin:xq,normal_fragment_maps:bq,normal_pars_fragment:Sq,normal_pars_vertex:wq,normal_vertex:Tq,normalmap_pars_fragment:Mq,clearcoat_normal_fragment_begin:Eq,clearcoat_normal_fragment_maps:Cq,clearcoat_pars_fragment:Nq,iridescence_pars_fragment:Rq,opaque_fragment:Dq,packing:Pq,premultiplied_alpha_fragment:Lq,project_vertex:Uq,dithering_fragment:Bq,dithering_pars_fragment:Oq,roughnessmap_fragment:Iq,roughnessmap_pars_fragment:Fq,shadowmap_pars_fragment:kq,shadowmap_pars_vertex:zq,shadowmap_vertex:Gq,shadowmask_pars_fragment:qq,skinbase_vertex:Vq,skinning_pars_vertex:jq,skinning_vertex:Hq,skinnormal_vertex:Wq,specularmap_fragment:$q,specularmap_pars_fragment:Xq,tonemapping_fragment:Yq,tonemapping_pars_fragment:Qq,transmission_fragment:Kq,transmission_pars_fragment:Zq,uv_pars_fragment:Jq,uv_pars_vertex:eV,uv_vertex:tV,worldpos_vertex:nV,background_vert:iV,background_frag:rV,backgroundCube_vert:sV,backgroundCube_frag:aV,cube_vert:oV,cube_frag:lV,depth_vert:uV,depth_frag:cV,distanceRGBA_vert:hV,distanceRGBA_frag:fV,equirect_vert:dV,equirect_frag:AV,linedashed_vert:pV,linedashed_frag:mV,meshbasic_vert:gV,meshbasic_frag:vV,meshlambert_vert:_V,meshlambert_frag:yV,meshmatcap_vert:xV,meshmatcap_frag:bV,meshnormal_vert:SV,meshnormal_frag:wV,meshphong_vert:TV,meshphong_frag:MV,meshphysical_vert:EV,meshphysical_frag:CV,meshtoon_vert:NV,meshtoon_frag:RV,points_vert:DV,points_frag:PV,shadow_vert:LV,shadow_frag:UV,sprite_vert:BV,sprite_frag:OV},nn={common:{diffuse:{value:new cn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xn},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xn}},envmap:{envMap:{value:null},envMapRotation:{value:new Xn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xn},normalScale:{value:new bt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new cn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new cn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0},uvTransform:{value:new Xn}},sprite:{diffuse:{value:new cn(16777215)},opacity:{value:1},center:{value:new bt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xn},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0}}},Fa={basic:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.fog]),vertexShader:ei.meshbasic_vert,fragmentShader:ei.meshbasic_frag},lambert:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,nn.lights,{emissive:{value:new cn(0)}}]),vertexShader:ei.meshlambert_vert,fragmentShader:ei.meshlambert_frag},phong:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,nn.lights,{emissive:{value:new cn(0)},specular:{value:new cn(1118481)},shininess:{value:30}}]),vertexShader:ei.meshphong_vert,fragmentShader:ei.meshphong_frag},standard:{uniforms:ga([nn.common,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.roughnessmap,nn.metalnessmap,nn.fog,nn.lights,{emissive:{value:new cn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ei.meshphysical_vert,fragmentShader:ei.meshphysical_frag},toon:{uniforms:ga([nn.common,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.gradientmap,nn.fog,nn.lights,{emissive:{value:new cn(0)}}]),vertexShader:ei.meshtoon_vert,fragmentShader:ei.meshtoon_frag},matcap:{uniforms:ga([nn.common,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,{matcap:{value:null}}]),vertexShader:ei.meshmatcap_vert,fragmentShader:ei.meshmatcap_frag},points:{uniforms:ga([nn.points,nn.fog]),vertexShader:ei.points_vert,fragmentShader:ei.points_frag},dashed:{uniforms:ga([nn.common,nn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ei.linedashed_vert,fragmentShader:ei.linedashed_frag},depth:{uniforms:ga([nn.common,nn.displacementmap]),vertexShader:ei.depth_vert,fragmentShader:ei.depth_frag},normal:{uniforms:ga([nn.common,nn.bumpmap,nn.normalmap,nn.displacementmap,{opacity:{value:1}}]),vertexShader:ei.meshnormal_vert,fragmentShader:ei.meshnormal_frag},sprite:{uniforms:ga([nn.sprite,nn.fog]),vertexShader:ei.sprite_vert,fragmentShader:ei.sprite_frag},background:{uniforms:{uvTransform:{value:new Xn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ei.background_vert,fragmentShader:ei.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xn}},vertexShader:ei.backgroundCube_vert,fragmentShader:ei.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ei.cube_vert,fragmentShader:ei.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ei.equirect_vert,fragmentShader:ei.equirect_frag},distanceRGBA:{uniforms:ga([nn.common,nn.displacementmap,{referencePosition:{value:new me},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ei.distanceRGBA_vert,fragmentShader:ei.distanceRGBA_frag},shadow:{uniforms:ga([nn.lights,nn.fog,{color:{value:new cn(0)},opacity:{value:1}}]),vertexShader:ei.shadow_vert,fragmentShader:ei.shadow_frag}};Fa.physical={uniforms:ga([Fa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xn},clearcoatNormalScale:{value:new bt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xn},sheen:{value:0},sheenColor:{value:new cn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xn},transmissionSamplerSize:{value:new bt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xn},attenuationDistance:{value:0},attenuationColor:{value:new cn(0)},specularColor:{value:new cn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xn},anisotropyVector:{value:new bt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xn}}]),vertexShader:ei.meshphysical_vert,fragmentShader:ei.meshphysical_frag};const j2={r:0,b:0,g:0},_f=new aa,IV=new jn;function FV(i,e,t,n,r,s,a){const l=new cn(0);let u=s===!0?0:1,h,m,v=null,x=0,S=null;function T(U){let I=U.isScene===!0?U.background:null;return I&&I.isTexture&&(I=(U.backgroundBlurriness>0?t:e).get(I)),I}function N(U){let I=!1;const j=T(U);j===null?E(l,u):j&&j.isColor&&(E(j,1),I=!0);const z=i.xr.getEnvironmentBlendMode();z==="additive"?n.buffers.color.setClear(0,0,0,1,a):z==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function C(U,I){const j=T(I);j&&(j.isCubeTexture||j.mapping===ed)?(m===void 0&&(m=new Oi(new Vh(1,1,1),new Qa({name:"BackgroundCubeMaterial",uniforms:b0(Fa.backgroundCube.uniforms),vertexShader:Fa.backgroundCube.vertexShader,fragmentShader:Fa.backgroundCube.fragmentShader,side:or,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(z,G,H){this.matrixWorld.copyPosition(H.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(m)),_f.copy(I.backgroundRotation),_f.x*=-1,_f.y*=-1,_f.z*=-1,j.isCubeTexture&&j.isRenderTargetTexture===!1&&(_f.y*=-1,_f.z*=-1),m.material.uniforms.envMap.value=j,m.material.uniforms.flipEnvMap.value=j.isCubeTexture&&j.isRenderTargetTexture===!1?-1:1,m.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,m.material.uniforms.backgroundRotation.value.setFromMatrix4(IV.makeRotationFromEuler(_f)),m.material.toneMapped=li.getTransfer(j.colorSpace)!==Fi,(v!==j||x!==j.version||S!==i.toneMapping)&&(m.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),m.layers.enableAll(),U.unshift(m,m.geometry,m.material,0,0,null)):j&&j.isTexture&&(h===void 0&&(h=new Oi(new by(2,2),new Qa({name:"BackgroundMaterial",uniforms:b0(Fa.background.uniforms),vertexShader:Fa.background.vertexShader,fragmentShader:Fa.background.fragmentShader,side:El,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=j,h.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,h.material.toneMapped=li.getTransfer(j.colorSpace)!==Fi,j.matrixAutoUpdate===!0&&j.updateMatrix(),h.material.uniforms.uvTransform.value.copy(j.matrix),(v!==j||x!==j.version||S!==i.toneMapping)&&(h.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),h.layers.enableAll(),U.unshift(h,h.geometry,h.material,0,0,null))}function E(U,I){U.getRGB(j2,W7(i)),n.buffers.color.setClear(j2.r,j2.g,j2.b,I,a)}function O(){m!==void 0&&(m.geometry.dispose(),m.material.dispose()),h!==void 0&&(h.geometry.dispose(),h.material.dispose())}return{getClearColor:function(){return l},setClearColor:function(U,I=1){l.set(U),u=I,E(l,u)},getClearAlpha:function(){return u},setClearAlpha:function(U){u=U,E(l,u)},render:N,addToRenderList:C,dispose:O}}function kV(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=x(null);let s=r,a=!1;function l(V,Q,J,ne,oe){let ie=!1;const Z=v(ne,J,Q);s!==Z&&(s=Z,h(s.object)),ie=S(V,ne,J,oe),ie&&T(V,ne,J,oe),oe!==null&&e.update(oe,i.ELEMENT_ARRAY_BUFFER),(ie||a)&&(a=!1,I(V,Q,J,ne),oe!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(oe).buffer))}function u(){return i.createVertexArray()}function h(V){return i.bindVertexArray(V)}function m(V){return i.deleteVertexArray(V)}function v(V,Q,J){const ne=J.wireframe===!0;let oe=n[V.id];oe===void 0&&(oe={},n[V.id]=oe);let ie=oe[Q.id];ie===void 0&&(ie={},oe[Q.id]=ie);let Z=ie[ne];return Z===void 0&&(Z=x(u()),ie[ne]=Z),Z}function x(V){const Q=[],J=[],ne=[];for(let oe=0;oe=0){const Te=oe[de];let ae=ie[de];if(ae===void 0&&(de==="instanceMatrix"&&V.instanceMatrix&&(ae=V.instanceMatrix),de==="instanceColor"&&V.instanceColor&&(ae=V.instanceColor)),Te===void 0||Te.attribute!==ae||ae&&Te.data!==ae.data)return!0;Z++}return s.attributesNum!==Z||s.index!==ne}function T(V,Q,J,ne){const oe={},ie=Q.attributes;let Z=0;const te=J.getAttributes();for(const de in te)if(te[de].location>=0){let Te=ie[de];Te===void 0&&(de==="instanceMatrix"&&V.instanceMatrix&&(Te=V.instanceMatrix),de==="instanceColor"&&V.instanceColor&&(Te=V.instanceColor));const ae={};ae.attribute=Te,Te&&Te.data&&(ae.data=Te.data),oe[de]=ae,Z++}s.attributes=oe,s.attributesNum=Z,s.index=ne}function N(){const V=s.newAttributes;for(let Q=0,J=V.length;Q=0){let Se=oe[te];if(Se===void 0&&(te==="instanceMatrix"&&V.instanceMatrix&&(Se=V.instanceMatrix),te==="instanceColor"&&V.instanceColor&&(Se=V.instanceColor)),Se!==void 0){const Te=Se.normalized,ae=Se.itemSize,Me=e.get(Se);if(Me===void 0)continue;const Ve=Me.buffer,Ce=Me.type,Fe=Me.bytesPerElement,et=Ce===i.INT||Ce===i.UNSIGNED_INT||Se.gpuType===Ns;if(Se.isInterleavedBufferAttribute){const He=Se.data,Rt=He.stride,Et=Se.offset;if(He.isInstancedInterleavedBuffer){for(let zt=0;zt0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";G="mediump"}return G==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const m=u(h);m!==h&&(console.warn("THREE.WebGLRenderer:",h,"not supported, using",m,"instead."),h=m);const v=t.logarithmicDepthBuffer===!0,x=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),S=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),T=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),N=i.getParameter(i.MAX_TEXTURE_SIZE),C=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),E=i.getParameter(i.MAX_VERTEX_ATTRIBS),O=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),U=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),j=T>0,z=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:l,precision:h,logarithmicDepthBuffer:v,reverseDepthBuffer:x,maxTextures:S,maxVertexTextures:T,maxTextureSize:N,maxCubemapSize:C,maxAttributes:E,maxVertexUniforms:O,maxVaryings:U,maxFragmentUniforms:I,vertexTextures:j,maxSamples:z}}function qV(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new jl,l=new Xn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(v,x){const S=v.length!==0||x||n!==0||r;return r=x,n=v.length,S},this.beginShadows=function(){s=!0,m(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(v,x){t=m(v,x,0)},this.setState=function(v,x,S){const T=v.clippingPlanes,N=v.clipIntersection,C=v.clipShadows,E=i.get(v);if(!r||T===null||T.length===0||s&&!C)s?m(null):h();else{const O=s?0:n,U=O*4;let I=E.clippingState||null;u.value=I,I=m(T,x,U,S);for(let j=0;j!==U;++j)I[j]=t[j];E.clippingState=I,this.numIntersection=N?this.numPlanes:0,this.numPlanes+=O}};function h(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function m(v,x,S,T){const N=v!==null?v.length:0;let C=null;if(N!==0){if(C=u.value,T!==!0||C===null){const E=S+N*4,O=x.matrixWorldInverse;l.getNormalMatrix(O),(C===null||C.length0){const h=new X7(u.height);return h.fromEquirectangularTexture(i,a),e.set(a,h),a.addEventListener("dispose",r),t(h.texture,a.mapping)}else return null}}return a}function r(a){const l=a.target;l.removeEventListener("dispose",r);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const kA=4,BN=[.125,.215,.35,.446,.526,.582],Bf=20,M3=new Ig,ON=new cn;let E3=null,C3=0,N3=0,R3=!1;const Rf=(1+Math.sqrt(5))/2,dA=1/Rf,IN=[new me(-Rf,dA,0),new me(Rf,dA,0),new me(-dA,0,Rf),new me(dA,0,Rf),new me(0,Rf,-dA),new me(0,Rf,dA),new me(-1,1,-1),new me(1,1,-1),new me(-1,1,1),new me(1,1,1)];let FN=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){E3=this._renderer.getRenderTarget(),C3=this._renderer.getActiveCubeFace(),N3=this._renderer.getActiveMipmapLevel(),R3=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=GN(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zN(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?U:0,U,U),m.setRenderTarget(r),N&&m.render(T,l),m.render(e,l)}T.geometry.dispose(),T.material.dispose(),m.toneMapping=x,m.autoClear=v,e.background=C}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Xo||e.mapping===Yo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=GN()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zN());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new Oi(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const u=this._cubeSize;H2(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,M3)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sBf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Bf}`);const E=[];let O=0;for(let G=0;GU-kA?r-U+kA:0),z=4*(this._cubeSize-I);H2(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,M3)}};function jV(i){const e=[],t=[],n=[];let r=i;const s=i-kA+1+BN.length;for(let a=0;ai-kA?u=BN[a-i+kA-1]:a===0&&(u=0),n.push(u);const h=1/(l-2),m=-h,v=1+h,x=[m,m,v,m,v,v,m,m,v,v,m,v],S=6,T=6,N=3,C=2,E=1,O=new Float32Array(N*T*S),U=new Float32Array(C*T*S),I=new Float32Array(E*T*S);for(let z=0;z2?0:-1,q=[G,H,0,G+2/3,H,0,G+2/3,H+1,0,G,H,0,G+2/3,H+1,0,G,H+1,0];O.set(q,N*T*z),U.set(x,C*T*z);const V=[z,z,z,z,z,z];I.set(V,E*T*z)}const j=new Hi;j.setAttribute("position",new wr(O,N)),j.setAttribute("uv",new wr(U,C)),j.setAttribute("faceIndex",new wr(I,E)),e.push(j),r>kA&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function kN(i,e,t){const n=new Fh(i,e,t);return n.texture.mapping=ed,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function H2(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function HV(i,e,t){const n=new Float32Array(Bf),r=new me(0,1,0);return new Qa({name:"SphericalGaussianBlur",defines:{n:Bf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:cM(),fragmentShader:` +}`,ei={alphahash_fragment:rG,alphahash_pars_fragment:sG,alphamap_fragment:aG,alphamap_pars_fragment:oG,alphatest_fragment:lG,alphatest_pars_fragment:uG,aomap_fragment:cG,aomap_pars_fragment:hG,batching_pars_vertex:fG,batching_vertex:dG,begin_vertex:AG,beginnormal_vertex:pG,bsdfs:mG,iridescence_fragment:gG,bumpmap_pars_fragment:vG,clipping_planes_fragment:_G,clipping_planes_pars_fragment:yG,clipping_planes_pars_vertex:xG,clipping_planes_vertex:bG,color_fragment:SG,color_pars_fragment:wG,color_pars_vertex:TG,color_vertex:MG,common:EG,cube_uv_reflection_fragment:CG,defaultnormal_vertex:NG,displacementmap_pars_vertex:RG,displacementmap_vertex:DG,emissivemap_fragment:PG,emissivemap_pars_fragment:LG,colorspace_fragment:UG,colorspace_pars_fragment:BG,envmap_fragment:OG,envmap_common_pars_fragment:IG,envmap_pars_fragment:FG,envmap_pars_vertex:kG,envmap_physical_pars_fragment:QG,envmap_vertex:zG,fog_vertex:GG,fog_pars_vertex:qG,fog_fragment:VG,fog_pars_fragment:jG,gradientmap_pars_fragment:HG,lightmap_pars_fragment:WG,lights_lambert_fragment:$G,lights_lambert_pars_fragment:XG,lights_pars_begin:YG,lights_toon_fragment:KG,lights_toon_pars_fragment:ZG,lights_phong_fragment:JG,lights_phong_pars_fragment:eq,lights_physical_fragment:tq,lights_physical_pars_fragment:nq,lights_fragment_begin:iq,lights_fragment_maps:rq,lights_fragment_end:sq,logdepthbuf_fragment:aq,logdepthbuf_pars_fragment:oq,logdepthbuf_pars_vertex:lq,logdepthbuf_vertex:uq,map_fragment:cq,map_pars_fragment:hq,map_particle_fragment:fq,map_particle_pars_fragment:dq,metalnessmap_fragment:Aq,metalnessmap_pars_fragment:pq,morphinstance_vertex:mq,morphcolor_vertex:gq,morphnormal_vertex:vq,morphtarget_pars_vertex:_q,morphtarget_vertex:yq,normal_fragment_begin:xq,normal_fragment_maps:bq,normal_pars_fragment:Sq,normal_pars_vertex:wq,normal_vertex:Tq,normalmap_pars_fragment:Mq,clearcoat_normal_fragment_begin:Eq,clearcoat_normal_fragment_maps:Cq,clearcoat_pars_fragment:Nq,iridescence_pars_fragment:Rq,opaque_fragment:Dq,packing:Pq,premultiplied_alpha_fragment:Lq,project_vertex:Uq,dithering_fragment:Bq,dithering_pars_fragment:Oq,roughnessmap_fragment:Iq,roughnessmap_pars_fragment:Fq,shadowmap_pars_fragment:kq,shadowmap_pars_vertex:zq,shadowmap_vertex:Gq,shadowmask_pars_fragment:qq,skinbase_vertex:Vq,skinning_pars_vertex:jq,skinning_vertex:Hq,skinnormal_vertex:Wq,specularmap_fragment:$q,specularmap_pars_fragment:Xq,tonemapping_fragment:Yq,tonemapping_pars_fragment:Qq,transmission_fragment:Kq,transmission_pars_fragment:Zq,uv_pars_fragment:Jq,uv_pars_vertex:eV,uv_vertex:tV,worldpos_vertex:nV,background_vert:iV,background_frag:rV,backgroundCube_vert:sV,backgroundCube_frag:aV,cube_vert:oV,cube_frag:lV,depth_vert:uV,depth_frag:cV,distanceRGBA_vert:hV,distanceRGBA_frag:fV,equirect_vert:dV,equirect_frag:AV,linedashed_vert:pV,linedashed_frag:mV,meshbasic_vert:gV,meshbasic_frag:vV,meshlambert_vert:_V,meshlambert_frag:yV,meshmatcap_vert:xV,meshmatcap_frag:bV,meshnormal_vert:SV,meshnormal_frag:wV,meshphong_vert:TV,meshphong_frag:MV,meshphysical_vert:EV,meshphysical_frag:CV,meshtoon_vert:NV,meshtoon_frag:RV,points_vert:DV,points_frag:PV,shadow_vert:LV,shadow_frag:UV,sprite_vert:BV,sprite_frag:OV},nn={common:{diffuse:{value:new cn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xn},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xn}},envmap:{envMap:{value:null},envMapRotation:{value:new Xn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xn},normalScale:{value:new bt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new cn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new cn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0},uvTransform:{value:new Xn}},sprite:{diffuse:{value:new cn(16777215)},opacity:{value:1},center:{value:new bt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xn},alphaMap:{value:null},alphaMapTransform:{value:new Xn},alphaTest:{value:0}}},Fa={basic:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.fog]),vertexShader:ei.meshbasic_vert,fragmentShader:ei.meshbasic_frag},lambert:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,nn.lights,{emissive:{value:new cn(0)}}]),vertexShader:ei.meshlambert_vert,fragmentShader:ei.meshlambert_frag},phong:{uniforms:ga([nn.common,nn.specularmap,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,nn.lights,{emissive:{value:new cn(0)},specular:{value:new cn(1118481)},shininess:{value:30}}]),vertexShader:ei.meshphong_vert,fragmentShader:ei.meshphong_frag},standard:{uniforms:ga([nn.common,nn.envmap,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.roughnessmap,nn.metalnessmap,nn.fog,nn.lights,{emissive:{value:new cn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ei.meshphysical_vert,fragmentShader:ei.meshphysical_frag},toon:{uniforms:ga([nn.common,nn.aomap,nn.lightmap,nn.emissivemap,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.gradientmap,nn.fog,nn.lights,{emissive:{value:new cn(0)}}]),vertexShader:ei.meshtoon_vert,fragmentShader:ei.meshtoon_frag},matcap:{uniforms:ga([nn.common,nn.bumpmap,nn.normalmap,nn.displacementmap,nn.fog,{matcap:{value:null}}]),vertexShader:ei.meshmatcap_vert,fragmentShader:ei.meshmatcap_frag},points:{uniforms:ga([nn.points,nn.fog]),vertexShader:ei.points_vert,fragmentShader:ei.points_frag},dashed:{uniforms:ga([nn.common,nn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ei.linedashed_vert,fragmentShader:ei.linedashed_frag},depth:{uniforms:ga([nn.common,nn.displacementmap]),vertexShader:ei.depth_vert,fragmentShader:ei.depth_frag},normal:{uniforms:ga([nn.common,nn.bumpmap,nn.normalmap,nn.displacementmap,{opacity:{value:1}}]),vertexShader:ei.meshnormal_vert,fragmentShader:ei.meshnormal_frag},sprite:{uniforms:ga([nn.sprite,nn.fog]),vertexShader:ei.sprite_vert,fragmentShader:ei.sprite_frag},background:{uniforms:{uvTransform:{value:new Xn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ei.background_vert,fragmentShader:ei.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xn}},vertexShader:ei.backgroundCube_vert,fragmentShader:ei.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ei.cube_vert,fragmentShader:ei.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ei.equirect_vert,fragmentShader:ei.equirect_frag},distanceRGBA:{uniforms:ga([nn.common,nn.displacementmap,{referencePosition:{value:new pe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ei.distanceRGBA_vert,fragmentShader:ei.distanceRGBA_frag},shadow:{uniforms:ga([nn.lights,nn.fog,{color:{value:new cn(0)},opacity:{value:1}}]),vertexShader:ei.shadow_vert,fragmentShader:ei.shadow_frag}};Fa.physical={uniforms:ga([Fa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xn},clearcoatNormalScale:{value:new bt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xn},sheen:{value:0},sheenColor:{value:new cn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xn},transmissionSamplerSize:{value:new bt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xn},attenuationDistance:{value:0},attenuationColor:{value:new cn(0)},specularColor:{value:new cn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xn},anisotropyVector:{value:new bt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xn}}]),vertexShader:ei.meshphysical_vert,fragmentShader:ei.meshphysical_frag};const j2={r:0,b:0,g:0},_f=new aa,IV=new jn;function FV(i,e,t,n,r,s,a){const l=new cn(0);let u=s===!0?0:1,h,m,v=null,x=0,S=null;function T(U){let I=U.isScene===!0?U.background:null;return I&&I.isTexture&&(I=(U.backgroundBlurriness>0?t:e).get(I)),I}function N(U){let I=!1;const j=T(U);j===null?E(l,u):j&&j.isColor&&(E(j,1),I=!0);const z=i.xr.getEnvironmentBlendMode();z==="additive"?n.buffers.color.setClear(0,0,0,1,a):z==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function C(U,I){const j=T(I);j&&(j.isCubeTexture||j.mapping===ed)?(m===void 0&&(m=new Oi(new Vh(1,1,1),new Qa({name:"BackgroundCubeMaterial",uniforms:b0(Fa.backgroundCube.uniforms),vertexShader:Fa.backgroundCube.vertexShader,fragmentShader:Fa.backgroundCube.fragmentShader,side:or,depthTest:!1,depthWrite:!1,fog:!1})),m.geometry.deleteAttribute("normal"),m.geometry.deleteAttribute("uv"),m.onBeforeRender=function(z,G,H){this.matrixWorld.copyPosition(H.matrixWorld)},Object.defineProperty(m.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(m)),_f.copy(I.backgroundRotation),_f.x*=-1,_f.y*=-1,_f.z*=-1,j.isCubeTexture&&j.isRenderTargetTexture===!1&&(_f.y*=-1,_f.z*=-1),m.material.uniforms.envMap.value=j,m.material.uniforms.flipEnvMap.value=j.isCubeTexture&&j.isRenderTargetTexture===!1?-1:1,m.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,m.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,m.material.uniforms.backgroundRotation.value.setFromMatrix4(IV.makeRotationFromEuler(_f)),m.material.toneMapped=li.getTransfer(j.colorSpace)!==Fi,(v!==j||x!==j.version||S!==i.toneMapping)&&(m.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),m.layers.enableAll(),U.unshift(m,m.geometry,m.material,0,0,null)):j&&j.isTexture&&(h===void 0&&(h=new Oi(new by(2,2),new Qa({name:"BackgroundMaterial",uniforms:b0(Fa.background.uniforms),vertexShader:Fa.background.vertexShader,fragmentShader:Fa.background.fragmentShader,side:El,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=j,h.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,h.material.toneMapped=li.getTransfer(j.colorSpace)!==Fi,j.matrixAutoUpdate===!0&&j.updateMatrix(),h.material.uniforms.uvTransform.value.copy(j.matrix),(v!==j||x!==j.version||S!==i.toneMapping)&&(h.material.needsUpdate=!0,v=j,x=j.version,S=i.toneMapping),h.layers.enableAll(),U.unshift(h,h.geometry,h.material,0,0,null))}function E(U,I){U.getRGB(j2,W7(i)),n.buffers.color.setClear(j2.r,j2.g,j2.b,I,a)}function O(){m!==void 0&&(m.geometry.dispose(),m.material.dispose()),h!==void 0&&(h.geometry.dispose(),h.material.dispose())}return{getClearColor:function(){return l},setClearColor:function(U,I=1){l.set(U),u=I,E(l,u)},getClearAlpha:function(){return u},setClearAlpha:function(U){u=U,E(l,u)},render:N,addToRenderList:C,dispose:O}}function kV(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=x(null);let s=r,a=!1;function l(V,Q,J,ie,le){let re=!1;const Z=v(ie,J,Q);s!==Z&&(s=Z,h(s.object)),re=S(V,ie,J,le),re&&T(V,ie,J,le),le!==null&&e.update(le,i.ELEMENT_ARRAY_BUFFER),(re||a)&&(a=!1,I(V,Q,J,ie),le!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(le).buffer))}function u(){return i.createVertexArray()}function h(V){return i.bindVertexArray(V)}function m(V){return i.deleteVertexArray(V)}function v(V,Q,J){const ie=J.wireframe===!0;let le=n[V.id];le===void 0&&(le={},n[V.id]=le);let re=le[Q.id];re===void 0&&(re={},le[Q.id]=re);let Z=re[ie];return Z===void 0&&(Z=x(u()),re[ie]=Z),Z}function x(V){const Q=[],J=[],ie=[];for(let le=0;le=0){const Te=le[de];let ae=re[de];if(ae===void 0&&(de==="instanceMatrix"&&V.instanceMatrix&&(ae=V.instanceMatrix),de==="instanceColor"&&V.instanceColor&&(ae=V.instanceColor)),Te===void 0||Te.attribute!==ae||ae&&Te.data!==ae.data)return!0;Z++}return s.attributesNum!==Z||s.index!==ie}function T(V,Q,J,ie){const le={},re=Q.attributes;let Z=0;const ne=J.getAttributes();for(const de in ne)if(ne[de].location>=0){let Te=re[de];Te===void 0&&(de==="instanceMatrix"&&V.instanceMatrix&&(Te=V.instanceMatrix),de==="instanceColor"&&V.instanceColor&&(Te=V.instanceColor));const ae={};ae.attribute=Te,Te&&Te.data&&(ae.data=Te.data),le[de]=ae,Z++}s.attributes=le,s.attributesNum=Z,s.index=ie}function N(){const V=s.newAttributes;for(let Q=0,J=V.length;Q=0){let be=le[ne];if(be===void 0&&(ne==="instanceMatrix"&&V.instanceMatrix&&(be=V.instanceMatrix),ne==="instanceColor"&&V.instanceColor&&(be=V.instanceColor)),be!==void 0){const Te=be.normalized,ae=be.itemSize,Me=e.get(be);if(Me===void 0)continue;const Ve=Me.buffer,Ce=Me.type,Fe=Me.bytesPerElement,tt=Ce===i.INT||Ce===i.UNSIGNED_INT||be.gpuType===Ns;if(be.isInterleavedBufferAttribute){const je=be.data,Rt=je.stride,Et=be.offset;if(je.isInstancedInterleavedBuffer){for(let Ft=0;Ft0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";G="mediump"}return G==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let h=t.precision!==void 0?t.precision:"highp";const m=u(h);m!==h&&(console.warn("THREE.WebGLRenderer:",h,"not supported, using",m,"instead."),h=m);const v=t.logarithmicDepthBuffer===!0,x=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),S=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),T=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),N=i.getParameter(i.MAX_TEXTURE_SIZE),C=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),E=i.getParameter(i.MAX_VERTEX_ATTRIBS),O=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),U=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),j=T>0,z=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:l,precision:h,logarithmicDepthBuffer:v,reverseDepthBuffer:x,maxTextures:S,maxVertexTextures:T,maxTextureSize:N,maxCubemapSize:C,maxAttributes:E,maxVertexUniforms:O,maxVaryings:U,maxFragmentUniforms:I,vertexTextures:j,maxSamples:z}}function qV(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new jl,l=new Xn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(v,x){const S=v.length!==0||x||n!==0||r;return r=x,n=v.length,S},this.beginShadows=function(){s=!0,m(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(v,x){t=m(v,x,0)},this.setState=function(v,x,S){const T=v.clippingPlanes,N=v.clipIntersection,C=v.clipShadows,E=i.get(v);if(!r||T===null||T.length===0||s&&!C)s?m(null):h();else{const O=s?0:n,U=O*4;let I=E.clippingState||null;u.value=I,I=m(T,x,U,S);for(let j=0;j!==U;++j)I[j]=t[j];E.clippingState=I,this.numIntersection=N?this.numPlanes:0,this.numPlanes+=O}};function h(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function m(v,x,S,T){const N=v!==null?v.length:0;let C=null;if(N!==0){if(C=u.value,T!==!0||C===null){const E=S+N*4,O=x.matrixWorldInverse;l.getNormalMatrix(O),(C===null||C.length0){const h=new X7(u.height);return h.fromEquirectangularTexture(i,a),e.set(a,h),a.addEventListener("dispose",r),t(h.texture,a.mapping)}else return null}}return a}function r(a){const l=a.target;l.removeEventListener("dispose",r);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const kA=4,BN=[.125,.215,.35,.446,.526,.582],Bf=20,M3=new Ig,ON=new cn;let E3=null,C3=0,N3=0,R3=!1;const Rf=(1+Math.sqrt(5))/2,dA=1/Rf,IN=[new pe(-Rf,dA,0),new pe(Rf,dA,0),new pe(-dA,0,Rf),new pe(dA,0,Rf),new pe(0,Rf,-dA),new pe(0,Rf,dA),new pe(-1,1,-1),new pe(1,1,-1),new pe(-1,1,1),new pe(1,1,1)];let FN=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){E3=this._renderer.getRenderTarget(),C3=this._renderer.getActiveCubeFace(),N3=this._renderer.getActiveMipmapLevel(),R3=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=GN(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zN(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?U:0,U,U),m.setRenderTarget(r),N&&m.render(T,l),m.render(e,l)}T.geometry.dispose(),T.material.dispose(),m.toneMapping=x,m.autoClear=v,e.background=C}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Xo||e.mapping===Yo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=GN()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=zN());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new Oi(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const u=this._cubeSize;H2(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,M3)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sBf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Bf}`);const E=[];let O=0;for(let G=0;GU-kA?r-U+kA:0),z=4*(this._cubeSize-I);H2(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,M3)}};function jV(i){const e=[],t=[],n=[];let r=i;const s=i-kA+1+BN.length;for(let a=0;ai-kA?u=BN[a-i+kA-1]:a===0&&(u=0),n.push(u);const h=1/(l-2),m=-h,v=1+h,x=[m,m,v,m,v,v,m,m,v,v,m,v],S=6,T=6,N=3,C=2,E=1,O=new Float32Array(N*T*S),U=new Float32Array(C*T*S),I=new Float32Array(E*T*S);for(let z=0;z2?0:-1,q=[G,H,0,G+2/3,H,0,G+2/3,H+1,0,G,H,0,G+2/3,H+1,0,G,H+1,0];O.set(q,N*T*z),U.set(x,C*T*z);const V=[z,z,z,z,z,z];I.set(V,E*T*z)}const j=new Hi;j.setAttribute("position",new wr(O,N)),j.setAttribute("uv",new wr(U,C)),j.setAttribute("faceIndex",new wr(I,E)),e.push(j),r>kA&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function kN(i,e,t){const n=new Fh(i,e,t);return n.texture.mapping=ed,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function H2(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function HV(i,e,t){const n=new Float32Array(Bf),r=new pe(0,1,0);return new Qa({name:"SphericalGaussianBlur",defines:{n:Bf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:cM(),fragmentShader:` precision mediump float; precision mediump int; @@ -3769,14 +3769,14 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function WV(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const u=l.mapping,h=u===Oh||u===Ih,m=u===Xo||u===Yo;if(h||m){let v=e.get(l);const x=v!==void 0?v.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==x)return t===null&&(t=new FN(i)),v=h?t.fromEquirectangular(l,v):t.fromCubemap(l,v),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),v.texture;if(v!==void 0)return v.texture;{const S=l.image;return h&&S&&S.height>0||m&&S&&r(S)?(t===null&&(t=new FN(i)),v=h?t.fromEquirectangular(l):t.fromCubemap(l),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),l.addEventListener("dispose",s),v.texture):null}}}return l}function r(l){let u=0;const h=6;for(let m=0;me.maxTextureSize&&(z=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const G=new Float32Array(j*z*4*v),H=new XT(G,j,z,v);H.type=$r,H.needsUpdate=!0;const q=I*4;for(let Q=0;Q0)return i;const r=e*t;let s=VN[r];if(s===void 0&&(s=new Float32Array(r),VN[r]=s),e!==0){n.toArray(s,0);for(let a=1,l=0;a!==e;++a)l+=t,i[a].toArray(s,l)}return s}function gs(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0||m&&S&&r(S)?(t===null&&(t=new FN(i)),v=h?t.fromEquirectangular(l):t.fromCubemap(l),v.texture.pmremVersion=l.pmremVersion,e.set(l,v),l.addEventListener("dispose",s),v.texture):null}}}return l}function r(l){let u=0;const h=6;for(let m=0;me.maxTextureSize&&(z=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const G=new Float32Array(j*z*4*v),H=new XT(G,j,z,v);H.type=$r,H.needsUpdate=!0;const q=I*4;for(let Q=0;Q0)return i;const r=e*t;let s=VN[r];if(s===void 0&&(s=new Float32Array(r),VN[r]=s),e!==0){n.toArray(s,0);for(let a=1,l=0;a!==e;++a)l+=t,i[a].toArray(s,l)}return s}function gs(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t":" "} ${l}: ${t[a]}`)}return n.join(` `)}const QN=new Xn;function Wj(i){li._getMatrix(QN,li.workingColorSpace,i);const e=`mat3( ${QN.elements.map(t=>t.toFixed(4))} )`;switch(li.getTransfer(i)){case r_:return[e,"LinearTransferOETF"];case Fi:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function KN(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+` `+r+` `+Hj(i.getShaderSource(e),a)}else return r}function $j(i,e){const t=Wj(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` -`)}function Xj(i,e){let t;switch(e){case U7:t="Linear";break;case B7:t="Reinhard";break;case O7:t="Cineon";break;case I7:t="ACESFilmic";break;case F7:t="AgX";break;case k7:t="Neutral";break;case HF:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const W2=new me;function Yj(){li.getLuminanceCoefficients(W2);const i=W2.x.toFixed(4),e=W2.y.toFixed(4),t=W2.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Xj(i,e){let t;switch(e){case U7:t="Linear";break;case B7:t="Reinhard";break;case O7:t="Cineon";break;case I7:t="ACESFilmic";break;case F7:t="AgX";break;case k7:t="Neutral";break;case HF:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const W2=new pe;function Yj(){li.getLuminanceCoefficients(W2);const i=W2.x.toFixed(4),e=W2.y.toFixed(4),t=W2.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function Qj(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(gm).join(` `)}function Kj(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` `)}function Zj(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function tw(i){return i.replace(Jj,tH)}const eH=new Map;function tH(i,e){let t=ei[e];if(t===void 0){const n=eH.get(e);if(n!==void 0)t=ei[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return tw(t)}const nH=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function e5(i){return i.replace(nH,iH)}function iH(i,e,t,n){let r="";for(let s=parseInt(e);s0,be=q.clearcoat>0,Oe=q.dispersion>0,pe=q.iridescence>0,le=q.sheen>0,Ne=q.transmission>0,De=k&&!!q.anisotropyMap,Je=be&&!!q.clearcoatMap,we=be&&!!q.clearcoatNormalMap,Ue=be&&!!q.clearcoatRoughnessMap,ut=pe&&!!q.iridescenceMap,Dt=pe&&!!q.iridescenceThicknessMap,Bt=le&&!!q.sheenColorMap,ct=le&&!!q.sheenRoughnessMap,jt=!!q.specularMap,Jt=!!q.specularColorMap,In=!!q.specularIntensityMap,ge=Ne&&!!q.transmissionMap,Ot=Ne&&!!q.thicknessMap,ot=!!q.gradientMap,Tt=!!q.alphaMap,Ht=q.alphaTest>0,Yt=!!q.alphaHash,pn=!!q.extensions;let $e=Ya;q.toneMapped&&(He===null||He.isXRRenderTarget===!0)&&($e=i.toneMapping);const St={shaderID:Se,shaderType:q.type,shaderName:q.name,vertexShader:Ve,fragmentShader:Ce,defines:q.defines,customVertexShaderID:Fe,customFragmentShaderID:et,isRawShaderMaterial:q.isRawShaderMaterial===!0,glslVersion:q.glslVersion,precision:S,batching:zt,batchingColor:zt&&ne._colorsTexture!==null,instancing:Et,instancingColor:Et&&ne.instanceColor!==null,instancingMorph:Et&&ne.morphTexture!==null,supportsVertexTextures:x,outputColorSpace:He===null?i.outputColorSpace:He.isXRRenderTarget===!0?He.texture.colorSpace:Mo,alphaToCoverage:!!q.alphaToCoverage,map:Pt,matcap:We,envMap:ft,envMapMode:ft&&te.mapping,envMapCubeUVHeight:de,aoMap:fe,lightMap:Wt,bumpMap:yt,normalMap:Gt,displacementMap:x&&_t,emissiveMap:Xt,normalMapObjectSpace:Gt&&q.normalMapType===z7,normalMapTangentSpace:Gt&&q.normalMapType===Mc,metalnessMap:pt,roughnessMap:Ae,anisotropy:k,anisotropyMap:De,clearcoat:be,clearcoatMap:Je,clearcoatNormalMap:we,clearcoatRoughnessMap:Ue,dispersion:Oe,iridescence:pe,iridescenceMap:ut,iridescenceThicknessMap:Dt,sheen:le,sheenColorMap:Bt,sheenRoughnessMap:ct,specularMap:jt,specularColorMap:Jt,specularIntensityMap:In,transmission:Ne,transmissionMap:ge,thicknessMap:Ot,gradientMap:ot,opaque:q.transparent===!1&&q.blending===Xa&&q.alphaToCoverage===!1,alphaMap:Tt,alphaTest:Ht,alphaHash:Yt,combine:q.combine,mapUv:Pt&&N(q.map.channel),aoMapUv:fe&&N(q.aoMap.channel),lightMapUv:Wt&&N(q.lightMap.channel),bumpMapUv:yt&&N(q.bumpMap.channel),normalMapUv:Gt&&N(q.normalMap.channel),displacementMapUv:_t&&N(q.displacementMap.channel),emissiveMapUv:Xt&&N(q.emissiveMap.channel),metalnessMapUv:pt&&N(q.metalnessMap.channel),roughnessMapUv:Ae&&N(q.roughnessMap.channel),anisotropyMapUv:De&&N(q.anisotropyMap.channel),clearcoatMapUv:Je&&N(q.clearcoatMap.channel),clearcoatNormalMapUv:we&&N(q.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ue&&N(q.clearcoatRoughnessMap.channel),iridescenceMapUv:ut&&N(q.iridescenceMap.channel),iridescenceThicknessMapUv:Dt&&N(q.iridescenceThicknessMap.channel),sheenColorMapUv:Bt&&N(q.sheenColorMap.channel),sheenRoughnessMapUv:ct&&N(q.sheenRoughnessMap.channel),specularMapUv:jt&&N(q.specularMap.channel),specularColorMapUv:Jt&&N(q.specularColorMap.channel),specularIntensityMapUv:In&&N(q.specularIntensityMap.channel),transmissionMapUv:ge&&N(q.transmissionMap.channel),thicknessMapUv:Ot&&N(q.thicknessMap.channel),alphaMapUv:Tt&&N(q.alphaMap.channel),vertexTangents:!!ie.attributes.tangent&&(Gt||k),vertexColors:q.vertexColors,vertexAlphas:q.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,pointsUvs:ne.isPoints===!0&&!!ie.attributes.uv&&(Pt||Tt),fog:!!oe,useFog:q.fog===!0,fogExp2:!!oe&&oe.isFogExp2,flatShading:q.flatShading===!0,sizeAttenuation:q.sizeAttenuation===!0,logarithmicDepthBuffer:v,reverseDepthBuffer:Rt,skinning:ne.isSkinnedMesh===!0,morphTargets:ie.morphAttributes.position!==void 0,morphNormals:ie.morphAttributes.normal!==void 0,morphColors:ie.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:Me,numDirLights:V.directional.length,numPointLights:V.point.length,numSpotLights:V.spot.length,numSpotLightMaps:V.spotLightMap.length,numRectAreaLights:V.rectArea.length,numHemiLights:V.hemi.length,numDirLightShadows:V.directionalShadowMap.length,numPointLightShadows:V.pointShadowMap.length,numSpotLightShadows:V.spotShadowMap.length,numSpotLightShadowsWithMaps:V.numSpotLightShadowsWithMaps,numLightProbes:V.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:q.dithering,shadowMapEnabled:i.shadowMap.enabled&&Q.length>0,shadowMapType:i.shadowMap.type,toneMapping:$e,decodeVideoTexture:Pt&&q.map.isVideoTexture===!0&&li.getTransfer(q.map.colorSpace)===Fi,decodeVideoTextureEmissive:Xt&&q.emissiveMap.isVideoTexture===!0&&li.getTransfer(q.emissiveMap.colorSpace)===Fi,premultipliedAlpha:q.premultipliedAlpha,doubleSided:q.side===as,flipSided:q.side===or,useDepthPacking:q.depthPacking>=0,depthPacking:q.depthPacking||0,index0AttributeName:q.index0AttributeName,extensionClipCullDistance:pn&&q.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pn&&q.extensions.multiDraw===!0||zt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:q.customProgramCacheKey()};return St.vertexUv1s=h.has(1),St.vertexUv2s=h.has(2),St.vertexUv3s=h.has(3),h.clear(),St}function E(q){const V=[];if(q.shaderID?V.push(q.shaderID):(V.push(q.customVertexShaderID),V.push(q.customFragmentShaderID)),q.defines!==void 0)for(const Q in q.defines)V.push(Q),V.push(q.defines[Q]);return q.isRawShaderMaterial===!1&&(O(V,q),U(V,q),V.push(i.outputColorSpace)),V.push(q.customProgramCacheKey),V.join()}function O(q,V){q.push(V.precision),q.push(V.outputColorSpace),q.push(V.envMapMode),q.push(V.envMapCubeUVHeight),q.push(V.mapUv),q.push(V.alphaMapUv),q.push(V.lightMapUv),q.push(V.aoMapUv),q.push(V.bumpMapUv),q.push(V.normalMapUv),q.push(V.displacementMapUv),q.push(V.emissiveMapUv),q.push(V.metalnessMapUv),q.push(V.roughnessMapUv),q.push(V.anisotropyMapUv),q.push(V.clearcoatMapUv),q.push(V.clearcoatNormalMapUv),q.push(V.clearcoatRoughnessMapUv),q.push(V.iridescenceMapUv),q.push(V.iridescenceThicknessMapUv),q.push(V.sheenColorMapUv),q.push(V.sheenRoughnessMapUv),q.push(V.specularMapUv),q.push(V.specularColorMapUv),q.push(V.specularIntensityMapUv),q.push(V.transmissionMapUv),q.push(V.thicknessMapUv),q.push(V.combine),q.push(V.fogExp2),q.push(V.sizeAttenuation),q.push(V.morphTargetsCount),q.push(V.morphAttributeCount),q.push(V.numDirLights),q.push(V.numPointLights),q.push(V.numSpotLights),q.push(V.numSpotLightMaps),q.push(V.numHemiLights),q.push(V.numRectAreaLights),q.push(V.numDirLightShadows),q.push(V.numPointLightShadows),q.push(V.numSpotLightShadows),q.push(V.numSpotLightShadowsWithMaps),q.push(V.numLightProbes),q.push(V.shadowMapType),q.push(V.toneMapping),q.push(V.numClippingPlanes),q.push(V.numClipIntersection),q.push(V.depthPacking)}function U(q,V){l.disableAll(),V.supportsVertexTextures&&l.enable(0),V.instancing&&l.enable(1),V.instancingColor&&l.enable(2),V.instancingMorph&&l.enable(3),V.matcap&&l.enable(4),V.envMap&&l.enable(5),V.normalMapObjectSpace&&l.enable(6),V.normalMapTangentSpace&&l.enable(7),V.clearcoat&&l.enable(8),V.iridescence&&l.enable(9),V.alphaTest&&l.enable(10),V.vertexColors&&l.enable(11),V.vertexAlphas&&l.enable(12),V.vertexUv1s&&l.enable(13),V.vertexUv2s&&l.enable(14),V.vertexUv3s&&l.enable(15),V.vertexTangents&&l.enable(16),V.anisotropy&&l.enable(17),V.alphaHash&&l.enable(18),V.batching&&l.enable(19),V.dispersion&&l.enable(20),V.batchingColor&&l.enable(21),q.push(l.mask),l.disableAll(),V.fog&&l.enable(0),V.useFog&&l.enable(1),V.flatShading&&l.enable(2),V.logarithmicDepthBuffer&&l.enable(3),V.reverseDepthBuffer&&l.enable(4),V.skinning&&l.enable(5),V.morphTargets&&l.enable(6),V.morphNormals&&l.enable(7),V.morphColors&&l.enable(8),V.premultipliedAlpha&&l.enable(9),V.shadowMapEnabled&&l.enable(10),V.doubleSided&&l.enable(11),V.flipSided&&l.enable(12),V.useDepthPacking&&l.enable(13),V.dithering&&l.enable(14),V.transmission&&l.enable(15),V.sheen&&l.enable(16),V.opaque&&l.enable(17),V.pointsUvs&&l.enable(18),V.decodeVideoTexture&&l.enable(19),V.decodeVideoTextureEmissive&&l.enable(20),V.alphaToCoverage&&l.enable(21),q.push(l.mask)}function I(q){const V=T[q.type];let Q;if(V){const J=Fa[V];Q=my.clone(J.uniforms)}else Q=q.uniforms;return Q}function j(q,V){let Q;for(let J=0,ne=m.length;J0?n.push(E):S.transparent===!0?r.push(E):t.push(E)}function u(v,x,S,T,N,C){const E=a(v,x,S,T,N,C);S.transmission>0?n.unshift(E):S.transparent===!0?r.unshift(E):t.unshift(E)}function h(v,x){t.length>1&&t.sort(v||pH),n.length>1&&n.sort(x||n5),r.length>1&&r.sort(x||n5)}function m(){for(let v=e,x=i.length;v=s.length?(a=new i5,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function gH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new me,color:new cn};break;case"SpotLight":t={position:new me,direction:new me,color:new cn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new me,color:new cn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new me,skyColor:new cn,groundColor:new cn};break;case"RectAreaLight":t={color:new cn,position:new me,halfWidth:new me,halfHeight:new me};break}return i[e.id]=t,t}}}function vH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let _H=0;function yH(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function xH(i){const e=new gH,t=vH(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)n.probe.push(new me);const r=new me,s=new jn,a=new jn;function l(h){let m=0,v=0,x=0;for(let q=0;q<9;q++)n.probe[q].set(0,0,0);let S=0,T=0,N=0,C=0,E=0,O=0,U=0,I=0,j=0,z=0,G=0;h.sort(yH);for(let q=0,V=h.length;q0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=nn.LTC_FLOAT_1,n.rectAreaLTC2=nn.LTC_FLOAT_2):(n.rectAreaLTC1=nn.LTC_HALF_1,n.rectAreaLTC2=nn.LTC_HALF_2)),n.ambient[0]=m,n.ambient[1]=v,n.ambient[2]=x;const H=n.hash;(H.directionalLength!==S||H.pointLength!==T||H.spotLength!==N||H.rectAreaLength!==C||H.hemiLength!==E||H.numDirectionalShadows!==O||H.numPointShadows!==U||H.numSpotShadows!==I||H.numSpotMaps!==j||H.numLightProbes!==G)&&(n.directional.length=S,n.spot.length=N,n.rectArea.length=C,n.point.length=T,n.hemi.length=E,n.directionalShadow.length=O,n.directionalShadowMap.length=O,n.pointShadow.length=U,n.pointShadowMap.length=U,n.spotShadow.length=I,n.spotShadowMap.length=I,n.directionalShadowMatrix.length=O,n.pointShadowMatrix.length=U,n.spotLightMatrix.length=I+j-z,n.spotLightMap.length=j,n.numSpotLightShadowsWithMaps=z,n.numLightProbes=G,H.directionalLength=S,H.pointLength=T,H.spotLength=N,H.rectAreaLength=C,H.hemiLength=E,H.numDirectionalShadows=O,H.numPointShadows=U,H.numSpotShadows=I,H.numSpotMaps=j,H.numLightProbes=G,n.version=_H++)}function u(h,m){let v=0,x=0,S=0,T=0,N=0;const C=m.matrixWorldInverse;for(let E=0,O=h.length;E=a.length?(l=new r5(i),a.push(l)):l=a[s],l}function n(){e=new WeakMap}return{get:t,dispose:n}}const SH=`void main() { +`+ne+` +`+de)}else J!==""?console.warn("THREE.WebGLProgram: Program Info Log:",J):(ie===""||le==="")&&(Z=!1);Z&&(Q.diagnostics={runnable:re,programLog:J,vertexShader:{log:ie,prefix:C},fragmentShader:{log:le,prefix:E}})}r.deleteShader(j),r.deleteShader(z),H=new zv(r,N),q=Zj(r,N)}let H;this.getUniforms=function(){return H===void 0&&G(this),H};let q;this.getAttributes=function(){return q===void 0&&G(this),q};let V=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return V===!1&&(V=r.getProgramParameter(N,Vj)),V},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(N),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=jj++,this.cacheKey=e,this.usedTimes=1,this.program=N,this.vertexShader=j,this.fragmentShader=z,this}let cH=0;class hH{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new fH(e),t.set(e,n)),n}}class fH{constructor(e){this.id=cH++,this.code=e,this.usedTimes=0}}function dH(i,e,t,n,r,s,a){const l=new YT,u=new hH,h=new Set,m=[],v=r.logarithmicDepthBuffer,x=r.vertexTextures;let S=r.precision;const T={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function N(q){return h.add(q),q===0?"uv":`uv${q}`}function C(q,V,Q,J,ie){const le=J.fog,re=ie.geometry,Z=q.isMeshStandardMaterial?J.environment:null,ne=(q.isMeshStandardMaterial?t:e).get(q.envMap||Z),de=ne&&ne.mapping===ed?ne.image.height:null,be=T[q.type];q.precision!==null&&(S=r.getMaxPrecision(q.precision),S!==q.precision&&console.warn("THREE.WebGLProgram.getParameters:",q.precision,"not supported, using",S,"instead."));const Te=re.morphAttributes.position||re.morphAttributes.normal||re.morphAttributes.color,ae=Te!==void 0?Te.length:0;let Me=0;re.morphAttributes.position!==void 0&&(Me=1),re.morphAttributes.normal!==void 0&&(Me=2),re.morphAttributes.color!==void 0&&(Me=3);let Ve,Ce,Fe,tt;if(be){const Kt=Fa[be];Ve=Kt.vertexShader,Ce=Kt.fragmentShader}else Ve=q.vertexShader,Ce=q.fragmentShader,u.update(q),Fe=u.getVertexShaderID(q),tt=u.getFragmentShaderID(q);const je=i.getRenderTarget(),Rt=i.state.buffers.depth.getReversed(),Et=ie.isInstancedMesh===!0,Ft=ie.isBatchedMesh===!0,Ut=!!q.map,Ke=!!q.matcap,ht=!!ne,fe=!!q.aoMap,$t=!!q.lightMap,_t=!!q.bumpMap,Gt=!!q.normalMap,yt=!!q.displacementMap,Ht=!!q.emissiveMap,pt=!!q.metalnessMap,Ae=!!q.roughnessMap,k=q.anisotropy>0,xe=q.clearcoat>0,Oe=q.dispersion>0,Ue=q.iridescence>0,ee=q.sheen>0,we=q.transmission>0,Re=k&&!!q.anisotropyMap,We=xe&&!!q.clearcoatMap,Se=xe&&!!q.clearcoatNormalMap,Le=xe&&!!q.clearcoatRoughnessMap,ct=Ue&&!!q.iridescenceMap,Dt=Ue&&!!q.iridescenceThicknessMap,It=ee&&!!q.sheenColorMap,lt=ee&&!!q.sheenRoughnessMap,jt=!!q.specularMap,Jt=!!q.specularColorMap,In=!!q.specularIntensityMap,me=we&&!!q.transmissionMap,Bt=we&&!!q.thicknessMap,ot=!!q.gradientMap,Tt=!!q.alphaMap,Wt=q.alphaTest>0,Yt=!!q.alphaHash,pn=!!q.extensions;let $e=Ya;q.toneMapped&&(je===null||je.isXRRenderTarget===!0)&&($e=i.toneMapping);const St={shaderID:be,shaderType:q.type,shaderName:q.name,vertexShader:Ve,fragmentShader:Ce,defines:q.defines,customVertexShaderID:Fe,customFragmentShaderID:tt,isRawShaderMaterial:q.isRawShaderMaterial===!0,glslVersion:q.glslVersion,precision:S,batching:Ft,batchingColor:Ft&&ie._colorsTexture!==null,instancing:Et,instancingColor:Et&&ie.instanceColor!==null,instancingMorph:Et&&ie.morphTexture!==null,supportsVertexTextures:x,outputColorSpace:je===null?i.outputColorSpace:je.isXRRenderTarget===!0?je.texture.colorSpace:Mo,alphaToCoverage:!!q.alphaToCoverage,map:Ut,matcap:Ke,envMap:ht,envMapMode:ht&&ne.mapping,envMapCubeUVHeight:de,aoMap:fe,lightMap:$t,bumpMap:_t,normalMap:Gt,displacementMap:x&&yt,emissiveMap:Ht,normalMapObjectSpace:Gt&&q.normalMapType===z7,normalMapTangentSpace:Gt&&q.normalMapType===Mc,metalnessMap:pt,roughnessMap:Ae,anisotropy:k,anisotropyMap:Re,clearcoat:xe,clearcoatMap:We,clearcoatNormalMap:Se,clearcoatRoughnessMap:Le,dispersion:Oe,iridescence:Ue,iridescenceMap:ct,iridescenceThicknessMap:Dt,sheen:ee,sheenColorMap:It,sheenRoughnessMap:lt,specularMap:jt,specularColorMap:Jt,specularIntensityMap:In,transmission:we,transmissionMap:me,thicknessMap:Bt,gradientMap:ot,opaque:q.transparent===!1&&q.blending===Xa&&q.alphaToCoverage===!1,alphaMap:Tt,alphaTest:Wt,alphaHash:Yt,combine:q.combine,mapUv:Ut&&N(q.map.channel),aoMapUv:fe&&N(q.aoMap.channel),lightMapUv:$t&&N(q.lightMap.channel),bumpMapUv:_t&&N(q.bumpMap.channel),normalMapUv:Gt&&N(q.normalMap.channel),displacementMapUv:yt&&N(q.displacementMap.channel),emissiveMapUv:Ht&&N(q.emissiveMap.channel),metalnessMapUv:pt&&N(q.metalnessMap.channel),roughnessMapUv:Ae&&N(q.roughnessMap.channel),anisotropyMapUv:Re&&N(q.anisotropyMap.channel),clearcoatMapUv:We&&N(q.clearcoatMap.channel),clearcoatNormalMapUv:Se&&N(q.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Le&&N(q.clearcoatRoughnessMap.channel),iridescenceMapUv:ct&&N(q.iridescenceMap.channel),iridescenceThicknessMapUv:Dt&&N(q.iridescenceThicknessMap.channel),sheenColorMapUv:It&&N(q.sheenColorMap.channel),sheenRoughnessMapUv:lt&&N(q.sheenRoughnessMap.channel),specularMapUv:jt&&N(q.specularMap.channel),specularColorMapUv:Jt&&N(q.specularColorMap.channel),specularIntensityMapUv:In&&N(q.specularIntensityMap.channel),transmissionMapUv:me&&N(q.transmissionMap.channel),thicknessMapUv:Bt&&N(q.thicknessMap.channel),alphaMapUv:Tt&&N(q.alphaMap.channel),vertexTangents:!!re.attributes.tangent&&(Gt||k),vertexColors:q.vertexColors,vertexAlphas:q.vertexColors===!0&&!!re.attributes.color&&re.attributes.color.itemSize===4,pointsUvs:ie.isPoints===!0&&!!re.attributes.uv&&(Ut||Tt),fog:!!le,useFog:q.fog===!0,fogExp2:!!le&&le.isFogExp2,flatShading:q.flatShading===!0,sizeAttenuation:q.sizeAttenuation===!0,logarithmicDepthBuffer:v,reverseDepthBuffer:Rt,skinning:ie.isSkinnedMesh===!0,morphTargets:re.morphAttributes.position!==void 0,morphNormals:re.morphAttributes.normal!==void 0,morphColors:re.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:Me,numDirLights:V.directional.length,numPointLights:V.point.length,numSpotLights:V.spot.length,numSpotLightMaps:V.spotLightMap.length,numRectAreaLights:V.rectArea.length,numHemiLights:V.hemi.length,numDirLightShadows:V.directionalShadowMap.length,numPointLightShadows:V.pointShadowMap.length,numSpotLightShadows:V.spotShadowMap.length,numSpotLightShadowsWithMaps:V.numSpotLightShadowsWithMaps,numLightProbes:V.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:q.dithering,shadowMapEnabled:i.shadowMap.enabled&&Q.length>0,shadowMapType:i.shadowMap.type,toneMapping:$e,decodeVideoTexture:Ut&&q.map.isVideoTexture===!0&&li.getTransfer(q.map.colorSpace)===Fi,decodeVideoTextureEmissive:Ht&&q.emissiveMap.isVideoTexture===!0&&li.getTransfer(q.emissiveMap.colorSpace)===Fi,premultipliedAlpha:q.premultipliedAlpha,doubleSided:q.side===as,flipSided:q.side===or,useDepthPacking:q.depthPacking>=0,depthPacking:q.depthPacking||0,index0AttributeName:q.index0AttributeName,extensionClipCullDistance:pn&&q.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pn&&q.extensions.multiDraw===!0||Ft)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:q.customProgramCacheKey()};return St.vertexUv1s=h.has(1),St.vertexUv2s=h.has(2),St.vertexUv3s=h.has(3),h.clear(),St}function E(q){const V=[];if(q.shaderID?V.push(q.shaderID):(V.push(q.customVertexShaderID),V.push(q.customFragmentShaderID)),q.defines!==void 0)for(const Q in q.defines)V.push(Q),V.push(q.defines[Q]);return q.isRawShaderMaterial===!1&&(O(V,q),U(V,q),V.push(i.outputColorSpace)),V.push(q.customProgramCacheKey),V.join()}function O(q,V){q.push(V.precision),q.push(V.outputColorSpace),q.push(V.envMapMode),q.push(V.envMapCubeUVHeight),q.push(V.mapUv),q.push(V.alphaMapUv),q.push(V.lightMapUv),q.push(V.aoMapUv),q.push(V.bumpMapUv),q.push(V.normalMapUv),q.push(V.displacementMapUv),q.push(V.emissiveMapUv),q.push(V.metalnessMapUv),q.push(V.roughnessMapUv),q.push(V.anisotropyMapUv),q.push(V.clearcoatMapUv),q.push(V.clearcoatNormalMapUv),q.push(V.clearcoatRoughnessMapUv),q.push(V.iridescenceMapUv),q.push(V.iridescenceThicknessMapUv),q.push(V.sheenColorMapUv),q.push(V.sheenRoughnessMapUv),q.push(V.specularMapUv),q.push(V.specularColorMapUv),q.push(V.specularIntensityMapUv),q.push(V.transmissionMapUv),q.push(V.thicknessMapUv),q.push(V.combine),q.push(V.fogExp2),q.push(V.sizeAttenuation),q.push(V.morphTargetsCount),q.push(V.morphAttributeCount),q.push(V.numDirLights),q.push(V.numPointLights),q.push(V.numSpotLights),q.push(V.numSpotLightMaps),q.push(V.numHemiLights),q.push(V.numRectAreaLights),q.push(V.numDirLightShadows),q.push(V.numPointLightShadows),q.push(V.numSpotLightShadows),q.push(V.numSpotLightShadowsWithMaps),q.push(V.numLightProbes),q.push(V.shadowMapType),q.push(V.toneMapping),q.push(V.numClippingPlanes),q.push(V.numClipIntersection),q.push(V.depthPacking)}function U(q,V){l.disableAll(),V.supportsVertexTextures&&l.enable(0),V.instancing&&l.enable(1),V.instancingColor&&l.enable(2),V.instancingMorph&&l.enable(3),V.matcap&&l.enable(4),V.envMap&&l.enable(5),V.normalMapObjectSpace&&l.enable(6),V.normalMapTangentSpace&&l.enable(7),V.clearcoat&&l.enable(8),V.iridescence&&l.enable(9),V.alphaTest&&l.enable(10),V.vertexColors&&l.enable(11),V.vertexAlphas&&l.enable(12),V.vertexUv1s&&l.enable(13),V.vertexUv2s&&l.enable(14),V.vertexUv3s&&l.enable(15),V.vertexTangents&&l.enable(16),V.anisotropy&&l.enable(17),V.alphaHash&&l.enable(18),V.batching&&l.enable(19),V.dispersion&&l.enable(20),V.batchingColor&&l.enable(21),q.push(l.mask),l.disableAll(),V.fog&&l.enable(0),V.useFog&&l.enable(1),V.flatShading&&l.enable(2),V.logarithmicDepthBuffer&&l.enable(3),V.reverseDepthBuffer&&l.enable(4),V.skinning&&l.enable(5),V.morphTargets&&l.enable(6),V.morphNormals&&l.enable(7),V.morphColors&&l.enable(8),V.premultipliedAlpha&&l.enable(9),V.shadowMapEnabled&&l.enable(10),V.doubleSided&&l.enable(11),V.flipSided&&l.enable(12),V.useDepthPacking&&l.enable(13),V.dithering&&l.enable(14),V.transmission&&l.enable(15),V.sheen&&l.enable(16),V.opaque&&l.enable(17),V.pointsUvs&&l.enable(18),V.decodeVideoTexture&&l.enable(19),V.decodeVideoTextureEmissive&&l.enable(20),V.alphaToCoverage&&l.enable(21),q.push(l.mask)}function I(q){const V=T[q.type];let Q;if(V){const J=Fa[V];Q=my.clone(J.uniforms)}else Q=q.uniforms;return Q}function j(q,V){let Q;for(let J=0,ie=m.length;J0?n.push(E):S.transparent===!0?r.push(E):t.push(E)}function u(v,x,S,T,N,C){const E=a(v,x,S,T,N,C);S.transmission>0?n.unshift(E):S.transparent===!0?r.unshift(E):t.unshift(E)}function h(v,x){t.length>1&&t.sort(v||pH),n.length>1&&n.sort(x||n5),r.length>1&&r.sort(x||n5)}function m(){for(let v=e,x=i.length;v=s.length?(a=new i5,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function gH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new pe,color:new cn};break;case"SpotLight":t={position:new pe,direction:new pe,color:new cn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new pe,color:new cn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new pe,skyColor:new cn,groundColor:new cn};break;case"RectAreaLight":t={color:new cn,position:new pe,halfWidth:new pe,halfHeight:new pe};break}return i[e.id]=t,t}}}function vH(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let _H=0;function yH(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function xH(i){const e=new gH,t=vH(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)n.probe.push(new pe);const r=new pe,s=new jn,a=new jn;function l(h){let m=0,v=0,x=0;for(let q=0;q<9;q++)n.probe[q].set(0,0,0);let S=0,T=0,N=0,C=0,E=0,O=0,U=0,I=0,j=0,z=0,G=0;h.sort(yH);for(let q=0,V=h.length;q0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=nn.LTC_FLOAT_1,n.rectAreaLTC2=nn.LTC_FLOAT_2):(n.rectAreaLTC1=nn.LTC_HALF_1,n.rectAreaLTC2=nn.LTC_HALF_2)),n.ambient[0]=m,n.ambient[1]=v,n.ambient[2]=x;const H=n.hash;(H.directionalLength!==S||H.pointLength!==T||H.spotLength!==N||H.rectAreaLength!==C||H.hemiLength!==E||H.numDirectionalShadows!==O||H.numPointShadows!==U||H.numSpotShadows!==I||H.numSpotMaps!==j||H.numLightProbes!==G)&&(n.directional.length=S,n.spot.length=N,n.rectArea.length=C,n.point.length=T,n.hemi.length=E,n.directionalShadow.length=O,n.directionalShadowMap.length=O,n.pointShadow.length=U,n.pointShadowMap.length=U,n.spotShadow.length=I,n.spotShadowMap.length=I,n.directionalShadowMatrix.length=O,n.pointShadowMatrix.length=U,n.spotLightMatrix.length=I+j-z,n.spotLightMap.length=j,n.numSpotLightShadowsWithMaps=z,n.numLightProbes=G,H.directionalLength=S,H.pointLength=T,H.spotLength=N,H.rectAreaLength=C,H.hemiLength=E,H.numDirectionalShadows=O,H.numPointShadows=U,H.numSpotShadows=I,H.numSpotMaps=j,H.numLightProbes=G,n.version=_H++)}function u(h,m){let v=0,x=0,S=0,T=0,N=0;const C=m.matrixWorldInverse;for(let E=0,O=h.length;E=a.length?(l=new r5(i),a.push(l)):l=a[s],l}function n(){e=new WeakMap}return{get:t,dispose:n}}const SH=`void main() { gl_Position = vec4( position, 1.0 ); }`,wH=`uniform sampler2D shadow_pass; uniform vec2 resolution; @@ -3848,7 +3848,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function TH(i,e,t){let n=new Og;const r=new bt,s=new bt,a=new On,l=new Oz({depthPacking:KF}),u=new Iz,h={},m=t.maxTextureSize,v={[El]:or,[or]:El,[as]:as},x=new Qa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bt},radius:{value:4}},vertexShader:SH,fragmentShader:wH}),S=x.clone();S.defines.HORIZONTAL_PASS=1;const T=new Hi;T.setAttribute("position",new wr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const N=new Oi(T,x),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ST;let E=this.type;this.render=function(z,G,H){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||z.length===0)return;const q=i.getRenderTarget(),V=i.getActiveCubeFace(),Q=i.getActiveMipmapLevel(),J=i.state;J.setBlending($a),J.buffers.color.setClear(1,1,1,1),J.buffers.depth.setTest(!0),J.setScissorTest(!1);const ne=E!==vo&&this.type===vo,oe=E===vo&&this.type!==vo;for(let ie=0,Z=z.length;iem||r.y>m)&&(r.x>m&&(s.x=Math.floor(m/Se.x),r.x=s.x*Se.x,de.mapSize.x=s.x),r.y>m&&(s.y=Math.floor(m/Se.y),r.y=s.y*Se.y,de.mapSize.y=s.y)),de.map===null||ne===!0||oe===!0){const ae=this.type!==vo?{minFilter:dr,magFilter:dr}:{};de.map!==null&&de.map.dispose(),de.map=new Fh(r.x,r.y,ae),de.map.texture.name=te.name+".shadowMap",de.camera.updateProjectionMatrix()}i.setRenderTarget(de.map),i.clear();const Te=de.getViewportCount();for(let ae=0;ae0||G.map&&G.alphaTest>0){const J=V.uuid,ne=G.uuid;let oe=h[J];oe===void 0&&(oe={},h[J]=oe);let ie=oe[ne];ie===void 0&&(ie=V.clone(),oe[ne]=ie,G.addEventListener("dispose",j)),V=ie}if(V.visible=G.visible,V.wireframe=G.wireframe,q===vo?V.side=G.shadowSide!==null?G.shadowSide:G.side:V.side=G.shadowSide!==null?G.shadowSide:v[G.side],V.alphaMap=G.alphaMap,V.alphaTest=G.alphaTest,V.map=G.map,V.clipShadows=G.clipShadows,V.clippingPlanes=G.clippingPlanes,V.clipIntersection=G.clipIntersection,V.displacementMap=G.displacementMap,V.displacementScale=G.displacementScale,V.displacementBias=G.displacementBias,V.wireframeLinewidth=G.wireframeLinewidth,V.linewidth=G.linewidth,H.isPointLight===!0&&V.isMeshDistanceMaterial===!0){const J=i.properties.get(V);J.light=H}return V}function I(z,G,H,q,V){if(z.visible===!1)return;if(z.layers.test(G.layers)&&(z.isMesh||z.isLine||z.isPoints)&&(z.castShadow||z.receiveShadow&&V===vo)&&(!z.frustumCulled||n.intersectsObject(z))){z.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,z.matrixWorld);const ne=e.update(z),oe=z.material;if(Array.isArray(oe)){const ie=ne.groups;for(let Z=0,te=ie.length;Z=1):de.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(de)[1]),Z=te>=2);let Se=null,Te={};const ae=i.getParameter(i.SCISSOR_BOX),Me=i.getParameter(i.VIEWPORT),Ve=new On().fromArray(ae),Ce=new On().fromArray(Me);function Fe(ge,Ot,ot,Tt){const Ht=new Uint8Array(4),Yt=i.createTexture();i.bindTexture(ge,Yt),i.texParameteri(ge,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(ge,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let pn=0;pn"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new bt,m=new WeakMap;let v;const x=new WeakMap;let S=!1;try{S=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function T(Ae,k){return S?new OffscreenCanvas(Ae,k):ig("canvas")}function N(Ae,k,be){let Oe=1;const pe=pt(Ae);if((pe.width>be||pe.height>be)&&(Oe=be/Math.max(pe.width,pe.height)),Oe<1)if(typeof HTMLImageElement<"u"&&Ae instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Ae instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Ae instanceof ImageBitmap||typeof VideoFrame<"u"&&Ae instanceof VideoFrame){const le=Math.floor(Oe*pe.width),Ne=Math.floor(Oe*pe.height);v===void 0&&(v=T(le,Ne));const De=k?T(le,Ne):v;return De.width=le,De.height=Ne,De.getContext("2d").drawImage(Ae,0,0,le,Ne),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+pe.width+"x"+pe.height+") to ("+le+"x"+Ne+")."),De}else return"data"in Ae&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+pe.width+"x"+pe.height+")."),Ae;return Ae}function C(Ae){return Ae.generateMipmaps}function E(Ae){i.generateMipmap(Ae)}function O(Ae){return Ae.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:Ae.isWebGL3DRenderTarget?i.TEXTURE_3D:Ae.isWebGLArrayRenderTarget||Ae.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function U(Ae,k,be,Oe,pe=!1){if(Ae!==null){if(i[Ae]!==void 0)return i[Ae];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Ae+"'")}let le=k;if(k===i.RED&&(be===i.FLOAT&&(le=i.R32F),be===i.HALF_FLOAT&&(le=i.R16F),be===i.UNSIGNED_BYTE&&(le=i.R8)),k===i.RED_INTEGER&&(be===i.UNSIGNED_BYTE&&(le=i.R8UI),be===i.UNSIGNED_SHORT&&(le=i.R16UI),be===i.UNSIGNED_INT&&(le=i.R32UI),be===i.BYTE&&(le=i.R8I),be===i.SHORT&&(le=i.R16I),be===i.INT&&(le=i.R32I)),k===i.RG&&(be===i.FLOAT&&(le=i.RG32F),be===i.HALF_FLOAT&&(le=i.RG16F),be===i.UNSIGNED_BYTE&&(le=i.RG8)),k===i.RG_INTEGER&&(be===i.UNSIGNED_BYTE&&(le=i.RG8UI),be===i.UNSIGNED_SHORT&&(le=i.RG16UI),be===i.UNSIGNED_INT&&(le=i.RG32UI),be===i.BYTE&&(le=i.RG8I),be===i.SHORT&&(le=i.RG16I),be===i.INT&&(le=i.RG32I)),k===i.RGB_INTEGER&&(be===i.UNSIGNED_BYTE&&(le=i.RGB8UI),be===i.UNSIGNED_SHORT&&(le=i.RGB16UI),be===i.UNSIGNED_INT&&(le=i.RGB32UI),be===i.BYTE&&(le=i.RGB8I),be===i.SHORT&&(le=i.RGB16I),be===i.INT&&(le=i.RGB32I)),k===i.RGBA_INTEGER&&(be===i.UNSIGNED_BYTE&&(le=i.RGBA8UI),be===i.UNSIGNED_SHORT&&(le=i.RGBA16UI),be===i.UNSIGNED_INT&&(le=i.RGBA32UI),be===i.BYTE&&(le=i.RGBA8I),be===i.SHORT&&(le=i.RGBA16I),be===i.INT&&(le=i.RGBA32I)),k===i.RGB&&be===i.UNSIGNED_INT_5_9_9_9_REV&&(le=i.RGB9_E5),k===i.RGBA){const Ne=pe?r_:li.getTransfer(Oe);be===i.FLOAT&&(le=i.RGBA32F),be===i.HALF_FLOAT&&(le=i.RGBA16F),be===i.UNSIGNED_BYTE&&(le=Ne===Fi?i.SRGB8_ALPHA8:i.RGBA8),be===i.UNSIGNED_SHORT_4_4_4_4&&(le=i.RGBA4),be===i.UNSIGNED_SHORT_5_5_5_1&&(le=i.RGB5_A1)}return(le===i.R16F||le===i.R32F||le===i.RG16F||le===i.RG32F||le===i.RGBA16F||le===i.RGBA32F)&&e.get("EXT_color_buffer_float"),le}function I(Ae,k){let be;return Ae?k===null||k===Nr||k===lu?be=i.DEPTH24_STENCIL8:k===$r?be=i.DEPTH32F_STENCIL8:k===bl&&(be=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):k===null||k===Nr||k===lu?be=i.DEPTH_COMPONENT24:k===$r?be=i.DEPTH_COMPONENT32F:k===bl&&(be=i.DEPTH_COMPONENT16),be}function j(Ae,k){return C(Ae)===!0||Ae.isFramebufferTexture&&Ae.minFilter!==dr&&Ae.minFilter!==ps?Math.log2(Math.max(k.width,k.height))+1:Ae.mipmaps!==void 0&&Ae.mipmaps.length>0?Ae.mipmaps.length:Ae.isCompressedTexture&&Array.isArray(Ae.image)?k.mipmaps.length:1}function z(Ae){const k=Ae.target;k.removeEventListener("dispose",z),H(k),k.isVideoTexture&&m.delete(k)}function G(Ae){const k=Ae.target;k.removeEventListener("dispose",G),V(k)}function H(Ae){const k=n.get(Ae);if(k.__webglInit===void 0)return;const be=Ae.source,Oe=x.get(be);if(Oe){const pe=Oe[k.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&q(Ae),Object.keys(Oe).length===0&&x.delete(be)}n.remove(Ae)}function q(Ae){const k=n.get(Ae);i.deleteTexture(k.__webglTexture);const be=Ae.source,Oe=x.get(be);delete Oe[k.__cacheKey],a.memory.textures--}function V(Ae){const k=n.get(Ae);if(Ae.depthTexture&&(Ae.depthTexture.dispose(),n.remove(Ae.depthTexture)),Ae.isWebGLCubeRenderTarget)for(let Oe=0;Oe<6;Oe++){if(Array.isArray(k.__webglFramebuffer[Oe]))for(let pe=0;pe=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Ae+" texture units while this GPU supports only "+r.maxTextures),Q+=1,Ae}function oe(Ae){const k=[];return k.push(Ae.wrapS),k.push(Ae.wrapT),k.push(Ae.wrapR||0),k.push(Ae.magFilter),k.push(Ae.minFilter),k.push(Ae.anisotropy),k.push(Ae.internalFormat),k.push(Ae.format),k.push(Ae.type),k.push(Ae.generateMipmaps),k.push(Ae.premultiplyAlpha),k.push(Ae.flipY),k.push(Ae.unpackAlignment),k.push(Ae.colorSpace),k.join()}function ie(Ae,k){const be=n.get(Ae);if(Ae.isVideoTexture&&_t(Ae),Ae.isRenderTargetTexture===!1&&Ae.version>0&&be.__version!==Ae.version){const Oe=Ae.image;if(Oe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Oe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(be,Ae,k);return}}t.bindTexture(i.TEXTURE_2D,be.__webglTexture,i.TEXTURE0+k)}function Z(Ae,k){const be=n.get(Ae);if(Ae.version>0&&be.__version!==Ae.version){Ce(be,Ae,k);return}t.bindTexture(i.TEXTURE_2D_ARRAY,be.__webglTexture,i.TEXTURE0+k)}function te(Ae,k){const be=n.get(Ae);if(Ae.version>0&&be.__version!==Ae.version){Ce(be,Ae,k);return}t.bindTexture(i.TEXTURE_3D,be.__webglTexture,i.TEXTURE0+k)}function de(Ae,k){const be=n.get(Ae);if(Ae.version>0&&be.__version!==Ae.version){Fe(be,Ae,k);return}t.bindTexture(i.TEXTURE_CUBE_MAP,be.__webglTexture,i.TEXTURE0+k)}const Se={[td]:i.REPEAT,[Yl]:i.CLAMP_TO_EDGE,[nd]:i.MIRRORED_REPEAT},Te={[dr]:i.NEAREST,[i_]:i.NEAREST_MIPMAP_NEAREST,[Ql]:i.NEAREST_MIPMAP_LINEAR,[ps]:i.LINEAR,[XA]:i.LINEAR_MIPMAP_NEAREST,[za]:i.LINEAR_MIPMAP_LINEAR},ae={[GT]:i.NEVER,[WT]:i.ALWAYS,[Ay]:i.LESS,[py]:i.LEQUAL,[qT]:i.EQUAL,[HT]:i.GEQUAL,[VT]:i.GREATER,[jT]:i.NOTEQUAL};function Me(Ae,k){if(k.type===$r&&e.has("OES_texture_float_linear")===!1&&(k.magFilter===ps||k.magFilter===XA||k.magFilter===Ql||k.magFilter===za||k.minFilter===ps||k.minFilter===XA||k.minFilter===Ql||k.minFilter===za)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(Ae,i.TEXTURE_WRAP_S,Se[k.wrapS]),i.texParameteri(Ae,i.TEXTURE_WRAP_T,Se[k.wrapT]),(Ae===i.TEXTURE_3D||Ae===i.TEXTURE_2D_ARRAY)&&i.texParameteri(Ae,i.TEXTURE_WRAP_R,Se[k.wrapR]),i.texParameteri(Ae,i.TEXTURE_MAG_FILTER,Te[k.magFilter]),i.texParameteri(Ae,i.TEXTURE_MIN_FILTER,Te[k.minFilter]),k.compareFunction&&(i.texParameteri(Ae,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(Ae,i.TEXTURE_COMPARE_FUNC,ae[k.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(k.magFilter===dr||k.minFilter!==Ql&&k.minFilter!==za||k.type===$r&&e.has("OES_texture_float_linear")===!1)return;if(k.anisotropy>1||n.get(k).__currentAnisotropy){const be=e.get("EXT_texture_filter_anisotropic");i.texParameterf(Ae,be.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),n.get(k).__currentAnisotropy=k.anisotropy}}}function Ve(Ae,k){let be=!1;Ae.__webglInit===void 0&&(Ae.__webglInit=!0,k.addEventListener("dispose",z));const Oe=k.source;let pe=x.get(Oe);pe===void 0&&(pe={},x.set(Oe,pe));const le=oe(k);if(le!==Ae.__cacheKey){pe[le]===void 0&&(pe[le]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,be=!0),pe[le].usedTimes++;const Ne=pe[Ae.__cacheKey];Ne!==void 0&&(pe[Ae.__cacheKey].usedTimes--,Ne.usedTimes===0&&q(k)),Ae.__cacheKey=le,Ae.__webglTexture=pe[le].texture}return be}function Ce(Ae,k,be){let Oe=i.TEXTURE_2D;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(Oe=i.TEXTURE_2D_ARRAY),k.isData3DTexture&&(Oe=i.TEXTURE_3D);const pe=Ve(Ae,k),le=k.source;t.bindTexture(Oe,Ae.__webglTexture,i.TEXTURE0+be);const Ne=n.get(le);if(le.version!==Ne.__version||pe===!0){t.activeTexture(i.TEXTURE0+be);const De=li.getPrimaries(li.workingColorSpace),Je=k.colorSpace===To?null:li.getPrimaries(k.colorSpace),we=k.colorSpace===To||De===Je?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,k.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,k.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,we);let Ue=N(k.image,!1,r.maxTextureSize);Ue=Xt(k,Ue);const ut=s.convert(k.format,k.colorSpace),Dt=s.convert(k.type);let Bt=U(k.internalFormat,ut,Dt,k.colorSpace,k.isVideoTexture);Me(Oe,k);let ct;const jt=k.mipmaps,Jt=k.isVideoTexture!==!0,In=Ne.__version===void 0||pe===!0,ge=le.dataReady,Ot=j(k,Ue);if(k.isDepthTexture)Bt=I(k.format===uu,k.type),In&&(Jt?t.texStorage2D(i.TEXTURE_2D,1,Bt,Ue.width,Ue.height):t.texImage2D(i.TEXTURE_2D,0,Bt,Ue.width,Ue.height,0,ut,Dt,null));else if(k.isDataTexture)if(jt.length>0){Jt&&In&&t.texStorage2D(i.TEXTURE_2D,Ot,Bt,jt[0].width,jt[0].height);for(let ot=0,Tt=jt.length;ot0){const Ht=UN(ct.width,ct.height,k.format,k.type);for(const Yt of k.layerUpdates){const pn=ct.data.subarray(Yt*Ht/ct.data.BYTES_PER_ELEMENT,(Yt+1)*Ht/ct.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,Yt,ct.width,ct.height,1,ut,pn)}k.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,0,ct.width,ct.height,Ue.depth,ut,ct.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,ot,Bt,ct.width,ct.height,Ue.depth,0,ct.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Jt?ge&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,0,ct.width,ct.height,Ue.depth,ut,Dt,ct.data):t.texImage3D(i.TEXTURE_2D_ARRAY,ot,Bt,ct.width,ct.height,Ue.depth,0,ut,Dt,ct.data)}else{Jt&&In&&t.texStorage2D(i.TEXTURE_2D,Ot,Bt,jt[0].width,jt[0].height);for(let ot=0,Tt=jt.length;ot0){const ot=UN(Ue.width,Ue.height,k.format,k.type);for(const Tt of k.layerUpdates){const Ht=Ue.data.subarray(Tt*ot/Ue.data.BYTES_PER_ELEMENT,(Tt+1)*ot/Ue.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Tt,Ue.width,Ue.height,1,ut,Dt,Ht)}k.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Ue.width,Ue.height,Ue.depth,ut,Dt,Ue.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Bt,Ue.width,Ue.height,Ue.depth,0,ut,Dt,Ue.data);else if(k.isData3DTexture)Jt?(In&&t.texStorage3D(i.TEXTURE_3D,Ot,Bt,Ue.width,Ue.height,Ue.depth),ge&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Ue.width,Ue.height,Ue.depth,ut,Dt,Ue.data)):t.texImage3D(i.TEXTURE_3D,0,Bt,Ue.width,Ue.height,Ue.depth,0,ut,Dt,Ue.data);else if(k.isFramebufferTexture){if(In)if(Jt)t.texStorage2D(i.TEXTURE_2D,Ot,Bt,Ue.width,Ue.height);else{let ot=Ue.width,Tt=Ue.height;for(let Ht=0;Ht>=1,Tt>>=1}}else if(jt.length>0){if(Jt&&In){const ot=pt(jt[0]);t.texStorage2D(i.TEXTURE_2D,Ot,Bt,ot.width,ot.height)}for(let ot=0,Tt=jt.length;ot0&&Ot++;const Tt=pt(ut[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Ot,jt,Tt.width,Tt.height)}for(let Tt=0;Tt<6;Tt++)if(Ue){Jt?ge&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Tt,0,0,0,ut[Tt].width,ut[Tt].height,Bt,ct,ut[Tt].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Tt,0,jt,ut[Tt].width,ut[Tt].height,0,Bt,ct,ut[Tt].data);for(let Ht=0;Ht>le),Dt=Math.max(1,k.height>>le);pe===i.TEXTURE_3D||pe===i.TEXTURE_2D_ARRAY?t.texImage3D(pe,le,Je,ut,Dt,k.depth,0,Ne,De,null):t.texImage2D(pe,le,Je,ut,Dt,0,Ne,De,null)}t.bindFramebuffer(i.FRAMEBUFFER,Ae),Gt(k)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Oe,pe,Ue.__webglTexture,0,yt(k)):(pe===i.TEXTURE_2D||pe>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&pe<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Oe,pe,Ue.__webglTexture,le),t.bindFramebuffer(i.FRAMEBUFFER,null)}function He(Ae,k,be){if(i.bindRenderbuffer(i.RENDERBUFFER,Ae),k.depthBuffer){const Oe=k.depthTexture,pe=Oe&&Oe.isDepthTexture?Oe.type:null,le=I(k.stencilBuffer,pe),Ne=k.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,De=yt(k);Gt(k)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,De,le,k.width,k.height):be?i.renderbufferStorageMultisample(i.RENDERBUFFER,De,le,k.width,k.height):i.renderbufferStorage(i.RENDERBUFFER,le,k.width,k.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ne,i.RENDERBUFFER,Ae)}else{const Oe=k.textures;for(let pe=0;pe{delete k.__boundDepthTexture,delete k.__depthDisposeCallback,Oe.removeEventListener("dispose",pe)};Oe.addEventListener("dispose",pe),k.__depthDisposeCallback=pe}k.__boundDepthTexture=Oe}if(Ae.depthTexture&&!k.__autoAllocateDepthBuffer){if(be)throw new Error("target.depthTexture not supported in Cube render targets");Rt(k.__webglFramebuffer,Ae)}else if(be){k.__webglDepthbuffer=[];for(let Oe=0;Oe<6;Oe++)if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer[Oe]),k.__webglDepthbuffer[Oe]===void 0)k.__webglDepthbuffer[Oe]=i.createRenderbuffer(),He(k.__webglDepthbuffer[Oe],Ae,!1);else{const pe=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,le=k.__webglDepthbuffer[Oe];i.bindRenderbuffer(i.RENDERBUFFER,le),i.framebufferRenderbuffer(i.FRAMEBUFFER,pe,i.RENDERBUFFER,le)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer),k.__webglDepthbuffer===void 0)k.__webglDepthbuffer=i.createRenderbuffer(),He(k.__webglDepthbuffer,Ae,!1);else{const Oe=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,pe=k.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,pe),i.framebufferRenderbuffer(i.FRAMEBUFFER,Oe,i.RENDERBUFFER,pe)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function zt(Ae,k,be){const Oe=n.get(Ae);k!==void 0&&et(Oe.__webglFramebuffer,Ae,Ae.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),be!==void 0&&Et(Ae)}function Pt(Ae){const k=Ae.texture,be=n.get(Ae),Oe=n.get(k);Ae.addEventListener("dispose",G);const pe=Ae.textures,le=Ae.isWebGLCubeRenderTarget===!0,Ne=pe.length>1;if(Ne||(Oe.__webglTexture===void 0&&(Oe.__webglTexture=i.createTexture()),Oe.__version=k.version,a.memory.textures++),le){be.__webglFramebuffer=[];for(let De=0;De<6;De++)if(k.mipmaps&&k.mipmaps.length>0){be.__webglFramebuffer[De]=[];for(let Je=0;Je0){be.__webglFramebuffer=[];for(let De=0;De0&&Gt(Ae)===!1){be.__webglMultisampledFramebuffer=i.createFramebuffer(),be.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,be.__webglMultisampledFramebuffer);for(let De=0;De0)for(let Je=0;Je0)for(let Je=0;Je0){if(Gt(Ae)===!1){const k=Ae.textures,be=Ae.width,Oe=Ae.height;let pe=i.COLOR_BUFFER_BIT;const le=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ne=n.get(Ae),De=k.length>1;if(De)for(let Je=0;Je0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function _t(Ae){const k=a.render.frame;m.get(Ae)!==k&&(m.set(Ae,k),Ae.update())}function Xt(Ae,k){const be=Ae.colorSpace,Oe=Ae.format,pe=Ae.type;return Ae.isCompressedTexture===!0||Ae.isVideoTexture===!0||be!==Mo&&be!==To&&(li.getTransfer(be)===Fi?(Oe!==ks||pe!==ra)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",be)),k}function pt(Ae){return typeof HTMLImageElement<"u"&&Ae instanceof HTMLImageElement?(h.width=Ae.naturalWidth||Ae.width,h.height=Ae.naturalHeight||Ae.height):typeof VideoFrame<"u"&&Ae instanceof VideoFrame?(h.width=Ae.displayWidth,h.height=Ae.displayHeight):(h.width=Ae.width,h.height=Ae.height),h}this.allocateTextureUnit=ne,this.resetTextureUnits=J,this.setTexture2D=ie,this.setTexture2DArray=Z,this.setTexture3D=te,this.setTextureCube=de,this.rebindTextures=zt,this.setupRenderTarget=Pt,this.updateRenderTargetMipmap=We,this.updateMultisampleRenderTarget=Wt,this.setupDepthRenderbuffer=Et,this.setupFrameBufferTexture=et,this.useMultisampledRTT=Gt}function NH(i,e){function t(n,r=To){let s;const a=li.getTransfer(r);if(n===ra)return i.UNSIGNED_BYTE;if(n===hy)return i.UNSIGNED_SHORT_4_4_4_4;if(n===fy)return i.UNSIGNED_SHORT_5_5_5_1;if(n===dy)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Hf)return i.BYTE;if(n===Wf)return i.SHORT;if(n===bl)return i.UNSIGNED_SHORT;if(n===Ns)return i.INT;if(n===Nr)return i.UNSIGNED_INT;if(n===$r)return i.FLOAT;if(n===Gs)return i.HALF_FLOAT;if(n===IT)return i.ALPHA;if(n===Pg)return i.RGB;if(n===ks)return i.RGBA;if(n===FT)return i.LUMINANCE;if(n===kT)return i.LUMINANCE_ALPHA;if(n===tu)return i.DEPTH_COMPONENT;if(n===uu)return i.DEPTH_STENCIL;if(n===Lg)return i.RED;if(n===k0)return i.RED_INTEGER;if(n===id)return i.RG;if(n===z0)return i.RG_INTEGER;if(n===G0)return i.RGBA_INTEGER;if(n===$f||n===Dh||n===Ph||n===Lh)if(a===Fi)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===$f)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Dh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ph)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Lh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===$f)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Dh)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ph)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Lh)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ym||n===Qm||n===Km||n===Zm)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Ym)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Qm)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Km)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Zm)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Jm||n===r0||n===s0)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Jm||n===r0)return a===Fi?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===s0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===a0||n===o0||n===l0||n===u0||n===c0||n===h0||n===f0||n===d0||n===A0||n===p0||n===m0||n===g0||n===v0||n===_0)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===a0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===o0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===l0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===u0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===c0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===h0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===f0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===d0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===A0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===p0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===m0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===g0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===v0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===_0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Xf||n===$S||n===XS)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Xf)return a===Fi?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===$S)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===XS)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===zT||n===eg||n===tg||n===ng)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Xf)return s.COMPRESSED_RED_RGTC1_EXT;if(n===eg)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===tg)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ng)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===lu?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const RH={type:"move"};class P3{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new qa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new me,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new me),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new me,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new me),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const l=this._targetRay,u=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const N of e.hand.values()){const C=t.getJointPose(N,n),E=this._getHandJoint(h,N);C!==null&&(E.matrix.fromArray(C.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=C.radius),E.visible=C!==null}const m=h.joints["index-finger-tip"],v=h.joints["thumb-tip"],x=m.position.distanceTo(v.position),S=.02,T=.005;h.inputState.pinching&&x>S+T?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&x<=S-T&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(RH)))}return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=s!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new qa;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const DH=` +}`;function TH(i,e,t){let n=new Og;const r=new bt,s=new bt,a=new On,l=new Oz({depthPacking:KF}),u=new Iz,h={},m=t.maxTextureSize,v={[El]:or,[or]:El,[as]:as},x=new Qa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bt},radius:{value:4}},vertexShader:SH,fragmentShader:wH}),S=x.clone();S.defines.HORIZONTAL_PASS=1;const T=new Hi;T.setAttribute("position",new wr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const N=new Oi(T,x),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ST;let E=this.type;this.render=function(z,G,H){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||z.length===0)return;const q=i.getRenderTarget(),V=i.getActiveCubeFace(),Q=i.getActiveMipmapLevel(),J=i.state;J.setBlending($a),J.buffers.color.setClear(1,1,1,1),J.buffers.depth.setTest(!0),J.setScissorTest(!1);const ie=E!==vo&&this.type===vo,le=E===vo&&this.type!==vo;for(let re=0,Z=z.length;rem||r.y>m)&&(r.x>m&&(s.x=Math.floor(m/be.x),r.x=s.x*be.x,de.mapSize.x=s.x),r.y>m&&(s.y=Math.floor(m/be.y),r.y=s.y*be.y,de.mapSize.y=s.y)),de.map===null||ie===!0||le===!0){const ae=this.type!==vo?{minFilter:dr,magFilter:dr}:{};de.map!==null&&de.map.dispose(),de.map=new Fh(r.x,r.y,ae),de.map.texture.name=ne.name+".shadowMap",de.camera.updateProjectionMatrix()}i.setRenderTarget(de.map),i.clear();const Te=de.getViewportCount();for(let ae=0;ae0||G.map&&G.alphaTest>0){const J=V.uuid,ie=G.uuid;let le=h[J];le===void 0&&(le={},h[J]=le);let re=le[ie];re===void 0&&(re=V.clone(),le[ie]=re,G.addEventListener("dispose",j)),V=re}if(V.visible=G.visible,V.wireframe=G.wireframe,q===vo?V.side=G.shadowSide!==null?G.shadowSide:G.side:V.side=G.shadowSide!==null?G.shadowSide:v[G.side],V.alphaMap=G.alphaMap,V.alphaTest=G.alphaTest,V.map=G.map,V.clipShadows=G.clipShadows,V.clippingPlanes=G.clippingPlanes,V.clipIntersection=G.clipIntersection,V.displacementMap=G.displacementMap,V.displacementScale=G.displacementScale,V.displacementBias=G.displacementBias,V.wireframeLinewidth=G.wireframeLinewidth,V.linewidth=G.linewidth,H.isPointLight===!0&&V.isMeshDistanceMaterial===!0){const J=i.properties.get(V);J.light=H}return V}function I(z,G,H,q,V){if(z.visible===!1)return;if(z.layers.test(G.layers)&&(z.isMesh||z.isLine||z.isPoints)&&(z.castShadow||z.receiveShadow&&V===vo)&&(!z.frustumCulled||n.intersectsObject(z))){z.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,z.matrixWorld);const ie=e.update(z),le=z.material;if(Array.isArray(le)){const re=ie.groups;for(let Z=0,ne=re.length;Z=1):de.indexOf("OpenGL ES")!==-1&&(ne=parseFloat(/^OpenGL ES (\d)/.exec(de)[1]),Z=ne>=2);let be=null,Te={};const ae=i.getParameter(i.SCISSOR_BOX),Me=i.getParameter(i.VIEWPORT),Ve=new On().fromArray(ae),Ce=new On().fromArray(Me);function Fe(me,Bt,ot,Tt){const Wt=new Uint8Array(4),Yt=i.createTexture();i.bindTexture(me,Yt),i.texParameteri(me,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(me,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let pn=0;pn"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new bt,m=new WeakMap;let v;const x=new WeakMap;let S=!1;try{S=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function T(Ae,k){return S?new OffscreenCanvas(Ae,k):ig("canvas")}function N(Ae,k,xe){let Oe=1;const Ue=pt(Ae);if((Ue.width>xe||Ue.height>xe)&&(Oe=xe/Math.max(Ue.width,Ue.height)),Oe<1)if(typeof HTMLImageElement<"u"&&Ae instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Ae instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Ae instanceof ImageBitmap||typeof VideoFrame<"u"&&Ae instanceof VideoFrame){const ee=Math.floor(Oe*Ue.width),we=Math.floor(Oe*Ue.height);v===void 0&&(v=T(ee,we));const Re=k?T(ee,we):v;return Re.width=ee,Re.height=we,Re.getContext("2d").drawImage(Ae,0,0,ee,we),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Ue.width+"x"+Ue.height+") to ("+ee+"x"+we+")."),Re}else return"data"in Ae&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Ue.width+"x"+Ue.height+")."),Ae;return Ae}function C(Ae){return Ae.generateMipmaps}function E(Ae){i.generateMipmap(Ae)}function O(Ae){return Ae.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:Ae.isWebGL3DRenderTarget?i.TEXTURE_3D:Ae.isWebGLArrayRenderTarget||Ae.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function U(Ae,k,xe,Oe,Ue=!1){if(Ae!==null){if(i[Ae]!==void 0)return i[Ae];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Ae+"'")}let ee=k;if(k===i.RED&&(xe===i.FLOAT&&(ee=i.R32F),xe===i.HALF_FLOAT&&(ee=i.R16F),xe===i.UNSIGNED_BYTE&&(ee=i.R8)),k===i.RED_INTEGER&&(xe===i.UNSIGNED_BYTE&&(ee=i.R8UI),xe===i.UNSIGNED_SHORT&&(ee=i.R16UI),xe===i.UNSIGNED_INT&&(ee=i.R32UI),xe===i.BYTE&&(ee=i.R8I),xe===i.SHORT&&(ee=i.R16I),xe===i.INT&&(ee=i.R32I)),k===i.RG&&(xe===i.FLOAT&&(ee=i.RG32F),xe===i.HALF_FLOAT&&(ee=i.RG16F),xe===i.UNSIGNED_BYTE&&(ee=i.RG8)),k===i.RG_INTEGER&&(xe===i.UNSIGNED_BYTE&&(ee=i.RG8UI),xe===i.UNSIGNED_SHORT&&(ee=i.RG16UI),xe===i.UNSIGNED_INT&&(ee=i.RG32UI),xe===i.BYTE&&(ee=i.RG8I),xe===i.SHORT&&(ee=i.RG16I),xe===i.INT&&(ee=i.RG32I)),k===i.RGB_INTEGER&&(xe===i.UNSIGNED_BYTE&&(ee=i.RGB8UI),xe===i.UNSIGNED_SHORT&&(ee=i.RGB16UI),xe===i.UNSIGNED_INT&&(ee=i.RGB32UI),xe===i.BYTE&&(ee=i.RGB8I),xe===i.SHORT&&(ee=i.RGB16I),xe===i.INT&&(ee=i.RGB32I)),k===i.RGBA_INTEGER&&(xe===i.UNSIGNED_BYTE&&(ee=i.RGBA8UI),xe===i.UNSIGNED_SHORT&&(ee=i.RGBA16UI),xe===i.UNSIGNED_INT&&(ee=i.RGBA32UI),xe===i.BYTE&&(ee=i.RGBA8I),xe===i.SHORT&&(ee=i.RGBA16I),xe===i.INT&&(ee=i.RGBA32I)),k===i.RGB&&xe===i.UNSIGNED_INT_5_9_9_9_REV&&(ee=i.RGB9_E5),k===i.RGBA){const we=Ue?r_:li.getTransfer(Oe);xe===i.FLOAT&&(ee=i.RGBA32F),xe===i.HALF_FLOAT&&(ee=i.RGBA16F),xe===i.UNSIGNED_BYTE&&(ee=we===Fi?i.SRGB8_ALPHA8:i.RGBA8),xe===i.UNSIGNED_SHORT_4_4_4_4&&(ee=i.RGBA4),xe===i.UNSIGNED_SHORT_5_5_5_1&&(ee=i.RGB5_A1)}return(ee===i.R16F||ee===i.R32F||ee===i.RG16F||ee===i.RG32F||ee===i.RGBA16F||ee===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ee}function I(Ae,k){let xe;return Ae?k===null||k===Nr||k===lu?xe=i.DEPTH24_STENCIL8:k===$r?xe=i.DEPTH32F_STENCIL8:k===bl&&(xe=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):k===null||k===Nr||k===lu?xe=i.DEPTH_COMPONENT24:k===$r?xe=i.DEPTH_COMPONENT32F:k===bl&&(xe=i.DEPTH_COMPONENT16),xe}function j(Ae,k){return C(Ae)===!0||Ae.isFramebufferTexture&&Ae.minFilter!==dr&&Ae.minFilter!==ps?Math.log2(Math.max(k.width,k.height))+1:Ae.mipmaps!==void 0&&Ae.mipmaps.length>0?Ae.mipmaps.length:Ae.isCompressedTexture&&Array.isArray(Ae.image)?k.mipmaps.length:1}function z(Ae){const k=Ae.target;k.removeEventListener("dispose",z),H(k),k.isVideoTexture&&m.delete(k)}function G(Ae){const k=Ae.target;k.removeEventListener("dispose",G),V(k)}function H(Ae){const k=n.get(Ae);if(k.__webglInit===void 0)return;const xe=Ae.source,Oe=x.get(xe);if(Oe){const Ue=Oe[k.__cacheKey];Ue.usedTimes--,Ue.usedTimes===0&&q(Ae),Object.keys(Oe).length===0&&x.delete(xe)}n.remove(Ae)}function q(Ae){const k=n.get(Ae);i.deleteTexture(k.__webglTexture);const xe=Ae.source,Oe=x.get(xe);delete Oe[k.__cacheKey],a.memory.textures--}function V(Ae){const k=n.get(Ae);if(Ae.depthTexture&&(Ae.depthTexture.dispose(),n.remove(Ae.depthTexture)),Ae.isWebGLCubeRenderTarget)for(let Oe=0;Oe<6;Oe++){if(Array.isArray(k.__webglFramebuffer[Oe]))for(let Ue=0;Ue=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Ae+" texture units while this GPU supports only "+r.maxTextures),Q+=1,Ae}function le(Ae){const k=[];return k.push(Ae.wrapS),k.push(Ae.wrapT),k.push(Ae.wrapR||0),k.push(Ae.magFilter),k.push(Ae.minFilter),k.push(Ae.anisotropy),k.push(Ae.internalFormat),k.push(Ae.format),k.push(Ae.type),k.push(Ae.generateMipmaps),k.push(Ae.premultiplyAlpha),k.push(Ae.flipY),k.push(Ae.unpackAlignment),k.push(Ae.colorSpace),k.join()}function re(Ae,k){const xe=n.get(Ae);if(Ae.isVideoTexture&&yt(Ae),Ae.isRenderTargetTexture===!1&&Ae.version>0&&xe.__version!==Ae.version){const Oe=Ae.image;if(Oe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Oe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(xe,Ae,k);return}}t.bindTexture(i.TEXTURE_2D,xe.__webglTexture,i.TEXTURE0+k)}function Z(Ae,k){const xe=n.get(Ae);if(Ae.version>0&&xe.__version!==Ae.version){Ce(xe,Ae,k);return}t.bindTexture(i.TEXTURE_2D_ARRAY,xe.__webglTexture,i.TEXTURE0+k)}function ne(Ae,k){const xe=n.get(Ae);if(Ae.version>0&&xe.__version!==Ae.version){Ce(xe,Ae,k);return}t.bindTexture(i.TEXTURE_3D,xe.__webglTexture,i.TEXTURE0+k)}function de(Ae,k){const xe=n.get(Ae);if(Ae.version>0&&xe.__version!==Ae.version){Fe(xe,Ae,k);return}t.bindTexture(i.TEXTURE_CUBE_MAP,xe.__webglTexture,i.TEXTURE0+k)}const be={[td]:i.REPEAT,[Yl]:i.CLAMP_TO_EDGE,[nd]:i.MIRRORED_REPEAT},Te={[dr]:i.NEAREST,[i_]:i.NEAREST_MIPMAP_NEAREST,[Ql]:i.NEAREST_MIPMAP_LINEAR,[ps]:i.LINEAR,[XA]:i.LINEAR_MIPMAP_NEAREST,[za]:i.LINEAR_MIPMAP_LINEAR},ae={[GT]:i.NEVER,[WT]:i.ALWAYS,[Ay]:i.LESS,[py]:i.LEQUAL,[qT]:i.EQUAL,[HT]:i.GEQUAL,[VT]:i.GREATER,[jT]:i.NOTEQUAL};function Me(Ae,k){if(k.type===$r&&e.has("OES_texture_float_linear")===!1&&(k.magFilter===ps||k.magFilter===XA||k.magFilter===Ql||k.magFilter===za||k.minFilter===ps||k.minFilter===XA||k.minFilter===Ql||k.minFilter===za)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(Ae,i.TEXTURE_WRAP_S,be[k.wrapS]),i.texParameteri(Ae,i.TEXTURE_WRAP_T,be[k.wrapT]),(Ae===i.TEXTURE_3D||Ae===i.TEXTURE_2D_ARRAY)&&i.texParameteri(Ae,i.TEXTURE_WRAP_R,be[k.wrapR]),i.texParameteri(Ae,i.TEXTURE_MAG_FILTER,Te[k.magFilter]),i.texParameteri(Ae,i.TEXTURE_MIN_FILTER,Te[k.minFilter]),k.compareFunction&&(i.texParameteri(Ae,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(Ae,i.TEXTURE_COMPARE_FUNC,ae[k.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(k.magFilter===dr||k.minFilter!==Ql&&k.minFilter!==za||k.type===$r&&e.has("OES_texture_float_linear")===!1)return;if(k.anisotropy>1||n.get(k).__currentAnisotropy){const xe=e.get("EXT_texture_filter_anisotropic");i.texParameterf(Ae,xe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),n.get(k).__currentAnisotropy=k.anisotropy}}}function Ve(Ae,k){let xe=!1;Ae.__webglInit===void 0&&(Ae.__webglInit=!0,k.addEventListener("dispose",z));const Oe=k.source;let Ue=x.get(Oe);Ue===void 0&&(Ue={},x.set(Oe,Ue));const ee=le(k);if(ee!==Ae.__cacheKey){Ue[ee]===void 0&&(Ue[ee]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,xe=!0),Ue[ee].usedTimes++;const we=Ue[Ae.__cacheKey];we!==void 0&&(Ue[Ae.__cacheKey].usedTimes--,we.usedTimes===0&&q(k)),Ae.__cacheKey=ee,Ae.__webglTexture=Ue[ee].texture}return xe}function Ce(Ae,k,xe){let Oe=i.TEXTURE_2D;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(Oe=i.TEXTURE_2D_ARRAY),k.isData3DTexture&&(Oe=i.TEXTURE_3D);const Ue=Ve(Ae,k),ee=k.source;t.bindTexture(Oe,Ae.__webglTexture,i.TEXTURE0+xe);const we=n.get(ee);if(ee.version!==we.__version||Ue===!0){t.activeTexture(i.TEXTURE0+xe);const Re=li.getPrimaries(li.workingColorSpace),We=k.colorSpace===To?null:li.getPrimaries(k.colorSpace),Se=k.colorSpace===To||Re===We?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,k.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,k.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Se);let Le=N(k.image,!1,r.maxTextureSize);Le=Ht(k,Le);const ct=s.convert(k.format,k.colorSpace),Dt=s.convert(k.type);let It=U(k.internalFormat,ct,Dt,k.colorSpace,k.isVideoTexture);Me(Oe,k);let lt;const jt=k.mipmaps,Jt=k.isVideoTexture!==!0,In=we.__version===void 0||Ue===!0,me=ee.dataReady,Bt=j(k,Le);if(k.isDepthTexture)It=I(k.format===uu,k.type),In&&(Jt?t.texStorage2D(i.TEXTURE_2D,1,It,Le.width,Le.height):t.texImage2D(i.TEXTURE_2D,0,It,Le.width,Le.height,0,ct,Dt,null));else if(k.isDataTexture)if(jt.length>0){Jt&&In&&t.texStorage2D(i.TEXTURE_2D,Bt,It,jt[0].width,jt[0].height);for(let ot=0,Tt=jt.length;ot0){const Wt=UN(lt.width,lt.height,k.format,k.type);for(const Yt of k.layerUpdates){const pn=lt.data.subarray(Yt*Wt/lt.data.BYTES_PER_ELEMENT,(Yt+1)*Wt/lt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,Yt,lt.width,lt.height,1,ct,pn)}k.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,0,lt.width,lt.height,Le.depth,ct,lt.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,ot,It,lt.width,lt.height,Le.depth,0,lt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Jt?me&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,ot,0,0,0,lt.width,lt.height,Le.depth,ct,Dt,lt.data):t.texImage3D(i.TEXTURE_2D_ARRAY,ot,It,lt.width,lt.height,Le.depth,0,ct,Dt,lt.data)}else{Jt&&In&&t.texStorage2D(i.TEXTURE_2D,Bt,It,jt[0].width,jt[0].height);for(let ot=0,Tt=jt.length;ot0){const ot=UN(Le.width,Le.height,k.format,k.type);for(const Tt of k.layerUpdates){const Wt=Le.data.subarray(Tt*ot/Le.data.BYTES_PER_ELEMENT,(Tt+1)*ot/Le.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Tt,Le.width,Le.height,1,ct,Dt,Wt)}k.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Le.width,Le.height,Le.depth,ct,Dt,Le.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,It,Le.width,Le.height,Le.depth,0,ct,Dt,Le.data);else if(k.isData3DTexture)Jt?(In&&t.texStorage3D(i.TEXTURE_3D,Bt,It,Le.width,Le.height,Le.depth),me&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Le.width,Le.height,Le.depth,ct,Dt,Le.data)):t.texImage3D(i.TEXTURE_3D,0,It,Le.width,Le.height,Le.depth,0,ct,Dt,Le.data);else if(k.isFramebufferTexture){if(In)if(Jt)t.texStorage2D(i.TEXTURE_2D,Bt,It,Le.width,Le.height);else{let ot=Le.width,Tt=Le.height;for(let Wt=0;Wt>=1,Tt>>=1}}else if(jt.length>0){if(Jt&&In){const ot=pt(jt[0]);t.texStorage2D(i.TEXTURE_2D,Bt,It,ot.width,ot.height)}for(let ot=0,Tt=jt.length;ot0&&Bt++;const Tt=pt(ct[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Bt,jt,Tt.width,Tt.height)}for(let Tt=0;Tt<6;Tt++)if(Le){Jt?me&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Tt,0,0,0,ct[Tt].width,ct[Tt].height,It,lt,ct[Tt].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Tt,0,jt,ct[Tt].width,ct[Tt].height,0,It,lt,ct[Tt].data);for(let Wt=0;Wt>ee),Dt=Math.max(1,k.height>>ee);Ue===i.TEXTURE_3D||Ue===i.TEXTURE_2D_ARRAY?t.texImage3D(Ue,ee,We,ct,Dt,k.depth,0,we,Re,null):t.texImage2D(Ue,ee,We,ct,Dt,0,we,Re,null)}t.bindFramebuffer(i.FRAMEBUFFER,Ae),Gt(k)?l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Oe,Ue,Le.__webglTexture,0,_t(k)):(Ue===i.TEXTURE_2D||Ue>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Ue<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Oe,Ue,Le.__webglTexture,ee),t.bindFramebuffer(i.FRAMEBUFFER,null)}function je(Ae,k,xe){if(i.bindRenderbuffer(i.RENDERBUFFER,Ae),k.depthBuffer){const Oe=k.depthTexture,Ue=Oe&&Oe.isDepthTexture?Oe.type:null,ee=I(k.stencilBuffer,Ue),we=k.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Re=_t(k);Gt(k)?l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Re,ee,k.width,k.height):xe?i.renderbufferStorageMultisample(i.RENDERBUFFER,Re,ee,k.width,k.height):i.renderbufferStorage(i.RENDERBUFFER,ee,k.width,k.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,we,i.RENDERBUFFER,Ae)}else{const Oe=k.textures;for(let Ue=0;Ue{delete k.__boundDepthTexture,delete k.__depthDisposeCallback,Oe.removeEventListener("dispose",Ue)};Oe.addEventListener("dispose",Ue),k.__depthDisposeCallback=Ue}k.__boundDepthTexture=Oe}if(Ae.depthTexture&&!k.__autoAllocateDepthBuffer){if(xe)throw new Error("target.depthTexture not supported in Cube render targets");Rt(k.__webglFramebuffer,Ae)}else if(xe){k.__webglDepthbuffer=[];for(let Oe=0;Oe<6;Oe++)if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer[Oe]),k.__webglDepthbuffer[Oe]===void 0)k.__webglDepthbuffer[Oe]=i.createRenderbuffer(),je(k.__webglDepthbuffer[Oe],Ae,!1);else{const Ue=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ee=k.__webglDepthbuffer[Oe];i.bindRenderbuffer(i.RENDERBUFFER,ee),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ue,i.RENDERBUFFER,ee)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,k.__webglFramebuffer),k.__webglDepthbuffer===void 0)k.__webglDepthbuffer=i.createRenderbuffer(),je(k.__webglDepthbuffer,Ae,!1);else{const Oe=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ue=k.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Ue),i.framebufferRenderbuffer(i.FRAMEBUFFER,Oe,i.RENDERBUFFER,Ue)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ft(Ae,k,xe){const Oe=n.get(Ae);k!==void 0&&tt(Oe.__webglFramebuffer,Ae,Ae.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),xe!==void 0&&Et(Ae)}function Ut(Ae){const k=Ae.texture,xe=n.get(Ae),Oe=n.get(k);Ae.addEventListener("dispose",G);const Ue=Ae.textures,ee=Ae.isWebGLCubeRenderTarget===!0,we=Ue.length>1;if(we||(Oe.__webglTexture===void 0&&(Oe.__webglTexture=i.createTexture()),Oe.__version=k.version,a.memory.textures++),ee){xe.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)if(k.mipmaps&&k.mipmaps.length>0){xe.__webglFramebuffer[Re]=[];for(let We=0;We0){xe.__webglFramebuffer=[];for(let Re=0;Re0&&Gt(Ae)===!1){xe.__webglMultisampledFramebuffer=i.createFramebuffer(),xe.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,xe.__webglMultisampledFramebuffer);for(let Re=0;Re0)for(let We=0;We0)for(let We=0;We0){if(Gt(Ae)===!1){const k=Ae.textures,xe=Ae.width,Oe=Ae.height;let Ue=i.COLOR_BUFFER_BIT;const ee=Ae.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,we=n.get(Ae),Re=k.length>1;if(Re)for(let We=0;We0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function yt(Ae){const k=a.render.frame;m.get(Ae)!==k&&(m.set(Ae,k),Ae.update())}function Ht(Ae,k){const xe=Ae.colorSpace,Oe=Ae.format,Ue=Ae.type;return Ae.isCompressedTexture===!0||Ae.isVideoTexture===!0||xe!==Mo&&xe!==To&&(li.getTransfer(xe)===Fi?(Oe!==ks||Ue!==ra)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",xe)),k}function pt(Ae){return typeof HTMLImageElement<"u"&&Ae instanceof HTMLImageElement?(h.width=Ae.naturalWidth||Ae.width,h.height=Ae.naturalHeight||Ae.height):typeof VideoFrame<"u"&&Ae instanceof VideoFrame?(h.width=Ae.displayWidth,h.height=Ae.displayHeight):(h.width=Ae.width,h.height=Ae.height),h}this.allocateTextureUnit=ie,this.resetTextureUnits=J,this.setTexture2D=re,this.setTexture2DArray=Z,this.setTexture3D=ne,this.setTextureCube=de,this.rebindTextures=Ft,this.setupRenderTarget=Ut,this.updateRenderTargetMipmap=Ke,this.updateMultisampleRenderTarget=$t,this.setupDepthRenderbuffer=Et,this.setupFrameBufferTexture=tt,this.useMultisampledRTT=Gt}function NH(i,e){function t(n,r=To){let s;const a=li.getTransfer(r);if(n===ra)return i.UNSIGNED_BYTE;if(n===hy)return i.UNSIGNED_SHORT_4_4_4_4;if(n===fy)return i.UNSIGNED_SHORT_5_5_5_1;if(n===dy)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Hf)return i.BYTE;if(n===Wf)return i.SHORT;if(n===bl)return i.UNSIGNED_SHORT;if(n===Ns)return i.INT;if(n===Nr)return i.UNSIGNED_INT;if(n===$r)return i.FLOAT;if(n===Gs)return i.HALF_FLOAT;if(n===IT)return i.ALPHA;if(n===Pg)return i.RGB;if(n===ks)return i.RGBA;if(n===FT)return i.LUMINANCE;if(n===kT)return i.LUMINANCE_ALPHA;if(n===tu)return i.DEPTH_COMPONENT;if(n===uu)return i.DEPTH_STENCIL;if(n===Lg)return i.RED;if(n===k0)return i.RED_INTEGER;if(n===id)return i.RG;if(n===z0)return i.RG_INTEGER;if(n===G0)return i.RGBA_INTEGER;if(n===$f||n===Dh||n===Ph||n===Lh)if(a===Fi)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===$f)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Dh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ph)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Lh)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===$f)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Dh)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ph)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Lh)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ym||n===Qm||n===Km||n===Zm)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Ym)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Qm)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Km)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Zm)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Jm||n===r0||n===s0)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Jm||n===r0)return a===Fi?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===s0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===a0||n===o0||n===l0||n===u0||n===c0||n===h0||n===f0||n===d0||n===A0||n===p0||n===m0||n===g0||n===v0||n===_0)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===a0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===o0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===l0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===u0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===c0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===h0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===f0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===d0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===A0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===p0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===m0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===g0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===v0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===_0)return a===Fi?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Xf||n===$S||n===XS)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Xf)return a===Fi?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===$S)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===XS)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===zT||n===eg||n===tg||n===ng)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Xf)return s.COMPRESSED_RED_RGTC1_EXT;if(n===eg)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===tg)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ng)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===lu?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const RH={type:"move"};class P3{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new qa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new pe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new pe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new pe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new pe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const l=this._targetRay,u=this._grip,h=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(h&&e.hand){a=!0;for(const N of e.hand.values()){const C=t.getJointPose(N,n),E=this._getHandJoint(h,N);C!==null&&(E.matrix.fromArray(C.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=C.radius),E.visible=C!==null}const m=h.joints["index-finger-tip"],v=h.joints["thumb-tip"],x=m.position.distanceTo(v.position),S=.02,T=.005;h.inputState.pinching&&x>S+T?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&x<=S-T&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(RH)))}return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=s!==null),h!==null&&(h.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new qa;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const DH=` void main() { gl_Position = vec4( position, 1.0 ); @@ -3872,23 +3872,23 @@ void main() { } -}`;class LH{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new ms,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Qa({vertexShader:DH,fragmentShader:PH,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Oi(new by(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class UH extends Bc{constructor(e,t){super();const n=this;let r=null,s=1,a=null,l="local-floor",u=1,h=null,m=null,v=null,x=null,S=null,T=null;const N=new LH,C=t.getContextAttributes();let E=null,O=null;const U=[],I=[],j=new bt;let z=null;const G=new va;G.viewport=new On;const H=new va;H.viewport=new On;const q=[G,H],V=new Zz;let Q=null,J=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ce){let Fe=U[Ce];return Fe===void 0&&(Fe=new P3,U[Ce]=Fe),Fe.getTargetRaySpace()},this.getControllerGrip=function(Ce){let Fe=U[Ce];return Fe===void 0&&(Fe=new P3,U[Ce]=Fe),Fe.getGripSpace()},this.getHand=function(Ce){let Fe=U[Ce];return Fe===void 0&&(Fe=new P3,U[Ce]=Fe),Fe.getHandSpace()};function ne(Ce){const Fe=I.indexOf(Ce.inputSource);if(Fe===-1)return;const et=U[Fe];et!==void 0&&(et.update(Ce.inputSource,Ce.frame,h||a),et.dispatchEvent({type:Ce.type,data:Ce.inputSource}))}function oe(){r.removeEventListener("select",ne),r.removeEventListener("selectstart",ne),r.removeEventListener("selectend",ne),r.removeEventListener("squeeze",ne),r.removeEventListener("squeezestart",ne),r.removeEventListener("squeezeend",ne),r.removeEventListener("end",oe),r.removeEventListener("inputsourceschange",ie);for(let Ce=0;Ce=0&&(I[He]=null,U[He].disconnect(et))}for(let Fe=0;Fe=I.length){I.push(et),He=Et;break}else if(I[Et]===null){I[Et]=et,He=Et;break}if(He===-1)break}const Rt=U[He];Rt&&Rt.connect(et)}}const Z=new me,te=new me;function de(Ce,Fe,et){Z.setFromMatrixPosition(Fe.matrixWorld),te.setFromMatrixPosition(et.matrixWorld);const He=Z.distanceTo(te),Rt=Fe.projectionMatrix.elements,Et=et.projectionMatrix.elements,zt=Rt[14]/(Rt[10]-1),Pt=Rt[14]/(Rt[10]+1),We=(Rt[9]+1)/Rt[5],ft=(Rt[9]-1)/Rt[5],fe=(Rt[8]-1)/Rt[0],Wt=(Et[8]+1)/Et[0],yt=zt*fe,Gt=zt*Wt,_t=He/(-fe+Wt),Xt=_t*-fe;if(Fe.matrixWorld.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.translateX(Xt),Ce.translateZ(_t),Ce.matrixWorld.compose(Ce.position,Ce.quaternion,Ce.scale),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert(),Rt[10]===-1)Ce.projectionMatrix.copy(Fe.projectionMatrix),Ce.projectionMatrixInverse.copy(Fe.projectionMatrixInverse);else{const pt=zt+_t,Ae=Pt+_t,k=yt-Xt,be=Gt+(He-Xt),Oe=We*Pt/Ae*pt,pe=ft*Pt/Ae*pt;Ce.projectionMatrix.makePerspective(k,be,Oe,pe,pt,Ae),Ce.projectionMatrixInverse.copy(Ce.projectionMatrix).invert()}}function Se(Ce,Fe){Fe===null?Ce.matrixWorld.copy(Ce.matrix):Ce.matrixWorld.multiplyMatrices(Fe.matrixWorld,Ce.matrix),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert()}this.updateCamera=function(Ce){if(r===null)return;let Fe=Ce.near,et=Ce.far;N.texture!==null&&(N.depthNear>0&&(Fe=N.depthNear),N.depthFar>0&&(et=N.depthFar)),V.near=H.near=G.near=Fe,V.far=H.far=G.far=et,(Q!==V.near||J!==V.far)&&(r.updateRenderState({depthNear:V.near,depthFar:V.far}),Q=V.near,J=V.far),G.layers.mask=Ce.layers.mask|2,H.layers.mask=Ce.layers.mask|4,V.layers.mask=G.layers.mask|H.layers.mask;const He=Ce.parent,Rt=V.cameras;Se(V,He);for(let Et=0;Et0&&(C.alphaTest.value=E.alphaTest);const O=e.get(E),U=O.envMap,I=O.envMapRotation;U&&(C.envMap.value=U,yf.copy(I),yf.x*=-1,yf.y*=-1,yf.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(yf.y*=-1,yf.z*=-1),C.envMapRotation.value.setFromMatrix4(BH.makeRotationFromEuler(yf)),C.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,C.reflectivity.value=E.reflectivity,C.ior.value=E.ior,C.refractionRatio.value=E.refractionRatio),E.lightMap&&(C.lightMap.value=E.lightMap,C.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,C.lightMapTransform)),E.aoMap&&(C.aoMap.value=E.aoMap,C.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,C.aoMapTransform))}function a(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform))}function l(C,E){C.dashSize.value=E.dashSize,C.totalSize.value=E.dashSize+E.gapSize,C.scale.value=E.scale}function u(C,E,O,U){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.size.value=E.size*O,C.scale.value=U*.5,E.map&&(C.map.value=E.map,t(E.map,C.uvTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function h(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.rotation.value=E.rotation,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function m(C,E){C.specular.value.copy(E.specular),C.shininess.value=Math.max(E.shininess,1e-4)}function v(C,E){E.gradientMap&&(C.gradientMap.value=E.gradientMap)}function x(C,E){C.metalness.value=E.metalness,E.metalnessMap&&(C.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,C.metalnessMapTransform)),C.roughness.value=E.roughness,E.roughnessMap&&(C.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,C.roughnessMapTransform)),E.envMap&&(C.envMapIntensity.value=E.envMapIntensity)}function S(C,E,O){C.ior.value=E.ior,E.sheen>0&&(C.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),C.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(C.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,C.sheenColorMapTransform)),E.sheenRoughnessMap&&(C.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,C.sheenRoughnessMapTransform))),E.clearcoat>0&&(C.clearcoat.value=E.clearcoat,C.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(C.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,C.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(C.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,C.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(C.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,C.clearcoatNormalMapTransform),C.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===or&&C.clearcoatNormalScale.value.negate())),E.dispersion>0&&(C.dispersion.value=E.dispersion),E.iridescence>0&&(C.iridescence.value=E.iridescence,C.iridescenceIOR.value=E.iridescenceIOR,C.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],C.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(C.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,C.iridescenceMapTransform)),E.iridescenceThicknessMap&&(C.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,C.iridescenceThicknessMapTransform))),E.transmission>0&&(C.transmission.value=E.transmission,C.transmissionSamplerMap.value=O.texture,C.transmissionSamplerSize.value.set(O.width,O.height),E.transmissionMap&&(C.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,C.transmissionMapTransform)),C.thickness.value=E.thickness,E.thicknessMap&&(C.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,C.thicknessMapTransform)),C.attenuationDistance.value=E.attenuationDistance,C.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(C.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(C.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,C.anisotropyMapTransform))),C.specularIntensity.value=E.specularIntensity,C.specularColor.value.copy(E.specularColor),E.specularColorMap&&(C.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,C.specularColorMapTransform)),E.specularIntensityMap&&(C.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,C.specularIntensityMapTransform))}function T(C,E){E.matcap&&(C.matcap.value=E.matcap)}function N(C,E){const O=e.get(E).light;C.referencePosition.value.setFromMatrixPosition(O.matrixWorld),C.nearDistance.value=O.shadow.camera.near,C.farDistance.value=O.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function IH(i,e,t,n){let r={},s={},a=[];const l=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(O,U){const I=U.program;n.uniformBlockBinding(O,I)}function h(O,U){let I=r[O.id];I===void 0&&(T(O),I=m(O),r[O.id]=I,O.addEventListener("dispose",C));const j=U.program;n.updateUBOMapping(O,j);const z=e.render.frame;s[O.id]!==z&&(x(O),s[O.id]=z)}function m(O){const U=v();O.__bindingPointIndex=U;const I=i.createBuffer(),j=O.__size,z=O.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,j,z),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,U,I),I}function v(){for(let O=0;O0&&(I+=j-z),O.__size=I,O.__cache={},this}function N(O){const U={boundary:0,storage:0};return typeof O=="number"||typeof O=="boolean"?(U.boundary=4,U.storage=4):O.isVector2?(U.boundary=8,U.storage=8):O.isVector3||O.isColor?(U.boundary=16,U.storage=12):O.isVector4?(U.boundary=16,U.storage=16):O.isMatrix3?(U.boundary=48,U.storage=48):O.isMatrix4?(U.boundary=64,U.storage=64):O.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",O),U}function C(O){const U=O.target;U.removeEventListener("dispose",C);const I=a.indexOf(U.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[U.id]),delete r[U.id],delete s[U.id]}function E(){for(const O in r)i.deleteBuffer(r[O]);a=[],r={},s={}}return{bind:u,update:h,dispose:E}}class FH{constructor(e={}){const{canvas:t=q7(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:l=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:h=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:v=!1,reverseDepthBuffer:x=!1}=e;this.isWebGLRenderer=!0;let S;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");S=n.getContextAttributes().alpha}else S=a;const T=new Uint32Array(4),N=new Int32Array(4);let C=null,E=null;const O=[],U=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=bn,this.toneMapping=Ya,this.toneMappingExposure=1;const I=this;let j=!1,z=0,G=0,H=null,q=-1,V=null;const Q=new On,J=new On;let ne=null;const oe=new cn(0);let ie=0,Z=t.width,te=t.height,de=1,Se=null,Te=null;const ae=new On(0,0,Z,te),Me=new On(0,0,Z,te);let Ve=!1;const Ce=new Og;let Fe=!1,et=!1;this.transmissionResolutionScale=1;const He=new jn,Rt=new jn,Et=new me,zt=new On,Pt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let We=!1;function ft(){return H===null?de:1}let fe=n;function Wt(ce,Ge){return t.getContext(ce,Ge)}try{const ce={alpha:!0,depth:r,stencil:s,antialias:l,premultipliedAlpha:u,preserveDrawingBuffer:h,powerPreference:m,failIfMajorPerformanceCaveat:v};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${F0}`),t.addEventListener("webglcontextlost",Tt,!1),t.addEventListener("webglcontextrestored",Ht,!1),t.addEventListener("webglcontextcreationerror",Yt,!1),fe===null){const Ge="webgl2";if(fe=Wt(Ge,ce),fe===null)throw Wt(Ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ce){throw console.error("THREE.WebGLRenderer: "+ce.message),ce}let yt,Gt,_t,Xt,pt,Ae,k,be,Oe,pe,le,Ne,De,Je,we,Ue,ut,Dt,Bt,ct,jt,Jt,In,ge;function Ot(){yt=new $V(fe),yt.init(),Jt=new NH(fe,yt),Gt=new GV(fe,yt,e,Jt),_t=new EH(fe,yt),Gt.reverseDepthBuffer&&x&&_t.buffers.depth.setReversed(!0),Xt=new QV(fe),pt=new AH,Ae=new CH(fe,yt,_t,pt,Gt,Jt,Xt),k=new VV(I),be=new WV(I),Oe=new iG(fe),In=new kV(fe,Oe),pe=new XV(fe,Oe,Xt,In),le=new ZV(fe,pe,Oe,Xt),Bt=new KV(fe,Gt,Ae),Ue=new qV(pt),Ne=new dH(I,k,be,yt,Gt,In,Ue),De=new OH(I,pt),Je=new mH,we=new bH(yt),Dt=new FV(I,k,be,_t,le,S,u),ut=new TH(I,le,Gt),ge=new IH(fe,Xt,Gt,_t),ct=new zV(fe,yt,Xt),jt=new YV(fe,yt,Xt),Xt.programs=Ne.programs,I.capabilities=Gt,I.extensions=yt,I.properties=pt,I.renderLists=Je,I.shadowMap=ut,I.state=_t,I.info=Xt}Ot();const ot=new UH(I,fe);this.xr=ot,this.getContext=function(){return fe},this.getContextAttributes=function(){return fe.getContextAttributes()},this.forceContextLoss=function(){const ce=yt.get("WEBGL_lose_context");ce&&ce.loseContext()},this.forceContextRestore=function(){const ce=yt.get("WEBGL_lose_context");ce&&ce.restoreContext()},this.getPixelRatio=function(){return de},this.setPixelRatio=function(ce){ce!==void 0&&(de=ce,this.setSize(Z,te,!1))},this.getSize=function(ce){return ce.set(Z,te)},this.setSize=function(ce,Ge,rt=!0){if(ot.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Z=ce,te=Ge,t.width=Math.floor(ce*de),t.height=Math.floor(Ge*de),rt===!0&&(t.style.width=ce+"px",t.style.height=Ge+"px"),this.setViewport(0,0,ce,Ge)},this.getDrawingBufferSize=function(ce){return ce.set(Z*de,te*de).floor()},this.setDrawingBufferSize=function(ce,Ge,rt){Z=ce,te=Ge,de=rt,t.width=Math.floor(ce*rt),t.height=Math.floor(Ge*rt),this.setViewport(0,0,ce,Ge)},this.getCurrentViewport=function(ce){return ce.copy(Q)},this.getViewport=function(ce){return ce.copy(ae)},this.setViewport=function(ce,Ge,rt,it){ce.isVector4?ae.set(ce.x,ce.y,ce.z,ce.w):ae.set(ce,Ge,rt,it),_t.viewport(Q.copy(ae).multiplyScalar(de).round())},this.getScissor=function(ce){return ce.copy(Me)},this.setScissor=function(ce,Ge,rt,it){ce.isVector4?Me.set(ce.x,ce.y,ce.z,ce.w):Me.set(ce,Ge,rt,it),_t.scissor(J.copy(Me).multiplyScalar(de).round())},this.getScissorTest=function(){return Ve},this.setScissorTest=function(ce){_t.setScissorTest(Ve=ce)},this.setOpaqueSort=function(ce){Se=ce},this.setTransparentSort=function(ce){Te=ce},this.getClearColor=function(ce){return ce.copy(Dt.getClearColor())},this.setClearColor=function(){Dt.setClearColor.apply(Dt,arguments)},this.getClearAlpha=function(){return Dt.getClearAlpha()},this.setClearAlpha=function(){Dt.setClearAlpha.apply(Dt,arguments)},this.clear=function(ce=!0,Ge=!0,rt=!0){let it=0;if(ce){let qe=!1;if(H!==null){const qt=H.texture.format;qe=qt===G0||qt===z0||qt===k0}if(qe){const qt=H.texture.type,Qt=qt===ra||qt===Nr||qt===bl||qt===lu||qt===hy||qt===fy,he=Dt.getClearColor(),X=Dt.getClearAlpha(),tt=he.r,en=he.g,sn=he.b;Qt?(T[0]=tt,T[1]=en,T[2]=sn,T[3]=X,fe.clearBufferuiv(fe.COLOR,0,T)):(N[0]=tt,N[1]=en,N[2]=sn,N[3]=X,fe.clearBufferiv(fe.COLOR,0,N))}else it|=fe.COLOR_BUFFER_BIT}Ge&&(it|=fe.DEPTH_BUFFER_BIT),rt&&(it|=fe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),fe.clear(it)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Tt,!1),t.removeEventListener("webglcontextrestored",Ht,!1),t.removeEventListener("webglcontextcreationerror",Yt,!1),Dt.dispose(),Je.dispose(),we.dispose(),pt.dispose(),k.dispose(),be.dispose(),le.dispose(),In.dispose(),ge.dispose(),Ne.dispose(),ot.dispose(),ot.removeEventListener("sessionstart",Ze),ot.removeEventListener("sessionend",dt),Vt.stop()};function Tt(ce){ce.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),j=!0}function Ht(){console.log("THREE.WebGLRenderer: Context Restored."),j=!1;const ce=Xt.autoReset,Ge=ut.enabled,rt=ut.autoUpdate,it=ut.needsUpdate,qe=ut.type;Ot(),Xt.autoReset=ce,ut.enabled=Ge,ut.autoUpdate=rt,ut.needsUpdate=it,ut.type=qe}function Yt(ce){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ce.statusMessage)}function pn(ce){const Ge=ce.target;Ge.removeEventListener("dispose",pn),$e(Ge)}function $e(ce){St(ce),pt.remove(ce)}function St(ce){const Ge=pt.get(ce).programs;Ge!==void 0&&(Ge.forEach(function(rt){Ne.releaseProgram(rt)}),ce.isShaderMaterial&&Ne.releaseShaderCache(ce))}this.renderBufferDirect=function(ce,Ge,rt,it,qe,qt){Ge===null&&(Ge=Pt);const Qt=qe.isMesh&&qe.matrixWorld.determinant()<0,he=lr(ce,Ge,rt,it,qe);_t.setMaterial(it,Qt);let X=rt.index,tt=1;if(it.wireframe===!0){if(X=pe.getWireframeAttribute(rt),X===void 0)return;tt=2}const en=rt.drawRange,sn=rt.attributes.position;let Tn=en.start*tt,Rn=(en.start+en.count)*tt;qt!==null&&(Tn=Math.max(Tn,qt.start*tt),Rn=Math.min(Rn,(qt.start+qt.count)*tt)),X!==null?(Tn=Math.max(Tn,0),Rn=Math.min(Rn,X.count)):sn!=null&&(Tn=Math.max(Tn,0),Rn=Math.min(Rn,sn.count));const xi=Rn-Tn;if(xi<0||xi===1/0)return;In.setup(qe,it,he,rt,X);let K,hn=ct;if(X!==null&&(K=Oe.get(X),hn=jt,hn.setIndex(K)),qe.isMesh)it.wireframe===!0?(_t.setLineWidth(it.wireframeLinewidth*ft()),hn.setMode(fe.LINES)):hn.setMode(fe.TRIANGLES);else if(qe.isLine){let Zt=it.linewidth;Zt===void 0&&(Zt=1),_t.setLineWidth(Zt*ft()),qe.isLineSegments?hn.setMode(fe.LINES):qe.isLineLoop?hn.setMode(fe.LINE_LOOP):hn.setMode(fe.LINE_STRIP)}else qe.isPoints?hn.setMode(fe.POINTS):qe.isSprite&&hn.setMode(fe.TRIANGLES);if(qe.isBatchedMesh)if(qe._multiDrawInstances!==null)hn.renderMultiDrawInstances(qe._multiDrawStarts,qe._multiDrawCounts,qe._multiDrawCount,qe._multiDrawInstances);else if(yt.get("WEBGL_multi_draw"))hn.renderMultiDraw(qe._multiDrawStarts,qe._multiDrawCounts,qe._multiDrawCount);else{const Zt=qe._multiDrawStarts,gr=qe._multiDrawCounts,ui=qe._multiDrawCount,vr=X?Oe.get(X).bytesPerElement:1,Ps=pt.get(it).currentProgram.getUniforms();for(let ys=0;ys{function qt(){if(it.forEach(function(Qt){pt.get(Qt).currentProgram.isReady()&&it.delete(Qt)}),it.size===0){qe(ce);return}setTimeout(qt,10)}yt.get("KHR_parallel_shader_compile")!==null?qt():setTimeout(qt,10)})};let wn=null;function qn(ce){wn&&wn(ce)}function Ze(){Vt.stop()}function dt(){Vt.start()}const Vt=new fD;Vt.setAnimationLoop(qn),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(ce){wn=ce,ot.setAnimationLoop(ce),ce===null?Vt.stop():Vt.start()},ot.addEventListener("sessionstart",Ze),ot.addEventListener("sessionend",dt),this.render=function(ce,Ge){if(Ge!==void 0&&Ge.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(j===!0)return;if(ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),Ge.parent===null&&Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),ot.enabled===!0&&ot.isPresenting===!0&&(ot.cameraAutoUpdate===!0&&ot.updateCamera(Ge),Ge=ot.getCamera()),ce.isScene===!0&&ce.onBeforeRender(I,ce,Ge,H),E=we.get(ce,U.length),E.init(Ge),U.push(E),Rt.multiplyMatrices(Ge.projectionMatrix,Ge.matrixWorldInverse),Ce.setFromProjectionMatrix(Rt),et=this.localClippingEnabled,Fe=Ue.init(this.clippingPlanes,et),C=Je.get(ce,O.length),C.init(),O.push(C),ot.enabled===!0&&ot.isPresenting===!0){const qt=I.xr.getDepthSensingMesh();qt!==null&&xt(qt,Ge,-1/0,I.sortObjects)}xt(ce,Ge,0,I.sortObjects),C.finish(),I.sortObjects===!0&&C.sort(Se,Te),We=ot.enabled===!1||ot.isPresenting===!1||ot.hasDepthSensing()===!1,We&&Dt.addToRenderList(C,ce),this.info.render.frame++,Fe===!0&&Ue.beginShadows();const rt=E.state.shadowsArray;ut.render(rt,ce,Ge),Fe===!0&&Ue.endShadows(),this.info.autoReset===!0&&this.info.reset();const it=C.opaque,qe=C.transmissive;if(E.setupLights(),Ge.isArrayCamera){const qt=Ge.cameras;if(qe.length>0)for(let Qt=0,he=qt.length;Qt0&&ee(it,qe,ce,Ge),We&&Dt.render(ce),A(C,ce,Ge);H!==null&&G===0&&(Ae.updateMultisampleRenderTarget(H),Ae.updateRenderTargetMipmap(H)),ce.isScene===!0&&ce.onAfterRender(I,ce,Ge),In.resetDefaultState(),q=-1,V=null,U.pop(),U.length>0?(E=U[U.length-1],Fe===!0&&Ue.setGlobalState(I.clippingPlanes,E.state.camera)):E=null,O.pop(),O.length>0?C=O[O.length-1]:C=null};function xt(ce,Ge,rt,it){if(ce.visible===!1)return;if(ce.layers.test(Ge.layers)){if(ce.isGroup)rt=ce.renderOrder;else if(ce.isLOD)ce.autoUpdate===!0&&ce.update(Ge);else if(ce.isLight)E.pushLight(ce),ce.castShadow&&E.pushShadow(ce);else if(ce.isSprite){if(!ce.frustumCulled||Ce.intersectsSprite(ce)){it&&zt.setFromMatrixPosition(ce.matrixWorld).applyMatrix4(Rt);const Qt=le.update(ce),he=ce.material;he.visible&&C.push(ce,Qt,he,rt,zt.z,null)}}else if((ce.isMesh||ce.isLine||ce.isPoints)&&(!ce.frustumCulled||Ce.intersectsObject(ce))){const Qt=le.update(ce),he=ce.material;if(it&&(ce.boundingSphere!==void 0?(ce.boundingSphere===null&&ce.computeBoundingSphere(),zt.copy(ce.boundingSphere.center)):(Qt.boundingSphere===null&&Qt.computeBoundingSphere(),zt.copy(Qt.boundingSphere.center)),zt.applyMatrix4(ce.matrixWorld).applyMatrix4(Rt)),Array.isArray(he)){const X=Qt.groups;for(let tt=0,en=X.length;tt0&&Vn(qe,Ge,rt),qt.length>0&&Vn(qt,Ge,rt),Qt.length>0&&Vn(Qt,Ge,rt),_t.buffers.depth.setTest(!0),_t.buffers.depth.setMask(!0),_t.buffers.color.setMask(!0),_t.setPolygonOffset(!1)}function ee(ce,Ge,rt,it){if((rt.isScene===!0?rt.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[it.id]===void 0&&(E.state.transmissionRenderTarget[it.id]=new Fh(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")||yt.has("EXT_color_buffer_float")?Gs:ra,minFilter:za,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:li.workingColorSpace}));const qt=E.state.transmissionRenderTarget[it.id],Qt=it.viewport||Q;qt.setSize(Qt.z*I.transmissionResolutionScale,Qt.w*I.transmissionResolutionScale);const he=I.getRenderTarget();I.setRenderTarget(qt),I.getClearColor(oe),ie=I.getClearAlpha(),ie<1&&I.setClearColor(16777215,.5),I.clear(),We&&Dt.render(rt);const X=I.toneMapping;I.toneMapping=Ya;const tt=it.viewport;if(it.viewport!==void 0&&(it.viewport=void 0),E.setupLightsView(it),Fe===!0&&Ue.setGlobalState(I.clippingPlanes,it),Vn(ce,rt,it),Ae.updateMultisampleRenderTarget(qt),Ae.updateRenderTargetMipmap(qt),yt.has("WEBGL_multisampled_render_to_texture")===!1){let en=!1;for(let sn=0,Tn=Ge.length;sn0),sn=!!rt.morphAttributes.position,Tn=!!rt.morphAttributes.normal,Rn=!!rt.morphAttributes.color;let xi=Ya;it.toneMapped&&(H===null||H.isXRRenderTarget===!0)&&(xi=I.toneMapping);const K=rt.morphAttributes.position||rt.morphAttributes.normal||rt.morphAttributes.color,hn=K!==void 0?K.length:0,Zt=pt.get(it),gr=E.state.lights;if(Fe===!0&&(et===!0||ce!==V)){const _r=ce===V&&it.id===q;Ue.setState(it,ce,_r)}let ui=!1;it.version===Zt.__version?(Zt.needsLights&&Zt.lightsStateVersion!==gr.state.version||Zt.outputColorSpace!==he||qe.isBatchedMesh&&Zt.batching===!1||!qe.isBatchedMesh&&Zt.batching===!0||qe.isBatchedMesh&&Zt.batchingColor===!0&&qe.colorTexture===null||qe.isBatchedMesh&&Zt.batchingColor===!1&&qe.colorTexture!==null||qe.isInstancedMesh&&Zt.instancing===!1||!qe.isInstancedMesh&&Zt.instancing===!0||qe.isSkinnedMesh&&Zt.skinning===!1||!qe.isSkinnedMesh&&Zt.skinning===!0||qe.isInstancedMesh&&Zt.instancingColor===!0&&qe.instanceColor===null||qe.isInstancedMesh&&Zt.instancingColor===!1&&qe.instanceColor!==null||qe.isInstancedMesh&&Zt.instancingMorph===!0&&qe.morphTexture===null||qe.isInstancedMesh&&Zt.instancingMorph===!1&&qe.morphTexture!==null||Zt.envMap!==X||it.fog===!0&&Zt.fog!==qt||Zt.numClippingPlanes!==void 0&&(Zt.numClippingPlanes!==Ue.numPlanes||Zt.numIntersection!==Ue.numIntersection)||Zt.vertexAlphas!==tt||Zt.vertexTangents!==en||Zt.morphTargets!==sn||Zt.morphNormals!==Tn||Zt.morphColors!==Rn||Zt.toneMapping!==xi||Zt.morphTargetsCount!==hn)&&(ui=!0):(ui=!0,Zt.__version=it.version);let vr=Zt.currentProgram;ui===!0&&(vr=$n(it,Ge,qe));let Ps=!1,ys=!1,Vr=!1;const Di=vr.getUniforms(),sr=Zt.uniforms;if(_t.useProgram(vr.program)&&(Ps=!0,ys=!0,Vr=!0),it.id!==q&&(q=it.id,ys=!0),Ps||V!==ce){_t.buffers.depth.getReversed()?(He.copy(ce.projectionMatrix),Nk(He),Rk(He),Di.setValue(fe,"projectionMatrix",He)):Di.setValue(fe,"projectionMatrix",ce.projectionMatrix),Di.setValue(fe,"viewMatrix",ce.matrixWorldInverse);const Jr=Di.map.cameraPosition;Jr!==void 0&&Jr.setValue(fe,Et.setFromMatrixPosition(ce.matrixWorld)),Gt.logarithmicDepthBuffer&&Di.setValue(fe,"logDepthBufFC",2/(Math.log(ce.far+1)/Math.LN2)),(it.isMeshPhongMaterial||it.isMeshToonMaterial||it.isMeshLambertMaterial||it.isMeshBasicMaterial||it.isMeshStandardMaterial||it.isShaderMaterial)&&Di.setValue(fe,"isOrthographic",ce.isOrthographicCamera===!0),V!==ce&&(V=ce,ys=!0,Vr=!0)}if(qe.isSkinnedMesh){Di.setOptional(fe,qe,"bindMatrix"),Di.setOptional(fe,qe,"bindMatrixInverse");const _r=qe.skeleton;_r&&(_r.boneTexture===null&&_r.computeBoneTexture(),Di.setValue(fe,"boneTexture",_r.boneTexture,Ae))}qe.isBatchedMesh&&(Di.setOptional(fe,qe,"batchingTexture"),Di.setValue(fe,"batchingTexture",qe._matricesTexture,Ae),Di.setOptional(fe,qe,"batchingIdTexture"),Di.setValue(fe,"batchingIdTexture",qe._indirectTexture,Ae),Di.setOptional(fe,qe,"batchingColorTexture"),qe._colorsTexture!==null&&Di.setValue(fe,"batchingColorTexture",qe._colorsTexture,Ae));const bi=rt.morphAttributes;if((bi.position!==void 0||bi.normal!==void 0||bi.color!==void 0)&&Bt.update(qe,rt,vr),(ys||Zt.receiveShadow!==qe.receiveShadow)&&(Zt.receiveShadow=qe.receiveShadow,Di.setValue(fe,"receiveShadow",qe.receiveShadow)),it.isMeshGouraudMaterial&&it.envMap!==null&&(sr.envMap.value=X,sr.flipEnvMap.value=X.isCubeTexture&&X.isRenderTargetTexture===!1?-1:1),it.isMeshStandardMaterial&&it.envMap===null&&Ge.environment!==null&&(sr.envMapIntensity.value=Ge.environmentIntensity),ys&&(Di.setValue(fe,"toneMappingExposure",I.toneMappingExposure),Zt.needsLights&&an(sr,Vr),qt&&it.fog===!0&&De.refreshFogUniforms(sr,qt),De.refreshMaterialUniforms(sr,it,de,te,E.state.transmissionRenderTarget[ce.id]),zv.upload(fe,dn(Zt),sr,Ae)),it.isShaderMaterial&&it.uniformsNeedUpdate===!0&&(zv.upload(fe,dn(Zt),sr,Ae),it.uniformsNeedUpdate=!1),it.isSpriteMaterial&&Di.setValue(fe,"center",qe.center),Di.setValue(fe,"modelViewMatrix",qe.modelViewMatrix),Di.setValue(fe,"normalMatrix",qe.normalMatrix),Di.setValue(fe,"modelMatrix",qe.matrixWorld),it.isShaderMaterial||it.isRawShaderMaterial){const _r=it.uniformsGroups;for(let Jr=0,Gc=_r.length;Jr0&&Ae.useMultisampledRTT(ce)===!1?qe=pt.get(ce).__webglMultisampledFramebuffer:Array.isArray(en)?qe=en[rt]:qe=en,Q.copy(ce.viewport),J.copy(ce.scissor),ne=ce.scissorTest}else Q.copy(ae).multiplyScalar(de).floor(),J.copy(Me).multiplyScalar(de).floor(),ne=Ve;if(rt!==0&&(qe=Er),_t.bindFramebuffer(fe.FRAMEBUFFER,qe)&&it&&_t.drawBuffers(ce,qe),_t.viewport(Q),_t.scissor(J),_t.setScissorTest(ne),qt){const X=pt.get(ce.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,X.__webglTexture,rt)}else if(Qt){const X=pt.get(ce.texture),tt=Ge;fe.framebufferTextureLayer(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,X.__webglTexture,rt,tt)}else if(ce!==null&&rt!==0){const X=pt.get(ce.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_2D,X.__webglTexture,rt)}q=-1},this.readRenderTargetPixels=function(ce,Ge,rt,it,qe,qt,Qt){if(!(ce&&ce.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let he=pt.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&Qt!==void 0&&(he=he[Qt]),he){_t.bindFramebuffer(fe.FRAMEBUFFER,he);try{const X=ce.texture,tt=X.format,en=X.type;if(!Gt.textureFormatReadable(tt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Gt.textureTypeReadable(en)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ge>=0&&Ge<=ce.width-it&&rt>=0&&rt<=ce.height-qe&&fe.readPixels(Ge,rt,it,qe,Jt.convert(tt),Jt.convert(en),qt)}finally{const X=H!==null?pt.get(H).__webglFramebuffer:null;_t.bindFramebuffer(fe.FRAMEBUFFER,X)}}},this.readRenderTargetPixelsAsync=async function(ce,Ge,rt,it,qe,qt,Qt){if(!(ce&&ce.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let he=pt.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&Qt!==void 0&&(he=he[Qt]),he){const X=ce.texture,tt=X.format,en=X.type;if(!Gt.textureFormatReadable(tt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Gt.textureTypeReadable(en))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(Ge>=0&&Ge<=ce.width-it&&rt>=0&&rt<=ce.height-qe){_t.bindFramebuffer(fe.FRAMEBUFFER,he);const sn=fe.createBuffer();fe.bindBuffer(fe.PIXEL_PACK_BUFFER,sn),fe.bufferData(fe.PIXEL_PACK_BUFFER,qt.byteLength,fe.STREAM_READ),fe.readPixels(Ge,rt,it,qe,Jt.convert(tt),Jt.convert(en),0);const Tn=H!==null?pt.get(H).__webglFramebuffer:null;_t.bindFramebuffer(fe.FRAMEBUFFER,Tn);const Rn=fe.fenceSync(fe.SYNC_GPU_COMMANDS_COMPLETE,0);return fe.flush(),await Ck(fe,Rn,4),fe.bindBuffer(fe.PIXEL_PACK_BUFFER,sn),fe.getBufferSubData(fe.PIXEL_PACK_BUFFER,0,qt),fe.deleteBuffer(sn),fe.deleteSync(Rn),qt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(ce,Ge=null,rt=0){ce.isTexture!==!0&&(Uf("WebGLRenderer: copyFramebufferToTexture function signature has changed."),Ge=arguments[0]||null,ce=arguments[1]);const it=Math.pow(2,-rt),qe=Math.floor(ce.image.width*it),qt=Math.floor(ce.image.height*it),Qt=Ge!==null?Ge.x:0,he=Ge!==null?Ge.y:0;Ae.setTexture2D(ce,0),fe.copyTexSubImage2D(fe.TEXTURE_2D,rt,0,0,Qt,he,qe,qt),_t.unbindTexture()};const Wi=fe.createFramebuffer(),No=fe.createFramebuffer();this.copyTextureToTexture=function(ce,Ge,rt=null,it=null,qe=0,qt=null){ce.isTexture!==!0&&(Uf("WebGLRenderer: copyTextureToTexture function signature has changed."),it=arguments[0]||null,ce=arguments[1],Ge=arguments[2],qt=arguments[3]||0,rt=null),qt===null&&(qe!==0?(Uf("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),qt=qe,qe=0):qt=0);let Qt,he,X,tt,en,sn,Tn,Rn,xi;const K=ce.isCompressedTexture?ce.mipmaps[qt]:ce.image;if(rt!==null)Qt=rt.max.x-rt.min.x,he=rt.max.y-rt.min.y,X=rt.isBox3?rt.max.z-rt.min.z:1,tt=rt.min.x,en=rt.min.y,sn=rt.isBox3?rt.min.z:0;else{const bi=Math.pow(2,-qe);Qt=Math.floor(K.width*bi),he=Math.floor(K.height*bi),ce.isDataArrayTexture?X=K.depth:ce.isData3DTexture?X=Math.floor(K.depth*bi):X=1,tt=0,en=0,sn=0}it!==null?(Tn=it.x,Rn=it.y,xi=it.z):(Tn=0,Rn=0,xi=0);const hn=Jt.convert(Ge.format),Zt=Jt.convert(Ge.type);let gr;Ge.isData3DTexture?(Ae.setTexture3D(Ge,0),gr=fe.TEXTURE_3D):Ge.isDataArrayTexture||Ge.isCompressedArrayTexture?(Ae.setTexture2DArray(Ge,0),gr=fe.TEXTURE_2D_ARRAY):(Ae.setTexture2D(Ge,0),gr=fe.TEXTURE_2D),fe.pixelStorei(fe.UNPACK_FLIP_Y_WEBGL,Ge.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ge.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,Ge.unpackAlignment);const ui=fe.getParameter(fe.UNPACK_ROW_LENGTH),vr=fe.getParameter(fe.UNPACK_IMAGE_HEIGHT),Ps=fe.getParameter(fe.UNPACK_SKIP_PIXELS),ys=fe.getParameter(fe.UNPACK_SKIP_ROWS),Vr=fe.getParameter(fe.UNPACK_SKIP_IMAGES);fe.pixelStorei(fe.UNPACK_ROW_LENGTH,K.width),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,K.height),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,tt),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,en),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,sn);const Di=ce.isDataArrayTexture||ce.isData3DTexture,sr=Ge.isDataArrayTexture||Ge.isData3DTexture;if(ce.isDepthTexture){const bi=pt.get(ce),_r=pt.get(Ge),Jr=pt.get(bi.__renderTarget),Gc=pt.get(_r.__renderTarget);_t.bindFramebuffer(fe.READ_FRAMEBUFFER,Jr.__webglFramebuffer),_t.bindFramebuffer(fe.DRAW_FRAMEBUFFER,Gc.__webglFramebuffer);for(let xs=0;xs=-1&&AA.z<=1&&T.layers.test(C.layers)===!0,O=T.element;O.style.display=E===!0?"":"none",E===!0&&(T.onBeforeRender(t,N,C),O.style.transform="translate("+-100*T.center.x+"%,"+-100*T.center.y+"%)translate("+(AA.x*s+s)+"px,"+(-AA.y*a+a)+"px)",O.parentNode!==u&&u.appendChild(O),T.onAfterRender(t,N,C));const U={distanceToCameraSquared:v(C,T)};l.objects.set(T,U)}for(let E=0,O=T.children.length;E=e||G<0||v&&H>=s}function E(){var z=L3();if(C(z))return O(z);l=setTimeout(E,N(z))}function O(z){return l=void 0,x&&n?S(z):(n=r=void 0,a)}function U(){l!==void 0&&clearTimeout(l),h=0,n=u=r=l=void 0}function I(){return l===void 0?a:O(L3())}function j(){var z=L3(),G=C(z);if(n=arguments,r=this,u=z,G){if(l===void 0)return T(u);if(v)return clearTimeout(l),l=setTimeout(E,e),S(u)}return l===void 0&&(l=setTimeout(E,e)),a}return j.cancel=U,j.flush=I,j}function f5(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),vm=function(){return performance.now()},wy=(function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=vm()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(i[t],i[t-1],t-n):s(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},_D=(function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i})(),rw=new wy,la=(function(){function i(e,t){t===void 0&&(t=rw),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=os.Linear.None,this._interpolationFunction=iw.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=_D.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=vm()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,s){for(var a in n){var l=e[a],u=Array.isArray(l),h=u?"array":typeof l,m=!u&&Array.isArray(n[a]);if(!(h==="undefined"||h==="function")){if(m){var v=n[a];if(v.length===0)continue;for(var x=[l],S=0,T=v.length;S"u"||s)&&(t[a]=l),u||(t[a]*=1),m?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=vm()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=vm()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;ea)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,eh)return 1;var C=Math.trunc(l/u),E=l-C*u,O=Math.min(E/n._duration,1);return O===0&&l===n._duration?1:O},v=m(),x=this._easingFunction(v);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,x),this._onUpdateCallback&&this._onUpdateCallback(this._object,v),this._duration===0||l>=this._duration)if(this._repeat>0){var S=Math.min(Math.trunc((l-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=S);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*S,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var T=0,N=this._chainedTweens.length;T=(T=(u+v)/2))?u=T:v=T,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C,s=a,!(a=a[G=z<<2|j<<1|I]))return s[G]=l,i;if(E=+i._x.call(null,a.data),O=+i._y.call(null,a.data),U=+i._z.call(null,a.data),e===E&&t===O&&n===U)return l.next=a,s?s[G]=l:i._root=l,i;do s=s?s[G]=new Array(8):i._root=new Array(8),(I=e>=(T=(u+v)/2))?u=T:v=T,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C;while((G=z<<2|j<<1|I)===(H=(U>=C)<<2|(O>=N)<<1|E>=T));return s[H]=a,s[G]=l,i}function bW(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),n=new Float64Array(e),r=new Float64Array(e);let s=1/0,a=1/0,l=1/0,u=-1/0,h=-1/0,m=-1/0;for(let v=0,x,S,T,N;vu&&(u=S),Th&&(h=T),Nm&&(m=N));if(s>u||a>h||l>m)return this;this.cover(s,a,l).cover(u,h,m);for(let v=0;vi||i>=a||r>e||e>=l||s>t||t>=u;)switch(x=(tT||(h=U.y0)>N||(m=U.z0)>C||(v=U.x1)=G)<<2|(e>=z)<<1|i>=j)&&(U=E[E.length-1],E[E.length-1]=E[E.length-1-I],E[E.length-1-I]=U)}else{var H=i-+this._x.call(null,O.data),q=e-+this._y.call(null,O.data),V=t-+this._z.call(null,O.data),Q=H*H+q*q+V*V;if(QMath.sqrt((i-n)**2+(e-r)**2+(t-s)**2);function CW(i,e,t,n){const r=[],s=i-n,a=e-n,l=t-n,u=i+n,h=e+n,m=t+n;return this.visit((v,x,S,T,N,C,E)=>{if(!v.length)do{const O=v.data;EW(i,e,t,this._x(O),this._y(O),this._z(O))<=n&&r.push(O)}while(v=v.next);return x>u||S>h||T>m||N=(N=(a+h)/2))?a=N:h=N,(U=S>=(C=(l+m)/2))?l=C:m=C,(I=T>=(E=(u+v)/2))?u=E:v=E,e=t,!(t=t[j=I<<2|U<<1|O]))return this;if(!t.length)break;(e[j+1&7]||e[j+2&7]||e[j+3&7]||e[j+4&7]||e[j+5&7]||e[j+6&7]||e[j+7&7])&&(n=e,z=j)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[j]=s:delete e[j],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[z]=t:this._root=t),this):(this._root=s,this)}function RW(i){for(var e=0,t=i.length;ee?1:i>=e?0:NaN}function GW(i,e){return i==null||e==null?NaN:ei?1:e>=i?0:NaN}function bD(i){let e,t,n;i.length!==2?(e=Gv,t=(l,u)=>Gv(i(l),u),n=(l,u)=>i(l)-u):(e=i===Gv||i===GW?i:qW,t=i,n=i);function r(l,u,h=0,m=l.length){if(h>>1;t(l[v],u)<0?h=v+1:m=v}while(h>>1;t(l[v],u)<=0?h=v+1:m=v}while(hh&&n(l[v-1],u)>-n(l[v],u)?v-1:v}return{left:r,center:a,right:s}}function qW(){return 0}function VW(i){return i===null?NaN:+i}const jW=bD(Gv),SD=jW.right;bD(VW).center;function h_(i,e){let t,n;if(e===void 0)for(const r of i)r!=null&&(t===void 0?r>=r&&(t=n=r):(t>r&&(t=r),n=s&&(t=n=s):(t>s&&(t=s),n0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,s=r-(a-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(r=s*2,n=a+r,r==n-a&&(a=n))}return a}}const HW=Math.sqrt(50),WW=Math.sqrt(10),$W=Math.sqrt(2);function f_(i,e,t){const n=(e-i)/Math.max(0,t),r=Math.floor(Math.log10(n)),s=n/Math.pow(10,r),a=s>=HW?10:s>=WW?5:s>=$W?2:1;let l,u,h;return r<0?(h=Math.pow(10,-r)/a,l=Math.round(i*h),u=Math.round(e*h),l/he&&--u,h=-h):(h=Math.pow(10,r)*a,l=Math.round(i/h),u=Math.round(e/h),l*he&&--u),u0))return[];if(i===e)return[i];const n=e=r))return[];const l=s-r+1,u=new Array(l);if(n)if(a<0)for(let h=0;h=n)&&(t=n);return t}function KW(i,e){let t=0,n=0;if(e===void 0)for(let r of i)r!=null&&(r=+r)>=r&&(++t,n+=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*ZW(i){for(const e of i)yield*e}function og(i){return Array.from(ZW(i))}function zA(i,e,t){i=+i,e=+e,t=(r=arguments.length)<2?(e=i,i=0,1):r<3?1:+t;for(var n=-1,r=Math.max(0,Math.ceil((e-i)/t))|0,s=new Array(r);++n>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?$2(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?$2(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=t$.exec(i))?new Va(e[1],e[2],e[3],1):(e=n$.exec(i))?new Va(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=i$.exec(i))?$2(e[1],e[2],e[3],e[4]):(e=r$.exec(i))?$2(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=s$.exec(i))?y5(e[1],e[2]/100,e[3]/100,1):(e=a$.exec(i))?y5(e[1],e[2]/100,e[3]/100,e[4]):A5.hasOwnProperty(i)?g5(A5[i]):i==="transparent"?new Va(NaN,NaN,NaN,0):null}function g5(i){return new Va(i>>16&255,i>>8&255,i&255,1)}function $2(i,e,t,n){return n<=0&&(i=e=t=NaN),new Va(i,e,t,n)}function u$(i){return i instanceof Fg||(i=sd(i)),i?(i=i.rgb(),new Va(i.r,i.g,i.b,i.opacity)):new Va}function aw(i,e,t,n){return arguments.length===1?u$(i):new Va(i,e,t,n??1)}function Va(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}fM(Va,aw,TD(Fg,{brighter(i){return i=i==null?d_:Math.pow(d_,i),new Va(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?lg:Math.pow(lg,i),new Va(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new Va(Yf(this.r),Yf(this.g),Yf(this.b),A_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:v5,formatHex:v5,formatHex8:c$,formatRgb:_5,toString:_5}));function v5(){return`#${Gf(this.r)}${Gf(this.g)}${Gf(this.b)}`}function c$(){return`#${Gf(this.r)}${Gf(this.g)}${Gf(this.b)}${Gf((isNaN(this.opacity)?1:this.opacity)*255)}`}function _5(){const i=A_(this.opacity);return`${i===1?"rgb(":"rgba("}${Yf(this.r)}, ${Yf(this.g)}, ${Yf(this.b)}${i===1?")":`, ${i})`}`}function A_(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function Yf(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function Gf(i){return i=Yf(i),(i<16?"0":"")+i.toString(16)}function y5(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new xl(i,e,t,n)}function MD(i){if(i instanceof xl)return new xl(i.h,i.s,i.l,i.opacity);if(i instanceof Fg||(i=sd(i)),!i)return new xl;if(i instanceof xl)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,r=Math.min(e,t,n),s=Math.max(e,t,n),a=NaN,l=s-r,u=(s+r)/2;return l?(e===s?a=(t-n)/l+(t0&&u<1?0:a,new xl(a,l,u,i.opacity)}function h$(i,e,t,n){return arguments.length===1?MD(i):new xl(i,e,t,n??1)}function xl(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}fM(xl,h$,TD(Fg,{brighter(i){return i=i==null?d_:Math.pow(d_,i),new xl(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?lg:Math.pow(lg,i),new xl(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,r=2*t-n;return new Va(U3(i>=240?i-240:i+120,r,n),U3(i,r,n),U3(i<120?i+240:i-120,r,n),this.opacity)},clamp(){return new xl(x5(this.h),X2(this.s),X2(this.l),A_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=A_(this.opacity);return`${i===1?"hsl(":"hsla("}${x5(this.h)}, ${X2(this.s)*100}%, ${X2(this.l)*100}%${i===1?")":`, ${i})`}`}}));function x5(i){return i=(i||0)%360,i<0?i+360:i}function X2(i){return Math.max(0,Math.min(1,i||0))}function U3(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const dM=i=>()=>i;function f$(i,e){return function(t){return i+t*e}}function d$(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function A$(i){return(i=+i)==1?ED:function(e,t){return t-e?d$(e,t,i):dM(isNaN(e)?t:e)}}function ED(i,e){var t=e-i;return t?f$(i,t):dM(isNaN(i)?e:i)}const b5=(function i(e){var t=A$(e);function n(r,s){var a=t((r=aw(r)).r,(s=aw(s)).r),l=t(r.g,s.g),u=t(r.b,s.b),h=ED(r.opacity,s.opacity);return function(m){return r.r=a(m),r.g=l(m),r.b=u(m),r.opacity=h(m),r+""}}return n.gamma=i,n})(1);function CD(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),r;return function(s){for(r=0;rt&&(s=e.slice(t,s),l[a]?l[a]+=s:l[++a]=s),(n=n[0])===(r=r[0])?l[a]?l[a]+=r:l[++a]=r:(l[++a]=null,u.push({i:a,x:cg(n,r)})),t=B3.lastIndex;return te&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function T$(i,e,t){var n=i[0],r=i[1],s=e[0],a=e[1];return r2?M$:T$,u=h=null,v}function v(x){return x==null||isNaN(x=+x)?s:(u||(u=l(i.map(n),e,t)))(n(a(x)))}return v.invert=function(x){return a(r((h||(h=l(e,i.map(n),cg)))(x)))},v.domain=function(x){return arguments.length?(i=Array.from(x,S$),m()):i.slice()},v.range=function(x){return arguments.length?(e=Array.from(x),m()):e.slice()},v.rangeRound=function(x){return e=Array.from(x),t=x$,m()},v.clamp=function(x){return arguments.length?(a=x?!0:GA,m()):a!==GA},v.interpolate=function(x){return arguments.length?(t=x,m()):t},v.unknown=function(x){return arguments.length?(s=x,v):s},function(x,S){return n=x,r=S,m()}}function N$(){return C$()(GA,GA)}function R$(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function p_(i,e){if(!isFinite(i)||i===0)return null;var t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"),n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function S0(i){return i=p_(Math.abs(i)),i?i[1]:NaN}function D$(i,e){return function(t,n){for(var r=t.length,s=[],a=0,l=i[0],u=0;r>0&&l>0&&(u+l+1>n&&(l=Math.max(1,n-u)),s.push(t.substring(r-=l,r+l)),!((u+=l+1)>n));)l=i[a=(a+1)%i.length];return s.reverse().join(e)}}function P$(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var L$=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function m_(i){if(!(e=L$.exec(i)))throw new Error("invalid format: "+i);var e;return new pM({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}m_.prototype=pM.prototype;function pM(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}pM.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function U$(i){e:for(var e=i.length,t=1,n=-1,r;t0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(r+1):i}var g_;function B$(i,e){var t=p_(i,e);if(!t)return g_=void 0,i.toPrecision(e);var n=t[0],r=t[1],s=r-(g_=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+p_(i,Math.max(0,e+s-1))[0]}function w5(i,e){var t=p_(i,e);if(!t)return i+"";var n=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}const T5={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:R$,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>w5(i*100,e),r:w5,s:B$,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function M5(i){return i}var E5=Array.prototype.map,C5=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function O$(i){var e=i.grouping===void 0||i.thousands===void 0?M5:D$(E5.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",r=i.decimal===void 0?".":i.decimal+"",s=i.numerals===void 0?M5:P$(E5.call(i.numerals,String)),a=i.percent===void 0?"%":i.percent+"",l=i.minus===void 0?"−":i.minus+"",u=i.nan===void 0?"NaN":i.nan+"";function h(v,x){v=m_(v);var S=v.fill,T=v.align,N=v.sign,C=v.symbol,E=v.zero,O=v.width,U=v.comma,I=v.precision,j=v.trim,z=v.type;z==="n"?(U=!0,z="g"):T5[z]||(I===void 0&&(I=12),j=!0,z="g"),(E||S==="0"&&T==="=")&&(E=!0,S="0",T="=");var G=(x&&x.prefix!==void 0?x.prefix:"")+(C==="$"?t:C==="#"&&/[boxX]/.test(z)?"0"+z.toLowerCase():""),H=(C==="$"?n:/[%p]/.test(z)?a:"")+(x&&x.suffix!==void 0?x.suffix:""),q=T5[z],V=/[defgprs%]/.test(z);I=I===void 0?6:/[gprs]/.test(z)?Math.max(1,Math.min(21,I)):Math.max(0,Math.min(20,I));function Q(J){var ne=G,oe=H,ie,Z,te;if(z==="c")oe=q(J)+oe,J="";else{J=+J;var de=J<0||1/J<0;if(J=isNaN(J)?u:q(Math.abs(J),I),j&&(J=U$(J)),de&&+J==0&&N!=="+"&&(de=!1),ne=(de?N==="("?N:l:N==="-"||N==="("?"":N)+ne,oe=(z==="s"&&!isNaN(J)&&g_!==void 0?C5[8+g_/3]:"")+oe+(de&&N==="("?")":""),V){for(ie=-1,Z=J.length;++iete||te>57){oe=(te===46?r+J.slice(ie+1):J.slice(ie))+oe,J=J.slice(0,ie);break}}}U&&!E&&(J=e(J,1/0));var Se=ne.length+J.length+oe.length,Te=Se>1)+ne+J+oe+Te.slice(Se);break;default:J=Te+ne+J+oe;break}return s(J)}return Q.toString=function(){return v+""},Q}function m(v,x){var S=Math.max(-8,Math.min(8,Math.floor(S0(x)/3)))*3,T=Math.pow(10,-S),N=h((v=m_(v),v.type="f",v),{suffix:C5[8+S/3]});return function(C){return N(T*C)}}return{format:h,formatPrefix:m}}var Y2,DD,PD;I$({thousands:",",grouping:[3],currency:["$",""]});function I$(i){return Y2=O$(i),DD=Y2.format,PD=Y2.formatPrefix,Y2}function F$(i){return Math.max(0,-S0(Math.abs(i)))}function k$(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(S0(e)/3)))*3-S0(Math.abs(i)))}function z$(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,S0(e)-S0(i))+1}function G$(i,e,t,n){var r=YW(i,e,t),s;switch(n=m_(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(s=k$(r,a))&&(n.precision=s),PD(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=z$(r,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=F$(r))&&(n.precision=s-(n.type==="%")*2);break}}return DD(n)}function LD(i){var e=i.domain;return i.ticks=function(t){var n=e();return XW(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var r=e();return G$(r[0],r[r.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),r=0,s=n.length-1,a=n[r],l=n[s],u,h,m=10;for(l0;){if(h=sw(a,l,t),h===u)return n[r]=a,n[s]=l,e(n);if(h>0)a=Math.floor(a/h)*h,l=Math.ceil(l/h)*h;else if(h<0)a=Math.ceil(a*h)/h,l=Math.floor(l*h)/h;else break;u=h}return i},i}function Ec(){var i=N$();return i.copy=function(){return E$(i,Ec())},wD.apply(i,arguments),LD(i)}function UD(){var i=0,e=1,t=1,n=[.5],r=[0,1],s;function a(u){return u!=null&&u<=u?r[SD(n,u,0,t)]:s}function l(){var u=-1;for(n=new Array(t);++u=t?[n[t-1],e]:[n[h-1],n[h]]},a.unknown=function(u){return arguments.length&&(s=u),a},a.thresholds=function(){return n.slice()},a.copy=function(){return UD().domain([i,e]).range(r).unknown(s)},wD.apply(LD(a),arguments)}var di=1e-6,v_=1e-12,Mi=Math.PI,ja=Mi/2,__=Mi/4,Eo=Mi*2,Fr=180/Mi,Yn=Mi/180,Zi=Math.abs,mM=Math.atan,Qo=Math.atan2,ni=Math.cos,Q2=Math.ceil,q$=Math.exp,uw=Math.hypot,V$=Math.log,Hn=Math.sin,j$=Math.sign||function(i){return i>0?1:i<0?-1:0},Cc=Math.sqrt,H$=Math.tan;function W$(i){return i>1?0:i<-1?Mi:Math.acos(i)}function Nc(i){return i>1?ja:i<-1?-ja:Math.asin(i)}function N5(i){return(i=Hn(i/2))*i}function na(){}function y_(i,e){i&&D5.hasOwnProperty(i.type)&&D5[i.type](i,e)}var R5={Feature:function(i,e){y_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n=0?1:-1,r=n*t,s=ni(e),a=Hn(e),l=dw*a,u=fw*s+l*ni(r),h=l*n*Hn(r);x_.add(Qo(h,u)),hw=i,fw=s,dw=a}function b_(i){return[Qo(i[1],i[0]),Nc(i[2])]}function ad(i){var e=i[0],t=i[1],n=ni(t);return[n*ni(e),n*Hn(e),Hn(t)]}function K2(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function w0(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function O3(i,e){i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}function Z2(i,e){return[i[0]*e,i[1]*e,i[2]*e]}function S_(i){var e=Cc(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);i[0]/=e,i[1]/=e,i[2]/=e}var Cr,ka,Or,bo,Df,FD,kD,ZA,Nm,wh,Dc,Ac={point:Aw,lineStart:U5,lineEnd:B5,polygonStart:function(){Ac.point=GD,Ac.lineStart=Q$,Ac.lineEnd=K$,Nm=new bc,Rc.polygonStart()},polygonEnd:function(){Rc.polygonEnd(),Ac.point=Aw,Ac.lineStart=U5,Ac.lineEnd=B5,x_<0?(Cr=-(Or=180),ka=-(bo=90)):Nm>di?bo=90:Nm<-di&&(ka=-90),Dc[0]=Cr,Dc[1]=Or},sphere:function(){Cr=-(Or=180),ka=-(bo=90)}};function Aw(i,e){wh.push(Dc=[Cr=i,Or=i]),ebo&&(bo=e)}function zD(i,e){var t=ad([i*Yn,e*Yn]);if(ZA){var n=w0(ZA,t),r=[n[1],-n[0],0],s=w0(r,n);S_(s),s=b_(s);var a=i-Df,l=a>0?1:-1,u=s[0]*Fr*l,h,m=Zi(a)>180;m^(l*Dfbo&&(bo=h)):(u=(u+360)%360-180,m^(l*Dfbo&&(bo=e))),m?i_o(Cr,Or)&&(Or=i):_o(i,Or)>_o(Cr,Or)&&(Cr=i):Or>=Cr?(iOr&&(Or=i)):i>Df?_o(Cr,i)>_o(Cr,Or)&&(Or=i):_o(i,Or)>_o(Cr,Or)&&(Cr=i)}else wh.push(Dc=[Cr=i,Or=i]);ebo&&(bo=e),ZA=t,Df=i}function U5(){Ac.point=zD}function B5(){Dc[0]=Cr,Dc[1]=Or,Ac.point=Aw,ZA=null}function GD(i,e){if(ZA){var t=i-Df;Nm.add(Zi(t)>180?t+(t>0?360:-360):t)}else FD=i,kD=e;Rc.point(i,e),zD(i,e)}function Q$(){Rc.lineStart()}function K$(){GD(FD,kD),Rc.lineEnd(),Zi(Nm)>di&&(Cr=-(Or=180)),Dc[0]=Cr,Dc[1]=Or,ZA=null}function _o(i,e){return(e-=i)<0?e+360:e}function Z$(i,e){return i[0]-e[0]}function O5(i,e){return i[0]<=i[1]?i[0]<=e&&e<=i[1]:e_o(n[0],n[1])&&(n[1]=r[1]),_o(r[0],n[1])>_o(n[0],n[1])&&(n[0]=r[0])):s.push(n=r);for(a=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=r,++e)r=s[e],(l=_o(n[1],r[0]))>a&&(a=l,Cr=r[0],Or=n[1])}return wh=Dc=null,Cr===1/0||ka===1/0?[[NaN,NaN],[NaN,NaN]]:[[Cr,ka],[Or,bo]]}var _m,w_,T_,M_,E_,C_,N_,R_,pw,mw,gw,VD,jD,_a,ya,xa,Sl={sphere:na,point:gM,lineStart:I5,lineEnd:F5,polygonStart:function(){Sl.lineStart=tX,Sl.lineEnd=nX},polygonEnd:function(){Sl.lineStart=I5,Sl.lineEnd=F5}};function gM(i,e){i*=Yn,e*=Yn;var t=ni(e);kg(t*ni(i),t*Hn(i),Hn(e))}function kg(i,e,t){++_m,T_+=(i-T_)/_m,M_+=(e-M_)/_m,E_+=(t-E_)/_m}function I5(){Sl.point=J$}function J$(i,e){i*=Yn,e*=Yn;var t=ni(e);_a=t*ni(i),ya=t*Hn(i),xa=Hn(e),Sl.point=eX,kg(_a,ya,xa)}function eX(i,e){i*=Yn,e*=Yn;var t=ni(e),n=t*ni(i),r=t*Hn(i),s=Hn(e),a=Qo(Cc((a=ya*s-xa*r)*a+(a=xa*n-_a*s)*a+(a=_a*r-ya*n)*a),_a*n+ya*r+xa*s);w_+=a,C_+=a*(_a+(_a=n)),N_+=a*(ya+(ya=r)),R_+=a*(xa+(xa=s)),kg(_a,ya,xa)}function F5(){Sl.point=gM}function tX(){Sl.point=iX}function nX(){HD(VD,jD),Sl.point=gM}function iX(i,e){VD=i,jD=e,i*=Yn,e*=Yn,Sl.point=HD;var t=ni(e);_a=t*ni(i),ya=t*Hn(i),xa=Hn(e),kg(_a,ya,xa)}function HD(i,e){i*=Yn,e*=Yn;var t=ni(e),n=t*ni(i),r=t*Hn(i),s=Hn(e),a=ya*s-xa*r,l=xa*n-_a*s,u=_a*r-ya*n,h=uw(a,l,u),m=Nc(h),v=h&&-m/h;pw.add(v*a),mw.add(v*l),gw.add(v*u),w_+=m,C_+=m*(_a+(_a=n)),N_+=m*(ya+(ya=r)),R_+=m*(xa+(xa=s)),kg(_a,ya,xa)}function k5(i){_m=w_=T_=M_=E_=C_=N_=R_=0,pw=new bc,mw=new bc,gw=new bc,Ty(i,Sl);var e=+pw,t=+mw,n=+gw,r=uw(e,t,n);return rMi&&(i-=Math.round(i/Eo)*Eo),[i,e]}_w.invert=_w;function WD(i,e,t){return(i%=Eo)?e||t?vw(G5(i),q5(e,t)):G5(i):e||t?q5(e,t):_w}function z5(i){return function(e,t){return e+=i,Zi(e)>Mi&&(e-=Math.round(e/Eo)*Eo),[e,t]}}function G5(i){var e=z5(i);return e.invert=z5(-i),e}function q5(i,e){var t=ni(i),n=Hn(i),r=ni(e),s=Hn(e);function a(l,u){var h=ni(u),m=ni(l)*h,v=Hn(l)*h,x=Hn(u),S=x*t+m*n;return[Qo(v*r-S*s,m*t-x*n),Nc(S*r+v*s)]}return a.invert=function(l,u){var h=ni(u),m=ni(l)*h,v=Hn(l)*h,x=Hn(u),S=x*r-v*s;return[Qo(v*r+x*s,m*t+S*n),Nc(S*t-m*n)]},a}function rX(i){i=WD(i[0]*Yn,i[1]*Yn,i.length>2?i[2]*Yn:0);function e(t){return t=i(t[0]*Yn,t[1]*Yn),t[0]*=Fr,t[1]*=Fr,t}return e.invert=function(t){return t=i.invert(t[0]*Yn,t[1]*Yn),t[0]*=Fr,t[1]*=Fr,t},e}function sX(i,e,t,n,r,s){if(t){var a=ni(e),l=Hn(e),u=n*t;r==null?(r=e+n*Eo,s=e-u/2):(r=V5(a,r),s=V5(a,s),(n>0?rs)&&(r+=n*Eo));for(var h,m=r;n>0?m>s:m1&&i.push(i.pop().concat(i.shift()))},result:function(){var t=i;return i=[],e=null,t}}}function qv(i,e){return Zi(i[0]-e[0])=0;--l)r.point((v=m[l])[0],v[1]);else n(x.x,x.p.x,-1,r);x=x.p}x=x.o,m=x.z,S=!S}while(!x.v);r.lineEnd()}}}function j5(i){if(e=i.length){for(var e,t=0,n=i[0],r;++t=0?1:-1,V=q*H,Q=V>Mi,J=C*z;if(u.add(Qo(J*q*Hn(V),E*G+J*ni(V))),a+=Q?H+q*Eo:H,Q^T>=t^I>=t){var ne=w0(ad(S),ad(U));S_(ne);var oe=w0(s,ne);S_(oe);var ie=(Q^H>=0?-1:1)*Nc(oe[2]);(n>ie||n===ie&&(ne[0]||ne[1]))&&(l+=Q^H>=0?1:-1)}}return(a<-di||a0){for(u||(r.polygonStart(),u=!0),r.lineStart(),z=0;z1&&I&2&&j.push(j.pop().concat(j.shift())),m.push(j.filter(aX))}}return x}}function aX(i){return i.length>1}function oX(i,e){return((i=i.x)[0]<0?i[1]-ja-di:ja-i[1])-((e=e.x)[0]<0?e[1]-ja-di:ja-e[1])}const H5=QD(function(){return!0},lX,cX,[-Mi,-ja]);function lX(i){var e=NaN,t=NaN,n=NaN,r;return{lineStart:function(){i.lineStart(),r=1},point:function(s,a){var l=s>0?Mi:-Mi,u=Zi(s-e);Zi(u-Mi)0?ja:-ja),i.point(n,t),i.lineEnd(),i.lineStart(),i.point(l,t),i.point(s,t),r=0):n!==l&&u>=Mi&&(Zi(e-n)di?mM((Hn(e)*(s=ni(n))*Hn(t)-Hn(n)*(r=ni(e))*Hn(i))/(r*s*a)):(e+n)/2}function cX(i,e,t,n){var r;if(i==null)r=t*ja,n.point(-Mi,r),n.point(0,r),n.point(Mi,r),n.point(Mi,0),n.point(Mi,-r),n.point(0,-r),n.point(-Mi,-r),n.point(-Mi,0),n.point(-Mi,r);else if(Zi(i[0]-e[0])>di){var s=i[0]0,r=Zi(e)>di;function s(m,v,x,S){sX(S,i,t,x,m,v)}function a(m,v){return ni(m)*ni(v)>e}function l(m){var v,x,S,T,N;return{lineStart:function(){T=S=!1,N=1},point:function(C,E){var O=[C,E],U,I=a(C,E),j=n?I?0:h(C,E):I?h(C+(C<0?Mi:-Mi),E):0;if(!v&&(T=S=I)&&m.lineStart(),I!==S&&(U=u(v,O),(!U||qv(v,U)||qv(O,U))&&(O[2]=1)),I!==S)N=0,I?(m.lineStart(),U=u(O,v),m.point(U[0],U[1])):(U=u(v,O),m.point(U[0],U[1],2),m.lineEnd()),v=U;else if(r&&v&&n^I){var z;!(j&x)&&(z=u(O,v,!0))&&(N=0,n?(m.lineStart(),m.point(z[0][0],z[0][1]),m.point(z[1][0],z[1][1]),m.lineEnd()):(m.point(z[1][0],z[1][1]),m.lineEnd(),m.lineStart(),m.point(z[0][0],z[0][1],3)))}I&&(!v||!qv(v,O))&&m.point(O[0],O[1]),v=O,S=I,x=j},lineEnd:function(){S&&m.lineEnd(),v=null},clean:function(){return N|(T&&S)<<1}}}function u(m,v,x){var S=ad(m),T=ad(v),N=[1,0,0],C=w0(S,T),E=K2(C,C),O=C[0],U=E-O*O;if(!U)return!x&&m;var I=e*E/U,j=-e*O/U,z=w0(N,C),G=Z2(N,I),H=Z2(C,j);O3(G,H);var q=z,V=K2(G,q),Q=K2(q,q),J=V*V-Q*(K2(G,G)-1);if(!(J<0)){var ne=Cc(J),oe=Z2(q,(-V-ne)/Q);if(O3(oe,G),oe=b_(oe),!x)return oe;var ie=m[0],Z=v[0],te=m[1],de=v[1],Se;Z0^oe[1]<(Zi(oe[0]-ie)Mi^(ie<=oe[0]&&oe[0]<=Z)){var Ve=Z2(q,(-V+ne)/Q);return O3(Ve,G),[oe,b_(Ve)]}}}function h(m,v){var x=n?i:Mi-i,S=0;return m<-x?S|=1:m>x&&(S|=2),v<-x?S|=4:v>x&&(S|=8),S}return QD(a,l,s,n?[0,-i]:[-Mi,i-Mi])}function fX(i,e,t,n,r,s){var a=i[0],l=i[1],u=e[0],h=e[1],m=0,v=1,x=u-a,S=h-l,T;if(T=t-a,!(!x&&T>0)){if(T/=x,x<0){if(T0){if(T>v)return;T>m&&(m=T)}if(T=r-a,!(!x&&T<0)){if(T/=x,x<0){if(T>v)return;T>m&&(m=T)}else if(x>0){if(T0)){if(T/=S,S<0){if(T0){if(T>v)return;T>m&&(m=T)}if(T=s-l,!(!S&&T<0)){if(T/=S,S<0){if(T>v)return;T>m&&(m=T)}else if(S>0){if(T0&&(i[0]=a+m*x,i[1]=l+m*S),v<1&&(e[0]=a+v*x,e[1]=l+v*S),!0}}}}}var ym=1e9,ev=-ym;function dX(i,e,t,n){function r(h,m){return i<=h&&h<=t&&e<=m&&m<=n}function s(h,m,v,x){var S=0,T=0;if(h==null||(S=a(h,v))!==(T=a(m,v))||u(h,m)<0^v>0)do x.point(S===0||S===3?i:t,S>1?n:e);while((S=(S+v+4)%4)!==T);else x.point(m[0],m[1])}function a(h,m){return Zi(h[0]-i)0?0:3:Zi(h[0]-t)0?2:1:Zi(h[1]-e)0?1:0:m>0?3:2}function l(h,m){return u(h.x,m.x)}function u(h,m){var v=a(h,1),x=a(m,1);return v!==x?v-x:v===0?m[1]-h[1]:v===1?h[0]-m[0]:v===2?h[1]-m[1]:m[0]-h[0]}return function(h){var m=h,v=$D(),x,S,T,N,C,E,O,U,I,j,z,G={point:H,lineStart:J,lineEnd:ne,polygonStart:V,polygonEnd:Q};function H(ie,Z){r(ie,Z)&&m.point(ie,Z)}function q(){for(var ie=0,Z=0,te=S.length;Zn&&(Ce-Me)*(n-Ve)>(Fe-Ve)*(i-Me)&&++ie:Fe<=n&&(Ce-Me)*(n-Ve)<(Fe-Ve)*(i-Me)&&--ie;return ie}function V(){m=v,x=[],S=[],z=!0}function Q(){var ie=q(),Z=z&&ie,te=(x=og(x)).length;(Z||te)&&(h.polygonStart(),Z&&(h.lineStart(),s(null,null,1,h),h.lineEnd()),te&&XD(x,l,ie,s,h),h.polygonEnd()),m=h,x=S=T=null}function J(){G.point=oe,S&&S.push(T=[]),j=!0,I=!1,O=U=NaN}function ne(){x&&(oe(N,C),E&&I&&v.rejoin(),x.push(v.result())),G.point=H,I&&m.lineEnd()}function oe(ie,Z){var te=r(ie,Z);if(S&&T.push([ie,Z]),j)N=ie,C=Z,E=te,j=!1,te&&(m.lineStart(),m.point(ie,Z));else if(te&&I)m.point(ie,Z);else{var de=[O=Math.max(ev,Math.min(ym,O)),U=Math.max(ev,Math.min(ym,U))],Se=[ie=Math.max(ev,Math.min(ym,ie)),Z=Math.max(ev,Math.min(ym,Z))];fX(de,Se,i,e,t,n)?(I||(m.lineStart(),m.point(de[0],de[1])),m.point(Se[0],Se[1]),te||m.lineEnd(),z=!1):te&&(m.lineStart(),m.point(ie,Z),z=!1)}O=ie,U=Z,I=te}return G}}var yw,xw,Vv,jv,T0={sphere:na,point:na,lineStart:AX,lineEnd:na,polygonStart:na,polygonEnd:na};function AX(){T0.point=mX,T0.lineEnd=pX}function pX(){T0.point=T0.lineEnd=na}function mX(i,e){i*=Yn,e*=Yn,xw=i,Vv=Hn(e),jv=ni(e),T0.point=gX}function gX(i,e){i*=Yn,e*=Yn;var t=Hn(e),n=ni(e),r=Zi(i-xw),s=ni(r),a=Hn(r),l=n*a,u=jv*t-Vv*n*s,h=Vv*t+jv*n*s;yw.add(Qo(Cc(l*l+u*u),h)),xw=i,Vv=t,jv=n}function vX(i){return yw=new bc,Ty(i,T0),+yw}var bw=[null,null],_X={type:"LineString",coordinates:bw};function kh(i,e){return bw[0]=i,bw[1]=e,vX(_X)}var W5={Feature:function(i,e){return D_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n0&&(r=kh(i[s],i[s-1]),r>0&&t<=r&&n<=r&&(t+n-r)*(1-Math.pow((t-n)/r,2))di}).map(x)).concat(zA(Q2(s/h)*h,r,h).filter(function(U){return Zi(U%v)>di}).map(S))}return E.lines=function(){return O().map(function(U){return{type:"LineString",coordinates:U}})},E.outline=function(){return{type:"Polygon",coordinates:[T(n).concat(N(a).slice(1),T(t).reverse().slice(1),N(l).reverse().slice(1))]}},E.extent=function(U){return arguments.length?E.extentMajor(U).extentMinor(U):E.extentMinor()},E.extentMajor=function(U){return arguments.length?(n=+U[0][0],t=+U[1][0],l=+U[0][1],a=+U[1][1],n>t&&(U=n,n=t,t=U),l>a&&(U=l,l=a,a=U),E.precision(C)):[[n,l],[t,a]]},E.extentMinor=function(U){return arguments.length?(e=+U[0][0],i=+U[1][0],s=+U[0][1],r=+U[1][1],e>i&&(U=e,e=i,i=U),s>r&&(U=s,s=r,r=U),E.precision(C)):[[e,s],[i,r]]},E.step=function(U){return arguments.length?E.stepMajor(U).stepMinor(U):E.stepMinor()},E.stepMajor=function(U){return arguments.length?(m=+U[0],v=+U[1],E):[m,v]},E.stepMinor=function(U){return arguments.length?(u=+U[0],h=+U[1],E):[u,h]},E.precision=function(U){return arguments.length?(C=+U,x=K5(s,r,90),S=Z5(e,i,C),T=K5(l,a,90),N=Z5(n,t,C),E):C},E.extentMajor([[-180,-90+di],[180,90-di]]).extentMinor([[-180,-80-di],[180,80+di]])}function SX(){return bX()()}function vM(i,e){var t=i[0]*Yn,n=i[1]*Yn,r=e[0]*Yn,s=e[1]*Yn,a=ni(n),l=Hn(n),u=ni(s),h=Hn(s),m=a*ni(t),v=a*Hn(t),x=u*ni(r),S=u*Hn(r),T=2*Nc(Cc(N5(s-n)+a*u*N5(r-t))),N=Hn(T),C=T?function(E){var O=Hn(E*=T)/N,U=Hn(T-E)/N,I=U*m+O*x,j=U*v+O*S,z=U*l+O*h;return[Qo(j,I)*Fr,Qo(z,Cc(I*I+j*j))*Fr]}:function(){return[t*Fr,n*Fr]};return C.distance=T,C}const J5=i=>i;var M0=1/0,P_=M0,hg=-M0,L_=hg,eR={point:wX,lineStart:na,lineEnd:na,polygonStart:na,polygonEnd:na,result:function(){var i=[[M0,P_],[hg,L_]];return hg=L_=-(P_=M0=1/0),i}};function wX(i,e){ihg&&(hg=i),eL_&&(L_=e)}function _M(i){return function(e){var t=new Sw;for(var n in i)t[n]=i[n];return t.stream=e,t}}function Sw(){}Sw.prototype={constructor:Sw,point:function(i,e){this.stream.point(i,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function yM(i,e,t){var n=i.clipExtent&&i.clipExtent();return i.scale(150).translate([0,0]),n!=null&&i.clipExtent(null),Ty(t,i.stream(eR)),e(eR.result()),n!=null&&i.clipExtent(n),i}function ZD(i,e,t){return yM(i,function(n){var r=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(r/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),l=+e[0][0]+(r-a*(n[1][0]+n[0][0]))/2,u=+e[0][1]+(s-a*(n[1][1]+n[0][1]))/2;i.scale(150*a).translate([l,u])},t)}function TX(i,e,t){return ZD(i,[[0,0],e],t)}function MX(i,e,t){return yM(i,function(n){var r=+e,s=r/(n[1][0]-n[0][0]),a=(r-s*(n[1][0]+n[0][0]))/2,l=-s*n[0][1];i.scale(150*s).translate([a,l])},t)}function EX(i,e,t){return yM(i,function(n){var r=+e,s=r/(n[1][1]-n[0][1]),a=-s*n[0][0],l=(r-s*(n[1][1]+n[0][1]))/2;i.scale(150*s).translate([a,l])},t)}var tR=16,CX=ni(30*Yn);function nR(i,e){return+e?RX(i,e):NX(i)}function NX(i){return _M({point:function(e,t){e=i(e,t),this.stream.point(e[0],e[1])}})}function RX(i,e){function t(n,r,s,a,l,u,h,m,v,x,S,T,N,C){var E=h-n,O=m-r,U=E*E+O*O;if(U>4*e&&N--){var I=a+x,j=l+S,z=u+T,G=Cc(I*I+j*j+z*z),H=Nc(z/=G),q=Zi(Zi(z)-1)e||Zi((E*ne+O*oe)/U-.5)>.3||a*x+l*S+u*T2?ie[2]%360*Yn:0,ne()):[l*Fr,u*Fr,h*Fr]},Q.angle=function(ie){return arguments.length?(v=ie%360*Yn,ne()):v*Fr},Q.reflectX=function(ie){return arguments.length?(x=ie?-1:1,ne()):x<0},Q.reflectY=function(ie){return arguments.length?(S=ie?-1:1,ne()):S<0},Q.precision=function(ie){return arguments.length?(z=nR(G,j=ie*ie),oe()):Cc(j)},Q.fitExtent=function(ie,Z){return ZD(Q,ie,Z)},Q.fitSize=function(ie,Z){return TX(Q,ie,Z)},Q.fitWidth=function(ie,Z){return MX(Q,ie,Z)},Q.fitHeight=function(ie,Z){return EX(Q,ie,Z)};function ne(){var ie=iR(t,0,0,x,S,v).apply(null,e(s,a)),Z=iR(t,n-ie[0],r-ie[1],x,S,v);return m=WD(l,u,h),G=vw(e,Z),H=vw(m,G),z=nR(G,j),oe()}function oe(){return q=V=null,Q}return function(){return e=i.apply(this,arguments),Q.invert=e.invert&&J,ne()}}function OX(i){return function(e,t){var n=Cc(e*e+t*t),r=i(n),s=Hn(r),a=ni(r);return[Qo(e*s,n*a),Nc(n&&t*s/n)]}}function xM(i,e){return[i,V$(H$((ja+e)/2))]}xM.invert=function(i,e){return[i,2*mM(q$(e))-ja]};function JD(i,e){var t=ni(e),n=1+ni(i)*t;return[t*Hn(i)/n,Hn(e)/n]}JD.invert=OX(function(i){return 2*mM(i)});function IX(){return UX(JD).scale(250).clipAngle(142)}function ww(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=0&&(I[je]=null,U[je].disconnect(tt))}for(let Fe=0;Fe=I.length){I.push(tt),je=Et;break}else if(I[Et]===null){I[Et]=tt,je=Et;break}if(je===-1)break}const Rt=U[je];Rt&&Rt.connect(tt)}}const Z=new pe,ne=new pe;function de(Ce,Fe,tt){Z.setFromMatrixPosition(Fe.matrixWorld),ne.setFromMatrixPosition(tt.matrixWorld);const je=Z.distanceTo(ne),Rt=Fe.projectionMatrix.elements,Et=tt.projectionMatrix.elements,Ft=Rt[14]/(Rt[10]-1),Ut=Rt[14]/(Rt[10]+1),Ke=(Rt[9]+1)/Rt[5],ht=(Rt[9]-1)/Rt[5],fe=(Rt[8]-1)/Rt[0],$t=(Et[8]+1)/Et[0],_t=Ft*fe,Gt=Ft*$t,yt=je/(-fe+$t),Ht=yt*-fe;if(Fe.matrixWorld.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.translateX(Ht),Ce.translateZ(yt),Ce.matrixWorld.compose(Ce.position,Ce.quaternion,Ce.scale),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert(),Rt[10]===-1)Ce.projectionMatrix.copy(Fe.projectionMatrix),Ce.projectionMatrixInverse.copy(Fe.projectionMatrixInverse);else{const pt=Ft+yt,Ae=Ut+yt,k=_t-Ht,xe=Gt+(je-Ht),Oe=Ke*Ut/Ae*pt,Ue=ht*Ut/Ae*pt;Ce.projectionMatrix.makePerspective(k,xe,Oe,Ue,pt,Ae),Ce.projectionMatrixInverse.copy(Ce.projectionMatrix).invert()}}function be(Ce,Fe){Fe===null?Ce.matrixWorld.copy(Ce.matrix):Ce.matrixWorld.multiplyMatrices(Fe.matrixWorld,Ce.matrix),Ce.matrixWorldInverse.copy(Ce.matrixWorld).invert()}this.updateCamera=function(Ce){if(r===null)return;let Fe=Ce.near,tt=Ce.far;N.texture!==null&&(N.depthNear>0&&(Fe=N.depthNear),N.depthFar>0&&(tt=N.depthFar)),V.near=H.near=G.near=Fe,V.far=H.far=G.far=tt,(Q!==V.near||J!==V.far)&&(r.updateRenderState({depthNear:V.near,depthFar:V.far}),Q=V.near,J=V.far),G.layers.mask=Ce.layers.mask|2,H.layers.mask=Ce.layers.mask|4,V.layers.mask=G.layers.mask|H.layers.mask;const je=Ce.parent,Rt=V.cameras;be(V,je);for(let Et=0;Et0&&(C.alphaTest.value=E.alphaTest);const O=e.get(E),U=O.envMap,I=O.envMapRotation;U&&(C.envMap.value=U,yf.copy(I),yf.x*=-1,yf.y*=-1,yf.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(yf.y*=-1,yf.z*=-1),C.envMapRotation.value.setFromMatrix4(BH.makeRotationFromEuler(yf)),C.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,C.reflectivity.value=E.reflectivity,C.ior.value=E.ior,C.refractionRatio.value=E.refractionRatio),E.lightMap&&(C.lightMap.value=E.lightMap,C.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,C.lightMapTransform)),E.aoMap&&(C.aoMap.value=E.aoMap,C.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,C.aoMapTransform))}function a(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform))}function l(C,E){C.dashSize.value=E.dashSize,C.totalSize.value=E.dashSize+E.gapSize,C.scale.value=E.scale}function u(C,E,O,U){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.size.value=E.size*O,C.scale.value=U*.5,E.map&&(C.map.value=E.map,t(E.map,C.uvTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function h(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.rotation.value=E.rotation,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function m(C,E){C.specular.value.copy(E.specular),C.shininess.value=Math.max(E.shininess,1e-4)}function v(C,E){E.gradientMap&&(C.gradientMap.value=E.gradientMap)}function x(C,E){C.metalness.value=E.metalness,E.metalnessMap&&(C.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,C.metalnessMapTransform)),C.roughness.value=E.roughness,E.roughnessMap&&(C.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,C.roughnessMapTransform)),E.envMap&&(C.envMapIntensity.value=E.envMapIntensity)}function S(C,E,O){C.ior.value=E.ior,E.sheen>0&&(C.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),C.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(C.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,C.sheenColorMapTransform)),E.sheenRoughnessMap&&(C.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,C.sheenRoughnessMapTransform))),E.clearcoat>0&&(C.clearcoat.value=E.clearcoat,C.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(C.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,C.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(C.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,C.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(C.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,C.clearcoatNormalMapTransform),C.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===or&&C.clearcoatNormalScale.value.negate())),E.dispersion>0&&(C.dispersion.value=E.dispersion),E.iridescence>0&&(C.iridescence.value=E.iridescence,C.iridescenceIOR.value=E.iridescenceIOR,C.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],C.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(C.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,C.iridescenceMapTransform)),E.iridescenceThicknessMap&&(C.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,C.iridescenceThicknessMapTransform))),E.transmission>0&&(C.transmission.value=E.transmission,C.transmissionSamplerMap.value=O.texture,C.transmissionSamplerSize.value.set(O.width,O.height),E.transmissionMap&&(C.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,C.transmissionMapTransform)),C.thickness.value=E.thickness,E.thicknessMap&&(C.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,C.thicknessMapTransform)),C.attenuationDistance.value=E.attenuationDistance,C.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(C.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(C.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,C.anisotropyMapTransform))),C.specularIntensity.value=E.specularIntensity,C.specularColor.value.copy(E.specularColor),E.specularColorMap&&(C.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,C.specularColorMapTransform)),E.specularIntensityMap&&(C.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,C.specularIntensityMapTransform))}function T(C,E){E.matcap&&(C.matcap.value=E.matcap)}function N(C,E){const O=e.get(E).light;C.referencePosition.value.setFromMatrixPosition(O.matrixWorld),C.nearDistance.value=O.shadow.camera.near,C.farDistance.value=O.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function IH(i,e,t,n){let r={},s={},a=[];const l=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(O,U){const I=U.program;n.uniformBlockBinding(O,I)}function h(O,U){let I=r[O.id];I===void 0&&(T(O),I=m(O),r[O.id]=I,O.addEventListener("dispose",C));const j=U.program;n.updateUBOMapping(O,j);const z=e.render.frame;s[O.id]!==z&&(x(O),s[O.id]=z)}function m(O){const U=v();O.__bindingPointIndex=U;const I=i.createBuffer(),j=O.__size,z=O.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,j,z),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,U,I),I}function v(){for(let O=0;O0&&(I+=j-z),O.__size=I,O.__cache={},this}function N(O){const U={boundary:0,storage:0};return typeof O=="number"||typeof O=="boolean"?(U.boundary=4,U.storage=4):O.isVector2?(U.boundary=8,U.storage=8):O.isVector3||O.isColor?(U.boundary=16,U.storage=12):O.isVector4?(U.boundary=16,U.storage=16):O.isMatrix3?(U.boundary=48,U.storage=48):O.isMatrix4?(U.boundary=64,U.storage=64):O.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",O),U}function C(O){const U=O.target;U.removeEventListener("dispose",C);const I=a.indexOf(U.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[U.id]),delete r[U.id],delete s[U.id]}function E(){for(const O in r)i.deleteBuffer(r[O]);a=[],r={},s={}}return{bind:u,update:h,dispose:E}}class FH{constructor(e={}){const{canvas:t=q7(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:l=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:h=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:v=!1,reverseDepthBuffer:x=!1}=e;this.isWebGLRenderer=!0;let S;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");S=n.getContextAttributes().alpha}else S=a;const T=new Uint32Array(4),N=new Int32Array(4);let C=null,E=null;const O=[],U=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=bn,this.toneMapping=Ya,this.toneMappingExposure=1;const I=this;let j=!1,z=0,G=0,H=null,q=-1,V=null;const Q=new On,J=new On;let ie=null;const le=new cn(0);let re=0,Z=t.width,ne=t.height,de=1,be=null,Te=null;const ae=new On(0,0,Z,ne),Me=new On(0,0,Z,ne);let Ve=!1;const Ce=new Og;let Fe=!1,tt=!1;this.transmissionResolutionScale=1;const je=new jn,Rt=new jn,Et=new pe,Ft=new On,Ut={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ke=!1;function ht(){return H===null?de:1}let fe=n;function $t(ce,Ge){return t.getContext(ce,Ge)}try{const ce={alpha:!0,depth:r,stencil:s,antialias:l,premultipliedAlpha:u,preserveDrawingBuffer:h,powerPreference:m,failIfMajorPerformanceCaveat:v};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${F0}`),t.addEventListener("webglcontextlost",Tt,!1),t.addEventListener("webglcontextrestored",Wt,!1),t.addEventListener("webglcontextcreationerror",Yt,!1),fe===null){const Ge="webgl2";if(fe=$t(Ge,ce),fe===null)throw $t(Ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ce){throw console.error("THREE.WebGLRenderer: "+ce.message),ce}let _t,Gt,yt,Ht,pt,Ae,k,xe,Oe,Ue,ee,we,Re,We,Se,Le,ct,Dt,It,lt,jt,Jt,In,me;function Bt(){_t=new $V(fe),_t.init(),Jt=new NH(fe,_t),Gt=new GV(fe,_t,e,Jt),yt=new EH(fe,_t),Gt.reverseDepthBuffer&&x&&yt.buffers.depth.setReversed(!0),Ht=new QV(fe),pt=new AH,Ae=new CH(fe,_t,yt,pt,Gt,Jt,Ht),k=new VV(I),xe=new WV(I),Oe=new iG(fe),In=new kV(fe,Oe),Ue=new XV(fe,Oe,Ht,In),ee=new ZV(fe,Ue,Oe,Ht),It=new KV(fe,Gt,Ae),Le=new qV(pt),we=new dH(I,k,xe,_t,Gt,In,Le),Re=new OH(I,pt),We=new mH,Se=new bH(_t),Dt=new FV(I,k,xe,yt,ee,S,u),ct=new TH(I,ee,Gt),me=new IH(fe,Ht,Gt,yt),lt=new zV(fe,_t,Ht),jt=new YV(fe,_t,Ht),Ht.programs=we.programs,I.capabilities=Gt,I.extensions=_t,I.properties=pt,I.renderLists=We,I.shadowMap=ct,I.state=yt,I.info=Ht}Bt();const ot=new UH(I,fe);this.xr=ot,this.getContext=function(){return fe},this.getContextAttributes=function(){return fe.getContextAttributes()},this.forceContextLoss=function(){const ce=_t.get("WEBGL_lose_context");ce&&ce.loseContext()},this.forceContextRestore=function(){const ce=_t.get("WEBGL_lose_context");ce&&ce.restoreContext()},this.getPixelRatio=function(){return de},this.setPixelRatio=function(ce){ce!==void 0&&(de=ce,this.setSize(Z,ne,!1))},this.getSize=function(ce){return ce.set(Z,ne)},this.setSize=function(ce,Ge,rt=!0){if(ot.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Z=ce,ne=Ge,t.width=Math.floor(ce*de),t.height=Math.floor(Ge*de),rt===!0&&(t.style.width=ce+"px",t.style.height=Ge+"px"),this.setViewport(0,0,ce,Ge)},this.getDrawingBufferSize=function(ce){return ce.set(Z*de,ne*de).floor()},this.setDrawingBufferSize=function(ce,Ge,rt){Z=ce,ne=Ge,de=rt,t.width=Math.floor(ce*rt),t.height=Math.floor(Ge*rt),this.setViewport(0,0,ce,Ge)},this.getCurrentViewport=function(ce){return ce.copy(Q)},this.getViewport=function(ce){return ce.copy(ae)},this.setViewport=function(ce,Ge,rt,it){ce.isVector4?ae.set(ce.x,ce.y,ce.z,ce.w):ae.set(ce,Ge,rt,it),yt.viewport(Q.copy(ae).multiplyScalar(de).round())},this.getScissor=function(ce){return ce.copy(Me)},this.setScissor=function(ce,Ge,rt,it){ce.isVector4?Me.set(ce.x,ce.y,ce.z,ce.w):Me.set(ce,Ge,rt,it),yt.scissor(J.copy(Me).multiplyScalar(de).round())},this.getScissorTest=function(){return Ve},this.setScissorTest=function(ce){yt.setScissorTest(Ve=ce)},this.setOpaqueSort=function(ce){be=ce},this.setTransparentSort=function(ce){Te=ce},this.getClearColor=function(ce){return ce.copy(Dt.getClearColor())},this.setClearColor=function(){Dt.setClearColor.apply(Dt,arguments)},this.getClearAlpha=function(){return Dt.getClearAlpha()},this.setClearAlpha=function(){Dt.setClearAlpha.apply(Dt,arguments)},this.clear=function(ce=!0,Ge=!0,rt=!0){let it=0;if(ce){let qe=!1;if(H!==null){const qt=H.texture.format;qe=qt===G0||qt===z0||qt===k0}if(qe){const qt=H.texture.type,Qt=qt===ra||qt===Nr||qt===bl||qt===lu||qt===hy||qt===fy,he=Dt.getClearColor(),X=Dt.getClearAlpha(),et=he.r,en=he.g,sn=he.b;Qt?(T[0]=et,T[1]=en,T[2]=sn,T[3]=X,fe.clearBufferuiv(fe.COLOR,0,T)):(N[0]=et,N[1]=en,N[2]=sn,N[3]=X,fe.clearBufferiv(fe.COLOR,0,N))}else it|=fe.COLOR_BUFFER_BIT}Ge&&(it|=fe.DEPTH_BUFFER_BIT),rt&&(it|=fe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),fe.clear(it)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Tt,!1),t.removeEventListener("webglcontextrestored",Wt,!1),t.removeEventListener("webglcontextcreationerror",Yt,!1),Dt.dispose(),We.dispose(),Se.dispose(),pt.dispose(),k.dispose(),xe.dispose(),ee.dispose(),In.dispose(),me.dispose(),we.dispose(),ot.dispose(),ot.removeEventListener("sessionstart",Je),ot.removeEventListener("sessionend",dt),Vt.stop()};function Tt(ce){ce.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),j=!0}function Wt(){console.log("THREE.WebGLRenderer: Context Restored."),j=!1;const ce=Ht.autoReset,Ge=ct.enabled,rt=ct.autoUpdate,it=ct.needsUpdate,qe=ct.type;Bt(),Ht.autoReset=ce,ct.enabled=Ge,ct.autoUpdate=rt,ct.needsUpdate=it,ct.type=qe}function Yt(ce){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ce.statusMessage)}function pn(ce){const Ge=ce.target;Ge.removeEventListener("dispose",pn),$e(Ge)}function $e(ce){St(ce),pt.remove(ce)}function St(ce){const Ge=pt.get(ce).programs;Ge!==void 0&&(Ge.forEach(function(rt){we.releaseProgram(rt)}),ce.isShaderMaterial&&we.releaseShaderCache(ce))}this.renderBufferDirect=function(ce,Ge,rt,it,qe,qt){Ge===null&&(Ge=Ut);const Qt=qe.isMesh&&qe.matrixWorld.determinant()<0,he=lr(ce,Ge,rt,it,qe);yt.setMaterial(it,Qt);let X=rt.index,et=1;if(it.wireframe===!0){if(X=Ue.getWireframeAttribute(rt),X===void 0)return;et=2}const en=rt.drawRange,sn=rt.attributes.position;let Tn=en.start*et,Rn=(en.start+en.count)*et;qt!==null&&(Tn=Math.max(Tn,qt.start*et),Rn=Math.min(Rn,(qt.start+qt.count)*et)),X!==null?(Tn=Math.max(Tn,0),Rn=Math.min(Rn,X.count)):sn!=null&&(Tn=Math.max(Tn,0),Rn=Math.min(Rn,sn.count));const xi=Rn-Tn;if(xi<0||xi===1/0)return;In.setup(qe,it,he,rt,X);let K,hn=lt;if(X!==null&&(K=Oe.get(X),hn=jt,hn.setIndex(K)),qe.isMesh)it.wireframe===!0?(yt.setLineWidth(it.wireframeLinewidth*ht()),hn.setMode(fe.LINES)):hn.setMode(fe.TRIANGLES);else if(qe.isLine){let Zt=it.linewidth;Zt===void 0&&(Zt=1),yt.setLineWidth(Zt*ht()),qe.isLineSegments?hn.setMode(fe.LINES):qe.isLineLoop?hn.setMode(fe.LINE_LOOP):hn.setMode(fe.LINE_STRIP)}else qe.isPoints?hn.setMode(fe.POINTS):qe.isSprite&&hn.setMode(fe.TRIANGLES);if(qe.isBatchedMesh)if(qe._multiDrawInstances!==null)hn.renderMultiDrawInstances(qe._multiDrawStarts,qe._multiDrawCounts,qe._multiDrawCount,qe._multiDrawInstances);else if(_t.get("WEBGL_multi_draw"))hn.renderMultiDraw(qe._multiDrawStarts,qe._multiDrawCounts,qe._multiDrawCount);else{const Zt=qe._multiDrawStarts,gr=qe._multiDrawCounts,ui=qe._multiDrawCount,vr=X?Oe.get(X).bytesPerElement:1,Ps=pt.get(it).currentProgram.getUniforms();for(let ys=0;ys{function qt(){if(it.forEach(function(Qt){pt.get(Qt).currentProgram.isReady()&&it.delete(Qt)}),it.size===0){qe(ce);return}setTimeout(qt,10)}_t.get("KHR_parallel_shader_compile")!==null?qt():setTimeout(qt,10)})};let wn=null;function qn(ce){wn&&wn(ce)}function Je(){Vt.stop()}function dt(){Vt.start()}const Vt=new fD;Vt.setAnimationLoop(qn),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(ce){wn=ce,ot.setAnimationLoop(ce),ce===null?Vt.stop():Vt.start()},ot.addEventListener("sessionstart",Je),ot.addEventListener("sessionend",dt),this.render=function(ce,Ge){if(Ge!==void 0&&Ge.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(j===!0)return;if(ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),Ge.parent===null&&Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),ot.enabled===!0&&ot.isPresenting===!0&&(ot.cameraAutoUpdate===!0&&ot.updateCamera(Ge),Ge=ot.getCamera()),ce.isScene===!0&&ce.onBeforeRender(I,ce,Ge,H),E=Se.get(ce,U.length),E.init(Ge),U.push(E),Rt.multiplyMatrices(Ge.projectionMatrix,Ge.matrixWorldInverse),Ce.setFromProjectionMatrix(Rt),tt=this.localClippingEnabled,Fe=Le.init(this.clippingPlanes,tt),C=We.get(ce,O.length),C.init(),O.push(C),ot.enabled===!0&&ot.isPresenting===!0){const qt=I.xr.getDepthSensingMesh();qt!==null&&xt(qt,Ge,-1/0,I.sortObjects)}xt(ce,Ge,0,I.sortObjects),C.finish(),I.sortObjects===!0&&C.sort(be,Te),Ke=ot.enabled===!1||ot.isPresenting===!1||ot.hasDepthSensing()===!1,Ke&&Dt.addToRenderList(C,ce),this.info.render.frame++,Fe===!0&&Le.beginShadows();const rt=E.state.shadowsArray;ct.render(rt,ce,Ge),Fe===!0&&Le.endShadows(),this.info.autoReset===!0&&this.info.reset();const it=C.opaque,qe=C.transmissive;if(E.setupLights(),Ge.isArrayCamera){const qt=Ge.cameras;if(qe.length>0)for(let Qt=0,he=qt.length;Qt0&&te(it,qe,ce,Ge),Ke&&Dt.render(ce),A(C,ce,Ge);H!==null&&G===0&&(Ae.updateMultisampleRenderTarget(H),Ae.updateRenderTargetMipmap(H)),ce.isScene===!0&&ce.onAfterRender(I,ce,Ge),In.resetDefaultState(),q=-1,V=null,U.pop(),U.length>0?(E=U[U.length-1],Fe===!0&&Le.setGlobalState(I.clippingPlanes,E.state.camera)):E=null,O.pop(),O.length>0?C=O[O.length-1]:C=null};function xt(ce,Ge,rt,it){if(ce.visible===!1)return;if(ce.layers.test(Ge.layers)){if(ce.isGroup)rt=ce.renderOrder;else if(ce.isLOD)ce.autoUpdate===!0&&ce.update(Ge);else if(ce.isLight)E.pushLight(ce),ce.castShadow&&E.pushShadow(ce);else if(ce.isSprite){if(!ce.frustumCulled||Ce.intersectsSprite(ce)){it&&Ft.setFromMatrixPosition(ce.matrixWorld).applyMatrix4(Rt);const Qt=ee.update(ce),he=ce.material;he.visible&&C.push(ce,Qt,he,rt,Ft.z,null)}}else if((ce.isMesh||ce.isLine||ce.isPoints)&&(!ce.frustumCulled||Ce.intersectsObject(ce))){const Qt=ee.update(ce),he=ce.material;if(it&&(ce.boundingSphere!==void 0?(ce.boundingSphere===null&&ce.computeBoundingSphere(),Ft.copy(ce.boundingSphere.center)):(Qt.boundingSphere===null&&Qt.computeBoundingSphere(),Ft.copy(Qt.boundingSphere.center)),Ft.applyMatrix4(ce.matrixWorld).applyMatrix4(Rt)),Array.isArray(he)){const X=Qt.groups;for(let et=0,en=X.length;et0&&Vn(qe,Ge,rt),qt.length>0&&Vn(qt,Ge,rt),Qt.length>0&&Vn(Qt,Ge,rt),yt.buffers.depth.setTest(!0),yt.buffers.depth.setMask(!0),yt.buffers.color.setMask(!0),yt.setPolygonOffset(!1)}function te(ce,Ge,rt,it){if((rt.isScene===!0?rt.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[it.id]===void 0&&(E.state.transmissionRenderTarget[it.id]=new Fh(1,1,{generateMipmaps:!0,type:_t.has("EXT_color_buffer_half_float")||_t.has("EXT_color_buffer_float")?Gs:ra,minFilter:za,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:li.workingColorSpace}));const qt=E.state.transmissionRenderTarget[it.id],Qt=it.viewport||Q;qt.setSize(Qt.z*I.transmissionResolutionScale,Qt.w*I.transmissionResolutionScale);const he=I.getRenderTarget();I.setRenderTarget(qt),I.getClearColor(le),re=I.getClearAlpha(),re<1&&I.setClearColor(16777215,.5),I.clear(),Ke&&Dt.render(rt);const X=I.toneMapping;I.toneMapping=Ya;const et=it.viewport;if(it.viewport!==void 0&&(it.viewport=void 0),E.setupLightsView(it),Fe===!0&&Le.setGlobalState(I.clippingPlanes,it),Vn(ce,rt,it),Ae.updateMultisampleRenderTarget(qt),Ae.updateRenderTargetMipmap(qt),_t.has("WEBGL_multisampled_render_to_texture")===!1){let en=!1;for(let sn=0,Tn=Ge.length;sn0),sn=!!rt.morphAttributes.position,Tn=!!rt.morphAttributes.normal,Rn=!!rt.morphAttributes.color;let xi=Ya;it.toneMapped&&(H===null||H.isXRRenderTarget===!0)&&(xi=I.toneMapping);const K=rt.morphAttributes.position||rt.morphAttributes.normal||rt.morphAttributes.color,hn=K!==void 0?K.length:0,Zt=pt.get(it),gr=E.state.lights;if(Fe===!0&&(tt===!0||ce!==V)){const _r=ce===V&&it.id===q;Le.setState(it,ce,_r)}let ui=!1;it.version===Zt.__version?(Zt.needsLights&&Zt.lightsStateVersion!==gr.state.version||Zt.outputColorSpace!==he||qe.isBatchedMesh&&Zt.batching===!1||!qe.isBatchedMesh&&Zt.batching===!0||qe.isBatchedMesh&&Zt.batchingColor===!0&&qe.colorTexture===null||qe.isBatchedMesh&&Zt.batchingColor===!1&&qe.colorTexture!==null||qe.isInstancedMesh&&Zt.instancing===!1||!qe.isInstancedMesh&&Zt.instancing===!0||qe.isSkinnedMesh&&Zt.skinning===!1||!qe.isSkinnedMesh&&Zt.skinning===!0||qe.isInstancedMesh&&Zt.instancingColor===!0&&qe.instanceColor===null||qe.isInstancedMesh&&Zt.instancingColor===!1&&qe.instanceColor!==null||qe.isInstancedMesh&&Zt.instancingMorph===!0&&qe.morphTexture===null||qe.isInstancedMesh&&Zt.instancingMorph===!1&&qe.morphTexture!==null||Zt.envMap!==X||it.fog===!0&&Zt.fog!==qt||Zt.numClippingPlanes!==void 0&&(Zt.numClippingPlanes!==Le.numPlanes||Zt.numIntersection!==Le.numIntersection)||Zt.vertexAlphas!==et||Zt.vertexTangents!==en||Zt.morphTargets!==sn||Zt.morphNormals!==Tn||Zt.morphColors!==Rn||Zt.toneMapping!==xi||Zt.morphTargetsCount!==hn)&&(ui=!0):(ui=!0,Zt.__version=it.version);let vr=Zt.currentProgram;ui===!0&&(vr=$n(it,Ge,qe));let Ps=!1,ys=!1,Vr=!1;const Di=vr.getUniforms(),sr=Zt.uniforms;if(yt.useProgram(vr.program)&&(Ps=!0,ys=!0,Vr=!0),it.id!==q&&(q=it.id,ys=!0),Ps||V!==ce){yt.buffers.depth.getReversed()?(je.copy(ce.projectionMatrix),Nk(je),Rk(je),Di.setValue(fe,"projectionMatrix",je)):Di.setValue(fe,"projectionMatrix",ce.projectionMatrix),Di.setValue(fe,"viewMatrix",ce.matrixWorldInverse);const Jr=Di.map.cameraPosition;Jr!==void 0&&Jr.setValue(fe,Et.setFromMatrixPosition(ce.matrixWorld)),Gt.logarithmicDepthBuffer&&Di.setValue(fe,"logDepthBufFC",2/(Math.log(ce.far+1)/Math.LN2)),(it.isMeshPhongMaterial||it.isMeshToonMaterial||it.isMeshLambertMaterial||it.isMeshBasicMaterial||it.isMeshStandardMaterial||it.isShaderMaterial)&&Di.setValue(fe,"isOrthographic",ce.isOrthographicCamera===!0),V!==ce&&(V=ce,ys=!0,Vr=!0)}if(qe.isSkinnedMesh){Di.setOptional(fe,qe,"bindMatrix"),Di.setOptional(fe,qe,"bindMatrixInverse");const _r=qe.skeleton;_r&&(_r.boneTexture===null&&_r.computeBoneTexture(),Di.setValue(fe,"boneTexture",_r.boneTexture,Ae))}qe.isBatchedMesh&&(Di.setOptional(fe,qe,"batchingTexture"),Di.setValue(fe,"batchingTexture",qe._matricesTexture,Ae),Di.setOptional(fe,qe,"batchingIdTexture"),Di.setValue(fe,"batchingIdTexture",qe._indirectTexture,Ae),Di.setOptional(fe,qe,"batchingColorTexture"),qe._colorsTexture!==null&&Di.setValue(fe,"batchingColorTexture",qe._colorsTexture,Ae));const bi=rt.morphAttributes;if((bi.position!==void 0||bi.normal!==void 0||bi.color!==void 0)&&It.update(qe,rt,vr),(ys||Zt.receiveShadow!==qe.receiveShadow)&&(Zt.receiveShadow=qe.receiveShadow,Di.setValue(fe,"receiveShadow",qe.receiveShadow)),it.isMeshGouraudMaterial&&it.envMap!==null&&(sr.envMap.value=X,sr.flipEnvMap.value=X.isCubeTexture&&X.isRenderTargetTexture===!1?-1:1),it.isMeshStandardMaterial&&it.envMap===null&&Ge.environment!==null&&(sr.envMapIntensity.value=Ge.environmentIntensity),ys&&(Di.setValue(fe,"toneMappingExposure",I.toneMappingExposure),Zt.needsLights&&an(sr,Vr),qt&&it.fog===!0&&Re.refreshFogUniforms(sr,qt),Re.refreshMaterialUniforms(sr,it,de,ne,E.state.transmissionRenderTarget[ce.id]),zv.upload(fe,dn(Zt),sr,Ae)),it.isShaderMaterial&&it.uniformsNeedUpdate===!0&&(zv.upload(fe,dn(Zt),sr,Ae),it.uniformsNeedUpdate=!1),it.isSpriteMaterial&&Di.setValue(fe,"center",qe.center),Di.setValue(fe,"modelViewMatrix",qe.modelViewMatrix),Di.setValue(fe,"normalMatrix",qe.normalMatrix),Di.setValue(fe,"modelMatrix",qe.matrixWorld),it.isShaderMaterial||it.isRawShaderMaterial){const _r=it.uniformsGroups;for(let Jr=0,Gc=_r.length;Jr0&&Ae.useMultisampledRTT(ce)===!1?qe=pt.get(ce).__webglMultisampledFramebuffer:Array.isArray(en)?qe=en[rt]:qe=en,Q.copy(ce.viewport),J.copy(ce.scissor),ie=ce.scissorTest}else Q.copy(ae).multiplyScalar(de).floor(),J.copy(Me).multiplyScalar(de).floor(),ie=Ve;if(rt!==0&&(qe=Er),yt.bindFramebuffer(fe.FRAMEBUFFER,qe)&&it&&yt.drawBuffers(ce,qe),yt.viewport(Q),yt.scissor(J),yt.setScissorTest(ie),qt){const X=pt.get(ce.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,X.__webglTexture,rt)}else if(Qt){const X=pt.get(ce.texture),et=Ge;fe.framebufferTextureLayer(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,X.__webglTexture,rt,et)}else if(ce!==null&&rt!==0){const X=pt.get(ce.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_2D,X.__webglTexture,rt)}q=-1},this.readRenderTargetPixels=function(ce,Ge,rt,it,qe,qt,Qt){if(!(ce&&ce.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let he=pt.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&Qt!==void 0&&(he=he[Qt]),he){yt.bindFramebuffer(fe.FRAMEBUFFER,he);try{const X=ce.texture,et=X.format,en=X.type;if(!Gt.textureFormatReadable(et)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Gt.textureTypeReadable(en)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ge>=0&&Ge<=ce.width-it&&rt>=0&&rt<=ce.height-qe&&fe.readPixels(Ge,rt,it,qe,Jt.convert(et),Jt.convert(en),qt)}finally{const X=H!==null?pt.get(H).__webglFramebuffer:null;yt.bindFramebuffer(fe.FRAMEBUFFER,X)}}},this.readRenderTargetPixelsAsync=async function(ce,Ge,rt,it,qe,qt,Qt){if(!(ce&&ce.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let he=pt.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&Qt!==void 0&&(he=he[Qt]),he){const X=ce.texture,et=X.format,en=X.type;if(!Gt.textureFormatReadable(et))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Gt.textureTypeReadable(en))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(Ge>=0&&Ge<=ce.width-it&&rt>=0&&rt<=ce.height-qe){yt.bindFramebuffer(fe.FRAMEBUFFER,he);const sn=fe.createBuffer();fe.bindBuffer(fe.PIXEL_PACK_BUFFER,sn),fe.bufferData(fe.PIXEL_PACK_BUFFER,qt.byteLength,fe.STREAM_READ),fe.readPixels(Ge,rt,it,qe,Jt.convert(et),Jt.convert(en),0);const Tn=H!==null?pt.get(H).__webglFramebuffer:null;yt.bindFramebuffer(fe.FRAMEBUFFER,Tn);const Rn=fe.fenceSync(fe.SYNC_GPU_COMMANDS_COMPLETE,0);return fe.flush(),await Ck(fe,Rn,4),fe.bindBuffer(fe.PIXEL_PACK_BUFFER,sn),fe.getBufferSubData(fe.PIXEL_PACK_BUFFER,0,qt),fe.deleteBuffer(sn),fe.deleteSync(Rn),qt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(ce,Ge=null,rt=0){ce.isTexture!==!0&&(Uf("WebGLRenderer: copyFramebufferToTexture function signature has changed."),Ge=arguments[0]||null,ce=arguments[1]);const it=Math.pow(2,-rt),qe=Math.floor(ce.image.width*it),qt=Math.floor(ce.image.height*it),Qt=Ge!==null?Ge.x:0,he=Ge!==null?Ge.y:0;Ae.setTexture2D(ce,0),fe.copyTexSubImage2D(fe.TEXTURE_2D,rt,0,0,Qt,he,qe,qt),yt.unbindTexture()};const Wi=fe.createFramebuffer(),No=fe.createFramebuffer();this.copyTextureToTexture=function(ce,Ge,rt=null,it=null,qe=0,qt=null){ce.isTexture!==!0&&(Uf("WebGLRenderer: copyTextureToTexture function signature has changed."),it=arguments[0]||null,ce=arguments[1],Ge=arguments[2],qt=arguments[3]||0,rt=null),qt===null&&(qe!==0?(Uf("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),qt=qe,qe=0):qt=0);let Qt,he,X,et,en,sn,Tn,Rn,xi;const K=ce.isCompressedTexture?ce.mipmaps[qt]:ce.image;if(rt!==null)Qt=rt.max.x-rt.min.x,he=rt.max.y-rt.min.y,X=rt.isBox3?rt.max.z-rt.min.z:1,et=rt.min.x,en=rt.min.y,sn=rt.isBox3?rt.min.z:0;else{const bi=Math.pow(2,-qe);Qt=Math.floor(K.width*bi),he=Math.floor(K.height*bi),ce.isDataArrayTexture?X=K.depth:ce.isData3DTexture?X=Math.floor(K.depth*bi):X=1,et=0,en=0,sn=0}it!==null?(Tn=it.x,Rn=it.y,xi=it.z):(Tn=0,Rn=0,xi=0);const hn=Jt.convert(Ge.format),Zt=Jt.convert(Ge.type);let gr;Ge.isData3DTexture?(Ae.setTexture3D(Ge,0),gr=fe.TEXTURE_3D):Ge.isDataArrayTexture||Ge.isCompressedArrayTexture?(Ae.setTexture2DArray(Ge,0),gr=fe.TEXTURE_2D_ARRAY):(Ae.setTexture2D(Ge,0),gr=fe.TEXTURE_2D),fe.pixelStorei(fe.UNPACK_FLIP_Y_WEBGL,Ge.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ge.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,Ge.unpackAlignment);const ui=fe.getParameter(fe.UNPACK_ROW_LENGTH),vr=fe.getParameter(fe.UNPACK_IMAGE_HEIGHT),Ps=fe.getParameter(fe.UNPACK_SKIP_PIXELS),ys=fe.getParameter(fe.UNPACK_SKIP_ROWS),Vr=fe.getParameter(fe.UNPACK_SKIP_IMAGES);fe.pixelStorei(fe.UNPACK_ROW_LENGTH,K.width),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,K.height),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,et),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,en),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,sn);const Di=ce.isDataArrayTexture||ce.isData3DTexture,sr=Ge.isDataArrayTexture||Ge.isData3DTexture;if(ce.isDepthTexture){const bi=pt.get(ce),_r=pt.get(Ge),Jr=pt.get(bi.__renderTarget),Gc=pt.get(_r.__renderTarget);yt.bindFramebuffer(fe.READ_FRAMEBUFFER,Jr.__webglFramebuffer),yt.bindFramebuffer(fe.DRAW_FRAMEBUFFER,Gc.__webglFramebuffer);for(let xs=0;xs=-1&&AA.z<=1&&T.layers.test(C.layers)===!0,O=T.element;O.style.display=E===!0?"":"none",E===!0&&(T.onBeforeRender(t,N,C),O.style.transform="translate("+-100*T.center.x+"%,"+-100*T.center.y+"%)translate("+(AA.x*s+s)+"px,"+(-AA.y*a+a)+"px)",O.parentNode!==u&&u.appendChild(O),T.onAfterRender(t,N,C));const U={distanceToCameraSquared:v(C,T)};l.objects.set(T,U)}for(let E=0,O=T.children.length;E=e||G<0||v&&H>=s}function E(){var z=L3();if(C(z))return O(z);l=setTimeout(E,N(z))}function O(z){return l=void 0,x&&n?S(z):(n=r=void 0,a)}function U(){l!==void 0&&clearTimeout(l),h=0,n=u=r=l=void 0}function I(){return l===void 0?a:O(L3())}function j(){var z=L3(),G=C(z);if(n=arguments,r=this,u=z,G){if(l===void 0)return T(u);if(v)return clearTimeout(l),l=setTimeout(E,e),S(u)}return l===void 0&&(l=setTimeout(E,e)),a}return j.cancel=U,j.flush=I,j}function f5(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),vm=function(){return performance.now()},wy=(function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=vm()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?s(i[t],i[t-1],t-n):s(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},_D=(function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i})(),rw=new wy,la=(function(){function i(e,t){t===void 0&&(t=rw),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=os.Linear.None,this._interpolationFunction=iw.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=_D.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=vm()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,s){for(var a in n){var l=e[a],u=Array.isArray(l),h=u?"array":typeof l,m=!u&&Array.isArray(n[a]);if(!(h==="undefined"||h==="function")){if(m){var v=n[a];if(v.length===0)continue;for(var x=[l],S=0,T=v.length;S"u"||s)&&(t[a]=l),u||(t[a]*=1),m?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=vm()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=vm()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;ea)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,eh)return 1;var C=Math.trunc(l/u),E=l-C*u,O=Math.min(E/n._duration,1);return O===0&&l===n._duration?1:O},v=m(),x=this._easingFunction(v);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,x),this._onUpdateCallback&&this._onUpdateCallback(this._object,v),this._duration===0||l>=this._duration)if(this._repeat>0){var S=Math.min(Math.trunc((l-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=S);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*S,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var T=0,N=this._chainedTweens.length;T=(T=(u+v)/2))?u=T:v=T,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C,s=a,!(a=a[G=z<<2|j<<1|I]))return s[G]=l,i;if(E=+i._x.call(null,a.data),O=+i._y.call(null,a.data),U=+i._z.call(null,a.data),e===E&&t===O&&n===U)return l.next=a,s?s[G]=l:i._root=l,i;do s=s?s[G]=new Array(8):i._root=new Array(8),(I=e>=(T=(u+v)/2))?u=T:v=T,(j=t>=(N=(h+x)/2))?h=N:x=N,(z=n>=(C=(m+S)/2))?m=C:S=C;while((G=z<<2|j<<1|I)===(H=(U>=C)<<2|(O>=N)<<1|E>=T));return s[H]=a,s[G]=l,i}function bW(i){Array.isArray(i)||(i=Array.from(i));const e=i.length,t=new Float64Array(e),n=new Float64Array(e),r=new Float64Array(e);let s=1/0,a=1/0,l=1/0,u=-1/0,h=-1/0,m=-1/0;for(let v=0,x,S,T,N;vu&&(u=S),Th&&(h=T),Nm&&(m=N));if(s>u||a>h||l>m)return this;this.cover(s,a,l).cover(u,h,m);for(let v=0;vi||i>=a||r>e||e>=l||s>t||t>=u;)switch(x=(tT||(h=U.y0)>N||(m=U.z0)>C||(v=U.x1)=G)<<2|(e>=z)<<1|i>=j)&&(U=E[E.length-1],E[E.length-1]=E[E.length-1-I],E[E.length-1-I]=U)}else{var H=i-+this._x.call(null,O.data),q=e-+this._y.call(null,O.data),V=t-+this._z.call(null,O.data),Q=H*H+q*q+V*V;if(QMath.sqrt((i-n)**2+(e-r)**2+(t-s)**2);function CW(i,e,t,n){const r=[],s=i-n,a=e-n,l=t-n,u=i+n,h=e+n,m=t+n;return this.visit((v,x,S,T,N,C,E)=>{if(!v.length)do{const O=v.data;EW(i,e,t,this._x(O),this._y(O),this._z(O))<=n&&r.push(O)}while(v=v.next);return x>u||S>h||T>m||N=(N=(a+h)/2))?a=N:h=N,(U=S>=(C=(l+m)/2))?l=C:m=C,(I=T>=(E=(u+v)/2))?u=E:v=E,e=t,!(t=t[j=I<<2|U<<1|O]))return this;if(!t.length)break;(e[j+1&7]||e[j+2&7]||e[j+3&7]||e[j+4&7]||e[j+5&7]||e[j+6&7]||e[j+7&7])&&(n=e,z=j)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[j]=s:delete e[j],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[z]=t:this._root=t),this):(this._root=s,this)}function RW(i){for(var e=0,t=i.length;ee?1:i>=e?0:NaN}function GW(i,e){return i==null||e==null?NaN:ei?1:e>=i?0:NaN}function bD(i){let e,t,n;i.length!==2?(e=Gv,t=(l,u)=>Gv(i(l),u),n=(l,u)=>i(l)-u):(e=i===Gv||i===GW?i:qW,t=i,n=i);function r(l,u,h=0,m=l.length){if(h>>1;t(l[v],u)<0?h=v+1:m=v}while(h>>1;t(l[v],u)<=0?h=v+1:m=v}while(hh&&n(l[v-1],u)>-n(l[v],u)?v-1:v}return{left:r,center:a,right:s}}function qW(){return 0}function VW(i){return i===null?NaN:+i}const jW=bD(Gv),SD=jW.right;bD(VW).center;function h_(i,e){let t,n;if(e===void 0)for(const r of i)r!=null&&(t===void 0?r>=r&&(t=n=r):(t>r&&(t=r),n=s&&(t=n=s):(t>s&&(t=s),n0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,s=r-(a-n),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(r=s*2,n=a+r,r==n-a&&(a=n))}return a}}const HW=Math.sqrt(50),WW=Math.sqrt(10),$W=Math.sqrt(2);function f_(i,e,t){const n=(e-i)/Math.max(0,t),r=Math.floor(Math.log10(n)),s=n/Math.pow(10,r),a=s>=HW?10:s>=WW?5:s>=$W?2:1;let l,u,h;return r<0?(h=Math.pow(10,-r)/a,l=Math.round(i*h),u=Math.round(e*h),l/he&&--u,h=-h):(h=Math.pow(10,r)*a,l=Math.round(i/h),u=Math.round(e/h),l*he&&--u),u0))return[];if(i===e)return[i];const n=e=r))return[];const l=s-r+1,u=new Array(l);if(n)if(a<0)for(let h=0;h=n)&&(t=n);return t}function KW(i,e){let t=0,n=0;if(e===void 0)for(let r of i)r!=null&&(r=+r)>=r&&(++t,n+=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(s=+s)>=s&&(++t,n+=s)}if(t)return n/t}function*ZW(i){for(const e of i)yield*e}function og(i){return Array.from(ZW(i))}function zA(i,e,t){i=+i,e=+e,t=(r=arguments.length)<2?(e=i,i=0,1):r<3?1:+t;for(var n=-1,r=Math.max(0,Math.ceil((e-i)/t))|0,s=new Array(r);++n>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?$2(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?$2(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=t$.exec(i))?new Va(e[1],e[2],e[3],1):(e=n$.exec(i))?new Va(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=i$.exec(i))?$2(e[1],e[2],e[3],e[4]):(e=r$.exec(i))?$2(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=s$.exec(i))?y5(e[1],e[2]/100,e[3]/100,1):(e=a$.exec(i))?y5(e[1],e[2]/100,e[3]/100,e[4]):A5.hasOwnProperty(i)?g5(A5[i]):i==="transparent"?new Va(NaN,NaN,NaN,0):null}function g5(i){return new Va(i>>16&255,i>>8&255,i&255,1)}function $2(i,e,t,n){return n<=0&&(i=e=t=NaN),new Va(i,e,t,n)}function u$(i){return i instanceof Fg||(i=sd(i)),i?(i=i.rgb(),new Va(i.r,i.g,i.b,i.opacity)):new Va}function aw(i,e,t,n){return arguments.length===1?u$(i):new Va(i,e,t,n??1)}function Va(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}fM(Va,aw,TD(Fg,{brighter(i){return i=i==null?d_:Math.pow(d_,i),new Va(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?lg:Math.pow(lg,i),new Va(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new Va(Yf(this.r),Yf(this.g),Yf(this.b),A_(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:v5,formatHex:v5,formatHex8:c$,formatRgb:_5,toString:_5}));function v5(){return`#${Gf(this.r)}${Gf(this.g)}${Gf(this.b)}`}function c$(){return`#${Gf(this.r)}${Gf(this.g)}${Gf(this.b)}${Gf((isNaN(this.opacity)?1:this.opacity)*255)}`}function _5(){const i=A_(this.opacity);return`${i===1?"rgb(":"rgba("}${Yf(this.r)}, ${Yf(this.g)}, ${Yf(this.b)}${i===1?")":`, ${i})`}`}function A_(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function Yf(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function Gf(i){return i=Yf(i),(i<16?"0":"")+i.toString(16)}function y5(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new xl(i,e,t,n)}function MD(i){if(i instanceof xl)return new xl(i.h,i.s,i.l,i.opacity);if(i instanceof Fg||(i=sd(i)),!i)return new xl;if(i instanceof xl)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,r=Math.min(e,t,n),s=Math.max(e,t,n),a=NaN,l=s-r,u=(s+r)/2;return l?(e===s?a=(t-n)/l+(t0&&u<1?0:a,new xl(a,l,u,i.opacity)}function h$(i,e,t,n){return arguments.length===1?MD(i):new xl(i,e,t,n??1)}function xl(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}fM(xl,h$,TD(Fg,{brighter(i){return i=i==null?d_:Math.pow(d_,i),new xl(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?lg:Math.pow(lg,i),new xl(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,r=2*t-n;return new Va(U3(i>=240?i-240:i+120,r,n),U3(i,r,n),U3(i<120?i+240:i-120,r,n),this.opacity)},clamp(){return new xl(x5(this.h),X2(this.s),X2(this.l),A_(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=A_(this.opacity);return`${i===1?"hsl(":"hsla("}${x5(this.h)}, ${X2(this.s)*100}%, ${X2(this.l)*100}%${i===1?")":`, ${i})`}`}}));function x5(i){return i=(i||0)%360,i<0?i+360:i}function X2(i){return Math.max(0,Math.min(1,i||0))}function U3(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const dM=i=>()=>i;function f$(i,e){return function(t){return i+t*e}}function d$(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function A$(i){return(i=+i)==1?ED:function(e,t){return t-e?d$(e,t,i):dM(isNaN(e)?t:e)}}function ED(i,e){var t=e-i;return t?f$(i,t):dM(isNaN(i)?e:i)}const b5=(function i(e){var t=A$(e);function n(r,s){var a=t((r=aw(r)).r,(s=aw(s)).r),l=t(r.g,s.g),u=t(r.b,s.b),h=ED(r.opacity,s.opacity);return function(m){return r.r=a(m),r.g=l(m),r.b=u(m),r.opacity=h(m),r+""}}return n.gamma=i,n})(1);function CD(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),r;return function(s){for(r=0;rt&&(s=e.slice(t,s),l[a]?l[a]+=s:l[++a]=s),(n=n[0])===(r=r[0])?l[a]?l[a]+=r:l[++a]=r:(l[++a]=null,u.push({i:a,x:cg(n,r)})),t=B3.lastIndex;return te&&(t=i,i=e,e=t),function(n){return Math.max(i,Math.min(e,n))}}function T$(i,e,t){var n=i[0],r=i[1],s=e[0],a=e[1];return r2?M$:T$,u=h=null,v}function v(x){return x==null||isNaN(x=+x)?s:(u||(u=l(i.map(n),e,t)))(n(a(x)))}return v.invert=function(x){return a(r((h||(h=l(e,i.map(n),cg)))(x)))},v.domain=function(x){return arguments.length?(i=Array.from(x,S$),m()):i.slice()},v.range=function(x){return arguments.length?(e=Array.from(x),m()):e.slice()},v.rangeRound=function(x){return e=Array.from(x),t=x$,m()},v.clamp=function(x){return arguments.length?(a=x?!0:GA,m()):a!==GA},v.interpolate=function(x){return arguments.length?(t=x,m()):t},v.unknown=function(x){return arguments.length?(s=x,v):s},function(x,S){return n=x,r=S,m()}}function N$(){return C$()(GA,GA)}function R$(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)}function p_(i,e){if(!isFinite(i)||i===0)return null;var t=(i=e?i.toExponential(e-1):i.toExponential()).indexOf("e"),n=i.slice(0,t);return[n.length>1?n[0]+n.slice(2):n,+i.slice(t+1)]}function S0(i){return i=p_(Math.abs(i)),i?i[1]:NaN}function D$(i,e){return function(t,n){for(var r=t.length,s=[],a=0,l=i[0],u=0;r>0&&l>0&&(u+l+1>n&&(l=Math.max(1,n-u)),s.push(t.substring(r-=l,r+l)),!((u+=l+1)>n));)l=i[a=(a+1)%i.length];return s.reverse().join(e)}}function P$(i){return function(e){return e.replace(/[0-9]/g,function(t){return i[+t]})}}var L$=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function m_(i){if(!(e=L$.exec(i)))throw new Error("invalid format: "+i);var e;return new pM({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}m_.prototype=pM.prototype;function pM(i){this.fill=i.fill===void 0?" ":i.fill+"",this.align=i.align===void 0?">":i.align+"",this.sign=i.sign===void 0?"-":i.sign+"",this.symbol=i.symbol===void 0?"":i.symbol+"",this.zero=!!i.zero,this.width=i.width===void 0?void 0:+i.width,this.comma=!!i.comma,this.precision=i.precision===void 0?void 0:+i.precision,this.trim=!!i.trim,this.type=i.type===void 0?"":i.type+""}pM.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function U$(i){e:for(var e=i.length,t=1,n=-1,r;t0&&(n=0);break}return n>0?i.slice(0,n)+i.slice(r+1):i}var g_;function B$(i,e){var t=p_(i,e);if(!t)return g_=void 0,i.toPrecision(e);var n=t[0],r=t[1],s=r-(g_=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,a=n.length;return s===a?n:s>a?n+new Array(s-a+1).join("0"):s>0?n.slice(0,s)+"."+n.slice(s):"0."+new Array(1-s).join("0")+p_(i,Math.max(0,e+s-1))[0]}function w5(i,e){var t=p_(i,e);if(!t)return i+"";var n=t[0],r=t[1];return r<0?"0."+new Array(-r).join("0")+n:n.length>r+1?n.slice(0,r+1)+"."+n.slice(r+1):n+new Array(r-n.length+2).join("0")}const T5={"%":(i,e)=>(i*100).toFixed(e),b:i=>Math.round(i).toString(2),c:i=>i+"",d:R$,e:(i,e)=>i.toExponential(e),f:(i,e)=>i.toFixed(e),g:(i,e)=>i.toPrecision(e),o:i=>Math.round(i).toString(8),p:(i,e)=>w5(i*100,e),r:w5,s:B$,X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function M5(i){return i}var E5=Array.prototype.map,C5=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function O$(i){var e=i.grouping===void 0||i.thousands===void 0?M5:D$(E5.call(i.grouping,Number),i.thousands+""),t=i.currency===void 0?"":i.currency[0]+"",n=i.currency===void 0?"":i.currency[1]+"",r=i.decimal===void 0?".":i.decimal+"",s=i.numerals===void 0?M5:P$(E5.call(i.numerals,String)),a=i.percent===void 0?"%":i.percent+"",l=i.minus===void 0?"−":i.minus+"",u=i.nan===void 0?"NaN":i.nan+"";function h(v,x){v=m_(v);var S=v.fill,T=v.align,N=v.sign,C=v.symbol,E=v.zero,O=v.width,U=v.comma,I=v.precision,j=v.trim,z=v.type;z==="n"?(U=!0,z="g"):T5[z]||(I===void 0&&(I=12),j=!0,z="g"),(E||S==="0"&&T==="=")&&(E=!0,S="0",T="=");var G=(x&&x.prefix!==void 0?x.prefix:"")+(C==="$"?t:C==="#"&&/[boxX]/.test(z)?"0"+z.toLowerCase():""),H=(C==="$"?n:/[%p]/.test(z)?a:"")+(x&&x.suffix!==void 0?x.suffix:""),q=T5[z],V=/[defgprs%]/.test(z);I=I===void 0?6:/[gprs]/.test(z)?Math.max(1,Math.min(21,I)):Math.max(0,Math.min(20,I));function Q(J){var ie=G,le=H,re,Z,ne;if(z==="c")le=q(J)+le,J="";else{J=+J;var de=J<0||1/J<0;if(J=isNaN(J)?u:q(Math.abs(J),I),j&&(J=U$(J)),de&&+J==0&&N!=="+"&&(de=!1),ie=(de?N==="("?N:l:N==="-"||N==="("?"":N)+ie,le=(z==="s"&&!isNaN(J)&&g_!==void 0?C5[8+g_/3]:"")+le+(de&&N==="("?")":""),V){for(re=-1,Z=J.length;++rene||ne>57){le=(ne===46?r+J.slice(re+1):J.slice(re))+le,J=J.slice(0,re);break}}}U&&!E&&(J=e(J,1/0));var be=ie.length+J.length+le.length,Te=be>1)+ie+J+le+Te.slice(be);break;default:J=Te+ie+J+le;break}return s(J)}return Q.toString=function(){return v+""},Q}function m(v,x){var S=Math.max(-8,Math.min(8,Math.floor(S0(x)/3)))*3,T=Math.pow(10,-S),N=h((v=m_(v),v.type="f",v),{suffix:C5[8+S/3]});return function(C){return N(T*C)}}return{format:h,formatPrefix:m}}var Y2,DD,PD;I$({thousands:",",grouping:[3],currency:["$",""]});function I$(i){return Y2=O$(i),DD=Y2.format,PD=Y2.formatPrefix,Y2}function F$(i){return Math.max(0,-S0(Math.abs(i)))}function k$(i,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(S0(e)/3)))*3-S0(Math.abs(i)))}function z$(i,e){return i=Math.abs(i),e=Math.abs(e)-i,Math.max(0,S0(e)-S0(i))+1}function G$(i,e,t,n){var r=YW(i,e,t),s;switch(n=m_(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(i),Math.abs(e));return n.precision==null&&!isNaN(s=k$(r,a))&&(n.precision=s),PD(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(s=z$(r,Math.max(Math.abs(i),Math.abs(e))))&&(n.precision=s-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(s=F$(r))&&(n.precision=s-(n.type==="%")*2);break}}return DD(n)}function LD(i){var e=i.domain;return i.ticks=function(t){var n=e();return XW(n[0],n[n.length-1],t??10)},i.tickFormat=function(t,n){var r=e();return G$(r[0],r[r.length-1],t??10,n)},i.nice=function(t){t==null&&(t=10);var n=e(),r=0,s=n.length-1,a=n[r],l=n[s],u,h,m=10;for(l0;){if(h=sw(a,l,t),h===u)return n[r]=a,n[s]=l,e(n);if(h>0)a=Math.floor(a/h)*h,l=Math.ceil(l/h)*h;else if(h<0)a=Math.ceil(a*h)/h,l=Math.floor(l*h)/h;else break;u=h}return i},i}function Ec(){var i=N$();return i.copy=function(){return E$(i,Ec())},wD.apply(i,arguments),LD(i)}function UD(){var i=0,e=1,t=1,n=[.5],r=[0,1],s;function a(u){return u!=null&&u<=u?r[SD(n,u,0,t)]:s}function l(){var u=-1;for(n=new Array(t);++u=t?[n[t-1],e]:[n[h-1],n[h]]},a.unknown=function(u){return arguments.length&&(s=u),a},a.thresholds=function(){return n.slice()},a.copy=function(){return UD().domain([i,e]).range(r).unknown(s)},wD.apply(LD(a),arguments)}var di=1e-6,v_=1e-12,Mi=Math.PI,ja=Mi/2,__=Mi/4,Eo=Mi*2,Fr=180/Mi,Yn=Mi/180,Zi=Math.abs,mM=Math.atan,Qo=Math.atan2,ni=Math.cos,Q2=Math.ceil,q$=Math.exp,uw=Math.hypot,V$=Math.log,Hn=Math.sin,j$=Math.sign||function(i){return i>0?1:i<0?-1:0},Cc=Math.sqrt,H$=Math.tan;function W$(i){return i>1?0:i<-1?Mi:Math.acos(i)}function Nc(i){return i>1?ja:i<-1?-ja:Math.asin(i)}function N5(i){return(i=Hn(i/2))*i}function na(){}function y_(i,e){i&&D5.hasOwnProperty(i.type)&&D5[i.type](i,e)}var R5={Feature:function(i,e){y_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n=0?1:-1,r=n*t,s=ni(e),a=Hn(e),l=dw*a,u=fw*s+l*ni(r),h=l*n*Hn(r);x_.add(Qo(h,u)),hw=i,fw=s,dw=a}function b_(i){return[Qo(i[1],i[0]),Nc(i[2])]}function ad(i){var e=i[0],t=i[1],n=ni(t);return[n*ni(e),n*Hn(e),Hn(t)]}function K2(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function w0(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function O3(i,e){i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}function Z2(i,e){return[i[0]*e,i[1]*e,i[2]*e]}function S_(i){var e=Cc(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);i[0]/=e,i[1]/=e,i[2]/=e}var Cr,ka,Or,bo,Df,FD,kD,ZA,Nm,wh,Dc,Ac={point:Aw,lineStart:U5,lineEnd:B5,polygonStart:function(){Ac.point=GD,Ac.lineStart=Q$,Ac.lineEnd=K$,Nm=new bc,Rc.polygonStart()},polygonEnd:function(){Rc.polygonEnd(),Ac.point=Aw,Ac.lineStart=U5,Ac.lineEnd=B5,x_<0?(Cr=-(Or=180),ka=-(bo=90)):Nm>di?bo=90:Nm<-di&&(ka=-90),Dc[0]=Cr,Dc[1]=Or},sphere:function(){Cr=-(Or=180),ka=-(bo=90)}};function Aw(i,e){wh.push(Dc=[Cr=i,Or=i]),ebo&&(bo=e)}function zD(i,e){var t=ad([i*Yn,e*Yn]);if(ZA){var n=w0(ZA,t),r=[n[1],-n[0],0],s=w0(r,n);S_(s),s=b_(s);var a=i-Df,l=a>0?1:-1,u=s[0]*Fr*l,h,m=Zi(a)>180;m^(l*Dfbo&&(bo=h)):(u=(u+360)%360-180,m^(l*Dfbo&&(bo=e))),m?i_o(Cr,Or)&&(Or=i):_o(i,Or)>_o(Cr,Or)&&(Cr=i):Or>=Cr?(iOr&&(Or=i)):i>Df?_o(Cr,i)>_o(Cr,Or)&&(Or=i):_o(i,Or)>_o(Cr,Or)&&(Cr=i)}else wh.push(Dc=[Cr=i,Or=i]);ebo&&(bo=e),ZA=t,Df=i}function U5(){Ac.point=zD}function B5(){Dc[0]=Cr,Dc[1]=Or,Ac.point=Aw,ZA=null}function GD(i,e){if(ZA){var t=i-Df;Nm.add(Zi(t)>180?t+(t>0?360:-360):t)}else FD=i,kD=e;Rc.point(i,e),zD(i,e)}function Q$(){Rc.lineStart()}function K$(){GD(FD,kD),Rc.lineEnd(),Zi(Nm)>di&&(Cr=-(Or=180)),Dc[0]=Cr,Dc[1]=Or,ZA=null}function _o(i,e){return(e-=i)<0?e+360:e}function Z$(i,e){return i[0]-e[0]}function O5(i,e){return i[0]<=i[1]?i[0]<=e&&e<=i[1]:e_o(n[0],n[1])&&(n[1]=r[1]),_o(r[0],n[1])>_o(n[0],n[1])&&(n[0]=r[0])):s.push(n=r);for(a=-1/0,t=s.length-1,e=0,n=s[t];e<=t;n=r,++e)r=s[e],(l=_o(n[1],r[0]))>a&&(a=l,Cr=r[0],Or=n[1])}return wh=Dc=null,Cr===1/0||ka===1/0?[[NaN,NaN],[NaN,NaN]]:[[Cr,ka],[Or,bo]]}var _m,w_,T_,M_,E_,C_,N_,R_,pw,mw,gw,VD,jD,_a,ya,xa,Sl={sphere:na,point:gM,lineStart:I5,lineEnd:F5,polygonStart:function(){Sl.lineStart=tX,Sl.lineEnd=nX},polygonEnd:function(){Sl.lineStart=I5,Sl.lineEnd=F5}};function gM(i,e){i*=Yn,e*=Yn;var t=ni(e);kg(t*ni(i),t*Hn(i),Hn(e))}function kg(i,e,t){++_m,T_+=(i-T_)/_m,M_+=(e-M_)/_m,E_+=(t-E_)/_m}function I5(){Sl.point=J$}function J$(i,e){i*=Yn,e*=Yn;var t=ni(e);_a=t*ni(i),ya=t*Hn(i),xa=Hn(e),Sl.point=eX,kg(_a,ya,xa)}function eX(i,e){i*=Yn,e*=Yn;var t=ni(e),n=t*ni(i),r=t*Hn(i),s=Hn(e),a=Qo(Cc((a=ya*s-xa*r)*a+(a=xa*n-_a*s)*a+(a=_a*r-ya*n)*a),_a*n+ya*r+xa*s);w_+=a,C_+=a*(_a+(_a=n)),N_+=a*(ya+(ya=r)),R_+=a*(xa+(xa=s)),kg(_a,ya,xa)}function F5(){Sl.point=gM}function tX(){Sl.point=iX}function nX(){HD(VD,jD),Sl.point=gM}function iX(i,e){VD=i,jD=e,i*=Yn,e*=Yn,Sl.point=HD;var t=ni(e);_a=t*ni(i),ya=t*Hn(i),xa=Hn(e),kg(_a,ya,xa)}function HD(i,e){i*=Yn,e*=Yn;var t=ni(e),n=t*ni(i),r=t*Hn(i),s=Hn(e),a=ya*s-xa*r,l=xa*n-_a*s,u=_a*r-ya*n,h=uw(a,l,u),m=Nc(h),v=h&&-m/h;pw.add(v*a),mw.add(v*l),gw.add(v*u),w_+=m,C_+=m*(_a+(_a=n)),N_+=m*(ya+(ya=r)),R_+=m*(xa+(xa=s)),kg(_a,ya,xa)}function k5(i){_m=w_=T_=M_=E_=C_=N_=R_=0,pw=new bc,mw=new bc,gw=new bc,Ty(i,Sl);var e=+pw,t=+mw,n=+gw,r=uw(e,t,n);return rMi&&(i-=Math.round(i/Eo)*Eo),[i,e]}_w.invert=_w;function WD(i,e,t){return(i%=Eo)?e||t?vw(G5(i),q5(e,t)):G5(i):e||t?q5(e,t):_w}function z5(i){return function(e,t){return e+=i,Zi(e)>Mi&&(e-=Math.round(e/Eo)*Eo),[e,t]}}function G5(i){var e=z5(i);return e.invert=z5(-i),e}function q5(i,e){var t=ni(i),n=Hn(i),r=ni(e),s=Hn(e);function a(l,u){var h=ni(u),m=ni(l)*h,v=Hn(l)*h,x=Hn(u),S=x*t+m*n;return[Qo(v*r-S*s,m*t-x*n),Nc(S*r+v*s)]}return a.invert=function(l,u){var h=ni(u),m=ni(l)*h,v=Hn(l)*h,x=Hn(u),S=x*r-v*s;return[Qo(v*r+x*s,m*t+S*n),Nc(S*t-m*n)]},a}function rX(i){i=WD(i[0]*Yn,i[1]*Yn,i.length>2?i[2]*Yn:0);function e(t){return t=i(t[0]*Yn,t[1]*Yn),t[0]*=Fr,t[1]*=Fr,t}return e.invert=function(t){return t=i.invert(t[0]*Yn,t[1]*Yn),t[0]*=Fr,t[1]*=Fr,t},e}function sX(i,e,t,n,r,s){if(t){var a=ni(e),l=Hn(e),u=n*t;r==null?(r=e+n*Eo,s=e-u/2):(r=V5(a,r),s=V5(a,s),(n>0?rs)&&(r+=n*Eo));for(var h,m=r;n>0?m>s:m1&&i.push(i.pop().concat(i.shift()))},result:function(){var t=i;return i=[],e=null,t}}}function qv(i,e){return Zi(i[0]-e[0])=0;--l)r.point((v=m[l])[0],v[1]);else n(x.x,x.p.x,-1,r);x=x.p}x=x.o,m=x.z,S=!S}while(!x.v);r.lineEnd()}}}function j5(i){if(e=i.length){for(var e,t=0,n=i[0],r;++t=0?1:-1,V=q*H,Q=V>Mi,J=C*z;if(u.add(Qo(J*q*Hn(V),E*G+J*ni(V))),a+=Q?H+q*Eo:H,Q^T>=t^I>=t){var ie=w0(ad(S),ad(U));S_(ie);var le=w0(s,ie);S_(le);var re=(Q^H>=0?-1:1)*Nc(le[2]);(n>re||n===re&&(ie[0]||ie[1]))&&(l+=Q^H>=0?1:-1)}}return(a<-di||a0){for(u||(r.polygonStart(),u=!0),r.lineStart(),z=0;z1&&I&2&&j.push(j.pop().concat(j.shift())),m.push(j.filter(aX))}}return x}}function aX(i){return i.length>1}function oX(i,e){return((i=i.x)[0]<0?i[1]-ja-di:ja-i[1])-((e=e.x)[0]<0?e[1]-ja-di:ja-e[1])}const H5=QD(function(){return!0},lX,cX,[-Mi,-ja]);function lX(i){var e=NaN,t=NaN,n=NaN,r;return{lineStart:function(){i.lineStart(),r=1},point:function(s,a){var l=s>0?Mi:-Mi,u=Zi(s-e);Zi(u-Mi)0?ja:-ja),i.point(n,t),i.lineEnd(),i.lineStart(),i.point(l,t),i.point(s,t),r=0):n!==l&&u>=Mi&&(Zi(e-n)di?mM((Hn(e)*(s=ni(n))*Hn(t)-Hn(n)*(r=ni(e))*Hn(i))/(r*s*a)):(e+n)/2}function cX(i,e,t,n){var r;if(i==null)r=t*ja,n.point(-Mi,r),n.point(0,r),n.point(Mi,r),n.point(Mi,0),n.point(Mi,-r),n.point(0,-r),n.point(-Mi,-r),n.point(-Mi,0),n.point(-Mi,r);else if(Zi(i[0]-e[0])>di){var s=i[0]0,r=Zi(e)>di;function s(m,v,x,S){sX(S,i,t,x,m,v)}function a(m,v){return ni(m)*ni(v)>e}function l(m){var v,x,S,T,N;return{lineStart:function(){T=S=!1,N=1},point:function(C,E){var O=[C,E],U,I=a(C,E),j=n?I?0:h(C,E):I?h(C+(C<0?Mi:-Mi),E):0;if(!v&&(T=S=I)&&m.lineStart(),I!==S&&(U=u(v,O),(!U||qv(v,U)||qv(O,U))&&(O[2]=1)),I!==S)N=0,I?(m.lineStart(),U=u(O,v),m.point(U[0],U[1])):(U=u(v,O),m.point(U[0],U[1],2),m.lineEnd()),v=U;else if(r&&v&&n^I){var z;!(j&x)&&(z=u(O,v,!0))&&(N=0,n?(m.lineStart(),m.point(z[0][0],z[0][1]),m.point(z[1][0],z[1][1]),m.lineEnd()):(m.point(z[1][0],z[1][1]),m.lineEnd(),m.lineStart(),m.point(z[0][0],z[0][1],3)))}I&&(!v||!qv(v,O))&&m.point(O[0],O[1]),v=O,S=I,x=j},lineEnd:function(){S&&m.lineEnd(),v=null},clean:function(){return N|(T&&S)<<1}}}function u(m,v,x){var S=ad(m),T=ad(v),N=[1,0,0],C=w0(S,T),E=K2(C,C),O=C[0],U=E-O*O;if(!U)return!x&&m;var I=e*E/U,j=-e*O/U,z=w0(N,C),G=Z2(N,I),H=Z2(C,j);O3(G,H);var q=z,V=K2(G,q),Q=K2(q,q),J=V*V-Q*(K2(G,G)-1);if(!(J<0)){var ie=Cc(J),le=Z2(q,(-V-ie)/Q);if(O3(le,G),le=b_(le),!x)return le;var re=m[0],Z=v[0],ne=m[1],de=v[1],be;Z0^le[1]<(Zi(le[0]-re)Mi^(re<=le[0]&&le[0]<=Z)){var Ve=Z2(q,(-V+ie)/Q);return O3(Ve,G),[le,b_(Ve)]}}}function h(m,v){var x=n?i:Mi-i,S=0;return m<-x?S|=1:m>x&&(S|=2),v<-x?S|=4:v>x&&(S|=8),S}return QD(a,l,s,n?[0,-i]:[-Mi,i-Mi])}function fX(i,e,t,n,r,s){var a=i[0],l=i[1],u=e[0],h=e[1],m=0,v=1,x=u-a,S=h-l,T;if(T=t-a,!(!x&&T>0)){if(T/=x,x<0){if(T0){if(T>v)return;T>m&&(m=T)}if(T=r-a,!(!x&&T<0)){if(T/=x,x<0){if(T>v)return;T>m&&(m=T)}else if(x>0){if(T0)){if(T/=S,S<0){if(T0){if(T>v)return;T>m&&(m=T)}if(T=s-l,!(!S&&T<0)){if(T/=S,S<0){if(T>v)return;T>m&&(m=T)}else if(S>0){if(T0&&(i[0]=a+m*x,i[1]=l+m*S),v<1&&(e[0]=a+v*x,e[1]=l+v*S),!0}}}}}var ym=1e9,ev=-ym;function dX(i,e,t,n){function r(h,m){return i<=h&&h<=t&&e<=m&&m<=n}function s(h,m,v,x){var S=0,T=0;if(h==null||(S=a(h,v))!==(T=a(m,v))||u(h,m)<0^v>0)do x.point(S===0||S===3?i:t,S>1?n:e);while((S=(S+v+4)%4)!==T);else x.point(m[0],m[1])}function a(h,m){return Zi(h[0]-i)0?0:3:Zi(h[0]-t)0?2:1:Zi(h[1]-e)0?1:0:m>0?3:2}function l(h,m){return u(h.x,m.x)}function u(h,m){var v=a(h,1),x=a(m,1);return v!==x?v-x:v===0?m[1]-h[1]:v===1?h[0]-m[0]:v===2?h[1]-m[1]:m[0]-h[0]}return function(h){var m=h,v=$D(),x,S,T,N,C,E,O,U,I,j,z,G={point:H,lineStart:J,lineEnd:ie,polygonStart:V,polygonEnd:Q};function H(re,Z){r(re,Z)&&m.point(re,Z)}function q(){for(var re=0,Z=0,ne=S.length;Zn&&(Ce-Me)*(n-Ve)>(Fe-Ve)*(i-Me)&&++re:Fe<=n&&(Ce-Me)*(n-Ve)<(Fe-Ve)*(i-Me)&&--re;return re}function V(){m=v,x=[],S=[],z=!0}function Q(){var re=q(),Z=z&&re,ne=(x=og(x)).length;(Z||ne)&&(h.polygonStart(),Z&&(h.lineStart(),s(null,null,1,h),h.lineEnd()),ne&&XD(x,l,re,s,h),h.polygonEnd()),m=h,x=S=T=null}function J(){G.point=le,S&&S.push(T=[]),j=!0,I=!1,O=U=NaN}function ie(){x&&(le(N,C),E&&I&&v.rejoin(),x.push(v.result())),G.point=H,I&&m.lineEnd()}function le(re,Z){var ne=r(re,Z);if(S&&T.push([re,Z]),j)N=re,C=Z,E=ne,j=!1,ne&&(m.lineStart(),m.point(re,Z));else if(ne&&I)m.point(re,Z);else{var de=[O=Math.max(ev,Math.min(ym,O)),U=Math.max(ev,Math.min(ym,U))],be=[re=Math.max(ev,Math.min(ym,re)),Z=Math.max(ev,Math.min(ym,Z))];fX(de,be,i,e,t,n)?(I||(m.lineStart(),m.point(de[0],de[1])),m.point(be[0],be[1]),ne||m.lineEnd(),z=!1):ne&&(m.lineStart(),m.point(re,Z),z=!1)}O=re,U=Z,I=ne}return G}}var yw,xw,Vv,jv,T0={sphere:na,point:na,lineStart:AX,lineEnd:na,polygonStart:na,polygonEnd:na};function AX(){T0.point=mX,T0.lineEnd=pX}function pX(){T0.point=T0.lineEnd=na}function mX(i,e){i*=Yn,e*=Yn,xw=i,Vv=Hn(e),jv=ni(e),T0.point=gX}function gX(i,e){i*=Yn,e*=Yn;var t=Hn(e),n=ni(e),r=Zi(i-xw),s=ni(r),a=Hn(r),l=n*a,u=jv*t-Vv*n*s,h=Vv*t+jv*n*s;yw.add(Qo(Cc(l*l+u*u),h)),xw=i,Vv=t,jv=n}function vX(i){return yw=new bc,Ty(i,T0),+yw}var bw=[null,null],_X={type:"LineString",coordinates:bw};function kh(i,e){return bw[0]=i,bw[1]=e,vX(_X)}var W5={Feature:function(i,e){return D_(i.geometry,e)},FeatureCollection:function(i,e){for(var t=i.features,n=-1,r=t.length;++n0&&(r=kh(i[s],i[s-1]),r>0&&t<=r&&n<=r&&(t+n-r)*(1-Math.pow((t-n)/r,2))di}).map(x)).concat(zA(Q2(s/h)*h,r,h).filter(function(U){return Zi(U%v)>di}).map(S))}return E.lines=function(){return O().map(function(U){return{type:"LineString",coordinates:U}})},E.outline=function(){return{type:"Polygon",coordinates:[T(n).concat(N(a).slice(1),T(t).reverse().slice(1),N(l).reverse().slice(1))]}},E.extent=function(U){return arguments.length?E.extentMajor(U).extentMinor(U):E.extentMinor()},E.extentMajor=function(U){return arguments.length?(n=+U[0][0],t=+U[1][0],l=+U[0][1],a=+U[1][1],n>t&&(U=n,n=t,t=U),l>a&&(U=l,l=a,a=U),E.precision(C)):[[n,l],[t,a]]},E.extentMinor=function(U){return arguments.length?(e=+U[0][0],i=+U[1][0],s=+U[0][1],r=+U[1][1],e>i&&(U=e,e=i,i=U),s>r&&(U=s,s=r,r=U),E.precision(C)):[[e,s],[i,r]]},E.step=function(U){return arguments.length?E.stepMajor(U).stepMinor(U):E.stepMinor()},E.stepMajor=function(U){return arguments.length?(m=+U[0],v=+U[1],E):[m,v]},E.stepMinor=function(U){return arguments.length?(u=+U[0],h=+U[1],E):[u,h]},E.precision=function(U){return arguments.length?(C=+U,x=K5(s,r,90),S=Z5(e,i,C),T=K5(l,a,90),N=Z5(n,t,C),E):C},E.extentMajor([[-180,-90+di],[180,90-di]]).extentMinor([[-180,-80-di],[180,80+di]])}function SX(){return bX()()}function vM(i,e){var t=i[0]*Yn,n=i[1]*Yn,r=e[0]*Yn,s=e[1]*Yn,a=ni(n),l=Hn(n),u=ni(s),h=Hn(s),m=a*ni(t),v=a*Hn(t),x=u*ni(r),S=u*Hn(r),T=2*Nc(Cc(N5(s-n)+a*u*N5(r-t))),N=Hn(T),C=T?function(E){var O=Hn(E*=T)/N,U=Hn(T-E)/N,I=U*m+O*x,j=U*v+O*S,z=U*l+O*h;return[Qo(j,I)*Fr,Qo(z,Cc(I*I+j*j))*Fr]}:function(){return[t*Fr,n*Fr]};return C.distance=T,C}const J5=i=>i;var M0=1/0,P_=M0,hg=-M0,L_=hg,eR={point:wX,lineStart:na,lineEnd:na,polygonStart:na,polygonEnd:na,result:function(){var i=[[M0,P_],[hg,L_]];return hg=L_=-(P_=M0=1/0),i}};function wX(i,e){ihg&&(hg=i),eL_&&(L_=e)}function _M(i){return function(e){var t=new Sw;for(var n in i)t[n]=i[n];return t.stream=e,t}}function Sw(){}Sw.prototype={constructor:Sw,point:function(i,e){this.stream.point(i,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function yM(i,e,t){var n=i.clipExtent&&i.clipExtent();return i.scale(150).translate([0,0]),n!=null&&i.clipExtent(null),Ty(t,i.stream(eR)),e(eR.result()),n!=null&&i.clipExtent(n),i}function ZD(i,e,t){return yM(i,function(n){var r=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(r/(n[1][0]-n[0][0]),s/(n[1][1]-n[0][1])),l=+e[0][0]+(r-a*(n[1][0]+n[0][0]))/2,u=+e[0][1]+(s-a*(n[1][1]+n[0][1]))/2;i.scale(150*a).translate([l,u])},t)}function TX(i,e,t){return ZD(i,[[0,0],e],t)}function MX(i,e,t){return yM(i,function(n){var r=+e,s=r/(n[1][0]-n[0][0]),a=(r-s*(n[1][0]+n[0][0]))/2,l=-s*n[0][1];i.scale(150*s).translate([a,l])},t)}function EX(i,e,t){return yM(i,function(n){var r=+e,s=r/(n[1][1]-n[0][1]),a=-s*n[0][0],l=(r-s*(n[1][1]+n[0][1]))/2;i.scale(150*s).translate([a,l])},t)}var tR=16,CX=ni(30*Yn);function nR(i,e){return+e?RX(i,e):NX(i)}function NX(i){return _M({point:function(e,t){e=i(e,t),this.stream.point(e[0],e[1])}})}function RX(i,e){function t(n,r,s,a,l,u,h,m,v,x,S,T,N,C){var E=h-n,O=m-r,U=E*E+O*O;if(U>4*e&&N--){var I=a+x,j=l+S,z=u+T,G=Cc(I*I+j*j+z*z),H=Nc(z/=G),q=Zi(Zi(z)-1)e||Zi((E*ie+O*le)/U-.5)>.3||a*x+l*S+u*T2?re[2]%360*Yn:0,ie()):[l*Fr,u*Fr,h*Fr]},Q.angle=function(re){return arguments.length?(v=re%360*Yn,ie()):v*Fr},Q.reflectX=function(re){return arguments.length?(x=re?-1:1,ie()):x<0},Q.reflectY=function(re){return arguments.length?(S=re?-1:1,ie()):S<0},Q.precision=function(re){return arguments.length?(z=nR(G,j=re*re),le()):Cc(j)},Q.fitExtent=function(re,Z){return ZD(Q,re,Z)},Q.fitSize=function(re,Z){return TX(Q,re,Z)},Q.fitWidth=function(re,Z){return MX(Q,re,Z)},Q.fitHeight=function(re,Z){return EX(Q,re,Z)};function ie(){var re=iR(t,0,0,x,S,v).apply(null,e(s,a)),Z=iR(t,n-re[0],r-re[1],x,S,v);return m=WD(l,u,h),G=vw(e,Z),H=vw(m,G),z=nR(G,j),le()}function le(){return q=V=null,Q}return function(){return e=i.apply(this,arguments),Q.invert=e.invert&&J,ie()}}function OX(i){return function(e,t){var n=Cc(e*e+t*t),r=i(n),s=Hn(r),a=ni(r);return[Qo(e*s,n*a),Nc(n&&t*s/n)]}}function xM(i,e){return[i,V$(H$((ja+e)/2))]}xM.invert=function(i,e){return[i,2*mM(q$(e))-ja]};function JD(i,e){var t=ni(e),n=1+ni(i)*t;return[t*Hn(i)/n,Hn(e)/n]}JD.invert=OX(function(i){return 2*mM(i)});function IX(){return UX(JD).scale(250).clipAngle(142)}function ww(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=Ec().domain([1,0]).range([t,n]).clamp(!0),s=Ec().domain([F3(t),F3(n)]).range([1,0]).clamp(!0),a=function(v){return s(F3(r(v)))},l=e.array,u=0,h=l.length;u2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,l=[],u=Math.pow(2,e),h=360/u,m=180/u,v=s===void 0?u-1:s,x=a===void 0?u-1:a,S=n,T=Math.min(u-1,v);S<=T;S++)for(var N=r,C=Math.min(u-1,x);N<=C;N++){var E=N,O=m;if(t){E=N===0?N:sR(N/u)*u;var U=N+1===u?N+1:sR((N+1)/u)*u;O=(U-E)*180/u}var I=-180+(S+.5)*h,j=90-(E*180/u+O/2),z=O;l.push({x:S,y:N,lng:I,lat:j,latLen:z})}return l},tY=6,nY=7,iY=3,rY=90,Hl=new WeakMap,Mh=new WeakMap,k3=new WeakMap,tv=new WeakMap,Go=new WeakMap,B_=new WeakMap,JA=new WeakMap,bf=new WeakMap,nv=new WeakSet,sY=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.tileUrl,a=r.minLevel,l=a===void 0?0:a,u=r.maxLevel,h=u===void 0?17:u,m=r.mercatorProjection,v=m===void 0?!0:m;return qX(this,e),n=GX(this,e),VX(n,nv),gh(n,Hl,void 0),gh(n,Mh,void 0),gh(n,k3,void 0),gh(n,tv,void 0),gh(n,Go,{}),gh(n,B_,void 0),gh(n,JA,void 0),gh(n,bf,void 0),pA(n,"minLevel",void 0),pA(n,"maxLevel",void 0),pA(n,"thresholds",nP(new Array(30)).map(function(x,S){return 8/Math.pow(2,S)})),pA(n,"curvatureResolution",5),pA(n,"tileMargin",0),pA(n,"clearTiles",function(){Object.values(hi(Go,n)).forEach(function(x){x.forEach(function(S){S.obj&&(n.remove(S.obj),rR(S.obj),delete S.obj)})}),vh(Go,n,{})}),vh(Hl,n,t),n.tileUrl=s,vh(Mh,n,v),n.minLevel=l,n.maxLevel=h,n.level=0,n.add(vh(bf,n,new Oi(new bu(hi(Hl,n)*.99,180,90),new cd({color:0})))),hi(bf,n).visible=!1,hi(bf,n).material.polygonOffset=!0,hi(bf,n).material.polygonOffsetUnits=3,hi(bf,n).material.polygonOffsetFactor=1,n}return WX(e,i),HX(e,[{key:"tileUrl",get:function(){return hi(k3,this)},set:function(n){vh(k3,this,n),this.updatePov(hi(JA,this))}},{key:"level",get:function(){return hi(tv,this)},set:function(n){var r,s=this;hi(Go,this)[n]||Rm(nv,this,aY).call(this,n);var a=hi(tv,this);if(vh(tv,this,n),!(n===a||a===void 0)){if(hi(bf,this).visible=n>0,hi(Go,this)[n].forEach(function(u){return u.obj&&(u.obj.material.depthWrite=!0)}),an)for(var l=n+1;l<=a;l++)hi(Go,this)[l]&&hi(Go,this)[l].forEach(function(u){u.obj&&(s.remove(u.obj),rR(u.obj),delete u.obj)});Rm(nv,this,oR).call(this)}}},{key:"updatePov",value:function(n){var r=this;if(!(!n||!(n instanceof gy))){vh(JA,this,n);var s;if(vh(B_,this,function(m){if(!m.hullPnts){var v=360/Math.pow(2,r.level),x=m.lng,S=m.lat,T=m.latLen,N=x-v/2,C=x+v/2,E=S-T/2,O=S+T/2;m.hullPnts=[[S,x],[E,N],[O,N],[E,C],[O,C]].map(function(U){var I=Hv(U,2),j=I[0],z=I[1];return oP(j,z,hi(Hl,r))}).map(function(U){var I=U.x,j=U.y,z=U.z;return new me(I,j,z)})}return s||(s=new Og,n.updateMatrix(),n.updateMatrixWorld(),s.setFromProjectionMatrix(new jn().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse))),m.hullPnts.some(function(U){return s.containsPoint(U.clone().applyMatrix4(r.matrixWorld))})}),this.tileUrl){var a=n.position.clone(),l=a.distanceTo(this.getWorldPosition(new me)),u=(l-hi(Hl,this))/hi(Hl,this),h=this.thresholds.findIndex(function(m){return m&&m<=u});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,h<0?this.thresholds.length:h)),Rm(nv,this,oR).call(this)}}}}])})(qa);function aY(i){var e=this;if(i>nY){hi(Go,this)[i]=[];return}var t=hi(Go,this)[i]=Mw(i,hi(Mh,this));t.forEach(function(n){return n.centroid=oP(n.lat,n.lng,hi(Hl,e))}),t.octree=xD().x(function(n){return n.centroid.x}).y(function(n){return n.centroid.y}).z(function(n){return n.centroid.z}).addAll(t)}function oR(){var i=this;if(!(!this.tileUrl||this.level===void 0||!hi(Go,this).hasOwnProperty(this.level))&&!(!hi(B_,this)&&this.level>tY)){var e=hi(Go,this)[this.level];if(hi(JA,this)){var t=this.worldToLocal(hi(JA,this).position.clone());if(e.octree){var n,r=this.worldToLocal(hi(JA,this).position.clone()),s=(r.length()-hi(Hl,this))*iY;e=(n=e.octree).findAllWithinRadius.apply(n,nP(r).concat([s]))}else{var a=JX(t),l=(a.r/hi(Hl,this)-1)*rY,u=l/Math.cos(xf(a.lat)),h=[a.lng-u,a.lng+u],m=[a.lat+l,a.lat-l],v=aR(this.level,hi(Mh,this),h[0],m[0]),x=Hv(v,2),S=x[0],T=x[1],N=aR(this.level,hi(Mh,this),h[1],m[1]),C=Hv(N,2),E=C[0],O=C[1];!e.record&&(e.record={});var U=e.record;if(!U.hasOwnProperty("".concat(Math.round((S+E)/2),"_").concat(Math.round((T+O)/2))))e=Mw(this.level,hi(Mh,this),S,T,E,O).map(function(H){var q="".concat(H.x,"_").concat(H.y);return U.hasOwnProperty(q)?U[q]:(U[q]=H,e.push(H),H)});else{for(var I=[],j=S;j<=E;j++)for(var z=T;z<=O;z++){var G="".concat(j,"_").concat(z);U.hasOwnProperty(G)||(U[G]=Mw(this.level,hi(Mh,this),j,z,j,z)[0],e.push(U[G])),I.push(U[G])}e=I}}}e.filter(function(H){return!H.obj}).filter(hi(B_,this)||function(){return!0}).forEach(function(H){var q=H.x,V=H.y,Q=H.lng,J=H.lat,ne=H.latLen,oe=360/Math.pow(2,i.level);if(!H.obj){var ie=oe*(1-i.tileMargin),Z=ne*(1-i.tileMargin),te=xf(Q),de=xf(-J),Se=new Oi(new bu(hi(Hl,i),Math.ceil(ie/i.curvatureResolution),Math.ceil(Z/i.curvatureResolution),xf(90-ie/2)+te,xf(ie),xf(90-Z/2)+de,xf(Z)),new Fc);if(hi(Mh,i)){var Te=[J+ne/2,J-ne/2].map(function(Ce){return .5-Ce/180}),ae=Hv(Te,2),Me=ae[0],Ve=ae[1];eY(Se.geometry.attributes.uv,Me,Ve)}H.obj=Se}H.loading||(H.loading=!0,new oM().load(i.tileUrl(q,V,i.level),function(Ce){var Fe=H.obj;Fe&&(Ce.colorSpace=bn,Fe.material.map=Ce,Fe.material.color=null,Fe.material.needsUpdate=!0,i.add(Fe)),H.loading=!1}))})}}function oY(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=uP(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let l,u,h;if(n&&(s=fY(i,e,s,t)),i.length>80*t){l=i[0],u=i[1];let m=l,v=u;for(let x=t;xm&&(m=S),T>v&&(v=T)}h=Math.max(m-l,v-u),h=h!==0?32767/h:0}return fg(s,a,t,l,u,h,0),a}function uP(i,e,t,n,r){let s;if(r===SY(i,e,t,n)>0)for(let a=e;a=e;a-=n)s=lR(a/n|0,i[a],i[a+1],s);return s&&E0(s,s.next)&&(Ag(s),s=s.next),s}function od(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(E0(t,t.next)||Dr(t.prev,t,t.next)===0)){if(Ag(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function fg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&gY(i,n,r,s);let l=i;for(;i.prev!==i.next;){const u=i.prev,h=i.next;if(s?uY(i,n,r,s):lY(i)){e.push(u.i,i.i,h.i),Ag(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=cY(od(i),e),fg(i,e,t,n,r,s,2)):a===2&&hY(i,e,t,n,r,s):fg(od(i),e,t,n,r,s,1);break}}}function lY(i){const e=i.prev,t=i,n=i.next;if(Dr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=Math.min(r,s,a),v=Math.min(l,u,h),x=Math.max(r,s,a),S=Math.max(l,u,h);let T=n.next;for(;T!==e;){if(T.x>=m&&T.x<=x&&T.y>=v&&T.y<=S&&xm(r,l,s,u,a,h,T.x,T.y)&&Dr(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function uY(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Dr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=Math.min(l,u,h),T=Math.min(m,v,x),N=Math.max(l,u,h),C=Math.max(m,v,x),E=Ew(S,T,e,t,n),O=Ew(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&xm(l,m,u,v,h,x,U.x,U.y)&&Dr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&xm(l,m,u,v,h,x,I.x,I.y)&&Dr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&xm(l,m,u,v,h,x,U.x,U.y)&&Dr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&xm(l,m,u,v,h,x,I.x,I.y)&&Dr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function cY(i,e){let t=i;do{const n=t.prev,r=t.next.next;!E0(n,r)&&hP(n,t,t.next,r)&&dg(n,r)&&dg(r,n)&&(e.push(n.i,t.i,r.i),Ag(t),Ag(t.next),t=i=r),t=t.next}while(t!==i);return od(t)}function hY(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&yY(a,l)){let u=fP(a,l);a=od(a,a.next),u=od(u,u.next),fg(a,e,t,n,r,s,0),fg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function fY(i,e,t,n){const r=[];for(let s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const v=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=n&&v>s&&(s=v,a=t.x=t.x&&t.x>=u&&n!==t.x&&cP(ra.x||t.x===a.x&&mY(a,t)))&&(a=t,m=v)}t=t.next}while(t!==l);return a}function mY(i,e){return Dr(i.prev,i,e.prev)<0&&Dr(e.next,i,i.next)<0}function gY(i,e,t,n){let r=i;do r.z===0&&(r.z=Ew(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,vY(r)}function vY(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,l=0;for(let h=0;h0||u>0&&a;)l!==0&&(u===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,l--):(r=a,a=a.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function Ew(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function _Y(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function xm(i,e,t,n,r,s,a,l){return!(i===a&&e===l)&&cP(i,e,t,n,r,s,a,l)}function yY(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!xY(i,e)&&(dg(i,e)&&dg(e,i)&&bY(i,e)&&(Dr(i.prev,i,e.prev)||Dr(i,e.prev,e))||E0(i,e)&&Dr(i.prev,i,i.next)>0&&Dr(e.prev,e,e.next)>0)}function Dr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function E0(i,e){return i.x===e.x&&i.y===e.y}function hP(i,e,t,n){const r=rv(Dr(i,e,t)),s=rv(Dr(i,e,n)),a=rv(Dr(t,n,i)),l=rv(Dr(t,n,e));return!!(r!==s&&a!==l||r===0&&iv(i,t,e)||s===0&&iv(i,n,e)||a===0&&iv(t,i,n)||l===0&&iv(t,e,n))}function iv(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function rv(i){return i>0?1:i<0?-1:0}function xY(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&hP(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function dg(i,e){return Dr(i.prev,i,i.next)<0?Dr(i,e,i.next)>=0&&Dr(i,i.prev,e)>=0:Dr(i,e,i.prev)<0||Dr(i,i.next,e)<0}function bY(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function fP(i,e){const t=Cw(i.i,i.x,i.y),n=Cw(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function lR(i,e,t,n){const r=Cw(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Ag(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Cw(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function SY(i,e,t,n){let r=0;for(let s=e,a=t-n;si.length)&&(e=i.length);for(var t=0,n=Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function KX(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return zX(i)}function Tw(i,e){return Tw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Tw(i,e)}function Hv(i,e){return FX(i)||XX(i,e)||rP(i,e)||YX()}function nP(i){return kX(i)||$X(i)||rP(i)||QX()}function ZX(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function iP(i){var e=ZX(i,"string");return typeof e=="symbol"?e:e+""}function rP(i,e){if(i){if(typeof i=="string")return ww(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ww(i,e):void 0}}var sP=function(e){e instanceof Array?e.forEach(sP):(e.map&&e.map.dispose(),e.dispose())},aP=function(e){e.geometry&&e.geometry.dispose(),e.material&&sP(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(aP)},rR=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),aP(t)}};function oP(i,e,t){var n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return{x:t*Math.sin(n)*Math.cos(r),y:t*Math.cos(n),z:t*Math.sin(n)*Math.sin(r)}}function JX(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),a=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),r}}function xf(i){return i*Math.PI/180}var lP=function(e){return 1-(xM(0,(.5-e)*Math.PI)[1]/Math.PI+1)/2},F3=function(e){return Math.max(0,Math.min(1,lP(e)))},sR=function(e){return .5-xM.invert(0,(2*(1-e)-1)*Math.PI)[1]/Math.PI},eY=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=Ec().domain([1,0]).range([t,n]).clamp(!0),s=Ec().domain([F3(t),F3(n)]).range([1,0]).clamp(!0),a=function(v){return s(F3(r(v)))},l=e.array,u=0,h=l.length;u2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,l=[],u=Math.pow(2,e),h=360/u,m=180/u,v=s===void 0?u-1:s,x=a===void 0?u-1:a,S=n,T=Math.min(u-1,v);S<=T;S++)for(var N=r,C=Math.min(u-1,x);N<=C;N++){var E=N,O=m;if(t){E=N===0?N:sR(N/u)*u;var U=N+1===u?N+1:sR((N+1)/u)*u;O=(U-E)*180/u}var I=-180+(S+.5)*h,j=90-(E*180/u+O/2),z=O;l.push({x:S,y:N,lng:I,lat:j,latLen:z})}return l},tY=6,nY=7,iY=3,rY=90,Hl=new WeakMap,Mh=new WeakMap,k3=new WeakMap,tv=new WeakMap,Go=new WeakMap,B_=new WeakMap,JA=new WeakMap,bf=new WeakMap,nv=new WeakSet,sY=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.tileUrl,a=r.minLevel,l=a===void 0?0:a,u=r.maxLevel,h=u===void 0?17:u,m=r.mercatorProjection,v=m===void 0?!0:m;return qX(this,e),n=GX(this,e),VX(n,nv),gh(n,Hl,void 0),gh(n,Mh,void 0),gh(n,k3,void 0),gh(n,tv,void 0),gh(n,Go,{}),gh(n,B_,void 0),gh(n,JA,void 0),gh(n,bf,void 0),pA(n,"minLevel",void 0),pA(n,"maxLevel",void 0),pA(n,"thresholds",nP(new Array(30)).map(function(x,S){return 8/Math.pow(2,S)})),pA(n,"curvatureResolution",5),pA(n,"tileMargin",0),pA(n,"clearTiles",function(){Object.values(hi(Go,n)).forEach(function(x){x.forEach(function(S){S.obj&&(n.remove(S.obj),rR(S.obj),delete S.obj)})}),vh(Go,n,{})}),vh(Hl,n,t),n.tileUrl=s,vh(Mh,n,v),n.minLevel=l,n.maxLevel=h,n.level=0,n.add(vh(bf,n,new Oi(new bu(hi(Hl,n)*.99,180,90),new cd({color:0})))),hi(bf,n).visible=!1,hi(bf,n).material.polygonOffset=!0,hi(bf,n).material.polygonOffsetUnits=3,hi(bf,n).material.polygonOffsetFactor=1,n}return WX(e,i),HX(e,[{key:"tileUrl",get:function(){return hi(k3,this)},set:function(n){vh(k3,this,n),this.updatePov(hi(JA,this))}},{key:"level",get:function(){return hi(tv,this)},set:function(n){var r,s=this;hi(Go,this)[n]||Rm(nv,this,aY).call(this,n);var a=hi(tv,this);if(vh(tv,this,n),!(n===a||a===void 0)){if(hi(bf,this).visible=n>0,hi(Go,this)[n].forEach(function(u){return u.obj&&(u.obj.material.depthWrite=!0)}),an)for(var l=n+1;l<=a;l++)hi(Go,this)[l]&&hi(Go,this)[l].forEach(function(u){u.obj&&(s.remove(u.obj),rR(u.obj),delete u.obj)});Rm(nv,this,oR).call(this)}}},{key:"updatePov",value:function(n){var r=this;if(!(!n||!(n instanceof gy))){vh(JA,this,n);var s;if(vh(B_,this,function(m){if(!m.hullPnts){var v=360/Math.pow(2,r.level),x=m.lng,S=m.lat,T=m.latLen,N=x-v/2,C=x+v/2,E=S-T/2,O=S+T/2;m.hullPnts=[[S,x],[E,N],[O,N],[E,C],[O,C]].map(function(U){var I=Hv(U,2),j=I[0],z=I[1];return oP(j,z,hi(Hl,r))}).map(function(U){var I=U.x,j=U.y,z=U.z;return new pe(I,j,z)})}return s||(s=new Og,n.updateMatrix(),n.updateMatrixWorld(),s.setFromProjectionMatrix(new jn().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse))),m.hullPnts.some(function(U){return s.containsPoint(U.clone().applyMatrix4(r.matrixWorld))})}),this.tileUrl){var a=n.position.clone(),l=a.distanceTo(this.getWorldPosition(new pe)),u=(l-hi(Hl,this))/hi(Hl,this),h=this.thresholds.findIndex(function(m){return m&&m<=u});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,h<0?this.thresholds.length:h)),Rm(nv,this,oR).call(this)}}}}])})(qa);function aY(i){var e=this;if(i>nY){hi(Go,this)[i]=[];return}var t=hi(Go,this)[i]=Mw(i,hi(Mh,this));t.forEach(function(n){return n.centroid=oP(n.lat,n.lng,hi(Hl,e))}),t.octree=xD().x(function(n){return n.centroid.x}).y(function(n){return n.centroid.y}).z(function(n){return n.centroid.z}).addAll(t)}function oR(){var i=this;if(!(!this.tileUrl||this.level===void 0||!hi(Go,this).hasOwnProperty(this.level))&&!(!hi(B_,this)&&this.level>tY)){var e=hi(Go,this)[this.level];if(hi(JA,this)){var t=this.worldToLocal(hi(JA,this).position.clone());if(e.octree){var n,r=this.worldToLocal(hi(JA,this).position.clone()),s=(r.length()-hi(Hl,this))*iY;e=(n=e.octree).findAllWithinRadius.apply(n,nP(r).concat([s]))}else{var a=JX(t),l=(a.r/hi(Hl,this)-1)*rY,u=l/Math.cos(xf(a.lat)),h=[a.lng-u,a.lng+u],m=[a.lat+l,a.lat-l],v=aR(this.level,hi(Mh,this),h[0],m[0]),x=Hv(v,2),S=x[0],T=x[1],N=aR(this.level,hi(Mh,this),h[1],m[1]),C=Hv(N,2),E=C[0],O=C[1];!e.record&&(e.record={});var U=e.record;if(!U.hasOwnProperty("".concat(Math.round((S+E)/2),"_").concat(Math.round((T+O)/2))))e=Mw(this.level,hi(Mh,this),S,T,E,O).map(function(H){var q="".concat(H.x,"_").concat(H.y);return U.hasOwnProperty(q)?U[q]:(U[q]=H,e.push(H),H)});else{for(var I=[],j=S;j<=E;j++)for(var z=T;z<=O;z++){var G="".concat(j,"_").concat(z);U.hasOwnProperty(G)||(U[G]=Mw(this.level,hi(Mh,this),j,z,j,z)[0],e.push(U[G])),I.push(U[G])}e=I}}}e.filter(function(H){return!H.obj}).filter(hi(B_,this)||function(){return!0}).forEach(function(H){var q=H.x,V=H.y,Q=H.lng,J=H.lat,ie=H.latLen,le=360/Math.pow(2,i.level);if(!H.obj){var re=le*(1-i.tileMargin),Z=ie*(1-i.tileMargin),ne=xf(Q),de=xf(-J),be=new Oi(new bu(hi(Hl,i),Math.ceil(re/i.curvatureResolution),Math.ceil(Z/i.curvatureResolution),xf(90-re/2)+ne,xf(re),xf(90-Z/2)+de,xf(Z)),new Fc);if(hi(Mh,i)){var Te=[J+ie/2,J-ie/2].map(function(Ce){return .5-Ce/180}),ae=Hv(Te,2),Me=ae[0],Ve=ae[1];eY(be.geometry.attributes.uv,Me,Ve)}H.obj=be}H.loading||(H.loading=!0,new oM().load(i.tileUrl(q,V,i.level),function(Ce){var Fe=H.obj;Fe&&(Ce.colorSpace=bn,Fe.material.map=Ce,Fe.material.color=null,Fe.material.needsUpdate=!0,i.add(Fe)),H.loading=!1}))})}}function oY(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let s=uP(i,0,r,t,!0);const a=[];if(!s||s.next===s.prev)return a;let l,u,h;if(n&&(s=fY(i,e,s,t)),i.length>80*t){l=i[0],u=i[1];let m=l,v=u;for(let x=t;xm&&(m=S),T>v&&(v=T)}h=Math.max(m-l,v-u),h=h!==0?32767/h:0}return fg(s,a,t,l,u,h,0),a}function uP(i,e,t,n,r){let s;if(r===SY(i,e,t,n)>0)for(let a=e;a=e;a-=n)s=lR(a/n|0,i[a],i[a+1],s);return s&&E0(s,s.next)&&(Ag(s),s=s.next),s}function od(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(E0(t,t.next)||Dr(t.prev,t,t.next)===0)){if(Ag(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function fg(i,e,t,n,r,s,a){if(!i)return;!a&&s&&gY(i,n,r,s);let l=i;for(;i.prev!==i.next;){const u=i.prev,h=i.next;if(s?uY(i,n,r,s):lY(i)){e.push(u.i,i.i,h.i),Ag(i),i=h.next,l=h.next;continue}if(i=h,i===l){a?a===1?(i=cY(od(i),e),fg(i,e,t,n,r,s,2)):a===2&&hY(i,e,t,n,r,s):fg(od(i),e,t,n,r,s,1);break}}}function lY(i){const e=i.prev,t=i,n=i.next;if(Dr(e,t,n)>=0)return!1;const r=e.x,s=t.x,a=n.x,l=e.y,u=t.y,h=n.y,m=Math.min(r,s,a),v=Math.min(l,u,h),x=Math.max(r,s,a),S=Math.max(l,u,h);let T=n.next;for(;T!==e;){if(T.x>=m&&T.x<=x&&T.y>=v&&T.y<=S&&xm(r,l,s,u,a,h,T.x,T.y)&&Dr(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function uY(i,e,t,n){const r=i.prev,s=i,a=i.next;if(Dr(r,s,a)>=0)return!1;const l=r.x,u=s.x,h=a.x,m=r.y,v=s.y,x=a.y,S=Math.min(l,u,h),T=Math.min(m,v,x),N=Math.max(l,u,h),C=Math.max(m,v,x),E=Ew(S,T,e,t,n),O=Ew(N,C,e,t,n);let U=i.prevZ,I=i.nextZ;for(;U&&U.z>=E&&I&&I.z<=O;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&xm(l,m,u,v,h,x,U.x,U.y)&&Dr(U.prev,U,U.next)>=0||(U=U.prevZ,I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&xm(l,m,u,v,h,x,I.x,I.y)&&Dr(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;U&&U.z>=E;){if(U.x>=S&&U.x<=N&&U.y>=T&&U.y<=C&&U!==r&&U!==a&&xm(l,m,u,v,h,x,U.x,U.y)&&Dr(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;I&&I.z<=O;){if(I.x>=S&&I.x<=N&&I.y>=T&&I.y<=C&&I!==r&&I!==a&&xm(l,m,u,v,h,x,I.x,I.y)&&Dr(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function cY(i,e){let t=i;do{const n=t.prev,r=t.next.next;!E0(n,r)&&hP(n,t,t.next,r)&&dg(n,r)&&dg(r,n)&&(e.push(n.i,t.i,r.i),Ag(t),Ag(t.next),t=i=r),t=t.next}while(t!==i);return od(t)}function hY(i,e,t,n,r,s){let a=i;do{let l=a.next.next;for(;l!==a.prev;){if(a.i!==l.i&&yY(a,l)){let u=fP(a,l);a=od(a,a.next),u=od(u,u.next),fg(a,e,t,n,r,s,0),fg(u,e,t,n,r,s,0);return}l=l.next}a=a.next}while(a!==i)}function fY(i,e,t,n){const r=[];for(let s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const v=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(v<=n&&v>s&&(s=v,a=t.x=t.x&&t.x>=u&&n!==t.x&&cP(ra.x||t.x===a.x&&mY(a,t)))&&(a=t,m=v)}t=t.next}while(t!==l);return a}function mY(i,e){return Dr(i.prev,i,e.prev)<0&&Dr(e.next,i,i.next)<0}function gY(i,e,t,n){let r=i;do r.z===0&&(r.z=Ew(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,vY(r)}function vY(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let a=n,l=0;for(let h=0;h0||u>0&&a;)l!==0&&(u===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,l--):(r=a,a=a.nextZ,u--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=a}s.nextZ=null,t*=2}while(e>1);return i}function Ew(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function _Y(i){let e=i,t=i;do(e.x=(i-a)*(s-l)&&(i-a)*(n-l)>=(t-a)*(e-l)&&(t-a)*(s-l)>=(r-a)*(n-l)}function xm(i,e,t,n,r,s,a,l){return!(i===a&&e===l)&&cP(i,e,t,n,r,s,a,l)}function yY(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!xY(i,e)&&(dg(i,e)&&dg(e,i)&&bY(i,e)&&(Dr(i.prev,i,e.prev)||Dr(i,e.prev,e))||E0(i,e)&&Dr(i.prev,i,i.next)>0&&Dr(e.prev,e,e.next)>0)}function Dr(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function E0(i,e){return i.x===e.x&&i.y===e.y}function hP(i,e,t,n){const r=rv(Dr(i,e,t)),s=rv(Dr(i,e,n)),a=rv(Dr(t,n,i)),l=rv(Dr(t,n,e));return!!(r!==s&&a!==l||r===0&&iv(i,t,e)||s===0&&iv(i,n,e)||a===0&&iv(t,i,n)||l===0&&iv(t,e,n))}function iv(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function rv(i){return i>0?1:i<0?-1:0}function xY(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&hP(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function dg(i,e){return Dr(i.prev,i,i.next)<0?Dr(i,e,i.next)>=0&&Dr(i,i.prev,e)>=0:Dr(i,e,i.prev)<0||Dr(i,i.next,e)<0}function bY(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function fP(i,e){const t=Cw(i.i,i.x,i.y),n=Cw(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function lR(i,e,t,n){const r=Cw(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Ag(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Cw(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function SY(i,e,t,n){let r=0;for(let s=e,a=t-n;si.length)&&(e=i.length);for(var t=0,n=Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,l=!1;return{s:function(){t=t.call(i)},n:function(){var u=t.next();return a=u.done,u},e:function(u){l=!0,s=u},f:function(){try{a||t.return==null||t.return()}finally{if(l)throw s}}}}function I_(i){return I_=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},I_(i)}function DY(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&Rw(i,e)}function dP(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dP=function(){return!!i})()}function PY(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function LY(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,s,a,l=[],u=!0,h=!1;try{if(s=(t=t.call(i)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=s.call(t)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(m){h=!0,r=m}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(h)throw r}}return l}}function UY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BY(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function OY(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return MY(i)}function Rw(i,e){return Rw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Rw(i,e)}function Jp(i,e){return wY(i)||LY(i,e)||bM(i,e)||UY()}function IY(i){return TY(i)||PY(i)||bM(i)||BY()}function bM(i,e){if(i){if(typeof i=="string")return Nw(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Nw(i,e):void 0}}var uR=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(s){if(r){var a=kh(s,r)*180/Math.PI;if(a>t)for(var l=vM(r,s),u=r.length>2||s.length>2?cg(r[2]||0,s[2]||0):null,h=u?function(x){return[].concat(IY(l(x)),[u(x)])}:l,m=1/Math.ceil(a/t),v=m;v<1;)n.push(h(v)),v+=m}n.push(r=s)}),n},Dw=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:Hi,Float32BufferAttribute:Si},FY=new Dw.BufferGeometry().setAttribute?"setAttribute":"addAttribute",AP=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;CY(this,e),n=EY(this,e),n.type="GeoJsonGeometry",n.parameters={geoJson:t,radius:r,resolution:s};var a=({Point:m,MultiPoint:v,LineString:x,MultiLineString:S,Polygon:T,MultiPolygon:N}[t.type]||function(){return[]})(t.coordinates,r),l=[],u=[],h=0;a.forEach(function(C){var E=l.length;em({indices:l,vertices:u},C),n.addGroup(E,l.length-E,h++)}),l.length&&n.setIndex(l),u.length&&n[FY]("position",new Dw.Float32BufferAttribute(u,3));function m(C,E){var O=z3(C[1],C[0],E+(C[2]||0)),U=[];return[{vertices:O,indices:U}]}function v(C,E){var O={vertices:[],indices:[]};return C.map(function(U){return m(U,E)}).forEach(function(U){var I=Jp(U,1),j=I[0];em(O,j)}),[O]}function x(C,E){for(var O=uR(C,s).map(function(H){var q=Jp(H,3),V=q[0],Q=q[1],J=q[2],ne=J===void 0?0:J;return z3(Q,V,E+ne)}),U=O_([O]),I=U.vertices,j=Math.round(I.length/3),z=[],G=1;G2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function kY(i,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!i.hasAttribute("position")||!i.hasAttribute("normal")||!i.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(a){if(a.normalized||a.isInterleavedBufferAttribute){const l=new Float32Array(a.count*a.itemSize);for(let u=0,h=0;u2&&(l[h++]=a.getZ(u));return l}return a.array instanceof Float32Array?a.array:new Float32Array(a.array)}const r=i.index?i.toNonIndexed():i,s=e.generateTangents(n(r.attributes.position),n(r.attributes.normal),n(r.attributes.uv));if(t)for(let a=3;a=2&&a.setY(l,i.getY(l)),n>=3&&a.setZ(l,i.getZ(l)),n>=4&&a.setW(l,i.getW(l));return a}function VY(i){const e=i.attributes,t=i.morphTargets,n=new Map;for(const r in e){const s=e[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,F_(s)),e[r]=n.get(s))}for(const r in t){const s=t[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,F_(s)),t[r]=n.get(s))}}function jY(i){let e=0;for(const n in i.attributes){const r=i.getAttribute(n);e+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const t=i.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function HY(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=i.getIndex(),r=i.getAttribute("position"),s=n?n.count:r.count;let a=0;const l=Object.keys(i.attributes),u={},h={},m=[],v=["getX","getY","getZ","getW"],x=["setX","setY","setZ","setW"];for(let O=0,U=l.length;O{const q=new G.array.constructor(G.count*G.itemSize);h[I][H]=new G.constructor(q,G.itemSize,G.normalized)}))}const S=e*.5,T=Math.log10(1/e),N=Math.pow(10,T),C=S*N;for(let O=0;Oa.materialIndex!==l.materialIndex?a.materialIndex-l.materialIndex:a.start-l.start),i.getIndex()===null){const a=i.getAttribute("position"),l=[];for(let u=0;ut&&u.add(Q)}u.normalize(),T.setXYZ(E+j,u.x,u.y,u.z)}}return m.setAttribute("normal",T),m}const SM=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:kY,computeMorphedAttributes:$Y,deepCloneAttribute:GY,deinterleaveAttribute:F_,deinterleaveGeometry:VY,estimateBytesUsed:jY,interleaveAttributes:qY,mergeAttributes:Pw,mergeGeometries:zY,mergeGroups:XY,mergeVertices:HY,toCreasedNormals:YY,toTrianglesDrawMode:WY},Symbol.toStringTag,{value:"Module"}));var Ut=(function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}});function k_(i){"@babel/helpers - typeof";return k_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k_(i)}var QY=/^\s+/,KY=/\s+$/;function Sn(i,e){if(i=i||"",e=e||{},i instanceof Sn)return i;if(!(this instanceof Sn))return new Sn(i,e);var t=ZY(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}Sn.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,r,s,a,l;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),n<=.03928?a=n/12.92:a=Math.pow((n+.055)/1.055,2.4),r<=.03928?l=r/12.92:l=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*a+.0722*l},setAlpha:function(e){return this._a=pP(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=fR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=fR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=hR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=hR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return dR(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return nQ(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(br(this._r,255)*100)+"%",g:Math.round(br(this._g,255)*100)+"%",b:Math.round(br(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(br(this._r,255)*100)+"%, "+Math.round(br(this._g,255)*100)+"%, "+Math.round(br(this._b,255)*100)+"%)":"rgba("+Math.round(br(this._r,255)*100)+"%, "+Math.round(br(this._g,255)*100)+"%, "+Math.round(br(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:AQ[dR(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+AR(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=Sn(e);n="#"+AR(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return Sn(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(aQ,arguments)},brighten:function(){return this._applyModification(oQ,arguments)},darken:function(){return this._applyModification(lQ,arguments)},desaturate:function(){return this._applyModification(iQ,arguments)},saturate:function(){return this._applyModification(rQ,arguments)},greyscale:function(){return this._applyModification(sQ,arguments)},spin:function(){return this._applyModification(uQ,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(fQ,arguments)},complement:function(){return this._applyCombination(cQ,arguments)},monochromatic:function(){return this._applyCombination(dQ,arguments)},splitcomplement:function(){return this._applyCombination(hQ,arguments)},triad:function(){return this._applyCombination(pR,[3])},tetrad:function(){return this._applyCombination(pR,[4])}};Sn.fromRatio=function(i,e){if(k_(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=bm(i[n]));i=t}return Sn(i,e)};function ZY(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,s=null,a=!1,l=!1;return typeof i=="string"&&(i=vQ(i)),k_(i)=="object"&&(fc(i.r)&&fc(i.g)&&fc(i.b)?(e=JY(i.r,i.g,i.b),a=!0,l=String(i.r).substr(-1)==="%"?"prgb":"rgb"):fc(i.h)&&fc(i.s)&&fc(i.v)?(n=bm(i.s),r=bm(i.v),e=tQ(i.h,n,r),a=!0,l="hsv"):fc(i.h)&&fc(i.s)&&fc(i.l)&&(n=bm(i.s),s=bm(i.l),e=eQ(i.h,n,s),a=!0,l="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=pP(t),{ok:a,format:i.format||l,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function JY(i,e,t){return{r:br(i,255)*255,g:br(e,255)*255,b:br(t,255)*255}}function hR(i,e,t){i=br(i,255),e=br(e,255),t=br(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=(n+r)/2;if(n==r)s=a=0;else{var u=n-r;switch(a=l>.5?u/(2-n-r):u/(n+r),n){case i:s=(e-t)/u+(e1&&(v-=1),v<1/6?h+(m-h)*6*v:v<1/2?m:v<2/3?h+(m-h)*(2/3-v)*6:h}if(e===0)n=r=s=t;else{var l=t<.5?t*(1+e):t+e-t*e,u=2*t-l;n=a(u,l,i+1/3),r=a(u,l,i),s=a(u,l,i-1/3)}return{r:n*255,g:r*255,b:s*255}}function fR(i,e,t){i=br(i,255),e=br(e,255),t=br(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=n,u=n-r;if(a=n===0?0:u/n,n==r)s=0;else{switch(n){case i:s=(e-t)/u+(e>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(Sn(n));return s}function dQ(i,e){e=e||6;for(var t=Sn(i).toHsv(),n=t.h,r=t.s,s=t.v,a=[],l=1/e;e--;)a.push(Sn({h:n,s:r,v:s})),s=(s+l)%1;return a}Sn.mix=function(i,e,t){t=t===0?0:t||50;var n=Sn(i).toRgb(),r=Sn(e).toRgb(),s=t/100,a={r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a};return Sn(a)};Sn.readability=function(i,e){var t=Sn(i),n=Sn(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)};Sn.isReadable=function(i,e,t){var n=Sn.readability(i,e),r,s;switch(s=!1,r=_Q(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=n>=4.5;break;case"AAlarge":s=n>=3;break;case"AAAsmall":s=n>=7;break}return s};Sn.mostReadable=function(i,e,t){var n=null,r=0,s,a,l,u;t=t||{},a=t.includeFallbackColors,l=t.level,u=t.size;for(var h=0;hr&&(r=s,n=Sn(e[h]));return Sn.isReadable(i,n,{level:l,size:u})||!a?n:(t.includeFallbackColors=!1,Sn.mostReadable(i,["#fff","#000"],t))};var Lw=Sn.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},AQ=Sn.hexNames=pQ(Lw);function pQ(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function pP(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function br(i,e){mQ(i)&&(i="100%");var t=gQ(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function My(i){return Math.min(1,Math.max(0,i))}function mo(i){return parseInt(i,16)}function mQ(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function gQ(i){return typeof i=="string"&&i.indexOf("%")!=-1}function wl(i){return i.length==1?"0"+i:""+i}function bm(i){return i<=1&&(i=i*100+"%"),i}function mP(i){return Math.round(parseFloat(i)*255).toString(16)}function mR(i){return mo(i)/255}var _l=(function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function fc(i){return!!_l.CSS_UNIT.exec(i)}function vQ(i){i=i.replace(QY,"").replace(KY,"").toLowerCase();var e=!1;if(Lw[i])i=Lw[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=_l.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=_l.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=_l.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=_l.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=_l.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=_l.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=_l.hex8.exec(i))?{r:mo(t[1]),g:mo(t[2]),b:mo(t[3]),a:mR(t[4]),format:e?"name":"hex8"}:(t=_l.hex6.exec(i))?{r:mo(t[1]),g:mo(t[2]),b:mo(t[3]),format:e?"name":"hex"}:(t=_l.hex4.exec(i))?{r:mo(t[1]+""+t[1]),g:mo(t[2]+""+t[2]),b:mo(t[3]+""+t[3]),a:mR(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=_l.hex3.exec(i))?{r:mo(t[1]+""+t[1]),g:mo(t[2]+""+t[2]),b:mo(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function _Q(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function Uw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=[],r=null;return e.forEach(function(s){if(r){var a=kh(s,r)*180/Math.PI;if(a>t)for(var l=vM(r,s),u=r.length>2||s.length>2?cg(r[2]||0,s[2]||0):null,h=u?function(x){return[].concat(IY(l(x)),[u(x)])}:l,m=1/Math.ceil(a/t),v=m;v<1;)n.push(h(v)),v+=m}n.push(r=s)}),n},Dw=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:Hi,Float32BufferAttribute:Si},FY=new Dw.BufferGeometry().setAttribute?"setAttribute":"addAttribute",AP=(function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;CY(this,e),n=EY(this,e),n.type="GeoJsonGeometry",n.parameters={geoJson:t,radius:r,resolution:s};var a=({Point:m,MultiPoint:v,LineString:x,MultiLineString:S,Polygon:T,MultiPolygon:N}[t.type]||function(){return[]})(t.coordinates,r),l=[],u=[],h=0;a.forEach(function(C){var E=l.length;em({indices:l,vertices:u},C),n.addGroup(E,l.length-E,h++)}),l.length&&n.setIndex(l),u.length&&n[FY]("position",new Dw.Float32BufferAttribute(u,3));function m(C,E){var O=z3(C[1],C[0],E+(C[2]||0)),U=[];return[{vertices:O,indices:U}]}function v(C,E){var O={vertices:[],indices:[]};return C.map(function(U){return m(U,E)}).forEach(function(U){var I=Jp(U,1),j=I[0];em(O,j)}),[O]}function x(C,E){for(var O=uR(C,s).map(function(H){var q=Jp(H,3),V=q[0],Q=q[1],J=q[2],ie=J===void 0?0:J;return z3(Q,V,E+ie)}),U=O_([O]),I=U.vertices,j=Math.round(I.length/3),z=[],G=1;G2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function kY(i,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!i.hasAttribute("position")||!i.hasAttribute("normal")||!i.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(a){if(a.normalized||a.isInterleavedBufferAttribute){const l=new Float32Array(a.count*a.itemSize);for(let u=0,h=0;u2&&(l[h++]=a.getZ(u));return l}return a.array instanceof Float32Array?a.array:new Float32Array(a.array)}const r=i.index?i.toNonIndexed():i,s=e.generateTangents(n(r.attributes.position),n(r.attributes.normal),n(r.attributes.uv));if(t)for(let a=3;a=2&&a.setY(l,i.getY(l)),n>=3&&a.setZ(l,i.getZ(l)),n>=4&&a.setW(l,i.getW(l));return a}function VY(i){const e=i.attributes,t=i.morphTargets,n=new Map;for(const r in e){const s=e[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,F_(s)),e[r]=n.get(s))}for(const r in t){const s=t[r];s.isInterleavedBufferAttribute&&(n.has(s)||n.set(s,F_(s)),t[r]=n.get(s))}}function jY(i){let e=0;for(const n in i.attributes){const r=i.getAttribute(n);e+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const t=i.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function HY(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=i.getIndex(),r=i.getAttribute("position"),s=n?n.count:r.count;let a=0;const l=Object.keys(i.attributes),u={},h={},m=[],v=["getX","getY","getZ","getW"],x=["setX","setY","setZ","setW"];for(let O=0,U=l.length;O{const q=new G.array.constructor(G.count*G.itemSize);h[I][H]=new G.constructor(q,G.itemSize,G.normalized)}))}const S=e*.5,T=Math.log10(1/e),N=Math.pow(10,T),C=S*N;for(let O=0;Oa.materialIndex!==l.materialIndex?a.materialIndex-l.materialIndex:a.start-l.start),i.getIndex()===null){const a=i.getAttribute("position"),l=[];for(let u=0;ut&&u.add(Q)}u.normalize(),T.setXYZ(E+j,u.x,u.y,u.z)}}return m.setAttribute("normal",T),m}const SM=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:kY,computeMorphedAttributes:$Y,deepCloneAttribute:GY,deinterleaveAttribute:F_,deinterleaveGeometry:VY,estimateBytesUsed:jY,interleaveAttributes:qY,mergeAttributes:Pw,mergeGeometries:zY,mergeGroups:XY,mergeVertices:HY,toCreasedNormals:YY,toTrianglesDrawMode:WY},Symbol.toStringTag,{value:"Module"}));var Lt=(function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}});function k_(i){"@babel/helpers - typeof";return k_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k_(i)}var QY=/^\s+/,KY=/\s+$/;function Sn(i,e){if(i=i||"",e=e||{},i instanceof Sn)return i;if(!(this instanceof Sn))return new Sn(i,e);var t=ZY(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}Sn.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,n,r,s,a,l;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),n<=.03928?a=n/12.92:a=Math.pow((n+.055)/1.055,2.4),r<=.03928?l=r/12.92:l=Math.pow((r+.055)/1.055,2.4),.2126*s+.7152*a+.0722*l},setAlpha:function(e){return this._a=pP(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=fR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=fR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=hR(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=hR(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return dR(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return nQ(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(br(this._r,255)*100)+"%",g:Math.round(br(this._g,255)*100)+"%",b:Math.round(br(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(br(this._r,255)*100)+"%, "+Math.round(br(this._g,255)*100)+"%, "+Math.round(br(this._b,255)*100)+"%)":"rgba("+Math.round(br(this._r,255)*100)+"%, "+Math.round(br(this._g,255)*100)+"%, "+Math.round(br(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:AQ[dR(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+AR(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var s=Sn(e);n="#"+AR(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,s=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return Sn(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(aQ,arguments)},brighten:function(){return this._applyModification(oQ,arguments)},darken:function(){return this._applyModification(lQ,arguments)},desaturate:function(){return this._applyModification(iQ,arguments)},saturate:function(){return this._applyModification(rQ,arguments)},greyscale:function(){return this._applyModification(sQ,arguments)},spin:function(){return this._applyModification(uQ,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(fQ,arguments)},complement:function(){return this._applyCombination(cQ,arguments)},monochromatic:function(){return this._applyCombination(dQ,arguments)},splitcomplement:function(){return this._applyCombination(hQ,arguments)},triad:function(){return this._applyCombination(pR,[3])},tetrad:function(){return this._applyCombination(pR,[4])}};Sn.fromRatio=function(i,e){if(k_(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=bm(i[n]));i=t}return Sn(i,e)};function ZY(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,s=null,a=!1,l=!1;return typeof i=="string"&&(i=vQ(i)),k_(i)=="object"&&(fc(i.r)&&fc(i.g)&&fc(i.b)?(e=JY(i.r,i.g,i.b),a=!0,l=String(i.r).substr(-1)==="%"?"prgb":"rgb"):fc(i.h)&&fc(i.s)&&fc(i.v)?(n=bm(i.s),r=bm(i.v),e=tQ(i.h,n,r),a=!0,l="hsv"):fc(i.h)&&fc(i.s)&&fc(i.l)&&(n=bm(i.s),s=bm(i.l),e=eQ(i.h,n,s),a=!0,l="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=pP(t),{ok:a,format:i.format||l,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function JY(i,e,t){return{r:br(i,255)*255,g:br(e,255)*255,b:br(t,255)*255}}function hR(i,e,t){i=br(i,255),e=br(e,255),t=br(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=(n+r)/2;if(n==r)s=a=0;else{var u=n-r;switch(a=l>.5?u/(2-n-r):u/(n+r),n){case i:s=(e-t)/u+(e1&&(v-=1),v<1/6?h+(m-h)*6*v:v<1/2?m:v<2/3?h+(m-h)*(2/3-v)*6:h}if(e===0)n=r=s=t;else{var l=t<.5?t*(1+e):t+e-t*e,u=2*t-l;n=a(u,l,i+1/3),r=a(u,l,i),s=a(u,l,i-1/3)}return{r:n*255,g:r*255,b:s*255}}function fR(i,e,t){i=br(i,255),e=br(e,255),t=br(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),s,a,l=n,u=n-r;if(a=n===0?0:u/n,n==r)s=0;else{switch(n){case i:s=(e-t)/u+(e>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(Sn(n));return s}function dQ(i,e){e=e||6;for(var t=Sn(i).toHsv(),n=t.h,r=t.s,s=t.v,a=[],l=1/e;e--;)a.push(Sn({h:n,s:r,v:s})),s=(s+l)%1;return a}Sn.mix=function(i,e,t){t=t===0?0:t||50;var n=Sn(i).toRgb(),r=Sn(e).toRgb(),s=t/100,a={r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a};return Sn(a)};Sn.readability=function(i,e){var t=Sn(i),n=Sn(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)};Sn.isReadable=function(i,e,t){var n=Sn.readability(i,e),r,s;switch(s=!1,r=_Q(t),r.level+r.size){case"AAsmall":case"AAAlarge":s=n>=4.5;break;case"AAlarge":s=n>=3;break;case"AAAsmall":s=n>=7;break}return s};Sn.mostReadable=function(i,e,t){var n=null,r=0,s,a,l,u;t=t||{},a=t.includeFallbackColors,l=t.level,u=t.size;for(var h=0;hr&&(r=s,n=Sn(e[h]));return Sn.isReadable(i,n,{level:l,size:u})||!a?n:(t.includeFallbackColors=!1,Sn.mostReadable(i,["#fff","#000"],t))};var Lw=Sn.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},AQ=Sn.hexNames=pQ(Lw);function pQ(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function pP(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function br(i,e){mQ(i)&&(i="100%");var t=gQ(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function My(i){return Math.min(1,Math.max(0,i))}function mo(i){return parseInt(i,16)}function mQ(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function gQ(i){return typeof i=="string"&&i.indexOf("%")!=-1}function wl(i){return i.length==1?"0"+i:""+i}function bm(i){return i<=1&&(i=i*100+"%"),i}function mP(i){return Math.round(parseFloat(i)*255).toString(16)}function mR(i){return mo(i)/255}var _l=(function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function fc(i){return!!_l.CSS_UNIT.exec(i)}function vQ(i){i=i.replace(QY,"").replace(KY,"").toLowerCase();var e=!1;if(Lw[i])i=Lw[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=_l.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=_l.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=_l.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=_l.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=_l.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=_l.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=_l.hex8.exec(i))?{r:mo(t[1]),g:mo(t[2]),b:mo(t[3]),a:mR(t[4]),format:e?"name":"hex8"}:(t=_l.hex6.exec(i))?{r:mo(t[1]),g:mo(t[2]),b:mo(t[3]),format:e?"name":"hex"}:(t=_l.hex4.exec(i))?{r:mo(t[1]+""+t[1]),g:mo(t[2]+""+t[2]),b:mo(t[3]+""+t[3]),a:mR(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=_l.hex3.exec(i))?{r:mo(t[1]+""+t[1]),g:mo(t[2]+""+t[2]),b:mo(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function _Q(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function Uw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},l.prototype.update=function(u,h){h===void 0&&(h=!0),this._currentTick++,this._currentTime+=u,this._tickDeltaTime=u,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),h&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},l.prototype.getTimer=function(){return Date.now()},l})();Object.defineProperty(n,"__esModule",{value:!0}),n.default=a},function(t,n,r){(function(s,a){t.exports=a()})(this,function(){return(function(s){function a(u){if(l[u])return l[u].exports;var h=l[u]={exports:{},id:u,loaded:!1};return s[u].call(h.exports,h,h.exports,a),h.loaded=!0,h.exports}var l={};return a.m=s,a.c=l,a.p="",a(0)})([function(s,a){var l=(function(){function u(){this.functions=[]}return u.prototype.add=function(h){return this.functions.indexOf(h)===-1&&(this.functions.push(h),!0)},u.prototype.remove=function(h){var m=this.functions.indexOf(h);return m>-1&&(this.functions.splice(m,1),!0)},u.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},u.prototype.dispatch=function(){for(var h=[],m=0;mh==m>-h?(s=h,h=e[++v]):(s=m,m=n[++x]);let S=0;if(vh==m>-h?(a=h+s,l=s-(a-h),h=e[++v]):(a=m+s,l=s-(a-m),m=n[++x]),s=a,l!==0&&(r[S++]=l);vh==m>-h?(a=s+h,u=a-s,l=s-(a-u)+(h-u),h=e[++v]):(a=s+m,u=a-s,l=s-(a-u)+(m-u),m=n[++x]),s=a,l!==0&&(r[S++]=l);for(;v=oe||-ne>=oe||(v=i-q,l=i-(q+v)+(v-r),v=t-V,h=t-(V+v)+(v-r),v=e-Q,u=e-(Q+v)+(v-s),v=n-J,m=n-(J+v)+(v-s),l===0&&u===0&&h===0&&m===0)||(oe=qQ*a+FQ*Math.abs(ne),ne+=q*m+J*l-(Q*h+V*u),ne>=oe||-ne>=oe))return ne;I=l*J,x=ea*l,S=x-(x-l),T=l-S,x=ea*J,N=x-(x-J),C=J-N,j=T*C-(I-S*N-T*N-S*C),z=u*V,x=ea*u,S=x-(x-u),T=u-S,x=ea*V,N=x-(x-V),C=V-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const ie=j3(4,_A,4,ma,vR);I=q*m,x=ea*q,S=x-(x-q),T=q-S,x=ea*m,N=x-(x-m),C=m-N,j=T*C-(I-S*N-T*N-S*C),z=Q*h,x=ea*Q,S=x-(x-Q),T=Q-S,x=ea*h,N=x-(x-h),C=h-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const Z=j3(ie,vR,4,ma,_R);I=l*m,x=ea*l,S=x-(x-l),T=l-S,x=ea*m,N=x-(x-m),C=m-N,j=T*C-(I-S*N-T*N-S*C),z=u*h,x=ea*u,S=x-(x-u),T=u-S,x=ea*h,N=x-(x-h),C=h-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const te=j3(Z,_R,4,ma,yR);return yR[te-1]}function Sm(i,e,t,n,r,s){const a=(e-s)*(t-r),l=(i-r)*(n-s),u=a-l,h=Math.abs(a+l);return Math.abs(u)>=zQ*h?u:-VQ(i,e,t,n,r,s,h)}const xR=Math.pow(2,-52),av=new Uint32Array(512);class pg{static from(e,t=XQ,n=YQ){const r=e.length,s=new Float64Array(r*2);for(let a=0;a>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:s}=this,a=e.length>>1;let l=1/0,u=1/0,h=-1/0,m=-1/0;for(let q=0;qh&&(h=V),Q>m&&(m=Q),this._ids[q]=q}const v=(l+h)/2,x=(u+m)/2;let S,T,N;for(let q=0,V=1/0;q0&&(T=q,V=Q)}let O=e[2*T],U=e[2*T+1],I=1/0;for(let q=0;qJ&&(q[V++]=ne,J=oe)}this.hull=q.subarray(0,V),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Sm(C,E,O,U,j,z)<0){const q=T,V=O,Q=U;T=N,O=j,U=z,N=q,j=V,z=Q}const G=$Q(C,E,O,U,j,z);this._cx=G.x,this._cy=G.y;for(let q=0;q0&&Math.abs(ne-V)<=xR&&Math.abs(oe-Q)<=xR||(V=ne,Q=oe,J===S||J===T||J===N))continue;let ie=0;for(let Te=0,ae=this._hashKey(ne,oe);Te=0;)if(Z=te,Z===ie){Z=-1;break}if(Z===-1)continue;let de=this._addTriangle(Z,J,n[Z],-1,-1,r[Z]);r[J]=this._legalize(de+2),r[Z]=de,H++;let Se=n[Z];for(;te=n[Se],Sm(ne,oe,e[2*Se],e[2*Se+1],e[2*te],e[2*te+1])<0;)de=this._addTriangle(Se,J,te,r[J],-1,r[Se]),r[J]=this._legalize(de+2),n[Se]=Se,H--,Se=te;if(Z===ie)for(;te=t[Z],Sm(ne,oe,e[2*te],e[2*te+1],e[2*Z],e[2*Z+1])<0;)de=this._addTriangle(te,J,Z,-1,r[Z],r[te]),this._legalize(de+2),r[te]=de,n[Z]=Z,H--,Z=te;this._hullStart=t[J]=Z,n[Z]=t[Se]=J,n[J]=Se,s[this._hashKey(ne,oe)]=J,s[this._hashKey(e[2*Z],e[2*Z+1])]=Z}this.hull=new Uint32Array(H);for(let q=0,V=this._hullStart;q0?3-t:1+t)/4}function H3(i,e,t,n){const r=i-t,s=e-n;return r*r+s*s}function HQ(i,e,t,n,r,s,a,l){const u=i-a,h=e-l,m=t-a,v=n-l,x=r-a,S=s-l,T=u*u+h*h,N=m*m+v*v,C=x*x+S*S;return u*(v*C-N*S)-h*(m*C-N*x)+T*(m*S-v*x)<0}function WQ(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=(h*m-l*v)*x,T=(a*v-u*m)*x;return S*S+T*T}function $Q(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=i+(h*m-l*v)*x,T=e+(a*v-u*m)*x;return{x:S,y:T}}function qA(i,e,t,n){if(n-t<=20)for(let r=t+1;r<=n;r++){const s=i[r],a=e[s];let l=r-1;for(;l>=t&&e[i[l]]>a;)i[l+1]=i[l--];i[l+1]=s}else{const r=t+n>>1;let s=t+1,a=n;nm(i,r,s),e[i[t]]>e[i[n]]&&nm(i,t,n),e[i[s]]>e[i[n]]&&nm(i,s,n),e[i[t]]>e[i[s]]&&nm(i,t,s);const l=i[s],u=e[l];for(;;){do s++;while(e[i[s]]u);if(a=a-t?(qA(i,e,s,n),qA(i,e,t,a-1)):(qA(i,e,t,a-1),qA(i,e,s,n))}}function nm(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function XQ(i){return i[0]}function YQ(i){return i[1]}function QQ(i,e){var t,n,r=0,s,a,l,u,h,m,v,x=i[0],S=i[1],T=e.length;for(t=0;t=0||a<=0&&u>=0)return 0}else if(h>=0&&l<=0||h<=0&&l>=0){if(s=Sm(a,u,l,h,0,0),s===0)return 0;(s>0&&h>0&&l<=0||s<0&&h<=0&&l>0)&&r++}m=v,l=h,a=u}}return r%2!==0}function KQ(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return[...i.geometry.coordinates];if(i.type==="Point")return[...i.coordinates]}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return[...i];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ZQ(i){return i.type==="Feature"?i.geometry:i}function JQ(i,e,t={}){if(!i)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=KQ(i),r=ZQ(e),s=r.type,a=e.bbox;let l=r.coordinates;if(a&&eK(n,a)===!1)return!1;s==="Polygon"&&(l=[l]);let u=!1;for(var h=0;h=i[0]&&e[3]>=i[1]}var tK=JQ;const bR=1e-6;class qf{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const r=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${r},${s}`:(Math.abs(this._x1-r)>bR||Math.abs(this._y1-s)>bR)&&(this._+="L"+r+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=s}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class Bw{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class nK{constructor(e,[t,n,r,s]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this;let s,a;const l=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let N=0,C=0,E=n.length,O,U;N1;)s-=2;for(let a=2;a0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function oK(i,e,t){return[i+Math.sin(i+e)*t,e+Math.cos(i-e)*t]}class wM{static from(e,t=rK,n=sK,r){return new wM("length"in e?lK(e,t,n,r):Float64Array.from(uK(e,t,n,r)))}constructor(e){this._delaunator=new pg(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&aK(e)){this.collinear=Int32Array.from({length:t.length/2},(x,S)=>S).sort((x,S)=>t[2*x]-t[2*S]||t[2*x+1]-t[2*S+1]);const u=this.collinear[0],h=this.collinear[this.collinear.length-1],m=[t[2*u],t[2*u+1],t[2*h],t[2*h+1]],v=1e-8*Math.hypot(m[3]-m[1],m[2]-m[0]);for(let x=0,S=t.length/2;x0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new nK(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:s,triangles:a,collinear:l}=this;if(l){const v=l.indexOf(e);v>0&&(yield l[v-1]),v=0&&s!==n&&s!==r;)n=s;return s}_step(e,t,n){const{inedges:r,hull:s,_hullIndex:a,halfedges:l,triangles:u,points:h}=this;if(r[e]===-1||!h.length)return(e+1)%(h.length>>1);let m=e,v=yA(t-h[e*2],2)+yA(n-h[e*2+1],2);const x=r[e];let S=x;do{let T=u[S];const N=yA(t-h[T*2],2)+yA(n-h[T*2+1],2);if(N0?1:i<0?-1:0},_P=Math.sqrt;function AK(i){return i>1?SR:i<-1?-SR:Math.asin(i)}function yP(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function yo(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function z_(i,e){return[i[0]+e[0],i[1]+e[1],i[2]+e[2]]}function G_(i){var e=_P(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);return[i[0]/e,i[1]/e,i[2]/e]}function MM(i){return[cK(i[1],i[0])*wR,AK(hK(-1,fK(1,i[2])))*wR]}function ru(i){const e=i[0]*TR,t=i[1]*TR,n=MR(t);return[n*MR(e),n*ER(e),ER(t)]}function EM(i){return i=i.map(e=>ru(e)),yP(i[0],yo(i[2],i[1]))}function pK(i){const e=gK(i),t=_K(e),n=vK(t,i),r=xK(t,i.length),s=mK(r,i),a=yK(t,i),{polygons:l,centers:u}=bK(a,t,i),h=SK(l),m=TK(t,i),v=wK(n,t);return{delaunay:e,edges:n,triangles:t,centers:u,neighbors:r,polygons:l,mesh:h,hull:m,urquhart:v,find:s}}function mK(i,e){function t(n,r){let s=n[0]-r[0],a=n[1]-r[1],l=n[2]-r[2];return s*s+a*a+l*l}return function(r,s,a){a===void 0&&(a=0);let l,u,h=a;const m=ru([r,s]);do l=a,a=null,u=t(m,ru(e[l])),i[l].forEach(v=>{let x=t(m,ru(e[v]));if(x1e32?r.push(v):S>s&&(s=S)}const a=1e6*_P(s);r.forEach(v=>i[v]=[a,0]),i.push([0,a]),i.push([-a,0]),i.push([0,-a]);const l=wM.from(i);l.projection=n;const{triangles:u,halfedges:h,inedges:m}=l;for(let v=0,x=h.length;vi.length-3-1&&(u[v]=e);return l}function vK(i,e){const t=new Set;return e.length===2?[[0,1]]:(i.forEach(n=>{if(n[0]!==n[1]&&!(EM(n.map(r=>e[r]))<0))for(let r=0,s;r<3;r++)s=(r+1)%3,t.add(h_([n[r],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function _K(i){const{triangles:e}=i;if(!e)return[];const t=[];for(let n=0,r=e.length/3;n{const n=t.map(s=>e[s]).map(ru),r=z_(z_(yo(n[1],n[0]),yo(n[2],n[1])),yo(n[0],n[2]));return MM(G_(r))})}function xK(i,e){const t=[];return i.forEach(n=>{for(let r=0;r<3;r++){const s=n[r],a=n[(r+1)%3];t[s]=t[s]||[],t[s].push(a)}}),i.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function bK(i,e,t){const n=[],r=i.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:r};if(t.length===2){const l=ru(t[0]),u=ru(t[1]),h=G_(z_(l,u)),m=G_(yo(l,u)),v=yo(h,m),x=[h,yo(h,v),yo(yo(h,v),v),yo(yo(yo(h,v),v),v)].map(MM).map(a);return n.push(x),n.push(x.slice().reverse()),{polygons:n,centers:r}}}e.forEach((l,u)=>{for(let h=0;h<3;h++){const m=l[h],v=l[(h+1)%3],x=l[(h+2)%3];n[m]=n[m]||[],n[m].push([v,x,u,[m,v,x]])}});const s=n.map(l=>{const u=[l[0][2]];let h=l[0][1];for(let m=1;m2)return u;if(u.length==2){const m=CR(t[l[0][3][0]],t[l[0][3][1]],r[u[0]]),v=CR(t[l[0][3][2]],t[l[0][3][0]],r[u[0]]),x=a(m),S=a(v);return[u[0],S,u[1],x]}});function a(l){let u=-1;return r.slice(e.length,1/0).forEach((h,m)=>{h[0]===l[0]&&h[1]===l[1]&&(u=m+e.length)}),u<0&&(u=r.length,r.push(l)),u}return{polygons:s,centers:r}}function CR(i,e,t){i=ru(i),e=ru(e),t=ru(t);const n=dK(yP(yo(e,i),t));return MM(G_(z_(i,e)).map(r=>n*r))}function SK(i){const e=[];return i.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let r of t)r>n&&e.push([n,r]),n=r}),e}function wK(i,e){return function(t){const n=new Map,r=new Map;return i.forEach((s,a)=>{const l=s.join("-");n.set(l,t[a]),r.set(l,!0)}),e.forEach(s=>{let a=0,l=-1;for(let u=0;u<3;u++){let h=h_([s[u],s[(u+1)%3]]).join("-");n.get(h)>a&&(a=n.get(h),l=h)}r.set(l,!1)}),i.map(s=>r.get(s.join("-")))}}function TK(i,e){const t=new Set,n=[];i.map(l=>{if(!(EM(l.map(u=>e[u>e.length?0:u]))>1e-12))for(let u=0;u<3;u++){let h=[l[u],l[(u+1)%3]],m=`${h[0]}-${h[1]}`;t.has(m)?t.delete(m):t.add(`${h[1]}-${h[0]}`)}});const r=new Map;let s;if(t.forEach(l=>{l=l.split("-").map(Number),r.set(l[0],l[1]),s=l[0]}),s===void 0)return n;let a=s;do{n.push(a);let l=r.get(a);r.set(a,-1),a=l}while(a>-1&&a!==s);return n}function MK(i){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(r=>[e._vx(r),e._vy(r),r]).filter(r=>isFinite(r[0]+r[1]));e.points=n.map(r=>[r[0],r[1]]),e.valid=n.map(r=>r[2]),e.delaunay=pK(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return k5(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return k5(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((r,s)=>n.features.push({type:"Feature",geometry:r?{type:"Polygon",coordinates:[[...r,r[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,r)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[r],n)).filter(n=>EM(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>kh(e.points[s[0]],e.points[s[1]])),r=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[a],urquhart:!!r[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:r}=e.delaunay,s=[];for(const a of r)if(a)for(let l=a.length,u=a[l-1],h=a[0],m=0;mu&&s.push([n[u],n[h]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,r){if(e._found=e.delaunay.find(t,n,e._found),!r||kh([t,n],e.points[e._found])r[s]),r[n[0]]]]}},i?e(i):e}function Ow(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},l.prototype.update=function(u,h){h===void 0&&(h=!0),this._currentTick++,this._currentTime+=u,this._tickDeltaTime=u,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),h&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},l.prototype.getTimer=function(){return Date.now()},l})();Object.defineProperty(n,"__esModule",{value:!0}),n.default=a},function(t,n,r){(function(s,a){t.exports=a()})(this,function(){return(function(s){function a(u){if(l[u])return l[u].exports;var h=l[u]={exports:{},id:u,loaded:!1};return s[u].call(h.exports,h,h.exports,a),h.loaded=!0,h.exports}var l={};return a.m=s,a.c=l,a.p="",a(0)})([function(s,a){var l=(function(){function u(){this.functions=[]}return u.prototype.add=function(h){return this.functions.indexOf(h)===-1&&(this.functions.push(h),!0)},u.prototype.remove=function(h){var m=this.functions.indexOf(h);return m>-1&&(this.functions.splice(m,1),!0)},u.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},u.prototype.dispatch=function(){for(var h=[],m=0;mh==m>-h?(s=h,h=e[++v]):(s=m,m=n[++x]);let S=0;if(vh==m>-h?(a=h+s,l=s-(a-h),h=e[++v]):(a=m+s,l=s-(a-m),m=n[++x]),s=a,l!==0&&(r[S++]=l);vh==m>-h?(a=s+h,u=a-s,l=s-(a-u)+(h-u),h=e[++v]):(a=s+m,u=a-s,l=s-(a-u)+(m-u),m=n[++x]),s=a,l!==0&&(r[S++]=l);for(;v=le||-ie>=le||(v=i-q,l=i-(q+v)+(v-r),v=t-V,h=t-(V+v)+(v-r),v=e-Q,u=e-(Q+v)+(v-s),v=n-J,m=n-(J+v)+(v-s),l===0&&u===0&&h===0&&m===0)||(le=qQ*a+FQ*Math.abs(ie),ie+=q*m+J*l-(Q*h+V*u),ie>=le||-ie>=le))return ie;I=l*J,x=ea*l,S=x-(x-l),T=l-S,x=ea*J,N=x-(x-J),C=J-N,j=T*C-(I-S*N-T*N-S*C),z=u*V,x=ea*u,S=x-(x-u),T=u-S,x=ea*V,N=x-(x-V),C=V-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const re=j3(4,_A,4,ma,vR);I=q*m,x=ea*q,S=x-(x-q),T=q-S,x=ea*m,N=x-(x-m),C=m-N,j=T*C-(I-S*N-T*N-S*C),z=Q*h,x=ea*Q,S=x-(x-Q),T=Q-S,x=ea*h,N=x-(x-h),C=h-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const Z=j3(re,vR,4,ma,_R);I=l*m,x=ea*l,S=x-(x-l),T=l-S,x=ea*m,N=x-(x-m),C=m-N,j=T*C-(I-S*N-T*N-S*C),z=u*h,x=ea*u,S=x-(x-u),T=u-S,x=ea*h,N=x-(x-h),C=h-N,G=T*C-(z-S*N-T*N-S*C),E=j-G,v=j-E,ma[0]=j-(E+v)+(v-G),O=I+E,v=O-I,U=I-(O-v)+(E-v),E=U-z,v=U-E,ma[1]=U-(E+v)+(v-z),H=O+E,v=H-O,ma[2]=O-(H-v)+(E-v),ma[3]=H;const ne=j3(Z,_R,4,ma,yR);return yR[ne-1]}function Sm(i,e,t,n,r,s){const a=(e-s)*(t-r),l=(i-r)*(n-s),u=a-l,h=Math.abs(a+l);return Math.abs(u)>=zQ*h?u:-VQ(i,e,t,n,r,s,h)}const xR=Math.pow(2,-52),av=new Uint32Array(512);class pg{static from(e,t=XQ,n=YQ){const r=e.length,s=new Float64Array(r*2);for(let a=0;a>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:s}=this,a=e.length>>1;let l=1/0,u=1/0,h=-1/0,m=-1/0;for(let q=0;qh&&(h=V),Q>m&&(m=Q),this._ids[q]=q}const v=(l+h)/2,x=(u+m)/2;let S,T,N;for(let q=0,V=1/0;q0&&(T=q,V=Q)}let O=e[2*T],U=e[2*T+1],I=1/0;for(let q=0;qJ&&(q[V++]=ie,J=le)}this.hull=q.subarray(0,V),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Sm(C,E,O,U,j,z)<0){const q=T,V=O,Q=U;T=N,O=j,U=z,N=q,j=V,z=Q}const G=$Q(C,E,O,U,j,z);this._cx=G.x,this._cy=G.y;for(let q=0;q0&&Math.abs(ie-V)<=xR&&Math.abs(le-Q)<=xR||(V=ie,Q=le,J===S||J===T||J===N))continue;let re=0;for(let Te=0,ae=this._hashKey(ie,le);Te=0;)if(Z=ne,Z===re){Z=-1;break}if(Z===-1)continue;let de=this._addTriangle(Z,J,n[Z],-1,-1,r[Z]);r[J]=this._legalize(de+2),r[Z]=de,H++;let be=n[Z];for(;ne=n[be],Sm(ie,le,e[2*be],e[2*be+1],e[2*ne],e[2*ne+1])<0;)de=this._addTriangle(be,J,ne,r[J],-1,r[be]),r[J]=this._legalize(de+2),n[be]=be,H--,be=ne;if(Z===re)for(;ne=t[Z],Sm(ie,le,e[2*ne],e[2*ne+1],e[2*Z],e[2*Z+1])<0;)de=this._addTriangle(ne,J,Z,-1,r[Z],r[ne]),this._legalize(de+2),r[ne]=de,n[Z]=Z,H--,Z=ne;this._hullStart=t[J]=Z,n[Z]=t[be]=J,n[J]=be,s[this._hashKey(ie,le)]=J,s[this._hashKey(e[2*Z],e[2*Z+1])]=Z}this.hull=new Uint32Array(H);for(let q=0,V=this._hullStart;q0?3-t:1+t)/4}function H3(i,e,t,n){const r=i-t,s=e-n;return r*r+s*s}function HQ(i,e,t,n,r,s,a,l){const u=i-a,h=e-l,m=t-a,v=n-l,x=r-a,S=s-l,T=u*u+h*h,N=m*m+v*v,C=x*x+S*S;return u*(v*C-N*S)-h*(m*C-N*x)+T*(m*S-v*x)<0}function WQ(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=(h*m-l*v)*x,T=(a*v-u*m)*x;return S*S+T*T}function $Q(i,e,t,n,r,s){const a=t-i,l=n-e,u=r-i,h=s-e,m=a*a+l*l,v=u*u+h*h,x=.5/(a*h-l*u),S=i+(h*m-l*v)*x,T=e+(a*v-u*m)*x;return{x:S,y:T}}function qA(i,e,t,n){if(n-t<=20)for(let r=t+1;r<=n;r++){const s=i[r],a=e[s];let l=r-1;for(;l>=t&&e[i[l]]>a;)i[l+1]=i[l--];i[l+1]=s}else{const r=t+n>>1;let s=t+1,a=n;nm(i,r,s),e[i[t]]>e[i[n]]&&nm(i,t,n),e[i[s]]>e[i[n]]&&nm(i,s,n),e[i[t]]>e[i[s]]&&nm(i,t,s);const l=i[s],u=e[l];for(;;){do s++;while(e[i[s]]u);if(a=a-t?(qA(i,e,s,n),qA(i,e,t,a-1)):(qA(i,e,t,a-1),qA(i,e,s,n))}}function nm(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function XQ(i){return i[0]}function YQ(i){return i[1]}function QQ(i,e){var t,n,r=0,s,a,l,u,h,m,v,x=i[0],S=i[1],T=e.length;for(t=0;t=0||a<=0&&u>=0)return 0}else if(h>=0&&l<=0||h<=0&&l>=0){if(s=Sm(a,u,l,h,0,0),s===0)return 0;(s>0&&h>0&&l<=0||s<0&&h<=0&&l>0)&&r++}m=v,l=h,a=u}}return r%2!==0}function KQ(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return[...i.geometry.coordinates];if(i.type==="Point")return[...i.coordinates]}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return[...i];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ZQ(i){return i.type==="Feature"?i.geometry:i}function JQ(i,e,t={}){if(!i)throw new Error("point is required");if(!e)throw new Error("polygon is required");const n=KQ(i),r=ZQ(e),s=r.type,a=e.bbox;let l=r.coordinates;if(a&&eK(n,a)===!1)return!1;s==="Polygon"&&(l=[l]);let u=!1;for(var h=0;h=i[0]&&e[3]>=i[1]}var tK=JQ;const bR=1e-6;class qf{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;const r=e+n,s=t;if(n<0)throw new Error("negative radius");this._x1===null?this._+=`M${r},${s}`:(Math.abs(this._x1-r)>bR||Math.abs(this._y1-s)>bR)&&(this._+="L"+r+","+s),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=s}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}class Bw{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class nK{constructor(e,[t,n,r,s]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((s=+s)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=s,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this;let s,a;const l=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let N=0,C=0,E=n.length,O,U;N1;)s-=2;for(let a=2;a0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function oK(i,e,t){return[i+Math.sin(i+e)*t,e+Math.cos(i-e)*t]}class wM{static from(e,t=rK,n=sK,r){return new wM("length"in e?lK(e,t,n,r):Float64Array.from(uK(e,t,n,r)))}constructor(e){this._delaunator=new pg(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&aK(e)){this.collinear=Int32Array.from({length:t.length/2},(x,S)=>S).sort((x,S)=>t[2*x]-t[2*S]||t[2*x+1]-t[2*S+1]);const u=this.collinear[0],h=this.collinear[this.collinear.length-1],m=[t[2*u],t[2*u+1],t[2*h],t[2*h+1]],v=1e-8*Math.hypot(m[3]-m[1],m[2]-m[0]);for(let x=0,S=t.length/2;x0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new nK(this,e)}*neighbors(e){const{inedges:t,hull:n,_hullIndex:r,halfedges:s,triangles:a,collinear:l}=this;if(l){const v=l.indexOf(e);v>0&&(yield l[v-1]),v=0&&s!==n&&s!==r;)n=s;return s}_step(e,t,n){const{inedges:r,hull:s,_hullIndex:a,halfedges:l,triangles:u,points:h}=this;if(r[e]===-1||!h.length)return(e+1)%(h.length>>1);let m=e,v=yA(t-h[e*2],2)+yA(n-h[e*2+1],2);const x=r[e];let S=x;do{let T=u[S];const N=yA(t-h[T*2],2)+yA(n-h[T*2+1],2);if(N0?1:i<0?-1:0},_P=Math.sqrt;function AK(i){return i>1?SR:i<-1?-SR:Math.asin(i)}function yP(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function yo(i,e){return[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]]}function z_(i,e){return[i[0]+e[0],i[1]+e[1],i[2]+e[2]]}function G_(i){var e=_P(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);return[i[0]/e,i[1]/e,i[2]/e]}function MM(i){return[cK(i[1],i[0])*wR,AK(hK(-1,fK(1,i[2])))*wR]}function ru(i){const e=i[0]*TR,t=i[1]*TR,n=MR(t);return[n*MR(e),n*ER(e),ER(t)]}function EM(i){return i=i.map(e=>ru(e)),yP(i[0],yo(i[2],i[1]))}function pK(i){const e=gK(i),t=_K(e),n=vK(t,i),r=xK(t,i.length),s=mK(r,i),a=yK(t,i),{polygons:l,centers:u}=bK(a,t,i),h=SK(l),m=TK(t,i),v=wK(n,t);return{delaunay:e,edges:n,triangles:t,centers:u,neighbors:r,polygons:l,mesh:h,hull:m,urquhart:v,find:s}}function mK(i,e){function t(n,r){let s=n[0]-r[0],a=n[1]-r[1],l=n[2]-r[2];return s*s+a*a+l*l}return function(r,s,a){a===void 0&&(a=0);let l,u,h=a;const m=ru([r,s]);do l=a,a=null,u=t(m,ru(e[l])),i[l].forEach(v=>{let x=t(m,ru(e[v]));if(x1e32?r.push(v):S>s&&(s=S)}const a=1e6*_P(s);r.forEach(v=>i[v]=[a,0]),i.push([0,a]),i.push([-a,0]),i.push([0,-a]);const l=wM.from(i);l.projection=n;const{triangles:u,halfedges:h,inedges:m}=l;for(let v=0,x=h.length;vi.length-3-1&&(u[v]=e);return l}function vK(i,e){const t=new Set;return e.length===2?[[0,1]]:(i.forEach(n=>{if(n[0]!==n[1]&&!(EM(n.map(r=>e[r]))<0))for(let r=0,s;r<3;r++)s=(r+1)%3,t.add(h_([n[r],n[s]]).join("-"))}),Array.from(t,n=>n.split("-").map(Number)))}function _K(i){const{triangles:e}=i;if(!e)return[];const t=[];for(let n=0,r=e.length/3;n{const n=t.map(s=>e[s]).map(ru),r=z_(z_(yo(n[1],n[0]),yo(n[2],n[1])),yo(n[0],n[2]));return MM(G_(r))})}function xK(i,e){const t=[];return i.forEach(n=>{for(let r=0;r<3;r++){const s=n[r],a=n[(r+1)%3];t[s]=t[s]||[],t[s].push(a)}}),i.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function bK(i,e,t){const n=[],r=i.slice();if(e.length===0){if(t.length<2)return{polygons:n,centers:r};if(t.length===2){const l=ru(t[0]),u=ru(t[1]),h=G_(z_(l,u)),m=G_(yo(l,u)),v=yo(h,m),x=[h,yo(h,v),yo(yo(h,v),v),yo(yo(yo(h,v),v),v)].map(MM).map(a);return n.push(x),n.push(x.slice().reverse()),{polygons:n,centers:r}}}e.forEach((l,u)=>{for(let h=0;h<3;h++){const m=l[h],v=l[(h+1)%3],x=l[(h+2)%3];n[m]=n[m]||[],n[m].push([v,x,u,[m,v,x]])}});const s=n.map(l=>{const u=[l[0][2]];let h=l[0][1];for(let m=1;m2)return u;if(u.length==2){const m=CR(t[l[0][3][0]],t[l[0][3][1]],r[u[0]]),v=CR(t[l[0][3][2]],t[l[0][3][0]],r[u[0]]),x=a(m),S=a(v);return[u[0],S,u[1],x]}});function a(l){let u=-1;return r.slice(e.length,1/0).forEach((h,m)=>{h[0]===l[0]&&h[1]===l[1]&&(u=m+e.length)}),u<0&&(u=r.length,r.push(l)),u}return{polygons:s,centers:r}}function CR(i,e,t){i=ru(i),e=ru(e),t=ru(t);const n=dK(yP(yo(e,i),t));return MM(G_(z_(i,e)).map(r=>n*r))}function SK(i){const e=[];return i.forEach(t=>{if(!t)return;let n=t[t.length-1];for(let r of t)r>n&&e.push([n,r]),n=r}),e}function wK(i,e){return function(t){const n=new Map,r=new Map;return i.forEach((s,a)=>{const l=s.join("-");n.set(l,t[a]),r.set(l,!0)}),e.forEach(s=>{let a=0,l=-1;for(let u=0;u<3;u++){let h=h_([s[u],s[(u+1)%3]]).join("-");n.get(h)>a&&(a=n.get(h),l=h)}r.set(l,!1)}),i.map(s=>r.get(s.join("-")))}}function TK(i,e){const t=new Set,n=[];i.map(l=>{if(!(EM(l.map(u=>e[u>e.length?0:u]))>1e-12))for(let u=0;u<3;u++){let h=[l[u],l[(u+1)%3]],m=`${h[0]}-${h[1]}`;t.has(m)?t.delete(m):t.add(`${h[1]}-${h[0]}`)}});const r=new Map;let s;if(t.forEach(l=>{l=l.split("-").map(Number),r.set(l[0],l[1]),s=l[0]}),s===void 0)return n;let a=s;do{n.push(a);let l=r.get(a);r.set(a,-1),a=l}while(a>-1&&a!==s);return n}function MK(i){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const n=e._data.map(r=>[e._vx(r),e._vy(r),r]).filter(r=>isFinite(r[0]+r[1]));e.points=n.map(r=>[r[0],r[1]]),e.valid=n.map(r=>r[2]),e.delaunay=pK(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return k5(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return k5(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((r,s)=>n.features.push({type:"Feature",geometry:r?{type:"Polygon",coordinates:[[...r,r[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&n.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),n},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((n,r)=>(n=n.map(s=>e.points[s]),n.center=e.delaunay.centers[r],n)).filter(n=>EM(n)>0).map(n=>({type:"Feature",properties:{circumcenter:n.center},geometry:{type:"Polygon",coordinates:[[...n,n[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const n=e.delaunay.edges.map(s=>kh(e.points[s[0]],e.points[s[1]])),r=e.delaunay.urquhart(n);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:n[a],urquhart:!!r[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(n=>[e.points[n[0]],e.points[n[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:n,polygons:r}=e.delaunay,s=[];for(const a of r)if(a)for(let l=a.length,u=a[l-1],h=a[0],m=0;mu&&s.push([n[u],n[h]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,n,r){if(e._found=e.delaunay.find(t,n,e._found),!r||kh([t,n],e.points[e._found])r[s]),r[n[0]]]]}},i?e(i):e}function Ow(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,n=t===void 0?1/0:t,r=zK(i,n),s=og(r),a=GK(i,n),l=[].concat(W3(s),W3(a)),u={type:"Polygon",coordinates:i},h=qD(u),m=Wl(h,2),v=Wl(m[0],2),x=v[0],S=v[1],T=Wl(m[1],2),N=T[0],C=T[1],E=x>N||C>=89||S<=-89,O=[];if(E){var U=MK(l).triangles(),I=new Map(l.map(function(te,de){var Se=Wl(te,2),Te=Se[0],ae=Se[1];return["".concat(Te,"-").concat(ae),de]}));U.features.forEach(function(te){var de,Se=te.geometry.coordinates[0].slice(0,3).reverse(),Te=[];if(Se.forEach(function(Me){var Ve=Wl(Me,2),Ce=Ve[0],Fe=Ve[1],et="".concat(Ce,"-").concat(Fe);I.has(et)&&Te.push(I.get(et))}),Te.length===3){if(Te.some(function(Me){return Mee)for(var l=vM(r,s),u=1/Math.ceil(a/e),h=u;h<1;)n.push(l(h)),h+=u}n.push(r=s)}),n})}function GK(i,e){var t={type:"Polygon",coordinates:i},n=qD(t),r=Wl(n,2),s=Wl(r[0],2),a=s[0],l=s[1],u=Wl(r[1],2),h=u[0],m=u[1];if(Math.min(Math.abs(h-a),Math.abs(m-l))h||m>=89||l<=-89;return qK(e,{minLng:a,maxLng:h,minLat:l,maxLat:m}).filter(function(x){return Fw(x,t,v)})}function qK(i){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,n=e.maxLng,r=e.minLat,s=e.maxLat,a=Math.round(Math.pow(360/i,2)/Math.PI),l=(1+Math.sqrt(5))/2,u=function(E){return E/l*360%360-180},h=function(E){return Math.acos(2*E/a-1)/Math.PI*180-90},m=function(E){return a*(Math.cos((E+90)*Math.PI/180)+1)/2},v=[s!==void 0?Math.ceil(m(s)):0,r!==void 0?Math.floor(m(r)):a-1],x=t===void 0&&n===void 0?function(){return!0}:t===void 0?function(C){return C<=n}:n===void 0?function(C){return C>=t}:n>=t?function(C){return C>=t&&C<=n}:function(C){return C>=t||C<=n},S=[],T=v[0];T<=v[1];T++){var N=u(T);x(N)&&S.push([N,h(T)])}return S}function Fw(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?xX(e,i):tK(i,e)}var $v=window.THREE?window.THREE:{BufferGeometry:Hi,Float32BufferAttribute:Si},NR=new $v.BufferGeometry().setAttribute?"setAttribute":"addAttribute",CM=(function(i){function e(t,n,r,s,a,l,u){var h;DK(this,e),h=RK(this,e),h.type="ConicPolygonGeometry",h.parameters={polygonGeoJson:t,bottomHeight:n,topHeight:r,closedBottom:s,closedTop:a,includeSides:l,curvatureResolution:u},n=n||0,r=r||1,s=s!==void 0?s:!0,a=a!==void 0?a:!0,l=l!==void 0?l:!0,u=u||5;var m=kK(t,{resolution:u}),v=m.contour,x=m.triangles,S=og(x.uvs),T=[],N=[],C=[],E=0,O=function(G){var H=Math.round(T.length/3),q=C.length;T=T.concat(G.vertices),N=N.concat(G.uvs),C=C.concat(H?G.indices.map(function(V){return V+H}):G.indices),h.addGroup(q,C.length-q,E++)};l&&O(I()),s&&O(j(n,!1)),a&&O(j(r,!0)),h.setIndex(C),h[NR]("position",new $v.Float32BufferAttribute(T,3)),h[NR]("uv",new $v.Float32BufferAttribute(N,2)),h.computeVertexNormals();function U(z,G){var H=typeof G=="function"?G:function(){return G},q=z.map(function(V){return V.map(function(Q){var J=Wl(Q,2),ne=J[0],oe=J[1];return VK(oe,ne,H(ne,oe))})});return O_(q)}function I(){for(var z=U(v,n),G=z.vertices,H=z.holes,q=U(v,r),V=q.vertices,Q=og([V,G]),J=Math.round(V.length/3),ne=new Set(H),oe=0,ie=[],Z=0;Z=0;Te--)for(var ae=0;ae1&&arguments[1]!==void 0?arguments[1]:!0;return{indices:G?x.indices:x.indices.slice().reverse(),vertices:U([x.points],z).vertices,uvs:S}}return h}return LK(e,i),PK(e)})($v.BufferGeometry);function VK(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function kw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,n=t===void 0?1/0:t,r=zK(i,n),s=og(r),a=GK(i,n),l=[].concat(W3(s),W3(a)),u={type:"Polygon",coordinates:i},h=qD(u),m=Wl(h,2),v=Wl(m[0],2),x=v[0],S=v[1],T=Wl(m[1],2),N=T[0],C=T[1],E=x>N||C>=89||S<=-89,O=[];if(E){var U=MK(l).triangles(),I=new Map(l.map(function(ne,de){var be=Wl(ne,2),Te=be[0],ae=be[1];return["".concat(Te,"-").concat(ae),de]}));U.features.forEach(function(ne){var de,be=ne.geometry.coordinates[0].slice(0,3).reverse(),Te=[];if(be.forEach(function(Me){var Ve=Wl(Me,2),Ce=Ve[0],Fe=Ve[1],tt="".concat(Ce,"-").concat(Fe);I.has(tt)&&Te.push(I.get(tt))}),Te.length===3){if(Te.some(function(Me){return Mee)for(var l=vM(r,s),u=1/Math.ceil(a/e),h=u;h<1;)n.push(l(h)),h+=u}n.push(r=s)}),n})}function GK(i,e){var t={type:"Polygon",coordinates:i},n=qD(t),r=Wl(n,2),s=Wl(r[0],2),a=s[0],l=s[1],u=Wl(r[1],2),h=u[0],m=u[1];if(Math.min(Math.abs(h-a),Math.abs(m-l))h||m>=89||l<=-89;return qK(e,{minLng:a,maxLng:h,minLat:l,maxLat:m}).filter(function(x){return Fw(x,t,v)})}function qK(i){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,n=e.maxLng,r=e.minLat,s=e.maxLat,a=Math.round(Math.pow(360/i,2)/Math.PI),l=(1+Math.sqrt(5))/2,u=function(E){return E/l*360%360-180},h=function(E){return Math.acos(2*E/a-1)/Math.PI*180-90},m=function(E){return a*(Math.cos((E+90)*Math.PI/180)+1)/2},v=[s!==void 0?Math.ceil(m(s)):0,r!==void 0?Math.floor(m(r)):a-1],x=t===void 0&&n===void 0?function(){return!0}:t===void 0?function(C){return C<=n}:n===void 0?function(C){return C>=t}:n>=t?function(C){return C>=t&&C<=n}:function(C){return C>=t||C<=n},S=[],T=v[0];T<=v[1];T++){var N=u(T);x(N)&&S.push([N,h(T)])}return S}function Fw(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?xX(e,i):tK(i,e)}var $v=window.THREE?window.THREE:{BufferGeometry:Hi,Float32BufferAttribute:Si},NR=new $v.BufferGeometry().setAttribute?"setAttribute":"addAttribute",CM=(function(i){function e(t,n,r,s,a,l,u){var h;DK(this,e),h=RK(this,e),h.type="ConicPolygonGeometry",h.parameters={polygonGeoJson:t,bottomHeight:n,topHeight:r,closedBottom:s,closedTop:a,includeSides:l,curvatureResolution:u},n=n||0,r=r||1,s=s!==void 0?s:!0,a=a!==void 0?a:!0,l=l!==void 0?l:!0,u=u||5;var m=kK(t,{resolution:u}),v=m.contour,x=m.triangles,S=og(x.uvs),T=[],N=[],C=[],E=0,O=function(G){var H=Math.round(T.length/3),q=C.length;T=T.concat(G.vertices),N=N.concat(G.uvs),C=C.concat(H?G.indices.map(function(V){return V+H}):G.indices),h.addGroup(q,C.length-q,E++)};l&&O(I()),s&&O(j(n,!1)),a&&O(j(r,!0)),h.setIndex(C),h[NR]("position",new $v.Float32BufferAttribute(T,3)),h[NR]("uv",new $v.Float32BufferAttribute(N,2)),h.computeVertexNormals();function U(z,G){var H=typeof G=="function"?G:function(){return G},q=z.map(function(V){return V.map(function(Q){var J=Wl(Q,2),ie=J[0],le=J[1];return VK(le,ie,H(ie,le))})});return O_(q)}function I(){for(var z=U(v,n),G=z.vertices,H=z.holes,q=U(v,r),V=q.vertices,Q=og([V,G]),J=Math.round(V.length/3),ie=new Set(H),le=0,re=[],Z=0;Z=0;Te--)for(var ae=0;ae1&&arguments[1]!==void 0?arguments[1]:!0;return{indices:G?x.indices:x.indices.slice().reverse(),vertices:U([x.points],z).vertices,uvs:S}}return h}return LK(e,i),PK(e)})($v.BufferGeometry);function VK(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180;return[t*Math.sin(n)*Math.cos(r),t*Math.cos(n),t*Math.sin(n)*Math.sin(r)]}function kw(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(l){return{keyAccessor:l,isProp:!(l instanceof Function)}}),s=i.reduce(function(l,u){var h=l,m=u;return r.forEach(function(v,x){var S=v.keyAccessor,T=v.isProp,N;if(T){var C=m,E=C[S],O=QK(C,[S].map(tZ));N=E,m=O}else N=S(m,x);x+11&&arguments[1]!==void 0?arguments[1]:1;h===r.length?Object.keys(u).forEach(function(m){return u[m]=t(u[m])}):Object.values(u).forEach(function(m){return l(m,h+1)})})(s);var a=s;return n&&(a=[],(function l(u){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];h.length===r.length?a.push({keys:h,vals:u}):Object.entries(u).forEach(function(m){var v=ZK(m,2),x=v[0],S=v[1];return l(S,[].concat(JK(h),[x]))})})(s),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a}),_i=(function(i){i=i||{};var e=typeof i<"u"?i:{},t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r="";function s(Ze){return e.locateFile?e.locateFile(Ze,r):r+Ze}var a;typeof document<"u"&&document.currentScript&&(r=document.currentScript.src),r.indexOf("blob:")!==0?r=r.substr(0,r.lastIndexOf("/")+1):r="",a=function(dt,Vt,xt){var A=new XMLHttpRequest;A.open("GET",dt,!0),A.responseType="arraybuffer",A.onload=function(){if(A.status==200||A.status==0&&A.response){Vt(A.response);return}var Vn=jt(dt);if(Vn){Vt(Vn.buffer);return}xt()},A.onerror=xt,A.send(null)};var l=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&e.arguments;var h=0,m=function(Ze){h=Ze},v=function(){return h},x=8;function S(Ze,dt,Vt,xt){switch(Vt=Vt||"i8",Vt.charAt(Vt.length-1)==="*"&&(Vt="i32"),Vt){case"i1":J[Ze>>0]=dt;break;case"i8":J[Ze>>0]=dt;break;case"i16":oe[Ze>>1]=dt;break;case"i32":ie[Ze>>2]=dt;break;case"i64":pe=[dt>>>0,(Oe=dt,+ft(Oe)>=1?Oe>0?(yt(+Wt(Oe/4294967296),4294967295)|0)>>>0:~~+fe((Oe-+(~~Oe>>>0))/4294967296)>>>0:0)],ie[Ze>>2]=pe[0],ie[Ze+4>>2]=pe[1];break;case"float":Z[Ze>>2]=dt;break;case"double":te[Ze>>3]=dt;break;default:qn("invalid type for setValue: "+Vt)}}function T(Ze,dt,Vt){switch(dt=dt||"i8",dt.charAt(dt.length-1)==="*"&&(dt="i32"),dt){case"i1":return J[Ze>>0];case"i8":return J[Ze>>0];case"i16":return oe[Ze>>1];case"i32":return ie[Ze>>2];case"i64":return ie[Ze>>2];case"float":return Z[Ze>>2];case"double":return te[Ze>>3];default:qn("invalid type for getValue: "+dt)}return null}var N=!1;function C(Ze,dt){Ze||qn("Assertion failed: "+dt)}function E(Ze){var dt=e["_"+Ze];return C(dt,"Cannot call unknown function "+Ze+", make sure it is exported"),dt}function O(Ze,dt,Vt,xt,A){var ee={string:function(mn){var Er=0;if(mn!=null&&mn!==0){var Wi=(mn.length<<2)+1;Er=ot(Wi),H(mn,Er,Wi)}return Er},array:function(mn){var Er=ot(mn.length);return q(mn,Er),Er}};function Vn(mn){return dt==="string"?z(mn):dt==="boolean"?!!mn:mn}var Wn=E(Ze),$n=[],dn=0;if(xt)for(var Fn=0;Fn=xt);)++A;if(A-dt>16&&Ze.subarray&&I)return I.decode(Ze.subarray(dt,A));for(var ee="";dt>10,56320|dn&1023)}}return ee}function z(Ze,dt){return Ze?j(ne,Ze,dt):""}function G(Ze,dt,Vt,xt){if(!(xt>0))return 0;for(var A=Vt,ee=Vt+xt-1,Vn=0;Vn=55296&&Wn<=57343){var $n=Ze.charCodeAt(++Vn);Wn=65536+((Wn&1023)<<10)|$n&1023}if(Wn<=127){if(Vt>=ee)break;dt[Vt++]=Wn}else if(Wn<=2047){if(Vt+1>=ee)break;dt[Vt++]=192|Wn>>6,dt[Vt++]=128|Wn&63}else if(Wn<=65535){if(Vt+2>=ee)break;dt[Vt++]=224|Wn>>12,dt[Vt++]=128|Wn>>6&63,dt[Vt++]=128|Wn&63}else{if(Vt+3>=ee)break;dt[Vt++]=240|Wn>>18,dt[Vt++]=128|Wn>>12&63,dt[Vt++]=128|Wn>>6&63,dt[Vt++]=128|Wn&63}}return dt[Vt]=0,Vt-A}function H(Ze,dt,Vt){return G(Ze,ne,dt,Vt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function q(Ze,dt){J.set(Ze,dt)}function V(Ze,dt){return Ze%dt>0&&(Ze+=dt-Ze%dt),Ze}var Q,J,ne,oe,ie,Z,te;function de(Ze){Q=Ze,e.HEAP8=J=new Int8Array(Ze),e.HEAP16=oe=new Int16Array(Ze),e.HEAP32=ie=new Int32Array(Ze),e.HEAPU8=ne=new Uint8Array(Ze),e.HEAPU16=new Uint16Array(Ze),e.HEAPU32=new Uint32Array(Ze),e.HEAPF32=Z=new Float32Array(Ze),e.HEAPF64=te=new Float64Array(Ze)}var Se=5271536,Te=28624,ae=e.TOTAL_MEMORY||33554432;e.buffer?Q=e.buffer:Q=new ArrayBuffer(ae),ae=Q.byteLength,de(Q),ie[Te>>2]=Se;function Me(Ze){for(;Ze.length>0;){var dt=Ze.shift();if(typeof dt=="function"){dt();continue}var Vt=dt.func;typeof Vt=="number"?dt.arg===void 0?e.dynCall_v(Vt):e.dynCall_vi(Vt,dt.arg):Vt(dt.arg===void 0?null:dt.arg)}}var Ve=[],Ce=[],Fe=[],et=[];function He(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Pt(e.preRun.shift());Me(Ve)}function Rt(){Me(Ce)}function Et(){Me(Fe)}function zt(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)We(e.postRun.shift());Me(et)}function Pt(Ze){Ve.unshift(Ze)}function We(Ze){et.unshift(Ze)}var ft=Math.abs,fe=Math.ceil,Wt=Math.floor,yt=Math.min,Gt=0,_t=null;function Xt(Ze){Gt++,e.monitorRunDependencies&&e.monitorRunDependencies(Gt)}function pt(Ze){if(Gt--,e.monitorRunDependencies&&e.monitorRunDependencies(Gt),Gt==0&&_t){var dt=_t;_t=null,dt()}}e.preloadedImages={},e.preloadedAudios={};var Ae=null,k="data:application/octet-stream;base64,";function be(Ze){return String.prototype.startsWith?Ze.startsWith(k):Ze.indexOf(k)===0}var Oe,pe;Ae="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var le=28640;function Ne(Ze,dt,Vt,xt){qn("Assertion failed: "+z(Ze)+", at: "+[dt?z(dt):"unknown filename",Vt,xt?z(xt):"unknown function"])}function De(){return J.length}function Je(Ze,dt,Vt){ne.set(ne.subarray(dt,dt+Vt),Ze)}function we(Ze){return e.___errno_location&&(ie[e.___errno_location()>>2]=Ze),Ze}function Ue(Ze){qn("OOM")}function ut(Ze){try{var dt=new ArrayBuffer(Ze);return dt.byteLength!=Ze?void 0:(new Int8Array(dt).set(J),Ot(dt),de(dt),1)}catch{}}function Dt(Ze){var dt=De(),Vt=16777216,xt=2147483648-Vt;if(Ze>xt)return!1;for(var A=16777216,ee=Math.max(dt,A);ee>4,A=(Wn&15)<<4|$n>>2,ee=($n&3)<<6|dn,Vt=Vt+String.fromCharCode(xt),$n!==64&&(Vt=Vt+String.fromCharCode(A)),dn!==64&&(Vt=Vt+String.fromCharCode(ee));while(Fn13780509?(f=ku(15,f)|0,f|0):(p=((d|0)<0)<<31>>31,y=ur(d|0,p|0,3,0)|0,_=X()|0,p=tn(d|0,p|0,1,0)|0,p=ur(y|0,_|0,p|0,X()|0)|0,p=tn(p|0,X()|0,1,0)|0,d=X()|0,A[f>>2]=p,A[f+4>>2]=d,f=0,f|0)}function ys(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,Vr(d,f,p,_,0)|0}function Vr(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0;if(B=K,K=K+16|0,M=B,!(Di(d,f,p,_,y)|0))return _=0,K=B,_|0;do if((p|0)>=0){if((p|0)>13780509){if(w=ku(15,M)|0,w|0)break;R=M,M=A[R>>2]|0,R=A[R+4>>2]|0}else w=((p|0)<0)<<31>>31,F=ur(p|0,w|0,3,0)|0,R=X()|0,w=tn(p|0,w|0,1,0)|0,w=ur(F|0,R|0,w|0,X()|0)|0,w=tn(w|0,X()|0,1,0)|0,R=X()|0,A[M>>2]=w,A[M+4>>2]=R,M=w;if(ao(_|0,0,M<<3|0)|0,y|0){ao(y|0,0,M<<2|0)|0,w=sr(d,f,p,_,y,M,R,0)|0;break}w=Ys(M,4)|0,w?(F=sr(d,f,p,_,w,M,R,0)|0,vn(w),w=F):w=13}else w=2;while(!1);return F=w,K=B,F|0}function Di(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0;if(Pe=K,K=K+16|0,ve=Pe,ye=Pe+8|0,_e=ve,A[_e>>2]=d,A[_e+4>>2]=f,(p|0)<0)return ye=2,K=Pe,ye|0;if(w=_,A[w>>2]=d,A[w+4>>2]=f,w=(y|0)!=0,w&&(A[y>>2]=0),wi(d,f)|0)return ye=9,K=Pe,ye|0;A[ye>>2]=0;e:do if((p|0)>=1)if(w)for(W=1,F=0,se=0,_e=1,w=d;;){if(!(F|se)){if(w=bi(w,f,4,ye,ve)|0,w|0)break e;if(f=ve,w=A[f>>2]|0,f=A[f+4>>2]|0,wi(w,f)|0){w=9;break e}}if(w=bi(w,f,A[26800+(se<<2)>>2]|0,ye,ve)|0,w|0)break e;if(f=ve,w=A[f>>2]|0,f=A[f+4>>2]|0,d=_+(W<<3)|0,A[d>>2]=w,A[d+4>>2]=f,A[y+(W<<2)>>2]=_e,d=F+1|0,M=(d|0)==(_e|0),R=se+1|0,B=(R|0)==6,wi(w,f)|0){w=9;break e}if(_e=_e+(B&M&1)|0,(_e|0)>(p|0)){w=0;break}else W=W+1|0,F=M?0:d,se=M?B?0:R:se}else for(W=1,F=0,se=0,_e=1,w=d;;){if(!(F|se)){if(w=bi(w,f,4,ye,ve)|0,w|0)break e;if(f=ve,w=A[f>>2]|0,f=A[f+4>>2]|0,wi(w,f)|0){w=9;break e}}if(w=bi(w,f,A[26800+(se<<2)>>2]|0,ye,ve)|0,w|0)break e;if(f=ve,w=A[f>>2]|0,f=A[f+4>>2]|0,d=_+(W<<3)|0,A[d>>2]=w,A[d+4>>2]=f,d=F+1|0,M=(d|0)==(_e|0),R=se+1|0,B=(R|0)==6,wi(w,f)|0){w=9;break e}if(_e=_e+(B&M&1)|0,(_e|0)>(p|0)){w=0;break}else W=W+1|0,F=M?0:d,se=M?B?0:R:se}else w=0;while(!1);return ye=w,K=Pe,ye|0}function sr(d,f,p,_,y,w,M,R){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0,R=R|0;var B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0;if(Pe=K,K=K+16|0,ve=Pe+8|0,ye=Pe,B=Yu(d|0,f|0,w|0,M|0)|0,W=X()|0,se=_+(B<<3)|0,ze=se,nt=A[ze>>2]|0,ze=A[ze+4>>2]|0,F=(nt|0)==(d|0)&(ze|0)==(f|0),!((nt|0)==0&(ze|0)==0|F))do B=tn(B|0,W|0,1,0)|0,B=Kc(B|0,X()|0,w|0,M|0)|0,W=X()|0,se=_+(B<<3)|0,nt=se,ze=A[nt>>2]|0,nt=A[nt+4>>2]|0,F=(ze|0)==(d|0)&(nt|0)==(f|0);while(!((ze|0)==0&(nt|0)==0|F));if(B=y+(B<<2)|0,F&&(A[B>>2]|0)<=(R|0)||(nt=se,A[nt>>2]=d,A[nt+4>>2]=f,A[B>>2]=R,(R|0)>=(p|0)))return nt=0,K=Pe,nt|0;switch(F=R+1|0,A[ve>>2]=0,B=bi(d,f,2,ve,ye)|0,B|0){case 9:{_e=9;break}case 0:{B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B||(_e=9);break}}e:do if((_e|0)==9){switch(A[ve>>2]=0,B=bi(d,f,3,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ve>>2]=0,B=bi(d,f,1,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ve>>2]=0,B=bi(d,f,5,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ve>>2]=0,B=bi(d,f,4,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ve>>2]=0,B=bi(d,f,6,ve,ye)|0,B|0){case 9:break;case 0:{if(B=ye,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}return nt=0,K=Pe,nt|0}while(!1);return nt=B,K=Pe,nt|0}function bi(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0;if(p>>>0>6)return y=1,y|0;if(se=(A[_>>2]|0)%6|0,A[_>>2]=se,(se|0)>0){w=0;do p=Nu(p)|0,w=w+1|0;while((w|0)<(A[_>>2]|0))}if(se=Ct(d|0,f|0,45)|0,X()|0,W=se&127,W>>>0>121)return y=5,y|0;B=Hs(d,f)|0,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15;e:do if(!w)F=8;else{for(;;){if(M=(15-w|0)*3|0,R=Ct(d|0,f|0,M|0)|0,X()|0,R=R&7,(R|0)==7){f=5;break}if(ye=(bs(w)|0)==0,w=w+-1|0,_e=It(7,0,M|0)|0,f=f&~(X()|0),ve=It(A[(ye?432:16)+(R*28|0)+(p<<2)>>2]|0,0,M|0)|0,M=X()|0,p=A[(ye?640:224)+(R*28|0)+(p<<2)>>2]|0,d=ve|d&~_e,f=M|f,!p){p=0;break e}if(!w){F=8;break e}}return f|0}while(!1);(F|0)==8&&(ye=A[848+(W*28|0)+(p<<2)>>2]|0,ve=It(ye|0,0,45)|0,d=ve|d,f=X()|0|f&-1040385,p=A[4272+(W*28|0)+(p<<2)>>2]|0,(ye&127|0)==127&&(ye=It(A[848+(W*28|0)+20>>2]|0,0,45)|0,f=X()|0|f&-1040385,p=A[4272+(W*28|0)+20>>2]|0,d=Uu(ye|d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+1)),R=Ct(d|0,f|0,45)|0,X()|0,R=R&127;e:do if(Ji(R)|0){t:do if((Hs(d,f)|0)==1){if((W|0)!=(R|0))if(wu(R,A[7696+(W*28|0)>>2]|0)|0){d=lp(d,f)|0,M=1,f=X()|0;break}else tt(27795,26864,533,26872);switch(B|0){case 3:{d=Uu(d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+1,M=0;break t}case 5:{d=lp(d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+5,M=0;break t}case 0:return ye=9,ye|0;default:return ye=1,ye|0}}else M=0;while(!1);if((p|0)>0){w=0;do d=op(d,f)|0,f=X()|0,w=w+1|0;while((w|0)!=(p|0))}if((W|0)!=(R|0)){if(!(qc(R)|0)){if((M|0)!=0|(Hs(d,f)|0)!=5)break;A[_>>2]=(A[_>>2]|0)+1;break}switch(se&127){case 8:case 118:break e}(Hs(d,f)|0)!=3&&(A[_>>2]=(A[_>>2]|0)+1)}}else if((p|0)>0){w=0;do d=Uu(d,f)|0,f=X()|0,w=w+1|0;while((w|0)!=(p|0))}while(!1);return A[_>>2]=((A[_>>2]|0)+p|0)%6|0,ye=y,A[ye>>2]=d,A[ye+4>>2]=f,ye=0,ye|0}function _r(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,Jr(d,f,p,_)|0?(ao(_|0,0,p*48|0)|0,_=Gc(d,f,p,_)|0,_|0):(_=0,_|0)}function Jr(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0;if(ye=K,K=K+16|0,_e=ye,ve=ye+8|0,se=_e,A[se>>2]=d,A[se+4>>2]=f,(p|0)<0)return ve=2,K=ye,ve|0;if(!p)return ve=_,A[ve>>2]=d,A[ve+4>>2]=f,ve=0,K=ye,ve|0;A[ve>>2]=0;e:do if(wi(d,f)|0)d=9;else{y=0,se=d;do{if(d=bi(se,f,4,ve,_e)|0,d|0)break e;if(f=_e,se=A[f>>2]|0,f=A[f+4>>2]|0,y=y+1|0,wi(se,f)|0){d=9;break e}}while((y|0)<(p|0));W=_,A[W>>2]=se,A[W+4>>2]=f,W=p+-1|0,F=0,d=1;do{if(y=26800+(F<<2)|0,(F|0)==5)for(M=A[y>>2]|0,w=0,y=d;;){if(d=_e,d=bi(A[d>>2]|0,A[d+4>>2]|0,M,ve,_e)|0,d|0)break e;if((w|0)!=(W|0))if(B=_e,R=A[B>>2]|0,B=A[B+4>>2]|0,d=_+(y<<3)|0,A[d>>2]=R,A[d+4>>2]=B,!(wi(R,B)|0))d=y+1|0;else{d=9;break e}else d=y;if(w=w+1|0,(w|0)>=(p|0))break;y=d}else for(M=_e,B=A[y>>2]|0,R=0,y=d,w=A[M>>2]|0,M=A[M+4>>2]|0;;){if(d=bi(w,M,B,ve,_e)|0,d|0)break e;if(M=_e,w=A[M>>2]|0,M=A[M+4>>2]|0,d=_+(y<<3)|0,A[d>>2]=w,A[d+4>>2]=M,d=y+1|0,wi(w,M)|0){d=9;break e}if(R=R+1|0,(R|0)>=(p|0))break;y=d}F=F+1|0}while(F>>>0<6);d=_e,d=(se|0)==(A[d>>2]|0)&&(f|0)==(A[d+4>>2]|0)?0:9}while(!1);return ve=d,K=ye,ve|0}function Gc(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;if(se=K,K=K+16|0,M=se,!p)return A[_>>2]=d,A[_+4>>2]=f,_=0,K=se,_|0;do if((p|0)>=0){if((p|0)>13780509){if(y=ku(15,M)|0,y|0)break;w=M,y=A[w>>2]|0,w=A[w+4>>2]|0}else y=((p|0)<0)<<31>>31,W=ur(p|0,y|0,3,0)|0,w=X()|0,y=tn(p|0,y|0,1,0)|0,y=ur(W|0,w|0,y|0,X()|0)|0,y=tn(y|0,X()|0,1,0)|0,w=X()|0,W=M,A[W>>2]=y,A[W+4>>2]=w;if(F=Ys(y,8)|0,!F)y=13;else{if(W=Ys(y,4)|0,!W){vn(F),y=13;break}if(y=sr(d,f,p,F,W,y,w,0)|0,y|0){vn(F),vn(W);break}if(f=A[M>>2]|0,M=A[M+4>>2]|0,(M|0)>0|(M|0)==0&f>>>0>0){y=0,R=0,B=0;do d=F+(R<<3)|0,w=A[d>>2]|0,d=A[d+4>>2]|0,!((w|0)==0&(d|0)==0)&&(A[W+(R<<2)>>2]|0)==(p|0)&&(_e=_+(y<<3)|0,A[_e>>2]=w,A[_e+4>>2]=d,y=y+1|0),R=tn(R|0,B|0,1,0)|0,B=X()|0;while((B|0)<(M|0)|(B|0)==(M|0)&R>>>0>>0)}vn(F),vn(W),y=0}}else y=2;while(!1);return _e=y,K=se,_e|0}function xs(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;for(R=K,K=K+16|0,w=R,M=R+8|0,y=(wi(d,f)|0)==0,y=y?1:2;;){if(A[M>>2]=0,F=(bi(d,f,y,M,w)|0)==0,B=w,F&((A[B>>2]|0)==(p|0)?(A[B+4>>2]|0)==(_|0):0)){d=4;break}if(y=y+1|0,y>>>0>=7){y=7,d=4;break}}return(d|0)==4?(K=R,y|0):0}function ux(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;if(R=K,K=K+48|0,y=R+16|0,w=R+8|0,M=R,p=Ma(p)|0,p|0)return M=p,K=R,M|0;if(F=d,B=A[F+4>>2]|0,p=w,A[p>>2]=A[F>>2],A[p+4>>2]=B,da(w,y),p=Jh(y,f,M)|0,!p){if(f=A[w>>2]|0,w=A[d+8>>2]|0,(w|0)>0){y=A[d+12>>2]|0,p=0;do f=(A[y+(p<<3)>>2]|0)+f|0,p=p+1|0;while((p|0)<(w|0))}p=M,y=A[p>>2]|0,p=A[p+4>>2]|0,w=((f|0)<0)<<31>>31,(p|0)<(w|0)|(p|0)==(w|0)&y>>>0>>0?(p=M,A[p>>2]=f,A[p+4>>2]=w,p=w):f=y,B=tn(f|0,p|0,12,0)|0,F=X()|0,p=M,A[p>>2]=B,A[p+4>>2]=F,p=_,A[p>>2]=B,A[p+4>>2]=F,p=0}return F=p,K=R,F|0}function Y0(d,f,p,_,y,w,M){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0;var R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0,xn=0,si=0,Cn=0,Ti=0,ws=0,cl=0;if(si=K,K=K+64|0,En=si+48|0,fn=si+32|0,kt=si+24|0,Ft=si+8|0,un=si,B=A[d>>2]|0,(B|0)<=0)return xn=0,K=si,xn|0;for(on=d+4|0,kn=En+8|0,Dn=fn+8|0,Zn=Ft+8|0,R=0,je=0;;){F=A[on>>2]|0,Xe=F+(je<<4)|0,A[En>>2]=A[Xe>>2],A[En+4>>2]=A[Xe+4>>2],A[En+8>>2]=A[Xe+8>>2],A[En+12>>2]=A[Xe+12>>2],(je|0)==(B+-1|0)?(A[fn>>2]=A[F>>2],A[fn+4>>2]=A[F+4>>2],A[fn+8>>2]=A[F+8>>2],A[fn+12>>2]=A[F+12>>2]):(Xe=F+(je+1<<4)|0,A[fn>>2]=A[Xe>>2],A[fn+4>>2]=A[Xe+4>>2],A[fn+8>>2]=A[Xe+8>>2],A[fn+12>>2]=A[Xe+12>>2]),B=s1(En,fn,_,kt)|0;e:do if(B)F=0,R=B;else if(B=kt,F=A[B>>2]|0,B=A[B+4>>2]|0,(B|0)>0|(B|0)==0&F>>>0>0){nt=0,Xe=0;t:for(;;){if(Ti=1/(+(F>>>0)+4294967296*+(B|0)),cl=+ee[En>>3],B=Lr(F|0,B|0,nt|0,Xe|0)|0,ws=+(B>>>0)+4294967296*+(X()|0),Cn=+(nt>>>0)+4294967296*+(Xe|0),ee[Ft>>3]=Ti*(cl*ws)+Ti*(+ee[fn>>3]*Cn),ee[Zn>>3]=Ti*(+ee[kn>>3]*ws)+Ti*(+ee[Dn>>3]*Cn),B=Ed(Ft,_,un)|0,B|0){R=B;break}ze=un,Pe=A[ze>>2]|0,ze=A[ze+4>>2]|0,_e=Yu(Pe|0,ze|0,f|0,p|0)|0,W=X()|0,B=M+(_e<<3)|0,se=B,F=A[se>>2]|0,se=A[se+4>>2]|0;n:do if((F|0)==0&(se|0)==0)Le=B,xn=16;else for(ve=0,ye=0;;){if((ve|0)>(p|0)|(ve|0)==(p|0)&ye>>>0>f>>>0){R=1;break t}if((F|0)==(Pe|0)&(se|0)==(ze|0))break n;if(B=tn(_e|0,W|0,1,0)|0,_e=Kc(B|0,X()|0,f|0,p|0)|0,W=X()|0,ye=tn(ye|0,ve|0,1,0)|0,ve=X()|0,B=M+(_e<<3)|0,se=B,F=A[se>>2]|0,se=A[se+4>>2]|0,(F|0)==0&(se|0)==0){Le=B,xn=16;break}}while(!1);if((xn|0)==16&&(xn=0,!((Pe|0)==0&(ze|0)==0))&&(ye=Le,A[ye>>2]=Pe,A[ye+4>>2]=ze,ye=w+(A[y>>2]<<3)|0,A[ye>>2]=Pe,A[ye+4>>2]=ze,ye=y,ye=tn(A[ye>>2]|0,A[ye+4>>2]|0,1,0)|0,Pe=X()|0,ze=y,A[ze>>2]=ye,A[ze+4>>2]=Pe),nt=tn(nt|0,Xe|0,1,0)|0,Xe=X()|0,B=kt,F=A[B>>2]|0,B=A[B+4>>2]|0,!((B|0)>(Xe|0)|(B|0)==(Xe|0)&F>>>0>nt>>>0)){F=1;break e}}F=0}else F=1;while(!1);if(je=je+1|0,!F){xn=21;break}if(B=A[d>>2]|0,(je|0)>=(B|0)){R=0,xn=21;break}}return(xn|0)==21?(K=si,R|0):0}function i1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0,xn=0,si=0,Cn=0,Ti=0,ws=0;if(ws=K,K=K+112|0,xn=ws+80|0,B=ws+72|0,si=ws,Cn=ws+56|0,y=Ma(p)|0,y|0)return Ti=y,K=ws,Ti|0;if(F=d+8|0,Ti=Oo((A[F>>2]<<5)+32|0)|0,!Ti)return Ti=13,K=ws,Ti|0;if(Ea(d,Ti),y=Ma(p)|0,!y){if(fn=d,kt=A[fn+4>>2]|0,y=B,A[y>>2]=A[fn>>2],A[y+4>>2]=kt,da(B,xn),y=Jh(xn,f,si)|0,y)fn=0,kt=0;else{if(y=A[B>>2]|0,w=A[F>>2]|0,(w|0)>0){M=A[d+12>>2]|0,p=0;do y=(A[M+(p<<3)>>2]|0)+y|0,p=p+1|0;while((p|0)!=(w|0));p=y}else p=y;y=si,w=A[y>>2]|0,y=A[y+4>>2]|0,M=((p|0)<0)<<31>>31,(y|0)<(M|0)|(y|0)==(M|0)&w>>>0

>>0?(y=si,A[y>>2]=p,A[y+4>>2]=M,y=M):p=w,fn=tn(p|0,y|0,12,0)|0,kt=X()|0,y=si,A[y>>2]=fn,A[y+4>>2]=kt,y=0}if(!y){if(p=Ys(fn,8)|0,!p)return vn(Ti),Ti=13,K=ws,Ti|0;if(R=Ys(fn,8)|0,!R)return vn(Ti),vn(p),Ti=13,K=ws,Ti|0;Zn=xn,A[Zn>>2]=0,A[Zn+4>>2]=0,Zn=d,En=A[Zn+4>>2]|0,y=B,A[y>>2]=A[Zn>>2],A[y+4>>2]=En,y=Y0(B,fn,kt,f,xn,p,R)|0;e:do if(y)vn(p),vn(R),vn(Ti);else{t:do if((A[F>>2]|0)>0){for(M=d+12|0,w=0;y=Y0((A[M>>2]|0)+(w<<3)|0,fn,kt,f,xn,p,R)|0,w=w+1|0,!(y|0);)if((w|0)>=(A[F>>2]|0))break t;vn(p),vn(R),vn(Ti);break e}while(!1);(kt|0)>0|(kt|0)==0&fn>>>0>0&&ao(R|0,0,fn<<3|0)|0,En=xn,Zn=A[En+4>>2]|0;t:do if((Zn|0)>0|(Zn|0)==0&(A[En>>2]|0)>>>0>0){on=p,kn=R,Dn=p,Zn=R,En=p,y=p,Le=p,Ft=R,un=R,p=R;n:for(;;){for(ze=0,nt=0,Xe=0,je=0,w=0,M=0;;){R=si,B=R+56|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));if(f=on+(ze<<3)|0,F=A[f>>2]|0,f=A[f+4>>2]|0,Di(F,f,1,si,0)|0){R=si,B=R+56|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));R=Ys(7,4)|0,R|0&&(sr(F,f,1,si,R,7,0,0)|0,vn(R))}for(Pe=0;;){ye=si+(Pe<<3)|0,ve=A[ye>>2]|0,ye=A[ye+4>>2]|0;i:do if((ve|0)==0&(ye|0)==0)R=w,B=M;else{if(W=Yu(ve|0,ye|0,fn|0,kt|0)|0,F=X()|0,R=_+(W<<3)|0,f=R,B=A[f>>2]|0,f=A[f+4>>2]|0,!((B|0)==0&(f|0)==0)){se=0,_e=0;do{if((se|0)>(kt|0)|(se|0)==(kt|0)&_e>>>0>fn>>>0)break n;if((B|0)==(ve|0)&(f|0)==(ye|0)){R=w,B=M;break i}R=tn(W|0,F|0,1,0)|0,W=Kc(R|0,X()|0,fn|0,kt|0)|0,F=X()|0,_e=tn(_e|0,se|0,1,0)|0,se=X()|0,R=_+(W<<3)|0,f=R,B=A[f>>2]|0,f=A[f+4>>2]|0}while(!((B|0)==0&(f|0)==0))}if((ve|0)==0&(ye|0)==0){R=w,B=M;break}Dl(ve,ye,Cn)|0,Ca(d,Ti,Cn)|0&&(_e=tn(w|0,M|0,1,0)|0,M=X()|0,se=R,A[se>>2]=ve,A[se+4>>2]=ye,w=kn+(w<<3)|0,A[w>>2]=ve,A[w+4>>2]=ye,w=_e),R=w,B=M}while(!1);if(Pe=Pe+1|0,Pe>>>0>=7)break;w=R,M=B}if(ze=tn(ze|0,nt|0,1,0)|0,nt=X()|0,Xe=tn(Xe|0,je|0,1,0)|0,je=X()|0,M=xn,w=A[M>>2]|0,M=A[M+4>>2]|0,(je|0)<(M|0)|(je|0)==(M|0)&Xe>>>0>>0)w=R,M=B;else break}if((M|0)>0|(M|0)==0&w>>>0>0){w=0,M=0;do je=on+(w<<3)|0,A[je>>2]=0,A[je+4>>2]=0,w=tn(w|0,M|0,1,0)|0,M=X()|0,je=xn,Xe=A[je+4>>2]|0;while((M|0)<(Xe|0)|((M|0)==(Xe|0)?w>>>0<(A[je>>2]|0)>>>0:0))}if(je=xn,A[je>>2]=R,A[je+4>>2]=B,(B|0)>0|(B|0)==0&R>>>0>0)Pe=p,ze=un,nt=En,Xe=Ft,je=kn,p=Le,un=y,Ft=Dn,Le=Pe,y=ze,En=Zn,Zn=nt,Dn=Xe,kn=on,on=je;else break t}vn(Dn),vn(Zn),vn(Ti),y=1;break e}else y=R;while(!1);vn(Ti),vn(p),vn(y),y=0}while(!1);return Ti=y,K=ws,Ti|0}}return vn(Ti),Ti=y,K=ws,Ti|0}function Q0(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+176|0,B=W,(f|0)<1)return Bo(p,0,0),F=0,K=W,F|0;for(R=d,R=Ct(A[R>>2]|0,A[R+4>>2]|0,52)|0,X()|0,Bo(p,(f|0)>6?f:6,R&15),R=0;_=d+(R<<3)|0,_=Pl(A[_>>2]|0,A[_+4>>2]|0,B)|0,!(_|0);){if(_=A[B>>2]|0,(_|0)>0){M=0;do w=B+8+(M<<4)|0,M=M+1|0,_=B+8+(((M|0)%(_|0)|0)<<4)|0,y=$u(p,_,w)|0,y?Wu(p,y)|0:Fd(p,w,_)|0,_=A[B>>2]|0;while((M|0)<(_|0))}if(R=R+1|0,(R|0)>=(f|0)){_=0,F=13;break}}return(F|0)==13?(K=W,_|0):(Od(p),F=_,K=W,F|0)}function cx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(w=K,K=K+32|0,_=w,y=w+16|0,d=Q0(d,f,y)|0,d|0)return p=d,K=w,p|0;if(A[p>>2]=0,A[p+4>>2]=0,A[p+8>>2]=0,d=Id(y)|0,d|0)do{f=T1(p)|0;do Dd(f,d)|0,M=d+16|0,A[_>>2]=A[M>>2],A[_+4>>2]=A[M+4>>2],A[_+8>>2]=A[M+8>>2],A[_+12>>2]=A[M+12>>2],Wu(y,d)|0,d=hs(y,_)|0;while((d|0)!=0);d=Id(y)|0}while((d|0)!=0);return Od(y),d=Rx(p)|0,d?(Gu(p),M=d,K=w,M|0):(M=0,K=w,M|0)}function Ji(d){return d=d|0,d>>>0>121?(d=0,d|0):(d=A[7696+(d*28|0)+16>>2]|0,d|0)}function qc(d){return d=d|0,(d|0)==4|(d|0)==117|0}function Ro(d){return d=d|0,A[11120+((A[d>>2]|0)*216|0)+((A[d+4>>2]|0)*72|0)+((A[d+8>>2]|0)*24|0)+(A[d+12>>2]<<3)>>2]|0}function K0(d){return d=d|0,A[11120+((A[d>>2]|0)*216|0)+((A[d+4>>2]|0)*72|0)+((A[d+8>>2]|0)*24|0)+(A[d+12>>2]<<3)+4>>2]|0}function Z0(d,f){d=d|0,f=f|0,d=7696+(d*28|0)|0,A[f>>2]=A[d>>2],A[f+4>>2]=A[d+4>>2],A[f+8>>2]=A[d+8>>2],A[f+12>>2]=A[d+12>>2]}function Vc(d,f){d=d|0,f=f|0;var p=0,_=0;if(f>>>0>20)return f=-1,f|0;do if((A[11120+(f*216|0)>>2]|0)!=(d|0))if((A[11120+(f*216|0)+8>>2]|0)!=(d|0))if((A[11120+(f*216|0)+16>>2]|0)!=(d|0))if((A[11120+(f*216|0)+24>>2]|0)!=(d|0))if((A[11120+(f*216|0)+32>>2]|0)!=(d|0))if((A[11120+(f*216|0)+40>>2]|0)!=(d|0))if((A[11120+(f*216|0)+48>>2]|0)!=(d|0))if((A[11120+(f*216|0)+56>>2]|0)!=(d|0))if((A[11120+(f*216|0)+64>>2]|0)!=(d|0))if((A[11120+(f*216|0)+72>>2]|0)!=(d|0))if((A[11120+(f*216|0)+80>>2]|0)!=(d|0))if((A[11120+(f*216|0)+88>>2]|0)!=(d|0))if((A[11120+(f*216|0)+96>>2]|0)!=(d|0))if((A[11120+(f*216|0)+104>>2]|0)!=(d|0))if((A[11120+(f*216|0)+112>>2]|0)!=(d|0))if((A[11120+(f*216|0)+120>>2]|0)!=(d|0))if((A[11120+(f*216|0)+128>>2]|0)!=(d|0))if((A[11120+(f*216|0)+136>>2]|0)==(d|0))d=2,p=1,_=2;else{if((A[11120+(f*216|0)+144>>2]|0)==(d|0)){d=0,p=2,_=0;break}if((A[11120+(f*216|0)+152>>2]|0)==(d|0)){d=0,p=2,_=1;break}if((A[11120+(f*216|0)+160>>2]|0)==(d|0)){d=0,p=2,_=2;break}if((A[11120+(f*216|0)+168>>2]|0)==(d|0)){d=1,p=2,_=0;break}if((A[11120+(f*216|0)+176>>2]|0)==(d|0)){d=1,p=2,_=1;break}if((A[11120+(f*216|0)+184>>2]|0)==(d|0)){d=1,p=2,_=2;break}if((A[11120+(f*216|0)+192>>2]|0)==(d|0)){d=2,p=2,_=0;break}if((A[11120+(f*216|0)+200>>2]|0)==(d|0)){d=2,p=2,_=1;break}if((A[11120+(f*216|0)+208>>2]|0)==(d|0)){d=2,p=2,_=2;break}else d=-1;return d|0}else d=2,p=1,_=1;else d=2,p=1,_=0;else d=1,p=1,_=2;else d=1,p=1,_=1;else d=1,p=1,_=0;else d=0,p=1,_=2;else d=0,p=1,_=1;else d=0,p=1,_=0;else d=2,p=0,_=2;else d=2,p=0,_=1;else d=2,p=0,_=0;else d=1,p=0,_=2;else d=1,p=0,_=1;else d=1,p=0,_=0;else d=0,p=0,_=2;else d=0,p=0,_=1;else d=0,p=0,_=0;while(!1);return f=A[11120+(f*216|0)+(p*72|0)+(d*24|0)+(_<<3)+4>>2]|0,f|0}function wu(d,f){return d=d|0,f=f|0,(A[7696+(d*28|0)+20>>2]|0)==(f|0)?(f=1,f|0):(f=(A[7696+(d*28|0)+24>>2]|0)==(f|0),f|0)}function vd(d,f){return d=d|0,f=f|0,A[848+(d*28|0)+(f<<2)>>2]|0}function Xh(d,f){return d=d|0,f=f|0,(A[848+(d*28|0)>>2]|0)==(f|0)?(f=0,f|0):(A[848+(d*28|0)+4>>2]|0)==(f|0)?(f=1,f|0):(A[848+(d*28|0)+8>>2]|0)==(f|0)?(f=2,f|0):(A[848+(d*28|0)+12>>2]|0)==(f|0)?(f=3,f|0):(A[848+(d*28|0)+16>>2]|0)==(f|0)?(f=4,f|0):(A[848+(d*28|0)+20>>2]|0)==(f|0)?(f=5,f|0):((A[848+(d*28|0)+24>>2]|0)==(f|0)?6:7)|0}function r1(){return 122}function Yh(d){d=d|0;var f=0,p=0,_=0;f=0;do It(f|0,0,45)|0,_=X()|0|134225919,p=d+(f<<3)|0,A[p>>2]=-1,A[p+4>>2]=_,f=f+1|0;while((f|0)!=122);return 0}function el(d){d=d|0;var f=0,p=0,_=0;return _=+ee[d+16>>3],p=+ee[d+24>>3],f=_-p,+(_>3]<+ee[d+24>>3]|0}function Qh(d){return d=d|0,+(+ee[d>>3]-+ee[d+8>>3])}function Do(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;return p=+ee[f>>3],!(p>=+ee[d+8>>3])||!(p<=+ee[d>>3])?(f=0,f|0):(_=+ee[d+16>>3],p=+ee[d+24>>3],y=+ee[f+8>>3],f=y>=p,d=y<=_&1,_>3]<+ee[f+8>>3]||+ee[d+8>>3]>+ee[f>>3]?(_=0,_|0):(w=+ee[d+16>>3],p=d+24|0,W=+ee[p>>3],M=w>3],y=f+24|0,B=+ee[y>>3],R=F>3],f)||(W=+Ws(+ee[p>>3],d),W>+Ws(+ee[_>>3],f))?(R=0,R|0):(R=1,R|0))}function yd(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0;w=+ee[d+16>>3],B=+ee[d+24>>3],d=w>3],M=+ee[f+24>>3],y=R>2]=d?y|f?1:2:0,A[_>>2]=y?d?1:f?2:1:0}function J0(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;return+ee[d>>3]<+ee[f>>3]||+ee[d+8>>3]>+ee[f+8>>3]?(_=0,_|0):(_=d+16|0,B=+ee[_>>3],w=+ee[d+24>>3],M=B>3],y=f+24|0,F=+ee[y>>3],R=W>3],f)?(W=+Ws(+ee[_>>3],d),R=W>=+Ws(+ee[p>>3],f),R|0):(R=0,R|0))}function Zh(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;y=K,K=K+176|0,_=y,A[_>>2]=4,R=+ee[f>>3],ee[_+8>>3]=R,w=+ee[f+16>>3],ee[_+16>>3]=w,ee[_+24>>3]=R,R=+ee[f+24>>3],ee[_+32>>3]=R,M=+ee[f+8>>3],ee[_+40>>3]=M,ee[_+48>>3]=R,ee[_+56>>3]=M,ee[_+64>>3]=w,f=_+72|0,p=f+96|0;do A[f>>2]=0,f=f+4|0;while((f|0)<(p|0));Ol(d|0,_|0,168)|0,K=y}function Jh(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0;ye=K,K=K+288|0,W=ye+264|0,se=ye+96|0,F=ye,R=F,B=R+96|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));return f=Iu(f,F)|0,f|0?(ve=f,K=ye,ve|0):(B=F,F=A[B>>2]|0,B=A[B+4>>2]|0,Dl(F,B,W)|0,Pl(F,B,se)|0,M=+Xc(W,se+8|0),ee[W>>3]=+ee[d>>3],B=W+8|0,ee[B>>3]=+ee[d+16>>3],ee[se>>3]=+ee[d+8>>3],F=se+8|0,ee[F>>3]=+ee[d+24>>3],y=+Xc(W,se),ze=+ee[B>>3]-+ee[F>>3],w=+dn(+ze),Pe=+ee[W>>3]-+ee[se>>3],_=+dn(+Pe),!(ze==0|Pe==0)&&(ze=+lf(+w,+_),ze=+rt(+(y*y/+uf(+(ze/+uf(+w,+_)),3)/(M*(M*2.59807621135)*.8))),ee[Vn>>3]=ze,_e=~~ze>>>0,ve=+dn(ze)>=1?ze>0?~~+qe(+$n(ze/4294967296),4294967295)>>>0:~~+rt((ze-+(~~ze>>>0))/4294967296)>>>0:0,(A[Vn+4>>2]&2146435072|0)!=2146435072)?(se=(_e|0)==0&(ve|0)==0,f=p,A[f>>2]=se?1:_e,A[f+4>>2]=se?0:ve,f=0):f=1,ve=f,K=ye,ve|0)}function s1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;F=K,K=K+288|0,M=F+264|0,R=F+96|0,B=F,y=B,w=y+96|0;do A[y>>2]=0,y=y+4|0;while((y|0)<(w|0));return p=Iu(p,B)|0,p|0?(_=p,K=F,_|0):(p=B,y=A[p>>2]|0,p=A[p+4>>2]|0,Dl(y,p,M)|0,Pl(y,p,R)|0,W=+Xc(M,R+8|0),W=+rt(+(+Xc(d,f)/(W*2))),ee[Vn>>3]=W,p=~~W>>>0,y=+dn(W)>=1?W>0?~~+qe(+$n(W/4294967296),4294967295)>>>0:~~+rt((W-+(~~W>>>0))/4294967296)>>>0:0,(A[Vn+4>>2]&2146435072|0)==2146435072?(_=1,K=F,_|0):(B=(p|0)==0&(y|0)==0,A[_>>2]=B?1:p,A[_+4>>2]=B?0:y,_=0,K=F,_|0))}function js(d,f){d=d|0,f=+f;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;w=d+16|0,M=+ee[w>>3],p=d+24|0,y=+ee[p>>3],_=M-y,_=M>3],R=d+8|0,B=+ee[R>>3],W=F-B,_=(_*f-_)*.5,f=(W*f-W)*.5,F=F+f,ee[d>>3]=F>1.5707963267948966?1.5707963267948966:F,f=B-f,ee[R>>3]=f<-1.5707963267948966?-1.5707963267948966:f,f=M+_,f=f>3.141592653589793?f+-6.283185307179586:f,ee[w>>3]=f<-3.141592653589793?f+6.283185307179586:f,f=y-_,f=f>3.141592653589793?f+-6.283185307179586:f,ee[p>>3]=f<-3.141592653589793?f+6.283185307179586:f}function Tu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0,A[d>>2]=f,A[d+4>>2]=p,A[d+8>>2]=_}function xd(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;se=f+8|0,A[se>>2]=0,B=+ee[d>>3],M=+dn(+B),F=+ee[d+8>>3],R=+dn(+F)*1.1547005383792515,M=M+R*.5,p=~~M,d=~~R,M=M-+(p|0),R=R-+(d|0);do if(M<.5)if(M<.3333333333333333)if(A[f>>2]=p,R<(M+1)*.5){A[f+4>>2]=d;break}else{d=d+1|0,A[f+4>>2]=d;break}else if(_e=1-M,d=(!(R<_e)&1)+d|0,A[f+4>>2]=d,_e<=R&R>2]=p;break}else{A[f>>2]=p;break}else{if(!(M<.6666666666666666))if(p=p+1|0,A[f>>2]=p,R>2]=d;break}else{d=d+1|0,A[f+4>>2]=d;break}if(R<1-M){if(A[f+4>>2]=d,M*2+-1>2]=p;break}}else d=d+1|0,A[f+4>>2]=d;p=p+1|0,A[f>>2]=p}while(!1);do if(B<0)if(d&1){W=(d+1|0)/2|0,W=Lr(p|0,((p|0)<0)<<31>>31|0,W|0,((W|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-((+(W>>>0)+4294967296*+(X()|0))*2+1)),A[f>>2]=p;break}else{W=(d|0)/2|0,W=Lr(p|0,((p|0)<0)<<31>>31|0,W|0,((W|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-(+(W>>>0)+4294967296*+(X()|0))*2),A[f>>2]=p;break}while(!1);W=f+4|0,F<0&&(p=p-((d<<1|1|0)/2|0)|0,A[f>>2]=p,d=0-d|0,A[W>>2]=d),_=d-p|0,(p|0)<0?(y=0-p|0,A[W>>2]=_,A[se>>2]=y,A[f>>2]=0,d=_,p=0):y=0,(d|0)<0&&(p=p-d|0,A[f>>2]=p,y=y-d|0,A[se>>2]=y,A[W>>2]=0,d=0),w=p-y|0,_=d-y|0,(y|0)<0&&(A[f>>2]=w,A[W>>2]=_,A[se>>2]=0,d=_,p=w,y=0),_=(d|0)<(p|0)?d:p,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(A[f>>2]=p-_,A[W>>2]=d-_,A[se>>2]=y-_)}function Pr(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,(f|0)<0&&(p=p-f|0,A[M>>2]=p,w=d+8|0,A[w>>2]=(A[w>>2]|0)-f,A[d>>2]=0,f=0),(p|0)<0?(f=f-p|0,A[d>>2]=f,w=d+8|0,y=(A[w>>2]|0)-p|0,A[w>>2]=y,A[M>>2]=0,p=0):(y=d+8|0,w=y,y=A[y>>2]|0),(y|0)<0&&(f=f-y|0,A[d>>2]=f,p=p-y|0,A[M>>2]=p,A[w>>2]=0,y=0),_=(p|0)<(f|0)?p:f,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(A[d>>2]=f-_,A[M>>2]=p-_,A[w>>2]=y-_)}function Mu(d,f){d=d|0,f=f|0;var p=0,_=0;_=A[d+8>>2]|0,p=+((A[d+4>>2]|0)-_|0),ee[f>>3]=+((A[d>>2]|0)-_|0)-p*.5,ee[f+8>>3]=p*.8660254037844386}function us(d,f,p){d=d|0,f=f|0,p=p|0,A[p>>2]=(A[f>>2]|0)+(A[d>>2]|0),A[p+4>>2]=(A[f+4>>2]|0)+(A[d+4>>2]|0),A[p+8>>2]=(A[f+8>>2]|0)+(A[d+8>>2]|0)}function ef(d,f,p){d=d|0,f=f|0,p=p|0,A[p>>2]=(A[d>>2]|0)-(A[f>>2]|0),A[p+4>>2]=(A[d+4>>2]|0)-(A[f+4>>2]|0),A[p+8>>2]=(A[d+8>>2]|0)-(A[f+8>>2]|0)}function jc(d,f){d=d|0,f=f|0;var p=0,_=0;p=it(A[d>>2]|0,f)|0,A[d>>2]=p,p=d+4|0,_=it(A[p>>2]|0,f)|0,A[p>>2]=_,d=d+8|0,f=it(A[d>>2]|0,f)|0,A[d>>2]=f}function Eu(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=A[d>>2]|0,R=(M|0)<0,_=(A[d+4>>2]|0)-(R?M:0)|0,w=(_|0)<0,y=(w?0-_|0:0)+((A[d+8>>2]|0)-(R?M:0))|0,p=(y|0)<0,d=p?0:y,f=(w?0:_)-(p?y:0)|0,y=(R?0:M)-(w?_:0)-(p?y:0)|0,p=(f|0)<(y|0)?f:y,p=(d|0)<(p|0)?d:p,_=(p|0)>0,d=d-(_?p:0)|0,f=f-(_?p:0)|0;e:do switch(y-(_?p:0)|0){case 0:switch(f|0){case 0:return R=(d|0)==0?0:(d|0)==1?1:7,R|0;case 1:return R=(d|0)==0?2:(d|0)==1?3:7,R|0;default:break e}case 1:switch(f|0){case 0:return R=(d|0)==0?4:(d|0)==1?5:7,R|0;case 1:{if(!d)d=6;else break e;return d|0}default:break e}}while(!1);return R=7,R|0}function a1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0;if(B=d+8|0,M=A[B>>2]|0,R=(A[d>>2]|0)-M|0,F=d+4|0,M=(A[F>>2]|0)-M|0,R>>>0>715827881|M>>>0>715827881){if(_=(R|0)>0,y=2147483647-R|0,w=-2147483648-R|0,(_?(y|0)<(R|0):(w|0)>(R|0))||(p=R<<1,_?(2147483647-p|0)<(R|0):(-2147483648-p|0)>(R|0))||((M|0)>0?(2147483647-M|0)<(M|0):(-2147483648-M|0)>(M|0))||(f=R*3|0,p=M<<1,(_?(y|0)<(p|0):(w|0)>(p|0))||((R|0)>-1?(f|-2147483648|0)>=(M|0):(f^-2147483648|0)<(M|0))))return F=1,F|0}else p=M<<1,f=R*3|0;return _=ol(+(f-M|0)*.14285714285714285)|0,A[d>>2]=_,y=ol(+(p+R|0)*.14285714285714285)|0,A[F>>2]=y,A[B>>2]=0,p=(y|0)<(_|0),f=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((f|0)>0?(2147483647-f|0)<(p|0):(-2147483648-f|0)>(p|0)))&&tt(27795,26892,354,26903),((f|0)>-1?(f|-2147483648|0)>=(p|0):(f^-2147483648|0)<(p|0))&&tt(27795,26892,354,26903)),f=y-_|0,(_|0)<0?(p=0-_|0,A[F>>2]=f,A[B>>2]=p,A[d>>2]=0,_=0):(f=y,p=0),(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[B>>2]=p,A[F>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[F>>2]=y,A[B>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(F=0,F|0):(A[d>>2]=y-_,A[F>>2]=f-_,A[B>>2]=p-_,F=0,F|0)}function hx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(M=d+8|0,y=A[M>>2]|0,w=(A[d>>2]|0)-y|0,R=d+4|0,y=(A[R>>2]|0)-y|0,w>>>0>715827881|y>>>0>715827881){if(p=(w|0)>0,(p?(2147483647-w|0)<(w|0):(-2147483648-w|0)>(w|0))||(f=w<<1,_=(y|0)>0,_?(2147483647-y|0)<(y|0):(-2147483648-y|0)>(y|0)))return R=1,R|0;if(B=y<<1,(_?(2147483647-B|0)<(y|0):(-2147483648-B|0)>(y|0))||(p?(2147483647-f|0)<(y|0):(-2147483648-f|0)>(y|0))||(p=y*3|0,(y|0)>-1?(p|-2147483648|0)>=(w|0):(p^-2147483648|0)<(w|0)))return B=1,B|0}else p=y*3|0,f=w<<1;return _=ol(+(f+y|0)*.14285714285714285)|0,A[d>>2]=_,y=ol(+(p-w|0)*.14285714285714285)|0,A[R>>2]=y,A[M>>2]=0,p=(y|0)<(_|0),f=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((f|0)>0?(2147483647-f|0)<(p|0):(-2147483648-f|0)>(p|0)))&&tt(27795,26892,402,26917),((f|0)>-1?(f|-2147483648|0)>=(p|0):(f^-2147483648|0)<(p|0))&&tt(27795,26892,402,26917)),f=y-_|0,(_|0)<0?(p=0-_|0,A[R>>2]=f,A[M>>2]=p,A[d>>2]=0,_=0):(f=y,p=0),(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(B=0,B|0):(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_,B=0,B|0)}function fx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=d+8|0,p=A[M>>2]|0,f=(A[d>>2]|0)-p|0,R=d+4|0,p=(A[R>>2]|0)-p|0,_=ol(+((f*3|0)-p|0)*.14285714285714285)|0,A[d>>2]=_,f=ol(+((p<<1)+f|0)*.14285714285714285)|0,A[R>>2]=f,A[M>>2]=0,p=f-_|0,(_|0)<0?(w=0-_|0,A[R>>2]=p,A[M>>2]=w,A[d>>2]=0,f=p,_=0,p=w):p=0,(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_)}function o1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=d+8|0,p=A[M>>2]|0,f=(A[d>>2]|0)-p|0,R=d+4|0,p=(A[R>>2]|0)-p|0,_=ol(+((f<<1)+p|0)*.14285714285714285)|0,A[d>>2]=_,f=ol(+((p*3|0)-f|0)*.14285714285714285)|0,A[R>>2]=f,A[M>>2]=0,p=f-_|0,(_|0)<0?(w=0-_|0,A[R>>2]=p,A[M>>2]=w,A[d>>2]=0,f=p,_=0,p=w):p=0,(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_)}function Hc(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,R=d+8|0,_=A[R>>2]|0,y=p+(f*3|0)|0,A[d>>2]=y,p=_+(p*3|0)|0,A[M>>2]=p,f=(_*3|0)+f|0,A[R>>2]=f,_=p-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=_,A[R>>2]=f,A[d>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function Cu(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=(f*3|0)+y|0,y=p+(y*3|0)|0,A[d>>2]=y,A[M>>2]=_,f=(p*3|0)+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,A[d>>2]=y,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=y-f|0,_=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=_,A[R>>2]=0,y=w,f=0):_=p,p=(_|0)<(y|0)?_:y,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=y-p,A[M>>2]=_-p,A[R>>2]=f-p)}function l1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;(f+-1|0)>>>0>=6||(y=(A[15440+(f*12|0)>>2]|0)+(A[d>>2]|0)|0,A[d>>2]=y,R=d+4|0,_=(A[15440+(f*12|0)+4>>2]|0)+(A[R>>2]|0)|0,A[R>>2]=_,M=d+8|0,f=(A[15440+(f*12|0)+8>>2]|0)+(A[M>>2]|0)|0,A[M>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[R>>2]=p,A[M>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[M>>2]=f,A[R>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[R>>2]=y-p,A[M>>2]=f-p))}function u1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=f+y|0,y=p+y|0,A[d>>2]=y,A[M>>2]=_,f=p+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function bd(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,_=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,y=_+f|0,A[d>>2]=y,_=p+_|0,A[M>>2]=_,f=p+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function Nu(d){switch(d=d|0,d|0){case 1:{d=5;break}case 5:{d=4;break}case 4:{d=6;break}case 6:{d=2;break}case 2:{d=3;break}case 3:{d=1;break}}return d|0}function tl(d){switch(d=d|0,d|0){case 1:{d=3;break}case 3:{d=2;break}case 2:{d=6;break}case 6:{d=4;break}case 4:{d=5;break}case 5:{d=1;break}}return d|0}function c1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,R=d+8|0,_=A[R>>2]|0,y=p+(f<<1)|0,A[d>>2]=y,p=_+(p<<1)|0,A[M>>2]=p,f=(_<<1)+f|0,A[R>>2]=f,_=p-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=_,A[R>>2]=f,A[d>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function h1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=(f<<1)+y|0,y=p+(y<<1)|0,A[d>>2]=y,A[M>>2]=_,f=(p<<1)+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,A[d>>2]=y,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=y-f|0,_=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=_,A[R>>2]=0,y=w,f=0):_=p,p=(_|0)<(y|0)?_:y,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=y-p,A[M>>2]=_-p,A[R>>2]=f-p)}function ep(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;return M=(A[d>>2]|0)-(A[f>>2]|0)|0,R=(M|0)<0,_=(A[d+4>>2]|0)-(A[f+4>>2]|0)-(R?M:0)|0,w=(_|0)<0,y=(R?0-M|0:0)+(A[d+8>>2]|0)-(A[f+8>>2]|0)+(w?0-_|0:0)|0,d=(y|0)<0,f=d?0:y,p=(w?0:_)-(d?y:0)|0,y=(R?0:M)-(w?_:0)-(d?y:0)|0,d=(p|0)<(y|0)?p:y,d=(f|0)<(d|0)?f:d,_=(d|0)>0,f=f-(_?d:0)|0,p=p-(_?d:0)|0,d=y-(_?d:0)|0,d=(d|0)>-1?d:0-d|0,p=(p|0)>-1?p:0-p|0,f=(f|0)>-1?f:0-f|0,f=(p|0)>(f|0)?p:f,((d|0)>(f|0)?d:f)|0}function dx(d,f){d=d|0,f=f|0;var p=0;p=A[d+8>>2]|0,A[f>>2]=(A[d>>2]|0)-p,A[f+4>>2]=(A[d+4>>2]|0)-p}function tp(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;return _=A[d>>2]|0,A[f>>2]=_,y=A[d+4>>2]|0,M=f+4|0,A[M>>2]=y,R=f+8|0,A[R>>2]=0,p=(y|0)<(_|0),d=p?_:y,p=p?y:_,(p|0)<0&&((p|0)==-2147483648||((d|0)>0?(2147483647-d|0)<(p|0):(-2147483648-d|0)>(p|0))||((d|0)>-1?(d|-2147483648|0)>=(p|0):(d^-2147483648|0)<(p|0)))?(f=1,f|0):(d=y-_|0,(_|0)<0?(p=0-_|0,A[M>>2]=d,A[R>>2]=p,A[f>>2]=0,_=0):(d=y,p=0),(d|0)<0&&(_=_-d|0,A[f>>2]=_,p=p-d|0,A[R>>2]=p,A[M>>2]=0,d=0),w=_-p|0,y=d-p|0,(p|0)<0?(A[f>>2]=w,A[M>>2]=y,A[R>>2]=0,d=y,y=w,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(f=0,f|0):(A[f>>2]=y-_,A[M>>2]=d-_,A[R>>2]=p-_,f=0,f|0))}function f1(d){d=d|0;var f=0,p=0,_=0,y=0;f=d+8|0,y=A[f>>2]|0,p=y-(A[d>>2]|0)|0,A[d>>2]=p,_=d+4|0,d=(A[_>>2]|0)-y|0,A[_>>2]=d,A[f>>2]=0-(d+p)}function Ax(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;p=A[d>>2]|0,f=0-p|0,A[d>>2]=f,M=d+8|0,A[M>>2]=0,R=d+4|0,_=A[R>>2]|0,y=_+p|0,(p|0)>0?(A[R>>2]=y,A[M>>2]=p,A[d>>2]=0,f=0,_=y):p=0,(_|0)<0?(w=f-_|0,A[d>>2]=w,p=p-_|0,A[M>>2]=p,A[R>>2]=0,y=w-p|0,f=0-p|0,(p|0)<0?(A[d>>2]=y,A[R>>2]=f,A[M>>2]=0,_=f,p=0):(_=0,y=w)):y=f,f=(_|0)<(y|0)?_:y,f=(p|0)<(f|0)?p:f,!((f|0)<=0)&&(A[d>>2]=y-f,A[R>>2]=_-f,A[M>>2]=p-f)}function px(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0;if(se=K,K=K+64|0,W=se,R=se+56|0,!(!0&(f&2013265920|0)==134217728&(!0&(_&2013265920|0)==134217728)))return y=5,K=se,y|0;if((d|0)==(p|0)&(f|0)==(_|0))return A[y>>2]=0,y=0,K=se,y|0;if(M=Ct(d|0,f|0,52)|0,X()|0,M=M&15,F=Ct(p|0,_|0,52)|0,X()|0,(M|0)!=(F&15|0))return y=12,K=se,y|0;if(w=M+-1|0,M>>>0>1){Lu(d,f,w,W)|0,Lu(p,_,w,R)|0,F=W,B=A[F>>2]|0,F=A[F+4>>2]|0;e:do if((B|0)==(A[R>>2]|0)&&(F|0)==(A[R+4>>2]|0)){M=(M^15)*3|0,w=Ct(d|0,f|0,M|0)|0,X()|0,w=w&7,M=Ct(p|0,_|0,M|0)|0,X()|0,M=M&7;do if((w|0)==0|(M|0)==0)A[y>>2]=1,w=0;else if((w|0)==7)w=5;else{if((w|0)==1|(M|0)==1&&wi(B,F)|0){w=5;break}if((A[15536+(w<<2)>>2]|0)!=(M|0)&&(A[15568+(w<<2)>>2]|0)!=(M|0))break e;A[y>>2]=1,w=0}while(!1);return y=w,K=se,y|0}while(!1)}w=W,M=w+56|0;do A[w>>2]=0,w=w+4|0;while((w|0)<(M|0));return ys(d,f,1,W)|0,f=W,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0))&&(f=W+8|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+16|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+24|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+32|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+40|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))?(w=W+48|0,w=((A[w>>2]|0)==(p|0)?(A[w+4>>2]|0)==(_|0):0)&1):w=1,A[y>>2]=w,y=0,K=se,y|0}function d1(d,f,p,_,y){return d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,p=xs(d,f,p,_)|0,(p|0)==7?(y=11,y|0):(_=It(p|0,0,56)|0,f=f&-2130706433|(X()|0)|268435456,A[y>>2]=d|_,A[y+4>>2]=f,y=0,y|0)}function mx(d,f,p){return d=d|0,f=f|0,p=p|0,!0&(f&2013265920|0)==268435456?(A[p>>2]=d,A[p+4>>2]=f&-2130706433|134217728,p=0,p|0):(p=6,p|0)}function gx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return y=K,K=K+16|0,_=y,A[_>>2]=0,!0&(f&2013265920|0)==268435456?(w=Ct(d|0,f|0,56)|0,X()|0,_=bi(d,f&-2130706433|134217728,w&7,_,p)|0,K=y,_|0):(_=6,K=y,_|0)}function A1(d,f){d=d|0,f=f|0;var p=0;switch(p=Ct(d|0,f|0,56)|0,X()|0,p&7){case 0:case 7:return p=0,p|0}return p=f&-2130706433|134217728,!(!0&(f&2013265920|0)==268435456)||!0&(f&117440512|0)==16777216&(wi(d,p)|0)!=0?(p=0,p|0):(p=Td(d,p)|0,p|0)}function vx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;return y=K,K=K+16|0,_=y,!0&(f&2013265920|0)==268435456?(w=f&-2130706433|134217728,M=p,A[M>>2]=d,A[M+4>>2]=w,A[_>>2]=0,f=Ct(d|0,f|0,56)|0,X()|0,_=bi(d,w,f&7,_,p+8|0)|0,K=y,_|0):(_=6,K=y,_|0)}function _x(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;return y=(wi(d,f)|0)==0,f=f&-2130706433,_=p,A[_>>2]=y?d:0,A[_+4>>2]=y?f|285212672:0,_=p+8|0,A[_>>2]=d,A[_+4>>2]=f|301989888,_=p+16|0,A[_>>2]=d,A[_+4>>2]=f|318767104,_=p+24|0,A[_>>2]=d,A[_+4>>2]=f|335544320,_=p+32|0,A[_>>2]=d,A[_+4>>2]=f|352321536,p=p+40|0,A[p>>2]=d,A[p+4>>2]=f|369098752,0}function Sd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;return M=K,K=K+16|0,y=M,w=f&-2130706433|134217728,!0&(f&2013265920|0)==268435456?(_=Ct(d|0,f|0,56)|0,X()|0,_=yp(d,w,_&7)|0,(_|0)==-1?(A[p>>2]=0,w=6,K=M,w|0):(Bu(d,w,y)|0&&tt(27795,26932,282,26947),f=Ct(d|0,f|0,52)|0,X()|0,f=f&15,wi(d,w)|0?np(y,f,_,2,p):wd(y,f,_,2,p),w=0,K=M,w|0)):(w=6,K=M,w|0)}function yx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;_=K,K=K+16|0,y=_,xx(d,f,p,y),xd(y,p+4|0),K=_}function xx(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0;if(R=K,K=K+16|0,B=R,bx(d,p,B),w=+Wi(+(1-+ee[B>>3]*.5)),w<1e-16){A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,A[_+12>>2]=0,K=R;return}if(B=A[p>>2]|0,y=+ee[15920+(B*24|0)>>3],y=+$c(y-+$c(+Cx(15600+(B<<4)|0,d))),bs(f)|0?M=+$c(y+-.3334731722518321):M=y,y=+Er(+w)*2.618033988749896,(f|0)>0){d=0;do y=y*2.6457513110645907,d=d+1|0;while((d|0)!=(f|0))}w=+an(+M)*y,ee[_>>3]=w,M=+mn(+M)*y,ee[_+8>>3]=M,K=R}function bx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(w=K,K=K+32|0,y=w,ju(d,y),A[f>>2]=0,ee[p>>3]=5,_=+tr(16400,y),_<+ee[p>>3]&&(A[f>>2]=0,ee[p>>3]=_),_=+tr(16424,y),_<+ee[p>>3]&&(A[f>>2]=1,ee[p>>3]=_),_=+tr(16448,y),_<+ee[p>>3]&&(A[f>>2]=2,ee[p>>3]=_),_=+tr(16472,y),_<+ee[p>>3]&&(A[f>>2]=3,ee[p>>3]=_),_=+tr(16496,y),_<+ee[p>>3]&&(A[f>>2]=4,ee[p>>3]=_),_=+tr(16520,y),_<+ee[p>>3]&&(A[f>>2]=5,ee[p>>3]=_),_=+tr(16544,y),_<+ee[p>>3]&&(A[f>>2]=6,ee[p>>3]=_),_=+tr(16568,y),_<+ee[p>>3]&&(A[f>>2]=7,ee[p>>3]=_),_=+tr(16592,y),_<+ee[p>>3]&&(A[f>>2]=8,ee[p>>3]=_),_=+tr(16616,y),_<+ee[p>>3]&&(A[f>>2]=9,ee[p>>3]=_),_=+tr(16640,y),_<+ee[p>>3]&&(A[f>>2]=10,ee[p>>3]=_),_=+tr(16664,y),_<+ee[p>>3]&&(A[f>>2]=11,ee[p>>3]=_),_=+tr(16688,y),_<+ee[p>>3]&&(A[f>>2]=12,ee[p>>3]=_),_=+tr(16712,y),_<+ee[p>>3]&&(A[f>>2]=13,ee[p>>3]=_),_=+tr(16736,y),_<+ee[p>>3]&&(A[f>>2]=14,ee[p>>3]=_),_=+tr(16760,y),_<+ee[p>>3]&&(A[f>>2]=15,ee[p>>3]=_),_=+tr(16784,y),_<+ee[p>>3]&&(A[f>>2]=16,ee[p>>3]=_),_=+tr(16808,y),_<+ee[p>>3]&&(A[f>>2]=17,ee[p>>3]=_),_=+tr(16832,y),_<+ee[p>>3]&&(A[f>>2]=18,ee[p>>3]=_),_=+tr(16856,y),!(_<+ee[p>>3])){K=w;return}A[f>>2]=19,ee[p>>3]=_,K=w}function Ru(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0;if(w=+Bl(d),w<1e-16){f=15600+(f<<4)|0,A[y>>2]=A[f>>2],A[y+4>>2]=A[f+4>>2],A[y+8>>2]=A[f+8>>2],A[y+12>>2]=A[f+12>>2];return}if(M=+Ge(+ +ee[d+8>>3],+ +ee[d>>3]),(p|0)>0){d=0;do w=w*.37796447300922725,d=d+1|0;while((d|0)!=(p|0))}R=w*.3333333333333333,_?(p=(bs(p)|0)==0,w=+ce(+((p?R:R*.37796447300922725)*.381966011250105))):(w=+ce(+(w*.381966011250105)),bs(p)|0&&(M=+$c(M+.3334731722518321))),Nx(15600+(f<<4)|0,+$c(+ee[15920+(f*24|0)>>3]-M),w,y)}function tf(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;_=K,K=K+16|0,y=_,Mu(d+4|0,y),Ru(y,A[d>>2]|0,f,0,p),K=_}function np(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0,xn=0,si=0,Cn=0;if(xn=K,K=K+272|0,w=xn+256|0,Xe=xn+240|0,En=xn,fn=xn+224|0,kt=xn+208|0,je=xn+176|0,Le=xn+160|0,Ft=xn+192|0,un=xn+144|0,on=xn+128|0,kn=xn+112|0,Dn=xn+96|0,Zn=xn+80|0,A[w>>2]=f,A[Xe>>2]=A[d>>2],A[Xe+4>>2]=A[d+4>>2],A[Xe+8>>2]=A[d+8>>2],A[Xe+12>>2]=A[d+12>>2],ip(Xe,w,En),A[y>>2]=0,Xe=_+p+((_|0)==5&1)|0,(Xe|0)<=(p|0)){K=xn;return}B=A[w>>2]|0,F=fn+4|0,W=je+4|0,se=p+5|0,_e=16880+(B<<2)|0,ve=16960+(B<<2)|0,ye=on+8|0,Pe=kn+8|0,ze=Dn+8|0,nt=kt+4|0,R=p;e:for(;;){M=En+(((R|0)%5|0)<<4)|0,A[kt>>2]=A[M>>2],A[kt+4>>2]=A[M+4>>2],A[kt+8>>2]=A[M+8>>2],A[kt+12>>2]=A[M+12>>2];do;while((Du(kt,B,0,1)|0)==2);if((R|0)>(p|0)&(bs(f)|0)!=0){if(A[je>>2]=A[kt>>2],A[je+4>>2]=A[kt+4>>2],A[je+8>>2]=A[kt+8>>2],A[je+12>>2]=A[kt+12>>2],Mu(F,Le),_=A[je>>2]|0,w=A[17040+(_*80|0)+(A[fn>>2]<<2)>>2]|0,A[je>>2]=A[18640+(_*80|0)+(w*20|0)>>2],M=A[18640+(_*80|0)+(w*20|0)+16>>2]|0,(M|0)>0){d=0;do u1(W),d=d+1|0;while((d|0)<(M|0))}switch(M=18640+(_*80|0)+(w*20|0)+4|0,A[Ft>>2]=A[M>>2],A[Ft+4>>2]=A[M+4>>2],A[Ft+8>>2]=A[M+8>>2],jc(Ft,(A[_e>>2]|0)*3|0),us(W,Ft,W),Pr(W),Mu(W,un),si=+(A[ve>>2]|0),ee[on>>3]=si*3,ee[ye>>3]=0,Cn=si*-1.5,ee[kn>>3]=Cn,ee[Pe>>3]=si*2.598076211353316,ee[Dn>>3]=Cn,ee[ze>>3]=si*-2.598076211353316,A[17040+((A[je>>2]|0)*80|0)+(A[kt>>2]<<2)>>2]|0){case 1:{d=kn,_=on;break}case 3:{d=Dn,_=kn;break}case 2:{d=on,_=Dn;break}default:{d=12;break e}}vp(Le,un,_,d,Zn),Ru(Zn,A[je>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1}if((R|0)<(se|0)&&(Mu(nt,je),Ru(je,A[kt>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1),A[fn>>2]=A[kt>>2],A[fn+4>>2]=A[kt+4>>2],A[fn+8>>2]=A[kt+8>>2],A[fn+12>>2]=A[kt+12>>2],R=R+1|0,(R|0)>=(Xe|0)){d=3;break}}if((d|0)==3){K=xn;return}else(d|0)==12&&tt(26970,27017,572,27027)}function ip(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;B=K,K=K+128|0,_=B+64|0,y=B,w=_,M=20240,R=w+60|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));w=y,M=20304,R=w+60|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));R=(bs(A[f>>2]|0)|0)==0,_=R?_:y,y=d+4|0,c1(y),h1(y),bs(A[f>>2]|0)|0&&(Cu(y),A[f>>2]=(A[f>>2]|0)+1),A[p>>2]=A[d>>2],f=p+4|0,us(y,_,f),Pr(f),A[p+16>>2]=A[d>>2],f=p+20|0,us(y,_+12|0,f),Pr(f),A[p+32>>2]=A[d>>2],f=p+36|0,us(y,_+24|0,f),Pr(f),A[p+48>>2]=A[d>>2],f=p+52|0,us(y,_+36|0,f),Pr(f),A[p+64>>2]=A[d>>2],p=p+68|0,us(y,_+48|0,p),Pr(p),K=B}function Du(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0;if(ye=K,K=K+32|0,_e=ye+12|0,R=ye,ve=d+4|0,se=A[16960+(f<<2)>>2]|0,W=(_|0)!=0,se=W?se*3|0:se,y=A[ve>>2]|0,F=d+8|0,M=A[F>>2]|0,W){if(w=d+12|0,_=A[w>>2]|0,y=M+y+_|0,(y|0)==(se|0))return ve=1,K=ye,ve|0;B=w}else B=d+12|0,_=A[B>>2]|0,y=M+y+_|0;if((y|0)<=(se|0))return ve=0,K=ye,ve|0;do if((_|0)>0){if(_=A[d>>2]|0,(M|0)>0){w=18640+(_*80|0)+60|0,_=d;break}_=18640+(_*80|0)+40|0,p?(Tu(_e,se,0,0),ef(ve,_e,R),bd(R),us(R,_e,ve),w=_,_=d):(w=_,_=d)}else w=18640+((A[d>>2]|0)*80|0)+20|0,_=d;while(!1);if(A[_>>2]=A[w>>2],y=w+16|0,(A[y>>2]|0)>0){_=0;do u1(ve),_=_+1|0;while((_|0)<(A[y>>2]|0))}return d=w+4|0,A[_e>>2]=A[d>>2],A[_e+4>>2]=A[d+4>>2],A[_e+8>>2]=A[d+8>>2],f=A[16880+(f<<2)>>2]|0,jc(_e,W?f*3|0:f),us(ve,_e,ve),Pr(ve),W?_=((A[F>>2]|0)+(A[ve>>2]|0)+(A[B>>2]|0)|0)==(se|0)?1:2:_=2,ve=_,K=ye,ve|0}function p1(d,f){d=d|0,f=f|0;var p=0;do p=Du(d,f,0,1)|0;while((p|0)==2);return p|0}function wd(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0;if(Dn=K,K=K+240|0,w=Dn+224|0,Ft=Dn+208|0,un=Dn,on=Dn+192|0,kn=Dn+176|0,ze=Dn+160|0,nt=Dn+144|0,Xe=Dn+128|0,je=Dn+112|0,Le=Dn+96|0,A[w>>2]=f,A[Ft>>2]=A[d>>2],A[Ft+4>>2]=A[d+4>>2],A[Ft+8>>2]=A[d+8>>2],A[Ft+12>>2]=A[d+12>>2],rp(Ft,w,un),A[y>>2]=0,Pe=_+p+((_|0)==6&1)|0,(Pe|0)<=(p|0)){K=Dn;return}B=A[w>>2]|0,F=p+6|0,W=16960+(B<<2)|0,se=nt+8|0,_e=Xe+8|0,ve=je+8|0,ye=on+4|0,M=0,R=p,_=-1;e:for(;;){if(w=(R|0)%6|0,d=un+(w<<4)|0,A[on>>2]=A[d>>2],A[on+4>>2]=A[d+4>>2],A[on+8>>2]=A[d+8>>2],A[on+12>>2]=A[d+12>>2],d=M,M=Du(on,B,0,1)|0,(R|0)>(p|0)&(bs(f)|0)!=0&&(d|0)!=1&&(A[on>>2]|0)!=(_|0)){switch(Mu(un+(((w+5|0)%6|0)<<4)+4|0,kn),Mu(un+(w<<4)+4|0,ze),Zn=+(A[W>>2]|0),ee[nt>>3]=Zn*3,ee[se>>3]=0,En=Zn*-1.5,ee[Xe>>3]=En,ee[_e>>3]=Zn*2.598076211353316,ee[je>>3]=En,ee[ve>>3]=Zn*-2.598076211353316,w=A[Ft>>2]|0,A[17040+(w*80|0)+(((_|0)==(w|0)?A[on>>2]|0:_)<<2)>>2]|0){case 1:{d=Xe,_=nt;break}case 3:{d=je,_=Xe;break}case 2:{d=nt,_=je;break}default:{d=8;break e}}vp(kn,ze,_,d,Le),!(_p(kn,Le)|0)&&!(_p(ze,Le)|0)&&(Ru(Le,A[Ft>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1)}if((R|0)<(F|0)&&(Mu(ye,kn),Ru(kn,A[on>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1),R=R+1|0,(R|0)>=(Pe|0)){d=3;break}else _=A[on>>2]|0}if((d|0)==3){K=Dn;return}else(d|0)==8&&tt(27054,27017,737,27099)}function rp(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;B=K,K=K+160|0,_=B+80|0,y=B,w=_,M=20368,R=w+72|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));w=y,M=20448,R=w+72|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));R=(bs(A[f>>2]|0)|0)==0,_=R?_:y,y=d+4|0,c1(y),h1(y),bs(A[f>>2]|0)|0&&(Cu(y),A[f>>2]=(A[f>>2]|0)+1),A[p>>2]=A[d>>2],f=p+4|0,us(y,_,f),Pr(f),A[p+16>>2]=A[d>>2],f=p+20|0,us(y,_+12|0,f),Pr(f),A[p+32>>2]=A[d>>2],f=p+36|0,us(y,_+24|0,f),Pr(f),A[p+48>>2]=A[d>>2],f=p+52|0,us(y,_+36|0,f),Pr(f),A[p+64>>2]=A[d>>2],f=p+68|0,us(y,_+48|0,f),Pr(f),A[p+80>>2]=A[d>>2],p=p+84|0,us(y,_+60|0,p),Pr(p),K=B}function Wc(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,52)|0,X()|0,f&15|0}function m1(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,45)|0,X()|0,f&127|0}function Sx(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,(p+-1|0)>>>0>14?(_=4,_|0):(p=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,A[_>>2]=p&7,_=0,_|0)}function wx(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;if(d>>>0>15)return _=4,_|0;if(f>>>0>121)return _=17,_|0;M=It(d|0,0,52)|0,y=X()|0,R=It(f|0,0,45)|0,y=y|(X()|0)|134225919;e:do if((d|0)>=1){for(R=1,M=(xt[20528+f>>0]|0)!=0,w=-1;;){if(f=A[p+(R+-1<<2)>>2]|0,f>>>0>6){y=18,f=10;break}if(!((f|0)==0|M^1))if((f|0)==1){y=19,f=10;break}else M=0;if(F=(15-R|0)*3|0,B=It(7,0,F|0)|0,y=y&~(X()|0),f=It(f|0,((f|0)<0)<<31>>31|0,F|0)|0,w=f|w&~B,y=X()|0|y,(R|0)<(d|0))R=R+1|0;else break e}if((f|0)==10)return y|0}else w=-1;while(!1);return F=_,A[F>>2]=w,A[F+4>>2]=y,F=0,F|0}function Td(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return!(!0&(f&-16777216|0)==134217728)||(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0,p=p&127,p>>>0>121)?(d=0,d|0):(M=(_^15)*3|0,y=Ct(d|0,f|0,M|0)|0,M=It(y|0,X()|0,M|0)|0,y=X()|0,w=Lr(-1227133514,-1171,M|0,y|0)|0,!((M&613566756&w|0)==0&(y&4681&(X()|0)|0)==0)||(M=(_*3|0)+19|0,w=It(~d|0,~f|0,M|0)|0,M=Ct(w|0,X()|0,M|0)|0,!((_|0)==15|(M|0)==0&(X()|0)==0))?(M=0,M|0):!(xt[20528+p>>0]|0)||(f=f&8191,(d|0)==0&(f|0)==0)?(M=1,M|0):(M=of(d|0,f|0)|0,X()|0,((63-M|0)%3|0|0)!=0|0))}function g1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return!0&(f&-16777216|0)==134217728&&(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0,p=p&127,p>>>0<=121)&&(M=(_^15)*3|0,y=Ct(d|0,f|0,M|0)|0,M=It(y|0,X()|0,M|0)|0,y=X()|0,w=Lr(-1227133514,-1171,M|0,y|0)|0,(M&613566756&w|0)==0&(y&4681&(X()|0)|0)==0)&&(M=(_*3|0)+19|0,w=It(~d|0,~f|0,M|0)|0,M=Ct(w|0,X()|0,M|0)|0,(_|0)==15|(M|0)==0&(X()|0)==0)&&(!(xt[20528+p>>0]|0)||(p=f&8191,(d|0)==0&(p|0)==0)||(M=of(d|0,p|0)|0,X()|0,(63-M|0)%3|0|0))||A1(d,f)|0?(M=1,M|0):(M=(al(d,f)|0)!=0&1,M|0)}function Pu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0;if(y=It(f|0,0,52)|0,w=X()|0,p=It(p|0,0,45)|0,p=w|(X()|0)|134225919,(f|0)<1){w=-1,_=p,f=d,A[f>>2]=w,d=d+4|0,A[d>>2]=_;return}for(w=1,y=-1;M=(15-w|0)*3|0,R=It(7,0,M|0)|0,p=p&~(X()|0),M=It(_|0,0,M|0)|0,y=y&~R|M,p=p|(X()|0),(w|0)!=(f|0);)w=w+1|0;R=d,M=R,A[M>>2]=y,R=R+4|0,A[R>>2]=p}function Lu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;if(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,p>>>0>15)return _=4,_|0;if((w|0)<(p|0))return _=12,_|0;if((w|0)==(p|0))return A[_>>2]=d,A[_+4>>2]=f,_=0,_|0;if(y=It(p|0,0,52)|0,y=y|d,d=X()|0|f&-15728641,(w|0)>(p|0))do f=It(7,0,(14-p|0)*3|0)|0,p=p+1|0,y=f|y,d=X()|0|d;while((p|0)<(w|0));return A[_>>2]=y,A[_+4>>2]=d,_=0,_|0}function nf(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,!((p|0)<16&(w|0)<=(p|0)))return _=4,_|0;y=p-w|0,p=Ct(d|0,f|0,45)|0,X()|0;e:do if(!(Ji(p&127)|0))p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,y=X()|0;else{t:do if(w|0){for(p=1;M=It(7,0,(15-p|0)*3|0)|0,!!((M&d|0)==0&((X()|0)&f|0)==0);)if(p>>>0>>0)p=p+1|0;else break t;p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,y=X()|0;break e}while(!1);p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,p=ur(p|0,X()|0,5,0)|0,p=tn(p|0,X()|0,-5,-1)|0,p=Io(p|0,X()|0,6,0)|0,p=tn(p|0,X()|0,1,0)|0,y=X()|0}while(!1);return M=_,A[M>>2]=p,A[M+4>>2]=y,M=0,M|0}function wi(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;if(y=Ct(d|0,f|0,45)|0,X()|0,!(Ji(y&127)|0))return y=0,y|0;y=Ct(d|0,f|0,52)|0,X()|0,y=y&15;e:do if(!y)p=0;else for(_=1;;){if(p=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,p=p&7,p|0)break e;if(_>>>0>>0)_=_+1|0;else{p=0;break}}while(!1);return y=(p|0)==0&1,y|0}function v1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0;if(M=K,K=K+16|0,w=M,nl(w,d,f,p),f=w,d=A[f>>2]|0,f=A[f+4>>2]|0,(d|0)==0&(f|0)==0)return K=M,0;y=0,p=0;do R=_+(y<<3)|0,A[R>>2]=d,A[R+4>>2]=f,y=tn(y|0,p|0,1,0)|0,p=X()|0,rf(w),R=w,d=A[R>>2]|0,f=A[R+4>>2]|0;while(!((d|0)==0&(f|0)==0));return K=M,0}function sp(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,(_|0)<(p|0)?(p=f,_=d,he(p|0),_|0):(p=It(-1,-1,((_-p|0)*3|0)+3|0)|0,_=It(~p|0,~(X()|0)|0,(15-_|0)*3|0)|0,p=~(X()|0)&f,_=~_&d,he(p|0),_|0)}function Md(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0;return y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,(p|0)<16&(y|0)<=(p|0)?((y|0)<(p|0)&&(y=It(-1,-1,((p+-1-y|0)*3|0)+3|0)|0,y=It(~y|0,~(X()|0)|0,(15-p|0)*3|0)|0,f=~(X()|0)&f,d=~y&d),y=It(p|0,0,52)|0,p=f&-15728641|(X()|0),A[_>>2]=d|y,A[_+4>>2]=p,_=0,_|0):(_=4,_|0)}function ap(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0;if((p|0)==0&(_|0)==0)return kt=0,kt|0;if(y=d,w=A[y>>2]|0,y=A[y+4>>2]|0,!0&(y&15728640|0)==0){if(!((_|0)>0|(_|0)==0&p>>>0>0)||(kt=f,A[kt>>2]=w,A[kt+4>>2]=y,(p|0)==1&(_|0)==0))return kt=0,kt|0;y=1,w=0;do En=d+(y<<3)|0,fn=A[En+4>>2]|0,kt=f+(y<<3)|0,A[kt>>2]=A[En>>2],A[kt+4>>2]=fn,y=tn(y|0,w|0,1,0)|0,w=X()|0;while((w|0)<(_|0)|(w|0)==(_|0)&y>>>0

>>0);return y=0,y|0}if(Zn=p<<3,fn=Oo(Zn)|0,!fn)return kt=13,kt|0;if(Ol(fn|0,d|0,Zn|0)|0,En=Ys(p,8)|0,!En)return vn(fn),kt=13,kt|0;e:for(;;){y=fn,F=A[y>>2]|0,y=A[y+4>>2]|0,kn=Ct(F|0,y|0,52)|0,X()|0,kn=kn&15,Dn=kn+-1|0,on=(kn|0)!=0,un=(_|0)>0|(_|0)==0&p>>>0>0;t:do if(on&un){if(Xe=It(Dn|0,0,52)|0,je=X()|0,Dn>>>0>15){if(!((F|0)==0&(y|0)==0)){kt=16;break e}for(w=0,d=0;;){if(w=tn(w|0,d|0,1,0)|0,d=X()|0,!((d|0)<(_|0)|(d|0)==(_|0)&w>>>0

>>0))break t;if(M=fn+(w<<3)|0,Ft=A[M>>2]|0,M=A[M+4>>2]|0,!((Ft|0)==0&(M|0)==0)){y=M,kt=16;break e}}}for(R=F,d=y,w=0,M=0;;){if(!((R|0)==0&(d|0)==0)){if(!(!0&(d&117440512|0)==0)){kt=21;break e}if(W=Ct(R|0,d|0,52)|0,X()|0,W=W&15,(W|0)<(Dn|0)){y=12,kt=27;break e}if((W|0)!=(Dn|0)&&(R=R|Xe,d=d&-15728641|je,W>>>0>=kn>>>0)){B=Dn;do Ft=It(7,0,(14-B|0)*3|0)|0,B=B+1|0,R=Ft|R,d=X()|0|d;while(B>>>0>>0)}if(_e=Yu(R|0,d|0,p|0,_|0)|0,ve=X()|0,B=En+(_e<<3)|0,W=B,se=A[W>>2]|0,W=A[W+4>>2]|0,!((se|0)==0&(W|0)==0)){ze=0,nt=0;do{if((ze|0)>(_|0)|(ze|0)==(_|0)&nt>>>0>p>>>0){kt=31;break e}if((se|0)==(R|0)&(W&-117440513|0)==(d|0)){ye=Ct(se|0,W|0,56)|0,X()|0,ye=ye&7,Pe=ye+1|0,Ft=Ct(se|0,W|0,45)|0,X()|0;n:do if(!(Ji(Ft&127)|0))W=7;else{if(se=Ct(se|0,W|0,52)|0,X()|0,se=se&15,!se){W=6;break}for(W=1;;){if(Ft=It(7,0,(15-W|0)*3|0)|0,!((Ft&R|0)==0&((X()|0)&d|0)==0)){W=7;break n}if(W>>>0>>0)W=W+1|0;else{W=6;break}}}while(!1);if((ye+2|0)>>>0>W>>>0){kt=41;break e}Ft=It(Pe|0,0,56)|0,d=X()|0|d&-117440513,Le=B,A[Le>>2]=0,A[Le+4>>2]=0,R=Ft|R}else _e=tn(_e|0,ve|0,1,0)|0,_e=Kc(_e|0,X()|0,p|0,_|0)|0,ve=X()|0;nt=tn(nt|0,ze|0,1,0)|0,ze=X()|0,B=En+(_e<<3)|0,W=B,se=A[W>>2]|0,W=A[W+4>>2]|0}while(!((se|0)==0&(W|0)==0))}Ft=B,A[Ft>>2]=R,A[Ft+4>>2]=d}if(w=tn(w|0,M|0,1,0)|0,M=X()|0,!((M|0)<(_|0)|(M|0)==(_|0)&w>>>0

>>0))break t;d=fn+(w<<3)|0,R=A[d>>2]|0,d=A[d+4>>2]|0}}while(!1);if(Ft=tn(p|0,_|0,5,0)|0,Le=X()|0,Le>>>0<0|(Le|0)==0&Ft>>>0<11){kt=85;break}if(Ft=Io(p|0,_|0,6,0)|0,X()|0,Ft=Ys(Ft,8)|0,!Ft){kt=48;break}do if(un){for(Pe=0,d=0,ye=0,ze=0;;){if(W=En+(Pe<<3)|0,M=W,w=A[M>>2]|0,M=A[M+4>>2]|0,(w|0)==0&(M|0)==0)Le=ye;else{se=Ct(w|0,M|0,56)|0,X()|0,se=se&7,R=se+1|0,_e=M&-117440513,Le=Ct(w|0,M|0,45)|0,X()|0;t:do if(Ji(Le&127)|0){if(ve=Ct(w|0,M|0,52)|0,X()|0,ve=ve&15,ve|0)for(B=1;;){if(Le=It(7,0,(15-B|0)*3|0)|0,!((w&Le|0)==0&(_e&(X()|0)|0)==0))break t;if(B>>>0>>0)B=B+1|0;else break}M=It(R|0,0,56)|0,w=M|w,M=X()|0|_e,R=W,A[R>>2]=w,A[R+4>>2]=M,R=se+2|0}while(!1);(R|0)==7?(Le=Ft+(d<<3)|0,A[Le>>2]=w,A[Le+4>>2]=M&-117440513,d=tn(d|0,ye|0,1,0)|0,Le=X()|0):Le=ye}if(Pe=tn(Pe|0,ze|0,1,0)|0,ze=X()|0,(ze|0)<(_|0)|(ze|0)==(_|0)&Pe>>>0

>>0)ye=Le;else break}if(un){if(nt=Dn>>>0>15,Xe=It(Dn|0,0,52)|0,je=X()|0,!on){for(w=0,B=0,R=0,M=0;(F|0)==0&(y|0)==0||(Dn=f+(w<<3)|0,A[Dn>>2]=F,A[Dn+4>>2]=y,w=tn(w|0,B|0,1,0)|0,B=X()|0),R=tn(R|0,M|0,1,0)|0,M=X()|0,!!((M|0)<(_|0)|(M|0)==(_|0)&R>>>0

>>0);)y=fn+(R<<3)|0,F=A[y>>2]|0,y=A[y+4>>2]|0;y=Le;break}for(w=0,B=0,M=0,R=0;;){do if(!((F|0)==0&(y|0)==0)){if(ve=Ct(F|0,y|0,52)|0,X()|0,ve=ve&15,nt|(ve|0)<(Dn|0)){kt=80;break e}if((ve|0)!=(Dn|0)){if(W=F|Xe,se=y&-15728641|je,ve>>>0>=kn>>>0){_e=Dn;do on=It(7,0,(14-_e|0)*3|0)|0,_e=_e+1|0,W=on|W,se=X()|0|se;while(_e>>>0>>0)}}else W=F,se=y;ye=Yu(W|0,se|0,p|0,_|0)|0,_e=0,ve=0,ze=X()|0;do{if((_e|0)>(_|0)|(_e|0)==(_|0)&ve>>>0>p>>>0){kt=81;break e}if(on=En+(ye<<3)|0,Pe=A[on+4>>2]|0,(Pe&-117440513|0)==(se|0)&&(A[on>>2]|0)==(W|0)){kt=65;break}on=tn(ye|0,ze|0,1,0)|0,ye=Kc(on|0,X()|0,p|0,_|0)|0,ze=X()|0,ve=tn(ve|0,_e|0,1,0)|0,_e=X()|0,on=En+(ye<<3)|0}while(!((A[on>>2]|0)==(W|0)&&(A[on+4>>2]|0)==(se|0)));if((kt|0)==65&&(kt=0,!0&(Pe&117440512|0)==100663296))break;on=f+(w<<3)|0,A[on>>2]=F,A[on+4>>2]=y,w=tn(w|0,B|0,1,0)|0,B=X()|0}while(!1);if(M=tn(M|0,R|0,1,0)|0,R=X()|0,!((R|0)<(_|0)|(R|0)==(_|0)&M>>>0

>>0))break;y=fn+(M<<3)|0,F=A[y>>2]|0,y=A[y+4>>2]|0}y=Le}else w=0,y=Le}else w=0,d=0,y=0;while(!1);if(ao(En|0,0,Zn|0)|0,Ol(fn|0,Ft|0,d<<3|0)|0,vn(Ft),(d|0)==0&(y|0)==0){kt=89;break}else f=f+(w<<3)|0,_=y,p=d}if((kt|0)==16)!0&(y&117440512|0)==0?(y=4,kt=27):kt=21;else if((kt|0)==31)tt(27795,27122,620,27132);else{if((kt|0)==41)return vn(fn),vn(En),kt=10,kt|0;if((kt|0)==48)return vn(fn),vn(En),kt=13,kt|0;(kt|0)==80?tt(27795,27122,711,27132):(kt|0)==81?tt(27795,27122,723,27132):(kt|0)==85&&(Ol(f|0,fn|0,p<<3|0)|0,kt=89)}return(kt|0)==21?(vn(fn),vn(En),kt=5,kt|0):(kt|0)==27?(vn(fn),vn(En),kt=y,kt|0):(kt|0)==89?(vn(fn),vn(En),kt=0,kt|0):0}function _1(d,f,p,_,y,w,M){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0;var R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0;if(Pe=K,K=K+16|0,ye=Pe,!((p|0)>0|(p|0)==0&f>>>0>0))return ye=0,K=Pe,ye|0;if((M|0)>=16)return ye=12,K=Pe,ye|0;_e=0,ve=0,se=0,R=0;e:for(;;){if(F=d+(_e<<3)|0,B=A[F>>2]|0,F=A[F+4>>2]|0,W=Ct(B|0,F|0,52)|0,X()|0,(W&15|0)>(M|0)){R=12,B=11;break}if(nl(ye,B,F,M),W=ye,F=A[W>>2]|0,W=A[W+4>>2]|0,(F|0)==0&(W|0)==0)B=se;else{B=se;do{if(!((R|0)<(w|0)|(R|0)==(w|0)&B>>>0>>0)){B=10;break e}se=_+(B<<3)|0,A[se>>2]=F,A[se+4>>2]=W,B=tn(B|0,R|0,1,0)|0,R=X()|0,rf(ye),se=ye,F=A[se>>2]|0,W=A[se+4>>2]|0}while(!((F|0)==0&(W|0)==0))}if(_e=tn(_e|0,ve|0,1,0)|0,ve=X()|0,(ve|0)<(p|0)|(ve|0)==(p|0)&_e>>>0>>0)se=B;else{R=0,B=11;break}}return(B|0)==10?(ye=14,K=Pe,ye|0):(B|0)==11?(K=Pe,R|0):0}function y1(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;_e=K,K=K+16|0,se=_e;e:do if((p|0)>0|(p|0)==0&f>>>0>0){for(F=0,M=0,w=0,W=0;;){if(B=d+(F<<3)|0,R=A[B>>2]|0,B=A[B+4>>2]|0,!((R|0)==0&(B|0)==0)&&(B=(nf(R,B,_,se)|0)==0,R=se,M=tn(A[R>>2]|0,A[R+4>>2]|0,M|0,w|0)|0,w=X()|0,!B)){w=12;break}if(F=tn(F|0,W|0,1,0)|0,W=X()|0,!((W|0)<(p|0)|(W|0)==(p|0)&F>>>0>>0))break e}return K=_e,w|0}else M=0,w=0;while(!1);return A[y>>2]=M,A[y+4>>2]=w,y=0,K=_e,y|0}function x1(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,52)|0,X()|0,f&1|0}function Hs(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,!y)return y=0,y|0;for(_=1;;){if(p=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,p=p&7,p|0){_=5;break}if(_>>>0>>0)_=_+1|0;else{p=0,_=5;break}}return(_|0)==5?p|0:0}function op(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(B=Ct(d|0,f|0,52)|0,X()|0,B=B&15,!B)return R=f,B=d,he(R|0),B|0;for(R=1,p=0;;){w=(15-R|0)*3|0,_=It(7,0,w|0)|0,y=X()|0,M=Ct(d|0,f|0,w|0)|0,X()|0,w=It(Nu(M&7)|0,0,w|0)|0,M=X()|0,d=w|d&~_,f=M|f&~y;e:do if(!p)if((w&_|0)==0&(M&y|0)==0)p=0;else if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(M=(15-p|0)*3|0,y=Ct(d|0,f|0,M|0)|0,X()|0,w=It(7,0,M|0)|0,f=f&~(X()|0),M=It(Nu(y&7)|0,0,M|0)|0,d=d&~w|M,f=f|(X()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return he(f|0),d|0}function Uu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)return p=f,_=d,he(p|0),_|0;for(p=1;w=(15-p|0)*3|0,M=Ct(d|0,f|0,w|0)|0,X()|0,y=It(7,0,w|0)|0,f=f&~(X()|0),w=It(Nu(M&7)|0,0,w|0)|0,d=w|d&~y,f=X()|0|f,p>>>0<_>>>0;)p=p+1|0;return he(f|0),d|0}function Tx(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(B=Ct(d|0,f|0,52)|0,X()|0,B=B&15,!B)return R=f,B=d,he(R|0),B|0;for(R=1,p=0;;){w=(15-R|0)*3|0,_=It(7,0,w|0)|0,y=X()|0,M=Ct(d|0,f|0,w|0)|0,X()|0,w=It(tl(M&7)|0,0,w|0)|0,M=X()|0,d=w|d&~_,f=M|f&~y;e:do if(!p)if((w&_|0)==0&(M&y|0)==0)p=0;else if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(y=(15-p|0)*3|0,w=It(7,0,y|0)|0,M=f&~(X()|0),f=Ct(d|0,f|0,y|0)|0,X()|0,f=It(tl(f&7)|0,0,y|0)|0,d=d&~w|f,f=M|(X()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return he(f|0),d|0}function lp(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)return p=f,_=d,he(p|0),_|0;for(p=1;M=(15-p|0)*3|0,w=It(7,0,M|0)|0,y=f&~(X()|0),f=Ct(d|0,f|0,M|0)|0,X()|0,f=It(tl(f&7)|0,0,M|0)|0,d=f|d&~w,f=X()|0|y,p>>>0<_>>>0;)p=p+1|0;return he(f|0),d|0}function ha(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(B=K,K=K+64|0,R=B+40|0,_=B+24|0,y=B+12|0,w=B,It(f|0,0,52)|0,p=X()|0|134225919,!f)return(A[d+4>>2]|0)>2||(A[d+8>>2]|0)>2||(A[d+12>>2]|0)>2?(M=0,R=0,he(M|0),K=B,R|0):(It(Ro(d)|0,0,45)|0,M=X()|0|p,R=-1,he(M|0),K=B,R|0);if(A[R>>2]=A[d>>2],A[R+4>>2]=A[d+4>>2],A[R+8>>2]=A[d+8>>2],A[R+12>>2]=A[d+12>>2],M=R+4|0,(f|0)>0)for(d=-1;A[_>>2]=A[M>>2],A[_+4>>2]=A[M+4>>2],A[_+8>>2]=A[M+8>>2],f&1?(fx(M),A[y>>2]=A[M>>2],A[y+4>>2]=A[M+4>>2],A[y+8>>2]=A[M+8>>2],Hc(y)):(o1(M),A[y>>2]=A[M>>2],A[y+4>>2]=A[M+4>>2],A[y+8>>2]=A[M+8>>2],Cu(y)),ef(_,y,w),Pr(w),W=(15-f|0)*3|0,F=It(7,0,W|0)|0,p=p&~(X()|0),W=It(Eu(w)|0,0,W|0)|0,d=W|d&~F,p=X()|0|p,(f|0)>1;)f=f+-1|0;else d=-1;e:do if((A[M>>2]|0)<=2&&(A[R+8>>2]|0)<=2&&(A[R+12>>2]|0)<=2){if(_=Ro(R)|0,f=It(_|0,0,45)|0,f=f|d,d=X()|0|p&-1040385,w=K0(R)|0,!(Ji(_)|0)){if((w|0)<=0)break;for(y=0;;){if(_=Ct(f|0,d|0,52)|0,X()|0,_=_&15,_)for(p=1;W=(15-p|0)*3|0,R=Ct(f|0,d|0,W|0)|0,X()|0,F=It(7,0,W|0)|0,d=d&~(X()|0),W=It(Nu(R&7)|0,0,W|0)|0,f=f&~F|W,d=d|(X()|0),p>>>0<_>>>0;)p=p+1|0;if(y=y+1|0,(y|0)==(w|0))break e}}y=Ct(f|0,d|0,52)|0,X()|0,y=y&15;t:do if(y){p=1;n:for(;;){switch(W=Ct(f|0,d|0,(15-p|0)*3|0)|0,X()|0,W&7){case 1:break n;case 0:break;default:break t}if(p>>>0>>0)p=p+1|0;else break t}if(wu(_,A[R>>2]|0)|0)for(p=1;R=(15-p|0)*3|0,F=It(7,0,R|0)|0,W=d&~(X()|0),d=Ct(f|0,d|0,R|0)|0,X()|0,d=It(tl(d&7)|0,0,R|0)|0,f=f&~F|d,d=W|(X()|0),p>>>0>>0;)p=p+1|0;else for(p=1;W=(15-p|0)*3|0,R=Ct(f|0,d|0,W|0)|0,X()|0,F=It(7,0,W|0)|0,d=d&~(X()|0),W=It(Nu(R&7)|0,0,W|0)|0,f=f&~F|W,d=d|(X()|0),p>>>0>>0;)p=p+1|0}while(!1);if((w|0)>0){p=0;do f=op(f,d)|0,d=X()|0,p=p+1|0;while((p|0)!=(w|0))}}else f=0,d=0;while(!1);return F=d,W=f,he(F|0),K=B,W|0}function bs(d){return d=d|0,(d|0)%2|0|0}function Ed(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;return y=K,K=K+16|0,_=y,f>>>0>15?(_=4,K=y,_|0):(A[d+4>>2]&2146435072|0)==2146435072||(A[d+8+4>>2]&2146435072|0)==2146435072?(_=3,K=y,_|0):(yx(d,f,_),f=ha(_,f)|0,_=X()|0,A[p>>2]=f,A[p+4>>2]=_,(f|0)==0&(_|0)==0&&tt(27795,27122,1050,27145),_=0,K=y,_|0)}function Cd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(y=p+4|0,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,M=Ct(d|0,f|0,45)|0,X()|0,_=(w|0)==0,Ji(M&127)|0){if(_)return M=1,M|0;_=1}else{if(_)return M=0,M|0;(A[y>>2]|0)==0&&(A[p+8>>2]|0)==0?_=(A[p+12>>2]|0)!=0&1:_=1}for(p=1;p&1?Hc(y):Cu(y),M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,l1(y,M&7),p>>>0>>0;)p=p+1|0;return _|0}function Bu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+16|0,B=W,F=Ct(d|0,f|0,45)|0,X()|0,F=F&127,F>>>0>121)return A[p>>2]=0,A[p+4>>2]=0,A[p+8>>2]=0,A[p+12>>2]=0,F=5,K=W,F|0;e:do if((Ji(F)|0)!=0&&(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,(w|0)!=0)){_=1;t:for(;;){switch(R=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,R&7){case 5:break t;case 0:break;default:{_=f;break e}}if(_>>>0>>0)_=_+1|0;else{_=f;break e}}for(y=1,_=f;f=(15-y|0)*3|0,M=It(7,0,f|0)|0,R=_&~(X()|0),_=Ct(d|0,_|0,f|0)|0,X()|0,_=It(tl(_&7)|0,0,f|0)|0,d=d&~M|_,_=R|(X()|0),y>>>0>>0;)y=y+1|0}else _=f;while(!1);if(R=7696+(F*28|0)|0,A[p>>2]=A[R>>2],A[p+4>>2]=A[R+4>>2],A[p+8>>2]=A[R+8>>2],A[p+12>>2]=A[R+12>>2],!(Cd(d,_,p)|0))return F=0,K=W,F|0;if(M=p+4|0,A[B>>2]=A[M>>2],A[B+4>>2]=A[M+4>>2],A[B+8>>2]=A[M+8>>2],w=Ct(d|0,_|0,52)|0,X()|0,R=w&15,w&1?(Cu(M),w=R+1|0):w=R,!(Ji(F)|0))_=0;else{e:do if(!R)_=0;else for(f=1;;){if(y=Ct(d|0,_|0,(15-f|0)*3|0)|0,X()|0,y=y&7,y|0){_=y;break e}if(f>>>0>>0)f=f+1|0;else{_=0;break}}while(!1);_=(_|0)==4&1}if(!(Du(p,w,_,0)|0))(w|0)!=(R|0)&&(A[M>>2]=A[B>>2],A[M+4>>2]=A[B+4>>2],A[M+8>>2]=A[B+8>>2]);else{if(Ji(F)|0)do;while((Du(p,w,0,0)|0)!=0);(w|0)!=(R|0)&&o1(M)}return F=0,K=W,F|0}function Dl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return w=K,K=K+16|0,_=w,y=Bu(d,f,_)|0,y|0?(K=w,y|0):(y=Ct(d|0,f|0,52)|0,X()|0,tf(_,y&15,p),y=0,K=w,y|0)}function Pl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0;if(M=K,K=K+16|0,w=M,_=Bu(d,f,w)|0,_|0)return w=_,K=M,w|0;_=Ct(d|0,f|0,45)|0,X()|0,_=(Ji(_&127)|0)==0,y=Ct(d|0,f|0,52)|0,X()|0,y=y&15;e:do if(!_){if(y|0)for(_=1;;){if(R=It(7,0,(15-_|0)*3|0)|0,!((R&d|0)==0&((X()|0)&f|0)==0))break e;if(_>>>0>>0)_=_+1|0;else break}return np(w,y,0,5,p),R=0,K=M,R|0}while(!1);return wd(w,y,0,6,p),R=0,K=M,R|0}function Mx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(y=Ct(d|0,f|0,45)|0,X()|0,!(Ji(y&127)|0))return y=2,A[p>>2]=y,0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,!y)return y=5,A[p>>2]=y,0;for(_=1;;){if(w=It(7,0,(15-_|0)*3|0)|0,!((w&d|0)==0&((X()|0)&f|0)==0)){_=2,d=6;break}if(_>>>0>>0)_=_+1|0;else{_=5,d=6;break}}return(d|0)==6&&(A[p>>2]=_),0}function Ou(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0;se=K,K=K+128|0,F=se+112|0,w=se+96|0,W=se,y=Ct(d|0,f|0,52)|0,X()|0,R=y&15,A[F>>2]=R,M=Ct(d|0,f|0,45)|0,X()|0,M=M&127;e:do if(Ji(M)|0){if(R|0)for(_=1;;){if(B=It(7,0,(15-_|0)*3|0)|0,!((B&d|0)==0&((X()|0)&f|0)==0)){y=0;break e}if(_>>>0>>0)_=_+1|0;else break}if(y&1)y=1;else return B=It(R+1|0,0,52)|0,W=X()|0|f&-15728641,F=It(7,0,(14-R|0)*3|0)|0,W=Ou((B|d)&~F,W&~(X()|0),p)|0,K=se,W|0}else y=0;while(!1);if(_=Bu(d,f,w)|0,!_){y?(ip(w,F,W),B=5):(rp(w,F,W),B=6);e:do if(Ji(M)|0)if(!R)d=5;else for(_=1;;){if(M=It(7,0,(15-_|0)*3|0)|0,!((M&d|0)==0&((X()|0)&f|0)==0)){d=2;break e}if(_>>>0>>0)_=_+1|0;else{d=5;break}}else d=2;while(!1);ao(p|0,-1,d<<2|0)|0;e:do if(y)for(w=0;;){if(M=W+(w<<4)|0,p1(M,A[F>>2]|0)|0,M=A[M>>2]|0,R=A[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=d>>>0){_=1;break e}_=p+(y<<2)|0,R=A[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(A[_>>2]=M,w=w+1|0,w>>>0>=B>>>0){_=0;break}}else for(w=0;;){if(M=W+(w<<4)|0,Du(M,A[F>>2]|0,0,1)|0,M=A[M>>2]|0,R=A[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=d>>>0){_=1;break e}_=p+(y<<2)|0,R=A[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(A[_>>2]=M,w=w+1|0,w>>>0>=B>>>0){_=0;break}}while(!1)}return W=_,K=se,W|0}function up(){return 12}function Iu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(d>>>0>15)return R=4,R|0;if(It(d|0,0,52)|0,R=X()|0|134225919,!d){p=0,_=0;do Ji(_)|0&&(It(_|0,0,45)|0,M=R|(X()|0),d=f+(p<<3)|0,A[d>>2]=-1,A[d+4>>2]=M,p=p+1|0),_=_+1|0;while((_|0)!=122);return p=0,p|0}p=0,M=0;do{if(Ji(M)|0){for(It(M|0,0,45)|0,_=1,y=-1,w=R|(X()|0);B=It(7,0,(15-_|0)*3|0)|0,y=y&~B,w=w&~(X()|0),(_|0)!=(d|0);)_=_+1|0;B=f+(p<<3)|0,A[B>>2]=y,A[B+4>>2]=w,p=p+1|0}M=M+1|0}while((M|0)!=122);return p=0,p|0}function cp(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0;if(Xe=K,K=K+16|0,ze=Xe,nt=Ct(d|0,f|0,52)|0,X()|0,nt=nt&15,p>>>0>15)return nt=4,K=Xe,nt|0;if((nt|0)<(p|0))return nt=12,K=Xe,nt|0;if((nt|0)!=(p|0))if(w=It(p|0,0,52)|0,w=w|d,R=X()|0|f&-15728641,(nt|0)>(p|0)){B=p;do Pe=It(7,0,(14-B|0)*3|0)|0,B=B+1|0,w=Pe|w,R=X()|0|R;while((B|0)<(nt|0));Pe=w}else Pe=w;else Pe=d,R=f;ye=Ct(Pe|0,R|0,45)|0,X()|0;e:do if(Ji(ye&127)|0){if(B=Ct(Pe|0,R|0,52)|0,X()|0,B=B&15,B|0)for(w=1;;){if(ye=It(7,0,(15-w|0)*3|0)|0,!((ye&Pe|0)==0&((X()|0)&R|0)==0)){F=33;break e}if(w>>>0>>0)w=w+1|0;else break}if(ye=_,A[ye>>2]=0,A[ye+4>>2]=0,(nt|0)>(p|0)){for(ye=f&-15728641,ve=nt;;){if(_e=ve,ve=ve+-1|0,ve>>>0>15|(nt|0)<(ve|0)){F=19;break}if((nt|0)!=(ve|0))if(w=It(ve|0,0,52)|0,w=w|d,B=X()|0|ye,(nt|0)<(_e|0))se=w;else{F=ve;do se=It(7,0,(14-F|0)*3|0)|0,F=F+1|0,w=se|w,B=X()|0|B;while((F|0)<(nt|0));se=w}else se=d,B=f;if(W=Ct(se|0,B|0,45)|0,X()|0,!(Ji(W&127)|0))w=0;else{W=Ct(se|0,B|0,52)|0,X()|0,W=W&15;t:do if(!W)w=0;else for(F=1;;){if(w=Ct(se|0,B|0,(15-F|0)*3|0)|0,X()|0,w=w&7,w|0)break t;if(F>>>0>>0)F=F+1|0;else{w=0;break}}while(!1);w=(w|0)==0&1}if(B=Ct(d|0,f|0,(15-_e|0)*3|0)|0,X()|0,B=B&7,(B|0)==7){y=5,F=42;break}if(w=(w|0)!=0,(B|0)==1&w){y=5,F=42;break}if(se=B+(((B|0)!=0&w)<<31>>31)|0,se|0&&(F=nt-_e|0,F=Lo(7,0,F,((F|0)<0)<<31>>31)|0,W=X()|0,w?(w=ur(F|0,W|0,5,0)|0,w=tn(w|0,X()|0,-5,-1)|0,w=Io(w|0,X()|0,6,0)|0,w=tn(w|0,X()|0,1,0)|0,B=X()|0):(w=F,B=W),_e=se+-1|0,_e=ur(F|0,W|0,_e|0,((_e|0)<0)<<31>>31|0)|0,_e=tn(w|0,B|0,_e|0,X()|0)|0,se=X()|0,W=_,W=tn(_e|0,se|0,A[W>>2]|0,A[W+4>>2]|0)|0,se=X()|0,_e=_,A[_e>>2]=W,A[_e+4>>2]=se),(ve|0)<=(p|0)){F=37;break}}if((F|0)==19)tt(27795,27122,1367,27158);else if((F|0)==37){M=_,y=A[M+4>>2]|0,M=A[M>>2]|0;break}else if((F|0)==42)return K=Xe,y|0}else y=0,M=0}else F=33;while(!1);e:do if((F|0)==33)if(ye=_,A[ye>>2]=0,A[ye+4>>2]=0,(nt|0)>(p|0)){for(w=nt;;){if(y=Ct(d|0,f|0,(15-w|0)*3|0)|0,X()|0,y=y&7,(y|0)==7){y=5;break}if(M=nt-w|0,M=Lo(7,0,M,((M|0)<0)<<31>>31)|0,y=ur(M|0,X()|0,y|0,0)|0,M=X()|0,ye=_,M=tn(A[ye>>2]|0,A[ye+4>>2]|0,y|0,M|0)|0,y=X()|0,ye=_,A[ye>>2]=M,A[ye+4>>2]=y,w=w+-1|0,(w|0)<=(p|0))break e}return K=Xe,y|0}else y=0,M=0;while(!1);return nf(Pe,R,nt,ze)|0&&tt(27795,27122,1327,27173),nt=ze,ze=A[nt+4>>2]|0,((y|0)>-1|(y|0)==-1&M>>>0>4294967295)&((ze|0)>(y|0)|((ze|0)==(y|0)?(A[nt>>2]|0)>>>0>M>>>0:0))?(nt=0,K=Xe,nt|0):(tt(27795,27122,1407,27158),0)}function b1(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0;if(se=K,K=K+16|0,M=se,y>>>0>15)return w=4,K=se,w|0;if(R=Ct(p|0,_|0,52)|0,X()|0,R=R&15,(R|0)>(y|0))return w=12,K=se,w|0;if(nf(p,_,y,M)|0&&tt(27795,27122,1327,27173),W=M,F=A[W+4>>2]|0,!(((f|0)>-1|(f|0)==-1&d>>>0>4294967295)&((F|0)>(f|0)|((F|0)==(f|0)?(A[W>>2]|0)>>>0>d>>>0:0))))return w=2,K=se,w|0;W=y-R|0,y=It(y|0,0,52)|0,B=X()|0|_&-15728641,F=w,A[F>>2]=y|p,A[F+4>>2]=B,F=Ct(p|0,_|0,45)|0,X()|0;e:do if(Ji(F&127)|0){if(R|0)for(M=1;;){if(F=It(7,0,(15-M|0)*3|0)|0,!((F&p|0)==0&((X()|0)&_|0)==0))break e;if(M>>>0>>0)M=M+1|0;else break}if((W|0)<1)return w=0,K=se,w|0;for(F=R^15,_=-1,B=1,M=1;;){R=W-B|0,R=Lo(7,0,R,((R|0)<0)<<31>>31)|0,p=X()|0;do if(M)if(M=ur(R|0,p|0,5,0)|0,M=tn(M|0,X()|0,-5,-1)|0,M=Io(M|0,X()|0,6,0)|0,y=X()|0,(f|0)>(y|0)|(f|0)==(y|0)&d>>>0>M>>>0){f=tn(d|0,f|0,-1,-1)|0,f=Lr(f|0,X()|0,M|0,y|0)|0,M=X()|0,_e=w,ye=A[_e>>2]|0,_e=A[_e+4>>2]|0,Pe=(F+_|0)*3|0,ve=It(7,0,Pe|0)|0,_e=_e&~(X()|0),_=Io(f|0,M|0,R|0,p|0)|0,d=X()|0,y=tn(_|0,d|0,2,0)|0,Pe=It(y|0,X()|0,Pe|0)|0,_e=X()|0|_e,y=w,A[y>>2]=Pe|ye&~ve,A[y+4>>2]=_e,d=ur(_|0,d|0,R|0,p|0)|0,d=Lr(f|0,M|0,d|0,X()|0)|0,M=0,f=X()|0;break}else{Pe=w,ve=A[Pe>>2]|0,Pe=A[Pe+4>>2]|0,ye=It(7,0,(F+_|0)*3|0)|0,Pe=Pe&~(X()|0),M=w,A[M>>2]=ve&~ye,A[M+4>>2]=Pe,M=1;break}else ve=w,y=A[ve>>2]|0,ve=A[ve+4>>2]|0,_=(F+_|0)*3|0,_e=It(7,0,_|0)|0,ve=ve&~(X()|0),Pe=Io(d|0,f|0,R|0,p|0)|0,M=X()|0,_=It(Pe|0,M|0,_|0)|0,ve=X()|0|ve,ye=w,A[ye>>2]=_|y&~_e,A[ye+4>>2]=ve,M=ur(Pe|0,M|0,R|0,p|0)|0,d=Lr(d|0,f|0,M|0,X()|0)|0,M=0,f=X()|0;while(!1);if((W|0)>(B|0))_=~B,B=B+1|0;else{f=0;break}}return K=se,f|0}while(!1);if((W|0)<1)return Pe=0,K=se,Pe|0;for(y=R^15,M=1;;)if(ye=W-M|0,ye=Lo(7,0,ye,((ye|0)<0)<<31>>31)|0,Pe=X()|0,B=w,p=A[B>>2]|0,B=A[B+4>>2]|0,R=(y-M|0)*3|0,_=It(7,0,R|0)|0,B=B&~(X()|0),_e=Io(d|0,f|0,ye|0,Pe|0)|0,ve=X()|0,R=It(_e|0,ve|0,R|0)|0,B=X()|0|B,F=w,A[F>>2]=R|p&~_,A[F+4>>2]=B,Pe=ur(_e|0,ve|0,ye|0,Pe|0)|0,d=Lr(d|0,f|0,Pe|0,X()|0)|0,f=X()|0,(W|0)<=(M|0)){f=0;break}else M=M+1|0;return K=se,f|0}function nl(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;y=Ct(f|0,p|0,52)|0,X()|0,y=y&15,(f|0)==0&(p|0)==0|((_|0)>15|(y|0)>(_|0))?(w=-1,f=-1,p=0,y=0):(f=sp(f,p,y+1|0,_)|0,M=(X()|0)&-15728641,p=It(_|0,0,52)|0,p=f|p,M=M|(X()|0),f=(wi(p,M)|0)==0,w=y,f=f?-1:_,y=M),M=d,A[M>>2]=p,A[M+4>>2]=y,A[d+8>>2]=w,A[d+12>>2]=f}function Fu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,w=_+8|0,A[w>>2]=y,(d|0)==0&(f|0)==0|((p|0)>15|(y|0)>(p|0))){p=_,A[p>>2]=0,A[p+4>>2]=0,A[w>>2]=-1,A[_+12>>2]=-1;return}if(d=sp(d,f,y+1|0,p)|0,w=(X()|0)&-15728641,y=It(p|0,0,52)|0,y=d|y,w=w|(X()|0),d=_,A[d>>2]=y,A[d+4>>2]=w,d=_+12|0,wi(y,w)|0){A[d>>2]=p;return}else{A[d>>2]=-1;return}}function rf(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0;if(p=d,f=A[p>>2]|0,p=A[p+4>>2]|0,!((f|0)==0&(p|0)==0)&&(_=Ct(f|0,p|0,52)|0,X()|0,_=_&15,R=It(1,0,(_^15)*3|0)|0,f=tn(R|0,X()|0,f|0,p|0)|0,p=X()|0,R=d,A[R>>2]=f,A[R+4>>2]=p,R=d+8|0,M=A[R>>2]|0,!((_|0)<(M|0)))){for(B=d+12|0,w=_;;){if((w|0)==(M|0)){_=5;break}if(F=(w|0)==(A[B>>2]|0),y=(15-w|0)*3|0,_=Ct(f|0,p|0,y|0)|0,X()|0,_=_&7,F&((_|0)==1&!0)){_=7;break}if(!((_|0)==7&!0)){_=10;break}if(F=It(1,0,y|0)|0,f=tn(f|0,p|0,F|0,X()|0)|0,p=X()|0,F=d,A[F>>2]=f,A[F+4>>2]=p,(w|0)>(M|0))w=w+-1|0;else{_=10;break}}if((_|0)==5){F=d,A[F>>2]=0,A[F+4>>2]=0,A[R>>2]=-1,A[B>>2]=-1;return}else if((_|0)==7){M=It(1,0,y|0)|0,M=tn(f|0,p|0,M|0,X()|0)|0,R=X()|0,F=d,A[F>>2]=M,A[F+4>>2]=R,A[B>>2]=w+-1;return}else if((_|0)==10)return}}function $c(d){d=+d;var f=0;return f=d<0?d+6.283185307179586:d,+(d>=6.283185307179586?f+-6.283185307179586:f)}function wa(d,f){return d=d|0,f=f|0,+dn(+(+ee[d>>3]-+ee[f>>3]))<17453292519943298e-27?(f=+dn(+(+ee[d+8>>3]-+ee[f+8>>3]))<17453292519943298e-27,f|0):(f=0,f|0)}function Ws(d,f){switch(d=+d,f=f|0,f|0){case 1:{d=d<0?d+6.283185307179586:d;break}case 2:{d=d>0?d+-6.283185307179586:d;break}}return+d}function S1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+ee[f>>3],_=+ee[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+ee[f+8>>3]-+ee[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2)}function Xc(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+ee[f>>3],_=+ee[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+ee[f+8>>3]-+ee[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2*6371.007180918475)}function Ex(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+ee[f>>3],_=+ee[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+ee[f+8>>3]-+ee[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2*6371.007180918475*1e3)}function Cx(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return w=+ee[f>>3],_=+an(+w),y=+ee[f+8>>3]-+ee[d+8>>3],M=_*+mn(+y),p=+ee[d>>3],+ +Ge(+M,+(+mn(+w)*+an(+p)-+an(+y)*(_*+mn(+p))))}function Nx(d,f,p,_){d=d|0,f=+f,p=+p,_=_|0;var y=0,w=0,M=0,R=0;if(p<1e-16){A[_>>2]=A[d>>2],A[_+4>>2]=A[d+4>>2],A[_+8>>2]=A[d+8>>2],A[_+12>>2]=A[d+12>>2];return}w=f<0?f+6.283185307179586:f,w=f>=6.283185307179586?w+-6.283185307179586:w;do if(w<1e-16)f=+ee[d>>3]+p,ee[_>>3]=f,y=_;else{if(y=+dn(+(w+-3.141592653589793))<1e-16,f=+ee[d>>3],y){f=f-p,ee[_>>3]=f,y=_;break}if(M=+an(+p),p=+mn(+p),f=M*+mn(+f)+ +an(+w)*(p*+an(+f)),f=f>1?1:f,f=+No(+(f<-1?-1:f)),ee[_>>3]=f,+dn(+(f+-1.5707963267948966))<1e-16){ee[_>>3]=1.5707963267948966,ee[_+8>>3]=0;return}if(+dn(+(f+1.5707963267948966))<1e-16){ee[_>>3]=-1.5707963267948966,ee[_+8>>3]=0;return}if(R=1/+an(+f),w=p*+mn(+w)*R,p=+ee[d>>3],f=R*((M-+mn(+f)*+mn(+p))/+an(+p)),M=w>1?1:w,f=f>1?1:f,f=+ee[d+8>>3]+ +Ge(+(M<-1?-1:M),+(f<-1?-1:f)),f>3.141592653589793)do f=f+-6.283185307179586;while(f>3.141592653589793);if(f<-3.141592653589793)do f=f+6.283185307179586;while(f<-3.141592653589793);ee[_+8>>3]=f;return}while(!1);if(+dn(+(f+-1.5707963267948966))<1e-16){ee[y>>3]=1.5707963267948966,ee[_+8>>3]=0;return}if(+dn(+(f+1.5707963267948966))<1e-16){ee[y>>3]=-1.5707963267948966,ee[_+8>>3]=0;return}if(f=+ee[d+8>>3],f>3.141592653589793)do f=f+-6.283185307179586;while(f>3.141592653589793);if(f<-3.141592653589793)do f=f+6.283185307179586;while(f<-3.141592653589793);ee[_+8>>3]=f}function hp(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(ee[f>>3]=+ee[20656+(d<<3)>>3],f=0,f|0)}function w1(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(ee[f>>3]=+ee[20784+(d<<3)>>3],f=0,f|0)}function fp(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(ee[f>>3]=+ee[20912+(d<<3)>>3],f=0,f|0)}function ro(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(ee[f>>3]=+ee[21040+(d<<3)>>3],f=0,f|0)}function ku(d,f){d=d|0,f=f|0;var p=0;return d>>>0>15?(f=4,f|0):(p=Lo(7,0,d,((d|0)<0)<<31>>31)|0,p=ur(p|0,X()|0,120,0)|0,d=X()|0,A[f>>2]=p|2,A[f+4>>2]=d,f=0,f|0)}function fa(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;return _e=+ee[f>>3],W=+ee[d>>3],B=+mn(+((_e-W)*.5)),w=+ee[f+8>>3],F=+ee[d+8>>3],M=+mn(+((w-F)*.5)),R=+an(+W),se=+an(+_e),M=B*B+M*(se*R*M),M=+Ge(+ +Fn(+M),+ +Fn(+(1-M)))*2,B=+ee[p>>3],_e=+mn(+((B-_e)*.5)),_=+ee[p+8>>3],w=+mn(+((_-w)*.5)),y=+an(+B),w=_e*_e+w*(se*y*w),w=+Ge(+ +Fn(+w),+ +Fn(+(1-w)))*2,B=+mn(+((W-B)*.5)),_=+mn(+((F-_)*.5)),_=B*B+_*(R*y*_),_=+Ge(+ +Fn(+_),+ +Fn(+(1-_)))*2,y=(M+w+_)*.5,+(+ce(+ +Fn(+(+Er(+(y*.5))*+Er(+((y-M)*.5))*+Er(+((y-w)*.5))*+Er(+((y-_)*.5)))))*4)}function Ll(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0;if(R=K,K=K+192|0,w=R+168|0,M=R,y=Dl(d,f,w)|0,y|0)return p=y,K=R,p|0;if(Pl(d,f,M)|0&&tt(27795,27190,415,27199),f=A[M>>2]|0,(f|0)>0){if(_=+fa(M+8|0,M+8+(((f|0)!=1&1)<<4)|0,w)+0,(f|0)!=1){d=1;do y=d,d=d+1|0,_=_+ +fa(M+8+(y<<4)|0,M+8+(((d|0)%(f|0)|0)<<4)|0,w);while((d|0)<(f|0))}}else _=0;return ee[p>>3]=_,p=0,K=R,p|0}function dp(d,f,p){return d=d|0,f=f|0,p=p|0,d=Ll(d,f,p)|0,d|0||(ee[p>>3]=+ee[p>>3]*6371.007180918475*6371.007180918475),d|0}function Nd(d,f,p){return d=d|0,f=f|0,p=p|0,d=Ll(d,f,p)|0,d|0||(ee[p>>3]=+ee[p>>3]*6371.007180918475*6371.007180918475*1e3*1e3),d|0}function Rd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,K=R,M|0;if(ee[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,K=R,M|0;f=d+-1|0,d=0,_=+ee[M+8>>3],y=+ee[M+16>>3],w=0;do d=d+1|0,F=_,_=+ee[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+ee[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+_)*+an(+F)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)<(f|0));return ee[p>>3]=w,M=0,K=R,M|0}function Ap(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,w=+ee[p>>3],w=w*6371.007180918475,ee[p>>3]=w,K=R,M|0;if(ee[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,w=0,w=w*6371.007180918475,ee[p>>3]=w,K=R,M|0;f=d+-1|0,d=0,_=+ee[M+8>>3],y=+ee[M+16>>3],w=0;do d=d+1|0,F=_,_=+ee[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+ee[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+F)*+an(+_)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)!=(f|0));return ee[p>>3]=w,M=0,W=w,W=W*6371.007180918475,ee[p>>3]=W,K=R,M|0}function zu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,w=+ee[p>>3],w=w*6371.007180918475,w=w*1e3,ee[p>>3]=w,K=R,M|0;if(ee[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,w=0,w=w*6371.007180918475,w=w*1e3,ee[p>>3]=w,K=R,M|0;f=d+-1|0,d=0,_=+ee[M+8>>3],y=+ee[M+16>>3],w=0;do d=d+1|0,F=_,_=+ee[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+ee[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+F)*+an(+_)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)!=(f|0));return ee[p>>3]=w,M=0,W=w,W=W*6371.007180918475,W=W*1e3,ee[p>>3]=W,K=R,M|0}function T1(d){d=d|0;var f=0,p=0,_=0;return f=Ys(1,12)|0,f||tt(27280,27235,49,27293),p=d+4|0,_=A[p>>2]|0,_|0?(_=_+8|0,A[_>>2]=f,A[p>>2]=f,f|0):(A[d>>2]|0&&tt(27310,27235,61,27333),_=d,A[_>>2]=f,A[p>>2]=f,f|0)}function Dd(d,f){d=d|0,f=f|0;var p=0,_=0;return _=Oo(24)|0,_||tt(27347,27235,78,27361),A[_>>2]=A[f>>2],A[_+4>>2]=A[f+4>>2],A[_+8>>2]=A[f+8>>2],A[_+12>>2]=A[f+12>>2],A[_+16>>2]=0,f=d+4|0,p=A[f>>2]|0,p|0?(A[p+16>>2]=_,A[f>>2]=_,_|0):(A[d>>2]|0&&tt(27376,27235,82,27361),A[d>>2]=_,A[f>>2]=_,_|0)}function Gu(d){d=d|0;var f=0,p=0,_=0,y=0;if(d)for(_=1;;){if(f=A[d>>2]|0,f|0)do{if(p=A[f>>2]|0,p|0)do y=p,p=A[p+16>>2]|0,vn(y);while((p|0)!=0);y=f,f=A[f+8>>2]|0,vn(y)}while((f|0)!=0);if(f=d,d=A[d+8>>2]|0,_||vn(f),d)_=0;else break}}function Rx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,kt=0,xn=0,si=0,Cn=0;if(y=d+8|0,A[y>>2]|0)return Cn=1,Cn|0;if(_=A[d>>2]|0,!_)return Cn=0,Cn|0;f=_,p=0;do p=p+1|0,f=A[f+8>>2]|0;while((f|0)!=0);if(p>>>0<2)return Cn=0,Cn|0;xn=Oo(p<<2)|0,xn||tt(27396,27235,317,27415),kt=Oo(p<<5)|0,kt||tt(27437,27235,321,27415),A[d>>2]=0,un=d+4|0,A[un>>2]=0,A[y>>2]=0,p=0,fn=0,Ft=0,se=0;e:for(;;){if(W=A[_>>2]|0,W){w=0,M=W;do{if(B=+ee[M+8>>3],f=M,M=A[M+16>>2]|0,F=(M|0)==0,y=F?W:M,R=+ee[y+8>>3],+dn(+(B-R))>3.141592653589793){Cn=14;break}w=w+(R-B)*(+ee[f>>3]+ +ee[y>>3])}while(!F);if((Cn|0)==14){Cn=0,w=0,f=W;do Le=+ee[f+8>>3],En=f+16|0,Zn=A[En>>2]|0,Zn=(Zn|0)==0?W:Zn,je=+ee[Zn+8>>3],w=w+(+ee[f>>3]+ +ee[Zn>>3])*((je<0?je+6.283185307179586:je)-(Le<0?Le+6.283185307179586:Le)),f=A[((f|0)==0?_:En)>>2]|0;while((f|0)!=0)}w>0?(A[xn+(fn<<2)>>2]=_,fn=fn+1|0,y=Ft,f=se):Cn=19}else Cn=19;if((Cn|0)==19){Cn=0;do if(p){if(f=p+8|0,A[f>>2]|0){Cn=21;break e}if(p=Ys(1,12)|0,!p){Cn=23;break e}A[f>>2]=p,y=p+4|0,M=p,f=se}else if(se){y=un,M=se+8|0,f=_,p=d;break}else if(A[d>>2]|0){Cn=27;break e}else{y=un,M=d,f=_,p=d;break}while(!1);if(A[M>>2]=_,A[y>>2]=_,M=kt+(Ft<<5)|0,F=A[_>>2]|0,F){for(W=kt+(Ft<<5)+8|0,ee[W>>3]=17976931348623157e292,se=kt+(Ft<<5)+24|0,ee[se>>3]=17976931348623157e292,ee[M>>3]=-17976931348623157e292,_e=kt+(Ft<<5)+16|0,ee[_e>>3]=-17976931348623157e292,nt=17976931348623157e292,Xe=-17976931348623157e292,y=0,ve=F,B=17976931348623157e292,Pe=17976931348623157e292,ze=-17976931348623157e292,R=-17976931348623157e292;w=+ee[ve>>3],Le=+ee[ve+8>>3],ve=A[ve+16>>2]|0,ye=(ve|0)==0,je=+ee[(ye?F:ve)+8>>3],w>3]=w,B=w),Le>3]=Le,Pe=Le),w>ze?ee[M>>3]=w:w=ze,Le>R&&(ee[_e>>3]=Le,R=Le),nt=Le>0&LeXe?Le:Xe,y=y|+dn(+(Le-je))>3.141592653589793,!ye;)ze=w;y&&(ee[_e>>3]=Xe,ee[se>>3]=nt)}else A[M>>2]=0,A[M+4>>2]=0,A[M+8>>2]=0,A[M+12>>2]=0,A[M+16>>2]=0,A[M+20>>2]=0,A[M+24>>2]=0,A[M+28>>2]=0;y=Ft+1|0}if(En=_+8|0,_=A[En>>2]|0,A[En>>2]=0,_)Ft=y,se=f;else{Cn=45;break}}if((Cn|0)==21)tt(27213,27235,35,27247);else if((Cn|0)==23)tt(27267,27235,37,27247);else if((Cn|0)==27)tt(27310,27235,61,27333);else if((Cn|0)==45){e:do if((fn|0)>0){for(En=(y|0)==0,Dn=y<<2,Zn=(d|0)==0,kn=0,f=0;;){if(on=A[xn+(kn<<2)>>2]|0,En)Cn=73;else{if(Ft=Oo(Dn)|0,!Ft){Cn=50;break}if(un=Oo(Dn)|0,!un){Cn=52;break}t:do if(Zn)p=0;else{for(y=0,p=0,M=d;_=kt+(y<<5)|0,$s(A[M>>2]|0,_,A[on>>2]|0)|0?(A[Ft+(p<<2)>>2]=M,A[un+(p<<2)>>2]=_,ye=p+1|0):ye=p,M=A[M+8>>2]|0,M;)y=y+1|0,p=ye;if((ye|0)>0)if(_=A[Ft>>2]|0,(ye|0)==1)p=_;else for(_e=0,ve=-1,p=_,se=_;;){for(F=A[se>>2]|0,_=0,M=0;y=A[A[Ft+(M<<2)>>2]>>2]|0,(y|0)==(F|0)?W=_:W=_+(($s(y,A[un+(M<<2)>>2]|0,A[F>>2]|0)|0)&1)|0,M=M+1|0,(M|0)!=(ye|0);)_=W;if(y=(W|0)>(ve|0),p=y?se:p,_=_e+1|0,(_|0)==(ye|0))break t;_e=_,ve=y?W:ve,se=A[Ft+(_<<2)>>2]|0}else p=0}while(!1);if(vn(Ft),vn(un),p){if(y=p+4|0,_=A[y>>2]|0,_)p=_+8|0;else if(A[p>>2]|0){Cn=70;break}A[p>>2]=on,A[y>>2]=on}else Cn=73}if((Cn|0)==73){if(Cn=0,f=A[on>>2]|0,f|0)do un=f,f=A[f+16>>2]|0,vn(un);while((f|0)!=0);vn(on),f=1}if(kn=kn+1|0,(kn|0)>=(fn|0)){si=f;break e}}(Cn|0)==50?tt(27452,27235,249,27471):(Cn|0)==52?tt(27490,27235,252,27471):(Cn|0)==70&&tt(27310,27235,61,27333)}else si=0;while(!1);return vn(xn),vn(kt),Cn=si,Cn|0}return 0}function $s(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(!(Do(f,p)|0)||(f=_d(f)|0,_=+ee[p>>3],y=+ee[p+8>>3],y=f&y<0?y+6.283185307179586:y,d=A[d>>2]|0,!d))return d=0,d|0;if(f){f=0,F=y,p=d;e:for(;;){for(;M=+ee[p>>3],y=+ee[p+8>>3],p=p+16|0,W=A[p>>2]|0,W=(W|0)==0?d:W,w=+ee[W>>3],R=+ee[W+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=A[p>>2]|0,!p){p=22;break e}if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,F=R==F|M==F?F+-2220446049250313e-31:F,B=R+(M-R)*((_-w)/(B-w)),(B<0?B+6.283185307179586:B)>F&&(f=f^1),p=A[p>>2]|0,!p){p=22;break}}if((p|0)==22)return f|0}else{f=0,F=y,p=d;e:for(;;){for(;M=+ee[p>>3],y=+ee[p+8>>3],p=p+16|0,W=A[p>>2]|0,W=(W|0)==0?d:W,w=+ee[W>>3],R=+ee[W+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=A[p>>2]|0,!p){p=22;break e}if(F=M==F|y==F?F+-2220446049250313e-31:F,M+(y-M)*((_-w)/(B-w))>F&&(f=f^1),p=A[p>>2]|0,!p){p=22;break}}if((p|0)==22)return f|0}return 0}function so(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0;if(Xe=K,K=K+32|0,nt=Xe+16|0,ze=Xe,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,ve=Ct(p|0,_|0,52)|0,X()|0,(w|0)!=(ve&15|0))return nt=12,K=Xe,nt|0;if(F=Ct(d|0,f|0,45)|0,X()|0,F=F&127,W=Ct(p|0,_|0,45)|0,X()|0,W=W&127,F>>>0>121|W>>>0>121)return nt=5,K=Xe,nt|0;if(ve=(F|0)!=(W|0),ve){if(R=Xh(F,W)|0,(R|0)==7)return nt=1,K=Xe,nt|0;B=Xh(W,F)|0,(B|0)==7?tt(27514,27538,161,27548):(ye=R,M=B)}else ye=0,M=0;se=Ji(F)|0,_e=Ji(W)|0,A[nt>>2]=0,A[nt+4>>2]=0,A[nt+8>>2]=0,A[nt+12>>2]=0;do if(ye){if(W=A[4272+(F*28|0)+(ye<<2)>>2]|0,R=(W|0)>0,_e)if(R){F=0,B=p,R=_;do B=Tx(B,R)|0,R=X()|0,M=tl(M)|0,(M|0)==1&&(M=tl(1)|0),F=F+1|0;while((F|0)!=(W|0));W=M,F=B,B=R}else W=M,F=p,B=_;else if(R){F=0,B=p,R=_;do B=lp(B,R)|0,R=X()|0,M=tl(M)|0,F=F+1|0;while((F|0)!=(W|0));W=M,F=B,B=R}else W=M,F=p,B=_;if(Cd(F,B,nt)|0,ve||tt(27563,27538,191,27548),R=(se|0)!=0,M=(_e|0)!=0,R&M&&tt(27590,27538,192,27548),R){if(M=Hs(d,f)|0,(M|0)==7){w=5;break}if(xt[22e3+(M*7|0)+ye>>0]|0){w=1;break}B=A[21168+(M*28|0)+(ye<<2)>>2]|0,F=B}else if(M){if(M=Hs(F,B)|0,(M|0)==7){w=5;break}if(xt[22e3+(M*7|0)+W>>0]|0){w=1;break}F=0,B=A[21168+(W*28|0)+(M<<2)>>2]|0}else F=0,B=0;if((F|B|0)<0)w=5;else{if((B|0)>0){R=nt+4|0,M=0;do bd(R),M=M+1|0;while((M|0)!=(B|0))}if(A[ze>>2]=0,A[ze+4>>2]=0,A[ze+8>>2]=0,l1(ze,ye),w|0)for(;bs(w)|0?Hc(ze):Cu(ze),(w|0)>1;)w=w+-1|0;if((F|0)>0){w=0;do bd(ze),w=w+1|0;while((w|0)!=(F|0))}Pe=nt+4|0,us(Pe,ze,Pe),Pr(Pe),Pe=51}}else if(Cd(p,_,nt)|0,(se|0)!=0&(_e|0)!=0)if((W|0)!=(F|0)&&tt(27621,27538,261,27548),M=Hs(d,f)|0,w=Hs(p,_)|0,(M|0)==7|(w|0)==7)w=5;else if(xt[22e3+(M*7|0)+w>>0]|0)w=1;else if(M=A[21168+(M*28|0)+(w<<2)>>2]|0,(M|0)>0){R=nt+4|0,w=0;do bd(R),w=w+1|0;while((w|0)!=(M|0));Pe=51}else Pe=51;else Pe=51;while(!1);return(Pe|0)==51&&(w=nt+4|0,A[y>>2]=A[w>>2],A[y+4>>2]=A[w+4>>2],A[y+8>>2]=A[w+8>>2],w=0),nt=w,K=Xe,nt|0}function Po(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0;if(Pe=K,K=K+48|0,F=Pe+36|0,M=Pe+24|0,R=Pe+12|0,B=Pe,y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,_e=Ct(d|0,f|0,45)|0,X()|0,_e=_e&127,_e>>>0>121)return _=5,K=Pe,_|0;if(W=Ji(_e)|0,It(y|0,0,52)|0,ze=X()|0|134225919,w=_,A[w>>2]=-1,A[w+4>>2]=ze,!y)return y=Eu(p)|0,(y|0)==7||(y=vd(_e,y)|0,(y|0)==127)?(ze=1,K=Pe,ze|0):(ve=It(y|0,0,45)|0,ye=X()|0,_e=_,ye=A[_e+4>>2]&-1040385|ye,ze=_,A[ze>>2]=A[_e>>2]|ve,A[ze+4>>2]=ye,ze=0,K=Pe,ze|0);for(A[F>>2]=A[p>>2],A[F+4>>2]=A[p+4>>2],A[F+8>>2]=A[p+8>>2],p=y;;){if(w=p,p=p+-1|0,A[M>>2]=A[F>>2],A[M+4>>2]=A[F+4>>2],A[M+8>>2]=A[F+8>>2],bs(w)|0){if(y=a1(F)|0,y|0){p=13;break}A[R>>2]=A[F>>2],A[R+4>>2]=A[F+4>>2],A[R+8>>2]=A[F+8>>2],Hc(R)}else{if(y=hx(F)|0,y|0){p=13;break}A[R>>2]=A[F>>2],A[R+4>>2]=A[F+4>>2],A[R+8>>2]=A[F+8>>2],Cu(R)}if(ef(M,R,B),Pr(B),y=_,Xe=A[y>>2]|0,y=A[y+4>>2]|0,je=(15-w|0)*3|0,nt=It(7,0,je|0)|0,y=y&~(X()|0),je=It(Eu(B)|0,0,je|0)|0,y=X()|0|y,ze=_,A[ze>>2]=je|Xe&~nt,A[ze+4>>2]=y,(w|0)<=1){p=14;break}}e:do if((p|0)!=13&&(p|0)==14)if((A[F>>2]|0)<=1&&(A[F+4>>2]|0)<=1&&(A[F+8>>2]|0)<=1){p=Eu(F)|0,y=vd(_e,p)|0,(y|0)==127?B=0:B=Ji(y)|0;t:do if(p){if(W){if(y=Hs(d,f)|0,(y|0)==7){y=5;break e}if(w=A[21376+(y*28|0)+(p<<2)>>2]|0,(w|0)>0){y=p,p=0;do y=Nu(y)|0,p=p+1|0;while((p|0)!=(w|0))}else y=p;if((y|0)==1){y=9;break e}p=vd(_e,y)|0,(p|0)==127&&tt(27648,27538,411,27678),Ji(p)|0?tt(27693,27538,412,27678):(ye=p,ve=w,se=y)}else ye=y,ve=0,se=p;if(R=A[4272+(_e*28|0)+(se<<2)>>2]|0,(R|0)<=-1&&tt(27724,27538,419,27678),!B){if((ve|0)<0){y=5;break e}if(ve|0){w=_,y=0,p=A[w>>2]|0,w=A[w+4>>2]|0;do p=Uu(p,w)|0,w=X()|0,je=_,A[je>>2]=p,A[je+4>>2]=w,y=y+1|0;while((y|0)<(ve|0))}if((R|0)<=0){y=ye,p=58;break}for(w=_,y=0,p=A[w>>2]|0,w=A[w+4>>2]|0;;)if(p=Uu(p,w)|0,w=X()|0,je=_,A[je>>2]=p,A[je+4>>2]=w,y=y+1|0,(y|0)==(R|0)){y=ye,p=58;break t}}if(M=Xh(ye,_e)|0,(M|0)==7&&tt(27514,27538,428,27678),y=_,p=A[y>>2]|0,y=A[y+4>>2]|0,(R|0)>0){w=0;do p=Uu(p,y)|0,y=X()|0,je=_,A[je>>2]=p,A[je+4>>2]=y,w=w+1|0;while((w|0)!=(R|0))}if(y=Hs(p,y)|0,(y|0)==7&&tt(27795,27538,440,27678),p=qc(ye)|0,p=A[(p?21792:21584)+(M*28|0)+(y<<2)>>2]|0,(p|0)<0&&tt(27795,27538,454,27678),!p)y=ye,p=58;else{M=_,y=0,w=A[M>>2]|0,M=A[M+4>>2]|0;do w=op(w,M)|0,M=X()|0,je=_,A[je>>2]=w,A[je+4>>2]=M,y=y+1|0;while((y|0)<(p|0));y=ye,p=58}}else if((W|0)!=0&(B|0)!=0){if(p=Hs(d,f)|0,w=_,w=Hs(A[w>>2]|0,A[w+4>>2]|0)|0,(p|0)==7|(w|0)==7){y=5;break e}if(w=A[21376+(p*28|0)+(w<<2)>>2]|0,(w|0)<0){y=5;break e}if(!w)p=59;else{R=_,p=0,M=A[R>>2]|0,R=A[R+4>>2]|0;do M=Uu(M,R)|0,R=X()|0,je=_,A[je>>2]=M,A[je+4>>2]=R,p=p+1|0;while((p|0)<(w|0));p=58}}else p=58;while(!1);if((p|0)==58&&B&&(p=59),(p|0)==59&&(je=_,(Hs(A[je>>2]|0,A[je+4>>2]|0)|0)==1)){y=9;break}je=_,nt=A[je>>2]|0,je=A[je+4>>2]&-1040385,Xe=It(y|0,0,45)|0,je=je|(X()|0),y=_,A[y>>2]=nt|Xe,A[y+4>>2]=je,y=0}else y=1;while(!1);return je=y,K=Pe,je|0}function M1(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0;return R=K,K=K+16|0,M=R,y?d=15:(d=so(d,f,p,_,M)|0,d||(dx(M,w),d=0)),K=R,d|0}function Pd(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0;return M=K,K=K+16|0,w=M,_?p=15:(p=tp(p,w)|0,p||(p=Po(d,f,w,y)|0)),K=M,p|0}function qu(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0;return B=K,K=K+32|0,M=B+12|0,R=B,w=so(d,f,d,f,M)|0,w|0?(R=w,K=B,R|0):(d=so(d,f,p,_,R)|0,d|0?(R=d,K=B,R|0):(M=ep(M,R)|0,R=y,A[R>>2]=M,A[R+4>>2]=((M|0)<0)<<31>>31,R=0,K=B,R|0))}function pp(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0;return B=K,K=K+32|0,M=B+12|0,R=B,w=so(d,f,d,f,M)|0,!w&&(w=so(d,f,p,_,R)|0,!w)?(_=ep(M,R)|0,_=tn(_|0,((_|0)<0)<<31>>31|0,1,0)|0,M=X()|0,R=y,A[R>>2]=_,A[R+4>>2]=M,R=0,K=B,R|0):(R=w,K=B,R|0)}function E1(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0;if(on=K,K=K+48|0,Ft=on+24|0,M=on+12|0,un=on,w=so(d,f,d,f,Ft)|0,!w&&(w=so(d,f,p,_,M)|0,!w)){je=ep(Ft,M)|0,Le=((je|0)<0)<<31>>31,A[Ft>>2]=0,A[Ft+4>>2]=0,A[Ft+8>>2]=0,A[M>>2]=0,A[M+4>>2]=0,A[M+8>>2]=0,so(d,f,d,f,Ft)|0&&tt(27795,27538,692,27747),so(d,f,p,_,M)|0&&tt(27795,27538,697,27747),f1(Ft),f1(M),W=(je|0)==0?0:1/+(je|0),p=A[Ft>>2]|0,Pe=W*+((A[M>>2]|0)-p|0),ze=Ft+4|0,_=A[ze>>2]|0,nt=W*+((A[M+4>>2]|0)-_|0),Xe=Ft+8|0,w=A[Xe>>2]|0,W=W*+((A[M+8>>2]|0)-w|0),A[un>>2]=p,se=un+4|0,A[se>>2]=_,_e=un+8|0,A[_e>>2]=w;e:do if((je|0)<0)w=0;else for(ve=0,ye=0;;){B=+(ye>>>0)+4294967296*+(ve|0),kn=Pe*B+ +(p|0),R=nt*B+ +(_|0),B=W*B+ +(w|0),p=~~+ll(+kn),M=~~+ll(+R),w=~~+ll(+B),kn=+dn(+(+(p|0)-kn)),R=+dn(+(+(M|0)-R)),B=+dn(+(+(w|0)-B));do if(kn>R&kn>B)p=0-(M+w)|0,_=M;else if(F=0-p|0,R>B){_=F-w|0;break}else{_=M,w=F-M|0;break}while(!1);if(A[un>>2]=p,A[se>>2]=_,A[_e>>2]=w,Ax(un),w=Po(d,f,un,y+(ye<<3)|0)|0,w|0)break e;if(!((ve|0)<(Le|0)|(ve|0)==(Le|0)&ye>>>0>>0)){w=0;break e}p=tn(ye|0,ve|0,1,0)|0,_=X()|0,ve=_,ye=p,p=A[Ft>>2]|0,_=A[ze>>2]|0,w=A[Xe>>2]|0}while(!1);return un=w,K=on,un|0}return un=w,K=on,un|0}function Lo(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if((p|0)==0&(_|0)==0)return y=0,w=1,he(y|0),w|0;w=d,y=f,d=1,f=0;do M=(p&1|0)==0&!0,d=ur((M?1:w)|0,(M?0:y)|0,d|0,f|0)|0,f=X()|0,p=N1(p|0,_|0,1)|0,_=X()|0,w=ur(w|0,y|0,w|0,y|0)|0,y=X()|0;while(!((p|0)==0&(_|0)==0));return he(f|0),d|0}function Ld(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;R=K,K=K+16|0,w=R,M=Ct(d|0,f|0,52)|0,X()|0,M=M&15;do if(M){if(y=Dl(d,f,w)|0,!y){F=+ee[w>>3],B=1/+an(+F),W=+ee[25968+(M<<3)>>3],ee[p>>3]=F+W,ee[p+8>>3]=F-W,F=+ee[w+8>>3],B=W*B,ee[p+16>>3]=B+F,ee[p+24>>3]=F-B;break}return M=y,K=R,M|0}else{if(y=Ct(d|0,f|0,45)|0,X()|0,y=y&127,y>>>0>121)return M=5,K=R,M|0;w=22064+(y<<5)|0,A[p>>2]=A[w>>2],A[p+4>>2]=A[w+4>>2],A[p+8>>2]=A[w+8>>2],A[p+12>>2]=A[w+12>>2],A[p+16>>2]=A[w+16>>2],A[p+20>>2]=A[w+20>>2],A[p+24>>2]=A[w+24>>2],A[p+28>>2]=A[w+28>>2];break}while(!1);return js(p,_?1.4:1.1),_=26096+(M<<3)|0,(A[_>>2]|0)==(d|0)&&(A[_+4>>2]|0)==(f|0)&&(ee[p>>3]=1.5707963267948966),M=26224+(M<<3)|0,(A[M>>2]|0)==(d|0)&&(A[M+4>>2]|0)==(f|0)&&(ee[p+8>>3]=-1.5707963267948966),+ee[p>>3]!=1.5707963267948966&&+ee[p+8>>3]!=-1.5707963267948966?(M=0,K=R,M|0):(ee[p+16>>3]=3.141592653589793,ee[p+24>>3]=-3.141592653589793,M=0,K=R,M|0)}function Ta(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;F=K,K=K+48|0,M=F+32|0,w=F+40|0,R=F,Pu(M,0,0,0),B=A[M>>2]|0,M=A[M+4>>2]|0;do if(p>>>0<=15){if(y=Ma(_)|0,y|0){_=R,A[_>>2]=0,A[_+4>>2]=0,A[R+8>>2]=y,A[R+12>>2]=-1,_=R+16|0,B=R+29|0,A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,xt[_+12>>0]=0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}if(y=Ys((A[f+8>>2]|0)+1|0,32)|0,y){Ea(f,y),W=R,A[W>>2]=B,A[W+4>>2]=M,A[R+8>>2]=0,A[R+12>>2]=p,A[R+16>>2]=_,A[R+20>>2]=f,A[R+24>>2]=y,xt[R+28>>0]=0,B=R+29|0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}else{_=R,A[_>>2]=0,A[_+4>>2]=0,A[R+8>>2]=13,A[R+12>>2]=-1,_=R+16|0,B=R+29|0,A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,xt[_+12>>0]=0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}}else B=R,A[B>>2]=0,A[B+4>>2]=0,A[R+8>>2]=4,A[R+12>>2]=-1,B=R+16|0,W=R+29|0,A[B>>2]=0,A[B+4>>2]=0,A[B+8>>2]=0,xt[B+12>>0]=0,xt[W>>0]=xt[w>>0]|0,xt[W+1>>0]=xt[w+1>>0]|0,xt[W+2>>0]=xt[w+2>>0]|0;while(!1);il(R),A[d>>2]=A[R>>2],A[d+4>>2]=A[R+4>>2],A[d+8>>2]=A[R+8>>2],A[d+12>>2]=A[R+12>>2],A[d+16>>2]=A[R+16>>2],A[d+20>>2]=A[R+20>>2],A[d+24>>2]=A[R+24>>2],A[d+28>>2]=A[R+28>>2],K=F}function il(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0;if(Le=K,K=K+336|0,ve=Le+168|0,ye=Le,_=d,p=A[_>>2]|0,_=A[_+4>>2]|0,(p|0)==0&(_|0)==0){K=Le;return}if(f=d+28|0,xt[f>>0]|0?(p=Vu(p,_)|0,_=X()|0):xt[f>>0]=1,je=d+20|0,!(A[A[je>>2]>>2]|0)){f=d+24|0,p=A[f>>2]|0,p|0&&vn(p),Xe=d,A[Xe>>2]=0,A[Xe+4>>2]=0,A[d+8>>2]=0,A[je>>2]=0,A[d+12>>2]=-1,A[d+16>>2]=0,A[f>>2]=0,K=Le;return}Xe=d+16|0,f=A[Xe>>2]|0,y=f&15;e:do if((p|0)==0&(_|0)==0)nt=d+24|0;else{Pe=d+12|0,se=(y|0)==3,W=f&255,B=(y|1|0)==3,_e=d+24|0,F=(y+-1|0)>>>0<3,M=(y|2|0)==3,R=ye+8|0;t:for(;;){if(w=Ct(p|0,_|0,52)|0,X()|0,w=w&15,(w|0)==(A[Pe>>2]|0)){switch(W&15){case 0:case 2:case 3:{if(y=Dl(p,_,ve)|0,y|0){ze=15;break t}if(Ca(A[je>>2]|0,A[_e>>2]|0,ve)|0){ze=19;break t}break}}if(B&&(y=A[(A[je>>2]|0)+4>>2]|0,A[ve>>2]=A[y>>2],A[ve+4>>2]=A[y+4>>2],A[ve+8>>2]=A[y+8>>2],A[ve+12>>2]=A[y+12>>2],Do(26832,ve)|0)){if(Ed(A[(A[je>>2]|0)+4>>2]|0,w,ye)|0){ze=25;break}if(y=ye,(A[y>>2]|0)==(p|0)&&(A[y+4>>2]|0)==(_|0)){ze=29;break}}if(F){if(y=Pl(p,_,ve)|0,y|0){ze=32;break}if(Ld(p,_,ye,0)|0){ze=36;break}if(M&&Uo(A[je>>2]|0,A[_e>>2]|0,ve,ye)|0){ze=42;break}if(B&&Bd(A[je>>2]|0,A[_e>>2]|0,ve,ye)|0){ze=42;break}}if(se){if(f=Ld(p,_,ve,1)|0,y=A[_e>>2]|0,f|0){ze=45;break}if(Kh(y,ve)|0){if(Zh(ye,ve),J0(ve,A[_e>>2]|0)|0){ze=53;break}if(Ca(A[je>>2]|0,A[_e>>2]|0,R)|0){ze=53;break}if(Bd(A[je>>2]|0,A[_e>>2]|0,ye,ve)|0){ze=53;break}}}}do if((w|0)<(A[Pe>>2]|0)){if(f=Ld(p,_,ve,1)|0,y=A[_e>>2]|0,f|0){ze=58;break t}if(!(Kh(y,ve)|0)){ze=73;break}if(J0(A[_e>>2]|0,ve)|0&&(Zh(ye,ve),Uo(A[je>>2]|0,A[_e>>2]|0,ye,ve)|0)){ze=65;break t}if(p=Md(p,_,w+1|0,ye)|0,p|0){ze=67;break t}_=ye,p=A[_>>2]|0,_=A[_+4>>2]|0}else ze=73;while(!1);if((ze|0)==73&&(ze=0,p=Vu(p,_)|0,_=X()|0),(p|0)==0&(_|0)==0){nt=_e;break e}}switch(ze|0){case 15:{f=A[_e>>2]|0,f|0&&vn(f),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=y,ze=20;break}case 19:{A[d>>2]=p,A[d+4>>2]=_,ze=20;break}case 25:{tt(27795,27761,470,27772);break}case 29:{A[d>>2]=p,A[d+4>>2]=_,K=Le;return}case 32:{f=A[_e>>2]|0,f|0&&vn(f),nt=d,A[nt>>2]=0,A[nt+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=y,K=Le;return}case 36:{tt(27795,27761,493,27772);break}case 42:{A[d>>2]=p,A[d+4>>2]=_,K=Le;return}case 45:{y|0&&vn(y),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=f,ze=55;break}case 53:{A[d>>2]=p,A[d+4>>2]=_,ze=55;break}case 58:{y|0&&vn(y),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=f,ze=71;break}case 65:{A[d>>2]=p,A[d+4>>2]=_,ze=71;break}case 67:{f=A[_e>>2]|0,f|0&&vn(f),nt=d,A[nt>>2]=0,A[nt+4>>2]=0,A[je>>2]=0,A[Pe>>2]=-1,A[Xe>>2]=0,A[_e>>2]=0,A[d+8>>2]=p,K=Le;return}}if((ze|0)==20){K=Le;return}else if((ze|0)==55){K=Le;return}else if((ze|0)==71){K=Le;return}}while(!1);f=A[nt>>2]|0,f|0&&vn(f),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[d+8>>2]=0,A[je>>2]=0,A[d+12>>2]=-1,A[Xe>>2]=0,A[nt>>2]=0,K=Le}function Vu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0;se=K,K=K+16|0,W=se,_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0;do if(_){for(;p=It(_+4095|0,0,52)|0,y=X()|0|f&-15728641,w=(15-_|0)*3|0,M=It(7,0,w|0)|0,R=X()|0,p=p|d|M,y=y|R,B=Ct(d|0,f|0,w|0)|0,X()|0,B=B&7,_=_+-1|0,!(B>>>0<6);)if(_)f=y,d=p;else{F=4;break}if((F|0)==4){p=Ct(p|0,y|0,45)|0,X()|0;break}return W=(B|0)==0&(wi(p,y)|0)!=0,W=It((W?2:1)+B|0,0,w|0)|0,F=X()|0|f&~R,W=W|d&~M,he(F|0),K=se,W|0}while(!1);return p=p&127,p>>>0>120?(F=0,W=0,he(F|0),K=se,W|0):(Pu(W,0,p+1|0,0),F=A[W+4>>2]|0,W=A[W>>2]|0,he(F|0),K=se,W|0)}function Ud(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0;ze=K,K=K+160|0,se=ze+80|0,R=ze+64|0,_e=ze+112|0,Pe=ze,Ta(se,d,f,p),F=se,nl(R,A[F>>2]|0,A[F+4>>2]|0,f),F=R,B=A[F>>2]|0,F=A[F+4>>2]|0,M=A[se+8>>2]|0,ve=_e+4|0,A[ve>>2]=A[se>>2],A[ve+4>>2]=A[se+4>>2],A[ve+8>>2]=A[se+8>>2],A[ve+12>>2]=A[se+12>>2],A[ve+16>>2]=A[se+16>>2],A[ve+20>>2]=A[se+20>>2],A[ve+24>>2]=A[se+24>>2],A[ve+28>>2]=A[se+28>>2],ve=Pe,A[ve>>2]=B,A[ve+4>>2]=F,ve=Pe+8|0,A[ve>>2]=M,d=Pe+12|0,f=_e,p=d+36|0;do A[d>>2]=A[f>>2],d=d+4|0,f=f+4|0;while((d|0)<(p|0));if(_e=Pe+48|0,A[_e>>2]=A[R>>2],A[_e+4>>2]=A[R+4>>2],A[_e+8>>2]=A[R+8>>2],A[_e+12>>2]=A[R+12>>2],(B|0)==0&(F|0)==0)return Pe=M,K=ze,Pe|0;p=Pe+16|0,W=Pe+24|0,se=Pe+28|0,M=0,R=0,f=B,d=F;do{if(!((M|0)<(y|0)|(M|0)==(y|0)&R>>>0<_>>>0)){ye=4;break}if(F=R,R=tn(R|0,M|0,1,0)|0,M=X()|0,F=w+(F<<3)|0,A[F>>2]=f,A[F+4>>2]=d,rf(_e),d=_e,f=A[d>>2]|0,d=A[d+4>>2]|0,(f|0)==0&(d|0)==0){if(il(p),f=p,d=A[f>>2]|0,f=A[f+4>>2]|0,(d|0)==0&(f|0)==0){ye=10;break}Fu(d,f,A[se>>2]|0,_e),d=_e,f=A[d>>2]|0,d=A[d+4>>2]|0}F=Pe,A[F>>2]=f,A[F+4>>2]=d}while(!((f|0)==0&(d|0)==0));return(ye|0)==4?(d=Pe+40|0,f=A[d>>2]|0,f|0&&vn(f),ye=Pe+16|0,A[ye>>2]=0,A[ye+4>>2]=0,A[W>>2]=0,A[Pe+36>>2]=0,A[se>>2]=-1,A[Pe+32>>2]=0,A[d>>2]=0,Fu(0,0,0,_e),A[Pe>>2]=0,A[Pe+4>>2]=0,A[ve>>2]=0,Pe=14,K=ze,Pe|0):((ye|0)==10&&(A[Pe>>2]=0,A[Pe+4>>2]=0,A[ve>>2]=A[W>>2]),Pe=A[ve>>2]|0,K=ze,Pe|0)}function sf(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0;if(se=K,K=K+48|0,B=se+32|0,R=se+40|0,F=se,!(A[d>>2]|0))return W=_,A[W>>2]=0,A[W+4>>2]=0,W=0,K=se,W|0;Pu(B,0,0,0),M=B,y=A[M>>2]|0,M=A[M+4>>2]|0;do if(f>>>0>15)W=F,A[W>>2]=0,A[W+4>>2]=0,A[F+8>>2]=4,A[F+12>>2]=-1,W=F+16|0,p=F+29|0,A[W>>2]=0,A[W+4>>2]=0,A[W+8>>2]=0,xt[W+12>>0]=0,xt[p>>0]=xt[R>>0]|0,xt[p+1>>0]=xt[R+1>>0]|0,xt[p+2>>0]=xt[R+2>>0]|0,p=4,W=9;else{if(p=Ma(p)|0,p|0){B=F,A[B>>2]=0,A[B+4>>2]=0,A[F+8>>2]=p,A[F+12>>2]=-1,B=F+16|0,W=F+29|0,A[B>>2]=0,A[B+4>>2]=0,A[B+8>>2]=0,xt[B+12>>0]=0,xt[W>>0]=xt[R>>0]|0,xt[W+1>>0]=xt[R+1>>0]|0,xt[W+2>>0]=xt[R+2>>0]|0,W=9;break}if(p=Ys((A[d+8>>2]|0)+1|0,32)|0,!p){W=F,A[W>>2]=0,A[W+4>>2]=0,A[F+8>>2]=13,A[F+12>>2]=-1,W=F+16|0,p=F+29|0,A[W>>2]=0,A[W+4>>2]=0,A[W+8>>2]=0,xt[W+12>>0]=0,xt[p>>0]=xt[R>>0]|0,xt[p+1>>0]=xt[R+1>>0]|0,xt[p+2>>0]=xt[R+2>>0]|0,p=13,W=9;break}Ea(d,p),ve=F,A[ve>>2]=y,A[ve+4>>2]=M,M=F+8|0,A[M>>2]=0,A[F+12>>2]=f,A[F+20>>2]=d,A[F+24>>2]=p,xt[F+28>>0]=0,y=F+29|0,xt[y>>0]=xt[R>>0]|0,xt[y+1>>0]=xt[R+1>>0]|0,xt[y+2>>0]=xt[R+2>>0]|0,A[F+16>>2]=3,_e=+Qh(p),_e=_e*+el(p),w=+dn(+ +ee[p>>3]),w=_e/+an(+ +uf(+w,+ +dn(+ +ee[p+8>>3])))*6371.007180918475*6371.007180918475,y=F+12|0,p=A[y>>2]|0;e:do if((p|0)>0)do{if(hp(p+-1|0,B)|0,!(w/+ee[B>>3]>10))break e;ve=A[y>>2]|0,p=ve+-1|0,A[y>>2]=p}while((ve|0)>1);while(!1);if(il(F),y=_,A[y>>2]=0,A[y+4>>2]=0,y=F,p=A[y>>2]|0,y=A[y+4>>2]|0,!((p|0)==0&(y|0)==0))do nf(p,y,f,B)|0,R=B,d=_,R=tn(A[d>>2]|0,A[d+4>>2]|0,A[R>>2]|0,A[R+4>>2]|0)|0,d=X()|0,ve=_,A[ve>>2]=R,A[ve+4>>2]=d,il(F),ve=F,p=A[ve>>2]|0,y=A[ve+4>>2]|0;while(!((p|0)==0&(y|0)==0));p=A[M>>2]|0}while(!1);return ve=p,K=se,ve|0}function Ss(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;if(!(Do(f,p)|0)||(f=_d(f)|0,_=+ee[p>>3],y=+ee[p+8>>3],y=f&y<0?y+6.283185307179586:y,_e=A[d>>2]|0,(_e|0)<=0))return _e=0,_e|0;if(se=A[d+4>>2]|0,f){f=0,W=y,p=-1,d=0;e:for(;;){for(F=d;M=+ee[se+(F<<4)>>3],y=+ee[se+(F<<4)+8>>3],d=(p+2|0)%(_e|0)|0,w=+ee[se+(d<<4)>>3],R=+ee[se+(d<<4)+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(_e|0)){p=22;break e}else d=F,F=p,p=d;if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,W=R==W|M==W?W+-2220446049250313e-31:W,B=R+(M-R)*((_-w)/(B-w)),(B<0?B+6.283185307179586:B)>W&&(f=f^1),d=F+1|0,(d|0)>=(_e|0)){p=22;break}else p=F}if((p|0)==22)return f|0}else{f=0,W=y,p=-1,d=0;e:for(;;){for(F=d;M=+ee[se+(F<<4)>>3],y=+ee[se+(F<<4)+8>>3],d=(p+2|0)%(_e|0)|0,w=+ee[se+(d<<4)>>3],R=+ee[se+(d<<4)+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(_e|0)){p=22;break e}else d=F,F=p,p=d;if(W=M==W|y==W?W+-2220446049250313e-31:W,M+(y-M)*((_-w)/(B-w))>W&&(f=f^1),d=F+1|0,(d|0)>=(_e|0)){p=22;break}else p=F}if((p|0)==22)return f|0}return 0}function da(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0;if(ye=A[d>>2]|0,!ye){A[f>>2]=0,A[f+4>>2]=0,A[f+8>>2]=0,A[f+12>>2]=0,A[f+16>>2]=0,A[f+20>>2]=0,A[f+24>>2]=0,A[f+28>>2]=0;return}if(Pe=f+8|0,ee[Pe>>3]=17976931348623157e292,ze=f+24|0,ee[ze>>3]=17976931348623157e292,ee[f>>3]=-17976931348623157e292,nt=f+16|0,ee[nt>>3]=-17976931348623157e292,!((ye|0)<=0)){for(_e=A[d+4>>2]|0,F=17976931348623157e292,W=-17976931348623157e292,se=0,d=-1,w=17976931348623157e292,M=17976931348623157e292,B=-17976931348623157e292,_=-17976931348623157e292,ve=0;p=+ee[_e+(ve<<4)>>3],R=+ee[_e+(ve<<4)+8>>3],d=d+2|0,y=+ee[_e+(((d|0)==(ye|0)?0:d)<<4)+8>>3],p>3]=p,w=p),R>3]=R,M=R),p>B?ee[f>>3]=p:p=B,R>_&&(ee[nt>>3]=R,_=R),F=R>0&RW?R:W,se=se|+dn(+(R-y))>3.141592653589793,d=ve+1|0,(d|0)!=(ye|0);)Xe=ve,B=p,ve=d,d=Xe;se&&(ee[nt>>3]=W,ee[ze>>3]=F)}}function Ma(d){return d=d|0,(d>>>0<4?0:15)|0}function Ea(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0;if(ye=A[d>>2]|0,ye){if(Pe=f+8|0,ee[Pe>>3]=17976931348623157e292,ze=f+24|0,ee[ze>>3]=17976931348623157e292,ee[f>>3]=-17976931348623157e292,nt=f+16|0,ee[nt>>3]=-17976931348623157e292,(ye|0)>0){for(y=A[d+4>>2]|0,_e=17976931348623157e292,ve=-17976931348623157e292,_=0,p=-1,B=17976931348623157e292,F=17976931348623157e292,se=-17976931348623157e292,M=-17976931348623157e292,Xe=0;w=+ee[y+(Xe<<4)>>3],W=+ee[y+(Xe<<4)+8>>3],un=p+2|0,R=+ee[y+(((un|0)==(ye|0)?0:un)<<4)+8>>3],w>3]=w,B=w),W>3]=W,F=W),w>se?ee[f>>3]=w:w=se,W>M&&(ee[nt>>3]=W,M=W),_e=W>0&W<_e?W:_e,ve=W<0&W>ve?W:ve,_=_|+dn(+(W-R))>3.141592653589793,p=Xe+1|0,(p|0)!=(ye|0);)un=Xe,se=w,Xe=p,p=un;_&&(ee[nt>>3]=ve,ee[ze>>3]=_e)}}else A[f>>2]=0,A[f+4>>2]=0,A[f+8>>2]=0,A[f+12>>2]=0,A[f+16>>2]=0,A[f+20>>2]=0,A[f+24>>2]=0,A[f+28>>2]=0;if(un=d+8|0,p=A[un>>2]|0,!((p|0)<=0)){Ft=d+12|0,Le=0;do if(y=A[Ft>>2]|0,_=Le,Le=Le+1|0,ze=f+(Le<<5)|0,nt=A[y+(_<<3)>>2]|0,nt){if(Xe=f+(Le<<5)+8|0,ee[Xe>>3]=17976931348623157e292,d=f+(Le<<5)+24|0,ee[d>>3]=17976931348623157e292,ee[ze>>3]=-17976931348623157e292,je=f+(Le<<5)+16|0,ee[je>>3]=-17976931348623157e292,(nt|0)>0){for(ye=A[y+(_<<3)+4>>2]|0,_e=17976931348623157e292,ve=-17976931348623157e292,y=0,_=-1,Pe=0,B=17976931348623157e292,F=17976931348623157e292,W=-17976931348623157e292,M=-17976931348623157e292;w=+ee[ye+(Pe<<4)>>3],se=+ee[ye+(Pe<<4)+8>>3],_=_+2|0,R=+ee[ye+(((_|0)==(nt|0)?0:_)<<4)+8>>3],w>3]=w,B=w),se>3]=se,F=se),w>W?ee[ze>>3]=w:w=W,se>M&&(ee[je>>3]=se,M=se),_e=se>0&se<_e?se:_e,ve=se<0&se>ve?se:ve,y=y|+dn(+(se-R))>3.141592653589793,_=Pe+1|0,(_|0)!=(nt|0);)on=Pe,Pe=_,W=w,_=on;y&&(ee[je>>3]=ve,ee[d>>3]=_e)}}else A[ze>>2]=0,A[ze+4>>2]=0,A[ze+8>>2]=0,A[ze+12>>2]=0,A[ze+16>>2]=0,A[ze+20>>2]=0,A[ze+24>>2]=0,A[ze+28>>2]=0,p=A[un>>2]|0;while((Le|0)<(p|0))}}function Ca(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(!(Ss(d,f,p)|0))return y=0,y|0;if(y=d+8|0,(A[y>>2]|0)<=0)return y=1,y|0;for(_=d+12|0,d=0;;){if(w=d,d=d+1|0,Ss((A[_>>2]|0)+(w<<3)|0,f+(d<<5)|0,p)|0){d=0,_=6;break}if((d|0)>=(A[y>>2]|0)){d=1,_=6;break}}return(_|0)==6?d|0:0}function Uo(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(F=K,K=K+16|0,R=F,M=p+8|0,!(Ss(d,f,M)|0))return B=0,K=F,B|0;B=d+8|0;e:do if((A[B>>2]|0)>0){for(w=d+12|0,y=0;;){if(W=y,y=y+1|0,Ss((A[w>>2]|0)+(W<<3)|0,f+(y<<5)|0,M)|0){y=0;break}if((y|0)>=(A[B>>2]|0))break e}return K=F,y|0}while(!1);if(af(d,f,p,_)|0)return W=0,K=F,W|0;A[R>>2]=A[p>>2],A[R+4>>2]=M,y=A[B>>2]|0;e:do if((y|0)>0)for(d=d+12|0,M=0,w=y;;){if(y=A[d>>2]|0,(A[y+(M<<3)>>2]|0)>0){if(Ss(R,_,A[y+(M<<3)+4>>2]|0)|0){y=0;break e}if(y=M+1|0,af((A[d>>2]|0)+(M<<3)|0,f+(y<<5)|0,p,_)|0){y=0;break e}w=A[B>>2]|0}else y=M+1|0;if((y|0)<(w|0))M=y;else{y=1;break}}else y=1;while(!1);return W=y,K=F,W|0}function af(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0,un=0,on=0,kn=0;if(un=K,K=K+176|0,Xe=un+172|0,y=un+168|0,je=un,!(Kh(f,_)|0))return d=0,K=un,d|0;if(yd(f,_,Xe,y),Ol(je|0,p|0,168)|0,(A[p>>2]|0)>0){f=0;do on=je+8+(f<<4)+8|0,nt=+Ws(+ee[on>>3],A[y>>2]|0),ee[on>>3]=nt,f=f+1|0;while((f|0)<(A[p>>2]|0))}Pe=+ee[_>>3],ze=+ee[_+8>>3],nt=+Ws(+ee[_+16>>3],A[y>>2]|0),ve=+Ws(+ee[_+24>>3],A[y>>2]|0);e:do if((A[d>>2]|0)>0){if(_=d+4|0,y=A[je>>2]|0,(y|0)<=0){for(f=0;;)if(f=f+1|0,(f|0)>=(A[d>>2]|0)){f=0;break e}}for(p=0;;){if(f=A[_>>2]|0,_e=+ee[f+(p<<4)>>3],ye=+Ws(+ee[f+(p<<4)+8>>3],A[Xe>>2]|0),f=A[_>>2]|0,p=p+1|0,on=(p|0)%(A[d>>2]|0)|0,w=+ee[f+(on<<4)>>3],M=+Ws(+ee[f+(on<<4)+8>>3],A[Xe>>2]|0),!(_e>=Pe)|!(w>=Pe)&&!(_e<=ze)|!(w<=ze)&&!(ye<=ve)|!(M<=ve)&&!(ye>=nt)|!(M>=nt)){se=w-_e,F=M-ye,f=0;do if(kn=f,f=f+1|0,on=(f|0)==(y|0)?0:f,w=+ee[je+8+(kn<<4)+8>>3],M=+ee[je+8+(on<<4)+8>>3]-w,R=+ee[je+8+(kn<<4)>>3],B=+ee[je+8+(on<<4)>>3]-R,W=se*M-F*B,W!=0&&(Le=ye-w,Ft=_e-R,B=(Le*B-M*Ft)/W,!(B<0|B>1))&&(W=(se*Le-F*Ft)/W,W>=0&W<=1)){f=1;break e}while((f|0)<(y|0))}if((p|0)>=(A[d>>2]|0)){f=0;break}}}else f=0;while(!1);return kn=f,K=un,kn|0}function Bd(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if(af(d,f,p,_)|0)return w=1,w|0;if(w=d+8|0,(A[w>>2]|0)<=0)return w=0,w|0;for(y=d+12|0,d=0;;){if(M=d,d=d+1|0,af((A[y>>2]|0)+(M<<3)|0,f+(d<<5)|0,p,_)|0){d=1,y=6;break}if((d|0)>=(A[w>>2]|0)){d=0,y=6;break}}return(y|0)==6?d|0:0}function mp(){return 8}function C1(){return 16}function cs(){return 168}function er(){return 8}function Ai(){return 16}function Ul(){return 12}function Na(){return 8}function gp(d){return d=d|0,+(+((A[d>>2]|0)>>>0)+4294967296*+(A[d+4>>2]|0))}function Bl(d){d=d|0;var f=0,p=0;return p=+ee[d>>3],f=+ee[d+8>>3],+ +Fn(+(p*p+f*f))}function vp(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0;F=+ee[d>>3],B=+ee[f>>3]-F,R=+ee[d+8>>3],M=+ee[f+8>>3]-R,se=+ee[p>>3],w=+ee[_>>3]-se,_e=+ee[p+8>>3],W=+ee[_+8>>3]-_e,w=(w*(R-_e)-(F-se)*W)/(B*W-M*w),ee[y>>3]=F+B*w,ee[y+8>>3]=R+M*w}function _p(d,f){return d=d|0,f=f|0,+dn(+(+ee[d>>3]-+ee[f>>3]))<11920928955078125e-23?(f=+dn(+(+ee[d+8>>3]-+ee[f+8>>3]))<11920928955078125e-23,f|0):(f=0,f|0)}function tr(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;return y=+ee[d>>3]-+ee[f>>3],_=+ee[d+8>>3]-+ee[f+8>>3],p=+ee[d+16>>3]-+ee[f+16>>3],+(y*y+_*_+p*p)}function ju(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;p=+ee[d>>3],_=+an(+p),p=+mn(+p),ee[f+16>>3]=p,p=+ee[d+8>>3],y=_*+an(+p),ee[f>>3]=y,p=_*+mn(+p),ee[f+8>>3]=p}function yp(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(w=K,K=K+16|0,y=w,_=wi(d,f)|0,(p+-1|0)>>>0>5||(_=(_|0)!=0,(p|0)==1&_))return y=-1,K=w,y|0;do if(rl(d,f,y)|0)_=-1;else if(_){_=((A[26352+(p<<2)>>2]|0)+5-(A[y>>2]|0)|0)%5|0;break}else{_=((A[26384+(p<<2)>>2]|0)+6-(A[y>>2]|0)|0)%6|0;break}while(!1);return y=_,K=w,y|0}function rl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+32|0,R=W+16|0,B=W,_=Bu(d,f,R)|0,_|0)return p=_,K=W,p|0;w=m1(d,f)|0,F=Hs(d,f)|0,Z0(w,B),_=Vc(w,A[R>>2]|0)|0;do if(Ji(w)|0){do switch(w|0){case 4:{y=0;break}case 14:{y=1;break}case 24:{y=2;break}case 38:{y=3;break}case 49:{y=4;break}case 58:{y=5;break}case 63:{y=6;break}case 72:{y=7;break}case 83:{y=8;break}case 97:{y=9;break}case 107:{y=10;break}case 117:{y=11;break}default:tt(27795,27797,75,27806)}while(!1);if(M=A[26416+(y*24|0)+8>>2]|0,f=A[26416+(y*24|0)+16>>2]|0,d=A[R>>2]|0,(d|0)!=(A[B>>2]|0)&&(B=qc(w)|0,d=A[R>>2]|0,B|(d|0)==(f|0)&&(_=(_+1|0)%6|0)),(F|0)==3&(d|0)==(f|0)){_=(_+5|0)%6|0;break}(F|0)==5&(d|0)==(M|0)&&(_=(_+1|0)%6|0)}while(!1);return A[p>>2]=_,p=0,K=W,p|0}function Xs(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0;if(je=K,K=K+32|0,Xe=je+24|0,ze=je+20|0,ye=je+8|0,ve=je+16|0,_e=je,B=(wi(d,f)|0)==0,B=B?6:5,W=Ct(d|0,f|0,52)|0,X()|0,W=W&15,B>>>0<=p>>>0)return _=2,K=je,_|0;se=(W|0)==0,!se&&(Pe=It(7,0,(W^15)*3|0)|0,(Pe&d|0)==0&((X()|0)&f|0)==0)?y=p:w=4;e:do if((w|0)==4){if(y=(wi(d,f)|0)!=0,((y?4:5)|0)<(p|0)||rl(d,f,Xe)|0||(w=(A[Xe>>2]|0)+p|0,y?y=26704+(((w|0)%5|0)<<2)|0:y=26736+(((w|0)%6|0)<<2)|0,Pe=A[y>>2]|0,(Pe|0)==7))return _=1,K=je,_|0;A[ze>>2]=0,y=bi(d,f,Pe,ze,ye)|0;do if(!y){if(R=ye,F=A[R>>2]|0,R=A[R+4>>2]|0,M=R>>>0>>0|(R|0)==(f|0)&F>>>0>>0,w=M?F:d,M=M?R:f,!se&&(se=It(7,0,(W^15)*3|0)|0,(F&se|0)==0&(R&(X()|0)|0)==0))y=p;else{if(R=(p+-1+B|0)%(B|0)|0,y=wi(d,f)|0,(R|0)<0&&tt(27795,27797,248,27822),B=(y|0)!=0,((B?4:5)|0)<(R|0)&&tt(27795,27797,248,27822),rl(d,f,Xe)|0&&tt(27795,27797,248,27822),y=(A[Xe>>2]|0)+R|0,B?y=26704+(((y|0)%5|0)<<2)|0:y=26736+(((y|0)%6|0)<<2)|0,R=A[y>>2]|0,(R|0)==7&&tt(27795,27797,248,27822),A[ve>>2]=0,y=bi(d,f,R,ve,_e)|0,y|0)break;F=_e,B=A[F>>2]|0,F=A[F+4>>2]|0;do if(F>>>0>>0|(F|0)==(M|0)&B>>>0>>0){if(wi(B,F)|0?w=xs(B,F,d,f)|0:w=A[26800+((((A[ve>>2]|0)+(A[26768+(R<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=wi(B,F)|0,(w+-1|0)>>>0>5){y=-1,w=B,M=F;break}if(y=(y|0)!=0,(w|0)==1&y){y=-1,w=B,M=F;break}do if(rl(B,F,Xe)|0)y=-1;else if(y){y=((A[26352+(w<<2)>>2]|0)+5-(A[Xe>>2]|0)|0)%5|0;break}else{y=((A[26384+(w<<2)>>2]|0)+6-(A[Xe>>2]|0)|0)%6|0;break}while(!1);w=B,M=F}else y=p;while(!1);R=ye,F=A[R>>2]|0,R=A[R+4>>2]|0}if((w|0)==(F|0)&(M|0)==(R|0)){if(B=(wi(F,R)|0)!=0,B?d=xs(F,R,d,f)|0:d=A[26800+((((A[ze>>2]|0)+(A[26768+(Pe<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=wi(F,R)|0,(d+-1|0)>>>0<=5&&(nt=(y|0)!=0,!((d|0)==1&nt)))do if(rl(F,R,Xe)|0)y=-1;else if(nt){y=((A[26352+(d<<2)>>2]|0)+5-(A[Xe>>2]|0)|0)%5|0;break}else{y=((A[26384+(d<<2)>>2]|0)+6-(A[Xe>>2]|0)|0)%6|0;break}while(!1);else y=-1;y=y+1|0,y=(y|0)==6|B&(y|0)==5?0:y}f=M,d=w;break e}while(!1);return _=y,K=je,_|0}while(!1);return nt=It(y|0,0,56)|0,Xe=X()|0|f&-2130706433|536870912,A[_>>2]=nt|d,A[_+4>>2]=Xe,_=0,K=je,_|0}function Hu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return w=(wi(d,f)|0)==0,_=Xs(d,f,0,p)|0,y=(_|0)==0,w?!y||(_=Xs(d,f,1,p+8|0)|0,_|0)||(_=Xs(d,f,2,p+16|0)|0,_|0)||(_=Xs(d,f,3,p+24|0)|0,_|0)||(_=Xs(d,f,4,p+32|0)|0,_)?(w=_,w|0):Xs(d,f,5,p+40|0)|0:!y||(_=Xs(d,f,1,p+8|0)|0,_|0)||(_=Xs(d,f,2,p+16|0)|0,_|0)||(_=Xs(d,f,3,p+24|0)|0,_|0)||(_=Xs(d,f,4,p+32|0)|0,_|0)?(w=_,w|0):(w=p+40|0,A[w>>2]=0,A[w+4>>2]=0,w=0,w|0)}function sl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;return B=K,K=K+192|0,y=B,w=B+168|0,M=Ct(d|0,f|0,56)|0,X()|0,M=M&7,R=f&-2130706433|134217728,_=Bu(d,R,w)|0,_|0?(R=_,K=B,R|0):(f=Ct(d|0,f|0,52)|0,X()|0,f=f&15,wi(d,R)|0?np(w,f,M,1,y):wd(w,f,M,1,y),R=y+8|0,A[p>>2]=A[R>>2],A[p+4>>2]=A[R+4>>2],A[p+8>>2]=A[R+8>>2],A[p+12>>2]=A[R+12>>2],R=0,K=B,R|0)}function al(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=K,K=K+16|0,p=y,!(!0&(f&2013265920|0)==536870912)||(_=f&-2130706433|134217728,!(Td(d,_)|0))?(_=0,K=y,_|0):(w=Ct(d|0,f|0,56)|0,X()|0,w=(Xs(d,_,w&7,p)|0)==0,_=p,_=w&((A[_>>2]|0)==(d|0)?(A[_+4>>2]|0)==(f|0):0)&1,K=y,_|0)}function Bo(d,f,p){d=d|0,f=f|0,p=p|0;var _=0;(f|0)>0?(_=Ys(f,4)|0,A[d>>2]=_,_||tt(27835,27858,40,27872)):A[d>>2]=0,A[d+4>>2]=f,A[d+8>>2]=0,A[d+12>>2]=p}function Od(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=d+4|0,w=d+12|0,M=d+8|0;e:for(;;){for(p=A[y>>2]|0,f=0;;){if((f|0)>=(p|0))break e;if(_=A[d>>2]|0,R=A[_+(f<<2)>>2]|0,!R)f=f+1|0;else break}f=_+(~~(+dn(+(+lr(10,+ +(15-(A[w>>2]|0)|0))*(+ee[R>>3]+ +ee[R+8>>3])))%+(p|0))>>>0<<2)|0,p=A[f>>2]|0;t:do if(p|0){if(_=R+32|0,(p|0)==(R|0))A[f>>2]=A[_>>2];else{if(p=p+32|0,f=A[p>>2]|0,!f)break;for(;(f|0)!=(R|0);)if(p=f+32|0,f=A[p>>2]|0,!f)break t;A[p>>2]=A[_>>2]}vn(R),A[M>>2]=(A[M>>2]|0)+-1}while(!1)}vn(A[d>>2]|0)}function Id(d){d=d|0;var f=0,p=0,_=0;for(_=A[d+4>>2]|0,p=0;;){if((p|0)>=(_|0)){f=0,p=4;break}if(f=A[(A[d>>2]|0)+(p<<2)>>2]|0,!f)p=p+1|0;else{p=4;break}}return(p|0)==4?f|0:0}function Wu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;if(p=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+ee[f>>3]+ +ee[f+8>>3])))%+(A[d+4>>2]|0))>>>0,p=(A[d>>2]|0)+(p<<2)|0,_=A[p>>2]|0,!_)return w=1,w|0;w=f+32|0;do if((_|0)!=(f|0)){if(p=A[_+32>>2]|0,!p)return w=1,w|0;for(y=p;;){if((y|0)==(f|0)){y=8;break}if(p=A[y+32>>2]|0,p)_=y,y=p;else{p=1,y=10;break}}if((y|0)==8){A[_+32>>2]=A[w>>2];break}else if((y|0)==10)return p|0}else A[p>>2]=A[w>>2];while(!1);return vn(f),w=d+8|0,A[w>>2]=(A[w>>2]|0)+-1,w=0,w|0}function Fd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;w=Oo(40)|0,w||tt(27888,27858,98,27901),A[w>>2]=A[f>>2],A[w+4>>2]=A[f+4>>2],A[w+8>>2]=A[f+8>>2],A[w+12>>2]=A[f+12>>2],y=w+16|0,A[y>>2]=A[p>>2],A[y+4>>2]=A[p+4>>2],A[y+8>>2]=A[p+8>>2],A[y+12>>2]=A[p+12>>2],A[w+32>>2]=0,y=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+ee[f>>3]+ +ee[f+8>>3])))%+(A[d+4>>2]|0))>>>0,y=(A[d>>2]|0)+(y<<2)|0,_=A[y>>2]|0;do if(!_)A[y>>2]=w;else{for(;!(wa(_,f)|0&&wa(_+16|0,p)|0);)if(y=A[_+32>>2]|0,_=(y|0)==0?_:y,!(A[_+32>>2]|0)){M=10;break}if((M|0)==10){A[_+32>>2]=w;break}return vn(w),M=_,M|0}while(!1);return M=d+8|0,A[M>>2]=(A[M>>2]|0)+1,M=w,M|0}function $u(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;if(y=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+ee[f>>3]+ +ee[f+8>>3])))%+(A[d+4>>2]|0))>>>0,y=A[(A[d>>2]|0)+(y<<2)>>2]|0,!y)return p=0,p|0;if(!p){for(d=y;;){if(wa(d,f)|0){_=10;break}if(d=A[d+32>>2]|0,!d){d=0,_=10;break}}if((_|0)==10)return d|0}for(d=y;;){if(wa(d,f)|0&&wa(d+16|0,p)|0){_=10;break}if(d=A[d+32>>2]|0,!d){d=0,_=10;break}}return(_|0)==10?d|0:0}function hs(d,f){d=d|0,f=f|0;var p=0;if(p=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+ee[f>>3]+ +ee[f+8>>3])))%+(A[d+4>>2]|0))>>>0,d=A[(A[d>>2]|0)+(p<<2)>>2]|0,!d)return p=0,p|0;for(;;){if(wa(d,f)|0){f=5;break}if(d=A[d+32>>2]|0,!d){d=0,f=5;break}}return(f|0)==5?d|0:0}function kd(){return 27920}function ol(d){return d=+d,~~+cf(+d)|0}function Oo(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0,Pe=0,ze=0,nt=0,Xe=0,je=0,Le=0,Ft=0;Ft=K,K=K+16|0,_e=Ft;do if(d>>>0<245){if(F=d>>>0<11?16:d+11&-8,d=F>>>3,se=A[6981]|0,p=se>>>d,p&3|0)return f=(p&1^1)+d|0,d=27964+(f<<1<<2)|0,p=d+8|0,_=A[p>>2]|0,y=_+8|0,w=A[y>>2]|0,(w|0)==(d|0)?A[6981]=se&~(1<>2]=d,A[p>>2]=w),Le=f<<3,A[_+4>>2]=Le|3,Le=_+Le+4|0,A[Le>>2]=A[Le>>2]|1,Le=y,K=Ft,Le|0;if(W=A[6983]|0,F>>>0>W>>>0){if(p|0)return f=2<>>12&16,f=f>>>R,p=f>>>5&8,f=f>>>p,w=f>>>2&4,f=f>>>w,d=f>>>1&2,f=f>>>d,_=f>>>1&1,_=(p|R|w|d|_)+(f>>>_)|0,f=27964+(_<<1<<2)|0,d=f+8|0,w=A[d>>2]|0,R=w+8|0,p=A[R>>2]|0,(p|0)==(f|0)?(d=se&~(1<<_),A[6981]=d):(A[p+12>>2]=f,A[d>>2]=p,d=se),Le=_<<3,M=Le-F|0,A[w+4>>2]=F|3,y=w+F|0,A[y+4>>2]=M|1,A[w+Le>>2]=M,W|0&&(_=A[6986]|0,f=W>>>3,p=27964+(f<<1<<2)|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=_,A[f+12>>2]=_,A[_+8>>2]=f,A[_+12>>2]=p),A[6983]=M,A[6986]=y,Le=R,K=Ft,Le|0;if(w=A[6982]|0,w){for(p=(w&0-w)+-1|0,y=p>>>12&16,p=p>>>y,_=p>>>5&8,p=p>>>_,M=p>>>2&4,p=p>>>M,R=p>>>1&2,p=p>>>R,B=p>>>1&1,B=A[28228+((_|y|M|R|B)+(p>>>B)<<2)>>2]|0,p=B,R=B,B=(A[B+4>>2]&-8)-F|0;d=A[p+16>>2]|0,!(!d&&(d=A[p+20>>2]|0,!d));)M=(A[d+4>>2]&-8)-F|0,y=M>>>0>>0,p=d,R=y?d:R,B=y?M:B;if(M=R+F|0,M>>>0>R>>>0){y=A[R+24>>2]|0,f=A[R+12>>2]|0;do if((f|0)==(R|0)){if(d=R+20|0,f=A[d>>2]|0,!f&&(d=R+16|0,f=A[d>>2]|0,!f)){p=0;break}for(;;)if(_=f+20|0,p=A[_>>2]|0,p)f=p,d=_;else if(_=f+16|0,p=A[_>>2]|0,p)f=p,d=_;else break;A[d>>2]=0,p=f}else p=A[R+8>>2]|0,A[p+12>>2]=f,A[f+8>>2]=p,p=f;while(!1);do if(y|0){if(f=A[R+28>>2]|0,d=28228+(f<<2)|0,(R|0)==(A[d>>2]|0)){if(A[d>>2]=p,!p){A[6982]=w&~(1<>2]|0)==(R|0)?Le:y+20|0)>>2]=p,!p)break;A[p+24>>2]=y,f=A[R+16>>2]|0,f|0&&(A[p+16>>2]=f,A[f+24>>2]=p),f=A[R+20>>2]|0,f|0&&(A[p+20>>2]=f,A[f+24>>2]=p)}while(!1);return B>>>0<16?(Le=B+F|0,A[R+4>>2]=Le|3,Le=R+Le+4|0,A[Le>>2]=A[Le>>2]|1):(A[R+4>>2]=F|3,A[M+4>>2]=B|1,A[M+B>>2]=B,W|0&&(_=A[6986]|0,f=W>>>3,p=27964+(f<<1<<2)|0,f=1<>2]|0):(A[6981]=f|se,f=p,d=p+8|0),A[d>>2]=_,A[f+12>>2]=_,A[_+8>>2]=f,A[_+12>>2]=p),A[6983]=B,A[6986]=M),Le=R+8|0,K=Ft,Le|0}else se=F}else se=F}else se=F}else if(d>>>0<=4294967231)if(d=d+11|0,F=d&-8,_=A[6982]|0,_){y=0-F|0,d=d>>>8,d?F>>>0>16777215?B=31:(se=(d+1048320|0)>>>16&8,Pe=d<>>16&4,Pe=Pe<>>16&2,B=14-(R|se|B)+(Pe<>>15)|0,B=F>>>(B+7|0)&1|B<<1):B=0,p=A[28228+(B<<2)>>2]|0;e:do if(!p)p=0,d=0,Pe=61;else for(d=0,R=F<<((B|0)==31?0:25-(B>>>1)|0),w=0;;){if(M=(A[p+4>>2]&-8)-F|0,M>>>0>>0)if(M)d=p,y=M;else{d=p,y=0,Pe=65;break e}if(Pe=A[p+20>>2]|0,p=A[p+16+(R>>>31<<2)>>2]|0,w=(Pe|0)==0|(Pe|0)==(p|0)?w:Pe,p)R=R<<1;else{p=w,Pe=61;break}}while(!1);if((Pe|0)==61){if((p|0)==0&(d|0)==0){if(d=2<>>12&16,se=se>>>M,w=se>>>5&8,se=se>>>w,R=se>>>2&4,se=se>>>R,B=se>>>1&2,se=se>>>B,p=se>>>1&1,d=0,p=A[28228+((w|M|R|B|p)+(se>>>p)<<2)>>2]|0}p?Pe=65:(R=d,M=y)}if((Pe|0)==65)for(w=p;;)if(se=(A[w+4>>2]&-8)-F|0,p=se>>>0>>0,y=p?se:y,d=p?w:d,p=A[w+16>>2]|0,p||(p=A[w+20>>2]|0),p)w=p;else{R=d,M=y;break}if((R|0)!=0&&M>>>0<((A[6983]|0)-F|0)>>>0&&(W=R+F|0,W>>>0>R>>>0)){w=A[R+24>>2]|0,f=A[R+12>>2]|0;do if((f|0)==(R|0)){if(d=R+20|0,f=A[d>>2]|0,!f&&(d=R+16|0,f=A[d>>2]|0,!f)){f=0;break}for(;;)if(y=f+20|0,p=A[y>>2]|0,p)f=p,d=y;else if(y=f+16|0,p=A[y>>2]|0,p)f=p,d=y;else break;A[d>>2]=0}else Le=A[R+8>>2]|0,A[Le+12>>2]=f,A[f+8>>2]=Le;while(!1);do if(w){if(d=A[R+28>>2]|0,p=28228+(d<<2)|0,(R|0)==(A[p>>2]|0)){if(A[p>>2]=f,!f){_=_&~(1<>2]|0)==(R|0)?Le:w+20|0)>>2]=f,!f)break;A[f+24>>2]=w,d=A[R+16>>2]|0,d|0&&(A[f+16>>2]=d,A[d+24>>2]=f),d=A[R+20>>2]|0,d&&(A[f+20>>2]=d,A[d+24>>2]=f)}while(!1);e:do if(M>>>0<16)Le=M+F|0,A[R+4>>2]=Le|3,Le=R+Le+4|0,A[Le>>2]=A[Le>>2]|1;else{if(A[R+4>>2]=F|3,A[W+4>>2]=M|1,A[W+M>>2]=M,f=M>>>3,M>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=W,A[f+12>>2]=W,A[W+8>>2]=f,A[W+12>>2]=p;break}if(f=M>>>8,f?M>>>0>16777215?p=31:(je=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,p=14-(Xe|je|p)+(Le<

>>15)|0,p=M>>>(p+7|0)&1|p<<1):p=0,f=28228+(p<<2)|0,A[W+28>>2]=p,d=W+16|0,A[d+4>>2]=0,A[d>>2]=0,d=1<>2]=W,A[W+24>>2]=f,A[W+12>>2]=W,A[W+8>>2]=W;break}f=A[f>>2]|0;t:do if((A[f+4>>2]&-8|0)!=(M|0)){for(_=M<<((p|0)==31?0:25-(p>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(M|0)){f=d;break t}else _=_<<1,f=d;A[p>>2]=W,A[W+24>>2]=f,A[W+12>>2]=W,A[W+8>>2]=W;break e}while(!1);je=f+8|0,Le=A[je>>2]|0,A[Le+12>>2]=W,A[je>>2]=W,A[W+8>>2]=Le,A[W+12>>2]=f,A[W+24>>2]=0}while(!1);return Le=R+8|0,K=Ft,Le|0}else se=F}else se=F;else se=-1;while(!1);if(p=A[6983]|0,p>>>0>=se>>>0)return f=p-se|0,d=A[6986]|0,f>>>0>15?(Le=d+se|0,A[6986]=Le,A[6983]=f,A[Le+4>>2]=f|1,A[d+p>>2]=f,A[d+4>>2]=se|3):(A[6983]=0,A[6986]=0,A[d+4>>2]=p|3,Le=d+p+4|0,A[Le>>2]=A[Le>>2]|1),Le=d+8|0,K=Ft,Le|0;if(M=A[6984]|0,M>>>0>se>>>0)return Xe=M-se|0,A[6984]=Xe,Le=A[6987]|0,je=Le+se|0,A[6987]=je,A[je+4>>2]=Xe|1,A[Le+4>>2]=se|3,Le=Le+8|0,K=Ft,Le|0;if(A[7099]|0?d=A[7101]|0:(A[7101]=4096,A[7100]=4096,A[7102]=-1,A[7103]=-1,A[7104]=0,A[7092]=0,A[7099]=_e&-16^1431655768,d=4096),R=se+48|0,B=se+47|0,w=d+B|0,y=0-d|0,F=w&y,F>>>0<=se>>>0||(d=A[7091]|0,d|0&&(W=A[7089]|0,_e=W+F|0,_e>>>0<=W>>>0|_e>>>0>d>>>0)))return Le=0,K=Ft,Le|0;e:do if(A[7092]&4)f=0,Pe=143;else{p=A[6987]|0;t:do if(p){for(_=28372;_e=A[_>>2]|0,!(_e>>>0<=p>>>0&&(_e+(A[_+4>>2]|0)|0)>>>0>p>>>0);)if(d=A[_+8>>2]|0,d)_=d;else{Pe=128;break t}if(f=w-M&y,f>>>0<2147483647)if(d=ul(f|0)|0,(d|0)==((A[_>>2]|0)+(A[_+4>>2]|0)|0)){if((d|0)!=-1){M=f,w=d,Pe=145;break e}}else _=d,Pe=136;else f=0}else Pe=128;while(!1);do if((Pe|0)==128)if(p=ul(0)|0,(p|0)!=-1&&(f=p,ve=A[7100]|0,ye=ve+-1|0,f=((ye&f|0)==0?0:(ye+f&0-ve)-f|0)+F|0,ve=A[7089]|0,ye=f+ve|0,f>>>0>se>>>0&f>>>0<2147483647)){if(_e=A[7091]|0,_e|0&&ye>>>0<=ve>>>0|ye>>>0>_e>>>0){f=0;break}if(d=ul(f|0)|0,(d|0)==(p|0)){M=f,w=p,Pe=145;break e}else _=d,Pe=136}else f=0;while(!1);do if((Pe|0)==136){if(p=0-f|0,!(R>>>0>f>>>0&(f>>>0<2147483647&(_|0)!=-1)))if((_|0)==-1){f=0;break}else{M=f,w=_,Pe=145;break e}if(d=A[7101]|0,d=B-f+d&0-d,d>>>0>=2147483647){M=f,w=_,Pe=145;break e}if((ul(d|0)|0)==-1){ul(p|0)|0,f=0;break}else{M=d+f|0,w=_,Pe=145;break e}}while(!1);A[7092]=A[7092]|4,Pe=143}while(!1);if((Pe|0)==143&&F>>>0<2147483647&&(Xe=ul(F|0)|0,ye=ul(0)|0,ze=ye-Xe|0,nt=ze>>>0>(se+40|0)>>>0,!((Xe|0)==-1|nt^1|Xe>>>0>>0&((Xe|0)!=-1&(ye|0)!=-1)^1))&&(M=nt?ze:f,w=Xe,Pe=145),(Pe|0)==145){f=(A[7089]|0)+M|0,A[7089]=f,f>>>0>(A[7090]|0)>>>0&&(A[7090]=f),B=A[6987]|0;e:do if(B){for(f=28372;;){if(d=A[f>>2]|0,p=A[f+4>>2]|0,(w|0)==(d+p|0)){Pe=154;break}if(_=A[f+8>>2]|0,_)f=_;else break}if((Pe|0)==154&&(je=f+4|0,(A[f+12>>2]&8|0)==0)&&w>>>0>B>>>0&d>>>0<=B>>>0){A[je>>2]=p+M,Le=(A[6984]|0)+M|0,Xe=B+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,je=B+Xe|0,Xe=Le-Xe|0,A[6987]=je,A[6984]=Xe,A[je+4>>2]=Xe|1,A[B+Le+4>>2]=40,A[6988]=A[7103];break}for(w>>>0<(A[6985]|0)>>>0&&(A[6985]=w),p=w+M|0,f=28372;;){if((A[f>>2]|0)==(p|0)){Pe=162;break}if(d=A[f+8>>2]|0,d)f=d;else break}if((Pe|0)==162&&(A[f+12>>2]&8|0)==0){A[f>>2]=w,W=f+4|0,A[W>>2]=(A[W>>2]|0)+M,W=w+8|0,W=w+((W&7|0)==0?0:0-W&7)|0,f=p+8|0,f=p+((f&7|0)==0?0:0-f&7)|0,F=W+se|0,R=f-W-se|0,A[W+4>>2]=se|3;t:do if((B|0)==(f|0))Le=(A[6984]|0)+R|0,A[6984]=Le,A[6987]=F,A[F+4>>2]=Le|1;else{if((A[6986]|0)==(f|0)){Le=(A[6983]|0)+R|0,A[6983]=Le,A[6986]=F,A[F+4>>2]=Le|1,A[F+Le>>2]=Le;break}if(d=A[f+4>>2]|0,(d&3|0)==1){M=d&-8,_=d>>>3;n:do if(d>>>0<256)if(d=A[f+8>>2]|0,p=A[f+12>>2]|0,(p|0)==(d|0)){A[6981]=A[6981]&~(1<<_);break}else{A[d+12>>2]=p,A[p+8>>2]=d;break}else{w=A[f+24>>2]|0,d=A[f+12>>2]|0;do if((d|0)==(f|0)){if(p=f+16|0,_=p+4|0,d=A[_>>2]|0,d)p=_;else if(d=A[p>>2]|0,!d){d=0;break}for(;;)if(y=d+20|0,_=A[y>>2]|0,_)d=_,p=y;else if(y=d+16|0,_=A[y>>2]|0,_)d=_,p=y;else break;A[p>>2]=0}else Le=A[f+8>>2]|0,A[Le+12>>2]=d,A[d+8>>2]=Le;while(!1);if(!w)break;p=A[f+28>>2]|0,_=28228+(p<<2)|0;do if((A[_>>2]|0)!=(f|0)){if(Le=w+16|0,A[((A[Le>>2]|0)==(f|0)?Le:w+20|0)>>2]=d,!d)break n}else{if(A[_>>2]=d,d|0)break;A[6982]=A[6982]&~(1<>2]=w,p=f+16|0,_=A[p>>2]|0,_|0&&(A[d+16>>2]=_,A[_+24>>2]=d),p=A[p+4>>2]|0,!p)break;A[d+20>>2]=p,A[p+24>>2]=d}while(!1);f=f+M|0,y=M+R|0}else y=R;if(f=f+4|0,A[f>>2]=A[f>>2]&-2,A[F+4>>2]=y|1,A[F+y>>2]=y,f=y>>>3,y>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=F,A[f+12>>2]=F,A[F+8>>2]=f,A[F+12>>2]=p;break}f=y>>>8;do if(!f)_=0;else{if(y>>>0>16777215){_=31;break}je=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,_=14-(Xe|je|_)+(Le<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1}while(!1);if(f=28228+(_<<2)|0,A[F+28>>2]=_,d=F+16|0,A[d+4>>2]=0,A[d>>2]=0,d=A[6982]|0,p=1<<_,!(d&p)){A[6982]=d|p,A[f>>2]=F,A[F+24>>2]=f,A[F+12>>2]=F,A[F+8>>2]=F;break}f=A[f>>2]|0;n:do if((A[f+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(y|0)){f=d;break n}else _=_<<1,f=d;A[p>>2]=F,A[F+24>>2]=f,A[F+12>>2]=F,A[F+8>>2]=F;break t}while(!1);je=f+8|0,Le=A[je>>2]|0,A[Le+12>>2]=F,A[je>>2]=F,A[F+8>>2]=Le,A[F+12>>2]=f,A[F+24>>2]=0}while(!1);return Le=W+8|0,K=Ft,Le|0}for(f=28372;d=A[f>>2]|0,!(d>>>0<=B>>>0&&(Le=d+(A[f+4>>2]|0)|0,Le>>>0>B>>>0));)f=A[f+8>>2]|0;y=Le+-47|0,d=y+8|0,d=y+((d&7|0)==0?0:0-d&7)|0,y=B+16|0,d=d>>>0>>0?B:d,f=d+8|0,p=M+-40|0,Xe=w+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,je=w+Xe|0,Xe=p-Xe|0,A[6987]=je,A[6984]=Xe,A[je+4>>2]=Xe|1,A[w+p+4>>2]=40,A[6988]=A[7103],p=d+4|0,A[p>>2]=27,A[f>>2]=A[7093],A[f+4>>2]=A[7094],A[f+8>>2]=A[7095],A[f+12>>2]=A[7096],A[7093]=w,A[7094]=M,A[7096]=0,A[7095]=f,f=d+24|0;do je=f,f=f+4|0,A[f>>2]=7;while((je+8|0)>>>0>>0);if((d|0)!=(B|0)){if(w=d-B|0,A[p>>2]=A[p>>2]&-2,A[B+4>>2]=w|1,A[d>>2]=w,f=w>>>3,w>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=B,A[f+12>>2]=B,A[B+8>>2]=f,A[B+12>>2]=p;break}if(f=w>>>8,f?w>>>0>16777215?_=31:(je=(f+1048320|0)>>>16&8,Le=f<>>16&4,Le=Le<>>16&2,_=14-(Xe|je|_)+(Le<<_>>>15)|0,_=w>>>(_+7|0)&1|_<<1):_=0,p=28228+(_<<2)|0,A[B+28>>2]=_,A[B+20>>2]=0,A[y>>2]=0,f=A[6982]|0,d=1<<_,!(f&d)){A[6982]=f|d,A[p>>2]=B,A[B+24>>2]=p,A[B+12>>2]=B,A[B+8>>2]=B;break}f=A[p>>2]|0;t:do if((A[f+4>>2]&-8|0)!=(w|0)){for(_=w<<((_|0)==31?0:25-(_>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(w|0)){f=d;break t}else _=_<<1,f=d;A[p>>2]=B,A[B+24>>2]=f,A[B+12>>2]=B,A[B+8>>2]=B;break e}while(!1);je=f+8|0,Le=A[je>>2]|0,A[Le+12>>2]=B,A[je>>2]=B,A[B+8>>2]=Le,A[B+12>>2]=f,A[B+24>>2]=0}}else Le=A[6985]|0,(Le|0)==0|w>>>0>>0&&(A[6985]=w),A[7093]=w,A[7094]=M,A[7096]=0,A[6990]=A[7099],A[6989]=-1,A[6994]=27964,A[6993]=27964,A[6996]=27972,A[6995]=27972,A[6998]=27980,A[6997]=27980,A[7e3]=27988,A[6999]=27988,A[7002]=27996,A[7001]=27996,A[7004]=28004,A[7003]=28004,A[7006]=28012,A[7005]=28012,A[7008]=28020,A[7007]=28020,A[7010]=28028,A[7009]=28028,A[7012]=28036,A[7011]=28036,A[7014]=28044,A[7013]=28044,A[7016]=28052,A[7015]=28052,A[7018]=28060,A[7017]=28060,A[7020]=28068,A[7019]=28068,A[7022]=28076,A[7021]=28076,A[7024]=28084,A[7023]=28084,A[7026]=28092,A[7025]=28092,A[7028]=28100,A[7027]=28100,A[7030]=28108,A[7029]=28108,A[7032]=28116,A[7031]=28116,A[7034]=28124,A[7033]=28124,A[7036]=28132,A[7035]=28132,A[7038]=28140,A[7037]=28140,A[7040]=28148,A[7039]=28148,A[7042]=28156,A[7041]=28156,A[7044]=28164,A[7043]=28164,A[7046]=28172,A[7045]=28172,A[7048]=28180,A[7047]=28180,A[7050]=28188,A[7049]=28188,A[7052]=28196,A[7051]=28196,A[7054]=28204,A[7053]=28204,A[7056]=28212,A[7055]=28212,Le=M+-40|0,Xe=w+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,je=w+Xe|0,Xe=Le-Xe|0,A[6987]=je,A[6984]=Xe,A[je+4>>2]=Xe|1,A[w+Le+4>>2]=40,A[6988]=A[7103];while(!1);if(f=A[6984]|0,f>>>0>se>>>0)return Xe=f-se|0,A[6984]=Xe,Le=A[6987]|0,je=Le+se|0,A[6987]=je,A[je+4>>2]=Xe|1,A[Le+4>>2]=se|3,Le=Le+8|0,K=Ft,Le|0}return Le=kd()|0,A[Le>>2]=12,Le=0,K=Ft,Le|0}function vn(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(d){p=d+-8|0,y=A[6985]|0,d=A[d+-4>>2]|0,f=d&-8,B=p+f|0;do if(d&1)R=p,M=p;else{if(_=A[p>>2]|0,!(d&3)||(M=p+(0-_)|0,w=_+f|0,M>>>0>>0))return;if((A[6986]|0)==(M|0)){if(d=B+4|0,f=A[d>>2]|0,(f&3|0)!=3){R=M,f=w;break}A[6983]=w,A[d>>2]=f&-2,A[M+4>>2]=w|1,A[M+w>>2]=w;return}if(p=_>>>3,_>>>0<256)if(d=A[M+8>>2]|0,f=A[M+12>>2]|0,(f|0)==(d|0)){A[6981]=A[6981]&~(1<>2]=f,A[f+8>>2]=d,R=M,f=w;break}y=A[M+24>>2]|0,d=A[M+12>>2]|0;do if((d|0)==(M|0)){if(f=M+16|0,p=f+4|0,d=A[p>>2]|0,d)f=p;else if(d=A[f>>2]|0,!d){d=0;break}for(;;)if(_=d+20|0,p=A[_>>2]|0,p)d=p,f=_;else if(_=d+16|0,p=A[_>>2]|0,p)d=p,f=_;else break;A[f>>2]=0}else R=A[M+8>>2]|0,A[R+12>>2]=d,A[d+8>>2]=R;while(!1);if(y){if(f=A[M+28>>2]|0,p=28228+(f<<2)|0,(A[p>>2]|0)==(M|0)){if(A[p>>2]=d,!d){A[6982]=A[6982]&~(1<>2]|0)==(M|0)?R:y+20|0)>>2]=d,!d){R=M,f=w;break}A[d+24>>2]=y,f=M+16|0,p=A[f>>2]|0,p|0&&(A[d+16>>2]=p,A[p+24>>2]=d),f=A[f+4>>2]|0,f?(A[d+20>>2]=f,A[f+24>>2]=d,R=M,f=w):(R=M,f=w)}else R=M,f=w}while(!1);if(!(M>>>0>=B>>>0)&&(d=B+4|0,_=A[d>>2]|0,!!(_&1))){if(_&2)A[d>>2]=_&-2,A[R+4>>2]=f|1,A[M+f>>2]=f,y=f;else{if((A[6987]|0)==(B|0)){if(B=(A[6984]|0)+f|0,A[6984]=B,A[6987]=R,A[R+4>>2]=B|1,(R|0)!=(A[6986]|0))return;A[6986]=0,A[6983]=0;return}if((A[6986]|0)==(B|0)){B=(A[6983]|0)+f|0,A[6983]=B,A[6986]=M,A[R+4>>2]=B|1,A[M+B>>2]=B;return}y=(_&-8)+f|0,p=_>>>3;do if(_>>>0<256)if(f=A[B+8>>2]|0,d=A[B+12>>2]|0,(d|0)==(f|0)){A[6981]=A[6981]&~(1<>2]=d,A[d+8>>2]=f;break}else{w=A[B+24>>2]|0,d=A[B+12>>2]|0;do if((d|0)==(B|0)){if(f=B+16|0,p=f+4|0,d=A[p>>2]|0,d)f=p;else if(d=A[f>>2]|0,!d){p=0;break}for(;;)if(_=d+20|0,p=A[_>>2]|0,p)d=p,f=_;else if(_=d+16|0,p=A[_>>2]|0,p)d=p,f=_;else break;A[f>>2]=0,p=d}else p=A[B+8>>2]|0,A[p+12>>2]=d,A[d+8>>2]=p,p=d;while(!1);if(w|0){if(d=A[B+28>>2]|0,f=28228+(d<<2)|0,(A[f>>2]|0)==(B|0)){if(A[f>>2]=p,!p){A[6982]=A[6982]&~(1<>2]|0)==(B|0)?_:w+20|0)>>2]=p,!p)break;A[p+24>>2]=w,d=B+16|0,f=A[d>>2]|0,f|0&&(A[p+16>>2]=f,A[f+24>>2]=p),d=A[d+4>>2]|0,d|0&&(A[p+20>>2]=d,A[d+24>>2]=p)}}while(!1);if(A[R+4>>2]=y|1,A[M+y>>2]=y,(R|0)==(A[6986]|0)){A[6983]=y;return}}if(d=y>>>3,y>>>0<256){p=27964+(d<<1<<2)|0,f=A[6981]|0,d=1<>2]|0):(A[6981]=f|d,d=p,f=p+8|0),A[f>>2]=R,A[d+12>>2]=R,A[R+8>>2]=d,A[R+12>>2]=p;return}d=y>>>8,d?y>>>0>16777215?_=31:(M=(d+1048320|0)>>>16&8,B=d<>>16&4,B=B<>>16&2,_=14-(w|M|_)+(B<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1):_=0,d=28228+(_<<2)|0,A[R+28>>2]=_,A[R+20>>2]=0,A[R+16>>2]=0,f=A[6982]|0,p=1<<_;e:do if(!(f&p))A[6982]=f|p,A[d>>2]=R,A[R+24>>2]=d,A[R+12>>2]=R,A[R+8>>2]=R;else{d=A[d>>2]|0;t:do if((A[d+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=d+16+(_>>>31<<2)|0,f=A[p>>2]|0,!!f;)if((A[f+4>>2]&-8|0)==(y|0)){d=f;break t}else _=_<<1,d=f;A[p>>2]=R,A[R+24>>2]=d,A[R+12>>2]=R,A[R+8>>2]=R;break e}while(!1);M=d+8|0,B=A[M>>2]|0,A[B+12>>2]=R,A[M>>2]=R,A[R+8>>2]=B,A[R+12>>2]=d,A[R+24>>2]=0}while(!1);if(B=(A[6989]|0)+-1|0,A[6989]=B,!(B|0)){for(d=28380;d=A[d>>2]|0,d;)d=d+8|0;A[6989]=-1}}}}function Ys(d,f){d=d|0,f=f|0;var p=0;return d?(p=it(f,d)|0,(f|d)>>>0>65535&&(p=((p>>>0)/(d>>>0)|0|0)==(f|0)?p:-1)):p=0,d=Oo(p)|0,!d||!(A[d+-4>>2]&3)||ao(d|0,0,p|0)|0,d|0}function tn(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,p=d+p>>>0,he(f+_+(p>>>0>>0|0)>>>0|0),p|0|0}function Lr(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,_=f-_-(p>>>0>d>>>0|0)>>>0,he(_|0),d-p>>>0|0|0}function Yc(d){return d=d|0,(d?31-(Qt(d^d-1)|0)|0:32)|0}function Xu(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,se=0,_e=0,ve=0,ye=0;if(W=d,B=f,F=B,M=p,_e=_,R=_e,!F)return w=(y|0)!=0,R?w?(A[y>>2]=d|0,A[y+4>>2]=f&0,_e=0,y=0,he(_e|0),y|0):(_e=0,y=0,he(_e|0),y|0):(w&&(A[y>>2]=(W>>>0)%(M>>>0),A[y+4>>2]=0),_e=0,y=(W>>>0)/(M>>>0)>>>0,he(_e|0),y|0);w=(R|0)==0;do if(M){if(!w){if(w=(Qt(R|0)|0)-(Qt(F|0)|0)|0,w>>>0<=31){se=w+1|0,R=31-w|0,f=w-31>>31,M=se,d=W>>>(se>>>0)&f|F<>>(se>>>0)&f,w=0,R=W<>2]=d|0,A[y+4>>2]=B|f&0,_e=0,y=0,he(_e|0),y|0):(_e=0,y=0,he(_e|0),y|0)}if(w=M-1|0,w&M|0){R=(Qt(M|0)|0)+33-(Qt(F|0)|0)|0,ye=64-R|0,se=32-R|0,B=se>>31,ve=R-32|0,f=ve>>31,M=R,d=se-1>>31&F>>>(ve>>>0)|(F<>>(R>>>0))&f,f=f&F>>>(R>>>0),w=W<>>(ve>>>0))&B|W<>31;break}return y|0&&(A[y>>2]=w&W,A[y+4>>2]=0),(M|0)==1?(ve=B|f&0,ye=d|0|0,he(ve|0),ye|0):(ye=Yc(M|0)|0,ve=F>>>(ye>>>0)|0,ye=F<<32-ye|W>>>(ye>>>0)|0,he(ve|0),ye|0)}else{if(w)return y|0&&(A[y>>2]=(F>>>0)%(M>>>0),A[y+4>>2]=0),ve=0,ye=(F>>>0)/(M>>>0)>>>0,he(ve|0),ye|0;if(!W)return y|0&&(A[y>>2]=0,A[y+4>>2]=(F>>>0)%(R>>>0)),ve=0,ye=(F>>>0)/(R>>>0)>>>0,he(ve|0),ye|0;if(w=R-1|0,!(w&R))return y|0&&(A[y>>2]=d|0,A[y+4>>2]=w&F|f&0),ve=0,ye=F>>>((Yc(R|0)|0)>>>0),he(ve|0),ye|0;if(w=(Qt(R|0)|0)-(Qt(F|0)|0)|0,w>>>0<=30){f=w+1|0,R=31-w|0,M=f,d=F<>>(f>>>0),f=F>>>(f>>>0),w=0,R=W<>2]=d|0,A[y+4>>2]=B|f&0,ve=0,ye=0,he(ve|0),ye|0):(ve=0,ye=0,he(ve|0),ye|0)}while(!1);if(!M)F=R,B=0,R=0;else{se=p|0|0,W=_e|_&0,F=tn(se|0,W|0,-1,-1)|0,p=X()|0,B=R,R=0;do _=B,B=w>>>31|B<<1,w=R|w<<1,_=d<<1|_>>>31|0,_e=d>>>31|f<<1|0,Lr(F|0,p|0,_|0,_e|0)|0,ye=X()|0,ve=ye>>31|((ye|0)<0?-1:0)<<1,R=ve&1,d=Lr(_|0,_e|0,ve&se|0,(((ye|0)<0?-1:0)>>31|((ye|0)<0?-1:0)<<1)&W|0)|0,f=X()|0,M=M-1|0;while((M|0)!=0);F=B,B=0}return M=0,y|0&&(A[y>>2]=d,A[y+4>>2]=f),ve=(w|0)>>>31|(F|M)<<1|(M<<1|w>>>31)&0|B,ye=(w<<1|0)&-2|R,he(ve|0),ye|0}function Io(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;return F=f>>31|((f|0)<0?-1:0)<<1,B=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,w=_>>31|((_|0)<0?-1:0)<<1,y=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,R=Lr(F^d|0,B^f|0,F|0,B|0)|0,M=X()|0,d=w^F,f=y^B,Lr((Xu(R,M,Lr(w^p|0,y^_|0,w|0,y|0)|0,X()|0,0)|0)^d|0,(X()|0)^f|0,d|0,f|0)|0}function Qc(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return w=d&65535,y=f&65535,p=it(y,w)|0,_=d>>>16,d=(p>>>16)+(it(y,_)|0)|0,y=f>>>16,f=it(y,w)|0,he((d>>>16)+(it(y,_)|0)+(((d&65535)+f|0)>>>16)|0),d+f<<16|p&65535|0|0}function ur(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;return y=d,w=p,p=Qc(y,w)|0,d=X()|0,he((it(f,w)|0)+(it(_,y)|0)+d|d&0|0),p|0|0|0}function Kc(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;return y=K,K=K+16|0,R=y|0,M=f>>31|((f|0)<0?-1:0)<<1,w=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,F=_>>31|((_|0)<0?-1:0)<<1,B=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,d=Lr(M^d|0,w^f|0,M|0,w|0)|0,f=X()|0,Xu(d,f,Lr(F^p|0,B^_|0,F|0,B|0)|0,X()|0,R)|0,_=Lr(A[R>>2]^M|0,A[R+4>>2]^w|0,M|0,w|0)|0,p=X()|0,K=y,he(p|0),_|0}function Yu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;return w=K,K=K+16|0,y=w|0,Xu(d,f,p,_,y)|0,K=w,he(A[y+4>>2]|0),A[y>>2]|0|0}function N1(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f>>p|0),d>>>p|(f&(1<>p-32|0)}function Ct(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f>>>p|0),d>>>p|(f&(1<>>p-32|0)}function It(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f<>>32-p|0),d<=0?+$n(d+.5):+rt(d-.5)}function Ol(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if((p|0)>=8192)return Tn(d|0,f|0,p|0)|0,d|0;if(w=d|0,y=d+p|0,(d&3)==(f&3)){for(;d&3;){if(!p)return w|0;xt[d>>0]=xt[f>>0]|0,d=d+1|0,f=f+1|0,p=p-1|0}for(p=y&-4|0,_=p-64|0;(d|0)<=(_|0);)A[d>>2]=A[f>>2],A[d+4>>2]=A[f+4>>2],A[d+8>>2]=A[f+8>>2],A[d+12>>2]=A[f+12>>2],A[d+16>>2]=A[f+16>>2],A[d+20>>2]=A[f+20>>2],A[d+24>>2]=A[f+24>>2],A[d+28>>2]=A[f+28>>2],A[d+32>>2]=A[f+32>>2],A[d+36>>2]=A[f+36>>2],A[d+40>>2]=A[f+40>>2],A[d+44>>2]=A[f+44>>2],A[d+48>>2]=A[f+48>>2],A[d+52>>2]=A[f+52>>2],A[d+56>>2]=A[f+56>>2],A[d+60>>2]=A[f+60>>2],d=d+64|0,f=f+64|0;for(;(d|0)<(p|0);)A[d>>2]=A[f>>2],d=d+4|0,f=f+4|0}else for(p=y-4|0;(d|0)<(p|0);)xt[d>>0]=xt[f>>0]|0,xt[d+1>>0]=xt[f+1>>0]|0,xt[d+2>>0]=xt[f+2>>0]|0,xt[d+3>>0]=xt[f+3>>0]|0,d=d+4|0,f=f+4|0;for(;(d|0)<(y|0);)xt[d>>0]=xt[f>>0]|0,d=d+1|0,f=f+1|0;return w|0}function ao(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(w=d+p|0,f=f&255,(p|0)>=67){for(;d&3;)xt[d>>0]=f,d=d+1|0;for(_=w&-4|0,M=f|f<<8|f<<16|f<<24,y=_-64|0;(d|0)<=(y|0);)A[d>>2]=M,A[d+4>>2]=M,A[d+8>>2]=M,A[d+12>>2]=M,A[d+16>>2]=M,A[d+20>>2]=M,A[d+24>>2]=M,A[d+28>>2]=M,A[d+32>>2]=M,A[d+36>>2]=M,A[d+40>>2]=M,A[d+44>>2]=M,A[d+48>>2]=M,A[d+52>>2]=M,A[d+56>>2]=M,A[d+60>>2]=M,d=d+64|0;for(;(d|0)<(_|0);)A[d>>2]=M,d=d+4|0}for(;(d|0)<(w|0);)xt[d>>0]=f,d=d+1|0;return w-p|0}function cf(d){return d=+d,d>=0?+$n(d+.5):+rt(d-.5)}function ul(d){d=d|0;var f=0,p=0,_=0;return _=sn()|0,p=A[Wn>>2]|0,f=p+d|0,(d|0)>0&(f|0)<(p|0)|(f|0)<0?(xi(f|0)|0,en(12),-1):(f|0)>(_|0)&&!(Rn(f|0)|0)?(en(12),-1):(A[Wn>>2]=f,p|0)}return{___divdi3:Io,___muldi3:ur,___remdi3:Kc,___uremdi3:Yu,_areNeighborCells:px,_bitshift64Ashr:N1,_bitshift64Lshr:Ct,_bitshift64Shl:It,_calloc:Ys,_cellAreaKm2:dp,_cellAreaM2:Nd,_cellAreaRads2:Ll,_cellToBoundary:Pl,_cellToCenterChild:Md,_cellToChildPos:cp,_cellToChildren:v1,_cellToChildrenSize:nf,_cellToLatLng:Dl,_cellToLocalIj:M1,_cellToParent:Lu,_cellToVertex:Xs,_cellToVertexes:Hu,_cellsToDirectedEdge:d1,_cellsToLinkedMultiPolygon:cx,_childPosToCell:b1,_compactCells:ap,_constructCell:wx,_destroyLinkedMultiPolygon:Gu,_directedEdgeToBoundary:Sd,_directedEdgeToCells:vx,_edgeLengthKm:Ap,_edgeLengthM:zu,_edgeLengthRads:Rd,_emscripten_replace_memory:hn,_free:vn,_getBaseCellNumber:m1,_getDirectedEdgeDestination:gx,_getDirectedEdgeOrigin:mx,_getHexagonAreaAvgKm2:hp,_getHexagonAreaAvgM2:w1,_getHexagonEdgeLengthAvgKm:fp,_getHexagonEdgeLengthAvgM:ro,_getIcosahedronFaces:Ou,_getIndexDigit:Sx,_getNumCells:ku,_getPentagons:Iu,_getRes0Cells:Yh,_getResolution:Wc,_greatCircleDistanceKm:Xc,_greatCircleDistanceM:Ex,_greatCircleDistanceRads:S1,_gridDisk:ys,_gridDiskDistances:Vr,_gridDistance:qu,_gridPathCells:E1,_gridPathCellsSize:pp,_gridRing:_r,_gridRingUnsafe:Jr,_i64Add:tn,_i64Subtract:Lr,_isPentagon:wi,_isResClassIII:x1,_isValidCell:Td,_isValidDirectedEdge:A1,_isValidIndex:g1,_isValidVertex:al,_latLngToCell:Ed,_llvm_ctlz_i64:of,_llvm_maxnum_f64:lf,_llvm_minnum_f64:uf,_llvm_round_f64:ll,_localIjToCell:Pd,_malloc:Oo,_maxFaceCount:Mx,_maxGridDiskSize:Ps,_maxPolygonToCellsSize:ux,_maxPolygonToCellsSizeExperimental:sf,_memcpy:Ol,_memset:ao,_originToDirectedEdges:_x,_pentagonCount:up,_polygonToCells:i1,_polygonToCellsExperimental:Ud,_readInt64AsDoubleFromPointer:gp,_res0CellCount:r1,_round:cf,_sbrk:ul,_sizeOfCellBoundary:cs,_sizeOfCoordIJ:Na,_sizeOfGeoLoop:er,_sizeOfGeoPolygon:Ai,_sizeOfH3Index:mp,_sizeOfLatLng:C1,_sizeOfLinkedGeoPolygon:Ul,_uncompactCells:_1,_uncompactCellsSize:y1,_vertexToLatLng:sl,establishStackSpace:vr,stackAlloc:Zt,stackRestore:ui,stackSave:gr}})(Jt,In,Q);e.___divdi3=ge.___divdi3,e.___muldi3=ge.___muldi3,e.___remdi3=ge.___remdi3,e.___uremdi3=ge.___uremdi3,e._areNeighborCells=ge._areNeighborCells,e._bitshift64Ashr=ge._bitshift64Ashr,e._bitshift64Lshr=ge._bitshift64Lshr,e._bitshift64Shl=ge._bitshift64Shl,e._calloc=ge._calloc,e._cellAreaKm2=ge._cellAreaKm2,e._cellAreaM2=ge._cellAreaM2,e._cellAreaRads2=ge._cellAreaRads2,e._cellToBoundary=ge._cellToBoundary,e._cellToCenterChild=ge._cellToCenterChild,e._cellToChildPos=ge._cellToChildPos,e._cellToChildren=ge._cellToChildren,e._cellToChildrenSize=ge._cellToChildrenSize,e._cellToLatLng=ge._cellToLatLng,e._cellToLocalIj=ge._cellToLocalIj,e._cellToParent=ge._cellToParent,e._cellToVertex=ge._cellToVertex,e._cellToVertexes=ge._cellToVertexes,e._cellsToDirectedEdge=ge._cellsToDirectedEdge,e._cellsToLinkedMultiPolygon=ge._cellsToLinkedMultiPolygon,e._childPosToCell=ge._childPosToCell,e._compactCells=ge._compactCells,e._constructCell=ge._constructCell,e._destroyLinkedMultiPolygon=ge._destroyLinkedMultiPolygon,e._directedEdgeToBoundary=ge._directedEdgeToBoundary,e._directedEdgeToCells=ge._directedEdgeToCells,e._edgeLengthKm=ge._edgeLengthKm,e._edgeLengthM=ge._edgeLengthM,e._edgeLengthRads=ge._edgeLengthRads;var Ot=e._emscripten_replace_memory=ge._emscripten_replace_memory;e._free=ge._free,e._getBaseCellNumber=ge._getBaseCellNumber,e._getDirectedEdgeDestination=ge._getDirectedEdgeDestination,e._getDirectedEdgeOrigin=ge._getDirectedEdgeOrigin,e._getHexagonAreaAvgKm2=ge._getHexagonAreaAvgKm2,e._getHexagonAreaAvgM2=ge._getHexagonAreaAvgM2,e._getHexagonEdgeLengthAvgKm=ge._getHexagonEdgeLengthAvgKm,e._getHexagonEdgeLengthAvgM=ge._getHexagonEdgeLengthAvgM,e._getIcosahedronFaces=ge._getIcosahedronFaces,e._getIndexDigit=ge._getIndexDigit,e._getNumCells=ge._getNumCells,e._getPentagons=ge._getPentagons,e._getRes0Cells=ge._getRes0Cells,e._getResolution=ge._getResolution,e._greatCircleDistanceKm=ge._greatCircleDistanceKm,e._greatCircleDistanceM=ge._greatCircleDistanceM,e._greatCircleDistanceRads=ge._greatCircleDistanceRads,e._gridDisk=ge._gridDisk,e._gridDiskDistances=ge._gridDiskDistances,e._gridDistance=ge._gridDistance,e._gridPathCells=ge._gridPathCells,e._gridPathCellsSize=ge._gridPathCellsSize,e._gridRing=ge._gridRing,e._gridRingUnsafe=ge._gridRingUnsafe,e._i64Add=ge._i64Add,e._i64Subtract=ge._i64Subtract,e._isPentagon=ge._isPentagon,e._isResClassIII=ge._isResClassIII,e._isValidCell=ge._isValidCell,e._isValidDirectedEdge=ge._isValidDirectedEdge,e._isValidIndex=ge._isValidIndex,e._isValidVertex=ge._isValidVertex,e._latLngToCell=ge._latLngToCell,e._llvm_ctlz_i64=ge._llvm_ctlz_i64,e._llvm_maxnum_f64=ge._llvm_maxnum_f64,e._llvm_minnum_f64=ge._llvm_minnum_f64,e._llvm_round_f64=ge._llvm_round_f64,e._localIjToCell=ge._localIjToCell,e._malloc=ge._malloc,e._maxFaceCount=ge._maxFaceCount,e._maxGridDiskSize=ge._maxGridDiskSize,e._maxPolygonToCellsSize=ge._maxPolygonToCellsSize,e._maxPolygonToCellsSizeExperimental=ge._maxPolygonToCellsSizeExperimental,e._memcpy=ge._memcpy,e._memset=ge._memset,e._originToDirectedEdges=ge._originToDirectedEdges,e._pentagonCount=ge._pentagonCount,e._polygonToCells=ge._polygonToCells,e._polygonToCellsExperimental=ge._polygonToCellsExperimental,e._readInt64AsDoubleFromPointer=ge._readInt64AsDoubleFromPointer,e._res0CellCount=ge._res0CellCount,e._round=ge._round,e._sbrk=ge._sbrk,e._sizeOfCellBoundary=ge._sizeOfCellBoundary,e._sizeOfCoordIJ=ge._sizeOfCoordIJ,e._sizeOfGeoLoop=ge._sizeOfGeoLoop,e._sizeOfGeoPolygon=ge._sizeOfGeoPolygon,e._sizeOfH3Index=ge._sizeOfH3Index,e._sizeOfLatLng=ge._sizeOfLatLng,e._sizeOfLinkedGeoPolygon=ge._sizeOfLinkedGeoPolygon,e._uncompactCells=ge._uncompactCells,e._uncompactCellsSize=ge._uncompactCellsSize,e._vertexToLatLng=ge._vertexToLatLng,e.establishStackSpace=ge.establishStackSpace;var ot=e.stackAlloc=ge.stackAlloc,Tt=e.stackRestore=ge.stackRestore,Ht=e.stackSave=ge.stackSave;if(e.asm=ge,e.cwrap=U,e.setValue=S,e.getValue=T,Ae){be(Ae)||(Ae=s(Ae));{Xt();var Yt=function(Ze){Ze.byteLength&&(Ze=new Uint8Array(Ze)),ne.set(Ze,x),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,pt()},pn=function(){a(Ae,Yt,function(){throw"could not load memory initializer "+Ae})},$e=jt(Ae);if($e)Yt($e.buffer);else if(e.memoryInitializerRequest){var St=function(){var Ze=e.memoryInitializerRequest,dt=Ze.response;if(Ze.status!==200&&Ze.status!==0){var Vt=jt(e.memoryInitializerRequestURL);if(Vt)dt=Vt.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+Ze.status+", retrying "+Ae),pn();return}}Yt(dt)};e.memoryInitializerRequest.response?setTimeout(St,0):e.memoryInitializerRequest.addEventListener("load",St)}else pn()}}var Kt;_t=function Ze(){Kt||wn(),Kt||(_t=Ze)};function wn(Ze){if(Gt>0||(He(),Gt>0))return;function dt(){Kt||(Kt=!0,!N&&(Rt(),Et(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),zt()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),dt()},1)):dt()}e.run=wn;function qn(Ze){throw e.onAbort&&e.onAbort(Ze),Ze+="",l(Ze),u(Ze),N=!0,"abort("+Ze+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=qn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return wn(),i})(typeof _i=="object"?_i:{}),Un="number",Pn=Un,xA=Un,zn=Un,Gn=Un,Es=Un,ln=Un,iZ=[["sizeOfH3Index",Un],["sizeOfLatLng",Un],["sizeOfCellBoundary",Un],["sizeOfGeoLoop",Un],["sizeOfGeoPolygon",Un],["sizeOfLinkedGeoPolygon",Un],["sizeOfCoordIJ",Un],["readInt64AsDoubleFromPointer",Un],["isValidCell",xA,[zn,Gn]],["isValidIndex",xA,[zn,Gn]],["latLngToCell",Pn,[Un,Un,Es,ln]],["cellToLatLng",Pn,[zn,Gn,ln]],["cellToBoundary",Pn,[zn,Gn,ln]],["maxGridDiskSize",Pn,[Un,ln]],["gridDisk",Pn,[zn,Gn,Un,ln]],["gridDiskDistances",Pn,[zn,Gn,Un,ln,ln]],["gridRing",Pn,[zn,Gn,Un,ln]],["gridRingUnsafe",Pn,[zn,Gn,Un,ln]],["maxPolygonToCellsSize",Pn,[ln,Es,Un,ln]],["polygonToCells",Pn,[ln,Es,Un,ln]],["maxPolygonToCellsSizeExperimental",Pn,[ln,Es,Un,ln]],["polygonToCellsExperimental",Pn,[ln,Es,Un,Un,Un,ln]],["cellsToLinkedMultiPolygon",Pn,[ln,Un,ln]],["destroyLinkedMultiPolygon",null,[ln]],["compactCells",Pn,[ln,ln,Un,Un]],["uncompactCells",Pn,[ln,Un,Un,ln,Un,Es]],["uncompactCellsSize",Pn,[ln,Un,Un,Es,ln]],["isPentagon",xA,[zn,Gn]],["isResClassIII",xA,[zn,Gn]],["getBaseCellNumber",Un,[zn,Gn]],["getResolution",Un,[zn,Gn]],["getIndexDigit",Un,[zn,Gn,Un]],["constructCell",Pn,[Un,Un,ln,ln]],["maxFaceCount",Pn,[zn,Gn,ln]],["getIcosahedronFaces",Pn,[zn,Gn,ln]],["cellToParent",Pn,[zn,Gn,Es,ln]],["cellToChildren",Pn,[zn,Gn,Es,ln]],["cellToCenterChild",Pn,[zn,Gn,Es,ln]],["cellToChildrenSize",Pn,[zn,Gn,Es,ln]],["cellToChildPos",Pn,[zn,Gn,Es,ln]],["childPosToCell",Pn,[Un,Un,zn,Gn,Es,ln]],["areNeighborCells",Pn,[zn,Gn,zn,Gn,ln]],["cellsToDirectedEdge",Pn,[zn,Gn,zn,Gn,ln]],["getDirectedEdgeOrigin",Pn,[zn,Gn,ln]],["getDirectedEdgeDestination",Pn,[zn,Gn,ln]],["isValidDirectedEdge",xA,[zn,Gn]],["directedEdgeToCells",Pn,[zn,Gn,ln]],["originToDirectedEdges",Pn,[zn,Gn,ln]],["directedEdgeToBoundary",Pn,[zn,Gn,ln]],["gridDistance",Pn,[zn,Gn,zn,Gn,ln]],["gridPathCells",Pn,[zn,Gn,zn,Gn,ln]],["gridPathCellsSize",Pn,[zn,Gn,zn,Gn,ln]],["cellToLocalIj",Pn,[zn,Gn,zn,Gn,Un,ln]],["localIjToCell",Pn,[zn,Gn,ln,Un,ln]],["getHexagonAreaAvgM2",Pn,[Es,ln]],["getHexagonAreaAvgKm2",Pn,[Es,ln]],["getHexagonEdgeLengthAvgM",Pn,[Es,ln]],["getHexagonEdgeLengthAvgKm",Pn,[Es,ln]],["greatCircleDistanceM",Un,[ln,ln]],["greatCircleDistanceKm",Un,[ln,ln]],["greatCircleDistanceRads",Un,[ln,ln]],["cellAreaM2",Pn,[zn,Gn,ln]],["cellAreaKm2",Pn,[zn,Gn,ln]],["cellAreaRads2",Pn,[zn,Gn,ln]],["edgeLengthM",Pn,[zn,Gn,ln]],["edgeLengthKm",Pn,[zn,Gn,ln]],["edgeLengthRads",Pn,[zn,Gn,ln]],["getNumCells",Pn,[Es,ln]],["getRes0Cells",Pn,[ln]],["res0CellCount",Un],["getPentagons",Pn,[Un,ln]],["pentagonCount",Un],["cellToVertex",Pn,[zn,Gn,Un,ln]],["cellToVertexes",Pn,[zn,Gn,ln]],["vertexToLatLng",Pn,[zn,Gn,ln]],["isValidVertex",xA,[zn,Gn]]],rZ=0,sZ=1,aZ=2,oZ=3,wP=4,lZ=5,uZ=6,cZ=7,hZ=8,fZ=9,dZ=10,AZ=11,pZ=12,mZ=13,gZ=14,vZ=15,_Z=16,yZ=17,xZ=18,bZ=19,Kr={};Kr[rZ]="Success";Kr[sZ]="The operation failed but a more specific error is not available";Kr[aZ]="Argument was outside of acceptable range";Kr[oZ]="Latitude or longitude arguments were outside of acceptable range";Kr[wP]="Resolution argument was outside of acceptable range";Kr[lZ]="Cell argument was not valid";Kr[uZ]="Directed edge argument was not valid";Kr[cZ]="Undirected edge argument was not valid";Kr[hZ]="Vertex argument was not valid";Kr[fZ]="Pentagon distortion was encountered";Kr[dZ]="Duplicate input";Kr[AZ]="Cell arguments were not neighbors";Kr[pZ]="Cell arguments had incompatible resolutions";Kr[mZ]="Memory allocation failed";Kr[gZ]="Bounds of provided memory were insufficient";Kr[vZ]="Mode or flags argument was not valid";Kr[_Z]="Index argument was not valid";Kr[yZ]="Base cell number was outside of acceptable range";Kr[xZ]="Child indexing digits invalid";Kr[bZ]="Child indexing digits refer to a deleted subsequence";var SZ=1e3,TP=1001,MP=1002,Ey={};Ey[SZ]="Unknown unit";Ey[TP]="Array length out of bounds";Ey[MP]="Got unexpected null value for H3 index";var wZ="Unknown error";function EP(i,e,t){var n=t&&"value"in t,r=new Error((i[e]||wZ)+" (code: "+e+(n?", value: "+t.value:"")+")");return r.code=e,r}function CP(i,e){var t=arguments.length===2?{value:e}:{};return EP(Kr,i,t)}function NP(i,e){var t=arguments.length===2?{value:e}:{};return EP(Ey,i,t)}function mg(i){if(i!==0)throw CP(i)}var Ka={};iZ.forEach(function(e){Ka[e[0]]=_i.cwrap.apply(_i,e)});var VA=16,gg=4,N0=8,TZ=8,V_=Ka.sizeOfH3Index(),NM=Ka.sizeOfLatLng(),MZ=Ka.sizeOfCellBoundary(),EZ=Ka.sizeOfGeoPolygon(),Dm=Ka.sizeOfGeoLoop();Ka.sizeOfLinkedGeoPolygon();Ka.sizeOfCoordIJ();function CZ(i){if(typeof i!="number"||i<0||i>15||Math.floor(i)!==i)throw CP(wP,i);return i}function NZ(i){if(!i)throw NP(MP);return i}var RZ=Math.pow(2,32)-1;function DZ(i){if(i>RZ)throw NP(TP,i);return i}var PZ=/[^0-9a-fA-F]/;function RP(i){if(Array.isArray(i)&&i.length===2&&Number.isInteger(i[0])&&Number.isInteger(i[1]))return i;if(typeof i!="string"||PZ.test(i))return[0,0];var e=parseInt(i.substring(0,i.length-8),VA),t=parseInt(i.substring(i.length-8),VA);return[t,e]}function RR(i){if(i>=0)return i.toString(VA);i=i&2147483647;var e=DP(8,i.toString(VA)),t=(parseInt(e[0],VA)+8).toString(VA);return e=t+e.substring(1),e}function LZ(i,e){return RR(e)+DP(8,RR(i))}function DP(i,e){for(var t=i-e.length,n="",r=0;r0){l=_i._calloc(t,Dm);for(var u=0;u0){for(var a=_i.getValue(i+n,"i32"),l=0;l0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,r=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(l){return{keyAccessor:l,isProp:!(l instanceof Function)}}),s=i.reduce(function(l,u){var h=l,m=u;return r.forEach(function(v,x){var S=v.keyAccessor,T=v.isProp,N;if(T){var C=m,E=C[S],O=QK(C,[S].map(tZ));N=E,m=O}else N=S(m,x);x+11&&arguments[1]!==void 0?arguments[1]:1;h===r.length?Object.keys(u).forEach(function(m){return u[m]=t(u[m])}):Object.values(u).forEach(function(m){return l(m,h+1)})})(s);var a=s;return n&&(a=[],(function l(u){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];h.length===r.length?a.push({keys:h,vals:u}):Object.entries(u).forEach(function(m){var v=ZK(m,2),x=v[0],S=v[1];return l(S,[].concat(JK(h),[x]))})})(s),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a}),_i=(function(i){i=i||{};var e=typeof i<"u"?i:{},t={},n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);var r="";function s(Je){return e.locateFile?e.locateFile(Je,r):r+Je}var a;typeof document<"u"&&document.currentScript&&(r=document.currentScript.src),r.indexOf("blob:")!==0?r=r.substr(0,r.lastIndexOf("/")+1):r="",a=function(dt,Vt,xt){var A=new XMLHttpRequest;A.open("GET",dt,!0),A.responseType="arraybuffer",A.onload=function(){if(A.status==200||A.status==0&&A.response){Vt(A.response);return}var Vn=jt(dt);if(Vn){Vt(Vn.buffer);return}xt()},A.onerror=xt,A.send(null)};var l=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);t=null,e.arguments&&e.arguments;var h=0,m=function(Je){h=Je},v=function(){return h},x=8;function S(Je,dt,Vt,xt){switch(Vt=Vt||"i8",Vt.charAt(Vt.length-1)==="*"&&(Vt="i32"),Vt){case"i1":J[Je>>0]=dt;break;case"i8":J[Je>>0]=dt;break;case"i16":le[Je>>1]=dt;break;case"i32":re[Je>>2]=dt;break;case"i64":Ue=[dt>>>0,(Oe=dt,+ht(Oe)>=1?Oe>0?(_t(+$t(Oe/4294967296),4294967295)|0)>>>0:~~+fe((Oe-+(~~Oe>>>0))/4294967296)>>>0:0)],re[Je>>2]=Ue[0],re[Je+4>>2]=Ue[1];break;case"float":Z[Je>>2]=dt;break;case"double":ne[Je>>3]=dt;break;default:qn("invalid type for setValue: "+Vt)}}function T(Je,dt,Vt){switch(dt=dt||"i8",dt.charAt(dt.length-1)==="*"&&(dt="i32"),dt){case"i1":return J[Je>>0];case"i8":return J[Je>>0];case"i16":return le[Je>>1];case"i32":return re[Je>>2];case"i64":return re[Je>>2];case"float":return Z[Je>>2];case"double":return ne[Je>>3];default:qn("invalid type for getValue: "+dt)}return null}var N=!1;function C(Je,dt){Je||qn("Assertion failed: "+dt)}function E(Je){var dt=e["_"+Je];return C(dt,"Cannot call unknown function "+Je+", make sure it is exported"),dt}function O(Je,dt,Vt,xt,A){var te={string:function(mn){var Er=0;if(mn!=null&&mn!==0){var Wi=(mn.length<<2)+1;Er=ot(Wi),H(mn,Er,Wi)}return Er},array:function(mn){var Er=ot(mn.length);return q(mn,Er),Er}};function Vn(mn){return dt==="string"?z(mn):dt==="boolean"?!!mn:mn}var Wn=E(Je),$n=[],dn=0;if(xt)for(var Fn=0;Fn=xt);)++A;if(A-dt>16&&Je.subarray&&I)return I.decode(Je.subarray(dt,A));for(var te="";dt>10,56320|dn&1023)}}return te}function z(Je,dt){return Je?j(ie,Je,dt):""}function G(Je,dt,Vt,xt){if(!(xt>0))return 0;for(var A=Vt,te=Vt+xt-1,Vn=0;Vn=55296&&Wn<=57343){var $n=Je.charCodeAt(++Vn);Wn=65536+((Wn&1023)<<10)|$n&1023}if(Wn<=127){if(Vt>=te)break;dt[Vt++]=Wn}else if(Wn<=2047){if(Vt+1>=te)break;dt[Vt++]=192|Wn>>6,dt[Vt++]=128|Wn&63}else if(Wn<=65535){if(Vt+2>=te)break;dt[Vt++]=224|Wn>>12,dt[Vt++]=128|Wn>>6&63,dt[Vt++]=128|Wn&63}else{if(Vt+3>=te)break;dt[Vt++]=240|Wn>>18,dt[Vt++]=128|Wn>>12&63,dt[Vt++]=128|Wn>>6&63,dt[Vt++]=128|Wn&63}}return dt[Vt]=0,Vt-A}function H(Je,dt,Vt){return G(Je,ie,dt,Vt)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function q(Je,dt){J.set(Je,dt)}function V(Je,dt){return Je%dt>0&&(Je+=dt-Je%dt),Je}var Q,J,ie,le,re,Z,ne;function de(Je){Q=Je,e.HEAP8=J=new Int8Array(Je),e.HEAP16=le=new Int16Array(Je),e.HEAP32=re=new Int32Array(Je),e.HEAPU8=ie=new Uint8Array(Je),e.HEAPU16=new Uint16Array(Je),e.HEAPU32=new Uint32Array(Je),e.HEAPF32=Z=new Float32Array(Je),e.HEAPF64=ne=new Float64Array(Je)}var be=5271536,Te=28624,ae=e.TOTAL_MEMORY||33554432;e.buffer?Q=e.buffer:Q=new ArrayBuffer(ae),ae=Q.byteLength,de(Q),re[Te>>2]=be;function Me(Je){for(;Je.length>0;){var dt=Je.shift();if(typeof dt=="function"){dt();continue}var Vt=dt.func;typeof Vt=="number"?dt.arg===void 0?e.dynCall_v(Vt):e.dynCall_vi(Vt,dt.arg):Vt(dt.arg===void 0?null:dt.arg)}}var Ve=[],Ce=[],Fe=[],tt=[];function je(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Ut(e.preRun.shift());Me(Ve)}function Rt(){Me(Ce)}function Et(){Me(Fe)}function Ft(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Ke(e.postRun.shift());Me(tt)}function Ut(Je){Ve.unshift(Je)}function Ke(Je){tt.unshift(Je)}var ht=Math.abs,fe=Math.ceil,$t=Math.floor,_t=Math.min,Gt=0,yt=null;function Ht(Je){Gt++,e.monitorRunDependencies&&e.monitorRunDependencies(Gt)}function pt(Je){if(Gt--,e.monitorRunDependencies&&e.monitorRunDependencies(Gt),Gt==0&&yt){var dt=yt;yt=null,dt()}}e.preloadedImages={},e.preloadedAudios={};var Ae=null,k="data:application/octet-stream;base64,";function xe(Je){return String.prototype.startsWith?Je.startsWith(k):Je.indexOf(k)===0}var Oe,Ue;Ae="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var ee=28640;function we(Je,dt,Vt,xt){qn("Assertion failed: "+z(Je)+", at: "+[dt?z(dt):"unknown filename",Vt,xt?z(xt):"unknown function"])}function Re(){return J.length}function We(Je,dt,Vt){ie.set(ie.subarray(dt,dt+Vt),Je)}function Se(Je){return e.___errno_location&&(re[e.___errno_location()>>2]=Je),Je}function Le(Je){qn("OOM")}function ct(Je){try{var dt=new ArrayBuffer(Je);return dt.byteLength!=Je?void 0:(new Int8Array(dt).set(J),Bt(dt),de(dt),1)}catch{}}function Dt(Je){var dt=Re(),Vt=16777216,xt=2147483648-Vt;if(Je>xt)return!1;for(var A=16777216,te=Math.max(dt,A);te>4,A=(Wn&15)<<4|$n>>2,te=($n&3)<<6|dn,Vt=Vt+String.fromCharCode(xt),$n!==64&&(Vt=Vt+String.fromCharCode(A)),dn!==64&&(Vt=Vt+String.fromCharCode(te));while(Fn13780509?(f=ku(15,f)|0,f|0):(p=((d|0)<0)<<31>>31,y=ur(d|0,p|0,3,0)|0,_=X()|0,p=tn(d|0,p|0,1,0)|0,p=ur(y|0,_|0,p|0,X()|0)|0,p=tn(p|0,X()|0,1,0)|0,d=X()|0,A[f>>2]=p,A[f+4>>2]=d,f=0,f|0)}function ys(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,Vr(d,f,p,_,0)|0}function Vr(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0;if(B=K,K=K+16|0,M=B,!(Di(d,f,p,_,y)|0))return _=0,K=B,_|0;do if((p|0)>=0){if((p|0)>13780509){if(w=ku(15,M)|0,w|0)break;R=M,M=A[R>>2]|0,R=A[R+4>>2]|0}else w=((p|0)<0)<<31>>31,F=ur(p|0,w|0,3,0)|0,R=X()|0,w=tn(p|0,w|0,1,0)|0,w=ur(F|0,R|0,w|0,X()|0)|0,w=tn(w|0,X()|0,1,0)|0,R=X()|0,A[M>>2]=w,A[M+4>>2]=R,M=w;if(ao(_|0,0,M<<3|0)|0,y|0){ao(y|0,0,M<<2|0)|0,w=sr(d,f,p,_,y,M,R,0)|0;break}w=Ys(M,4)|0,w?(F=sr(d,f,p,_,w,M,R,0)|0,vn(w),w=F):w=13}else w=2;while(!1);return F=w,K=B,F|0}function Di(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0;if(De=K,K=K+16|0,ge=De,_e=De+8|0,ve=ge,A[ve>>2]=d,A[ve+4>>2]=f,(p|0)<0)return _e=2,K=De,_e|0;if(w=_,A[w>>2]=d,A[w+4>>2]=f,w=(y|0)!=0,w&&(A[y>>2]=0),wi(d,f)|0)return _e=9,K=De,_e|0;A[_e>>2]=0;e:do if((p|0)>=1)if(w)for(W=1,F=0,oe=0,ve=1,w=d;;){if(!(F|oe)){if(w=bi(w,f,4,_e,ge)|0,w|0)break e;if(f=ge,w=A[f>>2]|0,f=A[f+4>>2]|0,wi(w,f)|0){w=9;break e}}if(w=bi(w,f,A[26800+(oe<<2)>>2]|0,_e,ge)|0,w|0)break e;if(f=ge,w=A[f>>2]|0,f=A[f+4>>2]|0,d=_+(W<<3)|0,A[d>>2]=w,A[d+4>>2]=f,A[y+(W<<2)>>2]=ve,d=F+1|0,M=(d|0)==(ve|0),R=oe+1|0,B=(R|0)==6,wi(w,f)|0){w=9;break e}if(ve=ve+(B&M&1)|0,(ve|0)>(p|0)){w=0;break}else W=W+1|0,F=M?0:d,oe=M?B?0:R:oe}else for(W=1,F=0,oe=0,ve=1,w=d;;){if(!(F|oe)){if(w=bi(w,f,4,_e,ge)|0,w|0)break e;if(f=ge,w=A[f>>2]|0,f=A[f+4>>2]|0,wi(w,f)|0){w=9;break e}}if(w=bi(w,f,A[26800+(oe<<2)>>2]|0,_e,ge)|0,w|0)break e;if(f=ge,w=A[f>>2]|0,f=A[f+4>>2]|0,d=_+(W<<3)|0,A[d>>2]=w,A[d+4>>2]=f,d=F+1|0,M=(d|0)==(ve|0),R=oe+1|0,B=(R|0)==6,wi(w,f)|0){w=9;break e}if(ve=ve+(B&M&1)|0,(ve|0)>(p|0)){w=0;break}else W=W+1|0,F=M?0:d,oe=M?B?0:R:oe}else w=0;while(!1);return _e=w,K=De,_e|0}function sr(d,f,p,_,y,w,M,R){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0,R=R|0;var B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0;if(De=K,K=K+16|0,ge=De+8|0,_e=De,B=Yu(d|0,f|0,w|0,M|0)|0,W=X()|0,oe=_+(B<<3)|0,ze=oe,nt=A[ze>>2]|0,ze=A[ze+4>>2]|0,F=(nt|0)==(d|0)&(ze|0)==(f|0),!((nt|0)==0&(ze|0)==0|F))do B=tn(B|0,W|0,1,0)|0,B=Kc(B|0,X()|0,w|0,M|0)|0,W=X()|0,oe=_+(B<<3)|0,nt=oe,ze=A[nt>>2]|0,nt=A[nt+4>>2]|0,F=(ze|0)==(d|0)&(nt|0)==(f|0);while(!((ze|0)==0&(nt|0)==0|F));if(B=y+(B<<2)|0,F&&(A[B>>2]|0)<=(R|0)||(nt=oe,A[nt>>2]=d,A[nt+4>>2]=f,A[B>>2]=R,(R|0)>=(p|0)))return nt=0,K=De,nt|0;switch(F=R+1|0,A[ge>>2]=0,B=bi(d,f,2,ge,_e)|0,B|0){case 9:{ve=9;break}case 0:{B=_e,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B||(ve=9);break}}e:do if((ve|0)==9){switch(A[ge>>2]=0,B=bi(d,f,3,ge,_e)|0,B|0){case 9:break;case 0:{if(B=_e,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ge>>2]=0,B=bi(d,f,1,ge,_e)|0,B|0){case 9:break;case 0:{if(B=_e,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ge>>2]=0,B=bi(d,f,5,ge,_e)|0,B|0){case 9:break;case 0:{if(B=_e,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ge>>2]=0,B=bi(d,f,4,ge,_e)|0,B|0){case 9:break;case 0:{if(B=_e,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}switch(A[ge>>2]=0,B=bi(d,f,6,ge,_e)|0,B|0){case 9:break;case 0:{if(B=_e,B=sr(A[B>>2]|0,A[B+4>>2]|0,p,_,y,w,M,F)|0,B|0)break e;break}default:break e}return nt=0,K=De,nt|0}while(!1);return nt=B,K=De,nt|0}function bi(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0;if(p>>>0>6)return y=1,y|0;if(oe=(A[_>>2]|0)%6|0,A[_>>2]=oe,(oe|0)>0){w=0;do p=Nu(p)|0,w=w+1|0;while((w|0)<(A[_>>2]|0))}if(oe=Ct(d|0,f|0,45)|0,X()|0,W=oe&127,W>>>0>121)return y=5,y|0;B=Hs(d,f)|0,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15;e:do if(!w)F=8;else{for(;;){if(M=(15-w|0)*3|0,R=Ct(d|0,f|0,M|0)|0,X()|0,R=R&7,(R|0)==7){f=5;break}if(_e=(bs(w)|0)==0,w=w+-1|0,ve=Ot(7,0,M|0)|0,f=f&~(X()|0),ge=Ot(A[(_e?432:16)+(R*28|0)+(p<<2)>>2]|0,0,M|0)|0,M=X()|0,p=A[(_e?640:224)+(R*28|0)+(p<<2)>>2]|0,d=ge|d&~ve,f=M|f,!p){p=0;break e}if(!w){F=8;break e}}return f|0}while(!1);(F|0)==8&&(_e=A[848+(W*28|0)+(p<<2)>>2]|0,ge=Ot(_e|0,0,45)|0,d=ge|d,f=X()|0|f&-1040385,p=A[4272+(W*28|0)+(p<<2)>>2]|0,(_e&127|0)==127&&(_e=Ot(A[848+(W*28|0)+20>>2]|0,0,45)|0,f=X()|0|f&-1040385,p=A[4272+(W*28|0)+20>>2]|0,d=Uu(_e|d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+1)),R=Ct(d|0,f|0,45)|0,X()|0,R=R&127;e:do if(Ji(R)|0){t:do if((Hs(d,f)|0)==1){if((W|0)!=(R|0))if(wu(R,A[7696+(W*28|0)>>2]|0)|0){d=lp(d,f)|0,M=1,f=X()|0;break}else et(27795,26864,533,26872);switch(B|0){case 3:{d=Uu(d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+1,M=0;break t}case 5:{d=lp(d,f)|0,f=X()|0,A[_>>2]=(A[_>>2]|0)+5,M=0;break t}case 0:return _e=9,_e|0;default:return _e=1,_e|0}}else M=0;while(!1);if((p|0)>0){w=0;do d=op(d,f)|0,f=X()|0,w=w+1|0;while((w|0)!=(p|0))}if((W|0)!=(R|0)){if(!(qc(R)|0)){if((M|0)!=0|(Hs(d,f)|0)!=5)break;A[_>>2]=(A[_>>2]|0)+1;break}switch(oe&127){case 8:case 118:break e}(Hs(d,f)|0)!=3&&(A[_>>2]=(A[_>>2]|0)+1)}}else if((p|0)>0){w=0;do d=Uu(d,f)|0,f=X()|0,w=w+1|0;while((w|0)!=(p|0))}while(!1);return A[_>>2]=((A[_>>2]|0)+p|0)%6|0,_e=y,A[_e>>2]=d,A[_e+4>>2]=f,_e=0,_e|0}function _r(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,Jr(d,f,p,_)|0?(ao(_|0,0,p*48|0)|0,_=Gc(d,f,p,_)|0,_|0):(_=0,_|0)}function Jr(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0;if(_e=K,K=K+16|0,ve=_e,ge=_e+8|0,oe=ve,A[oe>>2]=d,A[oe+4>>2]=f,(p|0)<0)return ge=2,K=_e,ge|0;if(!p)return ge=_,A[ge>>2]=d,A[ge+4>>2]=f,ge=0,K=_e,ge|0;A[ge>>2]=0;e:do if(wi(d,f)|0)d=9;else{y=0,oe=d;do{if(d=bi(oe,f,4,ge,ve)|0,d|0)break e;if(f=ve,oe=A[f>>2]|0,f=A[f+4>>2]|0,y=y+1|0,wi(oe,f)|0){d=9;break e}}while((y|0)<(p|0));W=_,A[W>>2]=oe,A[W+4>>2]=f,W=p+-1|0,F=0,d=1;do{if(y=26800+(F<<2)|0,(F|0)==5)for(M=A[y>>2]|0,w=0,y=d;;){if(d=ve,d=bi(A[d>>2]|0,A[d+4>>2]|0,M,ge,ve)|0,d|0)break e;if((w|0)!=(W|0))if(B=ve,R=A[B>>2]|0,B=A[B+4>>2]|0,d=_+(y<<3)|0,A[d>>2]=R,A[d+4>>2]=B,!(wi(R,B)|0))d=y+1|0;else{d=9;break e}else d=y;if(w=w+1|0,(w|0)>=(p|0))break;y=d}else for(M=ve,B=A[y>>2]|0,R=0,y=d,w=A[M>>2]|0,M=A[M+4>>2]|0;;){if(d=bi(w,M,B,ge,ve)|0,d|0)break e;if(M=ve,w=A[M>>2]|0,M=A[M+4>>2]|0,d=_+(y<<3)|0,A[d>>2]=w,A[d+4>>2]=M,d=y+1|0,wi(w,M)|0){d=9;break e}if(R=R+1|0,(R|0)>=(p|0))break;y=d}F=F+1|0}while(F>>>0<6);d=ve,d=(oe|0)==(A[d>>2]|0)&&(f|0)==(A[d+4>>2]|0)?0:9}while(!1);return ge=d,K=_e,ge|0}function Gc(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0;if(oe=K,K=K+16|0,M=oe,!p)return A[_>>2]=d,A[_+4>>2]=f,_=0,K=oe,_|0;do if((p|0)>=0){if((p|0)>13780509){if(y=ku(15,M)|0,y|0)break;w=M,y=A[w>>2]|0,w=A[w+4>>2]|0}else y=((p|0)<0)<<31>>31,W=ur(p|0,y|0,3,0)|0,w=X()|0,y=tn(p|0,y|0,1,0)|0,y=ur(W|0,w|0,y|0,X()|0)|0,y=tn(y|0,X()|0,1,0)|0,w=X()|0,W=M,A[W>>2]=y,A[W+4>>2]=w;if(F=Ys(y,8)|0,!F)y=13;else{if(W=Ys(y,4)|0,!W){vn(F),y=13;break}if(y=sr(d,f,p,F,W,y,w,0)|0,y|0){vn(F),vn(W);break}if(f=A[M>>2]|0,M=A[M+4>>2]|0,(M|0)>0|(M|0)==0&f>>>0>0){y=0,R=0,B=0;do d=F+(R<<3)|0,w=A[d>>2]|0,d=A[d+4>>2]|0,!((w|0)==0&(d|0)==0)&&(A[W+(R<<2)>>2]|0)==(p|0)&&(ve=_+(y<<3)|0,A[ve>>2]=w,A[ve+4>>2]=d,y=y+1|0),R=tn(R|0,B|0,1,0)|0,B=X()|0;while((B|0)<(M|0)|(B|0)==(M|0)&R>>>0>>0)}vn(F),vn(W),y=0}}else y=2;while(!1);return ve=y,K=oe,ve|0}function xs(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;for(R=K,K=K+16|0,w=R,M=R+8|0,y=(wi(d,f)|0)==0,y=y?1:2;;){if(A[M>>2]=0,F=(bi(d,f,y,M,w)|0)==0,B=w,F&((A[B>>2]|0)==(p|0)?(A[B+4>>2]|0)==(_|0):0)){d=4;break}if(y=y+1|0,y>>>0>=7){y=7,d=4;break}}return(d|0)==4?(K=R,y|0):0}function ux(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;if(R=K,K=K+48|0,y=R+16|0,w=R+8|0,M=R,p=Ma(p)|0,p|0)return M=p,K=R,M|0;if(F=d,B=A[F+4>>2]|0,p=w,A[p>>2]=A[F>>2],A[p+4>>2]=B,da(w,y),p=Jh(y,f,M)|0,!p){if(f=A[w>>2]|0,w=A[d+8>>2]|0,(w|0)>0){y=A[d+12>>2]|0,p=0;do f=(A[y+(p<<3)>>2]|0)+f|0,p=p+1|0;while((p|0)<(w|0))}p=M,y=A[p>>2]|0,p=A[p+4>>2]|0,w=((f|0)<0)<<31>>31,(p|0)<(w|0)|(p|0)==(w|0)&y>>>0>>0?(p=M,A[p>>2]=f,A[p+4>>2]=w,p=w):f=y,B=tn(f|0,p|0,12,0)|0,F=X()|0,p=M,A[p>>2]=B,A[p+4>>2]=F,p=_,A[p>>2]=B,A[p+4>>2]=F,p=0}return F=p,K=R,F|0}function Y0(d,f,p,_,y,w,M){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0;var R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,zt=0,xn=0,si=0,Cn=0,Ti=0,ws=0,cl=0;if(si=K,K=K+64|0,En=si+48|0,fn=si+32|0,zt=si+24|0,kt=si+8|0,un=si,B=A[d>>2]|0,(B|0)<=0)return xn=0,K=si,xn|0;for(on=d+4|0,kn=En+8|0,Dn=fn+8|0,Zn=kt+8|0,R=0,He=0;;){F=A[on>>2]|0,Xe=F+(He<<4)|0,A[En>>2]=A[Xe>>2],A[En+4>>2]=A[Xe+4>>2],A[En+8>>2]=A[Xe+8>>2],A[En+12>>2]=A[Xe+12>>2],(He|0)==(B+-1|0)?(A[fn>>2]=A[F>>2],A[fn+4>>2]=A[F+4>>2],A[fn+8>>2]=A[F+8>>2],A[fn+12>>2]=A[F+12>>2]):(Xe=F+(He+1<<4)|0,A[fn>>2]=A[Xe>>2],A[fn+4>>2]=A[Xe+4>>2],A[fn+8>>2]=A[Xe+8>>2],A[fn+12>>2]=A[Xe+12>>2]),B=s1(En,fn,_,zt)|0;e:do if(B)F=0,R=B;else if(B=zt,F=A[B>>2]|0,B=A[B+4>>2]|0,(B|0)>0|(B|0)==0&F>>>0>0){nt=0,Xe=0;t:for(;;){if(Ti=1/(+(F>>>0)+4294967296*+(B|0)),cl=+te[En>>3],B=Lr(F|0,B|0,nt|0,Xe|0)|0,ws=+(B>>>0)+4294967296*+(X()|0),Cn=+(nt>>>0)+4294967296*+(Xe|0),te[kt>>3]=Ti*(cl*ws)+Ti*(+te[fn>>3]*Cn),te[Zn>>3]=Ti*(+te[kn>>3]*ws)+Ti*(+te[Dn>>3]*Cn),B=Ed(kt,_,un)|0,B|0){R=B;break}ze=un,De=A[ze>>2]|0,ze=A[ze+4>>2]|0,ve=Yu(De|0,ze|0,f|0,p|0)|0,W=X()|0,B=M+(ve<<3)|0,oe=B,F=A[oe>>2]|0,oe=A[oe+4>>2]|0;n:do if((F|0)==0&(oe|0)==0)Pe=B,xn=16;else for(ge=0,_e=0;;){if((ge|0)>(p|0)|(ge|0)==(p|0)&_e>>>0>f>>>0){R=1;break t}if((F|0)==(De|0)&(oe|0)==(ze|0))break n;if(B=tn(ve|0,W|0,1,0)|0,ve=Kc(B|0,X()|0,f|0,p|0)|0,W=X()|0,_e=tn(_e|0,ge|0,1,0)|0,ge=X()|0,B=M+(ve<<3)|0,oe=B,F=A[oe>>2]|0,oe=A[oe+4>>2]|0,(F|0)==0&(oe|0)==0){Pe=B,xn=16;break}}while(!1);if((xn|0)==16&&(xn=0,!((De|0)==0&(ze|0)==0))&&(_e=Pe,A[_e>>2]=De,A[_e+4>>2]=ze,_e=w+(A[y>>2]<<3)|0,A[_e>>2]=De,A[_e+4>>2]=ze,_e=y,_e=tn(A[_e>>2]|0,A[_e+4>>2]|0,1,0)|0,De=X()|0,ze=y,A[ze>>2]=_e,A[ze+4>>2]=De),nt=tn(nt|0,Xe|0,1,0)|0,Xe=X()|0,B=zt,F=A[B>>2]|0,B=A[B+4>>2]|0,!((B|0)>(Xe|0)|(B|0)==(Xe|0)&F>>>0>nt>>>0)){F=1;break e}}F=0}else F=1;while(!1);if(He=He+1|0,!F){xn=21;break}if(B=A[d>>2]|0,(He|0)>=(B|0)){R=0,xn=21;break}}return(xn|0)==21?(K=si,R|0):0}function i1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,zt=0,xn=0,si=0,Cn=0,Ti=0,ws=0;if(ws=K,K=K+112|0,xn=ws+80|0,B=ws+72|0,si=ws,Cn=ws+56|0,y=Ma(p)|0,y|0)return Ti=y,K=ws,Ti|0;if(F=d+8|0,Ti=Oo((A[F>>2]<<5)+32|0)|0,!Ti)return Ti=13,K=ws,Ti|0;if(Ea(d,Ti),y=Ma(p)|0,!y){if(fn=d,zt=A[fn+4>>2]|0,y=B,A[y>>2]=A[fn>>2],A[y+4>>2]=zt,da(B,xn),y=Jh(xn,f,si)|0,y)fn=0,zt=0;else{if(y=A[B>>2]|0,w=A[F>>2]|0,(w|0)>0){M=A[d+12>>2]|0,p=0;do y=(A[M+(p<<3)>>2]|0)+y|0,p=p+1|0;while((p|0)!=(w|0));p=y}else p=y;y=si,w=A[y>>2]|0,y=A[y+4>>2]|0,M=((p|0)<0)<<31>>31,(y|0)<(M|0)|(y|0)==(M|0)&w>>>0

>>0?(y=si,A[y>>2]=p,A[y+4>>2]=M,y=M):p=w,fn=tn(p|0,y|0,12,0)|0,zt=X()|0,y=si,A[y>>2]=fn,A[y+4>>2]=zt,y=0}if(!y){if(p=Ys(fn,8)|0,!p)return vn(Ti),Ti=13,K=ws,Ti|0;if(R=Ys(fn,8)|0,!R)return vn(Ti),vn(p),Ti=13,K=ws,Ti|0;Zn=xn,A[Zn>>2]=0,A[Zn+4>>2]=0,Zn=d,En=A[Zn+4>>2]|0,y=B,A[y>>2]=A[Zn>>2],A[y+4>>2]=En,y=Y0(B,fn,zt,f,xn,p,R)|0;e:do if(y)vn(p),vn(R),vn(Ti);else{t:do if((A[F>>2]|0)>0){for(M=d+12|0,w=0;y=Y0((A[M>>2]|0)+(w<<3)|0,fn,zt,f,xn,p,R)|0,w=w+1|0,!(y|0);)if((w|0)>=(A[F>>2]|0))break t;vn(p),vn(R),vn(Ti);break e}while(!1);(zt|0)>0|(zt|0)==0&fn>>>0>0&&ao(R|0,0,fn<<3|0)|0,En=xn,Zn=A[En+4>>2]|0;t:do if((Zn|0)>0|(Zn|0)==0&(A[En>>2]|0)>>>0>0){on=p,kn=R,Dn=p,Zn=R,En=p,y=p,Pe=p,kt=R,un=R,p=R;n:for(;;){for(ze=0,nt=0,Xe=0,He=0,w=0,M=0;;){R=si,B=R+56|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));if(f=on+(ze<<3)|0,F=A[f>>2]|0,f=A[f+4>>2]|0,Di(F,f,1,si,0)|0){R=si,B=R+56|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));R=Ys(7,4)|0,R|0&&(sr(F,f,1,si,R,7,0,0)|0,vn(R))}for(De=0;;){_e=si+(De<<3)|0,ge=A[_e>>2]|0,_e=A[_e+4>>2]|0;i:do if((ge|0)==0&(_e|0)==0)R=w,B=M;else{if(W=Yu(ge|0,_e|0,fn|0,zt|0)|0,F=X()|0,R=_+(W<<3)|0,f=R,B=A[f>>2]|0,f=A[f+4>>2]|0,!((B|0)==0&(f|0)==0)){oe=0,ve=0;do{if((oe|0)>(zt|0)|(oe|0)==(zt|0)&ve>>>0>fn>>>0)break n;if((B|0)==(ge|0)&(f|0)==(_e|0)){R=w,B=M;break i}R=tn(W|0,F|0,1,0)|0,W=Kc(R|0,X()|0,fn|0,zt|0)|0,F=X()|0,ve=tn(ve|0,oe|0,1,0)|0,oe=X()|0,R=_+(W<<3)|0,f=R,B=A[f>>2]|0,f=A[f+4>>2]|0}while(!((B|0)==0&(f|0)==0))}if((ge|0)==0&(_e|0)==0){R=w,B=M;break}Dl(ge,_e,Cn)|0,Ca(d,Ti,Cn)|0&&(ve=tn(w|0,M|0,1,0)|0,M=X()|0,oe=R,A[oe>>2]=ge,A[oe+4>>2]=_e,w=kn+(w<<3)|0,A[w>>2]=ge,A[w+4>>2]=_e,w=ve),R=w,B=M}while(!1);if(De=De+1|0,De>>>0>=7)break;w=R,M=B}if(ze=tn(ze|0,nt|0,1,0)|0,nt=X()|0,Xe=tn(Xe|0,He|0,1,0)|0,He=X()|0,M=xn,w=A[M>>2]|0,M=A[M+4>>2]|0,(He|0)<(M|0)|(He|0)==(M|0)&Xe>>>0>>0)w=R,M=B;else break}if((M|0)>0|(M|0)==0&w>>>0>0){w=0,M=0;do He=on+(w<<3)|0,A[He>>2]=0,A[He+4>>2]=0,w=tn(w|0,M|0,1,0)|0,M=X()|0,He=xn,Xe=A[He+4>>2]|0;while((M|0)<(Xe|0)|((M|0)==(Xe|0)?w>>>0<(A[He>>2]|0)>>>0:0))}if(He=xn,A[He>>2]=R,A[He+4>>2]=B,(B|0)>0|(B|0)==0&R>>>0>0)De=p,ze=un,nt=En,Xe=kt,He=kn,p=Pe,un=y,kt=Dn,Pe=De,y=ze,En=Zn,Zn=nt,Dn=Xe,kn=on,on=He;else break t}vn(Dn),vn(Zn),vn(Ti),y=1;break e}else y=R;while(!1);vn(Ti),vn(p),vn(y),y=0}while(!1);return Ti=y,K=ws,Ti|0}}return vn(Ti),Ti=y,K=ws,Ti|0}function Q0(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+176|0,B=W,(f|0)<1)return Bo(p,0,0),F=0,K=W,F|0;for(R=d,R=Ct(A[R>>2]|0,A[R+4>>2]|0,52)|0,X()|0,Bo(p,(f|0)>6?f:6,R&15),R=0;_=d+(R<<3)|0,_=Pl(A[_>>2]|0,A[_+4>>2]|0,B)|0,!(_|0);){if(_=A[B>>2]|0,(_|0)>0){M=0;do w=B+8+(M<<4)|0,M=M+1|0,_=B+8+(((M|0)%(_|0)|0)<<4)|0,y=$u(p,_,w)|0,y?Wu(p,y)|0:Fd(p,w,_)|0,_=A[B>>2]|0;while((M|0)<(_|0))}if(R=R+1|0,(R|0)>=(f|0)){_=0,F=13;break}}return(F|0)==13?(K=W,_|0):(Od(p),F=_,K=W,F|0)}function cx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(w=K,K=K+32|0,_=w,y=w+16|0,d=Q0(d,f,y)|0,d|0)return p=d,K=w,p|0;if(A[p>>2]=0,A[p+4>>2]=0,A[p+8>>2]=0,d=Id(y)|0,d|0)do{f=T1(p)|0;do Dd(f,d)|0,M=d+16|0,A[_>>2]=A[M>>2],A[_+4>>2]=A[M+4>>2],A[_+8>>2]=A[M+8>>2],A[_+12>>2]=A[M+12>>2],Wu(y,d)|0,d=hs(y,_)|0;while((d|0)!=0);d=Id(y)|0}while((d|0)!=0);return Od(y),d=Rx(p)|0,d?(Gu(p),M=d,K=w,M|0):(M=0,K=w,M|0)}function Ji(d){return d=d|0,d>>>0>121?(d=0,d|0):(d=A[7696+(d*28|0)+16>>2]|0,d|0)}function qc(d){return d=d|0,(d|0)==4|(d|0)==117|0}function Ro(d){return d=d|0,A[11120+((A[d>>2]|0)*216|0)+((A[d+4>>2]|0)*72|0)+((A[d+8>>2]|0)*24|0)+(A[d+12>>2]<<3)>>2]|0}function K0(d){return d=d|0,A[11120+((A[d>>2]|0)*216|0)+((A[d+4>>2]|0)*72|0)+((A[d+8>>2]|0)*24|0)+(A[d+12>>2]<<3)+4>>2]|0}function Z0(d,f){d=d|0,f=f|0,d=7696+(d*28|0)|0,A[f>>2]=A[d>>2],A[f+4>>2]=A[d+4>>2],A[f+8>>2]=A[d+8>>2],A[f+12>>2]=A[d+12>>2]}function Vc(d,f){d=d|0,f=f|0;var p=0,_=0;if(f>>>0>20)return f=-1,f|0;do if((A[11120+(f*216|0)>>2]|0)!=(d|0))if((A[11120+(f*216|0)+8>>2]|0)!=(d|0))if((A[11120+(f*216|0)+16>>2]|0)!=(d|0))if((A[11120+(f*216|0)+24>>2]|0)!=(d|0))if((A[11120+(f*216|0)+32>>2]|0)!=(d|0))if((A[11120+(f*216|0)+40>>2]|0)!=(d|0))if((A[11120+(f*216|0)+48>>2]|0)!=(d|0))if((A[11120+(f*216|0)+56>>2]|0)!=(d|0))if((A[11120+(f*216|0)+64>>2]|0)!=(d|0))if((A[11120+(f*216|0)+72>>2]|0)!=(d|0))if((A[11120+(f*216|0)+80>>2]|0)!=(d|0))if((A[11120+(f*216|0)+88>>2]|0)!=(d|0))if((A[11120+(f*216|0)+96>>2]|0)!=(d|0))if((A[11120+(f*216|0)+104>>2]|0)!=(d|0))if((A[11120+(f*216|0)+112>>2]|0)!=(d|0))if((A[11120+(f*216|0)+120>>2]|0)!=(d|0))if((A[11120+(f*216|0)+128>>2]|0)!=(d|0))if((A[11120+(f*216|0)+136>>2]|0)==(d|0))d=2,p=1,_=2;else{if((A[11120+(f*216|0)+144>>2]|0)==(d|0)){d=0,p=2,_=0;break}if((A[11120+(f*216|0)+152>>2]|0)==(d|0)){d=0,p=2,_=1;break}if((A[11120+(f*216|0)+160>>2]|0)==(d|0)){d=0,p=2,_=2;break}if((A[11120+(f*216|0)+168>>2]|0)==(d|0)){d=1,p=2,_=0;break}if((A[11120+(f*216|0)+176>>2]|0)==(d|0)){d=1,p=2,_=1;break}if((A[11120+(f*216|0)+184>>2]|0)==(d|0)){d=1,p=2,_=2;break}if((A[11120+(f*216|0)+192>>2]|0)==(d|0)){d=2,p=2,_=0;break}if((A[11120+(f*216|0)+200>>2]|0)==(d|0)){d=2,p=2,_=1;break}if((A[11120+(f*216|0)+208>>2]|0)==(d|0)){d=2,p=2,_=2;break}else d=-1;return d|0}else d=2,p=1,_=1;else d=2,p=1,_=0;else d=1,p=1,_=2;else d=1,p=1,_=1;else d=1,p=1,_=0;else d=0,p=1,_=2;else d=0,p=1,_=1;else d=0,p=1,_=0;else d=2,p=0,_=2;else d=2,p=0,_=1;else d=2,p=0,_=0;else d=1,p=0,_=2;else d=1,p=0,_=1;else d=1,p=0,_=0;else d=0,p=0,_=2;else d=0,p=0,_=1;else d=0,p=0,_=0;while(!1);return f=A[11120+(f*216|0)+(p*72|0)+(d*24|0)+(_<<3)+4>>2]|0,f|0}function wu(d,f){return d=d|0,f=f|0,(A[7696+(d*28|0)+20>>2]|0)==(f|0)?(f=1,f|0):(f=(A[7696+(d*28|0)+24>>2]|0)==(f|0),f|0)}function vd(d,f){return d=d|0,f=f|0,A[848+(d*28|0)+(f<<2)>>2]|0}function Xh(d,f){return d=d|0,f=f|0,(A[848+(d*28|0)>>2]|0)==(f|0)?(f=0,f|0):(A[848+(d*28|0)+4>>2]|0)==(f|0)?(f=1,f|0):(A[848+(d*28|0)+8>>2]|0)==(f|0)?(f=2,f|0):(A[848+(d*28|0)+12>>2]|0)==(f|0)?(f=3,f|0):(A[848+(d*28|0)+16>>2]|0)==(f|0)?(f=4,f|0):(A[848+(d*28|0)+20>>2]|0)==(f|0)?(f=5,f|0):((A[848+(d*28|0)+24>>2]|0)==(f|0)?6:7)|0}function r1(){return 122}function Yh(d){d=d|0;var f=0,p=0,_=0;f=0;do Ot(f|0,0,45)|0,_=X()|0|134225919,p=d+(f<<3)|0,A[p>>2]=-1,A[p+4>>2]=_,f=f+1|0;while((f|0)!=122);return 0}function el(d){d=d|0;var f=0,p=0,_=0;return _=+te[d+16>>3],p=+te[d+24>>3],f=_-p,+(_>3]<+te[d+24>>3]|0}function Qh(d){return d=d|0,+(+te[d>>3]-+te[d+8>>3])}function Do(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;return p=+te[f>>3],!(p>=+te[d+8>>3])||!(p<=+te[d>>3])?(f=0,f|0):(_=+te[d+16>>3],p=+te[d+24>>3],y=+te[f+8>>3],f=y>=p,d=y<=_&1,_>3]<+te[f+8>>3]||+te[d+8>>3]>+te[f>>3]?(_=0,_|0):(w=+te[d+16>>3],p=d+24|0,W=+te[p>>3],M=w>3],y=f+24|0,B=+te[y>>3],R=F>3],f)||(W=+Ws(+te[p>>3],d),W>+Ws(+te[_>>3],f))?(R=0,R|0):(R=1,R|0))}function yd(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0;w=+te[d+16>>3],B=+te[d+24>>3],d=w>3],M=+te[f+24>>3],y=R>2]=d?y|f?1:2:0,A[_>>2]=y?d?1:f?2:1:0}function J0(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;return+te[d>>3]<+te[f>>3]||+te[d+8>>3]>+te[f+8>>3]?(_=0,_|0):(_=d+16|0,B=+te[_>>3],w=+te[d+24>>3],M=B>3],y=f+24|0,F=+te[y>>3],R=W>3],f)?(W=+Ws(+te[_>>3],d),R=W>=+Ws(+te[p>>3],f),R|0):(R=0,R|0))}function Zh(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;y=K,K=K+176|0,_=y,A[_>>2]=4,R=+te[f>>3],te[_+8>>3]=R,w=+te[f+16>>3],te[_+16>>3]=w,te[_+24>>3]=R,R=+te[f+24>>3],te[_+32>>3]=R,M=+te[f+8>>3],te[_+40>>3]=M,te[_+48>>3]=R,te[_+56>>3]=M,te[_+64>>3]=w,f=_+72|0,p=f+96|0;do A[f>>2]=0,f=f+4|0;while((f|0)<(p|0));Ol(d|0,_|0,168)|0,K=y}function Jh(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0;_e=K,K=K+288|0,W=_e+264|0,oe=_e+96|0,F=_e,R=F,B=R+96|0;do A[R>>2]=0,R=R+4|0;while((R|0)<(B|0));return f=Iu(f,F)|0,f|0?(ge=f,K=_e,ge|0):(B=F,F=A[B>>2]|0,B=A[B+4>>2]|0,Dl(F,B,W)|0,Pl(F,B,oe)|0,M=+Xc(W,oe+8|0),te[W>>3]=+te[d>>3],B=W+8|0,te[B>>3]=+te[d+16>>3],te[oe>>3]=+te[d+8>>3],F=oe+8|0,te[F>>3]=+te[d+24>>3],y=+Xc(W,oe),ze=+te[B>>3]-+te[F>>3],w=+dn(+ze),De=+te[W>>3]-+te[oe>>3],_=+dn(+De),!(ze==0|De==0)&&(ze=+lf(+w,+_),ze=+rt(+(y*y/+uf(+(ze/+uf(+w,+_)),3)/(M*(M*2.59807621135)*.8))),te[Vn>>3]=ze,ve=~~ze>>>0,ge=+dn(ze)>=1?ze>0?~~+qe(+$n(ze/4294967296),4294967295)>>>0:~~+rt((ze-+(~~ze>>>0))/4294967296)>>>0:0,(A[Vn+4>>2]&2146435072|0)!=2146435072)?(oe=(ve|0)==0&(ge|0)==0,f=p,A[f>>2]=oe?1:ve,A[f+4>>2]=oe?0:ge,f=0):f=1,ge=f,K=_e,ge|0)}function s1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;F=K,K=K+288|0,M=F+264|0,R=F+96|0,B=F,y=B,w=y+96|0;do A[y>>2]=0,y=y+4|0;while((y|0)<(w|0));return p=Iu(p,B)|0,p|0?(_=p,K=F,_|0):(p=B,y=A[p>>2]|0,p=A[p+4>>2]|0,Dl(y,p,M)|0,Pl(y,p,R)|0,W=+Xc(M,R+8|0),W=+rt(+(+Xc(d,f)/(W*2))),te[Vn>>3]=W,p=~~W>>>0,y=+dn(W)>=1?W>0?~~+qe(+$n(W/4294967296),4294967295)>>>0:~~+rt((W-+(~~W>>>0))/4294967296)>>>0:0,(A[Vn+4>>2]&2146435072|0)==2146435072?(_=1,K=F,_|0):(B=(p|0)==0&(y|0)==0,A[_>>2]=B?1:p,A[_+4>>2]=B?0:y,_=0,K=F,_|0))}function js(d,f){d=d|0,f=+f;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;w=d+16|0,M=+te[w>>3],p=d+24|0,y=+te[p>>3],_=M-y,_=M>3],R=d+8|0,B=+te[R>>3],W=F-B,_=(_*f-_)*.5,f=(W*f-W)*.5,F=F+f,te[d>>3]=F>1.5707963267948966?1.5707963267948966:F,f=B-f,te[R>>3]=f<-1.5707963267948966?-1.5707963267948966:f,f=M+_,f=f>3.141592653589793?f+-6.283185307179586:f,te[w>>3]=f<-3.141592653589793?f+6.283185307179586:f,f=y-_,f=f>3.141592653589793?f+-6.283185307179586:f,te[p>>3]=f<-3.141592653589793?f+6.283185307179586:f}function Tu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0,A[d>>2]=f,A[d+4>>2]=p,A[d+8>>2]=_}function xd(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0;oe=f+8|0,A[oe>>2]=0,B=+te[d>>3],M=+dn(+B),F=+te[d+8>>3],R=+dn(+F)*1.1547005383792515,M=M+R*.5,p=~~M,d=~~R,M=M-+(p|0),R=R-+(d|0);do if(M<.5)if(M<.3333333333333333)if(A[f>>2]=p,R<(M+1)*.5){A[f+4>>2]=d;break}else{d=d+1|0,A[f+4>>2]=d;break}else if(ve=1-M,d=(!(R>2]=d,ve<=R&R>2]=p;break}else{A[f>>2]=p;break}else{if(!(M<.6666666666666666))if(p=p+1|0,A[f>>2]=p,R>2]=d;break}else{d=d+1|0,A[f+4>>2]=d;break}if(R<1-M){if(A[f+4>>2]=d,M*2+-1>2]=p;break}}else d=d+1|0,A[f+4>>2]=d;p=p+1|0,A[f>>2]=p}while(!1);do if(B<0)if(d&1){W=(d+1|0)/2|0,W=Lr(p|0,((p|0)<0)<<31>>31|0,W|0,((W|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-((+(W>>>0)+4294967296*+(X()|0))*2+1)),A[f>>2]=p;break}else{W=(d|0)/2|0,W=Lr(p|0,((p|0)<0)<<31>>31|0,W|0,((W|0)<0)<<31>>31|0)|0,p=~~(+(p|0)-(+(W>>>0)+4294967296*+(X()|0))*2),A[f>>2]=p;break}while(!1);W=f+4|0,F<0&&(p=p-((d<<1|1|0)/2|0)|0,A[f>>2]=p,d=0-d|0,A[W>>2]=d),_=d-p|0,(p|0)<0?(y=0-p|0,A[W>>2]=_,A[oe>>2]=y,A[f>>2]=0,d=_,p=0):y=0,(d|0)<0&&(p=p-d|0,A[f>>2]=p,y=y-d|0,A[oe>>2]=y,A[W>>2]=0,d=0),w=p-y|0,_=d-y|0,(y|0)<0&&(A[f>>2]=w,A[W>>2]=_,A[oe>>2]=0,d=_,p=w,y=0),_=(d|0)<(p|0)?d:p,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(A[f>>2]=p-_,A[W>>2]=d-_,A[oe>>2]=y-_)}function Pr(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,(f|0)<0&&(p=p-f|0,A[M>>2]=p,w=d+8|0,A[w>>2]=(A[w>>2]|0)-f,A[d>>2]=0,f=0),(p|0)<0?(f=f-p|0,A[d>>2]=f,w=d+8|0,y=(A[w>>2]|0)-p|0,A[w>>2]=y,A[M>>2]=0,p=0):(y=d+8|0,w=y,y=A[y>>2]|0),(y|0)<0&&(f=f-y|0,A[d>>2]=f,p=p-y|0,A[M>>2]=p,A[w>>2]=0,y=0),_=(p|0)<(f|0)?p:f,_=(y|0)<(_|0)?y:_,!((_|0)<=0)&&(A[d>>2]=f-_,A[M>>2]=p-_,A[w>>2]=y-_)}function Mu(d,f){d=d|0,f=f|0;var p=0,_=0;_=A[d+8>>2]|0,p=+((A[d+4>>2]|0)-_|0),te[f>>3]=+((A[d>>2]|0)-_|0)-p*.5,te[f+8>>3]=p*.8660254037844386}function us(d,f,p){d=d|0,f=f|0,p=p|0,A[p>>2]=(A[f>>2]|0)+(A[d>>2]|0),A[p+4>>2]=(A[f+4>>2]|0)+(A[d+4>>2]|0),A[p+8>>2]=(A[f+8>>2]|0)+(A[d+8>>2]|0)}function ef(d,f,p){d=d|0,f=f|0,p=p|0,A[p>>2]=(A[d>>2]|0)-(A[f>>2]|0),A[p+4>>2]=(A[d+4>>2]|0)-(A[f+4>>2]|0),A[p+8>>2]=(A[d+8>>2]|0)-(A[f+8>>2]|0)}function jc(d,f){d=d|0,f=f|0;var p=0,_=0;p=it(A[d>>2]|0,f)|0,A[d>>2]=p,p=d+4|0,_=it(A[p>>2]|0,f)|0,A[p>>2]=_,d=d+8|0,f=it(A[d>>2]|0,f)|0,A[d>>2]=f}function Eu(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=A[d>>2]|0,R=(M|0)<0,_=(A[d+4>>2]|0)-(R?M:0)|0,w=(_|0)<0,y=(w?0-_|0:0)+((A[d+8>>2]|0)-(R?M:0))|0,p=(y|0)<0,d=p?0:y,f=(w?0:_)-(p?y:0)|0,y=(R?0:M)-(w?_:0)-(p?y:0)|0,p=(f|0)<(y|0)?f:y,p=(d|0)<(p|0)?d:p,_=(p|0)>0,d=d-(_?p:0)|0,f=f-(_?p:0)|0;e:do switch(y-(_?p:0)|0){case 0:switch(f|0){case 0:return R=(d|0)==0?0:(d|0)==1?1:7,R|0;case 1:return R=(d|0)==0?2:(d|0)==1?3:7,R|0;default:break e}case 1:switch(f|0){case 0:return R=(d|0)==0?4:(d|0)==1?5:7,R|0;case 1:{if(!d)d=6;else break e;return d|0}default:break e}}while(!1);return R=7,R|0}function a1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0;if(B=d+8|0,M=A[B>>2]|0,R=(A[d>>2]|0)-M|0,F=d+4|0,M=(A[F>>2]|0)-M|0,R>>>0>715827881|M>>>0>715827881){if(_=(R|0)>0,y=2147483647-R|0,w=-2147483648-R|0,(_?(y|0)<(R|0):(w|0)>(R|0))||(p=R<<1,_?(2147483647-p|0)<(R|0):(-2147483648-p|0)>(R|0))||((M|0)>0?(2147483647-M|0)<(M|0):(-2147483648-M|0)>(M|0))||(f=R*3|0,p=M<<1,(_?(y|0)<(p|0):(w|0)>(p|0))||((R|0)>-1?(f|-2147483648|0)>=(M|0):(f^-2147483648|0)<(M|0))))return F=1,F|0}else p=M<<1,f=R*3|0;return _=ol(+(f-M|0)*.14285714285714285)|0,A[d>>2]=_,y=ol(+(p+R|0)*.14285714285714285)|0,A[F>>2]=y,A[B>>2]=0,p=(y|0)<(_|0),f=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((f|0)>0?(2147483647-f|0)<(p|0):(-2147483648-f|0)>(p|0)))&&et(27795,26892,354,26903),((f|0)>-1?(f|-2147483648|0)>=(p|0):(f^-2147483648|0)<(p|0))&&et(27795,26892,354,26903)),f=y-_|0,(_|0)<0?(p=0-_|0,A[F>>2]=f,A[B>>2]=p,A[d>>2]=0,_=0):(f=y,p=0),(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[B>>2]=p,A[F>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[F>>2]=y,A[B>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(F=0,F|0):(A[d>>2]=y-_,A[F>>2]=f-_,A[B>>2]=p-_,F=0,F|0)}function hx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(M=d+8|0,y=A[M>>2]|0,w=(A[d>>2]|0)-y|0,R=d+4|0,y=(A[R>>2]|0)-y|0,w>>>0>715827881|y>>>0>715827881){if(p=(w|0)>0,(p?(2147483647-w|0)<(w|0):(-2147483648-w|0)>(w|0))||(f=w<<1,_=(y|0)>0,_?(2147483647-y|0)<(y|0):(-2147483648-y|0)>(y|0)))return R=1,R|0;if(B=y<<1,(_?(2147483647-B|0)<(y|0):(-2147483648-B|0)>(y|0))||(p?(2147483647-f|0)<(y|0):(-2147483648-f|0)>(y|0))||(p=y*3|0,(y|0)>-1?(p|-2147483648|0)>=(w|0):(p^-2147483648|0)<(w|0)))return B=1,B|0}else p=y*3|0,f=w<<1;return _=ol(+(f+y|0)*.14285714285714285)|0,A[d>>2]=_,y=ol(+(p-w|0)*.14285714285714285)|0,A[R>>2]=y,A[M>>2]=0,p=(y|0)<(_|0),f=p?_:y,p=p?y:_,(p|0)<0&&(((p|0)==-2147483648||((f|0)>0?(2147483647-f|0)<(p|0):(-2147483648-f|0)>(p|0)))&&et(27795,26892,402,26917),((f|0)>-1?(f|-2147483648|0)>=(p|0):(f^-2147483648|0)<(p|0))&&et(27795,26892,402,26917)),f=y-_|0,(_|0)<0?(p=0-_|0,A[R>>2]=f,A[M>>2]=p,A[d>>2]=0,_=0):(f=y,p=0),(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(B=0,B|0):(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_,B=0,B|0)}function fx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=d+8|0,p=A[M>>2]|0,f=(A[d>>2]|0)-p|0,R=d+4|0,p=(A[R>>2]|0)-p|0,_=ol(+((f*3|0)-p|0)*.14285714285714285)|0,A[d>>2]=_,f=ol(+((p<<1)+f|0)*.14285714285714285)|0,A[R>>2]=f,A[M>>2]=0,p=f-_|0,(_|0)<0?(w=0-_|0,A[R>>2]=p,A[M>>2]=w,A[d>>2]=0,f=p,_=0,p=w):p=0,(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_)}function o1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;M=d+8|0,p=A[M>>2]|0,f=(A[d>>2]|0)-p|0,R=d+4|0,p=(A[R>>2]|0)-p|0,_=ol(+((f<<1)+p|0)*.14285714285714285)|0,A[d>>2]=_,f=ol(+((p*3|0)-f|0)*.14285714285714285)|0,A[R>>2]=f,A[M>>2]=0,p=f-_|0,(_|0)<0?(w=0-_|0,A[R>>2]=p,A[M>>2]=w,A[d>>2]=0,f=p,_=0,p=w):p=0,(f|0)<0&&(_=_-f|0,A[d>>2]=_,p=p-f|0,A[M>>2]=p,A[R>>2]=0,f=0),w=_-p|0,y=f-p|0,(p|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,f=y,y=w,p=0):y=_,_=(f|0)<(y|0)?f:y,_=(p|0)<(_|0)?p:_,!((_|0)<=0)&&(A[d>>2]=y-_,A[R>>2]=f-_,A[M>>2]=p-_)}function Hc(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,R=d+8|0,_=A[R>>2]|0,y=p+(f*3|0)|0,A[d>>2]=y,p=_+(p*3|0)|0,A[M>>2]=p,f=(_*3|0)+f|0,A[R>>2]=f,_=p-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=_,A[R>>2]=f,A[d>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function Cu(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=(f*3|0)+y|0,y=p+(y*3|0)|0,A[d>>2]=y,A[M>>2]=_,f=(p*3|0)+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,A[d>>2]=y,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=y-f|0,_=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=_,A[R>>2]=0,y=w,f=0):_=p,p=(_|0)<(y|0)?_:y,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=y-p,A[M>>2]=_-p,A[R>>2]=f-p)}function l1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;(f+-1|0)>>>0>=6||(y=(A[15440+(f*12|0)>>2]|0)+(A[d>>2]|0)|0,A[d>>2]=y,R=d+4|0,_=(A[15440+(f*12|0)+4>>2]|0)+(A[R>>2]|0)|0,A[R>>2]=_,M=d+8|0,f=(A[15440+(f*12|0)+8>>2]|0)+(A[M>>2]|0)|0,A[M>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[R>>2]=p,A[M>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[M>>2]=f,A[R>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[R>>2]=y,A[M>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[R>>2]=y-p,A[M>>2]=f-p))}function u1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=f+y|0,y=p+y|0,A[d>>2]=y,A[M>>2]=_,f=p+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function bd(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,_=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,y=_+f|0,A[d>>2]=y,_=p+_|0,A[M>>2]=_,f=p+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,_=0):(p=_,_=y),(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function Nu(d){switch(d=d|0,d|0){case 1:{d=5;break}case 5:{d=4;break}case 4:{d=6;break}case 6:{d=2;break}case 2:{d=3;break}case 3:{d=1;break}}return d|0}function tl(d){switch(d=d|0,d|0){case 1:{d=3;break}case 3:{d=2;break}case 2:{d=6;break}case 6:{d=4;break}case 4:{d=5;break}case 5:{d=1;break}}return d|0}function c1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;f=A[d>>2]|0,M=d+4|0,p=A[M>>2]|0,R=d+8|0,_=A[R>>2]|0,y=p+(f<<1)|0,A[d>>2]=y,p=_+(p<<1)|0,A[M>>2]=p,f=(_<<1)+f|0,A[R>>2]=f,_=p-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=_,A[R>>2]=f,A[d>>2]=0,p=_,_=0):_=y,(p|0)<0&&(_=_-p|0,A[d>>2]=_,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=_-f|0,y=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=y,A[R>>2]=0,_=w,f=0):y=p,p=(y|0)<(_|0)?y:_,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=_-p,A[M>>2]=y-p,A[R>>2]=f-p)}function h1(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=A[d>>2]|0,M=d+4|0,f=A[M>>2]|0,R=d+8|0,p=A[R>>2]|0,_=(f<<1)+y|0,y=p+(y<<1)|0,A[d>>2]=y,A[M>>2]=_,f=(p<<1)+f|0,A[R>>2]=f,p=_-y|0,(y|0)<0?(f=f-y|0,A[M>>2]=p,A[R>>2]=f,A[d>>2]=0,y=0):p=_,(p|0)<0&&(y=y-p|0,A[d>>2]=y,f=f-p|0,A[R>>2]=f,A[M>>2]=0,p=0),w=y-f|0,_=p-f|0,(f|0)<0?(A[d>>2]=w,A[M>>2]=_,A[R>>2]=0,y=w,f=0):_=p,p=(_|0)<(y|0)?_:y,p=(f|0)<(p|0)?f:p,!((p|0)<=0)&&(A[d>>2]=y-p,A[M>>2]=_-p,A[R>>2]=f-p)}function ep(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;return M=(A[d>>2]|0)-(A[f>>2]|0)|0,R=(M|0)<0,_=(A[d+4>>2]|0)-(A[f+4>>2]|0)-(R?M:0)|0,w=(_|0)<0,y=(R?0-M|0:0)+(A[d+8>>2]|0)-(A[f+8>>2]|0)+(w?0-_|0:0)|0,d=(y|0)<0,f=d?0:y,p=(w?0:_)-(d?y:0)|0,y=(R?0:M)-(w?_:0)-(d?y:0)|0,d=(p|0)<(y|0)?p:y,d=(f|0)<(d|0)?f:d,_=(d|0)>0,f=f-(_?d:0)|0,p=p-(_?d:0)|0,d=y-(_?d:0)|0,d=(d|0)>-1?d:0-d|0,p=(p|0)>-1?p:0-p|0,f=(f|0)>-1?f:0-f|0,f=(p|0)>(f|0)?p:f,((d|0)>(f|0)?d:f)|0}function dx(d,f){d=d|0,f=f|0;var p=0;p=A[d+8>>2]|0,A[f>>2]=(A[d>>2]|0)-p,A[f+4>>2]=(A[d+4>>2]|0)-p}function tp(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0;return _=A[d>>2]|0,A[f>>2]=_,y=A[d+4>>2]|0,M=f+4|0,A[M>>2]=y,R=f+8|0,A[R>>2]=0,p=(y|0)<(_|0),d=p?_:y,p=p?y:_,(p|0)<0&&((p|0)==-2147483648||((d|0)>0?(2147483647-d|0)<(p|0):(-2147483648-d|0)>(p|0))||((d|0)>-1?(d|-2147483648|0)>=(p|0):(d^-2147483648|0)<(p|0)))?(f=1,f|0):(d=y-_|0,(_|0)<0?(p=0-_|0,A[M>>2]=d,A[R>>2]=p,A[f>>2]=0,_=0):(d=y,p=0),(d|0)<0&&(_=_-d|0,A[f>>2]=_,p=p-d|0,A[R>>2]=p,A[M>>2]=0,d=0),w=_-p|0,y=d-p|0,(p|0)<0?(A[f>>2]=w,A[M>>2]=y,A[R>>2]=0,d=y,y=w,p=0):y=_,_=(d|0)<(y|0)?d:y,_=(p|0)<(_|0)?p:_,(_|0)<=0?(f=0,f|0):(A[f>>2]=y-_,A[M>>2]=d-_,A[R>>2]=p-_,f=0,f|0))}function f1(d){d=d|0;var f=0,p=0,_=0,y=0;f=d+8|0,y=A[f>>2]|0,p=y-(A[d>>2]|0)|0,A[d>>2]=p,_=d+4|0,d=(A[_>>2]|0)-y|0,A[_>>2]=d,A[f>>2]=0-(d+p)}function Ax(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;p=A[d>>2]|0,f=0-p|0,A[d>>2]=f,M=d+8|0,A[M>>2]=0,R=d+4|0,_=A[R>>2]|0,y=_+p|0,(p|0)>0?(A[R>>2]=y,A[M>>2]=p,A[d>>2]=0,f=0,_=y):p=0,(_|0)<0?(w=f-_|0,A[d>>2]=w,p=p-_|0,A[M>>2]=p,A[R>>2]=0,y=w-p|0,f=0-p|0,(p|0)<0?(A[d>>2]=y,A[R>>2]=f,A[M>>2]=0,_=f,p=0):(_=0,y=w)):y=f,f=(_|0)<(y|0)?_:y,f=(p|0)<(f|0)?p:f,!((f|0)<=0)&&(A[d>>2]=y-f,A[R>>2]=_-f,A[M>>2]=p-f)}function px(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0;if(oe=K,K=K+64|0,W=oe,R=oe+56|0,!(!0&(f&2013265920|0)==134217728&(!0&(_&2013265920|0)==134217728)))return y=5,K=oe,y|0;if((d|0)==(p|0)&(f|0)==(_|0))return A[y>>2]=0,y=0,K=oe,y|0;if(M=Ct(d|0,f|0,52)|0,X()|0,M=M&15,F=Ct(p|0,_|0,52)|0,X()|0,(M|0)!=(F&15|0))return y=12,K=oe,y|0;if(w=M+-1|0,M>>>0>1){Lu(d,f,w,W)|0,Lu(p,_,w,R)|0,F=W,B=A[F>>2]|0,F=A[F+4>>2]|0;e:do if((B|0)==(A[R>>2]|0)&&(F|0)==(A[R+4>>2]|0)){M=(M^15)*3|0,w=Ct(d|0,f|0,M|0)|0,X()|0,w=w&7,M=Ct(p|0,_|0,M|0)|0,X()|0,M=M&7;do if((w|0)==0|(M|0)==0)A[y>>2]=1,w=0;else if((w|0)==7)w=5;else{if((w|0)==1|(M|0)==1&&wi(B,F)|0){w=5;break}if((A[15536+(w<<2)>>2]|0)!=(M|0)&&(A[15568+(w<<2)>>2]|0)!=(M|0))break e;A[y>>2]=1,w=0}while(!1);return y=w,K=oe,y|0}while(!1)}w=W,M=w+56|0;do A[w>>2]=0,w=w+4|0;while((w|0)<(M|0));return ys(d,f,1,W)|0,f=W,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0))&&(f=W+8|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+16|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+24|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+32|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))&&(f=W+40|0,!((A[f>>2]|0)==(p|0)&&(A[f+4>>2]|0)==(_|0)))?(w=W+48|0,w=((A[w>>2]|0)==(p|0)?(A[w+4>>2]|0)==(_|0):0)&1):w=1,A[y>>2]=w,y=0,K=oe,y|0}function d1(d,f,p,_,y){return d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,p=xs(d,f,p,_)|0,(p|0)==7?(y=11,y|0):(_=Ot(p|0,0,56)|0,f=f&-2130706433|(X()|0)|268435456,A[y>>2]=d|_,A[y+4>>2]=f,y=0,y|0)}function mx(d,f,p){return d=d|0,f=f|0,p=p|0,!0&(f&2013265920|0)==268435456?(A[p>>2]=d,A[p+4>>2]=f&-2130706433|134217728,p=0,p|0):(p=6,p|0)}function gx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return y=K,K=K+16|0,_=y,A[_>>2]=0,!0&(f&2013265920|0)==268435456?(w=Ct(d|0,f|0,56)|0,X()|0,_=bi(d,f&-2130706433|134217728,w&7,_,p)|0,K=y,_|0):(_=6,K=y,_|0)}function A1(d,f){d=d|0,f=f|0;var p=0;switch(p=Ct(d|0,f|0,56)|0,X()|0,p&7){case 0:case 7:return p=0,p|0}return p=f&-2130706433|134217728,!(!0&(f&2013265920|0)==268435456)||!0&(f&117440512|0)==16777216&(wi(d,p)|0)!=0?(p=0,p|0):(p=Td(d,p)|0,p|0)}function vx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;return y=K,K=K+16|0,_=y,!0&(f&2013265920|0)==268435456?(w=f&-2130706433|134217728,M=p,A[M>>2]=d,A[M+4>>2]=w,A[_>>2]=0,f=Ct(d|0,f|0,56)|0,X()|0,_=bi(d,w,f&7,_,p+8|0)|0,K=y,_|0):(_=6,K=y,_|0)}function _x(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;return y=(wi(d,f)|0)==0,f=f&-2130706433,_=p,A[_>>2]=y?d:0,A[_+4>>2]=y?f|285212672:0,_=p+8|0,A[_>>2]=d,A[_+4>>2]=f|301989888,_=p+16|0,A[_>>2]=d,A[_+4>>2]=f|318767104,_=p+24|0,A[_>>2]=d,A[_+4>>2]=f|335544320,_=p+32|0,A[_>>2]=d,A[_+4>>2]=f|352321536,p=p+40|0,A[p>>2]=d,A[p+4>>2]=f|369098752,0}function Sd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;return M=K,K=K+16|0,y=M,w=f&-2130706433|134217728,!0&(f&2013265920|0)==268435456?(_=Ct(d|0,f|0,56)|0,X()|0,_=yp(d,w,_&7)|0,(_|0)==-1?(A[p>>2]=0,w=6,K=M,w|0):(Bu(d,w,y)|0&&et(27795,26932,282,26947),f=Ct(d|0,f|0,52)|0,X()|0,f=f&15,wi(d,w)|0?np(y,f,_,2,p):wd(y,f,_,2,p),w=0,K=M,w|0)):(w=6,K=M,w|0)}function yx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;_=K,K=K+16|0,y=_,xx(d,f,p,y),xd(y,p+4|0),K=_}function xx(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0;if(R=K,K=K+16|0,B=R,bx(d,p,B),w=+Wi(+(1-+te[B>>3]*.5)),w<1e-16){A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,A[_+12>>2]=0,K=R;return}if(B=A[p>>2]|0,y=+te[15920+(B*24|0)>>3],y=+$c(y-+$c(+Cx(15600+(B<<4)|0,d))),bs(f)|0?M=+$c(y+-.3334731722518321):M=y,y=+Er(+w)*2.618033988749896,(f|0)>0){d=0;do y=y*2.6457513110645907,d=d+1|0;while((d|0)!=(f|0))}w=+an(+M)*y,te[_>>3]=w,M=+mn(+M)*y,te[_+8>>3]=M,K=R}function bx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(w=K,K=K+32|0,y=w,ju(d,y),A[f>>2]=0,te[p>>3]=5,_=+tr(16400,y),_<+te[p>>3]&&(A[f>>2]=0,te[p>>3]=_),_=+tr(16424,y),_<+te[p>>3]&&(A[f>>2]=1,te[p>>3]=_),_=+tr(16448,y),_<+te[p>>3]&&(A[f>>2]=2,te[p>>3]=_),_=+tr(16472,y),_<+te[p>>3]&&(A[f>>2]=3,te[p>>3]=_),_=+tr(16496,y),_<+te[p>>3]&&(A[f>>2]=4,te[p>>3]=_),_=+tr(16520,y),_<+te[p>>3]&&(A[f>>2]=5,te[p>>3]=_),_=+tr(16544,y),_<+te[p>>3]&&(A[f>>2]=6,te[p>>3]=_),_=+tr(16568,y),_<+te[p>>3]&&(A[f>>2]=7,te[p>>3]=_),_=+tr(16592,y),_<+te[p>>3]&&(A[f>>2]=8,te[p>>3]=_),_=+tr(16616,y),_<+te[p>>3]&&(A[f>>2]=9,te[p>>3]=_),_=+tr(16640,y),_<+te[p>>3]&&(A[f>>2]=10,te[p>>3]=_),_=+tr(16664,y),_<+te[p>>3]&&(A[f>>2]=11,te[p>>3]=_),_=+tr(16688,y),_<+te[p>>3]&&(A[f>>2]=12,te[p>>3]=_),_=+tr(16712,y),_<+te[p>>3]&&(A[f>>2]=13,te[p>>3]=_),_=+tr(16736,y),_<+te[p>>3]&&(A[f>>2]=14,te[p>>3]=_),_=+tr(16760,y),_<+te[p>>3]&&(A[f>>2]=15,te[p>>3]=_),_=+tr(16784,y),_<+te[p>>3]&&(A[f>>2]=16,te[p>>3]=_),_=+tr(16808,y),_<+te[p>>3]&&(A[f>>2]=17,te[p>>3]=_),_=+tr(16832,y),_<+te[p>>3]&&(A[f>>2]=18,te[p>>3]=_),_=+tr(16856,y),!(_<+te[p>>3])){K=w;return}A[f>>2]=19,te[p>>3]=_,K=w}function Ru(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0;if(w=+Bl(d),w<1e-16){f=15600+(f<<4)|0,A[y>>2]=A[f>>2],A[y+4>>2]=A[f+4>>2],A[y+8>>2]=A[f+8>>2],A[y+12>>2]=A[f+12>>2];return}if(M=+Ge(+ +te[d+8>>3],+ +te[d>>3]),(p|0)>0){d=0;do w=w*.37796447300922725,d=d+1|0;while((d|0)!=(p|0))}R=w*.3333333333333333,_?(p=(bs(p)|0)==0,w=+ce(+((p?R:R*.37796447300922725)*.381966011250105))):(w=+ce(+(w*.381966011250105)),bs(p)|0&&(M=+$c(M+.3334731722518321))),Nx(15600+(f<<4)|0,+$c(+te[15920+(f*24|0)>>3]-M),w,y)}function tf(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;_=K,K=K+16|0,y=_,Mu(d+4|0,y),Ru(y,A[d>>2]|0,f,0,p),K=_}function np(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,zt=0,xn=0,si=0,Cn=0;if(xn=K,K=K+272|0,w=xn+256|0,Xe=xn+240|0,En=xn,fn=xn+224|0,zt=xn+208|0,He=xn+176|0,Pe=xn+160|0,kt=xn+192|0,un=xn+144|0,on=xn+128|0,kn=xn+112|0,Dn=xn+96|0,Zn=xn+80|0,A[w>>2]=f,A[Xe>>2]=A[d>>2],A[Xe+4>>2]=A[d+4>>2],A[Xe+8>>2]=A[d+8>>2],A[Xe+12>>2]=A[d+12>>2],ip(Xe,w,En),A[y>>2]=0,Xe=_+p+((_|0)==5&1)|0,(Xe|0)<=(p|0)){K=xn;return}B=A[w>>2]|0,F=fn+4|0,W=He+4|0,oe=p+5|0,ve=16880+(B<<2)|0,ge=16960+(B<<2)|0,_e=on+8|0,De=kn+8|0,ze=Dn+8|0,nt=zt+4|0,R=p;e:for(;;){M=En+(((R|0)%5|0)<<4)|0,A[zt>>2]=A[M>>2],A[zt+4>>2]=A[M+4>>2],A[zt+8>>2]=A[M+8>>2],A[zt+12>>2]=A[M+12>>2];do;while((Du(zt,B,0,1)|0)==2);if((R|0)>(p|0)&(bs(f)|0)!=0){if(A[He>>2]=A[zt>>2],A[He+4>>2]=A[zt+4>>2],A[He+8>>2]=A[zt+8>>2],A[He+12>>2]=A[zt+12>>2],Mu(F,Pe),_=A[He>>2]|0,w=A[17040+(_*80|0)+(A[fn>>2]<<2)>>2]|0,A[He>>2]=A[18640+(_*80|0)+(w*20|0)>>2],M=A[18640+(_*80|0)+(w*20|0)+16>>2]|0,(M|0)>0){d=0;do u1(W),d=d+1|0;while((d|0)<(M|0))}switch(M=18640+(_*80|0)+(w*20|0)+4|0,A[kt>>2]=A[M>>2],A[kt+4>>2]=A[M+4>>2],A[kt+8>>2]=A[M+8>>2],jc(kt,(A[ve>>2]|0)*3|0),us(W,kt,W),Pr(W),Mu(W,un),si=+(A[ge>>2]|0),te[on>>3]=si*3,te[_e>>3]=0,Cn=si*-1.5,te[kn>>3]=Cn,te[De>>3]=si*2.598076211353316,te[Dn>>3]=Cn,te[ze>>3]=si*-2.598076211353316,A[17040+((A[He>>2]|0)*80|0)+(A[zt>>2]<<2)>>2]|0){case 1:{d=kn,_=on;break}case 3:{d=Dn,_=kn;break}case 2:{d=on,_=Dn;break}default:{d=12;break e}}vp(Pe,un,_,d,Zn),Ru(Zn,A[He>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1}if((R|0)<(oe|0)&&(Mu(nt,He),Ru(He,A[zt>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1),A[fn>>2]=A[zt>>2],A[fn+4>>2]=A[zt+4>>2],A[fn+8>>2]=A[zt+8>>2],A[fn+12>>2]=A[zt+12>>2],R=R+1|0,(R|0)>=(Xe|0)){d=3;break}}if((d|0)==3){K=xn;return}else(d|0)==12&&et(26970,27017,572,27027)}function ip(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;B=K,K=K+128|0,_=B+64|0,y=B,w=_,M=20240,R=w+60|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));w=y,M=20304,R=w+60|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));R=(bs(A[f>>2]|0)|0)==0,_=R?_:y,y=d+4|0,c1(y),h1(y),bs(A[f>>2]|0)|0&&(Cu(y),A[f>>2]=(A[f>>2]|0)+1),A[p>>2]=A[d>>2],f=p+4|0,us(y,_,f),Pr(f),A[p+16>>2]=A[d>>2],f=p+20|0,us(y,_+12|0,f),Pr(f),A[p+32>>2]=A[d>>2],f=p+36|0,us(y,_+24|0,f),Pr(f),A[p+48>>2]=A[d>>2],f=p+52|0,us(y,_+36|0,f),Pr(f),A[p+64>>2]=A[d>>2],p=p+68|0,us(y,_+48|0,p),Pr(p),K=B}function Du(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0;if(_e=K,K=K+32|0,ve=_e+12|0,R=_e,ge=d+4|0,oe=A[16960+(f<<2)>>2]|0,W=(_|0)!=0,oe=W?oe*3|0:oe,y=A[ge>>2]|0,F=d+8|0,M=A[F>>2]|0,W){if(w=d+12|0,_=A[w>>2]|0,y=M+y+_|0,(y|0)==(oe|0))return ge=1,K=_e,ge|0;B=w}else B=d+12|0,_=A[B>>2]|0,y=M+y+_|0;if((y|0)<=(oe|0))return ge=0,K=_e,ge|0;do if((_|0)>0){if(_=A[d>>2]|0,(M|0)>0){w=18640+(_*80|0)+60|0,_=d;break}_=18640+(_*80|0)+40|0,p?(Tu(ve,oe,0,0),ef(ge,ve,R),bd(R),us(R,ve,ge),w=_,_=d):(w=_,_=d)}else w=18640+((A[d>>2]|0)*80|0)+20|0,_=d;while(!1);if(A[_>>2]=A[w>>2],y=w+16|0,(A[y>>2]|0)>0){_=0;do u1(ge),_=_+1|0;while((_|0)<(A[y>>2]|0))}return d=w+4|0,A[ve>>2]=A[d>>2],A[ve+4>>2]=A[d+4>>2],A[ve+8>>2]=A[d+8>>2],f=A[16880+(f<<2)>>2]|0,jc(ve,W?f*3|0:f),us(ge,ve,ge),Pr(ge),W?_=((A[F>>2]|0)+(A[ge>>2]|0)+(A[B>>2]|0)|0)==(oe|0)?1:2:_=2,ge=_,K=_e,ge|0}function p1(d,f){d=d|0,f=f|0;var p=0;do p=Du(d,f,0,1)|0;while((p|0)==2);return p|0}function wd(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0;if(Dn=K,K=K+240|0,w=Dn+224|0,kt=Dn+208|0,un=Dn,on=Dn+192|0,kn=Dn+176|0,ze=Dn+160|0,nt=Dn+144|0,Xe=Dn+128|0,He=Dn+112|0,Pe=Dn+96|0,A[w>>2]=f,A[kt>>2]=A[d>>2],A[kt+4>>2]=A[d+4>>2],A[kt+8>>2]=A[d+8>>2],A[kt+12>>2]=A[d+12>>2],rp(kt,w,un),A[y>>2]=0,De=_+p+((_|0)==6&1)|0,(De|0)<=(p|0)){K=Dn;return}B=A[w>>2]|0,F=p+6|0,W=16960+(B<<2)|0,oe=nt+8|0,ve=Xe+8|0,ge=He+8|0,_e=on+4|0,M=0,R=p,_=-1;e:for(;;){if(w=(R|0)%6|0,d=un+(w<<4)|0,A[on>>2]=A[d>>2],A[on+4>>2]=A[d+4>>2],A[on+8>>2]=A[d+8>>2],A[on+12>>2]=A[d+12>>2],d=M,M=Du(on,B,0,1)|0,(R|0)>(p|0)&(bs(f)|0)!=0&&(d|0)!=1&&(A[on>>2]|0)!=(_|0)){switch(Mu(un+(((w+5|0)%6|0)<<4)+4|0,kn),Mu(un+(w<<4)+4|0,ze),Zn=+(A[W>>2]|0),te[nt>>3]=Zn*3,te[oe>>3]=0,En=Zn*-1.5,te[Xe>>3]=En,te[ve>>3]=Zn*2.598076211353316,te[He>>3]=En,te[ge>>3]=Zn*-2.598076211353316,w=A[kt>>2]|0,A[17040+(w*80|0)+(((_|0)==(w|0)?A[on>>2]|0:_)<<2)>>2]|0){case 1:{d=Xe,_=nt;break}case 3:{d=He,_=Xe;break}case 2:{d=nt,_=He;break}default:{d=8;break e}}vp(kn,ze,_,d,Pe),!(_p(kn,Pe)|0)&&!(_p(ze,Pe)|0)&&(Ru(Pe,A[kt>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1)}if((R|0)<(F|0)&&(Mu(_e,kn),Ru(kn,A[on>>2]|0,B,1,y+8+(A[y>>2]<<4)|0),A[y>>2]=(A[y>>2]|0)+1),R=R+1|0,(R|0)>=(De|0)){d=3;break}else _=A[on>>2]|0}if((d|0)==3){K=Dn;return}else(d|0)==8&&et(27054,27017,737,27099)}function rp(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;B=K,K=K+160|0,_=B+80|0,y=B,w=_,M=20368,R=w+72|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));w=y,M=20448,R=w+72|0;do A[w>>2]=A[M>>2],w=w+4|0,M=M+4|0;while((w|0)<(R|0));R=(bs(A[f>>2]|0)|0)==0,_=R?_:y,y=d+4|0,c1(y),h1(y),bs(A[f>>2]|0)|0&&(Cu(y),A[f>>2]=(A[f>>2]|0)+1),A[p>>2]=A[d>>2],f=p+4|0,us(y,_,f),Pr(f),A[p+16>>2]=A[d>>2],f=p+20|0,us(y,_+12|0,f),Pr(f),A[p+32>>2]=A[d>>2],f=p+36|0,us(y,_+24|0,f),Pr(f),A[p+48>>2]=A[d>>2],f=p+52|0,us(y,_+36|0,f),Pr(f),A[p+64>>2]=A[d>>2],f=p+68|0,us(y,_+48|0,f),Pr(f),A[p+80>>2]=A[d>>2],p=p+84|0,us(y,_+60|0,p),Pr(p),K=B}function Wc(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,52)|0,X()|0,f&15|0}function m1(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,45)|0,X()|0,f&127|0}function Sx(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,(p+-1|0)>>>0>14?(_=4,_|0):(p=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,A[_>>2]=p&7,_=0,_|0)}function wx(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;if(d>>>0>15)return _=4,_|0;if(f>>>0>121)return _=17,_|0;M=Ot(d|0,0,52)|0,y=X()|0,R=Ot(f|0,0,45)|0,y=y|(X()|0)|134225919;e:do if((d|0)>=1){for(R=1,M=(xt[20528+f>>0]|0)!=0,w=-1;;){if(f=A[p+(R+-1<<2)>>2]|0,f>>>0>6){y=18,f=10;break}if(!((f|0)==0|M^1))if((f|0)==1){y=19,f=10;break}else M=0;if(F=(15-R|0)*3|0,B=Ot(7,0,F|0)|0,y=y&~(X()|0),f=Ot(f|0,((f|0)<0)<<31>>31|0,F|0)|0,w=f|w&~B,y=X()|0|y,(R|0)<(d|0))R=R+1|0;else break e}if((f|0)==10)return y|0}else w=-1;while(!1);return F=_,A[F>>2]=w,A[F+4>>2]=y,F=0,F|0}function Td(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return!(!0&(f&-16777216|0)==134217728)||(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0,p=p&127,p>>>0>121)?(d=0,d|0):(M=(_^15)*3|0,y=Ct(d|0,f|0,M|0)|0,M=Ot(y|0,X()|0,M|0)|0,y=X()|0,w=Lr(-1227133514,-1171,M|0,y|0)|0,!((M&613566756&w|0)==0&(y&4681&(X()|0)|0)==0)||(M=(_*3|0)+19|0,w=Ot(~d|0,~f|0,M|0)|0,M=Ct(w|0,X()|0,M|0)|0,!((_|0)==15|(M|0)==0&(X()|0)==0))?(M=0,M|0):!(xt[20528+p>>0]|0)||(f=f&8191,(d|0)==0&(f|0)==0)?(M=1,M|0):(M=of(d|0,f|0)|0,X()|0,((63-M|0)%3|0|0)!=0|0))}function g1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return!0&(f&-16777216|0)==134217728&&(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0,p=p&127,p>>>0<=121)&&(M=(_^15)*3|0,y=Ct(d|0,f|0,M|0)|0,M=Ot(y|0,X()|0,M|0)|0,y=X()|0,w=Lr(-1227133514,-1171,M|0,y|0)|0,(M&613566756&w|0)==0&(y&4681&(X()|0)|0)==0)&&(M=(_*3|0)+19|0,w=Ot(~d|0,~f|0,M|0)|0,M=Ct(w|0,X()|0,M|0)|0,(_|0)==15|(M|0)==0&(X()|0)==0)&&(!(xt[20528+p>>0]|0)||(p=f&8191,(d|0)==0&(p|0)==0)||(M=of(d|0,p|0)|0,X()|0,(63-M|0)%3|0|0))||A1(d,f)|0?(M=1,M|0):(M=(al(d,f)|0)!=0&1,M|0)}function Pu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0;if(y=Ot(f|0,0,52)|0,w=X()|0,p=Ot(p|0,0,45)|0,p=w|(X()|0)|134225919,(f|0)<1){w=-1,_=p,f=d,A[f>>2]=w,d=d+4|0,A[d>>2]=_;return}for(w=1,y=-1;M=(15-w|0)*3|0,R=Ot(7,0,M|0)|0,p=p&~(X()|0),M=Ot(_|0,0,M|0)|0,y=y&~R|M,p=p|(X()|0),(w|0)!=(f|0);)w=w+1|0;R=d,M=R,A[M>>2]=y,R=R+4|0,A[R>>2]=p}function Lu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;if(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,p>>>0>15)return _=4,_|0;if((w|0)<(p|0))return _=12,_|0;if((w|0)==(p|0))return A[_>>2]=d,A[_+4>>2]=f,_=0,_|0;if(y=Ot(p|0,0,52)|0,y=y|d,d=X()|0|f&-15728641,(w|0)>(p|0))do f=Ot(7,0,(14-p|0)*3|0)|0,p=p+1|0,y=f|y,d=X()|0|d;while((p|0)<(w|0));return A[_>>2]=y,A[_+4>>2]=d,_=0,_|0}function nf(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,!((p|0)<16&(w|0)<=(p|0)))return _=4,_|0;y=p-w|0,p=Ct(d|0,f|0,45)|0,X()|0;e:do if(!(Ji(p&127)|0))p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,y=X()|0;else{t:do if(w|0){for(p=1;M=Ot(7,0,(15-p|0)*3|0)|0,!!((M&d|0)==0&((X()|0)&f|0)==0);)if(p>>>0>>0)p=p+1|0;else break t;p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,y=X()|0;break e}while(!1);p=Lo(7,0,y,((y|0)<0)<<31>>31)|0,p=ur(p|0,X()|0,5,0)|0,p=tn(p|0,X()|0,-5,-1)|0,p=Io(p|0,X()|0,6,0)|0,p=tn(p|0,X()|0,1,0)|0,y=X()|0}while(!1);return M=_,A[M>>2]=p,A[M+4>>2]=y,M=0,M|0}function wi(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;if(y=Ct(d|0,f|0,45)|0,X()|0,!(Ji(y&127)|0))return y=0,y|0;y=Ct(d|0,f|0,52)|0,X()|0,y=y&15;e:do if(!y)p=0;else for(_=1;;){if(p=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,p=p&7,p|0)break e;if(_>>>0>>0)_=_+1|0;else{p=0;break}}while(!1);return y=(p|0)==0&1,y|0}function v1(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0;if(M=K,K=K+16|0,w=M,nl(w,d,f,p),f=w,d=A[f>>2]|0,f=A[f+4>>2]|0,(d|0)==0&(f|0)==0)return K=M,0;y=0,p=0;do R=_+(y<<3)|0,A[R>>2]=d,A[R+4>>2]=f,y=tn(y|0,p|0,1,0)|0,p=X()|0,rf(w),R=w,d=A[R>>2]|0,f=A[R+4>>2]|0;while(!((d|0)==0&(f|0)==0));return K=M,0}function sp(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,(_|0)<(p|0)?(p=f,_=d,he(p|0),_|0):(p=Ot(-1,-1,((_-p|0)*3|0)+3|0)|0,_=Ot(~p|0,~(X()|0)|0,(15-_|0)*3|0)|0,p=~(X()|0)&f,_=~_&d,he(p|0),_|0)}function Md(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0;return y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,(p|0)<16&(y|0)<=(p|0)?((y|0)<(p|0)&&(y=Ot(-1,-1,((p+-1-y|0)*3|0)+3|0)|0,y=Ot(~y|0,~(X()|0)|0,(15-p|0)*3|0)|0,f=~(X()|0)&f,d=~y&d),y=Ot(p|0,0,52)|0,p=f&-15728641|(X()|0),A[_>>2]=d|y,A[_+4>>2]=p,_=0,_|0):(_=4,_|0)}function ap(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,zt=0;if((p|0)==0&(_|0)==0)return zt=0,zt|0;if(y=d,w=A[y>>2]|0,y=A[y+4>>2]|0,!0&(y&15728640|0)==0){if(!((_|0)>0|(_|0)==0&p>>>0>0)||(zt=f,A[zt>>2]=w,A[zt+4>>2]=y,(p|0)==1&(_|0)==0))return zt=0,zt|0;y=1,w=0;do En=d+(y<<3)|0,fn=A[En+4>>2]|0,zt=f+(y<<3)|0,A[zt>>2]=A[En>>2],A[zt+4>>2]=fn,y=tn(y|0,w|0,1,0)|0,w=X()|0;while((w|0)<(_|0)|(w|0)==(_|0)&y>>>0

>>0);return y=0,y|0}if(Zn=p<<3,fn=Oo(Zn)|0,!fn)return zt=13,zt|0;if(Ol(fn|0,d|0,Zn|0)|0,En=Ys(p,8)|0,!En)return vn(fn),zt=13,zt|0;e:for(;;){y=fn,F=A[y>>2]|0,y=A[y+4>>2]|0,kn=Ct(F|0,y|0,52)|0,X()|0,kn=kn&15,Dn=kn+-1|0,on=(kn|0)!=0,un=(_|0)>0|(_|0)==0&p>>>0>0;t:do if(on&un){if(Xe=Ot(Dn|0,0,52)|0,He=X()|0,Dn>>>0>15){if(!((F|0)==0&(y|0)==0)){zt=16;break e}for(w=0,d=0;;){if(w=tn(w|0,d|0,1,0)|0,d=X()|0,!((d|0)<(_|0)|(d|0)==(_|0)&w>>>0

>>0))break t;if(M=fn+(w<<3)|0,kt=A[M>>2]|0,M=A[M+4>>2]|0,!((kt|0)==0&(M|0)==0)){y=M,zt=16;break e}}}for(R=F,d=y,w=0,M=0;;){if(!((R|0)==0&(d|0)==0)){if(!(!0&(d&117440512|0)==0)){zt=21;break e}if(W=Ct(R|0,d|0,52)|0,X()|0,W=W&15,(W|0)<(Dn|0)){y=12,zt=27;break e}if((W|0)!=(Dn|0)&&(R=R|Xe,d=d&-15728641|He,W>>>0>=kn>>>0)){B=Dn;do kt=Ot(7,0,(14-B|0)*3|0)|0,B=B+1|0,R=kt|R,d=X()|0|d;while(B>>>0>>0)}if(ve=Yu(R|0,d|0,p|0,_|0)|0,ge=X()|0,B=En+(ve<<3)|0,W=B,oe=A[W>>2]|0,W=A[W+4>>2]|0,!((oe|0)==0&(W|0)==0)){ze=0,nt=0;do{if((ze|0)>(_|0)|(ze|0)==(_|0)&nt>>>0>p>>>0){zt=31;break e}if((oe|0)==(R|0)&(W&-117440513|0)==(d|0)){_e=Ct(oe|0,W|0,56)|0,X()|0,_e=_e&7,De=_e+1|0,kt=Ct(oe|0,W|0,45)|0,X()|0;n:do if(!(Ji(kt&127)|0))W=7;else{if(oe=Ct(oe|0,W|0,52)|0,X()|0,oe=oe&15,!oe){W=6;break}for(W=1;;){if(kt=Ot(7,0,(15-W|0)*3|0)|0,!((kt&R|0)==0&((X()|0)&d|0)==0)){W=7;break n}if(W>>>0>>0)W=W+1|0;else{W=6;break}}}while(!1);if((_e+2|0)>>>0>W>>>0){zt=41;break e}kt=Ot(De|0,0,56)|0,d=X()|0|d&-117440513,Pe=B,A[Pe>>2]=0,A[Pe+4>>2]=0,R=kt|R}else ve=tn(ve|0,ge|0,1,0)|0,ve=Kc(ve|0,X()|0,p|0,_|0)|0,ge=X()|0;nt=tn(nt|0,ze|0,1,0)|0,ze=X()|0,B=En+(ve<<3)|0,W=B,oe=A[W>>2]|0,W=A[W+4>>2]|0}while(!((oe|0)==0&(W|0)==0))}kt=B,A[kt>>2]=R,A[kt+4>>2]=d}if(w=tn(w|0,M|0,1,0)|0,M=X()|0,!((M|0)<(_|0)|(M|0)==(_|0)&w>>>0

>>0))break t;d=fn+(w<<3)|0,R=A[d>>2]|0,d=A[d+4>>2]|0}}while(!1);if(kt=tn(p|0,_|0,5,0)|0,Pe=X()|0,Pe>>>0<0|(Pe|0)==0&kt>>>0<11){zt=85;break}if(kt=Io(p|0,_|0,6,0)|0,X()|0,kt=Ys(kt,8)|0,!kt){zt=48;break}do if(un){for(De=0,d=0,_e=0,ze=0;;){if(W=En+(De<<3)|0,M=W,w=A[M>>2]|0,M=A[M+4>>2]|0,(w|0)==0&(M|0)==0)Pe=_e;else{oe=Ct(w|0,M|0,56)|0,X()|0,oe=oe&7,R=oe+1|0,ve=M&-117440513,Pe=Ct(w|0,M|0,45)|0,X()|0;t:do if(Ji(Pe&127)|0){if(ge=Ct(w|0,M|0,52)|0,X()|0,ge=ge&15,ge|0)for(B=1;;){if(Pe=Ot(7,0,(15-B|0)*3|0)|0,!((w&Pe|0)==0&(ve&(X()|0)|0)==0))break t;if(B>>>0>>0)B=B+1|0;else break}M=Ot(R|0,0,56)|0,w=M|w,M=X()|0|ve,R=W,A[R>>2]=w,A[R+4>>2]=M,R=oe+2|0}while(!1);(R|0)==7?(Pe=kt+(d<<3)|0,A[Pe>>2]=w,A[Pe+4>>2]=M&-117440513,d=tn(d|0,_e|0,1,0)|0,Pe=X()|0):Pe=_e}if(De=tn(De|0,ze|0,1,0)|0,ze=X()|0,(ze|0)<(_|0)|(ze|0)==(_|0)&De>>>0

>>0)_e=Pe;else break}if(un){if(nt=Dn>>>0>15,Xe=Ot(Dn|0,0,52)|0,He=X()|0,!on){for(w=0,B=0,R=0,M=0;(F|0)==0&(y|0)==0||(Dn=f+(w<<3)|0,A[Dn>>2]=F,A[Dn+4>>2]=y,w=tn(w|0,B|0,1,0)|0,B=X()|0),R=tn(R|0,M|0,1,0)|0,M=X()|0,!!((M|0)<(_|0)|(M|0)==(_|0)&R>>>0

>>0);)y=fn+(R<<3)|0,F=A[y>>2]|0,y=A[y+4>>2]|0;y=Pe;break}for(w=0,B=0,M=0,R=0;;){do if(!((F|0)==0&(y|0)==0)){if(ge=Ct(F|0,y|0,52)|0,X()|0,ge=ge&15,nt|(ge|0)<(Dn|0)){zt=80;break e}if((ge|0)!=(Dn|0)){if(W=F|Xe,oe=y&-15728641|He,ge>>>0>=kn>>>0){ve=Dn;do on=Ot(7,0,(14-ve|0)*3|0)|0,ve=ve+1|0,W=on|W,oe=X()|0|oe;while(ve>>>0>>0)}}else W=F,oe=y;_e=Yu(W|0,oe|0,p|0,_|0)|0,ve=0,ge=0,ze=X()|0;do{if((ve|0)>(_|0)|(ve|0)==(_|0)&ge>>>0>p>>>0){zt=81;break e}if(on=En+(_e<<3)|0,De=A[on+4>>2]|0,(De&-117440513|0)==(oe|0)&&(A[on>>2]|0)==(W|0)){zt=65;break}on=tn(_e|0,ze|0,1,0)|0,_e=Kc(on|0,X()|0,p|0,_|0)|0,ze=X()|0,ge=tn(ge|0,ve|0,1,0)|0,ve=X()|0,on=En+(_e<<3)|0}while(!((A[on>>2]|0)==(W|0)&&(A[on+4>>2]|0)==(oe|0)));if((zt|0)==65&&(zt=0,!0&(De&117440512|0)==100663296))break;on=f+(w<<3)|0,A[on>>2]=F,A[on+4>>2]=y,w=tn(w|0,B|0,1,0)|0,B=X()|0}while(!1);if(M=tn(M|0,R|0,1,0)|0,R=X()|0,!((R|0)<(_|0)|(R|0)==(_|0)&M>>>0

>>0))break;y=fn+(M<<3)|0,F=A[y>>2]|0,y=A[y+4>>2]|0}y=Pe}else w=0,y=Pe}else w=0,d=0,y=0;while(!1);if(ao(En|0,0,Zn|0)|0,Ol(fn|0,kt|0,d<<3|0)|0,vn(kt),(d|0)==0&(y|0)==0){zt=89;break}else f=f+(w<<3)|0,_=y,p=d}if((zt|0)==16)!0&(y&117440512|0)==0?(y=4,zt=27):zt=21;else if((zt|0)==31)et(27795,27122,620,27132);else{if((zt|0)==41)return vn(fn),vn(En),zt=10,zt|0;if((zt|0)==48)return vn(fn),vn(En),zt=13,zt|0;(zt|0)==80?et(27795,27122,711,27132):(zt|0)==81?et(27795,27122,723,27132):(zt|0)==85&&(Ol(f|0,fn|0,p<<3|0)|0,zt=89)}return(zt|0)==21?(vn(fn),vn(En),zt=5,zt|0):(zt|0)==27?(vn(fn),vn(En),zt=y,zt|0):(zt|0)==89?(vn(fn),vn(En),zt=0,zt|0):0}function _1(d,f,p,_,y,w,M){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0,M=M|0;var R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0;if(De=K,K=K+16|0,_e=De,!((p|0)>0|(p|0)==0&f>>>0>0))return _e=0,K=De,_e|0;if((M|0)>=16)return _e=12,K=De,_e|0;ve=0,ge=0,oe=0,R=0;e:for(;;){if(F=d+(ve<<3)|0,B=A[F>>2]|0,F=A[F+4>>2]|0,W=Ct(B|0,F|0,52)|0,X()|0,(W&15|0)>(M|0)){R=12,B=11;break}if(nl(_e,B,F,M),W=_e,F=A[W>>2]|0,W=A[W+4>>2]|0,(F|0)==0&(W|0)==0)B=oe;else{B=oe;do{if(!((R|0)<(w|0)|(R|0)==(w|0)&B>>>0>>0)){B=10;break e}oe=_+(B<<3)|0,A[oe>>2]=F,A[oe+4>>2]=W,B=tn(B|0,R|0,1,0)|0,R=X()|0,rf(_e),oe=_e,F=A[oe>>2]|0,W=A[oe+4>>2]|0}while(!((F|0)==0&(W|0)==0))}if(ve=tn(ve|0,ge|0,1,0)|0,ge=X()|0,(ge|0)<(p|0)|(ge|0)==(p|0)&ve>>>0>>0)oe=B;else{R=0,B=11;break}}return(B|0)==10?(_e=14,K=De,_e|0):(B|0)==11?(K=De,R|0):0}function y1(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0;ve=K,K=K+16|0,oe=ve;e:do if((p|0)>0|(p|0)==0&f>>>0>0){for(F=0,M=0,w=0,W=0;;){if(B=d+(F<<3)|0,R=A[B>>2]|0,B=A[B+4>>2]|0,!((R|0)==0&(B|0)==0)&&(B=(nf(R,B,_,oe)|0)==0,R=oe,M=tn(A[R>>2]|0,A[R+4>>2]|0,M|0,w|0)|0,w=X()|0,!B)){w=12;break}if(F=tn(F|0,W|0,1,0)|0,W=X()|0,!((W|0)<(p|0)|(W|0)==(p|0)&F>>>0>>0))break e}return K=ve,w|0}else M=0,w=0;while(!1);return A[y>>2]=M,A[y+4>>2]=w,y=0,K=ve,y|0}function x1(d,f){return d=d|0,f=f|0,f=Ct(d|0,f|0,52)|0,X()|0,f&1|0}function Hs(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,!y)return y=0,y|0;for(_=1;;){if(p=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,p=p&7,p|0){_=5;break}if(_>>>0>>0)_=_+1|0;else{p=0,_=5;break}}return(_|0)==5?p|0:0}function op(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(B=Ct(d|0,f|0,52)|0,X()|0,B=B&15,!B)return R=f,B=d,he(R|0),B|0;for(R=1,p=0;;){w=(15-R|0)*3|0,_=Ot(7,0,w|0)|0,y=X()|0,M=Ct(d|0,f|0,w|0)|0,X()|0,w=Ot(Nu(M&7)|0,0,w|0)|0,M=X()|0,d=w|d&~_,f=M|f&~y;e:do if(!p)if((w&_|0)==0&(M&y|0)==0)p=0;else if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(M=(15-p|0)*3|0,y=Ct(d|0,f|0,M|0)|0,X()|0,w=Ot(7,0,M|0)|0,f=f&~(X()|0),M=Ot(Nu(y&7)|0,0,M|0)|0,d=d&~w|M,f=f|(X()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return he(f|0),d|0}function Uu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)return p=f,_=d,he(p|0),_|0;for(p=1;w=(15-p|0)*3|0,M=Ct(d|0,f|0,w|0)|0,X()|0,y=Ot(7,0,w|0)|0,f=f&~(X()|0),w=Ot(Nu(M&7)|0,0,w|0)|0,d=w|d&~y,f=X()|0|f,p>>>0<_>>>0;)p=p+1|0;return he(f|0),d|0}function Tx(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(B=Ct(d|0,f|0,52)|0,X()|0,B=B&15,!B)return R=f,B=d,he(R|0),B|0;for(R=1,p=0;;){w=(15-R|0)*3|0,_=Ot(7,0,w|0)|0,y=X()|0,M=Ct(d|0,f|0,w|0)|0,X()|0,w=Ot(tl(M&7)|0,0,w|0)|0,M=X()|0,d=w|d&~_,f=M|f&~y;e:do if(!p)if((w&_|0)==0&(M&y|0)==0)p=0;else if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)p=1;else{p=1;t:for(;;){switch(M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,M&7){case 1:break t;case 0:break;default:{p=1;break e}}if(p>>>0<_>>>0)p=p+1|0;else{p=1;break e}}for(p=1;;)if(y=(15-p|0)*3|0,w=Ot(7,0,y|0)|0,M=f&~(X()|0),f=Ct(d|0,f|0,y|0)|0,X()|0,f=Ot(tl(f&7)|0,0,y|0)|0,d=d&~w|f,f=M|(X()|0),p>>>0<_>>>0)p=p+1|0;else{p=1;break}}while(!1);if(R>>>0>>0)R=R+1|0;else break}return he(f|0),d|0}function lp(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;if(_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,!_)return p=f,_=d,he(p|0),_|0;for(p=1;M=(15-p|0)*3|0,w=Ot(7,0,M|0)|0,y=f&~(X()|0),f=Ct(d|0,f|0,M|0)|0,X()|0,f=Ot(tl(f&7)|0,0,M|0)|0,d=f|d&~w,f=X()|0|y,p>>>0<_>>>0;)p=p+1|0;return he(f|0),d|0}function ha(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(B=K,K=K+64|0,R=B+40|0,_=B+24|0,y=B+12|0,w=B,Ot(f|0,0,52)|0,p=X()|0|134225919,!f)return(A[d+4>>2]|0)>2||(A[d+8>>2]|0)>2||(A[d+12>>2]|0)>2?(M=0,R=0,he(M|0),K=B,R|0):(Ot(Ro(d)|0,0,45)|0,M=X()|0|p,R=-1,he(M|0),K=B,R|0);if(A[R>>2]=A[d>>2],A[R+4>>2]=A[d+4>>2],A[R+8>>2]=A[d+8>>2],A[R+12>>2]=A[d+12>>2],M=R+4|0,(f|0)>0)for(d=-1;A[_>>2]=A[M>>2],A[_+4>>2]=A[M+4>>2],A[_+8>>2]=A[M+8>>2],f&1?(fx(M),A[y>>2]=A[M>>2],A[y+4>>2]=A[M+4>>2],A[y+8>>2]=A[M+8>>2],Hc(y)):(o1(M),A[y>>2]=A[M>>2],A[y+4>>2]=A[M+4>>2],A[y+8>>2]=A[M+8>>2],Cu(y)),ef(_,y,w),Pr(w),W=(15-f|0)*3|0,F=Ot(7,0,W|0)|0,p=p&~(X()|0),W=Ot(Eu(w)|0,0,W|0)|0,d=W|d&~F,p=X()|0|p,(f|0)>1;)f=f+-1|0;else d=-1;e:do if((A[M>>2]|0)<=2&&(A[R+8>>2]|0)<=2&&(A[R+12>>2]|0)<=2){if(_=Ro(R)|0,f=Ot(_|0,0,45)|0,f=f|d,d=X()|0|p&-1040385,w=K0(R)|0,!(Ji(_)|0)){if((w|0)<=0)break;for(y=0;;){if(_=Ct(f|0,d|0,52)|0,X()|0,_=_&15,_)for(p=1;W=(15-p|0)*3|0,R=Ct(f|0,d|0,W|0)|0,X()|0,F=Ot(7,0,W|0)|0,d=d&~(X()|0),W=Ot(Nu(R&7)|0,0,W|0)|0,f=f&~F|W,d=d|(X()|0),p>>>0<_>>>0;)p=p+1|0;if(y=y+1|0,(y|0)==(w|0))break e}}y=Ct(f|0,d|0,52)|0,X()|0,y=y&15;t:do if(y){p=1;n:for(;;){switch(W=Ct(f|0,d|0,(15-p|0)*3|0)|0,X()|0,W&7){case 1:break n;case 0:break;default:break t}if(p>>>0>>0)p=p+1|0;else break t}if(wu(_,A[R>>2]|0)|0)for(p=1;R=(15-p|0)*3|0,F=Ot(7,0,R|0)|0,W=d&~(X()|0),d=Ct(f|0,d|0,R|0)|0,X()|0,d=Ot(tl(d&7)|0,0,R|0)|0,f=f&~F|d,d=W|(X()|0),p>>>0>>0;)p=p+1|0;else for(p=1;W=(15-p|0)*3|0,R=Ct(f|0,d|0,W|0)|0,X()|0,F=Ot(7,0,W|0)|0,d=d&~(X()|0),W=Ot(Nu(R&7)|0,0,W|0)|0,f=f&~F|W,d=d|(X()|0),p>>>0>>0;)p=p+1|0}while(!1);if((w|0)>0){p=0;do f=op(f,d)|0,d=X()|0,p=p+1|0;while((p|0)!=(w|0))}}else f=0,d=0;while(!1);return F=d,W=f,he(F|0),K=B,W|0}function bs(d){return d=d|0,(d|0)%2|0|0}function Ed(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;return y=K,K=K+16|0,_=y,f>>>0>15?(_=4,K=y,_|0):(A[d+4>>2]&2146435072|0)==2146435072||(A[d+8+4>>2]&2146435072|0)==2146435072?(_=3,K=y,_|0):(yx(d,f,_),f=ha(_,f)|0,_=X()|0,A[p>>2]=f,A[p+4>>2]=_,(f|0)==0&(_|0)==0&&et(27795,27122,1050,27145),_=0,K=y,_|0)}function Cd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(y=p+4|0,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,M=Ct(d|0,f|0,45)|0,X()|0,_=(w|0)==0,Ji(M&127)|0){if(_)return M=1,M|0;_=1}else{if(_)return M=0,M|0;(A[y>>2]|0)==0&&(A[p+8>>2]|0)==0?_=(A[p+12>>2]|0)!=0&1:_=1}for(p=1;p&1?Hc(y):Cu(y),M=Ct(d|0,f|0,(15-p|0)*3|0)|0,X()|0,l1(y,M&7),p>>>0>>0;)p=p+1|0;return _|0}function Bu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+16|0,B=W,F=Ct(d|0,f|0,45)|0,X()|0,F=F&127,F>>>0>121)return A[p>>2]=0,A[p+4>>2]=0,A[p+8>>2]=0,A[p+12>>2]=0,F=5,K=W,F|0;e:do if((Ji(F)|0)!=0&&(w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,(w|0)!=0)){_=1;t:for(;;){switch(R=Ct(d|0,f|0,(15-_|0)*3|0)|0,X()|0,R&7){case 5:break t;case 0:break;default:{_=f;break e}}if(_>>>0>>0)_=_+1|0;else{_=f;break e}}for(y=1,_=f;f=(15-y|0)*3|0,M=Ot(7,0,f|0)|0,R=_&~(X()|0),_=Ct(d|0,_|0,f|0)|0,X()|0,_=Ot(tl(_&7)|0,0,f|0)|0,d=d&~M|_,_=R|(X()|0),y>>>0>>0;)y=y+1|0}else _=f;while(!1);if(R=7696+(F*28|0)|0,A[p>>2]=A[R>>2],A[p+4>>2]=A[R+4>>2],A[p+8>>2]=A[R+8>>2],A[p+12>>2]=A[R+12>>2],!(Cd(d,_,p)|0))return F=0,K=W,F|0;if(M=p+4|0,A[B>>2]=A[M>>2],A[B+4>>2]=A[M+4>>2],A[B+8>>2]=A[M+8>>2],w=Ct(d|0,_|0,52)|0,X()|0,R=w&15,w&1?(Cu(M),w=R+1|0):w=R,!(Ji(F)|0))_=0;else{e:do if(!R)_=0;else for(f=1;;){if(y=Ct(d|0,_|0,(15-f|0)*3|0)|0,X()|0,y=y&7,y|0){_=y;break e}if(f>>>0>>0)f=f+1|0;else{_=0;break}}while(!1);_=(_|0)==4&1}if(!(Du(p,w,_,0)|0))(w|0)!=(R|0)&&(A[M>>2]=A[B>>2],A[M+4>>2]=A[B+4>>2],A[M+8>>2]=A[B+8>>2]);else{if(Ji(F)|0)do;while((Du(p,w,0,0)|0)!=0);(w|0)!=(R|0)&&o1(M)}return F=0,K=W,F|0}function Dl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return w=K,K=K+16|0,_=w,y=Bu(d,f,_)|0,y|0?(K=w,y|0):(y=Ct(d|0,f|0,52)|0,X()|0,tf(_,y&15,p),y=0,K=w,y|0)}function Pl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0;if(M=K,K=K+16|0,w=M,_=Bu(d,f,w)|0,_|0)return w=_,K=M,w|0;_=Ct(d|0,f|0,45)|0,X()|0,_=(Ji(_&127)|0)==0,y=Ct(d|0,f|0,52)|0,X()|0,y=y&15;e:do if(!_){if(y|0)for(_=1;;){if(R=Ot(7,0,(15-_|0)*3|0)|0,!((R&d|0)==0&((X()|0)&f|0)==0))break e;if(_>>>0>>0)_=_+1|0;else break}return np(w,y,0,5,p),R=0,K=M,R|0}while(!1);return wd(w,y,0,6,p),R=0,K=M,R|0}function Mx(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(y=Ct(d|0,f|0,45)|0,X()|0,!(Ji(y&127)|0))return y=2,A[p>>2]=y,0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,!y)return y=5,A[p>>2]=y,0;for(_=1;;){if(w=Ot(7,0,(15-_|0)*3|0)|0,!((w&d|0)==0&((X()|0)&f|0)==0)){_=2,d=6;break}if(_>>>0>>0)_=_+1|0;else{_=5,d=6;break}}return(d|0)==6&&(A[p>>2]=_),0}function Ou(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0;oe=K,K=K+128|0,F=oe+112|0,w=oe+96|0,W=oe,y=Ct(d|0,f|0,52)|0,X()|0,R=y&15,A[F>>2]=R,M=Ct(d|0,f|0,45)|0,X()|0,M=M&127;e:do if(Ji(M)|0){if(R|0)for(_=1;;){if(B=Ot(7,0,(15-_|0)*3|0)|0,!((B&d|0)==0&((X()|0)&f|0)==0)){y=0;break e}if(_>>>0>>0)_=_+1|0;else break}if(y&1)y=1;else return B=Ot(R+1|0,0,52)|0,W=X()|0|f&-15728641,F=Ot(7,0,(14-R|0)*3|0)|0,W=Ou((B|d)&~F,W&~(X()|0),p)|0,K=oe,W|0}else y=0;while(!1);if(_=Bu(d,f,w)|0,!_){y?(ip(w,F,W),B=5):(rp(w,F,W),B=6);e:do if(Ji(M)|0)if(!R)d=5;else for(_=1;;){if(M=Ot(7,0,(15-_|0)*3|0)|0,!((M&d|0)==0&((X()|0)&f|0)==0)){d=2;break e}if(_>>>0>>0)_=_+1|0;else{d=5;break}}else d=2;while(!1);ao(p|0,-1,d<<2|0)|0;e:do if(y)for(w=0;;){if(M=W+(w<<4)|0,p1(M,A[F>>2]|0)|0,M=A[M>>2]|0,R=A[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=d>>>0){_=1;break e}_=p+(y<<2)|0,R=A[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(A[_>>2]=M,w=w+1|0,w>>>0>=B>>>0){_=0;break}}else for(w=0;;){if(M=W+(w<<4)|0,Du(M,A[F>>2]|0,0,1)|0,M=A[M>>2]|0,R=A[p>>2]|0,(R|0)==-1|(R|0)==(M|0))_=p;else{y=0;do{if(y=y+1|0,y>>>0>=d>>>0){_=1;break e}_=p+(y<<2)|0,R=A[_>>2]|0}while(!((R|0)==-1|(R|0)==(M|0)))}if(A[_>>2]=M,w=w+1|0,w>>>0>=B>>>0){_=0;break}}while(!1)}return W=_,K=oe,W|0}function up(){return 12}function Iu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(d>>>0>15)return R=4,R|0;if(Ot(d|0,0,52)|0,R=X()|0|134225919,!d){p=0,_=0;do Ji(_)|0&&(Ot(_|0,0,45)|0,M=R|(X()|0),d=f+(p<<3)|0,A[d>>2]=-1,A[d+4>>2]=M,p=p+1|0),_=_+1|0;while((_|0)!=122);return p=0,p|0}p=0,M=0;do{if(Ji(M)|0){for(Ot(M|0,0,45)|0,_=1,y=-1,w=R|(X()|0);B=Ot(7,0,(15-_|0)*3|0)|0,y=y&~B,w=w&~(X()|0),(_|0)!=(d|0);)_=_+1|0;B=f+(p<<3)|0,A[B>>2]=y,A[B+4>>2]=w,p=p+1|0}M=M+1|0}while((M|0)!=122);return p=0,p|0}function cp(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0;if(Xe=K,K=K+16|0,ze=Xe,nt=Ct(d|0,f|0,52)|0,X()|0,nt=nt&15,p>>>0>15)return nt=4,K=Xe,nt|0;if((nt|0)<(p|0))return nt=12,K=Xe,nt|0;if((nt|0)!=(p|0))if(w=Ot(p|0,0,52)|0,w=w|d,R=X()|0|f&-15728641,(nt|0)>(p|0)){B=p;do De=Ot(7,0,(14-B|0)*3|0)|0,B=B+1|0,w=De|w,R=X()|0|R;while((B|0)<(nt|0));De=w}else De=w;else De=d,R=f;_e=Ct(De|0,R|0,45)|0,X()|0;e:do if(Ji(_e&127)|0){if(B=Ct(De|0,R|0,52)|0,X()|0,B=B&15,B|0)for(w=1;;){if(_e=Ot(7,0,(15-w|0)*3|0)|0,!((_e&De|0)==0&((X()|0)&R|0)==0)){F=33;break e}if(w>>>0>>0)w=w+1|0;else break}if(_e=_,A[_e>>2]=0,A[_e+4>>2]=0,(nt|0)>(p|0)){for(_e=f&-15728641,ge=nt;;){if(ve=ge,ge=ge+-1|0,ge>>>0>15|(nt|0)<(ge|0)){F=19;break}if((nt|0)!=(ge|0))if(w=Ot(ge|0,0,52)|0,w=w|d,B=X()|0|_e,(nt|0)<(ve|0))oe=w;else{F=ge;do oe=Ot(7,0,(14-F|0)*3|0)|0,F=F+1|0,w=oe|w,B=X()|0|B;while((F|0)<(nt|0));oe=w}else oe=d,B=f;if(W=Ct(oe|0,B|0,45)|0,X()|0,!(Ji(W&127)|0))w=0;else{W=Ct(oe|0,B|0,52)|0,X()|0,W=W&15;t:do if(!W)w=0;else for(F=1;;){if(w=Ct(oe|0,B|0,(15-F|0)*3|0)|0,X()|0,w=w&7,w|0)break t;if(F>>>0>>0)F=F+1|0;else{w=0;break}}while(!1);w=(w|0)==0&1}if(B=Ct(d|0,f|0,(15-ve|0)*3|0)|0,X()|0,B=B&7,(B|0)==7){y=5,F=42;break}if(w=(w|0)!=0,(B|0)==1&w){y=5,F=42;break}if(oe=B+(((B|0)!=0&w)<<31>>31)|0,oe|0&&(F=nt-ve|0,F=Lo(7,0,F,((F|0)<0)<<31>>31)|0,W=X()|0,w?(w=ur(F|0,W|0,5,0)|0,w=tn(w|0,X()|0,-5,-1)|0,w=Io(w|0,X()|0,6,0)|0,w=tn(w|0,X()|0,1,0)|0,B=X()|0):(w=F,B=W),ve=oe+-1|0,ve=ur(F|0,W|0,ve|0,((ve|0)<0)<<31>>31|0)|0,ve=tn(w|0,B|0,ve|0,X()|0)|0,oe=X()|0,W=_,W=tn(ve|0,oe|0,A[W>>2]|0,A[W+4>>2]|0)|0,oe=X()|0,ve=_,A[ve>>2]=W,A[ve+4>>2]=oe),(ge|0)<=(p|0)){F=37;break}}if((F|0)==19)et(27795,27122,1367,27158);else if((F|0)==37){M=_,y=A[M+4>>2]|0,M=A[M>>2]|0;break}else if((F|0)==42)return K=Xe,y|0}else y=0,M=0}else F=33;while(!1);e:do if((F|0)==33)if(_e=_,A[_e>>2]=0,A[_e+4>>2]=0,(nt|0)>(p|0)){for(w=nt;;){if(y=Ct(d|0,f|0,(15-w|0)*3|0)|0,X()|0,y=y&7,(y|0)==7){y=5;break}if(M=nt-w|0,M=Lo(7,0,M,((M|0)<0)<<31>>31)|0,y=ur(M|0,X()|0,y|0,0)|0,M=X()|0,_e=_,M=tn(A[_e>>2]|0,A[_e+4>>2]|0,y|0,M|0)|0,y=X()|0,_e=_,A[_e>>2]=M,A[_e+4>>2]=y,w=w+-1|0,(w|0)<=(p|0))break e}return K=Xe,y|0}else y=0,M=0;while(!1);return nf(De,R,nt,ze)|0&&et(27795,27122,1327,27173),nt=ze,ze=A[nt+4>>2]|0,((y|0)>-1|(y|0)==-1&M>>>0>4294967295)&((ze|0)>(y|0)|((ze|0)==(y|0)?(A[nt>>2]|0)>>>0>M>>>0:0))?(nt=0,K=Xe,nt|0):(et(27795,27122,1407,27158),0)}function b1(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0;if(oe=K,K=K+16|0,M=oe,y>>>0>15)return w=4,K=oe,w|0;if(R=Ct(p|0,_|0,52)|0,X()|0,R=R&15,(R|0)>(y|0))return w=12,K=oe,w|0;if(nf(p,_,y,M)|0&&et(27795,27122,1327,27173),W=M,F=A[W+4>>2]|0,!(((f|0)>-1|(f|0)==-1&d>>>0>4294967295)&((F|0)>(f|0)|((F|0)==(f|0)?(A[W>>2]|0)>>>0>d>>>0:0))))return w=2,K=oe,w|0;W=y-R|0,y=Ot(y|0,0,52)|0,B=X()|0|_&-15728641,F=w,A[F>>2]=y|p,A[F+4>>2]=B,F=Ct(p|0,_|0,45)|0,X()|0;e:do if(Ji(F&127)|0){if(R|0)for(M=1;;){if(F=Ot(7,0,(15-M|0)*3|0)|0,!((F&p|0)==0&((X()|0)&_|0)==0))break e;if(M>>>0>>0)M=M+1|0;else break}if((W|0)<1)return w=0,K=oe,w|0;for(F=R^15,_=-1,B=1,M=1;;){R=W-B|0,R=Lo(7,0,R,((R|0)<0)<<31>>31)|0,p=X()|0;do if(M)if(M=ur(R|0,p|0,5,0)|0,M=tn(M|0,X()|0,-5,-1)|0,M=Io(M|0,X()|0,6,0)|0,y=X()|0,(f|0)>(y|0)|(f|0)==(y|0)&d>>>0>M>>>0){f=tn(d|0,f|0,-1,-1)|0,f=Lr(f|0,X()|0,M|0,y|0)|0,M=X()|0,ve=w,_e=A[ve>>2]|0,ve=A[ve+4>>2]|0,De=(F+_|0)*3|0,ge=Ot(7,0,De|0)|0,ve=ve&~(X()|0),_=Io(f|0,M|0,R|0,p|0)|0,d=X()|0,y=tn(_|0,d|0,2,0)|0,De=Ot(y|0,X()|0,De|0)|0,ve=X()|0|ve,y=w,A[y>>2]=De|_e&~ge,A[y+4>>2]=ve,d=ur(_|0,d|0,R|0,p|0)|0,d=Lr(f|0,M|0,d|0,X()|0)|0,M=0,f=X()|0;break}else{De=w,ge=A[De>>2]|0,De=A[De+4>>2]|0,_e=Ot(7,0,(F+_|0)*3|0)|0,De=De&~(X()|0),M=w,A[M>>2]=ge&~_e,A[M+4>>2]=De,M=1;break}else ge=w,y=A[ge>>2]|0,ge=A[ge+4>>2]|0,_=(F+_|0)*3|0,ve=Ot(7,0,_|0)|0,ge=ge&~(X()|0),De=Io(d|0,f|0,R|0,p|0)|0,M=X()|0,_=Ot(De|0,M|0,_|0)|0,ge=X()|0|ge,_e=w,A[_e>>2]=_|y&~ve,A[_e+4>>2]=ge,M=ur(De|0,M|0,R|0,p|0)|0,d=Lr(d|0,f|0,M|0,X()|0)|0,M=0,f=X()|0;while(!1);if((W|0)>(B|0))_=~B,B=B+1|0;else{f=0;break}}return K=oe,f|0}while(!1);if((W|0)<1)return De=0,K=oe,De|0;for(y=R^15,M=1;;)if(_e=W-M|0,_e=Lo(7,0,_e,((_e|0)<0)<<31>>31)|0,De=X()|0,B=w,p=A[B>>2]|0,B=A[B+4>>2]|0,R=(y-M|0)*3|0,_=Ot(7,0,R|0)|0,B=B&~(X()|0),ve=Io(d|0,f|0,_e|0,De|0)|0,ge=X()|0,R=Ot(ve|0,ge|0,R|0)|0,B=X()|0|B,F=w,A[F>>2]=R|p&~_,A[F+4>>2]=B,De=ur(ve|0,ge|0,_e|0,De|0)|0,d=Lr(d|0,f|0,De|0,X()|0)|0,f=X()|0,(W|0)<=(M|0)){f=0;break}else M=M+1|0;return K=oe,f|0}function nl(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;y=Ct(f|0,p|0,52)|0,X()|0,y=y&15,(f|0)==0&(p|0)==0|((_|0)>15|(y|0)>(_|0))?(w=-1,f=-1,p=0,y=0):(f=sp(f,p,y+1|0,_)|0,M=(X()|0)&-15728641,p=Ot(_|0,0,52)|0,p=f|p,M=M|(X()|0),f=(wi(p,M)|0)==0,w=y,f=f?-1:_,y=M),M=d,A[M>>2]=p,A[M+4>>2]=y,A[d+8>>2]=w,A[d+12>>2]=f}function Fu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;if(y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,w=_+8|0,A[w>>2]=y,(d|0)==0&(f|0)==0|((p|0)>15|(y|0)>(p|0))){p=_,A[p>>2]=0,A[p+4>>2]=0,A[w>>2]=-1,A[_+12>>2]=-1;return}if(d=sp(d,f,y+1|0,p)|0,w=(X()|0)&-15728641,y=Ot(p|0,0,52)|0,y=d|y,w=w|(X()|0),d=_,A[d>>2]=y,A[d+4>>2]=w,d=_+12|0,wi(y,w)|0){A[d>>2]=p;return}else{A[d>>2]=-1;return}}function rf(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0;if(p=d,f=A[p>>2]|0,p=A[p+4>>2]|0,!((f|0)==0&(p|0)==0)&&(_=Ct(f|0,p|0,52)|0,X()|0,_=_&15,R=Ot(1,0,(_^15)*3|0)|0,f=tn(R|0,X()|0,f|0,p|0)|0,p=X()|0,R=d,A[R>>2]=f,A[R+4>>2]=p,R=d+8|0,M=A[R>>2]|0,!((_|0)<(M|0)))){for(B=d+12|0,w=_;;){if((w|0)==(M|0)){_=5;break}if(F=(w|0)==(A[B>>2]|0),y=(15-w|0)*3|0,_=Ct(f|0,p|0,y|0)|0,X()|0,_=_&7,F&((_|0)==1&!0)){_=7;break}if(!((_|0)==7&!0)){_=10;break}if(F=Ot(1,0,y|0)|0,f=tn(f|0,p|0,F|0,X()|0)|0,p=X()|0,F=d,A[F>>2]=f,A[F+4>>2]=p,(w|0)>(M|0))w=w+-1|0;else{_=10;break}}if((_|0)==5){F=d,A[F>>2]=0,A[F+4>>2]=0,A[R>>2]=-1,A[B>>2]=-1;return}else if((_|0)==7){M=Ot(1,0,y|0)|0,M=tn(f|0,p|0,M|0,X()|0)|0,R=X()|0,F=d,A[F>>2]=M,A[F+4>>2]=R,A[B>>2]=w+-1;return}else if((_|0)==10)return}}function $c(d){d=+d;var f=0;return f=d<0?d+6.283185307179586:d,+(d>=6.283185307179586?f+-6.283185307179586:f)}function wa(d,f){return d=d|0,f=f|0,+dn(+(+te[d>>3]-+te[f>>3]))<17453292519943298e-27?(f=+dn(+(+te[d+8>>3]-+te[f+8>>3]))<17453292519943298e-27,f|0):(f=0,f|0)}function Ws(d,f){switch(d=+d,f=f|0,f|0){case 1:{d=d<0?d+6.283185307179586:d;break}case 2:{d=d>0?d+-6.283185307179586:d;break}}return+d}function S1(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+te[f>>3],_=+te[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+te[f+8>>3]-+te[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2)}function Xc(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+te[f>>3],_=+te[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+te[f+8>>3]-+te[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2*6371.007180918475)}function Ex(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=+te[f>>3],_=+te[d>>3],w=+mn(+((y-_)*.5)),p=+mn(+((+te[f+8>>3]-+te[d+8>>3])*.5)),p=w*w+p*(+an(+y)*+an(+_)*p),+(+Ge(+ +Fn(+p),+ +Fn(+(1-p)))*2*6371.007180918475*1e3)}function Cx(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0;return w=+te[f>>3],_=+an(+w),y=+te[f+8>>3]-+te[d+8>>3],M=_*+mn(+y),p=+te[d>>3],+ +Ge(+M,+(+mn(+w)*+an(+p)-+an(+y)*(_*+mn(+p))))}function Nx(d,f,p,_){d=d|0,f=+f,p=+p,_=_|0;var y=0,w=0,M=0,R=0;if(p<1e-16){A[_>>2]=A[d>>2],A[_+4>>2]=A[d+4>>2],A[_+8>>2]=A[d+8>>2],A[_+12>>2]=A[d+12>>2];return}w=f<0?f+6.283185307179586:f,w=f>=6.283185307179586?w+-6.283185307179586:w;do if(w<1e-16)f=+te[d>>3]+p,te[_>>3]=f,y=_;else{if(y=+dn(+(w+-3.141592653589793))<1e-16,f=+te[d>>3],y){f=f-p,te[_>>3]=f,y=_;break}if(M=+an(+p),p=+mn(+p),f=M*+mn(+f)+ +an(+w)*(p*+an(+f)),f=f>1?1:f,f=+No(+(f<-1?-1:f)),te[_>>3]=f,+dn(+(f+-1.5707963267948966))<1e-16){te[_>>3]=1.5707963267948966,te[_+8>>3]=0;return}if(+dn(+(f+1.5707963267948966))<1e-16){te[_>>3]=-1.5707963267948966,te[_+8>>3]=0;return}if(R=1/+an(+f),w=p*+mn(+w)*R,p=+te[d>>3],f=R*((M-+mn(+f)*+mn(+p))/+an(+p)),M=w>1?1:w,f=f>1?1:f,f=+te[d+8>>3]+ +Ge(+(M<-1?-1:M),+(f<-1?-1:f)),f>3.141592653589793)do f=f+-6.283185307179586;while(f>3.141592653589793);if(f<-3.141592653589793)do f=f+6.283185307179586;while(f<-3.141592653589793);te[_+8>>3]=f;return}while(!1);if(+dn(+(f+-1.5707963267948966))<1e-16){te[y>>3]=1.5707963267948966,te[_+8>>3]=0;return}if(+dn(+(f+1.5707963267948966))<1e-16){te[y>>3]=-1.5707963267948966,te[_+8>>3]=0;return}if(f=+te[d+8>>3],f>3.141592653589793)do f=f+-6.283185307179586;while(f>3.141592653589793);if(f<-3.141592653589793)do f=f+6.283185307179586;while(f<-3.141592653589793);te[_+8>>3]=f}function hp(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(te[f>>3]=+te[20656+(d<<3)>>3],f=0,f|0)}function w1(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(te[f>>3]=+te[20784+(d<<3)>>3],f=0,f|0)}function fp(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(te[f>>3]=+te[20912+(d<<3)>>3],f=0,f|0)}function ro(d,f){return d=d|0,f=f|0,d>>>0>15?(f=4,f|0):(te[f>>3]=+te[21040+(d<<3)>>3],f=0,f|0)}function ku(d,f){d=d|0,f=f|0;var p=0;return d>>>0>15?(f=4,f|0):(p=Lo(7,0,d,((d|0)<0)<<31>>31)|0,p=ur(p|0,X()|0,120,0)|0,d=X()|0,A[f>>2]=p|2,A[f+4>>2]=d,f=0,f|0)}function fa(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0;return ve=+te[f>>3],W=+te[d>>3],B=+mn(+((ve-W)*.5)),w=+te[f+8>>3],F=+te[d+8>>3],M=+mn(+((w-F)*.5)),R=+an(+W),oe=+an(+ve),M=B*B+M*(oe*R*M),M=+Ge(+ +Fn(+M),+ +Fn(+(1-M)))*2,B=+te[p>>3],ve=+mn(+((B-ve)*.5)),_=+te[p+8>>3],w=+mn(+((_-w)*.5)),y=+an(+B),w=ve*ve+w*(oe*y*w),w=+Ge(+ +Fn(+w),+ +Fn(+(1-w)))*2,B=+mn(+((W-B)*.5)),_=+mn(+((F-_)*.5)),_=B*B+_*(R*y*_),_=+Ge(+ +Fn(+_),+ +Fn(+(1-_)))*2,y=(M+w+_)*.5,+(+ce(+ +Fn(+(+Er(+(y*.5))*+Er(+((y-M)*.5))*+Er(+((y-w)*.5))*+Er(+((y-_)*.5)))))*4)}function Ll(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0;if(R=K,K=K+192|0,w=R+168|0,M=R,y=Dl(d,f,w)|0,y|0)return p=y,K=R,p|0;if(Pl(d,f,M)|0&&et(27795,27190,415,27199),f=A[M>>2]|0,(f|0)>0){if(_=+fa(M+8|0,M+8+(((f|0)!=1&1)<<4)|0,w)+0,(f|0)!=1){d=1;do y=d,d=d+1|0,_=_+ +fa(M+8+(y<<4)|0,M+8+(((d|0)%(f|0)|0)<<4)|0,w);while((d|0)<(f|0))}}else _=0;return te[p>>3]=_,p=0,K=R,p|0}function dp(d,f,p){return d=d|0,f=f|0,p=p|0,d=Ll(d,f,p)|0,d|0||(te[p>>3]=+te[p>>3]*6371.007180918475*6371.007180918475),d|0}function Nd(d,f,p){return d=d|0,f=f|0,p=p|0,d=Ll(d,f,p)|0,d|0||(te[p>>3]=+te[p>>3]*6371.007180918475*6371.007180918475*1e3*1e3),d|0}function Rd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,K=R,M|0;if(te[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,K=R,M|0;f=d+-1|0,d=0,_=+te[M+8>>3],y=+te[M+16>>3],w=0;do d=d+1|0,F=_,_=+te[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+te[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+_)*+an(+F)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)<(f|0));return te[p>>3]=w,M=0,K=R,M|0}function Ap(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,w=+te[p>>3],w=w*6371.007180918475,te[p>>3]=w,K=R,M|0;if(te[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,w=0,w=w*6371.007180918475,te[p>>3]=w,K=R,M|0;f=d+-1|0,d=0,_=+te[M+8>>3],y=+te[M+16>>3],w=0;do d=d+1|0,F=_,_=+te[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+te[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+F)*+an(+_)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)!=(f|0));return te[p>>3]=w,M=0,W=w,W=W*6371.007180918475,te[p>>3]=W,K=R,M|0}function zu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(R=K,K=K+176|0,M=R,d=Sd(d,f,M)|0,d|0)return M=d,w=+te[p>>3],w=w*6371.007180918475,w=w*1e3,te[p>>3]=w,K=R,M|0;if(te[p>>3]=0,d=A[M>>2]|0,(d|0)<=1)return M=0,w=0,w=w*6371.007180918475,w=w*1e3,te[p>>3]=w,K=R,M|0;f=d+-1|0,d=0,_=+te[M+8>>3],y=+te[M+16>>3],w=0;do d=d+1|0,F=_,_=+te[M+8+(d<<4)>>3],W=+mn(+((_-F)*.5)),B=y,y=+te[M+8+(d<<4)+8>>3],B=+mn(+((y-B)*.5)),B=W*W+B*(+an(+F)*+an(+_)*B),w=w+ +Ge(+ +Fn(+B),+ +Fn(+(1-B)))*2;while((d|0)!=(f|0));return te[p>>3]=w,M=0,W=w,W=W*6371.007180918475,W=W*1e3,te[p>>3]=W,K=R,M|0}function T1(d){d=d|0;var f=0,p=0,_=0;return f=Ys(1,12)|0,f||et(27280,27235,49,27293),p=d+4|0,_=A[p>>2]|0,_|0?(_=_+8|0,A[_>>2]=f,A[p>>2]=f,f|0):(A[d>>2]|0&&et(27310,27235,61,27333),_=d,A[_>>2]=f,A[p>>2]=f,f|0)}function Dd(d,f){d=d|0,f=f|0;var p=0,_=0;return _=Oo(24)|0,_||et(27347,27235,78,27361),A[_>>2]=A[f>>2],A[_+4>>2]=A[f+4>>2],A[_+8>>2]=A[f+8>>2],A[_+12>>2]=A[f+12>>2],A[_+16>>2]=0,f=d+4|0,p=A[f>>2]|0,p|0?(A[p+16>>2]=_,A[f>>2]=_,_|0):(A[d>>2]|0&&et(27376,27235,82,27361),A[d>>2]=_,A[f>>2]=_,_|0)}function Gu(d){d=d|0;var f=0,p=0,_=0,y=0;if(d)for(_=1;;){if(f=A[d>>2]|0,f|0)do{if(p=A[f>>2]|0,p|0)do y=p,p=A[p+16>>2]|0,vn(y);while((p|0)!=0);y=f,f=A[f+8>>2]|0,vn(y)}while((f|0)!=0);if(f=d,d=A[d+8>>2]|0,_||vn(f),d)_=0;else break}}function Rx(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0,kn=0,Dn=0,Zn=0,En=0,fn=0,zt=0,xn=0,si=0,Cn=0;if(y=d+8|0,A[y>>2]|0)return Cn=1,Cn|0;if(_=A[d>>2]|0,!_)return Cn=0,Cn|0;f=_,p=0;do p=p+1|0,f=A[f+8>>2]|0;while((f|0)!=0);if(p>>>0<2)return Cn=0,Cn|0;xn=Oo(p<<2)|0,xn||et(27396,27235,317,27415),zt=Oo(p<<5)|0,zt||et(27437,27235,321,27415),A[d>>2]=0,un=d+4|0,A[un>>2]=0,A[y>>2]=0,p=0,fn=0,kt=0,oe=0;e:for(;;){if(W=A[_>>2]|0,W){w=0,M=W;do{if(B=+te[M+8>>3],f=M,M=A[M+16>>2]|0,F=(M|0)==0,y=F?W:M,R=+te[y+8>>3],+dn(+(B-R))>3.141592653589793){Cn=14;break}w=w+(R-B)*(+te[f>>3]+ +te[y>>3])}while(!F);if((Cn|0)==14){Cn=0,w=0,f=W;do Pe=+te[f+8>>3],En=f+16|0,Zn=A[En>>2]|0,Zn=(Zn|0)==0?W:Zn,He=+te[Zn+8>>3],w=w+(+te[f>>3]+ +te[Zn>>3])*((He<0?He+6.283185307179586:He)-(Pe<0?Pe+6.283185307179586:Pe)),f=A[((f|0)==0?_:En)>>2]|0;while((f|0)!=0)}w>0?(A[xn+(fn<<2)>>2]=_,fn=fn+1|0,y=kt,f=oe):Cn=19}else Cn=19;if((Cn|0)==19){Cn=0;do if(p){if(f=p+8|0,A[f>>2]|0){Cn=21;break e}if(p=Ys(1,12)|0,!p){Cn=23;break e}A[f>>2]=p,y=p+4|0,M=p,f=oe}else if(oe){y=un,M=oe+8|0,f=_,p=d;break}else if(A[d>>2]|0){Cn=27;break e}else{y=un,M=d,f=_,p=d;break}while(!1);if(A[M>>2]=_,A[y>>2]=_,M=zt+(kt<<5)|0,F=A[_>>2]|0,F){for(W=zt+(kt<<5)+8|0,te[W>>3]=17976931348623157e292,oe=zt+(kt<<5)+24|0,te[oe>>3]=17976931348623157e292,te[M>>3]=-17976931348623157e292,ve=zt+(kt<<5)+16|0,te[ve>>3]=-17976931348623157e292,nt=17976931348623157e292,Xe=-17976931348623157e292,y=0,ge=F,B=17976931348623157e292,De=17976931348623157e292,ze=-17976931348623157e292,R=-17976931348623157e292;w=+te[ge>>3],Pe=+te[ge+8>>3],ge=A[ge+16>>2]|0,_e=(ge|0)==0,He=+te[(_e?F:ge)+8>>3],w>3]=w,B=w),Pe>3]=Pe,De=Pe),w>ze?te[M>>3]=w:w=ze,Pe>R&&(te[ve>>3]=Pe,R=Pe),nt=Pe>0&PeXe?Pe:Xe,y=y|+dn(+(Pe-He))>3.141592653589793,!_e;)ze=w;y&&(te[ve>>3]=Xe,te[oe>>3]=nt)}else A[M>>2]=0,A[M+4>>2]=0,A[M+8>>2]=0,A[M+12>>2]=0,A[M+16>>2]=0,A[M+20>>2]=0,A[M+24>>2]=0,A[M+28>>2]=0;y=kt+1|0}if(En=_+8|0,_=A[En>>2]|0,A[En>>2]=0,_)kt=y,oe=f;else{Cn=45;break}}if((Cn|0)==21)et(27213,27235,35,27247);else if((Cn|0)==23)et(27267,27235,37,27247);else if((Cn|0)==27)et(27310,27235,61,27333);else if((Cn|0)==45){e:do if((fn|0)>0){for(En=(y|0)==0,Dn=y<<2,Zn=(d|0)==0,kn=0,f=0;;){if(on=A[xn+(kn<<2)>>2]|0,En)Cn=73;else{if(kt=Oo(Dn)|0,!kt){Cn=50;break}if(un=Oo(Dn)|0,!un){Cn=52;break}t:do if(Zn)p=0;else{for(y=0,p=0,M=d;_=zt+(y<<5)|0,$s(A[M>>2]|0,_,A[on>>2]|0)|0?(A[kt+(p<<2)>>2]=M,A[un+(p<<2)>>2]=_,_e=p+1|0):_e=p,M=A[M+8>>2]|0,M;)y=y+1|0,p=_e;if((_e|0)>0)if(_=A[kt>>2]|0,(_e|0)==1)p=_;else for(ve=0,ge=-1,p=_,oe=_;;){for(F=A[oe>>2]|0,_=0,M=0;y=A[A[kt+(M<<2)>>2]>>2]|0,(y|0)==(F|0)?W=_:W=_+(($s(y,A[un+(M<<2)>>2]|0,A[F>>2]|0)|0)&1)|0,M=M+1|0,(M|0)!=(_e|0);)_=W;if(y=(W|0)>(ge|0),p=y?oe:p,_=ve+1|0,(_|0)==(_e|0))break t;ve=_,ge=y?W:ge,oe=A[kt+(_<<2)>>2]|0}else p=0}while(!1);if(vn(kt),vn(un),p){if(y=p+4|0,_=A[y>>2]|0,_)p=_+8|0;else if(A[p>>2]|0){Cn=70;break}A[p>>2]=on,A[y>>2]=on}else Cn=73}if((Cn|0)==73){if(Cn=0,f=A[on>>2]|0,f|0)do un=f,f=A[f+16>>2]|0,vn(un);while((f|0)!=0);vn(on),f=1}if(kn=kn+1|0,(kn|0)>=(fn|0)){si=f;break e}}(Cn|0)==50?et(27452,27235,249,27471):(Cn|0)==52?et(27490,27235,252,27471):(Cn|0)==70&&et(27310,27235,61,27333)}else si=0;while(!1);return vn(xn),vn(zt),Cn=si,Cn|0}return 0}function $s(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(!(Do(f,p)|0)||(f=_d(f)|0,_=+te[p>>3],y=+te[p+8>>3],y=f&y<0?y+6.283185307179586:y,d=A[d>>2]|0,!d))return d=0,d|0;if(f){f=0,F=y,p=d;e:for(;;){for(;M=+te[p>>3],y=+te[p+8>>3],p=p+16|0,W=A[p>>2]|0,W=(W|0)==0?d:W,w=+te[W>>3],R=+te[W+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=A[p>>2]|0,!p){p=22;break e}if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,F=R==F|M==F?F+-2220446049250313e-31:F,B=R+(M-R)*((_-w)/(B-w)),(B<0?B+6.283185307179586:B)>F&&(f=f^1),p=A[p>>2]|0,!p){p=22;break}}if((p|0)==22)return f|0}else{f=0,F=y,p=d;e:for(;;){for(;M=+te[p>>3],y=+te[p+8>>3],p=p+16|0,W=A[p>>2]|0,W=(W|0)==0?d:W,w=+te[W>>3],R=+te[W+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=A[p>>2]|0,!p){p=22;break e}if(F=M==F|y==F?F+-2220446049250313e-31:F,M+(y-M)*((_-w)/(B-w))>F&&(f=f^1),p=A[p>>2]|0,!p){p=22;break}}if((p|0)==22)return f|0}return 0}function so(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0;if(Xe=K,K=K+32|0,nt=Xe+16|0,ze=Xe,w=Ct(d|0,f|0,52)|0,X()|0,w=w&15,ge=Ct(p|0,_|0,52)|0,X()|0,(w|0)!=(ge&15|0))return nt=12,K=Xe,nt|0;if(F=Ct(d|0,f|0,45)|0,X()|0,F=F&127,W=Ct(p|0,_|0,45)|0,X()|0,W=W&127,F>>>0>121|W>>>0>121)return nt=5,K=Xe,nt|0;if(ge=(F|0)!=(W|0),ge){if(R=Xh(F,W)|0,(R|0)==7)return nt=1,K=Xe,nt|0;B=Xh(W,F)|0,(B|0)==7?et(27514,27538,161,27548):(_e=R,M=B)}else _e=0,M=0;oe=Ji(F)|0,ve=Ji(W)|0,A[nt>>2]=0,A[nt+4>>2]=0,A[nt+8>>2]=0,A[nt+12>>2]=0;do if(_e){if(W=A[4272+(F*28|0)+(_e<<2)>>2]|0,R=(W|0)>0,ve)if(R){F=0,B=p,R=_;do B=Tx(B,R)|0,R=X()|0,M=tl(M)|0,(M|0)==1&&(M=tl(1)|0),F=F+1|0;while((F|0)!=(W|0));W=M,F=B,B=R}else W=M,F=p,B=_;else if(R){F=0,B=p,R=_;do B=lp(B,R)|0,R=X()|0,M=tl(M)|0,F=F+1|0;while((F|0)!=(W|0));W=M,F=B,B=R}else W=M,F=p,B=_;if(Cd(F,B,nt)|0,ge||et(27563,27538,191,27548),R=(oe|0)!=0,M=(ve|0)!=0,R&M&&et(27590,27538,192,27548),R){if(M=Hs(d,f)|0,(M|0)==7){w=5;break}if(xt[22e3+(M*7|0)+_e>>0]|0){w=1;break}B=A[21168+(M*28|0)+(_e<<2)>>2]|0,F=B}else if(M){if(M=Hs(F,B)|0,(M|0)==7){w=5;break}if(xt[22e3+(M*7|0)+W>>0]|0){w=1;break}F=0,B=A[21168+(W*28|0)+(M<<2)>>2]|0}else F=0,B=0;if((F|B|0)<0)w=5;else{if((B|0)>0){R=nt+4|0,M=0;do bd(R),M=M+1|0;while((M|0)!=(B|0))}if(A[ze>>2]=0,A[ze+4>>2]=0,A[ze+8>>2]=0,l1(ze,_e),w|0)for(;bs(w)|0?Hc(ze):Cu(ze),(w|0)>1;)w=w+-1|0;if((F|0)>0){w=0;do bd(ze),w=w+1|0;while((w|0)!=(F|0))}De=nt+4|0,us(De,ze,De),Pr(De),De=51}}else if(Cd(p,_,nt)|0,(oe|0)!=0&(ve|0)!=0)if((W|0)!=(F|0)&&et(27621,27538,261,27548),M=Hs(d,f)|0,w=Hs(p,_)|0,(M|0)==7|(w|0)==7)w=5;else if(xt[22e3+(M*7|0)+w>>0]|0)w=1;else if(M=A[21168+(M*28|0)+(w<<2)>>2]|0,(M|0)>0){R=nt+4|0,w=0;do bd(R),w=w+1|0;while((w|0)!=(M|0));De=51}else De=51;else De=51;while(!1);return(De|0)==51&&(w=nt+4|0,A[y>>2]=A[w>>2],A[y+4>>2]=A[w+4>>2],A[y+8>>2]=A[w+8>>2],w=0),nt=w,K=Xe,nt|0}function Po(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0;if(De=K,K=K+48|0,F=De+36|0,M=De+24|0,R=De+12|0,B=De,y=Ct(d|0,f|0,52)|0,X()|0,y=y&15,ve=Ct(d|0,f|0,45)|0,X()|0,ve=ve&127,ve>>>0>121)return _=5,K=De,_|0;if(W=Ji(ve)|0,Ot(y|0,0,52)|0,ze=X()|0|134225919,w=_,A[w>>2]=-1,A[w+4>>2]=ze,!y)return y=Eu(p)|0,(y|0)==7||(y=vd(ve,y)|0,(y|0)==127)?(ze=1,K=De,ze|0):(ge=Ot(y|0,0,45)|0,_e=X()|0,ve=_,_e=A[ve+4>>2]&-1040385|_e,ze=_,A[ze>>2]=A[ve>>2]|ge,A[ze+4>>2]=_e,ze=0,K=De,ze|0);for(A[F>>2]=A[p>>2],A[F+4>>2]=A[p+4>>2],A[F+8>>2]=A[p+8>>2],p=y;;){if(w=p,p=p+-1|0,A[M>>2]=A[F>>2],A[M+4>>2]=A[F+4>>2],A[M+8>>2]=A[F+8>>2],bs(w)|0){if(y=a1(F)|0,y|0){p=13;break}A[R>>2]=A[F>>2],A[R+4>>2]=A[F+4>>2],A[R+8>>2]=A[F+8>>2],Hc(R)}else{if(y=hx(F)|0,y|0){p=13;break}A[R>>2]=A[F>>2],A[R+4>>2]=A[F+4>>2],A[R+8>>2]=A[F+8>>2],Cu(R)}if(ef(M,R,B),Pr(B),y=_,Xe=A[y>>2]|0,y=A[y+4>>2]|0,He=(15-w|0)*3|0,nt=Ot(7,0,He|0)|0,y=y&~(X()|0),He=Ot(Eu(B)|0,0,He|0)|0,y=X()|0|y,ze=_,A[ze>>2]=He|Xe&~nt,A[ze+4>>2]=y,(w|0)<=1){p=14;break}}e:do if((p|0)!=13&&(p|0)==14)if((A[F>>2]|0)<=1&&(A[F+4>>2]|0)<=1&&(A[F+8>>2]|0)<=1){p=Eu(F)|0,y=vd(ve,p)|0,(y|0)==127?B=0:B=Ji(y)|0;t:do if(p){if(W){if(y=Hs(d,f)|0,(y|0)==7){y=5;break e}if(w=A[21376+(y*28|0)+(p<<2)>>2]|0,(w|0)>0){y=p,p=0;do y=Nu(y)|0,p=p+1|0;while((p|0)!=(w|0))}else y=p;if((y|0)==1){y=9;break e}p=vd(ve,y)|0,(p|0)==127&&et(27648,27538,411,27678),Ji(p)|0?et(27693,27538,412,27678):(_e=p,ge=w,oe=y)}else _e=y,ge=0,oe=p;if(R=A[4272+(ve*28|0)+(oe<<2)>>2]|0,(R|0)<=-1&&et(27724,27538,419,27678),!B){if((ge|0)<0){y=5;break e}if(ge|0){w=_,y=0,p=A[w>>2]|0,w=A[w+4>>2]|0;do p=Uu(p,w)|0,w=X()|0,He=_,A[He>>2]=p,A[He+4>>2]=w,y=y+1|0;while((y|0)<(ge|0))}if((R|0)<=0){y=_e,p=58;break}for(w=_,y=0,p=A[w>>2]|0,w=A[w+4>>2]|0;;)if(p=Uu(p,w)|0,w=X()|0,He=_,A[He>>2]=p,A[He+4>>2]=w,y=y+1|0,(y|0)==(R|0)){y=_e,p=58;break t}}if(M=Xh(_e,ve)|0,(M|0)==7&&et(27514,27538,428,27678),y=_,p=A[y>>2]|0,y=A[y+4>>2]|0,(R|0)>0){w=0;do p=Uu(p,y)|0,y=X()|0,He=_,A[He>>2]=p,A[He+4>>2]=y,w=w+1|0;while((w|0)!=(R|0))}if(y=Hs(p,y)|0,(y|0)==7&&et(27795,27538,440,27678),p=qc(_e)|0,p=A[(p?21792:21584)+(M*28|0)+(y<<2)>>2]|0,(p|0)<0&&et(27795,27538,454,27678),!p)y=_e,p=58;else{M=_,y=0,w=A[M>>2]|0,M=A[M+4>>2]|0;do w=op(w,M)|0,M=X()|0,He=_,A[He>>2]=w,A[He+4>>2]=M,y=y+1|0;while((y|0)<(p|0));y=_e,p=58}}else if((W|0)!=0&(B|0)!=0){if(p=Hs(d,f)|0,w=_,w=Hs(A[w>>2]|0,A[w+4>>2]|0)|0,(p|0)==7|(w|0)==7){y=5;break e}if(w=A[21376+(p*28|0)+(w<<2)>>2]|0,(w|0)<0){y=5;break e}if(!w)p=59;else{R=_,p=0,M=A[R>>2]|0,R=A[R+4>>2]|0;do M=Uu(M,R)|0,R=X()|0,He=_,A[He>>2]=M,A[He+4>>2]=R,p=p+1|0;while((p|0)<(w|0));p=58}}else p=58;while(!1);if((p|0)==58&&B&&(p=59),(p|0)==59&&(He=_,(Hs(A[He>>2]|0,A[He+4>>2]|0)|0)==1)){y=9;break}He=_,nt=A[He>>2]|0,He=A[He+4>>2]&-1040385,Xe=Ot(y|0,0,45)|0,He=He|(X()|0),y=_,A[y>>2]=nt|Xe,A[y+4>>2]=He,y=0}else y=1;while(!1);return He=y,K=De,He|0}function M1(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0;return R=K,K=K+16|0,M=R,y?d=15:(d=so(d,f,p,_,M)|0,d||(dx(M,w),d=0)),K=R,d|0}function Pd(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0;return M=K,K=K+16|0,w=M,_?p=15:(p=tp(p,w)|0,p||(p=Po(d,f,w,y)|0)),K=M,p|0}function qu(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0;return B=K,K=K+32|0,M=B+12|0,R=B,w=so(d,f,d,f,M)|0,w|0?(R=w,K=B,R|0):(d=so(d,f,p,_,R)|0,d|0?(R=d,K=B,R|0):(M=ep(M,R)|0,R=y,A[R>>2]=M,A[R+4>>2]=((M|0)<0)<<31>>31,R=0,K=B,R|0))}function pp(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0;return B=K,K=K+32|0,M=B+12|0,R=B,w=so(d,f,d,f,M)|0,!w&&(w=so(d,f,p,_,R)|0,!w)?(_=ep(M,R)|0,_=tn(_|0,((_|0)<0)<<31>>31|0,1,0)|0,M=X()|0,R=y,A[R>>2]=_,A[R+4>>2]=M,R=0,K=B,R|0):(R=w,K=B,R|0)}function E1(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0,kn=0;if(on=K,K=K+48|0,kt=on+24|0,M=on+12|0,un=on,w=so(d,f,d,f,kt)|0,!w&&(w=so(d,f,p,_,M)|0,!w)){He=ep(kt,M)|0,Pe=((He|0)<0)<<31>>31,A[kt>>2]=0,A[kt+4>>2]=0,A[kt+8>>2]=0,A[M>>2]=0,A[M+4>>2]=0,A[M+8>>2]=0,so(d,f,d,f,kt)|0&&et(27795,27538,692,27747),so(d,f,p,_,M)|0&&et(27795,27538,697,27747),f1(kt),f1(M),W=(He|0)==0?0:1/+(He|0),p=A[kt>>2]|0,De=W*+((A[M>>2]|0)-p|0),ze=kt+4|0,_=A[ze>>2]|0,nt=W*+((A[M+4>>2]|0)-_|0),Xe=kt+8|0,w=A[Xe>>2]|0,W=W*+((A[M+8>>2]|0)-w|0),A[un>>2]=p,oe=un+4|0,A[oe>>2]=_,ve=un+8|0,A[ve>>2]=w;e:do if((He|0)<0)w=0;else for(ge=0,_e=0;;){B=+(_e>>>0)+4294967296*+(ge|0),kn=De*B+ +(p|0),R=nt*B+ +(_|0),B=W*B+ +(w|0),p=~~+ll(+kn),M=~~+ll(+R),w=~~+ll(+B),kn=+dn(+(+(p|0)-kn)),R=+dn(+(+(M|0)-R)),B=+dn(+(+(w|0)-B));do if(kn>R&kn>B)p=0-(M+w)|0,_=M;else if(F=0-p|0,R>B){_=F-w|0;break}else{_=M,w=F-M|0;break}while(!1);if(A[un>>2]=p,A[oe>>2]=_,A[ve>>2]=w,Ax(un),w=Po(d,f,un,y+(_e<<3)|0)|0,w|0)break e;if(!((ge|0)<(Pe|0)|(ge|0)==(Pe|0)&_e>>>0>>0)){w=0;break e}p=tn(_e|0,ge|0,1,0)|0,_=X()|0,ge=_,_e=p,p=A[kt>>2]|0,_=A[ze>>2]|0,w=A[Xe>>2]|0}while(!1);return un=w,K=on,un|0}return un=w,K=on,un|0}function Lo(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if((p|0)==0&(_|0)==0)return y=0,w=1,he(y|0),w|0;w=d,y=f,d=1,f=0;do M=(p&1|0)==0&!0,d=ur((M?1:w)|0,(M?0:y)|0,d|0,f|0)|0,f=X()|0,p=N1(p|0,_|0,1)|0,_=X()|0,w=ur(w|0,y|0,w|0,y|0)|0,y=X()|0;while(!((p|0)==0&(_|0)==0));return he(f|0),d|0}function Ld(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;R=K,K=K+16|0,w=R,M=Ct(d|0,f|0,52)|0,X()|0,M=M&15;do if(M){if(y=Dl(d,f,w)|0,!y){F=+te[w>>3],B=1/+an(+F),W=+te[25968+(M<<3)>>3],te[p>>3]=F+W,te[p+8>>3]=F-W,F=+te[w+8>>3],B=W*B,te[p+16>>3]=B+F,te[p+24>>3]=F-B;break}return M=y,K=R,M|0}else{if(y=Ct(d|0,f|0,45)|0,X()|0,y=y&127,y>>>0>121)return M=5,K=R,M|0;w=22064+(y<<5)|0,A[p>>2]=A[w>>2],A[p+4>>2]=A[w+4>>2],A[p+8>>2]=A[w+8>>2],A[p+12>>2]=A[w+12>>2],A[p+16>>2]=A[w+16>>2],A[p+20>>2]=A[w+20>>2],A[p+24>>2]=A[w+24>>2],A[p+28>>2]=A[w+28>>2];break}while(!1);return js(p,_?1.4:1.1),_=26096+(M<<3)|0,(A[_>>2]|0)==(d|0)&&(A[_+4>>2]|0)==(f|0)&&(te[p>>3]=1.5707963267948966),M=26224+(M<<3)|0,(A[M>>2]|0)==(d|0)&&(A[M+4>>2]|0)==(f|0)&&(te[p+8>>3]=-1.5707963267948966),+te[p>>3]!=1.5707963267948966&&+te[p+8>>3]!=-1.5707963267948966?(M=0,K=R,M|0):(te[p+16>>3]=3.141592653589793,te[p+24>>3]=-3.141592653589793,M=0,K=R,M|0)}function Ta(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;F=K,K=K+48|0,M=F+32|0,w=F+40|0,R=F,Pu(M,0,0,0),B=A[M>>2]|0,M=A[M+4>>2]|0;do if(p>>>0<=15){if(y=Ma(_)|0,y|0){_=R,A[_>>2]=0,A[_+4>>2]=0,A[R+8>>2]=y,A[R+12>>2]=-1,_=R+16|0,B=R+29|0,A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,xt[_+12>>0]=0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}if(y=Ys((A[f+8>>2]|0)+1|0,32)|0,y){Ea(f,y),W=R,A[W>>2]=B,A[W+4>>2]=M,A[R+8>>2]=0,A[R+12>>2]=p,A[R+16>>2]=_,A[R+20>>2]=f,A[R+24>>2]=y,xt[R+28>>0]=0,B=R+29|0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}else{_=R,A[_>>2]=0,A[_+4>>2]=0,A[R+8>>2]=13,A[R+12>>2]=-1,_=R+16|0,B=R+29|0,A[_>>2]=0,A[_+4>>2]=0,A[_+8>>2]=0,xt[_+12>>0]=0,xt[B>>0]=xt[w>>0]|0,xt[B+1>>0]=xt[w+1>>0]|0,xt[B+2>>0]=xt[w+2>>0]|0;break}}else B=R,A[B>>2]=0,A[B+4>>2]=0,A[R+8>>2]=4,A[R+12>>2]=-1,B=R+16|0,W=R+29|0,A[B>>2]=0,A[B+4>>2]=0,A[B+8>>2]=0,xt[B+12>>0]=0,xt[W>>0]=xt[w>>0]|0,xt[W+1>>0]=xt[w+1>>0]|0,xt[W+2>>0]=xt[w+2>>0]|0;while(!1);il(R),A[d>>2]=A[R>>2],A[d+4>>2]=A[R+4>>2],A[d+8>>2]=A[R+8>>2],A[d+12>>2]=A[R+12>>2],A[d+16>>2]=A[R+16>>2],A[d+20>>2]=A[R+20>>2],A[d+24>>2]=A[R+24>>2],A[d+28>>2]=A[R+28>>2],K=F}function il(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0;if(Pe=K,K=K+336|0,ge=Pe+168|0,_e=Pe,_=d,p=A[_>>2]|0,_=A[_+4>>2]|0,(p|0)==0&(_|0)==0){K=Pe;return}if(f=d+28|0,xt[f>>0]|0?(p=Vu(p,_)|0,_=X()|0):xt[f>>0]=1,He=d+20|0,!(A[A[He>>2]>>2]|0)){f=d+24|0,p=A[f>>2]|0,p|0&&vn(p),Xe=d,A[Xe>>2]=0,A[Xe+4>>2]=0,A[d+8>>2]=0,A[He>>2]=0,A[d+12>>2]=-1,A[d+16>>2]=0,A[f>>2]=0,K=Pe;return}Xe=d+16|0,f=A[Xe>>2]|0,y=f&15;e:do if((p|0)==0&(_|0)==0)nt=d+24|0;else{De=d+12|0,oe=(y|0)==3,W=f&255,B=(y|1|0)==3,ve=d+24|0,F=(y+-1|0)>>>0<3,M=(y|2|0)==3,R=_e+8|0;t:for(;;){if(w=Ct(p|0,_|0,52)|0,X()|0,w=w&15,(w|0)==(A[De>>2]|0)){switch(W&15){case 0:case 2:case 3:{if(y=Dl(p,_,ge)|0,y|0){ze=15;break t}if(Ca(A[He>>2]|0,A[ve>>2]|0,ge)|0){ze=19;break t}break}}if(B&&(y=A[(A[He>>2]|0)+4>>2]|0,A[ge>>2]=A[y>>2],A[ge+4>>2]=A[y+4>>2],A[ge+8>>2]=A[y+8>>2],A[ge+12>>2]=A[y+12>>2],Do(26832,ge)|0)){if(Ed(A[(A[He>>2]|0)+4>>2]|0,w,_e)|0){ze=25;break}if(y=_e,(A[y>>2]|0)==(p|0)&&(A[y+4>>2]|0)==(_|0)){ze=29;break}}if(F){if(y=Pl(p,_,ge)|0,y|0){ze=32;break}if(Ld(p,_,_e,0)|0){ze=36;break}if(M&&Uo(A[He>>2]|0,A[ve>>2]|0,ge,_e)|0){ze=42;break}if(B&&Bd(A[He>>2]|0,A[ve>>2]|0,ge,_e)|0){ze=42;break}}if(oe){if(f=Ld(p,_,ge,1)|0,y=A[ve>>2]|0,f|0){ze=45;break}if(Kh(y,ge)|0){if(Zh(_e,ge),J0(ge,A[ve>>2]|0)|0){ze=53;break}if(Ca(A[He>>2]|0,A[ve>>2]|0,R)|0){ze=53;break}if(Bd(A[He>>2]|0,A[ve>>2]|0,_e,ge)|0){ze=53;break}}}}do if((w|0)<(A[De>>2]|0)){if(f=Ld(p,_,ge,1)|0,y=A[ve>>2]|0,f|0){ze=58;break t}if(!(Kh(y,ge)|0)){ze=73;break}if(J0(A[ve>>2]|0,ge)|0&&(Zh(_e,ge),Uo(A[He>>2]|0,A[ve>>2]|0,_e,ge)|0)){ze=65;break t}if(p=Md(p,_,w+1|0,_e)|0,p|0){ze=67;break t}_=_e,p=A[_>>2]|0,_=A[_+4>>2]|0}else ze=73;while(!1);if((ze|0)==73&&(ze=0,p=Vu(p,_)|0,_=X()|0),(p|0)==0&(_|0)==0){nt=ve;break e}}switch(ze|0){case 15:{f=A[ve>>2]|0,f|0&&vn(f),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[He>>2]=0,A[De>>2]=-1,A[Xe>>2]=0,A[ve>>2]=0,A[d+8>>2]=y,ze=20;break}case 19:{A[d>>2]=p,A[d+4>>2]=_,ze=20;break}case 25:{et(27795,27761,470,27772);break}case 29:{A[d>>2]=p,A[d+4>>2]=_,K=Pe;return}case 32:{f=A[ve>>2]|0,f|0&&vn(f),nt=d,A[nt>>2]=0,A[nt+4>>2]=0,A[He>>2]=0,A[De>>2]=-1,A[Xe>>2]=0,A[ve>>2]=0,A[d+8>>2]=y,K=Pe;return}case 36:{et(27795,27761,493,27772);break}case 42:{A[d>>2]=p,A[d+4>>2]=_,K=Pe;return}case 45:{y|0&&vn(y),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[He>>2]=0,A[De>>2]=-1,A[Xe>>2]=0,A[ve>>2]=0,A[d+8>>2]=f,ze=55;break}case 53:{A[d>>2]=p,A[d+4>>2]=_,ze=55;break}case 58:{y|0&&vn(y),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[He>>2]=0,A[De>>2]=-1,A[Xe>>2]=0,A[ve>>2]=0,A[d+8>>2]=f,ze=71;break}case 65:{A[d>>2]=p,A[d+4>>2]=_,ze=71;break}case 67:{f=A[ve>>2]|0,f|0&&vn(f),nt=d,A[nt>>2]=0,A[nt+4>>2]=0,A[He>>2]=0,A[De>>2]=-1,A[Xe>>2]=0,A[ve>>2]=0,A[d+8>>2]=p,K=Pe;return}}if((ze|0)==20){K=Pe;return}else if((ze|0)==55){K=Pe;return}else if((ze|0)==71){K=Pe;return}}while(!1);f=A[nt>>2]|0,f|0&&vn(f),ze=d,A[ze>>2]=0,A[ze+4>>2]=0,A[d+8>>2]=0,A[He>>2]=0,A[d+12>>2]=-1,A[Xe>>2]=0,A[nt>>2]=0,K=Pe}function Vu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0;oe=K,K=K+16|0,W=oe,_=Ct(d|0,f|0,52)|0,X()|0,_=_&15,p=Ct(d|0,f|0,45)|0,X()|0;do if(_){for(;p=Ot(_+4095|0,0,52)|0,y=X()|0|f&-15728641,w=(15-_|0)*3|0,M=Ot(7,0,w|0)|0,R=X()|0,p=p|d|M,y=y|R,B=Ct(d|0,f|0,w|0)|0,X()|0,B=B&7,_=_+-1|0,!(B>>>0<6);)if(_)f=y,d=p;else{F=4;break}if((F|0)==4){p=Ct(p|0,y|0,45)|0,X()|0;break}return W=(B|0)==0&(wi(p,y)|0)!=0,W=Ot((W?2:1)+B|0,0,w|0)|0,F=X()|0|f&~R,W=W|d&~M,he(F|0),K=oe,W|0}while(!1);return p=p&127,p>>>0>120?(F=0,W=0,he(F|0),K=oe,W|0):(Pu(W,0,p+1|0,0),F=A[W+4>>2]|0,W=A[W>>2]|0,he(F|0),K=oe,W|0)}function Ud(d,f,p,_,y,w){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0,w=w|0;var M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0;ze=K,K=K+160|0,oe=ze+80|0,R=ze+64|0,ve=ze+112|0,De=ze,Ta(oe,d,f,p),F=oe,nl(R,A[F>>2]|0,A[F+4>>2]|0,f),F=R,B=A[F>>2]|0,F=A[F+4>>2]|0,M=A[oe+8>>2]|0,ge=ve+4|0,A[ge>>2]=A[oe>>2],A[ge+4>>2]=A[oe+4>>2],A[ge+8>>2]=A[oe+8>>2],A[ge+12>>2]=A[oe+12>>2],A[ge+16>>2]=A[oe+16>>2],A[ge+20>>2]=A[oe+20>>2],A[ge+24>>2]=A[oe+24>>2],A[ge+28>>2]=A[oe+28>>2],ge=De,A[ge>>2]=B,A[ge+4>>2]=F,ge=De+8|0,A[ge>>2]=M,d=De+12|0,f=ve,p=d+36|0;do A[d>>2]=A[f>>2],d=d+4|0,f=f+4|0;while((d|0)<(p|0));if(ve=De+48|0,A[ve>>2]=A[R>>2],A[ve+4>>2]=A[R+4>>2],A[ve+8>>2]=A[R+8>>2],A[ve+12>>2]=A[R+12>>2],(B|0)==0&(F|0)==0)return De=M,K=ze,De|0;p=De+16|0,W=De+24|0,oe=De+28|0,M=0,R=0,f=B,d=F;do{if(!((M|0)<(y|0)|(M|0)==(y|0)&R>>>0<_>>>0)){_e=4;break}if(F=R,R=tn(R|0,M|0,1,0)|0,M=X()|0,F=w+(F<<3)|0,A[F>>2]=f,A[F+4>>2]=d,rf(ve),d=ve,f=A[d>>2]|0,d=A[d+4>>2]|0,(f|0)==0&(d|0)==0){if(il(p),f=p,d=A[f>>2]|0,f=A[f+4>>2]|0,(d|0)==0&(f|0)==0){_e=10;break}Fu(d,f,A[oe>>2]|0,ve),d=ve,f=A[d>>2]|0,d=A[d+4>>2]|0}F=De,A[F>>2]=f,A[F+4>>2]=d}while(!((f|0)==0&(d|0)==0));return(_e|0)==4?(d=De+40|0,f=A[d>>2]|0,f|0&&vn(f),_e=De+16|0,A[_e>>2]=0,A[_e+4>>2]=0,A[W>>2]=0,A[De+36>>2]=0,A[oe>>2]=-1,A[De+32>>2]=0,A[d>>2]=0,Fu(0,0,0,ve),A[De>>2]=0,A[De+4>>2]=0,A[ge>>2]=0,De=14,K=ze,De|0):((_e|0)==10&&(A[De>>2]=0,A[De+4>>2]=0,A[ge>>2]=A[W>>2]),De=A[ge>>2]|0,K=ze,De|0)}function sf(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0;if(oe=K,K=K+48|0,B=oe+32|0,R=oe+40|0,F=oe,!(A[d>>2]|0))return W=_,A[W>>2]=0,A[W+4>>2]=0,W=0,K=oe,W|0;Pu(B,0,0,0),M=B,y=A[M>>2]|0,M=A[M+4>>2]|0;do if(f>>>0>15)W=F,A[W>>2]=0,A[W+4>>2]=0,A[F+8>>2]=4,A[F+12>>2]=-1,W=F+16|0,p=F+29|0,A[W>>2]=0,A[W+4>>2]=0,A[W+8>>2]=0,xt[W+12>>0]=0,xt[p>>0]=xt[R>>0]|0,xt[p+1>>0]=xt[R+1>>0]|0,xt[p+2>>0]=xt[R+2>>0]|0,p=4,W=9;else{if(p=Ma(p)|0,p|0){B=F,A[B>>2]=0,A[B+4>>2]=0,A[F+8>>2]=p,A[F+12>>2]=-1,B=F+16|0,W=F+29|0,A[B>>2]=0,A[B+4>>2]=0,A[B+8>>2]=0,xt[B+12>>0]=0,xt[W>>0]=xt[R>>0]|0,xt[W+1>>0]=xt[R+1>>0]|0,xt[W+2>>0]=xt[R+2>>0]|0,W=9;break}if(p=Ys((A[d+8>>2]|0)+1|0,32)|0,!p){W=F,A[W>>2]=0,A[W+4>>2]=0,A[F+8>>2]=13,A[F+12>>2]=-1,W=F+16|0,p=F+29|0,A[W>>2]=0,A[W+4>>2]=0,A[W+8>>2]=0,xt[W+12>>0]=0,xt[p>>0]=xt[R>>0]|0,xt[p+1>>0]=xt[R+1>>0]|0,xt[p+2>>0]=xt[R+2>>0]|0,p=13,W=9;break}Ea(d,p),ge=F,A[ge>>2]=y,A[ge+4>>2]=M,M=F+8|0,A[M>>2]=0,A[F+12>>2]=f,A[F+20>>2]=d,A[F+24>>2]=p,xt[F+28>>0]=0,y=F+29|0,xt[y>>0]=xt[R>>0]|0,xt[y+1>>0]=xt[R+1>>0]|0,xt[y+2>>0]=xt[R+2>>0]|0,A[F+16>>2]=3,ve=+Qh(p),ve=ve*+el(p),w=+dn(+ +te[p>>3]),w=ve/+an(+ +uf(+w,+ +dn(+ +te[p+8>>3])))*6371.007180918475*6371.007180918475,y=F+12|0,p=A[y>>2]|0;e:do if((p|0)>0)do{if(hp(p+-1|0,B)|0,!(w/+te[B>>3]>10))break e;ge=A[y>>2]|0,p=ge+-1|0,A[y>>2]=p}while((ge|0)>1);while(!1);if(il(F),y=_,A[y>>2]=0,A[y+4>>2]=0,y=F,p=A[y>>2]|0,y=A[y+4>>2]|0,!((p|0)==0&(y|0)==0))do nf(p,y,f,B)|0,R=B,d=_,R=tn(A[d>>2]|0,A[d+4>>2]|0,A[R>>2]|0,A[R+4>>2]|0)|0,d=X()|0,ge=_,A[ge>>2]=R,A[ge+4>>2]=d,il(F),ge=F,p=A[ge>>2]|0,y=A[ge+4>>2]|0;while(!((p|0)==0&(y|0)==0));p=A[M>>2]|0}while(!1);return ge=p,K=oe,ge|0}function Ss(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0;if(!(Do(f,p)|0)||(f=_d(f)|0,_=+te[p>>3],y=+te[p+8>>3],y=f&y<0?y+6.283185307179586:y,ve=A[d>>2]|0,(ve|0)<=0))return ve=0,ve|0;if(oe=A[d+4>>2]|0,f){f=0,W=y,p=-1,d=0;e:for(;;){for(F=d;M=+te[oe+(F<<4)>>3],y=+te[oe+(F<<4)+8>>3],d=(p+2|0)%(ve|0)|0,w=+te[oe+(d<<4)>>3],R=+te[oe+(d<<4)+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(ve|0)){p=22;break e}else d=F,F=p,p=d;if(R=M<0?M+6.283185307179586:M,M=y<0?y+6.283185307179586:y,W=R==W|M==W?W+-2220446049250313e-31:W,B=R+(M-R)*((_-w)/(B-w)),(B<0?B+6.283185307179586:B)>W&&(f=f^1),d=F+1|0,(d|0)>=(ve|0)){p=22;break}else p=F}if((p|0)==22)return f|0}else{f=0,W=y,p=-1,d=0;e:for(;;){for(F=d;M=+te[oe+(F<<4)>>3],y=+te[oe+(F<<4)+8>>3],d=(p+2|0)%(ve|0)|0,w=+te[oe+(d<<4)>>3],R=+te[oe+(d<<4)+8>>3],M>w?(B=M,M=R):(B=w,w=M,M=y,y=R),_=_==w|_==B?_+2220446049250313e-31:_,!!(_B);)if(p=F+1|0,(p|0)>=(ve|0)){p=22;break e}else d=F,F=p,p=d;if(W=M==W|y==W?W+-2220446049250313e-31:W,M+(y-M)*((_-w)/(B-w))>W&&(f=f^1),d=F+1|0,(d|0)>=(ve|0)){p=22;break}else p=F}if((p|0)==22)return f|0}return 0}function da(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0;if(_e=A[d>>2]|0,!_e){A[f>>2]=0,A[f+4>>2]=0,A[f+8>>2]=0,A[f+12>>2]=0,A[f+16>>2]=0,A[f+20>>2]=0,A[f+24>>2]=0,A[f+28>>2]=0;return}if(De=f+8|0,te[De>>3]=17976931348623157e292,ze=f+24|0,te[ze>>3]=17976931348623157e292,te[f>>3]=-17976931348623157e292,nt=f+16|0,te[nt>>3]=-17976931348623157e292,!((_e|0)<=0)){for(ve=A[d+4>>2]|0,F=17976931348623157e292,W=-17976931348623157e292,oe=0,d=-1,w=17976931348623157e292,M=17976931348623157e292,B=-17976931348623157e292,_=-17976931348623157e292,ge=0;p=+te[ve+(ge<<4)>>3],R=+te[ve+(ge<<4)+8>>3],d=d+2|0,y=+te[ve+(((d|0)==(_e|0)?0:d)<<4)+8>>3],p>3]=p,w=p),R>3]=R,M=R),p>B?te[f>>3]=p:p=B,R>_&&(te[nt>>3]=R,_=R),F=R>0&RW?R:W,oe=oe|+dn(+(R-y))>3.141592653589793,d=ge+1|0,(d|0)!=(_e|0);)Xe=ge,B=p,ge=d,d=Xe;oe&&(te[nt>>3]=W,te[ze>>3]=F)}}function Ma(d){return d=d|0,(d>>>0<4?0:15)|0}function Ea(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0;if(_e=A[d>>2]|0,_e){if(De=f+8|0,te[De>>3]=17976931348623157e292,ze=f+24|0,te[ze>>3]=17976931348623157e292,te[f>>3]=-17976931348623157e292,nt=f+16|0,te[nt>>3]=-17976931348623157e292,(_e|0)>0){for(y=A[d+4>>2]|0,ve=17976931348623157e292,ge=-17976931348623157e292,_=0,p=-1,B=17976931348623157e292,F=17976931348623157e292,oe=-17976931348623157e292,M=-17976931348623157e292,Xe=0;w=+te[y+(Xe<<4)>>3],W=+te[y+(Xe<<4)+8>>3],un=p+2|0,R=+te[y+(((un|0)==(_e|0)?0:un)<<4)+8>>3],w>3]=w,B=w),W>3]=W,F=W),w>oe?te[f>>3]=w:w=oe,W>M&&(te[nt>>3]=W,M=W),ve=W>0&Wge?W:ge,_=_|+dn(+(W-R))>3.141592653589793,p=Xe+1|0,(p|0)!=(_e|0);)un=Xe,oe=w,Xe=p,p=un;_&&(te[nt>>3]=ge,te[ze>>3]=ve)}}else A[f>>2]=0,A[f+4>>2]=0,A[f+8>>2]=0,A[f+12>>2]=0,A[f+16>>2]=0,A[f+20>>2]=0,A[f+24>>2]=0,A[f+28>>2]=0;if(un=d+8|0,p=A[un>>2]|0,!((p|0)<=0)){kt=d+12|0,Pe=0;do if(y=A[kt>>2]|0,_=Pe,Pe=Pe+1|0,ze=f+(Pe<<5)|0,nt=A[y+(_<<3)>>2]|0,nt){if(Xe=f+(Pe<<5)+8|0,te[Xe>>3]=17976931348623157e292,d=f+(Pe<<5)+24|0,te[d>>3]=17976931348623157e292,te[ze>>3]=-17976931348623157e292,He=f+(Pe<<5)+16|0,te[He>>3]=-17976931348623157e292,(nt|0)>0){for(_e=A[y+(_<<3)+4>>2]|0,ve=17976931348623157e292,ge=-17976931348623157e292,y=0,_=-1,De=0,B=17976931348623157e292,F=17976931348623157e292,W=-17976931348623157e292,M=-17976931348623157e292;w=+te[_e+(De<<4)>>3],oe=+te[_e+(De<<4)+8>>3],_=_+2|0,R=+te[_e+(((_|0)==(nt|0)?0:_)<<4)+8>>3],w>3]=w,B=w),oe>3]=oe,F=oe),w>W?te[ze>>3]=w:w=W,oe>M&&(te[He>>3]=oe,M=oe),ve=oe>0&oege?oe:ge,y=y|+dn(+(oe-R))>3.141592653589793,_=De+1|0,(_|0)!=(nt|0);)on=De,De=_,W=w,_=on;y&&(te[He>>3]=ge,te[d>>3]=ve)}}else A[ze>>2]=0,A[ze+4>>2]=0,A[ze+8>>2]=0,A[ze+12>>2]=0,A[ze+16>>2]=0,A[ze+20>>2]=0,A[ze+24>>2]=0,A[ze+28>>2]=0,p=A[un>>2]|0;while((Pe|0)<(p|0))}}function Ca(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(!(Ss(d,f,p)|0))return y=0,y|0;if(y=d+8|0,(A[y>>2]|0)<=0)return y=1,y|0;for(_=d+12|0,d=0;;){if(w=d,d=d+1|0,Ss((A[_>>2]|0)+(w<<3)|0,f+(d<<5)|0,p)|0){d=0,_=6;break}if((d|0)>=(A[y>>2]|0)){d=1,_=6;break}}return(_|0)==6?d|0:0}function Uo(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(F=K,K=K+16|0,R=F,M=p+8|0,!(Ss(d,f,M)|0))return B=0,K=F,B|0;B=d+8|0;e:do if((A[B>>2]|0)>0){for(w=d+12|0,y=0;;){if(W=y,y=y+1|0,Ss((A[w>>2]|0)+(W<<3)|0,f+(y<<5)|0,M)|0){y=0;break}if((y|0)>=(A[B>>2]|0))break e}return K=F,y|0}while(!1);if(af(d,f,p,_)|0)return W=0,K=F,W|0;A[R>>2]=A[p>>2],A[R+4>>2]=M,y=A[B>>2]|0;e:do if((y|0)>0)for(d=d+12|0,M=0,w=y;;){if(y=A[d>>2]|0,(A[y+(M<<3)>>2]|0)>0){if(Ss(R,_,A[y+(M<<3)+4>>2]|0)|0){y=0;break e}if(y=M+1|0,af((A[d>>2]|0)+(M<<3)|0,f+(y<<5)|0,p,_)|0){y=0;break e}w=A[B>>2]|0}else y=M+1|0;if((y|0)<(w|0))M=y;else{y=1;break}}else y=1;while(!1);return W=y,K=F,W|0}function af(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0,un=0,on=0,kn=0;if(un=K,K=K+176|0,Xe=un+172|0,y=un+168|0,He=un,!(Kh(f,_)|0))return d=0,K=un,d|0;if(yd(f,_,Xe,y),Ol(He|0,p|0,168)|0,(A[p>>2]|0)>0){f=0;do on=He+8+(f<<4)+8|0,nt=+Ws(+te[on>>3],A[y>>2]|0),te[on>>3]=nt,f=f+1|0;while((f|0)<(A[p>>2]|0))}De=+te[_>>3],ze=+te[_+8>>3],nt=+Ws(+te[_+16>>3],A[y>>2]|0),ge=+Ws(+te[_+24>>3],A[y>>2]|0);e:do if((A[d>>2]|0)>0){if(_=d+4|0,y=A[He>>2]|0,(y|0)<=0){for(f=0;;)if(f=f+1|0,(f|0)>=(A[d>>2]|0)){f=0;break e}}for(p=0;;){if(f=A[_>>2]|0,ve=+te[f+(p<<4)>>3],_e=+Ws(+te[f+(p<<4)+8>>3],A[Xe>>2]|0),f=A[_>>2]|0,p=p+1|0,on=(p|0)%(A[d>>2]|0)|0,w=+te[f+(on<<4)>>3],M=+Ws(+te[f+(on<<4)+8>>3],A[Xe>>2]|0),!(ve>=De)|!(w>=De)&&!(ve<=ze)|!(w<=ze)&&!(_e<=ge)|!(M<=ge)&&!(_e>=nt)|!(M>=nt)){oe=w-ve,F=M-_e,f=0;do if(kn=f,f=f+1|0,on=(f|0)==(y|0)?0:f,w=+te[He+8+(kn<<4)+8>>3],M=+te[He+8+(on<<4)+8>>3]-w,R=+te[He+8+(kn<<4)>>3],B=+te[He+8+(on<<4)>>3]-R,W=oe*M-F*B,W!=0&&(Pe=_e-w,kt=ve-R,B=(Pe*B-M*kt)/W,!(B<0|B>1))&&(W=(oe*Pe-F*kt)/W,W>=0&W<=1)){f=1;break e}while((f|0)<(y|0))}if((p|0)>=(A[d>>2]|0)){f=0;break}}}else f=0;while(!1);return kn=f,K=un,kn|0}function Bd(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0;if(af(d,f,p,_)|0)return w=1,w|0;if(w=d+8|0,(A[w>>2]|0)<=0)return w=0,w|0;for(y=d+12|0,d=0;;){if(M=d,d=d+1|0,af((A[y>>2]|0)+(M<<3)|0,f+(d<<5)|0,p,_)|0){d=1,y=6;break}if((d|0)>=(A[w>>2]|0)){d=0,y=6;break}}return(y|0)==6?d|0:0}function mp(){return 8}function C1(){return 16}function cs(){return 168}function er(){return 8}function Ai(){return 16}function Ul(){return 12}function Na(){return 8}function gp(d){return d=d|0,+(+((A[d>>2]|0)>>>0)+4294967296*+(A[d+4>>2]|0))}function Bl(d){d=d|0;var f=0,p=0;return p=+te[d>>3],f=+te[d+8>>3],+ +Fn(+(p*p+f*f))}function vp(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0;F=+te[d>>3],B=+te[f>>3]-F,R=+te[d+8>>3],M=+te[f+8>>3]-R,oe=+te[p>>3],w=+te[_>>3]-oe,ve=+te[p+8>>3],W=+te[_+8>>3]-ve,w=(w*(R-ve)-(F-oe)*W)/(B*W-M*w),te[y>>3]=F+B*w,te[y+8>>3]=R+M*w}function _p(d,f){return d=d|0,f=f|0,+dn(+(+te[d>>3]-+te[f>>3]))<11920928955078125e-23?(f=+dn(+(+te[d+8>>3]-+te[f+8>>3]))<11920928955078125e-23,f|0):(f=0,f|0)}function tr(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;return y=+te[d>>3]-+te[f>>3],_=+te[d+8>>3]-+te[f+8>>3],p=+te[d+16>>3]-+te[f+16>>3],+(y*y+_*_+p*p)}function ju(d,f){d=d|0,f=f|0;var p=0,_=0,y=0;p=+te[d>>3],_=+an(+p),p=+mn(+p),te[f+16>>3]=p,p=+te[d+8>>3],y=_*+an(+p),te[f>>3]=y,p=_*+mn(+p),te[f+8>>3]=p}function yp(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if(w=K,K=K+16|0,y=w,_=wi(d,f)|0,(p+-1|0)>>>0>5||(_=(_|0)!=0,(p|0)==1&_))return y=-1,K=w,y|0;do if(rl(d,f,y)|0)_=-1;else if(_){_=((A[26352+(p<<2)>>2]|0)+5-(A[y>>2]|0)|0)%5|0;break}else{_=((A[26384+(p<<2)>>2]|0)+6-(A[y>>2]|0)|0)%6|0;break}while(!1);return y=_,K=w,y|0}function rl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0;if(W=K,K=K+32|0,R=W+16|0,B=W,_=Bu(d,f,R)|0,_|0)return p=_,K=W,p|0;w=m1(d,f)|0,F=Hs(d,f)|0,Z0(w,B),_=Vc(w,A[R>>2]|0)|0;do if(Ji(w)|0){do switch(w|0){case 4:{y=0;break}case 14:{y=1;break}case 24:{y=2;break}case 38:{y=3;break}case 49:{y=4;break}case 58:{y=5;break}case 63:{y=6;break}case 72:{y=7;break}case 83:{y=8;break}case 97:{y=9;break}case 107:{y=10;break}case 117:{y=11;break}default:et(27795,27797,75,27806)}while(!1);if(M=A[26416+(y*24|0)+8>>2]|0,f=A[26416+(y*24|0)+16>>2]|0,d=A[R>>2]|0,(d|0)!=(A[B>>2]|0)&&(B=qc(w)|0,d=A[R>>2]|0,B|(d|0)==(f|0)&&(_=(_+1|0)%6|0)),(F|0)==3&(d|0)==(f|0)){_=(_+5|0)%6|0;break}(F|0)==5&(d|0)==(M|0)&&(_=(_+1|0)%6|0)}while(!1);return A[p>>2]=_,p=0,K=W,p|0}function Xs(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0;if(He=K,K=K+32|0,Xe=He+24|0,ze=He+20|0,_e=He+8|0,ge=He+16|0,ve=He,B=(wi(d,f)|0)==0,B=B?6:5,W=Ct(d|0,f|0,52)|0,X()|0,W=W&15,B>>>0<=p>>>0)return _=2,K=He,_|0;oe=(W|0)==0,!oe&&(De=Ot(7,0,(W^15)*3|0)|0,(De&d|0)==0&((X()|0)&f|0)==0)?y=p:w=4;e:do if((w|0)==4){if(y=(wi(d,f)|0)!=0,((y?4:5)|0)<(p|0)||rl(d,f,Xe)|0||(w=(A[Xe>>2]|0)+p|0,y?y=26704+(((w|0)%5|0)<<2)|0:y=26736+(((w|0)%6|0)<<2)|0,De=A[y>>2]|0,(De|0)==7))return _=1,K=He,_|0;A[ze>>2]=0,y=bi(d,f,De,ze,_e)|0;do if(!y){if(R=_e,F=A[R>>2]|0,R=A[R+4>>2]|0,M=R>>>0>>0|(R|0)==(f|0)&F>>>0>>0,w=M?F:d,M=M?R:f,!oe&&(oe=Ot(7,0,(W^15)*3|0)|0,(F&oe|0)==0&(R&(X()|0)|0)==0))y=p;else{if(R=(p+-1+B|0)%(B|0)|0,y=wi(d,f)|0,(R|0)<0&&et(27795,27797,248,27822),B=(y|0)!=0,((B?4:5)|0)<(R|0)&&et(27795,27797,248,27822),rl(d,f,Xe)|0&&et(27795,27797,248,27822),y=(A[Xe>>2]|0)+R|0,B?y=26704+(((y|0)%5|0)<<2)|0:y=26736+(((y|0)%6|0)<<2)|0,R=A[y>>2]|0,(R|0)==7&&et(27795,27797,248,27822),A[ge>>2]=0,y=bi(d,f,R,ge,ve)|0,y|0)break;F=ve,B=A[F>>2]|0,F=A[F+4>>2]|0;do if(F>>>0>>0|(F|0)==(M|0)&B>>>0>>0){if(wi(B,F)|0?w=xs(B,F,d,f)|0:w=A[26800+((((A[ge>>2]|0)+(A[26768+(R<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=wi(B,F)|0,(w+-1|0)>>>0>5){y=-1,w=B,M=F;break}if(y=(y|0)!=0,(w|0)==1&y){y=-1,w=B,M=F;break}do if(rl(B,F,Xe)|0)y=-1;else if(y){y=((A[26352+(w<<2)>>2]|0)+5-(A[Xe>>2]|0)|0)%5|0;break}else{y=((A[26384+(w<<2)>>2]|0)+6-(A[Xe>>2]|0)|0)%6|0;break}while(!1);w=B,M=F}else y=p;while(!1);R=_e,F=A[R>>2]|0,R=A[R+4>>2]|0}if((w|0)==(F|0)&(M|0)==(R|0)){if(B=(wi(F,R)|0)!=0,B?d=xs(F,R,d,f)|0:d=A[26800+((((A[ze>>2]|0)+(A[26768+(De<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,y=wi(F,R)|0,(d+-1|0)>>>0<=5&&(nt=(y|0)!=0,!((d|0)==1&nt)))do if(rl(F,R,Xe)|0)y=-1;else if(nt){y=((A[26352+(d<<2)>>2]|0)+5-(A[Xe>>2]|0)|0)%5|0;break}else{y=((A[26384+(d<<2)>>2]|0)+6-(A[Xe>>2]|0)|0)%6|0;break}while(!1);else y=-1;y=y+1|0,y=(y|0)==6|B&(y|0)==5?0:y}f=M,d=w;break e}while(!1);return _=y,K=He,_|0}while(!1);return nt=Ot(y|0,0,56)|0,Xe=X()|0|f&-2130706433|536870912,A[_>>2]=nt|d,A[_+4>>2]=Xe,_=0,K=He,_|0}function Hu(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;return w=(wi(d,f)|0)==0,_=Xs(d,f,0,p)|0,y=(_|0)==0,w?!y||(_=Xs(d,f,1,p+8|0)|0,_|0)||(_=Xs(d,f,2,p+16|0)|0,_|0)||(_=Xs(d,f,3,p+24|0)|0,_|0)||(_=Xs(d,f,4,p+32|0)|0,_)?(w=_,w|0):Xs(d,f,5,p+40|0)|0:!y||(_=Xs(d,f,1,p+8|0)|0,_|0)||(_=Xs(d,f,2,p+16|0)|0,_|0)||(_=Xs(d,f,3,p+24|0)|0,_|0)||(_=Xs(d,f,4,p+32|0)|0,_|0)?(w=_,w|0):(w=p+40|0,A[w>>2]=0,A[w+4>>2]=0,w=0,w|0)}function sl(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0,R=0,B=0;return B=K,K=K+192|0,y=B,w=B+168|0,M=Ct(d|0,f|0,56)|0,X()|0,M=M&7,R=f&-2130706433|134217728,_=Bu(d,R,w)|0,_|0?(R=_,K=B,R|0):(f=Ct(d|0,f|0,52)|0,X()|0,f=f&15,wi(d,R)|0?np(w,f,M,1,y):wd(w,f,M,1,y),R=y+8|0,A[p>>2]=A[R>>2],A[p+4>>2]=A[R+4>>2],A[p+8>>2]=A[R+8>>2],A[p+12>>2]=A[R+12>>2],R=0,K=B,R|0)}function al(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return y=K,K=K+16|0,p=y,!(!0&(f&2013265920|0)==536870912)||(_=f&-2130706433|134217728,!(Td(d,_)|0))?(_=0,K=y,_|0):(w=Ct(d|0,f|0,56)|0,X()|0,w=(Xs(d,_,w&7,p)|0)==0,_=p,_=w&((A[_>>2]|0)==(d|0)?(A[_+4>>2]|0)==(f|0):0)&1,K=y,_|0)}function Bo(d,f,p){d=d|0,f=f|0,p=p|0;var _=0;(f|0)>0?(_=Ys(f,4)|0,A[d>>2]=_,_||et(27835,27858,40,27872)):A[d>>2]=0,A[d+4>>2]=f,A[d+8>>2]=0,A[d+12>>2]=p}function Od(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0;y=d+4|0,w=d+12|0,M=d+8|0;e:for(;;){for(p=A[y>>2]|0,f=0;;){if((f|0)>=(p|0))break e;if(_=A[d>>2]|0,R=A[_+(f<<2)>>2]|0,!R)f=f+1|0;else break}f=_+(~~(+dn(+(+lr(10,+ +(15-(A[w>>2]|0)|0))*(+te[R>>3]+ +te[R+8>>3])))%+(p|0))>>>0<<2)|0,p=A[f>>2]|0;t:do if(p|0){if(_=R+32|0,(p|0)==(R|0))A[f>>2]=A[_>>2];else{if(p=p+32|0,f=A[p>>2]|0,!f)break;for(;(f|0)!=(R|0);)if(p=f+32|0,f=A[p>>2]|0,!f)break t;A[p>>2]=A[_>>2]}vn(R),A[M>>2]=(A[M>>2]|0)+-1}while(!1)}vn(A[d>>2]|0)}function Id(d){d=d|0;var f=0,p=0,_=0;for(_=A[d+4>>2]|0,p=0;;){if((p|0)>=(_|0)){f=0,p=4;break}if(f=A[(A[d>>2]|0)+(p<<2)>>2]|0,!f)p=p+1|0;else{p=4;break}}return(p|0)==4?f|0:0}function Wu(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;if(p=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+te[f>>3]+ +te[f+8>>3])))%+(A[d+4>>2]|0))>>>0,p=(A[d>>2]|0)+(p<<2)|0,_=A[p>>2]|0,!_)return w=1,w|0;w=f+32|0;do if((_|0)!=(f|0)){if(p=A[_+32>>2]|0,!p)return w=1,w|0;for(y=p;;){if((y|0)==(f|0)){y=8;break}if(p=A[y+32>>2]|0,p)_=y,y=p;else{p=1,y=10;break}}if((y|0)==8){A[_+32>>2]=A[w>>2];break}else if((y|0)==10)return p|0}else A[p>>2]=A[w>>2];while(!1);return vn(f),w=d+8|0,A[w>>2]=(A[w>>2]|0)+-1,w=0,w|0}function Fd(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;w=Oo(40)|0,w||et(27888,27858,98,27901),A[w>>2]=A[f>>2],A[w+4>>2]=A[f+4>>2],A[w+8>>2]=A[f+8>>2],A[w+12>>2]=A[f+12>>2],y=w+16|0,A[y>>2]=A[p>>2],A[y+4>>2]=A[p+4>>2],A[y+8>>2]=A[p+8>>2],A[y+12>>2]=A[p+12>>2],A[w+32>>2]=0,y=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+te[f>>3]+ +te[f+8>>3])))%+(A[d+4>>2]|0))>>>0,y=(A[d>>2]|0)+(y<<2)|0,_=A[y>>2]|0;do if(!_)A[y>>2]=w;else{for(;!(wa(_,f)|0&&wa(_+16|0,p)|0);)if(y=A[_+32>>2]|0,_=(y|0)==0?_:y,!(A[_+32>>2]|0)){M=10;break}if((M|0)==10){A[_+32>>2]=w;break}return vn(w),M=_,M|0}while(!1);return M=d+8|0,A[M>>2]=(A[M>>2]|0)+1,M=w,M|0}function $u(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0;if(y=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+te[f>>3]+ +te[f+8>>3])))%+(A[d+4>>2]|0))>>>0,y=A[(A[d>>2]|0)+(y<<2)>>2]|0,!y)return p=0,p|0;if(!p){for(d=y;;){if(wa(d,f)|0){_=10;break}if(d=A[d+32>>2]|0,!d){d=0,_=10;break}}if((_|0)==10)return d|0}for(d=y;;){if(wa(d,f)|0&&wa(d+16|0,p)|0){_=10;break}if(d=A[d+32>>2]|0,!d){d=0,_=10;break}}return(_|0)==10?d|0:0}function hs(d,f){d=d|0,f=f|0;var p=0;if(p=~~(+dn(+(+lr(10,+ +(15-(A[d+12>>2]|0)|0))*(+te[f>>3]+ +te[f+8>>3])))%+(A[d+4>>2]|0))>>>0,d=A[(A[d>>2]|0)+(p<<2)>>2]|0,!d)return p=0,p|0;for(;;){if(wa(d,f)|0){f=5;break}if(d=A[d+32>>2]|0,!d){d=0,f=5;break}}return(f|0)==5?d|0:0}function kd(){return 27920}function ol(d){return d=+d,~~+cf(+d)|0}function Oo(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0,De=0,ze=0,nt=0,Xe=0,He=0,Pe=0,kt=0;kt=K,K=K+16|0,ve=kt;do if(d>>>0<245){if(F=d>>>0<11?16:d+11&-8,d=F>>>3,oe=A[6981]|0,p=oe>>>d,p&3|0)return f=(p&1^1)+d|0,d=27964+(f<<1<<2)|0,p=d+8|0,_=A[p>>2]|0,y=_+8|0,w=A[y>>2]|0,(w|0)==(d|0)?A[6981]=oe&~(1<>2]=d,A[p>>2]=w),Pe=f<<3,A[_+4>>2]=Pe|3,Pe=_+Pe+4|0,A[Pe>>2]=A[Pe>>2]|1,Pe=y,K=kt,Pe|0;if(W=A[6983]|0,F>>>0>W>>>0){if(p|0)return f=2<>>12&16,f=f>>>R,p=f>>>5&8,f=f>>>p,w=f>>>2&4,f=f>>>w,d=f>>>1&2,f=f>>>d,_=f>>>1&1,_=(p|R|w|d|_)+(f>>>_)|0,f=27964+(_<<1<<2)|0,d=f+8|0,w=A[d>>2]|0,R=w+8|0,p=A[R>>2]|0,(p|0)==(f|0)?(d=oe&~(1<<_),A[6981]=d):(A[p+12>>2]=f,A[d>>2]=p,d=oe),Pe=_<<3,M=Pe-F|0,A[w+4>>2]=F|3,y=w+F|0,A[y+4>>2]=M|1,A[w+Pe>>2]=M,W|0&&(_=A[6986]|0,f=W>>>3,p=27964+(f<<1<<2)|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=_,A[f+12>>2]=_,A[_+8>>2]=f,A[_+12>>2]=p),A[6983]=M,A[6986]=y,Pe=R,K=kt,Pe|0;if(w=A[6982]|0,w){for(p=(w&0-w)+-1|0,y=p>>>12&16,p=p>>>y,_=p>>>5&8,p=p>>>_,M=p>>>2&4,p=p>>>M,R=p>>>1&2,p=p>>>R,B=p>>>1&1,B=A[28228+((_|y|M|R|B)+(p>>>B)<<2)>>2]|0,p=B,R=B,B=(A[B+4>>2]&-8)-F|0;d=A[p+16>>2]|0,!(!d&&(d=A[p+20>>2]|0,!d));)M=(A[d+4>>2]&-8)-F|0,y=M>>>0>>0,p=d,R=y?d:R,B=y?M:B;if(M=R+F|0,M>>>0>R>>>0){y=A[R+24>>2]|0,f=A[R+12>>2]|0;do if((f|0)==(R|0)){if(d=R+20|0,f=A[d>>2]|0,!f&&(d=R+16|0,f=A[d>>2]|0,!f)){p=0;break}for(;;)if(_=f+20|0,p=A[_>>2]|0,p)f=p,d=_;else if(_=f+16|0,p=A[_>>2]|0,p)f=p,d=_;else break;A[d>>2]=0,p=f}else p=A[R+8>>2]|0,A[p+12>>2]=f,A[f+8>>2]=p,p=f;while(!1);do if(y|0){if(f=A[R+28>>2]|0,d=28228+(f<<2)|0,(R|0)==(A[d>>2]|0)){if(A[d>>2]=p,!p){A[6982]=w&~(1<>2]|0)==(R|0)?Pe:y+20|0)>>2]=p,!p)break;A[p+24>>2]=y,f=A[R+16>>2]|0,f|0&&(A[p+16>>2]=f,A[f+24>>2]=p),f=A[R+20>>2]|0,f|0&&(A[p+20>>2]=f,A[f+24>>2]=p)}while(!1);return B>>>0<16?(Pe=B+F|0,A[R+4>>2]=Pe|3,Pe=R+Pe+4|0,A[Pe>>2]=A[Pe>>2]|1):(A[R+4>>2]=F|3,A[M+4>>2]=B|1,A[M+B>>2]=B,W|0&&(_=A[6986]|0,f=W>>>3,p=27964+(f<<1<<2)|0,f=1<>2]|0):(A[6981]=f|oe,f=p,d=p+8|0),A[d>>2]=_,A[f+12>>2]=_,A[_+8>>2]=f,A[_+12>>2]=p),A[6983]=B,A[6986]=M),Pe=R+8|0,K=kt,Pe|0}else oe=F}else oe=F}else oe=F}else if(d>>>0<=4294967231)if(d=d+11|0,F=d&-8,_=A[6982]|0,_){y=0-F|0,d=d>>>8,d?F>>>0>16777215?B=31:(oe=(d+1048320|0)>>>16&8,De=d<>>16&4,De=De<>>16&2,B=14-(R|oe|B)+(De<>>15)|0,B=F>>>(B+7|0)&1|B<<1):B=0,p=A[28228+(B<<2)>>2]|0;e:do if(!p)p=0,d=0,De=61;else for(d=0,R=F<<((B|0)==31?0:25-(B>>>1)|0),w=0;;){if(M=(A[p+4>>2]&-8)-F|0,M>>>0>>0)if(M)d=p,y=M;else{d=p,y=0,De=65;break e}if(De=A[p+20>>2]|0,p=A[p+16+(R>>>31<<2)>>2]|0,w=(De|0)==0|(De|0)==(p|0)?w:De,p)R=R<<1;else{p=w,De=61;break}}while(!1);if((De|0)==61){if((p|0)==0&(d|0)==0){if(d=2<>>12&16,oe=oe>>>M,w=oe>>>5&8,oe=oe>>>w,R=oe>>>2&4,oe=oe>>>R,B=oe>>>1&2,oe=oe>>>B,p=oe>>>1&1,d=0,p=A[28228+((w|M|R|B|p)+(oe>>>p)<<2)>>2]|0}p?De=65:(R=d,M=y)}if((De|0)==65)for(w=p;;)if(oe=(A[w+4>>2]&-8)-F|0,p=oe>>>0>>0,y=p?oe:y,d=p?w:d,p=A[w+16>>2]|0,p||(p=A[w+20>>2]|0),p)w=p;else{R=d,M=y;break}if((R|0)!=0&&M>>>0<((A[6983]|0)-F|0)>>>0&&(W=R+F|0,W>>>0>R>>>0)){w=A[R+24>>2]|0,f=A[R+12>>2]|0;do if((f|0)==(R|0)){if(d=R+20|0,f=A[d>>2]|0,!f&&(d=R+16|0,f=A[d>>2]|0,!f)){f=0;break}for(;;)if(y=f+20|0,p=A[y>>2]|0,p)f=p,d=y;else if(y=f+16|0,p=A[y>>2]|0,p)f=p,d=y;else break;A[d>>2]=0}else Pe=A[R+8>>2]|0,A[Pe+12>>2]=f,A[f+8>>2]=Pe;while(!1);do if(w){if(d=A[R+28>>2]|0,p=28228+(d<<2)|0,(R|0)==(A[p>>2]|0)){if(A[p>>2]=f,!f){_=_&~(1<>2]|0)==(R|0)?Pe:w+20|0)>>2]=f,!f)break;A[f+24>>2]=w,d=A[R+16>>2]|0,d|0&&(A[f+16>>2]=d,A[d+24>>2]=f),d=A[R+20>>2]|0,d&&(A[f+20>>2]=d,A[d+24>>2]=f)}while(!1);e:do if(M>>>0<16)Pe=M+F|0,A[R+4>>2]=Pe|3,Pe=R+Pe+4|0,A[Pe>>2]=A[Pe>>2]|1;else{if(A[R+4>>2]=F|3,A[W+4>>2]=M|1,A[W+M>>2]=M,f=M>>>3,M>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=W,A[f+12>>2]=W,A[W+8>>2]=f,A[W+12>>2]=p;break}if(f=M>>>8,f?M>>>0>16777215?p=31:(He=(f+1048320|0)>>>16&8,Pe=f<>>16&4,Pe=Pe<>>16&2,p=14-(Xe|He|p)+(Pe<

>>15)|0,p=M>>>(p+7|0)&1|p<<1):p=0,f=28228+(p<<2)|0,A[W+28>>2]=p,d=W+16|0,A[d+4>>2]=0,A[d>>2]=0,d=1<>2]=W,A[W+24>>2]=f,A[W+12>>2]=W,A[W+8>>2]=W;break}f=A[f>>2]|0;t:do if((A[f+4>>2]&-8|0)!=(M|0)){for(_=M<<((p|0)==31?0:25-(p>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(M|0)){f=d;break t}else _=_<<1,f=d;A[p>>2]=W,A[W+24>>2]=f,A[W+12>>2]=W,A[W+8>>2]=W;break e}while(!1);He=f+8|0,Pe=A[He>>2]|0,A[Pe+12>>2]=W,A[He>>2]=W,A[W+8>>2]=Pe,A[W+12>>2]=f,A[W+24>>2]=0}while(!1);return Pe=R+8|0,K=kt,Pe|0}else oe=F}else oe=F;else oe=-1;while(!1);if(p=A[6983]|0,p>>>0>=oe>>>0)return f=p-oe|0,d=A[6986]|0,f>>>0>15?(Pe=d+oe|0,A[6986]=Pe,A[6983]=f,A[Pe+4>>2]=f|1,A[d+p>>2]=f,A[d+4>>2]=oe|3):(A[6983]=0,A[6986]=0,A[d+4>>2]=p|3,Pe=d+p+4|0,A[Pe>>2]=A[Pe>>2]|1),Pe=d+8|0,K=kt,Pe|0;if(M=A[6984]|0,M>>>0>oe>>>0)return Xe=M-oe|0,A[6984]=Xe,Pe=A[6987]|0,He=Pe+oe|0,A[6987]=He,A[He+4>>2]=Xe|1,A[Pe+4>>2]=oe|3,Pe=Pe+8|0,K=kt,Pe|0;if(A[7099]|0?d=A[7101]|0:(A[7101]=4096,A[7100]=4096,A[7102]=-1,A[7103]=-1,A[7104]=0,A[7092]=0,A[7099]=ve&-16^1431655768,d=4096),R=oe+48|0,B=oe+47|0,w=d+B|0,y=0-d|0,F=w&y,F>>>0<=oe>>>0||(d=A[7091]|0,d|0&&(W=A[7089]|0,ve=W+F|0,ve>>>0<=W>>>0|ve>>>0>d>>>0)))return Pe=0,K=kt,Pe|0;e:do if(A[7092]&4)f=0,De=143;else{p=A[6987]|0;t:do if(p){for(_=28372;ve=A[_>>2]|0,!(ve>>>0<=p>>>0&&(ve+(A[_+4>>2]|0)|0)>>>0>p>>>0);)if(d=A[_+8>>2]|0,d)_=d;else{De=128;break t}if(f=w-M&y,f>>>0<2147483647)if(d=ul(f|0)|0,(d|0)==((A[_>>2]|0)+(A[_+4>>2]|0)|0)){if((d|0)!=-1){M=f,w=d,De=145;break e}}else _=d,De=136;else f=0}else De=128;while(!1);do if((De|0)==128)if(p=ul(0)|0,(p|0)!=-1&&(f=p,ge=A[7100]|0,_e=ge+-1|0,f=((_e&f|0)==0?0:(_e+f&0-ge)-f|0)+F|0,ge=A[7089]|0,_e=f+ge|0,f>>>0>oe>>>0&f>>>0<2147483647)){if(ve=A[7091]|0,ve|0&&_e>>>0<=ge>>>0|_e>>>0>ve>>>0){f=0;break}if(d=ul(f|0)|0,(d|0)==(p|0)){M=f,w=p,De=145;break e}else _=d,De=136}else f=0;while(!1);do if((De|0)==136){if(p=0-f|0,!(R>>>0>f>>>0&(f>>>0<2147483647&(_|0)!=-1)))if((_|0)==-1){f=0;break}else{M=f,w=_,De=145;break e}if(d=A[7101]|0,d=B-f+d&0-d,d>>>0>=2147483647){M=f,w=_,De=145;break e}if((ul(d|0)|0)==-1){ul(p|0)|0,f=0;break}else{M=d+f|0,w=_,De=145;break e}}while(!1);A[7092]=A[7092]|4,De=143}while(!1);if((De|0)==143&&F>>>0<2147483647&&(Xe=ul(F|0)|0,_e=ul(0)|0,ze=_e-Xe|0,nt=ze>>>0>(oe+40|0)>>>0,!((Xe|0)==-1|nt^1|Xe>>>0<_e>>>0&((Xe|0)!=-1&(_e|0)!=-1)^1))&&(M=nt?ze:f,w=Xe,De=145),(De|0)==145){f=(A[7089]|0)+M|0,A[7089]=f,f>>>0>(A[7090]|0)>>>0&&(A[7090]=f),B=A[6987]|0;e:do if(B){for(f=28372;;){if(d=A[f>>2]|0,p=A[f+4>>2]|0,(w|0)==(d+p|0)){De=154;break}if(_=A[f+8>>2]|0,_)f=_;else break}if((De|0)==154&&(He=f+4|0,(A[f+12>>2]&8|0)==0)&&w>>>0>B>>>0&d>>>0<=B>>>0){A[He>>2]=p+M,Pe=(A[6984]|0)+M|0,Xe=B+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,He=B+Xe|0,Xe=Pe-Xe|0,A[6987]=He,A[6984]=Xe,A[He+4>>2]=Xe|1,A[B+Pe+4>>2]=40,A[6988]=A[7103];break}for(w>>>0<(A[6985]|0)>>>0&&(A[6985]=w),p=w+M|0,f=28372;;){if((A[f>>2]|0)==(p|0)){De=162;break}if(d=A[f+8>>2]|0,d)f=d;else break}if((De|0)==162&&(A[f+12>>2]&8|0)==0){A[f>>2]=w,W=f+4|0,A[W>>2]=(A[W>>2]|0)+M,W=w+8|0,W=w+((W&7|0)==0?0:0-W&7)|0,f=p+8|0,f=p+((f&7|0)==0?0:0-f&7)|0,F=W+oe|0,R=f-W-oe|0,A[W+4>>2]=oe|3;t:do if((B|0)==(f|0))Pe=(A[6984]|0)+R|0,A[6984]=Pe,A[6987]=F,A[F+4>>2]=Pe|1;else{if((A[6986]|0)==(f|0)){Pe=(A[6983]|0)+R|0,A[6983]=Pe,A[6986]=F,A[F+4>>2]=Pe|1,A[F+Pe>>2]=Pe;break}if(d=A[f+4>>2]|0,(d&3|0)==1){M=d&-8,_=d>>>3;n:do if(d>>>0<256)if(d=A[f+8>>2]|0,p=A[f+12>>2]|0,(p|0)==(d|0)){A[6981]=A[6981]&~(1<<_);break}else{A[d+12>>2]=p,A[p+8>>2]=d;break}else{w=A[f+24>>2]|0,d=A[f+12>>2]|0;do if((d|0)==(f|0)){if(p=f+16|0,_=p+4|0,d=A[_>>2]|0,d)p=_;else if(d=A[p>>2]|0,!d){d=0;break}for(;;)if(y=d+20|0,_=A[y>>2]|0,_)d=_,p=y;else if(y=d+16|0,_=A[y>>2]|0,_)d=_,p=y;else break;A[p>>2]=0}else Pe=A[f+8>>2]|0,A[Pe+12>>2]=d,A[d+8>>2]=Pe;while(!1);if(!w)break;p=A[f+28>>2]|0,_=28228+(p<<2)|0;do if((A[_>>2]|0)!=(f|0)){if(Pe=w+16|0,A[((A[Pe>>2]|0)==(f|0)?Pe:w+20|0)>>2]=d,!d)break n}else{if(A[_>>2]=d,d|0)break;A[6982]=A[6982]&~(1<>2]=w,p=f+16|0,_=A[p>>2]|0,_|0&&(A[d+16>>2]=_,A[_+24>>2]=d),p=A[p+4>>2]|0,!p)break;A[d+20>>2]=p,A[p+24>>2]=d}while(!1);f=f+M|0,y=M+R|0}else y=R;if(f=f+4|0,A[f>>2]=A[f>>2]&-2,A[F+4>>2]=y|1,A[F+y>>2]=y,f=y>>>3,y>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=F,A[f+12>>2]=F,A[F+8>>2]=f,A[F+12>>2]=p;break}f=y>>>8;do if(!f)_=0;else{if(y>>>0>16777215){_=31;break}He=(f+1048320|0)>>>16&8,Pe=f<>>16&4,Pe=Pe<>>16&2,_=14-(Xe|He|_)+(Pe<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1}while(!1);if(f=28228+(_<<2)|0,A[F+28>>2]=_,d=F+16|0,A[d+4>>2]=0,A[d>>2]=0,d=A[6982]|0,p=1<<_,!(d&p)){A[6982]=d|p,A[f>>2]=F,A[F+24>>2]=f,A[F+12>>2]=F,A[F+8>>2]=F;break}f=A[f>>2]|0;n:do if((A[f+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(y|0)){f=d;break n}else _=_<<1,f=d;A[p>>2]=F,A[F+24>>2]=f,A[F+12>>2]=F,A[F+8>>2]=F;break t}while(!1);He=f+8|0,Pe=A[He>>2]|0,A[Pe+12>>2]=F,A[He>>2]=F,A[F+8>>2]=Pe,A[F+12>>2]=f,A[F+24>>2]=0}while(!1);return Pe=W+8|0,K=kt,Pe|0}for(f=28372;d=A[f>>2]|0,!(d>>>0<=B>>>0&&(Pe=d+(A[f+4>>2]|0)|0,Pe>>>0>B>>>0));)f=A[f+8>>2]|0;y=Pe+-47|0,d=y+8|0,d=y+((d&7|0)==0?0:0-d&7)|0,y=B+16|0,d=d>>>0>>0?B:d,f=d+8|0,p=M+-40|0,Xe=w+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,He=w+Xe|0,Xe=p-Xe|0,A[6987]=He,A[6984]=Xe,A[He+4>>2]=Xe|1,A[w+p+4>>2]=40,A[6988]=A[7103],p=d+4|0,A[p>>2]=27,A[f>>2]=A[7093],A[f+4>>2]=A[7094],A[f+8>>2]=A[7095],A[f+12>>2]=A[7096],A[7093]=w,A[7094]=M,A[7096]=0,A[7095]=f,f=d+24|0;do He=f,f=f+4|0,A[f>>2]=7;while((He+8|0)>>>0>>0);if((d|0)!=(B|0)){if(w=d-B|0,A[p>>2]=A[p>>2]&-2,A[B+4>>2]=w|1,A[d>>2]=w,f=w>>>3,w>>>0<256){p=27964+(f<<1<<2)|0,d=A[6981]|0,f=1<>2]|0):(A[6981]=d|f,f=p,d=p+8|0),A[d>>2]=B,A[f+12>>2]=B,A[B+8>>2]=f,A[B+12>>2]=p;break}if(f=w>>>8,f?w>>>0>16777215?_=31:(He=(f+1048320|0)>>>16&8,Pe=f<>>16&4,Pe=Pe<>>16&2,_=14-(Xe|He|_)+(Pe<<_>>>15)|0,_=w>>>(_+7|0)&1|_<<1):_=0,p=28228+(_<<2)|0,A[B+28>>2]=_,A[B+20>>2]=0,A[y>>2]=0,f=A[6982]|0,d=1<<_,!(f&d)){A[6982]=f|d,A[p>>2]=B,A[B+24>>2]=p,A[B+12>>2]=B,A[B+8>>2]=B;break}f=A[p>>2]|0;t:do if((A[f+4>>2]&-8|0)!=(w|0)){for(_=w<<((_|0)==31?0:25-(_>>>1)|0);p=f+16+(_>>>31<<2)|0,d=A[p>>2]|0,!!d;)if((A[d+4>>2]&-8|0)==(w|0)){f=d;break t}else _=_<<1,f=d;A[p>>2]=B,A[B+24>>2]=f,A[B+12>>2]=B,A[B+8>>2]=B;break e}while(!1);He=f+8|0,Pe=A[He>>2]|0,A[Pe+12>>2]=B,A[He>>2]=B,A[B+8>>2]=Pe,A[B+12>>2]=f,A[B+24>>2]=0}}else Pe=A[6985]|0,(Pe|0)==0|w>>>0>>0&&(A[6985]=w),A[7093]=w,A[7094]=M,A[7096]=0,A[6990]=A[7099],A[6989]=-1,A[6994]=27964,A[6993]=27964,A[6996]=27972,A[6995]=27972,A[6998]=27980,A[6997]=27980,A[7e3]=27988,A[6999]=27988,A[7002]=27996,A[7001]=27996,A[7004]=28004,A[7003]=28004,A[7006]=28012,A[7005]=28012,A[7008]=28020,A[7007]=28020,A[7010]=28028,A[7009]=28028,A[7012]=28036,A[7011]=28036,A[7014]=28044,A[7013]=28044,A[7016]=28052,A[7015]=28052,A[7018]=28060,A[7017]=28060,A[7020]=28068,A[7019]=28068,A[7022]=28076,A[7021]=28076,A[7024]=28084,A[7023]=28084,A[7026]=28092,A[7025]=28092,A[7028]=28100,A[7027]=28100,A[7030]=28108,A[7029]=28108,A[7032]=28116,A[7031]=28116,A[7034]=28124,A[7033]=28124,A[7036]=28132,A[7035]=28132,A[7038]=28140,A[7037]=28140,A[7040]=28148,A[7039]=28148,A[7042]=28156,A[7041]=28156,A[7044]=28164,A[7043]=28164,A[7046]=28172,A[7045]=28172,A[7048]=28180,A[7047]=28180,A[7050]=28188,A[7049]=28188,A[7052]=28196,A[7051]=28196,A[7054]=28204,A[7053]=28204,A[7056]=28212,A[7055]=28212,Pe=M+-40|0,Xe=w+8|0,Xe=(Xe&7|0)==0?0:0-Xe&7,He=w+Xe|0,Xe=Pe-Xe|0,A[6987]=He,A[6984]=Xe,A[He+4>>2]=Xe|1,A[w+Pe+4>>2]=40,A[6988]=A[7103];while(!1);if(f=A[6984]|0,f>>>0>oe>>>0)return Xe=f-oe|0,A[6984]=Xe,Pe=A[6987]|0,He=Pe+oe|0,A[6987]=He,A[He+4>>2]=Xe|1,A[Pe+4>>2]=oe|3,Pe=Pe+8|0,K=kt,Pe|0}return Pe=kd()|0,A[Pe>>2]=12,Pe=0,K=kt,Pe|0}function vn(d){d=d|0;var f=0,p=0,_=0,y=0,w=0,M=0,R=0,B=0;if(d){p=d+-8|0,y=A[6985]|0,d=A[d+-4>>2]|0,f=d&-8,B=p+f|0;do if(d&1)R=p,M=p;else{if(_=A[p>>2]|0,!(d&3)||(M=p+(0-_)|0,w=_+f|0,M>>>0>>0))return;if((A[6986]|0)==(M|0)){if(d=B+4|0,f=A[d>>2]|0,(f&3|0)!=3){R=M,f=w;break}A[6983]=w,A[d>>2]=f&-2,A[M+4>>2]=w|1,A[M+w>>2]=w;return}if(p=_>>>3,_>>>0<256)if(d=A[M+8>>2]|0,f=A[M+12>>2]|0,(f|0)==(d|0)){A[6981]=A[6981]&~(1<>2]=f,A[f+8>>2]=d,R=M,f=w;break}y=A[M+24>>2]|0,d=A[M+12>>2]|0;do if((d|0)==(M|0)){if(f=M+16|0,p=f+4|0,d=A[p>>2]|0,d)f=p;else if(d=A[f>>2]|0,!d){d=0;break}for(;;)if(_=d+20|0,p=A[_>>2]|0,p)d=p,f=_;else if(_=d+16|0,p=A[_>>2]|0,p)d=p,f=_;else break;A[f>>2]=0}else R=A[M+8>>2]|0,A[R+12>>2]=d,A[d+8>>2]=R;while(!1);if(y){if(f=A[M+28>>2]|0,p=28228+(f<<2)|0,(A[p>>2]|0)==(M|0)){if(A[p>>2]=d,!d){A[6982]=A[6982]&~(1<>2]|0)==(M|0)?R:y+20|0)>>2]=d,!d){R=M,f=w;break}A[d+24>>2]=y,f=M+16|0,p=A[f>>2]|0,p|0&&(A[d+16>>2]=p,A[p+24>>2]=d),f=A[f+4>>2]|0,f?(A[d+20>>2]=f,A[f+24>>2]=d,R=M,f=w):(R=M,f=w)}else R=M,f=w}while(!1);if(!(M>>>0>=B>>>0)&&(d=B+4|0,_=A[d>>2]|0,!!(_&1))){if(_&2)A[d>>2]=_&-2,A[R+4>>2]=f|1,A[M+f>>2]=f,y=f;else{if((A[6987]|0)==(B|0)){if(B=(A[6984]|0)+f|0,A[6984]=B,A[6987]=R,A[R+4>>2]=B|1,(R|0)!=(A[6986]|0))return;A[6986]=0,A[6983]=0;return}if((A[6986]|0)==(B|0)){B=(A[6983]|0)+f|0,A[6983]=B,A[6986]=M,A[R+4>>2]=B|1,A[M+B>>2]=B;return}y=(_&-8)+f|0,p=_>>>3;do if(_>>>0<256)if(f=A[B+8>>2]|0,d=A[B+12>>2]|0,(d|0)==(f|0)){A[6981]=A[6981]&~(1<>2]=d,A[d+8>>2]=f;break}else{w=A[B+24>>2]|0,d=A[B+12>>2]|0;do if((d|0)==(B|0)){if(f=B+16|0,p=f+4|0,d=A[p>>2]|0,d)f=p;else if(d=A[f>>2]|0,!d){p=0;break}for(;;)if(_=d+20|0,p=A[_>>2]|0,p)d=p,f=_;else if(_=d+16|0,p=A[_>>2]|0,p)d=p,f=_;else break;A[f>>2]=0,p=d}else p=A[B+8>>2]|0,A[p+12>>2]=d,A[d+8>>2]=p,p=d;while(!1);if(w|0){if(d=A[B+28>>2]|0,f=28228+(d<<2)|0,(A[f>>2]|0)==(B|0)){if(A[f>>2]=p,!p){A[6982]=A[6982]&~(1<>2]|0)==(B|0)?_:w+20|0)>>2]=p,!p)break;A[p+24>>2]=w,d=B+16|0,f=A[d>>2]|0,f|0&&(A[p+16>>2]=f,A[f+24>>2]=p),d=A[d+4>>2]|0,d|0&&(A[p+20>>2]=d,A[d+24>>2]=p)}}while(!1);if(A[R+4>>2]=y|1,A[M+y>>2]=y,(R|0)==(A[6986]|0)){A[6983]=y;return}}if(d=y>>>3,y>>>0<256){p=27964+(d<<1<<2)|0,f=A[6981]|0,d=1<>2]|0):(A[6981]=f|d,d=p,f=p+8|0),A[f>>2]=R,A[d+12>>2]=R,A[R+8>>2]=d,A[R+12>>2]=p;return}d=y>>>8,d?y>>>0>16777215?_=31:(M=(d+1048320|0)>>>16&8,B=d<>>16&4,B=B<>>16&2,_=14-(w|M|_)+(B<<_>>>15)|0,_=y>>>(_+7|0)&1|_<<1):_=0,d=28228+(_<<2)|0,A[R+28>>2]=_,A[R+20>>2]=0,A[R+16>>2]=0,f=A[6982]|0,p=1<<_;e:do if(!(f&p))A[6982]=f|p,A[d>>2]=R,A[R+24>>2]=d,A[R+12>>2]=R,A[R+8>>2]=R;else{d=A[d>>2]|0;t:do if((A[d+4>>2]&-8|0)!=(y|0)){for(_=y<<((_|0)==31?0:25-(_>>>1)|0);p=d+16+(_>>>31<<2)|0,f=A[p>>2]|0,!!f;)if((A[f+4>>2]&-8|0)==(y|0)){d=f;break t}else _=_<<1,d=f;A[p>>2]=R,A[R+24>>2]=d,A[R+12>>2]=R,A[R+8>>2]=R;break e}while(!1);M=d+8|0,B=A[M>>2]|0,A[B+12>>2]=R,A[M>>2]=R,A[R+8>>2]=B,A[R+12>>2]=d,A[R+24>>2]=0}while(!1);if(B=(A[6989]|0)+-1|0,A[6989]=B,!(B|0)){for(d=28380;d=A[d>>2]|0,d;)d=d+8|0;A[6989]=-1}}}}function Ys(d,f){d=d|0,f=f|0;var p=0;return d?(p=it(f,d)|0,(f|d)>>>0>65535&&(p=((p>>>0)/(d>>>0)|0|0)==(f|0)?p:-1)):p=0,d=Oo(p)|0,!d||!(A[d+-4>>2]&3)||ao(d|0,0,p|0)|0,d|0}function tn(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,p=d+p>>>0,he(f+_+(p>>>0>>0|0)>>>0|0),p|0|0}function Lr(d,f,p,_){return d=d|0,f=f|0,p=p|0,_=_|0,_=f-_-(p>>>0>d>>>0|0)>>>0,he(_|0),d-p>>>0|0|0}function Yc(d){return d=d|0,(d?31-(Qt(d^d-1)|0)|0:32)|0}function Xu(d,f,p,_,y){d=d|0,f=f|0,p=p|0,_=_|0,y=y|0;var w=0,M=0,R=0,B=0,F=0,W=0,oe=0,ve=0,ge=0,_e=0;if(W=d,B=f,F=B,M=p,ve=_,R=ve,!F)return w=(y|0)!=0,R?w?(A[y>>2]=d|0,A[y+4>>2]=f&0,ve=0,y=0,he(ve|0),y|0):(ve=0,y=0,he(ve|0),y|0):(w&&(A[y>>2]=(W>>>0)%(M>>>0),A[y+4>>2]=0),ve=0,y=(W>>>0)/(M>>>0)>>>0,he(ve|0),y|0);w=(R|0)==0;do if(M){if(!w){if(w=(Qt(R|0)|0)-(Qt(F|0)|0)|0,w>>>0<=31){oe=w+1|0,R=31-w|0,f=w-31>>31,M=oe,d=W>>>(oe>>>0)&f|F<>>(oe>>>0)&f,w=0,R=W<>2]=d|0,A[y+4>>2]=B|f&0,ve=0,y=0,he(ve|0),y|0):(ve=0,y=0,he(ve|0),y|0)}if(w=M-1|0,w&M|0){R=(Qt(M|0)|0)+33-(Qt(F|0)|0)|0,_e=64-R|0,oe=32-R|0,B=oe>>31,ge=R-32|0,f=ge>>31,M=R,d=oe-1>>31&F>>>(ge>>>0)|(F<>>(R>>>0))&f,f=f&F>>>(R>>>0),w=W<<_e&B,R=(F<<_e|W>>>(ge>>>0))&B|W<>31;break}return y|0&&(A[y>>2]=w&W,A[y+4>>2]=0),(M|0)==1?(ge=B|f&0,_e=d|0|0,he(ge|0),_e|0):(_e=Yc(M|0)|0,ge=F>>>(_e>>>0)|0,_e=F<<32-_e|W>>>(_e>>>0)|0,he(ge|0),_e|0)}else{if(w)return y|0&&(A[y>>2]=(F>>>0)%(M>>>0),A[y+4>>2]=0),ge=0,_e=(F>>>0)/(M>>>0)>>>0,he(ge|0),_e|0;if(!W)return y|0&&(A[y>>2]=0,A[y+4>>2]=(F>>>0)%(R>>>0)),ge=0,_e=(F>>>0)/(R>>>0)>>>0,he(ge|0),_e|0;if(w=R-1|0,!(w&R))return y|0&&(A[y>>2]=d|0,A[y+4>>2]=w&F|f&0),ge=0,_e=F>>>((Yc(R|0)|0)>>>0),he(ge|0),_e|0;if(w=(Qt(R|0)|0)-(Qt(F|0)|0)|0,w>>>0<=30){f=w+1|0,R=31-w|0,M=f,d=F<>>(f>>>0),f=F>>>(f>>>0),w=0,R=W<>2]=d|0,A[y+4>>2]=B|f&0,ge=0,_e=0,he(ge|0),_e|0):(ge=0,_e=0,he(ge|0),_e|0)}while(!1);if(!M)F=R,B=0,R=0;else{oe=p|0|0,W=ve|_&0,F=tn(oe|0,W|0,-1,-1)|0,p=X()|0,B=R,R=0;do _=B,B=w>>>31|B<<1,w=R|w<<1,_=d<<1|_>>>31|0,ve=d>>>31|f<<1|0,Lr(F|0,p|0,_|0,ve|0)|0,_e=X()|0,ge=_e>>31|((_e|0)<0?-1:0)<<1,R=ge&1,d=Lr(_|0,ve|0,ge&oe|0,(((_e|0)<0?-1:0)>>31|((_e|0)<0?-1:0)<<1)&W|0)|0,f=X()|0,M=M-1|0;while((M|0)!=0);F=B,B=0}return M=0,y|0&&(A[y>>2]=d,A[y+4>>2]=f),ge=(w|0)>>>31|(F|M)<<1|(M<<1|w>>>31)&0|B,_e=(w<<1|0)&-2|R,he(ge|0),_e|0}function Io(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;return F=f>>31|((f|0)<0?-1:0)<<1,B=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,w=_>>31|((_|0)<0?-1:0)<<1,y=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,R=Lr(F^d|0,B^f|0,F|0,B|0)|0,M=X()|0,d=w^F,f=y^B,Lr((Xu(R,M,Lr(w^p|0,y^_|0,w|0,y|0)|0,X()|0,0)|0)^d|0,(X()|0)^f|0,d|0,f|0)|0}function Qc(d,f){d=d|0,f=f|0;var p=0,_=0,y=0,w=0;return w=d&65535,y=f&65535,p=it(y,w)|0,_=d>>>16,d=(p>>>16)+(it(y,_)|0)|0,y=f>>>16,f=it(y,w)|0,he((d>>>16)+(it(y,_)|0)+(((d&65535)+f|0)>>>16)|0),d+f<<16|p&65535|0|0}function ur(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;return y=d,w=p,p=Qc(y,w)|0,d=X()|0,he((it(f,w)|0)+(it(_,y)|0)+d|d&0|0),p|0|0|0}function Kc(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0,M=0,R=0,B=0,F=0;return y=K,K=K+16|0,R=y|0,M=f>>31|((f|0)<0?-1:0)<<1,w=((f|0)<0?-1:0)>>31|((f|0)<0?-1:0)<<1,F=_>>31|((_|0)<0?-1:0)<<1,B=((_|0)<0?-1:0)>>31|((_|0)<0?-1:0)<<1,d=Lr(M^d|0,w^f|0,M|0,w|0)|0,f=X()|0,Xu(d,f,Lr(F^p|0,B^_|0,F|0,B|0)|0,X()|0,R)|0,_=Lr(A[R>>2]^M|0,A[R+4>>2]^w|0,M|0,w|0)|0,p=X()|0,K=y,he(p|0),_|0}function Yu(d,f,p,_){d=d|0,f=f|0,p=p|0,_=_|0;var y=0,w=0;return w=K,K=K+16|0,y=w|0,Xu(d,f,p,_,y)|0,K=w,he(A[y+4>>2]|0),A[y>>2]|0|0}function N1(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f>>p|0),d>>>p|(f&(1<>p-32|0)}function Ct(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f>>>p|0),d>>>p|(f&(1<>>p-32|0)}function Ot(d,f,p){return d=d|0,f=f|0,p=p|0,(p|0)<32?(he(f<>>32-p|0),d<=0?+$n(d+.5):+rt(d-.5)}function Ol(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0;if((p|0)>=8192)return Tn(d|0,f|0,p|0)|0,d|0;if(w=d|0,y=d+p|0,(d&3)==(f&3)){for(;d&3;){if(!p)return w|0;xt[d>>0]=xt[f>>0]|0,d=d+1|0,f=f+1|0,p=p-1|0}for(p=y&-4|0,_=p-64|0;(d|0)<=(_|0);)A[d>>2]=A[f>>2],A[d+4>>2]=A[f+4>>2],A[d+8>>2]=A[f+8>>2],A[d+12>>2]=A[f+12>>2],A[d+16>>2]=A[f+16>>2],A[d+20>>2]=A[f+20>>2],A[d+24>>2]=A[f+24>>2],A[d+28>>2]=A[f+28>>2],A[d+32>>2]=A[f+32>>2],A[d+36>>2]=A[f+36>>2],A[d+40>>2]=A[f+40>>2],A[d+44>>2]=A[f+44>>2],A[d+48>>2]=A[f+48>>2],A[d+52>>2]=A[f+52>>2],A[d+56>>2]=A[f+56>>2],A[d+60>>2]=A[f+60>>2],d=d+64|0,f=f+64|0;for(;(d|0)<(p|0);)A[d>>2]=A[f>>2],d=d+4|0,f=f+4|0}else for(p=y-4|0;(d|0)<(p|0);)xt[d>>0]=xt[f>>0]|0,xt[d+1>>0]=xt[f+1>>0]|0,xt[d+2>>0]=xt[f+2>>0]|0,xt[d+3>>0]=xt[f+3>>0]|0,d=d+4|0,f=f+4|0;for(;(d|0)<(y|0);)xt[d>>0]=xt[f>>0]|0,d=d+1|0,f=f+1|0;return w|0}function ao(d,f,p){d=d|0,f=f|0,p=p|0;var _=0,y=0,w=0,M=0;if(w=d+p|0,f=f&255,(p|0)>=67){for(;d&3;)xt[d>>0]=f,d=d+1|0;for(_=w&-4|0,M=f|f<<8|f<<16|f<<24,y=_-64|0;(d|0)<=(y|0);)A[d>>2]=M,A[d+4>>2]=M,A[d+8>>2]=M,A[d+12>>2]=M,A[d+16>>2]=M,A[d+20>>2]=M,A[d+24>>2]=M,A[d+28>>2]=M,A[d+32>>2]=M,A[d+36>>2]=M,A[d+40>>2]=M,A[d+44>>2]=M,A[d+48>>2]=M,A[d+52>>2]=M,A[d+56>>2]=M,A[d+60>>2]=M,d=d+64|0;for(;(d|0)<(_|0);)A[d>>2]=M,d=d+4|0}for(;(d|0)<(w|0);)xt[d>>0]=f,d=d+1|0;return w-p|0}function cf(d){return d=+d,d>=0?+$n(d+.5):+rt(d-.5)}function ul(d){d=d|0;var f=0,p=0,_=0;return _=sn()|0,p=A[Wn>>2]|0,f=p+d|0,(d|0)>0&(f|0)<(p|0)|(f|0)<0?(xi(f|0)|0,en(12),-1):(f|0)>(_|0)&&!(Rn(f|0)|0)?(en(12),-1):(A[Wn>>2]=f,p|0)}return{___divdi3:Io,___muldi3:ur,___remdi3:Kc,___uremdi3:Yu,_areNeighborCells:px,_bitshift64Ashr:N1,_bitshift64Lshr:Ct,_bitshift64Shl:Ot,_calloc:Ys,_cellAreaKm2:dp,_cellAreaM2:Nd,_cellAreaRads2:Ll,_cellToBoundary:Pl,_cellToCenterChild:Md,_cellToChildPos:cp,_cellToChildren:v1,_cellToChildrenSize:nf,_cellToLatLng:Dl,_cellToLocalIj:M1,_cellToParent:Lu,_cellToVertex:Xs,_cellToVertexes:Hu,_cellsToDirectedEdge:d1,_cellsToLinkedMultiPolygon:cx,_childPosToCell:b1,_compactCells:ap,_constructCell:wx,_destroyLinkedMultiPolygon:Gu,_directedEdgeToBoundary:Sd,_directedEdgeToCells:vx,_edgeLengthKm:Ap,_edgeLengthM:zu,_edgeLengthRads:Rd,_emscripten_replace_memory:hn,_free:vn,_getBaseCellNumber:m1,_getDirectedEdgeDestination:gx,_getDirectedEdgeOrigin:mx,_getHexagonAreaAvgKm2:hp,_getHexagonAreaAvgM2:w1,_getHexagonEdgeLengthAvgKm:fp,_getHexagonEdgeLengthAvgM:ro,_getIcosahedronFaces:Ou,_getIndexDigit:Sx,_getNumCells:ku,_getPentagons:Iu,_getRes0Cells:Yh,_getResolution:Wc,_greatCircleDistanceKm:Xc,_greatCircleDistanceM:Ex,_greatCircleDistanceRads:S1,_gridDisk:ys,_gridDiskDistances:Vr,_gridDistance:qu,_gridPathCells:E1,_gridPathCellsSize:pp,_gridRing:_r,_gridRingUnsafe:Jr,_i64Add:tn,_i64Subtract:Lr,_isPentagon:wi,_isResClassIII:x1,_isValidCell:Td,_isValidDirectedEdge:A1,_isValidIndex:g1,_isValidVertex:al,_latLngToCell:Ed,_llvm_ctlz_i64:of,_llvm_maxnum_f64:lf,_llvm_minnum_f64:uf,_llvm_round_f64:ll,_localIjToCell:Pd,_malloc:Oo,_maxFaceCount:Mx,_maxGridDiskSize:Ps,_maxPolygonToCellsSize:ux,_maxPolygonToCellsSizeExperimental:sf,_memcpy:Ol,_memset:ao,_originToDirectedEdges:_x,_pentagonCount:up,_polygonToCells:i1,_polygonToCellsExperimental:Ud,_readInt64AsDoubleFromPointer:gp,_res0CellCount:r1,_round:cf,_sbrk:ul,_sizeOfCellBoundary:cs,_sizeOfCoordIJ:Na,_sizeOfGeoLoop:er,_sizeOfGeoPolygon:Ai,_sizeOfH3Index:mp,_sizeOfLatLng:C1,_sizeOfLinkedGeoPolygon:Ul,_uncompactCells:_1,_uncompactCellsSize:y1,_vertexToLatLng:sl,establishStackSpace:vr,stackAlloc:Zt,stackRestore:ui,stackSave:gr}})(Jt,In,Q);e.___divdi3=me.___divdi3,e.___muldi3=me.___muldi3,e.___remdi3=me.___remdi3,e.___uremdi3=me.___uremdi3,e._areNeighborCells=me._areNeighborCells,e._bitshift64Ashr=me._bitshift64Ashr,e._bitshift64Lshr=me._bitshift64Lshr,e._bitshift64Shl=me._bitshift64Shl,e._calloc=me._calloc,e._cellAreaKm2=me._cellAreaKm2,e._cellAreaM2=me._cellAreaM2,e._cellAreaRads2=me._cellAreaRads2,e._cellToBoundary=me._cellToBoundary,e._cellToCenterChild=me._cellToCenterChild,e._cellToChildPos=me._cellToChildPos,e._cellToChildren=me._cellToChildren,e._cellToChildrenSize=me._cellToChildrenSize,e._cellToLatLng=me._cellToLatLng,e._cellToLocalIj=me._cellToLocalIj,e._cellToParent=me._cellToParent,e._cellToVertex=me._cellToVertex,e._cellToVertexes=me._cellToVertexes,e._cellsToDirectedEdge=me._cellsToDirectedEdge,e._cellsToLinkedMultiPolygon=me._cellsToLinkedMultiPolygon,e._childPosToCell=me._childPosToCell,e._compactCells=me._compactCells,e._constructCell=me._constructCell,e._destroyLinkedMultiPolygon=me._destroyLinkedMultiPolygon,e._directedEdgeToBoundary=me._directedEdgeToBoundary,e._directedEdgeToCells=me._directedEdgeToCells,e._edgeLengthKm=me._edgeLengthKm,e._edgeLengthM=me._edgeLengthM,e._edgeLengthRads=me._edgeLengthRads;var Bt=e._emscripten_replace_memory=me._emscripten_replace_memory;e._free=me._free,e._getBaseCellNumber=me._getBaseCellNumber,e._getDirectedEdgeDestination=me._getDirectedEdgeDestination,e._getDirectedEdgeOrigin=me._getDirectedEdgeOrigin,e._getHexagonAreaAvgKm2=me._getHexagonAreaAvgKm2,e._getHexagonAreaAvgM2=me._getHexagonAreaAvgM2,e._getHexagonEdgeLengthAvgKm=me._getHexagonEdgeLengthAvgKm,e._getHexagonEdgeLengthAvgM=me._getHexagonEdgeLengthAvgM,e._getIcosahedronFaces=me._getIcosahedronFaces,e._getIndexDigit=me._getIndexDigit,e._getNumCells=me._getNumCells,e._getPentagons=me._getPentagons,e._getRes0Cells=me._getRes0Cells,e._getResolution=me._getResolution,e._greatCircleDistanceKm=me._greatCircleDistanceKm,e._greatCircleDistanceM=me._greatCircleDistanceM,e._greatCircleDistanceRads=me._greatCircleDistanceRads,e._gridDisk=me._gridDisk,e._gridDiskDistances=me._gridDiskDistances,e._gridDistance=me._gridDistance,e._gridPathCells=me._gridPathCells,e._gridPathCellsSize=me._gridPathCellsSize,e._gridRing=me._gridRing,e._gridRingUnsafe=me._gridRingUnsafe,e._i64Add=me._i64Add,e._i64Subtract=me._i64Subtract,e._isPentagon=me._isPentagon,e._isResClassIII=me._isResClassIII,e._isValidCell=me._isValidCell,e._isValidDirectedEdge=me._isValidDirectedEdge,e._isValidIndex=me._isValidIndex,e._isValidVertex=me._isValidVertex,e._latLngToCell=me._latLngToCell,e._llvm_ctlz_i64=me._llvm_ctlz_i64,e._llvm_maxnum_f64=me._llvm_maxnum_f64,e._llvm_minnum_f64=me._llvm_minnum_f64,e._llvm_round_f64=me._llvm_round_f64,e._localIjToCell=me._localIjToCell,e._malloc=me._malloc,e._maxFaceCount=me._maxFaceCount,e._maxGridDiskSize=me._maxGridDiskSize,e._maxPolygonToCellsSize=me._maxPolygonToCellsSize,e._maxPolygonToCellsSizeExperimental=me._maxPolygonToCellsSizeExperimental,e._memcpy=me._memcpy,e._memset=me._memset,e._originToDirectedEdges=me._originToDirectedEdges,e._pentagonCount=me._pentagonCount,e._polygonToCells=me._polygonToCells,e._polygonToCellsExperimental=me._polygonToCellsExperimental,e._readInt64AsDoubleFromPointer=me._readInt64AsDoubleFromPointer,e._res0CellCount=me._res0CellCount,e._round=me._round,e._sbrk=me._sbrk,e._sizeOfCellBoundary=me._sizeOfCellBoundary,e._sizeOfCoordIJ=me._sizeOfCoordIJ,e._sizeOfGeoLoop=me._sizeOfGeoLoop,e._sizeOfGeoPolygon=me._sizeOfGeoPolygon,e._sizeOfH3Index=me._sizeOfH3Index,e._sizeOfLatLng=me._sizeOfLatLng,e._sizeOfLinkedGeoPolygon=me._sizeOfLinkedGeoPolygon,e._uncompactCells=me._uncompactCells,e._uncompactCellsSize=me._uncompactCellsSize,e._vertexToLatLng=me._vertexToLatLng,e.establishStackSpace=me.establishStackSpace;var ot=e.stackAlloc=me.stackAlloc,Tt=e.stackRestore=me.stackRestore,Wt=e.stackSave=me.stackSave;if(e.asm=me,e.cwrap=U,e.setValue=S,e.getValue=T,Ae){xe(Ae)||(Ae=s(Ae));{Ht();var Yt=function(Je){Je.byteLength&&(Je=new Uint8Array(Je)),ie.set(Je,x),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,pt()},pn=function(){a(Ae,Yt,function(){throw"could not load memory initializer "+Ae})},$e=jt(Ae);if($e)Yt($e.buffer);else if(e.memoryInitializerRequest){var St=function(){var Je=e.memoryInitializerRequest,dt=Je.response;if(Je.status!==200&&Je.status!==0){var Vt=jt(e.memoryInitializerRequestURL);if(Vt)dt=Vt.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+Je.status+", retrying "+Ae),pn();return}}Yt(dt)};e.memoryInitializerRequest.response?setTimeout(St,0):e.memoryInitializerRequest.addEventListener("load",St)}else pn()}}var Kt;yt=function Je(){Kt||wn(),Kt||(yt=Je)};function wn(Je){if(Gt>0||(je(),Gt>0))return;function dt(){Kt||(Kt=!0,!N&&(Rt(),Et(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Ft()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),dt()},1)):dt()}e.run=wn;function qn(Je){throw e.onAbort&&e.onAbort(Je),Je+="",l(Je),u(Je),N=!0,"abort("+Je+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=qn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return wn(),i})(typeof _i=="object"?_i:{}),Un="number",Pn=Un,xA=Un,zn=Un,Gn=Un,Es=Un,ln=Un,iZ=[["sizeOfH3Index",Un],["sizeOfLatLng",Un],["sizeOfCellBoundary",Un],["sizeOfGeoLoop",Un],["sizeOfGeoPolygon",Un],["sizeOfLinkedGeoPolygon",Un],["sizeOfCoordIJ",Un],["readInt64AsDoubleFromPointer",Un],["isValidCell",xA,[zn,Gn]],["isValidIndex",xA,[zn,Gn]],["latLngToCell",Pn,[Un,Un,Es,ln]],["cellToLatLng",Pn,[zn,Gn,ln]],["cellToBoundary",Pn,[zn,Gn,ln]],["maxGridDiskSize",Pn,[Un,ln]],["gridDisk",Pn,[zn,Gn,Un,ln]],["gridDiskDistances",Pn,[zn,Gn,Un,ln,ln]],["gridRing",Pn,[zn,Gn,Un,ln]],["gridRingUnsafe",Pn,[zn,Gn,Un,ln]],["maxPolygonToCellsSize",Pn,[ln,Es,Un,ln]],["polygonToCells",Pn,[ln,Es,Un,ln]],["maxPolygonToCellsSizeExperimental",Pn,[ln,Es,Un,ln]],["polygonToCellsExperimental",Pn,[ln,Es,Un,Un,Un,ln]],["cellsToLinkedMultiPolygon",Pn,[ln,Un,ln]],["destroyLinkedMultiPolygon",null,[ln]],["compactCells",Pn,[ln,ln,Un,Un]],["uncompactCells",Pn,[ln,Un,Un,ln,Un,Es]],["uncompactCellsSize",Pn,[ln,Un,Un,Es,ln]],["isPentagon",xA,[zn,Gn]],["isResClassIII",xA,[zn,Gn]],["getBaseCellNumber",Un,[zn,Gn]],["getResolution",Un,[zn,Gn]],["getIndexDigit",Un,[zn,Gn,Un]],["constructCell",Pn,[Un,Un,ln,ln]],["maxFaceCount",Pn,[zn,Gn,ln]],["getIcosahedronFaces",Pn,[zn,Gn,ln]],["cellToParent",Pn,[zn,Gn,Es,ln]],["cellToChildren",Pn,[zn,Gn,Es,ln]],["cellToCenterChild",Pn,[zn,Gn,Es,ln]],["cellToChildrenSize",Pn,[zn,Gn,Es,ln]],["cellToChildPos",Pn,[zn,Gn,Es,ln]],["childPosToCell",Pn,[Un,Un,zn,Gn,Es,ln]],["areNeighborCells",Pn,[zn,Gn,zn,Gn,ln]],["cellsToDirectedEdge",Pn,[zn,Gn,zn,Gn,ln]],["getDirectedEdgeOrigin",Pn,[zn,Gn,ln]],["getDirectedEdgeDestination",Pn,[zn,Gn,ln]],["isValidDirectedEdge",xA,[zn,Gn]],["directedEdgeToCells",Pn,[zn,Gn,ln]],["originToDirectedEdges",Pn,[zn,Gn,ln]],["directedEdgeToBoundary",Pn,[zn,Gn,ln]],["gridDistance",Pn,[zn,Gn,zn,Gn,ln]],["gridPathCells",Pn,[zn,Gn,zn,Gn,ln]],["gridPathCellsSize",Pn,[zn,Gn,zn,Gn,ln]],["cellToLocalIj",Pn,[zn,Gn,zn,Gn,Un,ln]],["localIjToCell",Pn,[zn,Gn,ln,Un,ln]],["getHexagonAreaAvgM2",Pn,[Es,ln]],["getHexagonAreaAvgKm2",Pn,[Es,ln]],["getHexagonEdgeLengthAvgM",Pn,[Es,ln]],["getHexagonEdgeLengthAvgKm",Pn,[Es,ln]],["greatCircleDistanceM",Un,[ln,ln]],["greatCircleDistanceKm",Un,[ln,ln]],["greatCircleDistanceRads",Un,[ln,ln]],["cellAreaM2",Pn,[zn,Gn,ln]],["cellAreaKm2",Pn,[zn,Gn,ln]],["cellAreaRads2",Pn,[zn,Gn,ln]],["edgeLengthM",Pn,[zn,Gn,ln]],["edgeLengthKm",Pn,[zn,Gn,ln]],["edgeLengthRads",Pn,[zn,Gn,ln]],["getNumCells",Pn,[Es,ln]],["getRes0Cells",Pn,[ln]],["res0CellCount",Un],["getPentagons",Pn,[Un,ln]],["pentagonCount",Un],["cellToVertex",Pn,[zn,Gn,Un,ln]],["cellToVertexes",Pn,[zn,Gn,ln]],["vertexToLatLng",Pn,[zn,Gn,ln]],["isValidVertex",xA,[zn,Gn]]],rZ=0,sZ=1,aZ=2,oZ=3,wP=4,lZ=5,uZ=6,cZ=7,hZ=8,fZ=9,dZ=10,AZ=11,pZ=12,mZ=13,gZ=14,vZ=15,_Z=16,yZ=17,xZ=18,bZ=19,Kr={};Kr[rZ]="Success";Kr[sZ]="The operation failed but a more specific error is not available";Kr[aZ]="Argument was outside of acceptable range";Kr[oZ]="Latitude or longitude arguments were outside of acceptable range";Kr[wP]="Resolution argument was outside of acceptable range";Kr[lZ]="Cell argument was not valid";Kr[uZ]="Directed edge argument was not valid";Kr[cZ]="Undirected edge argument was not valid";Kr[hZ]="Vertex argument was not valid";Kr[fZ]="Pentagon distortion was encountered";Kr[dZ]="Duplicate input";Kr[AZ]="Cell arguments were not neighbors";Kr[pZ]="Cell arguments had incompatible resolutions";Kr[mZ]="Memory allocation failed";Kr[gZ]="Bounds of provided memory were insufficient";Kr[vZ]="Mode or flags argument was not valid";Kr[_Z]="Index argument was not valid";Kr[yZ]="Base cell number was outside of acceptable range";Kr[xZ]="Child indexing digits invalid";Kr[bZ]="Child indexing digits refer to a deleted subsequence";var SZ=1e3,TP=1001,MP=1002,Ey={};Ey[SZ]="Unknown unit";Ey[TP]="Array length out of bounds";Ey[MP]="Got unexpected null value for H3 index";var wZ="Unknown error";function EP(i,e,t){var n=t&&"value"in t,r=new Error((i[e]||wZ)+" (code: "+e+(n?", value: "+t.value:"")+")");return r.code=e,r}function CP(i,e){var t=arguments.length===2?{value:e}:{};return EP(Kr,i,t)}function NP(i,e){var t=arguments.length===2?{value:e}:{};return EP(Ey,i,t)}function mg(i){if(i!==0)throw CP(i)}var Ka={};iZ.forEach(function(e){Ka[e[0]]=_i.cwrap.apply(_i,e)});var VA=16,gg=4,N0=8,TZ=8,V_=Ka.sizeOfH3Index(),NM=Ka.sizeOfLatLng(),MZ=Ka.sizeOfCellBoundary(),EZ=Ka.sizeOfGeoPolygon(),Dm=Ka.sizeOfGeoLoop();Ka.sizeOfLinkedGeoPolygon();Ka.sizeOfCoordIJ();function CZ(i){if(typeof i!="number"||i<0||i>15||Math.floor(i)!==i)throw CP(wP,i);return i}function NZ(i){if(!i)throw NP(MP);return i}var RZ=Math.pow(2,32)-1;function DZ(i){if(i>RZ)throw NP(TP,i);return i}var PZ=/[^0-9a-fA-F]/;function RP(i){if(Array.isArray(i)&&i.length===2&&Number.isInteger(i[0])&&Number.isInteger(i[1]))return i;if(typeof i!="string"||PZ.test(i))return[0,0];var e=parseInt(i.substring(0,i.length-8),VA),t=parseInt(i.substring(i.length-8),VA);return[t,e]}function RR(i){if(i>=0)return i.toString(VA);i=i&2147483647;var e=DP(8,i.toString(VA)),t=(parseInt(e[0],VA)+8).toString(VA);return e=t+e.substring(1),e}function LZ(i,e){return RR(e)+DP(8,RR(i))}function DP(i,e){for(var t=i-e.length,n="",r=0;r0){l=_i._calloc(t,Dm);for(var u=0;u0){for(var a=_i.getValue(i+n,"i32"),l=0;l0){const{width:a,height:l}=e.context;t.bufferWidth=a,t.bufferHeight=l}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){const{object:t,material:n,geometry:r}=e,s=this.getRenderObjectData(e);if(s.worldMatrix.equals(t.matrixWorld)!==!0)return s.worldMatrix.copy(t.matrixWorld),!1;const a=s.material;for(const N in a){const C=a[N],E=n[N];if(C.equals!==void 0){if(C.equals(E)===!1)return C.copy(E),!1}else if(E.isTexture===!0){if(C.id!==E.id||C.version!==E.version)return C.id=E.id,C.version=E.version,!1}else if(C!==E)return a[N]=E,!1}if(a.transmission>0){const{width:N,height:C}=e.context;if(s.bufferWidth!==N||s.bufferHeight!==C)return s.bufferWidth=N,s.bufferHeight=C,!1}const l=s.geometry,u=r.attributes,h=l.attributes,m=Object.keys(h),v=Object.keys(u);if(m.length!==v.length)return s.geometry.attributes=this.getAttributesData(u),!1;for(const N of m){const C=h[N],E=u[N];if(E===void 0)return delete h[N],!1;if(C.version!==E.version)return C.version=E.version,!1}const x=r.index,S=l.indexVersion,T=x?x.version:null;if(S!==T)return l.indexVersion=T,!1;if(l.drawRange.start!==r.drawRange.start||l.drawRange.count!==r.drawRange.count)return l.drawRange.start=r.drawRange.start,l.drawRange.count=r.drawRange.count,!1;if(s.morphTargetInfluences){let N=!1;for(let C=0;C>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const OP=i=>vg(i),Cy=i=>vg(i),RM=(...i)=>vg(i);function IP(i,e=!1){const t=[];i.isNode===!0&&(t.push(i.id),i=i.getSelf());for(const{property:n,childNode:r}of H_(i))t.push(t,vg(n.slice(0,-4)),r.getCacheKey(e));return vg(t)}function*H_(i,e=!1){for(const t in i){if(t.startsWith("_")===!0)continue;const n=i[t];if(Array.isArray(n)===!0)for(let r=0;re.charCodeAt(0)).buffer}const zw={VERTEX:"vertex",FRAGMENT:"fragment"},Qn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},$Z={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ia={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},HP=["fragment","vertex"],Gw=["setup","analyze","generate"],qw=[...HP,"compute"],fd=["x","y","z","w"];let XZ=0;class Nn extends Bc{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Qn.NONE,this.updateBeforeType=Qn.NONE,this.updateAfterType=Qn.NONE,this.uuid=x0.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:XZ++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Qn.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Qn.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Qn.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of H_(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=RM(IP(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e){if(e.increaseUsage(this)===1){const n=e.getNodeProperties(this);for(const r of Object.values(n))r&&r.isNode===!0&&r.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){a.initialized=!0;const l=this.setup(e),u=l&&l.isNode===!0;for(const h of Object.values(a))h&&h.isNode===!0&&h.build(e);u&&l.build(e),a.outputNode=l}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const l=this.getNodeType(e),u=e.getDataFromNode(this);r=u.snippet,r===void 0?(r=this.generate(e)||"",u.snippet=r):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,l,t)}else r=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return H_(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(s)?[]:{}),n[r][s]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const s of e.inputNodes[n])r.push(t[s]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const s in e.inputNodes[n]){const a=e.inputNodes[n][s];r[s]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}if(r){const l=a(e.textures),u=a(e.images),h=a(e.nodes);l.length>0&&(s.textures=l),u.length>0&&(s.images=u),h.length>0&&(s.nodes=h)}return s}}class dd extends Nn{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),n=this.indexNode.build(e,"uint");return`${t}[ ${n} ]`}}class WP extends Nn{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),s=n.build(e,r);return e.format(s,r,t)}}class Zr extends Nn{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),l=e.getVarFromNode(this,null,r),u=e.getPropertyName(l);return e.addLineFlowCode(`${u} = ${a}`,this),s.snippet=a,s.propertyName=u,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class YZ extends Zr{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=this.nodes,s=e.getComponentType(n),a=[];for(const u of r){let h=u.build(e);const m=e.getComponentType(u.getNodeType(e));m!==s&&(h=e.format(h,m,s)),a.push(h)}const l=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(l,n,t)}}const QZ=fd.join("");class Vw extends Nn{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(fd.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===QZ.slice(0,this.components.length)?s=e.format(u,a,t):s=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class KZ extends Zr{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,s=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),l=e.getTypeFromLength(n.length,a),u=r.build(e,l),h=t.build(e,s),m=e.getTypeLength(s),v=[];for(let x=0;xi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),UR=i=>$P(i).split("").sort().join(""),XP={setup(i,e){const t=e.shift();return i(Gg(t),...e)},get(i,e,t){if(typeof e=="string"&&i[e]===void 0){if(i.isStackNode!==!0&&e==="assign")return(...n)=>(R0.assign(t,...n),t);if(jA.has(e)){const n=jA.get(e);return i.isStackNode?(...r)=>t.add(n(...r)):(...r)=>n(t,...r)}else{if(e==="self")return i;if(e.endsWith("Assign")&&jA.has(e.slice(0,e.length-6))){const n=jA.get(e.slice(0,e.length-6));return i.isStackNode?(...r)=>t.assign(r[0],n(...r)):(...r)=>t.assign(n(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=$P(e),wt(new Vw(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=UR(e.slice(3).toLowerCase()),n=>wt(new KZ(i,e,n));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=UR(e.slice(4).toLowerCase()),()=>wt(new ZZ(wt(i),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),wt(new Vw(i,e));if(/^\d+$/.test(e)===!0)return wt(new dd(t,new Rl(Number(e),"uint")))}}}return Reflect.get(i,e,t)},set(i,e,t,n){return typeof e=="string"&&i[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(i,e,t,n)}},$3=new WeakMap,BR=new WeakMap,JZ=function(i,e=null){const t=Rh(i);if(t==="node"){let n=$3.get(i);return n===void 0&&(n=new Proxy(i,XP),$3.set(i,n),$3.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return wt(jw(i,e));if(t==="shader")return Ke(i)}return i},eJ=function(i,e=null){for(const t in i)i[t]=wt(i[t],e);return i},tJ=function(i,e=null){const t=i.length;for(let n=0;nwt(n!==null?Object.assign(s,n):s);return e===null?(...s)=>r(new i(...Qf(s))):t!==null?(t=wt(t),(...s)=>r(new i(e,...Qf(s),t))):(...s)=>r(new i(e,...Qf(s)))},iJ=function(i,...e){return wt(new i(...Qf(e)))};class rJ extends Nn{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=BR.get(e.constructor);a===void 0&&(a=new WeakMap,BR.set(e.constructor,a));let l=a.get(t);l===void 0&&(l=wt(e.buildFunctionNode(t)),a.set(t,l)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(l),s=wt(l.call(n))}else{const a=t.jsFunc,l=n!==null?a(n,e):a(e);s=wt(l)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class sJ extends Nn{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Gg(e),wt(new rJ(this,e))}setup(){return this.call()}}const aJ=[!1,!0],oJ=[0,1,2,3],lJ=[-1,-2],YP=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],PM=new Map;for(const i of aJ)PM.set(i,new Rl(i));const LM=new Map;for(const i of oJ)LM.set(i,new Rl(i,"uint"));const UM=new Map([...LM].map(i=>new Rl(i.value,"int")));for(const i of lJ)UM.set(i,new Rl(i,"int"));const Ny=new Map([...UM].map(i=>new Rl(i.value)));for(const i of YP)Ny.set(i,new Rl(i));for(const i of YP)Ny.set(-i,new Rl(-i));const Ry={bool:PM,uint:LM,ints:UM,float:Ny},OR=new Map([...PM,...Ny]),jw=(i,e)=>OR.has(i)?OR.get(i):i.isNode===!0?i:new Rl(i,e),uJ=i=>{try{return i.getNodeType()}catch{return}},ls=function(i,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>typeof r!="object"))&&(t=[GP(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return wt(e.get(t[0]));if(t.length===1){const r=jw(t[0],i);return uJ(r)===i?wt(r):wt(new WP(r,i))}const n=t.map(r=>jw(r));return wt(new YZ(n,i))}},_g=i=>typeof i=="object"&&i!==null?i.value:i,QP=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Pm(i,e){return new Proxy(new sJ(i,e),XP)}const wt=(i,e=null)=>JZ(i,e),Gg=(i,e=null)=>new eJ(i,e),Qf=(i,e=null)=>new tJ(i,e),gt=(...i)=>new nJ(...i),$t=(...i)=>new iJ(...i),Ke=(i,e)=>{const t=new Pm(i,e),n=(...r)=>{let s;return Gg(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return n.shaderNode=t,n.setLayout=r=>(t.setLayout(r),n),n.once=()=>(t.once=!0,n),n},cJ=(...i)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),Ke(...i));mt("toGlobal",i=>(i.global=!0,i));const yg=i=>{R0=i},BM=()=>R0,ii=(...i)=>R0.If(...i);function KP(i){return R0&&R0.add(i),i}mt("append",KP);const ZP=new ls("color"),xe=new ls("float",Ry.float),Ee=new ls("int",Ry.ints),rn=new ls("uint",Ry.uint),Pc=new ls("bool",Ry.bool),Lt=new ls("vec2"),As=new ls("ivec2"),JP=new ls("uvec2"),eL=new ls("bvec2"),Ie=new ls("vec3"),tL=new ls("ivec3"),j0=new ls("uvec3"),OM=new ls("bvec3"),_n=new ls("vec4"),nL=new ls("ivec4"),iL=new ls("uvec4"),rL=new ls("bvec4"),Dy=new ls("mat2"),ua=new ls("mat3"),Kf=new ls("mat4"),hJ=(i="")=>wt(new Rl(i,"string")),fJ=i=>wt(new Rl(i,"ArrayBuffer"));mt("toColor",ZP);mt("toFloat",xe);mt("toInt",Ee);mt("toUint",rn);mt("toBool",Pc);mt("toVec2",Lt);mt("toIVec2",As);mt("toUVec2",JP);mt("toBVec2",eL);mt("toVec3",Ie);mt("toIVec3",tL);mt("toUVec3",j0);mt("toBVec3",OM);mt("toVec4",_n);mt("toIVec4",nL);mt("toUVec4",iL);mt("toBVec4",rL);mt("toMat2",Dy);mt("toMat3",ua);mt("toMat4",Kf);const sL=gt(dd),aL=(i,e)=>wt(new WP(wt(i),e)),dJ=(i,e)=>wt(new Vw(wt(i),e));mt("element",sL);mt("convert",aL);class oL extends Nn{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const lL=i=>new oL(i),IM=(i,e=0)=>new oL(i,!0,e),uL=IM("frame"),Ln=IM("render"),FM=lL("object");class qg extends DM{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=FM}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(r=>{const s=e(r,n);s!==void 0&&(this.value=s)},t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),l=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(l);return e.context.label!==void 0&&delete e.context.label,e.format(u,n,t)}}const yn=(i,e)=>{const t=QP(e||i),n=i&&i.isNode===!0?i.node&&i.node.value||i.value:i;return wt(new qg(n,t))};class Ii extends Nn{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const cL=(i,e)=>wt(new Ii(i,e)),xg=(i,e)=>wt(new Ii(i,e,!0)),Ri=$t(Ii,"vec4","DiffuseColor"),Hw=$t(Ii,"vec3","EmissiveColor"),$l=$t(Ii,"float","Roughness"),bg=$t(Ii,"float","Metalness"),W_=$t(Ii,"float","Clearcoat"),Sg=$t(Ii,"float","ClearcoatRoughness"),Vf=$t(Ii,"vec3","Sheen"),Py=$t(Ii,"float","SheenRoughness"),Ly=$t(Ii,"float","Iridescence"),kM=$t(Ii,"float","IridescenceIOR"),zM=$t(Ii,"float","IridescenceThickness"),$_=$t(Ii,"float","AlphaT"),Th=$t(Ii,"float","Anisotropy"),Lm=$t(Ii,"vec3","AnisotropyT"),Zf=$t(Ii,"vec3","AnisotropyB"),Oa=$t(Ii,"color","SpecularColor"),wg=$t(Ii,"float","SpecularF90"),X_=$t(Ii,"float","Shininess"),Tg=$t(Ii,"vec4","Output"),Xv=$t(Ii,"float","dashSize"),Ww=$t(Ii,"float","gapSize"),AJ=$t(Ii,"float","pointWidth"),Um=$t(Ii,"float","IOR"),Y_=$t(Ii,"float","Transmission"),GM=$t(Ii,"float","Thickness"),qM=$t(Ii,"float","AttenuationDistance"),VM=$t(Ii,"color","AttenuationColor"),jM=$t(Ii,"float","Dispersion");class pJ extends Zr{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return fd.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:r}=this,s=this.needsSplitAssign(e),a=n.getNodeType(e),l=n.context({assign:!0}).build(e),u=r.build(e,a),h=r.getNodeType(e),m=e.getDataFromNode(this);let v;if(m.initialized===!0)t!=="void"&&(v=l);else if(s){const x=e.getVarFromNode(this,null,a),S=e.getPropertyName(x);e.addLineFlowCode(`${S} = ${u}`,this);const T=n.node.context({assign:!0}).build(e);for(let N=0;N{const m=h.type,v=m==="pointer";let x;return v?x="&"+u.build(e):x=u.build(e,m),x};if(Array.isArray(s))for(let u=0;u(e=e.length>1||e[0]&&e[0].isNode===!0?Qf(e):Gg(e[0]),wt(new mJ(wt(i),e)));mt("call",fL);class Tr extends Zr{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let s=new Tr(e,t,n);for(let a=0;a>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="=="||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="<"||n===">"||n==="<="||n===">="){const u=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(l));return u>1?`bvec${u}`:"bool"}else return a==="float"&&e.isMatrix(l)?l:e.isMatrix(a)&&e.isVector(l)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(l)?e.getVectorFromMatrix(l):e.getTypeLength(l)>e.getTypeLength(a)?l:a}generate(e,t){const n=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let l=null,u=null;a!=="void"?(l=r.getNodeType(e),u=typeof s<"u"?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="?e.isVector(l)?u=l:l!==u&&(l=u="float"):n===">>"||n==="<<"?(l=a,u=e.changeComponentType(u,"uint")):e.isMatrix(l)&&e.isVector(u)?u=e.getVectorFromMatrix(l):e.isVector(l)&&e.isMatrix(u)?l=e.getVectorFromMatrix(u):l=u=a):l=u=a;const h=r.build(e,l),m=typeof s<"u"?s.build(e,u):null,v=e.getTypeLength(t),x=e.getFunctionOperator(n);if(t!=="void")return n==="<"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} < ${m} )`,a,t):n==="<="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} <= ${m} )`,a,t):n===">"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} > ${m} )`,a,t):n===">="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} >= ${m} )`,a,t):n==="!"||n==="~"?e.format(`(${n}${h})`,l,t):x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`( ${h} ${n} ${m} )`,a,t);if(l!=="void")return x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`${h} ${n} ${m}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Qr=gt(Tr,"+"),yi=gt(Tr,"-"),Kn=gt(Tr,"*"),Cl=gt(Tr,"/"),HM=gt(Tr,"%"),dL=gt(Tr,"=="),AL=gt(Tr,"!="),pL=gt(Tr,"<"),WM=gt(Tr,">"),mL=gt(Tr,"<="),gL=gt(Tr,">="),vL=gt(Tr,"&&"),_L=gt(Tr,"||"),yL=gt(Tr,"!"),xL=gt(Tr,"^^"),bL=gt(Tr,"&"),SL=gt(Tr,"~"),wL=gt(Tr,"|"),TL=gt(Tr,"^"),ML=gt(Tr,"<<"),EL=gt(Tr,">>");mt("add",Qr);mt("sub",yi);mt("mul",Kn);mt("div",Cl);mt("modInt",HM);mt("equal",dL);mt("notEqual",AL);mt("lessThan",pL);mt("greaterThan",WM);mt("lessThanEqual",mL);mt("greaterThanEqual",gL);mt("and",vL);mt("or",_L);mt("not",yL);mt("xor",xL);mt("bitAnd",bL);mt("bitNot",SL);mt("bitOr",wL);mt("bitXor",TL);mt("shiftLeft",ML);mt("shiftRight",EL);const CL=(...i)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),HM(...i));mt("remainder",CL);class Qe extends Zr{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),l=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>l?t:a>l?n:l>s?r:t}getNodeType(e){const t=this.method;return t===Qe.LENGTH||t===Qe.DISTANCE||t===Qe.DOT?"float":t===Qe.CROSS?"vec3":t===Qe.ALL?"bool":t===Qe.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===Qe.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){let n=this.method;const r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,l=this.bNode,u=this.cNode,h=e.renderer.coordinateSystem;if(n===Qe.TRANSFORM_DIRECTION){let m=a,v=l;e.isMatrix(m.getNodeType(e))?v=_n(Ie(v),0):m=_n(Ie(m),0);const x=Kn(m,v).xyz;return Lc(x).build(e,t)}else{if(n===Qe.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(n===Qe.ONE_MINUS)return yi(1,a).build(e,t);if(n===Qe.RECIPROCAL)return Cl(1,a).build(e,t);if(n===Qe.DIFFERENCE)return rr(yi(a,l)).build(e,t);{const m=[];return n===Qe.CROSS||n===Qe.MOD?m.push(a.build(e,r),l.build(e,r)):h===Ga&&n===Qe.STEP?m.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),l.build(e,s)):h===Ga&&(n===Qe.MIN||n===Qe.MAX)||n===Qe.MOD?m.push(a.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):n===Qe.REFRACT?m.push(a.build(e,s),l.build(e,s),u.build(e,"float")):n===Qe.MIX?m.push(a.build(e,s),l.build(e,s),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":s)):(h===cu&&n===Qe.ATAN&&l!==null&&(n="atan2"),m.push(a.build(e,s)),l!==null&&m.push(l.build(e,s)),u!==null&&m.push(u.build(e,s))),e.format(`${e.getMethod(n,r)}( ${m.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Qe.ALL="all";Qe.ANY="any";Qe.RADIANS="radians";Qe.DEGREES="degrees";Qe.EXP="exp";Qe.EXP2="exp2";Qe.LOG="log";Qe.LOG2="log2";Qe.SQRT="sqrt";Qe.INVERSE_SQRT="inversesqrt";Qe.FLOOR="floor";Qe.CEIL="ceil";Qe.NORMALIZE="normalize";Qe.FRACT="fract";Qe.SIN="sin";Qe.COS="cos";Qe.TAN="tan";Qe.ASIN="asin";Qe.ACOS="acos";Qe.ATAN="atan";Qe.ABS="abs";Qe.SIGN="sign";Qe.LENGTH="length";Qe.NEGATE="negate";Qe.ONE_MINUS="oneMinus";Qe.DFDX="dFdx";Qe.DFDY="dFdy";Qe.ROUND="round";Qe.RECIPROCAL="reciprocal";Qe.TRUNC="trunc";Qe.FWIDTH="fwidth";Qe.TRANSPOSE="transpose";Qe.BITCAST="bitcast";Qe.EQUALS="equals";Qe.MIN="min";Qe.MAX="max";Qe.MOD="mod";Qe.STEP="step";Qe.REFLECT="reflect";Qe.DISTANCE="distance";Qe.DIFFERENCE="difference";Qe.DOT="dot";Qe.CROSS="cross";Qe.POW="pow";Qe.TRANSFORM_DIRECTION="transformDirection";Qe.MIX="mix";Qe.CLAMP="clamp";Qe.REFRACT="refract";Qe.SMOOTHSTEP="smoothstep";Qe.FACEFORWARD="faceforward";const NL=xe(1e-6),gJ=xe(1e6),Q_=xe(Math.PI),vJ=xe(Math.PI*2),$M=gt(Qe,Qe.ALL),RL=gt(Qe,Qe.ANY),DL=gt(Qe,Qe.RADIANS),PL=gt(Qe,Qe.DEGREES),XM=gt(Qe,Qe.EXP),D0=gt(Qe,Qe.EXP2),Uy=gt(Qe,Qe.LOG),su=gt(Qe,Qe.LOG2),Su=gt(Qe,Qe.SQRT),YM=gt(Qe,Qe.INVERSE_SQRT),au=gt(Qe,Qe.FLOOR),By=gt(Qe,Qe.CEIL),Lc=gt(Qe,Qe.NORMALIZE),kc=gt(Qe,Qe.FRACT),So=gt(Qe,Qe.SIN),pc=gt(Qe,Qe.COS),LL=gt(Qe,Qe.TAN),UL=gt(Qe,Qe.ASIN),BL=gt(Qe,Qe.ACOS),QM=gt(Qe,Qe.ATAN),rr=gt(Qe,Qe.ABS),Mg=gt(Qe,Qe.SIGN),wc=gt(Qe,Qe.LENGTH),OL=gt(Qe,Qe.NEGATE),IL=gt(Qe,Qe.ONE_MINUS),KM=gt(Qe,Qe.DFDX),ZM=gt(Qe,Qe.DFDY),FL=gt(Qe,Qe.ROUND),kL=gt(Qe,Qe.RECIPROCAL),JM=gt(Qe,Qe.TRUNC),zL=gt(Qe,Qe.FWIDTH),GL=gt(Qe,Qe.TRANSPOSE),_J=gt(Qe,Qe.BITCAST),qL=gt(Qe,Qe.EQUALS),Za=gt(Qe,Qe.MIN),Gr=gt(Qe,Qe.MAX),eE=gt(Qe,Qe.MOD),Oy=gt(Qe,Qe.STEP),VL=gt(Qe,Qe.REFLECT),jL=gt(Qe,Qe.DISTANCE),HL=gt(Qe,Qe.DIFFERENCE),jh=gt(Qe,Qe.DOT),Iy=gt(Qe,Qe.CROSS),Tl=gt(Qe,Qe.POW),tE=gt(Qe,Qe.POW,2),WL=gt(Qe,Qe.POW,3),$L=gt(Qe,Qe.POW,4),XL=gt(Qe,Qe.TRANSFORM_DIRECTION),YL=i=>Kn(Mg(i),Tl(rr(i),1/3)),QL=i=>jh(i,i),Ui=gt(Qe,Qe.MIX),du=(i,e=0,t=1)=>wt(new Qe(Qe.CLAMP,wt(i),wt(e),wt(t))),KL=i=>du(i),nE=gt(Qe,Qe.REFRACT),Uc=gt(Qe,Qe.SMOOTHSTEP),iE=gt(Qe,Qe.FACEFORWARD),ZL=Ke(([i])=>{const n=43758.5453,r=jh(i.xy,Lt(12.9898,78.233)),s=eE(r,Q_);return kc(So(s).mul(n))}),JL=(i,e,t)=>Ui(e,t,i),e9=(i,e,t)=>Uc(e,t,i),t9=(i,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),QM(i,e)),yJ=iE,xJ=YM;mt("all",$M);mt("any",RL);mt("equals",qL);mt("radians",DL);mt("degrees",PL);mt("exp",XM);mt("exp2",D0);mt("log",Uy);mt("log2",su);mt("sqrt",Su);mt("inverseSqrt",YM);mt("floor",au);mt("ceil",By);mt("normalize",Lc);mt("fract",kc);mt("sin",So);mt("cos",pc);mt("tan",LL);mt("asin",UL);mt("acos",BL);mt("atan",QM);mt("abs",rr);mt("sign",Mg);mt("length",wc);mt("lengthSq",QL);mt("negate",OL);mt("oneMinus",IL);mt("dFdx",KM);mt("dFdy",ZM);mt("round",FL);mt("reciprocal",kL);mt("trunc",JM);mt("fwidth",zL);mt("atan2",t9);mt("min",Za);mt("max",Gr);mt("mod",eE);mt("step",Oy);mt("reflect",VL);mt("distance",jL);mt("dot",jh);mt("cross",Iy);mt("pow",Tl);mt("pow2",tE);mt("pow3",WL);mt("pow4",$L);mt("transformDirection",XL);mt("mix",JL);mt("clamp",du);mt("refract",nE);mt("smoothstep",e9);mt("faceForward",iE);mt("difference",HL);mt("saturate",KL);mt("cbrt",YL);mt("transpose",GL);mt("rand",ZL);class bJ extends Nn{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:l}=e.getNodeProperties(this),u=t!=="void",h=u?cL(n).build(e):"";r.nodeProperty=h;const m=s.build(e,"bool");e.addFlowCode(` + */const jZ=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class HZ{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=jZ,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:n,material:r,object:s}=e;if(t={material:this.getMaterialData(r),geometry:{attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:s.matrixWorld.clone()},s.center&&(t.center=s.center.clone()),s.morphTargetInfluences&&(t.morphTargetInfluences=s.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:a,height:l}=e.context;t.bufferWidth=a,t.bufferHeight=l}this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e){const{object:t,material:n,geometry:r}=e,s=this.getRenderObjectData(e);if(s.worldMatrix.equals(t.matrixWorld)!==!0)return s.worldMatrix.copy(t.matrixWorld),!1;const a=s.material;for(const N in a){const C=a[N],E=n[N];if(C.equals!==void 0){if(C.equals(E)===!1)return C.copy(E),!1}else if(E.isTexture===!0){if(C.id!==E.id||C.version!==E.version)return C.id=E.id,C.version=E.version,!1}else if(C!==E)return a[N]=E,!1}if(a.transmission>0){const{width:N,height:C}=e.context;if(s.bufferWidth!==N||s.bufferHeight!==C)return s.bufferWidth=N,s.bufferHeight=C,!1}const l=s.geometry,u=r.attributes,h=l.attributes,m=Object.keys(h),v=Object.keys(u);if(m.length!==v.length)return s.geometry.attributes=this.getAttributesData(u),!1;for(const N of m){const C=h[N],E=u[N];if(E===void 0)return delete h[N],!1;if(C.version!==E.version)return C.version=E.version,!1}const x=r.index,S=l.indexVersion,T=x?x.version:null;if(S!==T)return l.indexVersion=T,!1;if(l.drawRange.start!==r.drawRange.start||l.drawRange.count!==r.drawRange.count)return l.drawRange.start=r.drawRange.start,l.drawRange.count=r.drawRange.count,!1;if(s.morphTargetInfluences){let N=!1;for(let C=0;C>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const OP=i=>vg(i),Cy=i=>vg(i),RM=(...i)=>vg(i);function IP(i,e=!1){const t=[];i.isNode===!0&&(t.push(i.id),i=i.getSelf());for(const{property:n,childNode:r}of H_(i))t.push(t,vg(n.slice(0,-4)),r.getCacheKey(e));return vg(t)}function*H_(i,e=!1){for(const t in i){if(t.startsWith("_")===!0)continue;const n=i[t];if(Array.isArray(n)===!0)for(let r=0;re.charCodeAt(0)).buffer}const zw={VERTEX:"vertex",FRAGMENT:"fragment"},Qn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},$Z={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ia={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},HP=["fragment","vertex"],Gw=["setup","analyze","generate"],qw=[...HP,"compute"],fd=["x","y","z","w"];let XZ=0;class Nn extends Bc{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Qn.NONE,this.updateBeforeType=Qn.NONE,this.updateAfterType=Qn.NONE,this.uuid=x0.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:XZ++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Qn.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Qn.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Qn.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of H_(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=RM(IP(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e){if(e.increaseUsage(this)===1){const n=e.getNodeProperties(this);for(const r of Object.values(n))r&&r.isNode===!0&&r.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let r=null;const s=e.getBuildStage();if(s==="setup"){this.updateReference(e);const a=e.getNodeProperties(this);if(a.initialized!==!0){a.initialized=!0;const l=this.setup(e),u=l&&l.isNode===!0;for(const h of Object.values(a))h&&h.isNode===!0&&h.build(e);u&&l.build(e),a.outputNode=l}}else if(s==="analyze")this.analyze(e);else if(s==="generate")if(this.generate.length===1){const l=this.getNodeType(e),u=e.getDataFromNode(this);r=u.snippet,r===void 0?(r=this.generate(e)||"",u.snippet=r):u.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,l,t)}else r=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return H_(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:s,childNode:a}of t)s!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(s)?[]:{}),n[r][s]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const s of e.inputNodes[n])r.push(t[s]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const s in e.inputNodes[n]){const a=e.inputNodes[n][s];r[s]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(l){const u=[];for(const h in l){const m=l[h];delete m.metadata,u.push(m)}return u}if(r){const l=a(e.textures),u=a(e.images),h=a(e.nodes);l.length>0&&(s.textures=l),u.length>0&&(s.images=u),h.length>0&&(s.nodes=h)}return s}}class dd extends Nn{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),n=this.indexNode.build(e,"uint");return`${t}[ ${n} ]`}}class WP extends Nn{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),s=n.build(e,r);return e.format(s,r,t)}}class Zr extends Nn{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),l=e.getVarFromNode(this,null,r),u=e.getPropertyName(l);return e.addLineFlowCode(`${u} = ${a}`,this),s.snippet=a,s.propertyName=u,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class YZ extends Zr{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=this.nodes,s=e.getComponentType(n),a=[];for(const u of r){let h=u.build(e);const m=e.getComponentType(u.getNodeType(e));m!==s&&(h=e.format(h,m,s)),a.push(h)}const l=`${e.getType(n)}( ${a.join(", ")} )`;return e.format(l,n,t)}}const QZ=fd.join("");class Vw extends Nn{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(fd.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,r=e.getTypeLength(n.getNodeType(e));let s=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===QZ.slice(0,this.components.length)?s=e.format(u,a,t):s=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else s=n.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class KZ extends Zr{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,s=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),l=e.getTypeFromLength(n.length,a),u=r.build(e,l),h=t.build(e,s),m=e.getTypeLength(s),v=[];for(let x=0;xi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),UR=i=>$P(i).split("").sort().join(""),XP={setup(i,e){const t=e.shift();return i(Gg(t),...e)},get(i,e,t){if(typeof e=="string"&&i[e]===void 0){if(i.isStackNode!==!0&&e==="assign")return(...n)=>(R0.assign(t,...n),t);if(jA.has(e)){const n=jA.get(e);return i.isStackNode?(...r)=>t.add(n(...r)):(...r)=>n(t,...r)}else{if(e==="self")return i;if(e.endsWith("Assign")&&jA.has(e.slice(0,e.length-6))){const n=jA.get(e.slice(0,e.length-6));return i.isStackNode?(...r)=>t.assign(r[0],n(...r)):(...r)=>t.assign(n(t,...r))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=$P(e),wt(new Vw(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=UR(e.slice(3).toLowerCase()),n=>wt(new KZ(i,e,n));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=UR(e.slice(4).toLowerCase()),()=>wt(new ZZ(wt(i),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),wt(new Vw(i,e));if(/^\d+$/.test(e)===!0)return wt(new dd(t,new Rl(Number(e),"uint")))}}}return Reflect.get(i,e,t)},set(i,e,t,n){return typeof e=="string"&&i[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(i,e,t,n)}},$3=new WeakMap,BR=new WeakMap,JZ=function(i,e=null){const t=Rh(i);if(t==="node"){let n=$3.get(i);return n===void 0&&(n=new Proxy(i,XP),$3.set(i,n),$3.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return wt(jw(i,e));if(t==="shader")return Ze(i)}return i},eJ=function(i,e=null){for(const t in i)i[t]=wt(i[t],e);return i},tJ=function(i,e=null){const t=i.length;for(let n=0;nwt(n!==null?Object.assign(s,n):s);return e===null?(...s)=>r(new i(...Qf(s))):t!==null?(t=wt(t),(...s)=>r(new i(e,...Qf(s),t))):(...s)=>r(new i(e,...Qf(s)))},iJ=function(i,...e){return wt(new i(...Qf(e)))};class rJ extends Nn{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t);if(r.onceOutput)return r.onceOutput;let s=null;if(t.layout){let a=BR.get(e.constructor);a===void 0&&(a=new WeakMap,BR.set(e.constructor,a));let l=a.get(t);l===void 0&&(l=wt(e.buildFunctionNode(t)),a.set(t,l)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(l),s=wt(l.call(n))}else{const a=t.jsFunc,l=n!==null?a(n,e):a(e);s=wt(l)}return t.once&&(r.onceOutput=s),s}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class sJ extends Nn{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Gg(e),wt(new rJ(this,e))}setup(){return this.call()}}const aJ=[!1,!0],oJ=[0,1,2,3],lJ=[-1,-2],YP=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],PM=new Map;for(const i of aJ)PM.set(i,new Rl(i));const LM=new Map;for(const i of oJ)LM.set(i,new Rl(i,"uint"));const UM=new Map([...LM].map(i=>new Rl(i.value,"int")));for(const i of lJ)UM.set(i,new Rl(i,"int"));const Ny=new Map([...UM].map(i=>new Rl(i.value)));for(const i of YP)Ny.set(i,new Rl(i));for(const i of YP)Ny.set(-i,new Rl(-i));const Ry={bool:PM,uint:LM,ints:UM,float:Ny},OR=new Map([...PM,...Ny]),jw=(i,e)=>OR.has(i)?OR.get(i):i.isNode===!0?i:new Rl(i,e),uJ=i=>{try{return i.getNodeType()}catch{return}},ls=function(i,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>typeof r!="object"))&&(t=[GP(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return wt(e.get(t[0]));if(t.length===1){const r=jw(t[0],i);return uJ(r)===i?wt(r):wt(new WP(r,i))}const n=t.map(r=>jw(r));return wt(new YZ(n,i))}},_g=i=>typeof i=="object"&&i!==null?i.value:i,QP=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Pm(i,e){return new Proxy(new sJ(i,e),XP)}const wt=(i,e=null)=>JZ(i,e),Gg=(i,e=null)=>new eJ(i,e),Qf=(i,e=null)=>new tJ(i,e),gt=(...i)=>new nJ(...i),Xt=(...i)=>new iJ(...i),Ze=(i,e)=>{const t=new Pm(i,e),n=(...r)=>{let s;return Gg(r),r[0]&&r[0].isNode?s=[...r]:s=r[0],t.call(s)};return n.shaderNode=t,n.setLayout=r=>(t.setLayout(r),n),n.once=()=>(t.once=!0,n),n},cJ=(...i)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),Ze(...i));mt("toGlobal",i=>(i.global=!0,i));const yg=i=>{R0=i},BM=()=>R0,ii=(...i)=>R0.If(...i);function KP(i){return R0&&R0.add(i),i}mt("append",KP);const ZP=new ls("color"),ye=new ls("float",Ry.float),Ee=new ls("int",Ry.ints),rn=new ls("uint",Ry.uint),Pc=new ls("bool",Ry.bool),Pt=new ls("vec2"),As=new ls("ivec2"),JP=new ls("uvec2"),eL=new ls("bvec2"),Ie=new ls("vec3"),tL=new ls("ivec3"),j0=new ls("uvec3"),OM=new ls("bvec3"),_n=new ls("vec4"),nL=new ls("ivec4"),iL=new ls("uvec4"),rL=new ls("bvec4"),Dy=new ls("mat2"),ua=new ls("mat3"),Kf=new ls("mat4"),hJ=(i="")=>wt(new Rl(i,"string")),fJ=i=>wt(new Rl(i,"ArrayBuffer"));mt("toColor",ZP);mt("toFloat",ye);mt("toInt",Ee);mt("toUint",rn);mt("toBool",Pc);mt("toVec2",Pt);mt("toIVec2",As);mt("toUVec2",JP);mt("toBVec2",eL);mt("toVec3",Ie);mt("toIVec3",tL);mt("toUVec3",j0);mt("toBVec3",OM);mt("toVec4",_n);mt("toIVec4",nL);mt("toUVec4",iL);mt("toBVec4",rL);mt("toMat2",Dy);mt("toMat3",ua);mt("toMat4",Kf);const sL=gt(dd),aL=(i,e)=>wt(new WP(wt(i),e)),dJ=(i,e)=>wt(new Vw(wt(i),e));mt("element",sL);mt("convert",aL);class oL extends Nn{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const lL=i=>new oL(i),IM=(i,e=0)=>new oL(i,!0,e),uL=IM("frame"),Ln=IM("render"),FM=lL("object");class qg extends DM{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=FM}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(r=>{const s=e(r,n);s!==void 0&&(this.value=s)},t)}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let s=e.getNodeFromHash(r);s===void 0&&(e.setHashNode(this,r),s=this);const a=s.getInputType(e),l=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.label),u=e.getPropertyName(l);return e.context.label!==void 0&&delete e.context.label,e.format(u,n,t)}}const yn=(i,e)=>{const t=QP(e||i),n=i&&i.isNode===!0?i.node&&i.node.value||i.value:i;return wt(new qg(n,t))};class Ii extends Nn{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const cL=(i,e)=>wt(new Ii(i,e)),xg=(i,e)=>wt(new Ii(i,e,!0)),Ri=Xt(Ii,"vec4","DiffuseColor"),Hw=Xt(Ii,"vec3","EmissiveColor"),$l=Xt(Ii,"float","Roughness"),bg=Xt(Ii,"float","Metalness"),W_=Xt(Ii,"float","Clearcoat"),Sg=Xt(Ii,"float","ClearcoatRoughness"),Vf=Xt(Ii,"vec3","Sheen"),Py=Xt(Ii,"float","SheenRoughness"),Ly=Xt(Ii,"float","Iridescence"),kM=Xt(Ii,"float","IridescenceIOR"),zM=Xt(Ii,"float","IridescenceThickness"),$_=Xt(Ii,"float","AlphaT"),Th=Xt(Ii,"float","Anisotropy"),Lm=Xt(Ii,"vec3","AnisotropyT"),Zf=Xt(Ii,"vec3","AnisotropyB"),Oa=Xt(Ii,"color","SpecularColor"),wg=Xt(Ii,"float","SpecularF90"),X_=Xt(Ii,"float","Shininess"),Tg=Xt(Ii,"vec4","Output"),Xv=Xt(Ii,"float","dashSize"),Ww=Xt(Ii,"float","gapSize"),AJ=Xt(Ii,"float","pointWidth"),Um=Xt(Ii,"float","IOR"),Y_=Xt(Ii,"float","Transmission"),GM=Xt(Ii,"float","Thickness"),qM=Xt(Ii,"float","AttenuationDistance"),VM=Xt(Ii,"color","AttenuationColor"),jM=Xt(Ii,"float","Dispersion");class pJ extends Zr{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return fd.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:r}=this,s=this.needsSplitAssign(e),a=n.getNodeType(e),l=n.context({assign:!0}).build(e),u=r.build(e,a),h=r.getNodeType(e),m=e.getDataFromNode(this);let v;if(m.initialized===!0)t!=="void"&&(v=l);else if(s){const x=e.getVarFromNode(this,null,a),S=e.getPropertyName(x);e.addLineFlowCode(`${S} = ${u}`,this);const T=n.node.context({assign:!0}).build(e);for(let N=0;N{const m=h.type,v=m==="pointer";let x;return v?x="&"+u.build(e):x=u.build(e,m),x};if(Array.isArray(s))for(let u=0;u(e=e.length>1||e[0]&&e[0].isNode===!0?Qf(e):Gg(e[0]),wt(new mJ(wt(i),e)));mt("call",fL);class Tr extends Zr{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let s=new Tr(e,t,n);for(let a=0;a>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="=="||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="<"||n===">"||n==="<="||n===">="){const u=t?e.getTypeLength(t):Math.max(e.getTypeLength(a),e.getTypeLength(l));return u>1?`bvec${u}`:"bool"}else return a==="float"&&e.isMatrix(l)?l:e.isMatrix(a)&&e.isVector(l)?e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(l)?e.getVectorFromMatrix(l):e.getTypeLength(l)>e.getTypeLength(a)?l:a}generate(e,t){const n=this.op,r=this.aNode,s=this.bNode,a=this.getNodeType(e,t);let l=null,u=null;a!=="void"?(l=r.getNodeType(e),u=typeof s<"u"?s.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="?e.isVector(l)?u=l:l!==u&&(l=u="float"):n===">>"||n==="<<"?(l=a,u=e.changeComponentType(u,"uint")):e.isMatrix(l)&&e.isVector(u)?u=e.getVectorFromMatrix(l):e.isVector(l)&&e.isMatrix(u)?l=e.getVectorFromMatrix(u):l=u=a):l=u=a;const h=r.build(e,l),m=typeof s<"u"?s.build(e,u):null,v=e.getTypeLength(t),x=e.getFunctionOperator(n);if(t!=="void")return n==="<"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} < ${m} )`,a,t):n==="<="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} <= ${m} )`,a,t):n===">"&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} > ${m} )`,a,t):n===">="&&v>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${h}, ${m} )`,a,t):e.format(`( ${h} >= ${m} )`,a,t):n==="!"||n==="~"?e.format(`(${n}${h})`,l,t):x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`( ${h} ${n} ${m} )`,a,t);if(l!=="void")return x?e.format(`${x}( ${h}, ${m} )`,a,t):e.format(`${h} ${n} ${m}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Qr=gt(Tr,"+"),yi=gt(Tr,"-"),Kn=gt(Tr,"*"),Cl=gt(Tr,"/"),HM=gt(Tr,"%"),dL=gt(Tr,"=="),AL=gt(Tr,"!="),pL=gt(Tr,"<"),WM=gt(Tr,">"),mL=gt(Tr,"<="),gL=gt(Tr,">="),vL=gt(Tr,"&&"),_L=gt(Tr,"||"),yL=gt(Tr,"!"),xL=gt(Tr,"^^"),bL=gt(Tr,"&"),SL=gt(Tr,"~"),wL=gt(Tr,"|"),TL=gt(Tr,"^"),ML=gt(Tr,"<<"),EL=gt(Tr,">>");mt("add",Qr);mt("sub",yi);mt("mul",Kn);mt("div",Cl);mt("modInt",HM);mt("equal",dL);mt("notEqual",AL);mt("lessThan",pL);mt("greaterThan",WM);mt("lessThanEqual",mL);mt("greaterThanEqual",gL);mt("and",vL);mt("or",_L);mt("not",yL);mt("xor",xL);mt("bitAnd",bL);mt("bitNot",SL);mt("bitOr",wL);mt("bitXor",TL);mt("shiftLeft",ML);mt("shiftRight",EL);const CL=(...i)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),HM(...i));mt("remainder",CL);class Qe extends Zr{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=r}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),l=e.isMatrix(r)?0:e.getTypeLength(r);return s>a&&s>l?t:a>l?n:l>s?r:t}getNodeType(e){const t=this.method;return t===Qe.LENGTH||t===Qe.DISTANCE||t===Qe.DOT?"float":t===Qe.CROSS?"vec3":t===Qe.ALL?"bool":t===Qe.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===Qe.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){let n=this.method;const r=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,l=this.bNode,u=this.cNode,h=e.renderer.coordinateSystem;if(n===Qe.TRANSFORM_DIRECTION){let m=a,v=l;e.isMatrix(m.getNodeType(e))?v=_n(Ie(v),0):m=_n(Ie(m),0);const x=Kn(m,v).xyz;return Lc(x).build(e,t)}else{if(n===Qe.NEGATE)return e.format("( - "+a.build(e,s)+" )",r,t);if(n===Qe.ONE_MINUS)return yi(1,a).build(e,t);if(n===Qe.RECIPROCAL)return Cl(1,a).build(e,t);if(n===Qe.DIFFERENCE)return rr(yi(a,l)).build(e,t);{const m=[];return n===Qe.CROSS||n===Qe.MOD?m.push(a.build(e,r),l.build(e,r)):h===Ga&&n===Qe.STEP?m.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":s),l.build(e,s)):h===Ga&&(n===Qe.MIN||n===Qe.MAX)||n===Qe.MOD?m.push(a.build(e,s),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":s)):n===Qe.REFRACT?m.push(a.build(e,s),l.build(e,s),u.build(e,"float")):n===Qe.MIX?m.push(a.build(e,s),l.build(e,s),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":s)):(h===cu&&n===Qe.ATAN&&l!==null&&(n="atan2"),m.push(a.build(e,s)),l!==null&&m.push(l.build(e,s)),u!==null&&m.push(u.build(e,s))),e.format(`${e.getMethod(n,r)}( ${m.join(", ")} )`,r,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Qe.ALL="all";Qe.ANY="any";Qe.RADIANS="radians";Qe.DEGREES="degrees";Qe.EXP="exp";Qe.EXP2="exp2";Qe.LOG="log";Qe.LOG2="log2";Qe.SQRT="sqrt";Qe.INVERSE_SQRT="inversesqrt";Qe.FLOOR="floor";Qe.CEIL="ceil";Qe.NORMALIZE="normalize";Qe.FRACT="fract";Qe.SIN="sin";Qe.COS="cos";Qe.TAN="tan";Qe.ASIN="asin";Qe.ACOS="acos";Qe.ATAN="atan";Qe.ABS="abs";Qe.SIGN="sign";Qe.LENGTH="length";Qe.NEGATE="negate";Qe.ONE_MINUS="oneMinus";Qe.DFDX="dFdx";Qe.DFDY="dFdy";Qe.ROUND="round";Qe.RECIPROCAL="reciprocal";Qe.TRUNC="trunc";Qe.FWIDTH="fwidth";Qe.TRANSPOSE="transpose";Qe.BITCAST="bitcast";Qe.EQUALS="equals";Qe.MIN="min";Qe.MAX="max";Qe.MOD="mod";Qe.STEP="step";Qe.REFLECT="reflect";Qe.DISTANCE="distance";Qe.DIFFERENCE="difference";Qe.DOT="dot";Qe.CROSS="cross";Qe.POW="pow";Qe.TRANSFORM_DIRECTION="transformDirection";Qe.MIX="mix";Qe.CLAMP="clamp";Qe.REFRACT="refract";Qe.SMOOTHSTEP="smoothstep";Qe.FACEFORWARD="faceforward";const NL=ye(1e-6),gJ=ye(1e6),Q_=ye(Math.PI),vJ=ye(Math.PI*2),$M=gt(Qe,Qe.ALL),RL=gt(Qe,Qe.ANY),DL=gt(Qe,Qe.RADIANS),PL=gt(Qe,Qe.DEGREES),XM=gt(Qe,Qe.EXP),D0=gt(Qe,Qe.EXP2),Uy=gt(Qe,Qe.LOG),su=gt(Qe,Qe.LOG2),Su=gt(Qe,Qe.SQRT),YM=gt(Qe,Qe.INVERSE_SQRT),au=gt(Qe,Qe.FLOOR),By=gt(Qe,Qe.CEIL),Lc=gt(Qe,Qe.NORMALIZE),kc=gt(Qe,Qe.FRACT),So=gt(Qe,Qe.SIN),pc=gt(Qe,Qe.COS),LL=gt(Qe,Qe.TAN),UL=gt(Qe,Qe.ASIN),BL=gt(Qe,Qe.ACOS),QM=gt(Qe,Qe.ATAN),rr=gt(Qe,Qe.ABS),Mg=gt(Qe,Qe.SIGN),wc=gt(Qe,Qe.LENGTH),OL=gt(Qe,Qe.NEGATE),IL=gt(Qe,Qe.ONE_MINUS),KM=gt(Qe,Qe.DFDX),ZM=gt(Qe,Qe.DFDY),FL=gt(Qe,Qe.ROUND),kL=gt(Qe,Qe.RECIPROCAL),JM=gt(Qe,Qe.TRUNC),zL=gt(Qe,Qe.FWIDTH),GL=gt(Qe,Qe.TRANSPOSE),_J=gt(Qe,Qe.BITCAST),qL=gt(Qe,Qe.EQUALS),Za=gt(Qe,Qe.MIN),Gr=gt(Qe,Qe.MAX),eE=gt(Qe,Qe.MOD),Oy=gt(Qe,Qe.STEP),VL=gt(Qe,Qe.REFLECT),jL=gt(Qe,Qe.DISTANCE),HL=gt(Qe,Qe.DIFFERENCE),jh=gt(Qe,Qe.DOT),Iy=gt(Qe,Qe.CROSS),Tl=gt(Qe,Qe.POW),tE=gt(Qe,Qe.POW,2),WL=gt(Qe,Qe.POW,3),$L=gt(Qe,Qe.POW,4),XL=gt(Qe,Qe.TRANSFORM_DIRECTION),YL=i=>Kn(Mg(i),Tl(rr(i),1/3)),QL=i=>jh(i,i),Ui=gt(Qe,Qe.MIX),du=(i,e=0,t=1)=>wt(new Qe(Qe.CLAMP,wt(i),wt(e),wt(t))),KL=i=>du(i),nE=gt(Qe,Qe.REFRACT),Uc=gt(Qe,Qe.SMOOTHSTEP),iE=gt(Qe,Qe.FACEFORWARD),ZL=Ze(([i])=>{const n=43758.5453,r=jh(i.xy,Pt(12.9898,78.233)),s=eE(r,Q_);return kc(So(s).mul(n))}),JL=(i,e,t)=>Ui(e,t,i),e9=(i,e,t)=>Uc(e,t,i),t9=(i,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),QM(i,e)),yJ=iE,xJ=YM;mt("all",$M);mt("any",RL);mt("equals",qL);mt("radians",DL);mt("degrees",PL);mt("exp",XM);mt("exp2",D0);mt("log",Uy);mt("log2",su);mt("sqrt",Su);mt("inverseSqrt",YM);mt("floor",au);mt("ceil",By);mt("normalize",Lc);mt("fract",kc);mt("sin",So);mt("cos",pc);mt("tan",LL);mt("asin",UL);mt("acos",BL);mt("atan",QM);mt("abs",rr);mt("sign",Mg);mt("length",wc);mt("lengthSq",QL);mt("negate",OL);mt("oneMinus",IL);mt("dFdx",KM);mt("dFdy",ZM);mt("round",FL);mt("reciprocal",kL);mt("trunc",JM);mt("fwidth",zL);mt("atan2",t9);mt("min",Za);mt("max",Gr);mt("mod",eE);mt("step",Oy);mt("reflect",VL);mt("distance",jL);mt("dot",jh);mt("cross",Iy);mt("pow",Tl);mt("pow2",tE);mt("pow3",WL);mt("pow4",$L);mt("transformDirection",XL);mt("mix",JL);mt("clamp",du);mt("refract",nE);mt("smoothstep",e9);mt("faceForward",iE);mt("difference",HL);mt("saturate",KL);mt("cbrt",YL);mt("transpose",GL);mt("rand",ZL);class bJ extends Nn{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const s=n.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(r))return s}return r}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=s,r!==null&&(e.getDataFromNode(r).parentNodeBlock=s);const a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:s,ifNode:a,elseNode:l}=e.getNodeProperties(this),u=t!=="void",h=u?cL(n).build(e):"";r.nodeProperty=h;const m=s.build(e,"bool");e.addFlowCode(` ${e.tab}if ( ${m} ) { `).addFlowTab();let v=a.build(e,n);if(v&&(u?v=h+" = "+v+";":v="return "+v+";"),e.removeFlowTab().addFlowCode(e.tab+" "+v+` @@ -3901,21 +3901,21 @@ ${e.tab}if ( ${m} ) { `)}else e.addFlowCode(` -`);return e.format(h,n,t)}}const zs=gt(bJ);mt("select",zs);const n9=(...i)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),zs(...i));mt("cond",n9);class i9 extends Nn{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(n),r}}const Fy=gt(i9),r9=(i,e)=>Fy(i,{label:e});mt("context",Fy);mt("label",r9);class Yv extends Nn{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const s9=gt(Yv);mt("toVar",(...i)=>s9(...i).append());const a9=i=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),s9(i));mt("temp",a9);class SJ extends Nn{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,s),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e),r=e.shaderStage==="fragment"&&t.reassignPosition===!0&&e.context.needsPositionReassign;if(t.propertyName===void 0||r){const s=this.getNodeType(e),a=e.getPropertyName(n,zw.VERTEX);e.flowNodeFromShaderStage(zw.VERTEX,this.node,s,a),t.propertyName=a,r?t.reassignPosition=!1:t.reassignPosition===void 0&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(n)}}const to=gt(SJ),o9=i=>to(i);mt("varying",to);mt("vertexStage",o9);const l9=Ke(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return Ui(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),u9=Ke(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return Ui(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Vg="WorkingColorSpace",rE="OutputColorSpace";class jg extends Zr{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===Vg?li.workingColorSpace:t===rE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return li.enabled===!1||n===r||!n||!r||(li.getTransfer(n)===Fi&&(s=_n(l9(s.rgb),s.a)),li.getPrimaries(n)!==li.getPrimaries(r)&&(s=_n(ua(li._getMatrix(new Xn,n,r)).mul(s.rgb),s.a)),li.getTransfer(r)===Fi&&(s=_n(u9(s.rgb),s.a))),s}}const c9=i=>wt(new jg(wt(i),Vg,rE)),h9=i=>wt(new jg(wt(i),rE,Vg)),f9=(i,e)=>wt(new jg(wt(i),Vg,e)),sE=(i,e)=>wt(new jg(wt(i),e,Vg)),wJ=(i,e,t)=>wt(new jg(wt(i),e,t));mt("toOutputColorSpace",c9);mt("toWorkingColorSpace",h9);mt("workingToColorSpace",f9);mt("colorSpaceToWorking",sE);let TJ=class extends dd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class d9 extends Nn{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=Qn.OBJECT}setGroup(e){return this.group=e,this}element(e){return wt(new TJ(this,wt(e)))}setNodeType(e){const t=yn(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rwt(new d9(i,e,t));class EJ extends d9{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Ln)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const A9=(i,e,t=null)=>wt(new EJ(i,e,t));class CJ extends Zr{static get type(){return"ToneMappingNode"}constructor(e,t=m9,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return RM(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Ya)return t;let r=null;const s=e.renderer.library.getToneMappingFunction(n);return s!==null?r=_n(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const p9=(i,e,t)=>wt(new CJ(i,wt(e),wt(t))),m9=A9("toneMappingExposure","float");mt("toneMapping",(i,e,t)=>p9(e,t,i));class NJ extends DM{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=s_,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,l=n.isInterleavedBuffer===!0?n:new JT(n,s),u=new Kl(l,r,a);l.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=to(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Hg=(i,e=null,t=0,n=0)=>wt(new NJ(i,e,t,n)),g9=(i,e=null,t=0,n=0)=>Hg(i,e,t,n).setUsage(IA),K_=(i,e=null,t=0,n=0)=>Hg(i,e,t,n).setInstanced(!0),$w=(i,e=null,t=0,n=0)=>g9(i,e,t,n).setInstanced(!0);mt("toAttribute",i=>Hg(i.value));class RJ extends Nn{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Qn.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let r=1;rwt(new RJ(wt(i),e,t));mt("compute",v9);class DJ extends Nn{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(n),s}}const Bm=(i,e)=>wt(new DJ(wt(i),e));mt("cache",Bm);class PJ extends Nn{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const _9=gt(PJ);mt("bypass",_9);class y9 extends Nn{static get type(){return"RemapNode"}constructor(e,t,n,r=xe(0),s=xe(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:s,doClamp:a}=this;let l=e.sub(t).div(n.sub(t));return a===!0&&(l=l.clamp()),l.mul(s.sub(r)).add(r)}}const x9=gt(y9,null,null,{doClamp:!1}),b9=gt(y9);mt("remap",x9);mt("remapClamp",b9);class Qv extends Nn{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,n,t)}}const zh=gt(Qv),S9=i=>(i?zs(i,zh("discard")):zh("discard")).append(),LJ=()=>zh("return").append();mt("discard",S9);class UJ extends Zr{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Ya,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||To;return n!==Ya&&(t=t.toneMapping(n)),r!==To&&r!==li.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const w9=(i,e=null,t=null)=>wt(new UJ(wt(i),e,t));mt("renderOutput",w9);function BJ(i){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class T9 extends Nn{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(s),l=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(l.name,a,n):to(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Au=(i,e)=>wt(new T9(i,e)),Mr=(i=0)=>Au("uv"+(i>0?i:""),"vec2");class OJ extends Nn{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const Uh=gt(OJ);class IJ extends qg{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Qn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:s}=n;this.value=Math.log2(Math.max(r,s))}}}const M9=gt(IJ);class pu extends qg{static get type(){return"TextureNode"}constructor(e,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Qn.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Nr?"uvec4":this.value.type===Ns?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Mr(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=yn(this.value.matrix)),this._matrixUniform.mul(Ie(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Qn.RENDER:Qn.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Ee(Uh(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this)),r||(r=this.getDefaultUV()),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,n,r,s,a,l,u){const h=this.value;let m;return r?m=e.generateTextureLevel(h,t,n,r,a):s?m=e.generateTextureBias(h,t,n,s,a):u?m=e.generateTextureGrad(h,t,n,u,a):l?m=e.generateTextureCompare(h,t,n,l,a):this.sampler===!1?m=e.generateTextureLoad(h,t,n,a):m=e.generateTexture(h,t,n,a),m}generate(e,t){const n=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let l=a.propertyName;if(l===void 0){const{uvNode:m,levelNode:v,biasNode:x,compareNode:S,depthNode:T,gradNode:N}=r,C=this.generateUV(e,m),E=v?v.build(e,"float"):null,O=x?x.build(e,"float"):null,U=T?T.build(e,"int"):null,I=S?S.build(e,"float"):null,j=N?[N[0].build(e,"vec2"),N[1].build(e,"vec2")]:null,z=e.getVarFromNode(this);l=e.getPropertyName(z);const G=this.generateSnippet(e,s,C,E,O,U,I,j);e.addLineFlowCode(`${l} = ${G}`,this),a.snippet=G,a.propertyName=l}let u=l;const h=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=sE(zh(u,h),n.colorSpace).setup(e).build(e,h)),e.format(u,h,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}blur(e){const t=this.clone();return t.biasNode=wt(e).mul(M9(t)),t.referenceNode=this.getSelf(),wt(t)}level(e){const t=this.clone();return t.levelNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}size(e){return Uh(this,e)}bias(e){const t=this.clone();return t.biasNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}compare(e){const t=this.clone();return t.compareNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}grad(e,t){const n=this.clone();return n.gradNode=[wt(e),wt(t)],n.referenceNode=this.getSelf(),wt(n)}depth(e){const t=this.clone();return t.depthNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const fi=gt(pu),Ir=(...i)=>fi(...i).setSampler(!1),FJ=i=>(i.isNode===!0?i:fi(i)).convert("sampler"),Eh=yn("float").label("cameraNear").setGroup(Ln).onRenderUpdate(({camera:i})=>i.near),Ch=yn("float").label("cameraFar").setGroup(Ln).onRenderUpdate(({camera:i})=>i.far),Ad=yn("mat4").label("cameraProjectionMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.projectionMatrix),kJ=yn("mat4").label("cameraProjectionMatrixInverse").setGroup(Ln).onRenderUpdate(({camera:i})=>i.projectionMatrixInverse),no=yn("mat4").label("cameraViewMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.matrixWorldInverse),zJ=yn("mat4").label("cameraWorldMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.matrixWorld),GJ=yn("mat3").label("cameraNormalMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.normalMatrix),E9=yn(new me).label("cameraPosition").setGroup(Ln).onRenderUpdate(({camera:i},e)=>e.value.setFromMatrixPosition(i.matrixWorld));class Ni extends Nn{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Qn.OBJECT,this._uniformNode=new qg(null)}getNodeType(){const e=this.scope;if(e===Ni.WORLD_MATRIX)return"mat4";if(e===Ni.POSITION||e===Ni.VIEW_POSITION||e===Ni.DIRECTION||e===Ni.SCALE)return"vec3"}update(e){const t=this.object3d,n=this._uniformNode,r=this.scope;if(r===Ni.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===Ni.POSITION)n.value=n.value||new me,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===Ni.SCALE)n.value=n.value||new me,n.value.setFromMatrixScale(t.matrixWorld);else if(r===Ni.DIRECTION)n.value=n.value||new me,t.getWorldDirection(n.value);else if(r===Ni.VIEW_POSITION){const s=e.camera;n.value=n.value||new me,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===Ni.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===Ni.POSITION||t===Ni.VIEW_POSITION||t===Ni.DIRECTION||t===Ni.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Ni.WORLD_MATRIX="worldMatrix";Ni.POSITION="position";Ni.SCALE="scale";Ni.VIEW_POSITION="viewPosition";Ni.DIRECTION="direction";const qJ=gt(Ni,Ni.DIRECTION),VJ=gt(Ni,Ni.WORLD_MATRIX),C9=gt(Ni,Ni.POSITION),jJ=gt(Ni,Ni.SCALE),HJ=gt(Ni,Ni.VIEW_POSITION);class mu extends Ni{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const WJ=$t(mu,mu.DIRECTION),Ho=$t(mu,mu.WORLD_MATRIX),$J=$t(mu,mu.POSITION),XJ=$t(mu,mu.SCALE),YJ=$t(mu,mu.VIEW_POSITION),N9=yn(new Xn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),QJ=yn(new jn).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),H0=Ke(i=>i.renderer.nodes.modelViewMatrix||R9).once()().toVar("modelViewMatrix"),R9=no.mul(Ho),KJ=Ke(i=>(i.context.isHighPrecisionModelViewMatrix=!0,yn("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),ZJ=Ke(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return yn("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),ky=Au("position","vec3"),zr=ky.varying("positionLocal"),Z_=ky.varying("positionPrevious"),Tc=Ho.mul(zr).xyz.varying("v_positionWorld").context({needsPositionReassign:!0}),aE=zr.transformDirection(Ho).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection").context({needsPositionReassign:!0}),Xr=Ke(i=>i.context.setupPositionView(),"vec3").once()().varying("v_positionView").context({needsPositionReassign:!0}),hr=Xr.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class JJ extends Nn{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===Ga&&n.side===or?"false":e.getFrontFacing()}}const D9=$t(JJ),Wg=xe(D9).mul(2).sub(1),zy=Au("normal","vec3"),Ja=Ke(i=>i.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),Ie(0,1,0)):zy,"vec3").once()().toVar("normalLocal"),P9=Xr.dFdx().cross(Xr.dFdy()).normalize().toVar("normalFlat"),Ko=Ke(i=>{let e;return i.material.flatShading===!0?e=P9:e=to(oE(Ja),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Gy=to(Ko.transformDirection(no),"v_normalWorld").normalize().toVar("normalWorld"),kr=Ke(i=>i.context.setupNormal(),"vec3").once()().mul(Wg).toVar("transformedNormalView"),qy=kr.transformDirection(no).toVar("transformedNormalWorld"),HA=Ke(i=>i.context.setupClearcoatNormal(),"vec3").once()().mul(Wg).toVar("transformedClearcoatNormalView"),L9=Ke(([i,e=Ho])=>{const t=ua(e),n=i.div(Ie(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),oE=Ke(([i],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const n=N9.mul(i);return no.transformDirection(n)}),U9=yn(0).onReference(({material:i})=>i).onRenderUpdate(({material:i})=>i.refractionRatio),B9=hr.negate().reflect(kr),O9=hr.negate().refract(kr,U9),I9=B9.transformDirection(no).toVar("reflectVector"),F9=O9.transformDirection(no).toVar("reflectVector");class eee extends pu{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Xo?I9:e.mapping===Yo?F9:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Ie(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem===cu||!n.isRenderTargetTexture?Ie(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const P0=gt(eee);class lE extends qg{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const $g=(i,e,t)=>wt(new lE(i,e,t));class tee extends dd{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class k9 extends lE{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Rh(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Qn.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;rwt(new k9(i,e)),nee=(i,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),wt(new k9(i,e)));class iee extends dd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class Vy extends Nn{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Qn.OBJECT}element(e){return wt(new iee(this,wt(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=$g(null,e,this.count):Array.isArray(this.getValueFromReference())?t=vc(null,e):e==="texture"?t=fi(null):e==="cubeTexture"?t=P0(null):t=yn(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rwt(new Vy(i,e,t)),Xw=(i,e,t,n)=>wt(new Vy(i,e,n,t));class ree extends Vy{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const _c=(i,e,t=null)=>wt(new ree(i,e,t)),jy=Ke(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),Au("tangent","vec4")))(),Xg=jy.xyz.toVar("tangentLocal"),Yg=H0.mul(_n(Xg,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),z9=Yg.transformDirection(no).varying("v_tangentWorld").normalize().toVar("tangentWorld"),uE=Yg.toVar("transformedTangentView"),see=uE.transformDirection(no).normalize().toVar("transformedTangentWorld"),Qg=i=>i.mul(jy.w).xyz,aee=to(Qg(zy.cross(jy)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),oee=to(Qg(Ja.cross(Xg)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),G9=to(Qg(Ko.cross(Yg)),"v_bitangentView").normalize().toVar("bitangentView"),lee=to(Qg(Gy.cross(z9)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),q9=Qg(kr.cross(uE)).normalize().toVar("transformedBitangentView"),uee=q9.transformDirection(no).normalize().toVar("transformedBitangentWorld"),jf=ua(Yg,G9,Ko),V9=hr.mul(jf),cee=(i,e)=>i.sub(V9.mul(e)),j9=(()=>{let i=Zf.cross(hr);return i=i.cross(Zf).normalize(),i=Ui(i,kr,Th.mul($l.oneMinus()).oneMinus().pow2().pow2()).normalize(),i})(),hee=Ke(i=>{const{eye_pos:e,surf_norm:t,mapN:n,uv:r}=i,s=e.dFdx(),a=e.dFdy(),l=r.dFdx(),u=r.dFdy(),h=t,m=a.cross(h),v=h.cross(s),x=m.mul(l.x).add(v.mul(u.x)),S=m.mul(l.y).add(v.mul(u.y)),T=x.dot(x).max(S.dot(S)),N=Wg.mul(T.inverseSqrt());return Qr(x.mul(n.x,N),S.mul(n.y,N),h.mul(n.z)).normalize()});class fee extends Zr{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Mc}setup(e){const{normalMapType:t,scaleNode:n}=this;let r=this.node.mul(2).sub(1);n!==null&&(r=Ie(r.xy.mul(n),r.z));let s=null;return t===z7?s=oE(r):t===Mc&&(e.hasGeometryAttribute("tangent")===!0?s=jf.mul(r).normalize():s=hee({eye_pos:Xr,surf_norm:Ko,mapN:r,uv:Mr()})),s}}const Yw=gt(fee),dee=Ke(({textureNode:i,bumpScale:e})=>{const t=r=>i.cache().context({getUV:s=>r(s.uvNode||Mr()),forceUVContext:!0}),n=xe(t(r=>r));return Lt(xe(t(r=>r.add(r.dFdx()))).sub(n),xe(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),Aee=Ke(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,l=s.cross(a),u=a.cross(r),h=r.dot(l).mul(Wg),m=h.sign().mul(n.x.mul(l).add(n.y.mul(u)));return h.abs().mul(t).sub(m).normalize()});class pee extends Zr{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=dee({textureNode:this.textureNode,bumpScale:e});return Aee({surf_pos:Xr,surf_norm:Ko,dHdxy:t})}}const H9=gt(pee),IR=new Map;class At extends Nn{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=IR.get(e);return n===void 0&&(n=_c(e,t),IR.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let r=null;if(n===At.COLOR){const s=t.color!==void 0?this.getColor(n):Ie();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(n===At.OPACITY){const s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(n===At.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=xe(1);else if(n===At.SPECULAR_INTENSITY){const s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s}else if(n===At.SPECULAR_COLOR){const s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(n).rgb):r=s}else if(n===At.ROUGHNESS){const s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).g):r=s}else if(n===At.METALNESS){const s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(n).b):r=s}else if(n===At.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(n)):r=a}else if(n===At.NORMAL)t.normalMap?(r=Yw(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=H9(this.getTexture("bump").r,this.getFloat("bumpScale")):r=Ko;else if(n===At.CLEARCOAT){const s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=Yw(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=Ko;else if(n===At.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(n===At.SHEEN_ROUGHNESS){const s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s,r=r.clamp(.07,1)}else if(n===At.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(n);r=Dy(UA.x,UA.y,UA.y.negate(),UA.x).mul(s.rg.mul(2).sub(Lt(1)).normalize().mul(s.b))}else r=UA;else if(n===At.IRIDESCENCE_THICKNESS){const s=zi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=zi("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(n).g).add(a)}else r=s}else if(n===At.TRANSMISSION){const s=this.getFloat(n);t.transmissionMap?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.THICKNESS){const s=this.getFloat(n);t.thicknessMap?r=s.mul(this.getTexture(n).g):r=s}else if(n===At.IOR)r=this.getFloat(n);else if(n===At.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===At.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(n,s)}return r}}At.ALPHA_TEST="alphaTest";At.COLOR="color";At.OPACITY="opacity";At.SHININESS="shininess";At.SPECULAR="specular";At.SPECULAR_STRENGTH="specularStrength";At.SPECULAR_INTENSITY="specularIntensity";At.SPECULAR_COLOR="specularColor";At.REFLECTIVITY="reflectivity";At.ROUGHNESS="roughness";At.METALNESS="metalness";At.NORMAL="normal";At.CLEARCOAT="clearcoat";At.CLEARCOAT_ROUGHNESS="clearcoatRoughness";At.CLEARCOAT_NORMAL="clearcoatNormal";At.EMISSIVE="emissive";At.ROTATION="rotation";At.SHEEN="sheen";At.SHEEN_ROUGHNESS="sheenRoughness";At.ANISOTROPY="anisotropy";At.IRIDESCENCE="iridescence";At.IRIDESCENCE_IOR="iridescenceIOR";At.IRIDESCENCE_THICKNESS="iridescenceThickness";At.IOR="ior";At.TRANSMISSION="transmission";At.THICKNESS="thickness";At.ATTENUATION_DISTANCE="attenuationDistance";At.ATTENUATION_COLOR="attenuationColor";At.LINE_SCALE="scale";At.LINE_DASH_SIZE="dashSize";At.LINE_GAP_SIZE="gapSize";At.LINE_WIDTH="linewidth";At.LINE_DASH_OFFSET="dashOffset";At.POINT_WIDTH="pointWidth";At.DISPERSION="dispersion";At.LIGHT_MAP="light";At.AO="ao";const W9=$t(At,At.ALPHA_TEST),$9=$t(At,At.COLOR),X9=$t(At,At.SHININESS),Y9=$t(At,At.EMISSIVE),cE=$t(At,At.OPACITY),Q9=$t(At,At.SPECULAR),Qw=$t(At,At.SPECULAR_INTENSITY),K9=$t(At,At.SPECULAR_COLOR),Om=$t(At,At.SPECULAR_STRENGTH),Kv=$t(At,At.REFLECTIVITY),Z9=$t(At,At.ROUGHNESS),J9=$t(At,At.METALNESS),eU=$t(At,At.NORMAL).context({getUV:null}),tU=$t(At,At.CLEARCOAT),nU=$t(At,At.CLEARCOAT_ROUGHNESS),iU=$t(At,At.CLEARCOAT_NORMAL).context({getUV:null}),rU=$t(At,At.ROTATION),sU=$t(At,At.SHEEN),aU=$t(At,At.SHEEN_ROUGHNESS),oU=$t(At,At.ANISOTROPY),lU=$t(At,At.IRIDESCENCE),uU=$t(At,At.IRIDESCENCE_IOR),cU=$t(At,At.IRIDESCENCE_THICKNESS),hU=$t(At,At.TRANSMISSION),fU=$t(At,At.THICKNESS),dU=$t(At,At.IOR),AU=$t(At,At.ATTENUATION_DISTANCE),pU=$t(At,At.ATTENUATION_COLOR),mU=$t(At,At.LINE_SCALE),gU=$t(At,At.LINE_DASH_SIZE),vU=$t(At,At.LINE_GAP_SIZE),mee=$t(At,At.LINE_WIDTH),_U=$t(At,At.LINE_DASH_OFFSET),gee=$t(At,At.POINT_WIDTH),yU=$t(At,At.DISPERSION),hE=$t(At,At.LIGHT_MAP),xU=$t(At,At.AO),UA=yn(new bt).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),fE=Ke(i=>i.context.setupModelViewProjection(),"vec4").once()().varying("v_modelViewProjection");class fr extends Nn{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===fr.VERTEX)r=e.getVertexIndex();else if(n===fr.INSTANCE)r=e.getInstanceIndex();else if(n===fr.DRAW)r=e.getDrawIndex();else if(n===fr.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===fr.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===fr.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=to(this).build(e,t),s}}fr.VERTEX="vertex";fr.INSTANCE="instance";fr.SUBGROUP="subgroup";fr.INVOCATION_LOCAL="invocationLocal";fr.INVOCATION_SUBGROUP="invocationSubgroup";fr.DRAW="draw";const bU=$t(fr,fr.VERTEX),Kg=$t(fr,fr.INSTANCE),vee=$t(fr,fr.SUBGROUP),_ee=$t(fr,fr.INVOCATION_SUBGROUP),yee=$t(fr,fr.INVOCATION_LOCAL),SU=$t(fr,fr.DRAW);class wU extends Nn{static get type(){return"InstanceNode"}constructor(e,t,n){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Qn.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:n,instanceColor:r}=this;let{instanceMatrixNode:s,instanceColorNode:a}=this;if(s===null){if(t<=1e3)s=$g(n.array,"mat4",Math.max(t,1)).element(Kg);else{const u=new u_(n.array,16,1);this.buffer=u;const h=n.usage===IA?$w:K_,m=[h(u,"vec4",16,0),h(u,"vec4",16,4),h(u,"vec4",16,8),h(u,"vec4",16,12)];s=Kf(...m)}this.instanceMatrixNode=s}if(r&&a===null){const u=new Bg(r.array,3),h=r.usage===IA?$w:K_;this.bufferColor=u,a=Ie(h(u,"vec3",3,0)),this.instanceColorNode=a}const l=s.mul(zr).xyz;if(zr.assign(l),e.hasGeometryAttribute("normal")){const u=L9(Ja,s);Ja.assign(u)}this.instanceColorNode!==null&&xg("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==IA&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==IA&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const xee=gt(wU);class bee extends wU{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const TU=gt(bee);class See extends Nn{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Kg:this.batchingIdNode=SU);const n=Ke(([T])=>{const N=Uh(Ir(this.batchMesh._indirectTexture),0),C=Ee(T).modInt(Ee(N)),E=Ee(T).div(Ee(N));return Ir(this.batchMesh._indirectTexture,As(C,E)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Ee(this.batchingIdNode)),r=this.batchMesh._matricesTexture,s=Uh(Ir(r),0),a=xe(n).mul(4).toInt().toVar(),l=a.modInt(s),u=a.div(Ee(s)),h=Kf(Ir(r,As(l,u)),Ir(r,As(l.add(1),u)),Ir(r,As(l.add(2),u)),Ir(r,As(l.add(3),u))),m=this.batchMesh._colorsTexture;if(m!==null){const N=Ke(([C])=>{const E=Uh(Ir(m),0).x,O=C,U=O.modInt(E),I=O.div(E);return Ir(m,As(U,I)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);xg("vec3","vBatchColor").assign(N)}const v=ua(h);zr.assign(h.mul(zr));const x=Ja.div(Ie(v[0].dot(v[0]),v[1].dot(v[1]),v[2].dot(v[2]))),S=v.mul(x).xyz;Ja.assign(S),e.hasGeometryAttribute("tangent")&&Xg.mulAssign(v)}}const MU=gt(See),FR=new WeakMap;class EU extends Nn{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=Qn.OBJECT,this.skinIndexNode=Au("skinIndex","uvec4"),this.skinWeightNode=Au("skinWeight","vec4");let n,r,s;t?(n=zi("bindMatrix","mat4"),r=zi("bindMatrixInverse","mat4"),s=Xw("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=yn(e.bindMatrix,"mat4"),r=yn(e.bindMatrixInverse,"mat4"),s=$g(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=zr){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w),v=s.mul(t),x=Qr(l.mul(r.x).mul(v),u.mul(r.y).mul(v),h.mul(r.z).mul(v),m.mul(r.w).mul(v));return a.mul(x).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Ja){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w);let v=Qr(r.x.mul(l),r.y.mul(u),r.z.mul(h),r.w.mul(m));return v=a.mul(v).mul(s),v.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Xw("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Z_)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||qP(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Z_.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(zr.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();Ja.assign(n),e.hasGeometryAttribute("tangent")&&Xg.assign(n)}}generate(e,t){if(t!=="void")return zr.build(e,t)}update(e){const n=(this.useReference?e.object:this.skinnedMesh).skeleton;FR.get(n)!==e.frameId&&(FR.set(n,e.frameId),this.previousBoneMatricesNode!==null&&n.previousBoneMatrices.set(n.boneMatrices),n.update())}}const wee=i=>wt(new EU(i)),CU=i=>wt(new EU(i,!0));class Tee extends Nn{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let s=0,a=this.params.length-1;sNumber(v)?T=">=":T="<"));const C={start:m,end:v},E=C.start,O=C.end;let U="",I="",j="";N||(S==="int"||S==="uint"?T.includes("<")?N="++":N="--":T.includes("<")?N="+= 1.":N="-= 1."),U+=e.getVar(S,x)+" = "+E,I+=x+" "+T+" "+O,j+=x+" "+N;const z=`for ( ${U}; ${I}; ${j} )`;e.addFlowCode((l===0?` +`);return e.format(h,n,t)}}const zs=gt(bJ);mt("select",zs);const n9=(...i)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),zs(...i));mt("cond",n9);class i9 extends Nn{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const r=this.node.build(e,t);return e.setContext(n),r}}const Fy=gt(i9),r9=(i,e)=>Fy(i,{label:e});mt("context",Fy);mt("label",r9);class Yv extends Nn{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,r=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),s=e.getPropertyName(r),a=t.build(e,r.type);return e.addLineFlowCode(`${s} = ${a}`,this),s}}const s9=gt(Yv);mt("toVar",(...i)=>s9(...i).append());const a9=i=>(console.warn('TSL: "temp" is deprecated. Use ".toVar()" instead.'),s9(i));mt("temp",a9);class SJ extends Nn{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const r=this.name,s=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,r,s),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e),r=e.shaderStage==="fragment"&&t.reassignPosition===!0&&e.context.needsPositionReassign;if(t.propertyName===void 0||r){const s=this.getNodeType(e),a=e.getPropertyName(n,zw.VERTEX);e.flowNodeFromShaderStage(zw.VERTEX,this.node,s,a),t.propertyName=a,r?t.reassignPosition=!1:t.reassignPosition===void 0&&e.context.isPositionNodeInput&&(t.reassignPosition=!0)}return e.getPropertyName(n)}}const to=gt(SJ),o9=i=>to(i);mt("varying",to);mt("vertexStage",o9);const l9=Ze(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return Ui(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),u9=Ze(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return Ui(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Vg="WorkingColorSpace",rE="OutputColorSpace";class jg extends Zr{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===Vg?li.workingColorSpace:t===rE?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let s=t;return li.enabled===!1||n===r||!n||!r||(li.getTransfer(n)===Fi&&(s=_n(l9(s.rgb),s.a)),li.getPrimaries(n)!==li.getPrimaries(r)&&(s=_n(ua(li._getMatrix(new Xn,n,r)).mul(s.rgb),s.a)),li.getTransfer(r)===Fi&&(s=_n(u9(s.rgb),s.a))),s}}const c9=i=>wt(new jg(wt(i),Vg,rE)),h9=i=>wt(new jg(wt(i),rE,Vg)),f9=(i,e)=>wt(new jg(wt(i),Vg,e)),sE=(i,e)=>wt(new jg(wt(i),e,Vg)),wJ=(i,e,t)=>wt(new jg(wt(i),e,t));mt("toOutputColorSpace",c9);mt("toWorkingColorSpace",h9);mt("workingToColorSpace",f9);mt("colorSpaceToWorking",sE);let TJ=class extends dd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class d9 extends Nn{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=Qn.OBJECT}setGroup(e){return this.group=e,this}element(e){return wt(new TJ(this,wt(e)))}setNodeType(e){const t=yn(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rwt(new d9(i,e,t));class EJ extends d9{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Ln)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const A9=(i,e,t=null)=>wt(new EJ(i,e,t));class CJ extends Zr{static get type(){return"ToneMappingNode"}constructor(e,t=m9,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return RM(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Ya)return t;let r=null;const s=e.renderer.library.getToneMappingFunction(n);return s!==null?r=_n(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const p9=(i,e,t)=>wt(new CJ(i,wt(e),wt(t))),m9=A9("toneMappingExposure","float");mt("toneMapping",(i,e,t)=>p9(e,t,i));class NJ extends DM{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=s_,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),s=this.bufferStride||r,a=this.bufferOffset,l=n.isInterleavedBuffer===!0?n:new JT(n,s),u=new Kl(l,r,a);l.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let s=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,s=r):s=to(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Hg=(i,e=null,t=0,n=0)=>wt(new NJ(i,e,t,n)),g9=(i,e=null,t=0,n=0)=>Hg(i,e,t,n).setUsage(IA),K_=(i,e=null,t=0,n=0)=>Hg(i,e,t,n).setInstanced(!0),$w=(i,e=null,t=0,n=0)=>g9(i,e,t,n).setInstanced(!0);mt("toAttribute",i=>Hg(i.value));class RJ extends Nn{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name="",this.updateBeforeType=Qn.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}label(e){return this.name=e,this}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let r=1;rwt(new RJ(wt(i),e,t));mt("compute",v9);class DJ extends Nn{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){const t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.build(e,...t);return e.setCache(n),s}}const Bm=(i,e)=>wt(new DJ(wt(i),e));mt("cache",Bm);class PJ extends Nn{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const _9=gt(PJ);mt("bypass",_9);class y9 extends Nn{static get type(){return"RemapNode"}constructor(e,t,n,r=ye(0),s=ye(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=s,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:s,doClamp:a}=this;let l=e.sub(t).div(n.sub(t));return a===!0&&(l=l.clamp()),l.mul(s.sub(r)).add(r)}}const x9=gt(y9,null,null,{doClamp:!1}),b9=gt(y9);mt("remap",x9);mt("remapClamp",b9);class Qv extends Nn{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(`( ${r} )`,n,t)}}const zh=gt(Qv),S9=i=>(i?zs(i,zh("discard")):zh("discard")).append(),LJ=()=>zh("return").append();mt("discard",S9);class UJ extends Zr{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Ya,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||To;return n!==Ya&&(t=t.toneMapping(n)),r!==To&&r!==li.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const w9=(i,e=null,t=null)=>wt(new UJ(wt(i),e,t));mt("renderOutput",w9);function BJ(i){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class T9 extends Nn{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(s),l=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(l.name,a,n):to(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Au=(i,e)=>wt(new T9(i,e)),Mr=(i=0)=>Au("uv"+(i>0?i:""),"vec2");class OJ extends Nn{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const Uh=gt(OJ);class IJ extends qg{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Qn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:s}=n;this.value=Math.log2(Math.max(r,s))}}}const M9=gt(IJ);class pu extends qg{static get type(){return"TextureNode"}constructor(e,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Qn.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Nr?"uvec4":this.value.type===Ns?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Mr(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=yn(this.value.matrix)),this._matrixUniform.mul(Ie(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Qn.RENDER:Qn.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Ee(Uh(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this)),r||(r=this.getDefaultUV()),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,n,r,s,a,l,u){const h=this.value;let m;return r?m=e.generateTextureLevel(h,t,n,r,a):s?m=e.generateTextureBias(h,t,n,s,a):u?m=e.generateTextureGrad(h,t,n,u,a):l?m=e.generateTextureCompare(h,t,n,l,a):this.sampler===!1?m=e.generateTextureLoad(h,t,n,a):m=e.generateTexture(h,t,n,a),m}generate(e,t){const n=this.value,r=e.getNodeProperties(this),s=super.generate(e,"property");if(t==="sampler")return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let l=a.propertyName;if(l===void 0){const{uvNode:m,levelNode:v,biasNode:x,compareNode:S,depthNode:T,gradNode:N}=r,C=this.generateUV(e,m),E=v?v.build(e,"float"):null,O=x?x.build(e,"float"):null,U=T?T.build(e,"int"):null,I=S?S.build(e,"float"):null,j=N?[N[0].build(e,"vec2"),N[1].build(e,"vec2")]:null,z=e.getVarFromNode(this);l=e.getPropertyName(z);const G=this.generateSnippet(e,s,C,E,O,U,I,j);e.addLineFlowCode(`${l} = ${G}`,this),a.snippet=G,a.propertyName=l}let u=l;const h=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=sE(zh(u,h),n.colorSpace).setup(e).build(e,h)),e.format(u,h,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}blur(e){const t=this.clone();return t.biasNode=wt(e).mul(M9(t)),t.referenceNode=this.getSelf(),wt(t)}level(e){const t=this.clone();return t.levelNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}size(e){return Uh(this,e)}bias(e){const t=this.clone();return t.biasNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}compare(e){const t=this.clone();return t.compareNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}grad(e,t){const n=this.clone();return n.gradNode=[wt(e),wt(t)],n.referenceNode=this.getSelf(),wt(n)}depth(e){const t=this.clone();return t.depthNode=wt(e),t.referenceNode=this.getSelf(),wt(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const fi=gt(pu),Ir=(...i)=>fi(...i).setSampler(!1),FJ=i=>(i.isNode===!0?i:fi(i)).convert("sampler"),Eh=yn("float").label("cameraNear").setGroup(Ln).onRenderUpdate(({camera:i})=>i.near),Ch=yn("float").label("cameraFar").setGroup(Ln).onRenderUpdate(({camera:i})=>i.far),Ad=yn("mat4").label("cameraProjectionMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.projectionMatrix),kJ=yn("mat4").label("cameraProjectionMatrixInverse").setGroup(Ln).onRenderUpdate(({camera:i})=>i.projectionMatrixInverse),no=yn("mat4").label("cameraViewMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.matrixWorldInverse),zJ=yn("mat4").label("cameraWorldMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.matrixWorld),GJ=yn("mat3").label("cameraNormalMatrix").setGroup(Ln).onRenderUpdate(({camera:i})=>i.normalMatrix),E9=yn(new pe).label("cameraPosition").setGroup(Ln).onRenderUpdate(({camera:i},e)=>e.value.setFromMatrixPosition(i.matrixWorld));class Ni extends Nn{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Qn.OBJECT,this._uniformNode=new qg(null)}getNodeType(){const e=this.scope;if(e===Ni.WORLD_MATRIX)return"mat4";if(e===Ni.POSITION||e===Ni.VIEW_POSITION||e===Ni.DIRECTION||e===Ni.SCALE)return"vec3"}update(e){const t=this.object3d,n=this._uniformNode,r=this.scope;if(r===Ni.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===Ni.POSITION)n.value=n.value||new pe,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===Ni.SCALE)n.value=n.value||new pe,n.value.setFromMatrixScale(t.matrixWorld);else if(r===Ni.DIRECTION)n.value=n.value||new pe,t.getWorldDirection(n.value);else if(r===Ni.VIEW_POSITION){const s=e.camera;n.value=n.value||new pe,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(s.matrixWorldInverse)}}generate(e){const t=this.scope;return t===Ni.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===Ni.POSITION||t===Ni.VIEW_POSITION||t===Ni.DIRECTION||t===Ni.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Ni.WORLD_MATRIX="worldMatrix";Ni.POSITION="position";Ni.SCALE="scale";Ni.VIEW_POSITION="viewPosition";Ni.DIRECTION="direction";const qJ=gt(Ni,Ni.DIRECTION),VJ=gt(Ni,Ni.WORLD_MATRIX),C9=gt(Ni,Ni.POSITION),jJ=gt(Ni,Ni.SCALE),HJ=gt(Ni,Ni.VIEW_POSITION);class mu extends Ni{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const WJ=Xt(mu,mu.DIRECTION),Ho=Xt(mu,mu.WORLD_MATRIX),$J=Xt(mu,mu.POSITION),XJ=Xt(mu,mu.SCALE),YJ=Xt(mu,mu.VIEW_POSITION),N9=yn(new Xn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),QJ=yn(new jn).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),H0=Ze(i=>i.renderer.nodes.modelViewMatrix||R9).once()().toVar("modelViewMatrix"),R9=no.mul(Ho),KJ=Ze(i=>(i.context.isHighPrecisionModelViewMatrix=!0,yn("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),ZJ=Ze(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return yn("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),ky=Au("position","vec3"),zr=ky.varying("positionLocal"),Z_=ky.varying("positionPrevious"),Tc=Ho.mul(zr).xyz.varying("v_positionWorld").context({needsPositionReassign:!0}),aE=zr.transformDirection(Ho).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection").context({needsPositionReassign:!0}),Xr=Ze(i=>i.context.setupPositionView(),"vec3").once()().varying("v_positionView").context({needsPositionReassign:!0}),hr=Xr.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class JJ extends Nn{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===Ga&&n.side===or?"false":e.getFrontFacing()}}const D9=Xt(JJ),Wg=ye(D9).mul(2).sub(1),zy=Au("normal","vec3"),Ja=Ze(i=>i.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),Ie(0,1,0)):zy,"vec3").once()().toVar("normalLocal"),P9=Xr.dFdx().cross(Xr.dFdy()).normalize().toVar("normalFlat"),Ko=Ze(i=>{let e;return i.material.flatShading===!0?e=P9:e=to(oE(Ja),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Gy=to(Ko.transformDirection(no),"v_normalWorld").normalize().toVar("normalWorld"),kr=Ze(i=>i.context.setupNormal(),"vec3").once()().mul(Wg).toVar("transformedNormalView"),qy=kr.transformDirection(no).toVar("transformedNormalWorld"),HA=Ze(i=>i.context.setupClearcoatNormal(),"vec3").once()().mul(Wg).toVar("transformedClearcoatNormalView"),L9=Ze(([i,e=Ho])=>{const t=ua(e),n=i.div(Ie(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),oE=Ze(([i],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const n=N9.mul(i);return no.transformDirection(n)}),U9=yn(0).onReference(({material:i})=>i).onRenderUpdate(({material:i})=>i.refractionRatio),B9=hr.negate().reflect(kr),O9=hr.negate().refract(kr,U9),I9=B9.transformDirection(no).toVar("reflectVector"),F9=O9.transformDirection(no).toVar("reflectVector");class eee extends pu{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Xo?I9:e.mapping===Yo?F9:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),Ie(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem===cu||!n.isRenderTargetTexture?Ie(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const P0=gt(eee);class lE extends qg{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const $g=(i,e,t)=>wt(new lE(i,e,t));class tee extends dd{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class k9 extends lE{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Rh(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Qn.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;rwt(new k9(i,e)),nee=(i,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),wt(new k9(i,e)));class iee extends dd{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class Vy extends Nn{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Qn.OBJECT}element(e){return wt(new iee(this,wt(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=$g(null,e,this.count):Array.isArray(this.getValueFromReference())?t=vc(null,e):e==="texture"?t=fi(null):e==="cubeTexture"?t=P0(null):t=yn(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let r=1;rwt(new Vy(i,e,t)),Xw=(i,e,t,n)=>wt(new Vy(i,e,n,t));class ree extends Vy{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const _c=(i,e,t=null)=>wt(new ree(i,e,t)),jy=Ze(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),Au("tangent","vec4")))(),Xg=jy.xyz.toVar("tangentLocal"),Yg=H0.mul(_n(Xg,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),z9=Yg.transformDirection(no).varying("v_tangentWorld").normalize().toVar("tangentWorld"),uE=Yg.toVar("transformedTangentView"),see=uE.transformDirection(no).normalize().toVar("transformedTangentWorld"),Qg=i=>i.mul(jy.w).xyz,aee=to(Qg(zy.cross(jy)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),oee=to(Qg(Ja.cross(Xg)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),G9=to(Qg(Ko.cross(Yg)),"v_bitangentView").normalize().toVar("bitangentView"),lee=to(Qg(Gy.cross(z9)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),q9=Qg(kr.cross(uE)).normalize().toVar("transformedBitangentView"),uee=q9.transformDirection(no).normalize().toVar("transformedBitangentWorld"),jf=ua(Yg,G9,Ko),V9=hr.mul(jf),cee=(i,e)=>i.sub(V9.mul(e)),j9=(()=>{let i=Zf.cross(hr);return i=i.cross(Zf).normalize(),i=Ui(i,kr,Th.mul($l.oneMinus()).oneMinus().pow2().pow2()).normalize(),i})(),hee=Ze(i=>{const{eye_pos:e,surf_norm:t,mapN:n,uv:r}=i,s=e.dFdx(),a=e.dFdy(),l=r.dFdx(),u=r.dFdy(),h=t,m=a.cross(h),v=h.cross(s),x=m.mul(l.x).add(v.mul(u.x)),S=m.mul(l.y).add(v.mul(u.y)),T=x.dot(x).max(S.dot(S)),N=Wg.mul(T.inverseSqrt());return Qr(x.mul(n.x,N),S.mul(n.y,N),h.mul(n.z)).normalize()});class fee extends Zr{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Mc}setup(e){const{normalMapType:t,scaleNode:n}=this;let r=this.node.mul(2).sub(1);n!==null&&(r=Ie(r.xy.mul(n),r.z));let s=null;return t===z7?s=oE(r):t===Mc&&(e.hasGeometryAttribute("tangent")===!0?s=jf.mul(r).normalize():s=hee({eye_pos:Xr,surf_norm:Ko,mapN:r,uv:Mr()})),s}}const Yw=gt(fee),dee=Ze(({textureNode:i,bumpScale:e})=>{const t=r=>i.cache().context({getUV:s=>r(s.uvNode||Mr()),forceUVContext:!0}),n=ye(t(r=>r));return Pt(ye(t(r=>r.add(r.dFdx()))).sub(n),ye(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),Aee=Ze(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,l=s.cross(a),u=a.cross(r),h=r.dot(l).mul(Wg),m=h.sign().mul(n.x.mul(l).add(n.y.mul(u)));return h.abs().mul(t).sub(m).normalize()});class pee extends Zr{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=dee({textureNode:this.textureNode,bumpScale:e});return Aee({surf_pos:Xr,surf_norm:Ko,dHdxy:t})}}const H9=gt(pee),IR=new Map;class At extends Nn{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=IR.get(e);return n===void 0&&(n=_c(e,t),IR.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let r=null;if(n===At.COLOR){const s=t.color!==void 0?this.getColor(n):Ie();t.map&&t.map.isTexture===!0?r=s.mul(this.getTexture("map")):r=s}else if(n===At.OPACITY){const s=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=s.mul(this.getTexture("alpha")):r=s}else if(n===At.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=ye(1);else if(n===At.SPECULAR_INTENSITY){const s=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s}else if(n===At.SPECULAR_COLOR){const s=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=s.mul(this.getTexture(n).rgb):r=s}else if(n===At.ROUGHNESS){const s=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).g):r=s}else if(n===At.METALNESS){const s=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=s.mul(this.getTexture(n).b):r=s}else if(n===At.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(n)):r=a}else if(n===At.NORMAL)t.normalMap?(r=Yw(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=H9(this.getTexture("bump").r,this.getFloat("bumpScale")):r=Ko;else if(n===At.CLEARCOAT){const s=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.CLEARCOAT_ROUGHNESS){const s=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=Yw(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=Ko;else if(n===At.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=s.mul(this.getTexture("sheenColor").rgb):r=s}else if(n===At.SHEEN_ROUGHNESS){const s=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=s.mul(this.getTexture(n).a):r=s,r=r.clamp(.07,1)}else if(n===At.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(n);r=Dy(UA.x,UA.y,UA.y.negate(),UA.x).mul(s.rg.mul(2).sub(Pt(1)).normalize().mul(s.b))}else r=UA;else if(n===At.IRIDESCENCE_THICKNESS){const s=zi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=zi("0","float",t.iridescenceThicknessRange);r=s.sub(a).mul(this.getTexture(n).g).add(a)}else r=s}else if(n===At.TRANSMISSION){const s=this.getFloat(n);t.transmissionMap?r=s.mul(this.getTexture(n).r):r=s}else if(n===At.THICKNESS){const s=this.getFloat(n);t.thicknessMap?r=s.mul(this.getTexture(n).g):r=s}else if(n===At.IOR)r=this.getFloat(n);else if(n===At.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===At.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const s=this.getNodeType(e);r=this.getCache(n,s)}return r}}At.ALPHA_TEST="alphaTest";At.COLOR="color";At.OPACITY="opacity";At.SHININESS="shininess";At.SPECULAR="specular";At.SPECULAR_STRENGTH="specularStrength";At.SPECULAR_INTENSITY="specularIntensity";At.SPECULAR_COLOR="specularColor";At.REFLECTIVITY="reflectivity";At.ROUGHNESS="roughness";At.METALNESS="metalness";At.NORMAL="normal";At.CLEARCOAT="clearcoat";At.CLEARCOAT_ROUGHNESS="clearcoatRoughness";At.CLEARCOAT_NORMAL="clearcoatNormal";At.EMISSIVE="emissive";At.ROTATION="rotation";At.SHEEN="sheen";At.SHEEN_ROUGHNESS="sheenRoughness";At.ANISOTROPY="anisotropy";At.IRIDESCENCE="iridescence";At.IRIDESCENCE_IOR="iridescenceIOR";At.IRIDESCENCE_THICKNESS="iridescenceThickness";At.IOR="ior";At.TRANSMISSION="transmission";At.THICKNESS="thickness";At.ATTENUATION_DISTANCE="attenuationDistance";At.ATTENUATION_COLOR="attenuationColor";At.LINE_SCALE="scale";At.LINE_DASH_SIZE="dashSize";At.LINE_GAP_SIZE="gapSize";At.LINE_WIDTH="linewidth";At.LINE_DASH_OFFSET="dashOffset";At.POINT_WIDTH="pointWidth";At.DISPERSION="dispersion";At.LIGHT_MAP="light";At.AO="ao";const W9=Xt(At,At.ALPHA_TEST),$9=Xt(At,At.COLOR),X9=Xt(At,At.SHININESS),Y9=Xt(At,At.EMISSIVE),cE=Xt(At,At.OPACITY),Q9=Xt(At,At.SPECULAR),Qw=Xt(At,At.SPECULAR_INTENSITY),K9=Xt(At,At.SPECULAR_COLOR),Om=Xt(At,At.SPECULAR_STRENGTH),Kv=Xt(At,At.REFLECTIVITY),Z9=Xt(At,At.ROUGHNESS),J9=Xt(At,At.METALNESS),eU=Xt(At,At.NORMAL).context({getUV:null}),tU=Xt(At,At.CLEARCOAT),nU=Xt(At,At.CLEARCOAT_ROUGHNESS),iU=Xt(At,At.CLEARCOAT_NORMAL).context({getUV:null}),rU=Xt(At,At.ROTATION),sU=Xt(At,At.SHEEN),aU=Xt(At,At.SHEEN_ROUGHNESS),oU=Xt(At,At.ANISOTROPY),lU=Xt(At,At.IRIDESCENCE),uU=Xt(At,At.IRIDESCENCE_IOR),cU=Xt(At,At.IRIDESCENCE_THICKNESS),hU=Xt(At,At.TRANSMISSION),fU=Xt(At,At.THICKNESS),dU=Xt(At,At.IOR),AU=Xt(At,At.ATTENUATION_DISTANCE),pU=Xt(At,At.ATTENUATION_COLOR),mU=Xt(At,At.LINE_SCALE),gU=Xt(At,At.LINE_DASH_SIZE),vU=Xt(At,At.LINE_GAP_SIZE),mee=Xt(At,At.LINE_WIDTH),_U=Xt(At,At.LINE_DASH_OFFSET),gee=Xt(At,At.POINT_WIDTH),yU=Xt(At,At.DISPERSION),hE=Xt(At,At.LIGHT_MAP),xU=Xt(At,At.AO),UA=yn(new bt).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),fE=Ze(i=>i.context.setupModelViewProjection(),"vec4").once()().varying("v_modelViewProjection");class fr extends Nn{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===fr.VERTEX)r=e.getVertexIndex();else if(n===fr.INSTANCE)r=e.getInstanceIndex();else if(n===fr.DRAW)r=e.getDrawIndex();else if(n===fr.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===fr.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===fr.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=r:s=to(this).build(e,t),s}}fr.VERTEX="vertex";fr.INSTANCE="instance";fr.SUBGROUP="subgroup";fr.INVOCATION_LOCAL="invocationLocal";fr.INVOCATION_SUBGROUP="invocationSubgroup";fr.DRAW="draw";const bU=Xt(fr,fr.VERTEX),Kg=Xt(fr,fr.INSTANCE),vee=Xt(fr,fr.SUBGROUP),_ee=Xt(fr,fr.INVOCATION_SUBGROUP),yee=Xt(fr,fr.INVOCATION_LOCAL),SU=Xt(fr,fr.DRAW);class wU extends Nn{static get type(){return"InstanceNode"}constructor(e,t,n){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Qn.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{count:t,instanceMatrix:n,instanceColor:r}=this;let{instanceMatrixNode:s,instanceColorNode:a}=this;if(s===null){if(t<=1e3)s=$g(n.array,"mat4",Math.max(t,1)).element(Kg);else{const u=new u_(n.array,16,1);this.buffer=u;const h=n.usage===IA?$w:K_,m=[h(u,"vec4",16,0),h(u,"vec4",16,4),h(u,"vec4",16,8),h(u,"vec4",16,12)];s=Kf(...m)}this.instanceMatrixNode=s}if(r&&a===null){const u=new Bg(r.array,3),h=r.usage===IA?$w:K_;this.bufferColor=u,a=Ie(h(u,"vec3",3,0)),this.instanceColorNode=a}const l=s.mul(zr).xyz;if(zr.assign(l),e.hasGeometryAttribute("normal")){const u=L9(Ja,s);Ja.assign(u)}this.instanceColorNode!==null&&xg("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==IA&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==IA&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const xee=gt(wU);class bee extends wU{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const TU=gt(bee);class See extends Nn{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=Kg:this.batchingIdNode=SU);const n=Ze(([T])=>{const N=Uh(Ir(this.batchMesh._indirectTexture),0),C=Ee(T).modInt(Ee(N)),E=Ee(T).div(Ee(N));return Ir(this.batchMesh._indirectTexture,As(C,E)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(Ee(this.batchingIdNode)),r=this.batchMesh._matricesTexture,s=Uh(Ir(r),0),a=ye(n).mul(4).toInt().toVar(),l=a.modInt(s),u=a.div(Ee(s)),h=Kf(Ir(r,As(l,u)),Ir(r,As(l.add(1),u)),Ir(r,As(l.add(2),u)),Ir(r,As(l.add(3),u))),m=this.batchMesh._colorsTexture;if(m!==null){const N=Ze(([C])=>{const E=Uh(Ir(m),0).x,O=C,U=O.modInt(E),I=O.div(E);return Ir(m,As(U,I)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);xg("vec3","vBatchColor").assign(N)}const v=ua(h);zr.assign(h.mul(zr));const x=Ja.div(Ie(v[0].dot(v[0]),v[1].dot(v[1]),v[2].dot(v[2]))),S=v.mul(x).xyz;Ja.assign(S),e.hasGeometryAttribute("tangent")&&Xg.mulAssign(v)}}const MU=gt(See),FR=new WeakMap;class EU extends Nn{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=Qn.OBJECT,this.skinIndexNode=Au("skinIndex","uvec4"),this.skinWeightNode=Au("skinWeight","vec4");let n,r,s;t?(n=zi("bindMatrix","mat4"),r=zi("bindMatrixInverse","mat4"),s=Xw("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=yn(e.bindMatrix,"mat4"),r=yn(e.bindMatrixInverse,"mat4"),s=$g(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=r,this.boneMatricesNode=s,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=zr){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w),v=s.mul(t),x=Qr(l.mul(r.x).mul(v),u.mul(r.y).mul(v),h.mul(r.z).mul(v),m.mul(r.w).mul(v));return a.mul(x).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Ja){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:s,bindMatrixInverseNode:a}=this,l=e.element(n.x),u=e.element(n.y),h=e.element(n.z),m=e.element(n.w);let v=Qr(r.x.mul(l),r.y.mul(u),r.z.mul(h),r.w.mul(m));return v=a.mul(v).mul(s),v.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Xw("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Z_)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||qP(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Z_.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(zr.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();Ja.assign(n),e.hasGeometryAttribute("tangent")&&Xg.assign(n)}}generate(e,t){if(t!=="void")return zr.build(e,t)}update(e){const n=(this.useReference?e.object:this.skinnedMesh).skeleton;FR.get(n)!==e.frameId&&(FR.set(n,e.frameId),this.previousBoneMatricesNode!==null&&n.previousBoneMatrices.set(n.boneMatrices),n.update())}}const wee=i=>wt(new EU(i)),CU=i=>wt(new EU(i,!0));class Tee extends Nn{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let s=0,a=this.params.length-1;sNumber(v)?T=">=":T="<"));const C={start:m,end:v},E=C.start,O=C.end;let U="",I="",j="";N||(S==="int"||S==="uint"?T.includes("<")?N="++":N="--":T.includes("<")?N="+= 1.":N="-= 1."),U+=e.getVar(S,x)+" = "+E,I+=x+" "+T+" "+O,j+=x+" "+N;const z=`for ( ${U}; ${I}; ${j} )`;e.addFlowCode((l===0?` `:"")+e.tab+z+` { `).addFlowTab()}const s=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(` `+e.tab+s);for(let l=0,u=this.params.length-1;lwt(new Tee(Qf(i,"int"))).append(),Mee=()=>zh("continue").append(),NU=()=>zh("break").append(),Eee=(...i)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),Bi(...i)),X3=new WeakMap,po=new On,kR=Ke(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const a=Ee(bU).mul(t).add(s),l=a.div(n),u=a.sub(l.mul(n));return Ir(i,As(u,l)).depth(r).mul(e)});function Cee(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let a=X3.get(i);if(a===void 0||a.count!==s){let O=function(){C.dispose(),X3.delete(i),i.removeEventListener("dispose",O)};var l=O;a!==void 0&&a.texture.dispose();const u=i.morphAttributes.position||[],h=i.morphAttributes.normal||[],m=i.morphAttributes.color||[];let v=0;e===!0&&(v=1),t===!0&&(v=2),n===!0&&(v=3);let x=i.attributes.position.count*v,S=1;const T=4096;x>T&&(S=Math.ceil(x/T),x=T);const N=new Float32Array(x*S*4*s),C=new XT(N,x,S,s);C.type=$r,C.needsUpdate=!0;const E=v*4;for(let U=0;U{const x=xe(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?x.assign(Ir(this.mesh.morphTexture,As(Ee(v).add(1),Ee(Kg))).r):x.assign(zi("morphTargetInfluences","float").element(v).toVar()),n===!0&&zr.addAssign(kR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:Ee(0)})),r===!0&&Ja.addAssign(kR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:Ee(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const RU=gt(Nee);class W0 extends Nn{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Ree extends W0{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Dee extends i9{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=Ie().toVar("directDiffuse"),r=Ie().toVar("directSpecular"),s=Ie().toVar("indirectDiffuse"),a=Ie().toVar("indirectSpecular"),l={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:Ie().toVar("radiance"),irradiance:Ie().toVar("irradiance"),iblIrradiance:Ie().toVar("iblIrradiance"),ambientOcclusion:xe(1).toVar("ambientOcclusion"),reflectedLight:l,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const DU=gt(Dee);class Pee extends W0{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let im,rm;class ss extends Nn{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ss.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Qn.NONE;return(this.scope===ss.SIZE||this.scope===ss.VIEWPORT)&&(e=Qn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ss.VIEWPORT?t!==null?rm.copy(t.viewport):(e.getViewport(rm),rm.multiplyScalar(e.getPixelRatio())):t!==null?(im.width=t.width,im.height=t.height):e.getDrawingBufferSize(im)}setup(){const e=this.scope;let t=null;return e===ss.SIZE?t=yn(im||(im=new bt)):e===ss.VIEWPORT?t=yn(rm||(rm=new On)):t=Lt(Zg.div(Eg)),t}generate(e){if(this.scope===ss.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(Eg).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}ss.COORDINATE="coordinate";ss.VIEWPORT="viewport";ss.SIZE="size";ss.UV="uv";const gu=$t(ss,ss.UV),Eg=$t(ss,ss.SIZE),Zg=$t(ss,ss.COORDINATE),dE=$t(ss,ss.VIEWPORT),PU=dE.zw,LU=Zg.sub(dE.xy),Lee=LU.div(PU),Uee=Ke(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),Eg),"vec2").once()(),Bee=Ke(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),gu),"vec2").once()(),Oee=Ke(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),gu.flipY()),"vec2").once()(),sm=new bt;class Hy extends pu{static get type(){return"ViewportTextureNode"}constructor(e=gu,t=null,n=null){n===null&&(n=new Q7,n.minFilter=za),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Qn.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(sm);const n=this.value;(n.image.width!==sm.width||n.image.height!==sm.height)&&(n.image.width=sm.width,n.image.height=sm.height,n.needsUpdate=!0);const r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Iee=gt(Hy),AE=gt(Hy,null,null,{generateMipmaps:!0});let Y3=null;class Fee extends Hy{static get type(){return"ViewportDepthTextureNode"}constructor(e=gu,t=null){Y3===null&&(Y3=new Ic),super(e,t,Y3)}}const pE=gt(Fee);class Ha extends Nn{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Ha.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===Ha.DEPTH_BASE)n!==null&&(r=BU().assign(n));else if(t===Ha.DEPTH)e.isPerspectiveCamera?r=UU(Xr.z,Eh,Ch):r=e0(Xr.z,Eh,Ch);else if(t===Ha.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const s=mE(n,Eh,Ch);r=e0(s,Eh,Ch)}else r=n;else r=e0(Xr.z,Eh,Ch);return r}}Ha.DEPTH_BASE="depthBase";Ha.DEPTH="depth";Ha.LINEAR_DEPTH="linearDepth";const e0=(i,e,t)=>i.add(e).div(e.sub(t)),kee=(i,e,t)=>e.sub(t).mul(i).sub(e),UU=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),mE=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),gE=(i,e,t)=>{e=e.max(1e-6).toVar();const n=su(i.negate().div(e)),r=su(t.div(e));return n.div(r)},zee=(i,e,t)=>{const n=i.mul(Uy(t.div(e)));return xe(Math.E).pow(n).mul(e).negate()},BU=gt(Ha,Ha.DEPTH_BASE),vE=$t(Ha,Ha.DEPTH),J_=gt(Ha,Ha.LINEAR_DEPTH),Gee=J_(pE());vE.assign=i=>BU(i);class qee extends Nn{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Vee=gt(qee);class $o extends Nn{static get type(){return"ClippingNode"}constructor(e=$o.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===$o.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===$o.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return Ke(()=>{const n=xe().toVar("distanceToPlane"),r=xe().toVar("distanceToGradient"),s=xe(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=vc(t);Bi(a,({i:h})=>{const m=u.element(h);n.assign(Xr.dot(m.xyz).negate().add(m.w)),r.assign(n.fwidth().div(2)),s.mulAssign(Uc(r.negate(),r,n))})}const l=e.length;if(l>0){const u=vc(e),h=xe(1).toVar("intersectionClipOpacity");Bi(l,({i:m})=>{const v=u.element(m);n.assign(Xr.dot(v.xyz).negate().add(v.w)),r.assign(n.fwidth().div(2)),h.mulAssign(Uc(r.negate(),r,n).oneMinus())}),s.mulAssign(h.oneMinus())}Ri.a.mulAssign(s),Ri.a.equal(0).discard()})()}setupDefault(e,t){return Ke(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const s=vc(t);Bi(n,({i:a})=>{const l=s.element(a);Xr.dot(l.xyz).greaterThan(l.w).discard()})}const r=e.length;if(r>0){const s=vc(e),a=Pc(!0).toVar("clipped");Bi(r,({i:l})=>{const u=s.element(l);a.assign(Xr.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Ke(()=>{const r=vc(e),s=Vee(t.getClipDistance());Bi(n,({i:a})=>{const l=r.element(a),u=Xr.dot(l.xyz).sub(l.w).negate();s.element(a).assign(u)})})()}}$o.ALPHA_TO_COVERAGE="alphaToCoverage";$o.DEFAULT="default";$o.HARDWARE="hardware";const jee=()=>wt(new $o),Hee=()=>wt(new $o($o.ALPHA_TO_COVERAGE)),Wee=()=>wt(new $o($o.HARDWARE)),$ee=.05,zR=Ke(([i])=>kc(Kn(1e4,So(Kn(17,i.x).add(Kn(.1,i.y)))).mul(Qr(.1,rr(So(Kn(13,i.y).add(i.x))))))),GR=Ke(([i])=>zR(Lt(zR(i.xy),i.z))),Xee=Ke(([i])=>{const e=Gr(wc(KM(i.xyz)),wc(ZM(i.xyz))),t=xe(1).div(xe($ee).mul(e)).toVar("pixScale"),n=Lt(D0(au(su(t))),D0(By(su(t)))),r=Lt(GR(au(n.x.mul(i.xyz))),GR(au(n.y.mul(i.xyz)))),s=kc(su(t)),a=Qr(Kn(s.oneMinus(),r.x),Kn(s,r.y)),l=Za(s,s.oneMinus()),u=Ie(a.mul(a).div(Kn(2,l).mul(yi(1,l))),a.sub(Kn(.5,l)).div(yi(1,l)),yi(1,yi(1,a).mul(yi(1,a)).div(Kn(2,l).mul(yi(1,l))))),h=a.lessThan(l.oneMinus()).select(a.lessThan(l).select(u.x,u.y),u.z);return du(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class qr extends oa{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+IP(this)}build(e){this.setup(e)}setupObserver(e){return new HZ(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const r=this.vertexNode||this.setupVertex(e);e.stack.outputNode=r,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let s;const a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);a!==null&&e.stack.add(a);const u=_n(l,Ri.a).max(0);if(s=this.setupOutput(e,u),Tg.assign(s),this.outputNode!==null&&(s=this.outputNode),n!==null){const h=t.getMRT(),m=this.mrtNode;h!==null?(s=h,m!==null&&(s=h.merge(m))):m!==null&&(s=m)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=_n(l)),s=this.setupOutput(e,l)}e.stack.outputNode=s,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=Hee():e.stack.add(jee())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Wee()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=gE(Xr.z,Eh,Ch):r=e0(Xr.z,Eh,Ch))}r!==null&&vE.assign(r).append()}setupPositionView(){return H0.mul(zr).xyz}setupModelViewProjection(){return Ad.mul(Xr)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),fE}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&RU(t).append(),t.isSkinnedMesh===!0&&CU(t).append(),this.displacementMap){const r=_c("displacementMap","texture"),s=_c("displacementScale","float"),a=_c("displacementBias","float");zr.addAssign(Ja.normalize().mul(r.x.mul(s).add(a)))}return t.isBatchedMesh&&MU(t).append(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&TU(t).append(),this.positionNode!==null&&zr.assign(this.positionNode.context({isPositionNodeInput:!0})),zr}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?_n(this.colorNode):$9;this.vertexColors===!0&&t.hasAttribute("color")&&(n=_n(n.xyz.mul(Au("color","vec3")),n.a)),e.instanceColor&&(n=xg("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=xg("vec3","vBatchColor").mul(n)),Ri.assign(n);const r=this.opacityNode?xe(this.opacityNode):cE;if(Ri.a.assign(Ri.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?xe(this.alphaTestNode):W9;Ri.a.lessThanEqual(s).discard()}this.alphaHash===!0&&Ri.a.lessThan(Xee(zr)).discard(),this.transparent===!1&&this.blending===Xa&&this.alphaToCoverage===!1&&Ri.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Ie(0):Ri.rgb}setupNormal(){return this.normalNode?Ie(this.normalNode):eU}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?_c("envMap","cubeTexture"):_c("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Pee(hE)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:xU;t.push(new Ree(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:s}=this,l=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(l&&l.getScope().hasLights){const h=this.setupLightingModel(e);u=DU(l,h,n,r)}else n!==null&&(u=Ie(r!==null?Ui(u,n,r):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Hw.assign(Ie(s||Y9)),u=u.add(Hw)),u}setupOutput(e,t){if(this.fog===!0){const n=e.fogNode;n&&(Tg.assign(t),t=_n(n))}return t}setDefaultValues(e){for(const n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=oa.prototype.toJSON.call(this,e),r=H_(this);n.inputNodes={};for(const{property:a,childNode:l}of r)n.inputNodes[a]=l.toJSON(e).uuid;function s(a){const l=[];for(const u in a){const h=a[u];delete h.metadata,l.push(h)}return l}if(t){const a=s(e.textures),l=s(e.images),u=s(e.nodes);a.length>0&&(n.textures=a),l.length>0&&(n.images=l),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const Yee=new q0;class Qee extends qr{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Yee),this.setValues(e)}}const Kee=new kz;class Zee extends qr{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Kee),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?xe(this.offsetNode):_U,t=this.dashScaleNode?xe(this.dashScaleNode):mU,n=this.dashSizeNode?xe(this.dashSizeNode):gU,r=this.gapSizeNode?xe(this.gapSizeNode):vU;Xv.assign(n),Ww.assign(r);const s=to(Au("lineDistance").mul(t));(e?s.add(e):s).mod(Xv.add(Ww)).greaterThan(Xv).discard()}}let Q3=null;class Jee extends Hy{static get type(){return"ViewportSharedTextureNode"}constructor(e=gu,t=null){Q3===null&&(Q3=new Q7),super(e,t,Q3)}updateReference(){return this}}const ete=gt(Jee),OU=i=>wt(i).mul(.5).add(.5),tte=i=>wt(i).mul(2).sub(1),nte=new Bz;class ite extends qr{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(nte),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?xe(this.opacityNode):cE;Ri.assign(_n(OU(kr),e))}}class rte extends Zr{static get type(){return"EquirectUVNode"}constructor(e=aE){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Lt(t,n)}}const _E=gt(rte);class IU extends X7{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new Vh(5,5,5),a=_E(aE),l=new qr;l.colorNode=fi(t,a,0),l.side=or,l.blending=$a;const u=new Oi(s,l),h=new ZT;h.add(u),t.minFilter===za&&(t.minFilter=ps);const m=new $7(1,10,this),v=e.getMRT();return e.setMRT(null),m.update(e,h),e.setMRT(v),t.minFilter=n,t.currentGenerateMipmaps=r,u.geometry.dispose(),u.material.dispose(),this}}const Im=new WeakMap;class ste extends Zr{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=P0();const t=new vy;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Qn.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:n[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===Oh||a===Ih){if(Im.has(s)){const l=Im.get(s);qR(l,s.mapping),this._cubeTexture=l}else{const l=s.image;if(ate(l)){const u=new IU(l.height);u.fromEquirectangularTexture(t,s),qR(u.texture,s.mapping),this._cubeTexture=u.texture,Im.set(s,u.texture),s.addEventListener("dispose",FU)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function ate(i){return i==null?!1:i.height>0}function FU(i){const e=i.target;e.removeEventListener("dispose",FU);const t=Im.get(e);t!==void 0&&(Im.delete(e),t.dispose())}function qR(i,e){e===Oh?i.mapping=Xo:e===Ih&&(i.mapping=Yo)}const kU=gt(ste);class yE extends W0{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=kU(this.envNode)}}class ote extends W0{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=xe(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Wy{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class zU extends Wy{constructor(){super()}indirect(e,t,n){const r=e.ambientOcclusion,s=e.reflectedLight,a=n.context.irradianceLightMap;s.indirectDiffuse.assign(_n(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(_n(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Ri.rgb)}finish(e,t,n){const r=n.material,s=e.outgoingLight,a=n.context.environment;if(a)switch(r.combine){case Dg:s.rgb.assign(Ui(s.rgb,s.rgb.mul(a.rgb),Om.mul(Kv)));break;case P7:s.rgb.assign(Ui(s.rgb,a.rgb,Om.mul(Kv)));break;case L7:s.rgb.addAssign(a.rgb.mul(Om.mul(Kv)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const lte=new cd;class ute extends qr{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lte),this.setValues(e)}setupNormal(){return Ko}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ote(hE)),t}setupOutgoingLight(){return Ri.rgb}setupLightingModel(){return new zU}}const L0=Ke(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),ld=Ke(i=>i.diffuseColor.mul(1/Math.PI)),cte=()=>xe(.25),hte=Ke(({dotNH:i})=>X_.mul(xe(.5)).add(1).mul(xe(1/Math.PI)).mul(i.pow(X_))),fte=Ke(({lightDirection:i})=>{const e=i.add(hr).normalize(),t=kr.dot(e).clamp(),n=hr.dot(e).clamp(),r=L0({f0:Oa,f90:1,dotVH:n}),s=cte(),a=hte({dotNH:t});return r.mul(s).mul(a)});class GU extends zU{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=kr.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(ld({diffuseColor:Ri.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(fte({lightDirection:e})).mul(Om))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(ld({diffuseColor:Ri}))),n.indirectDiffuse.mulAssign(e)}}const dte=new Fc;class Ate extends qr{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(dte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightingModel(){return new GU(!1)}}const pte=new oD;class mte extends qr{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(pte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightingModel(){return new GU}setupVariants(){const e=(this.shininessNode?xe(this.shininessNode):X9).max(1e-4);X_.assign(e);const t=this.specularNode||Q9;Oa.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const qU=Ke(i=>{if(i.geometry.hasAttribute("normal")===!1)return xe(0);const e=Ko.dFdx().abs().max(Ko.dFdy().abs());return e.x.max(e.y).max(e.z)}),xE=Ke(i=>{const{roughness:e}=i,t=qU();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),VU=Ke(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Cl(.5,r.add(s).max(NL))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),gte=Ke(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:s,dotNV:a,dotNL:l})=>{const u=l.mul(Ie(i.mul(t),e.mul(n),a).length()),h=a.mul(Ie(i.mul(r),e.mul(s),l).length());return Cl(.5,u.add(h)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),jU=Ke(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),vte=xe(1/Math.PI),_te=Ke(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const s=i.mul(e),a=Ie(e.mul(n),i.mul(r),s.mul(t)),l=a.dot(a),u=s.div(l);return vte.mul(s.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),Kw=Ke(i=>{const{lightDirection:e,f0:t,f90:n,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:l}=i,u=i.normalView||kr,h=r.pow2(),m=e.add(hr).normalize(),v=u.dot(e).clamp(),x=u.dot(hr).clamp(),S=u.dot(m).clamp(),T=hr.dot(m).clamp();let N=L0({f0:t,f90:n,dotVH:T}),C,E;if(_g(a)&&(N=Ly.mix(N,s)),_g(l)){const O=Lm.dot(e),U=Lm.dot(hr),I=Lm.dot(m),j=Zf.dot(e),z=Zf.dot(hr),G=Zf.dot(m);C=gte({alphaT:$_,alphaB:h,dotTV:U,dotBV:z,dotTL:O,dotBL:j,dotNV:x,dotNL:v}),E=_te({alphaT:$_,alphaB:h,dotNH:S,dotTH:I,dotBH:G})}else C=VU({alpha:h,dotNL:v,dotNV:x}),E=jU({alpha:h,dotNH:S});return N.mul(C).mul(E)}),bE=Ke(({roughness:i,dotNV:e})=>{const t=_n(-1,-.0275,-.572,.022),n=_n(1,.0425,1.04,-.04),r=i.mul(t).add(n),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return Lt(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),HU=Ke(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,s=bE({dotNV:e,roughness:r});return t.mul(s.x).add(n.mul(s.y))}),WU=Ke(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),s=n.mul(r,r).clamp(0,.9999);return i.sub(Ie(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),yte=Ke(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=xe(1).div(t),s=e.pow2().oneMinus().max(.0078125);return xe(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),xte=Ke(({dotNV:i,dotNL:e})=>xe(1).div(xe(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),bte=Ke(({lightDirection:i})=>{const e=i.add(hr).normalize(),t=kr.dot(i).clamp(),n=kr.dot(hr).clamp(),r=kr.dot(e).clamp(),s=yte({roughness:Py,dotNH:r}),a=xte({dotNV:n,dotNL:t});return Vf.mul(s).mul(a)}),Ste=Ke(({N:i,V:e,roughness:t})=>{const s=.0078125,a=i.dot(e).saturate(),l=Lt(t,a.oneMinus().sqrt());return l.assign(l.mul(.984375).add(s)),l}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),wte=Ke(({f:i})=>{const e=i.length();return Gr(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),ov=Ke(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=r.div(s),l=t.greaterThan(0).select(a,Gr(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return i.cross(e).mul(l)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),VR=Ke(({N:i,V:e,P:t,mInv:n,p0:r,p1:s,p2:a,p3:l})=>{const u=s.sub(r).toVar(),h=l.sub(r).toVar(),m=u.cross(h),v=Ie().toVar();return ii(m.dot(t.sub(r)).greaterThanEqual(0),()=>{const x=e.sub(i.mul(e.dot(i))).normalize(),S=i.cross(x).negate(),T=n.mul(ua(x,S,i).transpose()).toVar(),N=T.mul(r.sub(t)).normalize().toVar(),C=T.mul(s.sub(t)).normalize().toVar(),E=T.mul(a.sub(t)).normalize().toVar(),O=T.mul(l.sub(t)).normalize().toVar(),U=Ie(0).toVar();U.addAssign(ov({v1:N,v2:C})),U.addAssign(ov({v1:C,v2:E})),U.addAssign(ov({v1:E,v2:O})),U.addAssign(ov({v1:O,v2:N})),v.assign(Ie(wte({f:U})))}),v}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),$y=1/6,$U=i=>Kn($y,Kn(i,Kn(i,i.negate().add(3)).sub(3)).add(1)),Zw=i=>Kn($y,Kn(i,Kn(i,Kn(3,i).sub(6))).add(4)),XU=i=>Kn($y,Kn(i,Kn(i,Kn(-3,i).add(3)).add(3)).add(1)),Jw=i=>Kn($y,Tl(i,3)),jR=i=>$U(i).add(Zw(i)),HR=i=>XU(i).add(Jw(i)),WR=i=>Qr(-1,Zw(i).div($U(i).add(Zw(i)))),$R=i=>Qr(1,Jw(i).div(XU(i).add(Jw(i)))),XR=(i,e,t)=>{const n=i.uvNode,r=Kn(n,e.zw).add(.5),s=au(r),a=kc(r),l=jR(a.x),u=HR(a.x),h=WR(a.x),m=$R(a.x),v=WR(a.y),x=$R(a.y),S=Lt(s.x.add(h),s.y.add(v)).sub(.5).mul(e.xy),T=Lt(s.x.add(m),s.y.add(v)).sub(.5).mul(e.xy),N=Lt(s.x.add(h),s.y.add(x)).sub(.5).mul(e.xy),C=Lt(s.x.add(m),s.y.add(x)).sub(.5).mul(e.xy),E=jR(a.y).mul(Qr(l.mul(i.sample(S).level(t)),u.mul(i.sample(T).level(t)))),O=HR(a.y).mul(Qr(l.mul(i.sample(N).level(t)),u.mul(i.sample(C).level(t))));return E.add(O)},YU=Ke(([i,e=xe(3)])=>{const t=Lt(i.size(Ee(e))),n=Lt(i.size(Ee(e.add(1)))),r=Cl(1,t),s=Cl(1,n),a=XR(i,_n(r,t),au(e)),l=XR(i,_n(s,n),By(e));return kc(e).mix(a,l)}),YR=Ke(([i,e,t,n,r])=>{const s=Ie(nE(e.negate(),Lc(i),Cl(1,n))),a=Ie(wc(r[0].xyz),wc(r[1].xyz),wc(r[2].xyz));return Lc(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Tte=Ke(([i,e])=>i.mul(du(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Mte=AE(),Ete=AE(),QR=Ke(([i,e,t],{material:n})=>{const s=(n.side===or?Mte:Ete).sample(i),a=su(Eg.x).mul(Tte(e,t));return YU(s,a)}),KR=Ke(([i,e,t])=>(ii(t.notEqual(0),()=>{const n=Uy(e).negate().div(t);return XM(n.negate().mul(i))}),Ie(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Cte=Ke(([i,e,t,n,r,s,a,l,u,h,m,v,x,S,T])=>{let N,C;if(T){N=_n().toVar(),C=Ie().toVar();const j=m.sub(1).mul(T.mul(.025)),z=Ie(m.sub(j),m,m.add(j));Bi({start:0,end:3},({i:G})=>{const H=z.element(G),q=YR(i,e,v,H,l),V=a.add(q),Q=h.mul(u.mul(_n(V,1))),J=Lt(Q.xy.div(Q.w)).toVar();J.addAssign(1),J.divAssign(2),J.assign(Lt(J.x,J.y.oneMinus()));const ne=QR(J,t,H);N.element(G).assign(ne.element(G)),N.a.addAssign(ne.a),C.element(G).assign(n.element(G).mul(KR(wc(q),x,S).element(G)))}),N.a.divAssign(3)}else{const j=YR(i,e,v,m,l),z=a.add(j),G=h.mul(u.mul(_n(z,1))),H=Lt(G.xy.div(G.w)).toVar();H.addAssign(1),H.divAssign(2),H.assign(Lt(H.x,H.y.oneMinus())),N=QR(H,t,m),C=n.mul(KR(wc(j),x,S))}const E=C.rgb.mul(N.rgb),O=i.dot(e).clamp(),U=Ie(HU({dotNV:O,specularColor:r,specularF90:s,roughness:t})),I=C.r.add(C.g,C.b).div(3);return _n(U.oneMinus().mul(E),N.a.oneMinus().mul(I).oneMinus())}),Nte=ua(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Rte=i=>{const e=i.sqrt();return Ie(1).add(e).div(Ie(1).sub(e))},ZR=(i,e)=>i.sub(e).div(i.add(e)).pow2(),Dte=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=Ie(54856e-17,44201e-17,52481e-17),r=Ie(1681e3,1795300,2208400),s=Ie(43278e5,93046e5,66121e5),a=xe(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let l=n.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return l=Ie(l.x.add(a),l.y,l.z).div(10685e-11),Nte.mul(l)},Pte=Ke(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const s=Ui(i,e,Uc(0,.03,n)),l=i.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();ii(l.lessThan(0),()=>Ie(1));const u=l.sqrt(),h=ZR(s,i),m=L0({f0:h,f90:1,dotVH:t}),v=m.oneMinus(),x=s.lessThan(i).select(Math.PI,0),S=xe(Math.PI).sub(x),T=Rte(r.clamp(0,.9999)),N=ZR(T,s.toVec3()),C=L0({f0:N,f90:1,dotVH:u}),E=Ie(T.x.lessThan(s).select(Math.PI,0),T.y.lessThan(s).select(Math.PI,0),T.z.lessThan(s).select(Math.PI,0)),O=s.mul(n,u,2),U=Ie(S).add(E),I=m.mul(C).clamp(1e-5,.9999),j=I.sqrt(),z=v.pow2().mul(C).div(Ie(1).sub(I)),H=m.add(z).toVar(),q=z.sub(v).toVar();return Bi({start:1,end:2,condition:"<=",name:"m"},({m:V})=>{q.mulAssign(j);const Q=Dte(xe(V).mul(O),xe(V).mul(U)).mul(2);H.addAssign(q.mul(Q))}),H.max(Ie(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Lte=Ke(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.pow2(),s=zs(t.lessThan(.25),xe(-339.2).mul(r).add(xe(161.4).mul(t)).sub(25.9),xe(-8.48).mul(r).add(xe(14.3).mul(t)).sub(9.95)),a=zs(t.lessThan(.25),xe(44).mul(r).sub(xe(23.7).mul(t)).add(3.26),xe(1.97).mul(r).sub(xe(3.27).mul(t)).add(.72));return zs(t.lessThan(.25),0,xe(.1).mul(t).sub(.025)).add(s.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),K3=Ie(.04),Z3=xe(1);class QU extends Wy{constructor(e=!1,t=!1,n=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Ie().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Ie().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Ie().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=Ie().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Ie().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=kr.dot(hr).clamp();this.iridescenceFresnel=Pte({outsideIOR:xe(1),eta2:kM,cosTheta1:t,thinFilmThickness:zM,baseF0:Oa}),this.iridescenceF0=WU({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Tc,n=E9.sub(Tc).normalize(),r=qy;e.backdrop=Cte(r,n,$l,Ri,Oa,wg,t,Ho,no,Ad,Um,GM,VM,qM,this.dispersion?jM:null),e.backdropAlpha=Y_,Ri.a.mulAssign(Ui(1,e.backdrop.a,Y_))}}computeMultiscattering(e,t,n){const r=kr.dot(hr).clamp(),s=bE({roughness:$l,dotNV:r}),l=(this.iridescenceF0?Ly.mix(Oa,this.iridescenceF0):Oa).mul(s.x).add(n.mul(s.y)),h=s.x.add(s.y).oneMinus(),m=Oa.add(Oa.oneMinus().mul(.047619)),v=l.mul(m).div(h.mul(m).oneMinus());e.addAssign(l),t.addAssign(v.mul(h))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=kr.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(s.mul(bte({lightDirection:e}))),this.clearcoat===!0){const l=HA.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(l.mul(Kw({lightDirection:e,f0:K3,f90:Z3,roughness:Sg,normalView:HA})))}n.directDiffuse.addAssign(s.mul(ld({diffuseColor:Ri.rgb}))),n.directSpecular.addAssign(s.mul(Kw({lightDirection:e,f0:Oa,f90:1,roughness:$l,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:l}){const u=t.add(n).sub(r),h=t.sub(n).sub(r),m=t.sub(n).add(r),v=t.add(n).add(r),x=kr,S=hr,T=Xr.toVar(),N=Ste({N:x,V:S,roughness:$l}),C=a.sample(N).toVar(),E=l.sample(N).toVar(),O=ua(Ie(C.x,0,C.y),Ie(0,1,0),Ie(C.z,0,C.w)).toVar(),U=Oa.mul(E.x).add(Oa.oneMinus().mul(E.y)).toVar();s.directSpecular.addAssign(e.mul(U).mul(VR({N:x,V:S,P:T,mInv:O,p0:u,p1:h,p2:m,p3:v}))),s.directDiffuse.addAssign(e.mul(Ri).mul(VR({N:x,V:S,P:T,mInv:ua(1,0,0,0,1,0,0,0,1),p0:u,p1:h,p2:m,p3:v})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(ld({diffuseColor:Ri})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Vf,Lte({normal:kr,viewDir:hr,roughness:Py}))),this.clearcoat===!0){const h=HA.dot(hr).clamp(),m=HU({dotNV:h,specularColor:K3,specularF90:Z3,roughness:Sg});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const r=Ie().toVar("singleScattering"),s=Ie().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,wg);const l=r.add(s),u=Ri.mul(l.r.max(l.g).max(l.b).oneMinus());n.indirectSpecular.addAssign(e.mul(r)),n.indirectSpecular.addAssign(s.mul(a)),n.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const r=kr.dot(hr).clamp().add(e),s=$l.mul(-16).oneMinus().negate().exp2(),a=e.sub(r.pow(s).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(a)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=HA.dot(hr).clamp(),r=L0({dotVH:n,f0:K3,f90:Z3}),s=t.mul(W_.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(W_));t.assign(s)}if(this.sheen===!0){const n=Vf.r.max(Vf.g).max(Vf.b).mul(.157).oneMinus(),r=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const JR=xe(1),eT=xe(-2),lv=xe(.8),J3=xe(-1),uv=xe(.4),eS=xe(2),cv=xe(.305),tS=xe(3),e6=xe(.21),Ute=xe(4),t6=xe(4),Bte=xe(16),Ote=Ke(([i])=>{const e=Ie(rr(i)).toVar(),t=xe(-1).toVar();return ii(e.x.greaterThan(e.z),()=>{ii(e.x.greaterThan(e.y),()=>{t.assign(zs(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(zs(i.y.greaterThan(0),1,4))})}).Else(()=>{ii(e.z.greaterThan(e.y),()=>{t.assign(zs(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(zs(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Ite=Ke(([i,e])=>{const t=Lt().toVar();return ii(e.equal(0),()=>{t.assign(Lt(i.z,i.y).div(rr(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Lt(i.x.negate(),i.z.negate()).div(rr(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Lt(i.x.negate(),i.y).div(rr(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Lt(i.z.negate(),i.y).div(rr(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Lt(i.x.negate(),i.z).div(rr(i.y)))}).Else(()=>{t.assign(Lt(i.x,i.y).div(rr(i.z)))}),Kn(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Fte=Ke(([i])=>{const e=xe(0).toVar();return ii(i.greaterThanEqual(lv),()=>{e.assign(JR.sub(i).mul(J3.sub(eT)).div(JR.sub(lv)).add(eT))}).ElseIf(i.greaterThanEqual(uv),()=>{e.assign(lv.sub(i).mul(eS.sub(J3)).div(lv.sub(uv)).add(J3))}).ElseIf(i.greaterThanEqual(cv),()=>{e.assign(uv.sub(i).mul(tS.sub(eS)).div(uv.sub(cv)).add(eS))}).ElseIf(i.greaterThanEqual(e6),()=>{e.assign(cv.sub(i).mul(Ute.sub(tS)).div(cv.sub(e6)).add(tS))}).Else(()=>{e.assign(xe(-2).mul(su(Kn(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),KU=Ke(([i,e])=>{const t=i.toVar();t.assign(Kn(2,t).sub(1));const n=Ie(t,1).toVar();return ii(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ZU=Ke(([i,e,t,n,r,s])=>{const a=xe(t),l=Ie(e),u=du(Fte(a),eT,s),h=kc(u),m=au(u),v=Ie(tT(i,l,m,n,r,s)).toVar();return ii(h.notEqual(0),()=>{const x=Ie(tT(i,l,m.add(1),n,r,s)).toVar();v.assign(Ui(v,x,h))}),v}),tT=Ke(([i,e,t,n,r,s])=>{const a=xe(t).toVar(),l=Ie(e),u=xe(Ote(l)).toVar(),h=xe(Gr(t6.sub(a),0)).toVar();a.assign(Gr(a,t6));const m=xe(D0(a)).toVar(),v=Lt(Ite(l,u).mul(m.sub(2)).add(1)).toVar();return ii(u.greaterThan(2),()=>{v.y.addAssign(m),u.subAssign(3)}),v.x.addAssign(u.mul(m)),v.x.addAssign(h.mul(Kn(3,Bte))),v.y.addAssign(Kn(4,D0(s).sub(m))),v.x.mulAssign(n),v.y.mulAssign(r),i.sample(v).grad(Lt(),Lt())}),nS=Ke(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:l})=>{const u=pc(n),h=t.mul(u).add(r.cross(t).mul(So(n))).add(r.mul(r.dot(t).mul(u.oneMinus())));return tT(i,h,e,s,a,l)}),JU=Ke(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:s,dTheta:a,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})=>{const x=Ie(zs(e,t,Iy(t,n))).toVar();ii($M(x.equals(Ie(0))),()=>{x.assign(Ie(n.z,0,n.x.negate()))}),x.assign(Lc(x));const S=Ie().toVar();return S.addAssign(r.element(Ee(0)).mul(nS({theta:0,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),Bi({start:Ee(1),end:i},({i:T})=>{ii(T.greaterThanEqual(s),()=>{NU()});const N=xe(a.mul(xe(T))).toVar();S.addAssign(r.element(T).mul(nS({theta:N.mul(-1),axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),S.addAssign(r.element(T).mul(nS({theta:N,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})))}),_n(S,1)});let ey=null;const n6=new WeakMap;function kte(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function zte(i){let e=n6.get(i);if((e!==void 0?e.pmremVersion:-1)!==i.pmremVersion){const n=i.image;if(i.isCubeTexture)if(qte(n))e=ey.fromCubemap(i,e);else return null;else if(Vte(n))e=ey.fromEquirectangular(i,e);else return null;e.pmremVersion=i.pmremVersion,n6.set(i,e)}return e.texture}class Gte extends Zr{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new ms;r.isRenderTargetTexture=!0,this._texture=fi(r),this._width=yn(0),this._height=yn(0),this._maxMip=yn(0),this.updateBeforeType=Qn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=kte(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(n.isPMREMTexture===!0?e=n:e=zte(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ey===null&&(ey=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===Ga&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=Ie(t.x.negate(),t.yz)),t=Ie(t.x,t.y.negate(),t.z);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ZU(this._texture,t,r,this._width,this._height,this._maxMip)}}function qte(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n0}const SE=gt(Gte),i6=new WeakMap;class jte extends W0{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const S=n.isTextureNode?n.value:t[n.property];let T=i6.get(S);T===void 0&&(T=SE(S),i6.set(S,T)),n=T}const s=t.envMap?zi("envMapIntensity","float",e.material):zi("environmentIntensity","float",e.scene),l=t.useAnisotropy===!0||t.anisotropy>0?j9:kr,u=n.context(r6($l,l)).mul(s),h=n.context(Hte(qy)).mul(Math.PI).mul(s),m=Bm(u),v=Bm(h);e.context.radiance.addAssign(m),e.context.iblIrradiance.addAssign(v);const x=e.context.lightingModel.clearcoatRadiance;if(x){const S=n.context(r6(Sg,HA)).mul(s),T=Bm(S);x.addAssign(T)}}}const r6=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=hr.negate().reflect(e),t=i.mul(i).mix(t,e).normalize(),t=t.transformDirection(no)),t),getTextureLevel:()=>i}},Hte=i=>({getUV:()=>i,getTextureLevel:()=>xe(1)}),Wte=new aD;class eB extends qr{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Wte),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new jte(t):null}setupLightingModel(){return new QU}setupSpecular(){const e=Ui(Ie(.04),Ri.rgb,bg);Oa.assign(e),wg.assign(1)}setupVariants(){const e=this.metalnessNode?xe(this.metalnessNode):J9;bg.assign(e);let t=this.roughnessNode?xe(this.roughnessNode):Z9;t=xE({roughness:t}),$l.assign(t),this.setupSpecular(),Ri.assign(_n(Ri.rgb.mul(e.oneMinus()),Ri.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const $te=new Lz;class Xte extends eB{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues($te),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?xe(this.iorNode):dU;Um.assign(e),Oa.assign(Ui(Za(tE(Um.sub(1).div(Um.add(1))).mul(K9),Ie(1)).mul(Qw),Ri.rgb,bg)),wg.assign(Ui(Qw,1,bg))}setupLightingModel(){return new QU(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?xe(this.clearcoatNode):tU,n=this.clearcoatRoughnessNode?xe(this.clearcoatRoughnessNode):nU;W_.assign(t),Sg.assign(xE({roughness:n}))}if(this.useSheen){const t=this.sheenNode?Ie(this.sheenNode):sU,n=this.sheenRoughnessNode?xe(this.sheenRoughnessNode):aU;Vf.assign(t),Py.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?xe(this.iridescenceNode):lU,n=this.iridescenceIORNode?xe(this.iridescenceIORNode):uU,r=this.iridescenceThicknessNode?xe(this.iridescenceThicknessNode):cU;Ly.assign(t),kM.assign(n),zM.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?Lt(this.anisotropyNode):oU).toVar();Th.assign(t.length()),ii(Th.equal(0),()=>{t.assign(Lt(1,0))}).Else(()=>{t.divAssign(Lt(Th)),Th.assign(Th.saturate())}),$_.assign(Th.pow2().mix($l.pow2(),1)),Lm.assign(jf[0].mul(t.x).add(jf[1].mul(t.y))),Zf.assign(jf[1].mul(t.x).sub(jf[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?xe(this.transmissionNode):hU,n=this.thicknessNode?xe(this.thicknessNode):fU,r=this.attenuationDistanceNode?xe(this.attenuationDistanceNode):AU,s=this.attenuationColorNode?Ie(this.attenuationColorNode):pU;if(Y_.assign(t),GM.assign(n),qM.assign(r),VM.assign(s),this.useDispersion){const a=this.dispersionNode?xe(this.dispersionNode):yU;jM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Ie(this.clearcoatNormalNode):iU}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const Yte=Ke(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=Lt(n.mul(.5).add(.5),0);if(t.material.gradientMap){const s=_c("gradientMap","texture").context({getUV:()=>r});return Ie(s.r)}else{const s=r.fwidth().mul(.5);return Ui(Ie(.7),Ie(1),Uc(xe(.7).sub(s.x),xe(.7).add(s.x),r.x))}});class Qte extends Wy{direct({lightDirection:e,lightColor:t,reflectedLight:n},r,s){const a=Yte({normal:zy,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(a.mul(ld({diffuseColor:Ri.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(ld({diffuseColor:Ri}))),n.indirectDiffuse.mulAssign(e)}}const Kte=new Uz;class Zte extends qr{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Kte),this.setValues(e)}setupLightingModel(){return new Qte}}class Jte extends Zr{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=Ie(hr.z,0,hr.x.negate()).normalize(),t=hr.cross(e);return Lt(e.dot(kr),t.dot(kr)).mul(.495).add(.5)}}const tB=$t(Jte),ene=new Fz;class tne extends qr{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(ene),this.setValues(e)}setupVariants(e){const t=tB;let n;e.material.matcap?n=_c("matcap","texture").context({getUV:()=>t}):n=Ie(Ui(.2,.8,t.y)),Ri.rgb.mulAssign(n.rgb)}}const nne=new eM;class ine extends qr{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.setDefaultValues(nne),this.setValues(e)}}class rne extends Zr{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),a=t.sin();return Dy(s,a,a.negate(),s).mul(n)}else{const s=t,a=Kf(_n(1,0,0,0),_n(0,pc(s.x),So(s.x).negate(),0),_n(0,So(s.x),pc(s.x),0),_n(0,0,0,1)),l=Kf(_n(pc(s.y),0,So(s.y),0),_n(0,1,0,0),_n(So(s.y).negate(),0,pc(s.y),0),_n(0,0,0,1)),u=Kf(_n(pc(s.z),So(s.z).negate(),0,0),_n(So(s.z),pc(s.z),0,0),_n(0,0,1,0),_n(0,0,0,1));return a.mul(l).mul(u).mul(_n(n,1)).xyz}}}const wE=gt(rne),sne=new Qk;class ane extends qr{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(sne),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:l}=this,u=H0.mul(Ie(s||0));let h=Lt(Ho[0].xyz.length(),Ho[1].xyz.length());if(l!==null&&(h=h.mul(l)),r===!1)if(n.isPerspectiveCamera)h=h.mul(u.z.negate());else{const S=xe(2).div(Ad.element(1).element(1));h=h.mul(S.mul(2))}let m=ky.xy;if(t.center&&t.center.isVector2===!0){const S=MJ("center","vec2",t);m=m.sub(S.sub(.5))}m=m.mul(h);const v=xe(a||rU),x=wE(m,v);return _n(u.xy.add(x),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class one extends Wy{constructor(){super(),this.shadowNode=xe(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Ri.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Ri.rgb)}}const lne=new Pz;class une extends qr{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lne),this.setValues(e)}setupLightingModel(){return new one}}const cne=Ke(({texture:i,uv:e})=>{const n=Ie().toVar();return ii(e.x.lessThan(1e-4),()=>{n.assign(Ie(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(Ie(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(Ie(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(Ie(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(Ie(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(Ie(0,0,-1))}).Else(()=>{const s=i.sample(e.add(Ie(-.01,0,0))).r.sub(i.sample(e.add(Ie(.01,0,0))).r),a=i.sample(e.add(Ie(0,-.01,0))).r.sub(i.sample(e.add(Ie(0,.01,0))).r),l=i.sample(e.add(Ie(0,0,-.01))).r.sub(i.sample(e.add(Ie(0,0,.01))).r);n.assign(Ie(s,a,l))}),n.normalize()});class hne extends pu{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Ie(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Ee(Uh(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return cne({texture:this,uv:e})}}const fne=gt(hne);class dne{constructor(e,t){this.nodes=e,this.info=t,this._context=self,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class vu{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const s of e){const a=s.node&&s.node.attribute?s.node.attribute:t.getAttribute(s.name);if(a===void 0)continue;n.push(a);const l=a.isInterleavedBufferAttribute?a.data:a;r.add(l)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:s}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),l=this.getIndex(),u=l!==null,h=n.isInstancedBufferGeometry?n.instanceCount:e.count>1?e.count:1;if(h===0)return null;if(a.instanceCount=h,e.isBatchedMesh===!0)return a;let m=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(m=2);let v=s.start*m,x=(s.start+s.count)*m;r!==null&&(v=Math.max(v,r.start*m),x=Math.min(x,(r.start+r.count)*m));const S=n.attributes.position;let T=1/0;u?T=l.count:S!=null&&(T=S.count),v=Math.max(v,0),x=Math.min(x,T);const N=x-v;return N<0||N===1/0?null:(a.vertexCount=N,a.firstVertex=v,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const r of pne(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const s=t[r];let a;if(s!==null){const l=typeof s;l==="number"?a=s!==0?"1":"0":l==="object"?(a="{",s.isTexture&&(a+=s.mapping),a+="}"):a=String(s)}else a=String(s);n+=a+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(n+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",OP(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const bA=[];class gne{constructor(e,t,n,r,s,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=s,this.info=a,this.chainMaps={}}get(e,t,n,r,s,a,l,u){const h=this.getChainMap(u);bA[0]=e,bA[1]=t,bA[2]=a,bA[3]=s;let m=h.get(bA);return m===void 0?(m=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,s,a,l,u),h.set(bA,m)):(m.updateClipping(l),m.needsGeometryUpdate&&m.setGeometry(e.geometry),(m.version!==t.version||m.needsUpdate)&&(m.initialCacheKey!==m.getCacheKey()?(m.dispose(),m=this.get(e,t,n,r,s,a,l,u)):m.version=t.version)),m}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new vu)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,s,a,l,u,h,m,v){const x=this.getChainMap(v),S=new mne(e,t,n,r,s,a,l,u,h,m);return S.onDispose=()=>{this.pipelines.delete(S),this.bindings.delete(S),this.nodes.delete(S),x.delete(S.getChainArray())},S}}class Hh{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Zl={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Nh=16,vne=211,_ne=212;class yne extends Hh{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==void 0&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===Zl.VERTEX?this.backend.createAttribute(e):t===Zl.INDEX?this.backend.createIndexAttribute(e):t===Zl.STORAGE?this.backend.createStorageAttribute(e):t===Zl.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version=0;--e)if(i[e]>=65535)return!0;return!1}function nB(i){return i.index!==null?i.index.version:i.attributes.position.version}function s6(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const s=t.array;for(let a=0,l=s.length;a{this.info.memory.geometries--;const s=t.index,a=e.getAttributes();s!==null&&this.attributes.delete(s);for(const u of a)this.attributes.delete(u);const l=this.wireframes.get(t);l!==void 0&&this.attributes.delete(l),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,Zl.STORAGE):this.updateAttribute(s,Zl.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,Zl.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Zl.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const s=this.wireframes;let a=s.get(t);a===void 0?(a=s6(t),s.set(t,a)):a.version!==nB(t)&&(this.attributes.delete(a),a=s6(t),s.set(t,a)),r=a}return r}}class Sne{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){this[e].timestampCalls===0&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class iB{constructor(e){this.cacheKey=e,this.usedTimes=0}}class wne extends iB{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class Tne extends iB{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Mne=0;class iS{constructor(e,t,n,r=null,s=null){this.id=Mne++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=s,this.usedTimes=0}}class Ene extends Hh{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let l=this.programs.compute.get(a.computeShader);l===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),l=new iS(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,l),n.createProgram(l));const u=this._getComputeCacheKey(e,l);let h=this.caches.get(u);h===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),h=this._getComputePipeline(e,l,u,t)),h.usedTimes++,l.usedTimes++,r.version=e.version,r.pipeline=h}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),l=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),u=new iS(a.vertexShader,"vertex",l),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let h=this.programs.fragment.get(a.fragmentShader);h===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),h=new iS(a.fragmentShader,"fragment",l),this.programs.fragment.set(a.fragmentShader,h),n.createProgram(h));const m=this._getRenderCacheKey(e,u,h);let v=this.caches.get(m);v===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),v=this._getRenderPipeline(e,u,h,m,t)):e.pipeline=v,v.usedTimes++,u.usedTimes++,h.usedTimes++,r.pipeline=v}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new Tne(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,n,r,s){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new wne(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,s)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Cne extends Hh{constructor(e,t,n,r,s,a){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?Zl.INDIRECT:Zl.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,s=!0,a=0,l=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const h=this.textures.get(u.texture);u.needsBindingsUpdate(h.generation)&&(r=!0);const m=u.update(),v=u.texture;m&&this.textures.updateTexture(v);const x=n.get(v);if(x.externalTexture!==void 0||h.isDefaultTexture?s=!1:(a=a*10+v.id,l+=v.version),n.isWebGPUBackend===!0&&x.texture===void 0&&x.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,m,v,u.textureNode.value,r),this.textures.updateTexture(v),r=!0),v.isStorageTexture===!0){const S=this.get(v);u.store===!0?S.needsMipmap=!0:this.textures.needsMipmaps(v)&&S.needsMipmap===!0&&(this.backend.generateMipmaps(v),S.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,s?a:0,l)}}function Nne(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function a6(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function o6(i){return(i.transmission>0||i.transmissionNode)&&i.side===as&&i.forceSinglePass===!1}class Rne{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,s,a,l){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:s,group:a,clippingContext:l},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=s,u.group=a,u.clippingContext=l),this.renderItemsIndex++,u}push(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(o6(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);n.transparent===!0||n.transmission>0?(o6(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Nne),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||a6),this.transparent.length>1&&this.transparent.sort(t||a6)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,h=l.height>>t;let m=e.depthTexture||s[t];const v=e.depthBuffer===!0||e.stencilBuffer===!0;let x=!1;m===void 0&&v&&(m=new Ic,m.format=e.stencilBuffer?uu:tu,m.type=e.stencilBuffer?lu:Nr,m.image.width=u,m.image.height=h,s[t]=m),(n.width!==l.width||l.height!==n.height)&&(x=!0,m&&(m.needsUpdate=!0,m.image.width=u,m.image.height=h)),n.width=l.width,n.height=l.height,n.textures=a,n.depthTexture=m||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(x=!0,m&&(m.needsUpdate=!0),n.sampleCount=r);const S={sampleCount:r};for(let T=0;T{e.removeEventListener("dispose",T);for(let N=0;N0){const m=e.image;if(m===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(m.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const v=[];for(const x of e.images)v.push(x);t.images=v}else t.image=m;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&s.generateMipmaps(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const h=()=>{e.removeEventListener("dispose",h),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",h)}n.version=e.version}getSize(e,t=Bne){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return this.isEnvironmentTexture(e)||e.isCompressedTexture===!0||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===Oh||t===Ih||t===Xo||t===Yo}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class TE extends cn{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class sB extends Ii{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const Ine=(i,e)=>wt(new sB(i,e));class Fne extends Nn{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new Pm(t);return this._currentCond=zs(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Pm(t),r=zs(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Pm(e),this}build(e,...t){const n=BM();yg(this);for(const r of this.nodes)r.build(e,"void");return yg(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const Zv=gt(Fne);class aB extends Nn{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,n=[];for(let r=0;r{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),nT=(i,e)=>Tl(Kn(4,i.mul(yi(1,i))),e),qne=(i,e)=>i.lessThan(.5)?nT(i.mul(2),e).div(2):yi(1,nT(Kn(yi(1,i),2),e).div(2)),Vne=(i,e,t)=>Tl(Cl(Tl(i,e),Qr(Tl(i,e),Tl(yi(1,i),t))),1/e),jne=(i,e)=>So(Q_.mul(e.mul(i).sub(1))).div(Q_.mul(e.mul(i).sub(1))),mc=Ke(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Hne=Ke(([i])=>Ie(mc(i.z.add(mc(i.y.mul(1)))),mc(i.z.add(mc(i.x.mul(1)))),mc(i.y.add(mc(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Wne=Ke(([i,e,t])=>{const n=Ie(i).toVar(),r=xe(1.4).toVar(),s=xe(0).toVar(),a=Ie(n).toVar();return Bi({start:xe(0),end:xe(3),type:"float",condition:"<="},()=>{const l=Ie(Hne(a.mul(2))).toVar();n.addAssign(l.add(t.mul(xe(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const u=xe(mc(n.z.add(mc(n.x.add(mc(n.y)))))).toVar();s.addAssign(u.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class $ne extends Nn{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let r=null,s=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=u.inputs;if(t.length===h.length){let m=0;for(let v=0;vs&&(r=a,s=m)}}this._candidateFnCall=n=r(...t)}return n}}const Xne=gt($ne),Vs=i=>(...e)=>Xne(i,...e),pd=yn(0).setGroup(Ln).onRenderUpdate(i=>i.time),uB=yn(0).setGroup(Ln).onRenderUpdate(i=>i.deltaTime),Yne=yn(0,"uint").setGroup(Ln).onRenderUpdate(i=>i.frameId),Qne=(i=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),pd.mul(i)),Kne=(i=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),pd.mul(i)),Zne=(i=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),uB.mul(i)),Jne=(i=pd)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),eie=(i=pd)=>i.fract().round(),tie=(i=pd)=>i.add(.5).fract().mul(2).sub(1).abs(),nie=(i=pd)=>i.fract(),iie=Ke(([i,e,t=Lt(.5)])=>wE(i.sub(t),e).add(t)),rie=Ke(([i,e,t=Lt(.5)])=>{const n=i.sub(t),r=n.dot(n),a=r.mul(r).mul(e);return i.add(n.mul(a))}),sie=Ke(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=Ho.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=Ho;const r=no.mul(n);return _g(e)&&(r[0][0]=Ho[0].length(),r[0][1]=0,r[0][2]=0),_g(t)&&(r[1][0]=0,r[1][1]=Ho[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,Ad.mul(r).mul(zr)}),aie=Ke(([i=null])=>{const e=J_();return J_(pE(i)).sub(e).lessThan(0).select(gu,i)});class oie extends Nn{static get type(){return"SpriteSheetUVNode"}constructor(e,t=Mr(),n=xe(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:s}=n,a=e.mod(r.mul(s)).floor(),l=a.mod(r),u=s.sub(a.add(1).div(r).ceil()),h=n.reciprocal(),m=Lt(l,u);return t.add(m).mul(h)}}const lie=gt(oie);class uie extends Nn{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,n=null,r=xe(1),s=zr,a=Ja){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:s,normalNode:a}=this;let l=a.abs().normalize();l=l.div(l.dot(Ie(1)));const u=s.yz.mul(r),h=s.zx.mul(r),m=s.xy.mul(r),v=e.value,x=t!==null?t.value:v,S=n!==null?n.value:v,T=fi(v,u).mul(l.x),N=fi(x,h).mul(l.y),C=fi(S,m).mul(l.z);return Qr(T,N,C)}}const cB=gt(uie),cie=(...i)=>cB(...i),SA=new jl,Sf=new me,wA=new me,rS=new me,am=new jn,hv=new me(0,0,-1),kl=new On,om=new me,fv=new me,lm=new On,dv=new bt,ty=new qh,hie=gu.flipX();ty.depthTexture=new Ic(1,1);let sS=!1;class ME extends pu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||ty.texture,hie),this._reflectorBaseNode=e.reflector||new fie(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=wt(new ME({defaultTexture:ty.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}}class fie extends Nn{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new pr,resolution:r=1,generateMipmaps:s=!1,bounces:a=!0,depth:l=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=s,this.bounces=a,this.depth=l,this.updateBeforeType=a?Qn.RENDER:Qn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const n=this.resolution;t.getDrawingBufferSize(dv),e.setSize(Math.round(dv.width*n),Math.round(dv.height*n))}setup(e){return this._updateResolution(ty,e.renderer),super.setup(e)}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new qh(0,0,{type:Gs}),this.generateMipmaps===!0&&(t.texture.minFilter=WF,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Ic),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&sS)return!1;sS=!0;const{scene:t,camera:n,renderer:r,material:s}=e,{target:a}=this,l=this.getVirtualCamera(n),u=this.getRenderTarget(l);if(r.getDrawingBufferSize(dv),this._updateResolution(u,r),wA.setFromMatrixPosition(a.matrixWorld),rS.setFromMatrixPosition(n.matrixWorld),am.extractRotation(a.matrixWorld),Sf.set(0,0,1),Sf.applyMatrix4(am),om.subVectors(wA,rS),om.dot(Sf)>0)return;om.reflect(Sf).negate(),om.add(wA),am.extractRotation(n.matrixWorld),hv.set(0,0,-1),hv.applyMatrix4(am),hv.add(rS),fv.subVectors(wA,hv),fv.reflect(Sf).negate(),fv.add(wA),l.coordinateSystem=n.coordinateSystem,l.position.copy(om),l.up.set(0,1,0),l.up.applyMatrix4(am),l.up.reflect(Sf),l.lookAt(fv),l.near=n.near,l.far=n.far,l.updateMatrixWorld(),l.projectionMatrix.copy(n.projectionMatrix),SA.setFromNormalAndCoplanarPoint(Sf,wA),SA.applyMatrix4(l.matrixWorldInverse),kl.set(SA.normal.x,SA.normal.y,SA.normal.z,SA.constant);const h=l.projectionMatrix;lm.x=(Math.sign(kl.x)+h.elements[8])/h.elements[0],lm.y=(Math.sign(kl.y)+h.elements[9])/h.elements[5],lm.z=-1,lm.w=(1+h.elements[10])/h.elements[14],kl.multiplyScalar(1/kl.dot(lm));const m=0;h.elements[2]=kl.x,h.elements[6]=kl.y,h.elements[10]=r.coordinateSystem===cu?kl.z-m:kl.z+1-m,h.elements[14]=kl.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),s.visible=!1;const v=r.getRenderTarget(),x=r.getMRT(),S=r.autoClear;r.setMRT(null),r.setRenderTarget(u),r.autoClear=!0,r.render(t,l),r.setMRT(x),r.setRenderTarget(v),r.autoClear=S,s.visible=!0,sS=!1}}const die=i=>wt(new ME(i)),aS=new Ig(-1,1,1,-1,0,1);class Aie extends Hi{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Si([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Si(t,2))}}const pie=new Aie;class EE extends Oi{constructor(e=null){super(pie,e),this.camera=aS,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,aS)}render(e){e.render(this,aS)}}const mie=new bt;class gie extends pu{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:Gs}){const s=new qh(t,n,r);super(s.texture,Mr()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new EE(new qr),this.updateBeforeType=Qn.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const n=e.getSize(mie);this.setSize(n.width,n.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new pu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const hB=(i,...e)=>wt(new gie(wt(i),...e)),vie=(i,...e)=>i.isTextureNode?i:i.isPassNode?i.getTextureNode():hB(i,...e),BA=Ke(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===cu?(i=Lt(i.x,i.y.oneMinus()).mul(2).sub(1),r=_n(Ie(i,e),1)):r=_n(Ie(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const s=_n(t.mul(r));return s.xyz.div(s.w)}),_ie=Ke(([i,e])=>{const t=e.mul(_n(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Lt(n.x,n.y.oneMinus())}),yie=Ke(([i,e,t])=>{const n=Uh(Ir(e)),r=As(i.mul(n)).toVar(),s=Ir(e,r).toVar(),a=Ir(e,r.sub(As(2,0))).toVar(),l=Ir(e,r.sub(As(1,0))).toVar(),u=Ir(e,r.add(As(1,0))).toVar(),h=Ir(e,r.add(As(2,0))).toVar(),m=Ir(e,r.add(As(0,2))).toVar(),v=Ir(e,r.add(As(0,1))).toVar(),x=Ir(e,r.sub(As(0,1))).toVar(),S=Ir(e,r.sub(As(0,2))).toVar(),T=rr(yi(xe(2).mul(l).sub(a),s)).toVar(),N=rr(yi(xe(2).mul(u).sub(h),s)).toVar(),C=rr(yi(xe(2).mul(v).sub(m),s)).toVar(),E=rr(yi(xe(2).mul(x).sub(S),s)).toVar(),O=BA(i,s,t).toVar(),U=T.lessThan(N).select(O.sub(BA(i.sub(Lt(xe(1).div(n.x),0)),l,t)),O.negate().add(BA(i.add(Lt(xe(1).div(n.x),0)),u,t))),I=C.lessThan(E).select(O.sub(BA(i.add(Lt(0,xe(1).div(n.y))),v,t)),O.negate().add(BA(i.sub(Lt(0,xe(1).div(n.y))),x,t)));return Lc(Iy(U,I))});class Jv extends Bg{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class xie extends wr{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}class bie extends dd{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}const Sie=gt(bie);class wie extends lE{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t=FP(e.itemSize),n=e.count),super(e,t,n),this.isStorageBufferNode=!0,this.access=ia.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Sie(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(ia.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Hg(this.value),this._varying=to(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}generate(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const Xy=(i,e=null,t=0)=>wt(new wie(i,e,t)),Tie=(i,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Xy(i,e,t).setPBO(!0)),Mie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new xie(i,t,n);return Xy(r,e,i)},Eie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new Jv(i,t,n);return Xy(r,e,i)};class Cie extends T9{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new On(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const Nie=i=>wt(new Cie(i));class Rie extends Nn{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Die=$t(Rie),um=new aa,oS=new jn;class Wa extends Nn{static get type(){return"SceneNode"}constructor(e=Wa.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let r;return t===Wa.BACKGROUND_BLURRINESS?r=zi("backgroundBlurriness","float",n):t===Wa.BACKGROUND_INTENSITY?r=zi("backgroundIntensity","float",n):t===Wa.BACKGROUND_ROTATION?r=yn("mat4").label("backgroundRotation").setGroup(Ln).onRenderUpdate(()=>{const s=n.background;return s!==null&&s.isTexture&&s.mapping!==OT?(um.copy(n.backgroundRotation),um.x*=-1,um.y*=-1,um.z*=-1,oS.makeRotationFromEuler(um)):oS.identity(),oS}):console.error("THREE.SceneNode: Unknown scope:",t),r}}Wa.BACKGROUND_BLURRINESS="backgroundBlurriness";Wa.BACKGROUND_INTENSITY="backgroundIntensity";Wa.BACKGROUND_ROTATION="backgroundRotation";const fB=$t(Wa,Wa.BACKGROUND_BLURRINESS),iT=$t(Wa,Wa.BACKGROUND_INTENSITY),dB=$t(Wa,Wa.BACKGROUND_ROTATION);class Pie extends pu{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=ia.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(ia.READ_WRITE)}toReadOnly(){return this.setAccess(ia.READ_ONLY)}toWriteOnly(){return this.setAccess(ia.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:r}=t,s=super.generate(e,"property"),a=n.build(e,"uvec2"),l=r.build(e,"vec4"),u=e.generateTextureStore(e,s,a,l);e.addLineFlowCode(u,this)}}const AB=gt(Pie),Lie=(i,e,t)=>{const n=AB(i,e,t);return t!==null&&n.append(),n};class Uie extends Vy{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Bie=(i,e,t)=>wt(new Uie(i,e,t)),l6=new WeakMap;class Oie extends Zr{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Qn.OBJECT,this.updateAfterType=Qn.OBJECT,this.previousModelWorldMatrix=yn(new jn),this.previousProjectionMatrix=yn(new jn).setGroup(Ln),this.previousCameraViewMatrix=yn(new jn)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=u6(n);this.previousModelWorldMatrix.value.copy(r);const s=pB(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new jn,s.previousCameraViewMatrix=new jn,s.currentProjectionMatrix=new jn,s.currentCameraViewMatrix=new jn,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){u6(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Ad:yn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(H0).mul(zr),r=this.previousProjectionMatrix.mul(t).mul(Z_),s=n.xy.div(n.w),a=r.xy.div(r.w);return yi(s,a)}}function pB(i){let e=l6.get(i);return e===void 0&&(e={},l6.set(i,e)),e}function u6(i,e=0){const t=pB(i);let n=t[e];return n===void 0&&(t[e]=n=new jn),n}const Iie=$t(Oie),mB=Ke(([i,e])=>Za(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),gB=Ke(([i,e])=>Za(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vB=Ke(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_B=Ke(([i,e])=>Ui(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Oy(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Fie=Ke(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return _n(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kie=(...i)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),mB(i)),zie=(...i)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),gB(i)),Gie=(...i)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),vB(i)),qie=(...i)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),_B(i)),Vie=Ke(([i])=>CE(i.rgb)),jie=Ke(([i,e=xe(1)])=>e.mix(CE(i.rgb),i.rgb)),Hie=Ke(([i,e=xe(1)])=>{const t=Qr(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),r=n.sub(t).mul(e).mul(-3);return Ui(i.rgb,n,r)}),Wie=Ke(([i,e=xe(1)])=>{const t=Ie(.57735,.57735,.57735),n=e.cos();return Ie(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(jh(t,i.rgb).mul(n.oneMinus())))))}),CE=(i,e=Ie(li.getLuminanceCoefficients(new me)))=>jh(i,e),$ie=Ke(([i,e=Ie(1),t=Ie(0),n=Ie(1),r=xe(1),s=Ie(li.getLuminanceCoefficients(new me,Mo))])=>{const a=i.rgb.dot(Ie(s)),l=Gr(i.rgb.mul(e).add(t),0).toVar(),u=l.pow(n).toVar();return ii(l.r.greaterThan(0),()=>{l.r.assign(u.r)}),ii(l.g.greaterThan(0),()=>{l.g.assign(u.g)}),ii(l.b.greaterThan(0),()=>{l.b.assign(u.b)}),l.assign(a.add(l.sub(a).mul(r))),_n(l.rgb,i.a)});class Xie extends Zr{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const Yie=gt(Xie),Qie=new bt;class yB extends pu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class c6 extends yB{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class _u extends Zr{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new Ic;s.isRenderTargetTexture=!0,s.name="depth";const a=new qh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Gs,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=yn(0),this._cameraFar=yn(0),this._mrt=null,this.isPassNode=!0,this.updateBeforeType=Qn.FRAME}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=wt(new c6(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=wt(new c6(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=mE(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=e0(s,n,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.scope===_u.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(Qie);this.setSize(s.width,s.height);const a=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const u in this._previousTextures)this.toggleTexture(u);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(a),t.setMRT(l)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}_u.COLOR="color";_u.DEPTH="depth";const Kie=(i,e,t)=>wt(new _u(_u.COLOR,i,e,t)),Zie=(i,e)=>wt(new yB(i,e)),Jie=(i,e,t)=>wt(new _u(_u.DEPTH,i,e,t));class ere extends _u{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,s){super(_u.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,l,u,h,m,v)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const x=this._getOutlineMaterial(u);t.renderObject(r,s,a,l,x,h,m,v)}t.renderObject(r,s,a,l,u,h,m,v)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new qr;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=or;const t=Ja.negate(),n=Ad.mul(H0),r=xe(1),s=n.mul(_n(zr,1)),a=n.mul(_n(zr.add(t),1)),l=Lc(s.sub(a));return e.vertexNode=s.add(l.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=_n(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const tre=(i,e,t=new cn(0,0,0),n=.003,r=1)=>wt(new ere(i,e,wt(t),wt(n),wt(r))),xB=Ke(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bB=Ke(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SB=Ke(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),nre=Ke(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),wB=Ke(([i,e])=>{const t=ua(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=ua(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=nre(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ire=ua(Ie(1.6605,-.1246,-.0182),Ie(-.5876,1.1329,-.1006),Ie(-.0728,-.0083,1.1187)),rre=ua(Ie(.6274,.0691,.0164),Ie(.3293,.9195,.088),Ie(.0433,.0113,.8956)),sre=Ke(([i])=>{const e=Ie(i).toVar(),t=Ie(e.mul(e)).toVar(),n=Ie(t.mul(t)).toVar();return xe(15.5).mul(n.mul(t)).sub(Kn(40.14,n.mul(e))).add(Kn(31.96,n).sub(Kn(6.868,t.mul(e))).add(Kn(.4298,t).add(Kn(.1191,e).sub(.00232))))}),TB=Ke(([i,e])=>{const t=Ie(i).toVar(),n=ua(Ie(.856627153315983,.137318972929847,.11189821299995),Ie(.0951212405381588,.761241990602591,.0767994186031903),Ie(.0482516061458583,.101439036467562,.811302368396859)),r=ua(Ie(1.1271005818144368,-.1413297634984383,-.14132976349843826),Ie(-.11060664309660323,1.157823702216272,-.11060664309660294),Ie(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=xe(-12.47393),a=xe(4.026069);return t.mulAssign(e),t.assign(rre.mul(t)),t.assign(n.mul(t)),t.assign(Gr(t,1e-10)),t.assign(su(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(du(t,0,1)),t.assign(sre(t)),t.assign(r.mul(t)),t.assign(Tl(Gr(Ie(0),t),Ie(2.2))),t.assign(ire.mul(t)),t.assign(du(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MB=Ke(([i,e])=>{const t=xe(.76),n=xe(.15);i=i.mul(e);const r=Za(i.r,Za(i.g,i.b)),s=zs(r.lessThan(.08),r.sub(Kn(6.25,r.mul(r))),.04);i.subAssign(s);const a=Gr(i.r,Gr(i.g,i.b));ii(a.lessThan(t),()=>i);const l=yi(1,t),u=yi(1,l.mul(l).div(a.add(l.sub(t))));i.mulAssign(u.div(a));const h=yi(1,Cl(1,n.mul(a.sub(u)).add(1)));return Ui(i,Ie(u),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class rs extends Nn{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.includes=t,this.language=n}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Yy=gt(rs),are=(i,e)=>Yy(i,e,"js"),ore=(i,e)=>Yy(i,e,"wgsl"),lre=(i,e)=>Yy(i,e,"glsl");class EB extends rs{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,s=n.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const l=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(l);return a.code=u+` -`,t==="property"?l:e.format(`${l}()`,s,t)}}const CB=(i,e=[],t="")=>{for(let s=0;sn.call(...s);return r.functionNode=n,r},ure=(i,e)=>CB(i,e,"glsl"),cre=(i,e)=>CB(i,e,"wgsl");class hre extends Nn{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Bc,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:xe()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=VP(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=jP(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const e_=gt(hre);class NB extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class fre{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const t_=new NB;class dre extends Nn{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new NB,this._output=e_(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=e_(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=e_(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r.constructor.name==="AsyncFunction"?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(h,m)=>this.setOutput(h,m),n=new fre(this),r=t_.get("THREE"),s=t_.get("TSL"),a=this.getMethod(),l=[n,this._local,t_,e,t,r,s];this._object=a(...l);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const h of u.elements){const m=h.id||h.name;h.inputType&&(this.getParameter(m)===void 0&&this.setParameter(m,null),this.getParameter(m).inputType=h.inputType),h.outputType&&(this.getOutput(m)===void 0&&this.setOutput(m,null),this.getOutput(m).outputType=h.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:xe()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),r="var "+n+`; var output = {}; +`).removeFlowTab();return e.addFlowTab(),a}}const Bi=(...i)=>wt(new Tee(Qf(i,"int"))).append(),Mee=()=>zh("continue").append(),NU=()=>zh("break").append(),Eee=(...i)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),Bi(...i)),X3=new WeakMap,po=new On,kR=Ze(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:s})=>{const a=Ee(bU).mul(t).add(s),l=a.div(n),u=a.sub(l.mul(n));return Ir(i,As(u,l)).depth(r).mul(e)});function Cee(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,s=r!==void 0?r.length:0;let a=X3.get(i);if(a===void 0||a.count!==s){let O=function(){C.dispose(),X3.delete(i),i.removeEventListener("dispose",O)};var l=O;a!==void 0&&a.texture.dispose();const u=i.morphAttributes.position||[],h=i.morphAttributes.normal||[],m=i.morphAttributes.color||[];let v=0;e===!0&&(v=1),t===!0&&(v=2),n===!0&&(v=3);let x=i.attributes.position.count*v,S=1;const T=4096;x>T&&(S=Math.ceil(x/T),x=T);const N=new Float32Array(x*S*4*s),C=new XT(N,x,S,s);C.type=$r,C.needsUpdate=!0;const E=v*4;for(let U=0;U{const x=ye(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?x.assign(Ir(this.mesh.morphTexture,As(Ee(v).add(1),Ee(Kg))).r):x.assign(zi("morphTargetInfluences","float").element(v).toVar()),n===!0&&zr.addAssign(kR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:Ee(0)})),r===!0&&Ja.addAssign(kR({bufferMap:l,influence:x,stride:u,width:m,depth:v,offset:Ee(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const RU=gt(Nee);class W0 extends Nn{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Ree extends W0{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Dee extends i9{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=Ie().toVar("directDiffuse"),r=Ie().toVar("directSpecular"),s=Ie().toVar("indirectDiffuse"),a=Ie().toVar("indirectSpecular"),l={directDiffuse:n,directSpecular:r,indirectDiffuse:s,indirectSpecular:a};return{radiance:Ie().toVar("radiance"),irradiance:Ie().toVar("irradiance"),iblIrradiance:Ie().toVar("iblIrradiance"),ambientOcclusion:ye(1).toVar("ambientOcclusion"),reflectedLight:l,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const DU=gt(Dee);class Pee extends W0{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let im,rm;class ss extends Nn{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===ss.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Qn.NONE;return(this.scope===ss.SIZE||this.scope===ss.VIEWPORT)&&(e=Qn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===ss.VIEWPORT?t!==null?rm.copy(t.viewport):(e.getViewport(rm),rm.multiplyScalar(e.getPixelRatio())):t!==null?(im.width=t.width,im.height=t.height):e.getDrawingBufferSize(im)}setup(){const e=this.scope;let t=null;return e===ss.SIZE?t=yn(im||(im=new bt)):e===ss.VIEWPORT?t=yn(rm||(rm=new On)):t=Pt(Zg.div(Eg)),t}generate(e){if(this.scope===ss.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(Eg).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}ss.COORDINATE="coordinate";ss.VIEWPORT="viewport";ss.SIZE="size";ss.UV="uv";const gu=Xt(ss,ss.UV),Eg=Xt(ss,ss.SIZE),Zg=Xt(ss,ss.COORDINATE),dE=Xt(ss,ss.VIEWPORT),PU=dE.zw,LU=Zg.sub(dE.xy),Lee=LU.div(PU),Uee=Ze(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),Eg),"vec2").once()(),Bee=Ze(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),gu),"vec2").once()(),Oee=Ze(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),gu.flipY()),"vec2").once()(),sm=new bt;class Hy extends pu{static get type(){return"ViewportTextureNode"}constructor(e=gu,t=null,n=null){n===null&&(n=new Q7,n.minFilter=za),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Qn.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(sm);const n=this.value;(n.image.width!==sm.width||n.image.height!==sm.height)&&(n.image.width=sm.width,n.image.height=sm.height,n.needsUpdate=!0);const r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Iee=gt(Hy),AE=gt(Hy,null,null,{generateMipmaps:!0});let Y3=null;class Fee extends Hy{static get type(){return"ViewportDepthTextureNode"}constructor(e=gu,t=null){Y3===null&&(Y3=new Ic),super(e,t,Y3)}}const pE=gt(Fee);class Ha extends Nn{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Ha.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===Ha.DEPTH_BASE)n!==null&&(r=BU().assign(n));else if(t===Ha.DEPTH)e.isPerspectiveCamera?r=UU(Xr.z,Eh,Ch):r=e0(Xr.z,Eh,Ch);else if(t===Ha.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const s=mE(n,Eh,Ch);r=e0(s,Eh,Ch)}else r=n;else r=e0(Xr.z,Eh,Ch);return r}}Ha.DEPTH_BASE="depthBase";Ha.DEPTH="depth";Ha.LINEAR_DEPTH="linearDepth";const e0=(i,e,t)=>i.add(e).div(e.sub(t)),kee=(i,e,t)=>e.sub(t).mul(i).sub(e),UU=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),mE=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),gE=(i,e,t)=>{e=e.max(1e-6).toVar();const n=su(i.negate().div(e)),r=su(t.div(e));return n.div(r)},zee=(i,e,t)=>{const n=i.mul(Uy(t.div(e)));return ye(Math.E).pow(n).mul(e).negate()},BU=gt(Ha,Ha.DEPTH_BASE),vE=Xt(Ha,Ha.DEPTH),J_=gt(Ha,Ha.LINEAR_DEPTH),Gee=J_(pE());vE.assign=i=>BU(i);class qee extends Nn{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Vee=gt(qee);class $o extends Nn{static get type(){return"ClippingNode"}constructor(e=$o.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===$o.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===$o.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return Ze(()=>{const n=ye().toVar("distanceToPlane"),r=ye().toVar("distanceToGradient"),s=ye(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=vc(t);Bi(a,({i:h})=>{const m=u.element(h);n.assign(Xr.dot(m.xyz).negate().add(m.w)),r.assign(n.fwidth().div(2)),s.mulAssign(Uc(r.negate(),r,n))})}const l=e.length;if(l>0){const u=vc(e),h=ye(1).toVar("intersectionClipOpacity");Bi(l,({i:m})=>{const v=u.element(m);n.assign(Xr.dot(v.xyz).negate().add(v.w)),r.assign(n.fwidth().div(2)),h.mulAssign(Uc(r.negate(),r,n).oneMinus())}),s.mulAssign(h.oneMinus())}Ri.a.mulAssign(s),Ri.a.equal(0).discard()})()}setupDefault(e,t){return Ze(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const s=vc(t);Bi(n,({i:a})=>{const l=s.element(a);Xr.dot(l.xyz).greaterThan(l.w).discard()})}const r=e.length;if(r>0){const s=vc(e),a=Pc(!0).toVar("clipped");Bi(r,({i:l})=>{const u=s.element(l);a.assign(Xr.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),Ze(()=>{const r=vc(e),s=Vee(t.getClipDistance());Bi(n,({i:a})=>{const l=r.element(a),u=Xr.dot(l.xyz).sub(l.w).negate();s.element(a).assign(u)})})()}}$o.ALPHA_TO_COVERAGE="alphaToCoverage";$o.DEFAULT="default";$o.HARDWARE="hardware";const jee=()=>wt(new $o),Hee=()=>wt(new $o($o.ALPHA_TO_COVERAGE)),Wee=()=>wt(new $o($o.HARDWARE)),$ee=.05,zR=Ze(([i])=>kc(Kn(1e4,So(Kn(17,i.x).add(Kn(.1,i.y)))).mul(Qr(.1,rr(So(Kn(13,i.y).add(i.x))))))),GR=Ze(([i])=>zR(Pt(zR(i.xy),i.z))),Xee=Ze(([i])=>{const e=Gr(wc(KM(i.xyz)),wc(ZM(i.xyz))),t=ye(1).div(ye($ee).mul(e)).toVar("pixScale"),n=Pt(D0(au(su(t))),D0(By(su(t)))),r=Pt(GR(au(n.x.mul(i.xyz))),GR(au(n.y.mul(i.xyz)))),s=kc(su(t)),a=Qr(Kn(s.oneMinus(),r.x),Kn(s,r.y)),l=Za(s,s.oneMinus()),u=Ie(a.mul(a).div(Kn(2,l).mul(yi(1,l))),a.sub(Kn(.5,l)).div(yi(1,l)),yi(1,yi(1,a).mul(yi(1,a)).div(Kn(2,l).mul(yi(1,l))))),h=a.lessThan(l.oneMinus()).select(a.lessThan(l).select(u.x,u.y),u.z);return du(h,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class qr extends oa{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.shadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+IP(this)}build(e){this.setup(e)}setupObserver(e){return new HZ(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const r=this.vertexNode||this.setupVertex(e);e.stack.outputNode=r,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let s;const a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const l=this.setupLighting(e);a!==null&&e.stack.add(a);const u=_n(l,Ri.a).max(0);if(s=this.setupOutput(e,u),Tg.assign(s),this.outputNode!==null&&(s=this.outputNode),n!==null){const h=t.getMRT(),m=this.mrtNode;h!==null?(s=h,m!==null&&(s=h.merge(m))):m!==null&&(s=m)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=_n(l)),s=this.setupOutput(e,l)}e.stack.outputNode=s,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const s=e.renderer.samples;this.alphaToCoverage&&s>1?r=Hee():e.stack.add(jee())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(Wee()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const s=t.getMRT();s&&s.has("depth")?r=s.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=gE(Xr.z,Eh,Ch):r=e0(Xr.z,Eh,Ch))}r!==null&&vE.assign(r).append()}setupPositionView(){return H0.mul(zr).xyz}setupModelViewProjection(){return Ad.mul(Xr)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),fE}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&RU(t).append(),t.isSkinnedMesh===!0&&CU(t).append(),this.displacementMap){const r=_c("displacementMap","texture"),s=_c("displacementScale","float"),a=_c("displacementBias","float");zr.addAssign(Ja.normalize().mul(r.x.mul(s).add(a)))}return t.isBatchedMesh&&MU(t).append(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&TU(t).append(),this.positionNode!==null&&zr.assign(this.positionNode.context({isPositionNodeInput:!0})),zr}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?_n(this.colorNode):$9;this.vertexColors===!0&&t.hasAttribute("color")&&(n=_n(n.xyz.mul(Au("color","vec3")),n.a)),e.instanceColor&&(n=xg("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=xg("vec3","vBatchColor").mul(n)),Ri.assign(n);const r=this.opacityNode?ye(this.opacityNode):cE;if(Ri.a.assign(Ri.a.mul(r)),this.alphaTestNode!==null||this.alphaTest>0){const s=this.alphaTestNode!==null?ye(this.alphaTestNode):W9;Ri.a.lessThanEqual(s).discard()}this.alphaHash===!0&&Ri.a.lessThan(Xee(zr)).discard(),this.transparent===!1&&this.blending===Xa&&this.alphaToCoverage===!1&&Ri.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Ie(0):Ri.rgb}setupNormal(){return this.normalNode?Ie(this.normalNode):eU}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?_c("envMap","cubeTexture"):_c("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Pee(hE)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:xU;t.push(new Ree(a))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:s}=this,l=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(l&&l.getScope().hasLights){const h=this.setupLightingModel(e);u=DU(l,h,n,r)}else n!==null&&(u=Ie(r!==null?Ui(u,n,r):n));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(Hw.assign(Ie(s||Y9)),u=u.add(Hw)),u}setupOutput(e,t){if(this.fog===!0){const n=e.fogNode;n&&(Tg.assign(t),t=_n(n))}return t}setDefaultValues(e){for(const n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=oa.prototype.toJSON.call(this,e),r=H_(this);n.inputNodes={};for(const{property:a,childNode:l}of r)n.inputNodes[a]=l.toJSON(e).uuid;function s(a){const l=[];for(const u in a){const h=a[u];delete h.metadata,l.push(h)}return l}if(t){const a=s(e.textures),l=s(e.images),u=s(e.nodes);a.length>0&&(n.textures=a),l.length>0&&(n.images=l),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.shadowPositionNode=e.shadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const Yee=new q0;class Qee extends qr{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(Yee),this.setValues(e)}}const Kee=new kz;class Zee extends qr{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(Kee),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?ye(this.offsetNode):_U,t=this.dashScaleNode?ye(this.dashScaleNode):mU,n=this.dashSizeNode?ye(this.dashSizeNode):gU,r=this.gapSizeNode?ye(this.gapSizeNode):vU;Xv.assign(n),Ww.assign(r);const s=to(Au("lineDistance").mul(t));(e?s.add(e):s).mod(Xv.add(Ww)).greaterThan(Xv).discard()}}let Q3=null;class Jee extends Hy{static get type(){return"ViewportSharedTextureNode"}constructor(e=gu,t=null){Q3===null&&(Q3=new Q7),super(e,t,Q3)}updateReference(){return this}}const ete=gt(Jee),OU=i=>wt(i).mul(.5).add(.5),tte=i=>wt(i).mul(2).sub(1),nte=new Bz;class ite extends qr{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(nte),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?ye(this.opacityNode):cE;Ri.assign(_n(OU(kr),e))}}class rte extends Zr{static get type(){return"EquirectUVNode"}constructor(e=aE){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Pt(t,n)}}const _E=gt(rte);class IU extends X7{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s=new Vh(5,5,5),a=_E(aE),l=new qr;l.colorNode=fi(t,a,0),l.side=or,l.blending=$a;const u=new Oi(s,l),h=new ZT;h.add(u),t.minFilter===za&&(t.minFilter=ps);const m=new $7(1,10,this),v=e.getMRT();return e.setMRT(null),m.update(e,h),e.setMRT(v),t.minFilter=n,t.currentGenerateMipmaps=r,u.geometry.dispose(),u.material.dispose(),this}}const Im=new WeakMap;class ste extends Zr{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=P0();const t=new vy;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Qn.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const s=r.isTextureNode?r.value:n[r.property];if(s&&s.isTexture){const a=s.mapping;if(a===Oh||a===Ih){if(Im.has(s)){const l=Im.get(s);qR(l,s.mapping),this._cubeTexture=l}else{const l=s.image;if(ate(l)){const u=new IU(l.height);u.fromEquirectangularTexture(t,s),qR(u.texture,s.mapping),this._cubeTexture=u.texture,Im.set(s,u.texture),s.addEventListener("dispose",FU)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function ate(i){return i==null?!1:i.height>0}function FU(i){const e=i.target;e.removeEventListener("dispose",FU);const t=Im.get(e);t!==void 0&&(Im.delete(e),t.dispose())}function qR(i,e){e===Oh?i.mapping=Xo:e===Ih&&(i.mapping=Yo)}const kU=gt(ste);class yE extends W0{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=kU(this.envNode)}}class ote extends W0{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=ye(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Wy{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class zU extends Wy{constructor(){super()}indirect(e,t,n){const r=e.ambientOcclusion,s=e.reflectedLight,a=n.context.irradianceLightMap;s.indirectDiffuse.assign(_n(0)),a?s.indirectDiffuse.addAssign(a):s.indirectDiffuse.addAssign(_n(1,1,1,0)),s.indirectDiffuse.mulAssign(r),s.indirectDiffuse.mulAssign(Ri.rgb)}finish(e,t,n){const r=n.material,s=e.outgoingLight,a=n.context.environment;if(a)switch(r.combine){case Dg:s.rgb.assign(Ui(s.rgb,s.rgb.mul(a.rgb),Om.mul(Kv)));break;case P7:s.rgb.assign(Ui(s.rgb,a.rgb,Om.mul(Kv)));break;case L7:s.rgb.addAssign(a.rgb.mul(Om.mul(Kv)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",r.combine);break}}}const lte=new cd;class ute extends qr{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lte),this.setValues(e)}setupNormal(){return Ko}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new ote(hE)),t}setupOutgoingLight(){return Ri.rgb}setupLightingModel(){return new zU}}const L0=Ze(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),ld=Ze(i=>i.diffuseColor.mul(1/Math.PI)),cte=()=>ye(.25),hte=Ze(({dotNH:i})=>X_.mul(ye(.5)).add(1).mul(ye(1/Math.PI)).mul(i.pow(X_))),fte=Ze(({lightDirection:i})=>{const e=i.add(hr).normalize(),t=kr.dot(e).clamp(),n=hr.dot(e).clamp(),r=L0({f0:Oa,f90:1,dotVH:n}),s=cte(),a=hte({dotNH:t});return r.mul(s).mul(a)});class GU extends zU{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=kr.dot(e).clamp().mul(t);n.directDiffuse.addAssign(s.mul(ld({diffuseColor:Ri.rgb}))),this.specular===!0&&n.directSpecular.addAssign(s.mul(fte({lightDirection:e})).mul(Om))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(ld({diffuseColor:Ri}))),n.indirectDiffuse.mulAssign(e)}}const dte=new Fc;class Ate extends qr{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(dte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightingModel(){return new GU(!1)}}const pte=new oD;class mte extends qr{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(pte),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new yE(t):null}setupLightingModel(){return new GU}setupVariants(){const e=(this.shininessNode?ye(this.shininessNode):X9).max(1e-4);X_.assign(e);const t=this.specularNode||Q9;Oa.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const qU=Ze(i=>{if(i.geometry.hasAttribute("normal")===!1)return ye(0);const e=Ko.dFdx().abs().max(Ko.dFdy().abs());return e.x.max(e.y).max(e.z)}),xE=Ze(i=>{const{roughness:e}=i,t=qU();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),VU=Ze(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return Cl(.5,r.add(s).max(NL))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),gte=Ze(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:s,dotNV:a,dotNL:l})=>{const u=l.mul(Ie(i.mul(t),e.mul(n),a).length()),h=a.mul(Ie(i.mul(r),e.mul(s),l).length());return Cl(.5,u.add(h)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),jU=Ze(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),vte=ye(1/Math.PI),_te=Ze(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const s=i.mul(e),a=Ie(e.mul(n),i.mul(r),s.mul(t)),l=a.dot(a),u=s.div(l);return vte.mul(s.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),Kw=Ze(i=>{const{lightDirection:e,f0:t,f90:n,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:l}=i,u=i.normalView||kr,h=r.pow2(),m=e.add(hr).normalize(),v=u.dot(e).clamp(),x=u.dot(hr).clamp(),S=u.dot(m).clamp(),T=hr.dot(m).clamp();let N=L0({f0:t,f90:n,dotVH:T}),C,E;if(_g(a)&&(N=Ly.mix(N,s)),_g(l)){const O=Lm.dot(e),U=Lm.dot(hr),I=Lm.dot(m),j=Zf.dot(e),z=Zf.dot(hr),G=Zf.dot(m);C=gte({alphaT:$_,alphaB:h,dotTV:U,dotBV:z,dotTL:O,dotBL:j,dotNV:x,dotNL:v}),E=_te({alphaT:$_,alphaB:h,dotNH:S,dotTH:I,dotBH:G})}else C=VU({alpha:h,dotNL:v,dotNV:x}),E=jU({alpha:h,dotNH:S});return N.mul(C).mul(E)}),bE=Ze(({roughness:i,dotNV:e})=>{const t=_n(-1,-.0275,-.572,.022),n=_n(1,.0425,1.04,-.04),r=i.mul(t).add(n),s=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return Pt(-1.04,1.04).mul(s).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),HU=Ze(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,s=bE({dotNV:e,roughness:r});return t.mul(s.x).add(n.mul(s.y))}),WU=Ze(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),s=n.mul(r,r).clamp(0,.9999);return i.sub(Ie(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),yte=Ze(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=ye(1).div(t),s=e.pow2().oneMinus().max(.0078125);return ye(2).add(n).mul(s.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),xte=Ze(({dotNV:i,dotNL:e})=>ye(1).div(ye(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),bte=Ze(({lightDirection:i})=>{const e=i.add(hr).normalize(),t=kr.dot(i).clamp(),n=kr.dot(hr).clamp(),r=kr.dot(e).clamp(),s=yte({roughness:Py,dotNH:r}),a=xte({dotNV:n,dotNL:t});return Vf.mul(s).mul(a)}),Ste=Ze(({N:i,V:e,roughness:t})=>{const s=.0078125,a=i.dot(e).saturate(),l=Pt(t,a.oneMinus().sqrt());return l.assign(l.mul(.984375).add(s)),l}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),wte=Ze(({f:i})=>{const e=i.length();return Gr(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),ov=Ze(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),s=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=r.div(s),l=t.greaterThan(0).select(a,Gr(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return i.cross(e).mul(l)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),VR=Ze(({N:i,V:e,P:t,mInv:n,p0:r,p1:s,p2:a,p3:l})=>{const u=s.sub(r).toVar(),h=l.sub(r).toVar(),m=u.cross(h),v=Ie().toVar();return ii(m.dot(t.sub(r)).greaterThanEqual(0),()=>{const x=e.sub(i.mul(e.dot(i))).normalize(),S=i.cross(x).negate(),T=n.mul(ua(x,S,i).transpose()).toVar(),N=T.mul(r.sub(t)).normalize().toVar(),C=T.mul(s.sub(t)).normalize().toVar(),E=T.mul(a.sub(t)).normalize().toVar(),O=T.mul(l.sub(t)).normalize().toVar(),U=Ie(0).toVar();U.addAssign(ov({v1:N,v2:C})),U.addAssign(ov({v1:C,v2:E})),U.addAssign(ov({v1:E,v2:O})),U.addAssign(ov({v1:O,v2:N})),v.assign(Ie(wte({f:U})))}),v}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),$y=1/6,$U=i=>Kn($y,Kn(i,Kn(i,i.negate().add(3)).sub(3)).add(1)),Zw=i=>Kn($y,Kn(i,Kn(i,Kn(3,i).sub(6))).add(4)),XU=i=>Kn($y,Kn(i,Kn(i,Kn(-3,i).add(3)).add(3)).add(1)),Jw=i=>Kn($y,Tl(i,3)),jR=i=>$U(i).add(Zw(i)),HR=i=>XU(i).add(Jw(i)),WR=i=>Qr(-1,Zw(i).div($U(i).add(Zw(i)))),$R=i=>Qr(1,Jw(i).div(XU(i).add(Jw(i)))),XR=(i,e,t)=>{const n=i.uvNode,r=Kn(n,e.zw).add(.5),s=au(r),a=kc(r),l=jR(a.x),u=HR(a.x),h=WR(a.x),m=$R(a.x),v=WR(a.y),x=$R(a.y),S=Pt(s.x.add(h),s.y.add(v)).sub(.5).mul(e.xy),T=Pt(s.x.add(m),s.y.add(v)).sub(.5).mul(e.xy),N=Pt(s.x.add(h),s.y.add(x)).sub(.5).mul(e.xy),C=Pt(s.x.add(m),s.y.add(x)).sub(.5).mul(e.xy),E=jR(a.y).mul(Qr(l.mul(i.sample(S).level(t)),u.mul(i.sample(T).level(t)))),O=HR(a.y).mul(Qr(l.mul(i.sample(N).level(t)),u.mul(i.sample(C).level(t))));return E.add(O)},YU=Ze(([i,e=ye(3)])=>{const t=Pt(i.size(Ee(e))),n=Pt(i.size(Ee(e.add(1)))),r=Cl(1,t),s=Cl(1,n),a=XR(i,_n(r,t),au(e)),l=XR(i,_n(s,n),By(e));return kc(e).mix(a,l)}),YR=Ze(([i,e,t,n,r])=>{const s=Ie(nE(e.negate(),Lc(i),Cl(1,n))),a=Ie(wc(r[0].xyz),wc(r[1].xyz),wc(r[2].xyz));return Lc(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Tte=Ze(([i,e])=>i.mul(du(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Mte=AE(),Ete=AE(),QR=Ze(([i,e,t],{material:n})=>{const s=(n.side===or?Mte:Ete).sample(i),a=su(Eg.x).mul(Tte(e,t));return YU(s,a)}),KR=Ze(([i,e,t])=>(ii(t.notEqual(0),()=>{const n=Uy(e).negate().div(t);return XM(n.negate().mul(i))}),Ie(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Cte=Ze(([i,e,t,n,r,s,a,l,u,h,m,v,x,S,T])=>{let N,C;if(T){N=_n().toVar(),C=Ie().toVar();const j=m.sub(1).mul(T.mul(.025)),z=Ie(m.sub(j),m,m.add(j));Bi({start:0,end:3},({i:G})=>{const H=z.element(G),q=YR(i,e,v,H,l),V=a.add(q),Q=h.mul(u.mul(_n(V,1))),J=Pt(Q.xy.div(Q.w)).toVar();J.addAssign(1),J.divAssign(2),J.assign(Pt(J.x,J.y.oneMinus()));const ie=QR(J,t,H);N.element(G).assign(ie.element(G)),N.a.addAssign(ie.a),C.element(G).assign(n.element(G).mul(KR(wc(q),x,S).element(G)))}),N.a.divAssign(3)}else{const j=YR(i,e,v,m,l),z=a.add(j),G=h.mul(u.mul(_n(z,1))),H=Pt(G.xy.div(G.w)).toVar();H.addAssign(1),H.divAssign(2),H.assign(Pt(H.x,H.y.oneMinus())),N=QR(H,t,m),C=n.mul(KR(wc(j),x,S))}const E=C.rgb.mul(N.rgb),O=i.dot(e).clamp(),U=Ie(HU({dotNV:O,specularColor:r,specularF90:s,roughness:t})),I=C.r.add(C.g,C.b).div(3);return _n(U.oneMinus().mul(E),N.a.oneMinus().mul(I).oneMinus())}),Nte=ua(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Rte=i=>{const e=i.sqrt();return Ie(1).add(e).div(Ie(1).sub(e))},ZR=(i,e)=>i.sub(e).div(i.add(e)).pow2(),Dte=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=Ie(54856e-17,44201e-17,52481e-17),r=Ie(1681e3,1795300,2208400),s=Ie(43278e5,93046e5,66121e5),a=ye(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let l=n.mul(s.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return l=Ie(l.x.add(a),l.y,l.z).div(10685e-11),Nte.mul(l)},Pte=Ze(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const s=Ui(i,e,Uc(0,.03,n)),l=i.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();ii(l.lessThan(0),()=>Ie(1));const u=l.sqrt(),h=ZR(s,i),m=L0({f0:h,f90:1,dotVH:t}),v=m.oneMinus(),x=s.lessThan(i).select(Math.PI,0),S=ye(Math.PI).sub(x),T=Rte(r.clamp(0,.9999)),N=ZR(T,s.toVec3()),C=L0({f0:N,f90:1,dotVH:u}),E=Ie(T.x.lessThan(s).select(Math.PI,0),T.y.lessThan(s).select(Math.PI,0),T.z.lessThan(s).select(Math.PI,0)),O=s.mul(n,u,2),U=Ie(S).add(E),I=m.mul(C).clamp(1e-5,.9999),j=I.sqrt(),z=v.pow2().mul(C).div(Ie(1).sub(I)),H=m.add(z).toVar(),q=z.sub(v).toVar();return Bi({start:1,end:2,condition:"<=",name:"m"},({m:V})=>{q.mulAssign(j);const Q=Dte(ye(V).mul(O),ye(V).mul(U)).mul(2);H.addAssign(q.mul(Q))}),H.max(Ie(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Lte=Ze(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.pow2(),s=zs(t.lessThan(.25),ye(-339.2).mul(r).add(ye(161.4).mul(t)).sub(25.9),ye(-8.48).mul(r).add(ye(14.3).mul(t)).sub(9.95)),a=zs(t.lessThan(.25),ye(44).mul(r).sub(ye(23.7).mul(t)).add(3.26),ye(1.97).mul(r).sub(ye(3.27).mul(t)).add(.72));return zs(t.lessThan(.25),0,ye(.1).mul(t).sub(.025)).add(s.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),K3=Ie(.04),Z3=ye(1);class QU extends Wy{constructor(e=!1,t=!1,n=!1,r=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Ie().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Ie().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Ie().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=Ie().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Ie().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=kr.dot(hr).clamp();this.iridescenceFresnel=Pte({outsideIOR:ye(1),eta2:kM,cosTheta1:t,thinFilmThickness:zM,baseF0:Oa}),this.iridescenceF0=WU({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Tc,n=E9.sub(Tc).normalize(),r=qy;e.backdrop=Cte(r,n,$l,Ri,Oa,wg,t,Ho,no,Ad,Um,GM,VM,qM,this.dispersion?jM:null),e.backdropAlpha=Y_,Ri.a.mulAssign(Ui(1,e.backdrop.a,Y_))}}computeMultiscattering(e,t,n){const r=kr.dot(hr).clamp(),s=bE({roughness:$l,dotNV:r}),l=(this.iridescenceF0?Ly.mix(Oa,this.iridescenceF0):Oa).mul(s.x).add(n.mul(s.y)),h=s.x.add(s.y).oneMinus(),m=Oa.add(Oa.oneMinus().mul(.047619)),v=l.mul(m).div(h.mul(m).oneMinus());e.addAssign(l),t.addAssign(v.mul(h))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const s=kr.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(s.mul(bte({lightDirection:e}))),this.clearcoat===!0){const l=HA.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(l.mul(Kw({lightDirection:e,f0:K3,f90:Z3,roughness:Sg,normalView:HA})))}n.directDiffuse.addAssign(s.mul(ld({diffuseColor:Ri.rgb}))),n.directSpecular.addAssign(s.mul(Kw({lightDirection:e,f0:Oa,f90:1,roughness:$l,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:s,ltc_1:a,ltc_2:l}){const u=t.add(n).sub(r),h=t.sub(n).sub(r),m=t.sub(n).add(r),v=t.add(n).add(r),x=kr,S=hr,T=Xr.toVar(),N=Ste({N:x,V:S,roughness:$l}),C=a.sample(N).toVar(),E=l.sample(N).toVar(),O=ua(Ie(C.x,0,C.y),Ie(0,1,0),Ie(C.z,0,C.w)).toVar(),U=Oa.mul(E.x).add(Oa.oneMinus().mul(E.y)).toVar();s.directSpecular.addAssign(e.mul(U).mul(VR({N:x,V:S,P:T,mInv:O,p0:u,p1:h,p2:m,p3:v}))),s.directDiffuse.addAssign(e.mul(Ri).mul(VR({N:x,V:S,P:T,mInv:ua(1,0,0,0,1,0,0,0,1),p0:u,p1:h,p2:m,p3:v})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(ld({diffuseColor:Ri})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Vf,Lte({normal:kr,viewDir:hr,roughness:Py}))),this.clearcoat===!0){const h=HA.dot(hr).clamp(),m=HU({dotNV:h,specularColor:K3,specularF90:Z3,roughness:Sg});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const r=Ie().toVar("singleScattering"),s=Ie().toVar("multiScattering"),a=t.mul(1/Math.PI);this.computeMultiscattering(r,s,wg);const l=r.add(s),u=Ri.mul(l.r.max(l.g).max(l.b).oneMinus());n.indirectSpecular.addAssign(e.mul(r)),n.indirectSpecular.addAssign(s.mul(a)),n.indirectDiffuse.addAssign(u.mul(a))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const r=kr.dot(hr).clamp().add(e),s=$l.mul(-16).oneMinus().negate().exp2(),a=e.sub(r.pow(s).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(a)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=HA.dot(hr).clamp(),r=L0({dotVH:n,f0:K3,f90:Z3}),s=t.mul(W_.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(W_));t.assign(s)}if(this.sheen===!0){const n=Vf.r.max(Vf.g).max(Vf.b).mul(.157).oneMinus(),r=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const JR=ye(1),eT=ye(-2),lv=ye(.8),J3=ye(-1),uv=ye(.4),eS=ye(2),cv=ye(.305),tS=ye(3),e6=ye(.21),Ute=ye(4),t6=ye(4),Bte=ye(16),Ote=Ze(([i])=>{const e=Ie(rr(i)).toVar(),t=ye(-1).toVar();return ii(e.x.greaterThan(e.z),()=>{ii(e.x.greaterThan(e.y),()=>{t.assign(zs(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(zs(i.y.greaterThan(0),1,4))})}).Else(()=>{ii(e.z.greaterThan(e.y),()=>{t.assign(zs(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(zs(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Ite=Ze(([i,e])=>{const t=Pt().toVar();return ii(e.equal(0),()=>{t.assign(Pt(i.z,i.y).div(rr(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Pt(i.x.negate(),i.z.negate()).div(rr(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Pt(i.x.negate(),i.y).div(rr(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Pt(i.z.negate(),i.y).div(rr(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Pt(i.x.negate(),i.z).div(rr(i.y)))}).Else(()=>{t.assign(Pt(i.x,i.y).div(rr(i.z)))}),Kn(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Fte=Ze(([i])=>{const e=ye(0).toVar();return ii(i.greaterThanEqual(lv),()=>{e.assign(JR.sub(i).mul(J3.sub(eT)).div(JR.sub(lv)).add(eT))}).ElseIf(i.greaterThanEqual(uv),()=>{e.assign(lv.sub(i).mul(eS.sub(J3)).div(lv.sub(uv)).add(J3))}).ElseIf(i.greaterThanEqual(cv),()=>{e.assign(uv.sub(i).mul(tS.sub(eS)).div(uv.sub(cv)).add(eS))}).ElseIf(i.greaterThanEqual(e6),()=>{e.assign(cv.sub(i).mul(Ute.sub(tS)).div(cv.sub(e6)).add(tS))}).Else(()=>{e.assign(ye(-2).mul(su(Kn(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),KU=Ze(([i,e])=>{const t=i.toVar();t.assign(Kn(2,t).sub(1));const n=Ie(t,1).toVar();return ii(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ZU=Ze(([i,e,t,n,r,s])=>{const a=ye(t),l=Ie(e),u=du(Fte(a),eT,s),h=kc(u),m=au(u),v=Ie(tT(i,l,m,n,r,s)).toVar();return ii(h.notEqual(0),()=>{const x=Ie(tT(i,l,m.add(1),n,r,s)).toVar();v.assign(Ui(v,x,h))}),v}),tT=Ze(([i,e,t,n,r,s])=>{const a=ye(t).toVar(),l=Ie(e),u=ye(Ote(l)).toVar(),h=ye(Gr(t6.sub(a),0)).toVar();a.assign(Gr(a,t6));const m=ye(D0(a)).toVar(),v=Pt(Ite(l,u).mul(m.sub(2)).add(1)).toVar();return ii(u.greaterThan(2),()=>{v.y.addAssign(m),u.subAssign(3)}),v.x.addAssign(u.mul(m)),v.x.addAssign(h.mul(Kn(3,Bte))),v.y.addAssign(Kn(4,D0(s).sub(m))),v.x.mulAssign(n),v.y.mulAssign(r),i.sample(v).grad(Pt(),Pt())}),nS=Ze(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:l})=>{const u=pc(n),h=t.mul(u).add(r.cross(t).mul(So(n))).add(r.mul(r.dot(t).mul(u.oneMinus())));return tT(i,h,e,s,a,l)}),JU=Ze(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:s,dTheta:a,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})=>{const x=Ie(zs(e,t,Iy(t,n))).toVar();ii($M(x.equals(Ie(0))),()=>{x.assign(Ie(n.z,0,n.x.negate()))}),x.assign(Lc(x));const S=Ie().toVar();return S.addAssign(r.element(Ee(0)).mul(nS({theta:0,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),Bi({start:Ee(1),end:i},({i:T})=>{ii(T.greaterThanEqual(s),()=>{NU()});const N=ye(a.mul(ye(T))).toVar();S.addAssign(r.element(T).mul(nS({theta:N.mul(-1),axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v}))),S.addAssign(r.element(T).mul(nS({theta:N,axis:x,outputDirection:n,mipInt:l,envMap:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:v})))}),_n(S,1)});let ey=null;const n6=new WeakMap;function kte(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function zte(i){let e=n6.get(i);if((e!==void 0?e.pmremVersion:-1)!==i.pmremVersion){const n=i.image;if(i.isCubeTexture)if(qte(n))e=ey.fromCubemap(i,e);else return null;else if(Vte(n))e=ey.fromEquirectangular(i,e);else return null;e.pmremVersion=i.pmremVersion,n6.set(i,e)}return e.texture}class Gte extends Zr{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new ms;r.isRenderTargetTexture=!0,this._texture=fi(r),this._width=yn(0),this._height=yn(0),this._maxMip=yn(0),this.updateBeforeType=Qn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=kte(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(n.isPMREMTexture===!0?e=n:e=zte(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){ey===null&&(ey=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===Ga&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=Ie(t.x.negate(),t.yz)),t=Ie(t.x,t.y.negate(),t.z);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ZU(this._texture,t,r,this._width,this._height,this._maxMip)}}function qte(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n0}const SE=gt(Gte),i6=new WeakMap;class jte extends W0{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const S=n.isTextureNode?n.value:t[n.property];let T=i6.get(S);T===void 0&&(T=SE(S),i6.set(S,T)),n=T}const s=t.envMap?zi("envMapIntensity","float",e.material):zi("environmentIntensity","float",e.scene),l=t.useAnisotropy===!0||t.anisotropy>0?j9:kr,u=n.context(r6($l,l)).mul(s),h=n.context(Hte(qy)).mul(Math.PI).mul(s),m=Bm(u),v=Bm(h);e.context.radiance.addAssign(m),e.context.iblIrradiance.addAssign(v);const x=e.context.lightingModel.clearcoatRadiance;if(x){const S=n.context(r6(Sg,HA)).mul(s),T=Bm(S);x.addAssign(T)}}}const r6=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=hr.negate().reflect(e),t=i.mul(i).mix(t,e).normalize(),t=t.transformDirection(no)),t),getTextureLevel:()=>i}},Hte=i=>({getUV:()=>i,getTextureLevel:()=>ye(1)}),Wte=new aD;class eB extends qr{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(Wte),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new jte(t):null}setupLightingModel(){return new QU}setupSpecular(){const e=Ui(Ie(.04),Ri.rgb,bg);Oa.assign(e),wg.assign(1)}setupVariants(){const e=this.metalnessNode?ye(this.metalnessNode):J9;bg.assign(e);let t=this.roughnessNode?ye(this.roughnessNode):Z9;t=xE({roughness:t}),$l.assign(t),this.setupSpecular(),Ri.assign(_n(Ri.rgb.mul(e.oneMinus()),Ri.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const $te=new Lz;class Xte extends eB{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues($te),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?ye(this.iorNode):dU;Um.assign(e),Oa.assign(Ui(Za(tE(Um.sub(1).div(Um.add(1))).mul(K9),Ie(1)).mul(Qw),Ri.rgb,bg)),wg.assign(Ui(Qw,1,bg))}setupLightingModel(){return new QU(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?ye(this.clearcoatNode):tU,n=this.clearcoatRoughnessNode?ye(this.clearcoatRoughnessNode):nU;W_.assign(t),Sg.assign(xE({roughness:n}))}if(this.useSheen){const t=this.sheenNode?Ie(this.sheenNode):sU,n=this.sheenRoughnessNode?ye(this.sheenRoughnessNode):aU;Vf.assign(t),Py.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?ye(this.iridescenceNode):lU,n=this.iridescenceIORNode?ye(this.iridescenceIORNode):uU,r=this.iridescenceThicknessNode?ye(this.iridescenceThicknessNode):cU;Ly.assign(t),kM.assign(n),zM.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?Pt(this.anisotropyNode):oU).toVar();Th.assign(t.length()),ii(Th.equal(0),()=>{t.assign(Pt(1,0))}).Else(()=>{t.divAssign(Pt(Th)),Th.assign(Th.saturate())}),$_.assign(Th.pow2().mix($l.pow2(),1)),Lm.assign(jf[0].mul(t.x).add(jf[1].mul(t.y))),Zf.assign(jf[1].mul(t.x).sub(jf[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?ye(this.transmissionNode):hU,n=this.thicknessNode?ye(this.thicknessNode):fU,r=this.attenuationDistanceNode?ye(this.attenuationDistanceNode):AU,s=this.attenuationColorNode?Ie(this.attenuationColorNode):pU;if(Y_.assign(t),GM.assign(n),qM.assign(r),VM.assign(s),this.useDispersion){const a=this.dispersionNode?ye(this.dispersionNode):yU;jM.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Ie(this.clearcoatNormalNode):iU}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}const Yte=Ze(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=Pt(n.mul(.5).add(.5),0);if(t.material.gradientMap){const s=_c("gradientMap","texture").context({getUV:()=>r});return Ie(s.r)}else{const s=r.fwidth().mul(.5);return Ui(Ie(.7),Ie(1),Uc(ye(.7).sub(s.x),ye(.7).add(s.x),r.x))}});class Qte extends Wy{direct({lightDirection:e,lightColor:t,reflectedLight:n},r,s){const a=Yte({normal:zy,lightDirection:e,builder:s}).mul(t);n.directDiffuse.addAssign(a.mul(ld({diffuseColor:Ri.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(ld({diffuseColor:Ri}))),n.indirectDiffuse.mulAssign(e)}}const Kte=new Uz;class Zte extends qr{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Kte),this.setValues(e)}setupLightingModel(){return new Qte}}class Jte extends Zr{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=Ie(hr.z,0,hr.x.negate()).normalize(),t=hr.cross(e);return Pt(e.dot(kr),t.dot(kr)).mul(.495).add(.5)}}const tB=Xt(Jte),ene=new Fz;class tne extends qr{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(ene),this.setValues(e)}setupVariants(e){const t=tB;let n;e.material.matcap?n=_c("matcap","texture").context({getUV:()=>t}):n=Ie(Ui(.2,.8,t.y)),Ri.rgb.mulAssign(n.rgb)}}const nne=new eM;class ine extends qr{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.setDefaultValues(nne),this.setValues(e)}}class rne extends Zr{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),a=t.sin();return Dy(s,a,a.negate(),s).mul(n)}else{const s=t,a=Kf(_n(1,0,0,0),_n(0,pc(s.x),So(s.x).negate(),0),_n(0,So(s.x),pc(s.x),0),_n(0,0,0,1)),l=Kf(_n(pc(s.y),0,So(s.y),0),_n(0,1,0,0),_n(So(s.y).negate(),0,pc(s.y),0),_n(0,0,0,1)),u=Kf(_n(pc(s.z),So(s.z).negate(),0,0),_n(So(s.z),pc(s.z),0,0),_n(0,0,1,0),_n(0,0,0,1));return a.mul(l).mul(u).mul(_n(n,1)).xyz}}}const wE=gt(rne),sne=new Qk;class ane extends qr{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(sne),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,r=this.sizeAttenuation,{positionNode:s,rotationNode:a,scaleNode:l}=this,u=H0.mul(Ie(s||0));let h=Pt(Ho[0].xyz.length(),Ho[1].xyz.length());if(l!==null&&(h=h.mul(l)),r===!1)if(n.isPerspectiveCamera)h=h.mul(u.z.negate());else{const S=ye(2).div(Ad.element(1).element(1));h=h.mul(S.mul(2))}let m=ky.xy;if(t.center&&t.center.isVector2===!0){const S=MJ("center","vec2",t);m=m.sub(S.sub(.5))}m=m.mul(h);const v=ye(a||rU),x=wE(m,v);return _n(u.xy.add(x),u.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class one extends Wy{constructor(){super(),this.shadowNode=ye(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Ri.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Ri.rgb)}}const lne=new Pz;class une extends qr{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lne),this.setValues(e)}setupLightingModel(){return new one}}const cne=Ze(({texture:i,uv:e})=>{const n=Ie().toVar();return ii(e.x.lessThan(1e-4),()=>{n.assign(Ie(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(Ie(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(Ie(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(Ie(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(Ie(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(Ie(0,0,-1))}).Else(()=>{const s=i.sample(e.add(Ie(-.01,0,0))).r.sub(i.sample(e.add(Ie(.01,0,0))).r),a=i.sample(e.add(Ie(0,-.01,0))).r.sub(i.sample(e.add(Ie(0,.01,0))).r),l=i.sample(e.add(Ie(0,0,-.01))).r.sub(i.sample(e.add(Ie(0,0,.01))).r);n.assign(Ie(s,a,l))}),n.normalize()});class hne extends pu{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Ie(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(Ee(Uh(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return cne({texture:this,uv:e})}}const fne=gt(hne);class dne{constructor(e,t){this.nodes=e,this.info=t,this._context=self,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,n)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}setAnimationLoop(e){this._animationLoop=e}setContext(e){this._context=e}dispose(){this.stop()}}class vu{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().monitor)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,n=[],r=new Set;for(const s of e){const a=s.node&&s.node.attribute?s.node.attribute:t.getAttribute(s.name);if(a===void 0)continue;n.push(a);const l=a.isInterleavedBufferAttribute?a.data:a;r.add(l)}return this.attributes=n,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:s}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),l=this.getIndex(),u=l!==null,h=n.isInstancedBufferGeometry?n.instanceCount:e.count>1?e.count:1;if(h===0)return null;if(a.instanceCount=h,e.isBatchedMesh===!0)return a;let m=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(m=2);let v=s.start*m,x=(s.start+s.count)*m;r!==null&&(v=Math.max(v,r.start*m),x=Math.min(x,(r.start+r.count)*m));const S=n.attributes.position;let T=1/0;u?T=l.count:S!=null&&(T=S.count),v=Math.max(v,0),x=Math.min(x,T);const N=x-v;return N<0||N===1/0?null:(a.vertexCount=N,a.firstVertex=v,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let n=t.customProgramCacheKey();for(const r of pne(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(r))continue;const s=t[r];let a;if(s!==null){const l=typeof s;l==="number"?a=s!==0?"1":"0":l==="object"?(a="{",s.isTexture&&(a+=s.mapping),a+="}"):a=String(s)}else a=String(s);n+=a+","}return n+=this.clippingContextCacheKey+",",e.geometry&&(n+=this.getGeometryCacheKey()),e.skeleton&&(n+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(n+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(n+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(n+=e._colorsTexture.uuid+",")),e.count>1&&(n+=e.uuid+","),n+=e.receiveShadow+",",OP(n)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=this._nodes.getCacheKey(this.scene,this.lightsNode);return this.object.receiveShadow&&(e+=1),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const bA=[];class gne{constructor(e,t,n,r,s,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=s,this.info=a,this.chainMaps={}}get(e,t,n,r,s,a,l,u){const h=this.getChainMap(u);bA[0]=e,bA[1]=t,bA[2]=a,bA[3]=s;let m=h.get(bA);return m===void 0?(m=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,s,a,l,u),h.set(bA,m)):(m.updateClipping(l),m.needsGeometryUpdate&&m.setGeometry(e.geometry),(m.version!==t.version||m.needsUpdate)&&(m.initialCacheKey!==m.getCacheKey()?(m.dispose(),m=this.get(e,t,n,r,s,a,l,u)):m.version=t.version)),m}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new vu)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,s,a,l,u,h,m,v){const x=this.getChainMap(v),S=new mne(e,t,n,r,s,a,l,u,h,m);return S.onDispose=()=>{this.pipelines.delete(S),this.bindings.delete(S),this.nodes.delete(S),x.delete(S.getChainArray())},S}}class Hh{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Zl={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Nh=16,vne=211,_ne=212;class yne extends Hh{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==void 0&&this.backend.destroyAttribute(e),t}update(e,t){const n=this.get(e);if(n.version===void 0)t===Zl.VERTEX?this.backend.createAttribute(e):t===Zl.INDEX?this.backend.createIndexAttribute(e):t===Zl.STORAGE?this.backend.createStorageAttribute(e):t===Zl.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version=0;--e)if(i[e]>=65535)return!0;return!1}function nB(i){return i.index!==null?i.index.version:i.attributes.position.version}function s6(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const s=t.array;for(let a=0,l=s.length;a{this.info.memory.geometries--;const s=t.index,a=e.getAttributes();s!==null&&this.attributes.delete(s);for(const u of a)this.attributes.delete(u);const l=this.wireframes.get(t);l!==void 0&&this.attributes.delete(l),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,Zl.STORAGE):this.updateAttribute(s,Zl.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,Zl.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Zl.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const s=this.wireframes;let a=s.get(t);a===void 0?(a=s6(t),s.set(t,a)):a.version!==nB(t)&&(this.attributes.delete(a),a=s6(t),s.set(t,a)),r=a}return r}}class Sne{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){this[e].timestampCalls===0&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class iB{constructor(e){this.cacheKey=e,this.usedTimes=0}}class wne extends iB{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class Tne extends iB{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Mne=0;class iS{constructor(e,t,n,r=null,s=null){this.id=Mne++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=s,this.usedTimes=0}}class Ene extends Hh{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let l=this.programs.compute.get(a.computeShader);l===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),l=new iS(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,l),n.createProgram(l));const u=this._getComputeCacheKey(e,l);let h=this.caches.get(u);h===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),h=this._getComputePipeline(e,l,u,t)),h.usedTimes++,l.usedTimes++,r.version=e.version,r.pipeline=h}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const s=r.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),l=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),u=new iS(a.vertexShader,"vertex",l),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let h=this.programs.fragment.get(a.fragmentShader);h===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),h=new iS(a.fragmentShader,"fragment",l),this.programs.fragment.set(a.fragmentShader,h),n.createProgram(h));const m=this._getRenderCacheKey(e,u,h);let v=this.caches.get(m);v===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),v=this._getRenderPipeline(e,u,h,m,t)):e.pipeline=v,v.usedTimes++,u.usedTimes++,h.usedTimes++,r.pipeline=v}return r.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,n,r){n=n||this._getComputeCacheKey(e,t);let s=this.caches.get(n);return s===void 0&&(s=new Tne(n,t),this.caches.set(n,s),this.backend.createComputePipeline(s,r)),s}_getRenderPipeline(e,t,n,r,s){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new wne(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,s)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Cne extends Hh{constructor(e,t,n,r,s,a){super(),this.backend=e,this.textures=n,this.pipelines=s,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?Zl.INDIRECT:Zl.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,s=!0,a=0,l=0;for(const u of e.bindings)if(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampler)u.update();else if(u.isSampledTexture){const h=this.textures.get(u.texture);u.needsBindingsUpdate(h.generation)&&(r=!0);const m=u.update(),v=u.texture;m&&this.textures.updateTexture(v);const x=n.get(v);if(x.externalTexture!==void 0||h.isDefaultTexture?s=!1:(a=a*10+v.id,l+=v.version),n.isWebGPUBackend===!0&&x.texture===void 0&&x.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",u,m,v,u.textureNode.value,r),this.textures.updateTexture(v),r=!0),v.isStorageTexture===!0){const S=this.get(v);u.store===!0?S.needsMipmap=!0:this.textures.needsMipmaps(v)&&S.needsMipmap===!0&&(this.backend.generateMipmaps(v),S.needsMipmap=!1)}}}r===!0&&this.backend.updateBindings(e,t,s?a:0,l)}}function Nne(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function a6(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function o6(i){return(i.transmission>0||i.transmissionNode)&&i.side===as&&i.forceSinglePass===!1}class Rne{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,n,r,s,a,l){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:s,group:a,clippingContext:l},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=s,u.group=a,u.clippingContext=l),this.renderItemsIndex++,u}push(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0?(o6(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,s,a,l){const u=this.getNextRenderItem(e,t,n,r,s,a,l);n.transparent===!0||n.transmission>0?(o6(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||Nne),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||a6),this.transparent.length>1&&this.transparent.sort(t||a6)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,h=l.height>>t;let m=e.depthTexture||s[t];const v=e.depthBuffer===!0||e.stencilBuffer===!0;let x=!1;m===void 0&&v&&(m=new Ic,m.format=e.stencilBuffer?uu:tu,m.type=e.stencilBuffer?lu:Nr,m.image.width=u,m.image.height=h,s[t]=m),(n.width!==l.width||l.height!==n.height)&&(x=!0,m&&(m.needsUpdate=!0,m.image.width=u,m.image.height=h)),n.width=l.width,n.height=l.height,n.textures=a,n.depthTexture=m||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(x=!0,m&&(m.needsUpdate=!0),n.sampleCount=r);const S={sampleCount:r};for(let T=0;T{e.removeEventListener("dispose",T);for(let N=0;N0){const m=e.image;if(m===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(m.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const v=[];for(const x of e.images)v.push(x);t.images=v}else t.image=m;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(s.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&s.generateMipmaps(e)}}else s.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++;const h=()=>{e.removeEventListener("dispose",h),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",h)}n.version=e.version}getSize(e,t=Bne){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.isCompressedTexture?e.mipmaps?r=e.mipmaps.length:r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return this.isEnvironmentTexture(e)||e.isCompressedTexture===!0||e.generateMipmaps}isEnvironmentTexture(e){const t=e.mapping;return t===Oh||t===Ih||t===Xo||t===Yo}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class TE extends cn{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class sB extends Ii{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const Ine=(i,e)=>wt(new sB(i,e));class Fne extends Nn{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new Pm(t);return this._currentCond=zs(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Pm(t),r=zs(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Pm(e),this}build(e,...t){const n=BM();yg(this);for(const r of this.nodes)r.build(e,"void");return yg(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const Zv=gt(Fne);class aB extends Nn{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,n=[];for(let r=0;r{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),nT=(i,e)=>Tl(Kn(4,i.mul(yi(1,i))),e),qne=(i,e)=>i.lessThan(.5)?nT(i.mul(2),e).div(2):yi(1,nT(Kn(yi(1,i),2),e).div(2)),Vne=(i,e,t)=>Tl(Cl(Tl(i,e),Qr(Tl(i,e),Tl(yi(1,i),t))),1/e),jne=(i,e)=>So(Q_.mul(e.mul(i).sub(1))).div(Q_.mul(e.mul(i).sub(1))),mc=Ze(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Hne=Ze(([i])=>Ie(mc(i.z.add(mc(i.y.mul(1)))),mc(i.z.add(mc(i.x.mul(1)))),mc(i.y.add(mc(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Wne=Ze(([i,e,t])=>{const n=Ie(i).toVar(),r=ye(1.4).toVar(),s=ye(0).toVar(),a=Ie(n).toVar();return Bi({start:ye(0),end:ye(3),type:"float",condition:"<="},()=>{const l=Ie(Hne(a.mul(2))).toVar();n.addAssign(l.add(t.mul(ye(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const u=ye(mc(n.z.add(mc(n.x.add(mc(n.y)))))).toVar();s.addAssign(u.div(r)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class $ne extends Nn{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let r=null,s=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const h=u.inputs;if(t.length===h.length){let m=0;for(let v=0;vs&&(r=a,s=m)}}this._candidateFnCall=n=r(...t)}return n}}const Xne=gt($ne),Vs=i=>(...e)=>Xne(i,...e),pd=yn(0).setGroup(Ln).onRenderUpdate(i=>i.time),uB=yn(0).setGroup(Ln).onRenderUpdate(i=>i.deltaTime),Yne=yn(0,"uint").setGroup(Ln).onRenderUpdate(i=>i.frameId),Qne=(i=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),pd.mul(i)),Kne=(i=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),pd.mul(i)),Zne=(i=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),uB.mul(i)),Jne=(i=pd)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),eie=(i=pd)=>i.fract().round(),tie=(i=pd)=>i.add(.5).fract().mul(2).sub(1).abs(),nie=(i=pd)=>i.fract(),iie=Ze(([i,e,t=Pt(.5)])=>wE(i.sub(t),e).add(t)),rie=Ze(([i,e,t=Pt(.5)])=>{const n=i.sub(t),r=n.dot(n),a=r.mul(r).mul(e);return i.add(n.mul(a))}),sie=Ze(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=Ho.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=Ho;const r=no.mul(n);return _g(e)&&(r[0][0]=Ho[0].length(),r[0][1]=0,r[0][2]=0),_g(t)&&(r[1][0]=0,r[1][1]=Ho[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,Ad.mul(r).mul(zr)}),aie=Ze(([i=null])=>{const e=J_();return J_(pE(i)).sub(e).lessThan(0).select(gu,i)});class oie extends Nn{static get type(){return"SpriteSheetUVNode"}constructor(e,t=Mr(),n=ye(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:s}=n,a=e.mod(r.mul(s)).floor(),l=a.mod(r),u=s.sub(a.add(1).div(r).ceil()),h=n.reciprocal(),m=Pt(l,u);return t.add(m).mul(h)}}const lie=gt(oie);class uie extends Nn{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,n=null,r=ye(1),s=zr,a=Ja){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=s,this.normalNode=a}setup(){const{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:s,normalNode:a}=this;let l=a.abs().normalize();l=l.div(l.dot(Ie(1)));const u=s.yz.mul(r),h=s.zx.mul(r),m=s.xy.mul(r),v=e.value,x=t!==null?t.value:v,S=n!==null?n.value:v,T=fi(v,u).mul(l.x),N=fi(x,h).mul(l.y),C=fi(S,m).mul(l.z);return Qr(T,N,C)}}const cB=gt(uie),cie=(...i)=>cB(...i),SA=new jl,Sf=new pe,wA=new pe,rS=new pe,am=new jn,hv=new pe(0,0,-1),kl=new On,om=new pe,fv=new pe,lm=new On,dv=new bt,ty=new qh,hie=gu.flipX();ty.depthTexture=new Ic(1,1);let sS=!1;class ME extends pu{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||ty.texture,hie),this._reflectorBaseNode=e.reflector||new fie(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=wt(new ME({defaultTexture:ty.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}}class fie extends Nn{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new pr,resolution:r=1,generateMipmaps:s=!1,bounces:a=!0,depth:l=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=s,this.bounces=a,this.depth=l,this.updateBeforeType=a?Qn.RENDER:Qn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const n=this.resolution;t.getDrawingBufferSize(dv),e.setSize(Math.round(dv.width*n),Math.round(dv.height*n))}setup(e){return this._updateResolution(ty,e.renderer),super.setup(e)}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new qh(0,0,{type:Gs}),this.generateMipmaps===!0&&(t.texture.minFilter=WF,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Ic),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&sS)return!1;sS=!0;const{scene:t,camera:n,renderer:r,material:s}=e,{target:a}=this,l=this.getVirtualCamera(n),u=this.getRenderTarget(l);if(r.getDrawingBufferSize(dv),this._updateResolution(u,r),wA.setFromMatrixPosition(a.matrixWorld),rS.setFromMatrixPosition(n.matrixWorld),am.extractRotation(a.matrixWorld),Sf.set(0,0,1),Sf.applyMatrix4(am),om.subVectors(wA,rS),om.dot(Sf)>0)return;om.reflect(Sf).negate(),om.add(wA),am.extractRotation(n.matrixWorld),hv.set(0,0,-1),hv.applyMatrix4(am),hv.add(rS),fv.subVectors(wA,hv),fv.reflect(Sf).negate(),fv.add(wA),l.coordinateSystem=n.coordinateSystem,l.position.copy(om),l.up.set(0,1,0),l.up.applyMatrix4(am),l.up.reflect(Sf),l.lookAt(fv),l.near=n.near,l.far=n.far,l.updateMatrixWorld(),l.projectionMatrix.copy(n.projectionMatrix),SA.setFromNormalAndCoplanarPoint(Sf,wA),SA.applyMatrix4(l.matrixWorldInverse),kl.set(SA.normal.x,SA.normal.y,SA.normal.z,SA.constant);const h=l.projectionMatrix;lm.x=(Math.sign(kl.x)+h.elements[8])/h.elements[0],lm.y=(Math.sign(kl.y)+h.elements[9])/h.elements[5],lm.z=-1,lm.w=(1+h.elements[10])/h.elements[14],kl.multiplyScalar(1/kl.dot(lm));const m=0;h.elements[2]=kl.x,h.elements[6]=kl.y,h.elements[10]=r.coordinateSystem===cu?kl.z-m:kl.z+1-m,h.elements[14]=kl.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),s.visible=!1;const v=r.getRenderTarget(),x=r.getMRT(),S=r.autoClear;r.setMRT(null),r.setRenderTarget(u),r.autoClear=!0,r.render(t,l),r.setMRT(x),r.setRenderTarget(v),r.autoClear=S,s.visible=!0,sS=!1}}const die=i=>wt(new ME(i)),aS=new Ig(-1,1,1,-1,0,1);class Aie extends Hi{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Si([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Si(t,2))}}const pie=new Aie;class EE extends Oi{constructor(e=null){super(pie,e),this.camera=aS,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,aS)}render(e){e.render(this,aS)}}const mie=new bt;class gie extends pu{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:Gs}){const s=new qh(t,n,r);super(s.texture,Mr()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new EE(new qr),this.updateBeforeType=Qn.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const n=e.getSize(mie);this.setSize(n.width,n.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new pu(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const hB=(i,...e)=>wt(new gie(wt(i),...e)),vie=(i,...e)=>i.isTextureNode?i:i.isPassNode?i.getTextureNode():hB(i,...e),BA=Ze(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===cu?(i=Pt(i.x,i.y.oneMinus()).mul(2).sub(1),r=_n(Ie(i,e),1)):r=_n(Ie(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const s=_n(t.mul(r));return s.xyz.div(s.w)}),_ie=Ze(([i,e])=>{const t=e.mul(_n(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Pt(n.x,n.y.oneMinus())}),yie=Ze(([i,e,t])=>{const n=Uh(Ir(e)),r=As(i.mul(n)).toVar(),s=Ir(e,r).toVar(),a=Ir(e,r.sub(As(2,0))).toVar(),l=Ir(e,r.sub(As(1,0))).toVar(),u=Ir(e,r.add(As(1,0))).toVar(),h=Ir(e,r.add(As(2,0))).toVar(),m=Ir(e,r.add(As(0,2))).toVar(),v=Ir(e,r.add(As(0,1))).toVar(),x=Ir(e,r.sub(As(0,1))).toVar(),S=Ir(e,r.sub(As(0,2))).toVar(),T=rr(yi(ye(2).mul(l).sub(a),s)).toVar(),N=rr(yi(ye(2).mul(u).sub(h),s)).toVar(),C=rr(yi(ye(2).mul(v).sub(m),s)).toVar(),E=rr(yi(ye(2).mul(x).sub(S),s)).toVar(),O=BA(i,s,t).toVar(),U=T.lessThan(N).select(O.sub(BA(i.sub(Pt(ye(1).div(n.x),0)),l,t)),O.negate().add(BA(i.add(Pt(ye(1).div(n.x),0)),u,t))),I=C.lessThan(E).select(O.sub(BA(i.add(Pt(0,ye(1).div(n.y))),v,t)),O.negate().add(BA(i.sub(Pt(0,ye(1).div(n.y))),x,t)));return Lc(Iy(U,I))});class Jv extends Bg{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class xie extends wr{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}class bie extends dd{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}const Sie=gt(bie);class wie extends lE{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t=FP(e.itemSize),n=e.count),super(e,t,n),this.isStorageBufferNode=!0,this.access=ia.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Sie(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(ia.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Hg(this.value),this._varying=to(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}generate(e){if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const Xy=(i,e=null,t=0)=>wt(new wie(i,e,t)),Tie=(i,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Xy(i,e,t).setPBO(!0)),Mie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new xie(i,t,n);return Xy(r,e,i)},Eie=(i,e="float")=>{const t=zP(e),n=kP(e),r=new Jv(i,t,n);return Xy(r,e,i)};class Cie extends T9{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new On(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const Nie=i=>wt(new Cie(i));class Rie extends Nn{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const Die=Xt(Rie),um=new aa,oS=new jn;class Wa extends Nn{static get type(){return"SceneNode"}constructor(e=Wa.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let r;return t===Wa.BACKGROUND_BLURRINESS?r=zi("backgroundBlurriness","float",n):t===Wa.BACKGROUND_INTENSITY?r=zi("backgroundIntensity","float",n):t===Wa.BACKGROUND_ROTATION?r=yn("mat4").label("backgroundRotation").setGroup(Ln).onRenderUpdate(()=>{const s=n.background;return s!==null&&s.isTexture&&s.mapping!==OT?(um.copy(n.backgroundRotation),um.x*=-1,um.y*=-1,um.z*=-1,oS.makeRotationFromEuler(um)):oS.identity(),oS}):console.error("THREE.SceneNode: Unknown scope:",t),r}}Wa.BACKGROUND_BLURRINESS="backgroundBlurriness";Wa.BACKGROUND_INTENSITY="backgroundIntensity";Wa.BACKGROUND_ROTATION="backgroundRotation";const fB=Xt(Wa,Wa.BACKGROUND_BLURRINESS),iT=Xt(Wa,Wa.BACKGROUND_INTENSITY),dB=Xt(Wa,Wa.BACKGROUND_ROTATION);class Pie extends pu{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=ia.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(ia.READ_WRITE)}toReadOnly(){return this.setAccess(ia.READ_ONLY)}toWriteOnly(){return this.setAccess(ia.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:r}=t,s=super.generate(e,"property"),a=n.build(e,"uvec2"),l=r.build(e,"vec4"),u=e.generateTextureStore(e,s,a,l);e.addLineFlowCode(u,this)}}const AB=gt(Pie),Lie=(i,e,t)=>{const n=AB(i,e,t);return t!==null&&n.append(),n};class Uie extends Vy{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const Bie=(i,e,t)=>wt(new Uie(i,e,t)),l6=new WeakMap;class Oie extends Zr{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Qn.OBJECT,this.updateAfterType=Qn.OBJECT,this.previousModelWorldMatrix=yn(new jn),this.previousProjectionMatrix=yn(new jn).setGroup(Ln),this.previousCameraViewMatrix=yn(new jn)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=u6(n);this.previousModelWorldMatrix.value.copy(r);const s=pB(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new jn,s.previousCameraViewMatrix=new jn,s.currentProjectionMatrix=new jn,s.currentCameraViewMatrix=new jn,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){u6(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Ad:yn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(H0).mul(zr),r=this.previousProjectionMatrix.mul(t).mul(Z_),s=n.xy.div(n.w),a=r.xy.div(r.w);return yi(s,a)}}function pB(i){let e=l6.get(i);return e===void 0&&(e={},l6.set(i,e)),e}function u6(i,e=0){const t=pB(i);let n=t[e];return n===void 0&&(t[e]=n=new jn),n}const Iie=Xt(Oie),mB=Ze(([i,e])=>Za(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),gB=Ze(([i,e])=>Za(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vB=Ze(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),_B=Ze(([i,e])=>Ui(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Oy(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Fie=Ze(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return _n(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),kie=(...i)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),mB(i)),zie=(...i)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),gB(i)),Gie=(...i)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),vB(i)),qie=(...i)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),_B(i)),Vie=Ze(([i])=>CE(i.rgb)),jie=Ze(([i,e=ye(1)])=>e.mix(CE(i.rgb),i.rgb)),Hie=Ze(([i,e=ye(1)])=>{const t=Qr(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),r=n.sub(t).mul(e).mul(-3);return Ui(i.rgb,n,r)}),Wie=Ze(([i,e=ye(1)])=>{const t=Ie(.57735,.57735,.57735),n=e.cos();return Ie(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(jh(t,i.rgb).mul(n.oneMinus())))))}),CE=(i,e=Ie(li.getLuminanceCoefficients(new pe)))=>jh(i,e),$ie=Ze(([i,e=Ie(1),t=Ie(0),n=Ie(1),r=ye(1),s=Ie(li.getLuminanceCoefficients(new pe,Mo))])=>{const a=i.rgb.dot(Ie(s)),l=Gr(i.rgb.mul(e).add(t),0).toVar(),u=l.pow(n).toVar();return ii(l.r.greaterThan(0),()=>{l.r.assign(u.r)}),ii(l.g.greaterThan(0),()=>{l.g.assign(u.g)}),ii(l.b.greaterThan(0),()=>{l.b.assign(u.b)}),l.assign(a.add(l.sub(a).mul(r))),_n(l.rgb,i.a)});class Xie extends Zr{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const Yie=gt(Xie),Qie=new bt;class yB extends pu{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class c6 extends yB{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class _u extends Zr{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const s=new Ic;s.isRenderTargetTexture=!0,s.name="depth";const a=new qh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Gs,...r});a.texture.name="output",a.depthTexture=s,this.renderTarget=a,this._textures={output:a.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=yn(0),this._cameraFar=yn(0),this._mrt=null,this.isPassNode=!0,this.updateBeforeType=Qn.FRAME}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=wt(new c6(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=wt(new c6(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=mE(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=e0(s,n,r)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.scope===_u.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:r}=this;this._pixelRatio=t.getPixelRatio();const s=t.getSize(Qie);this.setSize(s.width,s.height);const a=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=r.near,this._cameraFar.value=r.far;for(const u in this._previousTextures)this.toggleTexture(u);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(a),t.setMRT(l)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}_u.COLOR="color";_u.DEPTH="depth";const Kie=(i,e,t)=>wt(new _u(_u.COLOR,i,e,t)),Zie=(i,e)=>wt(new yB(i,e)),Jie=(i,e,t)=>wt(new _u(_u.DEPTH,i,e,t));class ere extends _u{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,s){super(_u.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((r,s,a,l,u,h,m,v)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const x=this._getOutlineMaterial(u);t.renderObject(r,s,a,l,x,h,m,v)}t.renderObject(r,s,a,l,u,h,m,v)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new qr;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=or;const t=Ja.negate(),n=Ad.mul(H0),r=ye(1),s=n.mul(_n(zr,1)),a=n.mul(_n(zr.add(t),1)),l=Lc(s.sub(a));return e.vertexNode=s.add(l.mul(this.thicknessNode).mul(s.w).mul(r)),e.colorNode=_n(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const tre=(i,e,t=new cn(0,0,0),n=.003,r=1)=>wt(new ere(i,e,wt(t),wt(n),wt(r))),xB=Ze(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),bB=Ze(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SB=Ze(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),nre=Ze(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),wB=Ze(([i,e])=>{const t=ua(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=ua(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=nre(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ire=ua(Ie(1.6605,-.1246,-.0182),Ie(-.5876,1.1329,-.1006),Ie(-.0728,-.0083,1.1187)),rre=ua(Ie(.6274,.0691,.0164),Ie(.3293,.9195,.088),Ie(.0433,.0113,.8956)),sre=Ze(([i])=>{const e=Ie(i).toVar(),t=Ie(e.mul(e)).toVar(),n=Ie(t.mul(t)).toVar();return ye(15.5).mul(n.mul(t)).sub(Kn(40.14,n.mul(e))).add(Kn(31.96,n).sub(Kn(6.868,t.mul(e))).add(Kn(.4298,t).add(Kn(.1191,e).sub(.00232))))}),TB=Ze(([i,e])=>{const t=Ie(i).toVar(),n=ua(Ie(.856627153315983,.137318972929847,.11189821299995),Ie(.0951212405381588,.761241990602591,.0767994186031903),Ie(.0482516061458583,.101439036467562,.811302368396859)),r=ua(Ie(1.1271005818144368,-.1413297634984383,-.14132976349843826),Ie(-.11060664309660323,1.157823702216272,-.11060664309660294),Ie(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=ye(-12.47393),a=ye(4.026069);return t.mulAssign(e),t.assign(rre.mul(t)),t.assign(n.mul(t)),t.assign(Gr(t,1e-10)),t.assign(su(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(du(t,0,1)),t.assign(sre(t)),t.assign(r.mul(t)),t.assign(Tl(Gr(Ie(0),t),Ie(2.2))),t.assign(ire.mul(t)),t.assign(du(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MB=Ze(([i,e])=>{const t=ye(.76),n=ye(.15);i=i.mul(e);const r=Za(i.r,Za(i.g,i.b)),s=zs(r.lessThan(.08),r.sub(Kn(6.25,r.mul(r))),.04);i.subAssign(s);const a=Gr(i.r,Gr(i.g,i.b));ii(a.lessThan(t),()=>i);const l=yi(1,t),u=yi(1,l.mul(l).div(a.add(l.sub(t))));i.mulAssign(u.div(a));const h=yi(1,Cl(1,n.mul(a.sub(u)).add(1)));return Ui(i,Ie(u),h)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class rs extends Nn{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.includes=t,this.language=n}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Yy=gt(rs),are=(i,e)=>Yy(i,e,"js"),ore=(i,e)=>Yy(i,e,"wgsl"),lre=(i,e)=>Yy(i,e,"glsl");class EB extends rs{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,s=n.type,a=e.getCodeFromNode(this,s);r!==""&&(a.name=r);const l=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(l);return a.code=u+` +`,t==="property"?l:e.format(`${l}()`,s,t)}}const CB=(i,e=[],t="")=>{for(let s=0;sn.call(...s);return r.functionNode=n,r},ure=(i,e)=>CB(i,e,"glsl"),cre=(i,e)=>CB(i,e,"wgsl");class hre extends Nn{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Bc,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:ye()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=VP(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=jP(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const e_=gt(hre);class NB extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class fre{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const t_=new NB;class dre extends Nn{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new NB,this._output=e_(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=e_(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=e_(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r(...t)}async callAsync(e,...t){const r=this.getObject()[e];if(typeof r=="function")return r.constructor.name==="AsyncFunction"?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(h,m)=>this.setOutput(h,m),n=new fre(this),r=t_.get("THREE"),s=t_.get("TSL"),a=this.getMethod(),l=[n,this._local,t_,e,t,r,s];this._object=a(...l);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const h of u.elements){const m=h.id||h.name;h.inputType&&(this.getParameter(m)===void 0&&this.setParameter(m,null),this.getParameter(m).inputType=h.inputType),h.outputType&&(this.getOutput(m)===void 0&&this.setOutput(m,null),this.getOutput(m).outputType=h.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:ye()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),r="var "+n+`; var output = {}; `,s=` -return { ...output, `+n+" };",a=r+this.codeNode.code+s;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[OP(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Cy(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Are=gt(dre);function RB(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Xr.z).negate()}const NE=Ke(([i,e],t)=>{const n=RB(t);return Uc(i,e,n)}),RE=Ke(([i],e)=>{const t=RB(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Cg=Ke(([i,e])=>_n(e.toFloat().mix(Tg.rgb,i.toVec3()),Tg.a));function pre(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Cg(i,NE(e,t))}function mre(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Cg(i,RE(e))}let wf=null,Tf=null;class gre extends Nn{static get type(){return"RangeNode"}constructor(e=xe(),t=xe()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Rh(this.minNode.value)),n=e.getTypeLength(Rh(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Rh(r)),l=e.getTypeLength(Rh(s));wf=wf||new On,Tf=Tf||new On,wf.setScalar(0),Tf.setScalar(0),a===1?wf.setScalar(r):r.isColor?wf.set(r.r,r.g,r.b,1):wf.set(r.x,r.y,r.z||0,r.w||0),l===1?Tf.setScalar(s):s.isColor?Tf.set(s.r,s.g,s.b,1):Tf.set(s.x,s.y,s.z||0,s.w||0);const u=4,h=u*t.count,m=new Float32Array(h);for(let x=0;xwt(new _re(i,e)),yre=Qy("numWorkgroups","uvec3"),xre=Qy("workgroupId","uvec3"),bre=Qy("localId","uvec3"),Sre=Qy("subgroupSize","uint");class wre extends Nn{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier -`):e.addLineFlowCode(`${t}Barrier()`,this)}}const DE=gt(wre),Tre=()=>DE("workgroup").append(),Mre=()=>DE("storage").append(),Ere=()=>DE("texture").append();class Cre extends dd{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}class Nre extends Nn{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return wt(new Cre(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const Rre=(i,e)=>wt(new Nre("Workgroup",i,e));class Rs extends Zr{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,l=[];l.push(`&${s.build(e,r)}`),l.push(a.build(e,r));const u=`${e.getMethod(t,n)}( ${l.join(", ")} )`;if(this.storeNode!==null){const h=this.storeNode.build(e,r);e.addLineFlowCode(`${h} = ${u}`,this)}else e.addLineFlowCode(u,this)}}Rs.ATOMIC_LOAD="atomicLoad";Rs.ATOMIC_STORE="atomicStore";Rs.ATOMIC_ADD="atomicAdd";Rs.ATOMIC_SUB="atomicSub";Rs.ATOMIC_MAX="atomicMax";Rs.ATOMIC_MIN="atomicMin";Rs.ATOMIC_AND="atomicAnd";Rs.ATOMIC_OR="atomicOr";Rs.ATOMIC_XOR="atomicXor";const Dre=gt(Rs),zc=(i,e,t,n=null)=>{const r=Dre(i,e,t,n);return r.append(),r},Pre=(i,e,t=null)=>zc(Rs.ATOMIC_STORE,i,e,t),Lre=(i,e,t=null)=>zc(Rs.ATOMIC_ADD,i,e,t),Ure=(i,e,t=null)=>zc(Rs.ATOMIC_SUB,i,e,t),Bre=(i,e,t=null)=>zc(Rs.ATOMIC_MAX,i,e,t),Ore=(i,e,t=null)=>zc(Rs.ATOMIC_MIN,i,e,t),Ire=(i,e,t=null)=>zc(Rs.ATOMIC_AND,i,e,t),Fre=(i,e,t=null)=>zc(Rs.ATOMIC_OR,i,e,t),kre=(i,e,t=null)=>zc(Rs.ATOMIC_XOR,i,e,t);let Av;function Jg(i){Av=Av||new WeakMap;let e=Av.get(i);return e===void 0&&Av.set(i,e={}),e}function PE(i){const e=Jg(i);return e.shadowMatrix||(e.shadowMatrix=yn("mat4").setGroup(Ln).onRenderUpdate(()=>(i.castShadow!==!0&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function DB(i){const e=Jg(i);if(e.projectionUV===void 0){const t=PE(i).mul(Tc);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function LE(i){const e=Jg(i);return e.position||(e.position=yn(new me).setGroup(Ln).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function PB(i){const e=Jg(i);return e.targetPosition||(e.targetPosition=yn(new me).setGroup(Ln).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function Ky(i){const e=Jg(i);return e.viewPosition||(e.viewPosition=yn(new me).setGroup(Ln).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new me,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const UE=i=>no.transformDirection(LE(i).sub(PB(i))),zre=i=>i.sort((e,t)=>e.id-t.id),Gre=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},lS=new WeakMap;class BE extends Nn{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Ie().toVar("totalDiffuse"),this.totalSpecularNode=Ie().toVar("totalSpecular"),this.outgoingLightNode=Ie().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let n=0;n0}}const qre=(i=[])=>wt(new BE).setLights(i);class Vre extends Nn{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Qn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({material:e}){OE.assign(e.shadowPositionNode||Tc)}dispose(){this.updateBeforeType=Qn.NONE}}const OE=Ie().toVar("shadowPositionWorld");function jre(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new cn),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function Hre(i,e){return e=jre(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function Wre(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function $re(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function Xre(i,e){return e=$re(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function Yre(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function Qre(i,e,t){return t=Hre(i,t),t=Xre(e,t),t}function Kre(i,e,t){Wre(i,t),Yre(e,t)}const h6=new WeakMap,Zre=Ke(([i,e,t])=>{let n=Tc.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),Jre=i=>{const e=i.shadow.camera,t=zi("near","float",e).setGroup(Ln),n=zi("far","float",e).setGroup(Ln),r=C9(i);return Zre(r,t,n)},ese=i=>{let e=h6.get(i);if(e===void 0){const t=i.isPointLight?Jre(i):null;e=new qr,e.colorNode=_n(0,0,0,1),e.depthNode=t,e.isShadowNodeMaterial=!0,e.name="ShadowMaterial",e.fog=!1,h6.set(i,e)}return e},LB=Ke(({depthTexture:i,shadowCoord:e})=>fi(i,e.xy).compare(e.z)),UB=Ke(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(N,C)=>fi(i,N).compare(C),r=zi("mapSize","vec2",t).setGroup(Ln),s=zi("radius","float",t).setGroup(Ln),a=Lt(1).div(r),l=a.x.negate().mul(s),u=a.y.negate().mul(s),h=a.x.mul(s),m=a.y.mul(s),v=l.div(2),x=u.div(2),S=h.div(2),T=m.div(2);return Qr(n(e.xy.add(Lt(l,u)),e.z),n(e.xy.add(Lt(0,u)),e.z),n(e.xy.add(Lt(h,u)),e.z),n(e.xy.add(Lt(v,x)),e.z),n(e.xy.add(Lt(0,x)),e.z),n(e.xy.add(Lt(S,x)),e.z),n(e.xy.add(Lt(l,0)),e.z),n(e.xy.add(Lt(v,0)),e.z),n(e.xy,e.z),n(e.xy.add(Lt(S,0)),e.z),n(e.xy.add(Lt(h,0)),e.z),n(e.xy.add(Lt(v,T)),e.z),n(e.xy.add(Lt(0,T)),e.z),n(e.xy.add(Lt(S,T)),e.z),n(e.xy.add(Lt(l,m)),e.z),n(e.xy.add(Lt(0,m)),e.z),n(e.xy.add(Lt(h,m)),e.z)).mul(1/17)}),BB=Ke(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(m,v)=>fi(i,m).compare(v),r=zi("mapSize","vec2",t).setGroup(Ln),s=Lt(1).div(r),a=s.x,l=s.y,u=e.xy,h=kc(u.mul(r).add(.5));return u.subAssign(h.mul(s)),Qr(n(u,e.z),n(u.add(Lt(a,0)),e.z),n(u.add(Lt(0,l)),e.z),n(u.add(s),e.z),Ui(n(u.add(Lt(a.negate(),0)),e.z),n(u.add(Lt(a.mul(2),0)),e.z),h.x),Ui(n(u.add(Lt(a.negate(),l)),e.z),n(u.add(Lt(a.mul(2),l)),e.z),h.x),Ui(n(u.add(Lt(0,l.negate())),e.z),n(u.add(Lt(0,l.mul(2))),e.z),h.y),Ui(n(u.add(Lt(a,l.negate())),e.z),n(u.add(Lt(a,l.mul(2))),e.z),h.y),Ui(Ui(n(u.add(Lt(a.negate(),l.negate())),e.z),n(u.add(Lt(a.mul(2),l.negate())),e.z),h.x),Ui(n(u.add(Lt(a.negate(),l.mul(2))),e.z),n(u.add(Lt(a.mul(2),l.mul(2))),e.z),h.x),h.y)).mul(1/9)}),OB=Ke(({depthTexture:i,shadowCoord:e})=>{const t=xe(1).toVar(),n=fi(i).sample(e.xy).rg,r=Oy(e.z,n.x);return ii(r.notEqual(xe(1)),()=>{const s=e.z.sub(n.x),a=Gr(0,n.y.mul(n.y));let l=a.div(a.add(s.mul(s)));l=du(yi(l,.3).div(.95-.3)),t.assign(du(Gr(r,l)))}),t}),tse=Ke(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=xe(0).toVar(),s=xe(0).toVar(),a=i.lessThanEqual(xe(1)).select(xe(0),xe(2).div(i.sub(1))),l=i.lessThanEqual(xe(1)).select(xe(0),xe(-1));Bi({start:Ee(0),end:Ee(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(xe(h).mul(a)),v=n.sample(Qr(Zg.xy,Lt(0,m).mul(e)).div(t)).x;r.addAssign(v),s.addAssign(v.mul(v))}),r.divAssign(i),s.divAssign(i);const u=Su(s.sub(r.mul(r)));return Lt(r,u)}),nse=Ke(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=xe(0).toVar(),s=xe(0).toVar(),a=i.lessThanEqual(xe(1)).select(xe(0),xe(2).div(i.sub(1))),l=i.lessThanEqual(xe(1)).select(xe(0),xe(-1));Bi({start:Ee(0),end:Ee(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(xe(h).mul(a)),v=n.sample(Qr(Zg.xy,Lt(m,0).mul(e)).div(t));r.addAssign(v.x),s.addAssign(Qr(v.y.mul(v.y),v.x.mul(v.x)))}),r.divAssign(i),s.divAssign(i);const u=Su(s.sub(r.mul(r)));return Lt(r,u)}),ise=[LB,UB,BB,OB];let uS;const pv=new EE;class IB extends Vre{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s}){const a=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:n,shadowCoord:r,shadow:s});return a.select(l,xe(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,s=zi("bias","float",n).setGroup(Ln);let a=t,l;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),l=a.z,r.coordinateSystem===cu&&(l=l.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const h=zi("near","float",n.camera).setGroup(Ln),m=zi("far","float",n.camera).setGroup(Ln);l=gE(u.negate(),h,m)}return a=Ie(a.x,a.y.oneMinus(),l.add(s)),a}getShadowFilterFn(e){return ise[e]}setupShadow(e){const{renderer:t}=e,{light:n,shadow:r}=this,s=t.shadowMap.type,a=new Ic(r.mapSize.width,r.mapSize.height);a.compareFunction=Ay;const l=e.createRenderTarget(r.mapSize.width,r.mapSize.height);if(l.depthTexture=a,r.camera.updateProjectionMatrix(),s===vo){a.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:id,type:Gs}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:id,type:Gs});const E=fi(a),O=fi(this.vsmShadowMapVertical.texture),U=zi("blurSamples","float",r).setGroup(Ln),I=zi("radius","float",r).setGroup(Ln),j=zi("mapSize","vec2",r).setGroup(Ln);let z=this.vsmMaterialVertical||(this.vsmMaterialVertical=new qr);z.fragmentNode=tse({samples:U,radius:I,size:j,shadowPass:E}).context(e.getSharedContext()),z.name="VSMVertical",z=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new qr),z.fragmentNode=nse({samples:U,radius:I,size:j,shadowPass:O}).context(e.getSharedContext()),z.name="VSMHorizontal"}const u=zi("intensity","float",r).setGroup(Ln),h=zi("normalBias","float",r).setGroup(Ln),m=PE(n).mul(OE.add(qy.mul(h))),v=this.setupShadowCoord(e,m),x=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(x===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const S=s===vo?this.vsmShadowMapHorizontal.texture:a,T=this.setupShadowFilter(e,{filterFn:x,shadowTexture:l.texture,depthTexture:S,shadowCoord:v,shadow:r}),N=fi(l.texture,v),C=Ui(1,T.rgb.mix(N,1),u.mul(N.a)).toVar();return this.shadowMap=l,this.shadow.map=l,C}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Ke(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height),s.render(a,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:s,scene:a,camera:l}=e,u=s.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h,r.camera.layers.mask=l.layers.mask;const m=s.getRenderObjectFunction(),v=s.getMRT(),x=v?v.has("velocity"):!1;uS=Qre(s,a,uS),a.overrideMaterial=ese(n),s.setRenderObjectFunction((S,T,N,C,E,O,...U)=>{(S.castShadow===!0||S.receiveShadow&&u===vo)&&(x&&(qP(S).useVelocity=!0),S.onBeforeShadow(s,S,l,r.camera,C,T.overrideMaterial,O),s.renderObject(S,T,N,C,E,O,...U),S.onAfterShadow(s,S,l,r.camera,C,T.overrideMaterial,O))}),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(m),n.isPointLight!==!0&&u===vo&&this.vsmPass(s),Kre(s,a,uS)}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),pv.material=this.vsmMaterialVertical,pv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),pv.material=this.vsmMaterialHorizontal,pv.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const FB=(i,e)=>wt(new IB(i,e));class md extends W0{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new cn,this.colorNode=e&&e.colorNode||yn(this.color).setGroup(Ln),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Qn.FRAME}customCacheKey(){return RM(this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return FB(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let s;r!==void 0?s=wt(r):s=this.setupShadowNode(e),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const IE=Ke(i=>{const{lightDistance:e,cutoffDistance:t,decayExponent:n}=i,r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),rse=new cn,Vl=Ke(([i,e])=>{const t=i.toVar(),n=rr(t),r=Cl(1,Gr(n.x,Gr(n.y,n.z)));n.mulAssign(r),t.mulAssign(r.mul(e.mul(2).oneMinus()));const s=Lt(t.xy).toVar(),l=e.mul(1.5).oneMinus();return ii(n.z.greaterThanEqual(l),()=>{ii(t.z.greaterThan(0),()=>{s.x.assign(yi(4,t.x))})}).ElseIf(n.x.greaterThanEqual(l),()=>{const u=Mg(t.x);s.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(l),()=>{const u=Mg(t.y);s.x.assign(t.x.add(u.mul(2)).add(2)),s.y.assign(t.z.mul(u).sub(2))}),Lt(.125,.25).mul(s).add(Lt(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),sse=Ke(({depthTexture:i,bd3D:e,dp:t,texelSize:n})=>fi(i,Vl(e,n.y)).compare(t)),ase=Ke(({depthTexture:i,bd3D:e,dp:t,texelSize:n,shadow:r})=>{const s=zi("radius","float",r).setGroup(Ln),a=Lt(-1,1).mul(s).mul(n.y);return fi(i,Vl(e.add(a.xyy),n.y)).compare(t).add(fi(i,Vl(e.add(a.yyy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.xyx),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yyx),n.y)).compare(t)).add(fi(i,Vl(e,n.y)).compare(t)).add(fi(i,Vl(e.add(a.xxy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yxy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.xxx),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),ose=Ke(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),s=r.length(),a=yn("float").setGroup(Ln).onRenderUpdate(()=>n.camera.near),l=yn("float").setGroup(Ln).onRenderUpdate(()=>n.camera.far),u=zi("bias","float",n).setGroup(Ln),h=yn(n.mapSize).setGroup(Ln),m=xe(1).toVar();return ii(s.sub(l).lessThanEqual(0).and(s.sub(a).greaterThanEqual(0)),()=>{const v=s.sub(a).div(l.sub(a)).toVar();v.addAssign(u);const x=r.normalize(),S=Lt(1).div(h.mul(Lt(4,2)));m.assign(i({depthTexture:e,bd3D:x,dp:v,texelSize:S,shadow:n}))}),m}),f6=new On,TA=new bt,cm=new bt;class lse extends IB{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===kF?sse:ase}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a}){return ose({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e,l=t.getFrameExtents();cm.copy(t.mapSize),cm.multiply(l),n.setSize(cm.width,cm.height),TA.copy(t.mapSize);const u=s.autoClear,h=s.getClearColor(rse),m=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha),s.clear();const v=t.getViewportCount();for(let x=0;xwt(new lse(i,e)),kB=Ke(({color:i,lightViewPosition:e,cutoffDistance:t,decayExponent:n},r)=>{const s=r.context.lightingModel,a=e.sub(Xr),l=a.normalize(),u=a.length(),h=IE({lightDistance:u,cutoffDistance:t,decayExponent:n}),m=i.mul(h),v=r.context.reflectedLight;s.direct({lightDirection:l,lightColor:m,reflectedLight:v},r.stack,r)});class cse extends md{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=yn(0).setGroup(Ln),this.decayExponentNode=yn(2).setGroup(Ln)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return use(this.light)}setup(e){super.setup(e),kB({color:this.colorNode,lightViewPosition:Ky(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const hse=Ke(([i=Mr()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),Fm=Ke(([i,e,t])=>{const n=xe(t).toVar(),r=xe(e).toVar(),s=Pc(i).toVar();return zs(s,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ny=Ke(([i,e])=>{const t=Pc(e).toVar(),n=xe(i).toVar();return zs(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Yr=Ke(([i])=>{const e=xe(i).toVar();return Ee(au(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),mr=Ke(([i,e])=>{const t=xe(i).toVar();return e.assign(Yr(t)),t.sub(xe(e))}),fse=Ke(([i,e,t,n,r,s])=>{const a=xe(s).toVar(),l=xe(r).toVar(),u=xe(n).toVar(),h=xe(t).toVar(),m=xe(e).toVar(),v=xe(i).toVar(),x=xe(yi(1,l)).toVar();return yi(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),dse=Ke(([i,e,t,n,r,s])=>{const a=xe(s).toVar(),l=xe(r).toVar(),u=Ie(n).toVar(),h=Ie(t).toVar(),m=Ie(e).toVar(),v=Ie(i).toVar(),x=xe(yi(1,l)).toVar();return yi(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),zB=Vs([fse,dse]),Ase=Ke(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=xe(m).toVar(),x=xe(h).toVar(),S=xe(u).toVar(),T=xe(l).toVar(),N=xe(a).toVar(),C=xe(s).toVar(),E=xe(r).toVar(),O=xe(n).toVar(),U=xe(t).toVar(),I=xe(e).toVar(),j=xe(i).toVar(),z=xe(yi(1,S)).toVar(),G=xe(yi(1,x)).toVar();return xe(yi(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(T.mul(S))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),pse=Ke(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=xe(m).toVar(),x=xe(h).toVar(),S=xe(u).toVar(),T=Ie(l).toVar(),N=Ie(a).toVar(),C=Ie(s).toVar(),E=Ie(r).toVar(),O=Ie(n).toVar(),U=Ie(t).toVar(),I=Ie(e).toVar(),j=Ie(i).toVar(),z=xe(yi(1,S)).toVar(),G=xe(yi(1,x)).toVar();return xe(yi(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(T.mul(S))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),GB=Vs([Ase,pse]),mse=Ke(([i,e,t])=>{const n=xe(t).toVar(),r=xe(e).toVar(),s=rn(i).toVar(),a=rn(s.bitAnd(rn(7))).toVar(),l=xe(Fm(a.lessThan(rn(4)),r,n)).toVar(),u=xe(Kn(2,Fm(a.lessThan(rn(4)),n,r))).toVar();return ny(l,Pc(a.bitAnd(rn(1)))).add(ny(u,Pc(a.bitAnd(rn(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),gse=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=xe(e).toVar(),l=rn(i).toVar(),u=rn(l.bitAnd(rn(15))).toVar(),h=xe(Fm(u.lessThan(rn(8)),a,s)).toVar(),m=xe(Fm(u.lessThan(rn(4)),s,Fm(u.equal(rn(12)).or(u.equal(rn(14))),a,r))).toVar();return ny(h,Pc(u.bitAnd(rn(1)))).add(ny(m,Pc(u.bitAnd(rn(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Cs=Vs([mse,gse]),vse=Ke(([i,e,t])=>{const n=xe(t).toVar(),r=xe(e).toVar(),s=j0(i).toVar();return Ie(Cs(s.x,r,n),Cs(s.y,r,n),Cs(s.z,r,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),_se=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=xe(e).toVar(),l=j0(i).toVar();return Ie(Cs(l.x,a,s,r),Cs(l.y,a,s,r),Cs(l.z,a,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),qo=Vs([vse,_se]),yse=Ke(([i])=>{const e=xe(i).toVar();return Kn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),xse=Ke(([i])=>{const e=xe(i).toVar();return Kn(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bse=Ke(([i])=>{const e=Ie(i).toVar();return Kn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),qB=Vs([yse,bse]),Sse=Ke(([i])=>{const e=Ie(i).toVar();return Kn(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),VB=Vs([xse,Sse]),xo=Ke(([i,e])=>{const t=Ee(e).toVar(),n=rn(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(Ee(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),jB=Ke(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(xo(t,Ee(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(xo(i,Ee(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(xo(e,Ee(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(xo(t,Ee(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(xo(i,Ee(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(xo(e,Ee(4))),e.addAssign(i)}),e1=Ke(([i,e,t])=>{const n=rn(t).toVar(),r=rn(e).toVar(),s=rn(i).toVar();return n.bitXorAssign(r),n.subAssign(xo(r,Ee(14))),s.bitXorAssign(n),s.subAssign(xo(n,Ee(11))),r.bitXorAssign(s),r.subAssign(xo(s,Ee(25))),n.bitXorAssign(r),n.subAssign(xo(r,Ee(16))),s.bitXorAssign(n),s.subAssign(xo(n,Ee(4))),r.bitXorAssign(s),r.subAssign(xo(s,Ee(14))),n.bitXorAssign(r),n.subAssign(xo(r,Ee(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),sa=Ke(([i])=>{const e=rn(i).toVar();return xe(e).div(xe(rn(Ee(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ou=Ke(([i])=>{const e=xe(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),wse=Ke(([i])=>{const e=Ee(i).toVar(),t=rn(rn(1)).toVar(),n=rn(rn(Ee(3735928559)).add(t.shiftLeft(rn(2))).add(rn(13))).toVar();return e1(n.add(rn(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),Tse=Ke(([i,e])=>{const t=Ee(e).toVar(),n=Ee(i).toVar(),r=rn(rn(2)).toVar(),s=rn().toVar(),a=rn().toVar(),l=rn().toVar();return s.assign(a.assign(l.assign(rn(Ee(3735928559)).add(r.shiftLeft(rn(2))).add(rn(13))))),s.addAssign(rn(n)),a.addAssign(rn(t)),e1(s,a,l)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Mse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=Ee(e).toVar(),s=Ee(i).toVar(),a=rn(rn(3)).toVar(),l=rn().toVar(),u=rn().toVar(),h=rn().toVar();return l.assign(u.assign(h.assign(rn(Ee(3735928559)).add(a.shiftLeft(rn(2))).add(rn(13))))),l.addAssign(rn(s)),u.addAssign(rn(r)),h.addAssign(rn(n)),e1(l,u,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Ese=Ke(([i,e,t,n])=>{const r=Ee(n).toVar(),s=Ee(t).toVar(),a=Ee(e).toVar(),l=Ee(i).toVar(),u=rn(rn(4)).toVar(),h=rn().toVar(),m=rn().toVar(),v=rn().toVar();return h.assign(m.assign(v.assign(rn(Ee(3735928559)).add(u.shiftLeft(rn(2))).add(rn(13))))),h.addAssign(rn(l)),m.addAssign(rn(a)),v.addAssign(rn(s)),jB(h,m,v),h.addAssign(rn(r)),e1(h,m,v)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Cse=Ke(([i,e,t,n,r])=>{const s=Ee(r).toVar(),a=Ee(n).toVar(),l=Ee(t).toVar(),u=Ee(e).toVar(),h=Ee(i).toVar(),m=rn(rn(5)).toVar(),v=rn().toVar(),x=rn().toVar(),S=rn().toVar();return v.assign(x.assign(S.assign(rn(Ee(3735928559)).add(m.shiftLeft(rn(2))).add(rn(13))))),v.addAssign(rn(h)),x.addAssign(rn(u)),S.addAssign(rn(l)),jB(v,x,S),v.addAssign(rn(a)),x.addAssign(rn(s)),e1(v,x,S)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Gi=Vs([wse,Tse,Mse,Ese,Cse]),Nse=Ke(([i,e])=>{const t=Ee(e).toVar(),n=Ee(i).toVar(),r=rn(Gi(n,t)).toVar(),s=j0().toVar();return s.x.assign(r.bitAnd(Ee(255))),s.y.assign(r.shiftRight(Ee(8)).bitAnd(Ee(255))),s.z.assign(r.shiftRight(Ee(16)).bitAnd(Ee(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Rse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=Ee(e).toVar(),s=Ee(i).toVar(),a=rn(Gi(s,r,n)).toVar(),l=j0().toVar();return l.x.assign(a.bitAnd(Ee(255))),l.y.assign(a.shiftRight(Ee(8)).bitAnd(Ee(255))),l.z.assign(a.shiftRight(Ee(16)).bitAnd(Ee(255))),l}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Vo=Vs([Nse,Rse]),Dse=Ke(([i])=>{const e=Lt(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=xe(mr(e.x,t)).toVar(),s=xe(mr(e.y,n)).toVar(),a=xe(ou(r)).toVar(),l=xe(ou(s)).toVar(),u=xe(zB(Cs(Gi(t,n),r,s),Cs(Gi(t.add(Ee(1)),n),r.sub(1),s),Cs(Gi(t,n.add(Ee(1))),r,s.sub(1)),Cs(Gi(t.add(Ee(1)),n.add(Ee(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Pse=Ke(([i])=>{const e=Ie(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=Ee().toVar(),s=xe(mr(e.x,t)).toVar(),a=xe(mr(e.y,n)).toVar(),l=xe(mr(e.z,r)).toVar(),u=xe(ou(s)).toVar(),h=xe(ou(a)).toVar(),m=xe(ou(l)).toVar(),v=xe(GB(Cs(Gi(t,n,r),s,a,l),Cs(Gi(t.add(Ee(1)),n,r),s.sub(1),a,l),Cs(Gi(t,n.add(Ee(1)),r),s,a.sub(1),l),Cs(Gi(t.add(Ee(1)),n.add(Ee(1)),r),s.sub(1),a.sub(1),l),Cs(Gi(t,n,r.add(Ee(1))),s,a,l.sub(1)),Cs(Gi(t.add(Ee(1)),n,r.add(Ee(1))),s.sub(1),a,l.sub(1)),Cs(Gi(t,n.add(Ee(1)),r.add(Ee(1))),s,a.sub(1),l.sub(1)),Cs(Gi(t.add(Ee(1)),n.add(Ee(1)),r.add(Ee(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),FE=Vs([Dse,Pse]),Lse=Ke(([i])=>{const e=Lt(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=xe(mr(e.x,t)).toVar(),s=xe(mr(e.y,n)).toVar(),a=xe(ou(r)).toVar(),l=xe(ou(s)).toVar(),u=Ie(zB(qo(Vo(t,n),r,s),qo(Vo(t.add(Ee(1)),n),r.sub(1),s),qo(Vo(t,n.add(Ee(1))),r,s.sub(1)),qo(Vo(t.add(Ee(1)),n.add(Ee(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Use=Ke(([i])=>{const e=Ie(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=Ee().toVar(),s=xe(mr(e.x,t)).toVar(),a=xe(mr(e.y,n)).toVar(),l=xe(mr(e.z,r)).toVar(),u=xe(ou(s)).toVar(),h=xe(ou(a)).toVar(),m=xe(ou(l)).toVar(),v=Ie(GB(qo(Vo(t,n,r),s,a,l),qo(Vo(t.add(Ee(1)),n,r),s.sub(1),a,l),qo(Vo(t,n.add(Ee(1)),r),s,a.sub(1),l),qo(Vo(t.add(Ee(1)),n.add(Ee(1)),r),s.sub(1),a.sub(1),l),qo(Vo(t,n,r.add(Ee(1))),s,a,l.sub(1)),qo(Vo(t.add(Ee(1)),n,r.add(Ee(1))),s.sub(1),a,l.sub(1)),qo(Vo(t,n.add(Ee(1)),r.add(Ee(1))),s,a.sub(1),l.sub(1)),qo(Vo(t.add(Ee(1)),n.add(Ee(1)),r.add(Ee(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),kE=Vs([Lse,Use]),Bse=Ke(([i])=>{const e=xe(i).toVar(),t=Ee(Yr(e)).toVar();return sa(Gi(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Ose=Ke(([i])=>{const e=Lt(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar();return sa(Gi(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Ise=Ke(([i])=>{const e=Ie(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar();return sa(Gi(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Fse=Ke(([i])=>{const e=_n(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar(),s=Ee(Yr(e.w)).toVar();return sa(Gi(t,n,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),kse=Vs([Bse,Ose,Ise,Fse]),zse=Ke(([i])=>{const e=xe(i).toVar(),t=Ee(Yr(e)).toVar();return Ie(sa(Gi(t,Ee(0))),sa(Gi(t,Ee(1))),sa(Gi(t,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Gse=Ke(([i])=>{const e=Lt(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar();return Ie(sa(Gi(t,n,Ee(0))),sa(Gi(t,n,Ee(1))),sa(Gi(t,n,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),qse=Ke(([i])=>{const e=Ie(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar();return Ie(sa(Gi(t,n,r,Ee(0))),sa(Gi(t,n,r,Ee(1))),sa(Gi(t,n,r,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Vse=Ke(([i])=>{const e=_n(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar(),s=Ee(Yr(e.w)).toVar();return Ie(sa(Gi(t,n,r,s,Ee(0))),sa(Gi(t,n,r,s,Ee(1))),sa(Gi(t,n,r,s,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),HB=Vs([zse,Gse,qse,Vse]),iy=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=xe(0).toVar(),h=xe(1).toVar();return Bi(a,()=>{u.addAssign(h.mul(FE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),WB=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=Ie(0).toVar(),h=xe(1).toVar();return Bi(a,()=>{u.addAssign(h.mul(kE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),jse=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar();return Lt(iy(l,a,s,r),iy(l.add(Ie(Ee(19),Ee(193),Ee(17))),a,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Hse=Ke(([i,e,t,n])=>{const r=xe(n).toVar(),s=xe(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=Ie(WB(l,a,s,r)).toVar(),h=xe(iy(l.add(Ie(Ee(19),Ee(193),Ee(17))),a,s,r)).toVar();return _n(u,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Wse=Ke(([i,e,t,n,r,s,a])=>{const l=Ee(a).toVar(),u=xe(s).toVar(),h=Ee(r).toVar(),m=Ee(n).toVar(),v=Ee(t).toVar(),x=Ee(e).toVar(),S=Lt(i).toVar(),T=Ie(HB(Lt(x.add(m),v.add(h)))).toVar(),N=Lt(T.x,T.y).toVar();N.subAssign(.5),N.mulAssign(u),N.addAssign(.5);const C=Lt(Lt(xe(x),xe(v)).add(N)).toVar(),E=Lt(C.sub(S)).toVar();return ii(l.equal(Ee(2)),()=>rr(E.x).add(rr(E.y))),ii(l.equal(Ee(3)),()=>Gr(rr(E.x),rr(E.y))),jh(E,E)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$se=Ke(([i,e,t,n,r,s,a,l,u])=>{const h=Ee(u).toVar(),m=xe(l).toVar(),v=Ee(a).toVar(),x=Ee(s).toVar(),S=Ee(r).toVar(),T=Ee(n).toVar(),N=Ee(t).toVar(),C=Ee(e).toVar(),E=Ie(i).toVar(),O=Ie(HB(Ie(C.add(S),N.add(x),T.add(v)))).toVar();O.subAssign(.5),O.mulAssign(m),O.addAssign(.5);const U=Ie(Ie(xe(C),xe(N),xe(T)).add(O)).toVar(),I=Ie(U.sub(E)).toVar();return ii(h.equal(Ee(2)),()=>rr(I.x).add(rr(I.y)).add(rr(I.z))),ii(h.equal(Ee(3)),()=>Gr(Gr(rr(I.x),rr(I.y)),rr(I.z))),jh(I,I)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$0=Vs([Wse,$se]),Xse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Lt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Lt(mr(s.x,a),mr(s.y,l)).toVar(),h=xe(1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=xe($0(u,m,v,a,l,r,n)).toVar();h.assign(Za(h,x))})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Yse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Lt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Lt(mr(s.x,a),mr(s.y,l)).toVar(),h=Lt(1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=xe($0(u,m,v,a,l,r,n)).toVar();ii(x.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.y.assign(x)})})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Qse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Lt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Lt(mr(s.x,a),mr(s.y,l)).toVar(),h=Ie(1e6,1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=xe($0(u,m,v,a,l,r,n)).toVar();ii(x.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(x)}).ElseIf(x.lessThan(h.z),()=>{h.z.assign(x)})})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Kse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=xe(1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=xe($0(h,v,x,S,a,l,u,r,n)).toVar();m.assign(Za(m,T))})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Zse=Vs([Xse,Kse]),Jse=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=Lt(1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=xe($0(h,v,x,S,a,l,u,r,n)).toVar();ii(T.lessThan(m.x),()=>{m.y.assign(m.x),m.x.assign(T)}).ElseIf(T.lessThan(m.y),()=>{m.y.assign(T)})})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),eae=Vs([Yse,Jse]),tae=Ke(([i,e,t])=>{const n=Ee(t).toVar(),r=xe(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=Ie(1e6,1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=xe($0(h,v,x,S,a,l,u,r,n)).toVar();ii(T.lessThan(m.x),()=>{m.z.assign(m.y),m.y.assign(m.x),m.x.assign(T)}).ElseIf(T.lessThan(m.y),()=>{m.z.assign(m.y),m.y.assign(T)}).ElseIf(T.lessThan(m.z),()=>{m.z.assign(T)})})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nae=Vs([Qse,tae]),iae=Ke(([i])=>{const e=i.y,t=i.z,n=Ie().toVar();return ii(e.lessThan(1e-4),()=>{n.assign(Ie(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(au(r)).mul(6).toVar();const s=Ee(JM(r)),a=r.sub(xe(s)),l=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),h=t.mul(e.mul(a.oneMinus()).oneMinus());ii(s.equal(Ee(0)),()=>{n.assign(Ie(t,h,l))}).ElseIf(s.equal(Ee(1)),()=>{n.assign(Ie(u,t,l))}).ElseIf(s.equal(Ee(2)),()=>{n.assign(Ie(l,t,h))}).ElseIf(s.equal(Ee(3)),()=>{n.assign(Ie(l,u,t))}).ElseIf(s.equal(Ee(4)),()=>{n.assign(Ie(h,l,t))}).Else(()=>{n.assign(Ie(t,l,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),rae=Ke(([i])=>{const e=Ie(i).toVar(),t=xe(e.x).toVar(),n=xe(e.y).toVar(),r=xe(e.z).toVar(),s=xe(Za(t,Za(n,r))).toVar(),a=xe(Gr(t,Gr(n,r))).toVar(),l=xe(a.sub(s)).toVar(),u=xe().toVar(),h=xe().toVar(),m=xe().toVar();return m.assign(a),ii(a.greaterThan(0),()=>{h.assign(l.div(a))}).Else(()=>{h.assign(0)}),ii(h.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{ii(t.greaterThanEqual(a),()=>{u.assign(n.sub(r).div(l))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(Qr(2,r.sub(t).div(l)))}).Else(()=>{u.assign(Qr(4,t.sub(n).div(l)))}),u.mulAssign(1/6),ii(u.lessThan(0),()=>{u.addAssign(1)})}),Ie(u,h,m)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),sae=Ke(([i])=>{const e=Ie(i).toVar(),t=OM(WM(e,Ie(.04045))).toVar(),n=Ie(e.div(12.92)).toVar(),r=Ie(Tl(Gr(e.add(Ie(.055)),Ie(0)).div(1.055),Ie(2.4))).toVar();return Ui(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),$B=(i,e)=>{i=xe(i),e=xe(e);const t=Lt(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Uc(i.sub(t),i.add(t),e)},XB=(i,e,t,n)=>Ui(i,e,t[n].clamp()),aae=(i,e,t=Mr())=>XB(i,e,t,"x"),oae=(i,e,t=Mr())=>XB(i,e,t,"y"),YB=(i,e,t,n,r)=>Ui(i,e,$B(t,n[r])),lae=(i,e,t,n=Mr())=>YB(i,e,t,n,"x"),uae=(i,e,t,n=Mr())=>YB(i,e,t,n,"y"),cae=(i=1,e=0,t=Mr())=>t.mul(i).add(e),hae=(i,e=1)=>(i=xe(i),i.abs().pow(e).mul(i.sign())),fae=(i,e=1,t=.5)=>xe(i).sub(t).mul(e).add(t),dae=(i=Mr(),e=1,t=0)=>FE(i.convert("vec2|vec3")).mul(e).add(t),Aae=(i=Mr(),e=1,t=0)=>kE(i.convert("vec2|vec3")).mul(e).add(t),pae=(i=Mr(),e=1,t=0)=>(i=i.convert("vec2|vec3"),_n(kE(i),FE(i.add(Lt(19,73)))).mul(e).add(t)),mae=(i=Mr(),e=1)=>Zse(i.convert("vec2|vec3"),e,Ee(1)),gae=(i=Mr(),e=1)=>eae(i.convert("vec2|vec3"),e,Ee(1)),vae=(i=Mr(),e=1)=>nae(i.convert("vec2|vec3"),e,Ee(1)),_ae=(i=Mr())=>kse(i.convert("vec2|vec3")),yae=(i=Mr(),e=3,t=2,n=.5,r=1)=>iy(i,Ee(e),t,n).mul(r),xae=(i=Mr(),e=3,t=2,n=.5,r=1)=>jse(i,Ee(e),t,n).mul(r),bae=(i=Mr(),e=3,t=2,n=.5,r=1)=>WB(i,Ee(e),t,n).mul(r),Sae=(i=Mr(),e=3,t=2,n=.5,r=1)=>Hse(i,Ee(e),t,n).mul(r),wae=Ke(([i,e,t])=>{const n=Lc(i).toVar("nDir"),r=yi(xe(.5).mul(e.sub(t)),Tc).div(n).toVar("rbmax"),s=yi(xe(-.5).mul(e.sub(t)),Tc).div(n).toVar("rbmin"),a=Ie().toVar("rbminmax");a.x=n.x.greaterThan(xe(0)).select(r.x,s.x),a.y=n.y.greaterThan(xe(0)).select(r.y,s.y),a.z=n.z.greaterThan(xe(0)).select(r.z,s.z);const l=Za(Za(a.x,a.y),a.z).toVar("correction");return Tc.add(n.mul(l)).toVar("boxIntersection").sub(t)}),QB=Ke(([i,e])=>{const t=i.x,n=i.y,r=i.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(Kn(t,t).sub(Kn(n,n)))),s});var $=Object.freeze({__proto__:null,BRDF_GGX:Kw,BRDF_Lambert:ld,BasicShadowFilter:LB,Break:NU,Continue:Mee,DFGApprox:bE,D_GGX:jU,Discard:S9,EPSILON:NL,F_Schlick:L0,Fn:Ke,INFINITY:gJ,If:ii,Loop:Bi,NodeAccess:ia,NodeShaderStage:zw,NodeType:$Z,NodeUpdateType:Qn,PCFShadowFilter:UB,PCFSoftShadowFilter:BB,PI:Q_,PI2:vJ,Return:LJ,Schlick_to_F0:WU,ScriptableNodeResources:t_,ShaderNode:Pm,TBNViewMatrix:jf,VSMShadowFilter:OB,V_GGX_SmithCorrelated:VU,abs:rr,acesFilmicToneMapping:wB,acos:BL,add:Qr,addMethodChaining:mt,addNodeElement:BJ,agxToneMapping:TB,all:$M,alphaT:$_,and:vL,anisotropy:Th,anisotropyB:Zf,anisotropyT:Lm,any:RL,append:KP,arrayBuffer:fJ,asin:UL,assign:hL,atan:QM,atan2:t9,atomicAdd:Lre,atomicAnd:Ire,atomicFunc:zc,atomicMax:Bre,atomicMin:Ore,atomicOr:Fre,atomicStore:Pre,atomicSub:Ure,atomicXor:kre,attenuationColor:VM,attenuationDistance:qM,attribute:Au,attributeArray:Mie,backgroundBlurriness:fB,backgroundIntensity:iT,backgroundRotation:dB,batch:MU,billboarding:sie,bitAnd:bL,bitNot:SL,bitOr:wL,bitXor:TL,bitangentGeometry:aee,bitangentLocal:oee,bitangentView:G9,bitangentWorld:lee,bitcast:_J,blendBurn:mB,blendColor:Fie,blendDodge:gB,blendOverlay:_B,blendScreen:vB,blur:JU,bool:Pc,buffer:$g,bufferAttribute:Hg,bumpMap:H9,burn:kie,bvec2:eL,bvec3:OM,bvec4:rL,bypass:_9,cache:Bm,call:fL,cameraFar:Ch,cameraNear:Eh,cameraNormalMatrix:GJ,cameraPosition:E9,cameraProjectionMatrix:Ad,cameraProjectionMatrixInverse:kJ,cameraViewMatrix:no,cameraWorldMatrix:zJ,cbrt:YL,cdl:$ie,ceil:By,checker:hse,cineonToneMapping:SB,clamp:du,clearcoat:W_,clearcoatRoughness:Sg,code:Yy,color:ZP,colorSpaceToWorking:sE,colorToDirection:tte,compute:v9,cond:n9,context:Fy,convert:aL,convertColorSpace:wJ,convertToTexture:vie,cos:pc,cross:Iy,cubeTexture:P0,dFdx:KM,dFdy:ZM,dashSize:Xv,defaultBuildStages:Gw,defaultShaderStages:HP,defined:_g,degrees:PL,deltaTime:uB,densityFog:mre,densityFogFactor:RE,depth:vE,depthPass:Jie,difference:HL,diffuseColor:Ri,directPointLight:kB,directionToColor:OU,dispersion:jM,distance:jL,div:Cl,dodge:zie,dot:jh,drawIndex:SU,dynamicBufferAttribute:g9,element:sL,emissive:Hw,equal:dL,equals:qL,equirectUV:_E,exp:XM,exp2:D0,expression:zh,faceDirection:Wg,faceForward:iE,faceforward:yJ,float:xe,floor:au,fog:Cg,fract:kc,frameGroup:uL,frameId:Yne,frontFacing:D9,fwidth:zL,gain:qne,gapSize:Ww,getConstNodeType:QP,getCurrentStack:BM,getDirection:KU,getDistanceAttenuation:IE,getGeometryRoughness:qU,getNormalFromDepth:yie,getParallaxCorrectNormal:wae,getRoughness:xE,getScreenPosition:_ie,getShIrradianceAt:QB,getTextureIndex:oB,getViewPosition:BA,glsl:lre,glslFn:ure,grayscale:Vie,greaterThan:WM,greaterThanEqual:gL,hash:Gne,highpModelNormalViewMatrix:ZJ,highpModelViewMatrix:KJ,hue:Wie,instance:xee,instanceIndex:Kg,instancedArray:Eie,instancedBufferAttribute:K_,instancedDynamicBufferAttribute:$w,instancedMesh:TU,int:Ee,inverseSqrt:YM,inversesqrt:xJ,invocationLocalIndex:yee,invocationSubgroupIndex:_ee,ior:Um,iridescence:Ly,iridescenceIOR:kM,iridescenceThickness:zM,ivec2:As,ivec3:tL,ivec4:nL,js:are,label:r9,length:wc,lengthSq:QL,lessThan:pL,lessThanEqual:mL,lightPosition:LE,lightProjectionUV:DB,lightShadowMatrix:PE,lightTargetDirection:UE,lightTargetPosition:PB,lightViewPosition:Ky,lightingContext:DU,lights:qre,linearDepth:J_,linearToneMapping:xB,localId:bre,log:Uy,log2:su,logarithmicDepthToViewZ:zee,loop:Eee,luminance:CE,mat2:Dy,mat3:ua,mat4:Kf,matcapUV:tB,materialAO:xU,materialAlphaTest:W9,materialAnisotropy:oU,materialAnisotropyVector:UA,materialAttenuationColor:pU,materialAttenuationDistance:AU,materialClearcoat:tU,materialClearcoatNormal:iU,materialClearcoatRoughness:nU,materialColor:$9,materialDispersion:yU,materialEmissive:Y9,materialIOR:dU,materialIridescence:lU,materialIridescenceIOR:uU,materialIridescenceThickness:cU,materialLightMap:hE,materialLineDashOffset:_U,materialLineDashSize:gU,materialLineGapSize:vU,materialLineScale:mU,materialLineWidth:mee,materialMetalness:J9,materialNormal:eU,materialOpacity:cE,materialPointWidth:gee,materialReference:_c,materialReflectivity:Kv,materialRefractionRatio:U9,materialRotation:rU,materialRoughness:Z9,materialSheen:sU,materialSheenRoughness:aU,materialShininess:X9,materialSpecular:Q9,materialSpecularColor:K9,materialSpecularIntensity:Qw,materialSpecularStrength:Om,materialThickness:fU,materialTransmission:hU,max:Gr,maxMipLevel:M9,mediumpModelViewMatrix:R9,metalness:bg,min:Za,mix:Ui,mixElement:JL,mod:eE,modInt:HM,modelDirection:WJ,modelNormalMatrix:N9,modelPosition:$J,modelScale:XJ,modelViewMatrix:H0,modelViewPosition:YJ,modelViewProjection:fE,modelWorldMatrix:Ho,modelWorldMatrixInverse:QJ,morphReference:RU,mrt:lB,mul:Kn,mx_aastep:$B,mx_cell_noise_float:_ae,mx_contrast:fae,mx_fractal_noise_float:yae,mx_fractal_noise_vec2:xae,mx_fractal_noise_vec3:bae,mx_fractal_noise_vec4:Sae,mx_hsvtorgb:iae,mx_noise_float:dae,mx_noise_vec3:Aae,mx_noise_vec4:pae,mx_ramplr:aae,mx_ramptb:oae,mx_rgbtohsv:rae,mx_safepower:hae,mx_splitlr:lae,mx_splittb:uae,mx_srgb_texture_to_lin_rec709:sae,mx_transform_uv:cae,mx_worley_noise_float:mae,mx_worley_noise_vec2:gae,mx_worley_noise_vec3:vae,negate:OL,neutralToneMapping:MB,nodeArray:Qf,nodeImmutable:$t,nodeObject:wt,nodeObjects:Gg,nodeProxy:gt,normalFlat:P9,normalGeometry:zy,normalLocal:Ja,normalMap:Yw,normalView:Ko,normalWorld:Gy,normalize:Lc,not:yL,notEqual:AL,numWorkgroups:yre,objectDirection:qJ,objectGroup:FM,objectPosition:C9,objectScale:jJ,objectViewPosition:HJ,objectWorldMatrix:VJ,oneMinus:IL,or:_L,orthographicDepthToViewZ:kee,oscSawtooth:nie,oscSine:Jne,oscSquare:eie,oscTriangle:tie,output:Tg,outputStruct:kne,overlay:qie,overloadingFn:Vs,parabola:nT,parallaxDirection:V9,parallaxUV:cee,parameter:Ine,pass:Kie,passTexture:Zie,pcurve:Vne,perspectiveDepthToViewZ:mE,pmremTexture:SE,pointUV:Die,pointWidth:AJ,positionGeometry:ky,positionLocal:zr,positionPrevious:Z_,positionView:Xr,positionViewDirection:hr,positionWorld:Tc,positionWorldDirection:aE,posterize:Yie,pow:Tl,pow2:tE,pow3:WL,pow4:$L,property:cL,radians:DL,rand:ZL,range:vre,rangeFog:pre,rangeFogFactor:NE,reciprocal:kL,reference:zi,referenceBuffer:Xw,reflect:VL,reflectVector:I9,reflectView:B9,reflector:die,refract:nE,refractVector:F9,refractView:O9,reinhardToneMapping:bB,remainder:CL,remap:x9,remapClamp:b9,renderGroup:Ln,renderOutput:w9,rendererReference:A9,rotate:wE,rotateUV:iie,roughness:$l,round:FL,rtt:hB,sRGBTransferEOTF:l9,sRGBTransferOETF:u9,sampler:FJ,saturate:KL,saturation:jie,screen:Gie,screenCoordinate:Zg,screenSize:Eg,screenUV:gu,scriptable:Are,scriptableValue:e_,select:zs,setCurrentStack:yg,shaderStages:qw,shadow:FB,shadowPositionWorld:OE,sharedUniformGroup:IM,sheen:Vf,sheenRoughness:Py,shiftLeft:ML,shiftRight:EL,shininess:X_,sign:Mg,sin:So,sinc:jne,skinning:wee,skinningReference:CU,smoothstep:Uc,smoothstepElement:e9,specularColor:Oa,specularF90:wg,spherizeUV:rie,split:dJ,spritesheetUV:lie,sqrt:Su,stack:Zv,step:Oy,storage:Xy,storageBarrier:Mre,storageObject:Tie,storageTexture:AB,string:hJ,sub:yi,subgroupIndex:vee,subgroupSize:Sre,tan:LL,tangentGeometry:jy,tangentLocal:Xg,tangentView:Yg,tangentWorld:z9,temp:a9,texture:fi,texture3D:fne,textureBarrier:Ere,textureBicubic:YU,textureCubeUV:ZU,textureLoad:Ir,textureSize:Uh,textureStore:Lie,thickness:GM,time:pd,timerDelta:Zne,timerGlobal:Kne,timerLocal:Qne,toOutputColorSpace:c9,toWorkingColorSpace:h9,toneMapping:p9,toneMappingExposure:m9,toonOutlinePass:tre,transformDirection:XL,transformNormal:L9,transformNormalToView:oE,transformedBentNormalView:j9,transformedBitangentView:q9,transformedBitangentWorld:uee,transformedClearcoatNormalView:HA,transformedNormalView:kr,transformedNormalWorld:qy,transformedTangentView:uE,transformedTangentWorld:see,transmission:Y_,transpose:GL,triNoise3D:Wne,triplanarTexture:cie,triplanarTextures:cB,trunc:JM,tslFn:cJ,uint:rn,uniform:yn,uniformArray:vc,uniformGroup:lL,uniforms:nee,userData:Bie,uv:Mr,uvec2:JP,uvec3:j0,uvec4:iL,varying:to,varyingProperty:xg,vec2:Lt,vec3:Ie,vec4:_n,vectorComponents:fd,velocity:Iie,vertexColor:Nie,vertexIndex:bU,vertexStage:o9,vibrance:Hie,viewZToLogarithmicDepth:gE,viewZToOrthographicDepth:e0,viewZToPerspectiveDepth:UU,viewport:dE,viewportBottomLeft:Oee,viewportCoordinate:LU,viewportDepthTexture:pE,viewportLinearDepth:Gee,viewportMipTexture:AE,viewportResolution:Uee,viewportSafeUV:aie,viewportSharedTexture:ete,viewportSize:PU,viewportTexture:Iee,viewportTopLeft:Bee,viewportUV:Lee,wgsl:ore,wgslFn:cre,workgroupArray:Rre,workgroupBarrier:Tre,workgroupId:xre,workingToColorSpace:f9,xor:xL});const dc=new TE;class Tae extends Hh{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(s===null)r._clearColor.getRGB(dc,Mo),dc.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(dc,Mo),dc.a=1,a=!0;else if(s.isNode===!0){const l=this.get(e),u=s;dc.copy(r._clearColor);let h=l.backgroundMesh;if(h===void 0){const v=Fy(_n(u).mul(iT),{getUV:()=>dB.mul(Gy),getTextureLevel:()=>fB});let x=fE;x=x.setZ(x.w);const S=new qr;S.name="Background.material",S.side=or,S.depthTest=!1,S.depthWrite=!1,S.fog=!1,S.lights=!1,S.vertexNode=x,S.colorNode=v,l.backgroundMeshNode=v,l.backgroundMesh=h=new Oi(new bu(1,32,32),S),h.frustumCulled=!1,h.name="Background.mesh",h.onBeforeRender=function(T,N,C){this.matrixWorld.copyPosition(C.matrixWorld)}}const m=u.getCacheKey();l.backgroundCacheKey!==m&&(l.backgroundMeshNode.node=_n(u).mul(iT),l.backgroundMeshNode.needsUpdate=!0,h.material.needsUpdate=!0,l.backgroundCacheKey=m),t.unshift(h,h.geometry,h.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",s);if(r.autoClear===!0||a===!0){const l=n.clearColorValue;l.r=dc.r,l.g=dc.g,l.b=dc.b,l.a=dc.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(l.r*=l.a,l.g*=l.a,l.b*=l.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let Mae=0;class rT{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=Mae++}}class Eae{constructor(e,t,n,r,s,a,l,u,h,m=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=m,this.nodeAttributes=r,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=l,this.updateAfterNodes=u,this.monitor=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new rT(t.name,[],t.index,t);e.push(r);for(const s of t.bindings)r.bindings.push(s.clone())}else e.push(t);return e}}class d6{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class Cae{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class KB{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Nae extends KB{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Rae{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Dae=0;class cS{constructor(e=null){this.id=Dae++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Pae extends Nn{static get type(){return"StructTypeNode"}constructor(e,t){super(),this.name=e,this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class gd{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class Lae extends gd{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Uae extends gd{constructor(e,t=new bt){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Bae extends gd{constructor(e,t=new me){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Oae extends gd{constructor(e,t=new On){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Iae extends gd{constructor(e,t=new cn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Fae extends gd{constructor(e,t=new Xn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kae extends gd{constructor(e,t=new jn){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class zae extends Lae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Gae extends Uae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qae extends Bae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vae extends Oae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jae extends Iae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Hae extends Fae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Wae extends kae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const WA=4,A6=[.125,.215,.35,.446,.526,.582],Of=20,hS=new Ig(-1,1,1,-1,0,1),$ae=new va(90,1),p6=new cn;let fS=null,dS=0,AS=0;const Pf=(1+Math.sqrt(5))/2,MA=1/Pf,m6=[new me(-Pf,MA,0),new me(Pf,MA,0),new me(-MA,0,Pf),new me(MA,0,Pf),new me(0,Pf,-MA),new me(0,Pf,MA),new me(-1,1,-1),new me(1,1,-1),new me(-1,1,1),new me(1,1,1)],Xae=[3,1,5,0,4,2],pS=KU(Mr(),Au("faceIndex")).normalize(),zE=Ie(pS.x,pS.y,pS.z);class Yae{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,s=null){if(this._setSize(256),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const l=s||this._allocateTargets();return this.fromSceneAsync(e,t,n,r,l),l}fS=this._renderer.getRenderTarget(),dS=this._renderer.getActiveCubeFace(),AS=this._renderer.getActiveMipmapLevel();const a=s||this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,n,r,a),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}async fromSceneAsync(e,t=0,n=.1,r=100,s=null){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=v6(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_6(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Xo||e.mapping===Yo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?N:0,N,N),u.render(e,s)}u.autoClear=h,e.background=x}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Xo||e.mapping===Yo;r?this._cubemapMaterial===null&&(this._cubemapMaterial=v6(e)):this._equirectMaterial===null&&(this._equirectMaterial=_6(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const l=this._cubeSize;mv(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,hS)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sOf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Of}`);const E=[];let O=0;for(let G=0;GU-WA?r-U+WA:0),z=4*(this._cubeSize-I);mv(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,hS)}}function Qae(i){const e=[],t=[],n=[],r=[];let s=i;const a=i-WA+1+A6.length;for(let l=0;li-WA?h=A6[l-i+WA-1]:l===0&&(h=0),n.push(h);const m=1/(u-2),v=-m,x=1+m,S=[v,v,x,v,x,x,v,v,x,x,v,x],T=6,N=6,C=3,E=2,O=1,U=new Float32Array(C*N*T),I=new Float32Array(E*N*T),j=new Float32Array(O*N*T);for(let G=0;G2?0:-1,V=[H,q,0,H+2/3,q,0,H+2/3,q+1,0,H,q,0,H+2/3,q+1,0,H,q+1,0],Q=Xae[G];U.set(V,C*N*Q),I.set(S,E*N*Q);const J=[Q,Q,Q,Q,Q,Q];j.set(J,O*N*Q)}const z=new Hi;z.setAttribute("position",new wr(U,C)),z.setAttribute("uv",new wr(I,E)),z.setAttribute("faceIndex",new wr(j,O)),e.push(z),r.push(new Oi(z,null)),s>WA&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:r}}function g6(i,e,t){const n=new qh(i,e,t);return n.texture.mapping=ed,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function mv(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function GE(i){const e=new qr;return e.depthTest=!1,e.depthWrite=!1,e.blending=$a,e.name=`PMREM_${i}`,e}function Kae(i,e,t){const n=vc(new Array(Of).fill(0)),r=yn(new me(0,1,0)),s=yn(0),a=xe(Of),l=yn(0),u=yn(1),h=fi(null),m=yn(0),v=xe(1/e),x=xe(1/t),S=xe(i),T={n:a,latitudinal:l,weights:n,poleAxis:r,outputDirection:zE,dTheta:s,samples:u,envMap:h,mipInt:m,CUBEUV_TEXEL_WIDTH:v,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:S},N=GE("blur");return N.uniforms=T,N.fragmentNode=JU({...T,latitudinal:l.equal(1)}),N}function v6(i){const e=GE("cubemap");return e.fragmentNode=P0(i,zE),e}function _6(i){const e=GE("equirect");return e.fragmentNode=fi(i,_E(zE),0),e}const y6=new WeakMap,Zae=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),gv=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class ZB{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=Zv(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new cS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=y6.get(this.renderer);return e===void 0&&(e=new vu,y6.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new qh(e,t,n)}createCubeRenderTarget(e,t){return new IU(e,t)}createPMREMGenerator(){return new Yae(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let s=!0;for(const l of t)r.push(l),s=s&&l.groupNode.shared!==!0;let a;return s?(a=n.get(r),a===void 0&&(a=new rT(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new rT(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of qw)for(const s in n[r]){const a=n[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${gv(t.r)}, ${gv(t.g)}, ${gv(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const s of n)if(s.name===e)return s;const r=new d6(e,t);return n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Ns)return"int";if(t===Nr)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const n=FP(e);return(t==="float"?"":t[0])+n}getTypeFromArray(e){return Zae.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof H7)&&s!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Zv(this.stack),this.stacks.push(BM()||this.stack),yg(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,yg(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);return r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let r=n.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new d6("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e,n);let s=r.structType;if(s===void 0){const a=this.structs.index++;s=new Pae("StructType"+a,t),this.structs[n].push(s),r.structType=s}return s}getUniformFromNode(e,t,n=this.shaderStage,r=null){const s=this.getDataFromNode(e,n,this.globalCache);let a=s.uniform;if(a===void 0){const l=this.uniforms.index++;a=new Cae(r||"nodeUniform"+l,t,e),this.uniforms[n].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const l=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+l.length),a=new KB(t,n),l.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,l=a.length;t===null&&(t="nodeVarying"+l),s=new Nae(t,n),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[n]||(this.codes[n]=[]),l=a.length;s=new Rae("nodeCode"+l,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const l of n)this.addLineFlowCode(l)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; +return { ...output, `+n+" };",a=r+this.codeNode.code+s;return this._method=new Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[OP(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Cy(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const Are=gt(dre);function RB(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Xr.z).negate()}const NE=Ze(([i,e],t)=>{const n=RB(t);return Uc(i,e,n)}),RE=Ze(([i],e)=>{const t=RB(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Cg=Ze(([i,e])=>_n(e.toFloat().mix(Tg.rgb,i.toVec3()),Tg.a));function pre(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Cg(i,NE(e,t))}function mre(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Cg(i,RE(e))}let wf=null,Tf=null;class gre extends Nn{static get type(){return"RangeNode"}constructor(e=ye(),t=ye()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Rh(this.minNode.value)),n=e.getTypeLength(Rh(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.minNode.value,s=this.maxNode.value,a=e.getTypeLength(Rh(r)),l=e.getTypeLength(Rh(s));wf=wf||new On,Tf=Tf||new On,wf.setScalar(0),Tf.setScalar(0),a===1?wf.setScalar(r):r.isColor?wf.set(r.r,r.g,r.b,1):wf.set(r.x,r.y,r.z||0,r.w||0),l===1?Tf.setScalar(s):s.isColor?Tf.set(s.r,s.g,s.b,1):Tf.set(s.x,s.y,s.z||0,s.w||0);const u=4,h=u*t.count,m=new Float32Array(h);for(let x=0;xwt(new _re(i,e)),yre=Qy("numWorkgroups","uvec3"),xre=Qy("workgroupId","uvec3"),bre=Qy("localId","uvec3"),Sre=Qy("subgroupSize","uint");class wre extends Nn{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier +`):e.addLineFlowCode(`${t}Barrier()`,this)}}const DE=gt(wre),Tre=()=>DE("workgroup").append(),Mre=()=>DE("storage").append(),Ere=()=>DE("texture").append();class Cre extends dd{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const s=this.getNodeType(e);n=e.format(n,s,t)}return n}}class Nre extends Nn{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return wt(new Cre(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const Rre=(i,e)=>wt(new Nre("Workgroup",i,e));class Rs extends Zr{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,r=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=r}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),r=this.getInputType(e),s=this.pointerNode,a=this.valueNode,l=[];l.push(`&${s.build(e,r)}`),l.push(a.build(e,r));const u=`${e.getMethod(t,n)}( ${l.join(", ")} )`;if(this.storeNode!==null){const h=this.storeNode.build(e,r);e.addLineFlowCode(`${h} = ${u}`,this)}else e.addLineFlowCode(u,this)}}Rs.ATOMIC_LOAD="atomicLoad";Rs.ATOMIC_STORE="atomicStore";Rs.ATOMIC_ADD="atomicAdd";Rs.ATOMIC_SUB="atomicSub";Rs.ATOMIC_MAX="atomicMax";Rs.ATOMIC_MIN="atomicMin";Rs.ATOMIC_AND="atomicAnd";Rs.ATOMIC_OR="atomicOr";Rs.ATOMIC_XOR="atomicXor";const Dre=gt(Rs),zc=(i,e,t,n=null)=>{const r=Dre(i,e,t,n);return r.append(),r},Pre=(i,e,t=null)=>zc(Rs.ATOMIC_STORE,i,e,t),Lre=(i,e,t=null)=>zc(Rs.ATOMIC_ADD,i,e,t),Ure=(i,e,t=null)=>zc(Rs.ATOMIC_SUB,i,e,t),Bre=(i,e,t=null)=>zc(Rs.ATOMIC_MAX,i,e,t),Ore=(i,e,t=null)=>zc(Rs.ATOMIC_MIN,i,e,t),Ire=(i,e,t=null)=>zc(Rs.ATOMIC_AND,i,e,t),Fre=(i,e,t=null)=>zc(Rs.ATOMIC_OR,i,e,t),kre=(i,e,t=null)=>zc(Rs.ATOMIC_XOR,i,e,t);let Av;function Jg(i){Av=Av||new WeakMap;let e=Av.get(i);return e===void 0&&Av.set(i,e={}),e}function PE(i){const e=Jg(i);return e.shadowMatrix||(e.shadowMatrix=yn("mat4").setGroup(Ln).onRenderUpdate(()=>(i.castShadow!==!0&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function DB(i){const e=Jg(i);if(e.projectionUV===void 0){const t=PE(i).mul(Tc);e.projectionUV=t.xyz.div(t.w)}return e.projectionUV}function LE(i){const e=Jg(i);return e.position||(e.position=yn(new pe).setGroup(Ln).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function PB(i){const e=Jg(i);return e.targetPosition||(e.targetPosition=yn(new pe).setGroup(Ln).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function Ky(i){const e=Jg(i);return e.viewPosition||(e.viewPosition=yn(new pe).setGroup(Ln).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new pe,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const UE=i=>no.transformDirection(LE(i).sub(PB(i))),zre=i=>i.sort((e,t)=>e.id-t.id),Gre=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},lS=new WeakMap;class BE extends Nn{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Ie().toVar("totalDiffuse"),this.totalSpecularNode=Ie().toVar("totalSpecular"),this.outgoingLightNode=Ie().toVar("outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=[],t=this._lights;for(let n=0;n0}}const qre=(i=[])=>wt(new BE).setLights(i);class Vre extends Nn{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Qn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({material:e}){OE.assign(e.shadowPositionNode||Tc)}dispose(){this.updateBeforeType=Qn.NONE}}const OE=Ie().toVar("shadowPositionWorld");function jre(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new cn),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function Hre(i,e){return e=jre(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function Wre(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function $re(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function Xre(i,e){return e=$re(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function Yre(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function Qre(i,e,t){return t=Hre(i,t),t=Xre(e,t),t}function Kre(i,e,t){Wre(i,t),Yre(e,t)}const h6=new WeakMap,Zre=Ze(([i,e,t])=>{let n=Tc.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),Jre=i=>{const e=i.shadow.camera,t=zi("near","float",e).setGroup(Ln),n=zi("far","float",e).setGroup(Ln),r=C9(i);return Zre(r,t,n)},ese=i=>{let e=h6.get(i);if(e===void 0){const t=i.isPointLight?Jre(i):null;e=new qr,e.colorNode=_n(0,0,0,1),e.depthNode=t,e.isShadowNodeMaterial=!0,e.name="ShadowMaterial",e.fog=!1,h6.set(i,e)}return e},LB=Ze(({depthTexture:i,shadowCoord:e})=>fi(i,e.xy).compare(e.z)),UB=Ze(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(N,C)=>fi(i,N).compare(C),r=zi("mapSize","vec2",t).setGroup(Ln),s=zi("radius","float",t).setGroup(Ln),a=Pt(1).div(r),l=a.x.negate().mul(s),u=a.y.negate().mul(s),h=a.x.mul(s),m=a.y.mul(s),v=l.div(2),x=u.div(2),S=h.div(2),T=m.div(2);return Qr(n(e.xy.add(Pt(l,u)),e.z),n(e.xy.add(Pt(0,u)),e.z),n(e.xy.add(Pt(h,u)),e.z),n(e.xy.add(Pt(v,x)),e.z),n(e.xy.add(Pt(0,x)),e.z),n(e.xy.add(Pt(S,x)),e.z),n(e.xy.add(Pt(l,0)),e.z),n(e.xy.add(Pt(v,0)),e.z),n(e.xy,e.z),n(e.xy.add(Pt(S,0)),e.z),n(e.xy.add(Pt(h,0)),e.z),n(e.xy.add(Pt(v,T)),e.z),n(e.xy.add(Pt(0,T)),e.z),n(e.xy.add(Pt(S,T)),e.z),n(e.xy.add(Pt(l,m)),e.z),n(e.xy.add(Pt(0,m)),e.z),n(e.xy.add(Pt(h,m)),e.z)).mul(1/17)}),BB=Ze(({depthTexture:i,shadowCoord:e,shadow:t})=>{const n=(m,v)=>fi(i,m).compare(v),r=zi("mapSize","vec2",t).setGroup(Ln),s=Pt(1).div(r),a=s.x,l=s.y,u=e.xy,h=kc(u.mul(r).add(.5));return u.subAssign(h.mul(s)),Qr(n(u,e.z),n(u.add(Pt(a,0)),e.z),n(u.add(Pt(0,l)),e.z),n(u.add(s),e.z),Ui(n(u.add(Pt(a.negate(),0)),e.z),n(u.add(Pt(a.mul(2),0)),e.z),h.x),Ui(n(u.add(Pt(a.negate(),l)),e.z),n(u.add(Pt(a.mul(2),l)),e.z),h.x),Ui(n(u.add(Pt(0,l.negate())),e.z),n(u.add(Pt(0,l.mul(2))),e.z),h.y),Ui(n(u.add(Pt(a,l.negate())),e.z),n(u.add(Pt(a,l.mul(2))),e.z),h.y),Ui(Ui(n(u.add(Pt(a.negate(),l.negate())),e.z),n(u.add(Pt(a.mul(2),l.negate())),e.z),h.x),Ui(n(u.add(Pt(a.negate(),l.mul(2))),e.z),n(u.add(Pt(a.mul(2),l.mul(2))),e.z),h.x),h.y)).mul(1/9)}),OB=Ze(({depthTexture:i,shadowCoord:e})=>{const t=ye(1).toVar(),n=fi(i).sample(e.xy).rg,r=Oy(e.z,n.x);return ii(r.notEqual(ye(1)),()=>{const s=e.z.sub(n.x),a=Gr(0,n.y.mul(n.y));let l=a.div(a.add(s.mul(s)));l=du(yi(l,.3).div(.95-.3)),t.assign(du(Gr(r,l)))}),t}),tse=Ze(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=ye(0).toVar(),s=ye(0).toVar(),a=i.lessThanEqual(ye(1)).select(ye(0),ye(2).div(i.sub(1))),l=i.lessThanEqual(ye(1)).select(ye(0),ye(-1));Bi({start:Ee(0),end:Ee(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(ye(h).mul(a)),v=n.sample(Qr(Zg.xy,Pt(0,m).mul(e)).div(t)).x;r.addAssign(v),s.addAssign(v.mul(v))}),r.divAssign(i),s.divAssign(i);const u=Su(s.sub(r.mul(r)));return Pt(r,u)}),nse=Ze(({samples:i,radius:e,size:t,shadowPass:n})=>{const r=ye(0).toVar(),s=ye(0).toVar(),a=i.lessThanEqual(ye(1)).select(ye(0),ye(2).div(i.sub(1))),l=i.lessThanEqual(ye(1)).select(ye(0),ye(-1));Bi({start:Ee(0),end:Ee(i),type:"int",condition:"<"},({i:h})=>{const m=l.add(ye(h).mul(a)),v=n.sample(Qr(Zg.xy,Pt(m,0).mul(e)).div(t));r.addAssign(v.x),s.addAssign(Qr(v.y.mul(v.y),v.x.mul(v.x)))}),r.divAssign(i),s.divAssign(i);const u=Su(s.sub(r.mul(r)));return Pt(r,u)}),ise=[LB,UB,BB,OB];let uS;const pv=new EE;class IB extends Vre{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this.isShadowNode=!0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:s}){const a=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),l=t({depthTexture:n,shadowCoord:r,shadow:s});return a.select(l,ye(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,s=zi("bias","float",n).setGroup(Ln);let a=t,l;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),l=a.z,r.coordinateSystem===cu&&(l=l.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const h=zi("near","float",n.camera).setGroup(Ln),m=zi("far","float",n.camera).setGroup(Ln);l=gE(u.negate(),h,m)}return a=Ie(a.x,a.y.oneMinus(),l.add(s)),a}getShadowFilterFn(e){return ise[e]}setupShadow(e){const{renderer:t}=e,{light:n,shadow:r}=this,s=t.shadowMap.type,a=new Ic(r.mapSize.width,r.mapSize.height);a.compareFunction=Ay;const l=e.createRenderTarget(r.mapSize.width,r.mapSize.height);if(l.depthTexture=a,r.camera.updateProjectionMatrix(),s===vo){a.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:id,type:Gs}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:id,type:Gs});const E=fi(a),O=fi(this.vsmShadowMapVertical.texture),U=zi("blurSamples","float",r).setGroup(Ln),I=zi("radius","float",r).setGroup(Ln),j=zi("mapSize","vec2",r).setGroup(Ln);let z=this.vsmMaterialVertical||(this.vsmMaterialVertical=new qr);z.fragmentNode=tse({samples:U,radius:I,size:j,shadowPass:E}).context(e.getSharedContext()),z.name="VSMVertical",z=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new qr),z.fragmentNode=nse({samples:U,radius:I,size:j,shadowPass:O}).context(e.getSharedContext()),z.name="VSMHorizontal"}const u=zi("intensity","float",r).setGroup(Ln),h=zi("normalBias","float",r).setGroup(Ln),m=PE(n).mul(OE.add(qy.mul(h))),v=this.setupShadowCoord(e,m),x=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(x===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const S=s===vo?this.vsmShadowMapHorizontal.texture:a,T=this.setupShadowFilter(e,{filterFn:x,shadowTexture:l.texture,depthTexture:S,shadowCoord:v,shadow:r}),N=fi(l.texture,v),C=Ui(1,T.rgb.mix(N,1),u.mul(N.a)).toVar();return this.shadowMap=l,this.shadow.map=l,C}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Ze(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height),s.render(a,t.camera)}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:s,scene:a,camera:l}=e,u=s.shadowMap.type,h=t.depthTexture.version;this._depthVersionCached=h,r.camera.layers.mask=l.layers.mask;const m=s.getRenderObjectFunction(),v=s.getMRT(),x=v?v.has("velocity"):!1;uS=Qre(s,a,uS),a.overrideMaterial=ese(n),s.setRenderObjectFunction((S,T,N,C,E,O,...U)=>{(S.castShadow===!0||S.receiveShadow&&u===vo)&&(x&&(qP(S).useVelocity=!0),S.onBeforeShadow(s,S,l,r.camera,C,T.overrideMaterial,O),s.renderObject(S,T,N,C,E,O,...U),S.onAfterShadow(s,S,l,r.camera,C,T.overrideMaterial,O))}),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(m),n.isPointLight!==!0&&u===vo&&this.vsmPass(s),Kre(s,a,uS)}vsmPass(e){const{shadow:t}=this;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height),e.setRenderTarget(this.vsmShadowMapVertical),pv.material=this.vsmMaterialVertical,pv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),pv.material=this.vsmMaterialHorizontal,pv.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){const{shadow:t}=this;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const FB=(i,e)=>wt(new IB(i,e));class md extends W0{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new cn,this.colorNode=e&&e.colorNode||yn(this.color).setGroup(Ln),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Qn.FRAME}customCacheKey(){return RM(this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadowNode(){return FB(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let s;r!==void 0?s=wt(r):s=this.setupShadowNode(e),this.shadowNode=s,this.shadowColorNode=n=this.colorNode.mul(s),this.baseColorNode=this.colorNode}this.colorNode=n}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const IE=Ze(i=>{const{lightDistance:e,cutoffDistance:t,decayExponent:n}=i,r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),rse=new cn,Vl=Ze(([i,e])=>{const t=i.toVar(),n=rr(t),r=Cl(1,Gr(n.x,Gr(n.y,n.z)));n.mulAssign(r),t.mulAssign(r.mul(e.mul(2).oneMinus()));const s=Pt(t.xy).toVar(),l=e.mul(1.5).oneMinus();return ii(n.z.greaterThanEqual(l),()=>{ii(t.z.greaterThan(0),()=>{s.x.assign(yi(4,t.x))})}).ElseIf(n.x.greaterThanEqual(l),()=>{const u=Mg(t.x);s.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(l),()=>{const u=Mg(t.y);s.x.assign(t.x.add(u.mul(2)).add(2)),s.y.assign(t.z.mul(u).sub(2))}),Pt(.125,.25).mul(s).add(Pt(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),sse=Ze(({depthTexture:i,bd3D:e,dp:t,texelSize:n})=>fi(i,Vl(e,n.y)).compare(t)),ase=Ze(({depthTexture:i,bd3D:e,dp:t,texelSize:n,shadow:r})=>{const s=zi("radius","float",r).setGroup(Ln),a=Pt(-1,1).mul(s).mul(n.y);return fi(i,Vl(e.add(a.xyy),n.y)).compare(t).add(fi(i,Vl(e.add(a.yyy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.xyx),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yyx),n.y)).compare(t)).add(fi(i,Vl(e,n.y)).compare(t)).add(fi(i,Vl(e.add(a.xxy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yxy),n.y)).compare(t)).add(fi(i,Vl(e.add(a.xxx),n.y)).compare(t)).add(fi(i,Vl(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),ose=Ze(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),s=r.length(),a=yn("float").setGroup(Ln).onRenderUpdate(()=>n.camera.near),l=yn("float").setGroup(Ln).onRenderUpdate(()=>n.camera.far),u=zi("bias","float",n).setGroup(Ln),h=yn(n.mapSize).setGroup(Ln),m=ye(1).toVar();return ii(s.sub(l).lessThanEqual(0).and(s.sub(a).greaterThanEqual(0)),()=>{const v=s.sub(a).div(l.sub(a)).toVar();v.addAssign(u);const x=r.normalize(),S=Pt(1).div(h.mul(Pt(4,2)));m.assign(i({depthTexture:e,bd3D:x,dp:v,texelSize:S,shadow:n}))}),m}),f6=new On,TA=new bt,cm=new bt;class lse extends IB{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===kF?sse:ase}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a}){return ose({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:s,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:s,scene:a}=e,l=t.getFrameExtents();cm.copy(t.mapSize),cm.multiply(l),n.setSize(cm.width,cm.height),TA.copy(t.mapSize);const u=s.autoClear,h=s.getClearColor(rse),m=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha),s.clear();const v=t.getViewportCount();for(let x=0;xwt(new lse(i,e)),kB=Ze(({color:i,lightViewPosition:e,cutoffDistance:t,decayExponent:n},r)=>{const s=r.context.lightingModel,a=e.sub(Xr),l=a.normalize(),u=a.length(),h=IE({lightDistance:u,cutoffDistance:t,decayExponent:n}),m=i.mul(h),v=r.context.reflectedLight;s.direct({lightDirection:l,lightColor:m,reflectedLight:v},r.stack,r)});class cse extends md{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=yn(0).setGroup(Ln),this.decayExponentNode=yn(2).setGroup(Ln)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return use(this.light)}setup(e){super.setup(e),kB({color:this.colorNode,lightViewPosition:Ky(this.light),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode}).append()}}const hse=Ze(([i=Mr()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),Fm=Ze(([i,e,t])=>{const n=ye(t).toVar(),r=ye(e).toVar(),s=Pc(i).toVar();return zs(s,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ny=Ze(([i,e])=>{const t=Pc(e).toVar(),n=ye(i).toVar();return zs(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Yr=Ze(([i])=>{const e=ye(i).toVar();return Ee(au(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),mr=Ze(([i,e])=>{const t=ye(i).toVar();return e.assign(Yr(t)),t.sub(ye(e))}),fse=Ze(([i,e,t,n,r,s])=>{const a=ye(s).toVar(),l=ye(r).toVar(),u=ye(n).toVar(),h=ye(t).toVar(),m=ye(e).toVar(),v=ye(i).toVar(),x=ye(yi(1,l)).toVar();return yi(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),dse=Ze(([i,e,t,n,r,s])=>{const a=ye(s).toVar(),l=ye(r).toVar(),u=Ie(n).toVar(),h=Ie(t).toVar(),m=Ie(e).toVar(),v=Ie(i).toVar(),x=ye(yi(1,l)).toVar();return yi(1,a).mul(v.mul(x).add(m.mul(l))).add(a.mul(h.mul(x).add(u.mul(l))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),zB=Vs([fse,dse]),Ase=Ze(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=ye(m).toVar(),x=ye(h).toVar(),S=ye(u).toVar(),T=ye(l).toVar(),N=ye(a).toVar(),C=ye(s).toVar(),E=ye(r).toVar(),O=ye(n).toVar(),U=ye(t).toVar(),I=ye(e).toVar(),j=ye(i).toVar(),z=ye(yi(1,S)).toVar(),G=ye(yi(1,x)).toVar();return ye(yi(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(T.mul(S))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),pse=Ze(([i,e,t,n,r,s,a,l,u,h,m])=>{const v=ye(m).toVar(),x=ye(h).toVar(),S=ye(u).toVar(),T=Ie(l).toVar(),N=Ie(a).toVar(),C=Ie(s).toVar(),E=Ie(r).toVar(),O=Ie(n).toVar(),U=Ie(t).toVar(),I=Ie(e).toVar(),j=Ie(i).toVar(),z=ye(yi(1,S)).toVar(),G=ye(yi(1,x)).toVar();return ye(yi(1,v)).toVar().mul(G.mul(j.mul(z).add(I.mul(S))).add(x.mul(U.mul(z).add(O.mul(S))))).add(v.mul(G.mul(E.mul(z).add(C.mul(S))).add(x.mul(N.mul(z).add(T.mul(S))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),GB=Vs([Ase,pse]),mse=Ze(([i,e,t])=>{const n=ye(t).toVar(),r=ye(e).toVar(),s=rn(i).toVar(),a=rn(s.bitAnd(rn(7))).toVar(),l=ye(Fm(a.lessThan(rn(4)),r,n)).toVar(),u=ye(Kn(2,Fm(a.lessThan(rn(4)),n,r))).toVar();return ny(l,Pc(a.bitAnd(rn(1)))).add(ny(u,Pc(a.bitAnd(rn(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),gse=Ze(([i,e,t,n])=>{const r=ye(n).toVar(),s=ye(t).toVar(),a=ye(e).toVar(),l=rn(i).toVar(),u=rn(l.bitAnd(rn(15))).toVar(),h=ye(Fm(u.lessThan(rn(8)),a,s)).toVar(),m=ye(Fm(u.lessThan(rn(4)),s,Fm(u.equal(rn(12)).or(u.equal(rn(14))),a,r))).toVar();return ny(h,Pc(u.bitAnd(rn(1)))).add(ny(m,Pc(u.bitAnd(rn(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Cs=Vs([mse,gse]),vse=Ze(([i,e,t])=>{const n=ye(t).toVar(),r=ye(e).toVar(),s=j0(i).toVar();return Ie(Cs(s.x,r,n),Cs(s.y,r,n),Cs(s.z,r,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),_se=Ze(([i,e,t,n])=>{const r=ye(n).toVar(),s=ye(t).toVar(),a=ye(e).toVar(),l=j0(i).toVar();return Ie(Cs(l.x,a,s,r),Cs(l.y,a,s,r),Cs(l.z,a,s,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),qo=Vs([vse,_se]),yse=Ze(([i])=>{const e=ye(i).toVar();return Kn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),xse=Ze(([i])=>{const e=ye(i).toVar();return Kn(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),bse=Ze(([i])=>{const e=Ie(i).toVar();return Kn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),qB=Vs([yse,bse]),Sse=Ze(([i])=>{const e=Ie(i).toVar();return Kn(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),VB=Vs([xse,Sse]),xo=Ze(([i,e])=>{const t=Ee(e).toVar(),n=rn(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(Ee(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),jB=Ze(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(xo(t,Ee(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(xo(i,Ee(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(xo(e,Ee(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(xo(t,Ee(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(xo(i,Ee(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(xo(e,Ee(4))),e.addAssign(i)}),e1=Ze(([i,e,t])=>{const n=rn(t).toVar(),r=rn(e).toVar(),s=rn(i).toVar();return n.bitXorAssign(r),n.subAssign(xo(r,Ee(14))),s.bitXorAssign(n),s.subAssign(xo(n,Ee(11))),r.bitXorAssign(s),r.subAssign(xo(s,Ee(25))),n.bitXorAssign(r),n.subAssign(xo(r,Ee(16))),s.bitXorAssign(n),s.subAssign(xo(n,Ee(4))),r.bitXorAssign(s),r.subAssign(xo(s,Ee(14))),n.bitXorAssign(r),n.subAssign(xo(r,Ee(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),sa=Ze(([i])=>{const e=rn(i).toVar();return ye(e).div(ye(rn(Ee(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ou=Ze(([i])=>{const e=ye(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),wse=Ze(([i])=>{const e=Ee(i).toVar(),t=rn(rn(1)).toVar(),n=rn(rn(Ee(3735928559)).add(t.shiftLeft(rn(2))).add(rn(13))).toVar();return e1(n.add(rn(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),Tse=Ze(([i,e])=>{const t=Ee(e).toVar(),n=Ee(i).toVar(),r=rn(rn(2)).toVar(),s=rn().toVar(),a=rn().toVar(),l=rn().toVar();return s.assign(a.assign(l.assign(rn(Ee(3735928559)).add(r.shiftLeft(rn(2))).add(rn(13))))),s.addAssign(rn(n)),a.addAssign(rn(t)),e1(s,a,l)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Mse=Ze(([i,e,t])=>{const n=Ee(t).toVar(),r=Ee(e).toVar(),s=Ee(i).toVar(),a=rn(rn(3)).toVar(),l=rn().toVar(),u=rn().toVar(),h=rn().toVar();return l.assign(u.assign(h.assign(rn(Ee(3735928559)).add(a.shiftLeft(rn(2))).add(rn(13))))),l.addAssign(rn(s)),u.addAssign(rn(r)),h.addAssign(rn(n)),e1(l,u,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Ese=Ze(([i,e,t,n])=>{const r=Ee(n).toVar(),s=Ee(t).toVar(),a=Ee(e).toVar(),l=Ee(i).toVar(),u=rn(rn(4)).toVar(),h=rn().toVar(),m=rn().toVar(),v=rn().toVar();return h.assign(m.assign(v.assign(rn(Ee(3735928559)).add(u.shiftLeft(rn(2))).add(rn(13))))),h.addAssign(rn(l)),m.addAssign(rn(a)),v.addAssign(rn(s)),jB(h,m,v),h.addAssign(rn(r)),e1(h,m,v)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),Cse=Ze(([i,e,t,n,r])=>{const s=Ee(r).toVar(),a=Ee(n).toVar(),l=Ee(t).toVar(),u=Ee(e).toVar(),h=Ee(i).toVar(),m=rn(rn(5)).toVar(),v=rn().toVar(),x=rn().toVar(),S=rn().toVar();return v.assign(x.assign(S.assign(rn(Ee(3735928559)).add(m.shiftLeft(rn(2))).add(rn(13))))),v.addAssign(rn(h)),x.addAssign(rn(u)),S.addAssign(rn(l)),jB(v,x,S),v.addAssign(rn(a)),x.addAssign(rn(s)),e1(v,x,S)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Gi=Vs([wse,Tse,Mse,Ese,Cse]),Nse=Ze(([i,e])=>{const t=Ee(e).toVar(),n=Ee(i).toVar(),r=rn(Gi(n,t)).toVar(),s=j0().toVar();return s.x.assign(r.bitAnd(Ee(255))),s.y.assign(r.shiftRight(Ee(8)).bitAnd(Ee(255))),s.z.assign(r.shiftRight(Ee(16)).bitAnd(Ee(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),Rse=Ze(([i,e,t])=>{const n=Ee(t).toVar(),r=Ee(e).toVar(),s=Ee(i).toVar(),a=rn(Gi(s,r,n)).toVar(),l=j0().toVar();return l.x.assign(a.bitAnd(Ee(255))),l.y.assign(a.shiftRight(Ee(8)).bitAnd(Ee(255))),l.z.assign(a.shiftRight(Ee(16)).bitAnd(Ee(255))),l}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Vo=Vs([Nse,Rse]),Dse=Ze(([i])=>{const e=Pt(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=ye(mr(e.x,t)).toVar(),s=ye(mr(e.y,n)).toVar(),a=ye(ou(r)).toVar(),l=ye(ou(s)).toVar(),u=ye(zB(Cs(Gi(t,n),r,s),Cs(Gi(t.add(Ee(1)),n),r.sub(1),s),Cs(Gi(t,n.add(Ee(1))),r,s.sub(1)),Cs(Gi(t.add(Ee(1)),n.add(Ee(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),Pse=Ze(([i])=>{const e=Ie(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=Ee().toVar(),s=ye(mr(e.x,t)).toVar(),a=ye(mr(e.y,n)).toVar(),l=ye(mr(e.z,r)).toVar(),u=ye(ou(s)).toVar(),h=ye(ou(a)).toVar(),m=ye(ou(l)).toVar(),v=ye(GB(Cs(Gi(t,n,r),s,a,l),Cs(Gi(t.add(Ee(1)),n,r),s.sub(1),a,l),Cs(Gi(t,n.add(Ee(1)),r),s,a.sub(1),l),Cs(Gi(t.add(Ee(1)),n.add(Ee(1)),r),s.sub(1),a.sub(1),l),Cs(Gi(t,n,r.add(Ee(1))),s,a,l.sub(1)),Cs(Gi(t.add(Ee(1)),n,r.add(Ee(1))),s.sub(1),a,l.sub(1)),Cs(Gi(t,n.add(Ee(1)),r.add(Ee(1))),s,a.sub(1),l.sub(1)),Cs(Gi(t.add(Ee(1)),n.add(Ee(1)),r.add(Ee(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),FE=Vs([Dse,Pse]),Lse=Ze(([i])=>{const e=Pt(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=ye(mr(e.x,t)).toVar(),s=ye(mr(e.y,n)).toVar(),a=ye(ou(r)).toVar(),l=ye(ou(s)).toVar(),u=Ie(zB(qo(Vo(t,n),r,s),qo(Vo(t.add(Ee(1)),n),r.sub(1),s),qo(Vo(t,n.add(Ee(1))),r,s.sub(1)),qo(Vo(t.add(Ee(1)),n.add(Ee(1))),r.sub(1),s.sub(1)),a,l)).toVar();return qB(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Use=Ze(([i])=>{const e=Ie(i).toVar(),t=Ee().toVar(),n=Ee().toVar(),r=Ee().toVar(),s=ye(mr(e.x,t)).toVar(),a=ye(mr(e.y,n)).toVar(),l=ye(mr(e.z,r)).toVar(),u=ye(ou(s)).toVar(),h=ye(ou(a)).toVar(),m=ye(ou(l)).toVar(),v=Ie(GB(qo(Vo(t,n,r),s,a,l),qo(Vo(t.add(Ee(1)),n,r),s.sub(1),a,l),qo(Vo(t,n.add(Ee(1)),r),s,a.sub(1),l),qo(Vo(t.add(Ee(1)),n.add(Ee(1)),r),s.sub(1),a.sub(1),l),qo(Vo(t,n,r.add(Ee(1))),s,a,l.sub(1)),qo(Vo(t.add(Ee(1)),n,r.add(Ee(1))),s.sub(1),a,l.sub(1)),qo(Vo(t,n.add(Ee(1)),r.add(Ee(1))),s,a.sub(1),l.sub(1)),qo(Vo(t.add(Ee(1)),n.add(Ee(1)),r.add(Ee(1))),s.sub(1),a.sub(1),l.sub(1)),u,h,m)).toVar();return VB(v)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),kE=Vs([Lse,Use]),Bse=Ze(([i])=>{const e=ye(i).toVar(),t=Ee(Yr(e)).toVar();return sa(Gi(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),Ose=Ze(([i])=>{const e=Pt(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar();return sa(Gi(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),Ise=Ze(([i])=>{const e=Ie(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar();return sa(Gi(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),Fse=Ze(([i])=>{const e=_n(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar(),s=Ee(Yr(e.w)).toVar();return sa(Gi(t,n,r,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),kse=Vs([Bse,Ose,Ise,Fse]),zse=Ze(([i])=>{const e=ye(i).toVar(),t=Ee(Yr(e)).toVar();return Ie(sa(Gi(t,Ee(0))),sa(Gi(t,Ee(1))),sa(Gi(t,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Gse=Ze(([i])=>{const e=Pt(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar();return Ie(sa(Gi(t,n,Ee(0))),sa(Gi(t,n,Ee(1))),sa(Gi(t,n,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),qse=Ze(([i])=>{const e=Ie(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar();return Ie(sa(Gi(t,n,r,Ee(0))),sa(Gi(t,n,r,Ee(1))),sa(Gi(t,n,r,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Vse=Ze(([i])=>{const e=_n(i).toVar(),t=Ee(Yr(e.x)).toVar(),n=Ee(Yr(e.y)).toVar(),r=Ee(Yr(e.z)).toVar(),s=Ee(Yr(e.w)).toVar();return Ie(sa(Gi(t,n,r,s,Ee(0))),sa(Gi(t,n,r,s,Ee(1))),sa(Gi(t,n,r,s,Ee(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),HB=Vs([zse,Gse,qse,Vse]),iy=Ze(([i,e,t,n])=>{const r=ye(n).toVar(),s=ye(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=ye(0).toVar(),h=ye(1).toVar();return Bi(a,()=>{u.addAssign(h.mul(FE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),WB=Ze(([i,e,t,n])=>{const r=ye(n).toVar(),s=ye(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=Ie(0).toVar(),h=ye(1).toVar();return Bi(a,()=>{u.addAssign(h.mul(kE(l))),h.mulAssign(r),l.mulAssign(s)}),u}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),jse=Ze(([i,e,t,n])=>{const r=ye(n).toVar(),s=ye(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar();return Pt(iy(l,a,s,r),iy(l.add(Ie(Ee(19),Ee(193),Ee(17))),a,s,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Hse=Ze(([i,e,t,n])=>{const r=ye(n).toVar(),s=ye(t).toVar(),a=Ee(e).toVar(),l=Ie(i).toVar(),u=Ie(WB(l,a,s,r)).toVar(),h=ye(iy(l.add(Ie(Ee(19),Ee(193),Ee(17))),a,s,r)).toVar();return _n(u,h)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Wse=Ze(([i,e,t,n,r,s,a])=>{const l=Ee(a).toVar(),u=ye(s).toVar(),h=Ee(r).toVar(),m=Ee(n).toVar(),v=Ee(t).toVar(),x=Ee(e).toVar(),S=Pt(i).toVar(),T=Ie(HB(Pt(x.add(m),v.add(h)))).toVar(),N=Pt(T.x,T.y).toVar();N.subAssign(.5),N.mulAssign(u),N.addAssign(.5);const C=Pt(Pt(ye(x),ye(v)).add(N)).toVar(),E=Pt(C.sub(S)).toVar();return ii(l.equal(Ee(2)),()=>rr(E.x).add(rr(E.y))),ii(l.equal(Ee(3)),()=>Gr(rr(E.x),rr(E.y))),jh(E,E)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$se=Ze(([i,e,t,n,r,s,a,l,u])=>{const h=Ee(u).toVar(),m=ye(l).toVar(),v=Ee(a).toVar(),x=Ee(s).toVar(),S=Ee(r).toVar(),T=Ee(n).toVar(),N=Ee(t).toVar(),C=Ee(e).toVar(),E=Ie(i).toVar(),O=Ie(HB(Ie(C.add(S),N.add(x),T.add(v)))).toVar();O.subAssign(.5),O.mulAssign(m),O.addAssign(.5);const U=Ie(Ie(ye(C),ye(N),ye(T)).add(O)).toVar(),I=Ie(U.sub(E)).toVar();return ii(h.equal(Ee(2)),()=>rr(I.x).add(rr(I.y)).add(rr(I.z))),ii(h.equal(Ee(3)),()=>Gr(Gr(rr(I.x),rr(I.y)),rr(I.z))),jh(I,I)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$0=Vs([Wse,$se]),Xse=Ze(([i,e,t])=>{const n=Ee(t).toVar(),r=ye(e).toVar(),s=Pt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Pt(mr(s.x,a),mr(s.y,l)).toVar(),h=ye(1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=ye($0(u,m,v,a,l,r,n)).toVar();h.assign(Za(h,x))})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Yse=Ze(([i,e,t])=>{const n=Ee(t).toVar(),r=ye(e).toVar(),s=Pt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Pt(mr(s.x,a),mr(s.y,l)).toVar(),h=Pt(1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=ye($0(u,m,v,a,l,r,n)).toVar();ii(x.lessThan(h.x),()=>{h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.y.assign(x)})})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Qse=Ze(([i,e,t])=>{const n=Ee(t).toVar(),r=ye(e).toVar(),s=Pt(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Pt(mr(s.x,a),mr(s.y,l)).toVar(),h=Ie(1e6,1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:m})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:v})=>{const x=ye($0(u,m,v,a,l,r,n)).toVar();ii(x.lessThan(h.x),()=>{h.z.assign(h.y),h.y.assign(h.x),h.x.assign(x)}).ElseIf(x.lessThan(h.y),()=>{h.z.assign(h.y),h.y.assign(x)}).ElseIf(x.lessThan(h.z),()=>{h.z.assign(x)})})}),ii(n.equal(Ee(0)),()=>{h.assign(Su(h))}),h}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Kse=Ze(([i,e,t])=>{const n=Ee(t).toVar(),r=ye(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=ye(1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=ye($0(h,v,x,S,a,l,u,r,n)).toVar();m.assign(Za(m,T))})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Zse=Vs([Xse,Kse]),Jse=Ze(([i,e,t])=>{const n=Ee(t).toVar(),r=ye(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=Pt(1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=ye($0(h,v,x,S,a,l,u,r,n)).toVar();ii(T.lessThan(m.x),()=>{m.y.assign(m.x),m.x.assign(T)}).ElseIf(T.lessThan(m.y),()=>{m.y.assign(T)})})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),eae=Vs([Yse,Jse]),tae=Ze(([i,e,t])=>{const n=Ee(t).toVar(),r=ye(e).toVar(),s=Ie(i).toVar(),a=Ee().toVar(),l=Ee().toVar(),u=Ee().toVar(),h=Ie(mr(s.x,a),mr(s.y,l),mr(s.z,u)).toVar(),m=Ie(1e6,1e6,1e6).toVar();return Bi({start:-1,end:Ee(1),name:"x",condition:"<="},({x:v})=>{Bi({start:-1,end:Ee(1),name:"y",condition:"<="},({y:x})=>{Bi({start:-1,end:Ee(1),name:"z",condition:"<="},({z:S})=>{const T=ye($0(h,v,x,S,a,l,u,r,n)).toVar();ii(T.lessThan(m.x),()=>{m.z.assign(m.y),m.y.assign(m.x),m.x.assign(T)}).ElseIf(T.lessThan(m.y),()=>{m.z.assign(m.y),m.y.assign(T)}).ElseIf(T.lessThan(m.z),()=>{m.z.assign(T)})})})}),ii(n.equal(Ee(0)),()=>{m.assign(Su(m))}),m}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),nae=Vs([Qse,tae]),iae=Ze(([i])=>{const e=i.y,t=i.z,n=Ie().toVar();return ii(e.lessThan(1e-4),()=>{n.assign(Ie(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(au(r)).mul(6).toVar();const s=Ee(JM(r)),a=r.sub(ye(s)),l=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),h=t.mul(e.mul(a.oneMinus()).oneMinus());ii(s.equal(Ee(0)),()=>{n.assign(Ie(t,h,l))}).ElseIf(s.equal(Ee(1)),()=>{n.assign(Ie(u,t,l))}).ElseIf(s.equal(Ee(2)),()=>{n.assign(Ie(l,t,h))}).ElseIf(s.equal(Ee(3)),()=>{n.assign(Ie(l,u,t))}).ElseIf(s.equal(Ee(4)),()=>{n.assign(Ie(h,l,t))}).Else(()=>{n.assign(Ie(t,l,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),rae=Ze(([i])=>{const e=Ie(i).toVar(),t=ye(e.x).toVar(),n=ye(e.y).toVar(),r=ye(e.z).toVar(),s=ye(Za(t,Za(n,r))).toVar(),a=ye(Gr(t,Gr(n,r))).toVar(),l=ye(a.sub(s)).toVar(),u=ye().toVar(),h=ye().toVar(),m=ye().toVar();return m.assign(a),ii(a.greaterThan(0),()=>{h.assign(l.div(a))}).Else(()=>{h.assign(0)}),ii(h.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{ii(t.greaterThanEqual(a),()=>{u.assign(n.sub(r).div(l))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(Qr(2,r.sub(t).div(l)))}).Else(()=>{u.assign(Qr(4,t.sub(n).div(l)))}),u.mulAssign(1/6),ii(u.lessThan(0),()=>{u.addAssign(1)})}),Ie(u,h,m)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),sae=Ze(([i])=>{const e=Ie(i).toVar(),t=OM(WM(e,Ie(.04045))).toVar(),n=Ie(e.div(12.92)).toVar(),r=Ie(Tl(Gr(e.add(Ie(.055)),Ie(0)).div(1.055),Ie(2.4))).toVar();return Ui(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),$B=(i,e)=>{i=ye(i),e=ye(e);const t=Pt(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Uc(i.sub(t),i.add(t),e)},XB=(i,e,t,n)=>Ui(i,e,t[n].clamp()),aae=(i,e,t=Mr())=>XB(i,e,t,"x"),oae=(i,e,t=Mr())=>XB(i,e,t,"y"),YB=(i,e,t,n,r)=>Ui(i,e,$B(t,n[r])),lae=(i,e,t,n=Mr())=>YB(i,e,t,n,"x"),uae=(i,e,t,n=Mr())=>YB(i,e,t,n,"y"),cae=(i=1,e=0,t=Mr())=>t.mul(i).add(e),hae=(i,e=1)=>(i=ye(i),i.abs().pow(e).mul(i.sign())),fae=(i,e=1,t=.5)=>ye(i).sub(t).mul(e).add(t),dae=(i=Mr(),e=1,t=0)=>FE(i.convert("vec2|vec3")).mul(e).add(t),Aae=(i=Mr(),e=1,t=0)=>kE(i.convert("vec2|vec3")).mul(e).add(t),pae=(i=Mr(),e=1,t=0)=>(i=i.convert("vec2|vec3"),_n(kE(i),FE(i.add(Pt(19,73)))).mul(e).add(t)),mae=(i=Mr(),e=1)=>Zse(i.convert("vec2|vec3"),e,Ee(1)),gae=(i=Mr(),e=1)=>eae(i.convert("vec2|vec3"),e,Ee(1)),vae=(i=Mr(),e=1)=>nae(i.convert("vec2|vec3"),e,Ee(1)),_ae=(i=Mr())=>kse(i.convert("vec2|vec3")),yae=(i=Mr(),e=3,t=2,n=.5,r=1)=>iy(i,Ee(e),t,n).mul(r),xae=(i=Mr(),e=3,t=2,n=.5,r=1)=>jse(i,Ee(e),t,n).mul(r),bae=(i=Mr(),e=3,t=2,n=.5,r=1)=>WB(i,Ee(e),t,n).mul(r),Sae=(i=Mr(),e=3,t=2,n=.5,r=1)=>Hse(i,Ee(e),t,n).mul(r),wae=Ze(([i,e,t])=>{const n=Lc(i).toVar("nDir"),r=yi(ye(.5).mul(e.sub(t)),Tc).div(n).toVar("rbmax"),s=yi(ye(-.5).mul(e.sub(t)),Tc).div(n).toVar("rbmin"),a=Ie().toVar("rbminmax");a.x=n.x.greaterThan(ye(0)).select(r.x,s.x),a.y=n.y.greaterThan(ye(0)).select(r.y,s.y),a.z=n.z.greaterThan(ye(0)).select(r.z,s.z);const l=Za(Za(a.x,a.y),a.z).toVar("correction");return Tc.add(n.mul(l)).toVar("boxIntersection").sub(t)}),QB=Ze(([i,e])=>{const t=i.x,n=i.y,r=i.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(n)),s=s.add(e.element(2).mul(2*.511664).mul(r)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(n)),s=s.add(e.element(5).mul(2*.429043).mul(n).mul(r)),s=s.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(8).mul(.429043).mul(Kn(t,t).sub(Kn(n,n)))),s});var $=Object.freeze({__proto__:null,BRDF_GGX:Kw,BRDF_Lambert:ld,BasicShadowFilter:LB,Break:NU,Continue:Mee,DFGApprox:bE,D_GGX:jU,Discard:S9,EPSILON:NL,F_Schlick:L0,Fn:Ze,INFINITY:gJ,If:ii,Loop:Bi,NodeAccess:ia,NodeShaderStage:zw,NodeType:$Z,NodeUpdateType:Qn,PCFShadowFilter:UB,PCFSoftShadowFilter:BB,PI:Q_,PI2:vJ,Return:LJ,Schlick_to_F0:WU,ScriptableNodeResources:t_,ShaderNode:Pm,TBNViewMatrix:jf,VSMShadowFilter:OB,V_GGX_SmithCorrelated:VU,abs:rr,acesFilmicToneMapping:wB,acos:BL,add:Qr,addMethodChaining:mt,addNodeElement:BJ,agxToneMapping:TB,all:$M,alphaT:$_,and:vL,anisotropy:Th,anisotropyB:Zf,anisotropyT:Lm,any:RL,append:KP,arrayBuffer:fJ,asin:UL,assign:hL,atan:QM,atan2:t9,atomicAdd:Lre,atomicAnd:Ire,atomicFunc:zc,atomicMax:Bre,atomicMin:Ore,atomicOr:Fre,atomicStore:Pre,atomicSub:Ure,atomicXor:kre,attenuationColor:VM,attenuationDistance:qM,attribute:Au,attributeArray:Mie,backgroundBlurriness:fB,backgroundIntensity:iT,backgroundRotation:dB,batch:MU,billboarding:sie,bitAnd:bL,bitNot:SL,bitOr:wL,bitXor:TL,bitangentGeometry:aee,bitangentLocal:oee,bitangentView:G9,bitangentWorld:lee,bitcast:_J,blendBurn:mB,blendColor:Fie,blendDodge:gB,blendOverlay:_B,blendScreen:vB,blur:JU,bool:Pc,buffer:$g,bufferAttribute:Hg,bumpMap:H9,burn:kie,bvec2:eL,bvec3:OM,bvec4:rL,bypass:_9,cache:Bm,call:fL,cameraFar:Ch,cameraNear:Eh,cameraNormalMatrix:GJ,cameraPosition:E9,cameraProjectionMatrix:Ad,cameraProjectionMatrixInverse:kJ,cameraViewMatrix:no,cameraWorldMatrix:zJ,cbrt:YL,cdl:$ie,ceil:By,checker:hse,cineonToneMapping:SB,clamp:du,clearcoat:W_,clearcoatRoughness:Sg,code:Yy,color:ZP,colorSpaceToWorking:sE,colorToDirection:tte,compute:v9,cond:n9,context:Fy,convert:aL,convertColorSpace:wJ,convertToTexture:vie,cos:pc,cross:Iy,cubeTexture:P0,dFdx:KM,dFdy:ZM,dashSize:Xv,defaultBuildStages:Gw,defaultShaderStages:HP,defined:_g,degrees:PL,deltaTime:uB,densityFog:mre,densityFogFactor:RE,depth:vE,depthPass:Jie,difference:HL,diffuseColor:Ri,directPointLight:kB,directionToColor:OU,dispersion:jM,distance:jL,div:Cl,dodge:zie,dot:jh,drawIndex:SU,dynamicBufferAttribute:g9,element:sL,emissive:Hw,equal:dL,equals:qL,equirectUV:_E,exp:XM,exp2:D0,expression:zh,faceDirection:Wg,faceForward:iE,faceforward:yJ,float:ye,floor:au,fog:Cg,fract:kc,frameGroup:uL,frameId:Yne,frontFacing:D9,fwidth:zL,gain:qne,gapSize:Ww,getConstNodeType:QP,getCurrentStack:BM,getDirection:KU,getDistanceAttenuation:IE,getGeometryRoughness:qU,getNormalFromDepth:yie,getParallaxCorrectNormal:wae,getRoughness:xE,getScreenPosition:_ie,getShIrradianceAt:QB,getTextureIndex:oB,getViewPosition:BA,glsl:lre,glslFn:ure,grayscale:Vie,greaterThan:WM,greaterThanEqual:gL,hash:Gne,highpModelNormalViewMatrix:ZJ,highpModelViewMatrix:KJ,hue:Wie,instance:xee,instanceIndex:Kg,instancedArray:Eie,instancedBufferAttribute:K_,instancedDynamicBufferAttribute:$w,instancedMesh:TU,int:Ee,inverseSqrt:YM,inversesqrt:xJ,invocationLocalIndex:yee,invocationSubgroupIndex:_ee,ior:Um,iridescence:Ly,iridescenceIOR:kM,iridescenceThickness:zM,ivec2:As,ivec3:tL,ivec4:nL,js:are,label:r9,length:wc,lengthSq:QL,lessThan:pL,lessThanEqual:mL,lightPosition:LE,lightProjectionUV:DB,lightShadowMatrix:PE,lightTargetDirection:UE,lightTargetPosition:PB,lightViewPosition:Ky,lightingContext:DU,lights:qre,linearDepth:J_,linearToneMapping:xB,localId:bre,log:Uy,log2:su,logarithmicDepthToViewZ:zee,loop:Eee,luminance:CE,mat2:Dy,mat3:ua,mat4:Kf,matcapUV:tB,materialAO:xU,materialAlphaTest:W9,materialAnisotropy:oU,materialAnisotropyVector:UA,materialAttenuationColor:pU,materialAttenuationDistance:AU,materialClearcoat:tU,materialClearcoatNormal:iU,materialClearcoatRoughness:nU,materialColor:$9,materialDispersion:yU,materialEmissive:Y9,materialIOR:dU,materialIridescence:lU,materialIridescenceIOR:uU,materialIridescenceThickness:cU,materialLightMap:hE,materialLineDashOffset:_U,materialLineDashSize:gU,materialLineGapSize:vU,materialLineScale:mU,materialLineWidth:mee,materialMetalness:J9,materialNormal:eU,materialOpacity:cE,materialPointWidth:gee,materialReference:_c,materialReflectivity:Kv,materialRefractionRatio:U9,materialRotation:rU,materialRoughness:Z9,materialSheen:sU,materialSheenRoughness:aU,materialShininess:X9,materialSpecular:Q9,materialSpecularColor:K9,materialSpecularIntensity:Qw,materialSpecularStrength:Om,materialThickness:fU,materialTransmission:hU,max:Gr,maxMipLevel:M9,mediumpModelViewMatrix:R9,metalness:bg,min:Za,mix:Ui,mixElement:JL,mod:eE,modInt:HM,modelDirection:WJ,modelNormalMatrix:N9,modelPosition:$J,modelScale:XJ,modelViewMatrix:H0,modelViewPosition:YJ,modelViewProjection:fE,modelWorldMatrix:Ho,modelWorldMatrixInverse:QJ,morphReference:RU,mrt:lB,mul:Kn,mx_aastep:$B,mx_cell_noise_float:_ae,mx_contrast:fae,mx_fractal_noise_float:yae,mx_fractal_noise_vec2:xae,mx_fractal_noise_vec3:bae,mx_fractal_noise_vec4:Sae,mx_hsvtorgb:iae,mx_noise_float:dae,mx_noise_vec3:Aae,mx_noise_vec4:pae,mx_ramplr:aae,mx_ramptb:oae,mx_rgbtohsv:rae,mx_safepower:hae,mx_splitlr:lae,mx_splittb:uae,mx_srgb_texture_to_lin_rec709:sae,mx_transform_uv:cae,mx_worley_noise_float:mae,mx_worley_noise_vec2:gae,mx_worley_noise_vec3:vae,negate:OL,neutralToneMapping:MB,nodeArray:Qf,nodeImmutable:Xt,nodeObject:wt,nodeObjects:Gg,nodeProxy:gt,normalFlat:P9,normalGeometry:zy,normalLocal:Ja,normalMap:Yw,normalView:Ko,normalWorld:Gy,normalize:Lc,not:yL,notEqual:AL,numWorkgroups:yre,objectDirection:qJ,objectGroup:FM,objectPosition:C9,objectScale:jJ,objectViewPosition:HJ,objectWorldMatrix:VJ,oneMinus:IL,or:_L,orthographicDepthToViewZ:kee,oscSawtooth:nie,oscSine:Jne,oscSquare:eie,oscTriangle:tie,output:Tg,outputStruct:kne,overlay:qie,overloadingFn:Vs,parabola:nT,parallaxDirection:V9,parallaxUV:cee,parameter:Ine,pass:Kie,passTexture:Zie,pcurve:Vne,perspectiveDepthToViewZ:mE,pmremTexture:SE,pointUV:Die,pointWidth:AJ,positionGeometry:ky,positionLocal:zr,positionPrevious:Z_,positionView:Xr,positionViewDirection:hr,positionWorld:Tc,positionWorldDirection:aE,posterize:Yie,pow:Tl,pow2:tE,pow3:WL,pow4:$L,property:cL,radians:DL,rand:ZL,range:vre,rangeFog:pre,rangeFogFactor:NE,reciprocal:kL,reference:zi,referenceBuffer:Xw,reflect:VL,reflectVector:I9,reflectView:B9,reflector:die,refract:nE,refractVector:F9,refractView:O9,reinhardToneMapping:bB,remainder:CL,remap:x9,remapClamp:b9,renderGroup:Ln,renderOutput:w9,rendererReference:A9,rotate:wE,rotateUV:iie,roughness:$l,round:FL,rtt:hB,sRGBTransferEOTF:l9,sRGBTransferOETF:u9,sampler:FJ,saturate:KL,saturation:jie,screen:Gie,screenCoordinate:Zg,screenSize:Eg,screenUV:gu,scriptable:Are,scriptableValue:e_,select:zs,setCurrentStack:yg,shaderStages:qw,shadow:FB,shadowPositionWorld:OE,sharedUniformGroup:IM,sheen:Vf,sheenRoughness:Py,shiftLeft:ML,shiftRight:EL,shininess:X_,sign:Mg,sin:So,sinc:jne,skinning:wee,skinningReference:CU,smoothstep:Uc,smoothstepElement:e9,specularColor:Oa,specularF90:wg,spherizeUV:rie,split:dJ,spritesheetUV:lie,sqrt:Su,stack:Zv,step:Oy,storage:Xy,storageBarrier:Mre,storageObject:Tie,storageTexture:AB,string:hJ,sub:yi,subgroupIndex:vee,subgroupSize:Sre,tan:LL,tangentGeometry:jy,tangentLocal:Xg,tangentView:Yg,tangentWorld:z9,temp:a9,texture:fi,texture3D:fne,textureBarrier:Ere,textureBicubic:YU,textureCubeUV:ZU,textureLoad:Ir,textureSize:Uh,textureStore:Lie,thickness:GM,time:pd,timerDelta:Zne,timerGlobal:Kne,timerLocal:Qne,toOutputColorSpace:c9,toWorkingColorSpace:h9,toneMapping:p9,toneMappingExposure:m9,toonOutlinePass:tre,transformDirection:XL,transformNormal:L9,transformNormalToView:oE,transformedBentNormalView:j9,transformedBitangentView:q9,transformedBitangentWorld:uee,transformedClearcoatNormalView:HA,transformedNormalView:kr,transformedNormalWorld:qy,transformedTangentView:uE,transformedTangentWorld:see,transmission:Y_,transpose:GL,triNoise3D:Wne,triplanarTexture:cie,triplanarTextures:cB,trunc:JM,tslFn:cJ,uint:rn,uniform:yn,uniformArray:vc,uniformGroup:lL,uniforms:nee,userData:Bie,uv:Mr,uvec2:JP,uvec3:j0,uvec4:iL,varying:to,varyingProperty:xg,vec2:Pt,vec3:Ie,vec4:_n,vectorComponents:fd,velocity:Iie,vertexColor:Nie,vertexIndex:bU,vertexStage:o9,vibrance:Hie,viewZToLogarithmicDepth:gE,viewZToOrthographicDepth:e0,viewZToPerspectiveDepth:UU,viewport:dE,viewportBottomLeft:Oee,viewportCoordinate:LU,viewportDepthTexture:pE,viewportLinearDepth:Gee,viewportMipTexture:AE,viewportResolution:Uee,viewportSafeUV:aie,viewportSharedTexture:ete,viewportSize:PU,viewportTexture:Iee,viewportTopLeft:Bee,viewportUV:Lee,wgsl:ore,wgslFn:cre,workgroupArray:Rre,workgroupBarrier:Tre,workgroupId:xre,workingToColorSpace:f9,xor:xL});const dc=new TE;class Tae extends Hh{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(s===null)r._clearColor.getRGB(dc,Mo),dc.a=r._clearColor.a;else if(s.isColor===!0)s.getRGB(dc,Mo),dc.a=1,a=!0;else if(s.isNode===!0){const l=this.get(e),u=s;dc.copy(r._clearColor);let h=l.backgroundMesh;if(h===void 0){const v=Fy(_n(u).mul(iT),{getUV:()=>dB.mul(Gy),getTextureLevel:()=>fB});let x=fE;x=x.setZ(x.w);const S=new qr;S.name="Background.material",S.side=or,S.depthTest=!1,S.depthWrite=!1,S.fog=!1,S.lights=!1,S.vertexNode=x,S.colorNode=v,l.backgroundMeshNode=v,l.backgroundMesh=h=new Oi(new bu(1,32,32),S),h.frustumCulled=!1,h.name="Background.mesh",h.onBeforeRender=function(T,N,C){this.matrixWorld.copyPosition(C.matrixWorld)}}const m=u.getCacheKey();l.backgroundCacheKey!==m&&(l.backgroundMeshNode.node=_n(u).mul(iT),l.backgroundMeshNode.needsUpdate=!0,h.material.needsUpdate=!0,l.backgroundCacheKey=m),t.unshift(h,h.geometry,h.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",s);if(r.autoClear===!0||a===!0){const l=n.clearColorValue;l.r=dc.r,l.g=dc.g,l.b=dc.b,l.a=dc.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(l.r*=l.a,l.g*=l.a,l.b*=l.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let Mae=0;class rT{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=Mae++}}class Eae{constructor(e,t,n,r,s,a,l,u,h,m=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=m,this.nodeAttributes=r,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=l,this.updateAfterNodes=u,this.monitor=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new rT(t.name,[],t.index,t);e.push(r);for(const s of t.bindings)r.bindings.push(s.clone())}else e.push(t);return e}}class d6{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class Cae{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class KB{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Nae extends KB{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Rae{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let Dae=0;class cS{constructor(e=null){this.id=Dae++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class Pae extends Nn{static get type(){return"StructTypeNode"}constructor(e,t){super(),this.name=e,this.types=t,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class gd{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class Lae extends gd{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class Uae extends gd{constructor(e,t=new bt){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class Bae extends gd{constructor(e,t=new pe){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class Oae extends gd{constructor(e,t=new On){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class Iae extends gd{constructor(e,t=new cn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class Fae extends gd{constructor(e,t=new Xn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class kae extends gd{constructor(e,t=new jn){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class zae extends Lae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Gae extends Uae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class qae extends Bae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Vae extends Oae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class jae extends Iae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Hae extends Fae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Wae extends kae{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const WA=4,A6=[.125,.215,.35,.446,.526,.582],Of=20,hS=new Ig(-1,1,1,-1,0,1),$ae=new va(90,1),p6=new cn;let fS=null,dS=0,AS=0;const Pf=(1+Math.sqrt(5))/2,MA=1/Pf,m6=[new pe(-Pf,MA,0),new pe(Pf,MA,0),new pe(-MA,0,Pf),new pe(MA,0,Pf),new pe(0,Pf,-MA),new pe(0,Pf,MA),new pe(-1,1,-1),new pe(1,1,-1),new pe(-1,1,1),new pe(1,1,1)],Xae=[3,1,5,0,4,2],pS=KU(Mr(),Au("faceIndex")).normalize(),zE=Ie(pS.x,pS.y,pS.z);class Yae{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,s=null){if(this._setSize(256),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const l=s||this._allocateTargets();return this.fromSceneAsync(e,t,n,r,l),l}fS=this._renderer.getRenderTarget(),dS=this._renderer.getActiveCubeFace(),AS=this._renderer.getActiveMipmapLevel();const a=s||this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,n,r,a),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}async fromSceneAsync(e,t=0,n=.1,r=100,s=null){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTargets();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=v6(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_6(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Xo||e.mapping===Yo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?N:0,N,N),u.render(e,s)}u.autoClear=h,e.background=x}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Xo||e.mapping===Yo;r?this._cubemapMaterial===null&&(this._cubemapMaterial=v6(e)):this._equirectMaterial===null&&(this._equirectMaterial=_6(e));const s=r?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const l=this._cubeSize;mv(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,hS)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;sOf&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Of}`);const E=[];let O=0;for(let G=0;GU-WA?r-U+WA:0),z=4*(this._cubeSize-I);mv(t,j,z,3*I,2*I),u.setRenderTarget(t),u.render(v,hS)}}function Qae(i){const e=[],t=[],n=[],r=[];let s=i;const a=i-WA+1+A6.length;for(let l=0;li-WA?h=A6[l-i+WA-1]:l===0&&(h=0),n.push(h);const m=1/(u-2),v=-m,x=1+m,S=[v,v,x,v,x,x,v,v,x,x,v,x],T=6,N=6,C=3,E=2,O=1,U=new Float32Array(C*N*T),I=new Float32Array(E*N*T),j=new Float32Array(O*N*T);for(let G=0;G2?0:-1,V=[H,q,0,H+2/3,q,0,H+2/3,q+1,0,H,q,0,H+2/3,q+1,0,H,q+1,0],Q=Xae[G];U.set(V,C*N*Q),I.set(S,E*N*Q);const J=[Q,Q,Q,Q,Q,Q];j.set(J,O*N*Q)}const z=new Hi;z.setAttribute("position",new wr(U,C)),z.setAttribute("uv",new wr(I,E)),z.setAttribute("faceIndex",new wr(j,O)),e.push(z),r.push(new Oi(z,null)),s>WA&&s--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:r}}function g6(i,e,t){const n=new qh(i,e,t);return n.texture.mapping=ed,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function mv(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function GE(i){const e=new qr;return e.depthTest=!1,e.depthWrite=!1,e.blending=$a,e.name=`PMREM_${i}`,e}function Kae(i,e,t){const n=vc(new Array(Of).fill(0)),r=yn(new pe(0,1,0)),s=yn(0),a=ye(Of),l=yn(0),u=yn(1),h=fi(null),m=yn(0),v=ye(1/e),x=ye(1/t),S=ye(i),T={n:a,latitudinal:l,weights:n,poleAxis:r,outputDirection:zE,dTheta:s,samples:u,envMap:h,mipInt:m,CUBEUV_TEXEL_WIDTH:v,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:S},N=GE("blur");return N.uniforms=T,N.fragmentNode=JU({...T,latitudinal:l.equal(1)}),N}function v6(i){const e=GE("cubemap");return e.fragmentNode=P0(i,zE),e}function _6(i){const e=GE("equirect");return e.fragmentNode=fi(i,_E(zE),0),e}const y6=new WeakMap,Zae=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),gv=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class ZB{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=Zv(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new cS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=y6.get(this.renderer);return e===void 0&&(e=new vu,y6.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new qh(e,t,n)}createCubeRenderTarget(e,t){return new IU(e,t)}createPMREMGenerator(){return new Yae(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let s=!0;for(const l of t)r.push(l),s=s&&l.groupNode.shared!==!0;let a;return s?(a=n.get(r),a===void 0&&(a=new rT(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new rT(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of qw)for(const s in n[r]){const a=n[r][s];(t[s]||(t[s]=[])).push(...a)}e=[];for(const r in t){const s=t[r],a=this._getBindGroup(r,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${gv(t.r)}, ${gv(t.g)}, ${gv(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),s=a=>this.generateConst(r,a);if(n===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(n===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(n===4)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const s of n)if(s.name===e)return s;const r=new d6(e,t);return n.push(r),r}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Ns)return"int";if(t===Nr)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const n=FP(e);return(t==="float"?"":t[0])+n}getTypeFromArray(e){return Zae.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,s=e.normalized;let a;return!(e instanceof H7)&&s!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Zv(this.stack),this.stacks.push(BM()||this.stack),yg(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,yg(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);return r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={}),r[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let r=n.bufferAttribute;if(r===void 0){const s=this.uniforms.index++;r=new d6("nodeAttribute"+s,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e,n);let s=r.structType;if(s===void 0){const a=this.structs.index++;s=new Pae("StructType"+a,t),this.structs[n].push(s),r.structType=s}return s}getUniformFromNode(e,t,n=this.shaderStage,r=null){const s=this.getDataFromNode(e,n,this.globalCache);let a=s.uniform;if(a===void 0){const l=this.uniforms.index++;a=new Cae(r||"nodeUniform"+l,t,e),this.uniforms[n].push(a),s.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage){const s=this.getDataFromNode(e,r);let a=s.variable;if(a===void 0){const l=this.vars[r]||(this.vars[r]=[]);t===null&&(t="nodeVar"+l.length),a=new KB(t,n),l.push(a),s.variable=a}return a}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const r=this.getDataFromNode(e,"any");let s=r.varying;if(s===void 0){const a=this.varyings,l=a.length;t===null&&(t="nodeVarying"+l),s=new Nae(t,n),a.push(s),r.varying=s}return s}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let s=r.code;if(s===void 0){const a=this.codes[n]||(this.codes[n]=[]),l=a.length;s=new Rae("nodeCode"+l,t),a.push(s),r.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(r.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const l of n)this.addLineFlowCode(l)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),s=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);s.push(t),a.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; `),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){const t=new EB,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const l=Object.values(this);return{next:()=>({value:l[a],done:a++>=l.length})}}};for(const a of t.inputs)n[a.name]=new sB(a.type,a.name);e.layout=null;const r=e.call(n),s=this.flowStagesNode(r,t.type);return e.layout=t,s}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,s=this.cache,a=this.buildStage,l=this.stack,u={code:""};this.flow=u,this.vars={},this.cache=new cS,this.stack=Zv();for(const h of Gw)this.setBuildStage(h),u.result=e.build(this,t);return u.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.cache=s,this.stack=l,this.setBuildStage(a),u}getFunctionOperator(){return null}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const s=this.shaderStage;this.setShaderStage(e);const a=this.flowChildNode(t,n);return r!==null&&(a.code+=`${this.tab+r} = ${a.result}; `),this.flowCode[e]=this.flowCode[e]+a.code,this.setShaderStage(s),a}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+` `;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new qr),r.build(this)}else this.addFlow("compute",e);for(const r of Gw){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const s of qw){this.setShaderStage(s);const a=this.flowNodes[s];for(const l of a)r==="generate"?this.flowNode(l):l.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new zae(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new Gae(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new qae(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new Vae(e);if(t==="color")return new jae(e);if(t==="mat3")return new Hae(e);if(t==="mat4")return new Wae(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),s=this.getTypeLength(n);return r===16&&s===9?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:r===9&&s===4?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:r>4||s>4||s===0?e:r===s?`${this.getType(n)}( ${e} )`:r>s?this.format(`${e}.${"xyz".slice(0,s)}`,this.getTypeFromLength(s,this.getComponentType(t)),n):s===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&s>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${F0} - Node System -`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class x6{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.frameId&&e.update(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.renderId&&e.update(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class qE{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}qE.isNodeFunctionInput=!0;class Jae extends md{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,r=UE(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:s},e.stack,e)}}const mS=new jn,vv=new jn;let hm=null;class eoe extends md{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=yn(new me).setGroup(Ln),this.halfWidth=yn(new me).setGroup(Ln),this.updateType=Qn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;vv.identity(),mS.copy(t.matrixWorld),mS.premultiply(n),vv.extractRotation(mS),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(vv),this.halfHeight.value.applyMatrix4(vv)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=fi(hm.LTC_FLOAT_1),n=fi(hm.LTC_FLOAT_2)):(t=fi(hm.LTC_HALF_1),n=fi(hm.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,l=Ky(s),u=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:l,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:u,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){hm=e}}class JB extends md{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=yn(0).setGroup(Ln),this.penumbraCosNode=yn(0).setGroup(Ln),this.cutoffDistanceNode=yn(0).setGroup(Ln),this.decayExponentNode=yn(0).setGroup(Ln)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return Uc(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,l=Ky(a).sub(Xr),u=l.normalize(),h=u.dot(UE(a)),m=this.getSpotAttenuation(h),v=l.length(),x=IE({lightDistance:v,cutoffDistance:r,decayExponent:s});let S=n.mul(m).mul(x);if(a.map){const N=DB(a),C=fi(a.map,N.xy).onRenderUpdate(()=>a.map);S=N.mul(2).sub(1).abs().lessThan(1).all().select(S.mul(C),S)}const T=e.context.reflectedLight;t.direct({lightDirection:u,lightColor:S,reflectedLight:T},e.stack,e)}}class toe extends JB{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);n=fi(t,Lt(r,0),0).r}else n=super.getSpotAttenuation(e);return n}}class noe extends md{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class ioe extends md{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=LE(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=yn(new cn).setGroup(Ln)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,a=Ko.dot(r).mul(.5).add(.5),l=Ui(n,t,a);e.context.irradiance.addAssign(l)}}class roe extends md{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new me);this.lightProbe=vc(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=QB(Gy,this.lightProbe);e.context.irradiance.addAssign(t)}}class eO{parseFunction(){console.warn("Abstract function.")}}class VE{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn("Abstract function.")}}VE.isNodeFunction=!0;const soe=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,aoe=/[a-z_0-9]+/ig,b6="#pragma main",ooe=i=>{i=i.trim();const e=i.indexOf(b6),t=e!==-1?i.slice(e+b6.length):i,n=t.match(soe);if(n!==null&&n.length===5){const r=n[4],s=[];let a=null;for(;(a=aoe.exec(r))!==null;)s.push(a);const l=[];let u=0;for(;u0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Oh||n.mapping===Ih||n.mapping===ed){if(e.backgroundBlurriness>0||n.mapping===ed)return SE(n);{let a;return n.isCubeTexture===!0?a=P0(n):a=fi(n),kU(a)}}else{if(n.isTexture===!0)return fi(n,gu.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=s.get(t);return(a===void 0||r)&&(a=n(),s.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const s=zi("color","color",n).setGroup(Ln),a=zi("density","float",n).setGroup(Ln);return Cg(s,RE(a))}else if(n.isFog){const s=zi("color","color",n).setGroup(Ln),a=zi("near","float",n).setGroup(Ln),l=zi("far","float",n).setGroup(Ln);return Cg(s,NE(a,l))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return P0(n);if(n.isTexture===!0)return fi(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,s=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=s,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return S6.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=fi(e,gu).renderOutput(t.toneMapping,t.currentColorSpace);return S6.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new x6,this.nodeBuilderCache=new Map,this.cacheLib={}}}const gS=new jl;class ry{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Xn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const r=e.length;for(let s=0;s{await this.compileAsync(v,x);const T=this._renderLists.get(v,x),N=this._renderContexts.get(v,x,this._renderTarget),C=v.overrideMaterial||S.material,E=this._objects.get(S,C,v,x,T.lightsNode,N,N.clippingContext),{fragmentShader:O,vertexShader:U}=E.getNodeBuilderState();return{fragmentShader:O,vertexShader:U}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),await n.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new coe(this,n),this._animation=new dne(this._nodes,this.info),this._attributes=new yne(n),this._background=new Tae(this,this._nodes),this._geometries=new bne(this._attributes,this.info),this._textures=new One(this,n,this.info),this._pipelines=new Ene(n,this._nodes),this._bindings=new Cne(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new gne(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new Dne(this.lighting),this._bundles=new foe,this._renderContexts=new Une,this._animation.start(),this._initialized=!0,e()}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,s=r.renderId,a=this._currentRenderContext,l=this._currentRenderObjectFunction,u=this._compilationPromises,h=e.isScene===!0?e:w6;n===null&&(n=e);const m=this._renderTarget,v=this._renderContexts.get(n,t,m),x=this._activeMipmapLevel,S=[];this._currentRenderContext=v,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=S,r.renderId++,r.update(),v.depth=this.depth,v.stencil=this.stencil,v.clippingContext||(v.clippingContext=new ry),v.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,m);const T=this._renderLists.get(e,t);if(T.begin(),this._projectObject(e,t,0,T,v.clippingContext),n!==e&&n.traverseVisible(function(U){U.isLight&&U.layers.test(t.layers)&&T.pushLight(U)}),T.finish(),m!==null){this._textures.updateRenderTarget(m,x);const U=this._textures.get(m);v.textures=U.textures,v.depthTexture=U.depthTexture}else v.textures=null,v.depthTexture=null;this._background.update(h,T,v);const N=T.opaque,C=T.transparent,E=T.transparentDoublePass,O=T.lightsNode;this.opaque===!0&&N.length>0&&this._renderObjects(N,t,h,O),this.transparent===!0&&C.length>0&&this._renderTransparents(C,E,t,h,O),r.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=l,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(S)}async renderAsync(e,t){this._initialized===!1&&await this.init();const n=this._renderScene(e,t);await this.backend.resolveTimestampAsync(n,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: +`}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}}class x6{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===Qn.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.frameId&&e.update(this)!==!1&&r.set(n,this.frameId)}else if(t===Qn.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.renderId&&e.update(this)!==!1&&r.set(n,this.renderId)}else t===Qn.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class qE{constructor(e,t,n=null,r="",s=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=s}}qE.isNodeFunctionInput=!0;class Jae extends md{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,r=UE(this.light),s=e.context.reflectedLight;t.direct({lightDirection:r,lightColor:n,reflectedLight:s},e.stack,e)}}const mS=new jn,vv=new jn;let hm=null;class eoe extends md{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=yn(new pe).setGroup(Ln),this.halfWidth=yn(new pe).setGroup(Ln),this.updateType=Qn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;vv.identity(),mS.copy(t.matrixWorld),mS.premultiply(n),vv.extractRotation(mS),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(vv),this.halfHeight.value.applyMatrix4(vv)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=fi(hm.LTC_FLOAT_1),n=fi(hm.LTC_FLOAT_2)):(t=fi(hm.LTC_HALF_1),n=fi(hm.LTC_HALF_2));const{colorNode:r,light:s}=this,a=e.context.lightingModel,l=Ky(s),u=e.context.reflectedLight;a.directRectArea({lightColor:r,lightPosition:l,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:u,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){hm=e}}class JB extends md{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=yn(0).setGroup(Ln),this.penumbraCosNode=yn(0).setGroup(Ln),this.cutoffDistanceNode=yn(0).setGroup(Ln),this.decayExponentNode=yn(0).setGroup(Ln)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return Uc(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,l=Ky(a).sub(Xr),u=l.normalize(),h=u.dot(UE(a)),m=this.getSpotAttenuation(h),v=l.length(),x=IE({lightDistance:v,cutoffDistance:r,decayExponent:s});let S=n.mul(m).mul(x);if(a.map){const N=DB(a),C=fi(a.map,N.xy).onRenderUpdate(()=>a.map);S=N.mul(2).sub(1).abs().lessThan(1).all().select(S.mul(C),S)}const T=e.context.reflectedLight;t.direct({lightDirection:u,lightColor:S,reflectedLight:T},e.stack,e)}}class toe extends JB{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&t.isTexture===!0){const r=e.acos().mul(1/Math.PI);n=fi(t,Pt(r,0),0).r}else n=super.getSpotAttenuation(e);return n}}class noe extends md{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class ioe extends md{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=LE(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=yn(new cn).setGroup(Ln)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:r}=this,a=Ko.dot(r).mul(.5).add(.5),l=Ui(n,t,a);e.context.irradiance.addAssign(l)}}class roe extends md{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new pe);this.lightProbe=vc(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=QB(Gy,this.lightProbe);e.context.irradiance.addAssign(t)}}class eO{parseFunction(){console.warn("Abstract function.")}}class VE{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn("Abstract function.")}}VE.isNodeFunction=!0;const soe=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,aoe=/[a-z_0-9]+/ig,b6="#pragma main",ooe=i=>{i=i.trim();const e=i.indexOf(b6),t=e!==-1?i.slice(e+b6.length):i,n=t.match(soe);if(n!==null&&n.length===5){const r=n[4],s=[];let a=null;for(;(a=aoe.exec(r))!==null;)s.push(a);const l=[];let u=0;for(;u0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const s=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===Oh||n.mapping===Ih||n.mapping===ed){if(e.backgroundBlurriness>0||n.mapping===ed)return SE(n);{let a;return n.isCubeTexture===!0?a=P0(n):a=fi(n),kU(a)}}else{if(n.isTexture===!0)return fi(n,gu.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=s,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=s.get(t);return(a===void 0||r)&&(a=n(),s.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const s=zi("color","color",n).setGroup(Ln),a=zi("density","float",n).setGroup(Ln);return Cg(s,RE(a))}else if(n.isFog){const s=zi("color","color",n).setGroup(Ln),a=zi("near","float",n).setGroup(Ln),l=zi("far","float",n).setGroup(Ln);return Cg(s,NE(a,l))}else console.error("THREE.Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return P0(n);if(n.isTexture===!0)return fi(n);console.error("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,s=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=s,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return S6.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=fi(e,gu).renderOutput(t.toneMapping,t.currentColorSpace);return S6.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new x6,this.nodeBuilderCache=new Map,this.cacheLib={}}}const gS=new jl;class ry{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Xn,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,n){const r=e.length;for(let s=0;s{await this.compileAsync(v,x);const T=this._renderLists.get(v,x),N=this._renderContexts.get(v,x,this._renderTarget),C=v.overrideMaterial||S.material,E=this._objects.get(S,C,v,x,T.lightsNode,N,N.clippingContext),{fragmentShader:O,vertexShader:U}=E.getNodeBuilderState();return{fragmentShader:O,vertexShader:U}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let n=this.backend;try{await n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),await n.init(this)}catch(s){t(s);return}else{t(r);return}}this._nodes=new coe(this,n),this._animation=new dne(this._nodes,this.info),this._attributes=new yne(n),this._background=new Tae(this,this._nodes),this._geometries=new bne(this._attributes,this.info),this._textures=new One(this,n,this.info),this._pipelines=new Ene(n,this._nodes),this._bindings=new Cne(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new gne(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new Dne(this.lighting),this._bundles=new foe,this._renderContexts=new Une,this._animation.start(),this._initialized=!0,e()}),this._initPromise)}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,n=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const r=this._nodes.nodeFrame,s=r.renderId,a=this._currentRenderContext,l=this._currentRenderObjectFunction,u=this._compilationPromises,h=e.isScene===!0?e:w6;n===null&&(n=e);const m=this._renderTarget,v=this._renderContexts.get(n,t,m),x=this._activeMipmapLevel,S=[];this._currentRenderContext=v,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=S,r.renderId++,r.update(),v.depth=this.depth,v.stencil=this.stencil,v.clippingContext||(v.clippingContext=new ry),v.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,m);const T=this._renderLists.get(e,t);if(T.begin(),this._projectObject(e,t,0,T,v.clippingContext),n!==e&&n.traverseVisible(function(U){U.isLight&&U.layers.test(t.layers)&&T.pushLight(U)}),T.finish(),m!==null){this._textures.updateRenderTarget(m,x);const U=this._textures.get(m);v.textures=U.textures,v.depthTexture=U.depthTexture}else v.textures=null,v.depthTexture=null;this._background.update(h,T,v);const N=T.opaque,C=T.transparent,E=T.transparentDoublePass,O=T.lightsNode;this.opaque===!0&&N.length>0&&this._renderObjects(N,t,h,O),this.transparent===!0&&C.length>0&&this._renderTransparents(C,E,t,h,O),r.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=l,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(S)}async renderAsync(e,t){this._initialized===!1&&await this.init();const n=this._renderScene(e,t);await this.backend.resolveTimestampAsync(n,"render")}async waitForGPU(){await this.backend.waitForGPU()}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: Message: ${e.message}`;e.reason&&(t+=` Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:s,renderList:a}=e,l=this._currentRenderContext,u=this._bundles.get(r,s),h=this.backend.get(u);h.renderContexts===void 0&&(h.renderContexts=new Set);const m=r.version!==h.version,v=h.renderContexts.has(l)===!1||m;if(h.renderContexts.add(l),v){this.backend.beginBundle(l),(h.renderObjects===void 0||m)&&(h.renderObjects=[]),this._currentRenderBundle=u;const x=a.opaque;this.opaque===!0&&x.length>0&&this._renderObjects(x,s,t,n),this._currentRenderBundle=null,this.backend.finishBundle(l,u),h.version=r.version}else{const{renderObjects:x}=h;for(let S=0,T=x.length;S>=x,T.viewportValue.height>>=x,T.viewportValue.minDepth=U,T.viewportValue.maxDepth=I,T.viewport=T.viewportValue.equals(vS)===!1,T.scissorValue.copy(E).multiplyScalar(O).floor(),T.scissor=this._scissorTest&&T.scissorValue.equals(vS)===!1,T.scissorValue.width>>=x,T.scissorValue.height>>=x,T.clippingContext||(T.clippingContext=new ry),T.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,S),yv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_S.setFromProjectionMatrix(yv,N);const j=this._renderLists.get(e,t);if(j.begin(),this._projectObject(e,t,0,j,T.clippingContext),j.finish(),this.sortObjects===!0&&j.sort(this._opaqueSort,this._transparentSort),S!==null){this._textures.updateRenderTarget(S,x);const Q=this._textures.get(S);T.textures=Q.textures,T.depthTexture=Q.depthTexture,T.width=Q.width,T.height=Q.height,T.renderTarget=S,T.depth=S.depthBuffer,T.stencil=S.stencilBuffer}else T.textures=null,T.depthTexture=null,T.width=this.domElement.width,T.height=this.domElement.height,T.depth=this.depth,T.stencil=this.stencil;T.width>>=x,T.height>>=x,T.activeCubeFace=v,T.activeMipmapLevel=x,T.occlusionQueryCount=j.occlusionQueryCount,this._background.update(h,j,T),this.backend.beginRender(T);const{bundles:z,lightsNode:G,transparentDoublePass:H,transparent:q,opaque:V}=j;if(z.length>0&&this._renderBundles(z,h,G),this.opaque===!0&&V.length>0&&this._renderObjects(V,t,h,G),this.transparent===!0&&q.length>0&&this._renderTransparents(q,H,t,h,G),this.backend.finishRender(T),s.renderId=a,this._currentRenderContext=l,this._currentRenderObjectFunction=u,r!==null){this.setRenderTarget(m,v,x);const Q=this._quad;this._nodes.hasOutputChange(S.texture)&&(Q.material.fragmentNode=this._nodes.getOutputNode(S.texture),Q.material.needsUpdate=!0),this._renderScene(Q,Q.camera,!1)}return h.onAfterRender(this,e,t,S),T}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,n){this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,n=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),n===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,n,r){const s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,s=0,a=1){const l=this._viewport;e.isVector4?l.copy(e):l.set(e,t,n,r),l.minDepth=s,l.maxDepth=a}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,n=!0){if(this._initialized===!1)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);const r=this._renderTarget||this._getFrameBufferTarget();let s=null;if(r!==null){this._textures.updateRenderTarget(r);const a=this._textures.get(r);s=this._renderContexts.get(null,null,r),s.textures=a.textures,s.depthTexture=a.depthTexture,s.width=a.width,s.height=a.height,s.renderTarget=r,s.depth=r.depthBuffer,s.stencil=r.stencilBuffer}if(this.backend.clear(e,t,n,s),r!==null&&this._renderTarget===null){const a=this._quad;this._nodes.hasOutputChange(r.texture)&&(a.material.fragmentNode=this._nodes.getOutputNode(r.texture),a.material.needsUpdate=!0),this._renderScene(a,a.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,n=!0){this._initialized===!1&&await this.init(),this.clear(e,t,n)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this._renderTarget!==null?Ya:this.toneMapping}get currentColorSpace(){return this._renderTarget!==null?Mo:this.outputColorSpace}dispose(){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e){if(this.isDeviceLost===!0)return;if(this._initialized===!1)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const t=this._nodes.nodeFrame,n=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const r=this.backend,s=this._pipelines,a=this._bindings,l=this._nodes,u=Array.isArray(e)?e:[e];if(u[0]===void 0||u[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");r.beginCompute(e);for(const h of u){if(s.has(h)===!1){const x=()=>{h.removeEventListener("dispose",x),s.delete(h),a.delete(h),l.delete(h)};h.addEventListener("dispose",x);const S=h.onInitFunction;S!==null&&S.call(h,{renderer:this})}l.updateForCompute(h),a.updateForCompute(h);const m=a.getForCompute(h),v=s.getForCompute(h,m);r.compute(e,h,m,v)}r.finishCompute(e),t.renderId=n}async computeAsync(e){this._initialized===!1&&await this.init(),this.compute(e),await this.backend.resolveTimestampAsync(e,"compute")}async hasFeatureAsync(e){return this._initialized===!1&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){this._initialized===!1&&await this.init(),this._textures.updateTexture(e)}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=_h.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=_h.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=_h.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n!==null?r=n.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t)}copyTextureToTexture(e,t,n=null,r=null,s=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,s)}async readRenderTargetPixelsAsync(e,t,n,r,s,a=0,l=0){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,s,l)}_projectObject(e,t,n,r,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||_S.intersectsSprite(e)){this.sortObjects===!0&&_h.setFromMatrixPosition(e.matrixWorld).applyMatrix4(yv);const{geometry:u,material:h}=e;h.visible&&r.push(e,u,h,n,_h.z,null,s)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||_S.intersectsObject(e))){const{geometry:u,material:h}=e;if(this.sortObjects===!0&&(u.boundingSphere===null&&u.computeBoundingSphere(),_h.copy(u.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(yv)),Array.isArray(h)){const m=u.groups;for(let v=0,x=m.length;v0){for(const{material:a}of t)a.side=or;this._renderObjects(t,n,r,s,"backSide");for(const{material:a}of t)a.side=El;this._renderObjects(e,n,r,s);for(const{material:a}of t)a.side=as}else this._renderObjects(e,n,r,s)}_renderObjects(e,t,n,r,s=null){for(let a=0,l=e.length;a0,S.isShadowNodeMaterial&&(S.side=s.shadowSide===null?s.side:s.shadowSide,s.depthNode&&s.depthNode.isNode&&(x=S.depthNode,S.depthNode=s.depthNode),s.castShadowNode&&s.castShadowNode.isNode&&(v=S.colorNode,S.colorNode=s.castShadowNode)),s=S}s.transparent===!0&&s.side===as&&s.forceSinglePass===!1?(s.side=or,this._handleObjectFunction(e,s,t,n,l,a,u,"backSide"),s.side=El,this._handleObjectFunction(e,s,t,n,l,a,u,h),s.side=as):this._handleObjectFunction(e,s,t,n,l,a,u,h),m!==void 0&&(t.overrideMaterial.positionNode=m),x!==void 0&&(t.overrideMaterial.depthNode=x),v!==void 0&&(t.overrideMaterial.colorNode=v),e.onAfterRender(this,t,n,r,s,a)}_renderObjectDirect(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a;const m=this._nodes.needsRefresh(h);m&&(this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h)),this._pipelines.updateForRender(h),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(h),h.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(h,this.info),m&&this._nodes.updateAfter(h)}_createObjectPipeline(e,t,n,r,s,a,l,u){const h=this._objects.get(e,t,n,r,s,this._currentRenderContext,l,u);h.drawRange=e.geometry.drawRange,h.group=a,this._nodes.updateBefore(h),this._geometries.updateForRender(h),this._nodes.updateForRender(h),this._bindings.updateForRender(h),this._pipelines.getForRender(h,this._compilationPromises),this._nodes.updateAfter(h)}get compile(){return this.compileAsync}}class jE{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function moe(i){return i+(Nh-i%Nh)%Nh}class nO extends jE{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return moe(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class iO extends nO{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let goe=0;class rO extends iO{constructor(e,t){super("UniformBuffer_"+goe++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class voe extends iO{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){let e=0;for(let t=0,n=this.uniforms.length;t ${h} `),n+=`${u.code} `,l===s&&t!=="compute"&&(n+=`// result - `,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(l.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);let l=a.uniformGPU;if(l===void 0){const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture")l=new Zy(s.name,s.node,u),m.push(l);else if(t==="cubeTexture")l=new aO(s.name,s.node,u),m.push(l);else if(t==="texture3D")l=new oO(s.name,s.node,u),m.push(l);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;const v=new rO(e,u);v.name=e.name,m.push(v),l=v}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new sO(n+"_"+h,u),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}}let yS=null,EA=null;class lO{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return yS=yS||new bt,this.renderer.getDrawingBufferSize(yS)}setScissorTest(){}getClearColor(){const e=this.renderer;return EA=EA||new TE,e.getClearColor(EA),EA.getRGB(EA,this.renderer.currentColorSpace),EA}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:q7(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${F0} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let Eoe=0;class Coe{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class Noe{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,a=e.usage||r.STATIC_DRAW,l=e.isInterleavedBufferAttribute?e.data:e,u=n.get(l);let h=u.bufferGPU;h===void 0&&(h=this._createBuffer(r,t,s,a),u.bufferGPU=h,u.bufferType=t,u.version=l.version);let m;if(s instanceof Float32Array)m=r.FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?m=r.HALF_FLOAT:m=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)m=r.SHORT;else if(s instanceof Uint32Array)m=r.UNSIGNED_INT;else if(s instanceof Int32Array)m=r.INT;else if(s instanceof Int8Array)m=r.BYTE;else if(s instanceof Uint8Array)m=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)m=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let v={bufferGPU:h,bufferType:t,type:m,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:m===r.INT||m===r.UNSIGNED_INT||e.gpuType===Ns,id:Eoe++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const x=this._createBuffer(r,t,s,a);v=new Coe(v,x)}n.set(e,v)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,a=t.get(s),l=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(l,a.bufferGPU),u.length===0)n.bufferSubData(l,0,r);else{for(let h=0,m=u.length;h1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u{function s(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}}let C6=!1,xv,bS,N6;class Poe{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},C6===!1&&(this._init(this.gl),C6=!0)}_init(e){xv={[td]:e.REPEAT,[Yl]:e.CLAMP_TO_EDGE,[nd]:e.MIRRORED_REPEAT},bS={[dr]:e.NEAREST,[i_]:e.NEAREST_MIPMAP_NEAREST,[Ql]:e.NEAREST_MIPMAP_LINEAR,[ps]:e.LINEAR,[XA]:e.LINEAR_MIPMAP_NEAREST,[za]:e.LINEAR_MIPMAP_LINEAR},N6={[GT]:e.NEVER,[WT]:e.ALWAYS,[Ay]:e.LESS,[py]:e.LEQUAL,[qT]:e.EQUAL,[HT]:e.GEQUAL,[VT]:e.GREATER,[jT]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===dr||e===i_||e===Ql?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,s=!1){const{gl:a,extensions:l}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;return t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB&&(n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=r===bn&&s===!1?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5)),t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA&&(n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=r===bn&&s===!1?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)),t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_INT&&(u=a.DEPTH24_STENCIL8),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&l.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:r,backend:s}=this;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),n.texParameteri(e,n.TEXTURE_WRAP_S,xv[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,xv[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&n.texParameteri(e,n.TEXTURE_WRAP_R,xv[t.wrapR]),n.texParameteri(e,n.TEXTURE_MAG_FILTER,bS[t.magFilter]);const a=t.mipmaps!==void 0&&t.mipmaps.length>0,l=t.minFilter===ps&&a?za:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,bS[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,N6[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===dr||t.minFilter!==Ql&&t.minFilter!==za||t.type===$r&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const u=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,s=this.getGLTextureType(e);let a=r[s];a===void 0&&(a=t.createTexture(),n.state.bindTexture(s,a),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=a),n.set(e,{textureGPU:a,glTextureType:s,isDefault:!0})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:s,width:a,height:l,depth:u}=t,h=r.utils.convert(e.format,e.colorSpace),m=r.utils.convert(e.type),v=this.getInternalFormat(e.internalFormat,h,m,e.colorSpace,e.isVideoTexture),x=n.createTexture(),S=this.getGLTextureType(e);r.state.bindTexture(S,x),this.setTextureParameters(S,e),e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,v,a,l,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,v,a,l,u):e.isVideoTexture||n.texStorage2D(S,s,v,a,l),r.set(e,{textureGPU:x,glTextureType:S,glFormat:h,glType:m,glInternalFormat:v})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:s,glTextureType:a,glFormat:l,glType:u}=r.get(t),{width:h,height:m}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,h,m,l,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:s}=t,{textureGPU:a,glTextureType:l,glFormat:u,glType:h,glInternalFormat:m}=this.backend.get(e);if(e.isRenderTargetTexture||a===void 0)return;const v=x=>x.isDataTexture?x.image.data:typeof HTMLImageElement<"u"&&x instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&x instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&x instanceof ImageBitmap||x instanceof OffscreenCanvas?x:x.data;if(this.backend.state.bindTexture(l,a),this.setTextureParameters(l,e),e.isCompressedTexture){const x=e.mipmaps,S=t.image;for(let T=0;T0,x=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(v){const S=l!==0||u!==0;let T,N;if(e.isDepthTexture===!0?(T=r.DEPTH_BUFFER_BIT,N=r.DEPTH_ATTACHMENT,t.stencil&&(T|=r.STENCIL_BUFFER_BIT)):(T=r.COLOR_BUFFER_BIT,N=r.COLOR_ATTACHMENT0),S){const C=this.backend.get(t.renderTarget),E=C.framebuffers[t.getCacheKey()],O=C.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,E),s.bindFramebuffer(r.READ_FRAMEBUFFER,O);const U=x-u-m;r.blitFramebuffer(l,U,l+h,U+m,l,U,l+h,U+m,T,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,E),s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,U,h,m),s.unbindTexture()}else{const C=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,C),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,N,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,h,m,0,0,h,m,T,r.NEAREST),r.deleteFramebuffer(C)}}else s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,x-m-u,h,m),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:n}=this,r=t.renderTarget,{samples:s,depthTexture:a,depthBuffer:l,stencilBuffer:u,width:h,height:m}=r;if(n.bindRenderbuffer(n.RENDERBUFFER,e),l&&!u){let v=n.DEPTH_COMPONENT24;s>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(v=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,s,v,h,m)):n.renderbufferStorage(n.RENDERBUFFER,v,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else l&&u&&(s>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,s,n.DEPTH24_STENCIL8,h,m):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,n,r,s,a){const{backend:l,gl:u}=this,{textureGPU:h,glFormat:m,glType:v}=this.backend.get(e),x=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,x);const S=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,S,h,0);const T=this._getTypedArrayType(v),N=this._getBytesPerTexel(v,m),E=r*s*N,O=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.bufferData(u.PIXEL_PACK_BUFFER,E,u.STREAM_READ),u.readPixels(t,n,r,s,m,v,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await l.utils._clientWaitAsync();const U=new T(E/T.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,U),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(x),U}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}}class Loe{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class Uoe{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const R6={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class Boe{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:r,object:s,type:a,info:l,index:u}=this;u!==0?n.drawElements(r,t,a,e):n.drawArrays(r,e,t),l.update(s,t,r,1)}renderInstances(e,t,n){const{gl:r,mode:s,type:a,index:l,object:u,info:h}=this;n!==0&&(l!==0?r.drawElementsInstanced(s,t,a,e,n):r.drawArraysInstanced(s,e,t,n),h.update(u,t,s,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:s,object:a,info:l}=this;if(n===0)return;const u=r.get("WEBGL_multi_draw");if(u===null)for(let h=0;h0)){const n=t.queryQueue.shift();this.initTimestampQuery(n)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const n=this.get(e);n.gpuQueries||(n.gpuQueries=[]);for(let r=0;r0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),s=r.previousContext,a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const l=e.textures;if(l!==null)for(let u=0;u0){const m=u.framebuffers[e.getCacheKey()],v=t.COLOR_BUFFER_BIT,x=u.msaaFrameBuffer,S=e.textures;n.bindFramebuffer(t.READ_FRAMEBUFFER,x),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,m);for(let T=0;T{let u=0;for(let h=0;h0&&s.add(r[h]),n[h]=null,a.deleteQuery(m),u++)}u1?E.renderInstances(I,O,U):E.render(I,O),u.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new Moe(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,s=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,r),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:s,vertexProgram:a}=r,l=n.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU;if(n.attachShader(l,u),n.attachShader(l,h),n.linkProgram(l),this.set(r,{programGPU:l,fragmentShader:u,vertexShader:h}),t!==null&&this.parallel){const m=new Promise(v=>{const x=this.parallel,S=()=>{n.getProgramParameter(l,x.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),v()):requestAnimationFrame(S)};S()});t.push(m);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(` + `,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(l.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const s=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);let l=a.uniformGPU;if(l===void 0){const u=e.groupNode,h=u.name,m=this.getBindGroupArray(h,n);if(t==="texture")l=new Zy(s.name,s.node,u),m.push(l);else if(t==="cubeTexture")l=new aO(s.name,s.node,u),m.push(l);else if(t==="texture3D")l=new oO(s.name,s.node,u),m.push(l);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;const v=new rO(e,u);v.name=e.name,m.push(v),l=v}else{const v=this.uniformGroups[n]||(this.uniformGroups[n]={});let x=v[h];x===void 0&&(x=new sO(n+"_"+h,u),v[h]=x,m.push(x)),l=this.getNodeUniform(s,t),x.addUniform(l)}a.uniformGPU=l}return s}}let yS=null,EA=null;class lO{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}isOccluded(){}async resolveTimestampAsync(){}async waitForGPU(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return yS=yS||new bt,this.renderer.getDrawingBufferSize(yS)}setScissorTest(){}getClearColor(){const e=this.renderer;return EA=EA||new TE,e.getClearColor(EA),EA.getRGB(EA,this.renderer.currentColorSpace),EA}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:q7(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${F0} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let Eoe=0;class Coe{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class Noe{constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,s=e.array,a=e.usage||r.STATIC_DRAW,l=e.isInterleavedBufferAttribute?e.data:e,u=n.get(l);let h=u.bufferGPU;h===void 0&&(h=this._createBuffer(r,t,s,a),u.bufferGPU=h,u.bufferType=t,u.version=l.version);let m;if(s instanceof Float32Array)m=r.FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?m=r.HALF_FLOAT:m=r.UNSIGNED_SHORT;else if(s instanceof Int16Array)m=r.SHORT;else if(s instanceof Uint32Array)m=r.UNSIGNED_INT;else if(s instanceof Int32Array)m=r.INT;else if(s instanceof Int8Array)m=r.BYTE;else if(s instanceof Uint8Array)m=r.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)m=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let v={bufferGPU:h,bufferType:t,type:m,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:m===r.INT||m===r.UNSIGNED_INT||e.gpuType===Ns,id:Eoe++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const x=this._createBuffer(r,t,s,a);v=new Coe(v,x)}n.set(e,v)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,s=e.isInterleavedBufferAttribute?e.data:e,a=t.get(s),l=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(l,a.bufferGPU),u.length===0)n.bufferSubData(l,0,r);else{for(let h=0,m=u.length;h1?this.enable(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u{function s(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),n()}s()})}}let C6=!1,xv,bS,N6;class Poe{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},C6===!1&&(this._init(this.gl),C6=!0)}_init(e){xv={[td]:e.REPEAT,[Yl]:e.CLAMP_TO_EDGE,[nd]:e.MIRRORED_REPEAT},bS={[dr]:e.NEAREST,[i_]:e.NEAREST_MIPMAP_NEAREST,[Ql]:e.NEAREST_MIPMAP_LINEAR,[ps]:e.LINEAR,[XA]:e.LINEAR_MIPMAP_NEAREST,[za]:e.LINEAR_MIPMAP_LINEAR},N6={[GT]:e.NEVER,[WT]:e.ALWAYS,[Ay]:e.LESS,[py]:e.LEQUAL,[qT]:e.EQUAL,[HT]:e.GEQUAL,[VT]:e.GREATER,[jT]:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===dr||e===i_||e===Ql?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,s=!1){const{gl:a,extensions:l}=this;if(e!==null){if(a[e]!==void 0)return a[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;return t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB&&(n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=r===bn&&s===!1?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5)),t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA&&(n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=r===bn&&s===!1?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)),t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_INT&&(u=a.DEPTH24_STENCIL8),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&l.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:r,backend:s}=this;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),n.texParameteri(e,n.TEXTURE_WRAP_S,xv[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,xv[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&n.texParameteri(e,n.TEXTURE_WRAP_R,xv[t.wrapR]),n.texParameteri(e,n.TEXTURE_MAG_FILTER,bS[t.magFilter]);const a=t.mipmaps!==void 0&&t.mipmaps.length>0,l=t.minFilter===ps&&a?za:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,bS[l]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,N6[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===dr||t.minFilter!==Ql&&t.minFilter!==za||t.type===$r&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const u=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,u.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,s=this.getGLTextureType(e);let a=r[s];a===void 0&&(a=t.createTexture(),n.state.bindTexture(s,a),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),r[s]=a),n.set(e,{textureGPU:a,glTextureType:s,isDefault:!0})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:s,width:a,height:l,depth:u}=t,h=r.utils.convert(e.format,e.colorSpace),m=r.utils.convert(e.type),v=this.getInternalFormat(e.internalFormat,h,m,e.colorSpace,e.isVideoTexture),x=n.createTexture(),S=this.getGLTextureType(e);r.state.bindTexture(S,x),this.setTextureParameters(S,e),e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,s,v,a,l,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,s,v,a,l,u):e.isVideoTexture||n.texStorage2D(S,s,v,a,l),r.set(e,{textureGPU:x,glTextureType:S,glFormat:h,glType:m,glInternalFormat:v})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:s,glTextureType:a,glFormat:l,glType:u}=r.get(t),{width:h,height:m}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,s),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,h,m,l,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:s}=t,{textureGPU:a,glTextureType:l,glFormat:u,glType:h,glInternalFormat:m}=this.backend.get(e);if(e.isRenderTargetTexture||a===void 0)return;const v=x=>x.isDataTexture?x.image.data:typeof HTMLImageElement<"u"&&x instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&x instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&x instanceof ImageBitmap||x instanceof OffscreenCanvas?x:x.data;if(this.backend.state.bindTexture(l,a),this.setTextureParameters(l,e),e.isCompressedTexture){const x=e.mipmaps,S=t.image;for(let T=0;T0,x=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(v){const S=l!==0||u!==0;let T,N;if(e.isDepthTexture===!0?(T=r.DEPTH_BUFFER_BIT,N=r.DEPTH_ATTACHMENT,t.stencil&&(T|=r.STENCIL_BUFFER_BIT)):(T=r.COLOR_BUFFER_BIT,N=r.COLOR_ATTACHMENT0),S){const C=this.backend.get(t.renderTarget),E=C.framebuffers[t.getCacheKey()],O=C.msaaFrameBuffer;s.bindFramebuffer(r.DRAW_FRAMEBUFFER,E),s.bindFramebuffer(r.READ_FRAMEBUFFER,O);const U=x-u-m;r.blitFramebuffer(l,U,l+h,U+m,l,U,l+h,U+m,T,r.NEAREST),s.bindFramebuffer(r.READ_FRAMEBUFFER,E),s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,U,h,m),s.unbindTexture()}else{const C=r.createFramebuffer();s.bindFramebuffer(r.DRAW_FRAMEBUFFER,C),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,N,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,h,m,0,0,h,m,T,r.NEAREST),r.deleteFramebuffer(C)}}else s.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,l,x-m-u,h,m),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:n}=this,r=t.renderTarget,{samples:s,depthTexture:a,depthBuffer:l,stencilBuffer:u,width:h,height:m}=r;if(n.bindRenderbuffer(n.RENDERBUFFER,e),l&&!u){let v=n.DEPTH_COMPONENT24;s>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(v=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,s,v,h,m)):n.renderbufferStorage(n.RENDERBUFFER,v,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else l&&u&&(s>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,s,n.DEPTH24_STENCIL8,h,m):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,h,m),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,n,r,s,a){const{backend:l,gl:u}=this,{textureGPU:h,glFormat:m,glType:v}=this.backend.get(e),x=u.createFramebuffer();u.bindFramebuffer(u.READ_FRAMEBUFFER,x);const S=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,S,h,0);const T=this._getTypedArrayType(v),N=this._getBytesPerTexel(v,m),E=r*s*N,O=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.bufferData(u.PIXEL_PACK_BUFFER,E,u.STREAM_READ),u.readPixels(t,n,r,s,m,v,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await l.utils._clientWaitAsync();const U=new T(E/T.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,O),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,U),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(x),U}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}}class Loe{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class Uoe{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const R6={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class Boe{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:n,mode:r,object:s,type:a,info:l,index:u}=this;u!==0?n.drawElements(r,t,a,e):n.drawArrays(r,e,t),l.update(s,t,r,1)}renderInstances(e,t,n){const{gl:r,mode:s,type:a,index:l,object:u,info:h}=this;n!==0&&(l!==0?r.drawElementsInstanced(s,t,a,e,n):r.drawArraysInstanced(s,e,t,n),h.update(u,t,s,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:s,object:a,info:l}=this;if(n===0)return;const u=r.get("WEBGL_multi_draw");if(u===null)for(let h=0;h0)){const n=t.queryQueue.shift();this.initTimestampQuery(n)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const n=this.get(e);n.gpuQueries||(n.gpuQueries=[]);for(let r=0;r0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),s=r.previousContext,a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const l=e.textures;if(l!==null)for(let u=0;u0){const m=u.framebuffers[e.getCacheKey()],v=t.COLOR_BUFFER_BIT,x=u.msaaFrameBuffer,S=e.textures;n.bindFramebuffer(t.READ_FRAMEBUFFER,x),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,m);for(let T=0;T{let u=0;for(let h=0;h0&&s.add(r[h]),n[h]=null,a.deleteQuery(m),u++)}u1?E.renderInstances(I,O,U):E.render(I,O),u.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new Moe(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,s=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,r),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:s,vertexProgram:a}=r,l=n.createProgram(),u=this.get(s).shaderGPU,h=this.get(a).shaderGPU;if(n.attachShader(l,u),n.attachShader(l,h),n.linkProgram(l),this.set(r,{programGPU:l,fragmentShader:u,vertexShader:h}),t!==null&&this.parallel){const m=new Promise(v=>{const x=this.parallel,S=()=>{n.getProgramParameter(l,x.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),v()):requestAnimationFrame(S)};S()});t.push(m);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(` `),r=[],s=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let l=s;l":" "} ${u}: ${n[l]}`)}return r.join(` `)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),s=e.getShaderInfoLog(t).trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const l=parseInt(a[1]);return n.toUpperCase()+` @@ -4259,11 +4259,11 @@ struct ${e} { ${t} };`}_getWGSLStructBinding(e,t,n,r=0,s=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)} @binding( ${r} ) @group( ${s} ) -var<${n}> ${e} : ${a};`}}class tle{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=Be.Depth24PlusStencil8:e.depth&&(t=Be.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,a=s.getRenderTarget();t=a?a.samples:s.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return $A.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return $A.LineList;if(e.isLine)return $A.LineStrip;if(e.isMesh)return $A.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?Be.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const nle=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),ile=new Map([[H7,["float16"]]]),rle=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class sle{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let a=s.buffer;if(a===void 0){const l=r.device;let u=n.array;if(e.normalized===!1&&(u.constructor===Int16Array||u.constructor===Uint16Array)){const m=new Uint32Array(u.length);for(let v=0;v1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=CA.UnfilterableFloat)),a.texture.isDepthTexture)u.sampleType=CA.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const m=a.texture.type;m===Ns?u.sampleType=CA.SInt:m===Nr?u.sampleType=CA.UInt:m===$r&&(this.backend.hasFeature("float32-filterable")?u.sampleType=CA.Float:u.sampleType=CA.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=Ia.Cube:a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=Ia.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=Ia.ThreeD),l.texture=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);r.push(l)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){const{backend:s,bindGroupLayoutCache:a}=this,l=s.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let h;n>0&&(l.groups===void 0&&(l.groups=[],l.versions=[]),l.versions[n]===r&&(h=l.groups[n])),h===void 0&&(h=this.createBindGroup(e,u),n>0&&(l.groups[n]=h,l.versions[n]=r)),l.group=h,l.layout=u}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,s=t.get(e).buffer;n.queue.writeBuffer(s,0,r,0)}createBindGroup(e,t){const n=this.backend,r=n.device;let s=0;const a=[];for(const l of e.bindings){if(l.isUniformBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.byteLength,m=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,v=r.createBuffer({label:"bindingBuffer_"+l.name,size:h,usage:m});u.buffer=v}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isStorageBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.attribute;u.buffer=n.get(h).buffer}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isSampler){const u=n.get(l.texture);a.push({binding:s,resource:u.sampler})}else if(l.isSampledTexture){const u=n.get(l.texture);let h;if(u.externalTexture!==void 0)h=r.importExternalTexture({source:u.externalTexture});else{const m=l.store?1:u.texture.mipLevelCount,v=`view-${u.texture.width}-${u.texture.height}-${m}`;if(h=u[v],h===void 0){const x=Ooe.All;let S;l.isSampledCubeTexture?S=Ia.Cube:l.isSampledTexture3D?S=Ia.ThreeD:l.texture.isDataArrayTexture||l.texture.isCompressedArrayTexture?S=Ia.TwoDArray:S=Ia.TwoD,h=u[v]=u.texture.createView({aspect:x,dimension:S,mipLevelCount:m})}}a.push({binding:s,resource:h})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}}class ole{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:s,pipeline:a}=e,{vertexProgram:l,fragmentProgram:u}=a,h=this.backend,m=h.device,v=h.utils,x=h.get(a),S=[];for(const ne of e.getBindings()){const oe=h.get(ne);S.push(oe.layout)}const T=h.attributeUtils.createShaderVertexBuffers(e);let N;r.transparent===!0&&r.blending!==$a&&(N=this._getBlending(r));let C={};r.stencilWrite===!0&&(C={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const E=this._getColorWriteMask(r),O=[];if(e.context.textures!==null){const ne=e.context.textures;for(let oe=0;oe1},layout:m.createPipelineLayout({bindGroupLayouts:S})},V={},Q=e.context.depth,J=e.context.stencil;if((Q===!0||J===!0)&&(Q===!0&&(V.format=G,V.depthWriteEnabled=r.depthWrite,V.depthCompare=z),J===!0&&(V.stencilFront=C,V.stencilBack={},V.stencilReadMask=r.stencilFuncMask,V.stencilWriteMask=r.stencilWriteMask),q.depthStencil=V),t===null)x.pipeline=m.createRenderPipeline(q);else{const ne=new Promise(oe=>{m.createRenderPipelineAsync(q).then(ie=>{x.pipeline=ie,oe()})});t.push(ne)}}createBundleEncoder(e){const t=this.backend,{utils:n,device:r}=t,s=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormat(e),l=this._getSampleCount(e),u={label:"renderBundleEncoder",colorFormats:[a],depthStencilFormat:s,sampleCount:l};return r.createRenderBundleEncoder(u)}createComputePipeline(e,t){const n=this.backend,r=n.device,s=n.get(e.computeProgram).module,a=n.get(e),l=[];for(const u of t){const h=n.get(u);l.push(h.layout)}a.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:l})})}_getBlending(e){let t,n;const r=e.blending,s=e.blendSrc,a=e.blendDst,l=e.blendEquation;if(r===wT){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,h=e.blendDstAlpha!==null?e.blendDstAlpha:a,m=e.blendEquationAlpha!==null?e.blendEquationAlpha:l;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(l)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(h),operation:this._getBlendOperation(m)}}else{const u=e.premultipliedAlpha,h=(m,v,x,S)=>{t={srcFactor:m,dstFactor:v,operation:Mf.Add},n={srcFactor:x,dstFactor:S,operation:Mf.Add}};if(u)switch(r){case Xa:h(Jn.One,Jn.OneMinusSrcAlpha,Jn.One,Jn.OneMinusSrcAlpha);break;case t0:h(Jn.One,Jn.One,Jn.One,Jn.One);break;case n0:h(Jn.Zero,Jn.OneMinusSrc,Jn.Zero,Jn.One);break;case i0:h(Jn.Zero,Jn.Src,Jn.Zero,Jn.SrcAlpha);break}else switch(r){case Xa:h(Jn.SrcAlpha,Jn.OneMinusSrcAlpha,Jn.One,Jn.OneMinusSrcAlpha);break;case t0:h(Jn.SrcAlpha,Jn.One,Jn.SrcAlpha,Jn.One);break;case n0:h(Jn.Zero,Jn.OneMinusSrc,Jn.Zero,Jn.One);break;case i0:h(Jn.Zero,Jn.Src,Jn.Zero,Jn.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case ET:t=Jn.Zero;break;case CT:t=Jn.One;break;case NT:t=Jn.Src;break;case RT:t=Jn.OneMinusSrc;break;case zm:t=Jn.SrcAlpha;break;case Gm:t=Jn.OneMinusSrcAlpha;break;case LT:t=Jn.Dst;break;case UT:t=Jn.OneMinusDstColor;break;case DT:t=Jn.DstAlpha;break;case PT:t=Jn.OneMinusDstAlpha;break;case BT:t=Jn.SrcAlphaSaturated;break;case vne:t=Jn.Constant;break;case _ne:t=Jn.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case sk:t=Bs.Never;break;case YS:t=Bs.Always;break;case ak:t=Bs.Less;break;case lk:t=Bs.LessEqual;break;case ok:t=Bs.Equal;break;case hk:t=Bs.GreaterEqual;break;case uk:t=Bs.Greater;break;case ck:t=Bs.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Nf:t=yh.Keep;break;case ZF:t=yh.Zero;break;case JF:t=yh.Replace;break;case rk:t=yh.Invert;break;case ek:t=yh.IncrementClamp;break;case tk:t=yh.DecrementClamp;break;case nk:t=yh.IncrementWrap;break;case ik:t=yh.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case wo:t=Mf.Add;break;case TT:t=Mf.Subtract;break;case MT:t=Mf.ReverseSubtract;break;case R7:t=Mf.Min;break;case D7:t=Mf.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},s=this.backend.utils;switch(r.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?U0.Uint16:U0.Uint32),n.side){case El:r.frontFace=SS.CCW,r.cullMode=wS.Back;break;case or:r.frontFace=SS.CCW,r.cullMode=wS.Front;break;case as:r.frontFace=SS.CCW,r.cullMode=wS.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?P6.All:P6.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Bs.Always;else{const n=e.depthFunc;switch(n){case qm:t=Bs.Never;break;case Vm:t=Bs.Always;break;case jm:t=Bs.Less;break;case Bh:t=Bs.LessEqual;break;case Hm:t=Bs.Equal;break;case Wm:t=Bs.GreaterEqual;break;case $m:t=Bs.Greater;break;case Xm:t=Bs.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class lle extends lO{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.trackTimestamp=e.trackTimestamp===!0,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new tle(this),this.attributeUtils=new sle(this),this.bindingUtils=new ale(this),this.pipelineUtils=new ole(this),this.textureUtils=new Hoe(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===void 0){const a={powerPreference:t.powerPreference},l=typeof navigator<"u"?await navigator.gpu.requestAdapter(a):null;if(l===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const u=Object.values(sT),h=[];for(const v of u)l.features.has(v)&&h.push(v);const m={requiredFeatures:h,requiredLimits:t.requiredLimits};n=await l.requestDevice(m)}else n=t.device;n.lost.then(a=>{const l={api:"WebGPU",message:a.message||"Unknown reason",reason:a.reason||null,originalEvent:a};e.onDeviceLost(l)});const r=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=r;const s=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(sT.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s}),this.updateSize()}get coordinateSystem(){return cu}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let s=r.descriptors;if(s===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==n.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples||r.loadOp!==t.loadOp){s={},r.descriptors=s;const u=()=>{n.removeEventListener("dispose",u),this.delete(n)};n.addEventListener("dispose",u)}const a=e.getCacheKey();let l=s[a];if(l===void 0){const u=e.textures,h=[];let m;for(let v=0;v0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:Wr.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=s;const l=a.depthStencilAttachment;if(e.textures!==null){const m=a.colorAttachments;for(let v=0;v0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),n>0){const r=n*8;let s=this.occludedResolveCache.get(r);s===void 0&&(s=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,s));const a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const r=e.textures;for(let s=0;sl?(h.x=Math.min(t.dispatchCount,l),h.y=Math.ceil(t.dispatchCount/l)):h.x=t.dispatchCount,s.dispatchWorkgroups(h.x,h.y,h.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:n,context:r,pipeline:s}=e,a=e.getBindings(),l=this.get(r),u=this.get(s).pipeline,h=l.currentSets,m=l.currentPass,v=e.getDrawParameters();if(v===null)return;h.pipeline!==u&&(m.setPipeline(u),h.pipeline=u);const x=h.bindingGroups;for(let C=0,E=a.length;C1?0:I;T===!0?m.drawIndexed(E[I],j,C[I]/S.array.BYTES_PER_ELEMENT,0,z):m.draw(E[I],j,C[I],z)}}else if(T===!0){const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndexedIndirect(I,0)}else m.drawIndexed(C,E,O,0,0);t.update(n,C,E)}else{const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndirect(I,0)}else m.draw(C,E,O,0);t.update(n,C,E)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,s=this.utils,a=s.getSampleCountRenderContext(e.context),l=s.getCurrentColorSpace(e.context),u=s.getCurrentColorFormat(e.context),h=s.getCurrentDepthStencilFormat(e.context),m=s.getPrimitiveTopology(n,r);let v=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==l||t.colorFormat!==u||t.depthStencilFormat!==h||t.primitiveTopology!==m||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=l,t.colorFormat=u,t.depthStencilFormat=h,t.primitiveTopology=m,t.clippingContextCacheKey=e.clippingContextCacheKey,v=!0),v}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,s=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(s),r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const n=this.get(e);if(!n.timeStampQuerySet){const r=e.isComputeNode?"compute":"render",s=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${r}_${e.id}`});Object.assign(t,{timestampWrites:{querySet:s,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}),n.timeStampQuerySet=s}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const n=this.get(e),r=2*BigInt64Array.BYTES_PER_ELEMENT;n.currentTimestampQueryBuffers===void 0&&(n.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:s,resultBuffer:a}=n.currentTimestampQueryBuffers;t.resolveQuerySet(n.timeStampQuerySet,0,2,s,0),a.mapState==="unmapped"&&t.copyBufferToBuffer(s,0,a,0,r)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const n=this.get(e);if(n.currentTimestampQueryBuffers===void 0)return;const{resultBuffer:r}=n.currentTimestampQueryBuffers;r.mapState==="unmapped"&&r.mapAsync(GPUMapMode.READ).then(()=>{const s=new BigUint64Array(r.getMappedRange()),a=Number(s[1]-s[0])/1e6;this.renderer.info.updateTimestamp(t,a),r.unmap()})}createNodeBuilder(e,t){return new ele(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),s=n.currentPass.finish();this.get(t).bundleGPU=s,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,s=0){let a=0,l=0,u=0,h=0,m=0,v=0,x=e.image.width,S=e.image.height;n!==null&&(h=n.x,m=n.y,v=n.z||0,x=n.width,S=n.height),r!==null&&(a=r.x,l=r.y,u=r.z||0);const T=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),N=this.get(e).texture,C=this.get(t).texture;T.copyTextureToTexture({texture:N,mipLevel:s,origin:{x:h,y:m,z:v}},{texture:C,mipLevel:s,origin:{x:a,y:l,z:u}},[x,S,1]),this.device.queue.submit([T.finish()])}copyFramebufferToTexture(e,t,n){const r=this.get(t);let s=null;t.renderTarget?e.isDepthTexture?s=this.get(t.depthTexture).texture:s=this.get(t.textures[0]).texture:e.isDepthTexture?s=this.textureUtils.getDepthBuffer(t.depth,t.stencil):s=this.context.getCurrentTexture();const a=this.get(e).texture;if(s.format!==a.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,a.format);return}let l;if(r.currentPass?(r.currentPass.end(),l=r.encoder):l=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),l.copyTextureToTexture({texture:s,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),r.currentPass){const{descriptor:u}=r;for(let h=0;h(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new D6(e)));const n=new t(e);super(n,e),this.library=new cle,this.isWebGPURenderer=!0}}/** +var<${n}> ${e} : ${a};`}}class tle{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=Be.Depth24PlusStencil8:e.depth&&(t=Be.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,a=s.getRenderTarget();t=a?a.samples:s.samples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return $A.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return $A.LineList;if(e.isLine)return $A.LineStrip;if(e.isMesh)return $A.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?Be.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const nle=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),ile=new Map([[H7,["float16"]]]),rle=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class sle{constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,s=r.get(n);let a=s.buffer;if(a===void 0){const l=r.device;let u=n.array;if(e.normalized===!1&&(u.constructor===Int16Array||u.constructor===Uint16Array)){const m=new Uint32Array(u.length);for(let v=0;v1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=CA.UnfilterableFloat)),a.texture.isDepthTexture)u.sampleType=CA.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const m=a.texture.type;m===Ns?u.sampleType=CA.SInt:m===Nr?u.sampleType=CA.UInt:m===$r&&(this.backend.hasFeature("float32-filterable")?u.sampleType=CA.Float:u.sampleType=CA.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=Ia.Cube:a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=Ia.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=Ia.ThreeD),l.texture=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);r.push(l)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){const{backend:s,bindGroupLayoutCache:a}=this,l=s.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let h;n>0&&(l.groups===void 0&&(l.groups=[],l.versions=[]),l.versions[n]===r&&(h=l.groups[n])),h===void 0&&(h=this.createBindGroup(e,u),n>0&&(l.groups[n]=h,l.versions[n]=r)),l.group=h,l.layout=u}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,s=t.get(e).buffer;n.queue.writeBuffer(s,0,r,0)}createBindGroup(e,t){const n=this.backend,r=n.device;let s=0;const a=[];for(const l of e.bindings){if(l.isUniformBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.byteLength,m=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,v=r.createBuffer({label:"bindingBuffer_"+l.name,size:h,usage:m});u.buffer=v}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isStorageBuffer){const u=n.get(l);if(u.buffer===void 0){const h=l.attribute;u.buffer=n.get(h).buffer}a.push({binding:s,resource:{buffer:u.buffer}})}else if(l.isSampler){const u=n.get(l.texture);a.push({binding:s,resource:u.sampler})}else if(l.isSampledTexture){const u=n.get(l.texture);let h;if(u.externalTexture!==void 0)h=r.importExternalTexture({source:u.externalTexture});else{const m=l.store?1:u.texture.mipLevelCount,v=`view-${u.texture.width}-${u.texture.height}-${m}`;if(h=u[v],h===void 0){const x=Ooe.All;let S;l.isSampledCubeTexture?S=Ia.Cube:l.isSampledTexture3D?S=Ia.ThreeD:l.texture.isDataArrayTexture||l.texture.isCompressedArrayTexture?S=Ia.TwoDArray:S=Ia.TwoD,h=u[v]=u.texture.createView({aspect:x,dimension:S,mipLevelCount:m})}}a.push({binding:s,resource:h})}s++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}}class ole{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:n,material:r,geometry:s,pipeline:a}=e,{vertexProgram:l,fragmentProgram:u}=a,h=this.backend,m=h.device,v=h.utils,x=h.get(a),S=[];for(const ie of e.getBindings()){const le=h.get(ie);S.push(le.layout)}const T=h.attributeUtils.createShaderVertexBuffers(e);let N;r.transparent===!0&&r.blending!==$a&&(N=this._getBlending(r));let C={};r.stencilWrite===!0&&(C={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const E=this._getColorWriteMask(r),O=[];if(e.context.textures!==null){const ie=e.context.textures;for(let le=0;le1},layout:m.createPipelineLayout({bindGroupLayouts:S})},V={},Q=e.context.depth,J=e.context.stencil;if((Q===!0||J===!0)&&(Q===!0&&(V.format=G,V.depthWriteEnabled=r.depthWrite,V.depthCompare=z),J===!0&&(V.stencilFront=C,V.stencilBack={},V.stencilReadMask=r.stencilFuncMask,V.stencilWriteMask=r.stencilWriteMask),q.depthStencil=V),t===null)x.pipeline=m.createRenderPipeline(q);else{const ie=new Promise(le=>{m.createRenderPipelineAsync(q).then(re=>{x.pipeline=re,le()})});t.push(ie)}}createBundleEncoder(e){const t=this.backend,{utils:n,device:r}=t,s=n.getCurrentDepthStencilFormat(e),a=n.getCurrentColorFormat(e),l=this._getSampleCount(e),u={label:"renderBundleEncoder",colorFormats:[a],depthStencilFormat:s,sampleCount:l};return r.createRenderBundleEncoder(u)}createComputePipeline(e,t){const n=this.backend,r=n.device,s=n.get(e.computeProgram).module,a=n.get(e),l=[];for(const u of t){const h=n.get(u);l.push(h.layout)}a.pipeline=r.createComputePipeline({compute:s,layout:r.createPipelineLayout({bindGroupLayouts:l})})}_getBlending(e){let t,n;const r=e.blending,s=e.blendSrc,a=e.blendDst,l=e.blendEquation;if(r===wT){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,h=e.blendDstAlpha!==null?e.blendDstAlpha:a,m=e.blendEquationAlpha!==null?e.blendEquationAlpha:l;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(l)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(h),operation:this._getBlendOperation(m)}}else{const u=e.premultipliedAlpha,h=(m,v,x,S)=>{t={srcFactor:m,dstFactor:v,operation:Mf.Add},n={srcFactor:x,dstFactor:S,operation:Mf.Add}};if(u)switch(r){case Xa:h(Jn.One,Jn.OneMinusSrcAlpha,Jn.One,Jn.OneMinusSrcAlpha);break;case t0:h(Jn.One,Jn.One,Jn.One,Jn.One);break;case n0:h(Jn.Zero,Jn.OneMinusSrc,Jn.Zero,Jn.One);break;case i0:h(Jn.Zero,Jn.Src,Jn.Zero,Jn.SrcAlpha);break}else switch(r){case Xa:h(Jn.SrcAlpha,Jn.OneMinusSrcAlpha,Jn.One,Jn.OneMinusSrcAlpha);break;case t0:h(Jn.SrcAlpha,Jn.One,Jn.SrcAlpha,Jn.One);break;case n0:h(Jn.Zero,Jn.OneMinusSrc,Jn.Zero,Jn.One);break;case i0:h(Jn.Zero,Jn.Src,Jn.Zero,Jn.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case ET:t=Jn.Zero;break;case CT:t=Jn.One;break;case NT:t=Jn.Src;break;case RT:t=Jn.OneMinusSrc;break;case zm:t=Jn.SrcAlpha;break;case Gm:t=Jn.OneMinusSrcAlpha;break;case LT:t=Jn.Dst;break;case UT:t=Jn.OneMinusDstColor;break;case DT:t=Jn.DstAlpha;break;case PT:t=Jn.OneMinusDstAlpha;break;case BT:t=Jn.SrcAlphaSaturated;break;case vne:t=Jn.Constant;break;case _ne:t=Jn.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case sk:t=Bs.Never;break;case YS:t=Bs.Always;break;case ak:t=Bs.Less;break;case lk:t=Bs.LessEqual;break;case ok:t=Bs.Equal;break;case hk:t=Bs.GreaterEqual;break;case uk:t=Bs.Greater;break;case ck:t=Bs.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Nf:t=yh.Keep;break;case ZF:t=yh.Zero;break;case JF:t=yh.Replace;break;case rk:t=yh.Invert;break;case ek:t=yh.IncrementClamp;break;case tk:t=yh.DecrementClamp;break;case nk:t=yh.IncrementWrap;break;case ik:t=yh.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case wo:t=Mf.Add;break;case TT:t=Mf.Subtract;break;case MT:t=Mf.ReverseSubtract;break;case R7:t=Mf.Min;break;case D7:t=Mf.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},s=this.backend.utils;switch(r.topology=s.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?U0.Uint16:U0.Uint32),n.side){case El:r.frontFace=SS.CCW,r.cullMode=wS.Back;break;case or:r.frontFace=SS.CCW,r.cullMode=wS.Front;break;case as:r.frontFace=SS.CCW,r.cullMode=wS.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?P6.All:P6.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Bs.Always;else{const n=e.depthFunc;switch(n){case qm:t=Bs.Never;break;case Vm:t=Bs.Always;break;case jm:t=Bs.Less;break;case Bh:t=Bs.LessEqual;break;case Hm:t=Bs.Equal;break;case Wm:t=Bs.GreaterEqual;break;case $m:t=Bs.Greater;break;case Xm:t=Bs.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class lle extends lO{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.trackTimestamp=e.trackTimestamp===!0,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new tle(this),this.attributeUtils=new sle(this),this.bindingUtils=new ale(this),this.pipelineUtils=new ole(this),this.textureUtils=new Hoe(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let n;if(t.device===void 0){const a={powerPreference:t.powerPreference},l=typeof navigator<"u"?await navigator.gpu.requestAdapter(a):null;if(l===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const u=Object.values(sT),h=[];for(const v of u)l.features.has(v)&&h.push(v);const m={requiredFeatures:h,requiredLimits:t.requiredLimits};n=await l.requestDevice(m)}else n=t.device;n.lost.then(a=>{const l={api:"WebGPU",message:a.message||"Unknown reason",reason:a.reason||null,originalEvent:a};e.onDeviceLost(l)});const r=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=r;const s=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(sT.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s}),this.updateSize()}get coordinateSystem(){return cu}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let s=r.descriptors;if(s===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==n.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples||r.loadOp!==t.loadOp){s={},r.descriptors=s;const u=()=>{n.removeEventListener("dispose",u),this.delete(n)};n.addEventListener("dispose",u)}const a=e.getCacheKey();let l=s[a];if(l===void 0){const u=e.textures,h=[];let m;for(let v=0;v0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,s=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:Wr.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=s;const l=a.depthStencilAttachment;if(e.textures!==null){const m=a.colorAttachments;for(let v=0;v0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),n>0){const r=n*8;let s=this.occludedResolveCache.get(r);s===void 0&&(s=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,s));const a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const r=e.textures;for(let s=0;sl?(h.x=Math.min(t.dispatchCount,l),h.y=Math.ceil(t.dispatchCount/l)):h.x=t.dispatchCount,s.dispatchWorkgroups(h.x,h.y,h.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){const{object:n,context:r,pipeline:s}=e,a=e.getBindings(),l=this.get(r),u=this.get(s).pipeline,h=l.currentSets,m=l.currentPass,v=e.getDrawParameters();if(v===null)return;h.pipeline!==u&&(m.setPipeline(u),h.pipeline=u);const x=h.bindingGroups;for(let C=0,E=a.length;C1?0:I;T===!0?m.drawIndexed(E[I],j,C[I]/S.array.BYTES_PER_ELEMENT,0,z):m.draw(E[I],j,C[I],z)}}else if(T===!0){const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndexedIndirect(I,0)}else m.drawIndexed(C,E,O,0,0);t.update(n,C,E)}else{const{vertexCount:C,instanceCount:E,firstVertex:O}=v,U=e.getIndirect();if(U!==null){const I=this.get(U).buffer;m.drawIndirect(I,0)}else m.draw(C,E,O,0);t.update(n,C,E)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,s=this.utils,a=s.getSampleCountRenderContext(e.context),l=s.getCurrentColorSpace(e.context),u=s.getCurrentColorFormat(e.context),h=s.getCurrentDepthStencilFormat(e.context),m=s.getPrimitiveTopology(n,r);let v=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==l||t.colorFormat!==u||t.depthStencilFormat!==h||t.primitiveTopology!==m||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=l,t.colorFormat=u,t.depthStencilFormat=h,t.primitiveTopology=m,t.clippingContextCacheKey=e.clippingContextCacheKey,v=!0),v}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,s=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(s),r.getCurrentColorSpace(s),r.getCurrentColorFormat(s),r.getCurrentDepthStencilFormat(s),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,s,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,s,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const n=this.get(e);if(!n.timeStampQuerySet){const r=e.isComputeNode?"compute":"render",s=this.device.createQuerySet({type:"timestamp",count:2,label:`timestamp_${r}_${e.id}`});Object.assign(t,{timestampWrites:{querySet:s,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1}}),n.timeStampQuerySet=s}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const n=this.get(e),r=2*BigInt64Array.BYTES_PER_ELEMENT;n.currentTimestampQueryBuffers===void 0&&(n.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})});const{resolveBuffer:s,resultBuffer:a}=n.currentTimestampQueryBuffers;t.resolveQuerySet(n.timeStampQuerySet,0,2,s,0),a.mapState==="unmapped"&&t.copyBufferToBuffer(s,0,a,0,r)}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const n=this.get(e);if(n.currentTimestampQueryBuffers===void 0)return;const{resultBuffer:r}=n.currentTimestampQueryBuffers;r.mapState==="unmapped"&&r.mapAsync(GPUMapMode.READ).then(()=>{const s=new BigUint64Array(r.getMappedRange()),a=Number(s[1]-s[0])/1e6;this.renderer.info.updateTimestamp(t,a),r.unmap()})}createNodeBuilder(e,t){return new ele(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const n=this.get(e),s=n.currentPass.finish();this.get(t).bundleGPU=s,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,s=0){let a=0,l=0,u=0,h=0,m=0,v=0,x=e.image.width,S=e.image.height;n!==null&&(h=n.x,m=n.y,v=n.z||0,x=n.width,S=n.height),r!==null&&(a=r.x,l=r.y,u=r.z||0);const T=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),N=this.get(e).texture,C=this.get(t).texture;T.copyTextureToTexture({texture:N,mipLevel:s,origin:{x:h,y:m,z:v}},{texture:C,mipLevel:s,origin:{x:a,y:l,z:u}},[x,S,1]),this.device.queue.submit([T.finish()])}copyFramebufferToTexture(e,t,n){const r=this.get(t);let s=null;t.renderTarget?e.isDepthTexture?s=this.get(t.depthTexture).texture:s=this.get(t.textures[0]).texture:e.isDepthTexture?s=this.textureUtils.getDepthBuffer(t.depth,t.stencil):s=this.context.getCurrentTexture();const a=this.get(e).texture;if(s.format!==a.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",s.format,a.format);return}let l;if(r.currentPass?(r.currentPass.end(),l=r.encoder):l=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),l.copyTextureToTexture({texture:s,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e),r.currentPass){const{descriptor:u}=r;for(let h=0;h(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new D6(e)));const n=new t(e);super(n,e),this.library=new cle,this.isWebGPURenderer=!0}}/** * @license * Copyright 2010-2024 Three.js Authors * SPDX-License-Identifier: MIT - */$.BRDF_GGX;$.BRDF_Lambert;$.BasicShadowFilter;$.Break;$.Continue;$.DFGApprox;$.D_GGX;$.Discard;$.EPSILON;$.F_Schlick;const hle=$.Fn;$.INFINITY;const fle=$.If,dle=$.Loop;$.NodeShaderStage;$.NodeType;$.NodeUpdateType;$.NodeAccess;$.PCFShadowFilter;$.PCFSoftShadowFilter;$.PI;$.PI2;$.Return;$.Schlick_to_F0;$.ScriptableNodeResources;$.ShaderNode;$.TBNViewMatrix;$.VSMShadowFilter;$.V_GGX_SmithCorrelated;$.abs;$.acesFilmicToneMapping;$.acos;$.add;$.addNodeElement;$.agxToneMapping;$.all;$.alphaT;$.and;$.anisotropy;$.anisotropyB;$.anisotropyT;$.any;$.append;$.arrayBuffer;const Ale=$.asin;$.assign;$.atan;$.atan2;$.atomicAdd;$.atomicAnd;$.atomicFunc;$.atomicMax;$.atomicMin;$.atomicOr;$.atomicStore;$.atomicSub;$.atomicXor;$.attenuationColor;$.attenuationDistance;$.attribute;$.attributeArray;$.backgroundBlurriness;$.backgroundIntensity;$.backgroundRotation;$.batch;$.billboarding;$.bitAnd;$.bitNot;$.bitOr;$.bitXor;$.bitangentGeometry;$.bitangentLocal;$.bitangentView;$.bitangentWorld;$.bitcast;$.blendBurn;$.blendColor;$.blendDodge;$.blendOverlay;$.blendScreen;$.blur;$.bool;$.buffer;$.bufferAttribute;$.bumpMap;$.burn;$.bvec2;$.bvec3;$.bvec4;$.bypass;$.cache;$.call;$.cameraFar;$.cameraNear;$.cameraNormalMatrix;$.cameraPosition;$.cameraProjectionMatrix;$.cameraProjectionMatrixInverse;$.cameraViewMatrix;$.cameraWorldMatrix;$.cbrt;$.cdl;$.ceil;$.checker;$.cineonToneMapping;$.clamp;$.clearcoat;$.clearcoatRoughness;$.code;$.color;$.colorSpaceToWorking;$.colorToDirection;$.compute;$.cond;$.context;$.convert;$.convertColorSpace;$.convertToTexture;const ple=$.cos;$.cross;$.cubeTexture;$.dFdx;$.dFdy;$.dashSize;$.defaultBuildStages;$.defaultShaderStages;$.defined;$.degrees;$.deltaTime;$.densityFog;$.densityFogFactor;$.depth;$.depthPass;$.difference;$.diffuseColor;$.directPointLight;$.directionToColor;$.dispersion;$.distance;$.div;$.dodge;$.dot;$.drawIndex;$.dynamicBufferAttribute;$.element;$.emissive;$.equal;$.equals;$.equirectUV;const mle=$.exp;$.exp2;$.expression;$.faceDirection;$.faceForward;$.faceforward;const gle=$.float;$.floor;$.fog;$.fract;$.frameGroup;$.frameId;$.frontFacing;$.fwidth;$.gain;$.gapSize;$.getConstNodeType;$.getCurrentStack;$.getDirection;$.getDistanceAttenuation;$.getGeometryRoughness;$.getNormalFromDepth;$.getParallaxCorrectNormal;$.getRoughness;$.getScreenPosition;$.getShIrradianceAt;$.getTextureIndex;$.getViewPosition;$.glsl;$.glslFn;$.grayscale;$.greaterThan;$.greaterThanEqual;$.hash;$.highpModelNormalViewMatrix;$.highpModelViewMatrix;$.hue;$.instance;const vle=$.instanceIndex;$.instancedArray;$.instancedBufferAttribute;$.instancedDynamicBufferAttribute;$.instancedMesh;$.int;$.inverseSqrt;$.inversesqrt;$.invocationLocalIndex;$.invocationSubgroupIndex;$.ior;$.iridescence;$.iridescenceIOR;$.iridescenceThickness;$.ivec2;$.ivec3;$.ivec4;$.js;$.label;$.length;$.lengthSq;$.lessThan;$.lessThanEqual;$.lightPosition;$.lightTargetDirection;$.lightTargetPosition;$.lightViewPosition;$.lightingContext;$.lights;$.linearDepth;$.linearToneMapping;$.localId;$.log;$.log2;$.logarithmicDepthToViewZ;$.loop;$.luminance;$.mediumpModelViewMatrix;$.mat2;$.mat3;$.mat4;$.matcapUV;$.materialAO;$.materialAlphaTest;$.materialAnisotropy;$.materialAnisotropyVector;$.materialAttenuationColor;$.materialAttenuationDistance;$.materialClearcoat;$.materialClearcoatNormal;$.materialClearcoatRoughness;$.materialColor;$.materialDispersion;$.materialEmissive;$.materialIOR;$.materialIridescence;$.materialIridescenceIOR;$.materialIridescenceThickness;$.materialLightMap;$.materialLineDashOffset;$.materialLineDashSize;$.materialLineGapSize;$.materialLineScale;$.materialLineWidth;$.materialMetalness;$.materialNormal;$.materialOpacity;$.materialPointWidth;$.materialReference;$.materialReflectivity;$.materialRefractionRatio;$.materialRotation;$.materialRoughness;$.materialSheen;$.materialSheenRoughness;$.materialShininess;$.materialSpecular;$.materialSpecularColor;$.materialSpecularIntensity;$.materialSpecularStrength;$.materialThickness;$.materialTransmission;$.max;$.maxMipLevel;$.metalness;$.min;$.mix;$.mixElement;$.mod;$.modInt;$.modelDirection;$.modelNormalMatrix;$.modelPosition;$.modelScale;$.modelViewMatrix;$.modelViewPosition;$.modelViewProjection;$.modelWorldMatrix;$.modelWorldMatrixInverse;$.morphReference;$.mrt;$.mul;$.mx_aastep;$.mx_cell_noise_float;$.mx_contrast;$.mx_fractal_noise_float;$.mx_fractal_noise_vec2;$.mx_fractal_noise_vec3;$.mx_fractal_noise_vec4;$.mx_hsvtorgb;$.mx_noise_float;$.mx_noise_vec3;$.mx_noise_vec4;$.mx_ramplr;$.mx_ramptb;$.mx_rgbtohsv;$.mx_safepower;$.mx_splitlr;$.mx_splittb;$.mx_srgb_texture_to_lin_rec709;$.mx_transform_uv;$.mx_worley_noise_float;$.mx_worley_noise_vec2;$.mx_worley_noise_vec3;const _le=$.negate;$.neutralToneMapping;$.nodeArray;$.nodeImmutable;$.nodeObject;$.nodeObjects;$.nodeProxy;$.normalFlat;$.normalGeometry;$.normalLocal;$.normalMap;$.normalView;$.normalWorld;$.normalize;$.not;$.notEqual;$.numWorkgroups;$.objectDirection;$.objectGroup;$.objectPosition;$.objectScale;$.objectViewPosition;$.objectWorldMatrix;$.oneMinus;$.or;$.orthographicDepthToViewZ;$.oscSawtooth;$.oscSine;$.oscSquare;$.oscTriangle;$.output;$.outputStruct;$.overlay;$.overloadingFn;$.parabola;$.parallaxDirection;$.parallaxUV;$.parameter;$.pass;$.passTexture;$.pcurve;$.perspectiveDepthToViewZ;$.pmremTexture;$.pointUV;$.pointWidth;$.positionGeometry;$.positionLocal;$.positionPrevious;$.positionView;$.positionViewDirection;$.positionWorld;$.positionWorldDirection;$.posterize;$.pow;$.pow2;$.pow3;$.pow4;$.property;$.radians;$.rand;$.range;$.rangeFog;$.rangeFogFactor;$.reciprocal;$.reference;$.referenceBuffer;$.reflect;$.reflectVector;$.reflectView;$.reflector;$.refract;$.refractVector;$.refractView;$.reinhardToneMapping;$.remainder;$.remap;$.remapClamp;$.renderGroup;$.renderOutput;$.rendererReference;$.rotate;$.rotateUV;$.roughness;$.round;$.rtt;$.sRGBTransferEOTF;$.sRGBTransferOETF;$.sampler;$.saturate;$.saturation;$.screen;$.screenCoordinate;$.screenSize;$.screenUV;$.scriptable;$.scriptableValue;$.select;$.setCurrentStack;$.shaderStages;$.shadow;$.shadowPositionWorld;$.sharedUniformGroup;$.sheen;$.sheenRoughness;$.shiftLeft;$.shiftRight;$.shininess;$.sign;const yle=$.sin;$.sinc;$.skinning;$.skinningReference;$.smoothstep;$.smoothstepElement;$.specularColor;$.specularF90;$.spherizeUV;$.split;$.spritesheetUV;const xle=$.sqrt;$.stack;$.step;const ble=$.storage;$.storageBarrier;$.storageObject;$.storageTexture;$.string;$.sub;$.subgroupIndex;$.subgroupSize;$.tan;$.tangentGeometry;$.tangentLocal;$.tangentView;$.tangentWorld;$.temp;$.texture;$.texture3D;$.textureBarrier;$.textureBicubic;$.textureCubeUV;$.textureLoad;$.textureSize;$.textureStore;$.thickness;$.threshold;$.time;$.timerDelta;$.timerGlobal;$.timerLocal;$.toOutputColorSpace;$.toWorkingColorSpace;$.toneMapping;$.toneMappingExposure;$.toonOutlinePass;$.transformDirection;$.transformNormal;$.transformNormalToView;$.transformedBentNormalView;$.transformedBitangentView;$.transformedBitangentWorld;$.transformedClearcoatNormalView;$.transformedNormalView;$.transformedNormalWorld;$.transformedTangentView;$.transformedTangentWorld;$.transmission;$.transpose;$.tri;$.tri3;$.triNoise3D;$.triplanarTexture;$.triplanarTextures;$.trunc;$.tslFn;$.uint;const Sle=$.uniform;$.uniformArray;$.uniformGroup;$.uniforms;$.userData;$.uv;$.uvec2;$.uvec3;$.uvec4;$.varying;$.varyingProperty;$.vec2;$.vec3;$.vec4;$.vectorComponents;$.velocity;$.vertexColor;$.vertexIndex;$.vibrance;$.viewZToLogarithmicDepth;$.viewZToOrthographicDepth;$.viewZToPerspectiveDepth;$.viewport;$.viewportBottomLeft;$.viewportCoordinate;$.viewportDepthTexture;$.viewportLinearDepth;$.viewportMipTexture;$.viewportResolution;$.viewportSafeUV;$.viewportSharedTexture;$.viewportSize;$.viewportTexture;$.viewportTopLeft;$.viewportUV;$.wgsl;$.wgslFn;$.workgroupArray;$.workgroupBarrier;$.workgroupId;$.workingToColorSpace;$.xor;const F6=new Oc,wv=new me;class hO extends Kz{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Si(e,3)),this.setAttribute("uv",new Si(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u_(t,6,1);return this.setAttribute("instanceStart",new Kl(n,3,0)),this.setAttribute("instanceEnd",new Kl(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new u_(t,6,1);return this.setAttribute("instanceColorStart",new Kl(n,3,0)),this.setAttribute("instanceColorEnd",new Kl(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Dz(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Oc);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),F6.setFromBufferAttribute(t),this.boundingBox.union(F6))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ud),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let s=0,a=e.count;s #include #include @@ -4633,10 +4633,10 @@ var<${n}> ${e} : ${a};`}}class tle{constructor(e){this.backend=e}getCurrentDepth #include } - `};class HE extends Qa{constructor(e){super({type:"LineMaterial",uniforms:my.clone(Fa.line.uniforms),vertexShader:Fa.line.vertexShader,fragmentShader:Fa.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const CS=new On,k6=new me,z6=new me,Os=new On,Is=new On,zl=new On,NS=new me,RS=new jn,Fs=new eG,G6=new me,Tv=new Oc,Mv=new ud,Gl=new On;let Xl,Jf;function q6(i,e,t){return Gl.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),Gl.multiplyScalar(1/Gl.w),Gl.x=Jf/t.width,Gl.y=Jf/t.height,Gl.applyMatrix4(i.projectionMatrixInverse),Gl.multiplyScalar(1/Gl.w),Math.abs(Math.max(Gl.x,Gl.y))}function wle(i,e){const t=i.matrixWorld,n=i.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,r.count);for(let l=0,u=a;lv&&Is.z>v)continue;if(Os.z>v){const U=Os.z-Is.z,I=(Os.z-v)/U;Os.lerp(Is,I)}else if(Is.z>v){const U=Is.z-Os.z,I=(Is.z-v)/U;Is.lerp(Os,I)}Os.applyMatrix4(n),Is.applyMatrix4(n),Os.multiplyScalar(1/Os.w),Is.multiplyScalar(1/Is.w),Os.x*=s.x/2,Os.y*=s.y/2,Is.x*=s.x/2,Is.y*=s.y/2,Fs.start.copy(Os),Fs.start.z=0,Fs.end.copy(Is),Fs.end.z=0;const N=Fs.closestPointToPointParameter(NS,!0);Fs.at(N,G6);const C=x0.lerp(Os.z,Is.z,N),E=C>=-1&&C<=1,O=NS.distanceTo(G6)v&&Is.z>v)continue;if(Os.z>v){const U=Os.z-Is.z,I=(Os.z-v)/U;Os.lerp(Is,I)}else if(Is.z>v){const U=Is.z-Os.z,I=(Is.z-v)/U;Is.lerp(Os,I)}Os.applyMatrix4(n),Is.applyMatrix4(n),Os.multiplyScalar(1/Os.w),Is.multiplyScalar(1/Is.w),Os.x*=s.x/2,Os.y*=s.y/2,Is.x*=s.x/2,Is.y*=s.y/2,Fs.start.copy(Os),Fs.start.z=0,Fs.end.copy(Is),Fs.end.z=0;const N=Fs.closestPointToPointParameter(NS,!0);Fs.at(N,G6);const C=x0.lerp(Os.z,Is.z,N),E=C>=-1&&C<=1,O=NS.distanceTo(G6)i.length)&&(e=i.length);for(var t=0,n=Array(e);t3?(Z=Se===ie)&&(H=te[(G=te[4])?5:(G=3,3)],te[4]=te[5]=i):te[0]<=de&&((Z=oe<2&&deie||ie>Se)&&(te[4]=oe,te[5]=ie,J.n=Se,G=0))}if(Z||oe>1)return a;throw Q=!0,ie}return function(oe,ie,Z){if(q>1)throw TypeError("Generator is already running");for(Q&&ie===1&&ne(ie,Z),G=ie,H=Z;(e=G<2?i:H)||!Q;){z||(G?G<3?(G>1&&(J.n=-1),ne(G,H)):J.n=H:J.v=H);try{if(q=2,z){if(G||(oe="next"),e=z[oe]){if(!(e=e.call(z,H)))throw TypeError("iterator result is not an object");if(!e.done)return e;H=e.value,G<2&&(G=0)}else G===1&&(e=z.return)&&e.call(z),G<2&&(H=TypeError("The iterator does not provide a '"+oe+"' method"),G=1);z=i}else if((e=(Q=J.n<0)?H:U.call(I,J))!==a)break}catch(te){z=i,G=1,H=te}finally{q=1}}return{value:e,done:Q}}})(S,N,C),!0),O}var a={};function l(){}function u(){}function h(){}e=Object.getPrototypeOf;var m=[][n]?e(e([][n]())):(go(e={},n,function(){return this}),e),v=h.prototype=l.prototype=Object.create(m);function x(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,go(S,r,"GeneratorFunction")),S.prototype=Object.create(v),S}return u.prototype=h,go(v,"constructor",h),go(h,"constructor",u),u.displayName="GeneratorFunction",go(h,r,"GeneratorFunction"),go(v),go(v,r,"Generator"),go(v,n,function(){return this}),go(v,"toString",function(){return"[object Generator]"}),(uT=function(){return{w:s,m:x}})()}function go(i,e,t,n){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}go=function(s,a,l,u){function h(m,v){go(s,m,function(x){return this._invoke(m,v,x)})}a?r?r(s,a,{value:l,enumerable:!u,configurable:!u,writable:!u}):s[a]=l:(h("next",0),h("throw",1),h("return",2))},go(i,e,t,n)}function cT(i,e){return cT=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},cT(i,e)}function Ar(i,e){return Dle(i)||Fle(i,e)||pO(i,e)||kle()}function jle(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=B0(i))!==null;);return i}function LS(i,e,t,n){var r=lT(B0(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function ji(i){return Ple(i)||Ile(i)||pO(i)||zle()}function Hle(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function AO(i){var e=Hle(i,"string");return typeof e=="symbol"?e:e+""}function pO(i,e){if(i){if(typeof i=="string")return oT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?oT(i,e):void 0}}var mO=function(e){e instanceof Array?e.forEach(mO):(e.map&&e.map.dispose(),e.dispose())},XE=function(e){e.geometry&&e.geometry.dispose(),e.material&&mO(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(XE)},Ki=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),XE(t)}};function Sa(i,e){var t=new e;return{linkProp:function(r){return{default:t[r](),onChange:function(a,l){l[i][r](a)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var a=s[i],l=arguments.length,u=new Array(l>1?l-1:0),h=1;h2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180,s=ar*(1+t),a=Math.sin(n);return{x:s*a*Math.cos(r),y:s*Math.cos(n),z:s*a*Math.sin(r)}}function gO(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),a=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),altitude:r/ar-1}}function Ff(i){return i*Math.PI/180}var Ng=window.THREE?window.THREE:{BackSide:or,BufferAttribute:wr,Color:cn,Mesh:Oi,ShaderMaterial:Qa},Wle=` +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function H6(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function ki(i){for(var e=1;e3?(Z=be===re)&&(H=ne[(G=ne[4])?5:(G=3,3)],ne[4]=ne[5]=i):ne[0]<=de&&((Z=le<2&&dere||re>be)&&(ne[4]=le,ne[5]=re,J.n=be,G=0))}if(Z||le>1)return a;throw Q=!0,re}return function(le,re,Z){if(q>1)throw TypeError("Generator is already running");for(Q&&re===1&&ie(re,Z),G=re,H=Z;(e=G<2?i:H)||!Q;){z||(G?G<3?(G>1&&(J.n=-1),ie(G,H)):J.n=H:J.v=H);try{if(q=2,z){if(G||(le="next"),e=z[le]){if(!(e=e.call(z,H)))throw TypeError("iterator result is not an object");if(!e.done)return e;H=e.value,G<2&&(G=0)}else G===1&&(e=z.return)&&e.call(z),G<2&&(H=TypeError("The iterator does not provide a '"+le+"' method"),G=1);z=i}else if((e=(Q=J.n<0)?H:U.call(I,J))!==a)break}catch(ne){z=i,G=1,H=ne}finally{q=1}}return{value:e,done:Q}}})(S,N,C),!0),O}var a={};function l(){}function u(){}function h(){}e=Object.getPrototypeOf;var m=[][n]?e(e([][n]())):(go(e={},n,function(){return this}),e),v=h.prototype=l.prototype=Object.create(m);function x(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,go(S,r,"GeneratorFunction")),S.prototype=Object.create(v),S}return u.prototype=h,go(v,"constructor",h),go(h,"constructor",u),u.displayName="GeneratorFunction",go(h,r,"GeneratorFunction"),go(v),go(v,r,"Generator"),go(v,n,function(){return this}),go(v,"toString",function(){return"[object Generator]"}),(uT=function(){return{w:s,m:x}})()}function go(i,e,t,n){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}go=function(s,a,l,u){function h(m,v){go(s,m,function(x){return this._invoke(m,v,x)})}a?r?r(s,a,{value:l,enumerable:!u,configurable:!u,writable:!u}):s[a]=l:(h("next",0),h("throw",1),h("return",2))},go(i,e,t,n)}function cT(i,e){return cT=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},cT(i,e)}function Ar(i,e){return Dle(i)||Fle(i,e)||pO(i,e)||kle()}function jle(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=B0(i))!==null;);return i}function LS(i,e,t,n){var r=lT(B0(i.prototype),e,t);return typeof r=="function"?function(s){return r.apply(t,s)}:r}function ji(i){return Ple(i)||Ile(i)||pO(i)||zle()}function Hle(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function AO(i){var e=Hle(i,"string");return typeof e=="symbol"?e:e+""}function pO(i,e){if(i){if(typeof i=="string")return oT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?oT(i,e):void 0}}var mO=function(e){e instanceof Array?e.forEach(mO):(e.map&&e.map.dispose(),e.dispose())},XE=function(e){e.geometry&&e.geometry.dispose(),e.material&&mO(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(XE)},Ki=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),XE(t)}};function Sa(i,e){var t=new e;return{linkProp:function(r){return{default:t[r](),onChange:function(a,l){l[i][r](a)},triggerUpdate:!1}},linkMethod:function(r){return function(s){for(var a=s[i],l=arguments.length,u=new Array(l>1?l-1:0),h=1;h2&&arguments[2]!==void 0?arguments[2]:0,n=(90-i)*Math.PI/180,r=(90-e)*Math.PI/180,s=ar*(1+t),a=Math.sin(n);return{x:s*a*Math.cos(r),y:s*Math.cos(n),z:s*a*Math.sin(r)}}function gO(i){var e=i.x,t=i.y,n=i.z,r=Math.sqrt(e*e+t*t+n*n),s=Math.acos(t/r),a=Math.atan2(n,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),altitude:r/ar-1}}function Ff(i){return i*Math.PI/180}var Ng=window.THREE?window.THREE:{BackSide:or,BufferAttribute:wr,Color:cn,Mesh:Oi,ShaderMaterial:Qa},Wle=` uniform float hollowRadius; varying vec3 vVertexWorldPosition; @@ -4679,7 +4679,7 @@ void main() { power ); gl_FragColor = vec4(color, intensity); -}`;function Xle(i,e,t,n){return new Ng.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:Wle,fragmentShader:$le,uniforms:{coefficient:{value:i},color:{value:new Ng.Color(e)},power:{value:t},hollowRadius:{value:n}}})}function Yle(i,e){for(var t=i.clone(),n=new Float32Array(i.attributes.position.count*3),r=0,s=n.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.color,a=s===void 0?"gold":s,l=r.size,u=l===void 0?2:l,h=r.coefficient,m=h===void 0?.5:h,v=r.power,x=v===void 0?1:v,S=r.hollowRadius,T=S===void 0?0:S,N=r.backside,C=N===void 0?!0:N;ex(this,e),n=Jy(this,e);var E=Yle(t,u),O=Xle(m,a,x,T);return C&&(O.side=Ng.BackSide),n.geometry=E,n.material=O,n}return nx(e,i),tx(e)})(Ng.Mesh),ql=window.THREE?window.THREE:{Color:cn,Group:qa,LineBasicMaterial:q0,LineSegments:Y7,Mesh:Oi,MeshPhongMaterial:oD,SphereGeometry:bu,SRGBColorSpace:bn,TextureLoader:oM},vO=_s({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){Ki(e.globeObj),Ki(e.tileEngine),Ki(e.graticulesObj)}},stateInit:function(){var e=new ql.MeshPhongMaterial({color:0}),t=new ql.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new sY(ar),r=new ql.Group;r.__globeObjType="globe",r.add(t),r.add(n);var s=new ql.LineSegments(new AP(SX(),ar,2),new ql.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:r,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){Ki(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var r;(r=e.globeObj.geometry)===null||r===void 0||r.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new ql.SphereGeometry(ar,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new ql.TextureLoader().load(e.globeImageUrl,function(l){l.colorSpace=ql.SRGBColorSpace,n.map=l,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new ql.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new ql.TextureLoader().load(e.bumpImageUrl,function(l){n.bumpMap=l,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),Ki(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new Qle(e.globeObj.geometry,{color:e.atmosphereColor,size:ar*e.atmosphereAltitude,hollowRadius:ar,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType="atmosphere",e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),yu=function(e){return isNaN(e)?parseInt(Sn(e).toHex(),16):e},Ml=function(e){return e&&isNaN(e)?sd(e).opacity:1},Gh=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,s=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var l=a.slice(1),u=Ar(l,4),h=u[0],m=u[1],v=u[2],x=u[3];r=new cn("rgb(".concat(+h,",").concat(+m,",").concat(+v,")")),s=Math.min(+x,1)}else r=new cn(e);n&&r.convertLinearToSRGB();var S=r.toArray();return t?[].concat(ji(S),[s]):S};function Kle(i,e,t){return i.opacity=e,i.transparent=e<1,i.depthWrite=e>=1,i}var $6=window.THREE?window.THREE:{BufferAttribute:wr};function xu(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(e===1)return new $6.BufferAttribute(new t(i),e);for(var n=new $6.BufferAttribute(new t(i.length*e),e),r=0,s=i.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.dataBindAttr,a=s===void 0?"__data":s,l=r.objBindAttr,u=l===void 0?"__threeObj":l,h=r.removeDelay,m=h===void 0?0:h;return ex(this,e),n=Jy(this,e),Ds(n,"scene",void 0),DS(n,US,void 0),DS(n,Ev,void 0),DS(n,Cv,void 0),n.scene=t,PS(US,n,a),PS(Ev,n,u),PS(Cv,n,m),n.onRemoveObj(function(){}),n}return nx(e,i),tx(e,[{key:"onCreateObj",value:function(n){var r=this;return LS(e,"onCreateObj",this)([function(s){var a=n(s);return s[dm(Ev,r)]=a,a[dm(US,r)]=s,r.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return LS(e,"onRemoveObj",this)([function(s,a){var l=LS(e,"getData",r)([s]);n(s,a);var u=function(){r.scene.remove(s),Ki(s),delete l[dm(Ev,r)]};dm(Cv,r)?setTimeout(u,dm(Cv,r)):u()}]),this}}])})(UQ),ml=window.THREE?window.THREE:{BufferGeometry:Hi,CylinderGeometry:iM,Matrix4:jn,Mesh:Oi,MeshLambertMaterial:Fc,Object3D:pr,Vector3:me},X6=Object.assign({},SM),Y6=X6.BufferGeometryUtils||X6,_O=_s({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var n=Ut(e.pointLat),r=Ut(e.pointLng),s=Ut(e.pointAltitude),a=Ut(e.pointRadius),l=Ut(e.pointColor),u=new ml.CylinderGeometry(1,1,1,e.pointResolution);u.applyMatrix4(new ml.Matrix4().makeRotationX(Math.PI/2)),u.applyMatrix4(new ml.Matrix4().makeTranslation(0,0,-.5));var h=2*Math.PI*ar/360,m={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&Ki(e.scene),e.dataMapper.scene=e.pointsMerge?new ml.Object3D:e.scene,e.dataMapper.onCreateObj(S).onUpdateObj(T).digest(e.pointsData),e.pointsMerge){var v=e.pointsData.length?(Y6.mergeGeometries||Y6.mergeBufferGeometries)(e.pointsData.map(function(N){var C=e.dataMapper.getObj(N),E=C.geometry.clone();C.updateMatrix(),E.applyMatrix4(C.matrix);var O=Gh(l(N));return E.setAttribute("color",xu(Array(E.getAttribute("position").count).fill(O),4)),E})):new ml.BufferGeometry,x=new ml.Mesh(v,new ml.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));x.__globeObjType="points",x.__data=e.pointsData,e.dataMapper.clear(),Ki(e.scene),e.scene.add(x)}function S(){var N=new ml.Mesh(u);return N.__globeObjType="point",N}function T(N,C){var E=function(H){var q=N.__currentTargetD=H,V=q.r,Q=q.alt,J=q.lat,ne=q.lng;Object.assign(N.position,Zo(J,ne));var oe=e.pointsMerge?new ml.Vector3(0,0,0):e.scene.localToWorld(new ml.Vector3(0,0,0));N.lookAt(oe),N.scale.x=N.scale.y=Math.min(30,V)*h,N.scale.z=Math.max(Q*ar,.1)},O={alt:+s(C),r:+a(C),lat:+n(C),lng:+r(C)},U=N.__currentTargetD||Object.assign({},O,{alt:-.001});if(Object.keys(O).some(function(G){return U[G]!==O[G]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?E(O):e.tweenGroup.add(new la(U).to(O,e.pointsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(E).start())),!e.pointsMerge){var I=l(C),j=I?Ml(I):0,z=!!j;N.visible=z,z&&(m.hasOwnProperty(I)||(m[I]=new ml.MeshLambertMaterial({color:yu(I),transparent:j<1,opacity:j})),N.material=m[I])}}}}),yO=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` +}`;function Xle(i,e,t,n){return new Ng.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:Wle,fragmentShader:$le,uniforms:{coefficient:{value:i},color:{value:new Ng.Color(e)},power:{value:t},hollowRadius:{value:n}}})}function Yle(i,e){for(var t=i.clone(),n=new Float32Array(i.attributes.position.count*3),r=0,s=n.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.color,a=s===void 0?"gold":s,l=r.size,u=l===void 0?2:l,h=r.coefficient,m=h===void 0?.5:h,v=r.power,x=v===void 0?1:v,S=r.hollowRadius,T=S===void 0?0:S,N=r.backside,C=N===void 0?!0:N;ex(this,e),n=Jy(this,e);var E=Yle(t,u),O=Xle(m,a,x,T);return C&&(O.side=Ng.BackSide),n.geometry=E,n.material=O,n}return nx(e,i),tx(e)})(Ng.Mesh),ql=window.THREE?window.THREE:{Color:cn,Group:qa,LineBasicMaterial:q0,LineSegments:Y7,Mesh:Oi,MeshPhongMaterial:oD,SphereGeometry:bu,SRGBColorSpace:bn,TextureLoader:oM},vO=_s({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){Ki(e.globeObj),Ki(e.tileEngine),Ki(e.graticulesObj)}},stateInit:function(){var e=new ql.MeshPhongMaterial({color:0}),t=new ql.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var n=new sY(ar),r=new ql.Group;r.__globeObjType="globe",r.add(t),r.add(n);var s=new ql.LineSegments(new AP(SX(),ar,2),new ql.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:r,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:n}},init:function(e,t){Ki(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var n=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var r;(r=e.globeObj.geometry)===null||r===void 0||r.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new ql.SphereGeometry(ar,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new ql.TextureLoader().load(e.globeImageUrl,function(l){l.colorSpace=ql.SRGBColorSpace,n.map=l,n.color=null,n.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!n.color&&(n.color=new ql.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new ql.TextureLoader().load(e.bumpImageUrl,function(l){n.bumpMap=l,n.needsUpdate=!0}):(n.bumpMap=null,n.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),Ki(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new Qle(e.globeObj.geometry,{color:e.atmosphereColor,size:ar*e.atmosphereAltitude,hollowRadius:ar,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType="atmosphere",e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),yu=function(e){return isNaN(e)?parseInt(Sn(e).toHex(),16):e},Ml=function(e){return e&&isNaN(e)?sd(e).opacity:1},Gh=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r,s=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var l=a.slice(1),u=Ar(l,4),h=u[0],m=u[1],v=u[2],x=u[3];r=new cn("rgb(".concat(+h,",").concat(+m,",").concat(+v,")")),s=Math.min(+x,1)}else r=new cn(e);n&&r.convertLinearToSRGB();var S=r.toArray();return t?[].concat(ji(S),[s]):S};function Kle(i,e,t){return i.opacity=e,i.transparent=e<1,i.depthWrite=e>=1,i}var $6=window.THREE?window.THREE:{BufferAttribute:wr};function xu(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(e===1)return new $6.BufferAttribute(new t(i),e);for(var n=new $6.BufferAttribute(new t(i.length*e),e),r=0,s=i.length;r1&&arguments[1]!==void 0?arguments[1]:{},s=r.dataBindAttr,a=s===void 0?"__data":s,l=r.objBindAttr,u=l===void 0?"__threeObj":l,h=r.removeDelay,m=h===void 0?0:h;return ex(this,e),n=Jy(this,e),Ds(n,"scene",void 0),DS(n,US,void 0),DS(n,Ev,void 0),DS(n,Cv,void 0),n.scene=t,PS(US,n,a),PS(Ev,n,u),PS(Cv,n,m),n.onRemoveObj(function(){}),n}return nx(e,i),tx(e,[{key:"onCreateObj",value:function(n){var r=this;return LS(e,"onCreateObj",this)([function(s){var a=n(s);return s[dm(Ev,r)]=a,a[dm(US,r)]=s,r.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return LS(e,"onRemoveObj",this)([function(s,a){var l=LS(e,"getData",r)([s]);n(s,a);var u=function(){r.scene.remove(s),Ki(s),delete l[dm(Ev,r)]};dm(Cv,r)?setTimeout(u,dm(Cv,r)):u()}]),this}}])})(UQ),ml=window.THREE?window.THREE:{BufferGeometry:Hi,CylinderGeometry:iM,Matrix4:jn,Mesh:Oi,MeshLambertMaterial:Fc,Object3D:pr,Vector3:pe},X6=Object.assign({},SM),Y6=X6.BufferGeometryUtils||X6,_O=_s({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var n=Lt(e.pointLat),r=Lt(e.pointLng),s=Lt(e.pointAltitude),a=Lt(e.pointRadius),l=Lt(e.pointColor),u=new ml.CylinderGeometry(1,1,1,e.pointResolution);u.applyMatrix4(new ml.Matrix4().makeRotationX(Math.PI/2)),u.applyMatrix4(new ml.Matrix4().makeTranslation(0,0,-.5));var h=2*Math.PI*ar/360,m={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&Ki(e.scene),e.dataMapper.scene=e.pointsMerge?new ml.Object3D:e.scene,e.dataMapper.onCreateObj(S).onUpdateObj(T).digest(e.pointsData),e.pointsMerge){var v=e.pointsData.length?(Y6.mergeGeometries||Y6.mergeBufferGeometries)(e.pointsData.map(function(N){var C=e.dataMapper.getObj(N),E=C.geometry.clone();C.updateMatrix(),E.applyMatrix4(C.matrix);var O=Gh(l(N));return E.setAttribute("color",xu(Array(E.getAttribute("position").count).fill(O),4)),E})):new ml.BufferGeometry,x=new ml.Mesh(v,new ml.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));x.__globeObjType="points",x.__data=e.pointsData,e.dataMapper.clear(),Ki(e.scene),e.scene.add(x)}function S(){var N=new ml.Mesh(u);return N.__globeObjType="point",N}function T(N,C){var E=function(H){var q=N.__currentTargetD=H,V=q.r,Q=q.alt,J=q.lat,ie=q.lng;Object.assign(N.position,Zo(J,ie));var le=e.pointsMerge?new ml.Vector3(0,0,0):e.scene.localToWorld(new ml.Vector3(0,0,0));N.lookAt(le),N.scale.x=N.scale.y=Math.min(30,V)*h,N.scale.z=Math.max(Q*ar,.1)},O={alt:+s(C),r:+a(C),lat:+n(C),lng:+r(C)},U=N.__currentTargetD||Object.assign({},O,{alt:-.001});if(Object.keys(O).some(function(G){return U[G]!==O[G]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?E(O):e.tweenGroup.add(new la(U).to(O,e.pointsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(E).start())),!e.pointsMerge){var I=l(C),j=I?Ml(I):0,z=!!j;N.visible=z,z&&(m.hasOwnProperty(I)||(m[I]=new ml.MeshLambertMaterial({color:yu(I),transparent:j<1,opacity:j})),N.material=m[I])}}}}),yO=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` `.concat(ei.common,` `).concat(ei.logdepthbuf_pars_vertex,` @@ -4760,7 +4760,7 @@ varying vec3 vPos; gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); } `),` - `),e},YE=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},eue=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(r){return r};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(r){n(r),t(r.uniforms)}}},tue=["stroke"],gl=window.THREE?window.THREE:{BufferGeometry:Hi,CubicBezierCurve3:Z7,Curve:Nl,Group:qa,Line:_y,Mesh:Oi,NormalBlending:Xa,ShaderMaterial:Qa,TubeGeometry:sM,Vector3:me},nue=C0.default||C0,xO=_s({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new nue,sharedMaterial:new gl.ShaderMaterial(ki(ki({},yO()),{},{transparent:!0,blending:gl.NormalBlending}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var n=new gl.Group;return n.__globeObjType="arc",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Ar(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r,u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l})})},update:function(e){var t=Ut(e.arcStartLat),n=Ut(e.arcStartLng),r=Ut(e.arcStartAltitude),s=Ut(e.arcEndLat),a=Ut(e.arcEndLng),l=Ut(e.arcEndAltitude),u=Ut(e.arcAltitude),h=Ut(e.arcAltitudeAutoScale),m=Ut(e.arcStroke),v=Ut(e.arcColor),x=Ut(e.arcDashLength),S=Ut(e.arcDashGap),T=Ut(e.arcDashInitialGap),N=Ut(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(U,I){var j=m(I),z=j!=null;if(!U.children.length||z!==(U.children[0].type==="Mesh")){Ki(U);var G=z?new gl.Mesh:new gl.Line(new gl.BufferGeometry);G.material=e.sharedMaterial.clone(),U.add(G)}var H=U.children[0];Object.assign(H.material.uniforms,{dashSize:{value:x(I)},gapSize:{value:S(I)},dashOffset:{value:T(I)}});var q=N(I);H.__dashAnimateStep=q>0?1e3/q:0;var V=E(v(I),e.arcCurveResolution,z?e.arcCircularResolution+1:1),Q=O(e.arcCurveResolution,z?e.arcCircularResolution+1:1,!0);H.geometry.setAttribute("color",V),H.geometry.setAttribute("relDistance",Q);var J=function(Z){var te=U.__currentTargetD=Z,de=te.stroke,Se=Gle(te,tue),Te=C(Se);z?(H.geometry&&H.geometry.dispose(),H.geometry=new gl.TubeGeometry(Te,e.arcCurveResolution,de/2,e.arcCircularResolution),H.geometry.setAttribute("color",V),H.geometry.setAttribute("relDistance",Q)):H.geometry.setFromPoints(Te.getPoints(e.arcCurveResolution))},ne={stroke:j,alt:u(I),altAutoScale:+h(I),startLat:+t(I),startLng:+n(I),startAlt:+r(I),endLat:+s(I),endLng:+a(I),endAlt:+l(I)},oe=U.__currentTargetD||Object.assign({},ne,{altAutoScale:-.001});Object.keys(ne).some(function(ie){return oe[ie]!==ne[ie]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?J(ne):e.tweenGroup.add(new la(oe).to(ne,e.arcsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start()))}).digest(e.arcsData);function C(U){var I=U.alt,j=U.altAutoScale,z=U.startLat,G=U.startLng,H=U.startAlt,q=U.endLat,V=U.endLng,Q=U.endAlt,J=function(et){var He=Ar(et,3),Rt=He[0],Et=He[1],zt=He[2],Pt=Zo(Et,Rt,zt),We=Pt.x,ft=Pt.y,fe=Pt.z;return new gl.Vector3(We,ft,fe)},ne=[G,z],oe=[V,q],ie=I;if(ie==null&&(ie=kh(ne,oe)/2*j+Math.max(H,Q)),ie||H||Q){var Z=vM(ne,oe),te=function(et,He){return He+(He-et)*(et2&&arguments[2]!==void 0?arguments[2]:1,z=I+1,G;if(U instanceof Array||U instanceof Function){var H=U instanceof Array?Ec().domain(U.map(function(ie,Z){return Z/(U.length-1)})).range(U):U;G=function(Z){return Gh(H(Z),!0,!0)}}else{var q=Gh(U,!0,!0);G=function(){return q}}for(var V=[],Q=0,J=z;Q1&&arguments[1]!==void 0?arguments[1]:1,j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,z=U+1,G=[],H=0,q=z;H=H?j:z}),4)),I})):new xh.BufferGeometry,T=new xh.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:xh.DoubleSide});T.onBeforeCompile=function(O){T.userData.shader=hT(O)};var N=new xh.Mesh(S,T);N.__globeObjType="hexBinPoints",N.__data=v,e.dataMapper.clear(),Ki(e.scene),e.scene.add(N)}function C(O){var U=new xh.Mesh;U.__hexCenter=LP(O.h3Idx),U.__hexGeoJson=UP(O.h3Idx,!0).reverse();var I=U.__hexCenter[1];return U.__hexGeoJson.forEach(function(j){var z=j[0];Math.abs(I-z)>170&&(j[0]+=I>z?360:-360)}),U.__globeObjType="hexbin",U}function E(O,U){var I=function(te,de,Se){return te-(te-de)*Se},j=Math.max(0,Math.min(1,+h(U))),z=Ar(O.__hexCenter,2),G=z[0],H=z[1],q=j===0?O.__hexGeoJson:O.__hexGeoJson.map(function(Z){var te=Ar(Z,2),de=te[0],Se=te[1];return[[de,H],[Se,G]].map(function(Te){var ae=Ar(Te,2),Me=ae[0],Ve=ae[1];return I(Me,Ve,j)})}),V=e.hexTopCurvatureResolution;O.geometry&&O.geometry.dispose(),O.geometry=new CM([q],0,ar,!1,!0,!0,V);var Q={alt:+a(U)},J=function(te){var de=O.__currentTargetD=te,Se=de.alt;O.scale.x=O.scale.y=O.scale.z=1+Se;var Te=ar/(Se+1);O.geometry.setAttribute("surfaceRadius",xu(Array(O.geometry.getAttribute("position").count).fill(Te),1))},ne=O.__currentTargetD||Object.assign({},Q,{alt:-.001});if(Object.keys(Q).some(function(Z){return ne[Z]!==Q[Z]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?J(Q):e.tweenGroup.add(new la(ne).to(Q,e.hexTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start())),!e.hexBinMerge){var oe=u(U),ie=l(U);[oe,ie].forEach(function(Z){if(!x.hasOwnProperty(Z)){var te=Ml(Z);x[Z]=YE(new xh.MeshLambertMaterial({color:yu(Z),transparent:te<1,opacity:te,side:xh.DoubleSide}),hT)}}),O.material=[oe,ie].map(function(Z){return x[Z]})}}}}),SO=function(e){return e*e},yc=function(e){return e*Math.PI/180};function iue(i,e){var t=Math.sqrt,n=Math.cos,r=function(m){return SO(Math.sin(m/2))},s=yc(i[1]),a=yc(e[1]),l=yc(i[0]),u=yc(e[0]);return 2*Math.asin(t(r(a-s)+n(s)*n(a)*r(u-l)))}var rue=Math.sqrt(2*Math.PI);function sue(i,e){return Math.exp(-SO(i/e)/2)/(e*rue)}var aue=function(e){var t=Ar(e,2),n=t[0],r=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},l=a.lngAccessor,u=l===void 0?function(C){return C[0]}:l,h=a.latAccessor,m=h===void 0?function(C){return C[1]}:h,v=a.weightAccessor,x=v===void 0?function(){return 1}:v,S=a.bandwidth,T=[n,r],N=S*Math.PI/180;return JW(s.map(function(C){var E=x(C);if(!E)return 0;var O=iue(T,[u(C),m(C)]);return sue(O,N)*E}))},oue=(function(){var i=Ule(uT().m(function e(t){var n,r,s,a,l,u,h,m,v,x,S,T,N,C,E,O,U,I,j,z,G,H,q,V,Q,J,ne,oe,ie,Z,te,de,Se,Te,ae,Me,Ve,Ce,Fe,et,He=arguments,Rt,Et,zt;return uT().w(function(Pt){for(;;)switch(Pt.n){case 0:if(r=He.length>1&&He[1]!==void 0?He[1]:[],s=He.length>2&&He[2]!==void 0?He[2]:{},a=s.lngAccessor,l=a===void 0?function(We){return We[0]}:a,u=s.latAccessor,h=u===void 0?function(We){return We[1]}:u,m=s.weightAccessor,v=m===void 0?function(){return 1}:m,x=s.bandwidth,(n=navigator)!==null&&n!==void 0&&n.gpu){Pt.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),Pt.a(2,t.map(function(We){return aue(We,r,{lngAccessor:l,latAccessor:h,weightAccessor:v,bandwidth:x})}));case 1:return S=4,T=hle,N=fle,C=Sle,E=ble,O=gle,U=vle,I=dle,j=xle,z=yle,G=ple,H=Ale,q=mle,V=_le,Q=E(new Jv(new Float32Array(t.flat().map(yc)),2),"vec2",t.length),J=E(new Jv(new Float32Array(r.map(function(We){return[yc(l(We)),yc(h(We)),v(We)]}).flat()),3),"vec3",r.length),ne=new Jv(t.length,1),oe=E(ne,"float",t.length),ie=O(Math.PI),Z=j(ie.mul(2)),te=function(ft){return ft.mul(ft)},de=function(ft){return te(z(ft.div(2)))},Se=function(ft,fe){var Wt=O(ft[1]),yt=O(fe[1]),Gt=O(ft[0]),_t=O(fe[0]);return O(2).mul(H(j(de(yt.sub(Wt)).add(G(Wt).mul(G(yt)).mul(de(_t.sub(Gt)))))))},Te=function(ft,fe){return q(V(te(ft.div(fe)).div(2))).div(fe.mul(Z))},ae=C(yc(x)),Me=C(yc(x*S)),Ve=C(r.length),Ce=T(function(){var We=Q.element(U),ft=oe.element(U);ft.assign(0),I(Ve,function(fe){var Wt=fe.i,yt=J.element(Wt),Gt=yt.z;N(Gt,function(){var _t=Se(yt.xy,We.xy);N(_t&&_t.lessThan(Me),function(){ft.addAssign(Te(_t,ae).mul(Gt))})})})}),Fe=Ce().compute(t.length),et=new cO,Pt.n=2,et.computeAsync(Fe);case 2:return Rt=Array,Et=Float32Array,Pt.n=3,et.getArrayBufferAsync(ne);case 3:return zt=Pt.v,Pt.a(2,Rt.from.call(Rt,new Et(zt)))}},e)}));return function(t){return i.apply(this,arguments)}})(),Nv=window.THREE?window.THREE:{Mesh:Oi,MeshLambertMaterial:Fc,SphereGeometry:bu},lue=3.5,uue=.1,Z6=100,cue=function(e){var t=sd(VZ(e));return t.opacity=Math.cbrt(e),t.formatRgb()},wO=_s({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return cue}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var s=new Nv.Mesh(new Nv.SphereGeometry(ar),YE(new Nv.MeshLambertMaterial({vertexColors:!0,transparent:!0}),Jle));return s.__globeObjType="heatmap",s})},update:function(e){var t=Ut(e.heatmapPoints),n=Ut(e.heatmapPointLat),r=Ut(e.heatmapPointLng),s=Ut(e.heatmapPointWeight),a=Ut(e.heatmapBandwidth),l=Ut(e.heatmapColorFn),u=Ut(e.heatmapColorSaturation),h=Ut(e.heatmapBaseAltitude),m=Ut(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(v,x){var S=a(x),T=l(x),N=u(x),C=h(x),E=m(x),O=t(x).map(function(G){var H=n(G),q=r(G),V=Zo(H,q),Q=V.x,J=V.y,ne=V.z;return{x:Q,y:J,z:ne,lat:H,lng:q,weight:s(G)}}),U=Math.max(uue,S/lue),I=Math.ceil(360/(U||-1));v.geometry.parameters.widthSegments!==I&&(v.geometry.dispose(),v.geometry=new Nv.SphereGeometry(ar,I,I/2));var j=Zle(v.geometry.getAttribute("position")),z=j.map(function(G){var H=Ar(G,3),q=H[0],V=H[1],Q=H[2],J=gO({x:q,y:V,z:Q}),ne=J.lng,oe=J.lat;return[ne,oe]});oue(z,O,{latAccessor:function(H){return H.lat},lngAccessor:function(H){return H.lng},weightAccessor:function(H){return H.weight},bandwidth:S}).then(function(G){var H=ji(new Array(Z6)).map(function(J,ne){return Gh(T(ne/(Z6-1)))}),q=function(ne){var oe=v.__currentTargetD=ne,ie=oe.kdeVals,Z=oe.topAlt,te=oe.saturation,de=QW(ie.map(Math.abs))||1e-15,Se=UD([0,de/te],H);v.geometry.setAttribute("color",xu(ie.map(function(ae){return Se(Math.abs(ae))}),4));var Te=Ec([0,de],[ar*(1+C),ar*(1+(Z||C))]);v.geometry.setAttribute("r",xu(ie.map(Te)))},V={kdeVals:G,topAlt:E,saturation:N},Q=v.__currentTargetD||Object.assign({},V,{kdeVals:G.map(function(){return 0}),topAlt:E&&C,saturation:.5});Q.kdeVals.length!==G.length&&(Q.kdeVals=G.slice()),Object.keys(V).some(function(J){return Q[J]!==V[J]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?q(V):e.tweenGroup.add(new la(Q).to(V,e.heatmapsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(q).start()))})}).digest(e.heatmapsData)}}),bh=window.THREE?window.THREE:{DoubleSide:as,Group:qa,LineBasicMaterial:q0,LineSegments:Y7,Mesh:Oi,MeshBasicMaterial:cd},TO=_s({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjPolygon"}).id(function(s){return s.id}).onCreateObj(function(){var s=new bh.Group;return s.__defaultSideMaterial=YE(new bh.MeshBasicMaterial({side:bh.DoubleSide,depthWrite:!0}),hT),s.__defaultCapMaterial=new bh.MeshBasicMaterial({side:bh.DoubleSide,depthWrite:!0}),s.add(new bh.Mesh(void 0,[s.__defaultSideMaterial,s.__defaultCapMaterial])),s.add(new bh.LineSegments(void 0,new bh.LineBasicMaterial)),s.__globeObjType="polygon",s})},update:function(e){var t=Ut(e.polygonGeoJsonGeometry),n=Ut(e.polygonAltitude),r=Ut(e.polygonCapCurvatureResolution),s=Ut(e.polygonCapColor),a=Ut(e.polygonCapMaterial),l=Ut(e.polygonSideColor),u=Ut(e.polygonSideMaterial),h=Ut(e.polygonStrokeColor),m=[];e.polygonsData.forEach(function(v){var x={data:v,capColor:s(v),capMaterial:a(v),sideColor:l(v),sideMaterial:u(v),strokeColor:h(v),altitude:+n(v),capCurvatureResolution:+r(v)},S=t(v),T=v.__id||"".concat(Math.round(Math.random()*1e9));v.__id=T,S.type==="Polygon"?m.push(ki({id:"".concat(T,"_0"),coords:S.coordinates},x)):S.type==="MultiPolygon"?m.push.apply(m,ji(S.coordinates.map(function(N,C){return ki({id:"".concat(T,"_").concat(C),coords:N},x)}))):console.warn("Unsupported GeoJson geometry type: ".concat(S.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(v,x){var S=x.coords,T=x.capColor,N=x.capMaterial,C=x.sideColor,E=x.sideMaterial,O=x.strokeColor,U=x.altitude,I=x.capCurvatureResolution,j=Ar(v.children,2),z=j[0],G=j[1],H=!!O;G.visible=H;var q=!!(T||N),V=!!(C||E);hue(z.geometry.parameters||{},{polygonGeoJson:S,curvatureResolution:I,closedTop:q,includeSides:V})||(z.geometry&&z.geometry.dispose(),z.geometry=new CM(S,0,ar,!1,q,V,I)),H&&(!G.geometry.parameters||G.geometry.parameters.geoJson.coordinates!==S||G.geometry.parameters.resolution!==I)&&(G.geometry&&G.geometry.dispose(),G.geometry=new AP({type:"Polygon",coordinates:S},ar,I));var Q=V?0:-1,J=q?V?1:0:-1;if(Q>=0&&(z.material[Q]=E||v.__defaultSideMaterial),J>=0&&(z.material[J]=N||v.__defaultCapMaterial),[[!E&&C,Q],[!N&&T,J]].forEach(function(de){var Se=Ar(de,2),Te=Se[0],ae=Se[1];if(!(!Te||ae<0)){var Me=z.material[ae],Ve=Ml(Te);Me.color.set(yu(Te)),Me.transparent=Ve<1,Me.opacity=Ve}}),H){var ne=G.material,oe=Ml(O);ne.color.set(yu(O)),ne.transparent=oe<1,ne.opacity=oe}var ie={alt:U},Z=function(Se){var Te=v.__currentTargetD=Se,ae=Te.alt;z.scale.x=z.scale.y=z.scale.z=1+ae,H&&(G.scale.x=G.scale.y=G.scale.z=1+ae+1e-4),eue(v.__defaultSideMaterial,function(Me){return Me.uSurfaceRadius.value=ar/(ae+1)})},te=v.__currentTargetD||Object.assign({},ie,{alt:-.001});Object.keys(ie).some(function(de){return te[de]!==ie[de]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||te.alt===ie.alt?Z(ie):e.tweenGroup.add(new la(te).to(ie,e.polygonsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(Z).start()))}).digest(m)}});function hue(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(n,r){return n===r}};return Object.entries(e).every(function(n){var r=Ar(n,2),s=r[0],a=r[1];return i.hasOwnProperty(s)&&t(s)(i[s],a)})}var RA=window.THREE?window.THREE:{BufferGeometry:Hi,DoubleSide:as,Mesh:Oi,MeshLambertMaterial:Fc,Vector3:me},J6=Object.assign({},SM),e7=J6.BufferGeometryUtils||J6,MO=_s({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var s=new RA.Mesh(void 0,new RA.MeshLambertMaterial({side:RA.DoubleSide}));return s.__globeObjType="hexPolygon",s})},update:function(e){var t=Ut(e.hexPolygonGeoJsonGeometry),n=Ut(e.hexPolygonColor),r=Ut(e.hexPolygonAltitude),s=Ut(e.hexPolygonResolution),a=Ut(e.hexPolygonMargin),l=Ut(e.hexPolygonUseDots),u=Ut(e.hexPolygonCurvatureResolution),h=Ut(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(m,v){var x=t(v),S=s(v),T=r(v),N=Math.max(0,Math.min(1,+a(v))),C=l(v),E=u(v),O=h(v),U=n(v),I=Ml(U);m.material.color.set(yu(U)),m.material.transparent=I<1,m.material.opacity=I;var j={alt:T,margin:N,curvatureResolution:E},z={geoJson:x,h3Res:S},G=m.__currentTargetD||Object.assign({},j,{alt:-.001}),H=m.__currentMemD||z;if(Object.keys(j).some(function(J){return G[J]!==j[J]})||Object.keys(z).some(function(J){return H[J]!==z[J]})){m.__currentMemD=z;var q=[];x.type==="Polygon"?PR(x.coordinates,S,!0).forEach(function(J){return q.push(J)}):x.type==="MultiPolygon"?x.coordinates.forEach(function(J){return PR(J,S,!0).forEach(function(ne){return q.push(ne)})}):console.warn("Unsupported GeoJson geometry type: ".concat(x.type,". Skipping geometry..."));var V=q.map(function(J){var ne=LP(J),oe=UP(J,!0).reverse(),ie=ne[1];return oe.forEach(function(Z){var te=Z[0];Math.abs(ie-te)>170&&(Z[0]+=ie>te?360:-360)}),{h3Idx:J,hexCenter:ne,hexGeoJson:oe}}),Q=function(ne){var oe=m.__currentTargetD=ne,ie=oe.alt,Z=oe.margin,te=oe.curvatureResolution;m.geometry&&m.geometry.dispose(),m.geometry=V.length?(e7.mergeGeometries||e7.mergeBufferGeometries)(V.map(function(de){var Se=Ar(de.hexCenter,2),Te=Se[0],ae=Se[1];if(C){var Me=Zo(Te,ae,ie),Ve=Zo(de.hexGeoJson[0][1],de.hexGeoJson[0][0],ie),Ce=.85*(1-Z)*new RA.Vector3(Me.x,Me.y,Me.z).distanceTo(new RA.Vector3(Ve.x,Ve.y,Ve.z)),Fe=new yy(Ce,O);return Fe.rotateX(Ff(-Te)),Fe.rotateY(Ff(ae)),Fe.translate(Me.x,Me.y,Me.z),Fe}else{var et=function(Et,zt,Pt){return Et-(Et-zt)*Pt},He=Z===0?de.hexGeoJson:de.hexGeoJson.map(function(Rt){var Et=Ar(Rt,2),zt=Et[0],Pt=Et[1];return[[zt,ae],[Pt,Te]].map(function(We){var ft=Ar(We,2),fe=ft[0],Wt=ft[1];return et(fe,Wt,Z)})});return new CM([He],ar,ar*(1+ie),!1,!0,!1,te)}})):new RA.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?Q(j):e.tweenGroup.add(new la(G).to(j,e.hexPolygonsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(Q).start())}}).digest(e.hexPolygonsData)}}),fue=window.THREE?window.THREE:{Vector3:me};function due(i,e){var t=function(a,l){var u=a[a.length-1];return[].concat(ji(a),ji(Array(l-a.length).fill(u)))},n=Math.max(i.length,e.length),r=p$.apply(void 0,ji([i,e].map(function(s){return s.map(function(a){var l=a.x,u=a.y,h=a.z;return[l,u,h]})}).map(function(s){return t(s,n)})));return function(s){return s===0?i:s===1?e:r(s).map(function(a){var l=Ar(a,3),u=l[0],h=l[1],m=l[2];return new fue.Vector3(u,h,m)})}}var Ef=window.THREE?window.THREE:{BufferGeometry:Hi,Color:cn,Group:qa,Line:_y,NormalBlending:Xa,ShaderMaterial:Qa,Vector3:me},Aue=C0.default||C0,EO=_s({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new Aue,sharedMaterial:new Ef.ShaderMaterial(ki(ki({},yO()),{},{transparent:!0,blending:Ef.NormalBlending}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var n=new Ef.Group;return n.__globeObjType="path",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Ar(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r;if(a.type==="Line"){var u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l}else if(a.type==="Line2"){for(var h=a.material.dashOffset-l,m=a.material.dashSize+a.material.gapSize;h<=-m;)h+=m;a.material.dashOffset=h}})})},update:function(e){var t=Ut(e.pathPoints),n=Ut(e.pathPointLat),r=Ut(e.pathPointLng),s=Ut(e.pathPointAlt),a=Ut(e.pathStroke),l=Ut(e.pathColor),u=Ut(e.pathDashLength),h=Ut(e.pathDashGap),m=Ut(e.pathDashInitialGap),v=Ut(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(C,E){var O=a(E),U=O!=null;if(!C.children.length||U===(C.children[0].type==="Line")){Ki(C);var I=U?new Ele(new fO,new HE):new Ef.Line(new Ef.BufferGeometry,e.sharedMaterial.clone());C.add(I)}var j=C.children[0],z=S(t(E),n,r,s,e.pathResolution),G=v(E);if(j.__dashAnimateStep=G>0?1e3/G:0,U){j.material.resolution=e.rendererSize;{var V=u(E),Q=h(E),J=m(E);j.material.dashed=Q>0,j.material.dashed?j.material.defines.USE_DASH="":delete j.material.defines.USE_DASH,j.material.dashed&&(j.material.dashScale=1/x(z),j.material.dashSize=V,j.material.gapSize=Q,j.material.dashOffset=-J)}{var ne=l(E);if(ne instanceof Array){var oe=T(l(E),z.length-1,1,!1);j.geometry.setColors(oe.array),j.material.vertexColors=!0}else{var ie=ne,Z=Ml(ie);j.material.color=new Ef.Color(yu(ie)),j.material.transparent=Z<1,j.material.opacity=Z,j.material.vertexColors=!1}}j.material.needsUpdate=!0}else{Object.assign(j.material.uniforms,{dashSize:{value:u(E)},gapSize:{value:h(E)},dashOffset:{value:m(E)}});var H=T(l(E),z.length),q=N(z.length,1,!0);j.geometry.setAttribute("color",H),j.geometry.setAttribute("relDistance",q)}var te=due(C.__currentTargetD&&C.__currentTargetD.points||[z[0]],z),de=function(Me){var Ve=C.__currentTargetD=Me,Ce=Ve.stroke,Fe=Ve.interpolK,et=C.__currentTargetD.points=te(Fe);if(U){var He;j.geometry.setPositions((He=[]).concat.apply(He,ji(et.map(function(Rt){var Et=Rt.x,zt=Rt.y,Pt=Rt.z;return[Et,zt,Pt]})))),j.material.linewidth=Ce,j.material.dashed&&j.computeLineDistances()}else j.geometry.setFromPoints(et),j.geometry.computeBoundingSphere()},Se={stroke:O,interpolK:1},Te=Object.assign({},C.__currentTargetD||Se,{interpolK:0});Object.keys(Se).some(function(ae){return Te[ae]!==Se[ae]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?de(Se):e.tweenGroup.add(new la(Te).to(Se,e.pathTransitionDuration).easing(os.Quadratic.InOut).onUpdate(de).start()))}).digest(e.pathsData);function x(C){var E=0,O;return C.forEach(function(U){O&&(E+=O.distanceTo(U)),O=U}),E}function S(C,E,O,U,I){var j=function(q,V,Q){for(var J=[],ne=1;ne<=Q;ne++)J.push(q+(V-q)*ne/(Q+1));return J},z=function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Q=[],J=null;return q.forEach(function(ne){if(J){for(;Math.abs(J[1]-ne[1])>180;)J[1]+=360*(J[1]V)for(var ie=Math.floor(oe/V),Z=j(J[0],ne[0],ie),te=j(J[1],ne[1],ie),de=j(J[2],ne[2],ie),Se=0,Te=Z.length;Se2&&arguments[2]!==void 0?arguments[2]:1,U=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,I=E+1,j;if(C instanceof Array||C instanceof Function){var z=C instanceof Array?Ec().domain(C.map(function(ne,oe){return oe/(C.length-1)})).range(C):C;j=function(oe){return Gh(z(oe),U,!0)}}else{var G=Gh(C,U,!0);j=function(){return G}}for(var H=[],q=0,V=I;q1&&arguments[1]!==void 0?arguments[1]:1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,U=C+1,I=[],j=0,z=U;j0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;ex(this,e),t=Jy(this,e),t.type="CircleLineGeometry",t.parameters={radius:n,segmentCount:r};for(var s=[],a=0;a<=r;a++){var l=(a/r-.25)*Math.PI*2;s.push({x:Math.cos(l)*n,y:Math.sin(l)*n,z:0})}return t.setFromPoints(s),t}return nx(e,i),tx(e)})(pue.BufferGeometry),PA=window.THREE?window.THREE:{Color:cn,Group:qa,Line:_y,LineBasicMaterial:q0,Vector3:me},gue=C0.default||C0,RO=_s({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var s=new PA.Group;return s.__globeObjType="ring",s}),t.ticker=new gue,t.ticker.onTick.add(function(s){if(t.ringsData.length){var a=Ut(t.ringColor),l=Ut(t.ringAltitude),u=Ut(t.ringMaxRadius),h=Ut(t.ringPropagationSpeed),m=Ut(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(v){var x=Ar(v,2),S=x[1];return S}).forEach(function(v){var x=Ar(v,2),S=x[0],T=x[1];if((T.__nextRingTime||0)<=s){var N=m(S)/1e3;T.__nextRingTime=s+(N<=0?1/0:N);var C=new PA.Line(new mue(1,t.ringResolution),new PA.LineBasicMaterial),E=a(S),O=E instanceof Array||E instanceof Function,U;O?E instanceof Array?(U=Ec().domain(E.map(function(Q,J){return J/(E.length-1)})).range(E),C.material.transparent=E.some(function(Q){return Ml(Q)<1})):(U=E,C.material.transparent=!0):(C.material.color=new PA.Color(yu(E)),Kle(C.material,Ml(E)));var I=ar*(1+l(S)),j=u(S),z=j*Math.PI/180,G=h(S),H=G<=0,q=function(J){var ne=J.t,oe=(H?1-ne:ne)*z;if(C.scale.x=C.scale.y=I*Math.sin(oe),C.position.z=I*(1-Math.cos(oe)),O){var ie=U(ne);C.material.color=new PA.Color(yu(ie)),C.material.transparent&&(C.material.opacity=Ml(ie))}};if(G===0)q({t:0}),T.add(C);else{var V=Math.abs(j/G)*1e3;t.tweenGroup.add(new la({t:0}).to({t:1},V).onUpdate(q).onStart(function(){return T.add(C)}).onComplete(function(){T.remove(C),XE(C)}).start())}}})}})},update:function(e){var t=Ut(e.ringLat),n=Ut(e.ringLng),r=Ut(e.ringAltitude),s=e.scene.localToWorld(new PA.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(a,l){var u=t(l),h=n(l),m=r(l);Object.assign(a.position,Zo(u,h,m)),a.lookAt(s)}).digest(e.ringsData)}}),vue={0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},_ue="normal",yue=1189,xue=-100,bue="normal",Sue={yMin:-334,xMin:-111,yMax:1189,xMax:1672},wue=1e3,Tue={postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r + `),e},YE=function(e,t){return e.onBeforeCompile=function(n){e.userData.shader=t(n)},e},eue=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(r){return r};if(e.userData.shader)t(e.userData.shader.uniforms);else{var n=e.onBeforeCompile;e.onBeforeCompile=function(r){n(r),t(r.uniforms)}}},tue=["stroke"],gl=window.THREE?window.THREE:{BufferGeometry:Hi,CubicBezierCurve3:Z7,Curve:Nl,Group:qa,Line:_y,Mesh:Oi,NormalBlending:Xa,ShaderMaterial:Qa,TubeGeometry:sM,Vector3:pe},nue=C0.default||C0,xO=_s({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new nue,sharedMaterial:new gl.ShaderMaterial(ki(ki({},yO()),{},{transparent:!0,blending:gl.NormalBlending}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var n=new gl.Group;return n.__globeObjType="arc",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Ar(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r,u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l})})},update:function(e){var t=Lt(e.arcStartLat),n=Lt(e.arcStartLng),r=Lt(e.arcStartAltitude),s=Lt(e.arcEndLat),a=Lt(e.arcEndLng),l=Lt(e.arcEndAltitude),u=Lt(e.arcAltitude),h=Lt(e.arcAltitudeAutoScale),m=Lt(e.arcStroke),v=Lt(e.arcColor),x=Lt(e.arcDashLength),S=Lt(e.arcDashGap),T=Lt(e.arcDashInitialGap),N=Lt(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(U,I){var j=m(I),z=j!=null;if(!U.children.length||z!==(U.children[0].type==="Mesh")){Ki(U);var G=z?new gl.Mesh:new gl.Line(new gl.BufferGeometry);G.material=e.sharedMaterial.clone(),U.add(G)}var H=U.children[0];Object.assign(H.material.uniforms,{dashSize:{value:x(I)},gapSize:{value:S(I)},dashOffset:{value:T(I)}});var q=N(I);H.__dashAnimateStep=q>0?1e3/q:0;var V=E(v(I),e.arcCurveResolution,z?e.arcCircularResolution+1:1),Q=O(e.arcCurveResolution,z?e.arcCircularResolution+1:1,!0);H.geometry.setAttribute("color",V),H.geometry.setAttribute("relDistance",Q);var J=function(Z){var ne=U.__currentTargetD=Z,de=ne.stroke,be=Gle(ne,tue),Te=C(be);z?(H.geometry&&H.geometry.dispose(),H.geometry=new gl.TubeGeometry(Te,e.arcCurveResolution,de/2,e.arcCircularResolution),H.geometry.setAttribute("color",V),H.geometry.setAttribute("relDistance",Q)):H.geometry.setFromPoints(Te.getPoints(e.arcCurveResolution))},ie={stroke:j,alt:u(I),altAutoScale:+h(I),startLat:+t(I),startLng:+n(I),startAlt:+r(I),endLat:+s(I),endLng:+a(I),endAlt:+l(I)},le=U.__currentTargetD||Object.assign({},ie,{altAutoScale:-.001});Object.keys(ie).some(function(re){return le[re]!==ie[re]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?J(ie):e.tweenGroup.add(new la(le).to(ie,e.arcsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start()))}).digest(e.arcsData);function C(U){var I=U.alt,j=U.altAutoScale,z=U.startLat,G=U.startLng,H=U.startAlt,q=U.endLat,V=U.endLng,Q=U.endAlt,J=function(tt){var je=Ar(tt,3),Rt=je[0],Et=je[1],Ft=je[2],Ut=Zo(Et,Rt,Ft),Ke=Ut.x,ht=Ut.y,fe=Ut.z;return new gl.Vector3(Ke,ht,fe)},ie=[G,z],le=[V,q],re=I;if(re==null&&(re=kh(ie,le)/2*j+Math.max(H,Q)),re||H||Q){var Z=vM(ie,le),ne=function(tt,je){return je+(je-tt)*(tt2&&arguments[2]!==void 0?arguments[2]:1,z=I+1,G;if(U instanceof Array||U instanceof Function){var H=U instanceof Array?Ec().domain(U.map(function(re,Z){return Z/(U.length-1)})).range(U):U;G=function(Z){return Gh(H(Z),!0,!0)}}else{var q=Gh(U,!0,!0);G=function(){return q}}for(var V=[],Q=0,J=z;Q1&&arguments[1]!==void 0?arguments[1]:1,j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,z=U+1,G=[],H=0,q=z;H=H?j:z}),4)),I})):new xh.BufferGeometry,T=new xh.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:xh.DoubleSide});T.onBeforeCompile=function(O){T.userData.shader=hT(O)};var N=new xh.Mesh(S,T);N.__globeObjType="hexBinPoints",N.__data=v,e.dataMapper.clear(),Ki(e.scene),e.scene.add(N)}function C(O){var U=new xh.Mesh;U.__hexCenter=LP(O.h3Idx),U.__hexGeoJson=UP(O.h3Idx,!0).reverse();var I=U.__hexCenter[1];return U.__hexGeoJson.forEach(function(j){var z=j[0];Math.abs(I-z)>170&&(j[0]+=I>z?360:-360)}),U.__globeObjType="hexbin",U}function E(O,U){var I=function(ne,de,be){return ne-(ne-de)*be},j=Math.max(0,Math.min(1,+h(U))),z=Ar(O.__hexCenter,2),G=z[0],H=z[1],q=j===0?O.__hexGeoJson:O.__hexGeoJson.map(function(Z){var ne=Ar(Z,2),de=ne[0],be=ne[1];return[[de,H],[be,G]].map(function(Te){var ae=Ar(Te,2),Me=ae[0],Ve=ae[1];return I(Me,Ve,j)})}),V=e.hexTopCurvatureResolution;O.geometry&&O.geometry.dispose(),O.geometry=new CM([q],0,ar,!1,!0,!0,V);var Q={alt:+a(U)},J=function(ne){var de=O.__currentTargetD=ne,be=de.alt;O.scale.x=O.scale.y=O.scale.z=1+be;var Te=ar/(be+1);O.geometry.setAttribute("surfaceRadius",xu(Array(O.geometry.getAttribute("position").count).fill(Te),1))},ie=O.__currentTargetD||Object.assign({},Q,{alt:-.001});if(Object.keys(Q).some(function(Z){return ie[Z]!==Q[Z]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?J(Q):e.tweenGroup.add(new la(ie).to(Q,e.hexTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start())),!e.hexBinMerge){var le=u(U),re=l(U);[le,re].forEach(function(Z){if(!x.hasOwnProperty(Z)){var ne=Ml(Z);x[Z]=YE(new xh.MeshLambertMaterial({color:yu(Z),transparent:ne<1,opacity:ne,side:xh.DoubleSide}),hT)}}),O.material=[le,re].map(function(Z){return x[Z]})}}}}),SO=function(e){return e*e},yc=function(e){return e*Math.PI/180};function iue(i,e){var t=Math.sqrt,n=Math.cos,r=function(m){return SO(Math.sin(m/2))},s=yc(i[1]),a=yc(e[1]),l=yc(i[0]),u=yc(e[0]);return 2*Math.asin(t(r(a-s)+n(s)*n(a)*r(u-l)))}var rue=Math.sqrt(2*Math.PI);function sue(i,e){return Math.exp(-SO(i/e)/2)/(e*rue)}var aue=function(e){var t=Ar(e,2),n=t[0],r=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},l=a.lngAccessor,u=l===void 0?function(C){return C[0]}:l,h=a.latAccessor,m=h===void 0?function(C){return C[1]}:h,v=a.weightAccessor,x=v===void 0?function(){return 1}:v,S=a.bandwidth,T=[n,r],N=S*Math.PI/180;return JW(s.map(function(C){var E=x(C);if(!E)return 0;var O=iue(T,[u(C),m(C)]);return sue(O,N)*E}))},oue=(function(){var i=Ule(uT().m(function e(t){var n,r,s,a,l,u,h,m,v,x,S,T,N,C,E,O,U,I,j,z,G,H,q,V,Q,J,ie,le,re,Z,ne,de,be,Te,ae,Me,Ve,Ce,Fe,tt,je=arguments,Rt,Et,Ft;return uT().w(function(Ut){for(;;)switch(Ut.n){case 0:if(r=je.length>1&&je[1]!==void 0?je[1]:[],s=je.length>2&&je[2]!==void 0?je[2]:{},a=s.lngAccessor,l=a===void 0?function(Ke){return Ke[0]}:a,u=s.latAccessor,h=u===void 0?function(Ke){return Ke[1]}:u,m=s.weightAccessor,v=m===void 0?function(){return 1}:m,x=s.bandwidth,(n=navigator)!==null&&n!==void 0&&n.gpu){Ut.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),Ut.a(2,t.map(function(Ke){return aue(Ke,r,{lngAccessor:l,latAccessor:h,weightAccessor:v,bandwidth:x})}));case 1:return S=4,T=hle,N=fle,C=Sle,E=ble,O=gle,U=vle,I=dle,j=xle,z=yle,G=ple,H=Ale,q=mle,V=_le,Q=E(new Jv(new Float32Array(t.flat().map(yc)),2),"vec2",t.length),J=E(new Jv(new Float32Array(r.map(function(Ke){return[yc(l(Ke)),yc(h(Ke)),v(Ke)]}).flat()),3),"vec3",r.length),ie=new Jv(t.length,1),le=E(ie,"float",t.length),re=O(Math.PI),Z=j(re.mul(2)),ne=function(ht){return ht.mul(ht)},de=function(ht){return ne(z(ht.div(2)))},be=function(ht,fe){var $t=O(ht[1]),_t=O(fe[1]),Gt=O(ht[0]),yt=O(fe[0]);return O(2).mul(H(j(de(_t.sub($t)).add(G($t).mul(G(_t)).mul(de(yt.sub(Gt)))))))},Te=function(ht,fe){return q(V(ne(ht.div(fe)).div(2))).div(fe.mul(Z))},ae=C(yc(x)),Me=C(yc(x*S)),Ve=C(r.length),Ce=T(function(){var Ke=Q.element(U),ht=le.element(U);ht.assign(0),I(Ve,function(fe){var $t=fe.i,_t=J.element($t),Gt=_t.z;N(Gt,function(){var yt=be(_t.xy,Ke.xy);N(yt&&yt.lessThan(Me),function(){ht.addAssign(Te(yt,ae).mul(Gt))})})})}),Fe=Ce().compute(t.length),tt=new cO,Ut.n=2,tt.computeAsync(Fe);case 2:return Rt=Array,Et=Float32Array,Ut.n=3,tt.getArrayBufferAsync(ie);case 3:return Ft=Ut.v,Ut.a(2,Rt.from.call(Rt,new Et(Ft)))}},e)}));return function(t){return i.apply(this,arguments)}})(),Nv=window.THREE?window.THREE:{Mesh:Oi,MeshLambertMaterial:Fc,SphereGeometry:bu},lue=3.5,uue=.1,Z6=100,cue=function(e){var t=sd(VZ(e));return t.opacity=Math.cbrt(e),t.formatRgb()},wO=_s({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return cue}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var s=new Nv.Mesh(new Nv.SphereGeometry(ar),YE(new Nv.MeshLambertMaterial({vertexColors:!0,transparent:!0}),Jle));return s.__globeObjType="heatmap",s})},update:function(e){var t=Lt(e.heatmapPoints),n=Lt(e.heatmapPointLat),r=Lt(e.heatmapPointLng),s=Lt(e.heatmapPointWeight),a=Lt(e.heatmapBandwidth),l=Lt(e.heatmapColorFn),u=Lt(e.heatmapColorSaturation),h=Lt(e.heatmapBaseAltitude),m=Lt(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(v,x){var S=a(x),T=l(x),N=u(x),C=h(x),E=m(x),O=t(x).map(function(G){var H=n(G),q=r(G),V=Zo(H,q),Q=V.x,J=V.y,ie=V.z;return{x:Q,y:J,z:ie,lat:H,lng:q,weight:s(G)}}),U=Math.max(uue,S/lue),I=Math.ceil(360/(U||-1));v.geometry.parameters.widthSegments!==I&&(v.geometry.dispose(),v.geometry=new Nv.SphereGeometry(ar,I,I/2));var j=Zle(v.geometry.getAttribute("position")),z=j.map(function(G){var H=Ar(G,3),q=H[0],V=H[1],Q=H[2],J=gO({x:q,y:V,z:Q}),ie=J.lng,le=J.lat;return[ie,le]});oue(z,O,{latAccessor:function(H){return H.lat},lngAccessor:function(H){return H.lng},weightAccessor:function(H){return H.weight},bandwidth:S}).then(function(G){var H=ji(new Array(Z6)).map(function(J,ie){return Gh(T(ie/(Z6-1)))}),q=function(ie){var le=v.__currentTargetD=ie,re=le.kdeVals,Z=le.topAlt,ne=le.saturation,de=QW(re.map(Math.abs))||1e-15,be=UD([0,de/ne],H);v.geometry.setAttribute("color",xu(re.map(function(ae){return be(Math.abs(ae))}),4));var Te=Ec([0,de],[ar*(1+C),ar*(1+(Z||C))]);v.geometry.setAttribute("r",xu(re.map(Te)))},V={kdeVals:G,topAlt:E,saturation:N},Q=v.__currentTargetD||Object.assign({},V,{kdeVals:G.map(function(){return 0}),topAlt:E&&C,saturation:.5});Q.kdeVals.length!==G.length&&(Q.kdeVals=G.slice()),Object.keys(V).some(function(J){return Q[J]!==V[J]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?q(V):e.tweenGroup.add(new la(Q).to(V,e.heatmapsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(q).start()))})}).digest(e.heatmapsData)}}),bh=window.THREE?window.THREE:{DoubleSide:as,Group:qa,LineBasicMaterial:q0,LineSegments:Y7,Mesh:Oi,MeshBasicMaterial:cd},TO=_s({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjPolygon"}).id(function(s){return s.id}).onCreateObj(function(){var s=new bh.Group;return s.__defaultSideMaterial=YE(new bh.MeshBasicMaterial({side:bh.DoubleSide,depthWrite:!0}),hT),s.__defaultCapMaterial=new bh.MeshBasicMaterial({side:bh.DoubleSide,depthWrite:!0}),s.add(new bh.Mesh(void 0,[s.__defaultSideMaterial,s.__defaultCapMaterial])),s.add(new bh.LineSegments(void 0,new bh.LineBasicMaterial)),s.__globeObjType="polygon",s})},update:function(e){var t=Lt(e.polygonGeoJsonGeometry),n=Lt(e.polygonAltitude),r=Lt(e.polygonCapCurvatureResolution),s=Lt(e.polygonCapColor),a=Lt(e.polygonCapMaterial),l=Lt(e.polygonSideColor),u=Lt(e.polygonSideMaterial),h=Lt(e.polygonStrokeColor),m=[];e.polygonsData.forEach(function(v){var x={data:v,capColor:s(v),capMaterial:a(v),sideColor:l(v),sideMaterial:u(v),strokeColor:h(v),altitude:+n(v),capCurvatureResolution:+r(v)},S=t(v),T=v.__id||"".concat(Math.round(Math.random()*1e9));v.__id=T,S.type==="Polygon"?m.push(ki({id:"".concat(T,"_0"),coords:S.coordinates},x)):S.type==="MultiPolygon"?m.push.apply(m,ji(S.coordinates.map(function(N,C){return ki({id:"".concat(T,"_").concat(C),coords:N},x)}))):console.warn("Unsupported GeoJson geometry type: ".concat(S.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(v,x){var S=x.coords,T=x.capColor,N=x.capMaterial,C=x.sideColor,E=x.sideMaterial,O=x.strokeColor,U=x.altitude,I=x.capCurvatureResolution,j=Ar(v.children,2),z=j[0],G=j[1],H=!!O;G.visible=H;var q=!!(T||N),V=!!(C||E);hue(z.geometry.parameters||{},{polygonGeoJson:S,curvatureResolution:I,closedTop:q,includeSides:V})||(z.geometry&&z.geometry.dispose(),z.geometry=new CM(S,0,ar,!1,q,V,I)),H&&(!G.geometry.parameters||G.geometry.parameters.geoJson.coordinates!==S||G.geometry.parameters.resolution!==I)&&(G.geometry&&G.geometry.dispose(),G.geometry=new AP({type:"Polygon",coordinates:S},ar,I));var Q=V?0:-1,J=q?V?1:0:-1;if(Q>=0&&(z.material[Q]=E||v.__defaultSideMaterial),J>=0&&(z.material[J]=N||v.__defaultCapMaterial),[[!E&&C,Q],[!N&&T,J]].forEach(function(de){var be=Ar(de,2),Te=be[0],ae=be[1];if(!(!Te||ae<0)){var Me=z.material[ae],Ve=Ml(Te);Me.color.set(yu(Te)),Me.transparent=Ve<1,Me.opacity=Ve}}),H){var ie=G.material,le=Ml(O);ie.color.set(yu(O)),ie.transparent=le<1,ie.opacity=le}var re={alt:U},Z=function(be){var Te=v.__currentTargetD=be,ae=Te.alt;z.scale.x=z.scale.y=z.scale.z=1+ae,H&&(G.scale.x=G.scale.y=G.scale.z=1+ae+1e-4),eue(v.__defaultSideMaterial,function(Me){return Me.uSurfaceRadius.value=ar/(ae+1)})},ne=v.__currentTargetD||Object.assign({},re,{alt:-.001});Object.keys(re).some(function(de){return ne[de]!==re[de]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||ne.alt===re.alt?Z(re):e.tweenGroup.add(new la(ne).to(re,e.polygonsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(Z).start()))}).digest(m)}});function hue(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(n,r){return n===r}};return Object.entries(e).every(function(n){var r=Ar(n,2),s=r[0],a=r[1];return i.hasOwnProperty(s)&&t(s)(i[s],a)})}var RA=window.THREE?window.THREE:{BufferGeometry:Hi,DoubleSide:as,Mesh:Oi,MeshLambertMaterial:Fc,Vector3:pe},J6=Object.assign({},SM),e7=J6.BufferGeometryUtils||J6,MO=_s({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var s=new RA.Mesh(void 0,new RA.MeshLambertMaterial({side:RA.DoubleSide}));return s.__globeObjType="hexPolygon",s})},update:function(e){var t=Lt(e.hexPolygonGeoJsonGeometry),n=Lt(e.hexPolygonColor),r=Lt(e.hexPolygonAltitude),s=Lt(e.hexPolygonResolution),a=Lt(e.hexPolygonMargin),l=Lt(e.hexPolygonUseDots),u=Lt(e.hexPolygonCurvatureResolution),h=Lt(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(m,v){var x=t(v),S=s(v),T=r(v),N=Math.max(0,Math.min(1,+a(v))),C=l(v),E=u(v),O=h(v),U=n(v),I=Ml(U);m.material.color.set(yu(U)),m.material.transparent=I<1,m.material.opacity=I;var j={alt:T,margin:N,curvatureResolution:E},z={geoJson:x,h3Res:S},G=m.__currentTargetD||Object.assign({},j,{alt:-.001}),H=m.__currentMemD||z;if(Object.keys(j).some(function(J){return G[J]!==j[J]})||Object.keys(z).some(function(J){return H[J]!==z[J]})){m.__currentMemD=z;var q=[];x.type==="Polygon"?PR(x.coordinates,S,!0).forEach(function(J){return q.push(J)}):x.type==="MultiPolygon"?x.coordinates.forEach(function(J){return PR(J,S,!0).forEach(function(ie){return q.push(ie)})}):console.warn("Unsupported GeoJson geometry type: ".concat(x.type,". Skipping geometry..."));var V=q.map(function(J){var ie=LP(J),le=UP(J,!0).reverse(),re=ie[1];return le.forEach(function(Z){var ne=Z[0];Math.abs(re-ne)>170&&(Z[0]+=re>ne?360:-360)}),{h3Idx:J,hexCenter:ie,hexGeoJson:le}}),Q=function(ie){var le=m.__currentTargetD=ie,re=le.alt,Z=le.margin,ne=le.curvatureResolution;m.geometry&&m.geometry.dispose(),m.geometry=V.length?(e7.mergeGeometries||e7.mergeBufferGeometries)(V.map(function(de){var be=Ar(de.hexCenter,2),Te=be[0],ae=be[1];if(C){var Me=Zo(Te,ae,re),Ve=Zo(de.hexGeoJson[0][1],de.hexGeoJson[0][0],re),Ce=.85*(1-Z)*new RA.Vector3(Me.x,Me.y,Me.z).distanceTo(new RA.Vector3(Ve.x,Ve.y,Ve.z)),Fe=new yy(Ce,O);return Fe.rotateX(Ff(-Te)),Fe.rotateY(Ff(ae)),Fe.translate(Me.x,Me.y,Me.z),Fe}else{var tt=function(Et,Ft,Ut){return Et-(Et-Ft)*Ut},je=Z===0?de.hexGeoJson:de.hexGeoJson.map(function(Rt){var Et=Ar(Rt,2),Ft=Et[0],Ut=Et[1];return[[Ft,ae],[Ut,Te]].map(function(Ke){var ht=Ar(Ke,2),fe=ht[0],$t=ht[1];return tt(fe,$t,Z)})});return new CM([je],ar,ar*(1+re),!1,!0,!1,ne)}})):new RA.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?Q(j):e.tweenGroup.add(new la(G).to(j,e.hexPolygonsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(Q).start())}}).digest(e.hexPolygonsData)}}),fue=window.THREE?window.THREE:{Vector3:pe};function due(i,e){var t=function(a,l){var u=a[a.length-1];return[].concat(ji(a),ji(Array(l-a.length).fill(u)))},n=Math.max(i.length,e.length),r=p$.apply(void 0,ji([i,e].map(function(s){return s.map(function(a){var l=a.x,u=a.y,h=a.z;return[l,u,h]})}).map(function(s){return t(s,n)})));return function(s){return s===0?i:s===1?e:r(s).map(function(a){var l=Ar(a,3),u=l[0],h=l[1],m=l[2];return new fue.Vector3(u,h,m)})}}var Ef=window.THREE?window.THREE:{BufferGeometry:Hi,Color:cn,Group:qa,Line:_y,NormalBlending:Xa,ShaderMaterial:Qa,Vector3:pe},Aue=C0.default||C0,EO=_s({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new Aue,sharedMaterial:new Ef.ShaderMaterial(ki(ki({},yO()),{},{transparent:!0,blending:Ef.NormalBlending}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var n=new Ef.Group;return n.__globeObjType="path",n}),t.ticker.onTick.add(function(n,r){t.dataMapper.entries().map(function(s){var a=Ar(s,2),l=a[1];return l}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],l=a.__dashAnimateStep*r;if(a.type==="Line"){var u=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=u+l}else if(a.type==="Line2"){for(var h=a.material.dashOffset-l,m=a.material.dashSize+a.material.gapSize;h<=-m;)h+=m;a.material.dashOffset=h}})})},update:function(e){var t=Lt(e.pathPoints),n=Lt(e.pathPointLat),r=Lt(e.pathPointLng),s=Lt(e.pathPointAlt),a=Lt(e.pathStroke),l=Lt(e.pathColor),u=Lt(e.pathDashLength),h=Lt(e.pathDashGap),m=Lt(e.pathDashInitialGap),v=Lt(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(C,E){var O=a(E),U=O!=null;if(!C.children.length||U===(C.children[0].type==="Line")){Ki(C);var I=U?new Ele(new fO,new HE):new Ef.Line(new Ef.BufferGeometry,e.sharedMaterial.clone());C.add(I)}var j=C.children[0],z=S(t(E),n,r,s,e.pathResolution),G=v(E);if(j.__dashAnimateStep=G>0?1e3/G:0,U){j.material.resolution=e.rendererSize;{var V=u(E),Q=h(E),J=m(E);j.material.dashed=Q>0,j.material.dashed?j.material.defines.USE_DASH="":delete j.material.defines.USE_DASH,j.material.dashed&&(j.material.dashScale=1/x(z),j.material.dashSize=V,j.material.gapSize=Q,j.material.dashOffset=-J)}{var ie=l(E);if(ie instanceof Array){var le=T(l(E),z.length-1,1,!1);j.geometry.setColors(le.array),j.material.vertexColors=!0}else{var re=ie,Z=Ml(re);j.material.color=new Ef.Color(yu(re)),j.material.transparent=Z<1,j.material.opacity=Z,j.material.vertexColors=!1}}j.material.needsUpdate=!0}else{Object.assign(j.material.uniforms,{dashSize:{value:u(E)},gapSize:{value:h(E)},dashOffset:{value:m(E)}});var H=T(l(E),z.length),q=N(z.length,1,!0);j.geometry.setAttribute("color",H),j.geometry.setAttribute("relDistance",q)}var ne=due(C.__currentTargetD&&C.__currentTargetD.points||[z[0]],z),de=function(Me){var Ve=C.__currentTargetD=Me,Ce=Ve.stroke,Fe=Ve.interpolK,tt=C.__currentTargetD.points=ne(Fe);if(U){var je;j.geometry.setPositions((je=[]).concat.apply(je,ji(tt.map(function(Rt){var Et=Rt.x,Ft=Rt.y,Ut=Rt.z;return[Et,Ft,Ut]})))),j.material.linewidth=Ce,j.material.dashed&&j.computeLineDistances()}else j.geometry.setFromPoints(tt),j.geometry.computeBoundingSphere()},be={stroke:O,interpolK:1},Te=Object.assign({},C.__currentTargetD||be,{interpolK:0});Object.keys(be).some(function(ae){return Te[ae]!==be[ae]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?de(be):e.tweenGroup.add(new la(Te).to(be,e.pathTransitionDuration).easing(os.Quadratic.InOut).onUpdate(de).start()))}).digest(e.pathsData);function x(C){var E=0,O;return C.forEach(function(U){O&&(E+=O.distanceTo(U)),O=U}),E}function S(C,E,O,U,I){var j=function(q,V,Q){for(var J=[],ie=1;ie<=Q;ie++)J.push(q+(V-q)*ie/(Q+1));return J},z=function(){var q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,Q=[],J=null;return q.forEach(function(ie){if(J){for(;Math.abs(J[1]-ie[1])>180;)J[1]+=360*(J[1]V)for(var re=Math.floor(le/V),Z=j(J[0],ie[0],re),ne=j(J[1],ie[1],re),de=j(J[2],ie[2],re),be=0,Te=Z.length;be2&&arguments[2]!==void 0?arguments[2]:1,U=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,I=E+1,j;if(C instanceof Array||C instanceof Function){var z=C instanceof Array?Ec().domain(C.map(function(ie,le){return le/(C.length-1)})).range(C):C;j=function(le){return Gh(z(le),U,!0)}}else{var G=Gh(C,U,!0);j=function(){return G}}for(var H=[],q=0,V=I;q1&&arguments[1]!==void 0?arguments[1]:1,O=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,U=C+1,I=[],j=0,z=U;j0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;ex(this,e),t=Jy(this,e),t.type="CircleLineGeometry",t.parameters={radius:n,segmentCount:r};for(var s=[],a=0;a<=r;a++){var l=(a/r-.25)*Math.PI*2;s.push({x:Math.cos(l)*n,y:Math.sin(l)*n,z:0})}return t.setFromPoints(s),t}return nx(e,i),tx(e)})(pue.BufferGeometry),PA=window.THREE?window.THREE:{Color:cn,Group:qa,Line:_y,LineBasicMaterial:q0,Vector3:pe},gue=C0.default||C0,RO=_s({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var s=new PA.Group;return s.__globeObjType="ring",s}),t.ticker=new gue,t.ticker.onTick.add(function(s){if(t.ringsData.length){var a=Lt(t.ringColor),l=Lt(t.ringAltitude),u=Lt(t.ringMaxRadius),h=Lt(t.ringPropagationSpeed),m=Lt(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(v){var x=Ar(v,2),S=x[1];return S}).forEach(function(v){var x=Ar(v,2),S=x[0],T=x[1];if((T.__nextRingTime||0)<=s){var N=m(S)/1e3;T.__nextRingTime=s+(N<=0?1/0:N);var C=new PA.Line(new mue(1,t.ringResolution),new PA.LineBasicMaterial),E=a(S),O=E instanceof Array||E instanceof Function,U;O?E instanceof Array?(U=Ec().domain(E.map(function(Q,J){return J/(E.length-1)})).range(E),C.material.transparent=E.some(function(Q){return Ml(Q)<1})):(U=E,C.material.transparent=!0):(C.material.color=new PA.Color(yu(E)),Kle(C.material,Ml(E)));var I=ar*(1+l(S)),j=u(S),z=j*Math.PI/180,G=h(S),H=G<=0,q=function(J){var ie=J.t,le=(H?1-ie:ie)*z;if(C.scale.x=C.scale.y=I*Math.sin(le),C.position.z=I*(1-Math.cos(le)),O){var re=U(ie);C.material.color=new PA.Color(yu(re)),C.material.transparent&&(C.material.opacity=Ml(re))}};if(G===0)q({t:0}),T.add(C);else{var V=Math.abs(j/G)*1e3;t.tweenGroup.add(new la({t:0}).to({t:1},V).onUpdate(q).onStart(function(){return T.add(C)}).onComplete(function(){T.remove(C),XE(C)}).start())}}})}})},update:function(e){var t=Lt(e.ringLat),n=Lt(e.ringLng),r=Lt(e.ringAltitude),s=e.scene.localToWorld(new PA.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(a,l){var u=t(l),h=n(l),m=r(l);Object.assign(a.position,Zo(u,h,m)),a.lookAt(s)}).digest(e.ringsData)}}),vue={0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},_ue="normal",yue=1189,xue=-100,bue="normal",Sue={yMin:-334,xMin:-111,yMax:1189,xMax:1672},wue=1e3,Tue={postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r \r Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r \r @@ -4772,7 +4772,7 @@ This License becomes null and void to the extent applicable to Fonts or Font Sof \r The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r \r -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},Mue=-334,Eue="Helvetiker",Cue=1522,Nue=50,Rue={glyphs:vue,cssFontWeight:_ue,ascender:yue,underlinePosition:xue,cssFontStyle:bue,boundingBox:Sue,resolution:wue,original_font_information:Tue,descender:Mue,familyName:Eue,lineHeight:Cue,underlineThickness:Nue},vl=ki(ki({},window.THREE?window.THREE:{BoxGeometry:Vh,CircleGeometry:yy,DoubleSide:as,Group:qa,Mesh:Oi,MeshLambertMaterial:Fc,TextGeometry:V6,Vector3:me}),{},{Font:Cle,TextGeometry:V6}),DO=_s({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:Rue,onChange:function(e,t){t.font=new vl.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r;var s=new vl.CircleGeometry(1,32);t.dataMapper=new io(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var a=new vl.MeshLambertMaterial;a.side=as;var l=new vl.Group;l.add(new vl.Mesh(s,a));var u=new vl.Mesh(void 0,a);l.add(u);var h=new vl.Mesh;return h.visible=!1,u.add(h),l.__globeObjType="label",l})},update:function(e){var t=Ut(e.labelLat),n=Ut(e.labelLng),r=Ut(e.labelAltitude),s=Ut(e.labelText),a=Ut(e.labelSize),l=Ut(e.labelRotation),u=Ut(e.labelColor),h=Ut(e.labelIncludeDot),m=Ut(e.labelDotRadius),v=Ut(e.labelDotOrientation),x=new Set(["right","top","bottom"]),S=2*Math.PI*ar/360;e.dataMapper.onUpdateObj(function(T,N){var C=Ar(T.children,2),E=C[0],O=C[1],U=Ar(O.children,1),I=U[0],j=u(N),z=Ml(j);O.material.color.set(yu(j)),O.material.transparent=z<1,O.material.opacity=z;var G=h(N),H=v(N);!G||!x.has(H)&&(H="bottom");var q=G?+m(N)*S:1e-12;E.scale.x=E.scale.y=q;var V=+a(N)*S;if(O.geometry&&O.geometry.dispose(),O.geometry=new vl.TextGeometry(s(N),{font:e.font,size:V,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),I.geometry&&I.geometry.dispose(),O.geometry.computeBoundingBox(),I.geometry=WE(vl.BoxGeometry,ji(new vl.Vector3().subVectors(O.geometry.boundingBox.max,O.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),H!=="right"&&O.geometry.center(),G){var Q=q+V/2;H==="right"&&(O.position.x=Q),O.position.y={right:-V/2,top:Q+V/2,bottom:-Q-V/2}[H]}var J=function(Z){var te=T.__currentTargetD=Z,de=te.lat,Se=te.lng,Te=te.alt,ae=te.rot,Me=te.scale;Object.assign(T.position,Zo(de,Se,Te)),T.lookAt(e.scene.localToWorld(new vl.Vector3(0,0,0))),T.rotateY(Math.PI),T.rotateZ(-ae*Math.PI/180),T.scale.x=T.scale.y=T.scale.z=Me},ne={lat:+t(N),lng:+n(N),alt:+r(N),rot:+l(N),scale:1},oe=T.__currentTargetD||Object.assign({},ne,{scale:1e-12});Object.keys(ne).some(function(ie){return oe[ie]!==ne[ie]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?J(ne):e.tweenGroup.add(new la(oe).to(ne,e.labelsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start()))}).digest(e.labelsData)}}),Due=ki(ki({},window.THREE?window.THREE:{}),{},{CSS2DObject:kH}),PO=_s({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){if(e.dataMapper){var n=t?[t]:e.dataMapper.entries().map(function(r){var s=Ar(r,2),a=s[1];return a}).filter(function(r){return r});n.forEach(function(r){var s=!e.isBehindGlobe||!e.isBehindGlobe(r.position);e.htmlElementVisibilityModifier?(r.visible=!0,e.htmlElementVisibilityModifier(r.element,s)):r.visible=s})}}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(s){var a=Ut(t.htmlElement)(s),l=new Due.CSS2DObject(a);return l.__globeObjType="html",l})},update:function(e,t){var n=this,r=Ut(e.htmlLat),s=Ut(e.htmlLng),a=Ut(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(l,u){var h=function(x){var S=l.__currentTargetD=x,T=S.alt,N=S.lat,C=S.lng;Object.assign(l.position,Zo(N,C,T)),n.updateObjVisibility(l)},m={lat:+r(u),lng:+s(u),alt:+a(u)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!l.__currentTargetD?h(m):e.tweenGroup.add(new la(l.__currentTargetD).to(m,e.htmlTransitionDuration).easing(os.Quadratic.InOut).onUpdate(h).start())}).digest(e.htmlElementsData)}}),Dv=window.THREE?window.THREE:{Group:qa,Mesh:Oi,MeshLambertMaterial:Fc,SphereGeometry:bu},LO=_s({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new Dv.Mesh(new Dv.SphereGeometry(1,16,8),new Dv.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(n){var r=Ut(t.objectThreeObject)(n);t.objectThreeObject===r&&(r=r.clone());var s=new Dv.Group;return s.add(r),s.__globeObjType="object",s})},update:function(e,t){var n=Ut(e.objectLat),r=Ut(e.objectLng),s=Ut(e.objectAltitude),a=Ut(e.objectFacesSurface),l=Ut(e.objectRotation);t.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(u,h){var m=+n(h),v=+r(h),x=+s(h);Object.assign(u.position,Zo(m,v,x)),a(h)?u.setRotationFromEuler(new aa(Ff(-m),Ff(v),0,"YXZ")):u.rotation.set(0,0,0);var S=u.children[0],T=l(h);T&&S.setRotationFromEuler(new aa(Ff(T.x||0),Ff(T.y||0),Ff(T.z||0)))}).digest(e.objectsData)}}),UO=_s({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(n){var r=Ut(t.customThreeObject)(n,ar);return r&&(t.customThreeObject===r&&(r=r.clone()),r.__globeObjType="custom"),r})},update:function(e,t){e.customThreeObjectUpdate||Ki(e.scene);var n=Ut(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(r,s){return n(r,s,ar)}).digest(e.customLayerData)}}),Pv=window.THREE?window.THREE:{Camera:gy,Group:qa,Vector2:bt,Vector3:me},Pue=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],BO=Sa("globeLayer",vO),Lue=Object.assign.apply(Object,ji(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(i){return Ds({},i,BO.linkProp(i))}))),Uue=Object.assign.apply(Object,ji(["globeMaterial","globeTileEngineClearCache"].map(function(i){return Ds({},i,BO.linkMethod(i))}))),Bue=Sa("pointsLayer",_O),Oue=Object.assign.apply(Object,ji(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(i){return Ds({},i,Bue.linkProp(i))}))),Iue=Sa("arcsLayer",xO),Fue=Object.assign.apply(Object,ji(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(i){return Ds({},i,Iue.linkProp(i))}))),kue=Sa("hexBinLayer",bO),zue=Object.assign.apply(Object,ji(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(i){return Ds({},i,kue.linkProp(i))}))),Gue=Sa("heatmapsLayer",wO),que=Object.assign.apply(Object,ji(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(i){return Ds({},i,Gue.linkProp(i))}))),Vue=Sa("hexedPolygonsLayer",MO),jue=Object.assign.apply(Object,ji(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(i){return Ds({},i,Vue.linkProp(i))}))),Hue=Sa("polygonsLayer",TO),Wue=Object.assign.apply(Object,ji(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(i){return Ds({},i,Hue.linkProp(i))}))),$ue=Sa("pathsLayer",EO),Xue=Object.assign.apply(Object,ji(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(i){return Ds({},i,$ue.linkProp(i))}))),Yue=Sa("tilesLayer",CO),Que=Object.assign.apply(Object,ji(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(i){return Ds({},i,Yue.linkProp(i))}))),Kue=Sa("particlesLayer",NO),Zue=Object.assign.apply(Object,ji(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(i){return Ds({},i,Kue.linkProp(i))}))),Jue=Sa("ringsLayer",RO),ece=Object.assign.apply(Object,ji(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(i){return Ds({},i,Jue.linkProp(i))}))),tce=Sa("labelsLayer",DO),nce=Object.assign.apply(Object,ji(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(i){return Ds({},i,tce.linkProp(i))}))),ice=Sa("htmlElementsLayer",PO),rce=Object.assign.apply(Object,ji(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(i){return Ds({},i,ice.linkProp(i))}))),sce=Sa("objectsLayer",LO),ace=Object.assign.apply(Object,ji(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(i){return Ds({},i,sce.linkProp(i))}))),oce=Sa("customLayer",UO),lce=Object.assign.apply(Object,ji(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(i){return Ds({},i,oce.linkProp(i))}))),uce=_s({props:ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new Pv.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},Lue),Oue),Fue),zue),que),Wue),jue),Xue),Que),Zue),ece),nce),rce),ace),lce),methods:ki({getGlobeRadius:W6,getCoords:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=(function(r){function s(){var a;ex(this,s);for(var l=arguments.length,u=new Array(l),h=0;ht7&&(this.dispatchEvent(BS),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>t7||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(BS),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Li.NONE,this.keyState=Li.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(BS),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Sh.copy(this._panEnd).sub(this._panStart),Sh.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Sh.x*=e,Sh.y*=t}Sh.multiplyScalar(this._eye.length()*this.panSpeed),Uv.copy(this._eye).cross(this.object.up).setLength(Sh.x),Uv.add(fce.copy(this.object.up).setLength(Sh.y)),this.object.position.add(Uv),this.target.add(Uv),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Sh.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Ov.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Ov.length();e?(this._eye.copy(this.object.position).sub(this.target),n7.copy(this._eye).normalize(),Bv.copy(this.object.up).normalize(),IS.crossVectors(Bv,n7).normalize(),Bv.setLength(this._moveCurr.y-this._movePrev.y),IS.setLength(this._moveCurr.x-this._movePrev.x),Ov.copy(Bv.add(IS)),OS.crossVectors(Ov,this._eye).normalize(),e*=this.rotateSpeed,LA.setFromAxisAngle(OS,e),this._eye.applyQuaternion(LA),this.object.up.applyQuaternion(LA),this._lastAxis.copy(OS),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),LA.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(LA),this.object.up.applyQuaternion(LA)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Li.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=x0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=x0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Lv.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Lv}_getMouseOnCircle(e,t){return Lv.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Lv}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=Ba),r<-Math.PI?r+=Ba:r>Math.PI&&(r-=Ba),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(ds.setFromSpherical(this._spherical),ds.applyQuaternion(this._quatInverse),t.copy(this.target).add(ds),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=ds.length();a=this._clampDistance(l*this._scale);const u=l-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),s=!!u}else if(this.object.isOrthographicCamera){const l=new me(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=u!==this.object.zoom;const h=new me(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(l),this.object.updateMatrixWorld(),a=ds.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Iv.origin.copy(this.object.position),Iv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Iv.direction))FS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>FS||this._lastTargetPosition.distanceToSquared(this.target)>FS?(this.dispatchEvent(i7),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ba/60*this.autoRotateSpeed*e:Ba/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ds.setFromMatrixColumn(t,0),ds.multiplyScalar(-e),this._panOffset.add(ds)}_panUp(e,t){this.screenSpacePanning===!0?ds.setFromMatrixColumn(t,1):(ds.setFromMatrixColumn(t,0),ds.crossVectors(this.object.up,ds)),ds.multiplyScalar(e),this._panOffset.add(ds)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;ds.copy(r).sub(this.target);let s=ds.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,l=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ba*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ba*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ba*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ba*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;ts7||8*(1-this._lastQuaternion.dot(t.quaternion))>s7)&&(this.dispatchEvent(qce),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function jce(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function Hce(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function Wce(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function $ce(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function Xce(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function Yce(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Qce(i){this.enabled!==!1&&i.preventDefault()}const Kce={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},Mue=-334,Eue="Helvetiker",Cue=1522,Nue=50,Rue={glyphs:vue,cssFontWeight:_ue,ascender:yue,underlinePosition:xue,cssFontStyle:bue,boundingBox:Sue,resolution:wue,original_font_information:Tue,descender:Mue,familyName:Eue,lineHeight:Cue,underlineThickness:Nue},vl=ki(ki({},window.THREE?window.THREE:{BoxGeometry:Vh,CircleGeometry:yy,DoubleSide:as,Group:qa,Mesh:Oi,MeshLambertMaterial:Fc,TextGeometry:V6,Vector3:pe}),{},{Font:Cle,TextGeometry:V6}),DO=_s({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:Rue,onChange:function(e,t){t.font=new vl.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r;var s=new vl.CircleGeometry(1,32);t.dataMapper=new io(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var a=new vl.MeshLambertMaterial;a.side=as;var l=new vl.Group;l.add(new vl.Mesh(s,a));var u=new vl.Mesh(void 0,a);l.add(u);var h=new vl.Mesh;return h.visible=!1,u.add(h),l.__globeObjType="label",l})},update:function(e){var t=Lt(e.labelLat),n=Lt(e.labelLng),r=Lt(e.labelAltitude),s=Lt(e.labelText),a=Lt(e.labelSize),l=Lt(e.labelRotation),u=Lt(e.labelColor),h=Lt(e.labelIncludeDot),m=Lt(e.labelDotRadius),v=Lt(e.labelDotOrientation),x=new Set(["right","top","bottom"]),S=2*Math.PI*ar/360;e.dataMapper.onUpdateObj(function(T,N){var C=Ar(T.children,2),E=C[0],O=C[1],U=Ar(O.children,1),I=U[0],j=u(N),z=Ml(j);O.material.color.set(yu(j)),O.material.transparent=z<1,O.material.opacity=z;var G=h(N),H=v(N);!G||!x.has(H)&&(H="bottom");var q=G?+m(N)*S:1e-12;E.scale.x=E.scale.y=q;var V=+a(N)*S;if(O.geometry&&O.geometry.dispose(),O.geometry=new vl.TextGeometry(s(N),{font:e.font,size:V,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),I.geometry&&I.geometry.dispose(),O.geometry.computeBoundingBox(),I.geometry=WE(vl.BoxGeometry,ji(new vl.Vector3().subVectors(O.geometry.boundingBox.max,O.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),H!=="right"&&O.geometry.center(),G){var Q=q+V/2;H==="right"&&(O.position.x=Q),O.position.y={right:-V/2,top:Q+V/2,bottom:-Q-V/2}[H]}var J=function(Z){var ne=T.__currentTargetD=Z,de=ne.lat,be=ne.lng,Te=ne.alt,ae=ne.rot,Me=ne.scale;Object.assign(T.position,Zo(de,be,Te)),T.lookAt(e.scene.localToWorld(new vl.Vector3(0,0,0))),T.rotateY(Math.PI),T.rotateZ(-ae*Math.PI/180),T.scale.x=T.scale.y=T.scale.z=Me},ie={lat:+t(N),lng:+n(N),alt:+r(N),rot:+l(N),scale:1},le=T.__currentTargetD||Object.assign({},ie,{scale:1e-12});Object.keys(ie).some(function(re){return le[re]!==ie[re]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?J(ie):e.tweenGroup.add(new la(le).to(ie,e.labelsTransitionDuration).easing(os.Quadratic.InOut).onUpdate(J).start()))}).digest(e.labelsData)}}),Due=ki(ki({},window.THREE?window.THREE:{}),{},{CSS2DObject:kH}),PO=_s({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){if(e.dataMapper){var n=t?[t]:e.dataMapper.entries().map(function(r){var s=Ar(r,2),a=s[1];return a}).filter(function(r){return r});n.forEach(function(r){var s=!e.isBehindGlobe||!e.isBehindGlobe(r.position);e.htmlElementVisibilityModifier?(r.visible=!0,e.htmlElementVisibilityModifier(r.element,s)):r.visible=s})}}},init:function(e,t,n){var r=n.tweenGroup;Ki(e),t.scene=e,t.tweenGroup=r,t.dataMapper=new io(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(s){var a=Lt(t.htmlElement)(s),l=new Due.CSS2DObject(a);return l.__globeObjType="html",l})},update:function(e,t){var n=this,r=Lt(e.htmlLat),s=Lt(e.htmlLng),a=Lt(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(l,u){var h=function(x){var S=l.__currentTargetD=x,T=S.alt,N=S.lat,C=S.lng;Object.assign(l.position,Zo(N,C,T)),n.updateObjVisibility(l)},m={lat:+r(u),lng:+s(u),alt:+a(u)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!l.__currentTargetD?h(m):e.tweenGroup.add(new la(l.__currentTargetD).to(m,e.htmlTransitionDuration).easing(os.Quadratic.InOut).onUpdate(h).start())}).digest(e.htmlElementsData)}}),Dv=window.THREE?window.THREE:{Group:qa,Mesh:Oi,MeshLambertMaterial:Fc,SphereGeometry:bu},LO=_s({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new Dv.Mesh(new Dv.SphereGeometry(1,16,8),new Dv.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(n){var r=Lt(t.objectThreeObject)(n);t.objectThreeObject===r&&(r=r.clone());var s=new Dv.Group;return s.add(r),s.__globeObjType="object",s})},update:function(e,t){var n=Lt(e.objectLat),r=Lt(e.objectLng),s=Lt(e.objectAltitude),a=Lt(e.objectFacesSurface),l=Lt(e.objectRotation);t.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(u,h){var m=+n(h),v=+r(h),x=+s(h);Object.assign(u.position,Zo(m,v,x)),a(h)?u.setRotationFromEuler(new aa(Ff(-m),Ff(v),0,"YXZ")):u.rotation.set(0,0,0);var S=u.children[0],T=l(h);T&&S.setRotationFromEuler(new aa(Ff(T.x||0),Ff(T.y||0),Ff(T.z||0)))}).digest(e.objectsData)}}),UO=_s({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){Ki(e),t.scene=e,t.dataMapper=new io(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(n){var r=Lt(t.customThreeObject)(n,ar);return r&&(t.customThreeObject===r&&(r=r.clone()),r.__globeObjType="custom"),r})},update:function(e,t){e.customThreeObjectUpdate||Ki(e.scene);var n=Lt(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(r,s){return n(r,s,ar)}).digest(e.customLayerData)}}),Pv=window.THREE?window.THREE:{Camera:gy,Group:qa,Vector2:bt,Vector3:pe},Pue=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],BO=Sa("globeLayer",vO),Lue=Object.assign.apply(Object,ji(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(i){return Ds({},i,BO.linkProp(i))}))),Uue=Object.assign.apply(Object,ji(["globeMaterial","globeTileEngineClearCache"].map(function(i){return Ds({},i,BO.linkMethod(i))}))),Bue=Sa("pointsLayer",_O),Oue=Object.assign.apply(Object,ji(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(i){return Ds({},i,Bue.linkProp(i))}))),Iue=Sa("arcsLayer",xO),Fue=Object.assign.apply(Object,ji(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(i){return Ds({},i,Iue.linkProp(i))}))),kue=Sa("hexBinLayer",bO),zue=Object.assign.apply(Object,ji(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(i){return Ds({},i,kue.linkProp(i))}))),Gue=Sa("heatmapsLayer",wO),que=Object.assign.apply(Object,ji(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(i){return Ds({},i,Gue.linkProp(i))}))),Vue=Sa("hexedPolygonsLayer",MO),jue=Object.assign.apply(Object,ji(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(i){return Ds({},i,Vue.linkProp(i))}))),Hue=Sa("polygonsLayer",TO),Wue=Object.assign.apply(Object,ji(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(i){return Ds({},i,Hue.linkProp(i))}))),$ue=Sa("pathsLayer",EO),Xue=Object.assign.apply(Object,ji(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(i){return Ds({},i,$ue.linkProp(i))}))),Yue=Sa("tilesLayer",CO),Que=Object.assign.apply(Object,ji(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(i){return Ds({},i,Yue.linkProp(i))}))),Kue=Sa("particlesLayer",NO),Zue=Object.assign.apply(Object,ji(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(i){return Ds({},i,Kue.linkProp(i))}))),Jue=Sa("ringsLayer",RO),ece=Object.assign.apply(Object,ji(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(i){return Ds({},i,Jue.linkProp(i))}))),tce=Sa("labelsLayer",DO),nce=Object.assign.apply(Object,ji(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(i){return Ds({},i,tce.linkProp(i))}))),ice=Sa("htmlElementsLayer",PO),rce=Object.assign.apply(Object,ji(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(i){return Ds({},i,ice.linkProp(i))}))),sce=Sa("objectsLayer",LO),ace=Object.assign.apply(Object,ji(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(i){return Ds({},i,sce.linkProp(i))}))),oce=Sa("customLayer",UO),lce=Object.assign.apply(Object,ji(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(i){return Ds({},i,oce.linkProp(i))}))),uce=_s({props:ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki(ki({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new Pv.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},Lue),Oue),Fue),zue),que),Wue),jue),Xue),Que),Zue),ece),nce),rce),ace),lce),methods:ki({getGlobeRadius:W6,getCoords:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=(function(r){function s(){var a;ex(this,s);for(var l=arguments.length,u=new Array(l),h=0;ht7&&(this.dispatchEvent(BS),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>t7||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(BS),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Li.NONE,this.keyState=Li.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(BS),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Sh.copy(this._panEnd).sub(this._panStart),Sh.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Sh.x*=e,Sh.y*=t}Sh.multiplyScalar(this._eye.length()*this.panSpeed),Uv.copy(this._eye).cross(this.object.up).setLength(Sh.x),Uv.add(fce.copy(this.object.up).setLength(Sh.y)),this.object.position.add(Uv),this.target.add(Uv),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Sh.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Ov.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Ov.length();e?(this._eye.copy(this.object.position).sub(this.target),n7.copy(this._eye).normalize(),Bv.copy(this.object.up).normalize(),IS.crossVectors(Bv,n7).normalize(),Bv.setLength(this._moveCurr.y-this._movePrev.y),IS.setLength(this._moveCurr.x-this._movePrev.x),Ov.copy(Bv.add(IS)),OS.crossVectors(Ov,this._eye).normalize(),e*=this.rotateSpeed,LA.setFromAxisAngle(OS,e),this._eye.applyQuaternion(LA),this.object.up.applyQuaternion(LA),this._lastAxis.copy(OS),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),LA.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(LA),this.object.up.applyQuaternion(LA)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Li.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=x0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=x0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Lv.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Lv}_getMouseOnCircle(e,t){return Lv.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Lv}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(n-=Ba),r<-Math.PI?r+=Ba:r>Math.PI&&(r-=Ba),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(ds.setFromSpherical(this._spherical),ds.applyQuaternion(this._quatInverse),t.copy(this.target).add(ds),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=ds.length();a=this._clampDistance(l*this._scale);const u=l-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),s=!!u}else if(this.object.isOrthographicCamera){const l=new pe(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=u!==this.object.zoom;const h=new pe(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(l),this.object.updateMatrixWorld(),a=ds.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Iv.origin.copy(this.object.position),Iv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Iv.direction))FS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>FS||this._lastTargetPosition.distanceToSquared(this.target)>FS?(this.dispatchEvent(i7),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ba/60*this.autoRotateSpeed*e:Ba/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ds.setFromMatrixColumn(t,0),ds.multiplyScalar(-e),this._panOffset.add(ds)}_panUp(e,t){this.screenSpacePanning===!0?ds.setFromMatrixColumn(t,1):(ds.setFromMatrixColumn(t,0),ds.crossVectors(this.object.up,ds)),ds.multiplyScalar(e),this._panOffset.add(ds)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;ds.copy(r).sub(this.target);let s=ds.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,l=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ba*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ba*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Ba*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ba*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ba*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;ts7||8*(1-this._lastQuaternion.dot(t.quaternion))>s7)&&(this.dispatchEvent(qce),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function jce(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function Hce(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function Wce(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function $ce(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function Xce(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function Yce(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Qce(i){this.enabled!==!1&&i.preventDefault()}const Kce={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` varying vec2 vUv; @@ -4824,7 +4824,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho outline: none; }`;Kde(Zde);function yT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,l){return e.hoverOrderComparator(a.object,l.object)});var s=r.find(function(a){return e.hoverFilter(a.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Ut(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var a=t,l=n||{x:0,y:0,z:0};if(!r)m(a),v(l);else{var u=Object.assign({},s.position),h=x();e.tweenGroup.add(new la(u).to(a,r).easing(os.Quadratic.Out).onUpdate(m).start()),e.tweenGroup.add(new la(h).to(l,r/3).easing(os.Quadratic.Out).onUpdate(v).start())}return this}return Object.assign({},s.position,{lookAt:x()});function m(S){var T=S.x,N=S.y,C=S.z;T!==void 0&&(s.position.x=T),N!==void 0&&(s.position.y=N),C!==void 0&&(s.position.z=C)}function v(S){var T=new xr.Vector3(S.x,S.y,S.z);e.controls.enabled&&e.controls.target?e.controls.target=T:s.lookAt(T)}function x(){return Object.assign(new xr.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var a=new xr.Vector3(0,0,0),l=Math.max.apply(Math,Cf(Object.entries(t).map(function(S){var T=aAe(S,2),N=T[0],C=T[1];return Math.max.apply(Math,Cf(C.map(function(E){return Math.abs(a[N]-E)})))})))*2,u=(1-r*2/e.height)*s.fov,h=l/Math.atan(u*Math.PI/180),m=h/s.aspect,v=Math.max(h,m);if(v>0){var x=a.clone().sub(s.position).normalize().multiplyScalar(-v);this.cameraPosition(x,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new xr.Box3(new xr.Vector3(0,0,0),new xr.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,Cf(["x","y","z"].map(function(s){return tAe({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new xr.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new xr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new xr.Raycaster;return a.setFromCamera(s,e.camera),Object.assign({},a.ray.at(r,new xr.Vector3))},intersectingObjects:function(e,t,n){var r=new xr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new xr.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new xr.Scene,camera:new xr.PerspectiveCamera,clock:new xr.Clock,tweenGroup:new wy,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,a=n.useWebGPU,l=a===void 0?!1:a,u=n.rendererConfig,h=u===void 0?{}:u,m=n.extraRenderers,v=m===void 0?[]:m,x=n.waitForLoadComplete,S=x===void 0?!0:x;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new Qde(t.container),t.pointerPos=new xr.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(T){return t.container.addEventListener(T,function(N){if(T==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&N.type==="pointermove"&&(N.pressure>0||t.isPointerPressed)&&(N.pointerType==="mouse"||N.movementX===void 0||[N.movementX,N.movementY].some(function(O){return Math.abs(O)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var C=E(t.container);t.pointerPos.x=N.pageX-C.left,t.pointerPos.y=N.pageY-C.top}function E(O){var U=O.getBoundingClientRect(),I=window.pageXOffset||document.documentElement.scrollLeft,j=window.pageYOffset||document.documentElement.scrollTop;return{top:U.top+j,left:U.left+I}}},{passive:!0})}),t.container.addEventListener("pointerup",function(T){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){T.button===0&&t.onClick(t.hoverObj||null,T,t.intersection),T.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,T,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(T){t.onRightClick&&T.preventDefault()}),t.renderer=new(l?cO:xr.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},h)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=v,t.extraRenderers.forEach(function(T){T.domElement.style.position="absolute",T.domElement.style.top="0px",T.domElement.style.pointerEvents="none",t.container.appendChild(T.domElement)}),t.postProcessingComposer=new rhe(t.renderer),t.postProcessingComposer.addPass(new she(t.scene,t.camera)),t.controls=new{trackball:dce,orbit:Nce,fly:Vce}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Cf(t.extraRenderers)).forEach(function(T){return T.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new xr.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!S,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Cf(e.extraRenderers)).forEach(function(S){return S.setSize(r,s)}),e.camera.aspect=r/s;var a=e.viewOffset.slice(0,2);a.some(function(S){return S})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(Cf(a),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var l,u=e.width,h=e.height,m=e.viewOffset.slice(0,2);m.some(function(S){return S})?(l=e.camera).setViewOffset.apply(l,[u,h].concat(Cf(m),[u,h])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new xr.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var v=O0(e.backgroundColor).alpha;v===void 0&&(v=1),e.renderer.setClearColor(new xr.Color(Ohe(1,e.backgroundColor)),v)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new xr.TextureLoader().load(e.backgroundImageUrl,function(S){S.colorSpace=xr.SRGBColorSpace,e.skysphere.material=new xr.MeshBasicMaterial({map:S,side:xr.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&x()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&x())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(S){return e.scene.remove(S)}),e.lights.forEach(function(S){return e.scene.add(S)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(S){return e.scene.remove(S)}),e.objects.forEach(function(S){return e.scene.add(S)}));function x(){e.loadComplete=e.scene.visible=!0}}});function uAe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var cAe=`.scene-container .clickable { +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aAe(i,e){return Jde(i)||iAe(i,e)||fI(i,e)||rAe()}function Cf(i){return eAe(i)||nAe(i)||fI(i)||sAe()}function oAe(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function lAe(i){var e=oAe(i,"string");return typeof e=="symbol"?e:e+""}function fI(i,e){if(i){if(typeof i=="string")return yT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?yT(i,e):void 0}}var xr=window.THREE?window.THREE:{WebGLRenderer:FH,Scene:ZT,PerspectiveCamera:va,Raycaster:Jz,SRGBColorSpace:bn,TextureLoader:oM,Vector2:bt,Vector3:pe,Box3:Oc,Color:cn,Mesh:Oi,SphereGeometry:bu,MeshBasicMaterial:cd,BackSide:or,Clock:hD},dI=_s({props:{width:{default:window.innerWidth,onChange:function(e,t,n){isNaN(e)&&(t.width=n)}},height:{default:window.innerHeight,onChange:function(e,t,n){isNaN(e)&&(t.height=n)}},viewOffset:{default:[0,0]},backgroundColor:{default:"#000011"},backgroundImageUrl:{},onBackgroundImageLoaded:{},showNavInfo:{default:!0},skyRadius:{default:5e4},objects:{default:[]},lights:{default:[]},enablePointerInteraction:{default:!0,onChange:function(e,t){t.hoverObj=null,t.tooltip&&t.tooltip.content(null)},triggerUpdate:!1},pointerRaycasterThrottleMs:{default:50,triggerUpdate:!1},lineHoverPrecision:{default:1,triggerUpdate:!1},pointsHoverPrecision:{default:1,triggerUpdate:!1},hoverOrderComparator:{triggerUpdate:!1},hoverFilter:{default:function(){return!0},triggerUpdate:!1},tooltipContent:{triggerUpdate:!1},hoverDuringDrag:{default:!1,triggerUpdate:!1},clickAfterDrag:{default:!1,triggerUpdate:!1},onHover:{default:function(){},triggerUpdate:!1},onClick:{default:function(){},triggerUpdate:!1},onRightClick:{triggerUpdate:!1}},methods:{tick:function(e){if(e.initialised){e.controls.enabled&&e.controls.update&&e.controls.update(Math.min(1,e.clock.getDelta())),e.postProcessingComposer?e.postProcessingComposer.render():e.renderer.render(e.scene,e.camera),e.extraRenderers.forEach(function(a){return a.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,l){return e.hoverOrderComparator(a.object,l.object)});var s=r.find(function(a){return e.hoverFilter(a.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Lt(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var a=t,l=n||{x:0,y:0,z:0};if(!r)m(a),v(l);else{var u=Object.assign({},s.position),h=x();e.tweenGroup.add(new la(u).to(a,r).easing(os.Quadratic.Out).onUpdate(m).start()),e.tweenGroup.add(new la(h).to(l,r/3).easing(os.Quadratic.Out).onUpdate(v).start())}return this}return Object.assign({},s.position,{lookAt:x()});function m(S){var T=S.x,N=S.y,C=S.z;T!==void 0&&(s.position.x=T),N!==void 0&&(s.position.y=N),C!==void 0&&(s.position.z=C)}function v(S){var T=new xr.Vector3(S.x,S.y,S.z);e.controls.enabled&&e.controls.target?e.controls.target=T:s.lookAt(T)}function x(){return Object.assign(new xr.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var a=new xr.Vector3(0,0,0),l=Math.max.apply(Math,Cf(Object.entries(t).map(function(S){var T=aAe(S,2),N=T[0],C=T[1];return Math.max.apply(Math,Cf(C.map(function(E){return Math.abs(a[N]-E)})))})))*2,u=(1-r*2/e.height)*s.fov,h=l/Math.atan(u*Math.PI/180),m=h/s.aspect,v=Math.max(h,m);if(v>0){var x=a.clone().sub(s.position).normalize().multiplyScalar(-v);this.cameraPosition(x,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new xr.Box3(new xr.Vector3(0,0,0),new xr.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,Cf(["x","y","z"].map(function(s){return tAe({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new xr.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new xr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new xr.Raycaster;return a.setFromCamera(s,e.camera),Object.assign({},a.ray.at(r,new xr.Vector3))},intersectingObjects:function(e,t,n){var r=new xr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new xr.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new xr.Scene,camera:new xr.PerspectiveCamera,clock:new xr.Clock,tweenGroup:new wy,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,a=n.useWebGPU,l=a===void 0?!1:a,u=n.rendererConfig,h=u===void 0?{}:u,m=n.extraRenderers,v=m===void 0?[]:m,x=n.waitForLoadComplete,S=x===void 0?!0:x;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new Qde(t.container),t.pointerPos=new xr.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(T){return t.container.addEventListener(T,function(N){if(T==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&N.type==="pointermove"&&(N.pressure>0||t.isPointerPressed)&&(N.pointerType==="mouse"||N.movementX===void 0||[N.movementX,N.movementY].some(function(O){return Math.abs(O)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var C=E(t.container);t.pointerPos.x=N.pageX-C.left,t.pointerPos.y=N.pageY-C.top}function E(O){var U=O.getBoundingClientRect(),I=window.pageXOffset||document.documentElement.scrollLeft,j=window.pageYOffset||document.documentElement.scrollTop;return{top:U.top+j,left:U.left+I}}},{passive:!0})}),t.container.addEventListener("pointerup",function(T){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){T.button===0&&t.onClick(t.hoverObj||null,T,t.intersection),T.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,T,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(T){t.onRightClick&&T.preventDefault()}),t.renderer=new(l?cO:xr.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},h)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=v,t.extraRenderers.forEach(function(T){T.domElement.style.position="absolute",T.domElement.style.top="0px",T.domElement.style.pointerEvents="none",t.container.appendChild(T.domElement)}),t.postProcessingComposer=new rhe(t.renderer),t.postProcessingComposer.addPass(new she(t.scene,t.camera)),t.controls=new{trackball:dce,orbit:Nce,fly:Vce}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Cf(t.extraRenderers)).forEach(function(T){return T.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new xr.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!S,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Cf(e.extraRenderers)).forEach(function(S){return S.setSize(r,s)}),e.camera.aspect=r/s;var a=e.viewOffset.slice(0,2);a.some(function(S){return S})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(Cf(a),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var l,u=e.width,h=e.height,m=e.viewOffset.slice(0,2);m.some(function(S){return S})?(l=e.camera).setViewOffset.apply(l,[u,h].concat(Cf(m),[u,h])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new xr.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var v=O0(e.backgroundColor).alpha;v===void 0&&(v=1),e.renderer.setClearColor(new xr.Color(Ohe(1,e.backgroundColor)),v)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new xr.TextureLoader().load(e.backgroundImageUrl,function(S){S.colorSpace=xr.SRGBColorSpace,e.skysphere.material=new xr.MeshBasicMaterial({map:S,side:xr.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&x()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&x())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(S){return e.scene.remove(S)}),e.lights.forEach(function(S){return e.scene.add(S)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(S){return e.scene.remove(S)}),e.objects.forEach(function(S){return e.scene.add(S)}));function x(){e.loadComplete=e.scene.visible=!0}}});function uAe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var cAe=`.scene-container .clickable { cursor: pointer; }`;uAe(cAe);function xT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1?l-1:0),h=1;h1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=a();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(u){return s[u]=+s[u]}),!n)l(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new la(r).to(s,n).easing(os.Cubic.InOut).onUpdate(l).start())}return this;function a(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(u){var h=u.lat,m=u.lng,v=u.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(h,m,v)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;slocalStorage.getItem("radio-theme")||"default"),[a,l]=re.useState([]),[u,h]=re.useState(null),[m,v]=re.useState([]),[x,S]=re.useState(!1),[T,N]=re.useState({}),[C,E]=re.useState([]),[O,U]=re.useState(""),[I,j]=re.useState(""),[z,G]=re.useState(""),[H,q]=re.useState([]),[V,Q]=re.useState(!1),[J,ne]=re.useState([]),[oe,ie]=re.useState(!1),[Z,te]=re.useState(!1),[de,Se]=re.useState(.5),[Te,ae]=re.useState(null),[Me,Ve]=re.useState(!1),[Ce,Fe]=re.useState(!1),et=re.useRef(void 0),He=re.useRef(void 0),Rt=re.useRef(O);re.useEffect(()=>{fetch("/api/radio/places").then(k=>k.json()).then(l).catch(console.error),fetch("/api/radio/guilds").then(k=>k.json()).then(k=>{if(E(k),k.length>0){U(k[0].id);const be=k[0].voiceChannels.find(Oe=>Oe.members>0)??k[0].voiceChannels[0];be&&j(be.id)}}).catch(console.error),fetch("/api/radio/favorites").then(k=>k.json()).then(ne).catch(console.error)},[]),re.useEffect(()=>{Rt.current=O},[O]),re.useEffect(()=>{i!=null&&i.guildId&&"playing"in i&&i.type!=="radio_voicestats"?N(k=>{if(i.playing)return{...k,[i.guildId]:i.playing};const be={...k};return delete be[i.guildId],be}):i!=null&&i.playing&&!(i!=null&&i.guildId)&&N(i.playing),i!=null&&i.favorites&&ne(i.favorites),i!=null&&i.volumes&&O&&i.volumes[O]!=null&&Se(i.volumes[O]),(i==null?void 0:i.volume)!=null&&(i==null?void 0:i.guildId)===O&&Se(i.volume),(i==null?void 0:i.type)==="radio_voicestats"&&i.guildId===Rt.current&&ae({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})},[i,O]),re.useEffect(()=>{if(localStorage.setItem("radio-theme",r),t.current&&e.current){const be=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim();t.current.pointColor(()=>`rgba(${be}, 0.85)`).atmosphereColor(`rgba(${be}, 0.25)`)}},[r]);const Et=re.useRef(u);Et.current=u;const zt=re.useRef(oe);zt.current=oe;const Pt=re.useCallback(()=>{var be;const k=(be=t.current)==null?void 0:be.controls();k&&(k.autoRotate=!1),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{var pe;if(Et.current||zt.current)return;const Oe=(pe=t.current)==null?void 0:pe.controls();Oe&&(Oe.autoRotate=!0)},5e3)},[]);re.useEffect(()=>{var be;const k=(be=t.current)==null?void 0:be.controls();k&&(u||oe?(k.autoRotate=!1,n.current&&clearTimeout(n.current)):k.autoRotate=!0)},[u,oe]);const We=re.useRef(void 0);We.current=k=>{h(k),ie(!1),S(!0),v([]),Pt(),t.current&&t.current.pointOfView({lat:k.geo[1],lng:k.geo[0],altitude:.4},800),fetch(`/api/radio/place/${k.id}/channels`).then(be=>be.json()).then(be=>{v(be),S(!1)}).catch(()=>S(!1))},re.useEffect(()=>{const k=e.current;if(!k)return;k.clientWidth>0&&k.clientHeight>0&&Fe(!0);const be=new ResizeObserver(Oe=>{for(const pe of Oe){const{width:le,height:Ne}=pe.contentRect;le>0&&Ne>0&&Fe(!0)}});return be.observe(k),()=>be.disconnect()},[]),re.useEffect(()=>{if(!e.current||a.length===0)return;const k=e.current.clientWidth,be=e.current.clientHeight;if(t.current){t.current.pointsData(a),k>0&&be>0&&t.current.width(k).height(be);return}if(k===0||be===0)return;const pe=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim()||"230, 126, 34",le=new wAe(e.current).backgroundColor("rgba(0,0,0,0)").atmosphereColor(`rgba(${pe}, 0.25)`).atmosphereAltitude(.12).globeImageUrl("/nasa-blue-marble.jpg").pointsData(a).pointLat(Bt=>Bt.geo[1]).pointLng(Bt=>Bt.geo[0]).pointColor(()=>`rgba(${pe}, 0.85)`).pointRadius(Bt=>Math.max(.12,Math.min(.45,.06+(Bt.size??1)*.005))).pointAltitude(.001).pointResolution(24).pointLabel(Bt=>`

${Bt.title}
${Bt.country}
`).onPointClick(Bt=>{var ct;return(ct=We.current)==null?void 0:ct.call(We,Bt)}).width(e.current.clientWidth).height(e.current.clientHeight);le.renderer().setPixelRatio(window.devicePixelRatio),le.pointOfView({lat:48,lng:10,altitude:qS});const Ne=le.controls();Ne&&(Ne.autoRotate=!0,Ne.autoRotateSpeed=.3);let De=qS;const Je=()=>{const ct=le.pointOfView().altitude;if(Math.abs(ct-De)/De<.05)return;De=ct;const jt=Math.sqrt(ct/qS);le.pointRadius(Jt=>Math.max(.12,Math.min(.45,.06+(Jt.size??1)*.005))*Math.max(.15,Math.min(2.5,jt)))};Ne.addEventListener("change",Je),t.current=le;const we=e.current,Ue=()=>Pt();we.addEventListener("mousedown",Ue),we.addEventListener("touchstart",Ue),we.addEventListener("wheel",Ue);const ut=()=>{if(e.current&&t.current){const Bt=e.current.clientWidth,ct=e.current.clientHeight;Bt>0&&ct>0&&t.current.width(Bt).height(ct)}};window.addEventListener("resize",ut);const Dt=new ResizeObserver(()=>ut());return Dt.observe(we),()=>{Ne.removeEventListener("change",Je),we.removeEventListener("mousedown",Ue),we.removeEventListener("touchstart",Ue),we.removeEventListener("wheel",Ue),window.removeEventListener("resize",ut),Dt.disconnect()}},[a,Pt,Ce]);const ft=re.useCallback(async(k,be,Oe,pe)=>{if(!(!O||!I)){te(!0);try{(await(await fetch("/api/radio/play",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,voiceChannelId:I,stationId:k,stationName:be,placeName:Oe??(u==null?void 0:u.title)??"",country:pe??(u==null?void 0:u.country)??""})})).json()).ok&&(N(De=>{var Je,we;return{...De,[O]:{stationId:k,stationName:be,placeName:Oe??(u==null?void 0:u.title)??"",country:pe??(u==null?void 0:u.country)??"",startedAt:new Date().toISOString(),channelName:((we=(Je=C.find(Ue=>Ue.id===O))==null?void 0:Je.voiceChannels.find(Ue=>Ue.id===I))==null?void 0:we.name)??""}}}),Pt())}catch(le){console.error(le)}te(!1)}},[O,I,u,C]),fe=re.useCallback(async()=>{O&&(await fetch("/api/radio/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O})}),N(k=>{const be={...k};return delete be[O],be}))},[O]),Wt=re.useCallback(k=>{if(G(k),et.current&&clearTimeout(et.current),!k.trim()){q([]),Q(!1);return}et.current=setTimeout(async()=>{try{const Oe=await(await fetch(`/api/radio/search?q=${encodeURIComponent(k)}`)).json();q(Oe),Q(!0)}catch{q([])}},350)},[]),yt=re.useCallback(k=>{var be,Oe,pe;if(Q(!1),G(""),q([]),k.type==="channel"){const le=(be=k.url.match(/\/listen\/[^/]+\/([^/]+)/))==null?void 0:be[1];le&&ft(le,k.title,k.subtitle,"")}else if(k.type==="place"){const le=(Oe=k.url.match(/\/visit\/[^/]+\/([^/]+)/))==null?void 0:Oe[1],Ne=a.find(De=>De.id===le);Ne&&((pe=We.current)==null||pe.call(We,Ne))}},[a,ft]),Gt=re.useCallback(async(k,be)=>{try{const pe=await(await fetch("/api/radio/favorites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stationId:k,stationName:be,placeName:(u==null?void 0:u.title)??"",country:(u==null?void 0:u.country)??"",placeId:(u==null?void 0:u.id)??""})})).json();pe.favorites&&ne(pe.favorites)}catch{}},[u]),_t=re.useCallback(k=>{Se(k),O&&(He.current&&clearTimeout(He.current),He.current=setTimeout(()=>{fetch("/api/radio/volume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,volume:k})}).catch(console.error)},100))},[O]),Xt=k=>J.some(be=>be.stationId===k),pt=O?T[O]:null,Ae=C.find(k=>k.id===O);return P.jsxs("div",{className:"radio-container","data-theme":r,children:[P.jsxs("header",{className:"radio-topbar",children:[P.jsxs("div",{className:"radio-topbar-left",children:[P.jsx("span",{className:"radio-topbar-logo",children:"🌍"}),P.jsx("span",{className:"radio-topbar-title",children:"World Radio"}),C.length>1&&P.jsx("select",{className:"radio-sel",value:O,onChange:k=>{U(k.target.value);const be=C.find(pe=>pe.id===k.target.value),Oe=(be==null?void 0:be.voiceChannels.find(pe=>pe.members>0))??(be==null?void 0:be.voiceChannels[0]);j((Oe==null?void 0:Oe.id)??"")},children:C.map(k=>P.jsx("option",{value:k.id,children:k.name},k.id))}),P.jsxs("select",{className:"radio-sel",value:I,onChange:k=>j(k.target.value),children:[P.jsx("option",{value:"",children:"Voice Channel..."}),Ae==null?void 0:Ae.voiceChannels.map(k=>P.jsxs("option",{value:k.id,children:["🔊"," ",k.name,k.members>0?` (${k.members})`:""]},k.id))]})]}),pt&&P.jsxs("div",{className:"radio-topbar-np",children:[P.jsxs("div",{className:"radio-eq radio-eq-np",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),P.jsxs("div",{className:"radio-np-info",children:[P.jsx("span",{className:"radio-np-name",children:pt.stationName}),P.jsxs("span",{className:"radio-np-loc",children:[pt.placeName,pt.country?`, ${pt.country}`:""]})]})]}),P.jsxs("div",{className:"radio-topbar-right",children:[pt&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"radio-volume",children:[P.jsx("span",{className:"radio-volume-icon",children:de===0?"🔇":de<.4?"🔉":"🔊"}),P.jsx("input",{type:"range",className:"radio-volume-slider",min:0,max:1,step:.01,value:de,onChange:k=>_t(Number(k.target.value))}),P.jsxs("span",{className:"radio-volume-val",children:[Math.round(de*100),"%"]})]}),P.jsxs("div",{className:"radio-conn",onClick:()=>Ve(!0),title:"Verbindungsdetails",children:[P.jsx("span",{className:"radio-conn-dot"}),"Verbunden",(Te==null?void 0:Te.voicePing)!=null&&P.jsxs("span",{className:"radio-conn-ping",children:[Te.voicePing,"ms"]})]}),P.jsxs("button",{className:"radio-topbar-stop",onClick:fe,children:["⏹"," Stop"]})]}),P.jsx("div",{className:"radio-theme-inline",children:TAe.map(k=>P.jsx("div",{className:`radio-theme-dot ${r===k.id?"active":""}`,style:{background:k.color},title:k.label,onClick:()=>s(k.id)},k.id))})]})]}),P.jsxs("div",{className:"radio-globe-wrap",children:[P.jsx("div",{className:"radio-globe",ref:e}),P.jsxs("div",{className:"radio-search",children:[P.jsxs("div",{className:"radio-search-wrap",children:[P.jsx("span",{className:"radio-search-icon",children:"🔍"}),P.jsx("input",{className:"radio-search-input",type:"text",placeholder:"Sender oder Stadt suchen...",value:z,onChange:k=>Wt(k.target.value),onFocus:()=>{H.length&&Q(!0)}}),z&&P.jsx("button",{className:"radio-search-clear",onClick:()=>{G(""),q([]),Q(!1)},children:"✕"})]}),V&&H.length>0&&P.jsx("div",{className:"radio-search-results",children:H.slice(0,12).map(k=>P.jsxs("button",{className:"radio-search-result",onClick:()=>yt(k),children:[P.jsx("span",{className:"radio-search-result-icon",children:k.type==="channel"?"📻":k.type==="place"?"📍":"🌍"}),P.jsxs("div",{className:"radio-search-result-text",children:[P.jsx("span",{className:"radio-search-result-title",children:k.title}),P.jsx("span",{className:"radio-search-result-sub",children:k.subtitle})]})]},k.id+k.url))})]}),!u&&!oe&&P.jsxs("button",{className:"radio-fab",onClick:()=>{ie(!0),h(null)},title:"Favoriten",children:["⭐",J.length>0&&P.jsx("span",{className:"radio-fab-badge",children:J.length})]}),oe&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("h3",{children:["⭐"," Favoriten"]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>ie(!1),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:J.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Noch keine Favoriten"}):J.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.stationId?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.stationName}),P.jsxs("span",{className:"radio-station-loc",children:[k.placeName,", ",k.country]})]}),P.jsxs("div",{className:"radio-station-btns",children:[P.jsx("button",{className:"radio-btn-play",onClick:()=>ft(k.stationId,k.stationName,k.placeName,k.country),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:"radio-btn-fav active",onClick:()=>Gt(k.stationId,k.stationName),children:"★"})]})]},k.stationId))})]}),u&&!oe&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("div",{children:[P.jsx("h3",{children:u.title}),P.jsx("span",{className:"radio-panel-sub",children:u.country})]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>h(null),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:x?P.jsxs("div",{className:"radio-panel-loading",children:[P.jsx("div",{className:"radio-spinner"}),"Sender werden geladen..."]}):m.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Keine Sender gefunden"}):m.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.id?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.title}),(pt==null?void 0:pt.stationId)===k.id&&P.jsxs("span",{className:"radio-station-live",children:[P.jsxs("span",{className:"radio-eq",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),"Live"]})]}),P.jsxs("div",{className:"radio-station-btns",children:[(pt==null?void 0:pt.stationId)===k.id?P.jsx("button",{className:"radio-btn-stop",onClick:fe,children:"⏹"}):P.jsx("button",{className:"radio-btn-play",onClick:()=>ft(k.id,k.title),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:`radio-btn-fav ${Xt(k.id)?"active":""}`,onClick:()=>Gt(k.id,k.title),children:Xt(k.id)?"★":"☆"})]})]},k.id))})]}),P.jsxs("div",{className:"radio-counter",children:["📻"," ",a.length.toLocaleString("de-DE")," Sender weltweit"]}),P.jsx("a",{className:"radio-attribution",href:"https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/",target:"_blank",rel:"noreferrer",children:"Imagery © NASA Blue Marble"})]}),Me&&(()=>{const k=Te!=null&&Te.connectedSince?Math.floor((Date.now()-new Date(Te.connectedSince).getTime())/1e3):0,be=Math.floor(k/3600),Oe=Math.floor(k%3600/60),pe=k%60,le=be>0?`${be}h ${String(Oe).padStart(2,"0")}m ${String(pe).padStart(2,"0")}s`:Oe>0?`${Oe}m ${String(pe).padStart(2,"0")}s`:`${pe}s`,Ne=De=>De==null?"var(--text-faint)":De<80?"var(--success)":De<150?"#f0a830":"#e04040";return P.jsx("div",{className:"radio-modal-overlay",onClick:()=>Ve(!1),children:P.jsxs("div",{className:"radio-modal",onClick:De=>De.stopPropagation(),children:[P.jsxs("div",{className:"radio-modal-header",children:[P.jsx("span",{children:"📡"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"radio-modal-close",onClick:()=>Ve(!1),children:"✕"})]}),P.jsxs("div",{className:"radio-modal-body",children:[P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Voice Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:Ne((Te==null?void 0:Te.voicePing)??null)}}),(Te==null?void 0:Te.voicePing)!=null?`${Te.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Gateway Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:Ne((Te==null?void 0:Te.gatewayPing)??null)}}),Te&&Te.gatewayPing>=0?`${Te.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Status"}),P.jsx("span",{className:"radio-modal-value",style:{color:(Te==null?void 0:Te.status)==="ready"?"var(--success)":"#f0a830"},children:(Te==null?void 0:Te.status)==="ready"?"Verbunden":(Te==null?void 0:Te.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Kanal"}),P.jsx("span",{className:"radio-modal-value",children:(Te==null?void 0:Te.channelName)||"---"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Verbunden seit"}),P.jsx("span",{className:"radio-modal-value",children:le||"---"})]})]})]})})})()]})}function EAe(i,e,t=365){const n=new Date(Date.now()+t*24*60*60*1e3).toUTCString();document.cookie=`${encodeURIComponent(i)}=${encodeURIComponent(e)}; expires=${n}; path=/; SameSite=Lax`}function CAe(i){const e=`${encodeURIComponent(i)}=`,t=document.cookie.split(";");for(const n of t){const r=n.trim();if(r.startsWith(e))return decodeURIComponent(r.slice(e.length))}return null}const ca="/api/soundboard";async function NAe(i,e,t,n){const r=new URL(`${ca}/sounds`,window.location.origin);i&&r.searchParams.set("q",i),e!==void 0&&r.searchParams.set("folder",e),r.searchParams.set("fuzzy","0");const s=await fetch(r.toString());if(!s.ok)throw new Error("Fehler beim Laden der Sounds");return s.json()}async function RAe(){const i=await fetch(`${ca}/analytics`);if(!i.ok)throw new Error("Fehler beim Laden der Analytics");return i.json()}async function DAe(){const i=await fetch(`${ca}/categories`,{credentials:"include"});if(!i.ok)throw new Error("Fehler beim Laden der Kategorien");return i.json()}async function PAe(){const i=await fetch(`${ca}/channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channels");return i.json()}async function LAe(){const i=await fetch(`${ca}/selected-channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channel-Auswahl");const e=await i.json();return(e==null?void 0:e.selected)||{}}async function UAe(i,e){if(!(await fetch(`${ca}/selected-channel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Channel-Auswahl setzen fehlgeschlagen")}async function BAe(i,e,t,n,r){const s=await fetch(`${ca}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({soundName:i,guildId:e,channelId:t,volume:n,relativePath:r})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error((a==null?void 0:a.error)||"Play fehlgeschlagen")}}async function OAe(i,e,t,n,r){const s=await fetch(`${ca}/play-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,guildId:e,channelId:t,volume:n,filename:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error((a==null?void 0:a.error)||"Play-URL fehlgeschlagen");return a}async function IAe(i,e){const t=await fetch(`${ca}/download-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,filename:e})}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error((n==null?void 0:n.error)||"Download fehlgeschlagen");return n}async function FAe(i,e){if(!(await fetch(`${ca}/party/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Partymode Start fehlgeschlagen")}async function kAe(i){if(!(await fetch(`${ca}/party/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i})})).ok)throw new Error("Partymode Stop fehlgeschlagen")}async function g7(i,e){const t=await fetch(`${ca}/volume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,volume:e})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error((n==null?void 0:n.error)||"Volume aendern fehlgeschlagen")}}async function zAe(i){const e=new URL(`${ca}/volume`,window.location.origin);e.searchParams.set("guildId",i);const t=await fetch(e.toString());if(!t.ok)throw new Error("Fehler beim Laden der Lautstaerke");const n=await t.json();return typeof(n==null?void 0:n.volume)=="number"?n.volume:1}async function GAe(i){if(!(await fetch(`${ca}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}function qAe(i,e,t){return new Promise((n,r)=>{const s=new FormData;s.append("files",i),e&&s.append("customName",e);const a=new XMLHttpRequest;a.open("POST",`${ca}/upload`),a.upload.onprogress=l=>{l.lengthComputable&&t(Math.round(l.loaded/l.total*100))},a.onload=()=>{var l,u;if(a.status===200)try{const h=JSON.parse(a.responseText);n(((u=(l=h.files)==null?void 0:l[0])==null?void 0:u.name)??i.name)}catch{n(i.name)}else try{r(new Error(JSON.parse(a.responseText).error))}catch{r(new Error(`HTTP ${a.status}`))}},a.onerror=()=>r(new Error("Netzwerkfehler")),a.send(s)})}const VAe=[{id:"default",color:"#5865f2",label:"Discord"},{id:"purple",color:"#9b59b6",label:"Midnight"},{id:"forest",color:"#2ecc71",label:"Forest"},{id:"sunset",color:"#e67e22",label:"Sunset"},{id:"ocean",color:"#3498db",label:"Ocean"}],v7=["#3b82f6","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#06b6d4","#ef4444","#a855f7","#84cc16","#d946ef","#0ea5e9","#f43f5e","#10b981"];function jAe({data:i,isAdmin:e}){var qe,qt,Qt;const[t,n]=re.useState([]),[r,s]=re.useState(0),[a,l]=re.useState([]),[u,h]=re.useState([]),[m,v]=re.useState({totalSounds:0,totalPlays:0,mostPlayed:[]}),[x,S]=re.useState("all"),[T,N]=re.useState(""),[C,E]=re.useState(""),[O,U]=re.useState(""),[I,j]=re.useState(!1),[z,G]=re.useState(null),[H,q]=re.useState([]),[V,Q]=re.useState(""),J=re.useRef(""),[ne,oe]=re.useState(!1),[ie,Z]=re.useState(1),[te,de]=re.useState(""),[Se,Te]=re.useState({}),[ae,Me]=re.useState(()=>localStorage.getItem("jb-theme")||"default"),[Ve,Ce]=re.useState(()=>parseInt(localStorage.getItem("jb-card-size")||"110")),[Fe,et]=re.useState(!1),[He,Rt]=re.useState([]),Et=re.useRef(!1),zt=re.useRef(void 0),Pt=e??!1,[We,ft]=re.useState(!1),[fe,Wt]=re.useState([]),[yt,Gt]=re.useState(!1),_t=re.useRef(0);re.useRef(void 0);const[Xt,pt]=re.useState([]),[Ae,k]=re.useState(0),[be,Oe]=re.useState(""),[pe,le]=re.useState("naming"),[Ne,De]=re.useState(0),[Je,we]=re.useState(null),[Ue,ut]=re.useState(!1),[Dt,Bt]=re.useState(null),[ct,jt]=re.useState(""),[Jt,In]=re.useState(null),[ge,Ot]=re.useState(0);re.useEffect(()=>{Et.current=Fe},[Fe]),re.useEffect(()=>{J.current=V},[V]),re.useEffect(()=>{const he=sn=>{var Tn;Array.from(((Tn=sn.dataTransfer)==null?void 0:Tn.items)??[]).some(Rn=>Rn.kind==="file")&&(_t.current++,ft(!0))},X=()=>{_t.current=Math.max(0,_t.current-1),_t.current===0&&ft(!1)},tt=sn=>sn.preventDefault(),en=sn=>{var Rn;sn.preventDefault(),_t.current=0,ft(!1);const Tn=Array.from(((Rn=sn.dataTransfer)==null?void 0:Rn.files)??[]).filter(xi=>/\.(mp3|wav)$/i.test(xi.name));Tn.length&&xt(Tn)};return window.addEventListener("dragenter",he),window.addEventListener("dragleave",X),window.addEventListener("dragover",tt),window.addEventListener("drop",en),()=>{window.removeEventListener("dragenter",he),window.removeEventListener("dragleave",X),window.removeEventListener("dragover",tt),window.removeEventListener("drop",en)}},[Pt]);const ot=re.useCallback((he,X="info")=>{Bt({msg:he,type:X}),setTimeout(()=>Bt(null),3e3)},[]);re.useCallback(he=>he.relativePath??he.fileName,[]);const Tt=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","music.youtube.com","instagram.com","www.instagram.com"],Ht=re.useCallback(he=>{const X=he.trim();return!X||/^https?:\/\//i.test(X)?X:"https://"+X},[]),Yt=re.useCallback(he=>{try{const X=new URL(Ht(he)),tt=X.hostname.toLowerCase();return!!(X.pathname.toLowerCase().endsWith(".mp3")||Tt.some(en=>tt===en||tt.endsWith("."+en)))}catch{return!1}},[Ht]),pn=re.useCallback(he=>{try{const X=new URL(Ht(he)),tt=X.hostname.toLowerCase();return tt.includes("youtube")||tt==="youtu.be"?"youtube":tt.includes("instagram")?"instagram":X.pathname.toLowerCase().endsWith(".mp3")?"mp3":null}catch{return null}},[Ht]),$e=V?V.split(":")[0]:"",St=V?V.split(":")[1]:"",Kt=re.useMemo(()=>H.find(he=>`${he.guildId}:${he.channelId}`===V),[H,V]);re.useEffect(()=>{const he=()=>{const tt=new Date,en=String(tt.getHours()).padStart(2,"0"),sn=String(tt.getMinutes()).padStart(2,"0"),Tn=String(tt.getSeconds()).padStart(2,"0");jt(`${en}:${sn}:${Tn}`)};he();const X=setInterval(he,1e3);return()=>clearInterval(X)},[]),re.useEffect(()=>{(async()=>{try{const[he,X]=await Promise.all([PAe(),LAe()]);if(q(he),he.length){const tt=he[0].guildId,en=X[tt],sn=en&&he.find(Tn=>Tn.guildId===tt&&Tn.channelId===en);Q(sn?`${tt}:${en}`:`${he[0].guildId}:${he[0].channelId}`)}}catch(he){ot((he==null?void 0:he.message)||"Channel-Fehler","error")}try{const he=await DAe();h(he.categories||[])}catch{}})()},[]),re.useEffect(()=>{localStorage.setItem("jb-theme",ae)},[ae]);const wn=re.useRef(null);re.useEffect(()=>{const he=wn.current;if(!he)return;he.style.setProperty("--card-size",Ve+"px");const X=Ve/110;he.style.setProperty("--card-emoji",Math.round(28*X)+"px"),he.style.setProperty("--card-font",Math.max(9,Math.round(11*X))+"px"),localStorage.setItem("jb-card-size",String(Ve))},[Ve]),re.useEffect(()=>{var he,X,tt,en,sn,Tn,Rn,xi;if(i){if(i.soundboard){const K=i.soundboard;Array.isArray(K.party)&&Rt(K.party);try{const hn=K.selected||{},Zt=(he=J.current)==null?void 0:he.split(":")[0];Zt&&hn[Zt]&&Q(`${Zt}:${hn[Zt]}`)}catch{}try{const hn=K.volumes||{},Zt=(X=J.current)==null?void 0:X.split(":")[0];Zt&&typeof hn[Zt]=="number"&&Z(hn[Zt])}catch{}try{const hn=K.nowplaying||{},Zt=(tt=J.current)==null?void 0:tt.split(":")[0];Zt&&typeof hn[Zt]=="string"&&de(hn[Zt])}catch{}try{const hn=K.voicestats||{},Zt=(en=J.current)==null?void 0:en.split(":")[0];Zt&&hn[Zt]&&we(hn[Zt])}catch{}}if(i.type==="soundboard_party")Rt(K=>{const hn=new Set(K);return i.active?hn.add(i.guildId):hn.delete(i.guildId),Array.from(hn)});else if(i.type==="soundboard_channel"){const K=(sn=J.current)==null?void 0:sn.split(":")[0];i.guildId===K&&Q(`${i.guildId}:${i.channelId}`)}else if(i.type==="soundboard_volume"){const K=(Tn=J.current)==null?void 0:Tn.split(":")[0];i.guildId===K&&typeof i.volume=="number"&&Z(i.volume)}else if(i.type==="soundboard_nowplaying"){const K=(Rn=J.current)==null?void 0:Rn.split(":")[0];i.guildId===K&&de(i.name||"")}else if(i.type==="soundboard_voicestats"){const K=(xi=J.current)==null?void 0:xi.split(":")[0];i.guildId===K&&we({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})}}},[i]),re.useEffect(()=>{et($e?He.includes($e):!1)},[V,He,$e]),re.useEffect(()=>{(async()=>{try{let he="__all__";x==="recent"?he="__recent__":T&&(he=T);const X=await NAe(C,he,void 0,!1);n(X.items),s(X.total),l(X.folders)}catch(he){ot((he==null?void 0:he.message)||"Sounds-Fehler","error")}})()},[x,T,C,ge,ot]),re.useEffect(()=>{qn()},[ge]),re.useEffect(()=>{const he=CAe("favs");if(he)try{Te(JSON.parse(he))}catch{}},[]),re.useEffect(()=>{try{EAe("favs",JSON.stringify(Se))}catch{}},[Se]),re.useEffect(()=>{V&&(async()=>{try{const he=await zAe($e);Z(he)}catch{}})()},[V]),re.useEffect(()=>{const he=()=>{oe(!1),In(null)};return document.addEventListener("click",he),()=>document.removeEventListener("click",he)},[]);async function qn(){try{const he=await RAe();v(he)}catch{}}async function Ze(he){if(!V)return ot("Bitte einen Voice-Channel auswaehlen","error");try{await BAe(he.name,$e,St,ie,he.relativePath),de(he.name),qn()}catch(X){ot((X==null?void 0:X.message)||"Play fehlgeschlagen","error")}}function dt(){var en;const he=Ht(O);if(!he)return ot("Bitte einen Link eingeben","error");if(!Yt(he))return ot("Nur YouTube, Instagram oder direkte MP3-Links","error");const X=pn(he);let tt="";if(X==="mp3")try{tt=((en=new URL(he).pathname.split("/").pop())==null?void 0:en.replace(/\.mp3$/i,""))??""}catch{}G({url:he,type:X,filename:tt,phase:"input"})}async function Vt(){if(z){G(he=>he?{...he,phase:"downloading"}:null);try{let he;const X=z.filename.trim()||void 0;V&&$e&&St?he=(await OAe(z.url,$e,St,ie,X)).saved:he=(await IAe(z.url,X)).saved,G(tt=>tt?{...tt,phase:"done",savedName:he}:null),U(""),Ot(tt=>tt+1),qn(),setTimeout(()=>G(null),2500)}catch(he){G(X=>X?{...X,phase:"error",error:(he==null?void 0:he.message)||"Fehler"}:null)}}}async function xt(he){if(!Pt){ot("Admin-Login erforderlich zum Hochladen","error");return}if(he.length===0)return;pt(he),k(0);const X=he[0].name.replace(/\.(mp3|wav)$/i,"");Oe(X),le("naming"),De(0)}async function A(){if(Xt.length===0)return;const he=Xt[Ae],X=be.trim()||he.name.replace(/\.(mp3|wav)$/i,"");le("uploading"),De(0);try{await qAe(he,X,tt=>De(tt)),le("done"),setTimeout(()=>{const tt=Ae+1;if(tten+1),qn(),ot(`${Xt.length} Sound${Xt.length>1?"s":""} hochgeladen`,"info")},800)}catch(tt){ot((tt==null?void 0:tt.message)||"Upload fehlgeschlagen","error"),pt([])}}function ee(){const he=Ae+1;if(he0&&(Ot(X=>X+1),qn())}async function Vn(){if(V){de("");try{await fetch(`${ca}/stop?guildId=${encodeURIComponent($e)}`,{method:"POST"})}catch{}}}async function Wn(){if(!lr.length||!V)return;const he=lr[Math.floor(Math.random()*lr.length)];Ze(he)}async function $n(){if(Fe){await Vn();try{await kAe($e)}catch{}}else{if(!V)return ot("Bitte einen Channel auswaehlen","error");try{await FAe($e,St)}catch{}}}async function dn(he){const X=`${he.guildId}:${he.channelId}`;Q(X),oe(!1);try{await UAe(he.guildId,he.channelId)}catch{}}function Fn(he){Te(X=>({...X,[he]:!X[he]}))}const lr=re.useMemo(()=>x==="favorites"?t.filter(he=>Se[he.relativePath??he.fileName]):t,[t,x,Se]),an=re.useMemo(()=>Object.values(Se).filter(Boolean).length,[Se]),mn=re.useMemo(()=>a.filter(he=>!["__all__","__recent__","__top3__"].includes(he.key)),[a]),Er=re.useMemo(()=>{const he={};return mn.forEach((X,tt)=>{he[X.key]=v7[tt%v7.length]}),he},[mn]),Wi=re.useMemo(()=>{const he=new Set,X=new Set;return lr.forEach((tt,en)=>{const sn=tt.name.charAt(0).toUpperCase();he.has(sn)||(he.add(sn),X.add(en))}),X},[lr]),No=re.useMemo(()=>{const he={};return H.forEach(X=>{he[X.guildName]||(he[X.guildName]=[]),he[X.guildName].push(X)}),he},[H]),ce=m.mostPlayed.slice(0,10),Ge=m.totalSounds||r,rt=ct.slice(0,5),it=ct.slice(5);return P.jsxs("div",{className:"sb-app","data-theme":ae,ref:wn,children:[Fe&&P.jsx("div",{className:"party-overlay active"}),P.jsxs("header",{className:"topbar",children:[P.jsxs("div",{className:"topbar-left",children:[P.jsx("div",{className:"sb-app-logo",children:P.jsx("span",{className:"material-icons",style:{fontSize:16,color:"white"},children:"music_note"})}),P.jsx("span",{className:"sb-app-title",children:"Soundboard"}),P.jsxs("div",{className:"channel-dropdown",onClick:he=>he.stopPropagation(),children:[P.jsxs("button",{className:`channel-btn ${ne?"open":""}`,onClick:()=>oe(!ne),children:[P.jsx("span",{className:"material-icons cb-icon",children:"headset"}),V&&P.jsx("span",{className:"channel-status"}),P.jsx("span",{className:"channel-label",children:Kt?`${Kt.channelName}${Kt.members?` (${Kt.members})`:""}`:"Channel..."}),P.jsx("span",{className:"material-icons chevron",children:"expand_more"})]}),ne&&P.jsxs("div",{className:"channel-menu visible",children:[Object.entries(No).map(([he,X])=>P.jsxs(FF.Fragment,{children:[P.jsx("div",{className:"channel-menu-header",children:he}),X.map(tt=>P.jsxs("div",{className:`channel-option ${`${tt.guildId}:${tt.channelId}`===V?"active":""}`,onClick:()=>dn(tt),children:[P.jsx("span",{className:"material-icons co-icon",children:"volume_up"}),tt.channelName,tt.members?` (${tt.members})`:""]},`${tt.guildId}:${tt.channelId}`))]},he)),H.length===0&&P.jsx("div",{className:"channel-option",style:{color:"var(--text-faint)",cursor:"default"},children:"Keine Channels verfuegbar"})]})]})]}),P.jsx("div",{className:"clock-wrap",children:P.jsxs("div",{className:"clock",children:[rt,P.jsx("span",{className:"clock-seconds",children:it})]})}),P.jsxs("div",{className:"topbar-right",children:[te&&P.jsxs("div",{className:"now-playing",children:[P.jsxs("div",{className:"np-waves active",children:[P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"})]}),P.jsx("span",{className:"np-label",children:"Last Played:"})," ",P.jsx("span",{className:"np-name",children:te})]}),V&&P.jsxs("div",{className:"connection",onClick:()=>ut(!0),style:{cursor:"pointer"},title:"Verbindungsdetails",children:[P.jsx("span",{className:"conn-dot"}),"Verbunden",(Je==null?void 0:Je.voicePing)!=null&&P.jsxs("span",{className:"conn-ping",children:[Je.voicePing,"ms"]})]})]})]}),P.jsxs("div",{className:"toolbar",children:[P.jsxs("div",{className:"cat-tabs",children:[P.jsxs("button",{className:`cat-tab ${x==="all"?"active":""}`,onClick:()=>{S("all"),N("")},children:["Alle",P.jsx("span",{className:"tab-count",children:r})]}),P.jsx("button",{className:`cat-tab ${x==="recent"?"active":""}`,onClick:()=>{S("recent"),N("")},children:"Neu hinzugefuegt"}),P.jsxs("button",{className:`cat-tab ${x==="favorites"?"active":""}`,onClick:()=>{S("favorites"),N("")},children:["Favoriten",an>0&&P.jsx("span",{className:"tab-count",children:an})]})]}),P.jsxs("div",{className:"search-wrap",children:[P.jsx("span",{className:"material-icons search-icon",children:"search"}),P.jsx("input",{className:"search-input",type:"text",placeholder:"Suchen...",value:C,onChange:he=>E(he.target.value)}),C&&P.jsx("button",{className:"search-clear",onClick:()=>E(""),children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsxs("div",{className:"url-import-wrap",children:[P.jsx("span",{className:"material-icons url-import-icon",children:pn(O)==="youtube"?"smart_display":pn(O)==="instagram"?"photo_camera":"link"}),P.jsx("input",{className:"url-import-input",type:"text",placeholder:"YouTube / Instagram / MP3-Link...",value:O,onChange:he=>U(he.target.value),onKeyDown:he=>{he.key==="Enter"&&dt()}}),O&&P.jsx("span",{className:`url-import-tag ${Yt(O)?"valid":"invalid"}`,children:pn(O)==="youtube"?"YT":pn(O)==="instagram"?"IG":pn(O)==="mp3"?"MP3":"?"}),P.jsx("button",{className:"url-import-btn",onClick:()=>{dt()},disabled:I||!!O&&!Yt(O),title:"Sound herunterladen",children:I?"Laedt...":"Download"})]}),P.jsx("div",{className:"toolbar-spacer"}),P.jsxs("div",{className:"volume-control",children:[P.jsx("span",{className:"material-icons vol-icon",onClick:()=>{const he=ie>0?0:.5;Z(he),$e&&g7($e,he).catch(()=>{})},children:ie===0?"volume_off":ie<.5?"volume_down":"volume_up"}),P.jsx("input",{type:"range",className:"vol-slider",min:0,max:1,step:.01,value:ie,onChange:he=>{const X=parseFloat(he.target.value);Z(X),$e&&(zt.current&&clearTimeout(zt.current),zt.current=setTimeout(()=>{g7($e,X).catch(()=>{})},120))},style:{"--vol":`${Math.round(ie*100)}%`}}),P.jsxs("span",{className:"vol-pct",children:[Math.round(ie*100),"%"]})]}),P.jsxs("button",{className:"tb-btn random",onClick:Wn,title:"Zufaelliger Sound",children:[P.jsx("span",{className:"material-icons tb-icon",children:"shuffle"}),"Random"]}),P.jsxs("button",{className:`tb-btn party ${Fe?"active":""}`,onClick:$n,title:"Party Mode",children:[P.jsx("span",{className:"material-icons tb-icon",children:Fe?"celebration":"auto_awesome"}),Fe?"Party!":"Party"]}),P.jsxs("button",{className:"tb-btn stop",onClick:Vn,title:"Alle stoppen",children:[P.jsx("span",{className:"material-icons tb-icon",children:"stop"}),"Stop"]}),P.jsxs("div",{className:"size-control",title:"Button-Groesse",children:[P.jsx("span",{className:"material-icons sc-icon",children:"grid_view"}),P.jsx("input",{type:"range",className:"size-slider",min:80,max:160,value:Ve,onChange:he=>Ce(parseInt(he.target.value))})]}),P.jsx("div",{className:"theme-selector",children:VAe.map(he=>P.jsx("div",{className:`theme-dot ${ae===he.id?"active":""}`,style:{background:he.color},title:he.label,onClick:()=>Me(he.id)},he.id))})]}),P.jsxs("div",{className:"analytics-strip",children:[P.jsxs("div",{className:"analytics-card",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"library_music"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Sounds gesamt"}),P.jsx("strong",{className:"analytics-value",children:Ge})]})]}),P.jsxs("div",{className:"analytics-card analytics-wide",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"leaderboard"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Most Played"}),P.jsx("div",{className:"analytics-top-list",children:ce.length===0?P.jsx("span",{className:"analytics-muted",children:"Noch keine Plays"}):ce.map((he,X)=>P.jsxs("span",{className:"analytics-chip",children:[X+1,". ",he.name," (",he.count,")"]},he.relativePath))})]})]})]}),x==="all"&&mn.length>0&&P.jsx("div",{className:"category-strip",children:mn.map(he=>{const X=Er[he.key]||"#888",tt=T===he.key;return P.jsxs("button",{className:`cat-chip ${tt?"active":""}`,onClick:()=>N(tt?"":he.key),style:tt?{borderColor:X,color:X}:void 0,children:[P.jsx("span",{className:"cat-dot",style:{background:X}}),he.name.replace(/\s*\(\d+\)\s*$/,""),P.jsx("span",{className:"cat-count",children:he.count})]},he.key)})}),P.jsx("main",{className:"main",children:lr.length===0?P.jsxs("div",{className:"empty-state visible",children:[P.jsx("div",{className:"empty-emoji",children:x==="favorites"?"⭐":"🔇"}),P.jsx("div",{className:"empty-title",children:x==="favorites"?"Noch keine Favoriten":C?`Kein Sound fuer "${C}" gefunden`:"Keine Sounds vorhanden"}),P.jsx("div",{className:"empty-desc",children:x==="favorites"?"Klick den Stern auf einem Sound!":"Hier gibt's noch nichts zu hoeren."})]}):P.jsx("div",{className:"sound-grid",children:lr.map((he,X)=>{var hn;const tt=he.relativePath??he.fileName,en=!!Se[tt],sn=te===he.name,Tn=he.isRecent||((hn=he.badges)==null?void 0:hn.includes("new")),Rn=he.name.charAt(0).toUpperCase(),xi=Wi.has(X),K=he.folder&&Er[he.folder]||"var(--accent)";return P.jsxs("div",{className:`sound-card ${sn?"playing":""} ${xi?"has-initial":""}`,style:{animationDelay:`${Math.min(X*20,400)}ms`},onClick:Zt=>{const gr=Zt.currentTarget,ui=gr.getBoundingClientRect(),vr=document.createElement("div");vr.className="ripple";const Ps=Math.max(ui.width,ui.height);vr.style.width=vr.style.height=Ps+"px",vr.style.left=Zt.clientX-ui.left-Ps/2+"px",vr.style.top=Zt.clientY-ui.top-Ps/2+"px",gr.appendChild(vr),setTimeout(()=>vr.remove(),500),Ze(he)},onContextMenu:Zt=>{Zt.preventDefault(),Zt.stopPropagation(),In({x:Math.min(Zt.clientX,window.innerWidth-170),y:Math.min(Zt.clientY,window.innerHeight-140),sound:he})},title:`${he.name}${he.folder?` (${he.folder})`:""}`,children:[Tn&&P.jsx("span",{className:"new-badge",children:"NEU"}),P.jsx("span",{className:`fav-star ${en?"active":""}`,onClick:Zt=>{Zt.stopPropagation(),Fn(tt)},children:P.jsx("span",{className:"material-icons fav-icon",children:en?"star":"star_border"})}),xi&&P.jsx("span",{className:"sound-emoji",style:{color:K},children:Rn}),P.jsx("span",{className:"sound-name",children:he.name}),he.folder&&P.jsx("span",{className:"sound-duration",children:he.folder}),P.jsxs("div",{className:"playing-indicator",children:[P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"})]})]},tt)})})}),Jt&&P.jsxs("div",{className:"ctx-menu visible",style:{left:Jt.x,top:Jt.y},onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"ctx-item",onClick:()=>{Ze(Jt.sound),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"play_arrow"}),"Abspielen"]}),P.jsxs("div",{className:"ctx-item",onClick:()=>{Fn(Jt.sound.relativePath??Jt.sound.fileName),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:Se[Jt.sound.relativePath??Jt.sound.fileName]?"star":"star_border"}),"Favorit"]}),Pt&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"ctx-sep"}),P.jsxs("div",{className:"ctx-item danger",onClick:async()=>{const he=Jt.sound.relativePath??Jt.sound.fileName;if(!window.confirm(`Sound "${Jt.sound.name}" loeschen?`)){In(null);return}try{await GAe([he]),ot("Sound geloescht"),Ot(X=>X+1)}catch(X){ot((X==null?void 0:X.message)||"Loeschen fehlgeschlagen","error")}In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"delete"}),"Loeschen"]})]})]}),Ue&&(()=>{const he=Je!=null&&Je.connectedSince?Math.floor((Date.now()-new Date(Je.connectedSince).getTime())/1e3):0,X=Math.floor(he/3600),tt=Math.floor(he%3600/60),en=he%60,sn=X>0?`${X}h ${String(tt).padStart(2,"0")}m ${String(en).padStart(2,"0")}s`:tt>0?`${tt}m ${String(en).padStart(2,"0")}s`:`${en}s`,Tn=Rn=>Rn==null?"var(--muted)":Rn<80?"var(--green)":Rn<150?"#f0a830":"#e04040";return P.jsx("div",{className:"conn-modal-overlay",onClick:()=>ut(!1),children:P.jsxs("div",{className:"conn-modal",onClick:Rn=>Rn.stopPropagation(),children:[P.jsxs("div",{className:"conn-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20,color:"var(--green)"},children:"cell_tower"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"conn-modal-close",onClick:()=>ut(!1),children:P.jsx("span",{className:"material-icons",children:"close"})})]}),P.jsxs("div",{className:"conn-modal-body",children:[P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Voice Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((Je==null?void 0:Je.voicePing)??null)}}),(Je==null?void 0:Je.voicePing)!=null?`${Je.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Gateway Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((Je==null?void 0:Je.gatewayPing)??null)}}),Je&&Je.gatewayPing>=0?`${Je.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Status"}),P.jsx("span",{className:"conn-stat-value",style:{color:(Je==null?void 0:Je.status)==="ready"?"var(--green)":"#f0a830"},children:(Je==null?void 0:Je.status)==="ready"?"Verbunden":(Je==null?void 0:Je.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Kanal"}),P.jsx("span",{className:"conn-stat-value",children:(Je==null?void 0:Je.channelName)||"---"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Verbunden seit"}),P.jsx("span",{className:"conn-stat-value",children:sn||"---"})]})]})]})})})(),Dt&&P.jsxs("div",{className:`toast ${Dt.type}`,children:[P.jsx("span",{className:"material-icons toast-icon",children:Dt.type==="error"?"error_outline":"check_circle"}),Dt.msg]}),We&&P.jsx("div",{className:"drop-overlay",children:P.jsxs("div",{className:"drop-zone",children:[P.jsx("span",{className:"material-icons drop-icon",children:"cloud_upload"}),P.jsx("div",{className:"drop-title",children:"MP3 & WAV hier ablegen"}),P.jsx("div",{className:"drop-sub",children:"Mehrere Dateien gleichzeitig moeglich"})]})}),yt&&fe.length>0&&P.jsxs("div",{className:"upload-queue",children:[P.jsxs("div",{className:"uq-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),P.jsx("span",{children:fe.every(he=>he.status==="done"||he.status==="error")?`${fe.filter(he=>he.status==="done").length} von ${fe.length} hochgeladen`:`Lade hoch… (${fe.filter(he=>he.status==="done").length}/${fe.length})`}),P.jsx("button",{className:"uq-close",onClick:()=>{Gt(!1),Wt([])},children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsx("div",{className:"uq-list",children:fe.map(he=>P.jsxs("div",{className:`uq-item uq-${he.status}`,children:[P.jsx("span",{className:"material-icons uq-file-icon",children:"audio_file"}),P.jsxs("div",{className:"uq-info",children:[P.jsx("div",{className:"uq-name",title:he.savedName??he.file.name,children:he.savedName??he.file.name}),P.jsxs("div",{className:"uq-size",children:[(he.file.size/1024).toFixed(0)," KB"]})]}),(he.status==="waiting"||he.status==="uploading")&&P.jsx("div",{className:"uq-progress-wrap",children:P.jsx("div",{className:"uq-progress-bar",style:{width:`${he.progress}%`}})}),P.jsx("span",{className:`material-icons uq-status-icon uq-status-${he.status}`,children:he.status==="done"?"check_circle":he.status==="error"?"error":he.status==="uploading"?"sync":"schedule"}),he.status==="error"&&P.jsx("div",{className:"uq-error",children:he.error})]},he.id))})]}),Xt.length>0&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>pe==="naming"&&ee(),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:"upload_file"}),P.jsxs("span",{children:[pe==="naming"?"Sound benennen":pe==="uploading"?"Wird hochgeladen...":"Gespeichert!",Xt.length>1&&` (${Ae+1}/${Xt.length})`]}),pe==="naming"&&P.jsx("button",{className:"dl-modal-close",onClick:ee,children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:"dl-modal-tag mp3",children:"Datei"}),P.jsx("span",{className:"dl-modal-url-text",title:(qe=Xt[Ae])==null?void 0:qe.name,children:(qt=Xt[Ae])==null?void 0:qt.name}),P.jsxs("span",{style:{marginLeft:"auto",opacity:.5,fontSize:12},children:[((((Qt=Xt[Ae])==null?void 0:Qt.size)??0)/1024).toFixed(0)," KB"]})]}),pe==="naming"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:"Dateiname eingeben...",value:be,onChange:he=>Oe(he.target.value),onKeyDown:he=>{he.key==="Enter"&&A()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]})]}),pe==="uploading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsxs("span",{children:["Upload: ",Ne,"%"]})]}),pe==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsx("span",{children:"Erfolgreich hochgeladen!"})]})]}),pe==="naming"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:ee,children:Xt.length>1?"Überspringen":"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void A(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),"Hochladen"]})]})]})}),z&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>z.phase!=="downloading"&&G(null),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:z.type==="youtube"?"smart_display":z.type==="instagram"?"photo_camera":"audio_file"}),P.jsx("span",{children:z.phase==="input"?"Sound herunterladen":z.phase==="downloading"?"Wird heruntergeladen...":z.phase==="done"?"Fertig!":"Fehler"}),z.phase!=="downloading"&&P.jsx("button",{className:"dl-modal-close",onClick:()=>G(null),children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:`dl-modal-tag ${z.type??""}`,children:z.type==="youtube"?"YouTube":z.type==="instagram"?"Instagram":"MP3"}),P.jsx("span",{className:"dl-modal-url-text",title:z.url,children:z.url.length>60?z.url.slice(0,57)+"...":z.url})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:z.type==="mp3"?"Dateiname...":"Wird automatisch erkannt...",value:z.filename,onChange:he=>G(X=>X?{...X,filename:he.target.value}:null),onKeyDown:he=>{he.key==="Enter"&&Vt()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]}),P.jsx("span",{className:"dl-modal-hint",children:"Leer lassen = automatischer Name"})]}),z.phase==="downloading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsx("span",{children:z.type==="youtube"||z.type==="instagram"?"Audio wird extrahiert...":"MP3 wird heruntergeladen..."})]}),z.phase==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsxs("span",{children:["Gespeichert als ",P.jsx("b",{children:z.savedName})]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-error",children:[P.jsx("span",{className:"material-icons",style:{color:"#e74c3c"},children:"error"}),P.jsx("span",{children:z.error})]})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void Vt(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"download"}),"Herunterladen"]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Schliessen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>G(he=>he?{...he,phase:"input",error:void 0}:null),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"refresh"}),"Nochmal"]})]})]})})]})}const _7={IRON:"#6b6b6b",BRONZE:"#8c6239",SILVER:"#8c8c8c",GOLD:"#d4a017",PLATINUM:"#28b29e",EMERALD:"#1e9e5e",DIAMOND:"#576cce",MASTER:"#9d48e0",GRANDMASTER:"#e44c3e",CHALLENGER:"#f4c874"},HAe={SOLORANKED:"Ranked Solo",FLEXRANKED:"Ranked Flex",NORMAL:"Normal",ARAM:"ARAM",ARENA:"Arena",URF:"URF",BOT:"Co-op vs AI"},WAe="https://ddragon.leagueoflegends.com/cdn/15.5.1/img";function mm(i){return`${WAe}/champion/${i}.png`}function y7(i){const e=Math.floor((Date.now()-new Date(i).getTime())/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function $Ae(i){const e=Math.floor(i/60),t=i%60;return`${e}:${String(t).padStart(2,"0")}`}function x7(i,e,t){return e===0?"Perfect":((i+t)/e).toFixed(2)}function b7(i,e){const t=i+e;return t>0?Math.round(i/t*100):0}function XAe(i,e){if(!i)return"Unranked";const t=["","I","II","III","IV"];return`${i.charAt(0)}${i.slice(1).toLowerCase()}${e?" "+(t[e]??e):""}`}function YAe({data:i}){var _t,Xt,pt,Ae;const[e,t]=re.useState(""),[n,r]=re.useState("EUW"),[s,a]=re.useState([]),[l,u]=re.useState(null),[h,m]=re.useState([]),[v,x]=re.useState(!1),[S,T]=re.useState(null),[N,C]=re.useState([]),[E,O]=re.useState(null),[U,I]=re.useState({}),[j,z]=re.useState(!1),[G,H]=re.useState(!1),[q,V]=re.useState(null),[Q,J]=re.useState("aram"),[ne,oe]=re.useState("EUW"),[ie,Z]=re.useState([]),[te,de]=re.useState(!1),[Se,Te]=re.useState(null),[ae,Me]=re.useState([]),[Ve,Ce]=re.useState(""),[Fe,et]=re.useState(!1),He=re.useRef(null),Rt=re.useRef(null);re.useEffect(()=>{fetch("/api/lolstats/regions").then(k=>k.json()).then(a).catch(()=>{}),fetch("/api/lolstats/recent").then(k=>k.json()).then(C).catch(()=>{}),fetch("/api/lolstats/modes").then(k=>k.json()).then(Me).catch(()=>{})},[]),re.useEffect(()=>{Q&&(de(!0),Te(null),et(!1),fetch(`/api/lolstats/tierlist?mode=${Q}®ion=${ne}`).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>Z(k.champions??[])).catch(k=>Te(k.message)).finally(()=>de(!1)))},[Q,ne]),re.useEffect(()=>{i&&(i.recentSearches&&C(i.recentSearches),i.regions&&!s.length&&a(i.regions))},[i]);const Et=re.useCallback(async(k,be,Oe)=>{H(!0);try{const pe=`gameName=${encodeURIComponent(k)}&tagLine=${encodeURIComponent(be)}®ion=${Oe}`,le=await fetch(`/api/lolstats/renew?${pe}`,{method:"POST"});if(le.ok){const Ne=await le.json();return Ne.last_updated_at&&V(Ne.last_updated_at),Ne.renewed??!1}}catch{}return H(!1),!1},[]),zt=re.useCallback(async(k,be,Oe,pe=!1)=>{var Je,we;let le=k??"",Ne=be??"";const De=Oe??n;if(!le){const Ue=e.split("#");le=((Je=Ue[0])==null?void 0:Je.trim())??"",Ne=((we=Ue[1])==null?void 0:we.trim())??""}if(!le||!Ne){T("Bitte im Format Name#Tag eingeben");return}x(!0),T(null),u(null),m([]),O(null),I({}),Rt.current={gameName:le,tagLine:Ne,region:De},pe||Et(le,Ne,De).finally(()=>H(!1));try{const Ue=`gameName=${encodeURIComponent(le)}&tagLine=${encodeURIComponent(Ne)}®ion=${De}`,[ut,Dt]=await Promise.all([fetch(`/api/lolstats/profile?${Ue}`),fetch(`/api/lolstats/matches?${Ue}&limit=10`)]);if(!ut.ok){const ct=await ut.json();throw new Error(ct.error??`Fehler ${ut.status}`)}const Bt=await ut.json();if(u(Bt),Bt.updated_at&&V(Bt.updated_at),Dt.ok){const ct=await Dt.json();m(Array.isArray(ct)?ct:[])}}catch(Ue){T(Ue.message)}x(!1)},[e,n,Et]),Pt=re.useCallback(async()=>{const k=Rt.current;if(!(!k||G)){H(!0);try{await Et(k.gameName,k.tagLine,k.region),await new Promise(be=>setTimeout(be,1500)),await zt(k.gameName,k.tagLine,k.region,!0)}finally{H(!1)}}},[Et,zt,G]),We=re.useCallback(async()=>{if(!(!l||j)){z(!0);try{const k=`gameName=${encodeURIComponent(l.game_name)}&tagLine=${encodeURIComponent(l.tagline)}®ion=${n}&limit=20`,be=await fetch(`/api/lolstats/matches?${k}`);if(be.ok){const Oe=await be.json();m(Array.isArray(Oe)?Oe:[])}}catch{}z(!1)}},[l,n,j]),ft=re.useCallback(async k=>{var be;if(E===k.id){O(null);return}if(O(k.id),!(((be=k.participants)==null?void 0:be.length)>=10||U[k.id]))try{const Oe=`region=${n}&createdAt=${encodeURIComponent(k.created_at)}`,pe=await fetch(`/api/lolstats/match/${encodeURIComponent(k.id)}?${Oe}`);if(pe.ok){const le=await pe.json();I(Ne=>({...Ne,[k.id]:le}))}}catch{}},[E,U,n]),fe=re.useCallback(k=>{t(`${k.game_name}#${k.tag_line}`),r(k.region),zt(k.game_name,k.tag_line,k.region)},[zt]),Wt=re.useCallback(k=>{var Oe,pe,le;if(!l)return((Oe=k.participants)==null?void 0:Oe[0])??null;const be=l.game_name.toLowerCase();return((pe=k.participants)==null?void 0:pe.find(Ne=>{var De,Je;return((Je=(De=Ne.summoner)==null?void 0:De.game_name)==null?void 0:Je.toLowerCase())===be}))??((le=k.participants)==null?void 0:le[0])??null},[l]),yt=k=>{var we,Ue,ut;const be=Wt(k);if(!be)return null;const Oe=((we=be.stats)==null?void 0:we.result)==="WIN",pe=x7(be.stats.kill,be.stats.death,be.stats.assist),le=(be.stats.minion_kill??0)+(be.stats.neutral_minion_kill??0),Ne=k.game_length_second>0?(le/(k.game_length_second/60)).toFixed(1):"0",De=E===k.id,Je=U[k.id]??(((Ue=k.participants)==null?void 0:Ue.length)>=10?k:null);return P.jsxs("div",{children:[P.jsxs("div",{className:`lol-match ${Oe?"win":"loss"}`,onClick:()=>ft(k),children:[P.jsx("div",{className:"lol-match-result",children:Oe?"W":"L"}),P.jsxs("div",{className:"lol-match-champ",children:[P.jsx("img",{src:mm(be.champion_name),alt:be.champion_name,title:be.champion_name}),P.jsx("span",{className:"lol-match-champ-level",children:be.stats.champion_level})]}),P.jsxs("div",{className:"lol-match-kda",children:[P.jsxs("div",{className:"lol-match-kda-nums",children:[be.stats.kill,"/",be.stats.death,"/",be.stats.assist]}),P.jsxs("div",{className:`lol-match-kda-ratio ${pe==="Perfect"?"perfect":Number(pe)>=4?"great":""}`,children:[pe," KDA"]})]}),P.jsxs("div",{className:"lol-match-stats",children:[P.jsxs("span",{children:[le," CS (",Ne,"/m)"]}),P.jsxs("span",{children:[be.stats.ward_place," wards"]})]}),P.jsx("div",{className:"lol-match-items",children:(be.items_names??[]).slice(0,7).map((Dt,Bt)=>Dt?P.jsx("img",{src:mm("Aatrox"),alt:Dt,title:Dt,style:{background:"var(--bg-deep)"},onError:ct=>{ct.target.style.display="none"}},Bt):P.jsx("div",{className:"lol-match-item-empty"},Bt))}),P.jsxs("div",{className:"lol-match-meta",children:[P.jsx("div",{className:"lol-match-duration",children:$Ae(k.game_length_second)}),P.jsx("div",{className:"lol-match-queue",children:HAe[k.game_type]??k.game_type}),P.jsxs("div",{className:"lol-match-ago",children:[y7(k.created_at)," ago"]})]})]}),De&&Je&&P.jsx("div",{className:"lol-match-detail",children:Gt(Je,(ut=be.summoner)==null?void 0:ut.game_name)})]},k.id)},Gt=(k,be)=>{var De,Je,we,Ue,ut;const Oe=((De=k.participants)==null?void 0:De.filter(Dt=>Dt.team_key==="BLUE"))??[],pe=((Je=k.participants)==null?void 0:Je.filter(Dt=>Dt.team_key==="RED"))??[],le=(ut=(Ue=(we=k.teams)==null?void 0:we.find(Dt=>Dt.key==="BLUE"))==null?void 0:Ue.game_stat)==null?void 0:ut.is_win,Ne=(Dt,Bt,ct)=>P.jsxs("div",{className:"lol-match-detail-team",children:[P.jsxs("div",{className:`lol-match-detail-team-header ${Bt?"win":"loss"}`,children:[ct," — ",Bt?"Victory":"Defeat"]}),Dt.map((jt,Jt)=>{var Ot,ot,Tt,Ht,Yt,pn,$e,St,Kt,wn,qn,Ze;const In=((ot=(Ot=jt.summoner)==null?void 0:Ot.game_name)==null?void 0:ot.toLowerCase())===(be==null?void 0:be.toLowerCase()),ge=(((Tt=jt.stats)==null?void 0:Tt.minion_kill)??0)+(((Ht=jt.stats)==null?void 0:Ht.neutral_minion_kill)??0);return P.jsxs("div",{className:`lol-detail-row ${In?"me":""}`,children:[P.jsx("img",{className:"lol-detail-champ",src:mm(jt.champion_name),alt:jt.champion_name}),P.jsx("span",{className:"lol-detail-name",title:`${(Yt=jt.summoner)==null?void 0:Yt.game_name}#${(pn=jt.summoner)==null?void 0:pn.tagline}`,children:(($e=jt.summoner)==null?void 0:$e.game_name)??jt.champion_name}),P.jsxs("span",{className:"lol-detail-kda",children:[(St=jt.stats)==null?void 0:St.kill,"/",(Kt=jt.stats)==null?void 0:Kt.death,"/",(wn=jt.stats)==null?void 0:wn.assist]}),P.jsxs("span",{className:"lol-detail-cs",children:[ge," CS"]}),P.jsxs("span",{className:"lol-detail-dmg",children:[((((qn=jt.stats)==null?void 0:qn.total_damage_dealt_to_champions)??0)/1e3).toFixed(1),"k"]}),P.jsxs("span",{className:"lol-detail-gold",children:[((((Ze=jt.stats)==null?void 0:Ze.gold_earned)??0)/1e3).toFixed(1),"k"]})]},Jt)})]});return P.jsxs(P.Fragment,{children:[Ne(Oe,le,"Blue Team"),Ne(pe,le===void 0?void 0:!le,"Red Team")]})};return P.jsxs("div",{className:"lol-container",children:[P.jsxs("div",{className:"lol-search",children:[P.jsx("input",{ref:He,className:"lol-search-input",placeholder:"Summoner Name#Tag",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>k.key==="Enter"&&zt()}),P.jsx("select",{className:"lol-search-region",value:n,onChange:k=>r(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("button",{className:"lol-search-btn",onClick:()=>zt(),disabled:v,children:v?"...":"Search"})]}),N.length>0&&P.jsx("div",{className:"lol-recent",children:N.map((k,be)=>P.jsxs("button",{className:"lol-recent-chip",onClick:()=>fe(k),children:[k.profile_image_url&&P.jsx("img",{src:k.profile_image_url,alt:""}),k.game_name,"#",k.tag_line,k.tier&&P.jsx("span",{className:"lol-recent-tier",style:{color:_7[k.tier]},children:k.tier})]},be))}),S&&P.jsx("div",{className:"lol-error",children:S}),v&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Profil..."]}),l&&!v&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-profile",children:[P.jsx("img",{className:"lol-profile-icon",src:l.profile_image_url,alt:""}),P.jsxs("div",{className:"lol-profile-info",children:[P.jsxs("h2",{children:[l.game_name,P.jsxs("span",{children:["#",l.tagline]})]}),P.jsxs("div",{className:"lol-profile-level",children:["Level ",l.level]}),((_t=l.ladder_rank)==null?void 0:_t.rank)&&P.jsxs("div",{className:"lol-profile-ladder",children:["Ladder Rank #",l.ladder_rank.rank.toLocaleString()," / ",(Xt=l.ladder_rank.total)==null?void 0:Xt.toLocaleString()]}),q&&P.jsxs("div",{className:"lol-profile-updated",children:["Updated ",y7(q)," ago"]})]}),P.jsxs("button",{className:`lol-update-btn ${G?"renewing":""}`,onClick:Pt,disabled:G,title:"Refresh data from Riot servers",children:[P.jsx("span",{className:"lol-update-icon",children:G?"⟳":"↻"}),G?"Updating...":"Update"]})]}),P.jsx("div",{className:"lol-ranked-row",children:(l.league_stats??[]).filter(k=>k.game_type==="SOLORANKED"||k.game_type==="FLEXRANKED").map(k=>{const be=k.tier_info,Oe=!!(be!=null&&be.tier),pe=_7[(be==null?void 0:be.tier)??""]??"var(--text-normal)";return P.jsxs("div",{className:`lol-ranked-card ${Oe?"has-rank":""}`,style:{"--tier-color":pe},children:[P.jsx("div",{className:"lol-ranked-type",children:k.game_type==="SOLORANKED"?"Ranked Solo/Duo":"Ranked Flex"}),Oe?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-ranked-tier",style:{color:pe},children:[XAe(be.tier,be.division),P.jsxs("span",{className:"lol-ranked-lp",children:[be.lp," LP"]})]}),P.jsxs("div",{className:"lol-ranked-record",children:[k.win,"W ",k.lose,"L",P.jsxs("span",{className:"lol-ranked-wr",children:["(",b7(k.win??0,k.lose??0),"%)"]}),k.is_hot_streak&&P.jsx("span",{className:"lol-ranked-streak",children:"🔥"})]})]}):P.jsx("div",{className:"lol-ranked-tier",children:"Unranked"})]},k.game_type)})}),((Ae=(pt=l.most_champions)==null?void 0:pt.champion_stats)==null?void 0:Ae.length)>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Top Champions"}),P.jsx("div",{className:"lol-champs",children:l.most_champions.champion_stats.slice(0,7).map(k=>{const be=b7(k.win,k.lose),Oe=k.play>0?x7(k.kill/k.play,k.death/k.play,k.assist/k.play):"0";return P.jsxs("div",{className:"lol-champ-card",children:[P.jsx("img",{className:"lol-champ-icon",src:mm(k.champion_name),alt:k.champion_name}),P.jsxs("div",{children:[P.jsx("div",{className:"lol-champ-name",children:k.champion_name}),P.jsxs("div",{className:"lol-champ-stats",children:[k.play," games · ",be,"% WR"]}),P.jsxs("div",{className:"lol-champ-kda",children:[Oe," KDA"]})]})]},k.champion_name)})})]}),h.length>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Match History"}),P.jsx("div",{className:"lol-matches",children:h.map(k=>yt(k))}),h.length<20&&P.jsx("button",{className:"lol-load-more",onClick:We,disabled:j,children:j?"Laden...":"Mehr laden"})]})]}),!l&&!v&&!S&&P.jsxs("div",{className:"lol-empty",children:[P.jsx("div",{className:"lol-empty-icon",children:"⚔️"}),P.jsx("h3",{children:"League of Legends Stats"}),P.jsx("p",{children:"Gib einen Summoner Name#Tag ein und wähle die Region"})]}),P.jsxs("div",{className:"lol-tier-section",children:[P.jsx("div",{className:"lol-section-title",children:"Champion Tier List"}),P.jsxs("div",{className:"lol-tier-controls",children:[P.jsx("div",{className:"lol-tier-modes",children:ae.map(k=>P.jsx("button",{className:`lol-tier-mode-btn ${Q===k.key?"active":""}`,onClick:()=>J(k.key),children:k.label},k.key))}),P.jsx("select",{className:"lol-search-region",value:ne,onChange:k=>oe(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("input",{className:"lol-tier-filter",placeholder:"Filter champion...",value:Ve,onChange:k=>Ce(k.target.value)})]}),te&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Tier List..."]}),Se&&P.jsx("div",{className:"lol-error",children:Se}),!te&&!Se&&ie.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-tier-table",children:[P.jsxs("div",{className:"lol-tier-header",children:[P.jsx("span",{className:"lol-tier-col-rank",children:"#"}),P.jsx("span",{className:"lol-tier-col-champ",children:"Champion"}),P.jsx("span",{className:"lol-tier-col-tier",children:"Tier"}),P.jsx("span",{className:"lol-tier-col-wr",children:Q==="arena"?"Win":"Win %"}),P.jsx("span",{className:"lol-tier-col-pr",children:"Pick %"}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:"Ban %"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?"Avg Place":"KDA"})]}),ie.filter(k=>!Ve||k.champion_name.toLowerCase().includes(Ve.toLowerCase())).slice(0,Fe?void 0:50).map(k=>{var Oe,pe;const be=["OP","1","2","3","4","5"];return P.jsxs("div",{className:`lol-tier-row tier-${k.tier}`,children:[P.jsx("span",{className:"lol-tier-col-rank",children:k.rank}),P.jsxs("span",{className:"lol-tier-col-champ",children:[P.jsx("img",{src:mm(k.champion_name),alt:k.champion_name}),k.champion_name]}),P.jsx("span",{className:`lol-tier-col-tier tier-badge-${k.tier}`,children:be[k.tier]??k.tier}),P.jsx("span",{className:"lol-tier-col-wr",children:k.win_rate!=null?`${(k.win_rate*100).toFixed(1)}%`:"-"}),P.jsxs("span",{className:"lol-tier-col-pr",children:[(k.pick_rate*100).toFixed(1),"%"]}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:k.ban_rate!=null?`${(k.ban_rate*100).toFixed(1)}%`:"-"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?((Oe=k.average_placement)==null?void 0:Oe.toFixed(1))??"-":((pe=k.kda)==null?void 0:pe.toFixed(2))??"-"})]},k.champion_id)})]}),!Fe&&ie.length>50&&P.jsxs("button",{className:"lol-load-more",onClick:()=>et(!0),children:["Alle ",ie.length," Champions anzeigen"]})]})]})]})}const S7={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function VS(i){const e=Math.max(0,Math.floor((Date.now()-new Date(i).getTime())/1e3)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}const jS=[{label:"Niedrig · 4 Mbit · 60fps",fps:60,bitrate:4e6},{label:"Mittel · 8 Mbit · 60fps",fps:60,bitrate:8e6},{label:"Hoch · 14 Mbit · 60fps",fps:60,bitrate:14e6},{label:"Ultra · 25 Mbit · 60fps",fps:60,bitrate:25e6},{label:"Max · 50 Mbit · 165fps",fps:165,bitrate:5e7}];function QAe({data:i,isAdmin:e}){var De,Je;const[t,n]=re.useState([]),[r,s]=re.useState(()=>localStorage.getItem("streaming_name")||""),[a,l]=re.useState("Screen Share"),[u,h]=re.useState(""),[m,v]=re.useState(1),[x,S]=re.useState(null),[T,N]=re.useState(null),[C,E]=re.useState(null),[O,U]=re.useState(!1),[I,j]=re.useState(!1),[z,G]=re.useState(null),[,H]=re.useState(0),[q,V]=re.useState(null),[Q,J]=re.useState(null),ne=re.useRef(null),oe=re.useRef(""),ie=re.useRef(null),Z=re.useRef(null),te=re.useRef(null),de=re.useRef(new Map),Se=re.useRef(null),Te=re.useRef(null),ae=re.useRef(new Map),Me=re.useRef(null),Ve=re.useRef(1e3),Ce=re.useRef(!1),Fe=re.useRef(null),et=re.useRef(jS[1]);re.useEffect(()=>{Ce.current=O},[O]),re.useEffect(()=>{Fe.current=z},[z]),re.useEffect(()=>{et.current=jS[m]},[m]),re.useEffect(()=>{var we,Ue;(Ue=(we=window.electronAPI)==null?void 0:we.setStreaming)==null||Ue.call(we,O||z!==null)},[O,z]),re.useEffect(()=>{if(!(t.length>0||O))return;const Ue=setInterval(()=>H(ut=>ut+1),1e3);return()=>clearInterval(Ue)},[t.length,O]),re.useEffect(()=>{i!=null&&i.streams&&n(i.streams)},[i]),re.useEffect(()=>{r&&localStorage.setItem("streaming_name",r)},[r]),re.useEffect(()=>{if(!q)return;const we=()=>V(null);return document.addEventListener("click",we),()=>document.removeEventListener("click",we)},[q]);const He=re.useCallback(we=>{var Ue;((Ue=ne.current)==null?void 0:Ue.readyState)===WebSocket.OPEN&&ne.current.send(JSON.stringify(we))},[]),Rt=re.useCallback((we,Ue,ut)=>{if(we.remoteDescription)we.addIceCandidate(new RTCIceCandidate(ut)).catch(()=>{});else{let Dt=ae.current.get(Ue);Dt||(Dt=[],ae.current.set(Ue,Dt)),Dt.push(ut)}},[]),Et=re.useCallback((we,Ue)=>{const ut=ae.current.get(Ue);if(ut){for(const Dt of ut)we.addIceCandidate(new RTCIceCandidate(Dt)).catch(()=>{});ae.current.delete(Ue)}},[]),zt=re.useCallback((we,Ue)=>{we.srcObject=Ue;const ut=we.play();ut&&ut.catch(()=>{we.muted=!0,we.play().catch(()=>{})})},[]),Pt=re.useCallback(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),Se.current&&(Se.current.close(),Se.current=null),Te.current=null,te.current&&(te.current.srcObject=null)},[]),We=re.useRef(()=>{});We.current=we=>{var Ue,ut,Dt;switch(we.type){case"welcome":oe.current=we.clientId,we.streams&&n(we.streams);break;case"broadcast_started":E(we.streamId),U(!0),Ce.current=!0,j(!1),(Ue=window.electronAPI)!=null&&Ue.showNotification&&window.electronAPI.showNotification("Stream gestartet","Dein Stream ist jetzt live!");break;case"stream_available":n(ct=>ct.some(jt=>jt.id===we.streamId)?ct:[...ct,{id:we.streamId,broadcasterName:we.broadcasterName,title:we.title,startedAt:new Date().toISOString(),viewerCount:0,hasPassword:!!we.hasPassword}]);const Bt=`${we.broadcasterName} streamt: ${we.title}`;(ut=window.electronAPI)!=null&&ut.showNotification?window.electronAPI.showNotification("Neuer Stream",Bt):Notification.permission==="granted"&&new Notification("Neuer Stream",{body:Bt,icon:"/assets/icon.png"});break;case"stream_ended":n(ct=>ct.filter(jt=>jt.id!==we.streamId)),((Dt=Fe.current)==null?void 0:Dt.streamId)===we.streamId&&(Pt(),G(null));break;case"viewer_joined":{const ct=we.viewerId,jt=de.current.get(ct);jt&&(jt.close(),de.current.delete(ct)),ae.current.delete(ct);const Jt=new RTCPeerConnection(S7);de.current.set(ct,Jt);const In=ie.current;if(In)for(const Ot of In.getTracks())Jt.addTrack(Ot,In);Jt.onicecandidate=Ot=>{Ot.candidate&&He({type:"ice_candidate",targetId:ct,candidate:Ot.candidate.toJSON()})};const ge=Jt.getSenders().find(Ot=>{var ot;return((ot=Ot.track)==null?void 0:ot.kind)==="video"});if(ge){const Ot=ge.getParameters();(!Ot.encodings||Ot.encodings.length===0)&&(Ot.encodings=[{}]),Ot.encodings[0].maxFramerate=et.current.fps,Ot.encodings[0].maxBitrate=et.current.bitrate,ge.setParameters(Ot).catch(()=>{})}Jt.createOffer().then(Ot=>Jt.setLocalDescription(Ot)).then(()=>He({type:"offer",targetId:ct,sdp:Jt.localDescription})).catch(console.error);break}case"viewer_left":{const ct=de.current.get(we.viewerId);ct&&(ct.close(),de.current.delete(we.viewerId)),ae.current.delete(we.viewerId);break}case"offer":{const ct=we.fromId;Se.current&&(Se.current.close(),Se.current=null),ae.current.delete(ct);const jt=new RTCPeerConnection(S7);Se.current=jt,jt.ontrack=Jt=>{const In=Jt.streams[0];if(!In)return;Te.current=In;const ge=te.current;ge&&zt(ge,In),G(Ot=>Ot&&{...Ot,phase:"connected"})},jt.onicecandidate=Jt=>{Jt.candidate&&He({type:"ice_candidate",targetId:ct,candidate:Jt.candidate.toJSON()})},jt.oniceconnectionstatechange=()=>{(jt.iceConnectionState==="failed"||jt.iceConnectionState==="disconnected")&&G(Jt=>Jt&&{...Jt,phase:"error",error:"Verbindung verloren"})},jt.setRemoteDescription(new RTCSessionDescription(we.sdp)).then(()=>(Et(jt,ct),jt.createAnswer())).then(Jt=>jt.setLocalDescription(Jt)).then(()=>He({type:"answer",targetId:ct,sdp:jt.localDescription})).catch(console.error);break}case"answer":{const ct=de.current.get(we.fromId);ct&&ct.setRemoteDescription(new RTCSessionDescription(we.sdp)).then(()=>Et(ct,we.fromId)).catch(console.error);break}case"ice_candidate":{if(!we.candidate)break;const ct=de.current.get(we.fromId);ct?Rt(ct,we.fromId,we.candidate):Se.current&&Rt(Se.current,we.fromId,we.candidate);break}case"error":we.code==="WRONG_PASSWORD"?N(ct=>ct&&{...ct,error:we.message}):S(we.message),j(!1);break}};const ft=re.useCallback(()=>{if(ne.current&&ne.current.readyState===WebSocket.OPEN)return;const we=location.protocol==="https:"?"wss":"ws",Ue=new WebSocket(`${we}://${location.host}/ws/streaming`);ne.current=Ue,Ue.onopen=()=>{Ve.current=1e3},Ue.onmessage=ut=>{let Dt;try{Dt=JSON.parse(ut.data)}catch{return}We.current(Dt)},Ue.onclose=()=>{ne.current=null,Me.current=setTimeout(()=>{Ve.current=Math.min(Ve.current*2,1e4),ft()},Ve.current)},Ue.onerror=()=>{Ue.close()}},[]);re.useEffect(()=>(ft(),()=>{Me.current&&clearTimeout(Me.current)}),[ft]);const fe=re.useCallback(async()=>{var we,Ue;if(!r.trim()){S("Bitte gib einen Namen ein.");return}if(!((we=navigator.mediaDevices)!=null&&we.getDisplayMedia)){S("Dein Browser unterstützt keine Bildschirmfreigabe.");return}S(null),j(!0);try{const ut=et.current,Dt=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:ut.fps}},audio:!0});ie.current=Dt,Z.current&&(Z.current.srcObject=Dt),(Ue=Dt.getVideoTracks()[0])==null||Ue.addEventListener("ended",()=>{Wt()}),ft();const Bt=()=>{var ct;((ct=ne.current)==null?void 0:ct.readyState)===WebSocket.OPEN?He({type:"start_broadcast",name:r.trim(),title:a.trim()||"Screen Share",password:u.trim()||void 0}):setTimeout(Bt,100)};Bt()}catch(ut){j(!1),ut.name==="NotAllowedError"?S("Bildschirmfreigabe wurde abgelehnt."):S(`Fehler: ${ut.message}`)}},[r,a,u,ft,He]),Wt=re.useCallback(()=>{var we;He({type:"stop_broadcast"}),(we=ie.current)==null||we.getTracks().forEach(Ue=>Ue.stop()),ie.current=null,Z.current&&(Z.current.srcObject=null);for(const Ue of de.current.values())Ue.close();de.current.clear(),U(!1),Ce.current=!1,E(null),h("")},[He]),yt=re.useCallback(we=>{S(null),G({streamId:we,phase:"connecting"}),ft();const Ue=()=>{var ut;((ut=ne.current)==null?void 0:ut.readyState)===WebSocket.OPEN?He({type:"join_viewer",name:r.trim()||"Viewer",streamId:we}):setTimeout(Ue,100)};Ue()},[r,ft,He]),Gt=re.useCallback(we=>{we.hasPassword?N({streamId:we.id,streamTitle:we.title,broadcasterName:we.broadcasterName,password:"",error:null}):yt(we.id)},[yt]),_t=re.useCallback(()=>{if(!T)return;if(!T.password.trim()){N(Dt=>Dt&&{...Dt,error:"Passwort eingeben."});return}const{streamId:we,password:Ue}=T;N(null),S(null),G({streamId:we,phase:"connecting"}),ft();const ut=()=>{var Dt;((Dt=ne.current)==null?void 0:Dt.readyState)===WebSocket.OPEN?He({type:"join_viewer",name:r.trim()||"Viewer",streamId:we,password:Ue.trim()}):setTimeout(ut,100)};ut()},[T,r,ft,He]),Xt=re.useCallback(()=>{He({type:"leave_viewer"}),Pt(),G(null)},[Pt,He]);re.useEffect(()=>{const we=ut=>{(Ce.current||Fe.current)&&ut.preventDefault()},Ue=()=>{oe.current&&navigator.sendBeacon("/api/streaming/disconnect",JSON.stringify({clientId:oe.current}))};return window.addEventListener("beforeunload",we),window.addEventListener("pagehide",Ue),()=>{window.removeEventListener("beforeunload",we),window.removeEventListener("pagehide",Ue)}},[]);const pt=re.useRef(null),[Ae,k]=re.useState(!1),be=re.useCallback(()=>{const we=pt.current;we&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):we.requestFullscreen().catch(()=>{}))},[]);re.useEffect(()=>{const we=()=>k(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",we),()=>document.removeEventListener("fullscreenchange",we)},[]),re.useEffect(()=>()=>{var we;(we=ie.current)==null||we.getTracks().forEach(Ue=>Ue.stop());for(const Ue of de.current.values())Ue.close();Se.current&&Se.current.close(),ne.current&&ne.current.close(),Me.current&&clearTimeout(Me.current)},[]),re.useEffect(()=>{z&&Te.current&&te.current&&!te.current.srcObject&&zt(te.current,Te.current)},[z,zt]);const Oe=re.useRef(null);re.useEffect(()=>{const Ue=new URLSearchParams(location.search).get("viewStream");if(Ue){Oe.current=Ue;const ut=new URL(location.href);ut.searchParams.delete("viewStream"),window.history.replaceState({},"",ut.toString())}},[]),re.useEffect(()=>{const we=Oe.current;if(!we||t.length===0)return;const Ue=t.find(ut=>ut.id===we);Ue&&(Oe.current=null,Gt(Ue))},[t,Gt]);const pe=re.useCallback(we=>{const Ue=new URL(location.href);return Ue.searchParams.set("viewStream",we),Ue.hash="",Ue.toString()},[]),le=re.useCallback(we=>{navigator.clipboard.writeText(pe(we)).then(()=>{J(we),setTimeout(()=>J(null),2e3)}).catch(()=>{})},[pe]),Ne=re.useCallback(we=>{window.open(pe(we),"_blank","noopener"),V(null)},[pe]);if(z){const we=t.find(Ue=>Ue.id===z.streamId);return P.jsxs("div",{className:"stream-viewer-overlay",ref:pt,children:[P.jsxs("div",{className:"stream-viewer-header",children:[P.jsxs("div",{className:"stream-viewer-header-left",children:[P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("div",{children:[P.jsx("div",{className:"stream-viewer-title",children:(we==null?void 0:we.title)||"Stream"}),P.jsxs("div",{className:"stream-viewer-subtitle",children:[(we==null?void 0:we.broadcasterName)||"..."," ",we?` · ${we.viewerCount} Zuschauer`:""]})]})]}),P.jsxs("div",{className:"stream-viewer-header-right",children:[P.jsx("button",{className:"stream-viewer-fullscreen",onClick:be,title:Ae?"Vollbild verlassen":"Vollbild",children:Ae?"✖":"⛶"}),P.jsx("button",{className:"stream-viewer-close",onClick:Xt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"stream-viewer-video",children:[z.phase==="connecting"?P.jsxs("div",{className:"stream-viewer-connecting",children:[P.jsx("div",{className:"stream-viewer-spinner"}),"Verbindung wird hergestellt..."]}):z.phase==="error"?P.jsxs("div",{className:"stream-viewer-connecting",children:[z.error||"Verbindungsfehler",P.jsx("button",{className:"stream-btn",onClick:Xt,children:"Zurück"})]}):null,P.jsx("video",{ref:te,autoPlay:!0,playsInline:!0,style:z.phase==="connected"?{}:{display:"none"}})]})]})}return P.jsxs("div",{className:"stream-container",children:[x&&P.jsxs("div",{className:"stream-error",children:[x,P.jsx("button",{className:"stream-error-dismiss",onClick:()=>S(null),children:"×"})]}),P.jsxs("div",{className:"stream-topbar",children:[P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Name"}),P.jsx("input",{className:"stream-input stream-input-name",placeholder:"Dein Name",value:r,onChange:we=>s(we.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field stream-field-grow",children:[P.jsx("span",{className:"stream-field-label",children:"Titel"}),P.jsx("input",{className:"stream-input stream-input-title",placeholder:"Stream-Titel",value:a,onChange:we=>l(we.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Passwort"}),P.jsx("input",{className:"stream-input stream-input-password",type:"password",placeholder:"optional",value:u,onChange:we=>h(we.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsxs("span",{className:"stream-field-label",children:["Qualit","ä","t"]}),P.jsx("select",{className:"stream-select-quality",value:m,onChange:we=>v(Number(we.target.value)),disabled:O,children:jS.map((we,Ue)=>P.jsx("option",{value:Ue,children:we.label},we.label))})]}),O?P.jsxs("button",{className:"stream-btn stream-btn-stop",onClick:Wt,children:["⏹"," Stream beenden"]}):P.jsx("button",{className:"stream-btn",onClick:fe,disabled:I,children:I?"Starte...":"🖥️ Stream starten"})]}),t.length===0&&!O?P.jsxs("div",{className:"stream-empty",children:[P.jsx("div",{className:"stream-empty-icon",children:"📺"}),P.jsx("h3",{children:"Keine aktiven Streams"}),P.jsx("p",{children:"Starte einen Stream, um deinen Bildschirm zu teilen."})]}):P.jsxs("div",{className:"stream-grid",children:[O&&P.jsxs("div",{className:"stream-tile own broadcasting",children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("video",{ref:Z,autoPlay:!0,playsInline:!0,muted:!0}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",((De=t.find(we=>we.id===C))==null?void 0:De.viewerCount)??0]})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsxs("div",{className:"stream-tile-name",children:[r," (Du)"]}),P.jsx("div",{className:"stream-tile-title",children:a})]}),P.jsx("span",{className:"stream-tile-time",children:C&&((Je=t.find(we=>we.id===C))!=null&&Je.startedAt)?VS(t.find(we=>we.id===C).startedAt):"0:00"})]})]}),t.filter(we=>we.id!==C).map(we=>P.jsxs("div",{className:"stream-tile",onClick:()=>Gt(we),children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("span",{className:"stream-tile-icon",children:"🖥️"}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",we.viewerCount]}),we.hasPassword&&P.jsx("span",{className:"stream-tile-lock",children:"🔒"})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsx("div",{className:"stream-tile-name",children:we.broadcasterName}),P.jsx("div",{className:"stream-tile-title",children:we.title})]}),P.jsx("span",{className:"stream-tile-time",children:VS(we.startedAt)}),P.jsxs("div",{className:"stream-tile-menu-wrap",children:[P.jsx("button",{className:"stream-tile-menu",onClick:Ue=>{Ue.stopPropagation(),V(q===we.id?null:we.id)},children:"⋮"}),q===we.id&&P.jsxs("div",{className:"stream-tile-dropdown",onClick:Ue=>Ue.stopPropagation(),children:[P.jsxs("div",{className:"stream-tile-dropdown-header",children:[P.jsx("div",{className:"stream-tile-dropdown-name",children:we.broadcasterName}),P.jsx("div",{className:"stream-tile-dropdown-title",children:we.title}),P.jsxs("div",{className:"stream-tile-dropdown-detail",children:["👥"," ",we.viewerCount," Zuschauer · ",VS(we.startedAt)]})]}),P.jsx("div",{className:"stream-tile-dropdown-divider"}),P.jsxs("button",{className:"stream-tile-dropdown-item",onClick:()=>Ne(we.id),children:["🗗"," In neuem Fenster öffnen"]}),P.jsx("button",{className:"stream-tile-dropdown-item",onClick:()=>{le(we.id),V(null)},children:Q===we.id?"✅ Kopiert!":"🔗 Link teilen"})]})]})]})]},we.id))]}),T&&P.jsx("div",{className:"stream-pw-overlay",onClick:()=>N(null),children:P.jsxs("div",{className:"stream-pw-modal",onClick:we=>we.stopPropagation(),children:[P.jsx("h3",{children:T.broadcasterName}),P.jsx("p",{children:T.streamTitle}),T.error&&P.jsx("div",{className:"stream-pw-modal-error",children:T.error}),P.jsx("input",{className:"stream-input",type:"password",placeholder:"Stream-Passwort",value:T.password,onChange:we=>N(Ue=>Ue&&{...Ue,password:we.target.value,error:null}),onKeyDown:we=>{we.key==="Enter"&&_t()},autoFocus:!0}),P.jsxs("div",{className:"stream-pw-actions",children:[P.jsx("button",{className:"stream-pw-cancel",onClick:()=>N(null),children:"Abbrechen"}),P.jsx("button",{className:"stream-btn",onClick:_t,children:"Beitreten"})]})]})})]})}function w7(i){const e=Math.floor(i),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function KAe(i){const e=i.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(e)return{type:"youtube",videoId:e[1]};const t=i.match(/(?:dailymotion\.com\/video\/|dai\.ly\/)([a-zA-Z0-9]+)/);return t?{type:"dailymotion",videoId:t[1]}:/\.(mp4|webm|ogg)(\?|$)/i.test(i)||i.startsWith("http")?{type:"direct",url:i}:null}function ZAe({data:i}){var pn;const[e,t]=re.useState([]),[n,r]=re.useState(()=>localStorage.getItem("wt_name")||""),[s,a]=re.useState(""),[l,u]=re.useState(""),[h,m]=re.useState(null),[v,x]=re.useState(null),[S,T]=re.useState(null),[N,C]=re.useState(""),[E,O]=re.useState(()=>{const $e=localStorage.getItem("wt_volume");return $e?parseFloat($e):1}),[U,I]=re.useState(!1),[j,z]=re.useState(0),[G,H]=re.useState(0),[q,V]=re.useState(null),[Q,J]=re.useState(!1),[ne,oe]=re.useState([]),[ie,Z]=re.useState(""),[te,de]=re.useState(null),[Se,Te]=re.useState("synced"),[ae,Me]=re.useState(!0),[Ve,Ce]=re.useState(()=>localStorage.getItem("wt_yt_quality")||"hd1080"),Fe=re.useRef(null),et=re.useRef(""),He=re.useRef(null),Rt=re.useRef(1e3),Et=re.useRef(null),zt=re.useRef(null),Pt=re.useRef(null),We=re.useRef(null),ft=re.useRef(null),fe=re.useRef(null),Wt=re.useRef(!1),yt=re.useRef(!1),Gt=re.useRef(null),_t=re.useRef(null),Xt=re.useRef(Ve),pt=re.useRef(null),Ae=re.useRef(!1),k=re.useRef(0),be=re.useRef(0);re.useEffect(()=>{Et.current=h},[h]);const Oe=h!=null&&et.current===h.hostId;re.useEffect(()=>{Xt.current=Ve,localStorage.setItem("wt_yt_quality",Ve),Pt.current&&typeof Pt.current.setPlaybackQuality=="function"&&Pt.current.setPlaybackQuality(Ve)},[Ve]),re.useEffect(()=>{i!=null&&i.rooms&&t(i.rooms)},[i]),re.useEffect(()=>{var $e;($e=_t.current)==null||$e.scrollIntoView({behavior:"smooth"})},[ne]),re.useEffect(()=>{const St=new URLSearchParams(window.location.search).get("wt");if(St&&n.trim()){const Kt=setTimeout(()=>ut(St),1500);return()=>clearTimeout(Kt)}},[]),re.useEffect(()=>{n&&localStorage.setItem("wt_name",n)},[n]),re.useEffect(()=>{var $e;localStorage.setItem("wt_volume",String(E)),Pt.current&&typeof Pt.current.setVolume=="function"&&Pt.current.setVolume(E*100),We.current&&(We.current.volume=E),($e=pt.current)!=null&&$e.contentWindow&&fe.current==="dailymotion"&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com")},[E]),re.useEffect(()=>{if(window.YT){Wt.current=!0;return}const $e=document.createElement("script");$e.src="https://www.youtube.com/iframe_api",document.head.appendChild($e);const St=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{Wt.current=!0,St&&St()}},[]);const pe=re.useCallback($e=>{var St;((St=Fe.current)==null?void 0:St.readyState)===WebSocket.OPEN&&Fe.current.send(JSON.stringify($e))},[]),le=re.useCallback(()=>fe.current==="youtube"&&Pt.current&&typeof Pt.current.getCurrentTime=="function"?Pt.current.getCurrentTime():fe.current==="direct"&&We.current?We.current.currentTime:fe.current==="dailymotion"?k.current:null,[]);re.useCallback(()=>fe.current==="youtube"&&Pt.current&&typeof Pt.current.getDuration=="function"?Pt.current.getDuration()||0:fe.current==="direct"&&We.current?We.current.duration||0:fe.current==="dailymotion"?be.current:0,[]);const Ne=re.useCallback(()=>{if(Pt.current){try{Pt.current.destroy()}catch{}Pt.current=null}We.current&&(We.current.pause(),We.current.removeAttribute("src"),We.current.load()),pt.current&&(pt.current.src="",Ae.current=!1,k.current=0,be.current=0),fe.current=null,Gt.current&&(clearInterval(Gt.current),Gt.current=null)},[]),De=re.useCallback($e=>{Ne(),V(null);const St=KAe($e);if(St)if(St.type==="youtube"){if(fe.current="youtube",!Wt.current||!ft.current)return;const Kt=ft.current,wn=document.createElement("div");wn.id="wt-yt-player-"+Date.now(),Kt.innerHTML="",Kt.appendChild(wn),Pt.current=new window.YT.Player(wn.id,{videoId:St.videoId,playerVars:{autoplay:1,controls:0,modestbranding:1,rel:0},events:{onReady:qn=>{qn.target.setVolume(E*100),qn.target.setPlaybackQuality(Xt.current),z(qn.target.getDuration()||0),Gt.current=setInterval(()=>{Pt.current&&typeof Pt.current.getCurrentTime=="function"&&(H(Pt.current.getCurrentTime()),z(Pt.current.getDuration()||0))},500)},onStateChange:qn=>{if(qn.data===window.YT.PlayerState.ENDED){const Ze=Et.current;Ze&&et.current===Ze.hostId&&pe({type:"skip"})}},onError:qn=>{const Ze=qn.data;V(Ze===101||Ze===150?"Embedding deaktiviert — Video kann nur auf YouTube angesehen werden.":Ze===100?"Video nicht gefunden oder entfernt.":"Wiedergabefehler — Video wird übersprungen."),setTimeout(()=>{const dt=Et.current;dt&&et.current===dt.hostId&&pe({type:"skip"})},3e3)}}})}else St.type==="dailymotion"?(fe.current="dailymotion",pt.current&&(pt.current.src=`https://www.dailymotion.com/embed/video/${St.videoId}?api=postMessage&autoplay=1&controls=0&mute=0&queue-enable=0`)):(fe.current="direct",We.current&&(We.current.src=St.url,We.current.volume=E,We.current.play().catch(()=>{})))},[Ne,E,pe]);re.useEffect(()=>{const $e=We.current;if(!$e)return;const St=()=>{const wn=Et.current;wn&&et.current===wn.hostId&&pe({type:"skip"})},Kt=()=>{H($e.currentTime),z($e.duration||0)};return $e.addEventListener("ended",St),$e.addEventListener("timeupdate",Kt),()=>{$e.removeEventListener("ended",St),$e.removeEventListener("timeupdate",Kt)}},[pe]),re.useEffect(()=>{const $e=St=>{var Ze;if(St.origin!=="https://www.dailymotion.com"||typeof St.data!="string")return;const Kt=new URLSearchParams(St.data),wn=Kt.get("method"),qn=Kt.get("value");if(wn==="timeupdate"&&qn){const dt=parseFloat(qn);k.current=dt,H(dt)}else if(wn==="durationchange"&&qn){const dt=parseFloat(qn);be.current=dt,z(dt)}else if(wn==="ended"){const dt=Et.current;dt&&et.current===dt.hostId&&pe({type:"skip"})}else wn==="apiready"&&(Ae.current=!0,(Ze=pt.current)!=null&&Ze.contentWindow&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com"))};return window.addEventListener("message",$e),()=>window.removeEventListener("message",$e)},[pe,E]);const Je=re.useRef(()=>{});Je.current=$e=>{var St,Kt,wn,qn,Ze,dt,Vt,xt,A,ee,Vn,Wn,$n,dn,Fn,lr;switch($e.type){case"welcome":et.current=$e.clientId,$e.rooms&&t($e.rooms);break;case"room_created":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]});break}case"room_joined":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]}),(St=an.currentVideo)!=null&&St.url&&setTimeout(()=>De(an.currentVideo.url),100);break}case"playback_state":{const an=Et.current;if(!an)break;const mn=$e.currentVideo,Er=(Kt=an.currentVideo)==null?void 0:Kt.url;if(mn!=null&&mn.url&&mn.url!==Er?De(mn.url):!mn&&Er&&Ne(),fe.current==="youtube"&&Pt.current){const Wi=(qn=(wn=Pt.current).getPlayerState)==null?void 0:qn.call(wn);$e.playing&&Wi!==((dt=(Ze=window.YT)==null?void 0:Ze.PlayerState)==null?void 0:dt.PLAYING)?(xt=(Vt=Pt.current).playVideo)==null||xt.call(Vt):!$e.playing&&Wi===((ee=(A=window.YT)==null?void 0:A.PlayerState)==null?void 0:ee.PLAYING)&&((Wn=(Vn=Pt.current).pauseVideo)==null||Wn.call(Vn))}else fe.current==="direct"&&We.current?$e.playing&&We.current.paused?We.current.play().catch(()=>{}):!$e.playing&&!We.current.paused&&We.current.pause():fe.current==="dailymotion"&&(($n=pt.current)!=null&&$n.contentWindow)&&($e.playing?pt.current.contentWindow.postMessage("play","https://www.dailymotion.com"):pt.current.contentWindow.postMessage("pause","https://www.dailymotion.com"));if($e.currentTime!==void 0&&!yt.current){const Wi=le();Wi!==null&&Math.abs(Wi-$e.currentTime)>2&&(fe.current==="youtube"&&Pt.current?(Fn=(dn=Pt.current).seekTo)==null||Fn.call(dn,$e.currentTime,!0):fe.current==="direct"&&We.current?We.current.currentTime=$e.currentTime:fe.current==="dailymotion"&&((lr=pt.current)!=null&&lr.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e.currentTime}`,"https://www.dailymotion.com"))}if($e.currentTime!==void 0){const Wi=le();if(Wi!==null){const No=Math.abs(Wi-$e.currentTime);No<1.5?Te("synced"):No<5?Te("drifting"):Te("desynced")}}m(Wi=>Wi&&{...Wi,currentVideo:mn||null,playing:$e.playing,currentTime:$e.currentTime??Wi.currentTime});break}case"queue_updated":m(an=>an&&{...an,queue:$e.queue});break;case"members_updated":m(an=>an&&{...an,members:$e.members,hostId:$e.hostId});break;case"vote_updated":de($e.votes);break;case"chat":oe(an=>{const mn=[...an,{sender:$e.sender,text:$e.text,timestamp:$e.timestamp}];return mn.length>100?mn.slice(-100):mn});break;case"chat_history":oe($e.messages||[]);break;case"error":$e.code==="WRONG_PASSWORD"?x(an=>an&&{...an,error:$e.message}):T($e.message);break}};const we=re.useCallback(()=>{if(Fe.current&&(Fe.current.readyState===WebSocket.OPEN||Fe.current.readyState===WebSocket.CONNECTING))return;const $e=location.protocol==="https:"?"wss":"ws",St=new WebSocket(`${$e}://${location.host}/ws/watch-together`);Fe.current=St,St.onopen=()=>{Rt.current=1e3},St.onmessage=Kt=>{let wn;try{wn=JSON.parse(Kt.data)}catch{return}Je.current(wn)},St.onclose=()=>{Fe.current===St&&(Fe.current=null),Et.current&&(He.current=setTimeout(()=>{Rt.current=Math.min(Rt.current*2,1e4),we()},Rt.current))},St.onerror=()=>{St.close()}},[]),Ue=re.useCallback(()=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}if(!s.trim()){T("Bitte gib einen Raumnamen ein.");return}T(null),we();const $e=Date.now(),St=()=>{var Kt;((Kt=Fe.current)==null?void 0:Kt.readyState)===WebSocket.OPEN?pe({type:"create_room",name:s.trim(),userName:n.trim(),password:l.trim()||void 0}):Date.now()-$e>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(St,100)};St()},[n,s,l,we,pe]),ut=re.useCallback(($e,St)=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}T(null),we();const Kt=Date.now(),wn=()=>{var qn;((qn=Fe.current)==null?void 0:qn.readyState)===WebSocket.OPEN?pe({type:"join_room",userName:n.trim(),roomId:$e,password:(St==null?void 0:St.trim())||void 0}):Date.now()-Kt>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(wn,100)};wn()},[n,we,pe]),Dt=re.useCallback(()=>{pe({type:"leave_room"}),Ne(),m(null),C(""),z(0),H(0),oe([]),de(null),Te("synced")},[pe,Ne]),Bt=re.useCallback(async()=>{const $e=N.trim();if(!$e)return;C(""),J(!0);let St="";try{const Kt=await fetch(`/api/watch-together/video-info?url=${encodeURIComponent($e)}`);Kt.ok&&(St=(await Kt.json()).title||"")}catch{}pe({type:"add_to_queue",url:$e,title:St||void 0}),J(!1)},[N,pe]),ct=re.useCallback(()=>{const $e=ie.trim();$e&&(Z(""),pe({type:"chat_message",text:$e}))},[ie,pe]);re.useCallback(()=>{pe({type:"vote_skip"})},[pe]),re.useCallback(()=>{pe({type:"vote_pause"})},[pe]);const jt=re.useCallback(()=>{pe({type:"clear_watched"})},[pe]),Jt=re.useCallback(()=>{if(!h)return;const $e=`${window.location.origin}${window.location.pathname}?wt=${h.id}`;navigator.clipboard.writeText($e).catch(()=>{})},[h]),In=re.useCallback($e=>{pe({type:"remove_from_queue",index:$e})},[pe]),ge=re.useCallback(()=>{const $e=Et.current;$e&&pe({type:$e.playing?"pause":"resume"})},[pe]),Ot=re.useCallback(()=>{pe({type:"skip"})},[pe]),ot=re.useCallback($e=>{var St,Kt,wn;yt.current=!0,pe({type:"seek",time:$e}),fe.current==="youtube"&&Pt.current?(Kt=(St=Pt.current).seekTo)==null||Kt.call(St,$e,!0):fe.current==="direct"&&We.current?We.current.currentTime=$e:fe.current==="dailymotion"&&((wn=pt.current)!=null&&wn.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e}`,"https://www.dailymotion.com"),H($e),setTimeout(()=>{yt.current=!1},3e3)},[pe]);re.useEffect(()=>{if(!Oe||!(h!=null&&h.playing))return;const $e=setInterval(()=>{const St=le();St!==null&&pe({type:"report_time",time:St})},2e3);return()=>clearInterval($e)},[Oe,h==null?void 0:h.playing,pe,le]);const Tt=re.useCallback(()=>{const $e=zt.current;$e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):$e.requestFullscreen().catch(()=>{}))},[]);re.useEffect(()=>{const $e=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$e),()=>document.removeEventListener("fullscreenchange",$e)},[]),re.useEffect(()=>{const $e=Kt=>{Et.current&&Kt.preventDefault()},St=()=>{et.current&&navigator.sendBeacon("/api/watch-together/disconnect",JSON.stringify({clientId:et.current}))};return window.addEventListener("beforeunload",$e),window.addEventListener("pagehide",St),()=>{window.removeEventListener("beforeunload",$e),window.removeEventListener("pagehide",St)}},[]),re.useEffect(()=>()=>{Ne(),Fe.current&&Fe.current.close(),He.current&&clearTimeout(He.current)},[Ne]);const Ht=re.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(Kt=>Kt&&{...Kt,error:"Passwort eingeben."});return}const{roomId:$e,password:St}=v;x(null),ut($e,St)},[v,ut]),Yt=re.useCallback($e=>{$e.hasPassword?x({roomId:$e.id,roomName:$e.name,password:"",error:null}):ut($e.id)},[ut]);if(h){const $e=h.members.find(St=>St.id===h.hostId);return P.jsxs("div",{className:"wt-room-overlay",ref:zt,children:[P.jsxs("div",{className:"wt-room-header",children:[P.jsxs("div",{className:"wt-room-header-left",children:[P.jsx("span",{className:"wt-room-name",children:h.name}),P.jsxs("span",{className:"wt-room-members",children:[h.members.length," Mitglieder"]}),$e&&P.jsxs("span",{className:"wt-host-badge",children:["Host: ",$e.name]})]}),P.jsxs("div",{className:"wt-room-header-right",children:[P.jsx("div",{className:`wt-sync-dot wt-sync-${Se}`,title:Se==="synced"?"Synchron":Se==="drifting"?"Leichte Verzögerung":"Nicht synchron"}),P.jsx("button",{className:"wt-header-btn",onClick:Jt,title:"Link kopieren",children:"Link"}),P.jsx("button",{className:"wt-header-btn",onClick:()=>Me(St=>!St),title:ae?"Chat ausblenden":"Chat einblenden",children:"Chat"}),P.jsx("button",{className:"wt-fullscreen-btn",onClick:Tt,title:U?"Vollbild verlassen":"Vollbild",children:U?"✖":"⛶"}),P.jsx("button",{className:"wt-leave-btn",onClick:Dt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"wt-room-body",children:[P.jsxs("div",{className:"wt-player-section",children:[P.jsxs("div",{className:"wt-player-wrap",children:[P.jsx("div",{ref:ft,className:"wt-yt-container",style:fe.current==="youtube"?{}:{display:"none"}}),P.jsx("video",{ref:We,className:"wt-video-element",style:fe.current==="direct"?{}:{display:"none"},playsInline:!0}),P.jsx("iframe",{ref:pt,className:"wt-dm-container",style:fe.current==="dailymotion"?{}:{display:"none"},allow:"autoplay; fullscreen",allowFullScreen:!0}),q&&P.jsxs("div",{className:"wt-player-error",children:[P.jsx("div",{className:"wt-error-icon",children:"⚠️"}),P.jsx("p",{children:q}),((pn=h.currentVideo)==null?void 0:pn.url)&&P.jsx("a",{className:"wt-yt-link",href:h.currentVideo.url,target:"_blank",rel:"noopener noreferrer",children:"Auf YouTube öffnen ↗"}),P.jsx("p",{className:"wt-skip-info",children:"Wird in 3 Sekunden übersprungen..."})]}),!h.currentVideo&&P.jsxs("div",{className:"wt-player-placeholder",children:[P.jsx("div",{className:"wt-placeholder-icon",children:"🎬"}),P.jsx("p",{children:"Fuege ein Video zur Warteschlange hinzu"})]})]}),P.jsxs("div",{className:"wt-controls",children:[P.jsx("button",{className:"wt-ctrl-btn",onClick:ge,disabled:!h.currentVideo,title:h.playing?"Pause":"Abspielen",children:h.playing?"⏸":"▶"}),P.jsxs("button",{className:"wt-ctrl-btn wt-next-btn",onClick:Ot,disabled:!h.currentVideo&&h.queue.length===0,title:"Nächstes Video",children:["⏭"," Weiter"]}),P.jsx("input",{className:"wt-seek",type:"range",min:0,max:j||0,step:.5,value:G,onChange:St=>ot(parseFloat(St.target.value)),disabled:!h.currentVideo}),P.jsxs("span",{className:"wt-time",children:[w7(G)," / ",w7(j)]}),P.jsxs("div",{className:"wt-volume",children:[P.jsx("span",{className:"wt-volume-icon",children:E===0?"🔇":E<.5?"🔉":"🔊"}),P.jsx("input",{className:"wt-volume-slider",type:"range",min:0,max:1,step:.01,value:E,onChange:St=>O(parseFloat(St.target.value))})]}),fe.current==="youtube"&&P.jsxs("select",{className:"wt-quality-select",value:Ve,onChange:St=>Ce(St.target.value),title:"Videoqualität",children:[P.jsx("option",{value:"highres",children:"4K+"}),P.jsx("option",{value:"hd2160",children:"2160p"}),P.jsx("option",{value:"hd1440",children:"1440p"}),P.jsx("option",{value:"hd1080",children:"1080p"}),P.jsx("option",{value:"hd720",children:"720p"}),P.jsx("option",{value:"large",children:"480p"}),P.jsx("option",{value:"medium",children:"360p"}),P.jsx("option",{value:"small",children:"240p"})]})]})]}),P.jsxs("div",{className:"wt-queue-panel",children:[P.jsxs("div",{className:"wt-queue-header",children:[P.jsxs("span",{children:["Warteschlange (",h.queue.length,")"]}),h.queue.some(St=>St.watched)&&P.jsx("button",{className:"wt-queue-clear-btn",onClick:jt,title:"Gesehene entfernen",children:"Gesehene entfernen"})]}),P.jsx("div",{className:"wt-queue-list",children:h.queue.length===0?P.jsx("div",{className:"wt-queue-empty",children:"Keine Videos in der Warteschlange"}):h.queue.map((St,Kt)=>{var qn,Ze;const wn=((qn=h.currentVideo)==null?void 0:qn.url)===St.url;return P.jsxs("div",{className:`wt-queue-item${wn?" playing":""}${St.watched&&!wn?" watched":""} clickable`,onClick:()=>pe({type:"play_video",index:Kt}),title:"Klicken zum Abspielen",children:[P.jsxs("div",{className:"wt-queue-item-info",children:[St.watched&&!wn&&P.jsx("span",{className:"wt-queue-item-check",children:"✓"}),St.url.match(/youtu/)&&P.jsx("img",{className:"wt-queue-thumb",src:`https://img.youtube.com/vi/${(Ze=St.url.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/))==null?void 0:Ze[1]}/default.jpg`,alt:""}),P.jsxs("div",{className:"wt-queue-item-text",children:[P.jsx("div",{className:"wt-queue-item-title",children:St.title||St.url}),P.jsx("div",{className:"wt-queue-item-by",children:St.addedBy})]})]}),Oe&&P.jsx("button",{className:"wt-queue-item-remove",onClick:dt=>{dt.stopPropagation(),In(Kt)},title:"Entfernen",children:"×"})]},Kt)})}),P.jsxs("div",{className:"wt-queue-add",children:[P.jsx("input",{className:"wt-input wt-queue-input",placeholder:"Video-URL eingeben",value:N,onChange:St=>C(St.target.value),onKeyDown:St=>{St.key==="Enter"&&Bt()}}),P.jsx("button",{className:"wt-btn wt-queue-add-btn",onClick:Bt,disabled:Q,children:Q?"Laden...":"Hinzufuegen"})]})]}),ae&&P.jsxs("div",{className:"wt-chat-panel",children:[P.jsx("div",{className:"wt-chat-header",children:"Chat"}),P.jsxs("div",{className:"wt-chat-messages",children:[ne.length===0?P.jsx("div",{className:"wt-chat-empty",children:"Noch keine Nachrichten"}):ne.map((St,Kt)=>P.jsxs("div",{className:"wt-chat-msg",children:[P.jsx("span",{className:"wt-chat-sender",children:St.sender}),P.jsx("span",{className:"wt-chat-text",children:St.text})]},Kt)),P.jsx("div",{ref:_t})]}),P.jsxs("div",{className:"wt-chat-input-row",children:[P.jsx("input",{className:"wt-input wt-chat-input",placeholder:"Nachricht...",value:ie,onChange:St=>Z(St.target.value),onKeyDown:St=>{St.key==="Enter"&&ct()},maxLength:500}),P.jsx("button",{className:"wt-btn wt-chat-send-btn",onClick:ct,children:"Senden"})]})]})]})]})}return P.jsxs("div",{className:"wt-container",children:[S&&P.jsxs("div",{className:"wt-error",children:[S,P.jsx("button",{className:"wt-error-dismiss",onClick:()=>T(null),children:"×"})]}),P.jsxs("div",{className:"wt-topbar",children:[P.jsx("input",{className:"wt-input wt-input-name",placeholder:"Dein Name",value:n,onChange:$e=>r($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-room",placeholder:"Raumname",value:s,onChange:$e=>a($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-password",type:"password",placeholder:"Passwort (optional)",value:l,onChange:$e=>u($e.target.value)}),P.jsx("button",{className:"wt-btn",onClick:Ue,children:"Raum erstellen"})]}),e.length===0?P.jsxs("div",{className:"wt-empty",children:[P.jsx("div",{className:"wt-empty-icon",children:"🎬"}),P.jsx("h3",{children:"Keine aktiven Raeume"}),P.jsx("p",{children:"Erstelle einen Raum, um gemeinsam Videos zu schauen."})]}):P.jsx("div",{className:"wt-grid",children:e.map($e=>P.jsxs("div",{className:"wt-tile",onClick:()=>Yt($e),children:[P.jsxs("div",{className:"wt-tile-preview",children:[P.jsx("span",{className:"wt-tile-icon",children:"🎬"}),P.jsxs("span",{className:"wt-tile-members",children:["👥"," ",$e.memberCount]}),$e.hasPassword&&P.jsx("span",{className:"wt-tile-lock",children:"🔒"}),$e.playing&&P.jsx("span",{className:"wt-tile-playing",children:"▶"})]}),P.jsxs("div",{className:"wt-tile-info",children:[P.jsxs("div",{className:"wt-tile-meta",children:[P.jsx("div",{className:"wt-tile-name",children:$e.name}),P.jsx("div",{className:"wt-tile-host",children:$e.hostName})]}),$e.memberNames&&$e.memberNames.length>0&&P.jsxs("div",{className:"wt-tile-members-list",children:[$e.memberNames.slice(0,5).join(", "),$e.memberNames.length>5&&` +${$e.memberNames.length-5}`]})]})]},$e.id))}),v&&P.jsx("div",{className:"wt-modal-overlay",onClick:()=>x(null),children:P.jsxs("div",{className:"wt-modal",onClick:$e=>$e.stopPropagation(),children:[P.jsx("h3",{children:v.roomName}),P.jsx("p",{children:"Raum-Passwort"}),v.error&&P.jsx("div",{className:"wt-modal-error",children:v.error}),P.jsx("input",{className:"wt-input",type:"password",placeholder:"Passwort",value:v.password,onChange:$e=>x(St=>St&&{...St,password:$e.target.value,error:null}),onKeyDown:$e=>{$e.key==="Enter"&&Ht()},autoFocus:!0}),P.jsxs("div",{className:"wt-modal-actions",children:[P.jsx("button",{className:"wt-modal-cancel",onClick:()=>x(null),children:"Abbrechen"}),P.jsx("button",{className:"wt-btn",onClick:Ht,children:"Beitreten"})]})]})})]})}function HS(i,e){return`https://media.steampowered.com/steamcommunity/public/images/apps/${i}/${e}.jpg`}function T7(i){if(i==null||i===0)return"—";if(i<60)return`${i} Min`;const e=Math.floor(i/60),t=i%60;return t>0?`${e}h ${t}m`:`${e}h`}function JAe(i){try{return new Date(i).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function e0e({data:i,isAdmin:e}){const[t,n]=re.useState([]),[r,s]=re.useState("overview"),[a,l]=re.useState(null),[u,h]=re.useState(new Set),[m,v]=re.useState(null),[x,S]=re.useState(null),[T,N]=re.useState(""),[C,E]=re.useState(null),[O,U]=re.useState(!1),[I,j]=re.useState(null),[z,G]=re.useState(new Set),[H,q]=re.useState("playtime"),V=re.useRef(null),Q=re.useRef(null),[J,ne]=re.useState("");re.useEffect(()=>{i!=null&&i.profiles&&n(i.profiles)},[i]);const oe=re.useCallback(async()=>{try{const le=await fetch("/api/game-library/profiles");if(le.ok){const Ne=await le.json();n(Ne.profiles||[])}}catch{}},[]),ie=re.useCallback(()=>{const le=window.open("/api/game-library/steam/login","_blank","width=800,height=600"),Ne=setInterval(()=>{le&&le.closed&&(clearInterval(Ne),setTimeout(oe,1e3))},500)},[oe]),Z=navigator.userAgent.includes("GamingHubDesktop"),[te,de]=re.useState(!1),[Se,Te]=re.useState(""),[ae,Me]=re.useState("idle"),[Ve,Ce]=re.useState(""),Fe=re.useCallback(()=>{const le=a?`?linkTo=${a}`:"";if(Z){const Ne=window.open(`/api/game-library/gog/login${le}`,"_blank","width=800,height=700"),De=setInterval(()=>{Ne&&Ne.closed&&(clearInterval(De),setTimeout(oe,1e3))},500)}else window.open(`/api/game-library/gog/login${le}`,"_blank","width=800,height=700"),Te(""),Me("idle"),Ce(""),de(!0)},[oe,a,Z]),et=re.useCallback(async()=>{let le=Se.trim();const Ne=le.match(/[?&]code=([^&]+)/);if(Ne&&(le=Ne[1]),!!le){Me("loading"),Ce("Verbinde mit GOG...");try{const De=await fetch("/api/game-library/gog/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:le,linkTo:a||""})}),Je=await De.json();De.ok&&Je.ok?(Me("success"),Ce(`${Je.profileName}: ${Je.gameCount} Spiele geladen!`),oe(),setTimeout(()=>de(!1),2e3)):(Me("error"),Ce(Je.error||"Unbekannter Fehler"))}catch{Me("error"),Ce("Verbindung fehlgeschlagen.")}}},[Se,a,oe]);re.useEffect(()=>{const le=()=>oe();return window.addEventListener("gog-connected",le),()=>window.removeEventListener("gog-connected",le)},[oe]),re.useEffect(()=>{const le=()=>oe();return window.addEventListener("focus",le),()=>window.removeEventListener("focus",le)},[oe]);const He=re.useCallback(async le=>{var Ne,De;s("user"),l(le),v(null),ne(""),U(!0);try{const Je=await fetch(`/api/game-library/profile/${le}/games`);if(Je.ok){const we=await Je.json(),Ue=we.games||we;v(Ue);const ut=t.find(Bt=>Bt.id===le),Dt=(De=(Ne=ut==null?void 0:ut.platforms)==null?void 0:Ne.steam)==null?void 0:De.steamId;Dt&&Ue.filter(ct=>!ct.igdb).length>0&&(j(le),fetch(`/api/game-library/igdb/enrich/${Dt}`).then(ct=>ct.ok?ct.json():null).then(()=>fetch(`/api/game-library/profile/${le}/games`)).then(ct=>ct.ok?ct.json():null).then(ct=>{ct&&v(ct.games||ct)}).catch(()=>{}).finally(()=>j(null)))}}catch{}finally{U(!1)}},[t]),Rt=re.useCallback(async(le,Ne)=>{var we,Ue;Ne&&Ne.stopPropagation();const De=t.find(ut=>ut.id===le),Je=(Ue=(we=De==null?void 0:De.platforms)==null?void 0:we.steam)==null?void 0:Ue.steamId;try{Je&&await fetch(`/api/game-library/user/${Je}?refresh=true`),await oe(),r==="user"&&a===le&&He(le)}catch{}},[oe,r,a,He,t]),Et=re.useCallback(async le=>{var Je,we;const Ne=t.find(Ue=>Ue.id===le),De=(we=(Je=Ne==null?void 0:Ne.platforms)==null?void 0:Je.steam)==null?void 0:we.steamId;if(De){j(le);try{(await fetch(`/api/game-library/igdb/enrich/${De}`)).ok&&r==="user"&&a===le&&He(le)}catch{}finally{j(null)}}},[r,a,He,t]),zt=re.useCallback(le=>{h(Ne=>{const De=new Set(Ne);return De.has(le)?De.delete(le):De.add(le),De})},[]),Pt=re.useCallback(async()=>{if(!(u.size<2)){s("common"),S(null),U(!0);try{const le=Array.from(u).join(","),Ne=await fetch(`/api/game-library/common-games?users=${le}`);if(Ne.ok){const De=await Ne.json();S(De.games||De)}else console.error("[GameLibrary] common-games error:",Ne.status,await Ne.text().catch(()=>"")),S([])}catch(le){console.error("[GameLibrary] common-games fetch failed:",le)}finally{U(!1)}}},[u]),We=re.useCallback(le=>{if(N(le),V.current&&clearTimeout(V.current),le.length<2){E(null);return}V.current=setTimeout(async()=>{try{const Ne=await fetch(`/api/game-library/search?q=${encodeURIComponent(le)}`);if(Ne.ok){const De=await Ne.json();E(De.results||De)}}catch{}},300)},[]),ft=re.useCallback(le=>{G(Ne=>{const De=new Set(Ne);return De.has(le)?De.delete(le):De.add(le),De})},[]),fe=re.useCallback(async(le,Ne)=>{if(confirm(`${Ne==="steam"?"Steam":"GOG"}-Verknuepfung wirklich trennen?`))try{const De=await fetch(`/api/game-library/profile/${le}/${Ne}`,{method:"DELETE"});if(De.ok&&(oe(),(await De.json()).ok)){const we=t.find(ut=>ut.id===le);(Ne==="steam"?we==null?void 0:we.platforms.gog:we==null?void 0:we.platforms.steam)||Wt()}}catch{}},[oe,t]);re.useCallback(async le=>{const Ne=t.find(De=>De.id===le);if(confirm(`Profil "${Ne==null?void 0:Ne.displayName}" wirklich komplett loeschen?`))try{(await fetch(`/api/game-library/profile/${le}`,{method:"DELETE"})).ok&&(oe(),Wt())}catch{}},[oe,t]);const Wt=re.useCallback(()=>{s("overview"),l(null),v(null),S(null),ne(""),G(new Set),q("playtime")},[]),yt=Wt,Gt=re.useCallback(le=>t.find(Ne=>Ne.id===le),[t]),_t=re.useCallback(le=>typeof le.playtime_forever=="number"?le.playtime_forever:Array.isArray(le.owners)?Math.max(...le.owners.map(Ne=>Ne.playtime_forever||0)):0,[]),Xt=re.useCallback(le=>[...le].sort((Ne,De)=>{var Je,we;if(H==="rating"){const Ue=((Je=Ne.igdb)==null?void 0:Je.rating)??-1;return(((we=De.igdb)==null?void 0:we.rating)??-1)-Ue}return H==="name"?Ne.name.localeCompare(De.name):_t(De)-_t(Ne)}),[H,_t]),pt=re.useCallback(le=>{var Ne,De;return z.size===0?!0:(De=(Ne=le.igdb)==null?void 0:Ne.genres)!=null&&De.length?le.igdb.genres.some(Je=>z.has(Je)):!1},[z]),Ae=re.useCallback(le=>{var De;const Ne=new Map;for(const Je of le)if((De=Je.igdb)!=null&&De.genres)for(const we of Je.igdb.genres)Ne.set(we,(Ne.get(we)||0)+1);return[...Ne.entries()].sort((Je,we)=>we[1]-Je[1]).map(([Je])=>Je)},[]),k=m?Xt(m.filter(le=>!J||le.name.toLowerCase().includes(J.toLowerCase())).filter(pt)):null,be=m?Ae(m):[],Oe=x?Ae(x):[],pe=x?Xt(x.filter(pt)):null;return P.jsxs("div",{className:"gl-container",children:[P.jsxs("div",{className:"gl-login-bar",children:[!a&&P.jsx("button",{className:"gl-connect-btn gl-steam-btn",onClick:ie,children:"🎮 Steam verbinden"}),P.jsx("div",{className:"gl-login-bar-spacer"})]}),t.length>0&&P.jsx("div",{className:"gl-profile-chips",children:t.map(le=>P.jsxs("div",{className:`gl-profile-chip${a===le.id?" selected":""}`,onClick:()=>He(le.id),children:[P.jsx("img",{className:"gl-profile-chip-avatar",src:le.avatarUrl,alt:le.displayName}),P.jsxs("div",{className:"gl-profile-chip-info",children:[P.jsx("span",{className:"gl-profile-chip-name",children:le.displayName}),P.jsxs("span",{className:"gl-profile-chip-platforms",children:[le.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:`Steam: ${le.platforms.steam.gameCount} Spiele`,children:"S"}),le.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:`GOG: ${le.platforms.gog.gameCount} Spiele`,children:"G"})]})]}),P.jsxs("span",{className:"gl-profile-chip-count",children:["(",le.totalGames,")"]})]},le.id))}),r==="overview"&&P.jsx(P.Fragment,{children:t.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"🎮"}),P.jsx("h3",{children:"Keine Konten verbunden"}),P.jsx("p",{children:"Klicke oben auf “Steam verbinden” oder “GOG verbinden”, um deine Spielebibliothek hinzuzufuegen."})]}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"gl-section-title",children:"Verbundene Spieler"}),P.jsx("div",{className:"gl-users-grid",children:t.map(le=>P.jsxs("div",{className:"gl-user-card",onClick:()=>He(le.id),children:[P.jsx("img",{className:"gl-user-card-avatar",src:le.avatarUrl,alt:le.displayName}),P.jsx("span",{className:"gl-user-card-name",children:le.displayName}),P.jsxs("div",{className:"gl-profile-card-platforms",children:[le.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:"Steam",children:"S"}),le.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:"GOG",children:"G"})]}),P.jsxs("span",{className:"gl-user-card-games",children:[le.totalGames," Spiele"]}),P.jsxs("span",{className:"gl-user-card-updated",children:["Aktualisiert: ",JAe(le.lastUpdated)]})]},le.id))}),t.length>=2&&P.jsxs("div",{className:"gl-common-finder",children:[P.jsx("h3",{children:"Gemeinsame Spiele finden"}),P.jsx("div",{className:"gl-common-users",children:t.map(le=>P.jsxs("label",{className:`gl-common-check${u.has(le.id)?" checked":""}`,children:[P.jsx("input",{type:"checkbox",checked:u.has(le.id),onChange:()=>zt(le.id)}),P.jsx("img",{className:"gl-common-check-avatar",src:le.avatarUrl,alt:le.displayName}),le.displayName,P.jsxs("span",{className:"gl-profile-chip-platforms",style:{marginLeft:4},children:[le.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",children:"S"}),le.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",children:"G"})]})]},le.id))}),P.jsx("button",{className:"gl-common-find-btn",disabled:u.size<2,onClick:Pt,children:"Finden"})]}),P.jsx("div",{className:"gl-search",children:P.jsx("input",{className:"gl-search-input",type:"text",placeholder:"Spiel suchen...",value:T,onChange:le=>We(le.target.value)})}),C&&C.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"gl-search-results-title",children:[C.length," Ergebnis",C.length!==1?"se":""]}),P.jsx("div",{className:"gl-game-list",children:C.map(le=>P.jsxs("div",{className:"gl-game-item",children:[le.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(le.appid,le.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"}),P.jsx("span",{className:"gl-game-name",children:le.name}),P.jsx("div",{className:"gl-game-owners",children:le.owners.map(Ne=>{const De=t.find(Je=>{var we;return((we=Je.platforms.steam)==null?void 0:we.steamId)===Ne.steamId});return De?P.jsx("img",{className:"gl-game-owner-avatar",src:De.avatarUrl,alt:Ne.personaName,title:Ne.personaName},Ne.steamId):null})})]},le.appid))})]}),C&&C.length===0&&P.jsx("p",{className:"gl-search-results-title",children:"Keine Ergebnisse gefunden."})]})}),r==="user"&&(()=>{const le=a?Gt(a):null;return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:yt,children:"← Zurueck"}),le&&P.jsxs(P.Fragment,{children:[P.jsx("img",{className:"gl-detail-avatar",src:le.avatarUrl,alt:le.displayName}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsxs("div",{className:"gl-detail-name",children:[le.displayName,P.jsxs("span",{className:"gl-game-count",children:[le.totalGames," Spiele"]})]}),P.jsxs("div",{className:"gl-detail-sub",children:[le.platforms.steam&&P.jsxs("span",{className:"gl-platform-detail steam",children:[P.jsx("span",{className:"gl-platform-badge steam",children:"Steam ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:Ne=>{Ne.stopPropagation(),fe(le.id,"steam")},title:"Steam trennen",children:"✕"})]}),le.platforms.gog?P.jsxs("span",{className:"gl-platform-detail gog",children:[P.jsx("span",{className:"gl-platform-badge gog",children:"GOG ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:Ne=>{Ne.stopPropagation(),fe(le.id,"gog")},title:"GOG trennen",children:"✕"})]}):P.jsx("button",{className:"gl-link-gog-btn",onClick:Fe,children:"🟣 GOG verknuepfen"})]})]}),P.jsx("button",{className:"gl-refresh-btn",onClick:()=>Rt(le.id),title:"Aktualisieren",children:"↻"}),le.platforms.steam&&P.jsxs("button",{className:`gl-enrich-btn ${I===a?"enriching":""}`,onClick:()=>Et(a),disabled:I===a,title:I===a?"IGDB-Daten werden geladen...":"Mit IGDB-Daten anreichern (erneut)",children:[I===a?"⏳":"🌐"," IGDB"]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Bibliothek wird geladen..."}):k?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-filter-bar",children:[P.jsx("input",{ref:Q,className:"gl-search-input",type:"text",placeholder:"Bibliothek durchsuchen...",value:J,onChange:Ne=>ne(Ne.target.value)}),P.jsxs("select",{className:"gl-sort-select",value:H,onChange:Ne=>q(Ne.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})]}),be.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),be.map(Ne=>P.jsx("button",{className:`gl-genre-chip${z.has(Ne)?" active":""}`,onClick:()=>ft(Ne),children:Ne},Ne))]}),P.jsxs("p",{className:"gl-filter-count",children:[k.length," Spiele"]}),k.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Spiele gefunden."}):P.jsx("div",{className:"gl-game-list",children:k.map((Ne,De)=>{var Je,we,Ue;return P.jsxs("div",{className:`gl-game-item ${Ne.igdb?"enriched":""}`,children:[P.jsx("span",{className:`gl-game-platform-icon ${Ne.platform||"steam"}`,children:Ne.platform==="gog"?"G":"S"}),P.jsx("div",{className:"gl-game-visual",children:(Je=Ne.igdb)!=null&&Je.coverUrl?P.jsx("img",{className:"gl-game-cover",src:Ne.igdb.coverUrl,alt:""}):Ne.img_icon_url&&Ne.appid?P.jsx("img",{className:"gl-game-icon",src:HS(Ne.appid,Ne.img_icon_url),alt:""}):Ne.image?P.jsx("img",{className:"gl-game-icon",src:Ne.image,alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:Ne.name}),((we=Ne.igdb)==null?void 0:we.genres)&&Ne.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:Ne.igdb.genres.slice(0,3).map(ut=>P.jsx("span",{className:"gl-genre-tag",children:ut},ut))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Ue=Ne.igdb)==null?void 0:Ue.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${Ne.igdb.rating>=75?"high":Ne.igdb.rating>=50?"mid":"low"}`,children:Math.round(Ne.igdb.rating)}),P.jsx("span",{className:"gl-game-playtime",children:T7(Ne.playtime_forever)})]})]},Ne.appid??Ne.gogId??De)})})]}):null]})})(),r==="common"&&(()=>{const le=Array.from(u).map(De=>Gt(De)).filter(Boolean),Ne=le.map(De=>De.displayName).join(", ");return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:yt,children:"← Zurueck"}),P.jsx("div",{className:"gl-detail-avatars",children:le.map(De=>P.jsx("img",{src:De.avatarUrl,alt:De.displayName},De.id))}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsx("div",{className:"gl-detail-name",children:"Gemeinsame Spiele"}),P.jsxs("div",{className:"gl-detail-sub",children:["von ",Ne]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Gemeinsame Spiele werden gesucht..."}):x?x.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"😔"}),P.jsx("h3",{children:"Keine gemeinsamen Spiele"}),P.jsx("p",{children:"Die ausgewaehlten Spieler besitzen leider keine gemeinsamen Spiele."})]}):P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"gl-filter-bar",children:P.jsxs("select",{className:"gl-sort-select",value:H,onChange:De=>q(De.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})}),Oe.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),Oe.map(De=>P.jsx("button",{className:`gl-genre-chip${z.has(De)?" active":""}`,onClick:()=>ft(De),children:De},De))]}),P.jsxs("p",{className:"gl-section-title",children:[pe.length," gemeinsame",pe.length!==1?" Spiele":"s Spiel",z.size>0?` (von ${x.length})`:""]}),P.jsx("div",{className:"gl-game-list",children:pe.map(De=>{var Je,we,Ue;return P.jsxs("div",{className:`gl-game-item ${De.igdb?"enriched":""}`,children:[P.jsx("div",{className:"gl-game-visual",children:(Je=De.igdb)!=null&&Je.coverUrl?P.jsx("img",{className:"gl-game-cover",src:De.igdb.coverUrl,alt:""}):De.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(De.appid,De.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:De.name}),((we=De.igdb)==null?void 0:we.genres)&&De.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:De.igdb.genres.slice(0,3).map(ut=>P.jsx("span",{className:"gl-genre-tag",children:ut},ut))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Ue=De.igdb)==null?void 0:Ue.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${De.igdb.rating>=75?"high":De.igdb.rating>=50?"mid":"low"}`,children:Math.round(De.igdb.rating)}),P.jsx("div",{className:"gl-common-playtimes",children:De.owners.map(ut=>P.jsxs("span",{className:"gl-common-pt",children:[ut.personaName,": ",T7(ut.playtime_forever)]},ut.steamId))})]})]},De.appid)})})]}):null]})})(),te&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>de(!1),children:P.jsxs("div",{className:"gl-dialog",onClick:le=>le.stopPropagation(),children:[P.jsx("h3",{children:"🟣 GOG verbinden"}),P.jsxs("p",{className:"gl-dialog-hint",children:["Nach dem GOG-Login wirst du auf eine Seite weitergeleitet. Kopiere die ",P.jsx("strong",{children:"komplette URL"})," aus der Adressleiste und füge sie hier ein:"]}),P.jsx("input",{className:"gl-dialog-input",type:"text",placeholder:"https://embed.gog.com/on_login_success?code=...",value:Se,onChange:le=>Te(le.target.value),onKeyDown:le=>{le.key==="Enter"&&et()},disabled:ae==="loading"||ae==="success",autoFocus:!0}),Ve&&P.jsx("p",{className:`gl-dialog-status ${ae}`,children:Ve}),P.jsxs("div",{className:"gl-dialog-actions",children:[P.jsx("button",{onClick:()=>de(!1),className:"gl-dialog-cancel",children:"Abbrechen"}),P.jsx("button",{onClick:et,className:"gl-dialog-submit",disabled:!Se.trim()||ae==="loading"||ae==="success",children:ae==="loading"?"Verbinde...":"Verbinden"})]})]})})]})}const lx="/api/soundboard";async function t0e(){const i=new URL(`${lx}/sounds`,window.location.origin);i.searchParams.set("folder","__all__"),i.searchParams.set("fuzzy","0");const e=await fetch(i.toString());if(!e.ok)throw new Error("Fehler beim Laden der Sounds");return e.json()}async function n0e(i){if(!(await fetch(`${lx}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}async function i0e(i,e){const t=await fetch(`${lx}/admin/sounds/rename`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({from:i,to:e})});if(!t.ok)throw new Error("Umbenennen fehlgeschlagen");const n=await t.json();return n==null?void 0:n.to}function r0e(i,e){return new Promise((t,n)=>{const r=new FormData;r.append("files",i);const s=new XMLHttpRequest;s.open("POST",`${lx}/upload`),s.upload.onprogress=a=>{a.lengthComputable&&e(Math.round(a.loaded/a.total*100))},s.onload=()=>{var a,l;if(s.status===200)try{const u=JSON.parse(s.responseText);t(((l=(a=u.files)==null?void 0:a[0])==null?void 0:l.name)??i.name)}catch{t(i.name)}else try{n(new Error(JSON.parse(s.responseText).error))}catch{n(new Error(`HTTP ${s.status}`))}},s.onerror=()=>n(new Error("Netzwerkfehler")),s.send(r)})}function s0e({onClose:i}){var be,Oe;const[e,t]=re.useState("soundboard"),[n,r]=re.useState(null),s=re.useCallback((pe,le="info")=>{r({msg:pe,type:le}),setTimeout(()=>r(null),3e3)},[]);re.useEffect(()=>{const pe=le=>{le.key==="Escape"&&i()};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},[i]);const[a,l]=re.useState([]),[u,h]=re.useState(!1),[m,v]=re.useState(""),[x,S]=re.useState({}),[T,N]=re.useState(""),[C,E]=re.useState(""),[O,U]=re.useState(null),I=re.useCallback(pe=>pe.relativePath??pe.fileName,[]),j=re.useCallback(async()=>{h(!0);try{const pe=await t0e();l(pe.items||[])}catch(pe){s((pe==null?void 0:pe.message)||"Sounds konnten nicht geladen werden","error")}finally{h(!1)}},[s]),[z,G]=re.useState(!1);re.useEffect(()=>{e==="soundboard"&&!z&&(G(!0),j())},[e,z,j]);const H=re.useMemo(()=>{const pe=m.trim().toLowerCase();return pe?a.filter(le=>{const Ne=I(le).toLowerCase();return le.name.toLowerCase().includes(pe)||(le.folder||"").toLowerCase().includes(pe)||Ne.includes(pe)}):a},[m,a,I]),q=re.useMemo(()=>Object.keys(x).filter(pe=>x[pe]),[x]),V=re.useMemo(()=>H.filter(pe=>!!x[I(pe)]).length,[H,x,I]),Q=H.length>0&&V===H.length;function J(pe){S(le=>({...le,[pe]:!le[pe]}))}function ne(pe){N(I(pe)),E(pe.name)}function oe(){N(""),E("")}async function ie(){if(!T)return;const pe=C.trim().replace(/\.(mp3|wav)$/i,"");if(!pe){s("Bitte einen gueltigen Namen eingeben","error");return}try{await i0e(T,pe),s("Sound umbenannt"),oe(),await j()}catch(le){s((le==null?void 0:le.message)||"Umbenennen fehlgeschlagen","error")}}async function Z(pe){if(pe.length!==0)try{await n0e(pe),s(pe.length===1?"Sound geloescht":`${pe.length} Sounds geloescht`),S({}),oe(),await j()}catch(le){s((le==null?void 0:le.message)||"Loeschen fehlgeschlagen","error")}}async function te(pe){U(0);try{await r0e(pe,le=>U(le)),s(`"${pe.name}" hochgeladen`),await j()}catch(le){s((le==null?void 0:le.message)||"Upload fehlgeschlagen","error")}finally{U(null)}}const[de,Se]=re.useState([]),[Te,ae]=re.useState([]),[Me,Ve]=re.useState(!1),[Ce,Fe]=re.useState(!1),[et,He]=re.useState({online:!1,botTag:null}),Rt=re.useCallback(async()=>{Ve(!0);try{const[pe,le,Ne]=await Promise.all([fetch("/api/notifications/status"),fetch("/api/notifications/channels",{credentials:"include"}),fetch("/api/notifications/config",{credentials:"include"})]);if(pe.ok){const De=await pe.json();He(De)}if(le.ok){const De=await le.json();Se(De.channels||[])}if(Ne.ok){const De=await Ne.json();ae(De.channels||[])}}catch{}finally{Ve(!1)}},[]),[Et,zt]=re.useState(!1);re.useEffect(()=>{e==="streaming"&&!Et&&(zt(!0),Rt())},[e,Et,Rt]);const Pt=re.useCallback((pe,le,Ne,De,Je)=>{ae(we=>{const Ue=we.find(ut=>ut.channelId===pe);if(Ue){const Dt=Ue.events.includes(Je)?Ue.events.filter(Bt=>Bt!==Je):[...Ue.events,Je];return Dt.length===0?we.filter(Bt=>Bt.channelId!==pe):we.map(Bt=>Bt.channelId===pe?{...Bt,events:Dt}:Bt)}else return[...we,{channelId:pe,channelName:le,guildId:Ne,guildName:De,events:[Je]}]})},[]),We=re.useCallback((pe,le)=>{const Ne=Te.find(De=>De.channelId===pe);return(Ne==null?void 0:Ne.events.includes(le))??!1},[Te]),ft=re.useCallback(async()=>{Fe(!0);try{await fetch("/api/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channels:Te}),credentials:"include"}),s("Konfiguration gespeichert")}catch{s("Speichern fehlgeschlagen","error")}finally{Fe(!1)}},[Te,s]),[fe,Wt]=re.useState([]),[yt,Gt]=re.useState(!1),_t=re.useCallback(async()=>{Gt(!0);try{const pe=await fetch("/api/game-library/admin/profiles",{credentials:"include"});if(pe.ok){const le=await pe.json();Wt(le.profiles||[])}}catch{}finally{Gt(!1)}},[]),[Xt,pt]=re.useState(!1);re.useEffect(()=>{e==="game-library"&&!Xt&&(pt(!0),_t())},[e,Xt,_t]);const Ae=re.useCallback(async(pe,le)=>{if(confirm(`Profil "${le}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`))try{(await fetch(`/api/game-library/admin/profile/${pe}`,{method:"DELETE",credentials:"include"})).ok&&(s("Profil geloescht"),_t())}catch{s("Loeschen fehlgeschlagen","error")}},[_t,s]),k=[{id:"soundboard",icon:"🎵",label:"Soundboard"},{id:"streaming",icon:"📺",label:"Streaming"},{id:"game-library",icon:"🎮",label:"Game Library"}];return P.jsx("div",{className:"ap-overlay",onClick:pe=>{pe.target===pe.currentTarget&&i()},children:P.jsxs("div",{className:"ap-modal",children:[P.jsxs("div",{className:"ap-sidebar",children:[P.jsxs("div",{className:"ap-sidebar-title",children:["⚙️"," Admin"]}),P.jsx("nav",{className:"ap-nav",children:k.map(pe=>P.jsxs("button",{className:`ap-nav-item ${e===pe.id?"active":""}`,onClick:()=>t(pe.id),children:[P.jsx("span",{className:"ap-nav-icon",children:pe.icon}),P.jsx("span",{className:"ap-nav-label",children:pe.label})]},pe.id))})]}),P.jsxs("div",{className:"ap-content",children:[P.jsxs("div",{className:"ap-header",children:[P.jsxs("h2",{className:"ap-title",children:[(be=k.find(pe=>pe.id===e))==null?void 0:be.icon," ",(Oe=k.find(pe=>pe.id===e))==null?void 0:Oe.label]}),P.jsx("button",{className:"ap-close",onClick:i,children:"✕"})]}),P.jsxs("div",{className:"ap-body",children:[e==="soundboard"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsx("input",{type:"text",className:"ap-search",value:m,onChange:pe=>v(pe.target.value),placeholder:"Nach Name, Ordner oder Pfad filtern..."}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{j()},disabled:u,children:["↻"," Aktualisieren"]})]}),P.jsxs("label",{className:"ap-upload-zone",children:[P.jsx("input",{type:"file",accept:".mp3,.wav",style:{display:"none"},onChange:pe=>{var Ne;const le=(Ne=pe.target.files)==null?void 0:Ne[0];le&&te(le),pe.target.value=""}}),O!==null?P.jsxs("span",{className:"ap-upload-progress",children:["Upload: ",O,"%"]}):P.jsxs("span",{className:"ap-upload-text",children:["⬆️"," Datei hochladen (MP3 / WAV)"]})]}),P.jsxs("div",{className:"ap-bulk-row",children:[P.jsxs("label",{className:"ap-select-all",children:[P.jsx("input",{type:"checkbox",checked:Q,onChange:pe=>{const le=pe.target.checked,Ne={...x};H.forEach(De=>{Ne[I(De)]=le}),S(Ne)}}),P.jsxs("span",{children:["Alle sichtbaren (",V,"/",H.length,")"]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger",disabled:q.length===0,onClick:async()=>{window.confirm(`Wirklich ${q.length} Sound(s) loeschen?`)&&await Z(q)},children:["🗑️"," Ausgewaehlte loeschen"]})]}),P.jsx("div",{className:"ap-list-wrap",children:u?P.jsx("div",{className:"ap-empty",children:"Lade Sounds..."}):H.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Sounds gefunden."}):P.jsx("div",{className:"ap-list",children:H.map(pe=>{const le=I(pe),Ne=T===le;return P.jsxs("div",{className:"ap-item",children:[P.jsx("label",{className:"ap-item-check",children:P.jsx("input",{type:"checkbox",checked:!!x[le],onChange:()=>J(le)})}),P.jsxs("div",{className:"ap-item-main",children:[P.jsx("div",{className:"ap-item-name",children:pe.name}),P.jsxs("div",{className:"ap-item-meta",children:[pe.folder?`Ordner: ${pe.folder}`:"Root"," · ",le]}),Ne&&P.jsxs("div",{className:"ap-rename-row",children:[P.jsx("input",{className:"ap-rename-input",value:C,onChange:De=>E(De.target.value),onKeyDown:De=>{De.key==="Enter"&&ie(),De.key==="Escape"&&oe()},placeholder:"Neuer Name...",autoFocus:!0}),P.jsx("button",{className:"ap-btn ap-btn-primary ap-btn-sm",onClick:()=>{ie()},children:"Speichern"}),P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:oe,children:"Abbrechen"})]})]}),!Ne&&P.jsxs("div",{className:"ap-item-actions",children:[P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:()=>ne(pe),children:"Umbenennen"}),P.jsx("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:async()=>{window.confirm(`Sound "${pe.name}" loeschen?`)&&await Z([le])},children:"Loeschen"})]})]},le)})})})]}),e==="streaming"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:`ap-status-dot ${et.online?"online":""}`}),et.online?P.jsxs(P.Fragment,{children:["Bot online: ",P.jsx("b",{children:et.botTag})]}):P.jsx(P.Fragment,{children:"Bot offline"})]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{Rt()},disabled:Me,children:["↻"," Aktualisieren"]})]}),Me?P.jsx("div",{className:"ap-empty",children:"Lade Kanaele..."}):de.length===0?P.jsx("div",{className:"ap-empty",children:et.online?"Keine Text-Kanaele gefunden. Bot hat moeglicherweise keinen Zugriff.":"Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren."}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"ap-hint",children:"Waehle die Kanaele, in die Benachrichtigungen gesendet werden sollen:"}),P.jsx("div",{className:"ap-channel-list",children:de.map(pe=>P.jsxs("div",{className:"ap-channel-row",children:[P.jsxs("div",{className:"ap-channel-info",children:[P.jsxs("span",{className:"ap-channel-name",children:["#",pe.channelName]}),P.jsx("span",{className:"ap-channel-guild",children:pe.guildName})]}),P.jsxs("div",{className:"ap-channel-toggles",children:[P.jsxs("label",{className:`ap-toggle ${We(pe.channelId,"stream_start")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:We(pe.channelId,"stream_start"),onChange:()=>Pt(pe.channelId,pe.channelName,pe.guildId,pe.guildName,"stream_start")}),"🔴"," Stream Start"]}),P.jsxs("label",{className:`ap-toggle ${We(pe.channelId,"stream_end")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:We(pe.channelId,"stream_end"),onChange:()=>Pt(pe.channelId,pe.channelName,pe.guildId,pe.guildName,"stream_end")}),"⏹️"," Stream Ende"]})]})]},pe.channelId))}),P.jsx("div",{className:"ap-save-row",children:P.jsx("button",{className:"ap-btn ap-btn-primary",onClick:ft,disabled:Ce,children:Ce?"Speichern...":"💾 Speichern"})})]})]}),e==="game-library"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:"ap-status-dot online"}),"Eingeloggt als Admin"]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{_t()},disabled:yt,children:["↻"," Aktualisieren"]})]}),yt?P.jsx("div",{className:"ap-empty",children:"Lade Profile..."}):fe.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Profile vorhanden."}):P.jsx("div",{className:"ap-profile-list",children:fe.map(pe=>P.jsxs("div",{className:"ap-profile-row",children:[P.jsx("img",{className:"ap-profile-avatar",src:pe.avatarUrl,alt:pe.displayName}),P.jsxs("div",{className:"ap-profile-info",children:[P.jsx("span",{className:"ap-profile-name",children:pe.displayName}),P.jsxs("span",{className:"ap-profile-details",children:[pe.steamName&&P.jsxs("span",{className:"ap-platform-badge steam",children:["Steam: ",pe.steamGames]}),pe.gogName&&P.jsxs("span",{className:"ap-platform-badge gog",children:["GOG: ",pe.gogGames]}),P.jsxs("span",{className:"ap-profile-total",children:[pe.totalGames," Spiele"]})]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:()=>Ae(pe.id,pe.displayName),children:["🗑️"," Entfernen"]})]},pe.id))})]})]})]}),n&&P.jsxs("div",{className:`ap-toast ${n.type}`,children:[n.type==="error"?"❌":"✅"," ",n.msg]})]})})}const M7={radio:MAe,soundboard:jAe,lolstats:YAe,streaming:QAe,"watch-together":ZAe,"game-library":e0e};function a0e(){var Z;const[i,e]=re.useState(!1),[t,n]=re.useState([]),[r,s]=re.useState(()=>localStorage.getItem("hub_activeTab")??""),a=te=>{s(te),localStorage.setItem("hub_activeTab",te)},[l,u]=re.useState(!1),[h,m]=re.useState({}),[v,x]=re.useState(!1),[S,T]=re.useState(!1),[N,C]=re.useState(!1),[E,O]=re.useState(""),[U,I]=re.useState(""),j=!!((Z=window.electronAPI)!=null&&Z.isElectron),z=j?window.electronAPI.version:null,[G,H]=re.useState("idle"),[q,V]=re.useState(""),Q=re.useRef(null);re.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]),re.useEffect(()=>{fetch("/api/soundboard/admin/status",{credentials:"include"}).then(te=>te.json()).then(te=>x(!!te.authenticated)).catch(()=>{})},[]),re.useEffect(()=>{if(!S)return;const te=de=>{de.key==="Escape"&&T(!1)};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[S]);async function J(){I("");try{(await fetch("/api/soundboard/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:E}),credentials:"include"})).ok?(x(!0),O(""),T(!1)):I("Falsches Passwort")}catch{I("Verbindung fehlgeschlagen")}}async function ne(){await fetch("/api/soundboard/admin/logout",{method:"POST",credentials:"include"}),x(!1)}re.useEffect(()=>{var Se;if(!j)return;const te=window.electronAPI;te.onUpdateAvailable(()=>H("downloading")),te.onUpdateReady(()=>H("ready")),te.onUpdateNotAvailable(()=>H("upToDate")),te.onUpdateError(Te=>{H("error"),V(Te||"Unbekannter Fehler")});const de=(Se=te.getUpdateStatus)==null?void 0:Se.call(te);de==="downloading"?H("downloading"):de==="ready"?H("ready"):de==="checking"&&H("checking")},[j]),re.useEffect(()=>{fetch("/api/plugins").then(te=>te.json()).then(te=>{if(n(te),new URLSearchParams(location.search).has("viewStream")&&te.some(ae=>ae.name==="streaming")){a("streaming");return}const Se=localStorage.getItem("hub_activeTab"),Te=te.some(ae=>ae.name===Se);te.length>0&&!Te&&a(te[0].name)}).catch(()=>{})},[]),re.useEffect(()=>{let te=null,de;function Se(){te=new EventSource("/api/events"),Q.current=te,te.onopen=()=>e(!0),te.onmessage=Te=>{try{const ae=JSON.parse(Te.data);ae.type==="snapshot"?m(Me=>({...Me,...ae})):ae.plugin&&m(Me=>({...Me,[ae.plugin]:{...Me[ae.plugin]||{},...ae}}))}catch{}},te.onerror=()=>{e(!1),te==null||te.close(),de=setTimeout(Se,3e3)}}return Se(),()=>{te==null||te.close(),clearTimeout(de)}},[]);const oe="1.0.0-dev";re.useEffect(()=>{if(!l)return;const te=de=>{de.key==="Escape"&&u(!1)};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[l]);const ie={radio:"🌍",soundboard:"🎵",lolstats:"⚔️",stats:"📊",events:"📅",games:"🎲",gamevote:"🎮",streaming:"📺","watch-together":"🎬","game-library":"🎮"};return P.jsxs("div",{className:"hub-app",children:[P.jsxs("header",{className:"hub-header",children:[P.jsxs("div",{className:"hub-header-left",children:[P.jsx("span",{className:"hub-logo",children:"🎮"}),P.jsx("span",{className:"hub-title",children:"Gaming Hub"}),P.jsx("span",{className:`hub-conn-dot ${i?"online":""}`})]}),P.jsx("nav",{className:"hub-tabs",children:t.filter(te=>te.name in M7).map(te=>P.jsxs("button",{className:`hub-tab ${r===te.name?"active":""}`,onClick:()=>a(te.name),title:te.description,children:[P.jsx("span",{className:"hub-tab-icon",children:ie[te.name]??"📦"}),P.jsx("span",{className:"hub-tab-label",children:te.name})]},te.name))}),P.jsxs("div",{className:"hub-header-right",children:[!window.electronAPI&&P.jsxs("a",{className:"hub-download-btn",href:"/downloads/GamingHub-Setup.exe",download:!0,title:"Desktop App herunterladen",children:[P.jsx("span",{className:"hub-download-icon",children:"⬇️"}),P.jsx("span",{className:"hub-download-label",children:"Desktop App"})]}),P.jsx("button",{className:`hub-admin-btn ${v?"active":""}`,onClick:()=>v?C(!0):T(!0),onContextMenu:te=>{v&&(te.preventDefault(),ne())},title:v?"Admin Panel (Rechtsklick = Abmelden)":"Admin Login",children:v?"🔓":"🔒"}),P.jsx("button",{className:"hub-refresh-btn",onClick:()=>window.location.reload(),title:"Seite neu laden",children:"🔄"}),P.jsxs("span",{className:"hub-version hub-version-clickable",onClick:()=>{var te;if(j){const de=window.electronAPI,Se=(te=de.getUpdateStatus)==null?void 0:te.call(de);Se==="downloading"?H("downloading"):Se==="ready"?H("ready"):Se==="checking"&&H("checking")}u(!0)},title:"Versionsinformationen",children:["v",oe]})]})]}),l&&P.jsx("div",{className:"hub-version-overlay",onClick:()=>u(!1),children:P.jsxs("div",{className:"hub-version-modal",onClick:te=>te.stopPropagation(),children:[P.jsxs("div",{className:"hub-version-modal-header",children:[P.jsx("span",{children:"Versionsinformationen"}),P.jsx("button",{className:"hub-version-modal-close",onClick:()=>u(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-version-modal-body",children:[P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Hub-Version"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",oe]})]}),j&&P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Desktop-App"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",z]})]}),P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Server"}),P.jsxs("span",{className:"hub-version-modal-value",children:[P.jsx("span",{className:`hub-version-modal-dot ${i?"online":""}`}),i?"Verbunden":"Getrennt"]})]}),j&&P.jsxs("div",{className:"hub-version-modal-update",children:[G==="idle"&&P.jsxs("button",{className:"hub-version-modal-update-btn",onClick:()=>{H("checking"),V(""),window.electronAPI.checkForUpdates()},children:["🔄"," Nach Updates suchen"]}),G==="checking"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Suche nach Updates…"]}),G==="downloading"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Update wird heruntergeladen…"]}),G==="ready"&&P.jsxs("button",{className:"hub-version-modal-update-btn ready",onClick:()=>window.electronAPI.installUpdate(),children:["✅"," Jetzt installieren & neu starten"]}),G==="upToDate"&&P.jsxs("div",{className:"hub-version-modal-update-status success",children:["✅"," App ist aktuell",P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut prüfen"})]}),G==="error"&&P.jsxs("div",{className:"hub-version-modal-update-status error",children:["❌"," ",q,P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut versuchen"})]})]})]})]})}),S&&P.jsx("div",{className:"hub-admin-overlay",onClick:()=>T(!1),children:P.jsxs("div",{className:"hub-admin-modal",onClick:te=>te.stopPropagation(),children:[P.jsxs("div",{className:"hub-admin-modal-header",children:[P.jsxs("span",{children:["🔒"," Admin Login"]}),P.jsx("button",{className:"hub-admin-modal-close",onClick:()=>T(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-admin-modal-body",children:[P.jsx("input",{type:"password",className:"hub-admin-input",placeholder:"Admin-Passwort...",value:E,onChange:te=>O(te.target.value),onKeyDown:te=>te.key==="Enter"&&J(),autoFocus:!0}),U&&P.jsx("p",{className:"hub-admin-error",children:U}),P.jsx("button",{className:"hub-admin-submit",onClick:J,children:"Login"})]})]})}),N&&v&&P.jsx(s0e,{onClose:()=>C(!1)}),P.jsx("main",{className:"hub-content",children:t.length===0?P.jsxs("div",{className:"hub-empty",children:[P.jsx("span",{className:"hub-empty-icon",children:"📦"}),P.jsx("h2",{children:"Keine Plugins geladen"}),P.jsx("p",{children:"Plugins werden im Server konfiguriert."})]}):t.map(te=>{const de=M7[te.name];if(!de)return null;const Se=r===te.name;return P.jsx("div",{className:`hub-tab-panel ${Se?"active":""}`,style:Se?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{display:"none"},children:P.jsx(de,{data:h[te.name]||{},isAdmin:v})},te.name)})})]})}IF.createRoot(document.getElementById("root")).render(P.jsx(a0e,{})); +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function m7(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function zf(i){for(var e=1;e1?l-1:0),h=1;h1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=a();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(u){return s[u]=+s[u]}),!n)l(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new la(r).to(s,n).easing(os.Cubic.InOut).onUpdate(l).start())}return this;function a(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(u){var h=u.lat,m=u.lng,v=u.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(h,m,v)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;slocalStorage.getItem("radio-theme")||"default"),[a,l]=se.useState([]),[u,h]=se.useState(null),[m,v]=se.useState([]),[x,S]=se.useState(!1),[T,N]=se.useState({}),[C,E]=se.useState([]),[O,U]=se.useState(""),[I,j]=se.useState(""),[z,G]=se.useState(""),[H,q]=se.useState([]),[V,Q]=se.useState(!1),[J,ie]=se.useState([]),[le,re]=se.useState(!1),[Z,ne]=se.useState(!1),[de,be]=se.useState(.5),[Te,ae]=se.useState(null),[Me,Ve]=se.useState(!1),[Ce,Fe]=se.useState(!1),tt=se.useRef(void 0),je=se.useRef(void 0),Rt=se.useRef(O);se.useEffect(()=>{fetch("/api/radio/places").then(k=>k.json()).then(l).catch(console.error),fetch("/api/radio/guilds").then(k=>k.json()).then(k=>{if(E(k),k.length>0){U(k[0].id);const xe=k[0].voiceChannels.find(Oe=>Oe.members>0)??k[0].voiceChannels[0];xe&&j(xe.id)}}).catch(console.error),fetch("/api/radio/favorites").then(k=>k.json()).then(ie).catch(console.error)},[]),se.useEffect(()=>{Rt.current=O},[O]),se.useEffect(()=>{i!=null&&i.guildId&&"playing"in i&&i.type!=="radio_voicestats"?N(k=>{if(i.playing)return{...k,[i.guildId]:i.playing};const xe={...k};return delete xe[i.guildId],xe}):i!=null&&i.playing&&!(i!=null&&i.guildId)&&N(i.playing),i!=null&&i.favorites&&ie(i.favorites),i!=null&&i.volumes&&O&&i.volumes[O]!=null&&be(i.volumes[O]),(i==null?void 0:i.volume)!=null&&(i==null?void 0:i.guildId)===O&&be(i.volume),(i==null?void 0:i.type)==="radio_voicestats"&&i.guildId===Rt.current&&ae({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})},[i,O]),se.useEffect(()=>{if(localStorage.setItem("radio-theme",r),t.current&&e.current){const xe=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim();t.current.pointColor(()=>`rgba(${xe}, 0.85)`).atmosphereColor(`rgba(${xe}, 0.25)`)}},[r]);const Et=se.useRef(u);Et.current=u;const Ft=se.useRef(le);Ft.current=le;const Ut=se.useCallback(()=>{var xe;const k=(xe=t.current)==null?void 0:xe.controls();k&&(k.autoRotate=!1),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{var Ue;if(Et.current||Ft.current)return;const Oe=(Ue=t.current)==null?void 0:Ue.controls();Oe&&(Oe.autoRotate=!0)},5e3)},[]);se.useEffect(()=>{var xe;const k=(xe=t.current)==null?void 0:xe.controls();k&&(u||le?(k.autoRotate=!1,n.current&&clearTimeout(n.current)):k.autoRotate=!0)},[u,le]);const Ke=se.useRef(void 0);Ke.current=k=>{h(k),re(!1),S(!0),v([]),Ut(),t.current&&t.current.pointOfView({lat:k.geo[1],lng:k.geo[0],altitude:.4},800),fetch(`/api/radio/place/${k.id}/channels`).then(xe=>xe.json()).then(xe=>{v(xe),S(!1)}).catch(()=>S(!1))},se.useEffect(()=>{const k=e.current;if(!k)return;k.clientWidth>0&&k.clientHeight>0&&Fe(!0);const xe=new ResizeObserver(Oe=>{for(const Ue of Oe){const{width:ee,height:we}=Ue.contentRect;ee>0&&we>0&&Fe(!0)}});return xe.observe(k),()=>xe.disconnect()},[]),se.useEffect(()=>{if(!e.current||a.length===0)return;const k=e.current.clientWidth,xe=e.current.clientHeight;if(t.current){t.current.pointsData(a),k>0&&xe>0&&t.current.width(k).height(xe);return}if(k===0||xe===0)return;const Ue=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim()||"230, 126, 34",ee=new wAe(e.current).backgroundColor("rgba(0,0,0,0)").atmosphereColor(`rgba(${Ue}, 0.25)`).atmosphereAltitude(.12).globeImageUrl("/nasa-blue-marble.jpg").pointsData(a).pointLat(It=>It.geo[1]).pointLng(It=>It.geo[0]).pointColor(()=>`rgba(${Ue}, 0.85)`).pointRadius(It=>Math.max(.12,Math.min(.45,.06+(It.size??1)*.005))).pointAltitude(.001).pointResolution(24).pointLabel(It=>`
${It.title}
${It.country}
`).onPointClick(It=>{var lt;return(lt=Ke.current)==null?void 0:lt.call(Ke,It)}).width(e.current.clientWidth).height(e.current.clientHeight);ee.renderer().setPixelRatio(window.devicePixelRatio),ee.pointOfView({lat:48,lng:10,altitude:qS});const we=ee.controls();we&&(we.autoRotate=!0,we.autoRotateSpeed=.3);let Re=qS;const We=()=>{const lt=ee.pointOfView().altitude;if(Math.abs(lt-Re)/Re<.05)return;Re=lt;const jt=Math.sqrt(lt/qS);ee.pointRadius(Jt=>Math.max(.12,Math.min(.45,.06+(Jt.size??1)*.005))*Math.max(.15,Math.min(2.5,jt)))};we.addEventListener("change",We),t.current=ee;const Se=e.current,Le=()=>Ut();Se.addEventListener("mousedown",Le),Se.addEventListener("touchstart",Le),Se.addEventListener("wheel",Le);const ct=()=>{if(e.current&&t.current){const It=e.current.clientWidth,lt=e.current.clientHeight;It>0&<>0&&t.current.width(It).height(lt)}};window.addEventListener("resize",ct);const Dt=new ResizeObserver(()=>ct());return Dt.observe(Se),()=>{we.removeEventListener("change",We),Se.removeEventListener("mousedown",Le),Se.removeEventListener("touchstart",Le),Se.removeEventListener("wheel",Le),window.removeEventListener("resize",ct),Dt.disconnect()}},[a,Ut,Ce]);const ht=se.useCallback(async(k,xe,Oe,Ue)=>{if(!(!O||!I)){ne(!0);try{(await(await fetch("/api/radio/play",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,voiceChannelId:I,stationId:k,stationName:xe,placeName:Oe??(u==null?void 0:u.title)??"",country:Ue??(u==null?void 0:u.country)??""})})).json()).ok&&(N(Re=>{var We,Se;return{...Re,[O]:{stationId:k,stationName:xe,placeName:Oe??(u==null?void 0:u.title)??"",country:Ue??(u==null?void 0:u.country)??"",startedAt:new Date().toISOString(),channelName:((Se=(We=C.find(Le=>Le.id===O))==null?void 0:We.voiceChannels.find(Le=>Le.id===I))==null?void 0:Se.name)??""}}}),Ut())}catch(ee){console.error(ee)}ne(!1)}},[O,I,u,C]),fe=se.useCallback(async()=>{O&&(await fetch("/api/radio/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O})}),N(k=>{const xe={...k};return delete xe[O],xe}))},[O]),$t=se.useCallback(k=>{if(G(k),tt.current&&clearTimeout(tt.current),!k.trim()){q([]),Q(!1);return}tt.current=setTimeout(async()=>{try{const Oe=await(await fetch(`/api/radio/search?q=${encodeURIComponent(k)}`)).json();q(Oe),Q(!0)}catch{q([])}},350)},[]),_t=se.useCallback(k=>{var xe,Oe,Ue;if(Q(!1),G(""),q([]),k.type==="channel"){const ee=(xe=k.url.match(/\/listen\/[^/]+\/([^/]+)/))==null?void 0:xe[1];ee&&ht(ee,k.title,k.subtitle,"")}else if(k.type==="place"){const ee=(Oe=k.url.match(/\/visit\/[^/]+\/([^/]+)/))==null?void 0:Oe[1],we=a.find(Re=>Re.id===ee);we&&((Ue=Ke.current)==null||Ue.call(Ke,we))}},[a,ht]),Gt=se.useCallback(async(k,xe)=>{try{const Ue=await(await fetch("/api/radio/favorites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stationId:k,stationName:xe,placeName:(u==null?void 0:u.title)??"",country:(u==null?void 0:u.country)??"",placeId:(u==null?void 0:u.id)??""})})).json();Ue.favorites&&ie(Ue.favorites)}catch{}},[u]),yt=se.useCallback(k=>{be(k),O&&(je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{fetch("/api/radio/volume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,volume:k})}).catch(console.error)},100))},[O]),Ht=k=>J.some(xe=>xe.stationId===k),pt=O?T[O]:null,Ae=C.find(k=>k.id===O);return P.jsxs("div",{className:"radio-container","data-theme":r,children:[P.jsxs("header",{className:"radio-topbar",children:[P.jsxs("div",{className:"radio-topbar-left",children:[P.jsx("span",{className:"radio-topbar-logo",children:"🌍"}),P.jsx("span",{className:"radio-topbar-title",children:"World Radio"}),C.length>1&&P.jsx("select",{className:"radio-sel",value:O,onChange:k=>{U(k.target.value);const xe=C.find(Ue=>Ue.id===k.target.value),Oe=(xe==null?void 0:xe.voiceChannels.find(Ue=>Ue.members>0))??(xe==null?void 0:xe.voiceChannels[0]);j((Oe==null?void 0:Oe.id)??"")},children:C.map(k=>P.jsx("option",{value:k.id,children:k.name},k.id))}),P.jsxs("select",{className:"radio-sel",value:I,onChange:k=>j(k.target.value),children:[P.jsx("option",{value:"",children:"Voice Channel..."}),Ae==null?void 0:Ae.voiceChannels.map(k=>P.jsxs("option",{value:k.id,children:["🔊"," ",k.name,k.members>0?` (${k.members})`:""]},k.id))]})]}),pt&&P.jsxs("div",{className:"radio-topbar-np",children:[P.jsxs("div",{className:"radio-eq radio-eq-np",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),P.jsxs("div",{className:"radio-np-info",children:[P.jsx("span",{className:"radio-np-name",children:pt.stationName}),P.jsxs("span",{className:"radio-np-loc",children:[pt.placeName,pt.country?`, ${pt.country}`:""]})]})]}),P.jsxs("div",{className:"radio-topbar-right",children:[pt&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"radio-volume",children:[P.jsx("span",{className:"radio-volume-icon",children:de===0?"🔇":de<.4?"🔉":"🔊"}),P.jsx("input",{type:"range",className:"radio-volume-slider",min:0,max:1,step:.01,value:de,onChange:k=>yt(Number(k.target.value))}),P.jsxs("span",{className:"radio-volume-val",children:[Math.round(de*100),"%"]})]}),P.jsxs("div",{className:"radio-conn",onClick:()=>Ve(!0),title:"Verbindungsdetails",children:[P.jsx("span",{className:"radio-conn-dot"}),"Verbunden",(Te==null?void 0:Te.voicePing)!=null&&P.jsxs("span",{className:"radio-conn-ping",children:[Te.voicePing,"ms"]})]}),P.jsxs("button",{className:"radio-topbar-stop",onClick:fe,children:["⏹"," Stop"]})]}),P.jsx("div",{className:"radio-theme-inline",children:TAe.map(k=>P.jsx("div",{className:`radio-theme-dot ${r===k.id?"active":""}`,style:{background:k.color},title:k.label,onClick:()=>s(k.id)},k.id))})]})]}),P.jsxs("div",{className:"radio-globe-wrap",children:[P.jsx("div",{className:"radio-globe",ref:e}),P.jsxs("div",{className:"radio-search",children:[P.jsxs("div",{className:"radio-search-wrap",children:[P.jsx("span",{className:"radio-search-icon",children:"🔍"}),P.jsx("input",{className:"radio-search-input",type:"text",placeholder:"Sender oder Stadt suchen...",value:z,onChange:k=>$t(k.target.value),onFocus:()=>{H.length&&Q(!0)}}),z&&P.jsx("button",{className:"radio-search-clear",onClick:()=>{G(""),q([]),Q(!1)},children:"✕"})]}),V&&H.length>0&&P.jsx("div",{className:"radio-search-results",children:H.slice(0,12).map(k=>P.jsxs("button",{className:"radio-search-result",onClick:()=>_t(k),children:[P.jsx("span",{className:"radio-search-result-icon",children:k.type==="channel"?"📻":k.type==="place"?"📍":"🌍"}),P.jsxs("div",{className:"radio-search-result-text",children:[P.jsx("span",{className:"radio-search-result-title",children:k.title}),P.jsx("span",{className:"radio-search-result-sub",children:k.subtitle})]})]},k.id+k.url))})]}),!u&&!le&&P.jsxs("button",{className:"radio-fab",onClick:()=>{re(!0),h(null)},title:"Favoriten",children:["⭐",J.length>0&&P.jsx("span",{className:"radio-fab-badge",children:J.length})]}),le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("h3",{children:["⭐"," Favoriten"]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>re(!1),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:J.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Noch keine Favoriten"}):J.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.stationId?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.stationName}),P.jsxs("span",{className:"radio-station-loc",children:[k.placeName,", ",k.country]})]}),P.jsxs("div",{className:"radio-station-btns",children:[P.jsx("button",{className:"radio-btn-play",onClick:()=>ht(k.stationId,k.stationName,k.placeName,k.country),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:"radio-btn-fav active",onClick:()=>Gt(k.stationId,k.stationName),children:"★"})]})]},k.stationId))})]}),u&&!le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("div",{children:[P.jsx("h3",{children:u.title}),P.jsx("span",{className:"radio-panel-sub",children:u.country})]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>h(null),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:x?P.jsxs("div",{className:"radio-panel-loading",children:[P.jsx("div",{className:"radio-spinner"}),"Sender werden geladen..."]}):m.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Keine Sender gefunden"}):m.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.id?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.title}),(pt==null?void 0:pt.stationId)===k.id&&P.jsxs("span",{className:"radio-station-live",children:[P.jsxs("span",{className:"radio-eq",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),"Live"]})]}),P.jsxs("div",{className:"radio-station-btns",children:[(pt==null?void 0:pt.stationId)===k.id?P.jsx("button",{className:"radio-btn-stop",onClick:fe,children:"⏹"}):P.jsx("button",{className:"radio-btn-play",onClick:()=>ht(k.id,k.title),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:`radio-btn-fav ${Ht(k.id)?"active":""}`,onClick:()=>Gt(k.id,k.title),children:Ht(k.id)?"★":"☆"})]})]},k.id))})]}),P.jsxs("div",{className:"radio-counter",children:["📻"," ",a.length.toLocaleString("de-DE")," Sender weltweit"]}),P.jsx("a",{className:"radio-attribution",href:"https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/",target:"_blank",rel:"noreferrer",children:"Imagery © NASA Blue Marble"})]}),Me&&(()=>{const k=Te!=null&&Te.connectedSince?Math.floor((Date.now()-new Date(Te.connectedSince).getTime())/1e3):0,xe=Math.floor(k/3600),Oe=Math.floor(k%3600/60),Ue=k%60,ee=xe>0?`${xe}h ${String(Oe).padStart(2,"0")}m ${String(Ue).padStart(2,"0")}s`:Oe>0?`${Oe}m ${String(Ue).padStart(2,"0")}s`:`${Ue}s`,we=Re=>Re==null?"var(--text-faint)":Re<80?"var(--success)":Re<150?"#f0a830":"#e04040";return P.jsx("div",{className:"radio-modal-overlay",onClick:()=>Ve(!1),children:P.jsxs("div",{className:"radio-modal",onClick:Re=>Re.stopPropagation(),children:[P.jsxs("div",{className:"radio-modal-header",children:[P.jsx("span",{children:"📡"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"radio-modal-close",onClick:()=>Ve(!1),children:"✕"})]}),P.jsxs("div",{className:"radio-modal-body",children:[P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Voice Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:we((Te==null?void 0:Te.voicePing)??null)}}),(Te==null?void 0:Te.voicePing)!=null?`${Te.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Gateway Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:we((Te==null?void 0:Te.gatewayPing)??null)}}),Te&&Te.gatewayPing>=0?`${Te.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Status"}),P.jsx("span",{className:"radio-modal-value",style:{color:(Te==null?void 0:Te.status)==="ready"?"var(--success)":"#f0a830"},children:(Te==null?void 0:Te.status)==="ready"?"Verbunden":(Te==null?void 0:Te.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Kanal"}),P.jsx("span",{className:"radio-modal-value",children:(Te==null?void 0:Te.channelName)||"---"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Verbunden seit"}),P.jsx("span",{className:"radio-modal-value",children:ee||"---"})]})]})]})})})()]})}function EAe(i,e,t=365){const n=new Date(Date.now()+t*24*60*60*1e3).toUTCString();document.cookie=`${encodeURIComponent(i)}=${encodeURIComponent(e)}; expires=${n}; path=/; SameSite=Lax`}function CAe(i){const e=`${encodeURIComponent(i)}=`,t=document.cookie.split(";");for(const n of t){const r=n.trim();if(r.startsWith(e))return decodeURIComponent(r.slice(e.length))}return null}const ca="/api/soundboard";async function NAe(i,e,t,n){const r=new URL(`${ca}/sounds`,window.location.origin);i&&r.searchParams.set("q",i),e!==void 0&&r.searchParams.set("folder",e),r.searchParams.set("fuzzy","0");const s=await fetch(r.toString());if(!s.ok)throw new Error("Fehler beim Laden der Sounds");return s.json()}async function RAe(){const i=await fetch(`${ca}/analytics`);if(!i.ok)throw new Error("Fehler beim Laden der Analytics");return i.json()}async function DAe(){const i=await fetch(`${ca}/categories`,{credentials:"include"});if(!i.ok)throw new Error("Fehler beim Laden der Kategorien");return i.json()}async function PAe(){const i=await fetch(`${ca}/channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channels");return i.json()}async function LAe(){const i=await fetch(`${ca}/selected-channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channel-Auswahl");const e=await i.json();return(e==null?void 0:e.selected)||{}}async function UAe(i,e){if(!(await fetch(`${ca}/selected-channel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Channel-Auswahl setzen fehlgeschlagen")}async function BAe(i,e,t,n,r){const s=await fetch(`${ca}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({soundName:i,guildId:e,channelId:t,volume:n,relativePath:r})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error((a==null?void 0:a.error)||"Play fehlgeschlagen")}}async function OAe(i,e,t,n,r){const s=await fetch(`${ca}/play-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,guildId:e,channelId:t,volume:n,filename:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error((a==null?void 0:a.error)||"Play-URL fehlgeschlagen");return a}async function IAe(i,e){const t=await fetch(`${ca}/download-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,filename:e})}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error((n==null?void 0:n.error)||"Download fehlgeschlagen");return n}async function FAe(i,e){if(!(await fetch(`${ca}/party/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Partymode Start fehlgeschlagen")}async function kAe(i){if(!(await fetch(`${ca}/party/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i})})).ok)throw new Error("Partymode Stop fehlgeschlagen")}async function g7(i,e){const t=await fetch(`${ca}/volume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,volume:e})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error((n==null?void 0:n.error)||"Volume aendern fehlgeschlagen")}}async function zAe(i){const e=new URL(`${ca}/volume`,window.location.origin);e.searchParams.set("guildId",i);const t=await fetch(e.toString());if(!t.ok)throw new Error("Fehler beim Laden der Lautstaerke");const n=await t.json();return typeof(n==null?void 0:n.volume)=="number"?n.volume:1}async function GAe(i){if(!(await fetch(`${ca}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}function qAe(i,e,t){return new Promise((n,r)=>{const s=new FormData;s.append("files",i),e&&s.append("customName",e);const a=new XMLHttpRequest;a.open("POST",`${ca}/upload`),a.upload.onprogress=l=>{l.lengthComputable&&t(Math.round(l.loaded/l.total*100))},a.onload=()=>{var l,u;if(a.status===200)try{const h=JSON.parse(a.responseText);n(((u=(l=h.files)==null?void 0:l[0])==null?void 0:u.name)??i.name)}catch{n(i.name)}else try{r(new Error(JSON.parse(a.responseText).error))}catch{r(new Error(`HTTP ${a.status}`))}},a.onerror=()=>r(new Error("Netzwerkfehler")),a.send(s)})}const VAe=[{id:"default",color:"#5865f2",label:"Discord"},{id:"purple",color:"#9b59b6",label:"Midnight"},{id:"forest",color:"#2ecc71",label:"Forest"},{id:"sunset",color:"#e67e22",label:"Sunset"},{id:"ocean",color:"#3498db",label:"Ocean"}],v7=["#3b82f6","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#06b6d4","#ef4444","#a855f7","#84cc16","#d946ef","#0ea5e9","#f43f5e","#10b981"];function jAe({data:i,isAdmin:e}){var qe,qt,Qt;const[t,n]=se.useState([]),[r,s]=se.useState(0),[a,l]=se.useState([]),[u,h]=se.useState([]),[m,v]=se.useState({totalSounds:0,totalPlays:0,mostPlayed:[]}),[x,S]=se.useState("all"),[T,N]=se.useState(""),[C,E]=se.useState(""),[O,U]=se.useState(""),[I,j]=se.useState(!1),[z,G]=se.useState(null),[H,q]=se.useState([]),[V,Q]=se.useState(""),J=se.useRef(""),[ie,le]=se.useState(!1),[re,Z]=se.useState(1),[ne,de]=se.useState(""),[be,Te]=se.useState({}),[ae,Me]=se.useState(()=>localStorage.getItem("jb-theme")||"default"),[Ve,Ce]=se.useState(()=>parseInt(localStorage.getItem("jb-card-size")||"110")),[Fe,tt]=se.useState(!1),[je,Rt]=se.useState([]),Et=se.useRef(!1),Ft=se.useRef(void 0),Ut=e??!1,[Ke,ht]=se.useState(!1),[fe,$t]=se.useState([]),[_t,Gt]=se.useState(!1),yt=se.useRef(0);se.useRef(void 0);const[Ht,pt]=se.useState([]),[Ae,k]=se.useState(0),[xe,Oe]=se.useState(""),[Ue,ee]=se.useState("naming"),[we,Re]=se.useState(0),[We,Se]=se.useState(null),[Le,ct]=se.useState(!1),[Dt,It]=se.useState(null),[lt,jt]=se.useState(""),[Jt,In]=se.useState(null),[me,Bt]=se.useState(0);se.useEffect(()=>{Et.current=Fe},[Fe]),se.useEffect(()=>{J.current=V},[V]),se.useEffect(()=>{const he=sn=>{var Tn;Array.from(((Tn=sn.dataTransfer)==null?void 0:Tn.items)??[]).some(Rn=>Rn.kind==="file")&&(yt.current++,ht(!0))},X=()=>{yt.current=Math.max(0,yt.current-1),yt.current===0&&ht(!1)},et=sn=>sn.preventDefault(),en=sn=>{var Rn;sn.preventDefault(),yt.current=0,ht(!1);const Tn=Array.from(((Rn=sn.dataTransfer)==null?void 0:Rn.files)??[]).filter(xi=>/\.(mp3|wav)$/i.test(xi.name));Tn.length&&xt(Tn)};return window.addEventListener("dragenter",he),window.addEventListener("dragleave",X),window.addEventListener("dragover",et),window.addEventListener("drop",en),()=>{window.removeEventListener("dragenter",he),window.removeEventListener("dragleave",X),window.removeEventListener("dragover",et),window.removeEventListener("drop",en)}},[Ut]);const ot=se.useCallback((he,X="info")=>{It({msg:he,type:X}),setTimeout(()=>It(null),3e3)},[]);se.useCallback(he=>he.relativePath??he.fileName,[]);const Tt=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","music.youtube.com","instagram.com","www.instagram.com"],Wt=se.useCallback(he=>{const X=he.trim();return!X||/^https?:\/\//i.test(X)?X:"https://"+X},[]),Yt=se.useCallback(he=>{try{const X=new URL(Wt(he)),et=X.hostname.toLowerCase();return!!(X.pathname.toLowerCase().endsWith(".mp3")||Tt.some(en=>et===en||et.endsWith("."+en)))}catch{return!1}},[Wt]),pn=se.useCallback(he=>{try{const X=new URL(Wt(he)),et=X.hostname.toLowerCase();return et.includes("youtube")||et==="youtu.be"?"youtube":et.includes("instagram")?"instagram":X.pathname.toLowerCase().endsWith(".mp3")?"mp3":null}catch{return null}},[Wt]),$e=V?V.split(":")[0]:"",St=V?V.split(":")[1]:"",Kt=se.useMemo(()=>H.find(he=>`${he.guildId}:${he.channelId}`===V),[H,V]);se.useEffect(()=>{const he=()=>{const et=new Date,en=String(et.getHours()).padStart(2,"0"),sn=String(et.getMinutes()).padStart(2,"0"),Tn=String(et.getSeconds()).padStart(2,"0");jt(`${en}:${sn}:${Tn}`)};he();const X=setInterval(he,1e3);return()=>clearInterval(X)},[]),se.useEffect(()=>{(async()=>{try{const[he,X]=await Promise.all([PAe(),LAe()]);if(q(he),he.length){const et=he[0].guildId,en=X[et],sn=en&&he.find(Tn=>Tn.guildId===et&&Tn.channelId===en);Q(sn?`${et}:${en}`:`${he[0].guildId}:${he[0].channelId}`)}}catch(he){ot((he==null?void 0:he.message)||"Channel-Fehler","error")}try{const he=await DAe();h(he.categories||[])}catch{}})()},[]),se.useEffect(()=>{localStorage.setItem("jb-theme",ae)},[ae]);const wn=se.useRef(null);se.useEffect(()=>{const he=wn.current;if(!he)return;he.style.setProperty("--card-size",Ve+"px");const X=Ve/110;he.style.setProperty("--card-emoji",Math.round(28*X)+"px"),he.style.setProperty("--card-font",Math.max(9,Math.round(11*X))+"px"),localStorage.setItem("jb-card-size",String(Ve))},[Ve]),se.useEffect(()=>{var he,X,et,en,sn,Tn,Rn,xi;if(i){if(i.soundboard){const K=i.soundboard;Array.isArray(K.party)&&Rt(K.party);try{const hn=K.selected||{},Zt=(he=J.current)==null?void 0:he.split(":")[0];Zt&&hn[Zt]&&Q(`${Zt}:${hn[Zt]}`)}catch{}try{const hn=K.volumes||{},Zt=(X=J.current)==null?void 0:X.split(":")[0];Zt&&typeof hn[Zt]=="number"&&Z(hn[Zt])}catch{}try{const hn=K.nowplaying||{},Zt=(et=J.current)==null?void 0:et.split(":")[0];Zt&&typeof hn[Zt]=="string"&&de(hn[Zt])}catch{}try{const hn=K.voicestats||{},Zt=(en=J.current)==null?void 0:en.split(":")[0];Zt&&hn[Zt]&&Se(hn[Zt])}catch{}}if(i.type==="soundboard_party")Rt(K=>{const hn=new Set(K);return i.active?hn.add(i.guildId):hn.delete(i.guildId),Array.from(hn)});else if(i.type==="soundboard_channel"){const K=(sn=J.current)==null?void 0:sn.split(":")[0];i.guildId===K&&Q(`${i.guildId}:${i.channelId}`)}else if(i.type==="soundboard_volume"){const K=(Tn=J.current)==null?void 0:Tn.split(":")[0];i.guildId===K&&typeof i.volume=="number"&&Z(i.volume)}else if(i.type==="soundboard_nowplaying"){const K=(Rn=J.current)==null?void 0:Rn.split(":")[0];i.guildId===K&&de(i.name||"")}else if(i.type==="soundboard_voicestats"){const K=(xi=J.current)==null?void 0:xi.split(":")[0];i.guildId===K&&Se({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})}}},[i]),se.useEffect(()=>{tt($e?je.includes($e):!1)},[V,je,$e]),se.useEffect(()=>{(async()=>{try{let he="__all__";x==="recent"?he="__recent__":T&&(he=T);const X=await NAe(C,he,void 0,!1);n(X.items),s(X.total),l(X.folders)}catch(he){ot((he==null?void 0:he.message)||"Sounds-Fehler","error")}})()},[x,T,C,me,ot]),se.useEffect(()=>{qn()},[me]),se.useEffect(()=>{const he=CAe("favs");if(he)try{Te(JSON.parse(he))}catch{}},[]),se.useEffect(()=>{try{EAe("favs",JSON.stringify(be))}catch{}},[be]),se.useEffect(()=>{V&&(async()=>{try{const he=await zAe($e);Z(he)}catch{}})()},[V]),se.useEffect(()=>{const he=()=>{le(!1),In(null)};return document.addEventListener("click",he),()=>document.removeEventListener("click",he)},[]);async function qn(){try{const he=await RAe();v(he)}catch{}}async function Je(he){if(!V)return ot("Bitte einen Voice-Channel auswaehlen","error");try{await BAe(he.name,$e,St,re,he.relativePath),de(he.name),qn()}catch(X){ot((X==null?void 0:X.message)||"Play fehlgeschlagen","error")}}function dt(){var en;const he=Wt(O);if(!he)return ot("Bitte einen Link eingeben","error");if(!Yt(he))return ot("Nur YouTube, Instagram oder direkte MP3-Links","error");const X=pn(he);let et="";if(X==="mp3")try{et=((en=new URL(he).pathname.split("/").pop())==null?void 0:en.replace(/\.mp3$/i,""))??""}catch{}G({url:he,type:X,filename:et,phase:"input"})}async function Vt(){if(z){G(he=>he?{...he,phase:"downloading"}:null);try{let he;const X=z.filename.trim()||void 0;V&&$e&&St?he=(await OAe(z.url,$e,St,re,X)).saved:he=(await IAe(z.url,X)).saved,G(et=>et?{...et,phase:"done",savedName:he}:null),U(""),Bt(et=>et+1),qn(),setTimeout(()=>G(null),2500)}catch(he){G(X=>X?{...X,phase:"error",error:(he==null?void 0:he.message)||"Fehler"}:null)}}}async function xt(he){if(!Ut){ot("Admin-Login erforderlich zum Hochladen","error");return}if(he.length===0)return;pt(he),k(0);const X=he[0].name.replace(/\.(mp3|wav)$/i,"");Oe(X),ee("naming"),Re(0)}async function A(){if(Ht.length===0)return;const he=Ht[Ae],X=xe.trim()||he.name.replace(/\.(mp3|wav)$/i,"");ee("uploading"),Re(0);try{await qAe(he,X,et=>Re(et)),ee("done"),setTimeout(()=>{const et=Ae+1;if(eten+1),qn(),ot(`${Ht.length} Sound${Ht.length>1?"s":""} hochgeladen`,"info")},800)}catch(et){ot((et==null?void 0:et.message)||"Upload fehlgeschlagen","error"),pt([])}}function te(){const he=Ae+1;if(he0&&(Bt(X=>X+1),qn())}async function Vn(){if(V){de("");try{await fetch(`${ca}/stop?guildId=${encodeURIComponent($e)}`,{method:"POST"})}catch{}}}async function Wn(){if(!lr.length||!V)return;const he=lr[Math.floor(Math.random()*lr.length)];Je(he)}async function $n(){if(Fe){await Vn();try{await kAe($e)}catch{}}else{if(!V)return ot("Bitte einen Channel auswaehlen","error");try{await FAe($e,St)}catch{}}}async function dn(he){const X=`${he.guildId}:${he.channelId}`;Q(X),le(!1);try{await UAe(he.guildId,he.channelId)}catch{}}function Fn(he){Te(X=>({...X,[he]:!X[he]}))}const lr=se.useMemo(()=>x==="favorites"?t.filter(he=>be[he.relativePath??he.fileName]):t,[t,x,be]),an=se.useMemo(()=>Object.values(be).filter(Boolean).length,[be]),mn=se.useMemo(()=>a.filter(he=>!["__all__","__recent__","__top3__"].includes(he.key)),[a]),Er=se.useMemo(()=>{const he={};return mn.forEach((X,et)=>{he[X.key]=v7[et%v7.length]}),he},[mn]),Wi=se.useMemo(()=>{const he=new Set,X=new Set;return lr.forEach((et,en)=>{const sn=et.name.charAt(0).toUpperCase();he.has(sn)||(he.add(sn),X.add(en))}),X},[lr]),No=se.useMemo(()=>{const he={};return H.forEach(X=>{he[X.guildName]||(he[X.guildName]=[]),he[X.guildName].push(X)}),he},[H]),ce=m.mostPlayed.slice(0,10),Ge=m.totalSounds||r,rt=lt.slice(0,5),it=lt.slice(5);return P.jsxs("div",{className:"sb-app","data-theme":ae,ref:wn,children:[Fe&&P.jsx("div",{className:"party-overlay active"}),P.jsxs("header",{className:"topbar",children:[P.jsxs("div",{className:"topbar-left",children:[P.jsx("div",{className:"sb-app-logo",children:P.jsx("span",{className:"material-icons",style:{fontSize:16,color:"white"},children:"music_note"})}),P.jsx("span",{className:"sb-app-title",children:"Soundboard"}),P.jsxs("div",{className:"channel-dropdown",onClick:he=>he.stopPropagation(),children:[P.jsxs("button",{className:`channel-btn ${ie?"open":""}`,onClick:()=>le(!ie),children:[P.jsx("span",{className:"material-icons cb-icon",children:"headset"}),V&&P.jsx("span",{className:"channel-status"}),P.jsx("span",{className:"channel-label",children:Kt?`${Kt.channelName}${Kt.members?` (${Kt.members})`:""}`:"Channel..."}),P.jsx("span",{className:"material-icons chevron",children:"expand_more"})]}),ie&&P.jsxs("div",{className:"channel-menu visible",children:[Object.entries(No).map(([he,X])=>P.jsxs(FF.Fragment,{children:[P.jsx("div",{className:"channel-menu-header",children:he}),X.map(et=>P.jsxs("div",{className:`channel-option ${`${et.guildId}:${et.channelId}`===V?"active":""}`,onClick:()=>dn(et),children:[P.jsx("span",{className:"material-icons co-icon",children:"volume_up"}),et.channelName,et.members?` (${et.members})`:""]},`${et.guildId}:${et.channelId}`))]},he)),H.length===0&&P.jsx("div",{className:"channel-option",style:{color:"var(--text-faint)",cursor:"default"},children:"Keine Channels verfuegbar"})]})]})]}),P.jsx("div",{className:"clock-wrap",children:P.jsxs("div",{className:"clock",children:[rt,P.jsx("span",{className:"clock-seconds",children:it})]})}),P.jsxs("div",{className:"topbar-right",children:[ne&&P.jsxs("div",{className:"now-playing",children:[P.jsxs("div",{className:"np-waves active",children:[P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"})]}),P.jsx("span",{className:"np-label",children:"Last Played:"})," ",P.jsx("span",{className:"np-name",children:ne})]}),V&&P.jsxs("div",{className:"connection",onClick:()=>ct(!0),style:{cursor:"pointer"},title:"Verbindungsdetails",children:[P.jsx("span",{className:"conn-dot"}),"Verbunden",(We==null?void 0:We.voicePing)!=null&&P.jsxs("span",{className:"conn-ping",children:[We.voicePing,"ms"]})]})]})]}),P.jsxs("div",{className:"toolbar",children:[P.jsxs("div",{className:"cat-tabs",children:[P.jsxs("button",{className:`cat-tab ${x==="all"?"active":""}`,onClick:()=>{S("all"),N("")},children:["Alle",P.jsx("span",{className:"tab-count",children:r})]}),P.jsx("button",{className:`cat-tab ${x==="recent"?"active":""}`,onClick:()=>{S("recent"),N("")},children:"Neu hinzugefuegt"}),P.jsxs("button",{className:`cat-tab ${x==="favorites"?"active":""}`,onClick:()=>{S("favorites"),N("")},children:["Favoriten",an>0&&P.jsx("span",{className:"tab-count",children:an})]})]}),P.jsxs("div",{className:"search-wrap",children:[P.jsx("span",{className:"material-icons search-icon",children:"search"}),P.jsx("input",{className:"search-input",type:"text",placeholder:"Suchen...",value:C,onChange:he=>E(he.target.value)}),C&&P.jsx("button",{className:"search-clear",onClick:()=>E(""),children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsxs("div",{className:"url-import-wrap",children:[P.jsx("span",{className:"material-icons url-import-icon",children:pn(O)==="youtube"?"smart_display":pn(O)==="instagram"?"photo_camera":"link"}),P.jsx("input",{className:"url-import-input",type:"text",placeholder:"YouTube / Instagram / MP3-Link...",value:O,onChange:he=>U(he.target.value),onKeyDown:he=>{he.key==="Enter"&&dt()}}),O&&P.jsx("span",{className:`url-import-tag ${Yt(O)?"valid":"invalid"}`,children:pn(O)==="youtube"?"YT":pn(O)==="instagram"?"IG":pn(O)==="mp3"?"MP3":"?"}),P.jsx("button",{className:"url-import-btn",onClick:()=>{dt()},disabled:I||!!O&&!Yt(O),title:"Sound herunterladen",children:I?"Laedt...":"Download"})]}),P.jsx("div",{className:"toolbar-spacer"}),P.jsxs("div",{className:"volume-control",children:[P.jsx("span",{className:"material-icons vol-icon",onClick:()=>{const he=re>0?0:.5;Z(he),$e&&g7($e,he).catch(()=>{})},children:re===0?"volume_off":re<.5?"volume_down":"volume_up"}),P.jsx("input",{type:"range",className:"vol-slider",min:0,max:1,step:.01,value:re,onChange:he=>{const X=parseFloat(he.target.value);Z(X),$e&&(Ft.current&&clearTimeout(Ft.current),Ft.current=setTimeout(()=>{g7($e,X).catch(()=>{})},120))},style:{"--vol":`${Math.round(re*100)}%`}}),P.jsxs("span",{className:"vol-pct",children:[Math.round(re*100),"%"]})]}),P.jsxs("button",{className:"tb-btn random",onClick:Wn,title:"Zufaelliger Sound",children:[P.jsx("span",{className:"material-icons tb-icon",children:"shuffle"}),"Random"]}),P.jsxs("button",{className:`tb-btn party ${Fe?"active":""}`,onClick:$n,title:"Party Mode",children:[P.jsx("span",{className:"material-icons tb-icon",children:Fe?"celebration":"auto_awesome"}),Fe?"Party!":"Party"]}),P.jsxs("button",{className:"tb-btn stop",onClick:Vn,title:"Alle stoppen",children:[P.jsx("span",{className:"material-icons tb-icon",children:"stop"}),"Stop"]}),P.jsxs("div",{className:"size-control",title:"Button-Groesse",children:[P.jsx("span",{className:"material-icons sc-icon",children:"grid_view"}),P.jsx("input",{type:"range",className:"size-slider",min:80,max:160,value:Ve,onChange:he=>Ce(parseInt(he.target.value))})]}),P.jsx("div",{className:"theme-selector",children:VAe.map(he=>P.jsx("div",{className:`theme-dot ${ae===he.id?"active":""}`,style:{background:he.color},title:he.label,onClick:()=>Me(he.id)},he.id))})]}),P.jsxs("div",{className:"analytics-strip",children:[P.jsxs("div",{className:"analytics-card",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"library_music"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Sounds gesamt"}),P.jsx("strong",{className:"analytics-value",children:Ge})]})]}),P.jsxs("div",{className:"analytics-card analytics-wide",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"leaderboard"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Most Played"}),P.jsx("div",{className:"analytics-top-list",children:ce.length===0?P.jsx("span",{className:"analytics-muted",children:"Noch keine Plays"}):ce.map((he,X)=>P.jsxs("span",{className:"analytics-chip",children:[X+1,". ",he.name," (",he.count,")"]},he.relativePath))})]})]})]}),x==="all"&&mn.length>0&&P.jsx("div",{className:"category-strip",children:mn.map(he=>{const X=Er[he.key]||"#888",et=T===he.key;return P.jsxs("button",{className:`cat-chip ${et?"active":""}`,onClick:()=>N(et?"":he.key),style:et?{borderColor:X,color:X}:void 0,children:[P.jsx("span",{className:"cat-dot",style:{background:X}}),he.name.replace(/\s*\(\d+\)\s*$/,""),P.jsx("span",{className:"cat-count",children:he.count})]},he.key)})}),P.jsx("main",{className:"main",children:lr.length===0?P.jsxs("div",{className:"empty-state visible",children:[P.jsx("div",{className:"empty-emoji",children:x==="favorites"?"⭐":"🔇"}),P.jsx("div",{className:"empty-title",children:x==="favorites"?"Noch keine Favoriten":C?`Kein Sound fuer "${C}" gefunden`:"Keine Sounds vorhanden"}),P.jsx("div",{className:"empty-desc",children:x==="favorites"?"Klick den Stern auf einem Sound!":"Hier gibt's noch nichts zu hoeren."})]}):P.jsx("div",{className:"sound-grid",children:lr.map((he,X)=>{var hn;const et=he.relativePath??he.fileName,en=!!be[et],sn=ne===he.name,Tn=he.isRecent||((hn=he.badges)==null?void 0:hn.includes("new")),Rn=he.name.charAt(0).toUpperCase(),xi=Wi.has(X),K=he.folder&&Er[he.folder]||"var(--accent)";return P.jsxs("div",{className:`sound-card ${sn?"playing":""} ${xi?"has-initial":""}`,style:{animationDelay:`${Math.min(X*20,400)}ms`},onClick:Zt=>{const gr=Zt.currentTarget,ui=gr.getBoundingClientRect(),vr=document.createElement("div");vr.className="ripple";const Ps=Math.max(ui.width,ui.height);vr.style.width=vr.style.height=Ps+"px",vr.style.left=Zt.clientX-ui.left-Ps/2+"px",vr.style.top=Zt.clientY-ui.top-Ps/2+"px",gr.appendChild(vr),setTimeout(()=>vr.remove(),500),Je(he)},onContextMenu:Zt=>{Zt.preventDefault(),Zt.stopPropagation(),In({x:Math.min(Zt.clientX,window.innerWidth-170),y:Math.min(Zt.clientY,window.innerHeight-140),sound:he})},title:`${he.name}${he.folder?` (${he.folder})`:""}`,children:[Tn&&P.jsx("span",{className:"new-badge",children:"NEU"}),P.jsx("span",{className:`fav-star ${en?"active":""}`,onClick:Zt=>{Zt.stopPropagation(),Fn(et)},children:P.jsx("span",{className:"material-icons fav-icon",children:en?"star":"star_border"})}),xi&&P.jsx("span",{className:"sound-emoji",style:{color:K},children:Rn}),P.jsx("span",{className:"sound-name",children:he.name}),he.folder&&P.jsx("span",{className:"sound-duration",children:he.folder}),P.jsxs("div",{className:"playing-indicator",children:[P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"})]})]},et)})})}),Jt&&P.jsxs("div",{className:"ctx-menu visible",style:{left:Jt.x,top:Jt.y},onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"ctx-item",onClick:()=>{Je(Jt.sound),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"play_arrow"}),"Abspielen"]}),P.jsxs("div",{className:"ctx-item",onClick:()=>{Fn(Jt.sound.relativePath??Jt.sound.fileName),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:be[Jt.sound.relativePath??Jt.sound.fileName]?"star":"star_border"}),"Favorit"]}),Ut&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"ctx-sep"}),P.jsxs("div",{className:"ctx-item danger",onClick:async()=>{const he=Jt.sound.relativePath??Jt.sound.fileName;if(!window.confirm(`Sound "${Jt.sound.name}" loeschen?`)){In(null);return}try{await GAe([he]),ot("Sound geloescht"),Bt(X=>X+1)}catch(X){ot((X==null?void 0:X.message)||"Loeschen fehlgeschlagen","error")}In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"delete"}),"Loeschen"]})]})]}),Le&&(()=>{const he=We!=null&&We.connectedSince?Math.floor((Date.now()-new Date(We.connectedSince).getTime())/1e3):0,X=Math.floor(he/3600),et=Math.floor(he%3600/60),en=he%60,sn=X>0?`${X}h ${String(et).padStart(2,"0")}m ${String(en).padStart(2,"0")}s`:et>0?`${et}m ${String(en).padStart(2,"0")}s`:`${en}s`,Tn=Rn=>Rn==null?"var(--muted)":Rn<80?"var(--green)":Rn<150?"#f0a830":"#e04040";return P.jsx("div",{className:"conn-modal-overlay",onClick:()=>ct(!1),children:P.jsxs("div",{className:"conn-modal",onClick:Rn=>Rn.stopPropagation(),children:[P.jsxs("div",{className:"conn-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20,color:"var(--green)"},children:"cell_tower"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"conn-modal-close",onClick:()=>ct(!1),children:P.jsx("span",{className:"material-icons",children:"close"})})]}),P.jsxs("div",{className:"conn-modal-body",children:[P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Voice Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((We==null?void 0:We.voicePing)??null)}}),(We==null?void 0:We.voicePing)!=null?`${We.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Gateway Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((We==null?void 0:We.gatewayPing)??null)}}),We&&We.gatewayPing>=0?`${We.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Status"}),P.jsx("span",{className:"conn-stat-value",style:{color:(We==null?void 0:We.status)==="ready"?"var(--green)":"#f0a830"},children:(We==null?void 0:We.status)==="ready"?"Verbunden":(We==null?void 0:We.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Kanal"}),P.jsx("span",{className:"conn-stat-value",children:(We==null?void 0:We.channelName)||"---"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Verbunden seit"}),P.jsx("span",{className:"conn-stat-value",children:sn||"---"})]})]})]})})})(),Dt&&P.jsxs("div",{className:`toast ${Dt.type}`,children:[P.jsx("span",{className:"material-icons toast-icon",children:Dt.type==="error"?"error_outline":"check_circle"}),Dt.msg]}),Ke&&P.jsx("div",{className:"drop-overlay",children:P.jsxs("div",{className:"drop-zone",children:[P.jsx("span",{className:"material-icons drop-icon",children:"cloud_upload"}),P.jsx("div",{className:"drop-title",children:"MP3 & WAV hier ablegen"}),P.jsx("div",{className:"drop-sub",children:"Mehrere Dateien gleichzeitig moeglich"})]})}),_t&&fe.length>0&&P.jsxs("div",{className:"upload-queue",children:[P.jsxs("div",{className:"uq-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),P.jsx("span",{children:fe.every(he=>he.status==="done"||he.status==="error")?`${fe.filter(he=>he.status==="done").length} von ${fe.length} hochgeladen`:`Lade hoch… (${fe.filter(he=>he.status==="done").length}/${fe.length})`}),P.jsx("button",{className:"uq-close",onClick:()=>{Gt(!1),$t([])},children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsx("div",{className:"uq-list",children:fe.map(he=>P.jsxs("div",{className:`uq-item uq-${he.status}`,children:[P.jsx("span",{className:"material-icons uq-file-icon",children:"audio_file"}),P.jsxs("div",{className:"uq-info",children:[P.jsx("div",{className:"uq-name",title:he.savedName??he.file.name,children:he.savedName??he.file.name}),P.jsxs("div",{className:"uq-size",children:[(he.file.size/1024).toFixed(0)," KB"]})]}),(he.status==="waiting"||he.status==="uploading")&&P.jsx("div",{className:"uq-progress-wrap",children:P.jsx("div",{className:"uq-progress-bar",style:{width:`${he.progress}%`}})}),P.jsx("span",{className:`material-icons uq-status-icon uq-status-${he.status}`,children:he.status==="done"?"check_circle":he.status==="error"?"error":he.status==="uploading"?"sync":"schedule"}),he.status==="error"&&P.jsx("div",{className:"uq-error",children:he.error})]},he.id))})]}),Ht.length>0&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>Ue==="naming"&&te(),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:"upload_file"}),P.jsxs("span",{children:[Ue==="naming"?"Sound benennen":Ue==="uploading"?"Wird hochgeladen...":"Gespeichert!",Ht.length>1&&` (${Ae+1}/${Ht.length})`]}),Ue==="naming"&&P.jsx("button",{className:"dl-modal-close",onClick:te,children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:"dl-modal-tag mp3",children:"Datei"}),P.jsx("span",{className:"dl-modal-url-text",title:(qe=Ht[Ae])==null?void 0:qe.name,children:(qt=Ht[Ae])==null?void 0:qt.name}),P.jsxs("span",{style:{marginLeft:"auto",opacity:.5,fontSize:12},children:[((((Qt=Ht[Ae])==null?void 0:Qt.size)??0)/1024).toFixed(0)," KB"]})]}),Ue==="naming"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:"Dateiname eingeben...",value:xe,onChange:he=>Oe(he.target.value),onKeyDown:he=>{he.key==="Enter"&&A()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]})]}),Ue==="uploading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsxs("span",{children:["Upload: ",we,"%"]})]}),Ue==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsx("span",{children:"Erfolgreich hochgeladen!"})]})]}),Ue==="naming"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:te,children:Ht.length>1?"Überspringen":"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void A(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),"Hochladen"]})]})]})}),z&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>z.phase!=="downloading"&&G(null),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:z.type==="youtube"?"smart_display":z.type==="instagram"?"photo_camera":"audio_file"}),P.jsx("span",{children:z.phase==="input"?"Sound herunterladen":z.phase==="downloading"?"Wird heruntergeladen...":z.phase==="done"?"Fertig!":"Fehler"}),z.phase!=="downloading"&&P.jsx("button",{className:"dl-modal-close",onClick:()=>G(null),children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:`dl-modal-tag ${z.type??""}`,children:z.type==="youtube"?"YouTube":z.type==="instagram"?"Instagram":"MP3"}),P.jsx("span",{className:"dl-modal-url-text",title:z.url,children:z.url.length>60?z.url.slice(0,57)+"...":z.url})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:z.type==="mp3"?"Dateiname...":"Wird automatisch erkannt...",value:z.filename,onChange:he=>G(X=>X?{...X,filename:he.target.value}:null),onKeyDown:he=>{he.key==="Enter"&&Vt()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]}),P.jsx("span",{className:"dl-modal-hint",children:"Leer lassen = automatischer Name"})]}),z.phase==="downloading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsx("span",{children:z.type==="youtube"||z.type==="instagram"?"Audio wird extrahiert...":"MP3 wird heruntergeladen..."})]}),z.phase==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsxs("span",{children:["Gespeichert als ",P.jsx("b",{children:z.savedName})]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-error",children:[P.jsx("span",{className:"material-icons",style:{color:"#e74c3c"},children:"error"}),P.jsx("span",{children:z.error})]})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void Vt(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"download"}),"Herunterladen"]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Schliessen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>G(he=>he?{...he,phase:"input",error:void 0}:null),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"refresh"}),"Nochmal"]})]})]})})]})}const _7={IRON:"#6b6b6b",BRONZE:"#8c6239",SILVER:"#8c8c8c",GOLD:"#d4a017",PLATINUM:"#28b29e",EMERALD:"#1e9e5e",DIAMOND:"#576cce",MASTER:"#9d48e0",GRANDMASTER:"#e44c3e",CHALLENGER:"#f4c874"},HAe={SOLORANKED:"Ranked Solo",FLEXRANKED:"Ranked Flex",NORMAL:"Normal",ARAM:"ARAM",ARENA:"Arena",URF:"URF",BOT:"Co-op vs AI"},WAe="https://ddragon.leagueoflegends.com/cdn/15.5.1/img";function mm(i){return`${WAe}/champion/${i}.png`}function y7(i){const e=Math.floor((Date.now()-new Date(i).getTime())/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function $Ae(i){const e=Math.floor(i/60),t=i%60;return`${e}:${String(t).padStart(2,"0")}`}function x7(i,e,t){return e===0?"Perfect":((i+t)/e).toFixed(2)}function b7(i,e){const t=i+e;return t>0?Math.round(i/t*100):0}function XAe(i,e){if(!i)return"Unranked";const t=["","I","II","III","IV"];return`${i.charAt(0)}${i.slice(1).toLowerCase()}${e?" "+(t[e]??e):""}`}function YAe({data:i}){var yt,Ht,pt,Ae;const[e,t]=se.useState(""),[n,r]=se.useState("EUW"),[s,a]=se.useState([]),[l,u]=se.useState(null),[h,m]=se.useState([]),[v,x]=se.useState(!1),[S,T]=se.useState(null),[N,C]=se.useState([]),[E,O]=se.useState(null),[U,I]=se.useState({}),[j,z]=se.useState(!1),[G,H]=se.useState(!1),[q,V]=se.useState(null),[Q,J]=se.useState("aram"),[ie,le]=se.useState("EUW"),[re,Z]=se.useState([]),[ne,de]=se.useState(!1),[be,Te]=se.useState(null),[ae,Me]=se.useState([]),[Ve,Ce]=se.useState(""),[Fe,tt]=se.useState(!1),je=se.useRef(null),Rt=se.useRef(null);se.useEffect(()=>{fetch("/api/lolstats/regions").then(k=>k.json()).then(a).catch(()=>{}),fetch("/api/lolstats/recent").then(k=>k.json()).then(C).catch(()=>{}),fetch("/api/lolstats/modes").then(k=>k.json()).then(Me).catch(()=>{})},[]),se.useEffect(()=>{Q&&(de(!0),Te(null),tt(!1),fetch(`/api/lolstats/tierlist?mode=${Q}®ion=${ie}`).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>Z(k.champions??[])).catch(k=>Te(k.message)).finally(()=>de(!1)))},[Q,ie]),se.useEffect(()=>{i&&(i.recentSearches&&C(i.recentSearches),i.regions&&!s.length&&a(i.regions))},[i]);const Et=se.useCallback(async(k,xe,Oe)=>{H(!0);try{const Ue=`gameName=${encodeURIComponent(k)}&tagLine=${encodeURIComponent(xe)}®ion=${Oe}`,ee=await fetch(`/api/lolstats/renew?${Ue}`,{method:"POST"});if(ee.ok){const we=await ee.json();return we.last_updated_at&&V(we.last_updated_at),we.renewed??!1}}catch{}return H(!1),!1},[]),Ft=se.useCallback(async(k,xe,Oe,Ue=!1)=>{var We,Se;let ee=k??"",we=xe??"";const Re=Oe??n;if(!ee){const Le=e.split("#");ee=((We=Le[0])==null?void 0:We.trim())??"",we=((Se=Le[1])==null?void 0:Se.trim())??""}if(!ee||!we){T("Bitte im Format Name#Tag eingeben");return}x(!0),T(null),u(null),m([]),O(null),I({}),Rt.current={gameName:ee,tagLine:we,region:Re},Ue||Et(ee,we,Re).finally(()=>H(!1));try{const Le=`gameName=${encodeURIComponent(ee)}&tagLine=${encodeURIComponent(we)}®ion=${Re}`,[ct,Dt]=await Promise.all([fetch(`/api/lolstats/profile?${Le}`),fetch(`/api/lolstats/matches?${Le}&limit=10`)]);if(!ct.ok){const lt=await ct.json();throw new Error(lt.error??`Fehler ${ct.status}`)}const It=await ct.json();if(u(It),It.updated_at&&V(It.updated_at),Dt.ok){const lt=await Dt.json();m(Array.isArray(lt)?lt:[])}}catch(Le){T(Le.message)}x(!1)},[e,n,Et]),Ut=se.useCallback(async()=>{const k=Rt.current;if(!(!k||G)){H(!0);try{await Et(k.gameName,k.tagLine,k.region),await new Promise(xe=>setTimeout(xe,1500)),await Ft(k.gameName,k.tagLine,k.region,!0)}finally{H(!1)}}},[Et,Ft,G]),Ke=se.useCallback(async()=>{if(!(!l||j)){z(!0);try{const k=`gameName=${encodeURIComponent(l.game_name)}&tagLine=${encodeURIComponent(l.tagline)}®ion=${n}&limit=20`,xe=await fetch(`/api/lolstats/matches?${k}`);if(xe.ok){const Oe=await xe.json();m(Array.isArray(Oe)?Oe:[])}}catch{}z(!1)}},[l,n,j]),ht=se.useCallback(async k=>{var xe;if(E===k.id){O(null);return}if(O(k.id),!(((xe=k.participants)==null?void 0:xe.length)>=10||U[k.id]))try{const Oe=`region=${n}&createdAt=${encodeURIComponent(k.created_at)}`,Ue=await fetch(`/api/lolstats/match/${encodeURIComponent(k.id)}?${Oe}`);if(Ue.ok){const ee=await Ue.json();I(we=>({...we,[k.id]:ee}))}}catch{}},[E,U,n]),fe=se.useCallback(k=>{t(`${k.game_name}#${k.tag_line}`),r(k.region),Ft(k.game_name,k.tag_line,k.region)},[Ft]),$t=se.useCallback(k=>{var Oe,Ue,ee;if(!l)return((Oe=k.participants)==null?void 0:Oe[0])??null;const xe=l.game_name.toLowerCase();return((Ue=k.participants)==null?void 0:Ue.find(we=>{var Re,We;return((We=(Re=we.summoner)==null?void 0:Re.game_name)==null?void 0:We.toLowerCase())===xe}))??((ee=k.participants)==null?void 0:ee[0])??null},[l]),_t=k=>{var Se,Le,ct;const xe=$t(k);if(!xe)return null;const Oe=((Se=xe.stats)==null?void 0:Se.result)==="WIN",Ue=x7(xe.stats.kill,xe.stats.death,xe.stats.assist),ee=(xe.stats.minion_kill??0)+(xe.stats.neutral_minion_kill??0),we=k.game_length_second>0?(ee/(k.game_length_second/60)).toFixed(1):"0",Re=E===k.id,We=U[k.id]??(((Le=k.participants)==null?void 0:Le.length)>=10?k:null);return P.jsxs("div",{children:[P.jsxs("div",{className:`lol-match ${Oe?"win":"loss"}`,onClick:()=>ht(k),children:[P.jsx("div",{className:"lol-match-result",children:Oe?"W":"L"}),P.jsxs("div",{className:"lol-match-champ",children:[P.jsx("img",{src:mm(xe.champion_name),alt:xe.champion_name,title:xe.champion_name}),P.jsx("span",{className:"lol-match-champ-level",children:xe.stats.champion_level})]}),P.jsxs("div",{className:"lol-match-kda",children:[P.jsxs("div",{className:"lol-match-kda-nums",children:[xe.stats.kill,"/",xe.stats.death,"/",xe.stats.assist]}),P.jsxs("div",{className:`lol-match-kda-ratio ${Ue==="Perfect"?"perfect":Number(Ue)>=4?"great":""}`,children:[Ue," KDA"]})]}),P.jsxs("div",{className:"lol-match-stats",children:[P.jsxs("span",{children:[ee," CS (",we,"/m)"]}),P.jsxs("span",{children:[xe.stats.ward_place," wards"]})]}),P.jsx("div",{className:"lol-match-items",children:(xe.items_names??[]).slice(0,7).map((Dt,It)=>Dt?P.jsx("img",{src:mm("Aatrox"),alt:Dt,title:Dt,style:{background:"var(--bg-deep)"},onError:lt=>{lt.target.style.display="none"}},It):P.jsx("div",{className:"lol-match-item-empty"},It))}),P.jsxs("div",{className:"lol-match-meta",children:[P.jsx("div",{className:"lol-match-duration",children:$Ae(k.game_length_second)}),P.jsx("div",{className:"lol-match-queue",children:HAe[k.game_type]??k.game_type}),P.jsxs("div",{className:"lol-match-ago",children:[y7(k.created_at)," ago"]})]})]}),Re&&We&&P.jsx("div",{className:"lol-match-detail",children:Gt(We,(ct=xe.summoner)==null?void 0:ct.game_name)})]},k.id)},Gt=(k,xe)=>{var Re,We,Se,Le,ct;const Oe=((Re=k.participants)==null?void 0:Re.filter(Dt=>Dt.team_key==="BLUE"))??[],Ue=((We=k.participants)==null?void 0:We.filter(Dt=>Dt.team_key==="RED"))??[],ee=(ct=(Le=(Se=k.teams)==null?void 0:Se.find(Dt=>Dt.key==="BLUE"))==null?void 0:Le.game_stat)==null?void 0:ct.is_win,we=(Dt,It,lt)=>P.jsxs("div",{className:"lol-match-detail-team",children:[P.jsxs("div",{className:`lol-match-detail-team-header ${It?"win":"loss"}`,children:[lt," — ",It?"Victory":"Defeat"]}),Dt.map((jt,Jt)=>{var Bt,ot,Tt,Wt,Yt,pn,$e,St,Kt,wn,qn,Je;const In=((ot=(Bt=jt.summoner)==null?void 0:Bt.game_name)==null?void 0:ot.toLowerCase())===(xe==null?void 0:xe.toLowerCase()),me=(((Tt=jt.stats)==null?void 0:Tt.minion_kill)??0)+(((Wt=jt.stats)==null?void 0:Wt.neutral_minion_kill)??0);return P.jsxs("div",{className:`lol-detail-row ${In?"me":""}`,children:[P.jsx("img",{className:"lol-detail-champ",src:mm(jt.champion_name),alt:jt.champion_name}),P.jsx("span",{className:"lol-detail-name",title:`${(Yt=jt.summoner)==null?void 0:Yt.game_name}#${(pn=jt.summoner)==null?void 0:pn.tagline}`,children:(($e=jt.summoner)==null?void 0:$e.game_name)??jt.champion_name}),P.jsxs("span",{className:"lol-detail-kda",children:[(St=jt.stats)==null?void 0:St.kill,"/",(Kt=jt.stats)==null?void 0:Kt.death,"/",(wn=jt.stats)==null?void 0:wn.assist]}),P.jsxs("span",{className:"lol-detail-cs",children:[me," CS"]}),P.jsxs("span",{className:"lol-detail-dmg",children:[((((qn=jt.stats)==null?void 0:qn.total_damage_dealt_to_champions)??0)/1e3).toFixed(1),"k"]}),P.jsxs("span",{className:"lol-detail-gold",children:[((((Je=jt.stats)==null?void 0:Je.gold_earned)??0)/1e3).toFixed(1),"k"]})]},Jt)})]});return P.jsxs(P.Fragment,{children:[we(Oe,ee,"Blue Team"),we(Ue,ee===void 0?void 0:!ee,"Red Team")]})};return P.jsxs("div",{className:"lol-container",children:[P.jsxs("div",{className:"lol-search",children:[P.jsx("input",{ref:je,className:"lol-search-input",placeholder:"Summoner Name#Tag",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>k.key==="Enter"&&Ft()}),P.jsx("select",{className:"lol-search-region",value:n,onChange:k=>r(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("button",{className:"lol-search-btn",onClick:()=>Ft(),disabled:v,children:v?"...":"Search"})]}),N.length>0&&P.jsx("div",{className:"lol-recent",children:N.map((k,xe)=>P.jsxs("button",{className:"lol-recent-chip",onClick:()=>fe(k),children:[k.profile_image_url&&P.jsx("img",{src:k.profile_image_url,alt:""}),k.game_name,"#",k.tag_line,k.tier&&P.jsx("span",{className:"lol-recent-tier",style:{color:_7[k.tier]},children:k.tier})]},xe))}),S&&P.jsx("div",{className:"lol-error",children:S}),v&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Profil..."]}),l&&!v&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-profile",children:[P.jsx("img",{className:"lol-profile-icon",src:l.profile_image_url,alt:""}),P.jsxs("div",{className:"lol-profile-info",children:[P.jsxs("h2",{children:[l.game_name,P.jsxs("span",{children:["#",l.tagline]})]}),P.jsxs("div",{className:"lol-profile-level",children:["Level ",l.level]}),((yt=l.ladder_rank)==null?void 0:yt.rank)&&P.jsxs("div",{className:"lol-profile-ladder",children:["Ladder Rank #",l.ladder_rank.rank.toLocaleString()," / ",(Ht=l.ladder_rank.total)==null?void 0:Ht.toLocaleString()]}),q&&P.jsxs("div",{className:"lol-profile-updated",children:["Updated ",y7(q)," ago"]})]}),P.jsxs("button",{className:`lol-update-btn ${G?"renewing":""}`,onClick:Ut,disabled:G,title:"Refresh data from Riot servers",children:[P.jsx("span",{className:"lol-update-icon",children:G?"⟳":"↻"}),G?"Updating...":"Update"]})]}),P.jsx("div",{className:"lol-ranked-row",children:(l.league_stats??[]).filter(k=>k.game_type==="SOLORANKED"||k.game_type==="FLEXRANKED").map(k=>{const xe=k.tier_info,Oe=!!(xe!=null&&xe.tier),Ue=_7[(xe==null?void 0:xe.tier)??""]??"var(--text-normal)";return P.jsxs("div",{className:`lol-ranked-card ${Oe?"has-rank":""}`,style:{"--tier-color":Ue},children:[P.jsx("div",{className:"lol-ranked-type",children:k.game_type==="SOLORANKED"?"Ranked Solo/Duo":"Ranked Flex"}),Oe?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-ranked-tier",style:{color:Ue},children:[XAe(xe.tier,xe.division),P.jsxs("span",{className:"lol-ranked-lp",children:[xe.lp," LP"]})]}),P.jsxs("div",{className:"lol-ranked-record",children:[k.win,"W ",k.lose,"L",P.jsxs("span",{className:"lol-ranked-wr",children:["(",b7(k.win??0,k.lose??0),"%)"]}),k.is_hot_streak&&P.jsx("span",{className:"lol-ranked-streak",children:"🔥"})]})]}):P.jsx("div",{className:"lol-ranked-tier",children:"Unranked"})]},k.game_type)})}),((Ae=(pt=l.most_champions)==null?void 0:pt.champion_stats)==null?void 0:Ae.length)>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Top Champions"}),P.jsx("div",{className:"lol-champs",children:l.most_champions.champion_stats.slice(0,7).map(k=>{const xe=b7(k.win,k.lose),Oe=k.play>0?x7(k.kill/k.play,k.death/k.play,k.assist/k.play):"0";return P.jsxs("div",{className:"lol-champ-card",children:[P.jsx("img",{className:"lol-champ-icon",src:mm(k.champion_name),alt:k.champion_name}),P.jsxs("div",{children:[P.jsx("div",{className:"lol-champ-name",children:k.champion_name}),P.jsxs("div",{className:"lol-champ-stats",children:[k.play," games · ",xe,"% WR"]}),P.jsxs("div",{className:"lol-champ-kda",children:[Oe," KDA"]})]})]},k.champion_name)})})]}),h.length>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Match History"}),P.jsx("div",{className:"lol-matches",children:h.map(k=>_t(k))}),h.length<20&&P.jsx("button",{className:"lol-load-more",onClick:Ke,disabled:j,children:j?"Laden...":"Mehr laden"})]})]}),!l&&!v&&!S&&P.jsxs("div",{className:"lol-empty",children:[P.jsx("div",{className:"lol-empty-icon",children:"⚔️"}),P.jsx("h3",{children:"League of Legends Stats"}),P.jsx("p",{children:"Gib einen Summoner Name#Tag ein und wähle die Region"})]}),P.jsxs("div",{className:"lol-tier-section",children:[P.jsx("div",{className:"lol-section-title",children:"Champion Tier List"}),P.jsxs("div",{className:"lol-tier-controls",children:[P.jsx("div",{className:"lol-tier-modes",children:ae.map(k=>P.jsx("button",{className:`lol-tier-mode-btn ${Q===k.key?"active":""}`,onClick:()=>J(k.key),children:k.label},k.key))}),P.jsx("select",{className:"lol-search-region",value:ie,onChange:k=>le(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("input",{className:"lol-tier-filter",placeholder:"Filter champion...",value:Ve,onChange:k=>Ce(k.target.value)})]}),ne&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Tier List..."]}),be&&P.jsx("div",{className:"lol-error",children:be}),!ne&&!be&&re.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-tier-table",children:[P.jsxs("div",{className:"lol-tier-header",children:[P.jsx("span",{className:"lol-tier-col-rank",children:"#"}),P.jsx("span",{className:"lol-tier-col-champ",children:"Champion"}),P.jsx("span",{className:"lol-tier-col-tier",children:"Tier"}),P.jsx("span",{className:"lol-tier-col-wr",children:Q==="arena"?"Win":"Win %"}),P.jsx("span",{className:"lol-tier-col-pr",children:"Pick %"}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:"Ban %"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?"Avg Place":"KDA"})]}),re.filter(k=>!Ve||k.champion_name.toLowerCase().includes(Ve.toLowerCase())).slice(0,Fe?void 0:50).map(k=>{var Oe,Ue;const xe=["OP","1","2","3","4","5"];return P.jsxs("div",{className:`lol-tier-row tier-${k.tier}`,children:[P.jsx("span",{className:"lol-tier-col-rank",children:k.rank}),P.jsxs("span",{className:"lol-tier-col-champ",children:[P.jsx("img",{src:mm(k.champion_name),alt:k.champion_name}),k.champion_name]}),P.jsx("span",{className:`lol-tier-col-tier tier-badge-${k.tier}`,children:xe[k.tier]??k.tier}),P.jsx("span",{className:"lol-tier-col-wr",children:k.win_rate!=null?`${(k.win_rate*100).toFixed(1)}%`:"-"}),P.jsxs("span",{className:"lol-tier-col-pr",children:[(k.pick_rate*100).toFixed(1),"%"]}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:k.ban_rate!=null?`${(k.ban_rate*100).toFixed(1)}%`:"-"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?((Oe=k.average_placement)==null?void 0:Oe.toFixed(1))??"-":((Ue=k.kda)==null?void 0:Ue.toFixed(2))??"-"})]},k.champion_id)})]}),!Fe&&re.length>50&&P.jsxs("button",{className:"lol-load-more",onClick:()=>tt(!0),children:["Alle ",re.length," Champions anzeigen"]})]})]})]})}const S7={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function VS(i){const e=Math.max(0,Math.floor((Date.now()-new Date(i).getTime())/1e3)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}const jS=[{label:"Niedrig · 4 Mbit · 60fps",fps:60,bitrate:4e6},{label:"Mittel · 8 Mbit · 60fps",fps:60,bitrate:8e6},{label:"Hoch · 14 Mbit · 60fps",fps:60,bitrate:14e6},{label:"Ultra · 25 Mbit · 60fps",fps:60,bitrate:25e6},{label:"Max · 50 Mbit · 165fps",fps:165,bitrate:5e7}];function QAe({data:i,isAdmin:e}){var Re,We;const[t,n]=se.useState([]),[r,s]=se.useState(()=>localStorage.getItem("streaming_name")||""),[a,l]=se.useState("Screen Share"),[u,h]=se.useState(""),[m,v]=se.useState(1),[x,S]=se.useState(null),[T,N]=se.useState(null),[C,E]=se.useState(null),[O,U]=se.useState(!1),[I,j]=se.useState(!1),[z,G]=se.useState(null),[,H]=se.useState(0),[q,V]=se.useState(null),[Q,J]=se.useState(null),ie=se.useRef(null),le=se.useRef(""),re=se.useRef(null),Z=se.useRef(null),ne=se.useRef(null),de=se.useRef(new Map),be=se.useRef(null),Te=se.useRef(null),ae=se.useRef(new Map),Me=se.useRef(null),Ve=se.useRef(1e3),Ce=se.useRef(!1),Fe=se.useRef(null),tt=se.useRef(jS[1]);se.useEffect(()=>{Ce.current=O},[O]),se.useEffect(()=>{Fe.current=z},[z]),se.useEffect(()=>{tt.current=jS[m]},[m]),se.useEffect(()=>{var Se,Le;(Le=(Se=window.electronAPI)==null?void 0:Se.setStreaming)==null||Le.call(Se,O||z!==null)},[O,z]),se.useEffect(()=>{if(!(t.length>0||O))return;const Le=setInterval(()=>H(ct=>ct+1),1e3);return()=>clearInterval(Le)},[t.length,O]),se.useEffect(()=>{i!=null&&i.streams&&n(i.streams)},[i]),se.useEffect(()=>{r&&localStorage.setItem("streaming_name",r)},[r]),se.useEffect(()=>{if(!q)return;const Se=()=>V(null);return document.addEventListener("click",Se),()=>document.removeEventListener("click",Se)},[q]);const je=se.useCallback(Se=>{var Le;((Le=ie.current)==null?void 0:Le.readyState)===WebSocket.OPEN&&ie.current.send(JSON.stringify(Se))},[]),Rt=se.useCallback((Se,Le,ct)=>{if(Se.remoteDescription)Se.addIceCandidate(new RTCIceCandidate(ct)).catch(()=>{});else{let Dt=ae.current.get(Le);Dt||(Dt=[],ae.current.set(Le,Dt)),Dt.push(ct)}},[]),Et=se.useCallback((Se,Le)=>{const ct=ae.current.get(Le);if(ct){for(const Dt of ct)Se.addIceCandidate(new RTCIceCandidate(Dt)).catch(()=>{});ae.current.delete(Le)}},[]),Ft=se.useCallback((Se,Le)=>{Se.srcObject=Le;const ct=Se.play();ct&&ct.catch(()=>{Se.muted=!0,Se.play().catch(()=>{})})},[]),Ut=se.useCallback(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),be.current&&(be.current.close(),be.current=null),Te.current=null,ne.current&&(ne.current.srcObject=null)},[]),Ke=se.useRef(()=>{});Ke.current=Se=>{var Le,ct,Dt;switch(Se.type){case"welcome":le.current=Se.clientId,Se.streams&&n(Se.streams);break;case"broadcast_started":E(Se.streamId),U(!0),Ce.current=!0,j(!1),(Le=window.electronAPI)!=null&&Le.showNotification&&window.electronAPI.showNotification("Stream gestartet","Dein Stream ist jetzt live!");break;case"stream_available":n(lt=>lt.some(jt=>jt.id===Se.streamId)?lt:[...lt,{id:Se.streamId,broadcasterName:Se.broadcasterName,title:Se.title,startedAt:new Date().toISOString(),viewerCount:0,hasPassword:!!Se.hasPassword}]);const It=`${Se.broadcasterName} streamt: ${Se.title}`;(ct=window.electronAPI)!=null&&ct.showNotification?window.electronAPI.showNotification("Neuer Stream",It):Notification.permission==="granted"&&new Notification("Neuer Stream",{body:It,icon:"/assets/icon.png"});break;case"stream_ended":n(lt=>lt.filter(jt=>jt.id!==Se.streamId)),((Dt=Fe.current)==null?void 0:Dt.streamId)===Se.streamId&&(Ut(),G(null));break;case"viewer_joined":{const lt=Se.viewerId,jt=de.current.get(lt);jt&&(jt.close(),de.current.delete(lt)),ae.current.delete(lt);const Jt=new RTCPeerConnection(S7);de.current.set(lt,Jt);const In=re.current;if(In)for(const Bt of In.getTracks())Jt.addTrack(Bt,In);Jt.onicecandidate=Bt=>{Bt.candidate&&je({type:"ice_candidate",targetId:lt,candidate:Bt.candidate.toJSON()})};const me=Jt.getSenders().find(Bt=>{var ot;return((ot=Bt.track)==null?void 0:ot.kind)==="video"});if(me){const Bt=me.getParameters();(!Bt.encodings||Bt.encodings.length===0)&&(Bt.encodings=[{}]),Bt.encodings[0].maxFramerate=tt.current.fps,Bt.encodings[0].maxBitrate=tt.current.bitrate,me.setParameters(Bt).catch(()=>{})}Jt.createOffer().then(Bt=>Jt.setLocalDescription(Bt)).then(()=>je({type:"offer",targetId:lt,sdp:Jt.localDescription})).catch(console.error);break}case"viewer_left":{const lt=de.current.get(Se.viewerId);lt&&(lt.close(),de.current.delete(Se.viewerId)),ae.current.delete(Se.viewerId);break}case"offer":{const lt=Se.fromId;be.current&&(be.current.close(),be.current=null),ae.current.delete(lt);const jt=new RTCPeerConnection(S7);be.current=jt,jt.ontrack=Jt=>{const In=Jt.streams[0];if(!In)return;Te.current=In;const me=ne.current;me&&Ft(me,In),G(Bt=>Bt&&{...Bt,phase:"connected"})},jt.onicecandidate=Jt=>{Jt.candidate&&je({type:"ice_candidate",targetId:lt,candidate:Jt.candidate.toJSON()})},jt.oniceconnectionstatechange=()=>{(jt.iceConnectionState==="failed"||jt.iceConnectionState==="disconnected")&&G(Jt=>Jt&&{...Jt,phase:"error",error:"Verbindung verloren"})},jt.setRemoteDescription(new RTCSessionDescription(Se.sdp)).then(()=>(Et(jt,lt),jt.createAnswer())).then(Jt=>jt.setLocalDescription(Jt)).then(()=>je({type:"answer",targetId:lt,sdp:jt.localDescription})).catch(console.error);break}case"answer":{const lt=de.current.get(Se.fromId);lt&<.setRemoteDescription(new RTCSessionDescription(Se.sdp)).then(()=>Et(lt,Se.fromId)).catch(console.error);break}case"ice_candidate":{if(!Se.candidate)break;const lt=de.current.get(Se.fromId);lt?Rt(lt,Se.fromId,Se.candidate):be.current&&Rt(be.current,Se.fromId,Se.candidate);break}case"error":Se.code==="WRONG_PASSWORD"?N(lt=>lt&&{...lt,error:Se.message}):S(Se.message),j(!1);break}};const ht=se.useCallback(()=>{if(ie.current&&ie.current.readyState===WebSocket.OPEN)return;const Se=location.protocol==="https:"?"wss":"ws",Le=new WebSocket(`${Se}://${location.host}/ws/streaming`);ie.current=Le,Le.onopen=()=>{Ve.current=1e3},Le.onmessage=ct=>{let Dt;try{Dt=JSON.parse(ct.data)}catch{return}Ke.current(Dt)},Le.onclose=()=>{ie.current=null,Me.current=setTimeout(()=>{Ve.current=Math.min(Ve.current*2,1e4),ht()},Ve.current)},Le.onerror=()=>{Le.close()}},[]);se.useEffect(()=>(ht(),()=>{Me.current&&clearTimeout(Me.current)}),[ht]);const fe=se.useCallback(async()=>{var Se,Le;if(!r.trim()){S("Bitte gib einen Namen ein.");return}if(!((Se=navigator.mediaDevices)!=null&&Se.getDisplayMedia)){S("Dein Browser unterstützt keine Bildschirmfreigabe.");return}S(null),j(!0);try{const ct=tt.current,Dt=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:ct.fps}},audio:!0});re.current=Dt,Z.current&&(Z.current.srcObject=Dt),(Le=Dt.getVideoTracks()[0])==null||Le.addEventListener("ended",()=>{$t()}),ht();const It=()=>{var lt;((lt=ie.current)==null?void 0:lt.readyState)===WebSocket.OPEN?je({type:"start_broadcast",name:r.trim(),title:a.trim()||"Screen Share",password:u.trim()||void 0}):setTimeout(It,100)};It()}catch(ct){j(!1),ct.name==="NotAllowedError"?S("Bildschirmfreigabe wurde abgelehnt."):S(`Fehler: ${ct.message}`)}},[r,a,u,ht,je]),$t=se.useCallback(()=>{var Se;je({type:"stop_broadcast"}),(Se=re.current)==null||Se.getTracks().forEach(Le=>Le.stop()),re.current=null,Z.current&&(Z.current.srcObject=null);for(const Le of de.current.values())Le.close();de.current.clear(),U(!1),Ce.current=!1,E(null),h("")},[je]),_t=se.useCallback(Se=>{S(null),G({streamId:Se,phase:"connecting"}),ht();const Le=()=>{var ct;((ct=ie.current)==null?void 0:ct.readyState)===WebSocket.OPEN?je({type:"join_viewer",name:r.trim()||"Viewer",streamId:Se}):setTimeout(Le,100)};Le()},[r,ht,je]),Gt=se.useCallback(Se=>{Se.hasPassword?N({streamId:Se.id,streamTitle:Se.title,broadcasterName:Se.broadcasterName,password:"",error:null}):_t(Se.id)},[_t]),yt=se.useCallback(()=>{if(!T)return;if(!T.password.trim()){N(Dt=>Dt&&{...Dt,error:"Passwort eingeben."});return}const{streamId:Se,password:Le}=T;N(null),S(null),G({streamId:Se,phase:"connecting"}),ht();const ct=()=>{var Dt;((Dt=ie.current)==null?void 0:Dt.readyState)===WebSocket.OPEN?je({type:"join_viewer",name:r.trim()||"Viewer",streamId:Se,password:Le.trim()}):setTimeout(ct,100)};ct()},[T,r,ht,je]),Ht=se.useCallback(()=>{je({type:"leave_viewer"}),Ut(),G(null)},[Ut,je]);se.useEffect(()=>{const Se=ct=>{(Ce.current||Fe.current)&&ct.preventDefault()},Le=()=>{le.current&&navigator.sendBeacon("/api/streaming/disconnect",JSON.stringify({clientId:le.current}))};return window.addEventListener("beforeunload",Se),window.addEventListener("pagehide",Le),()=>{window.removeEventListener("beforeunload",Se),window.removeEventListener("pagehide",Le)}},[]);const pt=se.useRef(null),[Ae,k]=se.useState(!1),xe=se.useCallback(()=>{const Se=pt.current;Se&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):Se.requestFullscreen().catch(()=>{}))},[]);se.useEffect(()=>{const Se=()=>k(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",Se),()=>document.removeEventListener("fullscreenchange",Se)},[]),se.useEffect(()=>()=>{var Se;(Se=re.current)==null||Se.getTracks().forEach(Le=>Le.stop());for(const Le of de.current.values())Le.close();be.current&&be.current.close(),ie.current&&ie.current.close(),Me.current&&clearTimeout(Me.current)},[]),se.useEffect(()=>{z&&Te.current&&ne.current&&!ne.current.srcObject&&Ft(ne.current,Te.current)},[z,Ft]);const Oe=se.useRef(null);se.useEffect(()=>{const Le=new URLSearchParams(location.search).get("viewStream");if(Le){Oe.current=Le;const ct=new URL(location.href);ct.searchParams.delete("viewStream"),window.history.replaceState({},"",ct.toString())}},[]),se.useEffect(()=>{const Se=Oe.current;if(!Se||t.length===0)return;const Le=t.find(ct=>ct.id===Se);Le&&(Oe.current=null,Gt(Le))},[t,Gt]);const Ue=se.useCallback(Se=>{const Le=new URL(location.href);return Le.searchParams.set("viewStream",Se),Le.hash="",Le.toString()},[]),ee=se.useCallback(Se=>{navigator.clipboard.writeText(Ue(Se)).then(()=>{J(Se),setTimeout(()=>J(null),2e3)}).catch(()=>{})},[Ue]),we=se.useCallback(Se=>{window.open(Ue(Se),"_blank","noopener"),V(null)},[Ue]);if(z){const Se=t.find(Le=>Le.id===z.streamId);return P.jsxs("div",{className:"stream-viewer-overlay",ref:pt,children:[P.jsxs("div",{className:"stream-viewer-header",children:[P.jsxs("div",{className:"stream-viewer-header-left",children:[P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("div",{children:[P.jsx("div",{className:"stream-viewer-title",children:(Se==null?void 0:Se.title)||"Stream"}),P.jsxs("div",{className:"stream-viewer-subtitle",children:[(Se==null?void 0:Se.broadcasterName)||"..."," ",Se?` · ${Se.viewerCount} Zuschauer`:""]})]})]}),P.jsxs("div",{className:"stream-viewer-header-right",children:[P.jsx("button",{className:"stream-viewer-fullscreen",onClick:xe,title:Ae?"Vollbild verlassen":"Vollbild",children:Ae?"✖":"⛶"}),P.jsx("button",{className:"stream-viewer-close",onClick:Ht,children:"Verlassen"})]})]}),P.jsxs("div",{className:"stream-viewer-video",children:[z.phase==="connecting"?P.jsxs("div",{className:"stream-viewer-connecting",children:[P.jsx("div",{className:"stream-viewer-spinner"}),"Verbindung wird hergestellt..."]}):z.phase==="error"?P.jsxs("div",{className:"stream-viewer-connecting",children:[z.error||"Verbindungsfehler",P.jsx("button",{className:"stream-btn",onClick:Ht,children:"Zurück"})]}):null,P.jsx("video",{ref:ne,autoPlay:!0,playsInline:!0,style:z.phase==="connected"?{}:{display:"none"}})]})]})}return P.jsxs("div",{className:"stream-container",children:[x&&P.jsxs("div",{className:"stream-error",children:[x,P.jsx("button",{className:"stream-error-dismiss",onClick:()=>S(null),children:"×"})]}),P.jsxs("div",{className:"stream-topbar",children:[P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Name"}),P.jsx("input",{className:"stream-input stream-input-name",placeholder:"Dein Name",value:r,onChange:Se=>s(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field stream-field-grow",children:[P.jsx("span",{className:"stream-field-label",children:"Titel"}),P.jsx("input",{className:"stream-input stream-input-title",placeholder:"Stream-Titel",value:a,onChange:Se=>l(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Passwort"}),P.jsx("input",{className:"stream-input stream-input-password",type:"password",placeholder:"optional",value:u,onChange:Se=>h(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsxs("span",{className:"stream-field-label",children:["Qualit","ä","t"]}),P.jsx("select",{className:"stream-select-quality",value:m,onChange:Se=>v(Number(Se.target.value)),disabled:O,children:jS.map((Se,Le)=>P.jsx("option",{value:Le,children:Se.label},Se.label))})]}),O?P.jsxs("button",{className:"stream-btn stream-btn-stop",onClick:$t,children:["⏹"," Stream beenden"]}):P.jsx("button",{className:"stream-btn",onClick:fe,disabled:I,children:I?"Starte...":"🖥️ Stream starten"})]}),t.length===0&&!O?P.jsxs("div",{className:"stream-empty",children:[P.jsx("div",{className:"stream-empty-icon",children:"📺"}),P.jsx("h3",{children:"Keine aktiven Streams"}),P.jsx("p",{children:"Starte einen Stream, um deinen Bildschirm zu teilen."})]}):P.jsxs("div",{className:"stream-grid",children:[O&&P.jsxs("div",{className:"stream-tile own broadcasting",children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("video",{ref:Z,autoPlay:!0,playsInline:!0,muted:!0}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",((Re=t.find(Se=>Se.id===C))==null?void 0:Re.viewerCount)??0]})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsxs("div",{className:"stream-tile-name",children:[r," (Du)"]}),P.jsx("div",{className:"stream-tile-title",children:a})]}),P.jsx("span",{className:"stream-tile-time",children:C&&((We=t.find(Se=>Se.id===C))!=null&&We.startedAt)?VS(t.find(Se=>Se.id===C).startedAt):"0:00"})]})]}),t.filter(Se=>Se.id!==C).map(Se=>P.jsxs("div",{className:"stream-tile",onClick:()=>Gt(Se),children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("span",{className:"stream-tile-icon",children:"🖥️"}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",Se.viewerCount]}),Se.hasPassword&&P.jsx("span",{className:"stream-tile-lock",children:"🔒"})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsx("div",{className:"stream-tile-name",children:Se.broadcasterName}),P.jsx("div",{className:"stream-tile-title",children:Se.title})]}),P.jsx("span",{className:"stream-tile-time",children:VS(Se.startedAt)}),P.jsxs("div",{className:"stream-tile-menu-wrap",children:[P.jsx("button",{className:"stream-tile-menu",onClick:Le=>{Le.stopPropagation(),V(q===Se.id?null:Se.id)},children:"⋮"}),q===Se.id&&P.jsxs("div",{className:"stream-tile-dropdown",onClick:Le=>Le.stopPropagation(),children:[P.jsxs("div",{className:"stream-tile-dropdown-header",children:[P.jsx("div",{className:"stream-tile-dropdown-name",children:Se.broadcasterName}),P.jsx("div",{className:"stream-tile-dropdown-title",children:Se.title}),P.jsxs("div",{className:"stream-tile-dropdown-detail",children:["👥"," ",Se.viewerCount," Zuschauer · ",VS(Se.startedAt)]})]}),P.jsx("div",{className:"stream-tile-dropdown-divider"}),P.jsxs("button",{className:"stream-tile-dropdown-item",onClick:()=>we(Se.id),children:["🗗"," In neuem Fenster öffnen"]}),P.jsx("button",{className:"stream-tile-dropdown-item",onClick:()=>{ee(Se.id),V(null)},children:Q===Se.id?"✅ Kopiert!":"🔗 Link teilen"})]})]})]})]},Se.id))]}),T&&P.jsx("div",{className:"stream-pw-overlay",onClick:()=>N(null),children:P.jsxs("div",{className:"stream-pw-modal",onClick:Se=>Se.stopPropagation(),children:[P.jsx("h3",{children:T.broadcasterName}),P.jsx("p",{children:T.streamTitle}),T.error&&P.jsx("div",{className:"stream-pw-modal-error",children:T.error}),P.jsx("input",{className:"stream-input",type:"password",placeholder:"Stream-Passwort",value:T.password,onChange:Se=>N(Le=>Le&&{...Le,password:Se.target.value,error:null}),onKeyDown:Se=>{Se.key==="Enter"&&yt()},autoFocus:!0}),P.jsxs("div",{className:"stream-pw-actions",children:[P.jsx("button",{className:"stream-pw-cancel",onClick:()=>N(null),children:"Abbrechen"}),P.jsx("button",{className:"stream-btn",onClick:yt,children:"Beitreten"})]})]})})]})}function w7(i){const e=Math.floor(i),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function KAe(i){const e=i.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(e)return{type:"youtube",videoId:e[1]};const t=i.match(/(?:dailymotion\.com\/video\/|dai\.ly\/)([a-zA-Z0-9]+)/);return t?{type:"dailymotion",videoId:t[1]}:/\.(mp4|webm|ogg)(\?|$)/i.test(i)||i.startsWith("http")?{type:"direct",url:i}:null}function ZAe({data:i}){var pn;const[e,t]=se.useState([]),[n,r]=se.useState(()=>localStorage.getItem("wt_name")||""),[s,a]=se.useState(""),[l,u]=se.useState(""),[h,m]=se.useState(null),[v,x]=se.useState(null),[S,T]=se.useState(null),[N,C]=se.useState(""),[E,O]=se.useState(()=>{const $e=localStorage.getItem("wt_volume");return $e?parseFloat($e):1}),[U,I]=se.useState(!1),[j,z]=se.useState(0),[G,H]=se.useState(0),[q,V]=se.useState(null),[Q,J]=se.useState(!1),[ie,le]=se.useState([]),[re,Z]=se.useState(""),[ne,de]=se.useState(null),[be,Te]=se.useState("synced"),[ae,Me]=se.useState(!0),[Ve,Ce]=se.useState(()=>localStorage.getItem("wt_yt_quality")||"hd1080"),Fe=se.useRef(null),tt=se.useRef(""),je=se.useRef(null),Rt=se.useRef(1e3),Et=se.useRef(null),Ft=se.useRef(null),Ut=se.useRef(null),Ke=se.useRef(null),ht=se.useRef(null),fe=se.useRef(null),$t=se.useRef(!1),_t=se.useRef(!1),Gt=se.useRef(null),yt=se.useRef(null),Ht=se.useRef(Ve),pt=se.useRef(null),Ae=se.useRef(!1),k=se.useRef(0),xe=se.useRef(0);se.useEffect(()=>{Et.current=h},[h]);const Oe=h!=null&&tt.current===h.hostId;se.useEffect(()=>{Ht.current=Ve,localStorage.setItem("wt_yt_quality",Ve),Ut.current&&typeof Ut.current.setPlaybackQuality=="function"&&Ut.current.setPlaybackQuality(Ve)},[Ve]),se.useEffect(()=>{i!=null&&i.rooms&&t(i.rooms)},[i]),se.useEffect(()=>{var $e;($e=yt.current)==null||$e.scrollIntoView({behavior:"smooth"})},[ie]),se.useEffect(()=>{const St=new URLSearchParams(window.location.search).get("wt");if(St&&n.trim()){const Kt=setTimeout(()=>ct(St),1500);return()=>clearTimeout(Kt)}},[]),se.useEffect(()=>{n&&localStorage.setItem("wt_name",n)},[n]),se.useEffect(()=>{var $e;localStorage.setItem("wt_volume",String(E)),Ut.current&&typeof Ut.current.setVolume=="function"&&Ut.current.setVolume(E*100),Ke.current&&(Ke.current.volume=E),($e=pt.current)!=null&&$e.contentWindow&&fe.current==="dailymotion"&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com")},[E]),se.useEffect(()=>{if(window.YT){$t.current=!0;return}const $e=document.createElement("script");$e.src="https://www.youtube.com/iframe_api",document.head.appendChild($e);const St=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{$t.current=!0,St&&St()}},[]);const Ue=se.useCallback($e=>{var St;((St=Fe.current)==null?void 0:St.readyState)===WebSocket.OPEN&&Fe.current.send(JSON.stringify($e))},[]),ee=se.useCallback(()=>fe.current==="youtube"&&Ut.current&&typeof Ut.current.getCurrentTime=="function"?Ut.current.getCurrentTime():fe.current==="direct"&&Ke.current?Ke.current.currentTime:fe.current==="dailymotion"?k.current:null,[]);se.useCallback(()=>fe.current==="youtube"&&Ut.current&&typeof Ut.current.getDuration=="function"?Ut.current.getDuration()||0:fe.current==="direct"&&Ke.current?Ke.current.duration||0:fe.current==="dailymotion"?xe.current:0,[]);const we=se.useCallback(()=>{if(Ut.current){try{Ut.current.destroy()}catch{}Ut.current=null}Ke.current&&(Ke.current.pause(),Ke.current.removeAttribute("src"),Ke.current.load()),pt.current&&(pt.current.src="",Ae.current=!1,k.current=0,xe.current=0),fe.current=null,Gt.current&&(clearInterval(Gt.current),Gt.current=null)},[]),Re=se.useCallback($e=>{we(),V(null);const St=KAe($e);if(St)if(St.type==="youtube"){if(fe.current="youtube",!$t.current||!ht.current)return;const Kt=ht.current,wn=document.createElement("div");wn.id="wt-yt-player-"+Date.now(),Kt.innerHTML="",Kt.appendChild(wn),Ut.current=new window.YT.Player(wn.id,{videoId:St.videoId,playerVars:{autoplay:1,controls:0,modestbranding:1,rel:0},events:{onReady:qn=>{qn.target.setVolume(E*100),qn.target.setPlaybackQuality(Ht.current),z(qn.target.getDuration()||0),Gt.current=setInterval(()=>{Ut.current&&typeof Ut.current.getCurrentTime=="function"&&(H(Ut.current.getCurrentTime()),z(Ut.current.getDuration()||0))},500)},onStateChange:qn=>{if(qn.data===window.YT.PlayerState.ENDED){const Je=Et.current;Je&&tt.current===Je.hostId&&Ue({type:"skip"})}},onError:qn=>{const Je=qn.data;V(Je===101||Je===150?"Embedding deaktiviert — Video kann nur auf YouTube angesehen werden.":Je===100?"Video nicht gefunden oder entfernt.":"Wiedergabefehler — Video wird übersprungen."),setTimeout(()=>{const dt=Et.current;dt&&tt.current===dt.hostId&&Ue({type:"skip"})},3e3)}}})}else St.type==="dailymotion"?(fe.current="dailymotion",pt.current&&(pt.current.src=`https://www.dailymotion.com/embed/video/${St.videoId}?api=postMessage&autoplay=1&controls=0&mute=0&queue-enable=0`)):(fe.current="direct",Ke.current&&(Ke.current.src=St.url,Ke.current.volume=E,Ke.current.play().catch(()=>{})))},[we,E,Ue]);se.useEffect(()=>{const $e=Ke.current;if(!$e)return;const St=()=>{const wn=Et.current;wn&&tt.current===wn.hostId&&Ue({type:"skip"})},Kt=()=>{H($e.currentTime),z($e.duration||0)};return $e.addEventListener("ended",St),$e.addEventListener("timeupdate",Kt),()=>{$e.removeEventListener("ended",St),$e.removeEventListener("timeupdate",Kt)}},[Ue]),se.useEffect(()=>{const $e=St=>{var Je;if(St.origin!=="https://www.dailymotion.com"||typeof St.data!="string")return;const Kt=new URLSearchParams(St.data),wn=Kt.get("method"),qn=Kt.get("value");if(wn==="timeupdate"&&qn){const dt=parseFloat(qn);k.current=dt,H(dt)}else if(wn==="durationchange"&&qn){const dt=parseFloat(qn);xe.current=dt,z(dt)}else if(wn==="ended"){const dt=Et.current;dt&&tt.current===dt.hostId&&Ue({type:"skip"})}else wn==="apiready"&&(Ae.current=!0,(Je=pt.current)!=null&&Je.contentWindow&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com"))};return window.addEventListener("message",$e),()=>window.removeEventListener("message",$e)},[Ue,E]);const We=se.useRef(()=>{});We.current=$e=>{var St,Kt,wn,qn,Je,dt,Vt,xt,A,te,Vn,Wn,$n,dn,Fn,lr;switch($e.type){case"welcome":tt.current=$e.clientId,$e.rooms&&t($e.rooms);break;case"room_created":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]});break}case"room_joined":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]}),(St=an.currentVideo)!=null&&St.url&&setTimeout(()=>Re(an.currentVideo.url),100);break}case"playback_state":{const an=Et.current;if(!an)break;const mn=$e.currentVideo,Er=(Kt=an.currentVideo)==null?void 0:Kt.url;if(mn!=null&&mn.url&&mn.url!==Er?Re(mn.url):!mn&&Er&&we(),fe.current==="youtube"&&Ut.current){const Wi=(qn=(wn=Ut.current).getPlayerState)==null?void 0:qn.call(wn);$e.playing&&Wi!==((dt=(Je=window.YT)==null?void 0:Je.PlayerState)==null?void 0:dt.PLAYING)?(xt=(Vt=Ut.current).playVideo)==null||xt.call(Vt):!$e.playing&&Wi===((te=(A=window.YT)==null?void 0:A.PlayerState)==null?void 0:te.PLAYING)&&((Wn=(Vn=Ut.current).pauseVideo)==null||Wn.call(Vn))}else fe.current==="direct"&&Ke.current?$e.playing&&Ke.current.paused?Ke.current.play().catch(()=>{}):!$e.playing&&!Ke.current.paused&&Ke.current.pause():fe.current==="dailymotion"&&(($n=pt.current)!=null&&$n.contentWindow)&&($e.playing?pt.current.contentWindow.postMessage("play","https://www.dailymotion.com"):pt.current.contentWindow.postMessage("pause","https://www.dailymotion.com"));if($e.currentTime!==void 0&&!_t.current){const Wi=ee();Wi!==null&&Math.abs(Wi-$e.currentTime)>2&&(fe.current==="youtube"&&Ut.current?(Fn=(dn=Ut.current).seekTo)==null||Fn.call(dn,$e.currentTime,!0):fe.current==="direct"&&Ke.current?Ke.current.currentTime=$e.currentTime:fe.current==="dailymotion"&&((lr=pt.current)!=null&&lr.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e.currentTime}`,"https://www.dailymotion.com"))}if($e.currentTime!==void 0){const Wi=ee();if(Wi!==null){const No=Math.abs(Wi-$e.currentTime);No<1.5?Te("synced"):No<5?Te("drifting"):Te("desynced")}}m(Wi=>Wi&&{...Wi,currentVideo:mn||null,playing:$e.playing,currentTime:$e.currentTime??Wi.currentTime});break}case"queue_updated":m(an=>an&&{...an,queue:$e.queue});break;case"members_updated":m(an=>an&&{...an,members:$e.members,hostId:$e.hostId});break;case"vote_updated":de($e.votes);break;case"chat":le(an=>{const mn=[...an,{sender:$e.sender,text:$e.text,timestamp:$e.timestamp}];return mn.length>100?mn.slice(-100):mn});break;case"chat_history":le($e.messages||[]);break;case"error":$e.code==="WRONG_PASSWORD"?x(an=>an&&{...an,error:$e.message}):T($e.message);break}};const Se=se.useCallback(()=>{if(Fe.current&&(Fe.current.readyState===WebSocket.OPEN||Fe.current.readyState===WebSocket.CONNECTING))return;const $e=location.protocol==="https:"?"wss":"ws",St=new WebSocket(`${$e}://${location.host}/ws/watch-together`);Fe.current=St,St.onopen=()=>{Rt.current=1e3},St.onmessage=Kt=>{let wn;try{wn=JSON.parse(Kt.data)}catch{return}We.current(wn)},St.onclose=()=>{Fe.current===St&&(Fe.current=null),Et.current&&(je.current=setTimeout(()=>{Rt.current=Math.min(Rt.current*2,1e4),Se()},Rt.current))},St.onerror=()=>{St.close()}},[]),Le=se.useCallback(()=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}if(!s.trim()){T("Bitte gib einen Raumnamen ein.");return}T(null),Se();const $e=Date.now(),St=()=>{var Kt;((Kt=Fe.current)==null?void 0:Kt.readyState)===WebSocket.OPEN?Ue({type:"create_room",name:s.trim(),userName:n.trim(),password:l.trim()||void 0}):Date.now()-$e>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(St,100)};St()},[n,s,l,Se,Ue]),ct=se.useCallback(($e,St)=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}T(null),Se();const Kt=Date.now(),wn=()=>{var qn;((qn=Fe.current)==null?void 0:qn.readyState)===WebSocket.OPEN?Ue({type:"join_room",userName:n.trim(),roomId:$e,password:(St==null?void 0:St.trim())||void 0}):Date.now()-Kt>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(wn,100)};wn()},[n,Se,Ue]),Dt=se.useCallback(()=>{Ue({type:"leave_room"}),we(),m(null),C(""),z(0),H(0),le([]),de(null),Te("synced")},[Ue,we]),It=se.useCallback(async()=>{const $e=N.trim();if(!$e)return;C(""),J(!0);let St="";try{const Kt=await fetch(`/api/watch-together/video-info?url=${encodeURIComponent($e)}`);Kt.ok&&(St=(await Kt.json()).title||"")}catch{}Ue({type:"add_to_queue",url:$e,title:St||void 0}),J(!1)},[N,Ue]),lt=se.useCallback(()=>{const $e=re.trim();$e&&(Z(""),Ue({type:"chat_message",text:$e}))},[re,Ue]);se.useCallback(()=>{Ue({type:"vote_skip"})},[Ue]),se.useCallback(()=>{Ue({type:"vote_pause"})},[Ue]);const jt=se.useCallback(()=>{Ue({type:"clear_watched"})},[Ue]),Jt=se.useCallback(()=>{if(!h)return;const $e=`${window.location.origin}${window.location.pathname}?wt=${h.id}`;navigator.clipboard.writeText($e).catch(()=>{})},[h]),In=se.useCallback($e=>{Ue({type:"remove_from_queue",index:$e})},[Ue]),me=se.useCallback(()=>{const $e=Et.current;$e&&Ue({type:$e.playing?"pause":"resume"})},[Ue]),Bt=se.useCallback(()=>{Ue({type:"skip"})},[Ue]),ot=se.useCallback($e=>{var St,Kt,wn;_t.current=!0,Ue({type:"seek",time:$e}),fe.current==="youtube"&&Ut.current?(Kt=(St=Ut.current).seekTo)==null||Kt.call(St,$e,!0):fe.current==="direct"&&Ke.current?Ke.current.currentTime=$e:fe.current==="dailymotion"&&((wn=pt.current)!=null&&wn.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e}`,"https://www.dailymotion.com"),H($e),setTimeout(()=>{_t.current=!1},3e3)},[Ue]);se.useEffect(()=>{if(!Oe||!(h!=null&&h.playing))return;const $e=setInterval(()=>{const St=ee();St!==null&&Ue({type:"report_time",time:St})},2e3);return()=>clearInterval($e)},[Oe,h==null?void 0:h.playing,Ue,ee]);const Tt=se.useCallback(()=>{const $e=Ft.current;$e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):$e.requestFullscreen().catch(()=>{}))},[]);se.useEffect(()=>{const $e=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$e),()=>document.removeEventListener("fullscreenchange",$e)},[]),se.useEffect(()=>{const $e=Kt=>{Et.current&&Kt.preventDefault()},St=()=>{tt.current&&navigator.sendBeacon("/api/watch-together/disconnect",JSON.stringify({clientId:tt.current}))};return window.addEventListener("beforeunload",$e),window.addEventListener("pagehide",St),()=>{window.removeEventListener("beforeunload",$e),window.removeEventListener("pagehide",St)}},[]),se.useEffect(()=>()=>{we(),Fe.current&&Fe.current.close(),je.current&&clearTimeout(je.current)},[we]);const Wt=se.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(Kt=>Kt&&{...Kt,error:"Passwort eingeben."});return}const{roomId:$e,password:St}=v;x(null),ct($e,St)},[v,ct]),Yt=se.useCallback($e=>{$e.hasPassword?x({roomId:$e.id,roomName:$e.name,password:"",error:null}):ct($e.id)},[ct]);if(h){const $e=h.members.find(St=>St.id===h.hostId);return P.jsxs("div",{className:"wt-room-overlay",ref:Ft,children:[P.jsxs("div",{className:"wt-room-header",children:[P.jsxs("div",{className:"wt-room-header-left",children:[P.jsx("span",{className:"wt-room-name",children:h.name}),P.jsxs("span",{className:"wt-room-members",children:[h.members.length," Mitglieder"]}),$e&&P.jsxs("span",{className:"wt-host-badge",children:["Host: ",$e.name]})]}),P.jsxs("div",{className:"wt-room-header-right",children:[P.jsx("div",{className:`wt-sync-dot wt-sync-${be}`,title:be==="synced"?"Synchron":be==="drifting"?"Leichte Verzögerung":"Nicht synchron"}),P.jsx("button",{className:"wt-header-btn",onClick:Jt,title:"Link kopieren",children:"Link"}),P.jsx("button",{className:"wt-header-btn",onClick:()=>Me(St=>!St),title:ae?"Chat ausblenden":"Chat einblenden",children:"Chat"}),P.jsx("button",{className:"wt-fullscreen-btn",onClick:Tt,title:U?"Vollbild verlassen":"Vollbild",children:U?"✖":"⛶"}),P.jsx("button",{className:"wt-leave-btn",onClick:Dt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"wt-room-body",children:[P.jsxs("div",{className:"wt-player-section",children:[P.jsxs("div",{className:"wt-player-wrap",children:[P.jsx("div",{ref:ht,className:"wt-yt-container",style:fe.current==="youtube"?{}:{display:"none"}}),P.jsx("video",{ref:Ke,className:"wt-video-element",style:fe.current==="direct"?{}:{display:"none"},playsInline:!0}),P.jsx("iframe",{ref:pt,className:"wt-dm-container",style:fe.current==="dailymotion"?{}:{display:"none"},allow:"autoplay; fullscreen",allowFullScreen:!0}),q&&P.jsxs("div",{className:"wt-player-error",children:[P.jsx("div",{className:"wt-error-icon",children:"⚠️"}),P.jsx("p",{children:q}),((pn=h.currentVideo)==null?void 0:pn.url)&&P.jsx("a",{className:"wt-yt-link",href:h.currentVideo.url,target:"_blank",rel:"noopener noreferrer",children:"Auf YouTube öffnen ↗"}),P.jsx("p",{className:"wt-skip-info",children:"Wird in 3 Sekunden übersprungen..."})]}),!h.currentVideo&&P.jsxs("div",{className:"wt-player-placeholder",children:[P.jsx("div",{className:"wt-placeholder-icon",children:"🎬"}),P.jsx("p",{children:"Fuege ein Video zur Warteschlange hinzu"})]})]}),P.jsxs("div",{className:"wt-controls",children:[P.jsx("button",{className:"wt-ctrl-btn",onClick:me,disabled:!h.currentVideo,title:h.playing?"Pause":"Abspielen",children:h.playing?"⏸":"▶"}),P.jsxs("button",{className:"wt-ctrl-btn wt-next-btn",onClick:Bt,disabled:!h.currentVideo&&h.queue.length===0,title:"Nächstes Video",children:["⏭"," Weiter"]}),P.jsx("input",{className:"wt-seek",type:"range",min:0,max:j||0,step:.5,value:G,onChange:St=>ot(parseFloat(St.target.value)),disabled:!h.currentVideo}),P.jsxs("span",{className:"wt-time",children:[w7(G)," / ",w7(j)]}),P.jsxs("div",{className:"wt-volume",children:[P.jsx("span",{className:"wt-volume-icon",children:E===0?"🔇":E<.5?"🔉":"🔊"}),P.jsx("input",{className:"wt-volume-slider",type:"range",min:0,max:1,step:.01,value:E,onChange:St=>O(parseFloat(St.target.value))})]}),fe.current==="youtube"&&P.jsxs("select",{className:"wt-quality-select",value:Ve,onChange:St=>Ce(St.target.value),title:"Videoqualität",children:[P.jsx("option",{value:"highres",children:"4K+"}),P.jsx("option",{value:"hd2160",children:"2160p"}),P.jsx("option",{value:"hd1440",children:"1440p"}),P.jsx("option",{value:"hd1080",children:"1080p"}),P.jsx("option",{value:"hd720",children:"720p"}),P.jsx("option",{value:"large",children:"480p"}),P.jsx("option",{value:"medium",children:"360p"}),P.jsx("option",{value:"small",children:"240p"})]})]})]}),P.jsxs("div",{className:"wt-queue-panel",children:[P.jsxs("div",{className:"wt-queue-header",children:[P.jsxs("span",{children:["Warteschlange (",h.queue.length,")"]}),h.queue.some(St=>St.watched)&&P.jsx("button",{className:"wt-queue-clear-btn",onClick:jt,title:"Gesehene entfernen",children:"Gesehene entfernen"})]}),P.jsx("div",{className:"wt-queue-list",children:h.queue.length===0?P.jsx("div",{className:"wt-queue-empty",children:"Keine Videos in der Warteschlange"}):h.queue.map((St,Kt)=>{var qn,Je;const wn=((qn=h.currentVideo)==null?void 0:qn.url)===St.url;return P.jsxs("div",{className:`wt-queue-item${wn?" playing":""}${St.watched&&!wn?" watched":""} clickable`,onClick:()=>Ue({type:"play_video",index:Kt}),title:"Klicken zum Abspielen",children:[P.jsxs("div",{className:"wt-queue-item-info",children:[St.watched&&!wn&&P.jsx("span",{className:"wt-queue-item-check",children:"✓"}),St.url.match(/youtu/)&&P.jsx("img",{className:"wt-queue-thumb",src:`https://img.youtube.com/vi/${(Je=St.url.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/))==null?void 0:Je[1]}/default.jpg`,alt:""}),P.jsxs("div",{className:"wt-queue-item-text",children:[P.jsx("div",{className:"wt-queue-item-title",children:St.title||St.url}),P.jsx("div",{className:"wt-queue-item-by",children:St.addedBy})]})]}),Oe&&P.jsx("button",{className:"wt-queue-item-remove",onClick:dt=>{dt.stopPropagation(),In(Kt)},title:"Entfernen",children:"×"})]},Kt)})}),P.jsxs("div",{className:"wt-queue-add",children:[P.jsx("input",{className:"wt-input wt-queue-input",placeholder:"Video-URL eingeben",value:N,onChange:St=>C(St.target.value),onKeyDown:St=>{St.key==="Enter"&&It()}}),P.jsx("button",{className:"wt-btn wt-queue-add-btn",onClick:It,disabled:Q,children:Q?"Laden...":"Hinzufuegen"})]})]}),ae&&P.jsxs("div",{className:"wt-chat-panel",children:[P.jsx("div",{className:"wt-chat-header",children:"Chat"}),P.jsxs("div",{className:"wt-chat-messages",children:[ie.length===0?P.jsx("div",{className:"wt-chat-empty",children:"Noch keine Nachrichten"}):ie.map((St,Kt)=>P.jsxs("div",{className:"wt-chat-msg",children:[P.jsx("span",{className:"wt-chat-sender",children:St.sender}),P.jsx("span",{className:"wt-chat-text",children:St.text})]},Kt)),P.jsx("div",{ref:yt})]}),P.jsxs("div",{className:"wt-chat-input-row",children:[P.jsx("input",{className:"wt-input wt-chat-input",placeholder:"Nachricht...",value:re,onChange:St=>Z(St.target.value),onKeyDown:St=>{St.key==="Enter"&<()},maxLength:500}),P.jsx("button",{className:"wt-btn wt-chat-send-btn",onClick:lt,children:"Senden"})]})]})]})]})}return P.jsxs("div",{className:"wt-container",children:[S&&P.jsxs("div",{className:"wt-error",children:[S,P.jsx("button",{className:"wt-error-dismiss",onClick:()=>T(null),children:"×"})]}),P.jsxs("div",{className:"wt-topbar",children:[P.jsx("input",{className:"wt-input wt-input-name",placeholder:"Dein Name",value:n,onChange:$e=>r($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-room",placeholder:"Raumname",value:s,onChange:$e=>a($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-password",type:"password",placeholder:"Passwort (optional)",value:l,onChange:$e=>u($e.target.value)}),P.jsx("button",{className:"wt-btn",onClick:Le,children:"Raum erstellen"})]}),e.length===0?P.jsxs("div",{className:"wt-empty",children:[P.jsx("div",{className:"wt-empty-icon",children:"🎬"}),P.jsx("h3",{children:"Keine aktiven Raeume"}),P.jsx("p",{children:"Erstelle einen Raum, um gemeinsam Videos zu schauen."})]}):P.jsx("div",{className:"wt-grid",children:e.map($e=>P.jsxs("div",{className:"wt-tile",onClick:()=>Yt($e),children:[P.jsxs("div",{className:"wt-tile-preview",children:[P.jsx("span",{className:"wt-tile-icon",children:"🎬"}),P.jsxs("span",{className:"wt-tile-members",children:["👥"," ",$e.memberCount]}),$e.hasPassword&&P.jsx("span",{className:"wt-tile-lock",children:"🔒"}),$e.playing&&P.jsx("span",{className:"wt-tile-playing",children:"▶"})]}),P.jsxs("div",{className:"wt-tile-info",children:[P.jsxs("div",{className:"wt-tile-meta",children:[P.jsx("div",{className:"wt-tile-name",children:$e.name}),P.jsx("div",{className:"wt-tile-host",children:$e.hostName})]}),$e.memberNames&&$e.memberNames.length>0&&P.jsxs("div",{className:"wt-tile-members-list",children:[$e.memberNames.slice(0,5).join(", "),$e.memberNames.length>5&&` +${$e.memberNames.length-5}`]})]})]},$e.id))}),v&&P.jsx("div",{className:"wt-modal-overlay",onClick:()=>x(null),children:P.jsxs("div",{className:"wt-modal",onClick:$e=>$e.stopPropagation(),children:[P.jsx("h3",{children:v.roomName}),P.jsx("p",{children:"Raum-Passwort"}),v.error&&P.jsx("div",{className:"wt-modal-error",children:v.error}),P.jsx("input",{className:"wt-input",type:"password",placeholder:"Passwort",value:v.password,onChange:$e=>x(St=>St&&{...St,password:$e.target.value,error:null}),onKeyDown:$e=>{$e.key==="Enter"&&Wt()},autoFocus:!0}),P.jsxs("div",{className:"wt-modal-actions",children:[P.jsx("button",{className:"wt-modal-cancel",onClick:()=>x(null),children:"Abbrechen"}),P.jsx("button",{className:"wt-btn",onClick:Wt,children:"Beitreten"})]})]})})]})}function HS(i,e){return`https://media.steampowered.com/steamcommunity/public/images/apps/${i}/${e}.jpg`}function T7(i){if(i==null||i===0)return"—";if(i<60)return`${i} Min`;const e=Math.floor(i/60),t=i%60;return t>0?`${e}h ${t}m`:`${e}h`}function JAe(i){try{return new Date(i).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function e0e({data:i,isAdmin:e}){const[t,n]=se.useState([]),[r,s]=se.useState("overview"),[a,l]=se.useState(null),[u,h]=se.useState(new Set),[m,v]=se.useState(null),[x,S]=se.useState(null),[T,N]=se.useState(""),[C,E]=se.useState(null),[O,U]=se.useState(!1),[I,j]=se.useState(null),[z,G]=se.useState(new Set),[H,q]=se.useState("playtime"),V=se.useRef(null),Q=se.useRef(null),[J,ie]=se.useState("");se.useEffect(()=>{i!=null&&i.profiles&&n(i.profiles)},[i]);const le=se.useCallback(async()=>{try{const ee=await fetch("/api/game-library/profiles");if(ee.ok){const we=await ee.json();n(we.profiles||[])}}catch{}},[]),re=se.useCallback(()=>{const ee=window.open("/api/game-library/steam/login","_blank","width=800,height=600"),we=setInterval(()=>{ee&&ee.closed&&(clearInterval(we),setTimeout(le,1e3))},500)},[le]),Z=navigator.userAgent.includes("GamingHubDesktop"),[ne,de]=se.useState(!1),[be,Te]=se.useState(""),[ae,Me]=se.useState("idle"),[Ve,Ce]=se.useState(""),Fe=se.useCallback(()=>{const ee=a?`?linkTo=${a}`:"";if(Z){const we=window.open(`/api/game-library/gog/login${ee}`,"_blank","width=800,height=700"),Re=setInterval(()=>{we&&we.closed&&(clearInterval(Re),setTimeout(le,1e3))},500)}else window.open(`/api/game-library/gog/login${ee}`,"_blank","width=800,height=700"),Te(""),Me("idle"),Ce(""),de(!0)},[le,a,Z]),tt=se.useCallback(async()=>{let ee=be.trim();const we=ee.match(/[?&]code=([^&]+)/);if(we&&(ee=we[1]),!!ee){Me("loading"),Ce("Verbinde mit GOG...");try{const Re=await fetch("/api/game-library/gog/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:ee,linkTo:a||""})}),We=await Re.json();Re.ok&&We.ok?(Me("success"),Ce(`${We.profileName}: ${We.gameCount} Spiele geladen!`),le(),setTimeout(()=>de(!1),2e3)):(Me("error"),Ce(We.error||"Unbekannter Fehler"))}catch{Me("error"),Ce("Verbindung fehlgeschlagen.")}}},[be,a,le]);se.useEffect(()=>{const ee=()=>le();return window.addEventListener("gog-connected",ee),()=>window.removeEventListener("gog-connected",ee)},[le]),se.useEffect(()=>{const ee=()=>le();return window.addEventListener("focus",ee),()=>window.removeEventListener("focus",ee)},[le]);const je=se.useCallback(async ee=>{var we,Re;s("user"),l(ee),v(null),ie(""),U(!0);try{const We=await fetch(`/api/game-library/profile/${ee}/games`);if(We.ok){const Se=await We.json(),Le=Se.games||Se;v(Le);const ct=t.find(It=>It.id===ee),Dt=(Re=(we=ct==null?void 0:ct.platforms)==null?void 0:we.steam)==null?void 0:Re.steamId;Dt&&Le.filter(lt=>!lt.igdb).length>0&&(j(ee),fetch(`/api/game-library/igdb/enrich/${Dt}`).then(lt=>lt.ok?lt.json():null).then(()=>fetch(`/api/game-library/profile/${ee}/games`)).then(lt=>lt.ok?lt.json():null).then(lt=>{lt&&v(lt.games||lt)}).catch(()=>{}).finally(()=>j(null)))}}catch{}finally{U(!1)}},[t]),Rt=se.useCallback(async(ee,we)=>{var Se,Le;we&&we.stopPropagation();const Re=t.find(ct=>ct.id===ee),We=(Le=(Se=Re==null?void 0:Re.platforms)==null?void 0:Se.steam)==null?void 0:Le.steamId;try{We&&await fetch(`/api/game-library/user/${We}?refresh=true`),await le(),r==="user"&&a===ee&&je(ee)}catch{}},[le,r,a,je,t]),Et=se.useCallback(async ee=>{var We,Se;const we=t.find(Le=>Le.id===ee),Re=(Se=(We=we==null?void 0:we.platforms)==null?void 0:We.steam)==null?void 0:Se.steamId;if(Re){j(ee);try{(await fetch(`/api/game-library/igdb/enrich/${Re}`)).ok&&r==="user"&&a===ee&&je(ee)}catch{}finally{j(null)}}},[r,a,je,t]),Ft=se.useCallback(ee=>{h(we=>{const Re=new Set(we);return Re.has(ee)?Re.delete(ee):Re.add(ee),Re})},[]),Ut=se.useCallback(async()=>{if(!(u.size<2)){s("common"),S(null),U(!0);try{const ee=Array.from(u).join(","),we=await fetch(`/api/game-library/common-games?users=${ee}`);if(we.ok){const Re=await we.json();S(Re.games||Re)}else console.error("[GameLibrary] common-games error:",we.status,await we.text().catch(()=>"")),S([])}catch(ee){console.error("[GameLibrary] common-games fetch failed:",ee)}finally{U(!1)}}},[u]),Ke=se.useCallback(ee=>{if(N(ee),V.current&&clearTimeout(V.current),ee.length<2){E(null);return}V.current=setTimeout(async()=>{try{const we=await fetch(`/api/game-library/search?q=${encodeURIComponent(ee)}`);if(we.ok){const Re=await we.json();E(Re.results||Re)}}catch{}},300)},[]),ht=se.useCallback(ee=>{G(we=>{const Re=new Set(we);return Re.has(ee)?Re.delete(ee):Re.add(ee),Re})},[]),fe=se.useCallback(async(ee,we)=>{if(confirm(`${we==="steam"?"Steam":"GOG"}-Verknuepfung wirklich trennen?`))try{const Re=await fetch(`/api/game-library/profile/${ee}/${we}`,{method:"DELETE"});if(Re.ok&&(le(),(await Re.json()).ok)){const Se=t.find(ct=>ct.id===ee);(we==="steam"?Se==null?void 0:Se.platforms.gog:Se==null?void 0:Se.platforms.steam)||$t()}}catch{}},[le,t]);se.useCallback(async ee=>{const we=t.find(Re=>Re.id===ee);if(confirm(`Profil "${we==null?void 0:we.displayName}" wirklich komplett loeschen?`))try{(await fetch(`/api/game-library/profile/${ee}`,{method:"DELETE"})).ok&&(le(),$t())}catch{}},[le,t]);const $t=se.useCallback(()=>{s("overview"),l(null),v(null),S(null),ie(""),G(new Set),q("playtime")},[]),_t=$t,Gt=se.useCallback(ee=>t.find(we=>we.id===ee),[t]),yt=se.useCallback(ee=>typeof ee.playtime_forever=="number"?ee.playtime_forever:Array.isArray(ee.owners)?Math.max(...ee.owners.map(we=>we.playtime_forever||0)):0,[]),Ht=se.useCallback(ee=>[...ee].sort((we,Re)=>{var We,Se;if(H==="rating"){const Le=((We=we.igdb)==null?void 0:We.rating)??-1;return(((Se=Re.igdb)==null?void 0:Se.rating)??-1)-Le}return H==="name"?we.name.localeCompare(Re.name):yt(Re)-yt(we)}),[H,yt]),pt=se.useCallback(ee=>{var we,Re;return z.size===0?!0:(Re=(we=ee.igdb)==null?void 0:we.genres)!=null&&Re.length?ee.igdb.genres.some(We=>z.has(We)):!1},[z]),Ae=se.useCallback(ee=>{var Re;const we=new Map;for(const We of ee)if((Re=We.igdb)!=null&&Re.genres)for(const Se of We.igdb.genres)we.set(Se,(we.get(Se)||0)+1);return[...we.entries()].sort((We,Se)=>Se[1]-We[1]).map(([We])=>We)},[]),k=m?Ht(m.filter(ee=>!J||ee.name.toLowerCase().includes(J.toLowerCase())).filter(pt)):null,xe=m?Ae(m):[],Oe=x?Ae(x):[],Ue=x?Ht(x.filter(pt)):null;return P.jsxs("div",{className:"gl-container",children:[P.jsxs("div",{className:"gl-login-bar",children:[!a&&P.jsx("button",{className:"gl-connect-btn gl-steam-btn",onClick:re,children:"🎮 Steam verbinden"}),P.jsx("div",{className:"gl-login-bar-spacer"})]}),t.length>0&&P.jsx("div",{className:"gl-profile-chips",children:t.map(ee=>P.jsxs("div",{className:`gl-profile-chip${a===ee.id?" selected":""}`,onClick:()=>je(ee.id),children:[P.jsx("img",{className:"gl-profile-chip-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"gl-profile-chip-info",children:[P.jsx("span",{className:"gl-profile-chip-name",children:ee.displayName}),P.jsxs("span",{className:"gl-profile-chip-platforms",children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:`Steam: ${ee.platforms.steam.gameCount} Spiele`,children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:`GOG: ${ee.platforms.gog.gameCount} Spiele`,children:"G"})]})]}),P.jsxs("span",{className:"gl-profile-chip-count",children:["(",ee.totalGames,")"]})]},ee.id))}),r==="overview"&&P.jsx(P.Fragment,{children:t.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"🎮"}),P.jsx("h3",{children:"Keine Konten verbunden"}),P.jsx("p",{children:"Klicke oben auf “Steam verbinden” oder “GOG verbinden”, um deine Spielebibliothek hinzuzufuegen."})]}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"gl-section-title",children:"Verbundene Spieler"}),P.jsx("div",{className:"gl-users-grid",children:t.map(ee=>P.jsxs("div",{className:"gl-user-card",onClick:()=>je(ee.id),children:[P.jsx("img",{className:"gl-user-card-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsx("span",{className:"gl-user-card-name",children:ee.displayName}),P.jsxs("div",{className:"gl-profile-card-platforms",children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:"Steam",children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:"GOG",children:"G"})]}),P.jsxs("span",{className:"gl-user-card-games",children:[ee.totalGames," Spiele"]}),P.jsxs("span",{className:"gl-user-card-updated",children:["Aktualisiert: ",JAe(ee.lastUpdated)]})]},ee.id))}),t.length>=2&&P.jsxs("div",{className:"gl-common-finder",children:[P.jsx("h3",{children:"Gemeinsame Spiele finden"}),P.jsx("div",{className:"gl-common-users",children:t.map(ee=>P.jsxs("label",{className:`gl-common-check${u.has(ee.id)?" checked":""}`,children:[P.jsx("input",{type:"checkbox",checked:u.has(ee.id),onChange:()=>Ft(ee.id)}),P.jsx("img",{className:"gl-common-check-avatar",src:ee.avatarUrl,alt:ee.displayName}),ee.displayName,P.jsxs("span",{className:"gl-profile-chip-platforms",style:{marginLeft:4},children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",children:"G"})]})]},ee.id))}),P.jsx("button",{className:"gl-common-find-btn",disabled:u.size<2,onClick:Ut,children:"Finden"})]}),P.jsx("div",{className:"gl-search",children:P.jsx("input",{className:"gl-search-input",type:"text",placeholder:"Spiel suchen...",value:T,onChange:ee=>Ke(ee.target.value)})}),C&&C.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"gl-search-results-title",children:[C.length," Ergebnis",C.length!==1?"se":""]}),P.jsx("div",{className:"gl-game-list",children:C.map(ee=>P.jsxs("div",{className:"gl-game-item",children:[ee.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(ee.appid,ee.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"}),P.jsx("span",{className:"gl-game-name",children:ee.name}),P.jsx("div",{className:"gl-game-owners",children:ee.owners.map(we=>{const Re=t.find(We=>{var Se;return((Se=We.platforms.steam)==null?void 0:Se.steamId)===we.steamId});return Re?P.jsx("img",{className:"gl-game-owner-avatar",src:Re.avatarUrl,alt:we.personaName,title:we.personaName},we.steamId):null})})]},ee.appid))})]}),C&&C.length===0&&P.jsx("p",{className:"gl-search-results-title",children:"Keine Ergebnisse gefunden."})]})}),r==="user"&&(()=>{const ee=a?Gt(a):null;return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:_t,children:"← Zurueck"}),ee&&P.jsxs(P.Fragment,{children:[P.jsx("img",{className:"gl-detail-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsxs("div",{className:"gl-detail-name",children:[ee.displayName,P.jsxs("span",{className:"gl-game-count",children:[ee.totalGames," Spiele"]})]}),P.jsxs("div",{className:"gl-detail-sub",children:[ee.platforms.steam&&P.jsxs("span",{className:"gl-platform-detail steam",children:[P.jsx("span",{className:"gl-platform-badge steam",children:"Steam ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:we=>{we.stopPropagation(),fe(ee.id,"steam")},title:"Steam trennen",children:"✕"})]}),ee.platforms.gog?P.jsxs("span",{className:"gl-platform-detail gog",children:[P.jsx("span",{className:"gl-platform-badge gog",children:"GOG ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:we=>{we.stopPropagation(),fe(ee.id,"gog")},title:"GOG trennen",children:"✕"})]}):P.jsx("button",{className:"gl-link-gog-btn",onClick:Fe,children:"🟣 GOG verknuepfen"})]})]}),P.jsx("button",{className:"gl-refresh-btn",onClick:()=>Rt(ee.id),title:"Aktualisieren",children:"↻"}),ee.platforms.steam&&P.jsxs("button",{className:`gl-enrich-btn ${I===a?"enriching":""}`,onClick:()=>Et(a),disabled:I===a,title:I===a?"IGDB-Daten werden geladen...":"Mit IGDB-Daten anreichern (erneut)",children:[I===a?"⏳":"🌐"," IGDB"]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Bibliothek wird geladen..."}):k?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-filter-bar",children:[P.jsx("input",{ref:Q,className:"gl-search-input",type:"text",placeholder:"Bibliothek durchsuchen...",value:J,onChange:we=>ie(we.target.value)}),P.jsxs("select",{className:"gl-sort-select",value:H,onChange:we=>q(we.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})]}),xe.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),xe.map(we=>P.jsx("button",{className:`gl-genre-chip${z.has(we)?" active":""}`,onClick:()=>ht(we),children:we},we))]}),P.jsxs("p",{className:"gl-filter-count",children:[k.length," Spiele"]}),k.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Spiele gefunden."}):P.jsx("div",{className:"gl-game-list",children:k.map((we,Re)=>{var We,Se,Le;return P.jsxs("div",{className:`gl-game-item ${we.igdb?"enriched":""}`,children:[P.jsx("span",{className:`gl-game-platform-icon ${we.platform||"steam"}`,children:we.platform==="gog"?"G":"S"}),P.jsx("div",{className:"gl-game-visual",children:(We=we.igdb)!=null&&We.coverUrl?P.jsx("img",{className:"gl-game-cover",src:we.igdb.coverUrl,alt:""}):we.img_icon_url&&we.appid?P.jsx("img",{className:"gl-game-icon",src:HS(we.appid,we.img_icon_url),alt:""}):we.image?P.jsx("img",{className:"gl-game-icon",src:we.image,alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:we.name}),((Se=we.igdb)==null?void 0:Se.genres)&&we.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:we.igdb.genres.slice(0,3).map(ct=>P.jsx("span",{className:"gl-genre-tag",children:ct},ct))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Le=we.igdb)==null?void 0:Le.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${we.igdb.rating>=75?"high":we.igdb.rating>=50?"mid":"low"}`,children:Math.round(we.igdb.rating)}),P.jsx("span",{className:"gl-game-playtime",children:T7(we.playtime_forever)})]})]},we.appid??we.gogId??Re)})})]}):null]})})(),r==="common"&&(()=>{const ee=Array.from(u).map(Re=>Gt(Re)).filter(Boolean),we=ee.map(Re=>Re.displayName).join(", ");return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:_t,children:"← Zurueck"}),P.jsx("div",{className:"gl-detail-avatars",children:ee.map(Re=>P.jsx("img",{src:Re.avatarUrl,alt:Re.displayName},Re.id))}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsx("div",{className:"gl-detail-name",children:"Gemeinsame Spiele"}),P.jsxs("div",{className:"gl-detail-sub",children:["von ",we]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Gemeinsame Spiele werden gesucht..."}):x?x.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"😔"}),P.jsx("h3",{children:"Keine gemeinsamen Spiele"}),P.jsx("p",{children:"Die ausgewaehlten Spieler besitzen leider keine gemeinsamen Spiele."})]}):P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"gl-filter-bar",children:P.jsxs("select",{className:"gl-sort-select",value:H,onChange:Re=>q(Re.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})}),Oe.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),Oe.map(Re=>P.jsx("button",{className:`gl-genre-chip${z.has(Re)?" active":""}`,onClick:()=>ht(Re),children:Re},Re))]}),P.jsxs("p",{className:"gl-section-title",children:[Ue.length," gemeinsame",Ue.length!==1?" Spiele":"s Spiel",z.size>0?` (von ${x.length})`:""]}),P.jsx("div",{className:"gl-game-list",children:Ue.map(Re=>{var We,Se,Le;return P.jsxs("div",{className:`gl-game-item ${Re.igdb?"enriched":""}`,children:[P.jsx("div",{className:"gl-game-visual",children:(We=Re.igdb)!=null&&We.coverUrl?P.jsx("img",{className:"gl-game-cover",src:Re.igdb.coverUrl,alt:""}):Re.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(Re.appid,Re.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:Re.name}),((Se=Re.igdb)==null?void 0:Se.genres)&&Re.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:Re.igdb.genres.slice(0,3).map(ct=>P.jsx("span",{className:"gl-genre-tag",children:ct},ct))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Le=Re.igdb)==null?void 0:Le.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${Re.igdb.rating>=75?"high":Re.igdb.rating>=50?"mid":"low"}`,children:Math.round(Re.igdb.rating)}),P.jsx("div",{className:"gl-common-playtimes",children:Re.owners.map(ct=>P.jsxs("span",{className:"gl-common-pt",children:[ct.personaName,": ",T7(ct.playtime_forever)]},ct.steamId))})]})]},Re.appid)})})]}):null]})})(),ne&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>de(!1),children:P.jsxs("div",{className:"gl-dialog",onClick:ee=>ee.stopPropagation(),children:[P.jsx("h3",{children:"🟣 GOG verbinden"}),P.jsxs("p",{className:"gl-dialog-hint",children:["Nach dem GOG-Login wirst du auf eine Seite weitergeleitet. Kopiere die ",P.jsx("strong",{children:"komplette URL"})," aus der Adressleiste und füge sie hier ein:"]}),P.jsx("input",{className:"gl-dialog-input",type:"text",placeholder:"https://embed.gog.com/on_login_success?code=...",value:be,onChange:ee=>Te(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&tt()},disabled:ae==="loading"||ae==="success",autoFocus:!0}),Ve&&P.jsx("p",{className:`gl-dialog-status ${ae}`,children:Ve}),P.jsxs("div",{className:"gl-dialog-actions",children:[P.jsx("button",{onClick:()=>de(!1),className:"gl-dialog-cancel",children:"Abbrechen"}),P.jsx("button",{onClick:tt,className:"gl-dialog-submit",disabled:!be.trim()||ae==="loading"||ae==="success",children:ae==="loading"?"Verbinde...":"Verbinden"})]})]})})]})}const lx="/api/soundboard";async function t0e(){const i=new URL(`${lx}/sounds`,window.location.origin);i.searchParams.set("folder","__all__"),i.searchParams.set("fuzzy","0");const e=await fetch(i.toString());if(!e.ok)throw new Error("Fehler beim Laden der Sounds");return e.json()}async function n0e(i){if(!(await fetch(`${lx}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}async function i0e(i,e){const t=await fetch(`${lx}/admin/sounds/rename`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({from:i,to:e})});if(!t.ok)throw new Error("Umbenennen fehlgeschlagen");const n=await t.json();return n==null?void 0:n.to}function r0e(i,e){return new Promise((t,n)=>{const r=new FormData;r.append("files",i);const s=new XMLHttpRequest;s.open("POST",`${lx}/upload`),s.upload.onprogress=a=>{a.lengthComputable&&e(Math.round(a.loaded/a.total*100))},s.onload=()=>{var a,l;if(s.status===200)try{const u=JSON.parse(s.responseText);t(((l=(a=u.files)==null?void 0:a[0])==null?void 0:l.name)??i.name)}catch{t(i.name)}else try{n(new Error(JSON.parse(s.responseText).error))}catch{n(new Error(`HTTP ${s.status}`))}},s.onerror=()=>n(new Error("Netzwerkfehler")),s.send(r)})}function s0e({onClose:i,onLogout:e}){var Oe,Ue;const[t,n]=se.useState("soundboard"),[r,s]=se.useState(null),a=se.useCallback((ee,we="info")=>{s({msg:ee,type:we}),setTimeout(()=>s(null),3e3)},[]);se.useEffect(()=>{const ee=we=>{we.key==="Escape"&&i()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[i]);const[l,u]=se.useState([]),[h,m]=se.useState(!1),[v,x]=se.useState(""),[S,T]=se.useState({}),[N,C]=se.useState(""),[E,O]=se.useState(""),[U,I]=se.useState(null),j=se.useCallback(ee=>ee.relativePath??ee.fileName,[]),z=se.useCallback(async()=>{m(!0);try{const ee=await t0e();u(ee.items||[])}catch(ee){a((ee==null?void 0:ee.message)||"Sounds konnten nicht geladen werden","error")}finally{m(!1)}},[a]),[G,H]=se.useState(!1);se.useEffect(()=>{t==="soundboard"&&!G&&(H(!0),z())},[t,G,z]);const q=se.useMemo(()=>{const ee=v.trim().toLowerCase();return ee?l.filter(we=>{const Re=j(we).toLowerCase();return we.name.toLowerCase().includes(ee)||(we.folder||"").toLowerCase().includes(ee)||Re.includes(ee)}):l},[v,l,j]),V=se.useMemo(()=>Object.keys(S).filter(ee=>S[ee]),[S]),Q=se.useMemo(()=>q.filter(ee=>!!S[j(ee)]).length,[q,S,j]),J=q.length>0&&Q===q.length;function ie(ee){T(we=>({...we,[ee]:!we[ee]}))}function le(ee){C(j(ee)),O(ee.name)}function re(){C(""),O("")}async function Z(){if(!N)return;const ee=E.trim().replace(/\.(mp3|wav)$/i,"");if(!ee){a("Bitte einen gueltigen Namen eingeben","error");return}try{await i0e(N,ee),a("Sound umbenannt"),re(),await z()}catch(we){a((we==null?void 0:we.message)||"Umbenennen fehlgeschlagen","error")}}async function ne(ee){if(ee.length!==0)try{await n0e(ee),a(ee.length===1?"Sound geloescht":`${ee.length} Sounds geloescht`),T({}),re(),await z()}catch(we){a((we==null?void 0:we.message)||"Loeschen fehlgeschlagen","error")}}async function de(ee){I(0);try{await r0e(ee,we=>I(we)),a(`"${ee.name}" hochgeladen`),await z()}catch(we){a((we==null?void 0:we.message)||"Upload fehlgeschlagen","error")}finally{I(null)}}const[be,Te]=se.useState([]),[ae,Me]=se.useState([]),[Ve,Ce]=se.useState(!1),[Fe,tt]=se.useState(!1),[je,Rt]=se.useState({online:!1,botTag:null}),Et=se.useCallback(async()=>{Ce(!0);try{const[ee,we,Re]=await Promise.all([fetch("/api/notifications/status"),fetch("/api/notifications/channels",{credentials:"include"}),fetch("/api/notifications/config",{credentials:"include"})]);if(ee.ok){const We=await ee.json();Rt(We)}if(we.ok){const We=await we.json();Te(We.channels||[])}if(Re.ok){const We=await Re.json();Me(We.channels||[])}}catch{}finally{Ce(!1)}},[]),[Ft,Ut]=se.useState(!1);se.useEffect(()=>{t==="streaming"&&!Ft&&(Ut(!0),Et())},[t,Ft,Et]);const Ke=se.useCallback((ee,we,Re,We,Se)=>{Me(Le=>{const ct=Le.find(Dt=>Dt.channelId===ee);if(ct){const It=ct.events.includes(Se)?ct.events.filter(lt=>lt!==Se):[...ct.events,Se];return It.length===0?Le.filter(lt=>lt.channelId!==ee):Le.map(lt=>lt.channelId===ee?{...lt,events:It}:lt)}else return[...Le,{channelId:ee,channelName:we,guildId:Re,guildName:We,events:[Se]}]})},[]),ht=se.useCallback((ee,we)=>{const Re=ae.find(We=>We.channelId===ee);return(Re==null?void 0:Re.events.includes(we))??!1},[ae]),fe=se.useCallback(async()=>{tt(!0);try{await fetch("/api/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channels:ae}),credentials:"include"}),a("Konfiguration gespeichert")}catch{a("Speichern fehlgeschlagen","error")}finally{tt(!1)}},[ae,a]),[$t,_t]=se.useState([]),[Gt,yt]=se.useState(!1),Ht=se.useCallback(async()=>{yt(!0);try{const ee=await fetch("/api/game-library/admin/profiles",{credentials:"include"});if(ee.ok){const we=await ee.json();_t(we.profiles||[])}}catch{}finally{yt(!1)}},[]),[pt,Ae]=se.useState(!1);se.useEffect(()=>{t==="game-library"&&!pt&&(Ae(!0),Ht())},[t,pt,Ht]);const k=se.useCallback(async(ee,we)=>{if(confirm(`Profil "${we}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`))try{(await fetch(`/api/game-library/admin/profile/${ee}`,{method:"DELETE",credentials:"include"})).ok&&(a("Profil geloescht"),Ht())}catch{a("Loeschen fehlgeschlagen","error")}},[Ht,a]),xe=[{id:"soundboard",icon:"🎵",label:"Soundboard"},{id:"streaming",icon:"📺",label:"Streaming"},{id:"game-library",icon:"🎮",label:"Game Library"}];return P.jsx("div",{className:"ap-overlay",onClick:ee=>{ee.target===ee.currentTarget&&i()},children:P.jsxs("div",{className:"ap-modal",children:[P.jsxs("div",{className:"ap-sidebar",children:[P.jsxs("div",{className:"ap-sidebar-title",children:["⚙️"," Admin"]}),P.jsx("nav",{className:"ap-nav",children:xe.map(ee=>P.jsxs("button",{className:`ap-nav-item ${t===ee.id?"active":""}`,onClick:()=>n(ee.id),children:[P.jsx("span",{className:"ap-nav-icon",children:ee.icon}),P.jsx("span",{className:"ap-nav-label",children:ee.label})]},ee.id))}),P.jsxs("button",{className:"ap-logout-btn",onClick:e,children:["🔒"," Abmelden"]})]}),P.jsxs("div",{className:"ap-content",children:[P.jsxs("div",{className:"ap-header",children:[P.jsxs("h2",{className:"ap-title",children:[(Oe=xe.find(ee=>ee.id===t))==null?void 0:Oe.icon," ",(Ue=xe.find(ee=>ee.id===t))==null?void 0:Ue.label]}),P.jsx("button",{className:"ap-close",onClick:i,children:"✕"})]}),P.jsxs("div",{className:"ap-body",children:[t==="soundboard"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsx("input",{type:"text",className:"ap-search",value:v,onChange:ee=>x(ee.target.value),placeholder:"Nach Name, Ordner oder Pfad filtern..."}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{z()},disabled:h,children:["↻"," Aktualisieren"]})]}),P.jsxs("label",{className:"ap-upload-zone",children:[P.jsx("input",{type:"file",accept:".mp3,.wav",style:{display:"none"},onChange:ee=>{var Re;const we=(Re=ee.target.files)==null?void 0:Re[0];we&&de(we),ee.target.value=""}}),U!==null?P.jsxs("span",{className:"ap-upload-progress",children:["Upload: ",U,"%"]}):P.jsxs("span",{className:"ap-upload-text",children:["⬆️"," Datei hochladen (MP3 / WAV)"]})]}),P.jsxs("div",{className:"ap-bulk-row",children:[P.jsxs("label",{className:"ap-select-all",children:[P.jsx("input",{type:"checkbox",checked:J,onChange:ee=>{const we=ee.target.checked,Re={...S};q.forEach(We=>{Re[j(We)]=we}),T(Re)}}),P.jsxs("span",{children:["Alle sichtbaren (",Q,"/",q.length,")"]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger",disabled:V.length===0,onClick:async()=>{window.confirm(`Wirklich ${V.length} Sound(s) loeschen?`)&&await ne(V)},children:["🗑️"," Ausgewaehlte loeschen"]})]}),P.jsx("div",{className:"ap-list-wrap",children:h?P.jsx("div",{className:"ap-empty",children:"Lade Sounds..."}):q.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Sounds gefunden."}):P.jsx("div",{className:"ap-list",children:q.map(ee=>{const we=j(ee),Re=N===we;return P.jsxs("div",{className:"ap-item",children:[P.jsx("label",{className:"ap-item-check",children:P.jsx("input",{type:"checkbox",checked:!!S[we],onChange:()=>ie(we)})}),P.jsxs("div",{className:"ap-item-main",children:[P.jsx("div",{className:"ap-item-name",children:ee.name}),P.jsxs("div",{className:"ap-item-meta",children:[ee.folder?`Ordner: ${ee.folder}`:"Root"," · ",we]}),Re&&P.jsxs("div",{className:"ap-rename-row",children:[P.jsx("input",{className:"ap-rename-input",value:E,onChange:We=>O(We.target.value),onKeyDown:We=>{We.key==="Enter"&&Z(),We.key==="Escape"&&re()},placeholder:"Neuer Name...",autoFocus:!0}),P.jsx("button",{className:"ap-btn ap-btn-primary ap-btn-sm",onClick:()=>{Z()},children:"Speichern"}),P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:re,children:"Abbrechen"})]})]}),!Re&&P.jsxs("div",{className:"ap-item-actions",children:[P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:()=>le(ee),children:"Umbenennen"}),P.jsx("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:async()=>{window.confirm(`Sound "${ee.name}" loeschen?`)&&await ne([we])},children:"Loeschen"})]})]},we)})})})]}),t==="streaming"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:`ap-status-dot ${je.online?"online":""}`}),je.online?P.jsxs(P.Fragment,{children:["Bot online: ",P.jsx("b",{children:je.botTag})]}):P.jsx(P.Fragment,{children:"Bot offline"})]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{Et()},disabled:Ve,children:["↻"," Aktualisieren"]})]}),Ve?P.jsx("div",{className:"ap-empty",children:"Lade Kanaele..."}):be.length===0?P.jsx("div",{className:"ap-empty",children:je.online?"Keine Text-Kanaele gefunden. Bot hat moeglicherweise keinen Zugriff.":"Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren."}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"ap-hint",children:"Waehle die Kanaele, in die Benachrichtigungen gesendet werden sollen:"}),P.jsx("div",{className:"ap-channel-list",children:be.map(ee=>P.jsxs("div",{className:"ap-channel-row",children:[P.jsxs("div",{className:"ap-channel-info",children:[P.jsxs("span",{className:"ap-channel-name",children:["#",ee.channelName]}),P.jsx("span",{className:"ap-channel-guild",children:ee.guildName})]}),P.jsxs("div",{className:"ap-channel-toggles",children:[P.jsxs("label",{className:`ap-toggle ${ht(ee.channelId,"stream_start")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:ht(ee.channelId,"stream_start"),onChange:()=>Ke(ee.channelId,ee.channelName,ee.guildId,ee.guildName,"stream_start")}),"🔴"," Stream Start"]}),P.jsxs("label",{className:`ap-toggle ${ht(ee.channelId,"stream_end")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:ht(ee.channelId,"stream_end"),onChange:()=>Ke(ee.channelId,ee.channelName,ee.guildId,ee.guildName,"stream_end")}),"⏹️"," Stream Ende"]})]})]},ee.channelId))}),P.jsx("div",{className:"ap-save-row",children:P.jsx("button",{className:"ap-btn ap-btn-primary",onClick:fe,disabled:Fe,children:Fe?"Speichern...":"💾 Speichern"})})]})]}),t==="game-library"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:"ap-status-dot online"}),"Eingeloggt als Admin"]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{Ht()},disabled:Gt,children:["↻"," Aktualisieren"]})]}),Gt?P.jsx("div",{className:"ap-empty",children:"Lade Profile..."}):$t.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Profile vorhanden."}):P.jsx("div",{className:"ap-profile-list",children:$t.map(ee=>P.jsxs("div",{className:"ap-profile-row",children:[P.jsx("img",{className:"ap-profile-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"ap-profile-info",children:[P.jsx("span",{className:"ap-profile-name",children:ee.displayName}),P.jsxs("span",{className:"ap-profile-details",children:[ee.steamName&&P.jsxs("span",{className:"ap-platform-badge steam",children:["Steam: ",ee.steamGames]}),ee.gogName&&P.jsxs("span",{className:"ap-platform-badge gog",children:["GOG: ",ee.gogGames]}),P.jsxs("span",{className:"ap-profile-total",children:[ee.totalGames," Spiele"]})]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:()=>k(ee.id,ee.displayName),children:["🗑️"," Entfernen"]})]},ee.id))})]})]})]}),r&&P.jsxs("div",{className:`ap-toast ${r.type}`,children:[r.type==="error"?"❌":"✅"," ",r.msg]})]})})}const M7={radio:MAe,soundboard:jAe,lolstats:YAe,streaming:QAe,"watch-together":ZAe,"game-library":e0e};function a0e(){var Z;const[i,e]=se.useState(!1),[t,n]=se.useState([]),[r,s]=se.useState(()=>localStorage.getItem("hub_activeTab")??""),a=ne=>{s(ne),localStorage.setItem("hub_activeTab",ne)},[l,u]=se.useState(!1),[h,m]=se.useState({}),[v,x]=se.useState(!1),[S,T]=se.useState(!1),[N,C]=se.useState(!1),[E,O]=se.useState(""),[U,I]=se.useState(""),j=!!((Z=window.electronAPI)!=null&&Z.isElectron),z=j?window.electronAPI.version:null,[G,H]=se.useState("idle"),[q,V]=se.useState(""),Q=se.useRef(null);se.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]),se.useEffect(()=>{fetch("/api/soundboard/admin/status",{credentials:"include"}).then(ne=>ne.json()).then(ne=>x(!!ne.authenticated)).catch(()=>{})},[]),se.useEffect(()=>{if(!S)return;const ne=de=>{de.key==="Escape"&&T(!1)};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[S]);async function J(){I("");try{(await fetch("/api/soundboard/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:E}),credentials:"include"})).ok?(x(!0),O(""),T(!1)):I("Falsches Passwort")}catch{I("Verbindung fehlgeschlagen")}}async function ie(){await fetch("/api/soundboard/admin/logout",{method:"POST",credentials:"include"}),x(!1)}se.useEffect(()=>{var be;if(!j)return;const ne=window.electronAPI;ne.onUpdateAvailable(()=>H("downloading")),ne.onUpdateReady(()=>H("ready")),ne.onUpdateNotAvailable(()=>H("upToDate")),ne.onUpdateError(Te=>{H("error"),V(Te||"Unbekannter Fehler")});const de=(be=ne.getUpdateStatus)==null?void 0:be.call(ne);de==="downloading"?H("downloading"):de==="ready"?H("ready"):de==="checking"&&H("checking")},[j]),se.useEffect(()=>{fetch("/api/plugins").then(ne=>ne.json()).then(ne=>{if(n(ne),new URLSearchParams(location.search).has("viewStream")&&ne.some(ae=>ae.name==="streaming")){a("streaming");return}const be=localStorage.getItem("hub_activeTab"),Te=ne.some(ae=>ae.name===be);ne.length>0&&!Te&&a(ne[0].name)}).catch(()=>{})},[]),se.useEffect(()=>{let ne=null,de;function be(){ne=new EventSource("/api/events"),Q.current=ne,ne.onopen=()=>e(!0),ne.onmessage=Te=>{try{const ae=JSON.parse(Te.data);ae.type==="snapshot"?m(Me=>({...Me,...ae})):ae.plugin&&m(Me=>({...Me,[ae.plugin]:{...Me[ae.plugin]||{},...ae}}))}catch{}},ne.onerror=()=>{e(!1),ne==null||ne.close(),de=setTimeout(be,3e3)}}return be(),()=>{ne==null||ne.close(),clearTimeout(de)}},[]);const le="1.0.0-dev";se.useEffect(()=>{if(!l)return;const ne=de=>{de.key==="Escape"&&u(!1)};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[l]);const re={radio:"🌍",soundboard:"🎵",lolstats:"⚔️",stats:"📊",events:"📅",games:"🎲",gamevote:"🎮",streaming:"📺","watch-together":"🎬","game-library":"🎮"};return P.jsxs("div",{className:"hub-app",children:[P.jsxs("header",{className:"hub-header",children:[P.jsxs("div",{className:"hub-header-left",children:[P.jsx("span",{className:"hub-logo",children:"🎮"}),P.jsx("span",{className:"hub-title",children:"Gaming Hub"}),P.jsx("span",{className:`hub-conn-dot ${i?"online":""}`})]}),P.jsx("nav",{className:"hub-tabs",children:t.filter(ne=>ne.name in M7).map(ne=>P.jsxs("button",{className:`hub-tab ${r===ne.name?"active":""}`,onClick:()=>a(ne.name),title:ne.description,children:[P.jsx("span",{className:"hub-tab-icon",children:re[ne.name]??"📦"}),P.jsx("span",{className:"hub-tab-label",children:ne.name})]},ne.name))}),P.jsxs("div",{className:"hub-header-right",children:[!window.electronAPI&&P.jsxs("a",{className:"hub-download-btn",href:"/downloads/GamingHub-Setup.exe",download:!0,title:"Desktop App herunterladen",children:[P.jsx("span",{className:"hub-download-icon",children:"⬇️"}),P.jsx("span",{className:"hub-download-label",children:"Desktop App"})]}),P.jsx("button",{className:`hub-admin-btn ${v?"active":""}`,onClick:()=>v?C(!0):T(!0),onContextMenu:ne=>{v&&(ne.preventDefault(),ie())},title:v?"Admin Panel (Rechtsklick = Abmelden)":"Admin Login",children:v?"🔓":"🔒"}),P.jsx("button",{className:"hub-refresh-btn",onClick:()=>window.location.reload(),title:"Seite neu laden",children:"🔄"}),P.jsxs("span",{className:"hub-version hub-version-clickable",onClick:()=>{var ne;if(j){const de=window.electronAPI,be=(ne=de.getUpdateStatus)==null?void 0:ne.call(de);be==="downloading"?H("downloading"):be==="ready"?H("ready"):be==="checking"&&H("checking")}u(!0)},title:"Versionsinformationen",children:["v",le]})]})]}),l&&P.jsx("div",{className:"hub-version-overlay",onClick:()=>u(!1),children:P.jsxs("div",{className:"hub-version-modal",onClick:ne=>ne.stopPropagation(),children:[P.jsxs("div",{className:"hub-version-modal-header",children:[P.jsx("span",{children:"Versionsinformationen"}),P.jsx("button",{className:"hub-version-modal-close",onClick:()=>u(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-version-modal-body",children:[P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Hub-Version"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",le]})]}),j&&P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Desktop-App"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",z]})]}),P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Server"}),P.jsxs("span",{className:"hub-version-modal-value",children:[P.jsx("span",{className:`hub-version-modal-dot ${i?"online":""}`}),i?"Verbunden":"Getrennt"]})]}),j&&P.jsxs("div",{className:"hub-version-modal-update",children:[G==="idle"&&P.jsxs("button",{className:"hub-version-modal-update-btn",onClick:()=>{H("checking"),V(""),window.electronAPI.checkForUpdates()},children:["🔄"," Nach Updates suchen"]}),G==="checking"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Suche nach Updates…"]}),G==="downloading"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Update wird heruntergeladen…"]}),G==="ready"&&P.jsxs("button",{className:"hub-version-modal-update-btn ready",onClick:()=>window.electronAPI.installUpdate(),children:["✅"," Jetzt installieren & neu starten"]}),G==="upToDate"&&P.jsxs("div",{className:"hub-version-modal-update-status success",children:["✅"," App ist aktuell",P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut prüfen"})]}),G==="error"&&P.jsxs("div",{className:"hub-version-modal-update-status error",children:["❌"," ",q,P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut versuchen"})]})]})]})]})}),S&&P.jsx("div",{className:"hub-admin-overlay",onClick:()=>T(!1),children:P.jsxs("div",{className:"hub-admin-modal",onClick:ne=>ne.stopPropagation(),children:[P.jsxs("div",{className:"hub-admin-modal-header",children:[P.jsxs("span",{children:["🔒"," Admin Login"]}),P.jsx("button",{className:"hub-admin-modal-close",onClick:()=>T(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-admin-modal-body",children:[P.jsx("input",{type:"password",className:"hub-admin-input",placeholder:"Admin-Passwort...",value:E,onChange:ne=>O(ne.target.value),onKeyDown:ne=>ne.key==="Enter"&&J(),autoFocus:!0}),U&&P.jsx("p",{className:"hub-admin-error",children:U}),P.jsx("button",{className:"hub-admin-submit",onClick:J,children:"Login"})]})]})}),N&&v&&P.jsx(s0e,{onClose:()=>C(!1),onLogout:()=>{ie(),C(!1)}}),P.jsx("main",{className:"hub-content",children:t.length===0?P.jsxs("div",{className:"hub-empty",children:[P.jsx("span",{className:"hub-empty-icon",children:"📦"}),P.jsx("h2",{children:"Keine Plugins geladen"}),P.jsx("p",{children:"Plugins werden im Server konfiguriert."})]}):t.map(ne=>{const de=M7[ne.name];if(!de)return null;const be=r===ne.name;return P.jsx("div",{className:`hub-tab-panel ${be?"active":""}`,style:be?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{display:"none"},children:P.jsx(de,{data:h[ne.name]||{},isAdmin:v})},ne.name)})})]})}IF.createRoot(document.getElementById("root")).render(P.jsx(a0e,{})); diff --git a/web/dist/index.html b/web/dist/index.html index d42f932..e6783aa 100644 --- a/web/dist/index.html +++ b/web/dist/index.html @@ -5,8 +5,8 @@ Gaming Hub - - + +
diff --git a/web/src/AdminPanel.tsx b/web/src/AdminPanel.tsx index 7391c7e..020babd 100644 --- a/web/src/AdminPanel.tsx +++ b/web/src/AdminPanel.tsx @@ -19,6 +19,7 @@ type SoundsResponse = { interface AdminPanelProps { onClose: () => void; + onLogout: () => void; } /* ══════════════════════════════════════════════════════════════════ @@ -88,7 +89,7 @@ function apiUploadFile( type AdminTab = 'soundboard' | 'streaming' | 'game-library'; -export default function AdminPanel({ onClose }: AdminPanelProps) { +export default function AdminPanel({ onClose, onLogout }: AdminPanelProps) { const [activeTab, setActiveTab] = useState('soundboard'); // ── Toast ── @@ -372,6 +373,9 @@ export default function AdminPanel({ onClose }: AdminPanelProps) { ))} + {/* ── Content ── */} diff --git a/web/src/App.tsx b/web/src/App.tsx index 7f42823..b1290e2 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -394,7 +394,7 @@ export default function App() { )} {showAdminPanel && isAdmin && ( - setShowAdminPanel(false)} /> + setShowAdminPanel(false)} onLogout={() => { handleAdminLogout(); setShowAdminPanel(false); }} /> )}
diff --git a/web/src/styles.css b/web/src/styles.css index 257d09f..a1bc6b9 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -1772,6 +1772,22 @@ html, body { line-height: 1; } +.ap-logout-btn { + margin-top: auto; + padding: 10px 16px; + background: transparent; + border: none; + border-top: 1px solid var(--border); + color: #e74c3c; + font-size: 0.85rem; + cursor: pointer; + text-align: left; + transition: background 0.15s; +} +.ap-logout-btn:hover { + background: rgba(231, 76, 60, 0.1); +} + /* ── Content Area ── */ .ap-content { flex: 1; From c0956fbc7e00e9a9bf527e922e698dbddc4ef93c Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Mon, 9 Mar 2026 21:45:35 +0000 Subject: [PATCH 25/53] v1.8.7 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f263cd1..88d3ee7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.6 +1.8.7 From 0bd31d93a8b5510b89b4375d507ce75ca1d2f38f Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 23:41:09 +0100 Subject: [PATCH 26/53] =?UTF-8?q?Fix:=20Lautst=C3=A4rke=20w=C3=A4hrend=20W?= =?UTF-8?q?iedergabe=20steuerbar=20(inlineVolume=20immer=20aktiv)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bei PCM-Memory-Cache wurde inlineVolume nur aktiviert wenn vol != 1, dadurch fehlte das Volume-Objekt auf der AudioResource und apiSetVolumeLive konnte die Lautstärke nicht live ändern. Co-Authored-By: Claude Opus 4.6 --- server/src/plugins/soundboard/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/plugins/soundboard/index.ts b/server/src/plugins/soundboard/index.ts index d53238e..84eace7 100644 --- a/server/src/plugins/soundboard/index.ts +++ b/server/src/plugins/soundboard/index.ts @@ -532,7 +532,7 @@ async function playFilePath(guildId: string, channelId: string, filePath: string if (cachedPath) { const pcmBuf = getPcmFromMemory(cachedPath); if (pcmBuf) { - resource = createAudioResource(Readable.from(pcmBuf), { inlineVolume: useVolume !== 1, inputType: StreamType.Raw }); + resource = createAudioResource(Readable.from(pcmBuf), { inlineVolume: true, inputType: StreamType.Raw }); } else { resource = createAudioResource(fs.createReadStream(cachedPath, { highWaterMark: 256 * 1024 }), { inlineVolume: true, inputType: StreamType.Raw }); } From 25e47fb0934f384ab75db2395982dc0b30339daa Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Mon, 9 Mar 2026 22:43:59 +0000 Subject: [PATCH 27/53] v1.8.8 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 88d3ee7..1790d35 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.7 +1.8.8 From 7ed6b81584b37678321c7d68a6e2133063a0ff6d Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Mar 2026 23:58:02 +0100 Subject: [PATCH 28/53] Fix: Volume-Slider reaktionsschneller (Latenz reduziert) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Server: writeState() → writeStateDebounced() im Volume-Endpoint (kein synchroner Disk-Write bei jedem Slider-Tick mehr) - Frontend: Debounce von 120ms auf 50ms reduziert Co-Authored-By: Claude Opus 4.6 --- server/src/plugins/soundboard/index.ts | 2 +- web/dist/assets/{index-CUixApZu.js => index-CqHVUt2T.js} | 2 +- web/dist/index.html | 2 +- web/src/plugins/soundboard/SoundboardTab.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename web/dist/assets/{index-CUixApZu.js => index-CqHVUt2T.js} (94%) diff --git a/server/src/plugins/soundboard/index.ts b/server/src/plugins/soundboard/index.ts index 84eace7..77b49e3 100644 --- a/server/src/plugins/soundboard/index.ts +++ b/server/src/plugins/soundboard/index.ts @@ -1064,7 +1064,7 @@ const soundboardPlugin: Plugin = { if (state.currentResource?.volume) state.currentResource.volume.setVolume(safeVol); } persistedState.volumes[guildId] = safeVol; - writeState(); + writeStateDebounced(); sseBroadcast({ type: 'soundboard_volume', plugin: 'soundboard', guildId, volume: safeVol }); res.json({ ok: true, volume: safeVol }); }); diff --git a/web/dist/assets/index-CUixApZu.js b/web/dist/assets/index-CqHVUt2T.js similarity index 94% rename from web/dist/assets/index-CUixApZu.js rename to web/dist/assets/index-CqHVUt2T.js index db5599a..51f0cec 100644 --- a/web/dist/assets/index-CUixApZu.js +++ b/web/dist/assets/index-CqHVUt2T.js @@ -4827,4 +4827,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aAe(i,e){return Jde(i)||iAe(i,e)||fI(i,e)||rAe()}function Cf(i){return eAe(i)||nAe(i)||fI(i)||sAe()}function oAe(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function lAe(i){var e=oAe(i,"string");return typeof e=="symbol"?e:e+""}function fI(i,e){if(i){if(typeof i=="string")return yT(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?yT(i,e):void 0}}var xr=window.THREE?window.THREE:{WebGLRenderer:FH,Scene:ZT,PerspectiveCamera:va,Raycaster:Jz,SRGBColorSpace:bn,TextureLoader:oM,Vector2:bt,Vector3:pe,Box3:Oc,Color:cn,Mesh:Oi,SphereGeometry:bu,MeshBasicMaterial:cd,BackSide:or,Clock:hD},dI=_s({props:{width:{default:window.innerWidth,onChange:function(e,t,n){isNaN(e)&&(t.width=n)}},height:{default:window.innerHeight,onChange:function(e,t,n){isNaN(e)&&(t.height=n)}},viewOffset:{default:[0,0]},backgroundColor:{default:"#000011"},backgroundImageUrl:{},onBackgroundImageLoaded:{},showNavInfo:{default:!0},skyRadius:{default:5e4},objects:{default:[]},lights:{default:[]},enablePointerInteraction:{default:!0,onChange:function(e,t){t.hoverObj=null,t.tooltip&&t.tooltip.content(null)},triggerUpdate:!1},pointerRaycasterThrottleMs:{default:50,triggerUpdate:!1},lineHoverPrecision:{default:1,triggerUpdate:!1},pointsHoverPrecision:{default:1,triggerUpdate:!1},hoverOrderComparator:{triggerUpdate:!1},hoverFilter:{default:function(){return!0},triggerUpdate:!1},tooltipContent:{triggerUpdate:!1},hoverDuringDrag:{default:!1,triggerUpdate:!1},clickAfterDrag:{default:!1,triggerUpdate:!1},onHover:{default:function(){},triggerUpdate:!1},onClick:{default:function(){},triggerUpdate:!1},onRightClick:{triggerUpdate:!1}},methods:{tick:function(e){if(e.initialised){e.controls.enabled&&e.controls.update&&e.controls.update(Math.min(1,e.clock.getDelta())),e.postProcessingComposer?e.postProcessingComposer.render():e.renderer.render(e.scene,e.camera),e.extraRenderers.forEach(function(a){return a.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,l){return e.hoverOrderComparator(a.object,l.object)});var s=r.find(function(a){return e.hoverFilter(a.object)})||null;n=s?s.object:null,e.intersection=s||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&Lt(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var s=e.camera;if(t&&e.initialised){var a=t,l=n||{x:0,y:0,z:0};if(!r)m(a),v(l);else{var u=Object.assign({},s.position),h=x();e.tweenGroup.add(new la(u).to(a,r).easing(os.Quadratic.Out).onUpdate(m).start()),e.tweenGroup.add(new la(h).to(l,r/3).easing(os.Quadratic.Out).onUpdate(v).start())}return this}return Object.assign({},s.position,{lookAt:x()});function m(S){var T=S.x,N=S.y,C=S.z;T!==void 0&&(s.position.x=T),N!==void 0&&(s.position.y=N),C!==void 0&&(s.position.z=C)}function v(S){var T=new xr.Vector3(S.x,S.y,S.z);e.controls.enabled&&e.controls.target?e.controls.target=T:s.lookAt(T)}function x(){return Object.assign(new xr.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,s=new Array(r>3?r-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var a=new xr.Vector3(0,0,0),l=Math.max.apply(Math,Cf(Object.entries(t).map(function(S){var T=aAe(S,2),N=T[0],C=T[1];return Math.max.apply(Math,Cf(C.map(function(E){return Math.abs(a[N]-E)})))})))*2,u=(1-r*2/e.height)*s.fov,h=l/Math.atan(u*Math.PI/180),m=h/s.aspect,v=Math.max(h,m);if(v>0){var x=a.clone().sub(s.position).normalize().multiplyScalar(-v);this.cameraPosition(x,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new xr.Box3(new xr.Vector3(0,0,0),new xr.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(s){return n.expandByObject(s)}),Object.assign.apply(Object,Cf(["x","y","z"].map(function(s){return tAe({},s,[n.min[s],n.max[s]])})))):null},getScreenCoords:function(e,t,n,r){var s=new xr.Vector3(t,n,r);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new xr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new xr.Raycaster;return a.setFromCamera(s,e.camera),Object.assign({},a.ray.at(r,new xr.Vector3))},intersectingObjects:function(e,t,n){var r=new xr.Vector2(t/e.width*2-1,-(n/e.height)*2+1),s=new xr.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(r,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new xr.Scene,camera:new xr.PerspectiveCamera,clock:new xr.Clock,tweenGroup:new wy,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,s=r===void 0?"trackball":r,a=n.useWebGPU,l=a===void 0?!1:a,u=n.rendererConfig,h=u===void 0?{}:u,m=n.extraRenderers,v=m===void 0?[]:m,x=n.waitForLoadComplete,S=x===void 0?!0:x;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new Qde(t.container),t.pointerPos=new xr.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(T){return t.container.addEventListener(T,function(N){if(T==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&N.type==="pointermove"&&(N.pressure>0||t.isPointerPressed)&&(N.pointerType==="mouse"||N.movementX===void 0||[N.movementX,N.movementY].some(function(O){return Math.abs(O)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var C=E(t.container);t.pointerPos.x=N.pageX-C.left,t.pointerPos.y=N.pageY-C.top}function E(O){var U=O.getBoundingClientRect(),I=window.pageXOffset||document.documentElement.scrollLeft,j=window.pageYOffset||document.documentElement.scrollTop;return{top:U.top+j,left:U.left+I}}},{passive:!0})}),t.container.addEventListener("pointerup",function(T){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){T.button===0&&t.onClick(t.hoverObj||null,T,t.intersection),T.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,T,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(T){t.onRightClick&&T.preventDefault()}),t.renderer=new(l?cO:xr.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},h)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=v,t.extraRenderers.forEach(function(T){T.domElement.style.position="absolute",T.domElement.style.top="0px",T.domElement.style.pointerEvents="none",t.container.appendChild(T.domElement)}),t.postProcessingComposer=new rhe(t.renderer),t.postProcessingComposer.addPass(new she(t.scene,t.camera)),t.controls=new{trackball:dce,orbit:Nce,fly:Vce}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Cf(t.extraRenderers)).forEach(function(T){return T.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new xr.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!S,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,s=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Cf(e.extraRenderers)).forEach(function(S){return S.setSize(r,s)}),e.camera.aspect=r/s;var a=e.viewOffset.slice(0,2);a.some(function(S){return S})&&(n=e.camera).setViewOffset.apply(n,[r,s].concat(Cf(a),[r,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var l,u=e.width,h=e.height,m=e.viewOffset.slice(0,2);m.some(function(S){return S})?(l=e.camera).setViewOffset.apply(l,[u,h].concat(Cf(m),[u,h])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new xr.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var v=O0(e.backgroundColor).alpha;v===void 0&&(v=1),e.renderer.setClearColor(new xr.Color(Ohe(1,e.backgroundColor)),v)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new xr.TextureLoader().load(e.backgroundImageUrl,function(S){S.colorSpace=xr.SRGBColorSpace,e.skysphere.material=new xr.MeshBasicMaterial({map:S,side:xr.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&x()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&x())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(S){return e.scene.remove(S)}),e.lights.forEach(function(S){return e.scene.add(S)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(S){return e.scene.remove(S)}),e.objects.forEach(function(S){return e.scene.add(S)}));function x(){e.loadComplete=e.scene.visible=!0}}});function uAe(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var cAe=`.scene-container .clickable { cursor: pointer; }`;uAe(cAe);function xT(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t1?l-1:0),h=1;h1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=a();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(u){return s[u]=+s[u]}),!n)l(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new la(r).to(s,n).easing(os.Cubic.InOut).onUpdate(l).start())}return this;function a(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(u){var h=u.lat,m=u.lng,v=u.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(h,m,v)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;slocalStorage.getItem("radio-theme")||"default"),[a,l]=se.useState([]),[u,h]=se.useState(null),[m,v]=se.useState([]),[x,S]=se.useState(!1),[T,N]=se.useState({}),[C,E]=se.useState([]),[O,U]=se.useState(""),[I,j]=se.useState(""),[z,G]=se.useState(""),[H,q]=se.useState([]),[V,Q]=se.useState(!1),[J,ie]=se.useState([]),[le,re]=se.useState(!1),[Z,ne]=se.useState(!1),[de,be]=se.useState(.5),[Te,ae]=se.useState(null),[Me,Ve]=se.useState(!1),[Ce,Fe]=se.useState(!1),tt=se.useRef(void 0),je=se.useRef(void 0),Rt=se.useRef(O);se.useEffect(()=>{fetch("/api/radio/places").then(k=>k.json()).then(l).catch(console.error),fetch("/api/radio/guilds").then(k=>k.json()).then(k=>{if(E(k),k.length>0){U(k[0].id);const xe=k[0].voiceChannels.find(Oe=>Oe.members>0)??k[0].voiceChannels[0];xe&&j(xe.id)}}).catch(console.error),fetch("/api/radio/favorites").then(k=>k.json()).then(ie).catch(console.error)},[]),se.useEffect(()=>{Rt.current=O},[O]),se.useEffect(()=>{i!=null&&i.guildId&&"playing"in i&&i.type!=="radio_voicestats"?N(k=>{if(i.playing)return{...k,[i.guildId]:i.playing};const xe={...k};return delete xe[i.guildId],xe}):i!=null&&i.playing&&!(i!=null&&i.guildId)&&N(i.playing),i!=null&&i.favorites&&ie(i.favorites),i!=null&&i.volumes&&O&&i.volumes[O]!=null&&be(i.volumes[O]),(i==null?void 0:i.volume)!=null&&(i==null?void 0:i.guildId)===O&&be(i.volume),(i==null?void 0:i.type)==="radio_voicestats"&&i.guildId===Rt.current&&ae({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})},[i,O]),se.useEffect(()=>{if(localStorage.setItem("radio-theme",r),t.current&&e.current){const xe=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim();t.current.pointColor(()=>`rgba(${xe}, 0.85)`).atmosphereColor(`rgba(${xe}, 0.25)`)}},[r]);const Et=se.useRef(u);Et.current=u;const Ft=se.useRef(le);Ft.current=le;const Ut=se.useCallback(()=>{var xe;const k=(xe=t.current)==null?void 0:xe.controls();k&&(k.autoRotate=!1),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{var Ue;if(Et.current||Ft.current)return;const Oe=(Ue=t.current)==null?void 0:Ue.controls();Oe&&(Oe.autoRotate=!0)},5e3)},[]);se.useEffect(()=>{var xe;const k=(xe=t.current)==null?void 0:xe.controls();k&&(u||le?(k.autoRotate=!1,n.current&&clearTimeout(n.current)):k.autoRotate=!0)},[u,le]);const Ke=se.useRef(void 0);Ke.current=k=>{h(k),re(!1),S(!0),v([]),Ut(),t.current&&t.current.pointOfView({lat:k.geo[1],lng:k.geo[0],altitude:.4},800),fetch(`/api/radio/place/${k.id}/channels`).then(xe=>xe.json()).then(xe=>{v(xe),S(!1)}).catch(()=>S(!1))},se.useEffect(()=>{const k=e.current;if(!k)return;k.clientWidth>0&&k.clientHeight>0&&Fe(!0);const xe=new ResizeObserver(Oe=>{for(const Ue of Oe){const{width:ee,height:we}=Ue.contentRect;ee>0&&we>0&&Fe(!0)}});return xe.observe(k),()=>xe.disconnect()},[]),se.useEffect(()=>{if(!e.current||a.length===0)return;const k=e.current.clientWidth,xe=e.current.clientHeight;if(t.current){t.current.pointsData(a),k>0&&xe>0&&t.current.width(k).height(xe);return}if(k===0||xe===0)return;const Ue=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim()||"230, 126, 34",ee=new wAe(e.current).backgroundColor("rgba(0,0,0,0)").atmosphereColor(`rgba(${Ue}, 0.25)`).atmosphereAltitude(.12).globeImageUrl("/nasa-blue-marble.jpg").pointsData(a).pointLat(It=>It.geo[1]).pointLng(It=>It.geo[0]).pointColor(()=>`rgba(${Ue}, 0.85)`).pointRadius(It=>Math.max(.12,Math.min(.45,.06+(It.size??1)*.005))).pointAltitude(.001).pointResolution(24).pointLabel(It=>`
${It.title}
${It.country}
`).onPointClick(It=>{var lt;return(lt=Ke.current)==null?void 0:lt.call(Ke,It)}).width(e.current.clientWidth).height(e.current.clientHeight);ee.renderer().setPixelRatio(window.devicePixelRatio),ee.pointOfView({lat:48,lng:10,altitude:qS});const we=ee.controls();we&&(we.autoRotate=!0,we.autoRotateSpeed=.3);let Re=qS;const We=()=>{const lt=ee.pointOfView().altitude;if(Math.abs(lt-Re)/Re<.05)return;Re=lt;const jt=Math.sqrt(lt/qS);ee.pointRadius(Jt=>Math.max(.12,Math.min(.45,.06+(Jt.size??1)*.005))*Math.max(.15,Math.min(2.5,jt)))};we.addEventListener("change",We),t.current=ee;const Se=e.current,Le=()=>Ut();Se.addEventListener("mousedown",Le),Se.addEventListener("touchstart",Le),Se.addEventListener("wheel",Le);const ct=()=>{if(e.current&&t.current){const It=e.current.clientWidth,lt=e.current.clientHeight;It>0&<>0&&t.current.width(It).height(lt)}};window.addEventListener("resize",ct);const Dt=new ResizeObserver(()=>ct());return Dt.observe(Se),()=>{we.removeEventListener("change",We),Se.removeEventListener("mousedown",Le),Se.removeEventListener("touchstart",Le),Se.removeEventListener("wheel",Le),window.removeEventListener("resize",ct),Dt.disconnect()}},[a,Ut,Ce]);const ht=se.useCallback(async(k,xe,Oe,Ue)=>{if(!(!O||!I)){ne(!0);try{(await(await fetch("/api/radio/play",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,voiceChannelId:I,stationId:k,stationName:xe,placeName:Oe??(u==null?void 0:u.title)??"",country:Ue??(u==null?void 0:u.country)??""})})).json()).ok&&(N(Re=>{var We,Se;return{...Re,[O]:{stationId:k,stationName:xe,placeName:Oe??(u==null?void 0:u.title)??"",country:Ue??(u==null?void 0:u.country)??"",startedAt:new Date().toISOString(),channelName:((Se=(We=C.find(Le=>Le.id===O))==null?void 0:We.voiceChannels.find(Le=>Le.id===I))==null?void 0:Se.name)??""}}}),Ut())}catch(ee){console.error(ee)}ne(!1)}},[O,I,u,C]),fe=se.useCallback(async()=>{O&&(await fetch("/api/radio/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O})}),N(k=>{const xe={...k};return delete xe[O],xe}))},[O]),$t=se.useCallback(k=>{if(G(k),tt.current&&clearTimeout(tt.current),!k.trim()){q([]),Q(!1);return}tt.current=setTimeout(async()=>{try{const Oe=await(await fetch(`/api/radio/search?q=${encodeURIComponent(k)}`)).json();q(Oe),Q(!0)}catch{q([])}},350)},[]),_t=se.useCallback(k=>{var xe,Oe,Ue;if(Q(!1),G(""),q([]),k.type==="channel"){const ee=(xe=k.url.match(/\/listen\/[^/]+\/([^/]+)/))==null?void 0:xe[1];ee&&ht(ee,k.title,k.subtitle,"")}else if(k.type==="place"){const ee=(Oe=k.url.match(/\/visit\/[^/]+\/([^/]+)/))==null?void 0:Oe[1],we=a.find(Re=>Re.id===ee);we&&((Ue=Ke.current)==null||Ue.call(Ke,we))}},[a,ht]),Gt=se.useCallback(async(k,xe)=>{try{const Ue=await(await fetch("/api/radio/favorites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stationId:k,stationName:xe,placeName:(u==null?void 0:u.title)??"",country:(u==null?void 0:u.country)??"",placeId:(u==null?void 0:u.id)??""})})).json();Ue.favorites&&ie(Ue.favorites)}catch{}},[u]),yt=se.useCallback(k=>{be(k),O&&(je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{fetch("/api/radio/volume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,volume:k})}).catch(console.error)},100))},[O]),Ht=k=>J.some(xe=>xe.stationId===k),pt=O?T[O]:null,Ae=C.find(k=>k.id===O);return P.jsxs("div",{className:"radio-container","data-theme":r,children:[P.jsxs("header",{className:"radio-topbar",children:[P.jsxs("div",{className:"radio-topbar-left",children:[P.jsx("span",{className:"radio-topbar-logo",children:"🌍"}),P.jsx("span",{className:"radio-topbar-title",children:"World Radio"}),C.length>1&&P.jsx("select",{className:"radio-sel",value:O,onChange:k=>{U(k.target.value);const xe=C.find(Ue=>Ue.id===k.target.value),Oe=(xe==null?void 0:xe.voiceChannels.find(Ue=>Ue.members>0))??(xe==null?void 0:xe.voiceChannels[0]);j((Oe==null?void 0:Oe.id)??"")},children:C.map(k=>P.jsx("option",{value:k.id,children:k.name},k.id))}),P.jsxs("select",{className:"radio-sel",value:I,onChange:k=>j(k.target.value),children:[P.jsx("option",{value:"",children:"Voice Channel..."}),Ae==null?void 0:Ae.voiceChannels.map(k=>P.jsxs("option",{value:k.id,children:["🔊"," ",k.name,k.members>0?` (${k.members})`:""]},k.id))]})]}),pt&&P.jsxs("div",{className:"radio-topbar-np",children:[P.jsxs("div",{className:"radio-eq radio-eq-np",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),P.jsxs("div",{className:"radio-np-info",children:[P.jsx("span",{className:"radio-np-name",children:pt.stationName}),P.jsxs("span",{className:"radio-np-loc",children:[pt.placeName,pt.country?`, ${pt.country}`:""]})]})]}),P.jsxs("div",{className:"radio-topbar-right",children:[pt&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"radio-volume",children:[P.jsx("span",{className:"radio-volume-icon",children:de===0?"🔇":de<.4?"🔉":"🔊"}),P.jsx("input",{type:"range",className:"radio-volume-slider",min:0,max:1,step:.01,value:de,onChange:k=>yt(Number(k.target.value))}),P.jsxs("span",{className:"radio-volume-val",children:[Math.round(de*100),"%"]})]}),P.jsxs("div",{className:"radio-conn",onClick:()=>Ve(!0),title:"Verbindungsdetails",children:[P.jsx("span",{className:"radio-conn-dot"}),"Verbunden",(Te==null?void 0:Te.voicePing)!=null&&P.jsxs("span",{className:"radio-conn-ping",children:[Te.voicePing,"ms"]})]}),P.jsxs("button",{className:"radio-topbar-stop",onClick:fe,children:["⏹"," Stop"]})]}),P.jsx("div",{className:"radio-theme-inline",children:TAe.map(k=>P.jsx("div",{className:`radio-theme-dot ${r===k.id?"active":""}`,style:{background:k.color},title:k.label,onClick:()=>s(k.id)},k.id))})]})]}),P.jsxs("div",{className:"radio-globe-wrap",children:[P.jsx("div",{className:"radio-globe",ref:e}),P.jsxs("div",{className:"radio-search",children:[P.jsxs("div",{className:"radio-search-wrap",children:[P.jsx("span",{className:"radio-search-icon",children:"🔍"}),P.jsx("input",{className:"radio-search-input",type:"text",placeholder:"Sender oder Stadt suchen...",value:z,onChange:k=>$t(k.target.value),onFocus:()=>{H.length&&Q(!0)}}),z&&P.jsx("button",{className:"radio-search-clear",onClick:()=>{G(""),q([]),Q(!1)},children:"✕"})]}),V&&H.length>0&&P.jsx("div",{className:"radio-search-results",children:H.slice(0,12).map(k=>P.jsxs("button",{className:"radio-search-result",onClick:()=>_t(k),children:[P.jsx("span",{className:"radio-search-result-icon",children:k.type==="channel"?"📻":k.type==="place"?"📍":"🌍"}),P.jsxs("div",{className:"radio-search-result-text",children:[P.jsx("span",{className:"radio-search-result-title",children:k.title}),P.jsx("span",{className:"radio-search-result-sub",children:k.subtitle})]})]},k.id+k.url))})]}),!u&&!le&&P.jsxs("button",{className:"radio-fab",onClick:()=>{re(!0),h(null)},title:"Favoriten",children:["⭐",J.length>0&&P.jsx("span",{className:"radio-fab-badge",children:J.length})]}),le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("h3",{children:["⭐"," Favoriten"]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>re(!1),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:J.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Noch keine Favoriten"}):J.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.stationId?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.stationName}),P.jsxs("span",{className:"radio-station-loc",children:[k.placeName,", ",k.country]})]}),P.jsxs("div",{className:"radio-station-btns",children:[P.jsx("button",{className:"radio-btn-play",onClick:()=>ht(k.stationId,k.stationName,k.placeName,k.country),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:"radio-btn-fav active",onClick:()=>Gt(k.stationId,k.stationName),children:"★"})]})]},k.stationId))})]}),u&&!le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("div",{children:[P.jsx("h3",{children:u.title}),P.jsx("span",{className:"radio-panel-sub",children:u.country})]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>h(null),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:x?P.jsxs("div",{className:"radio-panel-loading",children:[P.jsx("div",{className:"radio-spinner"}),"Sender werden geladen..."]}):m.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Keine Sender gefunden"}):m.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.id?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.title}),(pt==null?void 0:pt.stationId)===k.id&&P.jsxs("span",{className:"radio-station-live",children:[P.jsxs("span",{className:"radio-eq",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),"Live"]})]}),P.jsxs("div",{className:"radio-station-btns",children:[(pt==null?void 0:pt.stationId)===k.id?P.jsx("button",{className:"radio-btn-stop",onClick:fe,children:"⏹"}):P.jsx("button",{className:"radio-btn-play",onClick:()=>ht(k.id,k.title),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:`radio-btn-fav ${Ht(k.id)?"active":""}`,onClick:()=>Gt(k.id,k.title),children:Ht(k.id)?"★":"☆"})]})]},k.id))})]}),P.jsxs("div",{className:"radio-counter",children:["📻"," ",a.length.toLocaleString("de-DE")," Sender weltweit"]}),P.jsx("a",{className:"radio-attribution",href:"https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/",target:"_blank",rel:"noreferrer",children:"Imagery © NASA Blue Marble"})]}),Me&&(()=>{const k=Te!=null&&Te.connectedSince?Math.floor((Date.now()-new Date(Te.connectedSince).getTime())/1e3):0,xe=Math.floor(k/3600),Oe=Math.floor(k%3600/60),Ue=k%60,ee=xe>0?`${xe}h ${String(Oe).padStart(2,"0")}m ${String(Ue).padStart(2,"0")}s`:Oe>0?`${Oe}m ${String(Ue).padStart(2,"0")}s`:`${Ue}s`,we=Re=>Re==null?"var(--text-faint)":Re<80?"var(--success)":Re<150?"#f0a830":"#e04040";return P.jsx("div",{className:"radio-modal-overlay",onClick:()=>Ve(!1),children:P.jsxs("div",{className:"radio-modal",onClick:Re=>Re.stopPropagation(),children:[P.jsxs("div",{className:"radio-modal-header",children:[P.jsx("span",{children:"📡"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"radio-modal-close",onClick:()=>Ve(!1),children:"✕"})]}),P.jsxs("div",{className:"radio-modal-body",children:[P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Voice Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:we((Te==null?void 0:Te.voicePing)??null)}}),(Te==null?void 0:Te.voicePing)!=null?`${Te.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Gateway Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:we((Te==null?void 0:Te.gatewayPing)??null)}}),Te&&Te.gatewayPing>=0?`${Te.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Status"}),P.jsx("span",{className:"radio-modal-value",style:{color:(Te==null?void 0:Te.status)==="ready"?"var(--success)":"#f0a830"},children:(Te==null?void 0:Te.status)==="ready"?"Verbunden":(Te==null?void 0:Te.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Kanal"}),P.jsx("span",{className:"radio-modal-value",children:(Te==null?void 0:Te.channelName)||"---"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Verbunden seit"}),P.jsx("span",{className:"radio-modal-value",children:ee||"---"})]})]})]})})})()]})}function EAe(i,e,t=365){const n=new Date(Date.now()+t*24*60*60*1e3).toUTCString();document.cookie=`${encodeURIComponent(i)}=${encodeURIComponent(e)}; expires=${n}; path=/; SameSite=Lax`}function CAe(i){const e=`${encodeURIComponent(i)}=`,t=document.cookie.split(";");for(const n of t){const r=n.trim();if(r.startsWith(e))return decodeURIComponent(r.slice(e.length))}return null}const ca="/api/soundboard";async function NAe(i,e,t,n){const r=new URL(`${ca}/sounds`,window.location.origin);i&&r.searchParams.set("q",i),e!==void 0&&r.searchParams.set("folder",e),r.searchParams.set("fuzzy","0");const s=await fetch(r.toString());if(!s.ok)throw new Error("Fehler beim Laden der Sounds");return s.json()}async function RAe(){const i=await fetch(`${ca}/analytics`);if(!i.ok)throw new Error("Fehler beim Laden der Analytics");return i.json()}async function DAe(){const i=await fetch(`${ca}/categories`,{credentials:"include"});if(!i.ok)throw new Error("Fehler beim Laden der Kategorien");return i.json()}async function PAe(){const i=await fetch(`${ca}/channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channels");return i.json()}async function LAe(){const i=await fetch(`${ca}/selected-channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channel-Auswahl");const e=await i.json();return(e==null?void 0:e.selected)||{}}async function UAe(i,e){if(!(await fetch(`${ca}/selected-channel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Channel-Auswahl setzen fehlgeschlagen")}async function BAe(i,e,t,n,r){const s=await fetch(`${ca}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({soundName:i,guildId:e,channelId:t,volume:n,relativePath:r})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error((a==null?void 0:a.error)||"Play fehlgeschlagen")}}async function OAe(i,e,t,n,r){const s=await fetch(`${ca}/play-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,guildId:e,channelId:t,volume:n,filename:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error((a==null?void 0:a.error)||"Play-URL fehlgeschlagen");return a}async function IAe(i,e){const t=await fetch(`${ca}/download-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,filename:e})}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error((n==null?void 0:n.error)||"Download fehlgeschlagen");return n}async function FAe(i,e){if(!(await fetch(`${ca}/party/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Partymode Start fehlgeschlagen")}async function kAe(i){if(!(await fetch(`${ca}/party/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i})})).ok)throw new Error("Partymode Stop fehlgeschlagen")}async function g7(i,e){const t=await fetch(`${ca}/volume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,volume:e})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error((n==null?void 0:n.error)||"Volume aendern fehlgeschlagen")}}async function zAe(i){const e=new URL(`${ca}/volume`,window.location.origin);e.searchParams.set("guildId",i);const t=await fetch(e.toString());if(!t.ok)throw new Error("Fehler beim Laden der Lautstaerke");const n=await t.json();return typeof(n==null?void 0:n.volume)=="number"?n.volume:1}async function GAe(i){if(!(await fetch(`${ca}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}function qAe(i,e,t){return new Promise((n,r)=>{const s=new FormData;s.append("files",i),e&&s.append("customName",e);const a=new XMLHttpRequest;a.open("POST",`${ca}/upload`),a.upload.onprogress=l=>{l.lengthComputable&&t(Math.round(l.loaded/l.total*100))},a.onload=()=>{var l,u;if(a.status===200)try{const h=JSON.parse(a.responseText);n(((u=(l=h.files)==null?void 0:l[0])==null?void 0:u.name)??i.name)}catch{n(i.name)}else try{r(new Error(JSON.parse(a.responseText).error))}catch{r(new Error(`HTTP ${a.status}`))}},a.onerror=()=>r(new Error("Netzwerkfehler")),a.send(s)})}const VAe=[{id:"default",color:"#5865f2",label:"Discord"},{id:"purple",color:"#9b59b6",label:"Midnight"},{id:"forest",color:"#2ecc71",label:"Forest"},{id:"sunset",color:"#e67e22",label:"Sunset"},{id:"ocean",color:"#3498db",label:"Ocean"}],v7=["#3b82f6","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#06b6d4","#ef4444","#a855f7","#84cc16","#d946ef","#0ea5e9","#f43f5e","#10b981"];function jAe({data:i,isAdmin:e}){var qe,qt,Qt;const[t,n]=se.useState([]),[r,s]=se.useState(0),[a,l]=se.useState([]),[u,h]=se.useState([]),[m,v]=se.useState({totalSounds:0,totalPlays:0,mostPlayed:[]}),[x,S]=se.useState("all"),[T,N]=se.useState(""),[C,E]=se.useState(""),[O,U]=se.useState(""),[I,j]=se.useState(!1),[z,G]=se.useState(null),[H,q]=se.useState([]),[V,Q]=se.useState(""),J=se.useRef(""),[ie,le]=se.useState(!1),[re,Z]=se.useState(1),[ne,de]=se.useState(""),[be,Te]=se.useState({}),[ae,Me]=se.useState(()=>localStorage.getItem("jb-theme")||"default"),[Ve,Ce]=se.useState(()=>parseInt(localStorage.getItem("jb-card-size")||"110")),[Fe,tt]=se.useState(!1),[je,Rt]=se.useState([]),Et=se.useRef(!1),Ft=se.useRef(void 0),Ut=e??!1,[Ke,ht]=se.useState(!1),[fe,$t]=se.useState([]),[_t,Gt]=se.useState(!1),yt=se.useRef(0);se.useRef(void 0);const[Ht,pt]=se.useState([]),[Ae,k]=se.useState(0),[xe,Oe]=se.useState(""),[Ue,ee]=se.useState("naming"),[we,Re]=se.useState(0),[We,Se]=se.useState(null),[Le,ct]=se.useState(!1),[Dt,It]=se.useState(null),[lt,jt]=se.useState(""),[Jt,In]=se.useState(null),[me,Bt]=se.useState(0);se.useEffect(()=>{Et.current=Fe},[Fe]),se.useEffect(()=>{J.current=V},[V]),se.useEffect(()=>{const he=sn=>{var Tn;Array.from(((Tn=sn.dataTransfer)==null?void 0:Tn.items)??[]).some(Rn=>Rn.kind==="file")&&(yt.current++,ht(!0))},X=()=>{yt.current=Math.max(0,yt.current-1),yt.current===0&&ht(!1)},et=sn=>sn.preventDefault(),en=sn=>{var Rn;sn.preventDefault(),yt.current=0,ht(!1);const Tn=Array.from(((Rn=sn.dataTransfer)==null?void 0:Rn.files)??[]).filter(xi=>/\.(mp3|wav)$/i.test(xi.name));Tn.length&&xt(Tn)};return window.addEventListener("dragenter",he),window.addEventListener("dragleave",X),window.addEventListener("dragover",et),window.addEventListener("drop",en),()=>{window.removeEventListener("dragenter",he),window.removeEventListener("dragleave",X),window.removeEventListener("dragover",et),window.removeEventListener("drop",en)}},[Ut]);const ot=se.useCallback((he,X="info")=>{It({msg:he,type:X}),setTimeout(()=>It(null),3e3)},[]);se.useCallback(he=>he.relativePath??he.fileName,[]);const Tt=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","music.youtube.com","instagram.com","www.instagram.com"],Wt=se.useCallback(he=>{const X=he.trim();return!X||/^https?:\/\//i.test(X)?X:"https://"+X},[]),Yt=se.useCallback(he=>{try{const X=new URL(Wt(he)),et=X.hostname.toLowerCase();return!!(X.pathname.toLowerCase().endsWith(".mp3")||Tt.some(en=>et===en||et.endsWith("."+en)))}catch{return!1}},[Wt]),pn=se.useCallback(he=>{try{const X=new URL(Wt(he)),et=X.hostname.toLowerCase();return et.includes("youtube")||et==="youtu.be"?"youtube":et.includes("instagram")?"instagram":X.pathname.toLowerCase().endsWith(".mp3")?"mp3":null}catch{return null}},[Wt]),$e=V?V.split(":")[0]:"",St=V?V.split(":")[1]:"",Kt=se.useMemo(()=>H.find(he=>`${he.guildId}:${he.channelId}`===V),[H,V]);se.useEffect(()=>{const he=()=>{const et=new Date,en=String(et.getHours()).padStart(2,"0"),sn=String(et.getMinutes()).padStart(2,"0"),Tn=String(et.getSeconds()).padStart(2,"0");jt(`${en}:${sn}:${Tn}`)};he();const X=setInterval(he,1e3);return()=>clearInterval(X)},[]),se.useEffect(()=>{(async()=>{try{const[he,X]=await Promise.all([PAe(),LAe()]);if(q(he),he.length){const et=he[0].guildId,en=X[et],sn=en&&he.find(Tn=>Tn.guildId===et&&Tn.channelId===en);Q(sn?`${et}:${en}`:`${he[0].guildId}:${he[0].channelId}`)}}catch(he){ot((he==null?void 0:he.message)||"Channel-Fehler","error")}try{const he=await DAe();h(he.categories||[])}catch{}})()},[]),se.useEffect(()=>{localStorage.setItem("jb-theme",ae)},[ae]);const wn=se.useRef(null);se.useEffect(()=>{const he=wn.current;if(!he)return;he.style.setProperty("--card-size",Ve+"px");const X=Ve/110;he.style.setProperty("--card-emoji",Math.round(28*X)+"px"),he.style.setProperty("--card-font",Math.max(9,Math.round(11*X))+"px"),localStorage.setItem("jb-card-size",String(Ve))},[Ve]),se.useEffect(()=>{var he,X,et,en,sn,Tn,Rn,xi;if(i){if(i.soundboard){const K=i.soundboard;Array.isArray(K.party)&&Rt(K.party);try{const hn=K.selected||{},Zt=(he=J.current)==null?void 0:he.split(":")[0];Zt&&hn[Zt]&&Q(`${Zt}:${hn[Zt]}`)}catch{}try{const hn=K.volumes||{},Zt=(X=J.current)==null?void 0:X.split(":")[0];Zt&&typeof hn[Zt]=="number"&&Z(hn[Zt])}catch{}try{const hn=K.nowplaying||{},Zt=(et=J.current)==null?void 0:et.split(":")[0];Zt&&typeof hn[Zt]=="string"&&de(hn[Zt])}catch{}try{const hn=K.voicestats||{},Zt=(en=J.current)==null?void 0:en.split(":")[0];Zt&&hn[Zt]&&Se(hn[Zt])}catch{}}if(i.type==="soundboard_party")Rt(K=>{const hn=new Set(K);return i.active?hn.add(i.guildId):hn.delete(i.guildId),Array.from(hn)});else if(i.type==="soundboard_channel"){const K=(sn=J.current)==null?void 0:sn.split(":")[0];i.guildId===K&&Q(`${i.guildId}:${i.channelId}`)}else if(i.type==="soundboard_volume"){const K=(Tn=J.current)==null?void 0:Tn.split(":")[0];i.guildId===K&&typeof i.volume=="number"&&Z(i.volume)}else if(i.type==="soundboard_nowplaying"){const K=(Rn=J.current)==null?void 0:Rn.split(":")[0];i.guildId===K&&de(i.name||"")}else if(i.type==="soundboard_voicestats"){const K=(xi=J.current)==null?void 0:xi.split(":")[0];i.guildId===K&&Se({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})}}},[i]),se.useEffect(()=>{tt($e?je.includes($e):!1)},[V,je,$e]),se.useEffect(()=>{(async()=>{try{let he="__all__";x==="recent"?he="__recent__":T&&(he=T);const X=await NAe(C,he,void 0,!1);n(X.items),s(X.total),l(X.folders)}catch(he){ot((he==null?void 0:he.message)||"Sounds-Fehler","error")}})()},[x,T,C,me,ot]),se.useEffect(()=>{qn()},[me]),se.useEffect(()=>{const he=CAe("favs");if(he)try{Te(JSON.parse(he))}catch{}},[]),se.useEffect(()=>{try{EAe("favs",JSON.stringify(be))}catch{}},[be]),se.useEffect(()=>{V&&(async()=>{try{const he=await zAe($e);Z(he)}catch{}})()},[V]),se.useEffect(()=>{const he=()=>{le(!1),In(null)};return document.addEventListener("click",he),()=>document.removeEventListener("click",he)},[]);async function qn(){try{const he=await RAe();v(he)}catch{}}async function Je(he){if(!V)return ot("Bitte einen Voice-Channel auswaehlen","error");try{await BAe(he.name,$e,St,re,he.relativePath),de(he.name),qn()}catch(X){ot((X==null?void 0:X.message)||"Play fehlgeschlagen","error")}}function dt(){var en;const he=Wt(O);if(!he)return ot("Bitte einen Link eingeben","error");if(!Yt(he))return ot("Nur YouTube, Instagram oder direkte MP3-Links","error");const X=pn(he);let et="";if(X==="mp3")try{et=((en=new URL(he).pathname.split("/").pop())==null?void 0:en.replace(/\.mp3$/i,""))??""}catch{}G({url:he,type:X,filename:et,phase:"input"})}async function Vt(){if(z){G(he=>he?{...he,phase:"downloading"}:null);try{let he;const X=z.filename.trim()||void 0;V&&$e&&St?he=(await OAe(z.url,$e,St,re,X)).saved:he=(await IAe(z.url,X)).saved,G(et=>et?{...et,phase:"done",savedName:he}:null),U(""),Bt(et=>et+1),qn(),setTimeout(()=>G(null),2500)}catch(he){G(X=>X?{...X,phase:"error",error:(he==null?void 0:he.message)||"Fehler"}:null)}}}async function xt(he){if(!Ut){ot("Admin-Login erforderlich zum Hochladen","error");return}if(he.length===0)return;pt(he),k(0);const X=he[0].name.replace(/\.(mp3|wav)$/i,"");Oe(X),ee("naming"),Re(0)}async function A(){if(Ht.length===0)return;const he=Ht[Ae],X=xe.trim()||he.name.replace(/\.(mp3|wav)$/i,"");ee("uploading"),Re(0);try{await qAe(he,X,et=>Re(et)),ee("done"),setTimeout(()=>{const et=Ae+1;if(eten+1),qn(),ot(`${Ht.length} Sound${Ht.length>1?"s":""} hochgeladen`,"info")},800)}catch(et){ot((et==null?void 0:et.message)||"Upload fehlgeschlagen","error"),pt([])}}function te(){const he=Ae+1;if(he0&&(Bt(X=>X+1),qn())}async function Vn(){if(V){de("");try{await fetch(`${ca}/stop?guildId=${encodeURIComponent($e)}`,{method:"POST"})}catch{}}}async function Wn(){if(!lr.length||!V)return;const he=lr[Math.floor(Math.random()*lr.length)];Je(he)}async function $n(){if(Fe){await Vn();try{await kAe($e)}catch{}}else{if(!V)return ot("Bitte einen Channel auswaehlen","error");try{await FAe($e,St)}catch{}}}async function dn(he){const X=`${he.guildId}:${he.channelId}`;Q(X),le(!1);try{await UAe(he.guildId,he.channelId)}catch{}}function Fn(he){Te(X=>({...X,[he]:!X[he]}))}const lr=se.useMemo(()=>x==="favorites"?t.filter(he=>be[he.relativePath??he.fileName]):t,[t,x,be]),an=se.useMemo(()=>Object.values(be).filter(Boolean).length,[be]),mn=se.useMemo(()=>a.filter(he=>!["__all__","__recent__","__top3__"].includes(he.key)),[a]),Er=se.useMemo(()=>{const he={};return mn.forEach((X,et)=>{he[X.key]=v7[et%v7.length]}),he},[mn]),Wi=se.useMemo(()=>{const he=new Set,X=new Set;return lr.forEach((et,en)=>{const sn=et.name.charAt(0).toUpperCase();he.has(sn)||(he.add(sn),X.add(en))}),X},[lr]),No=se.useMemo(()=>{const he={};return H.forEach(X=>{he[X.guildName]||(he[X.guildName]=[]),he[X.guildName].push(X)}),he},[H]),ce=m.mostPlayed.slice(0,10),Ge=m.totalSounds||r,rt=lt.slice(0,5),it=lt.slice(5);return P.jsxs("div",{className:"sb-app","data-theme":ae,ref:wn,children:[Fe&&P.jsx("div",{className:"party-overlay active"}),P.jsxs("header",{className:"topbar",children:[P.jsxs("div",{className:"topbar-left",children:[P.jsx("div",{className:"sb-app-logo",children:P.jsx("span",{className:"material-icons",style:{fontSize:16,color:"white"},children:"music_note"})}),P.jsx("span",{className:"sb-app-title",children:"Soundboard"}),P.jsxs("div",{className:"channel-dropdown",onClick:he=>he.stopPropagation(),children:[P.jsxs("button",{className:`channel-btn ${ie?"open":""}`,onClick:()=>le(!ie),children:[P.jsx("span",{className:"material-icons cb-icon",children:"headset"}),V&&P.jsx("span",{className:"channel-status"}),P.jsx("span",{className:"channel-label",children:Kt?`${Kt.channelName}${Kt.members?` (${Kt.members})`:""}`:"Channel..."}),P.jsx("span",{className:"material-icons chevron",children:"expand_more"})]}),ie&&P.jsxs("div",{className:"channel-menu visible",children:[Object.entries(No).map(([he,X])=>P.jsxs(FF.Fragment,{children:[P.jsx("div",{className:"channel-menu-header",children:he}),X.map(et=>P.jsxs("div",{className:`channel-option ${`${et.guildId}:${et.channelId}`===V?"active":""}`,onClick:()=>dn(et),children:[P.jsx("span",{className:"material-icons co-icon",children:"volume_up"}),et.channelName,et.members?` (${et.members})`:""]},`${et.guildId}:${et.channelId}`))]},he)),H.length===0&&P.jsx("div",{className:"channel-option",style:{color:"var(--text-faint)",cursor:"default"},children:"Keine Channels verfuegbar"})]})]})]}),P.jsx("div",{className:"clock-wrap",children:P.jsxs("div",{className:"clock",children:[rt,P.jsx("span",{className:"clock-seconds",children:it})]})}),P.jsxs("div",{className:"topbar-right",children:[ne&&P.jsxs("div",{className:"now-playing",children:[P.jsxs("div",{className:"np-waves active",children:[P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"})]}),P.jsx("span",{className:"np-label",children:"Last Played:"})," ",P.jsx("span",{className:"np-name",children:ne})]}),V&&P.jsxs("div",{className:"connection",onClick:()=>ct(!0),style:{cursor:"pointer"},title:"Verbindungsdetails",children:[P.jsx("span",{className:"conn-dot"}),"Verbunden",(We==null?void 0:We.voicePing)!=null&&P.jsxs("span",{className:"conn-ping",children:[We.voicePing,"ms"]})]})]})]}),P.jsxs("div",{className:"toolbar",children:[P.jsxs("div",{className:"cat-tabs",children:[P.jsxs("button",{className:`cat-tab ${x==="all"?"active":""}`,onClick:()=>{S("all"),N("")},children:["Alle",P.jsx("span",{className:"tab-count",children:r})]}),P.jsx("button",{className:`cat-tab ${x==="recent"?"active":""}`,onClick:()=>{S("recent"),N("")},children:"Neu hinzugefuegt"}),P.jsxs("button",{className:`cat-tab ${x==="favorites"?"active":""}`,onClick:()=>{S("favorites"),N("")},children:["Favoriten",an>0&&P.jsx("span",{className:"tab-count",children:an})]})]}),P.jsxs("div",{className:"search-wrap",children:[P.jsx("span",{className:"material-icons search-icon",children:"search"}),P.jsx("input",{className:"search-input",type:"text",placeholder:"Suchen...",value:C,onChange:he=>E(he.target.value)}),C&&P.jsx("button",{className:"search-clear",onClick:()=>E(""),children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsxs("div",{className:"url-import-wrap",children:[P.jsx("span",{className:"material-icons url-import-icon",children:pn(O)==="youtube"?"smart_display":pn(O)==="instagram"?"photo_camera":"link"}),P.jsx("input",{className:"url-import-input",type:"text",placeholder:"YouTube / Instagram / MP3-Link...",value:O,onChange:he=>U(he.target.value),onKeyDown:he=>{he.key==="Enter"&&dt()}}),O&&P.jsx("span",{className:`url-import-tag ${Yt(O)?"valid":"invalid"}`,children:pn(O)==="youtube"?"YT":pn(O)==="instagram"?"IG":pn(O)==="mp3"?"MP3":"?"}),P.jsx("button",{className:"url-import-btn",onClick:()=>{dt()},disabled:I||!!O&&!Yt(O),title:"Sound herunterladen",children:I?"Laedt...":"Download"})]}),P.jsx("div",{className:"toolbar-spacer"}),P.jsxs("div",{className:"volume-control",children:[P.jsx("span",{className:"material-icons vol-icon",onClick:()=>{const he=re>0?0:.5;Z(he),$e&&g7($e,he).catch(()=>{})},children:re===0?"volume_off":re<.5?"volume_down":"volume_up"}),P.jsx("input",{type:"range",className:"vol-slider",min:0,max:1,step:.01,value:re,onChange:he=>{const X=parseFloat(he.target.value);Z(X),$e&&(Ft.current&&clearTimeout(Ft.current),Ft.current=setTimeout(()=>{g7($e,X).catch(()=>{})},120))},style:{"--vol":`${Math.round(re*100)}%`}}),P.jsxs("span",{className:"vol-pct",children:[Math.round(re*100),"%"]})]}),P.jsxs("button",{className:"tb-btn random",onClick:Wn,title:"Zufaelliger Sound",children:[P.jsx("span",{className:"material-icons tb-icon",children:"shuffle"}),"Random"]}),P.jsxs("button",{className:`tb-btn party ${Fe?"active":""}`,onClick:$n,title:"Party Mode",children:[P.jsx("span",{className:"material-icons tb-icon",children:Fe?"celebration":"auto_awesome"}),Fe?"Party!":"Party"]}),P.jsxs("button",{className:"tb-btn stop",onClick:Vn,title:"Alle stoppen",children:[P.jsx("span",{className:"material-icons tb-icon",children:"stop"}),"Stop"]}),P.jsxs("div",{className:"size-control",title:"Button-Groesse",children:[P.jsx("span",{className:"material-icons sc-icon",children:"grid_view"}),P.jsx("input",{type:"range",className:"size-slider",min:80,max:160,value:Ve,onChange:he=>Ce(parseInt(he.target.value))})]}),P.jsx("div",{className:"theme-selector",children:VAe.map(he=>P.jsx("div",{className:`theme-dot ${ae===he.id?"active":""}`,style:{background:he.color},title:he.label,onClick:()=>Me(he.id)},he.id))})]}),P.jsxs("div",{className:"analytics-strip",children:[P.jsxs("div",{className:"analytics-card",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"library_music"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Sounds gesamt"}),P.jsx("strong",{className:"analytics-value",children:Ge})]})]}),P.jsxs("div",{className:"analytics-card analytics-wide",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"leaderboard"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Most Played"}),P.jsx("div",{className:"analytics-top-list",children:ce.length===0?P.jsx("span",{className:"analytics-muted",children:"Noch keine Plays"}):ce.map((he,X)=>P.jsxs("span",{className:"analytics-chip",children:[X+1,". ",he.name," (",he.count,")"]},he.relativePath))})]})]})]}),x==="all"&&mn.length>0&&P.jsx("div",{className:"category-strip",children:mn.map(he=>{const X=Er[he.key]||"#888",et=T===he.key;return P.jsxs("button",{className:`cat-chip ${et?"active":""}`,onClick:()=>N(et?"":he.key),style:et?{borderColor:X,color:X}:void 0,children:[P.jsx("span",{className:"cat-dot",style:{background:X}}),he.name.replace(/\s*\(\d+\)\s*$/,""),P.jsx("span",{className:"cat-count",children:he.count})]},he.key)})}),P.jsx("main",{className:"main",children:lr.length===0?P.jsxs("div",{className:"empty-state visible",children:[P.jsx("div",{className:"empty-emoji",children:x==="favorites"?"⭐":"🔇"}),P.jsx("div",{className:"empty-title",children:x==="favorites"?"Noch keine Favoriten":C?`Kein Sound fuer "${C}" gefunden`:"Keine Sounds vorhanden"}),P.jsx("div",{className:"empty-desc",children:x==="favorites"?"Klick den Stern auf einem Sound!":"Hier gibt's noch nichts zu hoeren."})]}):P.jsx("div",{className:"sound-grid",children:lr.map((he,X)=>{var hn;const et=he.relativePath??he.fileName,en=!!be[et],sn=ne===he.name,Tn=he.isRecent||((hn=he.badges)==null?void 0:hn.includes("new")),Rn=he.name.charAt(0).toUpperCase(),xi=Wi.has(X),K=he.folder&&Er[he.folder]||"var(--accent)";return P.jsxs("div",{className:`sound-card ${sn?"playing":""} ${xi?"has-initial":""}`,style:{animationDelay:`${Math.min(X*20,400)}ms`},onClick:Zt=>{const gr=Zt.currentTarget,ui=gr.getBoundingClientRect(),vr=document.createElement("div");vr.className="ripple";const Ps=Math.max(ui.width,ui.height);vr.style.width=vr.style.height=Ps+"px",vr.style.left=Zt.clientX-ui.left-Ps/2+"px",vr.style.top=Zt.clientY-ui.top-Ps/2+"px",gr.appendChild(vr),setTimeout(()=>vr.remove(),500),Je(he)},onContextMenu:Zt=>{Zt.preventDefault(),Zt.stopPropagation(),In({x:Math.min(Zt.clientX,window.innerWidth-170),y:Math.min(Zt.clientY,window.innerHeight-140),sound:he})},title:`${he.name}${he.folder?` (${he.folder})`:""}`,children:[Tn&&P.jsx("span",{className:"new-badge",children:"NEU"}),P.jsx("span",{className:`fav-star ${en?"active":""}`,onClick:Zt=>{Zt.stopPropagation(),Fn(et)},children:P.jsx("span",{className:"material-icons fav-icon",children:en?"star":"star_border"})}),xi&&P.jsx("span",{className:"sound-emoji",style:{color:K},children:Rn}),P.jsx("span",{className:"sound-name",children:he.name}),he.folder&&P.jsx("span",{className:"sound-duration",children:he.folder}),P.jsxs("div",{className:"playing-indicator",children:[P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"})]})]},et)})})}),Jt&&P.jsxs("div",{className:"ctx-menu visible",style:{left:Jt.x,top:Jt.y},onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"ctx-item",onClick:()=>{Je(Jt.sound),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"play_arrow"}),"Abspielen"]}),P.jsxs("div",{className:"ctx-item",onClick:()=>{Fn(Jt.sound.relativePath??Jt.sound.fileName),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:be[Jt.sound.relativePath??Jt.sound.fileName]?"star":"star_border"}),"Favorit"]}),Ut&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"ctx-sep"}),P.jsxs("div",{className:"ctx-item danger",onClick:async()=>{const he=Jt.sound.relativePath??Jt.sound.fileName;if(!window.confirm(`Sound "${Jt.sound.name}" loeschen?`)){In(null);return}try{await GAe([he]),ot("Sound geloescht"),Bt(X=>X+1)}catch(X){ot((X==null?void 0:X.message)||"Loeschen fehlgeschlagen","error")}In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"delete"}),"Loeschen"]})]})]}),Le&&(()=>{const he=We!=null&&We.connectedSince?Math.floor((Date.now()-new Date(We.connectedSince).getTime())/1e3):0,X=Math.floor(he/3600),et=Math.floor(he%3600/60),en=he%60,sn=X>0?`${X}h ${String(et).padStart(2,"0")}m ${String(en).padStart(2,"0")}s`:et>0?`${et}m ${String(en).padStart(2,"0")}s`:`${en}s`,Tn=Rn=>Rn==null?"var(--muted)":Rn<80?"var(--green)":Rn<150?"#f0a830":"#e04040";return P.jsx("div",{className:"conn-modal-overlay",onClick:()=>ct(!1),children:P.jsxs("div",{className:"conn-modal",onClick:Rn=>Rn.stopPropagation(),children:[P.jsxs("div",{className:"conn-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20,color:"var(--green)"},children:"cell_tower"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"conn-modal-close",onClick:()=>ct(!1),children:P.jsx("span",{className:"material-icons",children:"close"})})]}),P.jsxs("div",{className:"conn-modal-body",children:[P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Voice Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((We==null?void 0:We.voicePing)??null)}}),(We==null?void 0:We.voicePing)!=null?`${We.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Gateway Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((We==null?void 0:We.gatewayPing)??null)}}),We&&We.gatewayPing>=0?`${We.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Status"}),P.jsx("span",{className:"conn-stat-value",style:{color:(We==null?void 0:We.status)==="ready"?"var(--green)":"#f0a830"},children:(We==null?void 0:We.status)==="ready"?"Verbunden":(We==null?void 0:We.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Kanal"}),P.jsx("span",{className:"conn-stat-value",children:(We==null?void 0:We.channelName)||"---"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Verbunden seit"}),P.jsx("span",{className:"conn-stat-value",children:sn||"---"})]})]})]})})})(),Dt&&P.jsxs("div",{className:`toast ${Dt.type}`,children:[P.jsx("span",{className:"material-icons toast-icon",children:Dt.type==="error"?"error_outline":"check_circle"}),Dt.msg]}),Ke&&P.jsx("div",{className:"drop-overlay",children:P.jsxs("div",{className:"drop-zone",children:[P.jsx("span",{className:"material-icons drop-icon",children:"cloud_upload"}),P.jsx("div",{className:"drop-title",children:"MP3 & WAV hier ablegen"}),P.jsx("div",{className:"drop-sub",children:"Mehrere Dateien gleichzeitig moeglich"})]})}),_t&&fe.length>0&&P.jsxs("div",{className:"upload-queue",children:[P.jsxs("div",{className:"uq-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),P.jsx("span",{children:fe.every(he=>he.status==="done"||he.status==="error")?`${fe.filter(he=>he.status==="done").length} von ${fe.length} hochgeladen`:`Lade hoch… (${fe.filter(he=>he.status==="done").length}/${fe.length})`}),P.jsx("button",{className:"uq-close",onClick:()=>{Gt(!1),$t([])},children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsx("div",{className:"uq-list",children:fe.map(he=>P.jsxs("div",{className:`uq-item uq-${he.status}`,children:[P.jsx("span",{className:"material-icons uq-file-icon",children:"audio_file"}),P.jsxs("div",{className:"uq-info",children:[P.jsx("div",{className:"uq-name",title:he.savedName??he.file.name,children:he.savedName??he.file.name}),P.jsxs("div",{className:"uq-size",children:[(he.file.size/1024).toFixed(0)," KB"]})]}),(he.status==="waiting"||he.status==="uploading")&&P.jsx("div",{className:"uq-progress-wrap",children:P.jsx("div",{className:"uq-progress-bar",style:{width:`${he.progress}%`}})}),P.jsx("span",{className:`material-icons uq-status-icon uq-status-${he.status}`,children:he.status==="done"?"check_circle":he.status==="error"?"error":he.status==="uploading"?"sync":"schedule"}),he.status==="error"&&P.jsx("div",{className:"uq-error",children:he.error})]},he.id))})]}),Ht.length>0&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>Ue==="naming"&&te(),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:"upload_file"}),P.jsxs("span",{children:[Ue==="naming"?"Sound benennen":Ue==="uploading"?"Wird hochgeladen...":"Gespeichert!",Ht.length>1&&` (${Ae+1}/${Ht.length})`]}),Ue==="naming"&&P.jsx("button",{className:"dl-modal-close",onClick:te,children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:"dl-modal-tag mp3",children:"Datei"}),P.jsx("span",{className:"dl-modal-url-text",title:(qe=Ht[Ae])==null?void 0:qe.name,children:(qt=Ht[Ae])==null?void 0:qt.name}),P.jsxs("span",{style:{marginLeft:"auto",opacity:.5,fontSize:12},children:[((((Qt=Ht[Ae])==null?void 0:Qt.size)??0)/1024).toFixed(0)," KB"]})]}),Ue==="naming"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:"Dateiname eingeben...",value:xe,onChange:he=>Oe(he.target.value),onKeyDown:he=>{he.key==="Enter"&&A()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]})]}),Ue==="uploading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsxs("span",{children:["Upload: ",we,"%"]})]}),Ue==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsx("span",{children:"Erfolgreich hochgeladen!"})]})]}),Ue==="naming"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:te,children:Ht.length>1?"Überspringen":"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void A(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),"Hochladen"]})]})]})}),z&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>z.phase!=="downloading"&&G(null),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:z.type==="youtube"?"smart_display":z.type==="instagram"?"photo_camera":"audio_file"}),P.jsx("span",{children:z.phase==="input"?"Sound herunterladen":z.phase==="downloading"?"Wird heruntergeladen...":z.phase==="done"?"Fertig!":"Fehler"}),z.phase!=="downloading"&&P.jsx("button",{className:"dl-modal-close",onClick:()=>G(null),children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:`dl-modal-tag ${z.type??""}`,children:z.type==="youtube"?"YouTube":z.type==="instagram"?"Instagram":"MP3"}),P.jsx("span",{className:"dl-modal-url-text",title:z.url,children:z.url.length>60?z.url.slice(0,57)+"...":z.url})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:z.type==="mp3"?"Dateiname...":"Wird automatisch erkannt...",value:z.filename,onChange:he=>G(X=>X?{...X,filename:he.target.value}:null),onKeyDown:he=>{he.key==="Enter"&&Vt()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]}),P.jsx("span",{className:"dl-modal-hint",children:"Leer lassen = automatischer Name"})]}),z.phase==="downloading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsx("span",{children:z.type==="youtube"||z.type==="instagram"?"Audio wird extrahiert...":"MP3 wird heruntergeladen..."})]}),z.phase==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsxs("span",{children:["Gespeichert als ",P.jsx("b",{children:z.savedName})]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-error",children:[P.jsx("span",{className:"material-icons",style:{color:"#e74c3c"},children:"error"}),P.jsx("span",{children:z.error})]})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void Vt(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"download"}),"Herunterladen"]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Schliessen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>G(he=>he?{...he,phase:"input",error:void 0}:null),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"refresh"}),"Nochmal"]})]})]})})]})}const _7={IRON:"#6b6b6b",BRONZE:"#8c6239",SILVER:"#8c8c8c",GOLD:"#d4a017",PLATINUM:"#28b29e",EMERALD:"#1e9e5e",DIAMOND:"#576cce",MASTER:"#9d48e0",GRANDMASTER:"#e44c3e",CHALLENGER:"#f4c874"},HAe={SOLORANKED:"Ranked Solo",FLEXRANKED:"Ranked Flex",NORMAL:"Normal",ARAM:"ARAM",ARENA:"Arena",URF:"URF",BOT:"Co-op vs AI"},WAe="https://ddragon.leagueoflegends.com/cdn/15.5.1/img";function mm(i){return`${WAe}/champion/${i}.png`}function y7(i){const e=Math.floor((Date.now()-new Date(i).getTime())/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function $Ae(i){const e=Math.floor(i/60),t=i%60;return`${e}:${String(t).padStart(2,"0")}`}function x7(i,e,t){return e===0?"Perfect":((i+t)/e).toFixed(2)}function b7(i,e){const t=i+e;return t>0?Math.round(i/t*100):0}function XAe(i,e){if(!i)return"Unranked";const t=["","I","II","III","IV"];return`${i.charAt(0)}${i.slice(1).toLowerCase()}${e?" "+(t[e]??e):""}`}function YAe({data:i}){var yt,Ht,pt,Ae;const[e,t]=se.useState(""),[n,r]=se.useState("EUW"),[s,a]=se.useState([]),[l,u]=se.useState(null),[h,m]=se.useState([]),[v,x]=se.useState(!1),[S,T]=se.useState(null),[N,C]=se.useState([]),[E,O]=se.useState(null),[U,I]=se.useState({}),[j,z]=se.useState(!1),[G,H]=se.useState(!1),[q,V]=se.useState(null),[Q,J]=se.useState("aram"),[ie,le]=se.useState("EUW"),[re,Z]=se.useState([]),[ne,de]=se.useState(!1),[be,Te]=se.useState(null),[ae,Me]=se.useState([]),[Ve,Ce]=se.useState(""),[Fe,tt]=se.useState(!1),je=se.useRef(null),Rt=se.useRef(null);se.useEffect(()=>{fetch("/api/lolstats/regions").then(k=>k.json()).then(a).catch(()=>{}),fetch("/api/lolstats/recent").then(k=>k.json()).then(C).catch(()=>{}),fetch("/api/lolstats/modes").then(k=>k.json()).then(Me).catch(()=>{})},[]),se.useEffect(()=>{Q&&(de(!0),Te(null),tt(!1),fetch(`/api/lolstats/tierlist?mode=${Q}®ion=${ie}`).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>Z(k.champions??[])).catch(k=>Te(k.message)).finally(()=>de(!1)))},[Q,ie]),se.useEffect(()=>{i&&(i.recentSearches&&C(i.recentSearches),i.regions&&!s.length&&a(i.regions))},[i]);const Et=se.useCallback(async(k,xe,Oe)=>{H(!0);try{const Ue=`gameName=${encodeURIComponent(k)}&tagLine=${encodeURIComponent(xe)}®ion=${Oe}`,ee=await fetch(`/api/lolstats/renew?${Ue}`,{method:"POST"});if(ee.ok){const we=await ee.json();return we.last_updated_at&&V(we.last_updated_at),we.renewed??!1}}catch{}return H(!1),!1},[]),Ft=se.useCallback(async(k,xe,Oe,Ue=!1)=>{var We,Se;let ee=k??"",we=xe??"";const Re=Oe??n;if(!ee){const Le=e.split("#");ee=((We=Le[0])==null?void 0:We.trim())??"",we=((Se=Le[1])==null?void 0:Se.trim())??""}if(!ee||!we){T("Bitte im Format Name#Tag eingeben");return}x(!0),T(null),u(null),m([]),O(null),I({}),Rt.current={gameName:ee,tagLine:we,region:Re},Ue||Et(ee,we,Re).finally(()=>H(!1));try{const Le=`gameName=${encodeURIComponent(ee)}&tagLine=${encodeURIComponent(we)}®ion=${Re}`,[ct,Dt]=await Promise.all([fetch(`/api/lolstats/profile?${Le}`),fetch(`/api/lolstats/matches?${Le}&limit=10`)]);if(!ct.ok){const lt=await ct.json();throw new Error(lt.error??`Fehler ${ct.status}`)}const It=await ct.json();if(u(It),It.updated_at&&V(It.updated_at),Dt.ok){const lt=await Dt.json();m(Array.isArray(lt)?lt:[])}}catch(Le){T(Le.message)}x(!1)},[e,n,Et]),Ut=se.useCallback(async()=>{const k=Rt.current;if(!(!k||G)){H(!0);try{await Et(k.gameName,k.tagLine,k.region),await new Promise(xe=>setTimeout(xe,1500)),await Ft(k.gameName,k.tagLine,k.region,!0)}finally{H(!1)}}},[Et,Ft,G]),Ke=se.useCallback(async()=>{if(!(!l||j)){z(!0);try{const k=`gameName=${encodeURIComponent(l.game_name)}&tagLine=${encodeURIComponent(l.tagline)}®ion=${n}&limit=20`,xe=await fetch(`/api/lolstats/matches?${k}`);if(xe.ok){const Oe=await xe.json();m(Array.isArray(Oe)?Oe:[])}}catch{}z(!1)}},[l,n,j]),ht=se.useCallback(async k=>{var xe;if(E===k.id){O(null);return}if(O(k.id),!(((xe=k.participants)==null?void 0:xe.length)>=10||U[k.id]))try{const Oe=`region=${n}&createdAt=${encodeURIComponent(k.created_at)}`,Ue=await fetch(`/api/lolstats/match/${encodeURIComponent(k.id)}?${Oe}`);if(Ue.ok){const ee=await Ue.json();I(we=>({...we,[k.id]:ee}))}}catch{}},[E,U,n]),fe=se.useCallback(k=>{t(`${k.game_name}#${k.tag_line}`),r(k.region),Ft(k.game_name,k.tag_line,k.region)},[Ft]),$t=se.useCallback(k=>{var Oe,Ue,ee;if(!l)return((Oe=k.participants)==null?void 0:Oe[0])??null;const xe=l.game_name.toLowerCase();return((Ue=k.participants)==null?void 0:Ue.find(we=>{var Re,We;return((We=(Re=we.summoner)==null?void 0:Re.game_name)==null?void 0:We.toLowerCase())===xe}))??((ee=k.participants)==null?void 0:ee[0])??null},[l]),_t=k=>{var Se,Le,ct;const xe=$t(k);if(!xe)return null;const Oe=((Se=xe.stats)==null?void 0:Se.result)==="WIN",Ue=x7(xe.stats.kill,xe.stats.death,xe.stats.assist),ee=(xe.stats.minion_kill??0)+(xe.stats.neutral_minion_kill??0),we=k.game_length_second>0?(ee/(k.game_length_second/60)).toFixed(1):"0",Re=E===k.id,We=U[k.id]??(((Le=k.participants)==null?void 0:Le.length)>=10?k:null);return P.jsxs("div",{children:[P.jsxs("div",{className:`lol-match ${Oe?"win":"loss"}`,onClick:()=>ht(k),children:[P.jsx("div",{className:"lol-match-result",children:Oe?"W":"L"}),P.jsxs("div",{className:"lol-match-champ",children:[P.jsx("img",{src:mm(xe.champion_name),alt:xe.champion_name,title:xe.champion_name}),P.jsx("span",{className:"lol-match-champ-level",children:xe.stats.champion_level})]}),P.jsxs("div",{className:"lol-match-kda",children:[P.jsxs("div",{className:"lol-match-kda-nums",children:[xe.stats.kill,"/",xe.stats.death,"/",xe.stats.assist]}),P.jsxs("div",{className:`lol-match-kda-ratio ${Ue==="Perfect"?"perfect":Number(Ue)>=4?"great":""}`,children:[Ue," KDA"]})]}),P.jsxs("div",{className:"lol-match-stats",children:[P.jsxs("span",{children:[ee," CS (",we,"/m)"]}),P.jsxs("span",{children:[xe.stats.ward_place," wards"]})]}),P.jsx("div",{className:"lol-match-items",children:(xe.items_names??[]).slice(0,7).map((Dt,It)=>Dt?P.jsx("img",{src:mm("Aatrox"),alt:Dt,title:Dt,style:{background:"var(--bg-deep)"},onError:lt=>{lt.target.style.display="none"}},It):P.jsx("div",{className:"lol-match-item-empty"},It))}),P.jsxs("div",{className:"lol-match-meta",children:[P.jsx("div",{className:"lol-match-duration",children:$Ae(k.game_length_second)}),P.jsx("div",{className:"lol-match-queue",children:HAe[k.game_type]??k.game_type}),P.jsxs("div",{className:"lol-match-ago",children:[y7(k.created_at)," ago"]})]})]}),Re&&We&&P.jsx("div",{className:"lol-match-detail",children:Gt(We,(ct=xe.summoner)==null?void 0:ct.game_name)})]},k.id)},Gt=(k,xe)=>{var Re,We,Se,Le,ct;const Oe=((Re=k.participants)==null?void 0:Re.filter(Dt=>Dt.team_key==="BLUE"))??[],Ue=((We=k.participants)==null?void 0:We.filter(Dt=>Dt.team_key==="RED"))??[],ee=(ct=(Le=(Se=k.teams)==null?void 0:Se.find(Dt=>Dt.key==="BLUE"))==null?void 0:Le.game_stat)==null?void 0:ct.is_win,we=(Dt,It,lt)=>P.jsxs("div",{className:"lol-match-detail-team",children:[P.jsxs("div",{className:`lol-match-detail-team-header ${It?"win":"loss"}`,children:[lt," — ",It?"Victory":"Defeat"]}),Dt.map((jt,Jt)=>{var Bt,ot,Tt,Wt,Yt,pn,$e,St,Kt,wn,qn,Je;const In=((ot=(Bt=jt.summoner)==null?void 0:Bt.game_name)==null?void 0:ot.toLowerCase())===(xe==null?void 0:xe.toLowerCase()),me=(((Tt=jt.stats)==null?void 0:Tt.minion_kill)??0)+(((Wt=jt.stats)==null?void 0:Wt.neutral_minion_kill)??0);return P.jsxs("div",{className:`lol-detail-row ${In?"me":""}`,children:[P.jsx("img",{className:"lol-detail-champ",src:mm(jt.champion_name),alt:jt.champion_name}),P.jsx("span",{className:"lol-detail-name",title:`${(Yt=jt.summoner)==null?void 0:Yt.game_name}#${(pn=jt.summoner)==null?void 0:pn.tagline}`,children:(($e=jt.summoner)==null?void 0:$e.game_name)??jt.champion_name}),P.jsxs("span",{className:"lol-detail-kda",children:[(St=jt.stats)==null?void 0:St.kill,"/",(Kt=jt.stats)==null?void 0:Kt.death,"/",(wn=jt.stats)==null?void 0:wn.assist]}),P.jsxs("span",{className:"lol-detail-cs",children:[me," CS"]}),P.jsxs("span",{className:"lol-detail-dmg",children:[((((qn=jt.stats)==null?void 0:qn.total_damage_dealt_to_champions)??0)/1e3).toFixed(1),"k"]}),P.jsxs("span",{className:"lol-detail-gold",children:[((((Je=jt.stats)==null?void 0:Je.gold_earned)??0)/1e3).toFixed(1),"k"]})]},Jt)})]});return P.jsxs(P.Fragment,{children:[we(Oe,ee,"Blue Team"),we(Ue,ee===void 0?void 0:!ee,"Red Team")]})};return P.jsxs("div",{className:"lol-container",children:[P.jsxs("div",{className:"lol-search",children:[P.jsx("input",{ref:je,className:"lol-search-input",placeholder:"Summoner Name#Tag",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>k.key==="Enter"&&Ft()}),P.jsx("select",{className:"lol-search-region",value:n,onChange:k=>r(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("button",{className:"lol-search-btn",onClick:()=>Ft(),disabled:v,children:v?"...":"Search"})]}),N.length>0&&P.jsx("div",{className:"lol-recent",children:N.map((k,xe)=>P.jsxs("button",{className:"lol-recent-chip",onClick:()=>fe(k),children:[k.profile_image_url&&P.jsx("img",{src:k.profile_image_url,alt:""}),k.game_name,"#",k.tag_line,k.tier&&P.jsx("span",{className:"lol-recent-tier",style:{color:_7[k.tier]},children:k.tier})]},xe))}),S&&P.jsx("div",{className:"lol-error",children:S}),v&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Profil..."]}),l&&!v&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-profile",children:[P.jsx("img",{className:"lol-profile-icon",src:l.profile_image_url,alt:""}),P.jsxs("div",{className:"lol-profile-info",children:[P.jsxs("h2",{children:[l.game_name,P.jsxs("span",{children:["#",l.tagline]})]}),P.jsxs("div",{className:"lol-profile-level",children:["Level ",l.level]}),((yt=l.ladder_rank)==null?void 0:yt.rank)&&P.jsxs("div",{className:"lol-profile-ladder",children:["Ladder Rank #",l.ladder_rank.rank.toLocaleString()," / ",(Ht=l.ladder_rank.total)==null?void 0:Ht.toLocaleString()]}),q&&P.jsxs("div",{className:"lol-profile-updated",children:["Updated ",y7(q)," ago"]})]}),P.jsxs("button",{className:`lol-update-btn ${G?"renewing":""}`,onClick:Ut,disabled:G,title:"Refresh data from Riot servers",children:[P.jsx("span",{className:"lol-update-icon",children:G?"⟳":"↻"}),G?"Updating...":"Update"]})]}),P.jsx("div",{className:"lol-ranked-row",children:(l.league_stats??[]).filter(k=>k.game_type==="SOLORANKED"||k.game_type==="FLEXRANKED").map(k=>{const xe=k.tier_info,Oe=!!(xe!=null&&xe.tier),Ue=_7[(xe==null?void 0:xe.tier)??""]??"var(--text-normal)";return P.jsxs("div",{className:`lol-ranked-card ${Oe?"has-rank":""}`,style:{"--tier-color":Ue},children:[P.jsx("div",{className:"lol-ranked-type",children:k.game_type==="SOLORANKED"?"Ranked Solo/Duo":"Ranked Flex"}),Oe?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-ranked-tier",style:{color:Ue},children:[XAe(xe.tier,xe.division),P.jsxs("span",{className:"lol-ranked-lp",children:[xe.lp," LP"]})]}),P.jsxs("div",{className:"lol-ranked-record",children:[k.win,"W ",k.lose,"L",P.jsxs("span",{className:"lol-ranked-wr",children:["(",b7(k.win??0,k.lose??0),"%)"]}),k.is_hot_streak&&P.jsx("span",{className:"lol-ranked-streak",children:"🔥"})]})]}):P.jsx("div",{className:"lol-ranked-tier",children:"Unranked"})]},k.game_type)})}),((Ae=(pt=l.most_champions)==null?void 0:pt.champion_stats)==null?void 0:Ae.length)>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Top Champions"}),P.jsx("div",{className:"lol-champs",children:l.most_champions.champion_stats.slice(0,7).map(k=>{const xe=b7(k.win,k.lose),Oe=k.play>0?x7(k.kill/k.play,k.death/k.play,k.assist/k.play):"0";return P.jsxs("div",{className:"lol-champ-card",children:[P.jsx("img",{className:"lol-champ-icon",src:mm(k.champion_name),alt:k.champion_name}),P.jsxs("div",{children:[P.jsx("div",{className:"lol-champ-name",children:k.champion_name}),P.jsxs("div",{className:"lol-champ-stats",children:[k.play," games · ",xe,"% WR"]}),P.jsxs("div",{className:"lol-champ-kda",children:[Oe," KDA"]})]})]},k.champion_name)})})]}),h.length>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Match History"}),P.jsx("div",{className:"lol-matches",children:h.map(k=>_t(k))}),h.length<20&&P.jsx("button",{className:"lol-load-more",onClick:Ke,disabled:j,children:j?"Laden...":"Mehr laden"})]})]}),!l&&!v&&!S&&P.jsxs("div",{className:"lol-empty",children:[P.jsx("div",{className:"lol-empty-icon",children:"⚔️"}),P.jsx("h3",{children:"League of Legends Stats"}),P.jsx("p",{children:"Gib einen Summoner Name#Tag ein und wähle die Region"})]}),P.jsxs("div",{className:"lol-tier-section",children:[P.jsx("div",{className:"lol-section-title",children:"Champion Tier List"}),P.jsxs("div",{className:"lol-tier-controls",children:[P.jsx("div",{className:"lol-tier-modes",children:ae.map(k=>P.jsx("button",{className:`lol-tier-mode-btn ${Q===k.key?"active":""}`,onClick:()=>J(k.key),children:k.label},k.key))}),P.jsx("select",{className:"lol-search-region",value:ie,onChange:k=>le(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("input",{className:"lol-tier-filter",placeholder:"Filter champion...",value:Ve,onChange:k=>Ce(k.target.value)})]}),ne&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Tier List..."]}),be&&P.jsx("div",{className:"lol-error",children:be}),!ne&&!be&&re.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-tier-table",children:[P.jsxs("div",{className:"lol-tier-header",children:[P.jsx("span",{className:"lol-tier-col-rank",children:"#"}),P.jsx("span",{className:"lol-tier-col-champ",children:"Champion"}),P.jsx("span",{className:"lol-tier-col-tier",children:"Tier"}),P.jsx("span",{className:"lol-tier-col-wr",children:Q==="arena"?"Win":"Win %"}),P.jsx("span",{className:"lol-tier-col-pr",children:"Pick %"}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:"Ban %"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?"Avg Place":"KDA"})]}),re.filter(k=>!Ve||k.champion_name.toLowerCase().includes(Ve.toLowerCase())).slice(0,Fe?void 0:50).map(k=>{var Oe,Ue;const xe=["OP","1","2","3","4","5"];return P.jsxs("div",{className:`lol-tier-row tier-${k.tier}`,children:[P.jsx("span",{className:"lol-tier-col-rank",children:k.rank}),P.jsxs("span",{className:"lol-tier-col-champ",children:[P.jsx("img",{src:mm(k.champion_name),alt:k.champion_name}),k.champion_name]}),P.jsx("span",{className:`lol-tier-col-tier tier-badge-${k.tier}`,children:xe[k.tier]??k.tier}),P.jsx("span",{className:"lol-tier-col-wr",children:k.win_rate!=null?`${(k.win_rate*100).toFixed(1)}%`:"-"}),P.jsxs("span",{className:"lol-tier-col-pr",children:[(k.pick_rate*100).toFixed(1),"%"]}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:k.ban_rate!=null?`${(k.ban_rate*100).toFixed(1)}%`:"-"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?((Oe=k.average_placement)==null?void 0:Oe.toFixed(1))??"-":((Ue=k.kda)==null?void 0:Ue.toFixed(2))??"-"})]},k.champion_id)})]}),!Fe&&re.length>50&&P.jsxs("button",{className:"lol-load-more",onClick:()=>tt(!0),children:["Alle ",re.length," Champions anzeigen"]})]})]})]})}const S7={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function VS(i){const e=Math.max(0,Math.floor((Date.now()-new Date(i).getTime())/1e3)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}const jS=[{label:"Niedrig · 4 Mbit · 60fps",fps:60,bitrate:4e6},{label:"Mittel · 8 Mbit · 60fps",fps:60,bitrate:8e6},{label:"Hoch · 14 Mbit · 60fps",fps:60,bitrate:14e6},{label:"Ultra · 25 Mbit · 60fps",fps:60,bitrate:25e6},{label:"Max · 50 Mbit · 165fps",fps:165,bitrate:5e7}];function QAe({data:i,isAdmin:e}){var Re,We;const[t,n]=se.useState([]),[r,s]=se.useState(()=>localStorage.getItem("streaming_name")||""),[a,l]=se.useState("Screen Share"),[u,h]=se.useState(""),[m,v]=se.useState(1),[x,S]=se.useState(null),[T,N]=se.useState(null),[C,E]=se.useState(null),[O,U]=se.useState(!1),[I,j]=se.useState(!1),[z,G]=se.useState(null),[,H]=se.useState(0),[q,V]=se.useState(null),[Q,J]=se.useState(null),ie=se.useRef(null),le=se.useRef(""),re=se.useRef(null),Z=se.useRef(null),ne=se.useRef(null),de=se.useRef(new Map),be=se.useRef(null),Te=se.useRef(null),ae=se.useRef(new Map),Me=se.useRef(null),Ve=se.useRef(1e3),Ce=se.useRef(!1),Fe=se.useRef(null),tt=se.useRef(jS[1]);se.useEffect(()=>{Ce.current=O},[O]),se.useEffect(()=>{Fe.current=z},[z]),se.useEffect(()=>{tt.current=jS[m]},[m]),se.useEffect(()=>{var Se,Le;(Le=(Se=window.electronAPI)==null?void 0:Se.setStreaming)==null||Le.call(Se,O||z!==null)},[O,z]),se.useEffect(()=>{if(!(t.length>0||O))return;const Le=setInterval(()=>H(ct=>ct+1),1e3);return()=>clearInterval(Le)},[t.length,O]),se.useEffect(()=>{i!=null&&i.streams&&n(i.streams)},[i]),se.useEffect(()=>{r&&localStorage.setItem("streaming_name",r)},[r]),se.useEffect(()=>{if(!q)return;const Se=()=>V(null);return document.addEventListener("click",Se),()=>document.removeEventListener("click",Se)},[q]);const je=se.useCallback(Se=>{var Le;((Le=ie.current)==null?void 0:Le.readyState)===WebSocket.OPEN&&ie.current.send(JSON.stringify(Se))},[]),Rt=se.useCallback((Se,Le,ct)=>{if(Se.remoteDescription)Se.addIceCandidate(new RTCIceCandidate(ct)).catch(()=>{});else{let Dt=ae.current.get(Le);Dt||(Dt=[],ae.current.set(Le,Dt)),Dt.push(ct)}},[]),Et=se.useCallback((Se,Le)=>{const ct=ae.current.get(Le);if(ct){for(const Dt of ct)Se.addIceCandidate(new RTCIceCandidate(Dt)).catch(()=>{});ae.current.delete(Le)}},[]),Ft=se.useCallback((Se,Le)=>{Se.srcObject=Le;const ct=Se.play();ct&&ct.catch(()=>{Se.muted=!0,Se.play().catch(()=>{})})},[]),Ut=se.useCallback(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),be.current&&(be.current.close(),be.current=null),Te.current=null,ne.current&&(ne.current.srcObject=null)},[]),Ke=se.useRef(()=>{});Ke.current=Se=>{var Le,ct,Dt;switch(Se.type){case"welcome":le.current=Se.clientId,Se.streams&&n(Se.streams);break;case"broadcast_started":E(Se.streamId),U(!0),Ce.current=!0,j(!1),(Le=window.electronAPI)!=null&&Le.showNotification&&window.electronAPI.showNotification("Stream gestartet","Dein Stream ist jetzt live!");break;case"stream_available":n(lt=>lt.some(jt=>jt.id===Se.streamId)?lt:[...lt,{id:Se.streamId,broadcasterName:Se.broadcasterName,title:Se.title,startedAt:new Date().toISOString(),viewerCount:0,hasPassword:!!Se.hasPassword}]);const It=`${Se.broadcasterName} streamt: ${Se.title}`;(ct=window.electronAPI)!=null&&ct.showNotification?window.electronAPI.showNotification("Neuer Stream",It):Notification.permission==="granted"&&new Notification("Neuer Stream",{body:It,icon:"/assets/icon.png"});break;case"stream_ended":n(lt=>lt.filter(jt=>jt.id!==Se.streamId)),((Dt=Fe.current)==null?void 0:Dt.streamId)===Se.streamId&&(Ut(),G(null));break;case"viewer_joined":{const lt=Se.viewerId,jt=de.current.get(lt);jt&&(jt.close(),de.current.delete(lt)),ae.current.delete(lt);const Jt=new RTCPeerConnection(S7);de.current.set(lt,Jt);const In=re.current;if(In)for(const Bt of In.getTracks())Jt.addTrack(Bt,In);Jt.onicecandidate=Bt=>{Bt.candidate&&je({type:"ice_candidate",targetId:lt,candidate:Bt.candidate.toJSON()})};const me=Jt.getSenders().find(Bt=>{var ot;return((ot=Bt.track)==null?void 0:ot.kind)==="video"});if(me){const Bt=me.getParameters();(!Bt.encodings||Bt.encodings.length===0)&&(Bt.encodings=[{}]),Bt.encodings[0].maxFramerate=tt.current.fps,Bt.encodings[0].maxBitrate=tt.current.bitrate,me.setParameters(Bt).catch(()=>{})}Jt.createOffer().then(Bt=>Jt.setLocalDescription(Bt)).then(()=>je({type:"offer",targetId:lt,sdp:Jt.localDescription})).catch(console.error);break}case"viewer_left":{const lt=de.current.get(Se.viewerId);lt&&(lt.close(),de.current.delete(Se.viewerId)),ae.current.delete(Se.viewerId);break}case"offer":{const lt=Se.fromId;be.current&&(be.current.close(),be.current=null),ae.current.delete(lt);const jt=new RTCPeerConnection(S7);be.current=jt,jt.ontrack=Jt=>{const In=Jt.streams[0];if(!In)return;Te.current=In;const me=ne.current;me&&Ft(me,In),G(Bt=>Bt&&{...Bt,phase:"connected"})},jt.onicecandidate=Jt=>{Jt.candidate&&je({type:"ice_candidate",targetId:lt,candidate:Jt.candidate.toJSON()})},jt.oniceconnectionstatechange=()=>{(jt.iceConnectionState==="failed"||jt.iceConnectionState==="disconnected")&&G(Jt=>Jt&&{...Jt,phase:"error",error:"Verbindung verloren"})},jt.setRemoteDescription(new RTCSessionDescription(Se.sdp)).then(()=>(Et(jt,lt),jt.createAnswer())).then(Jt=>jt.setLocalDescription(Jt)).then(()=>je({type:"answer",targetId:lt,sdp:jt.localDescription})).catch(console.error);break}case"answer":{const lt=de.current.get(Se.fromId);lt&<.setRemoteDescription(new RTCSessionDescription(Se.sdp)).then(()=>Et(lt,Se.fromId)).catch(console.error);break}case"ice_candidate":{if(!Se.candidate)break;const lt=de.current.get(Se.fromId);lt?Rt(lt,Se.fromId,Se.candidate):be.current&&Rt(be.current,Se.fromId,Se.candidate);break}case"error":Se.code==="WRONG_PASSWORD"?N(lt=>lt&&{...lt,error:Se.message}):S(Se.message),j(!1);break}};const ht=se.useCallback(()=>{if(ie.current&&ie.current.readyState===WebSocket.OPEN)return;const Se=location.protocol==="https:"?"wss":"ws",Le=new WebSocket(`${Se}://${location.host}/ws/streaming`);ie.current=Le,Le.onopen=()=>{Ve.current=1e3},Le.onmessage=ct=>{let Dt;try{Dt=JSON.parse(ct.data)}catch{return}Ke.current(Dt)},Le.onclose=()=>{ie.current=null,Me.current=setTimeout(()=>{Ve.current=Math.min(Ve.current*2,1e4),ht()},Ve.current)},Le.onerror=()=>{Le.close()}},[]);se.useEffect(()=>(ht(),()=>{Me.current&&clearTimeout(Me.current)}),[ht]);const fe=se.useCallback(async()=>{var Se,Le;if(!r.trim()){S("Bitte gib einen Namen ein.");return}if(!((Se=navigator.mediaDevices)!=null&&Se.getDisplayMedia)){S("Dein Browser unterstützt keine Bildschirmfreigabe.");return}S(null),j(!0);try{const ct=tt.current,Dt=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:ct.fps}},audio:!0});re.current=Dt,Z.current&&(Z.current.srcObject=Dt),(Le=Dt.getVideoTracks()[0])==null||Le.addEventListener("ended",()=>{$t()}),ht();const It=()=>{var lt;((lt=ie.current)==null?void 0:lt.readyState)===WebSocket.OPEN?je({type:"start_broadcast",name:r.trim(),title:a.trim()||"Screen Share",password:u.trim()||void 0}):setTimeout(It,100)};It()}catch(ct){j(!1),ct.name==="NotAllowedError"?S("Bildschirmfreigabe wurde abgelehnt."):S(`Fehler: ${ct.message}`)}},[r,a,u,ht,je]),$t=se.useCallback(()=>{var Se;je({type:"stop_broadcast"}),(Se=re.current)==null||Se.getTracks().forEach(Le=>Le.stop()),re.current=null,Z.current&&(Z.current.srcObject=null);for(const Le of de.current.values())Le.close();de.current.clear(),U(!1),Ce.current=!1,E(null),h("")},[je]),_t=se.useCallback(Se=>{S(null),G({streamId:Se,phase:"connecting"}),ht();const Le=()=>{var ct;((ct=ie.current)==null?void 0:ct.readyState)===WebSocket.OPEN?je({type:"join_viewer",name:r.trim()||"Viewer",streamId:Se}):setTimeout(Le,100)};Le()},[r,ht,je]),Gt=se.useCallback(Se=>{Se.hasPassword?N({streamId:Se.id,streamTitle:Se.title,broadcasterName:Se.broadcasterName,password:"",error:null}):_t(Se.id)},[_t]),yt=se.useCallback(()=>{if(!T)return;if(!T.password.trim()){N(Dt=>Dt&&{...Dt,error:"Passwort eingeben."});return}const{streamId:Se,password:Le}=T;N(null),S(null),G({streamId:Se,phase:"connecting"}),ht();const ct=()=>{var Dt;((Dt=ie.current)==null?void 0:Dt.readyState)===WebSocket.OPEN?je({type:"join_viewer",name:r.trim()||"Viewer",streamId:Se,password:Le.trim()}):setTimeout(ct,100)};ct()},[T,r,ht,je]),Ht=se.useCallback(()=>{je({type:"leave_viewer"}),Ut(),G(null)},[Ut,je]);se.useEffect(()=>{const Se=ct=>{(Ce.current||Fe.current)&&ct.preventDefault()},Le=()=>{le.current&&navigator.sendBeacon("/api/streaming/disconnect",JSON.stringify({clientId:le.current}))};return window.addEventListener("beforeunload",Se),window.addEventListener("pagehide",Le),()=>{window.removeEventListener("beforeunload",Se),window.removeEventListener("pagehide",Le)}},[]);const pt=se.useRef(null),[Ae,k]=se.useState(!1),xe=se.useCallback(()=>{const Se=pt.current;Se&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):Se.requestFullscreen().catch(()=>{}))},[]);se.useEffect(()=>{const Se=()=>k(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",Se),()=>document.removeEventListener("fullscreenchange",Se)},[]),se.useEffect(()=>()=>{var Se;(Se=re.current)==null||Se.getTracks().forEach(Le=>Le.stop());for(const Le of de.current.values())Le.close();be.current&&be.current.close(),ie.current&&ie.current.close(),Me.current&&clearTimeout(Me.current)},[]),se.useEffect(()=>{z&&Te.current&&ne.current&&!ne.current.srcObject&&Ft(ne.current,Te.current)},[z,Ft]);const Oe=se.useRef(null);se.useEffect(()=>{const Le=new URLSearchParams(location.search).get("viewStream");if(Le){Oe.current=Le;const ct=new URL(location.href);ct.searchParams.delete("viewStream"),window.history.replaceState({},"",ct.toString())}},[]),se.useEffect(()=>{const Se=Oe.current;if(!Se||t.length===0)return;const Le=t.find(ct=>ct.id===Se);Le&&(Oe.current=null,Gt(Le))},[t,Gt]);const Ue=se.useCallback(Se=>{const Le=new URL(location.href);return Le.searchParams.set("viewStream",Se),Le.hash="",Le.toString()},[]),ee=se.useCallback(Se=>{navigator.clipboard.writeText(Ue(Se)).then(()=>{J(Se),setTimeout(()=>J(null),2e3)}).catch(()=>{})},[Ue]),we=se.useCallback(Se=>{window.open(Ue(Se),"_blank","noopener"),V(null)},[Ue]);if(z){const Se=t.find(Le=>Le.id===z.streamId);return P.jsxs("div",{className:"stream-viewer-overlay",ref:pt,children:[P.jsxs("div",{className:"stream-viewer-header",children:[P.jsxs("div",{className:"stream-viewer-header-left",children:[P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("div",{children:[P.jsx("div",{className:"stream-viewer-title",children:(Se==null?void 0:Se.title)||"Stream"}),P.jsxs("div",{className:"stream-viewer-subtitle",children:[(Se==null?void 0:Se.broadcasterName)||"..."," ",Se?` · ${Se.viewerCount} Zuschauer`:""]})]})]}),P.jsxs("div",{className:"stream-viewer-header-right",children:[P.jsx("button",{className:"stream-viewer-fullscreen",onClick:xe,title:Ae?"Vollbild verlassen":"Vollbild",children:Ae?"✖":"⛶"}),P.jsx("button",{className:"stream-viewer-close",onClick:Ht,children:"Verlassen"})]})]}),P.jsxs("div",{className:"stream-viewer-video",children:[z.phase==="connecting"?P.jsxs("div",{className:"stream-viewer-connecting",children:[P.jsx("div",{className:"stream-viewer-spinner"}),"Verbindung wird hergestellt..."]}):z.phase==="error"?P.jsxs("div",{className:"stream-viewer-connecting",children:[z.error||"Verbindungsfehler",P.jsx("button",{className:"stream-btn",onClick:Ht,children:"Zurück"})]}):null,P.jsx("video",{ref:ne,autoPlay:!0,playsInline:!0,style:z.phase==="connected"?{}:{display:"none"}})]})]})}return P.jsxs("div",{className:"stream-container",children:[x&&P.jsxs("div",{className:"stream-error",children:[x,P.jsx("button",{className:"stream-error-dismiss",onClick:()=>S(null),children:"×"})]}),P.jsxs("div",{className:"stream-topbar",children:[P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Name"}),P.jsx("input",{className:"stream-input stream-input-name",placeholder:"Dein Name",value:r,onChange:Se=>s(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field stream-field-grow",children:[P.jsx("span",{className:"stream-field-label",children:"Titel"}),P.jsx("input",{className:"stream-input stream-input-title",placeholder:"Stream-Titel",value:a,onChange:Se=>l(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Passwort"}),P.jsx("input",{className:"stream-input stream-input-password",type:"password",placeholder:"optional",value:u,onChange:Se=>h(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsxs("span",{className:"stream-field-label",children:["Qualit","ä","t"]}),P.jsx("select",{className:"stream-select-quality",value:m,onChange:Se=>v(Number(Se.target.value)),disabled:O,children:jS.map((Se,Le)=>P.jsx("option",{value:Le,children:Se.label},Se.label))})]}),O?P.jsxs("button",{className:"stream-btn stream-btn-stop",onClick:$t,children:["⏹"," Stream beenden"]}):P.jsx("button",{className:"stream-btn",onClick:fe,disabled:I,children:I?"Starte...":"🖥️ Stream starten"})]}),t.length===0&&!O?P.jsxs("div",{className:"stream-empty",children:[P.jsx("div",{className:"stream-empty-icon",children:"📺"}),P.jsx("h3",{children:"Keine aktiven Streams"}),P.jsx("p",{children:"Starte einen Stream, um deinen Bildschirm zu teilen."})]}):P.jsxs("div",{className:"stream-grid",children:[O&&P.jsxs("div",{className:"stream-tile own broadcasting",children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("video",{ref:Z,autoPlay:!0,playsInline:!0,muted:!0}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",((Re=t.find(Se=>Se.id===C))==null?void 0:Re.viewerCount)??0]})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsxs("div",{className:"stream-tile-name",children:[r," (Du)"]}),P.jsx("div",{className:"stream-tile-title",children:a})]}),P.jsx("span",{className:"stream-tile-time",children:C&&((We=t.find(Se=>Se.id===C))!=null&&We.startedAt)?VS(t.find(Se=>Se.id===C).startedAt):"0:00"})]})]}),t.filter(Se=>Se.id!==C).map(Se=>P.jsxs("div",{className:"stream-tile",onClick:()=>Gt(Se),children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("span",{className:"stream-tile-icon",children:"🖥️"}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",Se.viewerCount]}),Se.hasPassword&&P.jsx("span",{className:"stream-tile-lock",children:"🔒"})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsx("div",{className:"stream-tile-name",children:Se.broadcasterName}),P.jsx("div",{className:"stream-tile-title",children:Se.title})]}),P.jsx("span",{className:"stream-tile-time",children:VS(Se.startedAt)}),P.jsxs("div",{className:"stream-tile-menu-wrap",children:[P.jsx("button",{className:"stream-tile-menu",onClick:Le=>{Le.stopPropagation(),V(q===Se.id?null:Se.id)},children:"⋮"}),q===Se.id&&P.jsxs("div",{className:"stream-tile-dropdown",onClick:Le=>Le.stopPropagation(),children:[P.jsxs("div",{className:"stream-tile-dropdown-header",children:[P.jsx("div",{className:"stream-tile-dropdown-name",children:Se.broadcasterName}),P.jsx("div",{className:"stream-tile-dropdown-title",children:Se.title}),P.jsxs("div",{className:"stream-tile-dropdown-detail",children:["👥"," ",Se.viewerCount," Zuschauer · ",VS(Se.startedAt)]})]}),P.jsx("div",{className:"stream-tile-dropdown-divider"}),P.jsxs("button",{className:"stream-tile-dropdown-item",onClick:()=>we(Se.id),children:["🗗"," In neuem Fenster öffnen"]}),P.jsx("button",{className:"stream-tile-dropdown-item",onClick:()=>{ee(Se.id),V(null)},children:Q===Se.id?"✅ Kopiert!":"🔗 Link teilen"})]})]})]})]},Se.id))]}),T&&P.jsx("div",{className:"stream-pw-overlay",onClick:()=>N(null),children:P.jsxs("div",{className:"stream-pw-modal",onClick:Se=>Se.stopPropagation(),children:[P.jsx("h3",{children:T.broadcasterName}),P.jsx("p",{children:T.streamTitle}),T.error&&P.jsx("div",{className:"stream-pw-modal-error",children:T.error}),P.jsx("input",{className:"stream-input",type:"password",placeholder:"Stream-Passwort",value:T.password,onChange:Se=>N(Le=>Le&&{...Le,password:Se.target.value,error:null}),onKeyDown:Se=>{Se.key==="Enter"&&yt()},autoFocus:!0}),P.jsxs("div",{className:"stream-pw-actions",children:[P.jsx("button",{className:"stream-pw-cancel",onClick:()=>N(null),children:"Abbrechen"}),P.jsx("button",{className:"stream-btn",onClick:yt,children:"Beitreten"})]})]})})]})}function w7(i){const e=Math.floor(i),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function KAe(i){const e=i.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(e)return{type:"youtube",videoId:e[1]};const t=i.match(/(?:dailymotion\.com\/video\/|dai\.ly\/)([a-zA-Z0-9]+)/);return t?{type:"dailymotion",videoId:t[1]}:/\.(mp4|webm|ogg)(\?|$)/i.test(i)||i.startsWith("http")?{type:"direct",url:i}:null}function ZAe({data:i}){var pn;const[e,t]=se.useState([]),[n,r]=se.useState(()=>localStorage.getItem("wt_name")||""),[s,a]=se.useState(""),[l,u]=se.useState(""),[h,m]=se.useState(null),[v,x]=se.useState(null),[S,T]=se.useState(null),[N,C]=se.useState(""),[E,O]=se.useState(()=>{const $e=localStorage.getItem("wt_volume");return $e?parseFloat($e):1}),[U,I]=se.useState(!1),[j,z]=se.useState(0),[G,H]=se.useState(0),[q,V]=se.useState(null),[Q,J]=se.useState(!1),[ie,le]=se.useState([]),[re,Z]=se.useState(""),[ne,de]=se.useState(null),[be,Te]=se.useState("synced"),[ae,Me]=se.useState(!0),[Ve,Ce]=se.useState(()=>localStorage.getItem("wt_yt_quality")||"hd1080"),Fe=se.useRef(null),tt=se.useRef(""),je=se.useRef(null),Rt=se.useRef(1e3),Et=se.useRef(null),Ft=se.useRef(null),Ut=se.useRef(null),Ke=se.useRef(null),ht=se.useRef(null),fe=se.useRef(null),$t=se.useRef(!1),_t=se.useRef(!1),Gt=se.useRef(null),yt=se.useRef(null),Ht=se.useRef(Ve),pt=se.useRef(null),Ae=se.useRef(!1),k=se.useRef(0),xe=se.useRef(0);se.useEffect(()=>{Et.current=h},[h]);const Oe=h!=null&&tt.current===h.hostId;se.useEffect(()=>{Ht.current=Ve,localStorage.setItem("wt_yt_quality",Ve),Ut.current&&typeof Ut.current.setPlaybackQuality=="function"&&Ut.current.setPlaybackQuality(Ve)},[Ve]),se.useEffect(()=>{i!=null&&i.rooms&&t(i.rooms)},[i]),se.useEffect(()=>{var $e;($e=yt.current)==null||$e.scrollIntoView({behavior:"smooth"})},[ie]),se.useEffect(()=>{const St=new URLSearchParams(window.location.search).get("wt");if(St&&n.trim()){const Kt=setTimeout(()=>ct(St),1500);return()=>clearTimeout(Kt)}},[]),se.useEffect(()=>{n&&localStorage.setItem("wt_name",n)},[n]),se.useEffect(()=>{var $e;localStorage.setItem("wt_volume",String(E)),Ut.current&&typeof Ut.current.setVolume=="function"&&Ut.current.setVolume(E*100),Ke.current&&(Ke.current.volume=E),($e=pt.current)!=null&&$e.contentWindow&&fe.current==="dailymotion"&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com")},[E]),se.useEffect(()=>{if(window.YT){$t.current=!0;return}const $e=document.createElement("script");$e.src="https://www.youtube.com/iframe_api",document.head.appendChild($e);const St=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{$t.current=!0,St&&St()}},[]);const Ue=se.useCallback($e=>{var St;((St=Fe.current)==null?void 0:St.readyState)===WebSocket.OPEN&&Fe.current.send(JSON.stringify($e))},[]),ee=se.useCallback(()=>fe.current==="youtube"&&Ut.current&&typeof Ut.current.getCurrentTime=="function"?Ut.current.getCurrentTime():fe.current==="direct"&&Ke.current?Ke.current.currentTime:fe.current==="dailymotion"?k.current:null,[]);se.useCallback(()=>fe.current==="youtube"&&Ut.current&&typeof Ut.current.getDuration=="function"?Ut.current.getDuration()||0:fe.current==="direct"&&Ke.current?Ke.current.duration||0:fe.current==="dailymotion"?xe.current:0,[]);const we=se.useCallback(()=>{if(Ut.current){try{Ut.current.destroy()}catch{}Ut.current=null}Ke.current&&(Ke.current.pause(),Ke.current.removeAttribute("src"),Ke.current.load()),pt.current&&(pt.current.src="",Ae.current=!1,k.current=0,xe.current=0),fe.current=null,Gt.current&&(clearInterval(Gt.current),Gt.current=null)},[]),Re=se.useCallback($e=>{we(),V(null);const St=KAe($e);if(St)if(St.type==="youtube"){if(fe.current="youtube",!$t.current||!ht.current)return;const Kt=ht.current,wn=document.createElement("div");wn.id="wt-yt-player-"+Date.now(),Kt.innerHTML="",Kt.appendChild(wn),Ut.current=new window.YT.Player(wn.id,{videoId:St.videoId,playerVars:{autoplay:1,controls:0,modestbranding:1,rel:0},events:{onReady:qn=>{qn.target.setVolume(E*100),qn.target.setPlaybackQuality(Ht.current),z(qn.target.getDuration()||0),Gt.current=setInterval(()=>{Ut.current&&typeof Ut.current.getCurrentTime=="function"&&(H(Ut.current.getCurrentTime()),z(Ut.current.getDuration()||0))},500)},onStateChange:qn=>{if(qn.data===window.YT.PlayerState.ENDED){const Je=Et.current;Je&&tt.current===Je.hostId&&Ue({type:"skip"})}},onError:qn=>{const Je=qn.data;V(Je===101||Je===150?"Embedding deaktiviert — Video kann nur auf YouTube angesehen werden.":Je===100?"Video nicht gefunden oder entfernt.":"Wiedergabefehler — Video wird übersprungen."),setTimeout(()=>{const dt=Et.current;dt&&tt.current===dt.hostId&&Ue({type:"skip"})},3e3)}}})}else St.type==="dailymotion"?(fe.current="dailymotion",pt.current&&(pt.current.src=`https://www.dailymotion.com/embed/video/${St.videoId}?api=postMessage&autoplay=1&controls=0&mute=0&queue-enable=0`)):(fe.current="direct",Ke.current&&(Ke.current.src=St.url,Ke.current.volume=E,Ke.current.play().catch(()=>{})))},[we,E,Ue]);se.useEffect(()=>{const $e=Ke.current;if(!$e)return;const St=()=>{const wn=Et.current;wn&&tt.current===wn.hostId&&Ue({type:"skip"})},Kt=()=>{H($e.currentTime),z($e.duration||0)};return $e.addEventListener("ended",St),$e.addEventListener("timeupdate",Kt),()=>{$e.removeEventListener("ended",St),$e.removeEventListener("timeupdate",Kt)}},[Ue]),se.useEffect(()=>{const $e=St=>{var Je;if(St.origin!=="https://www.dailymotion.com"||typeof St.data!="string")return;const Kt=new URLSearchParams(St.data),wn=Kt.get("method"),qn=Kt.get("value");if(wn==="timeupdate"&&qn){const dt=parseFloat(qn);k.current=dt,H(dt)}else if(wn==="durationchange"&&qn){const dt=parseFloat(qn);xe.current=dt,z(dt)}else if(wn==="ended"){const dt=Et.current;dt&&tt.current===dt.hostId&&Ue({type:"skip"})}else wn==="apiready"&&(Ae.current=!0,(Je=pt.current)!=null&&Je.contentWindow&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com"))};return window.addEventListener("message",$e),()=>window.removeEventListener("message",$e)},[Ue,E]);const We=se.useRef(()=>{});We.current=$e=>{var St,Kt,wn,qn,Je,dt,Vt,xt,A,te,Vn,Wn,$n,dn,Fn,lr;switch($e.type){case"welcome":tt.current=$e.clientId,$e.rooms&&t($e.rooms);break;case"room_created":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]});break}case"room_joined":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]}),(St=an.currentVideo)!=null&&St.url&&setTimeout(()=>Re(an.currentVideo.url),100);break}case"playback_state":{const an=Et.current;if(!an)break;const mn=$e.currentVideo,Er=(Kt=an.currentVideo)==null?void 0:Kt.url;if(mn!=null&&mn.url&&mn.url!==Er?Re(mn.url):!mn&&Er&&we(),fe.current==="youtube"&&Ut.current){const Wi=(qn=(wn=Ut.current).getPlayerState)==null?void 0:qn.call(wn);$e.playing&&Wi!==((dt=(Je=window.YT)==null?void 0:Je.PlayerState)==null?void 0:dt.PLAYING)?(xt=(Vt=Ut.current).playVideo)==null||xt.call(Vt):!$e.playing&&Wi===((te=(A=window.YT)==null?void 0:A.PlayerState)==null?void 0:te.PLAYING)&&((Wn=(Vn=Ut.current).pauseVideo)==null||Wn.call(Vn))}else fe.current==="direct"&&Ke.current?$e.playing&&Ke.current.paused?Ke.current.play().catch(()=>{}):!$e.playing&&!Ke.current.paused&&Ke.current.pause():fe.current==="dailymotion"&&(($n=pt.current)!=null&&$n.contentWindow)&&($e.playing?pt.current.contentWindow.postMessage("play","https://www.dailymotion.com"):pt.current.contentWindow.postMessage("pause","https://www.dailymotion.com"));if($e.currentTime!==void 0&&!_t.current){const Wi=ee();Wi!==null&&Math.abs(Wi-$e.currentTime)>2&&(fe.current==="youtube"&&Ut.current?(Fn=(dn=Ut.current).seekTo)==null||Fn.call(dn,$e.currentTime,!0):fe.current==="direct"&&Ke.current?Ke.current.currentTime=$e.currentTime:fe.current==="dailymotion"&&((lr=pt.current)!=null&&lr.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e.currentTime}`,"https://www.dailymotion.com"))}if($e.currentTime!==void 0){const Wi=ee();if(Wi!==null){const No=Math.abs(Wi-$e.currentTime);No<1.5?Te("synced"):No<5?Te("drifting"):Te("desynced")}}m(Wi=>Wi&&{...Wi,currentVideo:mn||null,playing:$e.playing,currentTime:$e.currentTime??Wi.currentTime});break}case"queue_updated":m(an=>an&&{...an,queue:$e.queue});break;case"members_updated":m(an=>an&&{...an,members:$e.members,hostId:$e.hostId});break;case"vote_updated":de($e.votes);break;case"chat":le(an=>{const mn=[...an,{sender:$e.sender,text:$e.text,timestamp:$e.timestamp}];return mn.length>100?mn.slice(-100):mn});break;case"chat_history":le($e.messages||[]);break;case"error":$e.code==="WRONG_PASSWORD"?x(an=>an&&{...an,error:$e.message}):T($e.message);break}};const Se=se.useCallback(()=>{if(Fe.current&&(Fe.current.readyState===WebSocket.OPEN||Fe.current.readyState===WebSocket.CONNECTING))return;const $e=location.protocol==="https:"?"wss":"ws",St=new WebSocket(`${$e}://${location.host}/ws/watch-together`);Fe.current=St,St.onopen=()=>{Rt.current=1e3},St.onmessage=Kt=>{let wn;try{wn=JSON.parse(Kt.data)}catch{return}We.current(wn)},St.onclose=()=>{Fe.current===St&&(Fe.current=null),Et.current&&(je.current=setTimeout(()=>{Rt.current=Math.min(Rt.current*2,1e4),Se()},Rt.current))},St.onerror=()=>{St.close()}},[]),Le=se.useCallback(()=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}if(!s.trim()){T("Bitte gib einen Raumnamen ein.");return}T(null),Se();const $e=Date.now(),St=()=>{var Kt;((Kt=Fe.current)==null?void 0:Kt.readyState)===WebSocket.OPEN?Ue({type:"create_room",name:s.trim(),userName:n.trim(),password:l.trim()||void 0}):Date.now()-$e>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(St,100)};St()},[n,s,l,Se,Ue]),ct=se.useCallback(($e,St)=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}T(null),Se();const Kt=Date.now(),wn=()=>{var qn;((qn=Fe.current)==null?void 0:qn.readyState)===WebSocket.OPEN?Ue({type:"join_room",userName:n.trim(),roomId:$e,password:(St==null?void 0:St.trim())||void 0}):Date.now()-Kt>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(wn,100)};wn()},[n,Se,Ue]),Dt=se.useCallback(()=>{Ue({type:"leave_room"}),we(),m(null),C(""),z(0),H(0),le([]),de(null),Te("synced")},[Ue,we]),It=se.useCallback(async()=>{const $e=N.trim();if(!$e)return;C(""),J(!0);let St="";try{const Kt=await fetch(`/api/watch-together/video-info?url=${encodeURIComponent($e)}`);Kt.ok&&(St=(await Kt.json()).title||"")}catch{}Ue({type:"add_to_queue",url:$e,title:St||void 0}),J(!1)},[N,Ue]),lt=se.useCallback(()=>{const $e=re.trim();$e&&(Z(""),Ue({type:"chat_message",text:$e}))},[re,Ue]);se.useCallback(()=>{Ue({type:"vote_skip"})},[Ue]),se.useCallback(()=>{Ue({type:"vote_pause"})},[Ue]);const jt=se.useCallback(()=>{Ue({type:"clear_watched"})},[Ue]),Jt=se.useCallback(()=>{if(!h)return;const $e=`${window.location.origin}${window.location.pathname}?wt=${h.id}`;navigator.clipboard.writeText($e).catch(()=>{})},[h]),In=se.useCallback($e=>{Ue({type:"remove_from_queue",index:$e})},[Ue]),me=se.useCallback(()=>{const $e=Et.current;$e&&Ue({type:$e.playing?"pause":"resume"})},[Ue]),Bt=se.useCallback(()=>{Ue({type:"skip"})},[Ue]),ot=se.useCallback($e=>{var St,Kt,wn;_t.current=!0,Ue({type:"seek",time:$e}),fe.current==="youtube"&&Ut.current?(Kt=(St=Ut.current).seekTo)==null||Kt.call(St,$e,!0):fe.current==="direct"&&Ke.current?Ke.current.currentTime=$e:fe.current==="dailymotion"&&((wn=pt.current)!=null&&wn.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e}`,"https://www.dailymotion.com"),H($e),setTimeout(()=>{_t.current=!1},3e3)},[Ue]);se.useEffect(()=>{if(!Oe||!(h!=null&&h.playing))return;const $e=setInterval(()=>{const St=ee();St!==null&&Ue({type:"report_time",time:St})},2e3);return()=>clearInterval($e)},[Oe,h==null?void 0:h.playing,Ue,ee]);const Tt=se.useCallback(()=>{const $e=Ft.current;$e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):$e.requestFullscreen().catch(()=>{}))},[]);se.useEffect(()=>{const $e=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$e),()=>document.removeEventListener("fullscreenchange",$e)},[]),se.useEffect(()=>{const $e=Kt=>{Et.current&&Kt.preventDefault()},St=()=>{tt.current&&navigator.sendBeacon("/api/watch-together/disconnect",JSON.stringify({clientId:tt.current}))};return window.addEventListener("beforeunload",$e),window.addEventListener("pagehide",St),()=>{window.removeEventListener("beforeunload",$e),window.removeEventListener("pagehide",St)}},[]),se.useEffect(()=>()=>{we(),Fe.current&&Fe.current.close(),je.current&&clearTimeout(je.current)},[we]);const Wt=se.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(Kt=>Kt&&{...Kt,error:"Passwort eingeben."});return}const{roomId:$e,password:St}=v;x(null),ct($e,St)},[v,ct]),Yt=se.useCallback($e=>{$e.hasPassword?x({roomId:$e.id,roomName:$e.name,password:"",error:null}):ct($e.id)},[ct]);if(h){const $e=h.members.find(St=>St.id===h.hostId);return P.jsxs("div",{className:"wt-room-overlay",ref:Ft,children:[P.jsxs("div",{className:"wt-room-header",children:[P.jsxs("div",{className:"wt-room-header-left",children:[P.jsx("span",{className:"wt-room-name",children:h.name}),P.jsxs("span",{className:"wt-room-members",children:[h.members.length," Mitglieder"]}),$e&&P.jsxs("span",{className:"wt-host-badge",children:["Host: ",$e.name]})]}),P.jsxs("div",{className:"wt-room-header-right",children:[P.jsx("div",{className:`wt-sync-dot wt-sync-${be}`,title:be==="synced"?"Synchron":be==="drifting"?"Leichte Verzögerung":"Nicht synchron"}),P.jsx("button",{className:"wt-header-btn",onClick:Jt,title:"Link kopieren",children:"Link"}),P.jsx("button",{className:"wt-header-btn",onClick:()=>Me(St=>!St),title:ae?"Chat ausblenden":"Chat einblenden",children:"Chat"}),P.jsx("button",{className:"wt-fullscreen-btn",onClick:Tt,title:U?"Vollbild verlassen":"Vollbild",children:U?"✖":"⛶"}),P.jsx("button",{className:"wt-leave-btn",onClick:Dt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"wt-room-body",children:[P.jsxs("div",{className:"wt-player-section",children:[P.jsxs("div",{className:"wt-player-wrap",children:[P.jsx("div",{ref:ht,className:"wt-yt-container",style:fe.current==="youtube"?{}:{display:"none"}}),P.jsx("video",{ref:Ke,className:"wt-video-element",style:fe.current==="direct"?{}:{display:"none"},playsInline:!0}),P.jsx("iframe",{ref:pt,className:"wt-dm-container",style:fe.current==="dailymotion"?{}:{display:"none"},allow:"autoplay; fullscreen",allowFullScreen:!0}),q&&P.jsxs("div",{className:"wt-player-error",children:[P.jsx("div",{className:"wt-error-icon",children:"⚠️"}),P.jsx("p",{children:q}),((pn=h.currentVideo)==null?void 0:pn.url)&&P.jsx("a",{className:"wt-yt-link",href:h.currentVideo.url,target:"_blank",rel:"noopener noreferrer",children:"Auf YouTube öffnen ↗"}),P.jsx("p",{className:"wt-skip-info",children:"Wird in 3 Sekunden übersprungen..."})]}),!h.currentVideo&&P.jsxs("div",{className:"wt-player-placeholder",children:[P.jsx("div",{className:"wt-placeholder-icon",children:"🎬"}),P.jsx("p",{children:"Fuege ein Video zur Warteschlange hinzu"})]})]}),P.jsxs("div",{className:"wt-controls",children:[P.jsx("button",{className:"wt-ctrl-btn",onClick:me,disabled:!h.currentVideo,title:h.playing?"Pause":"Abspielen",children:h.playing?"⏸":"▶"}),P.jsxs("button",{className:"wt-ctrl-btn wt-next-btn",onClick:Bt,disabled:!h.currentVideo&&h.queue.length===0,title:"Nächstes Video",children:["⏭"," Weiter"]}),P.jsx("input",{className:"wt-seek",type:"range",min:0,max:j||0,step:.5,value:G,onChange:St=>ot(parseFloat(St.target.value)),disabled:!h.currentVideo}),P.jsxs("span",{className:"wt-time",children:[w7(G)," / ",w7(j)]}),P.jsxs("div",{className:"wt-volume",children:[P.jsx("span",{className:"wt-volume-icon",children:E===0?"🔇":E<.5?"🔉":"🔊"}),P.jsx("input",{className:"wt-volume-slider",type:"range",min:0,max:1,step:.01,value:E,onChange:St=>O(parseFloat(St.target.value))})]}),fe.current==="youtube"&&P.jsxs("select",{className:"wt-quality-select",value:Ve,onChange:St=>Ce(St.target.value),title:"Videoqualität",children:[P.jsx("option",{value:"highres",children:"4K+"}),P.jsx("option",{value:"hd2160",children:"2160p"}),P.jsx("option",{value:"hd1440",children:"1440p"}),P.jsx("option",{value:"hd1080",children:"1080p"}),P.jsx("option",{value:"hd720",children:"720p"}),P.jsx("option",{value:"large",children:"480p"}),P.jsx("option",{value:"medium",children:"360p"}),P.jsx("option",{value:"small",children:"240p"})]})]})]}),P.jsxs("div",{className:"wt-queue-panel",children:[P.jsxs("div",{className:"wt-queue-header",children:[P.jsxs("span",{children:["Warteschlange (",h.queue.length,")"]}),h.queue.some(St=>St.watched)&&P.jsx("button",{className:"wt-queue-clear-btn",onClick:jt,title:"Gesehene entfernen",children:"Gesehene entfernen"})]}),P.jsx("div",{className:"wt-queue-list",children:h.queue.length===0?P.jsx("div",{className:"wt-queue-empty",children:"Keine Videos in der Warteschlange"}):h.queue.map((St,Kt)=>{var qn,Je;const wn=((qn=h.currentVideo)==null?void 0:qn.url)===St.url;return P.jsxs("div",{className:`wt-queue-item${wn?" playing":""}${St.watched&&!wn?" watched":""} clickable`,onClick:()=>Ue({type:"play_video",index:Kt}),title:"Klicken zum Abspielen",children:[P.jsxs("div",{className:"wt-queue-item-info",children:[St.watched&&!wn&&P.jsx("span",{className:"wt-queue-item-check",children:"✓"}),St.url.match(/youtu/)&&P.jsx("img",{className:"wt-queue-thumb",src:`https://img.youtube.com/vi/${(Je=St.url.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/))==null?void 0:Je[1]}/default.jpg`,alt:""}),P.jsxs("div",{className:"wt-queue-item-text",children:[P.jsx("div",{className:"wt-queue-item-title",children:St.title||St.url}),P.jsx("div",{className:"wt-queue-item-by",children:St.addedBy})]})]}),Oe&&P.jsx("button",{className:"wt-queue-item-remove",onClick:dt=>{dt.stopPropagation(),In(Kt)},title:"Entfernen",children:"×"})]},Kt)})}),P.jsxs("div",{className:"wt-queue-add",children:[P.jsx("input",{className:"wt-input wt-queue-input",placeholder:"Video-URL eingeben",value:N,onChange:St=>C(St.target.value),onKeyDown:St=>{St.key==="Enter"&&It()}}),P.jsx("button",{className:"wt-btn wt-queue-add-btn",onClick:It,disabled:Q,children:Q?"Laden...":"Hinzufuegen"})]})]}),ae&&P.jsxs("div",{className:"wt-chat-panel",children:[P.jsx("div",{className:"wt-chat-header",children:"Chat"}),P.jsxs("div",{className:"wt-chat-messages",children:[ie.length===0?P.jsx("div",{className:"wt-chat-empty",children:"Noch keine Nachrichten"}):ie.map((St,Kt)=>P.jsxs("div",{className:"wt-chat-msg",children:[P.jsx("span",{className:"wt-chat-sender",children:St.sender}),P.jsx("span",{className:"wt-chat-text",children:St.text})]},Kt)),P.jsx("div",{ref:yt})]}),P.jsxs("div",{className:"wt-chat-input-row",children:[P.jsx("input",{className:"wt-input wt-chat-input",placeholder:"Nachricht...",value:re,onChange:St=>Z(St.target.value),onKeyDown:St=>{St.key==="Enter"&<()},maxLength:500}),P.jsx("button",{className:"wt-btn wt-chat-send-btn",onClick:lt,children:"Senden"})]})]})]})]})}return P.jsxs("div",{className:"wt-container",children:[S&&P.jsxs("div",{className:"wt-error",children:[S,P.jsx("button",{className:"wt-error-dismiss",onClick:()=>T(null),children:"×"})]}),P.jsxs("div",{className:"wt-topbar",children:[P.jsx("input",{className:"wt-input wt-input-name",placeholder:"Dein Name",value:n,onChange:$e=>r($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-room",placeholder:"Raumname",value:s,onChange:$e=>a($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-password",type:"password",placeholder:"Passwort (optional)",value:l,onChange:$e=>u($e.target.value)}),P.jsx("button",{className:"wt-btn",onClick:Le,children:"Raum erstellen"})]}),e.length===0?P.jsxs("div",{className:"wt-empty",children:[P.jsx("div",{className:"wt-empty-icon",children:"🎬"}),P.jsx("h3",{children:"Keine aktiven Raeume"}),P.jsx("p",{children:"Erstelle einen Raum, um gemeinsam Videos zu schauen."})]}):P.jsx("div",{className:"wt-grid",children:e.map($e=>P.jsxs("div",{className:"wt-tile",onClick:()=>Yt($e),children:[P.jsxs("div",{className:"wt-tile-preview",children:[P.jsx("span",{className:"wt-tile-icon",children:"🎬"}),P.jsxs("span",{className:"wt-tile-members",children:["👥"," ",$e.memberCount]}),$e.hasPassword&&P.jsx("span",{className:"wt-tile-lock",children:"🔒"}),$e.playing&&P.jsx("span",{className:"wt-tile-playing",children:"▶"})]}),P.jsxs("div",{className:"wt-tile-info",children:[P.jsxs("div",{className:"wt-tile-meta",children:[P.jsx("div",{className:"wt-tile-name",children:$e.name}),P.jsx("div",{className:"wt-tile-host",children:$e.hostName})]}),$e.memberNames&&$e.memberNames.length>0&&P.jsxs("div",{className:"wt-tile-members-list",children:[$e.memberNames.slice(0,5).join(", "),$e.memberNames.length>5&&` +${$e.memberNames.length-5}`]})]})]},$e.id))}),v&&P.jsx("div",{className:"wt-modal-overlay",onClick:()=>x(null),children:P.jsxs("div",{className:"wt-modal",onClick:$e=>$e.stopPropagation(),children:[P.jsx("h3",{children:v.roomName}),P.jsx("p",{children:"Raum-Passwort"}),v.error&&P.jsx("div",{className:"wt-modal-error",children:v.error}),P.jsx("input",{className:"wt-input",type:"password",placeholder:"Passwort",value:v.password,onChange:$e=>x(St=>St&&{...St,password:$e.target.value,error:null}),onKeyDown:$e=>{$e.key==="Enter"&&Wt()},autoFocus:!0}),P.jsxs("div",{className:"wt-modal-actions",children:[P.jsx("button",{className:"wt-modal-cancel",onClick:()=>x(null),children:"Abbrechen"}),P.jsx("button",{className:"wt-btn",onClick:Wt,children:"Beitreten"})]})]})})]})}function HS(i,e){return`https://media.steampowered.com/steamcommunity/public/images/apps/${i}/${e}.jpg`}function T7(i){if(i==null||i===0)return"—";if(i<60)return`${i} Min`;const e=Math.floor(i/60),t=i%60;return t>0?`${e}h ${t}m`:`${e}h`}function JAe(i){try{return new Date(i).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function e0e({data:i,isAdmin:e}){const[t,n]=se.useState([]),[r,s]=se.useState("overview"),[a,l]=se.useState(null),[u,h]=se.useState(new Set),[m,v]=se.useState(null),[x,S]=se.useState(null),[T,N]=se.useState(""),[C,E]=se.useState(null),[O,U]=se.useState(!1),[I,j]=se.useState(null),[z,G]=se.useState(new Set),[H,q]=se.useState("playtime"),V=se.useRef(null),Q=se.useRef(null),[J,ie]=se.useState("");se.useEffect(()=>{i!=null&&i.profiles&&n(i.profiles)},[i]);const le=se.useCallback(async()=>{try{const ee=await fetch("/api/game-library/profiles");if(ee.ok){const we=await ee.json();n(we.profiles||[])}}catch{}},[]),re=se.useCallback(()=>{const ee=window.open("/api/game-library/steam/login","_blank","width=800,height=600"),we=setInterval(()=>{ee&&ee.closed&&(clearInterval(we),setTimeout(le,1e3))},500)},[le]),Z=navigator.userAgent.includes("GamingHubDesktop"),[ne,de]=se.useState(!1),[be,Te]=se.useState(""),[ae,Me]=se.useState("idle"),[Ve,Ce]=se.useState(""),Fe=se.useCallback(()=>{const ee=a?`?linkTo=${a}`:"";if(Z){const we=window.open(`/api/game-library/gog/login${ee}`,"_blank","width=800,height=700"),Re=setInterval(()=>{we&&we.closed&&(clearInterval(Re),setTimeout(le,1e3))},500)}else window.open(`/api/game-library/gog/login${ee}`,"_blank","width=800,height=700"),Te(""),Me("idle"),Ce(""),de(!0)},[le,a,Z]),tt=se.useCallback(async()=>{let ee=be.trim();const we=ee.match(/[?&]code=([^&]+)/);if(we&&(ee=we[1]),!!ee){Me("loading"),Ce("Verbinde mit GOG...");try{const Re=await fetch("/api/game-library/gog/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:ee,linkTo:a||""})}),We=await Re.json();Re.ok&&We.ok?(Me("success"),Ce(`${We.profileName}: ${We.gameCount} Spiele geladen!`),le(),setTimeout(()=>de(!1),2e3)):(Me("error"),Ce(We.error||"Unbekannter Fehler"))}catch{Me("error"),Ce("Verbindung fehlgeschlagen.")}}},[be,a,le]);se.useEffect(()=>{const ee=()=>le();return window.addEventListener("gog-connected",ee),()=>window.removeEventListener("gog-connected",ee)},[le]),se.useEffect(()=>{const ee=()=>le();return window.addEventListener("focus",ee),()=>window.removeEventListener("focus",ee)},[le]);const je=se.useCallback(async ee=>{var we,Re;s("user"),l(ee),v(null),ie(""),U(!0);try{const We=await fetch(`/api/game-library/profile/${ee}/games`);if(We.ok){const Se=await We.json(),Le=Se.games||Se;v(Le);const ct=t.find(It=>It.id===ee),Dt=(Re=(we=ct==null?void 0:ct.platforms)==null?void 0:we.steam)==null?void 0:Re.steamId;Dt&&Le.filter(lt=>!lt.igdb).length>0&&(j(ee),fetch(`/api/game-library/igdb/enrich/${Dt}`).then(lt=>lt.ok?lt.json():null).then(()=>fetch(`/api/game-library/profile/${ee}/games`)).then(lt=>lt.ok?lt.json():null).then(lt=>{lt&&v(lt.games||lt)}).catch(()=>{}).finally(()=>j(null)))}}catch{}finally{U(!1)}},[t]),Rt=se.useCallback(async(ee,we)=>{var Se,Le;we&&we.stopPropagation();const Re=t.find(ct=>ct.id===ee),We=(Le=(Se=Re==null?void 0:Re.platforms)==null?void 0:Se.steam)==null?void 0:Le.steamId;try{We&&await fetch(`/api/game-library/user/${We}?refresh=true`),await le(),r==="user"&&a===ee&&je(ee)}catch{}},[le,r,a,je,t]),Et=se.useCallback(async ee=>{var We,Se;const we=t.find(Le=>Le.id===ee),Re=(Se=(We=we==null?void 0:we.platforms)==null?void 0:We.steam)==null?void 0:Se.steamId;if(Re){j(ee);try{(await fetch(`/api/game-library/igdb/enrich/${Re}`)).ok&&r==="user"&&a===ee&&je(ee)}catch{}finally{j(null)}}},[r,a,je,t]),Ft=se.useCallback(ee=>{h(we=>{const Re=new Set(we);return Re.has(ee)?Re.delete(ee):Re.add(ee),Re})},[]),Ut=se.useCallback(async()=>{if(!(u.size<2)){s("common"),S(null),U(!0);try{const ee=Array.from(u).join(","),we=await fetch(`/api/game-library/common-games?users=${ee}`);if(we.ok){const Re=await we.json();S(Re.games||Re)}else console.error("[GameLibrary] common-games error:",we.status,await we.text().catch(()=>"")),S([])}catch(ee){console.error("[GameLibrary] common-games fetch failed:",ee)}finally{U(!1)}}},[u]),Ke=se.useCallback(ee=>{if(N(ee),V.current&&clearTimeout(V.current),ee.length<2){E(null);return}V.current=setTimeout(async()=>{try{const we=await fetch(`/api/game-library/search?q=${encodeURIComponent(ee)}`);if(we.ok){const Re=await we.json();E(Re.results||Re)}}catch{}},300)},[]),ht=se.useCallback(ee=>{G(we=>{const Re=new Set(we);return Re.has(ee)?Re.delete(ee):Re.add(ee),Re})},[]),fe=se.useCallback(async(ee,we)=>{if(confirm(`${we==="steam"?"Steam":"GOG"}-Verknuepfung wirklich trennen?`))try{const Re=await fetch(`/api/game-library/profile/${ee}/${we}`,{method:"DELETE"});if(Re.ok&&(le(),(await Re.json()).ok)){const Se=t.find(ct=>ct.id===ee);(we==="steam"?Se==null?void 0:Se.platforms.gog:Se==null?void 0:Se.platforms.steam)||$t()}}catch{}},[le,t]);se.useCallback(async ee=>{const we=t.find(Re=>Re.id===ee);if(confirm(`Profil "${we==null?void 0:we.displayName}" wirklich komplett loeschen?`))try{(await fetch(`/api/game-library/profile/${ee}`,{method:"DELETE"})).ok&&(le(),$t())}catch{}},[le,t]);const $t=se.useCallback(()=>{s("overview"),l(null),v(null),S(null),ie(""),G(new Set),q("playtime")},[]),_t=$t,Gt=se.useCallback(ee=>t.find(we=>we.id===ee),[t]),yt=se.useCallback(ee=>typeof ee.playtime_forever=="number"?ee.playtime_forever:Array.isArray(ee.owners)?Math.max(...ee.owners.map(we=>we.playtime_forever||0)):0,[]),Ht=se.useCallback(ee=>[...ee].sort((we,Re)=>{var We,Se;if(H==="rating"){const Le=((We=we.igdb)==null?void 0:We.rating)??-1;return(((Se=Re.igdb)==null?void 0:Se.rating)??-1)-Le}return H==="name"?we.name.localeCompare(Re.name):yt(Re)-yt(we)}),[H,yt]),pt=se.useCallback(ee=>{var we,Re;return z.size===0?!0:(Re=(we=ee.igdb)==null?void 0:we.genres)!=null&&Re.length?ee.igdb.genres.some(We=>z.has(We)):!1},[z]),Ae=se.useCallback(ee=>{var Re;const we=new Map;for(const We of ee)if((Re=We.igdb)!=null&&Re.genres)for(const Se of We.igdb.genres)we.set(Se,(we.get(Se)||0)+1);return[...we.entries()].sort((We,Se)=>Se[1]-We[1]).map(([We])=>We)},[]),k=m?Ht(m.filter(ee=>!J||ee.name.toLowerCase().includes(J.toLowerCase())).filter(pt)):null,xe=m?Ae(m):[],Oe=x?Ae(x):[],Ue=x?Ht(x.filter(pt)):null;return P.jsxs("div",{className:"gl-container",children:[P.jsxs("div",{className:"gl-login-bar",children:[!a&&P.jsx("button",{className:"gl-connect-btn gl-steam-btn",onClick:re,children:"🎮 Steam verbinden"}),P.jsx("div",{className:"gl-login-bar-spacer"})]}),t.length>0&&P.jsx("div",{className:"gl-profile-chips",children:t.map(ee=>P.jsxs("div",{className:`gl-profile-chip${a===ee.id?" selected":""}`,onClick:()=>je(ee.id),children:[P.jsx("img",{className:"gl-profile-chip-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"gl-profile-chip-info",children:[P.jsx("span",{className:"gl-profile-chip-name",children:ee.displayName}),P.jsxs("span",{className:"gl-profile-chip-platforms",children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:`Steam: ${ee.platforms.steam.gameCount} Spiele`,children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:`GOG: ${ee.platforms.gog.gameCount} Spiele`,children:"G"})]})]}),P.jsxs("span",{className:"gl-profile-chip-count",children:["(",ee.totalGames,")"]})]},ee.id))}),r==="overview"&&P.jsx(P.Fragment,{children:t.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"🎮"}),P.jsx("h3",{children:"Keine Konten verbunden"}),P.jsx("p",{children:"Klicke oben auf “Steam verbinden” oder “GOG verbinden”, um deine Spielebibliothek hinzuzufuegen."})]}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"gl-section-title",children:"Verbundene Spieler"}),P.jsx("div",{className:"gl-users-grid",children:t.map(ee=>P.jsxs("div",{className:"gl-user-card",onClick:()=>je(ee.id),children:[P.jsx("img",{className:"gl-user-card-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsx("span",{className:"gl-user-card-name",children:ee.displayName}),P.jsxs("div",{className:"gl-profile-card-platforms",children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:"Steam",children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:"GOG",children:"G"})]}),P.jsxs("span",{className:"gl-user-card-games",children:[ee.totalGames," Spiele"]}),P.jsxs("span",{className:"gl-user-card-updated",children:["Aktualisiert: ",JAe(ee.lastUpdated)]})]},ee.id))}),t.length>=2&&P.jsxs("div",{className:"gl-common-finder",children:[P.jsx("h3",{children:"Gemeinsame Spiele finden"}),P.jsx("div",{className:"gl-common-users",children:t.map(ee=>P.jsxs("label",{className:`gl-common-check${u.has(ee.id)?" checked":""}`,children:[P.jsx("input",{type:"checkbox",checked:u.has(ee.id),onChange:()=>Ft(ee.id)}),P.jsx("img",{className:"gl-common-check-avatar",src:ee.avatarUrl,alt:ee.displayName}),ee.displayName,P.jsxs("span",{className:"gl-profile-chip-platforms",style:{marginLeft:4},children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",children:"G"})]})]},ee.id))}),P.jsx("button",{className:"gl-common-find-btn",disabled:u.size<2,onClick:Ut,children:"Finden"})]}),P.jsx("div",{className:"gl-search",children:P.jsx("input",{className:"gl-search-input",type:"text",placeholder:"Spiel suchen...",value:T,onChange:ee=>Ke(ee.target.value)})}),C&&C.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"gl-search-results-title",children:[C.length," Ergebnis",C.length!==1?"se":""]}),P.jsx("div",{className:"gl-game-list",children:C.map(ee=>P.jsxs("div",{className:"gl-game-item",children:[ee.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(ee.appid,ee.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"}),P.jsx("span",{className:"gl-game-name",children:ee.name}),P.jsx("div",{className:"gl-game-owners",children:ee.owners.map(we=>{const Re=t.find(We=>{var Se;return((Se=We.platforms.steam)==null?void 0:Se.steamId)===we.steamId});return Re?P.jsx("img",{className:"gl-game-owner-avatar",src:Re.avatarUrl,alt:we.personaName,title:we.personaName},we.steamId):null})})]},ee.appid))})]}),C&&C.length===0&&P.jsx("p",{className:"gl-search-results-title",children:"Keine Ergebnisse gefunden."})]})}),r==="user"&&(()=>{const ee=a?Gt(a):null;return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:_t,children:"← Zurueck"}),ee&&P.jsxs(P.Fragment,{children:[P.jsx("img",{className:"gl-detail-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsxs("div",{className:"gl-detail-name",children:[ee.displayName,P.jsxs("span",{className:"gl-game-count",children:[ee.totalGames," Spiele"]})]}),P.jsxs("div",{className:"gl-detail-sub",children:[ee.platforms.steam&&P.jsxs("span",{className:"gl-platform-detail steam",children:[P.jsx("span",{className:"gl-platform-badge steam",children:"Steam ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:we=>{we.stopPropagation(),fe(ee.id,"steam")},title:"Steam trennen",children:"✕"})]}),ee.platforms.gog?P.jsxs("span",{className:"gl-platform-detail gog",children:[P.jsx("span",{className:"gl-platform-badge gog",children:"GOG ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:we=>{we.stopPropagation(),fe(ee.id,"gog")},title:"GOG trennen",children:"✕"})]}):P.jsx("button",{className:"gl-link-gog-btn",onClick:Fe,children:"🟣 GOG verknuepfen"})]})]}),P.jsx("button",{className:"gl-refresh-btn",onClick:()=>Rt(ee.id),title:"Aktualisieren",children:"↻"}),ee.platforms.steam&&P.jsxs("button",{className:`gl-enrich-btn ${I===a?"enriching":""}`,onClick:()=>Et(a),disabled:I===a,title:I===a?"IGDB-Daten werden geladen...":"Mit IGDB-Daten anreichern (erneut)",children:[I===a?"⏳":"🌐"," IGDB"]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Bibliothek wird geladen..."}):k?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-filter-bar",children:[P.jsx("input",{ref:Q,className:"gl-search-input",type:"text",placeholder:"Bibliothek durchsuchen...",value:J,onChange:we=>ie(we.target.value)}),P.jsxs("select",{className:"gl-sort-select",value:H,onChange:we=>q(we.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})]}),xe.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),xe.map(we=>P.jsx("button",{className:`gl-genre-chip${z.has(we)?" active":""}`,onClick:()=>ht(we),children:we},we))]}),P.jsxs("p",{className:"gl-filter-count",children:[k.length," Spiele"]}),k.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Spiele gefunden."}):P.jsx("div",{className:"gl-game-list",children:k.map((we,Re)=>{var We,Se,Le;return P.jsxs("div",{className:`gl-game-item ${we.igdb?"enriched":""}`,children:[P.jsx("span",{className:`gl-game-platform-icon ${we.platform||"steam"}`,children:we.platform==="gog"?"G":"S"}),P.jsx("div",{className:"gl-game-visual",children:(We=we.igdb)!=null&&We.coverUrl?P.jsx("img",{className:"gl-game-cover",src:we.igdb.coverUrl,alt:""}):we.img_icon_url&&we.appid?P.jsx("img",{className:"gl-game-icon",src:HS(we.appid,we.img_icon_url),alt:""}):we.image?P.jsx("img",{className:"gl-game-icon",src:we.image,alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:we.name}),((Se=we.igdb)==null?void 0:Se.genres)&&we.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:we.igdb.genres.slice(0,3).map(ct=>P.jsx("span",{className:"gl-genre-tag",children:ct},ct))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Le=we.igdb)==null?void 0:Le.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${we.igdb.rating>=75?"high":we.igdb.rating>=50?"mid":"low"}`,children:Math.round(we.igdb.rating)}),P.jsx("span",{className:"gl-game-playtime",children:T7(we.playtime_forever)})]})]},we.appid??we.gogId??Re)})})]}):null]})})(),r==="common"&&(()=>{const ee=Array.from(u).map(Re=>Gt(Re)).filter(Boolean),we=ee.map(Re=>Re.displayName).join(", ");return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:_t,children:"← Zurueck"}),P.jsx("div",{className:"gl-detail-avatars",children:ee.map(Re=>P.jsx("img",{src:Re.avatarUrl,alt:Re.displayName},Re.id))}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsx("div",{className:"gl-detail-name",children:"Gemeinsame Spiele"}),P.jsxs("div",{className:"gl-detail-sub",children:["von ",we]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Gemeinsame Spiele werden gesucht..."}):x?x.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"😔"}),P.jsx("h3",{children:"Keine gemeinsamen Spiele"}),P.jsx("p",{children:"Die ausgewaehlten Spieler besitzen leider keine gemeinsamen Spiele."})]}):P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"gl-filter-bar",children:P.jsxs("select",{className:"gl-sort-select",value:H,onChange:Re=>q(Re.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})}),Oe.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),Oe.map(Re=>P.jsx("button",{className:`gl-genre-chip${z.has(Re)?" active":""}`,onClick:()=>ht(Re),children:Re},Re))]}),P.jsxs("p",{className:"gl-section-title",children:[Ue.length," gemeinsame",Ue.length!==1?" Spiele":"s Spiel",z.size>0?` (von ${x.length})`:""]}),P.jsx("div",{className:"gl-game-list",children:Ue.map(Re=>{var We,Se,Le;return P.jsxs("div",{className:`gl-game-item ${Re.igdb?"enriched":""}`,children:[P.jsx("div",{className:"gl-game-visual",children:(We=Re.igdb)!=null&&We.coverUrl?P.jsx("img",{className:"gl-game-cover",src:Re.igdb.coverUrl,alt:""}):Re.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(Re.appid,Re.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:Re.name}),((Se=Re.igdb)==null?void 0:Se.genres)&&Re.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:Re.igdb.genres.slice(0,3).map(ct=>P.jsx("span",{className:"gl-genre-tag",children:ct},ct))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Le=Re.igdb)==null?void 0:Le.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${Re.igdb.rating>=75?"high":Re.igdb.rating>=50?"mid":"low"}`,children:Math.round(Re.igdb.rating)}),P.jsx("div",{className:"gl-common-playtimes",children:Re.owners.map(ct=>P.jsxs("span",{className:"gl-common-pt",children:[ct.personaName,": ",T7(ct.playtime_forever)]},ct.steamId))})]})]},Re.appid)})})]}):null]})})(),ne&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>de(!1),children:P.jsxs("div",{className:"gl-dialog",onClick:ee=>ee.stopPropagation(),children:[P.jsx("h3",{children:"🟣 GOG verbinden"}),P.jsxs("p",{className:"gl-dialog-hint",children:["Nach dem GOG-Login wirst du auf eine Seite weitergeleitet. Kopiere die ",P.jsx("strong",{children:"komplette URL"})," aus der Adressleiste und füge sie hier ein:"]}),P.jsx("input",{className:"gl-dialog-input",type:"text",placeholder:"https://embed.gog.com/on_login_success?code=...",value:be,onChange:ee=>Te(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&tt()},disabled:ae==="loading"||ae==="success",autoFocus:!0}),Ve&&P.jsx("p",{className:`gl-dialog-status ${ae}`,children:Ve}),P.jsxs("div",{className:"gl-dialog-actions",children:[P.jsx("button",{onClick:()=>de(!1),className:"gl-dialog-cancel",children:"Abbrechen"}),P.jsx("button",{onClick:tt,className:"gl-dialog-submit",disabled:!be.trim()||ae==="loading"||ae==="success",children:ae==="loading"?"Verbinde...":"Verbinden"})]})]})})]})}const lx="/api/soundboard";async function t0e(){const i=new URL(`${lx}/sounds`,window.location.origin);i.searchParams.set("folder","__all__"),i.searchParams.set("fuzzy","0");const e=await fetch(i.toString());if(!e.ok)throw new Error("Fehler beim Laden der Sounds");return e.json()}async function n0e(i){if(!(await fetch(`${lx}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}async function i0e(i,e){const t=await fetch(`${lx}/admin/sounds/rename`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({from:i,to:e})});if(!t.ok)throw new Error("Umbenennen fehlgeschlagen");const n=await t.json();return n==null?void 0:n.to}function r0e(i,e){return new Promise((t,n)=>{const r=new FormData;r.append("files",i);const s=new XMLHttpRequest;s.open("POST",`${lx}/upload`),s.upload.onprogress=a=>{a.lengthComputable&&e(Math.round(a.loaded/a.total*100))},s.onload=()=>{var a,l;if(s.status===200)try{const u=JSON.parse(s.responseText);t(((l=(a=u.files)==null?void 0:a[0])==null?void 0:l.name)??i.name)}catch{t(i.name)}else try{n(new Error(JSON.parse(s.responseText).error))}catch{n(new Error(`HTTP ${s.status}`))}},s.onerror=()=>n(new Error("Netzwerkfehler")),s.send(r)})}function s0e({onClose:i,onLogout:e}){var Oe,Ue;const[t,n]=se.useState("soundboard"),[r,s]=se.useState(null),a=se.useCallback((ee,we="info")=>{s({msg:ee,type:we}),setTimeout(()=>s(null),3e3)},[]);se.useEffect(()=>{const ee=we=>{we.key==="Escape"&&i()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[i]);const[l,u]=se.useState([]),[h,m]=se.useState(!1),[v,x]=se.useState(""),[S,T]=se.useState({}),[N,C]=se.useState(""),[E,O]=se.useState(""),[U,I]=se.useState(null),j=se.useCallback(ee=>ee.relativePath??ee.fileName,[]),z=se.useCallback(async()=>{m(!0);try{const ee=await t0e();u(ee.items||[])}catch(ee){a((ee==null?void 0:ee.message)||"Sounds konnten nicht geladen werden","error")}finally{m(!1)}},[a]),[G,H]=se.useState(!1);se.useEffect(()=>{t==="soundboard"&&!G&&(H(!0),z())},[t,G,z]);const q=se.useMemo(()=>{const ee=v.trim().toLowerCase();return ee?l.filter(we=>{const Re=j(we).toLowerCase();return we.name.toLowerCase().includes(ee)||(we.folder||"").toLowerCase().includes(ee)||Re.includes(ee)}):l},[v,l,j]),V=se.useMemo(()=>Object.keys(S).filter(ee=>S[ee]),[S]),Q=se.useMemo(()=>q.filter(ee=>!!S[j(ee)]).length,[q,S,j]),J=q.length>0&&Q===q.length;function ie(ee){T(we=>({...we,[ee]:!we[ee]}))}function le(ee){C(j(ee)),O(ee.name)}function re(){C(""),O("")}async function Z(){if(!N)return;const ee=E.trim().replace(/\.(mp3|wav)$/i,"");if(!ee){a("Bitte einen gueltigen Namen eingeben","error");return}try{await i0e(N,ee),a("Sound umbenannt"),re(),await z()}catch(we){a((we==null?void 0:we.message)||"Umbenennen fehlgeschlagen","error")}}async function ne(ee){if(ee.length!==0)try{await n0e(ee),a(ee.length===1?"Sound geloescht":`${ee.length} Sounds geloescht`),T({}),re(),await z()}catch(we){a((we==null?void 0:we.message)||"Loeschen fehlgeschlagen","error")}}async function de(ee){I(0);try{await r0e(ee,we=>I(we)),a(`"${ee.name}" hochgeladen`),await z()}catch(we){a((we==null?void 0:we.message)||"Upload fehlgeschlagen","error")}finally{I(null)}}const[be,Te]=se.useState([]),[ae,Me]=se.useState([]),[Ve,Ce]=se.useState(!1),[Fe,tt]=se.useState(!1),[je,Rt]=se.useState({online:!1,botTag:null}),Et=se.useCallback(async()=>{Ce(!0);try{const[ee,we,Re]=await Promise.all([fetch("/api/notifications/status"),fetch("/api/notifications/channels",{credentials:"include"}),fetch("/api/notifications/config",{credentials:"include"})]);if(ee.ok){const We=await ee.json();Rt(We)}if(we.ok){const We=await we.json();Te(We.channels||[])}if(Re.ok){const We=await Re.json();Me(We.channels||[])}}catch{}finally{Ce(!1)}},[]),[Ft,Ut]=se.useState(!1);se.useEffect(()=>{t==="streaming"&&!Ft&&(Ut(!0),Et())},[t,Ft,Et]);const Ke=se.useCallback((ee,we,Re,We,Se)=>{Me(Le=>{const ct=Le.find(Dt=>Dt.channelId===ee);if(ct){const It=ct.events.includes(Se)?ct.events.filter(lt=>lt!==Se):[...ct.events,Se];return It.length===0?Le.filter(lt=>lt.channelId!==ee):Le.map(lt=>lt.channelId===ee?{...lt,events:It}:lt)}else return[...Le,{channelId:ee,channelName:we,guildId:Re,guildName:We,events:[Se]}]})},[]),ht=se.useCallback((ee,we)=>{const Re=ae.find(We=>We.channelId===ee);return(Re==null?void 0:Re.events.includes(we))??!1},[ae]),fe=se.useCallback(async()=>{tt(!0);try{await fetch("/api/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channels:ae}),credentials:"include"}),a("Konfiguration gespeichert")}catch{a("Speichern fehlgeschlagen","error")}finally{tt(!1)}},[ae,a]),[$t,_t]=se.useState([]),[Gt,yt]=se.useState(!1),Ht=se.useCallback(async()=>{yt(!0);try{const ee=await fetch("/api/game-library/admin/profiles",{credentials:"include"});if(ee.ok){const we=await ee.json();_t(we.profiles||[])}}catch{}finally{yt(!1)}},[]),[pt,Ae]=se.useState(!1);se.useEffect(()=>{t==="game-library"&&!pt&&(Ae(!0),Ht())},[t,pt,Ht]);const k=se.useCallback(async(ee,we)=>{if(confirm(`Profil "${we}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`))try{(await fetch(`/api/game-library/admin/profile/${ee}`,{method:"DELETE",credentials:"include"})).ok&&(a("Profil geloescht"),Ht())}catch{a("Loeschen fehlgeschlagen","error")}},[Ht,a]),xe=[{id:"soundboard",icon:"🎵",label:"Soundboard"},{id:"streaming",icon:"📺",label:"Streaming"},{id:"game-library",icon:"🎮",label:"Game Library"}];return P.jsx("div",{className:"ap-overlay",onClick:ee=>{ee.target===ee.currentTarget&&i()},children:P.jsxs("div",{className:"ap-modal",children:[P.jsxs("div",{className:"ap-sidebar",children:[P.jsxs("div",{className:"ap-sidebar-title",children:["⚙️"," Admin"]}),P.jsx("nav",{className:"ap-nav",children:xe.map(ee=>P.jsxs("button",{className:`ap-nav-item ${t===ee.id?"active":""}`,onClick:()=>n(ee.id),children:[P.jsx("span",{className:"ap-nav-icon",children:ee.icon}),P.jsx("span",{className:"ap-nav-label",children:ee.label})]},ee.id))}),P.jsxs("button",{className:"ap-logout-btn",onClick:e,children:["🔒"," Abmelden"]})]}),P.jsxs("div",{className:"ap-content",children:[P.jsxs("div",{className:"ap-header",children:[P.jsxs("h2",{className:"ap-title",children:[(Oe=xe.find(ee=>ee.id===t))==null?void 0:Oe.icon," ",(Ue=xe.find(ee=>ee.id===t))==null?void 0:Ue.label]}),P.jsx("button",{className:"ap-close",onClick:i,children:"✕"})]}),P.jsxs("div",{className:"ap-body",children:[t==="soundboard"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsx("input",{type:"text",className:"ap-search",value:v,onChange:ee=>x(ee.target.value),placeholder:"Nach Name, Ordner oder Pfad filtern..."}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{z()},disabled:h,children:["↻"," Aktualisieren"]})]}),P.jsxs("label",{className:"ap-upload-zone",children:[P.jsx("input",{type:"file",accept:".mp3,.wav",style:{display:"none"},onChange:ee=>{var Re;const we=(Re=ee.target.files)==null?void 0:Re[0];we&&de(we),ee.target.value=""}}),U!==null?P.jsxs("span",{className:"ap-upload-progress",children:["Upload: ",U,"%"]}):P.jsxs("span",{className:"ap-upload-text",children:["⬆️"," Datei hochladen (MP3 / WAV)"]})]}),P.jsxs("div",{className:"ap-bulk-row",children:[P.jsxs("label",{className:"ap-select-all",children:[P.jsx("input",{type:"checkbox",checked:J,onChange:ee=>{const we=ee.target.checked,Re={...S};q.forEach(We=>{Re[j(We)]=we}),T(Re)}}),P.jsxs("span",{children:["Alle sichtbaren (",Q,"/",q.length,")"]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger",disabled:V.length===0,onClick:async()=>{window.confirm(`Wirklich ${V.length} Sound(s) loeschen?`)&&await ne(V)},children:["🗑️"," Ausgewaehlte loeschen"]})]}),P.jsx("div",{className:"ap-list-wrap",children:h?P.jsx("div",{className:"ap-empty",children:"Lade Sounds..."}):q.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Sounds gefunden."}):P.jsx("div",{className:"ap-list",children:q.map(ee=>{const we=j(ee),Re=N===we;return P.jsxs("div",{className:"ap-item",children:[P.jsx("label",{className:"ap-item-check",children:P.jsx("input",{type:"checkbox",checked:!!S[we],onChange:()=>ie(we)})}),P.jsxs("div",{className:"ap-item-main",children:[P.jsx("div",{className:"ap-item-name",children:ee.name}),P.jsxs("div",{className:"ap-item-meta",children:[ee.folder?`Ordner: ${ee.folder}`:"Root"," · ",we]}),Re&&P.jsxs("div",{className:"ap-rename-row",children:[P.jsx("input",{className:"ap-rename-input",value:E,onChange:We=>O(We.target.value),onKeyDown:We=>{We.key==="Enter"&&Z(),We.key==="Escape"&&re()},placeholder:"Neuer Name...",autoFocus:!0}),P.jsx("button",{className:"ap-btn ap-btn-primary ap-btn-sm",onClick:()=>{Z()},children:"Speichern"}),P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:re,children:"Abbrechen"})]})]}),!Re&&P.jsxs("div",{className:"ap-item-actions",children:[P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:()=>le(ee),children:"Umbenennen"}),P.jsx("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:async()=>{window.confirm(`Sound "${ee.name}" loeschen?`)&&await ne([we])},children:"Loeschen"})]})]},we)})})})]}),t==="streaming"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:`ap-status-dot ${je.online?"online":""}`}),je.online?P.jsxs(P.Fragment,{children:["Bot online: ",P.jsx("b",{children:je.botTag})]}):P.jsx(P.Fragment,{children:"Bot offline"})]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{Et()},disabled:Ve,children:["↻"," Aktualisieren"]})]}),Ve?P.jsx("div",{className:"ap-empty",children:"Lade Kanaele..."}):be.length===0?P.jsx("div",{className:"ap-empty",children:je.online?"Keine Text-Kanaele gefunden. Bot hat moeglicherweise keinen Zugriff.":"Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren."}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"ap-hint",children:"Waehle die Kanaele, in die Benachrichtigungen gesendet werden sollen:"}),P.jsx("div",{className:"ap-channel-list",children:be.map(ee=>P.jsxs("div",{className:"ap-channel-row",children:[P.jsxs("div",{className:"ap-channel-info",children:[P.jsxs("span",{className:"ap-channel-name",children:["#",ee.channelName]}),P.jsx("span",{className:"ap-channel-guild",children:ee.guildName})]}),P.jsxs("div",{className:"ap-channel-toggles",children:[P.jsxs("label",{className:`ap-toggle ${ht(ee.channelId,"stream_start")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:ht(ee.channelId,"stream_start"),onChange:()=>Ke(ee.channelId,ee.channelName,ee.guildId,ee.guildName,"stream_start")}),"🔴"," Stream Start"]}),P.jsxs("label",{className:`ap-toggle ${ht(ee.channelId,"stream_end")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:ht(ee.channelId,"stream_end"),onChange:()=>Ke(ee.channelId,ee.channelName,ee.guildId,ee.guildName,"stream_end")}),"⏹️"," Stream Ende"]})]})]},ee.channelId))}),P.jsx("div",{className:"ap-save-row",children:P.jsx("button",{className:"ap-btn ap-btn-primary",onClick:fe,disabled:Fe,children:Fe?"Speichern...":"💾 Speichern"})})]})]}),t==="game-library"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:"ap-status-dot online"}),"Eingeloggt als Admin"]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{Ht()},disabled:Gt,children:["↻"," Aktualisieren"]})]}),Gt?P.jsx("div",{className:"ap-empty",children:"Lade Profile..."}):$t.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Profile vorhanden."}):P.jsx("div",{className:"ap-profile-list",children:$t.map(ee=>P.jsxs("div",{className:"ap-profile-row",children:[P.jsx("img",{className:"ap-profile-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"ap-profile-info",children:[P.jsx("span",{className:"ap-profile-name",children:ee.displayName}),P.jsxs("span",{className:"ap-profile-details",children:[ee.steamName&&P.jsxs("span",{className:"ap-platform-badge steam",children:["Steam: ",ee.steamGames]}),ee.gogName&&P.jsxs("span",{className:"ap-platform-badge gog",children:["GOG: ",ee.gogGames]}),P.jsxs("span",{className:"ap-profile-total",children:[ee.totalGames," Spiele"]})]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:()=>k(ee.id,ee.displayName),children:["🗑️"," Entfernen"]})]},ee.id))})]})]})]}),r&&P.jsxs("div",{className:`ap-toast ${r.type}`,children:[r.type==="error"?"❌":"✅"," ",r.msg]})]})})}const M7={radio:MAe,soundboard:jAe,lolstats:YAe,streaming:QAe,"watch-together":ZAe,"game-library":e0e};function a0e(){var Z;const[i,e]=se.useState(!1),[t,n]=se.useState([]),[r,s]=se.useState(()=>localStorage.getItem("hub_activeTab")??""),a=ne=>{s(ne),localStorage.setItem("hub_activeTab",ne)},[l,u]=se.useState(!1),[h,m]=se.useState({}),[v,x]=se.useState(!1),[S,T]=se.useState(!1),[N,C]=se.useState(!1),[E,O]=se.useState(""),[U,I]=se.useState(""),j=!!((Z=window.electronAPI)!=null&&Z.isElectron),z=j?window.electronAPI.version:null,[G,H]=se.useState("idle"),[q,V]=se.useState(""),Q=se.useRef(null);se.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]),se.useEffect(()=>{fetch("/api/soundboard/admin/status",{credentials:"include"}).then(ne=>ne.json()).then(ne=>x(!!ne.authenticated)).catch(()=>{})},[]),se.useEffect(()=>{if(!S)return;const ne=de=>{de.key==="Escape"&&T(!1)};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[S]);async function J(){I("");try{(await fetch("/api/soundboard/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:E}),credentials:"include"})).ok?(x(!0),O(""),T(!1)):I("Falsches Passwort")}catch{I("Verbindung fehlgeschlagen")}}async function ie(){await fetch("/api/soundboard/admin/logout",{method:"POST",credentials:"include"}),x(!1)}se.useEffect(()=>{var be;if(!j)return;const ne=window.electronAPI;ne.onUpdateAvailable(()=>H("downloading")),ne.onUpdateReady(()=>H("ready")),ne.onUpdateNotAvailable(()=>H("upToDate")),ne.onUpdateError(Te=>{H("error"),V(Te||"Unbekannter Fehler")});const de=(be=ne.getUpdateStatus)==null?void 0:be.call(ne);de==="downloading"?H("downloading"):de==="ready"?H("ready"):de==="checking"&&H("checking")},[j]),se.useEffect(()=>{fetch("/api/plugins").then(ne=>ne.json()).then(ne=>{if(n(ne),new URLSearchParams(location.search).has("viewStream")&&ne.some(ae=>ae.name==="streaming")){a("streaming");return}const be=localStorage.getItem("hub_activeTab"),Te=ne.some(ae=>ae.name===be);ne.length>0&&!Te&&a(ne[0].name)}).catch(()=>{})},[]),se.useEffect(()=>{let ne=null,de;function be(){ne=new EventSource("/api/events"),Q.current=ne,ne.onopen=()=>e(!0),ne.onmessage=Te=>{try{const ae=JSON.parse(Te.data);ae.type==="snapshot"?m(Me=>({...Me,...ae})):ae.plugin&&m(Me=>({...Me,[ae.plugin]:{...Me[ae.plugin]||{},...ae}}))}catch{}},ne.onerror=()=>{e(!1),ne==null||ne.close(),de=setTimeout(be,3e3)}}return be(),()=>{ne==null||ne.close(),clearTimeout(de)}},[]);const le="1.0.0-dev";se.useEffect(()=>{if(!l)return;const ne=de=>{de.key==="Escape"&&u(!1)};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[l]);const re={radio:"🌍",soundboard:"🎵",lolstats:"⚔️",stats:"📊",events:"📅",games:"🎲",gamevote:"🎮",streaming:"📺","watch-together":"🎬","game-library":"🎮"};return P.jsxs("div",{className:"hub-app",children:[P.jsxs("header",{className:"hub-header",children:[P.jsxs("div",{className:"hub-header-left",children:[P.jsx("span",{className:"hub-logo",children:"🎮"}),P.jsx("span",{className:"hub-title",children:"Gaming Hub"}),P.jsx("span",{className:`hub-conn-dot ${i?"online":""}`})]}),P.jsx("nav",{className:"hub-tabs",children:t.filter(ne=>ne.name in M7).map(ne=>P.jsxs("button",{className:`hub-tab ${r===ne.name?"active":""}`,onClick:()=>a(ne.name),title:ne.description,children:[P.jsx("span",{className:"hub-tab-icon",children:re[ne.name]??"📦"}),P.jsx("span",{className:"hub-tab-label",children:ne.name})]},ne.name))}),P.jsxs("div",{className:"hub-header-right",children:[!window.electronAPI&&P.jsxs("a",{className:"hub-download-btn",href:"/downloads/GamingHub-Setup.exe",download:!0,title:"Desktop App herunterladen",children:[P.jsx("span",{className:"hub-download-icon",children:"⬇️"}),P.jsx("span",{className:"hub-download-label",children:"Desktop App"})]}),P.jsx("button",{className:`hub-admin-btn ${v?"active":""}`,onClick:()=>v?C(!0):T(!0),onContextMenu:ne=>{v&&(ne.preventDefault(),ie())},title:v?"Admin Panel (Rechtsklick = Abmelden)":"Admin Login",children:v?"🔓":"🔒"}),P.jsx("button",{className:"hub-refresh-btn",onClick:()=>window.location.reload(),title:"Seite neu laden",children:"🔄"}),P.jsxs("span",{className:"hub-version hub-version-clickable",onClick:()=>{var ne;if(j){const de=window.electronAPI,be=(ne=de.getUpdateStatus)==null?void 0:ne.call(de);be==="downloading"?H("downloading"):be==="ready"?H("ready"):be==="checking"&&H("checking")}u(!0)},title:"Versionsinformationen",children:["v",le]})]})]}),l&&P.jsx("div",{className:"hub-version-overlay",onClick:()=>u(!1),children:P.jsxs("div",{className:"hub-version-modal",onClick:ne=>ne.stopPropagation(),children:[P.jsxs("div",{className:"hub-version-modal-header",children:[P.jsx("span",{children:"Versionsinformationen"}),P.jsx("button",{className:"hub-version-modal-close",onClick:()=>u(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-version-modal-body",children:[P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Hub-Version"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",le]})]}),j&&P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Desktop-App"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",z]})]}),P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Server"}),P.jsxs("span",{className:"hub-version-modal-value",children:[P.jsx("span",{className:`hub-version-modal-dot ${i?"online":""}`}),i?"Verbunden":"Getrennt"]})]}),j&&P.jsxs("div",{className:"hub-version-modal-update",children:[G==="idle"&&P.jsxs("button",{className:"hub-version-modal-update-btn",onClick:()=>{H("checking"),V(""),window.electronAPI.checkForUpdates()},children:["🔄"," Nach Updates suchen"]}),G==="checking"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Suche nach Updates…"]}),G==="downloading"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Update wird heruntergeladen…"]}),G==="ready"&&P.jsxs("button",{className:"hub-version-modal-update-btn ready",onClick:()=>window.electronAPI.installUpdate(),children:["✅"," Jetzt installieren & neu starten"]}),G==="upToDate"&&P.jsxs("div",{className:"hub-version-modal-update-status success",children:["✅"," App ist aktuell",P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut prüfen"})]}),G==="error"&&P.jsxs("div",{className:"hub-version-modal-update-status error",children:["❌"," ",q,P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut versuchen"})]})]})]})]})}),S&&P.jsx("div",{className:"hub-admin-overlay",onClick:()=>T(!1),children:P.jsxs("div",{className:"hub-admin-modal",onClick:ne=>ne.stopPropagation(),children:[P.jsxs("div",{className:"hub-admin-modal-header",children:[P.jsxs("span",{children:["🔒"," Admin Login"]}),P.jsx("button",{className:"hub-admin-modal-close",onClick:()=>T(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-admin-modal-body",children:[P.jsx("input",{type:"password",className:"hub-admin-input",placeholder:"Admin-Passwort...",value:E,onChange:ne=>O(ne.target.value),onKeyDown:ne=>ne.key==="Enter"&&J(),autoFocus:!0}),U&&P.jsx("p",{className:"hub-admin-error",children:U}),P.jsx("button",{className:"hub-admin-submit",onClick:J,children:"Login"})]})]})}),N&&v&&P.jsx(s0e,{onClose:()=>C(!1),onLogout:()=>{ie(),C(!1)}}),P.jsx("main",{className:"hub-content",children:t.length===0?P.jsxs("div",{className:"hub-empty",children:[P.jsx("span",{className:"hub-empty-icon",children:"📦"}),P.jsx("h2",{children:"Keine Plugins geladen"}),P.jsx("p",{children:"Plugins werden im Server konfiguriert."})]}):t.map(ne=>{const de=M7[ne.name];if(!de)return null;const be=r===ne.name;return P.jsx("div",{className:`hub-tab-panel ${be?"active":""}`,style:be?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{display:"none"},children:P.jsx(de,{data:h[ne.name]||{},isAdmin:v})},ne.name)})})]})}IF.createRoot(document.getElementById("root")).render(P.jsx(a0e,{})); +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function m7(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function zf(i){for(var e=1;e1?l-1:0),h=1;h1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=a();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return r;var s=Object.assign({},r,t);if(["lat","lng","altitude"].forEach(function(u){return s[u]=+s[u]}),!n)l(s);else{for(;r.lng-s.lng>180;)r.lng-=360;for(;r.lng-s.lng<-180;)r.lng+=360;e.tweenGroup.add(new la(r).to(s,n).easing(os.Cubic.InOut).onUpdate(l).start())}return this;function a(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(u){var h=u.lat,m=u.lng,v=u.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(h,m,v)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),s=1;slocalStorage.getItem("radio-theme")||"default"),[a,l]=se.useState([]),[u,h]=se.useState(null),[m,v]=se.useState([]),[x,S]=se.useState(!1),[T,N]=se.useState({}),[C,E]=se.useState([]),[O,U]=se.useState(""),[I,j]=se.useState(""),[z,G]=se.useState(""),[H,q]=se.useState([]),[V,Q]=se.useState(!1),[J,ie]=se.useState([]),[le,re]=se.useState(!1),[Z,ne]=se.useState(!1),[de,be]=se.useState(.5),[Te,ae]=se.useState(null),[Me,Ve]=se.useState(!1),[Ce,Fe]=se.useState(!1),tt=se.useRef(void 0),je=se.useRef(void 0),Rt=se.useRef(O);se.useEffect(()=>{fetch("/api/radio/places").then(k=>k.json()).then(l).catch(console.error),fetch("/api/radio/guilds").then(k=>k.json()).then(k=>{if(E(k),k.length>0){U(k[0].id);const xe=k[0].voiceChannels.find(Oe=>Oe.members>0)??k[0].voiceChannels[0];xe&&j(xe.id)}}).catch(console.error),fetch("/api/radio/favorites").then(k=>k.json()).then(ie).catch(console.error)},[]),se.useEffect(()=>{Rt.current=O},[O]),se.useEffect(()=>{i!=null&&i.guildId&&"playing"in i&&i.type!=="radio_voicestats"?N(k=>{if(i.playing)return{...k,[i.guildId]:i.playing};const xe={...k};return delete xe[i.guildId],xe}):i!=null&&i.playing&&!(i!=null&&i.guildId)&&N(i.playing),i!=null&&i.favorites&&ie(i.favorites),i!=null&&i.volumes&&O&&i.volumes[O]!=null&&be(i.volumes[O]),(i==null?void 0:i.volume)!=null&&(i==null?void 0:i.guildId)===O&&be(i.volume),(i==null?void 0:i.type)==="radio_voicestats"&&i.guildId===Rt.current&&ae({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})},[i,O]),se.useEffect(()=>{if(localStorage.setItem("radio-theme",r),t.current&&e.current){const xe=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim();t.current.pointColor(()=>`rgba(${xe}, 0.85)`).atmosphereColor(`rgba(${xe}, 0.25)`)}},[r]);const Et=se.useRef(u);Et.current=u;const Ft=se.useRef(le);Ft.current=le;const Ut=se.useCallback(()=>{var xe;const k=(xe=t.current)==null?void 0:xe.controls();k&&(k.autoRotate=!1),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{var Ue;if(Et.current||Ft.current)return;const Oe=(Ue=t.current)==null?void 0:Ue.controls();Oe&&(Oe.autoRotate=!0)},5e3)},[]);se.useEffect(()=>{var xe;const k=(xe=t.current)==null?void 0:xe.controls();k&&(u||le?(k.autoRotate=!1,n.current&&clearTimeout(n.current)):k.autoRotate=!0)},[u,le]);const Ke=se.useRef(void 0);Ke.current=k=>{h(k),re(!1),S(!0),v([]),Ut(),t.current&&t.current.pointOfView({lat:k.geo[1],lng:k.geo[0],altitude:.4},800),fetch(`/api/radio/place/${k.id}/channels`).then(xe=>xe.json()).then(xe=>{v(xe),S(!1)}).catch(()=>S(!1))},se.useEffect(()=>{const k=e.current;if(!k)return;k.clientWidth>0&&k.clientHeight>0&&Fe(!0);const xe=new ResizeObserver(Oe=>{for(const Ue of Oe){const{width:ee,height:we}=Ue.contentRect;ee>0&&we>0&&Fe(!0)}});return xe.observe(k),()=>xe.disconnect()},[]),se.useEffect(()=>{if(!e.current||a.length===0)return;const k=e.current.clientWidth,xe=e.current.clientHeight;if(t.current){t.current.pointsData(a),k>0&&xe>0&&t.current.width(k).height(xe);return}if(k===0||xe===0)return;const Ue=getComputedStyle(e.current.parentElement).getPropertyValue("--accent-rgb").trim()||"230, 126, 34",ee=new wAe(e.current).backgroundColor("rgba(0,0,0,0)").atmosphereColor(`rgba(${Ue}, 0.25)`).atmosphereAltitude(.12).globeImageUrl("/nasa-blue-marble.jpg").pointsData(a).pointLat(It=>It.geo[1]).pointLng(It=>It.geo[0]).pointColor(()=>`rgba(${Ue}, 0.85)`).pointRadius(It=>Math.max(.12,Math.min(.45,.06+(It.size??1)*.005))).pointAltitude(.001).pointResolution(24).pointLabel(It=>`
${It.title}
${It.country}
`).onPointClick(It=>{var lt;return(lt=Ke.current)==null?void 0:lt.call(Ke,It)}).width(e.current.clientWidth).height(e.current.clientHeight);ee.renderer().setPixelRatio(window.devicePixelRatio),ee.pointOfView({lat:48,lng:10,altitude:qS});const we=ee.controls();we&&(we.autoRotate=!0,we.autoRotateSpeed=.3);let Re=qS;const We=()=>{const lt=ee.pointOfView().altitude;if(Math.abs(lt-Re)/Re<.05)return;Re=lt;const jt=Math.sqrt(lt/qS);ee.pointRadius(Jt=>Math.max(.12,Math.min(.45,.06+(Jt.size??1)*.005))*Math.max(.15,Math.min(2.5,jt)))};we.addEventListener("change",We),t.current=ee;const Se=e.current,Le=()=>Ut();Se.addEventListener("mousedown",Le),Se.addEventListener("touchstart",Le),Se.addEventListener("wheel",Le);const ct=()=>{if(e.current&&t.current){const It=e.current.clientWidth,lt=e.current.clientHeight;It>0&<>0&&t.current.width(It).height(lt)}};window.addEventListener("resize",ct);const Dt=new ResizeObserver(()=>ct());return Dt.observe(Se),()=>{we.removeEventListener("change",We),Se.removeEventListener("mousedown",Le),Se.removeEventListener("touchstart",Le),Se.removeEventListener("wheel",Le),window.removeEventListener("resize",ct),Dt.disconnect()}},[a,Ut,Ce]);const ht=se.useCallback(async(k,xe,Oe,Ue)=>{if(!(!O||!I)){ne(!0);try{(await(await fetch("/api/radio/play",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,voiceChannelId:I,stationId:k,stationName:xe,placeName:Oe??(u==null?void 0:u.title)??"",country:Ue??(u==null?void 0:u.country)??""})})).json()).ok&&(N(Re=>{var We,Se;return{...Re,[O]:{stationId:k,stationName:xe,placeName:Oe??(u==null?void 0:u.title)??"",country:Ue??(u==null?void 0:u.country)??"",startedAt:new Date().toISOString(),channelName:((Se=(We=C.find(Le=>Le.id===O))==null?void 0:We.voiceChannels.find(Le=>Le.id===I))==null?void 0:Se.name)??""}}}),Ut())}catch(ee){console.error(ee)}ne(!1)}},[O,I,u,C]),fe=se.useCallback(async()=>{O&&(await fetch("/api/radio/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O})}),N(k=>{const xe={...k};return delete xe[O],xe}))},[O]),$t=se.useCallback(k=>{if(G(k),tt.current&&clearTimeout(tt.current),!k.trim()){q([]),Q(!1);return}tt.current=setTimeout(async()=>{try{const Oe=await(await fetch(`/api/radio/search?q=${encodeURIComponent(k)}`)).json();q(Oe),Q(!0)}catch{q([])}},350)},[]),_t=se.useCallback(k=>{var xe,Oe,Ue;if(Q(!1),G(""),q([]),k.type==="channel"){const ee=(xe=k.url.match(/\/listen\/[^/]+\/([^/]+)/))==null?void 0:xe[1];ee&&ht(ee,k.title,k.subtitle,"")}else if(k.type==="place"){const ee=(Oe=k.url.match(/\/visit\/[^/]+\/([^/]+)/))==null?void 0:Oe[1],we=a.find(Re=>Re.id===ee);we&&((Ue=Ke.current)==null||Ue.call(Ke,we))}},[a,ht]),Gt=se.useCallback(async(k,xe)=>{try{const Ue=await(await fetch("/api/radio/favorites",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stationId:k,stationName:xe,placeName:(u==null?void 0:u.title)??"",country:(u==null?void 0:u.country)??"",placeId:(u==null?void 0:u.id)??""})})).json();Ue.favorites&&ie(Ue.favorites)}catch{}},[u]),yt=se.useCallback(k=>{be(k),O&&(je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{fetch("/api/radio/volume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:O,volume:k})}).catch(console.error)},100))},[O]),Ht=k=>J.some(xe=>xe.stationId===k),pt=O?T[O]:null,Ae=C.find(k=>k.id===O);return P.jsxs("div",{className:"radio-container","data-theme":r,children:[P.jsxs("header",{className:"radio-topbar",children:[P.jsxs("div",{className:"radio-topbar-left",children:[P.jsx("span",{className:"radio-topbar-logo",children:"🌍"}),P.jsx("span",{className:"radio-topbar-title",children:"World Radio"}),C.length>1&&P.jsx("select",{className:"radio-sel",value:O,onChange:k=>{U(k.target.value);const xe=C.find(Ue=>Ue.id===k.target.value),Oe=(xe==null?void 0:xe.voiceChannels.find(Ue=>Ue.members>0))??(xe==null?void 0:xe.voiceChannels[0]);j((Oe==null?void 0:Oe.id)??"")},children:C.map(k=>P.jsx("option",{value:k.id,children:k.name},k.id))}),P.jsxs("select",{className:"radio-sel",value:I,onChange:k=>j(k.target.value),children:[P.jsx("option",{value:"",children:"Voice Channel..."}),Ae==null?void 0:Ae.voiceChannels.map(k=>P.jsxs("option",{value:k.id,children:["🔊"," ",k.name,k.members>0?` (${k.members})`:""]},k.id))]})]}),pt&&P.jsxs("div",{className:"radio-topbar-np",children:[P.jsxs("div",{className:"radio-eq radio-eq-np",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),P.jsxs("div",{className:"radio-np-info",children:[P.jsx("span",{className:"radio-np-name",children:pt.stationName}),P.jsxs("span",{className:"radio-np-loc",children:[pt.placeName,pt.country?`, ${pt.country}`:""]})]})]}),P.jsxs("div",{className:"radio-topbar-right",children:[pt&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"radio-volume",children:[P.jsx("span",{className:"radio-volume-icon",children:de===0?"🔇":de<.4?"🔉":"🔊"}),P.jsx("input",{type:"range",className:"radio-volume-slider",min:0,max:1,step:.01,value:de,onChange:k=>yt(Number(k.target.value))}),P.jsxs("span",{className:"radio-volume-val",children:[Math.round(de*100),"%"]})]}),P.jsxs("div",{className:"radio-conn",onClick:()=>Ve(!0),title:"Verbindungsdetails",children:[P.jsx("span",{className:"radio-conn-dot"}),"Verbunden",(Te==null?void 0:Te.voicePing)!=null&&P.jsxs("span",{className:"radio-conn-ping",children:[Te.voicePing,"ms"]})]}),P.jsxs("button",{className:"radio-topbar-stop",onClick:fe,children:["⏹"," Stop"]})]}),P.jsx("div",{className:"radio-theme-inline",children:TAe.map(k=>P.jsx("div",{className:`radio-theme-dot ${r===k.id?"active":""}`,style:{background:k.color},title:k.label,onClick:()=>s(k.id)},k.id))})]})]}),P.jsxs("div",{className:"radio-globe-wrap",children:[P.jsx("div",{className:"radio-globe",ref:e}),P.jsxs("div",{className:"radio-search",children:[P.jsxs("div",{className:"radio-search-wrap",children:[P.jsx("span",{className:"radio-search-icon",children:"🔍"}),P.jsx("input",{className:"radio-search-input",type:"text",placeholder:"Sender oder Stadt suchen...",value:z,onChange:k=>$t(k.target.value),onFocus:()=>{H.length&&Q(!0)}}),z&&P.jsx("button",{className:"radio-search-clear",onClick:()=>{G(""),q([]),Q(!1)},children:"✕"})]}),V&&H.length>0&&P.jsx("div",{className:"radio-search-results",children:H.slice(0,12).map(k=>P.jsxs("button",{className:"radio-search-result",onClick:()=>_t(k),children:[P.jsx("span",{className:"radio-search-result-icon",children:k.type==="channel"?"📻":k.type==="place"?"📍":"🌍"}),P.jsxs("div",{className:"radio-search-result-text",children:[P.jsx("span",{className:"radio-search-result-title",children:k.title}),P.jsx("span",{className:"radio-search-result-sub",children:k.subtitle})]})]},k.id+k.url))})]}),!u&&!le&&P.jsxs("button",{className:"radio-fab",onClick:()=>{re(!0),h(null)},title:"Favoriten",children:["⭐",J.length>0&&P.jsx("span",{className:"radio-fab-badge",children:J.length})]}),le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("h3",{children:["⭐"," Favoriten"]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>re(!1),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:J.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Noch keine Favoriten"}):J.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.stationId?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.stationName}),P.jsxs("span",{className:"radio-station-loc",children:[k.placeName,", ",k.country]})]}),P.jsxs("div",{className:"radio-station-btns",children:[P.jsx("button",{className:"radio-btn-play",onClick:()=>ht(k.stationId,k.stationName,k.placeName,k.country),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:"radio-btn-fav active",onClick:()=>Gt(k.stationId,k.stationName),children:"★"})]})]},k.stationId))})]}),u&&!le&&P.jsxs("div",{className:"radio-panel open",children:[P.jsxs("div",{className:"radio-panel-header",children:[P.jsxs("div",{children:[P.jsx("h3",{children:u.title}),P.jsx("span",{className:"radio-panel-sub",children:u.country})]}),P.jsx("button",{className:"radio-panel-close",onClick:()=>h(null),children:"✕"})]}),P.jsx("div",{className:"radio-panel-body",children:x?P.jsxs("div",{className:"radio-panel-loading",children:[P.jsx("div",{className:"radio-spinner"}),"Sender werden geladen..."]}):m.length===0?P.jsx("div",{className:"radio-panel-empty",children:"Keine Sender gefunden"}):m.map(k=>P.jsxs("div",{className:`radio-station ${(pt==null?void 0:pt.stationId)===k.id?"playing":""}`,children:[P.jsxs("div",{className:"radio-station-info",children:[P.jsx("span",{className:"radio-station-name",children:k.title}),(pt==null?void 0:pt.stationId)===k.id&&P.jsxs("span",{className:"radio-station-live",children:[P.jsxs("span",{className:"radio-eq",children:[P.jsx("span",{}),P.jsx("span",{}),P.jsx("span",{})]}),"Live"]})]}),P.jsxs("div",{className:"radio-station-btns",children:[(pt==null?void 0:pt.stationId)===k.id?P.jsx("button",{className:"radio-btn-stop",onClick:fe,children:"⏹"}):P.jsx("button",{className:"radio-btn-play",onClick:()=>ht(k.id,k.title),disabled:!I||Z,children:"▶"}),P.jsx("button",{className:`radio-btn-fav ${Ht(k.id)?"active":""}`,onClick:()=>Gt(k.id,k.title),children:Ht(k.id)?"★":"☆"})]})]},k.id))})]}),P.jsxs("div",{className:"radio-counter",children:["📻"," ",a.length.toLocaleString("de-DE")," Sender weltweit"]}),P.jsx("a",{className:"radio-attribution",href:"https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/",target:"_blank",rel:"noreferrer",children:"Imagery © NASA Blue Marble"})]}),Me&&(()=>{const k=Te!=null&&Te.connectedSince?Math.floor((Date.now()-new Date(Te.connectedSince).getTime())/1e3):0,xe=Math.floor(k/3600),Oe=Math.floor(k%3600/60),Ue=k%60,ee=xe>0?`${xe}h ${String(Oe).padStart(2,"0")}m ${String(Ue).padStart(2,"0")}s`:Oe>0?`${Oe}m ${String(Ue).padStart(2,"0")}s`:`${Ue}s`,we=Re=>Re==null?"var(--text-faint)":Re<80?"var(--success)":Re<150?"#f0a830":"#e04040";return P.jsx("div",{className:"radio-modal-overlay",onClick:()=>Ve(!1),children:P.jsxs("div",{className:"radio-modal",onClick:Re=>Re.stopPropagation(),children:[P.jsxs("div",{className:"radio-modal-header",children:[P.jsx("span",{children:"📡"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"radio-modal-close",onClick:()=>Ve(!1),children:"✕"})]}),P.jsxs("div",{className:"radio-modal-body",children:[P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Voice Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:we((Te==null?void 0:Te.voicePing)??null)}}),(Te==null?void 0:Te.voicePing)!=null?`${Te.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Gateway Ping"}),P.jsxs("span",{className:"radio-modal-value",children:[P.jsx("span",{className:"radio-modal-dot",style:{background:we((Te==null?void 0:Te.gatewayPing)??null)}}),Te&&Te.gatewayPing>=0?`${Te.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Status"}),P.jsx("span",{className:"radio-modal-value",style:{color:(Te==null?void 0:Te.status)==="ready"?"var(--success)":"#f0a830"},children:(Te==null?void 0:Te.status)==="ready"?"Verbunden":(Te==null?void 0:Te.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Kanal"}),P.jsx("span",{className:"radio-modal-value",children:(Te==null?void 0:Te.channelName)||"---"})]}),P.jsxs("div",{className:"radio-modal-stat",children:[P.jsx("span",{className:"radio-modal-label",children:"Verbunden seit"}),P.jsx("span",{className:"radio-modal-value",children:ee||"---"})]})]})]})})})()]})}function EAe(i,e,t=365){const n=new Date(Date.now()+t*24*60*60*1e3).toUTCString();document.cookie=`${encodeURIComponent(i)}=${encodeURIComponent(e)}; expires=${n}; path=/; SameSite=Lax`}function CAe(i){const e=`${encodeURIComponent(i)}=`,t=document.cookie.split(";");for(const n of t){const r=n.trim();if(r.startsWith(e))return decodeURIComponent(r.slice(e.length))}return null}const ca="/api/soundboard";async function NAe(i,e,t,n){const r=new URL(`${ca}/sounds`,window.location.origin);i&&r.searchParams.set("q",i),e!==void 0&&r.searchParams.set("folder",e),r.searchParams.set("fuzzy","0");const s=await fetch(r.toString());if(!s.ok)throw new Error("Fehler beim Laden der Sounds");return s.json()}async function RAe(){const i=await fetch(`${ca}/analytics`);if(!i.ok)throw new Error("Fehler beim Laden der Analytics");return i.json()}async function DAe(){const i=await fetch(`${ca}/categories`,{credentials:"include"});if(!i.ok)throw new Error("Fehler beim Laden der Kategorien");return i.json()}async function PAe(){const i=await fetch(`${ca}/channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channels");return i.json()}async function LAe(){const i=await fetch(`${ca}/selected-channels`);if(!i.ok)throw new Error("Fehler beim Laden der Channel-Auswahl");const e=await i.json();return(e==null?void 0:e.selected)||{}}async function UAe(i,e){if(!(await fetch(`${ca}/selected-channel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Channel-Auswahl setzen fehlgeschlagen")}async function BAe(i,e,t,n,r){const s=await fetch(`${ca}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({soundName:i,guildId:e,channelId:t,volume:n,relativePath:r})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error((a==null?void 0:a.error)||"Play fehlgeschlagen")}}async function OAe(i,e,t,n,r){const s=await fetch(`${ca}/play-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,guildId:e,channelId:t,volume:n,filename:r})}),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error((a==null?void 0:a.error)||"Play-URL fehlgeschlagen");return a}async function IAe(i,e){const t=await fetch(`${ca}/download-url`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:i,filename:e})}),n=await t.json().catch(()=>({}));if(!t.ok)throw new Error((n==null?void 0:n.error)||"Download fehlgeschlagen");return n}async function FAe(i,e){if(!(await fetch(`${ca}/party/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,channelId:e})})).ok)throw new Error("Partymode Start fehlgeschlagen")}async function kAe(i){if(!(await fetch(`${ca}/party/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i})})).ok)throw new Error("Partymode Stop fehlgeschlagen")}async function g7(i,e){const t=await fetch(`${ca}/volume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({guildId:i,volume:e})});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error((n==null?void 0:n.error)||"Volume aendern fehlgeschlagen")}}async function zAe(i){const e=new URL(`${ca}/volume`,window.location.origin);e.searchParams.set("guildId",i);const t=await fetch(e.toString());if(!t.ok)throw new Error("Fehler beim Laden der Lautstaerke");const n=await t.json();return typeof(n==null?void 0:n.volume)=="number"?n.volume:1}async function GAe(i){if(!(await fetch(`${ca}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}function qAe(i,e,t){return new Promise((n,r)=>{const s=new FormData;s.append("files",i),e&&s.append("customName",e);const a=new XMLHttpRequest;a.open("POST",`${ca}/upload`),a.upload.onprogress=l=>{l.lengthComputable&&t(Math.round(l.loaded/l.total*100))},a.onload=()=>{var l,u;if(a.status===200)try{const h=JSON.parse(a.responseText);n(((u=(l=h.files)==null?void 0:l[0])==null?void 0:u.name)??i.name)}catch{n(i.name)}else try{r(new Error(JSON.parse(a.responseText).error))}catch{r(new Error(`HTTP ${a.status}`))}},a.onerror=()=>r(new Error("Netzwerkfehler")),a.send(s)})}const VAe=[{id:"default",color:"#5865f2",label:"Discord"},{id:"purple",color:"#9b59b6",label:"Midnight"},{id:"forest",color:"#2ecc71",label:"Forest"},{id:"sunset",color:"#e67e22",label:"Sunset"},{id:"ocean",color:"#3498db",label:"Ocean"}],v7=["#3b82f6","#f59e0b","#8b5cf6","#ec4899","#14b8a6","#f97316","#06b6d4","#ef4444","#a855f7","#84cc16","#d946ef","#0ea5e9","#f43f5e","#10b981"];function jAe({data:i,isAdmin:e}){var qe,qt,Qt;const[t,n]=se.useState([]),[r,s]=se.useState(0),[a,l]=se.useState([]),[u,h]=se.useState([]),[m,v]=se.useState({totalSounds:0,totalPlays:0,mostPlayed:[]}),[x,S]=se.useState("all"),[T,N]=se.useState(""),[C,E]=se.useState(""),[O,U]=se.useState(""),[I,j]=se.useState(!1),[z,G]=se.useState(null),[H,q]=se.useState([]),[V,Q]=se.useState(""),J=se.useRef(""),[ie,le]=se.useState(!1),[re,Z]=se.useState(1),[ne,de]=se.useState(""),[be,Te]=se.useState({}),[ae,Me]=se.useState(()=>localStorage.getItem("jb-theme")||"default"),[Ve,Ce]=se.useState(()=>parseInt(localStorage.getItem("jb-card-size")||"110")),[Fe,tt]=se.useState(!1),[je,Rt]=se.useState([]),Et=se.useRef(!1),Ft=se.useRef(void 0),Ut=e??!1,[Ke,ht]=se.useState(!1),[fe,$t]=se.useState([]),[_t,Gt]=se.useState(!1),yt=se.useRef(0);se.useRef(void 0);const[Ht,pt]=se.useState([]),[Ae,k]=se.useState(0),[xe,Oe]=se.useState(""),[Ue,ee]=se.useState("naming"),[we,Re]=se.useState(0),[We,Se]=se.useState(null),[Le,ct]=se.useState(!1),[Dt,It]=se.useState(null),[lt,jt]=se.useState(""),[Jt,In]=se.useState(null),[me,Bt]=se.useState(0);se.useEffect(()=>{Et.current=Fe},[Fe]),se.useEffect(()=>{J.current=V},[V]),se.useEffect(()=>{const he=sn=>{var Tn;Array.from(((Tn=sn.dataTransfer)==null?void 0:Tn.items)??[]).some(Rn=>Rn.kind==="file")&&(yt.current++,ht(!0))},X=()=>{yt.current=Math.max(0,yt.current-1),yt.current===0&&ht(!1)},et=sn=>sn.preventDefault(),en=sn=>{var Rn;sn.preventDefault(),yt.current=0,ht(!1);const Tn=Array.from(((Rn=sn.dataTransfer)==null?void 0:Rn.files)??[]).filter(xi=>/\.(mp3|wav)$/i.test(xi.name));Tn.length&&xt(Tn)};return window.addEventListener("dragenter",he),window.addEventListener("dragleave",X),window.addEventListener("dragover",et),window.addEventListener("drop",en),()=>{window.removeEventListener("dragenter",he),window.removeEventListener("dragleave",X),window.removeEventListener("dragover",et),window.removeEventListener("drop",en)}},[Ut]);const ot=se.useCallback((he,X="info")=>{It({msg:he,type:X}),setTimeout(()=>It(null),3e3)},[]);se.useCallback(he=>he.relativePath??he.fileName,[]);const Tt=["youtube.com","www.youtube.com","m.youtube.com","youtu.be","music.youtube.com","instagram.com","www.instagram.com"],Wt=se.useCallback(he=>{const X=he.trim();return!X||/^https?:\/\//i.test(X)?X:"https://"+X},[]),Yt=se.useCallback(he=>{try{const X=new URL(Wt(he)),et=X.hostname.toLowerCase();return!!(X.pathname.toLowerCase().endsWith(".mp3")||Tt.some(en=>et===en||et.endsWith("."+en)))}catch{return!1}},[Wt]),pn=se.useCallback(he=>{try{const X=new URL(Wt(he)),et=X.hostname.toLowerCase();return et.includes("youtube")||et==="youtu.be"?"youtube":et.includes("instagram")?"instagram":X.pathname.toLowerCase().endsWith(".mp3")?"mp3":null}catch{return null}},[Wt]),$e=V?V.split(":")[0]:"",St=V?V.split(":")[1]:"",Kt=se.useMemo(()=>H.find(he=>`${he.guildId}:${he.channelId}`===V),[H,V]);se.useEffect(()=>{const he=()=>{const et=new Date,en=String(et.getHours()).padStart(2,"0"),sn=String(et.getMinutes()).padStart(2,"0"),Tn=String(et.getSeconds()).padStart(2,"0");jt(`${en}:${sn}:${Tn}`)};he();const X=setInterval(he,1e3);return()=>clearInterval(X)},[]),se.useEffect(()=>{(async()=>{try{const[he,X]=await Promise.all([PAe(),LAe()]);if(q(he),he.length){const et=he[0].guildId,en=X[et],sn=en&&he.find(Tn=>Tn.guildId===et&&Tn.channelId===en);Q(sn?`${et}:${en}`:`${he[0].guildId}:${he[0].channelId}`)}}catch(he){ot((he==null?void 0:he.message)||"Channel-Fehler","error")}try{const he=await DAe();h(he.categories||[])}catch{}})()},[]),se.useEffect(()=>{localStorage.setItem("jb-theme",ae)},[ae]);const wn=se.useRef(null);se.useEffect(()=>{const he=wn.current;if(!he)return;he.style.setProperty("--card-size",Ve+"px");const X=Ve/110;he.style.setProperty("--card-emoji",Math.round(28*X)+"px"),he.style.setProperty("--card-font",Math.max(9,Math.round(11*X))+"px"),localStorage.setItem("jb-card-size",String(Ve))},[Ve]),se.useEffect(()=>{var he,X,et,en,sn,Tn,Rn,xi;if(i){if(i.soundboard){const K=i.soundboard;Array.isArray(K.party)&&Rt(K.party);try{const hn=K.selected||{},Zt=(he=J.current)==null?void 0:he.split(":")[0];Zt&&hn[Zt]&&Q(`${Zt}:${hn[Zt]}`)}catch{}try{const hn=K.volumes||{},Zt=(X=J.current)==null?void 0:X.split(":")[0];Zt&&typeof hn[Zt]=="number"&&Z(hn[Zt])}catch{}try{const hn=K.nowplaying||{},Zt=(et=J.current)==null?void 0:et.split(":")[0];Zt&&typeof hn[Zt]=="string"&&de(hn[Zt])}catch{}try{const hn=K.voicestats||{},Zt=(en=J.current)==null?void 0:en.split(":")[0];Zt&&hn[Zt]&&Se(hn[Zt])}catch{}}if(i.type==="soundboard_party")Rt(K=>{const hn=new Set(K);return i.active?hn.add(i.guildId):hn.delete(i.guildId),Array.from(hn)});else if(i.type==="soundboard_channel"){const K=(sn=J.current)==null?void 0:sn.split(":")[0];i.guildId===K&&Q(`${i.guildId}:${i.channelId}`)}else if(i.type==="soundboard_volume"){const K=(Tn=J.current)==null?void 0:Tn.split(":")[0];i.guildId===K&&typeof i.volume=="number"&&Z(i.volume)}else if(i.type==="soundboard_nowplaying"){const K=(Rn=J.current)==null?void 0:Rn.split(":")[0];i.guildId===K&&de(i.name||"")}else if(i.type==="soundboard_voicestats"){const K=(xi=J.current)==null?void 0:xi.split(":")[0];i.guildId===K&&Se({voicePing:i.voicePing,gatewayPing:i.gatewayPing,status:i.status,channelName:i.channelName,connectedSince:i.connectedSince})}}},[i]),se.useEffect(()=>{tt($e?je.includes($e):!1)},[V,je,$e]),se.useEffect(()=>{(async()=>{try{let he="__all__";x==="recent"?he="__recent__":T&&(he=T);const X=await NAe(C,he,void 0,!1);n(X.items),s(X.total),l(X.folders)}catch(he){ot((he==null?void 0:he.message)||"Sounds-Fehler","error")}})()},[x,T,C,me,ot]),se.useEffect(()=>{qn()},[me]),se.useEffect(()=>{const he=CAe("favs");if(he)try{Te(JSON.parse(he))}catch{}},[]),se.useEffect(()=>{try{EAe("favs",JSON.stringify(be))}catch{}},[be]),se.useEffect(()=>{V&&(async()=>{try{const he=await zAe($e);Z(he)}catch{}})()},[V]),se.useEffect(()=>{const he=()=>{le(!1),In(null)};return document.addEventListener("click",he),()=>document.removeEventListener("click",he)},[]);async function qn(){try{const he=await RAe();v(he)}catch{}}async function Je(he){if(!V)return ot("Bitte einen Voice-Channel auswaehlen","error");try{await BAe(he.name,$e,St,re,he.relativePath),de(he.name),qn()}catch(X){ot((X==null?void 0:X.message)||"Play fehlgeschlagen","error")}}function dt(){var en;const he=Wt(O);if(!he)return ot("Bitte einen Link eingeben","error");if(!Yt(he))return ot("Nur YouTube, Instagram oder direkte MP3-Links","error");const X=pn(he);let et="";if(X==="mp3")try{et=((en=new URL(he).pathname.split("/").pop())==null?void 0:en.replace(/\.mp3$/i,""))??""}catch{}G({url:he,type:X,filename:et,phase:"input"})}async function Vt(){if(z){G(he=>he?{...he,phase:"downloading"}:null);try{let he;const X=z.filename.trim()||void 0;V&&$e&&St?he=(await OAe(z.url,$e,St,re,X)).saved:he=(await IAe(z.url,X)).saved,G(et=>et?{...et,phase:"done",savedName:he}:null),U(""),Bt(et=>et+1),qn(),setTimeout(()=>G(null),2500)}catch(he){G(X=>X?{...X,phase:"error",error:(he==null?void 0:he.message)||"Fehler"}:null)}}}async function xt(he){if(!Ut){ot("Admin-Login erforderlich zum Hochladen","error");return}if(he.length===0)return;pt(he),k(0);const X=he[0].name.replace(/\.(mp3|wav)$/i,"");Oe(X),ee("naming"),Re(0)}async function A(){if(Ht.length===0)return;const he=Ht[Ae],X=xe.trim()||he.name.replace(/\.(mp3|wav)$/i,"");ee("uploading"),Re(0);try{await qAe(he,X,et=>Re(et)),ee("done"),setTimeout(()=>{const et=Ae+1;if(eten+1),qn(),ot(`${Ht.length} Sound${Ht.length>1?"s":""} hochgeladen`,"info")},800)}catch(et){ot((et==null?void 0:et.message)||"Upload fehlgeschlagen","error"),pt([])}}function te(){const he=Ae+1;if(he0&&(Bt(X=>X+1),qn())}async function Vn(){if(V){de("");try{await fetch(`${ca}/stop?guildId=${encodeURIComponent($e)}`,{method:"POST"})}catch{}}}async function Wn(){if(!lr.length||!V)return;const he=lr[Math.floor(Math.random()*lr.length)];Je(he)}async function $n(){if(Fe){await Vn();try{await kAe($e)}catch{}}else{if(!V)return ot("Bitte einen Channel auswaehlen","error");try{await FAe($e,St)}catch{}}}async function dn(he){const X=`${he.guildId}:${he.channelId}`;Q(X),le(!1);try{await UAe(he.guildId,he.channelId)}catch{}}function Fn(he){Te(X=>({...X,[he]:!X[he]}))}const lr=se.useMemo(()=>x==="favorites"?t.filter(he=>be[he.relativePath??he.fileName]):t,[t,x,be]),an=se.useMemo(()=>Object.values(be).filter(Boolean).length,[be]),mn=se.useMemo(()=>a.filter(he=>!["__all__","__recent__","__top3__"].includes(he.key)),[a]),Er=se.useMemo(()=>{const he={};return mn.forEach((X,et)=>{he[X.key]=v7[et%v7.length]}),he},[mn]),Wi=se.useMemo(()=>{const he=new Set,X=new Set;return lr.forEach((et,en)=>{const sn=et.name.charAt(0).toUpperCase();he.has(sn)||(he.add(sn),X.add(en))}),X},[lr]),No=se.useMemo(()=>{const he={};return H.forEach(X=>{he[X.guildName]||(he[X.guildName]=[]),he[X.guildName].push(X)}),he},[H]),ce=m.mostPlayed.slice(0,10),Ge=m.totalSounds||r,rt=lt.slice(0,5),it=lt.slice(5);return P.jsxs("div",{className:"sb-app","data-theme":ae,ref:wn,children:[Fe&&P.jsx("div",{className:"party-overlay active"}),P.jsxs("header",{className:"topbar",children:[P.jsxs("div",{className:"topbar-left",children:[P.jsx("div",{className:"sb-app-logo",children:P.jsx("span",{className:"material-icons",style:{fontSize:16,color:"white"},children:"music_note"})}),P.jsx("span",{className:"sb-app-title",children:"Soundboard"}),P.jsxs("div",{className:"channel-dropdown",onClick:he=>he.stopPropagation(),children:[P.jsxs("button",{className:`channel-btn ${ie?"open":""}`,onClick:()=>le(!ie),children:[P.jsx("span",{className:"material-icons cb-icon",children:"headset"}),V&&P.jsx("span",{className:"channel-status"}),P.jsx("span",{className:"channel-label",children:Kt?`${Kt.channelName}${Kt.members?` (${Kt.members})`:""}`:"Channel..."}),P.jsx("span",{className:"material-icons chevron",children:"expand_more"})]}),ie&&P.jsxs("div",{className:"channel-menu visible",children:[Object.entries(No).map(([he,X])=>P.jsxs(FF.Fragment,{children:[P.jsx("div",{className:"channel-menu-header",children:he}),X.map(et=>P.jsxs("div",{className:`channel-option ${`${et.guildId}:${et.channelId}`===V?"active":""}`,onClick:()=>dn(et),children:[P.jsx("span",{className:"material-icons co-icon",children:"volume_up"}),et.channelName,et.members?` (${et.members})`:""]},`${et.guildId}:${et.channelId}`))]},he)),H.length===0&&P.jsx("div",{className:"channel-option",style:{color:"var(--text-faint)",cursor:"default"},children:"Keine Channels verfuegbar"})]})]})]}),P.jsx("div",{className:"clock-wrap",children:P.jsxs("div",{className:"clock",children:[rt,P.jsx("span",{className:"clock-seconds",children:it})]})}),P.jsxs("div",{className:"topbar-right",children:[ne&&P.jsxs("div",{className:"now-playing",children:[P.jsxs("div",{className:"np-waves active",children:[P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"}),P.jsx("div",{className:"np-wave-bar"})]}),P.jsx("span",{className:"np-label",children:"Last Played:"})," ",P.jsx("span",{className:"np-name",children:ne})]}),V&&P.jsxs("div",{className:"connection",onClick:()=>ct(!0),style:{cursor:"pointer"},title:"Verbindungsdetails",children:[P.jsx("span",{className:"conn-dot"}),"Verbunden",(We==null?void 0:We.voicePing)!=null&&P.jsxs("span",{className:"conn-ping",children:[We.voicePing,"ms"]})]})]})]}),P.jsxs("div",{className:"toolbar",children:[P.jsxs("div",{className:"cat-tabs",children:[P.jsxs("button",{className:`cat-tab ${x==="all"?"active":""}`,onClick:()=>{S("all"),N("")},children:["Alle",P.jsx("span",{className:"tab-count",children:r})]}),P.jsx("button",{className:`cat-tab ${x==="recent"?"active":""}`,onClick:()=>{S("recent"),N("")},children:"Neu hinzugefuegt"}),P.jsxs("button",{className:`cat-tab ${x==="favorites"?"active":""}`,onClick:()=>{S("favorites"),N("")},children:["Favoriten",an>0&&P.jsx("span",{className:"tab-count",children:an})]})]}),P.jsxs("div",{className:"search-wrap",children:[P.jsx("span",{className:"material-icons search-icon",children:"search"}),P.jsx("input",{className:"search-input",type:"text",placeholder:"Suchen...",value:C,onChange:he=>E(he.target.value)}),C&&P.jsx("button",{className:"search-clear",onClick:()=>E(""),children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsxs("div",{className:"url-import-wrap",children:[P.jsx("span",{className:"material-icons url-import-icon",children:pn(O)==="youtube"?"smart_display":pn(O)==="instagram"?"photo_camera":"link"}),P.jsx("input",{className:"url-import-input",type:"text",placeholder:"YouTube / Instagram / MP3-Link...",value:O,onChange:he=>U(he.target.value),onKeyDown:he=>{he.key==="Enter"&&dt()}}),O&&P.jsx("span",{className:`url-import-tag ${Yt(O)?"valid":"invalid"}`,children:pn(O)==="youtube"?"YT":pn(O)==="instagram"?"IG":pn(O)==="mp3"?"MP3":"?"}),P.jsx("button",{className:"url-import-btn",onClick:()=>{dt()},disabled:I||!!O&&!Yt(O),title:"Sound herunterladen",children:I?"Laedt...":"Download"})]}),P.jsx("div",{className:"toolbar-spacer"}),P.jsxs("div",{className:"volume-control",children:[P.jsx("span",{className:"material-icons vol-icon",onClick:()=>{const he=re>0?0:.5;Z(he),$e&&g7($e,he).catch(()=>{})},children:re===0?"volume_off":re<.5?"volume_down":"volume_up"}),P.jsx("input",{type:"range",className:"vol-slider",min:0,max:1,step:.01,value:re,onChange:he=>{const X=parseFloat(he.target.value);Z(X),$e&&(Ft.current&&clearTimeout(Ft.current),Ft.current=setTimeout(()=>{g7($e,X).catch(()=>{})},50))},style:{"--vol":`${Math.round(re*100)}%`}}),P.jsxs("span",{className:"vol-pct",children:[Math.round(re*100),"%"]})]}),P.jsxs("button",{className:"tb-btn random",onClick:Wn,title:"Zufaelliger Sound",children:[P.jsx("span",{className:"material-icons tb-icon",children:"shuffle"}),"Random"]}),P.jsxs("button",{className:`tb-btn party ${Fe?"active":""}`,onClick:$n,title:"Party Mode",children:[P.jsx("span",{className:"material-icons tb-icon",children:Fe?"celebration":"auto_awesome"}),Fe?"Party!":"Party"]}),P.jsxs("button",{className:"tb-btn stop",onClick:Vn,title:"Alle stoppen",children:[P.jsx("span",{className:"material-icons tb-icon",children:"stop"}),"Stop"]}),P.jsxs("div",{className:"size-control",title:"Button-Groesse",children:[P.jsx("span",{className:"material-icons sc-icon",children:"grid_view"}),P.jsx("input",{type:"range",className:"size-slider",min:80,max:160,value:Ve,onChange:he=>Ce(parseInt(he.target.value))})]}),P.jsx("div",{className:"theme-selector",children:VAe.map(he=>P.jsx("div",{className:`theme-dot ${ae===he.id?"active":""}`,style:{background:he.color},title:he.label,onClick:()=>Me(he.id)},he.id))})]}),P.jsxs("div",{className:"analytics-strip",children:[P.jsxs("div",{className:"analytics-card",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"library_music"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Sounds gesamt"}),P.jsx("strong",{className:"analytics-value",children:Ge})]})]}),P.jsxs("div",{className:"analytics-card analytics-wide",children:[P.jsx("span",{className:"material-icons analytics-icon",children:"leaderboard"}),P.jsxs("div",{className:"analytics-copy",children:[P.jsx("span",{className:"analytics-label",children:"Most Played"}),P.jsx("div",{className:"analytics-top-list",children:ce.length===0?P.jsx("span",{className:"analytics-muted",children:"Noch keine Plays"}):ce.map((he,X)=>P.jsxs("span",{className:"analytics-chip",children:[X+1,". ",he.name," (",he.count,")"]},he.relativePath))})]})]})]}),x==="all"&&mn.length>0&&P.jsx("div",{className:"category-strip",children:mn.map(he=>{const X=Er[he.key]||"#888",et=T===he.key;return P.jsxs("button",{className:`cat-chip ${et?"active":""}`,onClick:()=>N(et?"":he.key),style:et?{borderColor:X,color:X}:void 0,children:[P.jsx("span",{className:"cat-dot",style:{background:X}}),he.name.replace(/\s*\(\d+\)\s*$/,""),P.jsx("span",{className:"cat-count",children:he.count})]},he.key)})}),P.jsx("main",{className:"main",children:lr.length===0?P.jsxs("div",{className:"empty-state visible",children:[P.jsx("div",{className:"empty-emoji",children:x==="favorites"?"⭐":"🔇"}),P.jsx("div",{className:"empty-title",children:x==="favorites"?"Noch keine Favoriten":C?`Kein Sound fuer "${C}" gefunden`:"Keine Sounds vorhanden"}),P.jsx("div",{className:"empty-desc",children:x==="favorites"?"Klick den Stern auf einem Sound!":"Hier gibt's noch nichts zu hoeren."})]}):P.jsx("div",{className:"sound-grid",children:lr.map((he,X)=>{var hn;const et=he.relativePath??he.fileName,en=!!be[et],sn=ne===he.name,Tn=he.isRecent||((hn=he.badges)==null?void 0:hn.includes("new")),Rn=he.name.charAt(0).toUpperCase(),xi=Wi.has(X),K=he.folder&&Er[he.folder]||"var(--accent)";return P.jsxs("div",{className:`sound-card ${sn?"playing":""} ${xi?"has-initial":""}`,style:{animationDelay:`${Math.min(X*20,400)}ms`},onClick:Zt=>{const gr=Zt.currentTarget,ui=gr.getBoundingClientRect(),vr=document.createElement("div");vr.className="ripple";const Ps=Math.max(ui.width,ui.height);vr.style.width=vr.style.height=Ps+"px",vr.style.left=Zt.clientX-ui.left-Ps/2+"px",vr.style.top=Zt.clientY-ui.top-Ps/2+"px",gr.appendChild(vr),setTimeout(()=>vr.remove(),500),Je(he)},onContextMenu:Zt=>{Zt.preventDefault(),Zt.stopPropagation(),In({x:Math.min(Zt.clientX,window.innerWidth-170),y:Math.min(Zt.clientY,window.innerHeight-140),sound:he})},title:`${he.name}${he.folder?` (${he.folder})`:""}`,children:[Tn&&P.jsx("span",{className:"new-badge",children:"NEU"}),P.jsx("span",{className:`fav-star ${en?"active":""}`,onClick:Zt=>{Zt.stopPropagation(),Fn(et)},children:P.jsx("span",{className:"material-icons fav-icon",children:en?"star":"star_border"})}),xi&&P.jsx("span",{className:"sound-emoji",style:{color:K},children:Rn}),P.jsx("span",{className:"sound-name",children:he.name}),he.folder&&P.jsx("span",{className:"sound-duration",children:he.folder}),P.jsxs("div",{className:"playing-indicator",children:[P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"}),P.jsx("div",{className:"wave-bar"})]})]},et)})})}),Jt&&P.jsxs("div",{className:"ctx-menu visible",style:{left:Jt.x,top:Jt.y},onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"ctx-item",onClick:()=>{Je(Jt.sound),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"play_arrow"}),"Abspielen"]}),P.jsxs("div",{className:"ctx-item",onClick:()=>{Fn(Jt.sound.relativePath??Jt.sound.fileName),In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:be[Jt.sound.relativePath??Jt.sound.fileName]?"star":"star_border"}),"Favorit"]}),Ut&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"ctx-sep"}),P.jsxs("div",{className:"ctx-item danger",onClick:async()=>{const he=Jt.sound.relativePath??Jt.sound.fileName;if(!window.confirm(`Sound "${Jt.sound.name}" loeschen?`)){In(null);return}try{await GAe([he]),ot("Sound geloescht"),Bt(X=>X+1)}catch(X){ot((X==null?void 0:X.message)||"Loeschen fehlgeschlagen","error")}In(null)},children:[P.jsx("span",{className:"material-icons ctx-icon",children:"delete"}),"Loeschen"]})]})]}),Le&&(()=>{const he=We!=null&&We.connectedSince?Math.floor((Date.now()-new Date(We.connectedSince).getTime())/1e3):0,X=Math.floor(he/3600),et=Math.floor(he%3600/60),en=he%60,sn=X>0?`${X}h ${String(et).padStart(2,"0")}m ${String(en).padStart(2,"0")}s`:et>0?`${et}m ${String(en).padStart(2,"0")}s`:`${en}s`,Tn=Rn=>Rn==null?"var(--muted)":Rn<80?"var(--green)":Rn<150?"#f0a830":"#e04040";return P.jsx("div",{className:"conn-modal-overlay",onClick:()=>ct(!1),children:P.jsxs("div",{className:"conn-modal",onClick:Rn=>Rn.stopPropagation(),children:[P.jsxs("div",{className:"conn-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20,color:"var(--green)"},children:"cell_tower"}),P.jsx("span",{children:"Verbindungsdetails"}),P.jsx("button",{className:"conn-modal-close",onClick:()=>ct(!1),children:P.jsx("span",{className:"material-icons",children:"close"})})]}),P.jsxs("div",{className:"conn-modal-body",children:[P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Voice Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((We==null?void 0:We.voicePing)??null)}}),(We==null?void 0:We.voicePing)!=null?`${We.voicePing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Gateway Ping"}),P.jsxs("span",{className:"conn-stat-value",children:[P.jsx("span",{className:"conn-ping-dot",style:{background:Tn((We==null?void 0:We.gatewayPing)??null)}}),We&&We.gatewayPing>=0?`${We.gatewayPing} ms`:"---"]})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Status"}),P.jsx("span",{className:"conn-stat-value",style:{color:(We==null?void 0:We.status)==="ready"?"var(--green)":"#f0a830"},children:(We==null?void 0:We.status)==="ready"?"Verbunden":(We==null?void 0:We.status)??"Warte auf Verbindung"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Kanal"}),P.jsx("span",{className:"conn-stat-value",children:(We==null?void 0:We.channelName)||"---"})]}),P.jsxs("div",{className:"conn-stat",children:[P.jsx("span",{className:"conn-stat-label",children:"Verbunden seit"}),P.jsx("span",{className:"conn-stat-value",children:sn||"---"})]})]})]})})})(),Dt&&P.jsxs("div",{className:`toast ${Dt.type}`,children:[P.jsx("span",{className:"material-icons toast-icon",children:Dt.type==="error"?"error_outline":"check_circle"}),Dt.msg]}),Ke&&P.jsx("div",{className:"drop-overlay",children:P.jsxs("div",{className:"drop-zone",children:[P.jsx("span",{className:"material-icons drop-icon",children:"cloud_upload"}),P.jsx("div",{className:"drop-title",children:"MP3 & WAV hier ablegen"}),P.jsx("div",{className:"drop-sub",children:"Mehrere Dateien gleichzeitig moeglich"})]})}),_t&&fe.length>0&&P.jsxs("div",{className:"upload-queue",children:[P.jsxs("div",{className:"uq-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),P.jsx("span",{children:fe.every(he=>he.status==="done"||he.status==="error")?`${fe.filter(he=>he.status==="done").length} von ${fe.length} hochgeladen`:`Lade hoch… (${fe.filter(he=>he.status==="done").length}/${fe.length})`}),P.jsx("button",{className:"uq-close",onClick:()=>{Gt(!1),$t([])},children:P.jsx("span",{className:"material-icons",style:{fontSize:14},children:"close"})})]}),P.jsx("div",{className:"uq-list",children:fe.map(he=>P.jsxs("div",{className:`uq-item uq-${he.status}`,children:[P.jsx("span",{className:"material-icons uq-file-icon",children:"audio_file"}),P.jsxs("div",{className:"uq-info",children:[P.jsx("div",{className:"uq-name",title:he.savedName??he.file.name,children:he.savedName??he.file.name}),P.jsxs("div",{className:"uq-size",children:[(he.file.size/1024).toFixed(0)," KB"]})]}),(he.status==="waiting"||he.status==="uploading")&&P.jsx("div",{className:"uq-progress-wrap",children:P.jsx("div",{className:"uq-progress-bar",style:{width:`${he.progress}%`}})}),P.jsx("span",{className:`material-icons uq-status-icon uq-status-${he.status}`,children:he.status==="done"?"check_circle":he.status==="error"?"error":he.status==="uploading"?"sync":"schedule"}),he.status==="error"&&P.jsx("div",{className:"uq-error",children:he.error})]},he.id))})]}),Ht.length>0&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>Ue==="naming"&&te(),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:"upload_file"}),P.jsxs("span",{children:[Ue==="naming"?"Sound benennen":Ue==="uploading"?"Wird hochgeladen...":"Gespeichert!",Ht.length>1&&` (${Ae+1}/${Ht.length})`]}),Ue==="naming"&&P.jsx("button",{className:"dl-modal-close",onClick:te,children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:"dl-modal-tag mp3",children:"Datei"}),P.jsx("span",{className:"dl-modal-url-text",title:(qe=Ht[Ae])==null?void 0:qe.name,children:(qt=Ht[Ae])==null?void 0:qt.name}),P.jsxs("span",{style:{marginLeft:"auto",opacity:.5,fontSize:12},children:[((((Qt=Ht[Ae])==null?void 0:Qt.size)??0)/1024).toFixed(0)," KB"]})]}),Ue==="naming"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:"Dateiname eingeben...",value:xe,onChange:he=>Oe(he.target.value),onKeyDown:he=>{he.key==="Enter"&&A()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]})]}),Ue==="uploading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsxs("span",{children:["Upload: ",we,"%"]})]}),Ue==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsx("span",{children:"Erfolgreich hochgeladen!"})]})]}),Ue==="naming"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:te,children:Ht.length>1?"Überspringen":"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void A(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"upload"}),"Hochladen"]})]})]})}),z&&P.jsx("div",{className:"dl-modal-overlay",onClick:()=>z.phase!=="downloading"&&G(null),children:P.jsxs("div",{className:"dl-modal",onClick:he=>he.stopPropagation(),children:[P.jsxs("div",{className:"dl-modal-header",children:[P.jsx("span",{className:"material-icons",style:{fontSize:20},children:z.type==="youtube"?"smart_display":z.type==="instagram"?"photo_camera":"audio_file"}),P.jsx("span",{children:z.phase==="input"?"Sound herunterladen":z.phase==="downloading"?"Wird heruntergeladen...":z.phase==="done"?"Fertig!":"Fehler"}),z.phase!=="downloading"&&P.jsx("button",{className:"dl-modal-close",onClick:()=>G(null),children:P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"close"})})]}),P.jsxs("div",{className:"dl-modal-body",children:[P.jsxs("div",{className:"dl-modal-url",children:[P.jsx("span",{className:`dl-modal-tag ${z.type??""}`,children:z.type==="youtube"?"YouTube":z.type==="instagram"?"Instagram":"MP3"}),P.jsx("span",{className:"dl-modal-url-text",title:z.url,children:z.url.length>60?z.url.slice(0,57)+"...":z.url})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-field",children:[P.jsx("label",{className:"dl-modal-label",children:"Dateiname"}),P.jsxs("div",{className:"dl-modal-input-wrap",children:[P.jsx("input",{className:"dl-modal-input",type:"text",placeholder:z.type==="mp3"?"Dateiname...":"Wird automatisch erkannt...",value:z.filename,onChange:he=>G(X=>X?{...X,filename:he.target.value}:null),onKeyDown:he=>{he.key==="Enter"&&Vt()},autoFocus:!0}),P.jsx("span",{className:"dl-modal-ext",children:".mp3"})]}),P.jsx("span",{className:"dl-modal-hint",children:"Leer lassen = automatischer Name"})]}),z.phase==="downloading"&&P.jsxs("div",{className:"dl-modal-progress",children:[P.jsx("div",{className:"dl-modal-spinner"}),P.jsx("span",{children:z.type==="youtube"||z.type==="instagram"?"Audio wird extrahiert...":"MP3 wird heruntergeladen..."})]}),z.phase==="done"&&P.jsxs("div",{className:"dl-modal-success",children:[P.jsx("span",{className:"material-icons dl-modal-check",children:"check_circle"}),P.jsxs("span",{children:["Gespeichert als ",P.jsx("b",{children:z.savedName})]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-error",children:[P.jsx("span",{className:"material-icons",style:{color:"#e74c3c"},children:"error"}),P.jsx("span",{children:z.error})]})]}),z.phase==="input"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Abbrechen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>void Vt(),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"download"}),"Herunterladen"]})]}),z.phase==="error"&&P.jsxs("div",{className:"dl-modal-actions",children:[P.jsx("button",{className:"dl-modal-cancel",onClick:()=>G(null),children:"Schliessen"}),P.jsxs("button",{className:"dl-modal-submit",onClick:()=>G(he=>he?{...he,phase:"input",error:void 0}:null),children:[P.jsx("span",{className:"material-icons",style:{fontSize:16},children:"refresh"}),"Nochmal"]})]})]})})]})}const _7={IRON:"#6b6b6b",BRONZE:"#8c6239",SILVER:"#8c8c8c",GOLD:"#d4a017",PLATINUM:"#28b29e",EMERALD:"#1e9e5e",DIAMOND:"#576cce",MASTER:"#9d48e0",GRANDMASTER:"#e44c3e",CHALLENGER:"#f4c874"},HAe={SOLORANKED:"Ranked Solo",FLEXRANKED:"Ranked Flex",NORMAL:"Normal",ARAM:"ARAM",ARENA:"Arena",URF:"URF",BOT:"Co-op vs AI"},WAe="https://ddragon.leagueoflegends.com/cdn/15.5.1/img";function mm(i){return`${WAe}/champion/${i}.png`}function y7(i){const e=Math.floor((Date.now()-new Date(i).getTime())/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function $Ae(i){const e=Math.floor(i/60),t=i%60;return`${e}:${String(t).padStart(2,"0")}`}function x7(i,e,t){return e===0?"Perfect":((i+t)/e).toFixed(2)}function b7(i,e){const t=i+e;return t>0?Math.round(i/t*100):0}function XAe(i,e){if(!i)return"Unranked";const t=["","I","II","III","IV"];return`${i.charAt(0)}${i.slice(1).toLowerCase()}${e?" "+(t[e]??e):""}`}function YAe({data:i}){var yt,Ht,pt,Ae;const[e,t]=se.useState(""),[n,r]=se.useState("EUW"),[s,a]=se.useState([]),[l,u]=se.useState(null),[h,m]=se.useState([]),[v,x]=se.useState(!1),[S,T]=se.useState(null),[N,C]=se.useState([]),[E,O]=se.useState(null),[U,I]=se.useState({}),[j,z]=se.useState(!1),[G,H]=se.useState(!1),[q,V]=se.useState(null),[Q,J]=se.useState("aram"),[ie,le]=se.useState("EUW"),[re,Z]=se.useState([]),[ne,de]=se.useState(!1),[be,Te]=se.useState(null),[ae,Me]=se.useState([]),[Ve,Ce]=se.useState(""),[Fe,tt]=se.useState(!1),je=se.useRef(null),Rt=se.useRef(null);se.useEffect(()=>{fetch("/api/lolstats/regions").then(k=>k.json()).then(a).catch(()=>{}),fetch("/api/lolstats/recent").then(k=>k.json()).then(C).catch(()=>{}),fetch("/api/lolstats/modes").then(k=>k.json()).then(Me).catch(()=>{})},[]),se.useEffect(()=>{Q&&(de(!0),Te(null),tt(!1),fetch(`/api/lolstats/tierlist?mode=${Q}®ion=${ie}`).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>Z(k.champions??[])).catch(k=>Te(k.message)).finally(()=>de(!1)))},[Q,ie]),se.useEffect(()=>{i&&(i.recentSearches&&C(i.recentSearches),i.regions&&!s.length&&a(i.regions))},[i]);const Et=se.useCallback(async(k,xe,Oe)=>{H(!0);try{const Ue=`gameName=${encodeURIComponent(k)}&tagLine=${encodeURIComponent(xe)}®ion=${Oe}`,ee=await fetch(`/api/lolstats/renew?${Ue}`,{method:"POST"});if(ee.ok){const we=await ee.json();return we.last_updated_at&&V(we.last_updated_at),we.renewed??!1}}catch{}return H(!1),!1},[]),Ft=se.useCallback(async(k,xe,Oe,Ue=!1)=>{var We,Se;let ee=k??"",we=xe??"";const Re=Oe??n;if(!ee){const Le=e.split("#");ee=((We=Le[0])==null?void 0:We.trim())??"",we=((Se=Le[1])==null?void 0:Se.trim())??""}if(!ee||!we){T("Bitte im Format Name#Tag eingeben");return}x(!0),T(null),u(null),m([]),O(null),I({}),Rt.current={gameName:ee,tagLine:we,region:Re},Ue||Et(ee,we,Re).finally(()=>H(!1));try{const Le=`gameName=${encodeURIComponent(ee)}&tagLine=${encodeURIComponent(we)}®ion=${Re}`,[ct,Dt]=await Promise.all([fetch(`/api/lolstats/profile?${Le}`),fetch(`/api/lolstats/matches?${Le}&limit=10`)]);if(!ct.ok){const lt=await ct.json();throw new Error(lt.error??`Fehler ${ct.status}`)}const It=await ct.json();if(u(It),It.updated_at&&V(It.updated_at),Dt.ok){const lt=await Dt.json();m(Array.isArray(lt)?lt:[])}}catch(Le){T(Le.message)}x(!1)},[e,n,Et]),Ut=se.useCallback(async()=>{const k=Rt.current;if(!(!k||G)){H(!0);try{await Et(k.gameName,k.tagLine,k.region),await new Promise(xe=>setTimeout(xe,1500)),await Ft(k.gameName,k.tagLine,k.region,!0)}finally{H(!1)}}},[Et,Ft,G]),Ke=se.useCallback(async()=>{if(!(!l||j)){z(!0);try{const k=`gameName=${encodeURIComponent(l.game_name)}&tagLine=${encodeURIComponent(l.tagline)}®ion=${n}&limit=20`,xe=await fetch(`/api/lolstats/matches?${k}`);if(xe.ok){const Oe=await xe.json();m(Array.isArray(Oe)?Oe:[])}}catch{}z(!1)}},[l,n,j]),ht=se.useCallback(async k=>{var xe;if(E===k.id){O(null);return}if(O(k.id),!(((xe=k.participants)==null?void 0:xe.length)>=10||U[k.id]))try{const Oe=`region=${n}&createdAt=${encodeURIComponent(k.created_at)}`,Ue=await fetch(`/api/lolstats/match/${encodeURIComponent(k.id)}?${Oe}`);if(Ue.ok){const ee=await Ue.json();I(we=>({...we,[k.id]:ee}))}}catch{}},[E,U,n]),fe=se.useCallback(k=>{t(`${k.game_name}#${k.tag_line}`),r(k.region),Ft(k.game_name,k.tag_line,k.region)},[Ft]),$t=se.useCallback(k=>{var Oe,Ue,ee;if(!l)return((Oe=k.participants)==null?void 0:Oe[0])??null;const xe=l.game_name.toLowerCase();return((Ue=k.participants)==null?void 0:Ue.find(we=>{var Re,We;return((We=(Re=we.summoner)==null?void 0:Re.game_name)==null?void 0:We.toLowerCase())===xe}))??((ee=k.participants)==null?void 0:ee[0])??null},[l]),_t=k=>{var Se,Le,ct;const xe=$t(k);if(!xe)return null;const Oe=((Se=xe.stats)==null?void 0:Se.result)==="WIN",Ue=x7(xe.stats.kill,xe.stats.death,xe.stats.assist),ee=(xe.stats.minion_kill??0)+(xe.stats.neutral_minion_kill??0),we=k.game_length_second>0?(ee/(k.game_length_second/60)).toFixed(1):"0",Re=E===k.id,We=U[k.id]??(((Le=k.participants)==null?void 0:Le.length)>=10?k:null);return P.jsxs("div",{children:[P.jsxs("div",{className:`lol-match ${Oe?"win":"loss"}`,onClick:()=>ht(k),children:[P.jsx("div",{className:"lol-match-result",children:Oe?"W":"L"}),P.jsxs("div",{className:"lol-match-champ",children:[P.jsx("img",{src:mm(xe.champion_name),alt:xe.champion_name,title:xe.champion_name}),P.jsx("span",{className:"lol-match-champ-level",children:xe.stats.champion_level})]}),P.jsxs("div",{className:"lol-match-kda",children:[P.jsxs("div",{className:"lol-match-kda-nums",children:[xe.stats.kill,"/",xe.stats.death,"/",xe.stats.assist]}),P.jsxs("div",{className:`lol-match-kda-ratio ${Ue==="Perfect"?"perfect":Number(Ue)>=4?"great":""}`,children:[Ue," KDA"]})]}),P.jsxs("div",{className:"lol-match-stats",children:[P.jsxs("span",{children:[ee," CS (",we,"/m)"]}),P.jsxs("span",{children:[xe.stats.ward_place," wards"]})]}),P.jsx("div",{className:"lol-match-items",children:(xe.items_names??[]).slice(0,7).map((Dt,It)=>Dt?P.jsx("img",{src:mm("Aatrox"),alt:Dt,title:Dt,style:{background:"var(--bg-deep)"},onError:lt=>{lt.target.style.display="none"}},It):P.jsx("div",{className:"lol-match-item-empty"},It))}),P.jsxs("div",{className:"lol-match-meta",children:[P.jsx("div",{className:"lol-match-duration",children:$Ae(k.game_length_second)}),P.jsx("div",{className:"lol-match-queue",children:HAe[k.game_type]??k.game_type}),P.jsxs("div",{className:"lol-match-ago",children:[y7(k.created_at)," ago"]})]})]}),Re&&We&&P.jsx("div",{className:"lol-match-detail",children:Gt(We,(ct=xe.summoner)==null?void 0:ct.game_name)})]},k.id)},Gt=(k,xe)=>{var Re,We,Se,Le,ct;const Oe=((Re=k.participants)==null?void 0:Re.filter(Dt=>Dt.team_key==="BLUE"))??[],Ue=((We=k.participants)==null?void 0:We.filter(Dt=>Dt.team_key==="RED"))??[],ee=(ct=(Le=(Se=k.teams)==null?void 0:Se.find(Dt=>Dt.key==="BLUE"))==null?void 0:Le.game_stat)==null?void 0:ct.is_win,we=(Dt,It,lt)=>P.jsxs("div",{className:"lol-match-detail-team",children:[P.jsxs("div",{className:`lol-match-detail-team-header ${It?"win":"loss"}`,children:[lt," — ",It?"Victory":"Defeat"]}),Dt.map((jt,Jt)=>{var Bt,ot,Tt,Wt,Yt,pn,$e,St,Kt,wn,qn,Je;const In=((ot=(Bt=jt.summoner)==null?void 0:Bt.game_name)==null?void 0:ot.toLowerCase())===(xe==null?void 0:xe.toLowerCase()),me=(((Tt=jt.stats)==null?void 0:Tt.minion_kill)??0)+(((Wt=jt.stats)==null?void 0:Wt.neutral_minion_kill)??0);return P.jsxs("div",{className:`lol-detail-row ${In?"me":""}`,children:[P.jsx("img",{className:"lol-detail-champ",src:mm(jt.champion_name),alt:jt.champion_name}),P.jsx("span",{className:"lol-detail-name",title:`${(Yt=jt.summoner)==null?void 0:Yt.game_name}#${(pn=jt.summoner)==null?void 0:pn.tagline}`,children:(($e=jt.summoner)==null?void 0:$e.game_name)??jt.champion_name}),P.jsxs("span",{className:"lol-detail-kda",children:[(St=jt.stats)==null?void 0:St.kill,"/",(Kt=jt.stats)==null?void 0:Kt.death,"/",(wn=jt.stats)==null?void 0:wn.assist]}),P.jsxs("span",{className:"lol-detail-cs",children:[me," CS"]}),P.jsxs("span",{className:"lol-detail-dmg",children:[((((qn=jt.stats)==null?void 0:qn.total_damage_dealt_to_champions)??0)/1e3).toFixed(1),"k"]}),P.jsxs("span",{className:"lol-detail-gold",children:[((((Je=jt.stats)==null?void 0:Je.gold_earned)??0)/1e3).toFixed(1),"k"]})]},Jt)})]});return P.jsxs(P.Fragment,{children:[we(Oe,ee,"Blue Team"),we(Ue,ee===void 0?void 0:!ee,"Red Team")]})};return P.jsxs("div",{className:"lol-container",children:[P.jsxs("div",{className:"lol-search",children:[P.jsx("input",{ref:je,className:"lol-search-input",placeholder:"Summoner Name#Tag",value:e,onChange:k=>t(k.target.value),onKeyDown:k=>k.key==="Enter"&&Ft()}),P.jsx("select",{className:"lol-search-region",value:n,onChange:k=>r(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("button",{className:"lol-search-btn",onClick:()=>Ft(),disabled:v,children:v?"...":"Search"})]}),N.length>0&&P.jsx("div",{className:"lol-recent",children:N.map((k,xe)=>P.jsxs("button",{className:"lol-recent-chip",onClick:()=>fe(k),children:[k.profile_image_url&&P.jsx("img",{src:k.profile_image_url,alt:""}),k.game_name,"#",k.tag_line,k.tier&&P.jsx("span",{className:"lol-recent-tier",style:{color:_7[k.tier]},children:k.tier})]},xe))}),S&&P.jsx("div",{className:"lol-error",children:S}),v&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Profil..."]}),l&&!v&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-profile",children:[P.jsx("img",{className:"lol-profile-icon",src:l.profile_image_url,alt:""}),P.jsxs("div",{className:"lol-profile-info",children:[P.jsxs("h2",{children:[l.game_name,P.jsxs("span",{children:["#",l.tagline]})]}),P.jsxs("div",{className:"lol-profile-level",children:["Level ",l.level]}),((yt=l.ladder_rank)==null?void 0:yt.rank)&&P.jsxs("div",{className:"lol-profile-ladder",children:["Ladder Rank #",l.ladder_rank.rank.toLocaleString()," / ",(Ht=l.ladder_rank.total)==null?void 0:Ht.toLocaleString()]}),q&&P.jsxs("div",{className:"lol-profile-updated",children:["Updated ",y7(q)," ago"]})]}),P.jsxs("button",{className:`lol-update-btn ${G?"renewing":""}`,onClick:Ut,disabled:G,title:"Refresh data from Riot servers",children:[P.jsx("span",{className:"lol-update-icon",children:G?"⟳":"↻"}),G?"Updating...":"Update"]})]}),P.jsx("div",{className:"lol-ranked-row",children:(l.league_stats??[]).filter(k=>k.game_type==="SOLORANKED"||k.game_type==="FLEXRANKED").map(k=>{const xe=k.tier_info,Oe=!!(xe!=null&&xe.tier),Ue=_7[(xe==null?void 0:xe.tier)??""]??"var(--text-normal)";return P.jsxs("div",{className:`lol-ranked-card ${Oe?"has-rank":""}`,style:{"--tier-color":Ue},children:[P.jsx("div",{className:"lol-ranked-type",children:k.game_type==="SOLORANKED"?"Ranked Solo/Duo":"Ranked Flex"}),Oe?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-ranked-tier",style:{color:Ue},children:[XAe(xe.tier,xe.division),P.jsxs("span",{className:"lol-ranked-lp",children:[xe.lp," LP"]})]}),P.jsxs("div",{className:"lol-ranked-record",children:[k.win,"W ",k.lose,"L",P.jsxs("span",{className:"lol-ranked-wr",children:["(",b7(k.win??0,k.lose??0),"%)"]}),k.is_hot_streak&&P.jsx("span",{className:"lol-ranked-streak",children:"🔥"})]})]}):P.jsx("div",{className:"lol-ranked-tier",children:"Unranked"})]},k.game_type)})}),((Ae=(pt=l.most_champions)==null?void 0:pt.champion_stats)==null?void 0:Ae.length)>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Top Champions"}),P.jsx("div",{className:"lol-champs",children:l.most_champions.champion_stats.slice(0,7).map(k=>{const xe=b7(k.win,k.lose),Oe=k.play>0?x7(k.kill/k.play,k.death/k.play,k.assist/k.play):"0";return P.jsxs("div",{className:"lol-champ-card",children:[P.jsx("img",{className:"lol-champ-icon",src:mm(k.champion_name),alt:k.champion_name}),P.jsxs("div",{children:[P.jsx("div",{className:"lol-champ-name",children:k.champion_name}),P.jsxs("div",{className:"lol-champ-stats",children:[k.play," games · ",xe,"% WR"]}),P.jsxs("div",{className:"lol-champ-kda",children:[Oe," KDA"]})]})]},k.champion_name)})})]}),h.length>0&&P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"lol-section-title",children:"Match History"}),P.jsx("div",{className:"lol-matches",children:h.map(k=>_t(k))}),h.length<20&&P.jsx("button",{className:"lol-load-more",onClick:Ke,disabled:j,children:j?"Laden...":"Mehr laden"})]})]}),!l&&!v&&!S&&P.jsxs("div",{className:"lol-empty",children:[P.jsx("div",{className:"lol-empty-icon",children:"⚔️"}),P.jsx("h3",{children:"League of Legends Stats"}),P.jsx("p",{children:"Gib einen Summoner Name#Tag ein und wähle die Region"})]}),P.jsxs("div",{className:"lol-tier-section",children:[P.jsx("div",{className:"lol-section-title",children:"Champion Tier List"}),P.jsxs("div",{className:"lol-tier-controls",children:[P.jsx("div",{className:"lol-tier-modes",children:ae.map(k=>P.jsx("button",{className:`lol-tier-mode-btn ${Q===k.key?"active":""}`,onClick:()=>J(k.key),children:k.label},k.key))}),P.jsx("select",{className:"lol-search-region",value:ie,onChange:k=>le(k.target.value),children:s.map(k=>P.jsx("option",{value:k.code,children:k.code},k.code))}),P.jsx("input",{className:"lol-tier-filter",placeholder:"Filter champion...",value:Ve,onChange:k=>Ce(k.target.value)})]}),ne&&P.jsxs("div",{className:"lol-loading",children:[P.jsx("div",{className:"lol-spinner"}),"Lade Tier List..."]}),be&&P.jsx("div",{className:"lol-error",children:be}),!ne&&!be&&re.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"lol-tier-table",children:[P.jsxs("div",{className:"lol-tier-header",children:[P.jsx("span",{className:"lol-tier-col-rank",children:"#"}),P.jsx("span",{className:"lol-tier-col-champ",children:"Champion"}),P.jsx("span",{className:"lol-tier-col-tier",children:"Tier"}),P.jsx("span",{className:"lol-tier-col-wr",children:Q==="arena"?"Win":"Win %"}),P.jsx("span",{className:"lol-tier-col-pr",children:"Pick %"}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:"Ban %"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?"Avg Place":"KDA"})]}),re.filter(k=>!Ve||k.champion_name.toLowerCase().includes(Ve.toLowerCase())).slice(0,Fe?void 0:50).map(k=>{var Oe,Ue;const xe=["OP","1","2","3","4","5"];return P.jsxs("div",{className:`lol-tier-row tier-${k.tier}`,children:[P.jsx("span",{className:"lol-tier-col-rank",children:k.rank}),P.jsxs("span",{className:"lol-tier-col-champ",children:[P.jsx("img",{src:mm(k.champion_name),alt:k.champion_name}),k.champion_name]}),P.jsx("span",{className:`lol-tier-col-tier tier-badge-${k.tier}`,children:xe[k.tier]??k.tier}),P.jsx("span",{className:"lol-tier-col-wr",children:k.win_rate!=null?`${(k.win_rate*100).toFixed(1)}%`:"-"}),P.jsxs("span",{className:"lol-tier-col-pr",children:[(k.pick_rate*100).toFixed(1),"%"]}),Q!=="arena"&&P.jsx("span",{className:"lol-tier-col-br",children:k.ban_rate!=null?`${(k.ban_rate*100).toFixed(1)}%`:"-"}),P.jsx("span",{className:"lol-tier-col-kda",children:Q==="arena"?((Oe=k.average_placement)==null?void 0:Oe.toFixed(1))??"-":((Ue=k.kda)==null?void 0:Ue.toFixed(2))??"-"})]},k.champion_id)})]}),!Fe&&re.length>50&&P.jsxs("button",{className:"lol-load-more",onClick:()=>tt(!0),children:["Alle ",re.length," Champions anzeigen"]})]})]})]})}const S7={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function VS(i){const e=Math.max(0,Math.floor((Date.now()-new Date(i).getTime())/1e3)),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}const jS=[{label:"Niedrig · 4 Mbit · 60fps",fps:60,bitrate:4e6},{label:"Mittel · 8 Mbit · 60fps",fps:60,bitrate:8e6},{label:"Hoch · 14 Mbit · 60fps",fps:60,bitrate:14e6},{label:"Ultra · 25 Mbit · 60fps",fps:60,bitrate:25e6},{label:"Max · 50 Mbit · 165fps",fps:165,bitrate:5e7}];function QAe({data:i,isAdmin:e}){var Re,We;const[t,n]=se.useState([]),[r,s]=se.useState(()=>localStorage.getItem("streaming_name")||""),[a,l]=se.useState("Screen Share"),[u,h]=se.useState(""),[m,v]=se.useState(1),[x,S]=se.useState(null),[T,N]=se.useState(null),[C,E]=se.useState(null),[O,U]=se.useState(!1),[I,j]=se.useState(!1),[z,G]=se.useState(null),[,H]=se.useState(0),[q,V]=se.useState(null),[Q,J]=se.useState(null),ie=se.useRef(null),le=se.useRef(""),re=se.useRef(null),Z=se.useRef(null),ne=se.useRef(null),de=se.useRef(new Map),be=se.useRef(null),Te=se.useRef(null),ae=se.useRef(new Map),Me=se.useRef(null),Ve=se.useRef(1e3),Ce=se.useRef(!1),Fe=se.useRef(null),tt=se.useRef(jS[1]);se.useEffect(()=>{Ce.current=O},[O]),se.useEffect(()=>{Fe.current=z},[z]),se.useEffect(()=>{tt.current=jS[m]},[m]),se.useEffect(()=>{var Se,Le;(Le=(Se=window.electronAPI)==null?void 0:Se.setStreaming)==null||Le.call(Se,O||z!==null)},[O,z]),se.useEffect(()=>{if(!(t.length>0||O))return;const Le=setInterval(()=>H(ct=>ct+1),1e3);return()=>clearInterval(Le)},[t.length,O]),se.useEffect(()=>{i!=null&&i.streams&&n(i.streams)},[i]),se.useEffect(()=>{r&&localStorage.setItem("streaming_name",r)},[r]),se.useEffect(()=>{if(!q)return;const Se=()=>V(null);return document.addEventListener("click",Se),()=>document.removeEventListener("click",Se)},[q]);const je=se.useCallback(Se=>{var Le;((Le=ie.current)==null?void 0:Le.readyState)===WebSocket.OPEN&&ie.current.send(JSON.stringify(Se))},[]),Rt=se.useCallback((Se,Le,ct)=>{if(Se.remoteDescription)Se.addIceCandidate(new RTCIceCandidate(ct)).catch(()=>{});else{let Dt=ae.current.get(Le);Dt||(Dt=[],ae.current.set(Le,Dt)),Dt.push(ct)}},[]),Et=se.useCallback((Se,Le)=>{const ct=ae.current.get(Le);if(ct){for(const Dt of ct)Se.addIceCandidate(new RTCIceCandidate(Dt)).catch(()=>{});ae.current.delete(Le)}},[]),Ft=se.useCallback((Se,Le)=>{Se.srcObject=Le;const ct=Se.play();ct&&ct.catch(()=>{Se.muted=!0,Se.play().catch(()=>{})})},[]),Ut=se.useCallback(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),be.current&&(be.current.close(),be.current=null),Te.current=null,ne.current&&(ne.current.srcObject=null)},[]),Ke=se.useRef(()=>{});Ke.current=Se=>{var Le,ct,Dt;switch(Se.type){case"welcome":le.current=Se.clientId,Se.streams&&n(Se.streams);break;case"broadcast_started":E(Se.streamId),U(!0),Ce.current=!0,j(!1),(Le=window.electronAPI)!=null&&Le.showNotification&&window.electronAPI.showNotification("Stream gestartet","Dein Stream ist jetzt live!");break;case"stream_available":n(lt=>lt.some(jt=>jt.id===Se.streamId)?lt:[...lt,{id:Se.streamId,broadcasterName:Se.broadcasterName,title:Se.title,startedAt:new Date().toISOString(),viewerCount:0,hasPassword:!!Se.hasPassword}]);const It=`${Se.broadcasterName} streamt: ${Se.title}`;(ct=window.electronAPI)!=null&&ct.showNotification?window.electronAPI.showNotification("Neuer Stream",It):Notification.permission==="granted"&&new Notification("Neuer Stream",{body:It,icon:"/assets/icon.png"});break;case"stream_ended":n(lt=>lt.filter(jt=>jt.id!==Se.streamId)),((Dt=Fe.current)==null?void 0:Dt.streamId)===Se.streamId&&(Ut(),G(null));break;case"viewer_joined":{const lt=Se.viewerId,jt=de.current.get(lt);jt&&(jt.close(),de.current.delete(lt)),ae.current.delete(lt);const Jt=new RTCPeerConnection(S7);de.current.set(lt,Jt);const In=re.current;if(In)for(const Bt of In.getTracks())Jt.addTrack(Bt,In);Jt.onicecandidate=Bt=>{Bt.candidate&&je({type:"ice_candidate",targetId:lt,candidate:Bt.candidate.toJSON()})};const me=Jt.getSenders().find(Bt=>{var ot;return((ot=Bt.track)==null?void 0:ot.kind)==="video"});if(me){const Bt=me.getParameters();(!Bt.encodings||Bt.encodings.length===0)&&(Bt.encodings=[{}]),Bt.encodings[0].maxFramerate=tt.current.fps,Bt.encodings[0].maxBitrate=tt.current.bitrate,me.setParameters(Bt).catch(()=>{})}Jt.createOffer().then(Bt=>Jt.setLocalDescription(Bt)).then(()=>je({type:"offer",targetId:lt,sdp:Jt.localDescription})).catch(console.error);break}case"viewer_left":{const lt=de.current.get(Se.viewerId);lt&&(lt.close(),de.current.delete(Se.viewerId)),ae.current.delete(Se.viewerId);break}case"offer":{const lt=Se.fromId;be.current&&(be.current.close(),be.current=null),ae.current.delete(lt);const jt=new RTCPeerConnection(S7);be.current=jt,jt.ontrack=Jt=>{const In=Jt.streams[0];if(!In)return;Te.current=In;const me=ne.current;me&&Ft(me,In),G(Bt=>Bt&&{...Bt,phase:"connected"})},jt.onicecandidate=Jt=>{Jt.candidate&&je({type:"ice_candidate",targetId:lt,candidate:Jt.candidate.toJSON()})},jt.oniceconnectionstatechange=()=>{(jt.iceConnectionState==="failed"||jt.iceConnectionState==="disconnected")&&G(Jt=>Jt&&{...Jt,phase:"error",error:"Verbindung verloren"})},jt.setRemoteDescription(new RTCSessionDescription(Se.sdp)).then(()=>(Et(jt,lt),jt.createAnswer())).then(Jt=>jt.setLocalDescription(Jt)).then(()=>je({type:"answer",targetId:lt,sdp:jt.localDescription})).catch(console.error);break}case"answer":{const lt=de.current.get(Se.fromId);lt&<.setRemoteDescription(new RTCSessionDescription(Se.sdp)).then(()=>Et(lt,Se.fromId)).catch(console.error);break}case"ice_candidate":{if(!Se.candidate)break;const lt=de.current.get(Se.fromId);lt?Rt(lt,Se.fromId,Se.candidate):be.current&&Rt(be.current,Se.fromId,Se.candidate);break}case"error":Se.code==="WRONG_PASSWORD"?N(lt=>lt&&{...lt,error:Se.message}):S(Se.message),j(!1);break}};const ht=se.useCallback(()=>{if(ie.current&&ie.current.readyState===WebSocket.OPEN)return;const Se=location.protocol==="https:"?"wss":"ws",Le=new WebSocket(`${Se}://${location.host}/ws/streaming`);ie.current=Le,Le.onopen=()=>{Ve.current=1e3},Le.onmessage=ct=>{let Dt;try{Dt=JSON.parse(ct.data)}catch{return}Ke.current(Dt)},Le.onclose=()=>{ie.current=null,Me.current=setTimeout(()=>{Ve.current=Math.min(Ve.current*2,1e4),ht()},Ve.current)},Le.onerror=()=>{Le.close()}},[]);se.useEffect(()=>(ht(),()=>{Me.current&&clearTimeout(Me.current)}),[ht]);const fe=se.useCallback(async()=>{var Se,Le;if(!r.trim()){S("Bitte gib einen Namen ein.");return}if(!((Se=navigator.mediaDevices)!=null&&Se.getDisplayMedia)){S("Dein Browser unterstützt keine Bildschirmfreigabe.");return}S(null),j(!0);try{const ct=tt.current,Dt=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:ct.fps}},audio:!0});re.current=Dt,Z.current&&(Z.current.srcObject=Dt),(Le=Dt.getVideoTracks()[0])==null||Le.addEventListener("ended",()=>{$t()}),ht();const It=()=>{var lt;((lt=ie.current)==null?void 0:lt.readyState)===WebSocket.OPEN?je({type:"start_broadcast",name:r.trim(),title:a.trim()||"Screen Share",password:u.trim()||void 0}):setTimeout(It,100)};It()}catch(ct){j(!1),ct.name==="NotAllowedError"?S("Bildschirmfreigabe wurde abgelehnt."):S(`Fehler: ${ct.message}`)}},[r,a,u,ht,je]),$t=se.useCallback(()=>{var Se;je({type:"stop_broadcast"}),(Se=re.current)==null||Se.getTracks().forEach(Le=>Le.stop()),re.current=null,Z.current&&(Z.current.srcObject=null);for(const Le of de.current.values())Le.close();de.current.clear(),U(!1),Ce.current=!1,E(null),h("")},[je]),_t=se.useCallback(Se=>{S(null),G({streamId:Se,phase:"connecting"}),ht();const Le=()=>{var ct;((ct=ie.current)==null?void 0:ct.readyState)===WebSocket.OPEN?je({type:"join_viewer",name:r.trim()||"Viewer",streamId:Se}):setTimeout(Le,100)};Le()},[r,ht,je]),Gt=se.useCallback(Se=>{Se.hasPassword?N({streamId:Se.id,streamTitle:Se.title,broadcasterName:Se.broadcasterName,password:"",error:null}):_t(Se.id)},[_t]),yt=se.useCallback(()=>{if(!T)return;if(!T.password.trim()){N(Dt=>Dt&&{...Dt,error:"Passwort eingeben."});return}const{streamId:Se,password:Le}=T;N(null),S(null),G({streamId:Se,phase:"connecting"}),ht();const ct=()=>{var Dt;((Dt=ie.current)==null?void 0:Dt.readyState)===WebSocket.OPEN?je({type:"join_viewer",name:r.trim()||"Viewer",streamId:Se,password:Le.trim()}):setTimeout(ct,100)};ct()},[T,r,ht,je]),Ht=se.useCallback(()=>{je({type:"leave_viewer"}),Ut(),G(null)},[Ut,je]);se.useEffect(()=>{const Se=ct=>{(Ce.current||Fe.current)&&ct.preventDefault()},Le=()=>{le.current&&navigator.sendBeacon("/api/streaming/disconnect",JSON.stringify({clientId:le.current}))};return window.addEventListener("beforeunload",Se),window.addEventListener("pagehide",Le),()=>{window.removeEventListener("beforeunload",Se),window.removeEventListener("pagehide",Le)}},[]);const pt=se.useRef(null),[Ae,k]=se.useState(!1),xe=se.useCallback(()=>{const Se=pt.current;Se&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):Se.requestFullscreen().catch(()=>{}))},[]);se.useEffect(()=>{const Se=()=>k(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",Se),()=>document.removeEventListener("fullscreenchange",Se)},[]),se.useEffect(()=>()=>{var Se;(Se=re.current)==null||Se.getTracks().forEach(Le=>Le.stop());for(const Le of de.current.values())Le.close();be.current&&be.current.close(),ie.current&&ie.current.close(),Me.current&&clearTimeout(Me.current)},[]),se.useEffect(()=>{z&&Te.current&&ne.current&&!ne.current.srcObject&&Ft(ne.current,Te.current)},[z,Ft]);const Oe=se.useRef(null);se.useEffect(()=>{const Le=new URLSearchParams(location.search).get("viewStream");if(Le){Oe.current=Le;const ct=new URL(location.href);ct.searchParams.delete("viewStream"),window.history.replaceState({},"",ct.toString())}},[]),se.useEffect(()=>{const Se=Oe.current;if(!Se||t.length===0)return;const Le=t.find(ct=>ct.id===Se);Le&&(Oe.current=null,Gt(Le))},[t,Gt]);const Ue=se.useCallback(Se=>{const Le=new URL(location.href);return Le.searchParams.set("viewStream",Se),Le.hash="",Le.toString()},[]),ee=se.useCallback(Se=>{navigator.clipboard.writeText(Ue(Se)).then(()=>{J(Se),setTimeout(()=>J(null),2e3)}).catch(()=>{})},[Ue]),we=se.useCallback(Se=>{window.open(Ue(Se),"_blank","noopener"),V(null)},[Ue]);if(z){const Se=t.find(Le=>Le.id===z.streamId);return P.jsxs("div",{className:"stream-viewer-overlay",ref:pt,children:[P.jsxs("div",{className:"stream-viewer-header",children:[P.jsxs("div",{className:"stream-viewer-header-left",children:[P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("div",{children:[P.jsx("div",{className:"stream-viewer-title",children:(Se==null?void 0:Se.title)||"Stream"}),P.jsxs("div",{className:"stream-viewer-subtitle",children:[(Se==null?void 0:Se.broadcasterName)||"..."," ",Se?` · ${Se.viewerCount} Zuschauer`:""]})]})]}),P.jsxs("div",{className:"stream-viewer-header-right",children:[P.jsx("button",{className:"stream-viewer-fullscreen",onClick:xe,title:Ae?"Vollbild verlassen":"Vollbild",children:Ae?"✖":"⛶"}),P.jsx("button",{className:"stream-viewer-close",onClick:Ht,children:"Verlassen"})]})]}),P.jsxs("div",{className:"stream-viewer-video",children:[z.phase==="connecting"?P.jsxs("div",{className:"stream-viewer-connecting",children:[P.jsx("div",{className:"stream-viewer-spinner"}),"Verbindung wird hergestellt..."]}):z.phase==="error"?P.jsxs("div",{className:"stream-viewer-connecting",children:[z.error||"Verbindungsfehler",P.jsx("button",{className:"stream-btn",onClick:Ht,children:"Zurück"})]}):null,P.jsx("video",{ref:ne,autoPlay:!0,playsInline:!0,style:z.phase==="connected"?{}:{display:"none"}})]})]})}return P.jsxs("div",{className:"stream-container",children:[x&&P.jsxs("div",{className:"stream-error",children:[x,P.jsx("button",{className:"stream-error-dismiss",onClick:()=>S(null),children:"×"})]}),P.jsxs("div",{className:"stream-topbar",children:[P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Name"}),P.jsx("input",{className:"stream-input stream-input-name",placeholder:"Dein Name",value:r,onChange:Se=>s(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field stream-field-grow",children:[P.jsx("span",{className:"stream-field-label",children:"Titel"}),P.jsx("input",{className:"stream-input stream-input-title",placeholder:"Stream-Titel",value:a,onChange:Se=>l(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsx("span",{className:"stream-field-label",children:"Passwort"}),P.jsx("input",{className:"stream-input stream-input-password",type:"password",placeholder:"optional",value:u,onChange:Se=>h(Se.target.value),disabled:O})]}),P.jsxs("label",{className:"stream-field",children:[P.jsxs("span",{className:"stream-field-label",children:["Qualit","ä","t"]}),P.jsx("select",{className:"stream-select-quality",value:m,onChange:Se=>v(Number(Se.target.value)),disabled:O,children:jS.map((Se,Le)=>P.jsx("option",{value:Le,children:Se.label},Se.label))})]}),O?P.jsxs("button",{className:"stream-btn stream-btn-stop",onClick:$t,children:["⏹"," Stream beenden"]}):P.jsx("button",{className:"stream-btn",onClick:fe,disabled:I,children:I?"Starte...":"🖥️ Stream starten"})]}),t.length===0&&!O?P.jsxs("div",{className:"stream-empty",children:[P.jsx("div",{className:"stream-empty-icon",children:"📺"}),P.jsx("h3",{children:"Keine aktiven Streams"}),P.jsx("p",{children:"Starte einen Stream, um deinen Bildschirm zu teilen."})]}):P.jsxs("div",{className:"stream-grid",children:[O&&P.jsxs("div",{className:"stream-tile own broadcasting",children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("video",{ref:Z,autoPlay:!0,playsInline:!0,muted:!0}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",((Re=t.find(Se=>Se.id===C))==null?void 0:Re.viewerCount)??0]})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsxs("div",{className:"stream-tile-name",children:[r," (Du)"]}),P.jsx("div",{className:"stream-tile-title",children:a})]}),P.jsx("span",{className:"stream-tile-time",children:C&&((We=t.find(Se=>Se.id===C))!=null&&We.startedAt)?VS(t.find(Se=>Se.id===C).startedAt):"0:00"})]})]}),t.filter(Se=>Se.id!==C).map(Se=>P.jsxs("div",{className:"stream-tile",onClick:()=>Gt(Se),children:[P.jsxs("div",{className:"stream-tile-preview",children:[P.jsx("span",{className:"stream-tile-icon",children:"🖥️"}),P.jsxs("span",{className:"stream-live-badge",children:[P.jsx("span",{className:"stream-live-dot"})," LIVE"]}),P.jsxs("span",{className:"stream-tile-viewers",children:["👥"," ",Se.viewerCount]}),Se.hasPassword&&P.jsx("span",{className:"stream-tile-lock",children:"🔒"})]}),P.jsxs("div",{className:"stream-tile-info",children:[P.jsxs("div",{className:"stream-tile-meta",children:[P.jsx("div",{className:"stream-tile-name",children:Se.broadcasterName}),P.jsx("div",{className:"stream-tile-title",children:Se.title})]}),P.jsx("span",{className:"stream-tile-time",children:VS(Se.startedAt)}),P.jsxs("div",{className:"stream-tile-menu-wrap",children:[P.jsx("button",{className:"stream-tile-menu",onClick:Le=>{Le.stopPropagation(),V(q===Se.id?null:Se.id)},children:"⋮"}),q===Se.id&&P.jsxs("div",{className:"stream-tile-dropdown",onClick:Le=>Le.stopPropagation(),children:[P.jsxs("div",{className:"stream-tile-dropdown-header",children:[P.jsx("div",{className:"stream-tile-dropdown-name",children:Se.broadcasterName}),P.jsx("div",{className:"stream-tile-dropdown-title",children:Se.title}),P.jsxs("div",{className:"stream-tile-dropdown-detail",children:["👥"," ",Se.viewerCount," Zuschauer · ",VS(Se.startedAt)]})]}),P.jsx("div",{className:"stream-tile-dropdown-divider"}),P.jsxs("button",{className:"stream-tile-dropdown-item",onClick:()=>we(Se.id),children:["🗗"," In neuem Fenster öffnen"]}),P.jsx("button",{className:"stream-tile-dropdown-item",onClick:()=>{ee(Se.id),V(null)},children:Q===Se.id?"✅ Kopiert!":"🔗 Link teilen"})]})]})]})]},Se.id))]}),T&&P.jsx("div",{className:"stream-pw-overlay",onClick:()=>N(null),children:P.jsxs("div",{className:"stream-pw-modal",onClick:Se=>Se.stopPropagation(),children:[P.jsx("h3",{children:T.broadcasterName}),P.jsx("p",{children:T.streamTitle}),T.error&&P.jsx("div",{className:"stream-pw-modal-error",children:T.error}),P.jsx("input",{className:"stream-input",type:"password",placeholder:"Stream-Passwort",value:T.password,onChange:Se=>N(Le=>Le&&{...Le,password:Se.target.value,error:null}),onKeyDown:Se=>{Se.key==="Enter"&&yt()},autoFocus:!0}),P.jsxs("div",{className:"stream-pw-actions",children:[P.jsx("button",{className:"stream-pw-cancel",onClick:()=>N(null),children:"Abbrechen"}),P.jsx("button",{className:"stream-btn",onClick:yt,children:"Beitreten"})]})]})})]})}function w7(i){const e=Math.floor(i),t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`:`${n}:${String(r).padStart(2,"0")}`}function KAe(i){const e=i.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(e)return{type:"youtube",videoId:e[1]};const t=i.match(/(?:dailymotion\.com\/video\/|dai\.ly\/)([a-zA-Z0-9]+)/);return t?{type:"dailymotion",videoId:t[1]}:/\.(mp4|webm|ogg)(\?|$)/i.test(i)||i.startsWith("http")?{type:"direct",url:i}:null}function ZAe({data:i}){var pn;const[e,t]=se.useState([]),[n,r]=se.useState(()=>localStorage.getItem("wt_name")||""),[s,a]=se.useState(""),[l,u]=se.useState(""),[h,m]=se.useState(null),[v,x]=se.useState(null),[S,T]=se.useState(null),[N,C]=se.useState(""),[E,O]=se.useState(()=>{const $e=localStorage.getItem("wt_volume");return $e?parseFloat($e):1}),[U,I]=se.useState(!1),[j,z]=se.useState(0),[G,H]=se.useState(0),[q,V]=se.useState(null),[Q,J]=se.useState(!1),[ie,le]=se.useState([]),[re,Z]=se.useState(""),[ne,de]=se.useState(null),[be,Te]=se.useState("synced"),[ae,Me]=se.useState(!0),[Ve,Ce]=se.useState(()=>localStorage.getItem("wt_yt_quality")||"hd1080"),Fe=se.useRef(null),tt=se.useRef(""),je=se.useRef(null),Rt=se.useRef(1e3),Et=se.useRef(null),Ft=se.useRef(null),Ut=se.useRef(null),Ke=se.useRef(null),ht=se.useRef(null),fe=se.useRef(null),$t=se.useRef(!1),_t=se.useRef(!1),Gt=se.useRef(null),yt=se.useRef(null),Ht=se.useRef(Ve),pt=se.useRef(null),Ae=se.useRef(!1),k=se.useRef(0),xe=se.useRef(0);se.useEffect(()=>{Et.current=h},[h]);const Oe=h!=null&&tt.current===h.hostId;se.useEffect(()=>{Ht.current=Ve,localStorage.setItem("wt_yt_quality",Ve),Ut.current&&typeof Ut.current.setPlaybackQuality=="function"&&Ut.current.setPlaybackQuality(Ve)},[Ve]),se.useEffect(()=>{i!=null&&i.rooms&&t(i.rooms)},[i]),se.useEffect(()=>{var $e;($e=yt.current)==null||$e.scrollIntoView({behavior:"smooth"})},[ie]),se.useEffect(()=>{const St=new URLSearchParams(window.location.search).get("wt");if(St&&n.trim()){const Kt=setTimeout(()=>ct(St),1500);return()=>clearTimeout(Kt)}},[]),se.useEffect(()=>{n&&localStorage.setItem("wt_name",n)},[n]),se.useEffect(()=>{var $e;localStorage.setItem("wt_volume",String(E)),Ut.current&&typeof Ut.current.setVolume=="function"&&Ut.current.setVolume(E*100),Ke.current&&(Ke.current.volume=E),($e=pt.current)!=null&&$e.contentWindow&&fe.current==="dailymotion"&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com")},[E]),se.useEffect(()=>{if(window.YT){$t.current=!0;return}const $e=document.createElement("script");$e.src="https://www.youtube.com/iframe_api",document.head.appendChild($e);const St=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{$t.current=!0,St&&St()}},[]);const Ue=se.useCallback($e=>{var St;((St=Fe.current)==null?void 0:St.readyState)===WebSocket.OPEN&&Fe.current.send(JSON.stringify($e))},[]),ee=se.useCallback(()=>fe.current==="youtube"&&Ut.current&&typeof Ut.current.getCurrentTime=="function"?Ut.current.getCurrentTime():fe.current==="direct"&&Ke.current?Ke.current.currentTime:fe.current==="dailymotion"?k.current:null,[]);se.useCallback(()=>fe.current==="youtube"&&Ut.current&&typeof Ut.current.getDuration=="function"?Ut.current.getDuration()||0:fe.current==="direct"&&Ke.current?Ke.current.duration||0:fe.current==="dailymotion"?xe.current:0,[]);const we=se.useCallback(()=>{if(Ut.current){try{Ut.current.destroy()}catch{}Ut.current=null}Ke.current&&(Ke.current.pause(),Ke.current.removeAttribute("src"),Ke.current.load()),pt.current&&(pt.current.src="",Ae.current=!1,k.current=0,xe.current=0),fe.current=null,Gt.current&&(clearInterval(Gt.current),Gt.current=null)},[]),Re=se.useCallback($e=>{we(),V(null);const St=KAe($e);if(St)if(St.type==="youtube"){if(fe.current="youtube",!$t.current||!ht.current)return;const Kt=ht.current,wn=document.createElement("div");wn.id="wt-yt-player-"+Date.now(),Kt.innerHTML="",Kt.appendChild(wn),Ut.current=new window.YT.Player(wn.id,{videoId:St.videoId,playerVars:{autoplay:1,controls:0,modestbranding:1,rel:0},events:{onReady:qn=>{qn.target.setVolume(E*100),qn.target.setPlaybackQuality(Ht.current),z(qn.target.getDuration()||0),Gt.current=setInterval(()=>{Ut.current&&typeof Ut.current.getCurrentTime=="function"&&(H(Ut.current.getCurrentTime()),z(Ut.current.getDuration()||0))},500)},onStateChange:qn=>{if(qn.data===window.YT.PlayerState.ENDED){const Je=Et.current;Je&&tt.current===Je.hostId&&Ue({type:"skip"})}},onError:qn=>{const Je=qn.data;V(Je===101||Je===150?"Embedding deaktiviert — Video kann nur auf YouTube angesehen werden.":Je===100?"Video nicht gefunden oder entfernt.":"Wiedergabefehler — Video wird übersprungen."),setTimeout(()=>{const dt=Et.current;dt&&tt.current===dt.hostId&&Ue({type:"skip"})},3e3)}}})}else St.type==="dailymotion"?(fe.current="dailymotion",pt.current&&(pt.current.src=`https://www.dailymotion.com/embed/video/${St.videoId}?api=postMessage&autoplay=1&controls=0&mute=0&queue-enable=0`)):(fe.current="direct",Ke.current&&(Ke.current.src=St.url,Ke.current.volume=E,Ke.current.play().catch(()=>{})))},[we,E,Ue]);se.useEffect(()=>{const $e=Ke.current;if(!$e)return;const St=()=>{const wn=Et.current;wn&&tt.current===wn.hostId&&Ue({type:"skip"})},Kt=()=>{H($e.currentTime),z($e.duration||0)};return $e.addEventListener("ended",St),$e.addEventListener("timeupdate",Kt),()=>{$e.removeEventListener("ended",St),$e.removeEventListener("timeupdate",Kt)}},[Ue]),se.useEffect(()=>{const $e=St=>{var Je;if(St.origin!=="https://www.dailymotion.com"||typeof St.data!="string")return;const Kt=new URLSearchParams(St.data),wn=Kt.get("method"),qn=Kt.get("value");if(wn==="timeupdate"&&qn){const dt=parseFloat(qn);k.current=dt,H(dt)}else if(wn==="durationchange"&&qn){const dt=parseFloat(qn);xe.current=dt,z(dt)}else if(wn==="ended"){const dt=Et.current;dt&&tt.current===dt.hostId&&Ue({type:"skip"})}else wn==="apiready"&&(Ae.current=!0,(Je=pt.current)!=null&&Je.contentWindow&&pt.current.contentWindow.postMessage(`volume?volume=${E}`,"https://www.dailymotion.com"))};return window.addEventListener("message",$e),()=>window.removeEventListener("message",$e)},[Ue,E]);const We=se.useRef(()=>{});We.current=$e=>{var St,Kt,wn,qn,Je,dt,Vt,xt,A,te,Vn,Wn,$n,dn,Fn,lr;switch($e.type){case"welcome":tt.current=$e.clientId,$e.rooms&&t($e.rooms);break;case"room_created":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]});break}case"room_joined":{const an=$e.room;m({id:an.id,name:an.name,hostId:an.hostId,members:an.members||[],currentVideo:an.currentVideo||null,playing:an.playing||!1,currentTime:an.currentTime||0,queue:an.queue||[]}),(St=an.currentVideo)!=null&&St.url&&setTimeout(()=>Re(an.currentVideo.url),100);break}case"playback_state":{const an=Et.current;if(!an)break;const mn=$e.currentVideo,Er=(Kt=an.currentVideo)==null?void 0:Kt.url;if(mn!=null&&mn.url&&mn.url!==Er?Re(mn.url):!mn&&Er&&we(),fe.current==="youtube"&&Ut.current){const Wi=(qn=(wn=Ut.current).getPlayerState)==null?void 0:qn.call(wn);$e.playing&&Wi!==((dt=(Je=window.YT)==null?void 0:Je.PlayerState)==null?void 0:dt.PLAYING)?(xt=(Vt=Ut.current).playVideo)==null||xt.call(Vt):!$e.playing&&Wi===((te=(A=window.YT)==null?void 0:A.PlayerState)==null?void 0:te.PLAYING)&&((Wn=(Vn=Ut.current).pauseVideo)==null||Wn.call(Vn))}else fe.current==="direct"&&Ke.current?$e.playing&&Ke.current.paused?Ke.current.play().catch(()=>{}):!$e.playing&&!Ke.current.paused&&Ke.current.pause():fe.current==="dailymotion"&&(($n=pt.current)!=null&&$n.contentWindow)&&($e.playing?pt.current.contentWindow.postMessage("play","https://www.dailymotion.com"):pt.current.contentWindow.postMessage("pause","https://www.dailymotion.com"));if($e.currentTime!==void 0&&!_t.current){const Wi=ee();Wi!==null&&Math.abs(Wi-$e.currentTime)>2&&(fe.current==="youtube"&&Ut.current?(Fn=(dn=Ut.current).seekTo)==null||Fn.call(dn,$e.currentTime,!0):fe.current==="direct"&&Ke.current?Ke.current.currentTime=$e.currentTime:fe.current==="dailymotion"&&((lr=pt.current)!=null&&lr.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e.currentTime}`,"https://www.dailymotion.com"))}if($e.currentTime!==void 0){const Wi=ee();if(Wi!==null){const No=Math.abs(Wi-$e.currentTime);No<1.5?Te("synced"):No<5?Te("drifting"):Te("desynced")}}m(Wi=>Wi&&{...Wi,currentVideo:mn||null,playing:$e.playing,currentTime:$e.currentTime??Wi.currentTime});break}case"queue_updated":m(an=>an&&{...an,queue:$e.queue});break;case"members_updated":m(an=>an&&{...an,members:$e.members,hostId:$e.hostId});break;case"vote_updated":de($e.votes);break;case"chat":le(an=>{const mn=[...an,{sender:$e.sender,text:$e.text,timestamp:$e.timestamp}];return mn.length>100?mn.slice(-100):mn});break;case"chat_history":le($e.messages||[]);break;case"error":$e.code==="WRONG_PASSWORD"?x(an=>an&&{...an,error:$e.message}):T($e.message);break}};const Se=se.useCallback(()=>{if(Fe.current&&(Fe.current.readyState===WebSocket.OPEN||Fe.current.readyState===WebSocket.CONNECTING))return;const $e=location.protocol==="https:"?"wss":"ws",St=new WebSocket(`${$e}://${location.host}/ws/watch-together`);Fe.current=St,St.onopen=()=>{Rt.current=1e3},St.onmessage=Kt=>{let wn;try{wn=JSON.parse(Kt.data)}catch{return}We.current(wn)},St.onclose=()=>{Fe.current===St&&(Fe.current=null),Et.current&&(je.current=setTimeout(()=>{Rt.current=Math.min(Rt.current*2,1e4),Se()},Rt.current))},St.onerror=()=>{St.close()}},[]),Le=se.useCallback(()=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}if(!s.trim()){T("Bitte gib einen Raumnamen ein.");return}T(null),Se();const $e=Date.now(),St=()=>{var Kt;((Kt=Fe.current)==null?void 0:Kt.readyState)===WebSocket.OPEN?Ue({type:"create_room",name:s.trim(),userName:n.trim(),password:l.trim()||void 0}):Date.now()-$e>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(St,100)};St()},[n,s,l,Se,Ue]),ct=se.useCallback(($e,St)=>{if(!n.trim()){T("Bitte gib einen Namen ein.");return}T(null),Se();const Kt=Date.now(),wn=()=>{var qn;((qn=Fe.current)==null?void 0:qn.readyState)===WebSocket.OPEN?Ue({type:"join_room",userName:n.trim(),roomId:$e,password:(St==null?void 0:St.trim())||void 0}):Date.now()-Kt>1e4?T("Verbindung zum Server fehlgeschlagen."):setTimeout(wn,100)};wn()},[n,Se,Ue]),Dt=se.useCallback(()=>{Ue({type:"leave_room"}),we(),m(null),C(""),z(0),H(0),le([]),de(null),Te("synced")},[Ue,we]),It=se.useCallback(async()=>{const $e=N.trim();if(!$e)return;C(""),J(!0);let St="";try{const Kt=await fetch(`/api/watch-together/video-info?url=${encodeURIComponent($e)}`);Kt.ok&&(St=(await Kt.json()).title||"")}catch{}Ue({type:"add_to_queue",url:$e,title:St||void 0}),J(!1)},[N,Ue]),lt=se.useCallback(()=>{const $e=re.trim();$e&&(Z(""),Ue({type:"chat_message",text:$e}))},[re,Ue]);se.useCallback(()=>{Ue({type:"vote_skip"})},[Ue]),se.useCallback(()=>{Ue({type:"vote_pause"})},[Ue]);const jt=se.useCallback(()=>{Ue({type:"clear_watched"})},[Ue]),Jt=se.useCallback(()=>{if(!h)return;const $e=`${window.location.origin}${window.location.pathname}?wt=${h.id}`;navigator.clipboard.writeText($e).catch(()=>{})},[h]),In=se.useCallback($e=>{Ue({type:"remove_from_queue",index:$e})},[Ue]),me=se.useCallback(()=>{const $e=Et.current;$e&&Ue({type:$e.playing?"pause":"resume"})},[Ue]),Bt=se.useCallback(()=>{Ue({type:"skip"})},[Ue]),ot=se.useCallback($e=>{var St,Kt,wn;_t.current=!0,Ue({type:"seek",time:$e}),fe.current==="youtube"&&Ut.current?(Kt=(St=Ut.current).seekTo)==null||Kt.call(St,$e,!0):fe.current==="direct"&&Ke.current?Ke.current.currentTime=$e:fe.current==="dailymotion"&&((wn=pt.current)!=null&&wn.contentWindow)&&pt.current.contentWindow.postMessage(`seek?to=${$e}`,"https://www.dailymotion.com"),H($e),setTimeout(()=>{_t.current=!1},3e3)},[Ue]);se.useEffect(()=>{if(!Oe||!(h!=null&&h.playing))return;const $e=setInterval(()=>{const St=ee();St!==null&&Ue({type:"report_time",time:St})},2e3);return()=>clearInterval($e)},[Oe,h==null?void 0:h.playing,Ue,ee]);const Tt=se.useCallback(()=>{const $e=Ft.current;$e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):$e.requestFullscreen().catch(()=>{}))},[]);se.useEffect(()=>{const $e=()=>I(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$e),()=>document.removeEventListener("fullscreenchange",$e)},[]),se.useEffect(()=>{const $e=Kt=>{Et.current&&Kt.preventDefault()},St=()=>{tt.current&&navigator.sendBeacon("/api/watch-together/disconnect",JSON.stringify({clientId:tt.current}))};return window.addEventListener("beforeunload",$e),window.addEventListener("pagehide",St),()=>{window.removeEventListener("beforeunload",$e),window.removeEventListener("pagehide",St)}},[]),se.useEffect(()=>()=>{we(),Fe.current&&Fe.current.close(),je.current&&clearTimeout(je.current)},[we]);const Wt=se.useCallback(()=>{if(!v)return;if(!v.password.trim()){x(Kt=>Kt&&{...Kt,error:"Passwort eingeben."});return}const{roomId:$e,password:St}=v;x(null),ct($e,St)},[v,ct]),Yt=se.useCallback($e=>{$e.hasPassword?x({roomId:$e.id,roomName:$e.name,password:"",error:null}):ct($e.id)},[ct]);if(h){const $e=h.members.find(St=>St.id===h.hostId);return P.jsxs("div",{className:"wt-room-overlay",ref:Ft,children:[P.jsxs("div",{className:"wt-room-header",children:[P.jsxs("div",{className:"wt-room-header-left",children:[P.jsx("span",{className:"wt-room-name",children:h.name}),P.jsxs("span",{className:"wt-room-members",children:[h.members.length," Mitglieder"]}),$e&&P.jsxs("span",{className:"wt-host-badge",children:["Host: ",$e.name]})]}),P.jsxs("div",{className:"wt-room-header-right",children:[P.jsx("div",{className:`wt-sync-dot wt-sync-${be}`,title:be==="synced"?"Synchron":be==="drifting"?"Leichte Verzögerung":"Nicht synchron"}),P.jsx("button",{className:"wt-header-btn",onClick:Jt,title:"Link kopieren",children:"Link"}),P.jsx("button",{className:"wt-header-btn",onClick:()=>Me(St=>!St),title:ae?"Chat ausblenden":"Chat einblenden",children:"Chat"}),P.jsx("button",{className:"wt-fullscreen-btn",onClick:Tt,title:U?"Vollbild verlassen":"Vollbild",children:U?"✖":"⛶"}),P.jsx("button",{className:"wt-leave-btn",onClick:Dt,children:"Verlassen"})]})]}),P.jsxs("div",{className:"wt-room-body",children:[P.jsxs("div",{className:"wt-player-section",children:[P.jsxs("div",{className:"wt-player-wrap",children:[P.jsx("div",{ref:ht,className:"wt-yt-container",style:fe.current==="youtube"?{}:{display:"none"}}),P.jsx("video",{ref:Ke,className:"wt-video-element",style:fe.current==="direct"?{}:{display:"none"},playsInline:!0}),P.jsx("iframe",{ref:pt,className:"wt-dm-container",style:fe.current==="dailymotion"?{}:{display:"none"},allow:"autoplay; fullscreen",allowFullScreen:!0}),q&&P.jsxs("div",{className:"wt-player-error",children:[P.jsx("div",{className:"wt-error-icon",children:"⚠️"}),P.jsx("p",{children:q}),((pn=h.currentVideo)==null?void 0:pn.url)&&P.jsx("a",{className:"wt-yt-link",href:h.currentVideo.url,target:"_blank",rel:"noopener noreferrer",children:"Auf YouTube öffnen ↗"}),P.jsx("p",{className:"wt-skip-info",children:"Wird in 3 Sekunden übersprungen..."})]}),!h.currentVideo&&P.jsxs("div",{className:"wt-player-placeholder",children:[P.jsx("div",{className:"wt-placeholder-icon",children:"🎬"}),P.jsx("p",{children:"Fuege ein Video zur Warteschlange hinzu"})]})]}),P.jsxs("div",{className:"wt-controls",children:[P.jsx("button",{className:"wt-ctrl-btn",onClick:me,disabled:!h.currentVideo,title:h.playing?"Pause":"Abspielen",children:h.playing?"⏸":"▶"}),P.jsxs("button",{className:"wt-ctrl-btn wt-next-btn",onClick:Bt,disabled:!h.currentVideo&&h.queue.length===0,title:"Nächstes Video",children:["⏭"," Weiter"]}),P.jsx("input",{className:"wt-seek",type:"range",min:0,max:j||0,step:.5,value:G,onChange:St=>ot(parseFloat(St.target.value)),disabled:!h.currentVideo}),P.jsxs("span",{className:"wt-time",children:[w7(G)," / ",w7(j)]}),P.jsxs("div",{className:"wt-volume",children:[P.jsx("span",{className:"wt-volume-icon",children:E===0?"🔇":E<.5?"🔉":"🔊"}),P.jsx("input",{className:"wt-volume-slider",type:"range",min:0,max:1,step:.01,value:E,onChange:St=>O(parseFloat(St.target.value))})]}),fe.current==="youtube"&&P.jsxs("select",{className:"wt-quality-select",value:Ve,onChange:St=>Ce(St.target.value),title:"Videoqualität",children:[P.jsx("option",{value:"highres",children:"4K+"}),P.jsx("option",{value:"hd2160",children:"2160p"}),P.jsx("option",{value:"hd1440",children:"1440p"}),P.jsx("option",{value:"hd1080",children:"1080p"}),P.jsx("option",{value:"hd720",children:"720p"}),P.jsx("option",{value:"large",children:"480p"}),P.jsx("option",{value:"medium",children:"360p"}),P.jsx("option",{value:"small",children:"240p"})]})]})]}),P.jsxs("div",{className:"wt-queue-panel",children:[P.jsxs("div",{className:"wt-queue-header",children:[P.jsxs("span",{children:["Warteschlange (",h.queue.length,")"]}),h.queue.some(St=>St.watched)&&P.jsx("button",{className:"wt-queue-clear-btn",onClick:jt,title:"Gesehene entfernen",children:"Gesehene entfernen"})]}),P.jsx("div",{className:"wt-queue-list",children:h.queue.length===0?P.jsx("div",{className:"wt-queue-empty",children:"Keine Videos in der Warteschlange"}):h.queue.map((St,Kt)=>{var qn,Je;const wn=((qn=h.currentVideo)==null?void 0:qn.url)===St.url;return P.jsxs("div",{className:`wt-queue-item${wn?" playing":""}${St.watched&&!wn?" watched":""} clickable`,onClick:()=>Ue({type:"play_video",index:Kt}),title:"Klicken zum Abspielen",children:[P.jsxs("div",{className:"wt-queue-item-info",children:[St.watched&&!wn&&P.jsx("span",{className:"wt-queue-item-check",children:"✓"}),St.url.match(/youtu/)&&P.jsx("img",{className:"wt-queue-thumb",src:`https://img.youtube.com/vi/${(Je=St.url.match(/(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/))==null?void 0:Je[1]}/default.jpg`,alt:""}),P.jsxs("div",{className:"wt-queue-item-text",children:[P.jsx("div",{className:"wt-queue-item-title",children:St.title||St.url}),P.jsx("div",{className:"wt-queue-item-by",children:St.addedBy})]})]}),Oe&&P.jsx("button",{className:"wt-queue-item-remove",onClick:dt=>{dt.stopPropagation(),In(Kt)},title:"Entfernen",children:"×"})]},Kt)})}),P.jsxs("div",{className:"wt-queue-add",children:[P.jsx("input",{className:"wt-input wt-queue-input",placeholder:"Video-URL eingeben",value:N,onChange:St=>C(St.target.value),onKeyDown:St=>{St.key==="Enter"&&It()}}),P.jsx("button",{className:"wt-btn wt-queue-add-btn",onClick:It,disabled:Q,children:Q?"Laden...":"Hinzufuegen"})]})]}),ae&&P.jsxs("div",{className:"wt-chat-panel",children:[P.jsx("div",{className:"wt-chat-header",children:"Chat"}),P.jsxs("div",{className:"wt-chat-messages",children:[ie.length===0?P.jsx("div",{className:"wt-chat-empty",children:"Noch keine Nachrichten"}):ie.map((St,Kt)=>P.jsxs("div",{className:"wt-chat-msg",children:[P.jsx("span",{className:"wt-chat-sender",children:St.sender}),P.jsx("span",{className:"wt-chat-text",children:St.text})]},Kt)),P.jsx("div",{ref:yt})]}),P.jsxs("div",{className:"wt-chat-input-row",children:[P.jsx("input",{className:"wt-input wt-chat-input",placeholder:"Nachricht...",value:re,onChange:St=>Z(St.target.value),onKeyDown:St=>{St.key==="Enter"&<()},maxLength:500}),P.jsx("button",{className:"wt-btn wt-chat-send-btn",onClick:lt,children:"Senden"})]})]})]})]})}return P.jsxs("div",{className:"wt-container",children:[S&&P.jsxs("div",{className:"wt-error",children:[S,P.jsx("button",{className:"wt-error-dismiss",onClick:()=>T(null),children:"×"})]}),P.jsxs("div",{className:"wt-topbar",children:[P.jsx("input",{className:"wt-input wt-input-name",placeholder:"Dein Name",value:n,onChange:$e=>r($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-room",placeholder:"Raumname",value:s,onChange:$e=>a($e.target.value)}),P.jsx("input",{className:"wt-input wt-input-password",type:"password",placeholder:"Passwort (optional)",value:l,onChange:$e=>u($e.target.value)}),P.jsx("button",{className:"wt-btn",onClick:Le,children:"Raum erstellen"})]}),e.length===0?P.jsxs("div",{className:"wt-empty",children:[P.jsx("div",{className:"wt-empty-icon",children:"🎬"}),P.jsx("h3",{children:"Keine aktiven Raeume"}),P.jsx("p",{children:"Erstelle einen Raum, um gemeinsam Videos zu schauen."})]}):P.jsx("div",{className:"wt-grid",children:e.map($e=>P.jsxs("div",{className:"wt-tile",onClick:()=>Yt($e),children:[P.jsxs("div",{className:"wt-tile-preview",children:[P.jsx("span",{className:"wt-tile-icon",children:"🎬"}),P.jsxs("span",{className:"wt-tile-members",children:["👥"," ",$e.memberCount]}),$e.hasPassword&&P.jsx("span",{className:"wt-tile-lock",children:"🔒"}),$e.playing&&P.jsx("span",{className:"wt-tile-playing",children:"▶"})]}),P.jsxs("div",{className:"wt-tile-info",children:[P.jsxs("div",{className:"wt-tile-meta",children:[P.jsx("div",{className:"wt-tile-name",children:$e.name}),P.jsx("div",{className:"wt-tile-host",children:$e.hostName})]}),$e.memberNames&&$e.memberNames.length>0&&P.jsxs("div",{className:"wt-tile-members-list",children:[$e.memberNames.slice(0,5).join(", "),$e.memberNames.length>5&&` +${$e.memberNames.length-5}`]})]})]},$e.id))}),v&&P.jsx("div",{className:"wt-modal-overlay",onClick:()=>x(null),children:P.jsxs("div",{className:"wt-modal",onClick:$e=>$e.stopPropagation(),children:[P.jsx("h3",{children:v.roomName}),P.jsx("p",{children:"Raum-Passwort"}),v.error&&P.jsx("div",{className:"wt-modal-error",children:v.error}),P.jsx("input",{className:"wt-input",type:"password",placeholder:"Passwort",value:v.password,onChange:$e=>x(St=>St&&{...St,password:$e.target.value,error:null}),onKeyDown:$e=>{$e.key==="Enter"&&Wt()},autoFocus:!0}),P.jsxs("div",{className:"wt-modal-actions",children:[P.jsx("button",{className:"wt-modal-cancel",onClick:()=>x(null),children:"Abbrechen"}),P.jsx("button",{className:"wt-btn",onClick:Wt,children:"Beitreten"})]})]})})]})}function HS(i,e){return`https://media.steampowered.com/steamcommunity/public/images/apps/${i}/${e}.jpg`}function T7(i){if(i==null||i===0)return"—";if(i<60)return`${i} Min`;const e=Math.floor(i/60),t=i%60;return t>0?`${e}h ${t}m`:`${e}h`}function JAe(i){try{return new Date(i).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function e0e({data:i,isAdmin:e}){const[t,n]=se.useState([]),[r,s]=se.useState("overview"),[a,l]=se.useState(null),[u,h]=se.useState(new Set),[m,v]=se.useState(null),[x,S]=se.useState(null),[T,N]=se.useState(""),[C,E]=se.useState(null),[O,U]=se.useState(!1),[I,j]=se.useState(null),[z,G]=se.useState(new Set),[H,q]=se.useState("playtime"),V=se.useRef(null),Q=se.useRef(null),[J,ie]=se.useState("");se.useEffect(()=>{i!=null&&i.profiles&&n(i.profiles)},[i]);const le=se.useCallback(async()=>{try{const ee=await fetch("/api/game-library/profiles");if(ee.ok){const we=await ee.json();n(we.profiles||[])}}catch{}},[]),re=se.useCallback(()=>{const ee=window.open("/api/game-library/steam/login","_blank","width=800,height=600"),we=setInterval(()=>{ee&&ee.closed&&(clearInterval(we),setTimeout(le,1e3))},500)},[le]),Z=navigator.userAgent.includes("GamingHubDesktop"),[ne,de]=se.useState(!1),[be,Te]=se.useState(""),[ae,Me]=se.useState("idle"),[Ve,Ce]=se.useState(""),Fe=se.useCallback(()=>{const ee=a?`?linkTo=${a}`:"";if(Z){const we=window.open(`/api/game-library/gog/login${ee}`,"_blank","width=800,height=700"),Re=setInterval(()=>{we&&we.closed&&(clearInterval(Re),setTimeout(le,1e3))},500)}else window.open(`/api/game-library/gog/login${ee}`,"_blank","width=800,height=700"),Te(""),Me("idle"),Ce(""),de(!0)},[le,a,Z]),tt=se.useCallback(async()=>{let ee=be.trim();const we=ee.match(/[?&]code=([^&]+)/);if(we&&(ee=we[1]),!!ee){Me("loading"),Ce("Verbinde mit GOG...");try{const Re=await fetch("/api/game-library/gog/exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:ee,linkTo:a||""})}),We=await Re.json();Re.ok&&We.ok?(Me("success"),Ce(`${We.profileName}: ${We.gameCount} Spiele geladen!`),le(),setTimeout(()=>de(!1),2e3)):(Me("error"),Ce(We.error||"Unbekannter Fehler"))}catch{Me("error"),Ce("Verbindung fehlgeschlagen.")}}},[be,a,le]);se.useEffect(()=>{const ee=()=>le();return window.addEventListener("gog-connected",ee),()=>window.removeEventListener("gog-connected",ee)},[le]),se.useEffect(()=>{const ee=()=>le();return window.addEventListener("focus",ee),()=>window.removeEventListener("focus",ee)},[le]);const je=se.useCallback(async ee=>{var we,Re;s("user"),l(ee),v(null),ie(""),U(!0);try{const We=await fetch(`/api/game-library/profile/${ee}/games`);if(We.ok){const Se=await We.json(),Le=Se.games||Se;v(Le);const ct=t.find(It=>It.id===ee),Dt=(Re=(we=ct==null?void 0:ct.platforms)==null?void 0:we.steam)==null?void 0:Re.steamId;Dt&&Le.filter(lt=>!lt.igdb).length>0&&(j(ee),fetch(`/api/game-library/igdb/enrich/${Dt}`).then(lt=>lt.ok?lt.json():null).then(()=>fetch(`/api/game-library/profile/${ee}/games`)).then(lt=>lt.ok?lt.json():null).then(lt=>{lt&&v(lt.games||lt)}).catch(()=>{}).finally(()=>j(null)))}}catch{}finally{U(!1)}},[t]),Rt=se.useCallback(async(ee,we)=>{var Se,Le;we&&we.stopPropagation();const Re=t.find(ct=>ct.id===ee),We=(Le=(Se=Re==null?void 0:Re.platforms)==null?void 0:Se.steam)==null?void 0:Le.steamId;try{We&&await fetch(`/api/game-library/user/${We}?refresh=true`),await le(),r==="user"&&a===ee&&je(ee)}catch{}},[le,r,a,je,t]),Et=se.useCallback(async ee=>{var We,Se;const we=t.find(Le=>Le.id===ee),Re=(Se=(We=we==null?void 0:we.platforms)==null?void 0:We.steam)==null?void 0:Se.steamId;if(Re){j(ee);try{(await fetch(`/api/game-library/igdb/enrich/${Re}`)).ok&&r==="user"&&a===ee&&je(ee)}catch{}finally{j(null)}}},[r,a,je,t]),Ft=se.useCallback(ee=>{h(we=>{const Re=new Set(we);return Re.has(ee)?Re.delete(ee):Re.add(ee),Re})},[]),Ut=se.useCallback(async()=>{if(!(u.size<2)){s("common"),S(null),U(!0);try{const ee=Array.from(u).join(","),we=await fetch(`/api/game-library/common-games?users=${ee}`);if(we.ok){const Re=await we.json();S(Re.games||Re)}else console.error("[GameLibrary] common-games error:",we.status,await we.text().catch(()=>"")),S([])}catch(ee){console.error("[GameLibrary] common-games fetch failed:",ee)}finally{U(!1)}}},[u]),Ke=se.useCallback(ee=>{if(N(ee),V.current&&clearTimeout(V.current),ee.length<2){E(null);return}V.current=setTimeout(async()=>{try{const we=await fetch(`/api/game-library/search?q=${encodeURIComponent(ee)}`);if(we.ok){const Re=await we.json();E(Re.results||Re)}}catch{}},300)},[]),ht=se.useCallback(ee=>{G(we=>{const Re=new Set(we);return Re.has(ee)?Re.delete(ee):Re.add(ee),Re})},[]),fe=se.useCallback(async(ee,we)=>{if(confirm(`${we==="steam"?"Steam":"GOG"}-Verknuepfung wirklich trennen?`))try{const Re=await fetch(`/api/game-library/profile/${ee}/${we}`,{method:"DELETE"});if(Re.ok&&(le(),(await Re.json()).ok)){const Se=t.find(ct=>ct.id===ee);(we==="steam"?Se==null?void 0:Se.platforms.gog:Se==null?void 0:Se.platforms.steam)||$t()}}catch{}},[le,t]);se.useCallback(async ee=>{const we=t.find(Re=>Re.id===ee);if(confirm(`Profil "${we==null?void 0:we.displayName}" wirklich komplett loeschen?`))try{(await fetch(`/api/game-library/profile/${ee}`,{method:"DELETE"})).ok&&(le(),$t())}catch{}},[le,t]);const $t=se.useCallback(()=>{s("overview"),l(null),v(null),S(null),ie(""),G(new Set),q("playtime")},[]),_t=$t,Gt=se.useCallback(ee=>t.find(we=>we.id===ee),[t]),yt=se.useCallback(ee=>typeof ee.playtime_forever=="number"?ee.playtime_forever:Array.isArray(ee.owners)?Math.max(...ee.owners.map(we=>we.playtime_forever||0)):0,[]),Ht=se.useCallback(ee=>[...ee].sort((we,Re)=>{var We,Se;if(H==="rating"){const Le=((We=we.igdb)==null?void 0:We.rating)??-1;return(((Se=Re.igdb)==null?void 0:Se.rating)??-1)-Le}return H==="name"?we.name.localeCompare(Re.name):yt(Re)-yt(we)}),[H,yt]),pt=se.useCallback(ee=>{var we,Re;return z.size===0?!0:(Re=(we=ee.igdb)==null?void 0:we.genres)!=null&&Re.length?ee.igdb.genres.some(We=>z.has(We)):!1},[z]),Ae=se.useCallback(ee=>{var Re;const we=new Map;for(const We of ee)if((Re=We.igdb)!=null&&Re.genres)for(const Se of We.igdb.genres)we.set(Se,(we.get(Se)||0)+1);return[...we.entries()].sort((We,Se)=>Se[1]-We[1]).map(([We])=>We)},[]),k=m?Ht(m.filter(ee=>!J||ee.name.toLowerCase().includes(J.toLowerCase())).filter(pt)):null,xe=m?Ae(m):[],Oe=x?Ae(x):[],Ue=x?Ht(x.filter(pt)):null;return P.jsxs("div",{className:"gl-container",children:[P.jsxs("div",{className:"gl-login-bar",children:[!a&&P.jsx("button",{className:"gl-connect-btn gl-steam-btn",onClick:re,children:"🎮 Steam verbinden"}),P.jsx("div",{className:"gl-login-bar-spacer"})]}),t.length>0&&P.jsx("div",{className:"gl-profile-chips",children:t.map(ee=>P.jsxs("div",{className:`gl-profile-chip${a===ee.id?" selected":""}`,onClick:()=>je(ee.id),children:[P.jsx("img",{className:"gl-profile-chip-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"gl-profile-chip-info",children:[P.jsx("span",{className:"gl-profile-chip-name",children:ee.displayName}),P.jsxs("span",{className:"gl-profile-chip-platforms",children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:`Steam: ${ee.platforms.steam.gameCount} Spiele`,children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:`GOG: ${ee.platforms.gog.gameCount} Spiele`,children:"G"})]})]}),P.jsxs("span",{className:"gl-profile-chip-count",children:["(",ee.totalGames,")"]})]},ee.id))}),r==="overview"&&P.jsx(P.Fragment,{children:t.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"🎮"}),P.jsx("h3",{children:"Keine Konten verbunden"}),P.jsx("p",{children:"Klicke oben auf “Steam verbinden” oder “GOG verbinden”, um deine Spielebibliothek hinzuzufuegen."})]}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"gl-section-title",children:"Verbundene Spieler"}),P.jsx("div",{className:"gl-users-grid",children:t.map(ee=>P.jsxs("div",{className:"gl-user-card",onClick:()=>je(ee.id),children:[P.jsx("img",{className:"gl-user-card-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsx("span",{className:"gl-user-card-name",children:ee.displayName}),P.jsxs("div",{className:"gl-profile-card-platforms",children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",title:"Steam",children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",title:"GOG",children:"G"})]}),P.jsxs("span",{className:"gl-user-card-games",children:[ee.totalGames," Spiele"]}),P.jsxs("span",{className:"gl-user-card-updated",children:["Aktualisiert: ",JAe(ee.lastUpdated)]})]},ee.id))}),t.length>=2&&P.jsxs("div",{className:"gl-common-finder",children:[P.jsx("h3",{children:"Gemeinsame Spiele finden"}),P.jsx("div",{className:"gl-common-users",children:t.map(ee=>P.jsxs("label",{className:`gl-common-check${u.has(ee.id)?" checked":""}`,children:[P.jsx("input",{type:"checkbox",checked:u.has(ee.id),onChange:()=>Ft(ee.id)}),P.jsx("img",{className:"gl-common-check-avatar",src:ee.avatarUrl,alt:ee.displayName}),ee.displayName,P.jsxs("span",{className:"gl-profile-chip-platforms",style:{marginLeft:4},children:[ee.platforms.steam&&P.jsx("span",{className:"gl-platform-badge steam",children:"S"}),ee.platforms.gog&&P.jsx("span",{className:"gl-platform-badge gog",children:"G"})]})]},ee.id))}),P.jsx("button",{className:"gl-common-find-btn",disabled:u.size<2,onClick:Ut,children:"Finden"})]}),P.jsx("div",{className:"gl-search",children:P.jsx("input",{className:"gl-search-input",type:"text",placeholder:"Spiel suchen...",value:T,onChange:ee=>Ke(ee.target.value)})}),C&&C.length>0&&P.jsxs(P.Fragment,{children:[P.jsxs("p",{className:"gl-search-results-title",children:[C.length," Ergebnis",C.length!==1?"se":""]}),P.jsx("div",{className:"gl-game-list",children:C.map(ee=>P.jsxs("div",{className:"gl-game-item",children:[ee.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(ee.appid,ee.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"}),P.jsx("span",{className:"gl-game-name",children:ee.name}),P.jsx("div",{className:"gl-game-owners",children:ee.owners.map(we=>{const Re=t.find(We=>{var Se;return((Se=We.platforms.steam)==null?void 0:Se.steamId)===we.steamId});return Re?P.jsx("img",{className:"gl-game-owner-avatar",src:Re.avatarUrl,alt:we.personaName,title:we.personaName},we.steamId):null})})]},ee.appid))})]}),C&&C.length===0&&P.jsx("p",{className:"gl-search-results-title",children:"Keine Ergebnisse gefunden."})]})}),r==="user"&&(()=>{const ee=a?Gt(a):null;return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:_t,children:"← Zurueck"}),ee&&P.jsxs(P.Fragment,{children:[P.jsx("img",{className:"gl-detail-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsxs("div",{className:"gl-detail-name",children:[ee.displayName,P.jsxs("span",{className:"gl-game-count",children:[ee.totalGames," Spiele"]})]}),P.jsxs("div",{className:"gl-detail-sub",children:[ee.platforms.steam&&P.jsxs("span",{className:"gl-platform-detail steam",children:[P.jsx("span",{className:"gl-platform-badge steam",children:"Steam ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:we=>{we.stopPropagation(),fe(ee.id,"steam")},title:"Steam trennen",children:"✕"})]}),ee.platforms.gog?P.jsxs("span",{className:"gl-platform-detail gog",children:[P.jsx("span",{className:"gl-platform-badge gog",children:"GOG ✓"}),P.jsx("button",{className:"gl-disconnect-btn",onClick:we=>{we.stopPropagation(),fe(ee.id,"gog")},title:"GOG trennen",children:"✕"})]}):P.jsx("button",{className:"gl-link-gog-btn",onClick:Fe,children:"🟣 GOG verknuepfen"})]})]}),P.jsx("button",{className:"gl-refresh-btn",onClick:()=>Rt(ee.id),title:"Aktualisieren",children:"↻"}),ee.platforms.steam&&P.jsxs("button",{className:`gl-enrich-btn ${I===a?"enriching":""}`,onClick:()=>Et(a),disabled:I===a,title:I===a?"IGDB-Daten werden geladen...":"Mit IGDB-Daten anreichern (erneut)",children:[I===a?"⏳":"🌐"," IGDB"]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Bibliothek wird geladen..."}):k?P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-filter-bar",children:[P.jsx("input",{ref:Q,className:"gl-search-input",type:"text",placeholder:"Bibliothek durchsuchen...",value:J,onChange:we=>ie(we.target.value)}),P.jsxs("select",{className:"gl-sort-select",value:H,onChange:we=>q(we.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})]}),xe.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),xe.map(we=>P.jsx("button",{className:`gl-genre-chip${z.has(we)?" active":""}`,onClick:()=>ht(we),children:we},we))]}),P.jsxs("p",{className:"gl-filter-count",children:[k.length," Spiele"]}),k.length===0?P.jsx("p",{className:"gl-search-results-title",children:"Keine Spiele gefunden."}):P.jsx("div",{className:"gl-game-list",children:k.map((we,Re)=>{var We,Se,Le;return P.jsxs("div",{className:`gl-game-item ${we.igdb?"enriched":""}`,children:[P.jsx("span",{className:`gl-game-platform-icon ${we.platform||"steam"}`,children:we.platform==="gog"?"G":"S"}),P.jsx("div",{className:"gl-game-visual",children:(We=we.igdb)!=null&&We.coverUrl?P.jsx("img",{className:"gl-game-cover",src:we.igdb.coverUrl,alt:""}):we.img_icon_url&&we.appid?P.jsx("img",{className:"gl-game-icon",src:HS(we.appid,we.img_icon_url),alt:""}):we.image?P.jsx("img",{className:"gl-game-icon",src:we.image,alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:we.name}),((Se=we.igdb)==null?void 0:Se.genres)&&we.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:we.igdb.genres.slice(0,3).map(ct=>P.jsx("span",{className:"gl-genre-tag",children:ct},ct))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Le=we.igdb)==null?void 0:Le.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${we.igdb.rating>=75?"high":we.igdb.rating>=50?"mid":"low"}`,children:Math.round(we.igdb.rating)}),P.jsx("span",{className:"gl-game-playtime",children:T7(we.playtime_forever)})]})]},we.appid??we.gogId??Re)})})]}):null]})})(),r==="common"&&(()=>{const ee=Array.from(u).map(Re=>Gt(Re)).filter(Boolean),we=ee.map(Re=>Re.displayName).join(", ");return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"gl-detail-header",children:[P.jsx("button",{className:"gl-back-btn",onClick:_t,children:"← Zurueck"}),P.jsx("div",{className:"gl-detail-avatars",children:ee.map(Re=>P.jsx("img",{src:Re.avatarUrl,alt:Re.displayName},Re.id))}),P.jsxs("div",{className:"gl-detail-info",children:[P.jsx("div",{className:"gl-detail-name",children:"Gemeinsame Spiele"}),P.jsxs("div",{className:"gl-detail-sub",children:["von ",we]})]})]}),O?P.jsx("div",{className:"gl-loading",children:"Gemeinsame Spiele werden gesucht..."}):x?x.length===0?P.jsxs("div",{className:"gl-empty",children:[P.jsx("div",{className:"gl-empty-icon",children:"😔"}),P.jsx("h3",{children:"Keine gemeinsamen Spiele"}),P.jsx("p",{children:"Die ausgewaehlten Spieler besitzen leider keine gemeinsamen Spiele."})]}):P.jsxs(P.Fragment,{children:[P.jsx("div",{className:"gl-filter-bar",children:P.jsxs("select",{className:"gl-sort-select",value:H,onChange:Re=>q(Re.target.value),children:[P.jsx("option",{value:"playtime",children:"Spielzeit"}),P.jsx("option",{value:"rating",children:"Bewertung"}),P.jsx("option",{value:"name",children:"Name"})]})}),Oe.length>0&&P.jsxs("div",{className:"gl-genre-filters",children:[z.size>0&&P.jsx("button",{className:"gl-genre-chip active clear",onClick:()=>G(new Set),children:"Alle"}),Oe.map(Re=>P.jsx("button",{className:`gl-genre-chip${z.has(Re)?" active":""}`,onClick:()=>ht(Re),children:Re},Re))]}),P.jsxs("p",{className:"gl-section-title",children:[Ue.length," gemeinsame",Ue.length!==1?" Spiele":"s Spiel",z.size>0?` (von ${x.length})`:""]}),P.jsx("div",{className:"gl-game-list",children:Ue.map(Re=>{var We,Se,Le;return P.jsxs("div",{className:`gl-game-item ${Re.igdb?"enriched":""}`,children:[P.jsx("div",{className:"gl-game-visual",children:(We=Re.igdb)!=null&&We.coverUrl?P.jsx("img",{className:"gl-game-cover",src:Re.igdb.coverUrl,alt:""}):Re.img_icon_url?P.jsx("img",{className:"gl-game-icon",src:HS(Re.appid,Re.img_icon_url),alt:""}):P.jsx("div",{className:"gl-game-icon"})}),P.jsxs("div",{className:"gl-game-info",children:[P.jsx("span",{className:"gl-game-name",children:Re.name}),((Se=Re.igdb)==null?void 0:Se.genres)&&Re.igdb.genres.length>0&&P.jsx("div",{className:"gl-game-genres",children:Re.igdb.genres.slice(0,3).map(ct=>P.jsx("span",{className:"gl-genre-tag",children:ct},ct))})]}),P.jsxs("div",{className:"gl-game-meta",children:[((Le=Re.igdb)==null?void 0:Le.rating)!=null&&P.jsx("span",{className:`gl-game-rating ${Re.igdb.rating>=75?"high":Re.igdb.rating>=50?"mid":"low"}`,children:Math.round(Re.igdb.rating)}),P.jsx("div",{className:"gl-common-playtimes",children:Re.owners.map(ct=>P.jsxs("span",{className:"gl-common-pt",children:[ct.personaName,": ",T7(ct.playtime_forever)]},ct.steamId))})]})]},Re.appid)})})]}):null]})})(),ne&&P.jsx("div",{className:"gl-dialog-overlay",onClick:()=>de(!1),children:P.jsxs("div",{className:"gl-dialog",onClick:ee=>ee.stopPropagation(),children:[P.jsx("h3",{children:"🟣 GOG verbinden"}),P.jsxs("p",{className:"gl-dialog-hint",children:["Nach dem GOG-Login wirst du auf eine Seite weitergeleitet. Kopiere die ",P.jsx("strong",{children:"komplette URL"})," aus der Adressleiste und füge sie hier ein:"]}),P.jsx("input",{className:"gl-dialog-input",type:"text",placeholder:"https://embed.gog.com/on_login_success?code=...",value:be,onChange:ee=>Te(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&tt()},disabled:ae==="loading"||ae==="success",autoFocus:!0}),Ve&&P.jsx("p",{className:`gl-dialog-status ${ae}`,children:Ve}),P.jsxs("div",{className:"gl-dialog-actions",children:[P.jsx("button",{onClick:()=>de(!1),className:"gl-dialog-cancel",children:"Abbrechen"}),P.jsx("button",{onClick:tt,className:"gl-dialog-submit",disabled:!be.trim()||ae==="loading"||ae==="success",children:ae==="loading"?"Verbinde...":"Verbinden"})]})]})})]})}const lx="/api/soundboard";async function t0e(){const i=new URL(`${lx}/sounds`,window.location.origin);i.searchParams.set("folder","__all__"),i.searchParams.set("fuzzy","0");const e=await fetch(i.toString());if(!e.ok)throw new Error("Fehler beim Laden der Sounds");return e.json()}async function n0e(i){if(!(await fetch(`${lx}/admin/sounds/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({paths:i})})).ok)throw new Error("Loeschen fehlgeschlagen")}async function i0e(i,e){const t=await fetch(`${lx}/admin/sounds/rename`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({from:i,to:e})});if(!t.ok)throw new Error("Umbenennen fehlgeschlagen");const n=await t.json();return n==null?void 0:n.to}function r0e(i,e){return new Promise((t,n)=>{const r=new FormData;r.append("files",i);const s=new XMLHttpRequest;s.open("POST",`${lx}/upload`),s.upload.onprogress=a=>{a.lengthComputable&&e(Math.round(a.loaded/a.total*100))},s.onload=()=>{var a,l;if(s.status===200)try{const u=JSON.parse(s.responseText);t(((l=(a=u.files)==null?void 0:a[0])==null?void 0:l.name)??i.name)}catch{t(i.name)}else try{n(new Error(JSON.parse(s.responseText).error))}catch{n(new Error(`HTTP ${s.status}`))}},s.onerror=()=>n(new Error("Netzwerkfehler")),s.send(r)})}function s0e({onClose:i,onLogout:e}){var Oe,Ue;const[t,n]=se.useState("soundboard"),[r,s]=se.useState(null),a=se.useCallback((ee,we="info")=>{s({msg:ee,type:we}),setTimeout(()=>s(null),3e3)},[]);se.useEffect(()=>{const ee=we=>{we.key==="Escape"&&i()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[i]);const[l,u]=se.useState([]),[h,m]=se.useState(!1),[v,x]=se.useState(""),[S,T]=se.useState({}),[N,C]=se.useState(""),[E,O]=se.useState(""),[U,I]=se.useState(null),j=se.useCallback(ee=>ee.relativePath??ee.fileName,[]),z=se.useCallback(async()=>{m(!0);try{const ee=await t0e();u(ee.items||[])}catch(ee){a((ee==null?void 0:ee.message)||"Sounds konnten nicht geladen werden","error")}finally{m(!1)}},[a]),[G,H]=se.useState(!1);se.useEffect(()=>{t==="soundboard"&&!G&&(H(!0),z())},[t,G,z]);const q=se.useMemo(()=>{const ee=v.trim().toLowerCase();return ee?l.filter(we=>{const Re=j(we).toLowerCase();return we.name.toLowerCase().includes(ee)||(we.folder||"").toLowerCase().includes(ee)||Re.includes(ee)}):l},[v,l,j]),V=se.useMemo(()=>Object.keys(S).filter(ee=>S[ee]),[S]),Q=se.useMemo(()=>q.filter(ee=>!!S[j(ee)]).length,[q,S,j]),J=q.length>0&&Q===q.length;function ie(ee){T(we=>({...we,[ee]:!we[ee]}))}function le(ee){C(j(ee)),O(ee.name)}function re(){C(""),O("")}async function Z(){if(!N)return;const ee=E.trim().replace(/\.(mp3|wav)$/i,"");if(!ee){a("Bitte einen gueltigen Namen eingeben","error");return}try{await i0e(N,ee),a("Sound umbenannt"),re(),await z()}catch(we){a((we==null?void 0:we.message)||"Umbenennen fehlgeschlagen","error")}}async function ne(ee){if(ee.length!==0)try{await n0e(ee),a(ee.length===1?"Sound geloescht":`${ee.length} Sounds geloescht`),T({}),re(),await z()}catch(we){a((we==null?void 0:we.message)||"Loeschen fehlgeschlagen","error")}}async function de(ee){I(0);try{await r0e(ee,we=>I(we)),a(`"${ee.name}" hochgeladen`),await z()}catch(we){a((we==null?void 0:we.message)||"Upload fehlgeschlagen","error")}finally{I(null)}}const[be,Te]=se.useState([]),[ae,Me]=se.useState([]),[Ve,Ce]=se.useState(!1),[Fe,tt]=se.useState(!1),[je,Rt]=se.useState({online:!1,botTag:null}),Et=se.useCallback(async()=>{Ce(!0);try{const[ee,we,Re]=await Promise.all([fetch("/api/notifications/status"),fetch("/api/notifications/channels",{credentials:"include"}),fetch("/api/notifications/config",{credentials:"include"})]);if(ee.ok){const We=await ee.json();Rt(We)}if(we.ok){const We=await we.json();Te(We.channels||[])}if(Re.ok){const We=await Re.json();Me(We.channels||[])}}catch{}finally{Ce(!1)}},[]),[Ft,Ut]=se.useState(!1);se.useEffect(()=>{t==="streaming"&&!Ft&&(Ut(!0),Et())},[t,Ft,Et]);const Ke=se.useCallback((ee,we,Re,We,Se)=>{Me(Le=>{const ct=Le.find(Dt=>Dt.channelId===ee);if(ct){const It=ct.events.includes(Se)?ct.events.filter(lt=>lt!==Se):[...ct.events,Se];return It.length===0?Le.filter(lt=>lt.channelId!==ee):Le.map(lt=>lt.channelId===ee?{...lt,events:It}:lt)}else return[...Le,{channelId:ee,channelName:we,guildId:Re,guildName:We,events:[Se]}]})},[]),ht=se.useCallback((ee,we)=>{const Re=ae.find(We=>We.channelId===ee);return(Re==null?void 0:Re.events.includes(we))??!1},[ae]),fe=se.useCallback(async()=>{tt(!0);try{await fetch("/api/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channels:ae}),credentials:"include"}),a("Konfiguration gespeichert")}catch{a("Speichern fehlgeschlagen","error")}finally{tt(!1)}},[ae,a]),[$t,_t]=se.useState([]),[Gt,yt]=se.useState(!1),Ht=se.useCallback(async()=>{yt(!0);try{const ee=await fetch("/api/game-library/admin/profiles",{credentials:"include"});if(ee.ok){const we=await ee.json();_t(we.profiles||[])}}catch{}finally{yt(!1)}},[]),[pt,Ae]=se.useState(!1);se.useEffect(()=>{t==="game-library"&&!pt&&(Ae(!0),Ht())},[t,pt,Ht]);const k=se.useCallback(async(ee,we)=>{if(confirm(`Profil "${we}" wirklich komplett loeschen? (Alle verknuepften Daten werden entfernt)`))try{(await fetch(`/api/game-library/admin/profile/${ee}`,{method:"DELETE",credentials:"include"})).ok&&(a("Profil geloescht"),Ht())}catch{a("Loeschen fehlgeschlagen","error")}},[Ht,a]),xe=[{id:"soundboard",icon:"🎵",label:"Soundboard"},{id:"streaming",icon:"📺",label:"Streaming"},{id:"game-library",icon:"🎮",label:"Game Library"}];return P.jsx("div",{className:"ap-overlay",onClick:ee=>{ee.target===ee.currentTarget&&i()},children:P.jsxs("div",{className:"ap-modal",children:[P.jsxs("div",{className:"ap-sidebar",children:[P.jsxs("div",{className:"ap-sidebar-title",children:["⚙️"," Admin"]}),P.jsx("nav",{className:"ap-nav",children:xe.map(ee=>P.jsxs("button",{className:`ap-nav-item ${t===ee.id?"active":""}`,onClick:()=>n(ee.id),children:[P.jsx("span",{className:"ap-nav-icon",children:ee.icon}),P.jsx("span",{className:"ap-nav-label",children:ee.label})]},ee.id))}),P.jsxs("button",{className:"ap-logout-btn",onClick:e,children:["🔒"," Abmelden"]})]}),P.jsxs("div",{className:"ap-content",children:[P.jsxs("div",{className:"ap-header",children:[P.jsxs("h2",{className:"ap-title",children:[(Oe=xe.find(ee=>ee.id===t))==null?void 0:Oe.icon," ",(Ue=xe.find(ee=>ee.id===t))==null?void 0:Ue.label]}),P.jsx("button",{className:"ap-close",onClick:i,children:"✕"})]}),P.jsxs("div",{className:"ap-body",children:[t==="soundboard"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsx("input",{type:"text",className:"ap-search",value:v,onChange:ee=>x(ee.target.value),placeholder:"Nach Name, Ordner oder Pfad filtern..."}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{z()},disabled:h,children:["↻"," Aktualisieren"]})]}),P.jsxs("label",{className:"ap-upload-zone",children:[P.jsx("input",{type:"file",accept:".mp3,.wav",style:{display:"none"},onChange:ee=>{var Re;const we=(Re=ee.target.files)==null?void 0:Re[0];we&&de(we),ee.target.value=""}}),U!==null?P.jsxs("span",{className:"ap-upload-progress",children:["Upload: ",U,"%"]}):P.jsxs("span",{className:"ap-upload-text",children:["⬆️"," Datei hochladen (MP3 / WAV)"]})]}),P.jsxs("div",{className:"ap-bulk-row",children:[P.jsxs("label",{className:"ap-select-all",children:[P.jsx("input",{type:"checkbox",checked:J,onChange:ee=>{const we=ee.target.checked,Re={...S};q.forEach(We=>{Re[j(We)]=we}),T(Re)}}),P.jsxs("span",{children:["Alle sichtbaren (",Q,"/",q.length,")"]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger",disabled:V.length===0,onClick:async()=>{window.confirm(`Wirklich ${V.length} Sound(s) loeschen?`)&&await ne(V)},children:["🗑️"," Ausgewaehlte loeschen"]})]}),P.jsx("div",{className:"ap-list-wrap",children:h?P.jsx("div",{className:"ap-empty",children:"Lade Sounds..."}):q.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Sounds gefunden."}):P.jsx("div",{className:"ap-list",children:q.map(ee=>{const we=j(ee),Re=N===we;return P.jsxs("div",{className:"ap-item",children:[P.jsx("label",{className:"ap-item-check",children:P.jsx("input",{type:"checkbox",checked:!!S[we],onChange:()=>ie(we)})}),P.jsxs("div",{className:"ap-item-main",children:[P.jsx("div",{className:"ap-item-name",children:ee.name}),P.jsxs("div",{className:"ap-item-meta",children:[ee.folder?`Ordner: ${ee.folder}`:"Root"," · ",we]}),Re&&P.jsxs("div",{className:"ap-rename-row",children:[P.jsx("input",{className:"ap-rename-input",value:E,onChange:We=>O(We.target.value),onKeyDown:We=>{We.key==="Enter"&&Z(),We.key==="Escape"&&re()},placeholder:"Neuer Name...",autoFocus:!0}),P.jsx("button",{className:"ap-btn ap-btn-primary ap-btn-sm",onClick:()=>{Z()},children:"Speichern"}),P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:re,children:"Abbrechen"})]})]}),!Re&&P.jsxs("div",{className:"ap-item-actions",children:[P.jsx("button",{className:"ap-btn ap-btn-outline ap-btn-sm",onClick:()=>le(ee),children:"Umbenennen"}),P.jsx("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:async()=>{window.confirm(`Sound "${ee.name}" loeschen?`)&&await ne([we])},children:"Loeschen"})]})]},we)})})})]}),t==="streaming"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:`ap-status-dot ${je.online?"online":""}`}),je.online?P.jsxs(P.Fragment,{children:["Bot online: ",P.jsx("b",{children:je.botTag})]}):P.jsx(P.Fragment,{children:"Bot offline"})]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{Et()},disabled:Ve,children:["↻"," Aktualisieren"]})]}),Ve?P.jsx("div",{className:"ap-empty",children:"Lade Kanaele..."}):be.length===0?P.jsx("div",{className:"ap-empty",children:je.online?"Keine Text-Kanaele gefunden. Bot hat moeglicherweise keinen Zugriff.":"Bot ist nicht verbunden. Bitte DISCORD_TOKEN_NOTIFICATIONS konfigurieren."}):P.jsxs(P.Fragment,{children:[P.jsx("p",{className:"ap-hint",children:"Waehle die Kanaele, in die Benachrichtigungen gesendet werden sollen:"}),P.jsx("div",{className:"ap-channel-list",children:be.map(ee=>P.jsxs("div",{className:"ap-channel-row",children:[P.jsxs("div",{className:"ap-channel-info",children:[P.jsxs("span",{className:"ap-channel-name",children:["#",ee.channelName]}),P.jsx("span",{className:"ap-channel-guild",children:ee.guildName})]}),P.jsxs("div",{className:"ap-channel-toggles",children:[P.jsxs("label",{className:`ap-toggle ${ht(ee.channelId,"stream_start")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:ht(ee.channelId,"stream_start"),onChange:()=>Ke(ee.channelId,ee.channelName,ee.guildId,ee.guildName,"stream_start")}),"🔴"," Stream Start"]}),P.jsxs("label",{className:`ap-toggle ${ht(ee.channelId,"stream_end")?"active":""}`,children:[P.jsx("input",{type:"checkbox",checked:ht(ee.channelId,"stream_end"),onChange:()=>Ke(ee.channelId,ee.channelName,ee.guildId,ee.guildName,"stream_end")}),"⏹️"," Stream Ende"]})]})]},ee.channelId))}),P.jsx("div",{className:"ap-save-row",children:P.jsx("button",{className:"ap-btn ap-btn-primary",onClick:fe,disabled:Fe,children:Fe?"Speichern...":"💾 Speichern"})})]})]}),t==="game-library"&&P.jsxs("div",{className:"ap-tab-content",children:[P.jsxs("div",{className:"ap-toolbar",children:[P.jsxs("span",{className:"ap-status-badge",children:[P.jsx("span",{className:"ap-status-dot online"}),"Eingeloggt als Admin"]}),P.jsxs("button",{className:"ap-btn ap-btn-outline",onClick:()=>{Ht()},disabled:Gt,children:["↻"," Aktualisieren"]})]}),Gt?P.jsx("div",{className:"ap-empty",children:"Lade Profile..."}):$t.length===0?P.jsx("div",{className:"ap-empty",children:"Keine Profile vorhanden."}):P.jsx("div",{className:"ap-profile-list",children:$t.map(ee=>P.jsxs("div",{className:"ap-profile-row",children:[P.jsx("img",{className:"ap-profile-avatar",src:ee.avatarUrl,alt:ee.displayName}),P.jsxs("div",{className:"ap-profile-info",children:[P.jsx("span",{className:"ap-profile-name",children:ee.displayName}),P.jsxs("span",{className:"ap-profile-details",children:[ee.steamName&&P.jsxs("span",{className:"ap-platform-badge steam",children:["Steam: ",ee.steamGames]}),ee.gogName&&P.jsxs("span",{className:"ap-platform-badge gog",children:["GOG: ",ee.gogGames]}),P.jsxs("span",{className:"ap-profile-total",children:[ee.totalGames," Spiele"]})]})]}),P.jsxs("button",{className:"ap-btn ap-btn-danger ap-btn-sm",onClick:()=>k(ee.id,ee.displayName),children:["🗑️"," Entfernen"]})]},ee.id))})]})]})]}),r&&P.jsxs("div",{className:`ap-toast ${r.type}`,children:[r.type==="error"?"❌":"✅"," ",r.msg]})]})})}const M7={radio:MAe,soundboard:jAe,lolstats:YAe,streaming:QAe,"watch-together":ZAe,"game-library":e0e};function a0e(){var Z;const[i,e]=se.useState(!1),[t,n]=se.useState([]),[r,s]=se.useState(()=>localStorage.getItem("hub_activeTab")??""),a=ne=>{s(ne),localStorage.setItem("hub_activeTab",ne)},[l,u]=se.useState(!1),[h,m]=se.useState({}),[v,x]=se.useState(!1),[S,T]=se.useState(!1),[N,C]=se.useState(!1),[E,O]=se.useState(""),[U,I]=se.useState(""),j=!!((Z=window.electronAPI)!=null&&Z.isElectron),z=j?window.electronAPI.version:null,[G,H]=se.useState("idle"),[q,V]=se.useState(""),Q=se.useRef(null);se.useEffect(()=>{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()},[]),se.useEffect(()=>{fetch("/api/soundboard/admin/status",{credentials:"include"}).then(ne=>ne.json()).then(ne=>x(!!ne.authenticated)).catch(()=>{})},[]),se.useEffect(()=>{if(!S)return;const ne=de=>{de.key==="Escape"&&T(!1)};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[S]);async function J(){I("");try{(await fetch("/api/soundboard/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:E}),credentials:"include"})).ok?(x(!0),O(""),T(!1)):I("Falsches Passwort")}catch{I("Verbindung fehlgeschlagen")}}async function ie(){await fetch("/api/soundboard/admin/logout",{method:"POST",credentials:"include"}),x(!1)}se.useEffect(()=>{var be;if(!j)return;const ne=window.electronAPI;ne.onUpdateAvailable(()=>H("downloading")),ne.onUpdateReady(()=>H("ready")),ne.onUpdateNotAvailable(()=>H("upToDate")),ne.onUpdateError(Te=>{H("error"),V(Te||"Unbekannter Fehler")});const de=(be=ne.getUpdateStatus)==null?void 0:be.call(ne);de==="downloading"?H("downloading"):de==="ready"?H("ready"):de==="checking"&&H("checking")},[j]),se.useEffect(()=>{fetch("/api/plugins").then(ne=>ne.json()).then(ne=>{if(n(ne),new URLSearchParams(location.search).has("viewStream")&&ne.some(ae=>ae.name==="streaming")){a("streaming");return}const be=localStorage.getItem("hub_activeTab"),Te=ne.some(ae=>ae.name===be);ne.length>0&&!Te&&a(ne[0].name)}).catch(()=>{})},[]),se.useEffect(()=>{let ne=null,de;function be(){ne=new EventSource("/api/events"),Q.current=ne,ne.onopen=()=>e(!0),ne.onmessage=Te=>{try{const ae=JSON.parse(Te.data);ae.type==="snapshot"?m(Me=>({...Me,...ae})):ae.plugin&&m(Me=>({...Me,[ae.plugin]:{...Me[ae.plugin]||{},...ae}}))}catch{}},ne.onerror=()=>{e(!1),ne==null||ne.close(),de=setTimeout(be,3e3)}}return be(),()=>{ne==null||ne.close(),clearTimeout(de)}},[]);const le="1.0.0-dev";se.useEffect(()=>{if(!l)return;const ne=de=>{de.key==="Escape"&&u(!1)};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[l]);const re={radio:"🌍",soundboard:"🎵",lolstats:"⚔️",stats:"📊",events:"📅",games:"🎲",gamevote:"🎮",streaming:"📺","watch-together":"🎬","game-library":"🎮"};return P.jsxs("div",{className:"hub-app",children:[P.jsxs("header",{className:"hub-header",children:[P.jsxs("div",{className:"hub-header-left",children:[P.jsx("span",{className:"hub-logo",children:"🎮"}),P.jsx("span",{className:"hub-title",children:"Gaming Hub"}),P.jsx("span",{className:`hub-conn-dot ${i?"online":""}`})]}),P.jsx("nav",{className:"hub-tabs",children:t.filter(ne=>ne.name in M7).map(ne=>P.jsxs("button",{className:`hub-tab ${r===ne.name?"active":""}`,onClick:()=>a(ne.name),title:ne.description,children:[P.jsx("span",{className:"hub-tab-icon",children:re[ne.name]??"📦"}),P.jsx("span",{className:"hub-tab-label",children:ne.name})]},ne.name))}),P.jsxs("div",{className:"hub-header-right",children:[!window.electronAPI&&P.jsxs("a",{className:"hub-download-btn",href:"/downloads/GamingHub-Setup.exe",download:!0,title:"Desktop App herunterladen",children:[P.jsx("span",{className:"hub-download-icon",children:"⬇️"}),P.jsx("span",{className:"hub-download-label",children:"Desktop App"})]}),P.jsx("button",{className:`hub-admin-btn ${v?"active":""}`,onClick:()=>v?C(!0):T(!0),onContextMenu:ne=>{v&&(ne.preventDefault(),ie())},title:v?"Admin Panel (Rechtsklick = Abmelden)":"Admin Login",children:v?"🔓":"🔒"}),P.jsx("button",{className:"hub-refresh-btn",onClick:()=>window.location.reload(),title:"Seite neu laden",children:"🔄"}),P.jsxs("span",{className:"hub-version hub-version-clickable",onClick:()=>{var ne;if(j){const de=window.electronAPI,be=(ne=de.getUpdateStatus)==null?void 0:ne.call(de);be==="downloading"?H("downloading"):be==="ready"?H("ready"):be==="checking"&&H("checking")}u(!0)},title:"Versionsinformationen",children:["v",le]})]})]}),l&&P.jsx("div",{className:"hub-version-overlay",onClick:()=>u(!1),children:P.jsxs("div",{className:"hub-version-modal",onClick:ne=>ne.stopPropagation(),children:[P.jsxs("div",{className:"hub-version-modal-header",children:[P.jsx("span",{children:"Versionsinformationen"}),P.jsx("button",{className:"hub-version-modal-close",onClick:()=>u(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-version-modal-body",children:[P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Hub-Version"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",le]})]}),j&&P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Desktop-App"}),P.jsxs("span",{className:"hub-version-modal-value",children:["v",z]})]}),P.jsxs("div",{className:"hub-version-modal-row",children:[P.jsx("span",{className:"hub-version-modal-label",children:"Server"}),P.jsxs("span",{className:"hub-version-modal-value",children:[P.jsx("span",{className:`hub-version-modal-dot ${i?"online":""}`}),i?"Verbunden":"Getrennt"]})]}),j&&P.jsxs("div",{className:"hub-version-modal-update",children:[G==="idle"&&P.jsxs("button",{className:"hub-version-modal-update-btn",onClick:()=>{H("checking"),V(""),window.electronAPI.checkForUpdates()},children:["🔄"," Nach Updates suchen"]}),G==="checking"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Suche nach Updates…"]}),G==="downloading"&&P.jsxs("div",{className:"hub-version-modal-update-status",children:[P.jsx("span",{className:"hub-update-spinner"}),"Update wird heruntergeladen…"]}),G==="ready"&&P.jsxs("button",{className:"hub-version-modal-update-btn ready",onClick:()=>window.electronAPI.installUpdate(),children:["✅"," Jetzt installieren & neu starten"]}),G==="upToDate"&&P.jsxs("div",{className:"hub-version-modal-update-status success",children:["✅"," App ist aktuell",P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut prüfen"})]}),G==="error"&&P.jsxs("div",{className:"hub-version-modal-update-status error",children:["❌"," ",q,P.jsx("button",{className:"hub-version-modal-update-retry",onClick:()=>H("idle"),children:"Erneut versuchen"})]})]})]})]})}),S&&P.jsx("div",{className:"hub-admin-overlay",onClick:()=>T(!1),children:P.jsxs("div",{className:"hub-admin-modal",onClick:ne=>ne.stopPropagation(),children:[P.jsxs("div",{className:"hub-admin-modal-header",children:[P.jsxs("span",{children:["🔒"," Admin Login"]}),P.jsx("button",{className:"hub-admin-modal-close",onClick:()=>T(!1),children:"✕"})]}),P.jsxs("div",{className:"hub-admin-modal-body",children:[P.jsx("input",{type:"password",className:"hub-admin-input",placeholder:"Admin-Passwort...",value:E,onChange:ne=>O(ne.target.value),onKeyDown:ne=>ne.key==="Enter"&&J(),autoFocus:!0}),U&&P.jsx("p",{className:"hub-admin-error",children:U}),P.jsx("button",{className:"hub-admin-submit",onClick:J,children:"Login"})]})]})}),N&&v&&P.jsx(s0e,{onClose:()=>C(!1),onLogout:()=>{ie(),C(!1)}}),P.jsx("main",{className:"hub-content",children:t.length===0?P.jsxs("div",{className:"hub-empty",children:[P.jsx("span",{className:"hub-empty-icon",children:"📦"}),P.jsx("h2",{children:"Keine Plugins geladen"}),P.jsx("p",{children:"Plugins werden im Server konfiguriert."})]}):t.map(ne=>{const de=M7[ne.name];if(!de)return null;const be=r===ne.name;return P.jsx("div",{className:`hub-tab-panel ${be?"active":""}`,style:be?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{display:"none"},children:P.jsx(de,{data:h[ne.name]||{},isAdmin:v})},ne.name)})})]})}IF.createRoot(document.getElementById("root")).render(P.jsx(a0e,{})); diff --git a/web/dist/index.html b/web/dist/index.html index e6783aa..da68df3 100644 --- a/web/dist/index.html +++ b/web/dist/index.html @@ -5,7 +5,7 @@ Gaming Hub - + diff --git a/web/src/plugins/soundboard/SoundboardTab.tsx b/web/src/plugins/soundboard/SoundboardTab.tsx index bf1274d..a58c165 100644 --- a/web/src/plugins/soundboard/SoundboardTab.tsx +++ b/web/src/plugins/soundboard/SoundboardTab.tsx @@ -1009,7 +1009,7 @@ export default function SoundboardTab({ data, isAdmin: isAdminProp }: Soundboard if (volDebounceRef.current) clearTimeout(volDebounceRef.current); volDebounceRef.current = setTimeout(() => { apiSetVolumeLive(guildId, v).catch(() => {}); - }, 120); + }, 50); } }} style={{ '--vol': `${Math.round(volume * 100)}%` } as React.CSSProperties} From c24b4c5d9e7dd54f5598701f015d5f02ba261db7 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Mon, 9 Mar 2026 23:00:49 +0000 Subject: [PATCH 29/53] v1.8.9 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1790d35..53ed4ba 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.8 +1.8.9 From 5796a6d62089b4f9164834da2b4b53dee0f072b0 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Mar 2026 17:38:06 +0100 Subject: [PATCH 30/53] Add: Forgejo CI/CD workflow (migrated from GitLab CI) --- .forgejo/workflows/build-deploy.yml | 175 ++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 .forgejo/workflows/build-deploy.yml diff --git a/.forgejo/workflows/build-deploy.yml b/.forgejo/workflows/build-deploy.yml new file mode 100644 index 0000000..db98457 --- /dev/null +++ b/.forgejo/workflows/build-deploy.yml @@ -0,0 +1,175 @@ +name: Build & Deploy + +on: + push: + branches: [main, nightly, feature/nightly] + +env: + REGISTRY: 192.168.1.100:3000 + IMAGE: root/gaming-hub + +jobs: + build: + runs-on: ubuntu-latest + container: + image: docker:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + steps: + - uses: actions/checkout@v4 + + - name: Determine version and tag + id: vars + run: | + VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0") + BRANCH="${GITHUB_REF_NAME}" + + if [ "$BRANCH" = "main" ]; then + TAG="main" + CHANNEL="stable" + elif [ "$BRANCH" = "nightly" ] || [ "$BRANCH" = "feature/nightly" ]; then + TAG="nightly" + VERSION="${VERSION}-nightly" + CHANNEL="nightly" + else + TAG=$(echo "$BRANCH" | sed 's/\//-/g') + VERSION="${VERSION}-dev" + CHANNEL="dev" + fi + + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT" + + - name: Build Docker image + run: | + docker build \ + --build-arg "VITE_BUILD_CHANNEL=${{ steps.vars.outputs.channel }}" \ + --build-arg "VITE_APP_VERSION=${{ steps.vars.outputs.version }}" \ + -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} \ + . + + if [ "${{ github.ref_name }}" = "main" ]; then + docker tag ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} \ + ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest + fi + + - name: Push to registry + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u root --password-stdin + docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} + if [ "${{ github.ref_name }}" = "main" ]; then + docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest + fi + + deploy: + runs-on: ubuntu-latest + needs: build + if: github.ref_name == 'main' + container: + image: docker:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + steps: + - name: Deploy container + run: | + DEPLOY_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE }}:latest" + CONTAINER_NAME="gaming-hub" + + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u root --password-stdin + docker pull "$DEPLOY_IMAGE" + docker stop "$CONTAINER_NAME" || true + docker rm "$CONTAINER_NAME" || true + + docker run -d \ + --name "$CONTAINER_NAME" \ + --network pangolin \ + --restart unless-stopped \ + -p 8085:8080 \ + -e TZ=Europe/Berlin \ + -e NODE_ENV=production \ + -e PORT=8080 \ + -e DATA_DIR=/data \ + -e SOUNDS_DIR=/data/sounds \ + -e "NODE_OPTIONS=--dns-result-order=ipv4first" \ + -e ADMIN_PWD="${{ secrets.GAMING_HUB_ADMIN_PWD }}" \ + -e PCM_CACHE_MAX_MB=2048 \ + -e DISCORD_TOKEN_JUKEBOX="${{ secrets.DISCORD_TOKEN_JUKEBOX }}" \ + -e DISCORD_TOKEN_RADIO="${{ secrets.DISCORD_TOKEN_RADIO }}" \ + -e DISCORD_TOKEN_NOTIFICATIONS="${{ secrets.DISCORD_TOKEN_NOTIFICATIONS }}" \ + -e PUBLIC_URL="${{ secrets.PUBLIC_URL }}" \ + -e STEAM_API_KEY="${{ secrets.STEAM_API_KEY }}" \ + -v /mnt/cache/appdata/gaming-hub/data:/data:rw \ + -v /mnt/cache/appdata/dockge/container/jukebox/sounds/:/data/sounds:rw \ + "$DEPLOY_IMAGE" + + docker ps --filter name="$CONTAINER_NAME" + docker image prune -f || true + + electron-build: + runs-on: ubuntu-latest + needs: deploy + if: github.ref_name == 'main' + container: + image: docker:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + steps: + - uses: actions/checkout@v4 + + - name: Build Electron app + run: | + VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0") + CONTAINER_NAME="gaming-hub" + + apk add --no-cache nodejs npm + cd electron + node -e " + const pkg = require('./package.json'); + pkg.version = '${VERSION}'; + require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); + " + npm ci --no-audit --no-fund + npx electron-forge make --platform win32 --arch x64 + + SRC_DIR="out/make/squirrel.windows/x64" + docker exec "$CONTAINER_NAME" mkdir -p /data/downloads + docker cp "${SRC_DIR}/RELEASES" "${CONTAINER_NAME}:/data/downloads/RELEASES" + + for f in ${SRC_DIR}/*.nupkg; do + docker cp "$f" "${CONTAINER_NAME}:/data/downloads/$(basename "$f")" + done + + SETUP_EXE=$(ls ${SRC_DIR}/*Setup*.exe 2>/dev/null | head -1) + if [ -n "$SETUP_EXE" ]; then + docker cp "$SETUP_EXE" "${CONTAINER_NAME}:/data/downloads/GamingHub-Setup.exe" + fi + + bump-version: + runs-on: ubuntu-latest + needs: deploy + if: github.ref_name == 'main' && !contains(github.event.head_commit.message, '[skip ci]') + container: + image: alpine/git:latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.PUSH_TOKEN }} + + - name: Bump patch version + run: | + git config user.name "Forgejo CI" + git config user.email "ci@adriahub.de" + + VERSION=$(cat VERSION) + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f2) + PATCH=$(echo "$VERSION" | cut -d. -f3) + NEXT_PATCH=$((PATCH + 1)) + NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}" + + echo "$NEXT_VERSION" > VERSION + git add VERSION + git commit -m "v${NEXT_VERSION} [skip ci]" + git push origin main From 9c483cedea7e470dc30f4c3724facd2197ba5f65 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Mar 2026 17:44:23 +0100 Subject: [PATCH 31/53] Debug: test runner --- .forgejo/workflows/debug.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .forgejo/workflows/debug.yml diff --git a/.forgejo/workflows/debug.yml b/.forgejo/workflows/debug.yml new file mode 100644 index 0000000..d4325d4 --- /dev/null +++ b/.forgejo/workflows/debug.yml @@ -0,0 +1,18 @@ +name: Debug Test + +on: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + container: + image: docker:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + steps: + - name: Test Docker + run: | + echo "Container works!" + docker version + docker ps | head -5 From 7e1b4e786007b2e6bc91da341fa7b70ed2337ff3 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Mar 2026 17:46:30 +0100 Subject: [PATCH 32/53] Fix: use git clone instead of actions/checkout (no Node in docker:latest) --- .forgejo/workflows/build-deploy.yml | 59 ++++++----------------------- 1 file changed, 11 insertions(+), 48 deletions(-) diff --git a/.forgejo/workflows/build-deploy.yml b/.forgejo/workflows/build-deploy.yml index db98457..cff3be2 100644 --- a/.forgejo/workflows/build-deploy.yml +++ b/.forgejo/workflows/build-deploy.yml @@ -16,7 +16,11 @@ jobs: volumes: - /var/run/docker.sock:/var/run/docker.sock steps: - - uses: actions/checkout@v4 + - name: Checkout + run: | + apk add --no-cache git + git clone --branch "${GITHUB_REF_NAME}" --depth 1 \ + "http://root:${{ secrets.PUSH_TOKEN }}@192.168.1.100:3000/${GITHUB_REPOSITORY}.git" . - name: Determine version and tag id: vars @@ -49,7 +53,7 @@ jobs: -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} \ . - if [ "${{ github.ref_name }}" = "main" ]; then + if [ "${GITHUB_REF_NAME}" = "main" ]; then docker tag ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} \ ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest fi @@ -58,7 +62,7 @@ jobs: run: | echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u root --password-stdin docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} - if [ "${{ github.ref_name }}" = "main" ]; then + if [ "${GITHUB_REF_NAME}" = "main" ]; then docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest fi @@ -106,45 +110,6 @@ jobs: docker ps --filter name="$CONTAINER_NAME" docker image prune -f || true - electron-build: - runs-on: ubuntu-latest - needs: deploy - if: github.ref_name == 'main' - container: - image: docker:latest - volumes: - - /var/run/docker.sock:/var/run/docker.sock - steps: - - uses: actions/checkout@v4 - - - name: Build Electron app - run: | - VERSION=$(cat VERSION 2>/dev/null || echo "0.0.0") - CONTAINER_NAME="gaming-hub" - - apk add --no-cache nodejs npm - cd electron - node -e " - const pkg = require('./package.json'); - pkg.version = '${VERSION}'; - require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); - " - npm ci --no-audit --no-fund - npx electron-forge make --platform win32 --arch x64 - - SRC_DIR="out/make/squirrel.windows/x64" - docker exec "$CONTAINER_NAME" mkdir -p /data/downloads - docker cp "${SRC_DIR}/RELEASES" "${CONTAINER_NAME}:/data/downloads/RELEASES" - - for f in ${SRC_DIR}/*.nupkg; do - docker cp "$f" "${CONTAINER_NAME}:/data/downloads/$(basename "$f")" - done - - SETUP_EXE=$(ls ${SRC_DIR}/*Setup*.exe 2>/dev/null | head -1) - if [ -n "$SETUP_EXE" ]; then - docker cp "$SETUP_EXE" "${CONTAINER_NAME}:/data/downloads/GamingHub-Setup.exe" - fi - bump-version: runs-on: ubuntu-latest needs: deploy @@ -152,13 +117,11 @@ jobs: container: image: alpine/git:latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ secrets.PUSH_TOKEN }} - - - name: Bump patch version + - name: Checkout and bump run: | + git clone --branch main --depth 5 \ + "http://root:${{ secrets.PUSH_TOKEN }}@192.168.1.100:3000/${GITHUB_REPOSITORY}.git" repo + cd repo git config user.name "Forgejo CI" git config user.email "ci@adriahub.de" From 710081fe21a3fb4733986d4015393e256de084e4 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Mar 2026 17:47:09 +0100 Subject: [PATCH 33/53] Remove debug workflow --- .forgejo/workflows/debug.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .forgejo/workflows/debug.yml diff --git a/.forgejo/workflows/debug.yml b/.forgejo/workflows/debug.yml deleted file mode 100644 index d4325d4..0000000 --- a/.forgejo/workflows/debug.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Debug Test - -on: - workflow_dispatch: - -jobs: - test: - runs-on: ubuntu-latest - container: - image: docker:latest - volumes: - - /var/run/docker.sock:/var/run/docker.sock - steps: - - name: Test Docker - run: | - echo "Container works!" - docker version - docker ps | head -5 From 5ff0dad28278aa901f33ff33f7fe9f6cadd32fd5 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Mar 2026 19:26:34 +0100 Subject: [PATCH 34/53] Fix: use HTTPS domain for registry push [skip ci] --- .forgejo/workflows/build-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build-deploy.yml b/.forgejo/workflows/build-deploy.yml index cff3be2..7aacbe3 100644 --- a/.forgejo/workflows/build-deploy.yml +++ b/.forgejo/workflows/build-deploy.yml @@ -5,7 +5,7 @@ on: branches: [main, nightly, feature/nightly] env: - REGISTRY: 192.168.1.100:3000 + REGISTRY: forgejo.adriahub.de IMAGE: root/gaming-hub jobs: From a7e840799608f2b9120bb282efc4a222e624d901 Mon Sep 17 00:00:00 2001 From: Forgejo CI Date: Tue, 10 Mar 2026 18:27:46 +0000 Subject: [PATCH 35/53] v1.8.10 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 53ed4ba..d9a03a9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.9 +1.8.10 From 99d69f30baf82c3ca4d450043af82b1f0f0b5e1e Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 10 Mar 2026 20:41:16 +0100 Subject: [PATCH 36/53] feat: Discord OAuth Login + User Settings GUI - Neues unified Login-Modal (Discord, Steam, Admin) ersetzt alten Admin-Login - Discord OAuth2 Backend (server/src/core/discord-auth.ts) - User Settings Panel: Entrance/Exit Sounds per Web-GUI konfigurierbar - API-Endpoints: /api/soundboard/user/{sounds,entrance,exit} - Session-Management via HMAC-signierte Cookies (hub_session) - Steam-Button als Platzhalter (bald verfuegbar) - Backward-kompatibel mit bestehendem Admin-Cookie Benoetigte neue Env-Vars: DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET Discord Redirect URI: PUBLIC_URL/api/auth/discord/callback Co-Authored-By: Claude Opus 4.6 --- server/src/core/discord-auth.ts | 247 ++++++++++ server/src/index.ts | 4 + server/src/plugins/soundboard/index.ts | 96 ++++ web/src/App.tsx | 177 +++++--- web/src/LoginModal.tsx | 124 ++++++ web/src/UserSettings.tsx | 254 +++++++++++ web/src/styles.css | 593 +++++++++++++++++++++++++ 7 files changed, 1435 insertions(+), 60 deletions(-) create mode 100644 server/src/core/discord-auth.ts create mode 100644 web/src/LoginModal.tsx create mode 100644 web/src/UserSettings.tsx diff --git a/server/src/core/discord-auth.ts b/server/src/core/discord-auth.ts new file mode 100644 index 0000000..253a10a --- /dev/null +++ b/server/src/core/discord-auth.ts @@ -0,0 +1,247 @@ +// ────────────────────────────────────────────────────────────────────────────── +// Discord OAuth2 Authentication + Unified Session Management +// ────────────────────────────────────────────────────────────────────────────── +import crypto from 'node:crypto'; +import type express from 'express'; + +// ── Config ── +const DISCORD_CLIENT_ID = process.env.DISCORD_CLIENT_ID ?? ''; +const DISCORD_CLIENT_SECRET = process.env.DISCORD_CLIENT_SECRET ?? ''; +const DISCORD_API = 'https://discord.com/api/v10'; +const DISCORD_AUTH_URL = 'https://discord.com/oauth2/authorize'; +const DISCORD_TOKEN_URL = `${DISCORD_API}/oauth2/token`; +const SESSION_MAX_AGE = 30 * 24 * 3600; // 30 days in seconds +const ADMIN_MAX_AGE = 7 * 24 * 3600; // 7 days in seconds + +// ── Types ── +export interface DiscordUser { + id: string; + username: string; + discriminator: string; + avatar: string | null; + global_name: string | null; +} + +export interface UserSession { + provider: 'discord' | 'admin'; + discordId?: string; + username?: string; + avatar?: string | null; + globalName?: string | null; + iat: number; + exp: number; +} + +// ── Helpers ── +function b64url(input: Buffer | string): string { + return Buffer.from(input).toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_'); +} + +function readCookie(req: express.Request, key: string): string | undefined { + const c = req.headers.cookie; + if (!c) return undefined; + for (const part of c.split(';')) { + const [k, v] = part.trim().split('='); + if (k === key) return decodeURIComponent(v || ''); + } + return undefined; +} + +// ── Session Token (HMAC-SHA256) ── +// Uses ADMIN_PWD as base secret, with a salt to differentiate from admin tokens +const SESSION_SECRET = (process.env.ADMIN_PWD ?? '') + ':hub_session_v1'; + +export function signSession(session: UserSession): string { + const body = b64url(JSON.stringify(session)); + const sig = crypto.createHmac('sha256', SESSION_SECRET).update(body).digest('base64url'); + return `${body}.${sig}`; +} + +export function verifySession(token: string | undefined): UserSession | null { + if (!token) return null; + const [body, sig] = token.split('.'); + if (!body || !sig) return null; + const expected = crypto.createHmac('sha256', SESSION_SECRET).update(body).digest('base64url'); + if (expected !== sig) return null; + try { + const session = JSON.parse(Buffer.from(body, 'base64').toString('utf8')) as UserSession; + if (typeof session.exp === 'number' && Date.now() < session.exp) return session; + return null; + } catch { return null; } +} + +export function getSession(req: express.Request): UserSession | null { + return verifySession(readCookie(req, 'hub_session')); +} + +// ── Admin Token (backward compat with soundboard plugin) ── +function signAdminTokenCompat(adminPwd: string): string { + const payload = { iat: Date.now(), exp: Date.now() + ADMIN_MAX_AGE * 1000 }; + const body = b64url(JSON.stringify(payload)); + const sig = crypto.createHmac('sha256', adminPwd).update(body).digest('base64url'); + return `${body}.${sig}`; +} + +// ── Discord OAuth2 ── +function getRedirectUri(): string { + const publicUrl = process.env.PUBLIC_URL ?? ''; + if (publicUrl) return `${publicUrl.replace(/\/$/, '')}/api/auth/discord/callback`; + return `http://localhost:${process.env.PORT ?? 8080}/api/auth/discord/callback`; +} + +export function isDiscordConfigured(): boolean { + return !!(DISCORD_CLIENT_ID && DISCORD_CLIENT_SECRET); +} + +function getDiscordAuthUrl(state: string): string { + const params = new URLSearchParams({ + client_id: DISCORD_CLIENT_ID, + redirect_uri: getRedirectUri(), + response_type: 'code', + scope: 'identify', + state, + }); + return `${DISCORD_AUTH_URL}?${params.toString()}`; +} + +async function exchangeDiscordCode(code: string): Promise { + const res = await fetch(DISCORD_TOKEN_URL, { + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: new URLSearchParams({ + client_id: DISCORD_CLIENT_ID, + client_secret: DISCORD_CLIENT_SECRET, + grant_type: 'authorization_code', + code, + redirect_uri: getRedirectUri(), + }), + }); + if (!res.ok) { + const text = await res.text(); + throw new Error(`Discord token exchange failed (${res.status}): ${text}`); + } + const data = await res.json() as { access_token: string }; + return data.access_token; +} + +async function fetchDiscordUser(accessToken: string): Promise { + const res = await fetch(`${DISCORD_API}/users/@me`, { + headers: { Authorization: `Bearer ${accessToken}` }, + }); + if (!res.ok) { + const text = await res.text(); + throw new Error(`Discord user fetch failed (${res.status}): ${text}`); + } + return await res.json() as DiscordUser; +} + +// ── Register Routes ── +export function registerAuthRoutes(app: express.Application, adminPwd: string): void { + + // Available providers + app.get('/api/auth/providers', (_req, res) => { + res.json({ + discord: isDiscordConfigured(), + steam: false, // Steam OpenID — planned + admin: !!adminPwd, + }); + }); + + // Current session + app.get('/api/auth/me', (req, res) => { + const session = getSession(req); + if (!session) { + res.json({ authenticated: false }); + return; + } + res.json({ + authenticated: true, + provider: session.provider, + discordId: session.discordId ?? null, + username: session.username ?? null, + avatar: session.avatar ?? null, + globalName: session.globalName ?? null, + isAdmin: session.provider === 'admin', + }); + }); + + // Discord OAuth2 — start + app.get('/api/auth/discord', (_req, res) => { + if (!isDiscordConfigured()) { + res.status(503).json({ error: 'Discord OAuth nicht konfiguriert (DISCORD_CLIENT_ID / DISCORD_CLIENT_SECRET fehlen)' }); + return; + } + const state = crypto.randomBytes(16).toString('hex'); + console.log(`[Auth] Discord OAuth2 redirect → ${getRedirectUri()}`); + res.redirect(getDiscordAuthUrl(state)); + }); + + // Discord OAuth2 — callback + app.get('/api/auth/discord/callback', async (req, res) => { + const code = req.query.code as string | undefined; + if (!code) { + res.status(400).send('Kein Authorization-Code erhalten.'); + return; + } + try { + const accessToken = await exchangeDiscordCode(code); + const user = await fetchDiscordUser(accessToken); + + const avatarUrl = user.avatar + ? `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png?size=128` + : null; + + const session: UserSession = { + provider: 'discord', + discordId: user.id, + username: user.username, + avatar: avatarUrl, + globalName: user.global_name, + iat: Date.now(), + exp: Date.now() + SESSION_MAX_AGE * 1000, + }; + + const token = signSession(session); + res.setHeader('Set-Cookie', `hub_session=${encodeURIComponent(token)}; HttpOnly; Path=/; Max-Age=${SESSION_MAX_AGE}; SameSite=Lax`); + console.log(`[Auth] Discord login: ${user.username} (${user.id})`); + res.redirect('/'); + } catch (e) { + console.error('[Auth] Discord callback error:', e); + res.status(500).send('Discord Login fehlgeschlagen. Bitte erneut versuchen.'); + } + }); + + // Admin login (via unified modal) + app.post('/api/auth/admin', (req, res) => { + if (!adminPwd) { res.status(503).json({ error: 'Admin nicht konfiguriert' }); return; } + const { password } = req.body ?? {}; + if (!password || password !== adminPwd) { + res.status(401).json({ error: 'Falsches Passwort' }); + return; + } + const session: UserSession = { + provider: 'admin', + username: 'Admin', + iat: Date.now(), + exp: Date.now() + ADMIN_MAX_AGE * 1000, + }; + const hubToken = signSession(session); + const adminToken = signAdminTokenCompat(adminPwd); + // Set hub_session AND legacy admin cookie (soundboard plugin reads 'admin' cookie) + res.setHeader('Set-Cookie', [ + `hub_session=${encodeURIComponent(hubToken)}; HttpOnly; Path=/; Max-Age=${ADMIN_MAX_AGE}; SameSite=Lax`, + `admin=${encodeURIComponent(adminToken)}; HttpOnly; Path=/; Max-Age=${ADMIN_MAX_AGE}; SameSite=Lax`, + ]); + console.log('[Auth] Admin login'); + res.json({ ok: true }); + }); + + // Logout (clears all session cookies) + app.post('/api/auth/logout', (_req, res) => { + res.setHeader('Set-Cookie', [ + 'hub_session=; HttpOnly; Path=/; Max-Age=0; SameSite=Lax', + 'admin=; HttpOnly; Path=/; Max-Age=0; SameSite=Lax', + ]); + res.json({ ok: true }); + }); +} diff --git a/server/src/index.ts b/server/src/index.ts index 6c322c2..c1676bb 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -8,6 +8,7 @@ import { createClient } from './core/discord.js'; import { addSSEClient, removeSSEClient, sseBroadcast, getSSEClientCount } from './core/sse.js'; import { loadState, getFullState, getStateDiag } from './core/persistence.js'; import { getPlugins, registerPlugin, getPluginCtx, type PluginContext } from './core/plugin.js'; +import { registerAuthRoutes } from './core/discord-auth.js'; import radioPlugin from './plugins/radio/index.js'; import soundboardPlugin from './plugins/soundboard/index.js'; import lolstatsPlugin from './plugins/lolstats/index.js'; @@ -130,6 +131,9 @@ function onClientReady(botName: string, client: Client): void { // ── Init ── async function boot(): Promise { + // ── Auth routes (before plugins so /api/auth/* is available) ── + registerAuthRoutes(app, ADMIN_PWD); + // ── Register plugins with their bot contexts ── registerPlugin(soundboardPlugin, ctxJukebox); registerPlugin(radioPlugin, ctxRadio); diff --git a/server/src/plugins/soundboard/index.ts b/server/src/plugins/soundboard/index.ts index 77b49e3..ea050d7 100644 --- a/server/src/plugins/soundboard/index.ts +++ b/server/src/plugins/soundboard/index.ts @@ -17,6 +17,7 @@ import nacl from 'tweetnacl'; import { ChannelType, Events, type VoiceBasedChannel, type VoiceState, type Message } from 'discord.js'; import type { Plugin, PluginContext } from '../../core/plugin.js'; import { sseBroadcast } from '../../core/sse.js'; +import { getSession } from '../../core/discord-auth.js'; // ── Config (env) ── const SOUNDS_DIR = process.env.SOUNDS_DIR ?? '/data/sounds'; @@ -1244,6 +1245,101 @@ const soundboardPlugin: Plugin = { }); }); + // ── User Sound Preferences (Discord-authenticated) ── + // Get current user's entrance/exit sounds + app.get('/api/soundboard/user/sounds', (req, res) => { + const session = getSession(req); + if (!session?.discordId) { + res.status(401).json({ error: 'Nicht eingeloggt' }); + return; + } + const userId = session.discordId; + const entrance = persistedState.entranceSounds?.[userId] ?? null; + const exit = persistedState.exitSounds?.[userId] ?? null; + res.json({ entrance, exit }); + }); + + // Set entrance sound + app.post('/api/soundboard/user/entrance', (req, res) => { + const session = getSession(req); + if (!session?.discordId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } + const { fileName } = req.body ?? {}; + if (!fileName || typeof fileName !== 'string') { res.status(400).json({ error: 'fileName erforderlich' }); return; } + if (!/\.(mp3|wav)$/i.test(fileName)) { res.status(400).json({ error: 'Nur .mp3 oder .wav' }); return; } + // Resolve file path (same logic as DM handler) + const resolve = (() => { + try { + if (fs.existsSync(path.join(SOUNDS_DIR, fileName))) return fileName; + for (const d of fs.readdirSync(SOUNDS_DIR, { withFileTypes: true })) { + if (!d.isDirectory()) continue; + if (fs.existsSync(path.join(SOUNDS_DIR, d.name, fileName))) return `${d.name}/${fileName}`; + } + return ''; + } catch { return ''; } + })(); + if (!resolve) { res.status(404).json({ error: 'Datei nicht gefunden' }); return; } + persistedState.entranceSounds = persistedState.entranceSounds ?? {}; + persistedState.entranceSounds[session.discordId] = resolve; + writeState(); + console.log(`[Soundboard] User ${session.username} (${session.discordId}) set entrance: ${resolve}`); + res.json({ ok: true, entrance: resolve }); + }); + + // Set exit sound + app.post('/api/soundboard/user/exit', (req, res) => { + const session = getSession(req); + if (!session?.discordId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } + const { fileName } = req.body ?? {}; + if (!fileName || typeof fileName !== 'string') { res.status(400).json({ error: 'fileName erforderlich' }); return; } + if (!/\.(mp3|wav)$/i.test(fileName)) { res.status(400).json({ error: 'Nur .mp3 oder .wav' }); return; } + const resolve = (() => { + try { + if (fs.existsSync(path.join(SOUNDS_DIR, fileName))) return fileName; + for (const d of fs.readdirSync(SOUNDS_DIR, { withFileTypes: true })) { + if (!d.isDirectory()) continue; + if (fs.existsSync(path.join(SOUNDS_DIR, d.name, fileName))) return `${d.name}/${fileName}`; + } + return ''; + } catch { return ''; } + })(); + if (!resolve) { res.status(404).json({ error: 'Datei nicht gefunden' }); return; } + persistedState.exitSounds = persistedState.exitSounds ?? {}; + persistedState.exitSounds[session.discordId] = resolve; + writeState(); + console.log(`[Soundboard] User ${session.username} (${session.discordId}) set exit: ${resolve}`); + res.json({ ok: true, exit: resolve }); + }); + + // Remove entrance sound + app.delete('/api/soundboard/user/entrance', (req, res) => { + const session = getSession(req); + if (!session?.discordId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } + if (persistedState.entranceSounds) { + delete persistedState.entranceSounds[session.discordId]; + writeState(); + } + console.log(`[Soundboard] User ${session.username} (${session.discordId}) removed entrance sound`); + res.json({ ok: true }); + }); + + // Remove exit sound + app.delete('/api/soundboard/user/exit', (req, res) => { + const session = getSession(req); + if (!session?.discordId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } + if (persistedState.exitSounds) { + delete persistedState.exitSounds[session.discordId]; + writeState(); + } + console.log(`[Soundboard] User ${session.username} (${session.discordId}) removed exit sound`); + res.json({ ok: true }); + }); + + // List available sounds (for user settings dropdown) - no auth required + app.get('/api/soundboard/user/available-sounds', (_req, res) => { + const allSounds = listAllSounds(); + res.json(allSounds.map(s => ({ name: s.name, fileName: s.fileName, folder: s.folder, relativePath: s.relativePath }))); + }); + // ── Health ── app.get('/api/soundboard/health', (_req, res) => { res.json({ ok: true, totalPlays: persistedState.totalPlays ?? 0, categories: (persistedState.categories ?? []).length, sounds: listAllSounds().length }); diff --git a/web/src/App.tsx b/web/src/App.tsx index b1290e2..065dc9b 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -6,6 +6,8 @@ import StreamingTab from './plugins/streaming/StreamingTab'; import WatchTogetherTab from './plugins/watch-together/WatchTogetherTab'; import GameLibraryTab from './plugins/game-library/GameLibraryTab'; import AdminPanel from './AdminPanel'; +import LoginModal from './LoginModal'; +import UserSettings from './UserSettings'; interface PluginInfo { name: string; @@ -13,6 +15,22 @@ interface PluginInfo { description: string; } +interface AuthUser { + authenticated: boolean; + provider?: 'discord' | 'admin'; + discordId?: string; + username?: string; + avatar?: string | null; + globalName?: string | null; + isAdmin?: boolean; +} + +interface AuthProviders { + discord: boolean; + steam: boolean; + admin: boolean; +} + // Plugin tab components const tabComponents: Record> = { radio: RadioTab, @@ -41,12 +59,16 @@ export default function App() { const [showVersionModal, setShowVersionModal] = useState(false); const [pluginData, setPluginData] = useState>({}); - // Centralized admin login state - const [isAdmin, setIsAdmin] = useState(false); - const [showAdminLogin, setShowAdminLogin] = useState(false); + // ── Unified Auth State ── + const [user, setUser] = useState({ authenticated: false }); + const [providers, setProviders] = useState({ discord: false, steam: false, admin: false }); + const [showLoginModal, setShowLoginModal] = useState(false); + const [showUserSettings, setShowUserSettings] = useState(false); const [showAdminPanel, setShowAdminPanel] = useState(false); - const [adminPwd, setAdminPwd] = useState(''); - const [adminError, setAdminError] = useState(''); + + // Derived state + const isAdmin = user.authenticated && (user.provider === 'admin' || user.isAdmin === true); + const isDiscordUser = user.authenticated && user.provider === 'discord'; // Electron auto-update state const isElectron = !!(window as any).electronAPI?.isElectron; @@ -62,46 +84,54 @@ export default function App() { } }, []); - // Check admin status on mount (shared cookie — any endpoint works) + // Check auth status + providers on mount useEffect(() => { + fetch('/api/auth/me', { credentials: 'include' }) + .then(r => r.json()) + .then((data: AuthUser) => setUser(data)) + .catch(() => {}); + + fetch('/api/auth/providers') + .then(r => r.json()) + .then((data: AuthProviders) => setProviders(data)) + .catch(() => {}); + + // Also check legacy admin cookie (backward compat) fetch('/api/soundboard/admin/status', { credentials: 'include' }) .then(r => r.json()) - .then(d => setIsAdmin(!!d.authenticated)) + .then(d => { + if (d.authenticated) { + setUser(prev => prev.authenticated ? prev : { authenticated: true, provider: 'admin', username: 'Admin', isAdmin: true }); + } + }) .catch(() => {}); }, []); - // Escape key closes admin login modal - useEffect(() => { - if (!showAdminLogin) return; - const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') setShowAdminLogin(false); }; - window.addEventListener('keydown', handler); - return () => window.removeEventListener('keydown', handler); - }, [showAdminLogin]); - - async function handleAdminLogin() { - setAdminError(''); + // Admin login handler (for LoginModal) + async function handleAdminLogin(password: string): Promise { try { - const resp = await fetch('/api/soundboard/admin/login', { + const resp = await fetch('/api/auth/admin', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ password: adminPwd }), + body: JSON.stringify({ password }), credentials: 'include', }); if (resp.ok) { - setIsAdmin(true); - setAdminPwd(''); - setShowAdminLogin(false); - } else { - setAdminError('Falsches Passwort'); + setUser({ authenticated: true, provider: 'admin', username: 'Admin', isAdmin: true }); + return true; } + return false; } catch { - setAdminError('Verbindung fehlgeschlagen'); + return false; } } - async function handleAdminLogout() { - await fetch('/api/soundboard/admin/logout', { method: 'POST', credentials: 'include' }); - setIsAdmin(false); + // Unified logout + async function handleLogout() { + await fetch('/api/auth/logout', { method: 'POST', credentials: 'include' }); + setUser({ authenticated: false }); + setShowUserSettings(false); + setShowAdminPanel(false); } // Electron auto-update listeners @@ -203,6 +233,17 @@ export default function App() { 'game-library': '\u{1F3AE}', }; + // What happens when the user button is clicked + function handleUserButtonClick() { + if (!user.authenticated) { + setShowLoginModal(true); + } else if (isAdmin) { + setShowAdminPanel(true); + } else if (isDiscordUser) { + setShowUserSettings(true); + } + } + return (
@@ -238,14 +279,34 @@ export default function App() { Desktop App )} + + {/* Unified Login / User button */} +
)} - {showAdminLogin && ( -
setShowAdminLogin(false)}> -
e.stopPropagation()}> -
- {'\uD83D\uDD12'} Admin Login - -
-
- setAdminPwd(e.target.value)} - onKeyDown={e => e.key === 'Enter' && handleAdminLogin()} - autoFocus - /> - {adminError &&

{adminError}

} - -
-
-
+ {/* Login Modal */} + {showLoginModal && ( + setShowLoginModal(false)} + onAdminLogin={handleAdminLogin} + providers={providers} + /> )} + {/* User Settings (Discord users) */} + {showUserSettings && isDiscordUser && user.discordId && ( + setShowUserSettings(false)} + onLogout={handleLogout} + /> + )} + + {/* Admin Panel */} {showAdminPanel && isAdmin && ( - setShowAdminPanel(false)} onLogout={() => { handleAdminLogout(); setShowAdminPanel(false); }} /> + setShowAdminPanel(false)} onLogout={() => { handleLogout(); setShowAdminPanel(false); }} /> )}
diff --git a/web/src/LoginModal.tsx b/web/src/LoginModal.tsx new file mode 100644 index 0000000..561ae0b --- /dev/null +++ b/web/src/LoginModal.tsx @@ -0,0 +1,124 @@ +import { useState, useEffect } from 'react'; + +interface LoginModalProps { + onClose: () => void; + onAdminLogin: (password: string) => Promise; + providers: { discord: boolean; steam: boolean; admin: boolean }; +} + +export default function LoginModal({ onClose, onAdminLogin, providers }: LoginModalProps) { + const [showAdminForm, setShowAdminForm] = useState(false); + const [adminPwd, setAdminPwd] = useState(''); + const [adminError, setAdminError] = useState(''); + const [loading, setLoading] = useState(false); + + // Close on Escape + useEffect(() => { + const handler = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + if (showAdminForm) setShowAdminForm(false); + else onClose(); + } + }; + window.addEventListener('keydown', handler); + return () => window.removeEventListener('keydown', handler); + }, [onClose, showAdminForm]); + + async function handleAdminSubmit() { + if (!adminPwd.trim()) return; + setLoading(true); + setAdminError(''); + const ok = await onAdminLogin(adminPwd); + setLoading(false); + if (ok) { + setAdminPwd(''); + onClose(); + } else { + setAdminError('Falsches Passwort'); + } + } + + return ( +
+
e.stopPropagation()}> +
+ {'\uD83D\uDD10'} Anmelden + +
+ + {!showAdminForm ? ( +
+

Melde dich an, um deine Einstellungen zu verwalten.

+ +
+ {/* Discord */} + {providers.discord && ( + + + + + Mit Discord anmelden + + )} + + {/* Steam — placeholder */} + + + {/* Admin */} + {providers.admin && ( + + )} +
+ + {!providers.discord && ( +

+ {'\u2139\uFE0F'} Discord Login ist nicht konfiguriert. Der Server braucht DISCORD_CLIENT_ID und DISCORD_CLIENT_SECRET. +

+ )} +
+ ) : ( +
+ +
+ + setAdminPwd(e.target.value)} + onKeyDown={e => e.key === 'Enter' && handleAdminSubmit()} + autoFocus + disabled={loading} + /> + {adminError &&

{adminError}

} + +
+
+ )} +
+
+ ); +} diff --git a/web/src/UserSettings.tsx b/web/src/UserSettings.tsx new file mode 100644 index 0000000..1720c46 --- /dev/null +++ b/web/src/UserSettings.tsx @@ -0,0 +1,254 @@ +import { useState, useEffect, useCallback } from 'react'; + +interface UserInfo { + discordId: string; + username: string; + avatar: string | null; + globalName: string | null; +} + +interface SoundOption { + name: string; + fileName: string; + folder: string; + relativePath: string; +} + +interface UserSettingsProps { + user: UserInfo; + onClose: () => void; + onLogout: () => void; +} + +export default function UserSettings({ user, onClose, onLogout }: UserSettingsProps) { + const [entranceSound, setEntranceSound] = useState(null); + const [exitSound, setExitSound] = useState(null); + const [availableSounds, setAvailableSounds] = useState([]); + const [search, setSearch] = useState(''); + const [loading, setLoading] = useState(true); + const [saving, setSaving] = useState<'entrance' | 'exit' | null>(null); + const [message, setMessage] = useState<{ text: string; type: 'success' | 'error' } | null>(null); + const [activeSection, setActiveSection] = useState<'entrance' | 'exit'>('entrance'); + + // Fetch current sounds + available sounds + useEffect(() => { + Promise.all([ + fetch('/api/soundboard/user/sounds', { credentials: 'include' }).then(r => r.json()), + fetch('/api/soundboard/user/available-sounds').then(r => r.json()), + ]) + .then(([userSounds, sounds]) => { + setEntranceSound(userSounds.entrance ?? null); + setExitSound(userSounds.exit ?? null); + setAvailableSounds(sounds); + setLoading(false); + }) + .catch(() => { + setMessage({ text: 'Fehler beim Laden der Einstellungen', type: 'error' }); + setLoading(false); + }); + }, []); + + // Close on Escape + useEffect(() => { + const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; + window.addEventListener('keydown', handler); + return () => window.removeEventListener('keydown', handler); + }, [onClose]); + + const showMessage = useCallback((text: string, type: 'success' | 'error') => { + setMessage({ text, type }); + setTimeout(() => setMessage(null), 3000); + }, []); + + async function setSound(type: 'entrance' | 'exit', fileName: string) { + setSaving(type); + try { + const resp = await fetch(`/api/soundboard/user/${type}`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ fileName }), + credentials: 'include', + }); + if (resp.ok) { + const data = await resp.json(); + if (type === 'entrance') setEntranceSound(data.entrance); + else setExitSound(data.exit); + showMessage(`${type === 'entrance' ? 'Entrance' : 'Exit'}-Sound gesetzt!`, 'success'); + } else { + const err = await resp.json().catch(() => ({ error: 'Unbekannter Fehler' })); + showMessage(err.error || 'Fehler', 'error'); + } + } catch { + showMessage('Verbindungsfehler', 'error'); + } + setSaving(null); + } + + async function removeSound(type: 'entrance' | 'exit') { + setSaving(type); + try { + const resp = await fetch(`/api/soundboard/user/${type}`, { + method: 'DELETE', + credentials: 'include', + }); + if (resp.ok) { + if (type === 'entrance') setEntranceSound(null); + else setExitSound(null); + showMessage(`${type === 'entrance' ? 'Entrance' : 'Exit'}-Sound entfernt`, 'success'); + } + } catch { + showMessage('Verbindungsfehler', 'error'); + } + setSaving(null); + } + + // Group sounds by folder + const folders = new Map(); + const q = search.toLowerCase(); + for (const s of availableSounds) { + if (q && !s.name.toLowerCase().includes(q) && !s.fileName.toLowerCase().includes(q)) continue; + const key = s.folder || 'Allgemein'; + if (!folders.has(key)) folders.set(key, []); + folders.get(key)!.push(s); + } + // Sort folders alphabetically, "Allgemein" first + const sortedFolders = [...folders.entries()].sort(([a], [b]) => { + if (a === 'Allgemein') return -1; + if (b === 'Allgemein') return 1; + return a.localeCompare(b); + }); + + const currentSound = activeSection === 'entrance' ? entranceSound : exitSound; + + return ( +
+
e.stopPropagation()}> + {/* Header */} +
+
+ {user.avatar ? ( + + ) : ( +
{user.username[0]?.toUpperCase()}
+ )} +
+ {user.globalName || user.username} + @{user.username} +
+
+
+ + +
+
+ + {/* Message toast */} + {message && ( +
+ {message.type === 'success' ? '\u2705' : '\u274C'} {message.text} +
+ )} + + {loading ? ( +
+ Lade Einstellungen... +
+ ) : ( +
+ {/* Section tabs */} +
+ + +
+ + {/* Current sound display */} +
+ + Aktuell: {' '} + + {currentSound ? ( + + {'\uD83C\uDFB5'} {currentSound} + + + ) : ( + Kein Sound gesetzt + )} +
+ + {/* Search */} +
+ setSearch(e.target.value)} + /> + {search && ( + + )} +
+ + {/* Sound list */} +
+ {sortedFolders.length === 0 ? ( +
+ {search ? 'Keine Treffer' : 'Keine Sounds verfügbar'} +
+ ) : ( + sortedFolders.map(([folder, sounds]) => ( +
+
{'\uD83D\uDCC1'} {folder}
+
+ {sounds.map(s => { + const isSelected = currentSound === s.relativePath || currentSound === s.fileName; + return ( + + ); + })} +
+
+ )) + )} +
+
+ )} +
+
+ ); +} diff --git a/web/src/styles.css b/web/src/styles.css index a1bc6b9..8acdfbc 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -2313,3 +2313,596 @@ html, body { gap: 4px; } } + +/* ════════════════════════════════════════════════════════════════════════════ + Unified Login Button (Header) + ════════════════════════════════════════════════════════════════════════════ */ +.hub-user-btn { + display: flex; + align-items: center; + gap: 6px; + padding: 4px 12px; + border: 1px solid var(--border); + border-radius: var(--radius); + background: transparent; + color: var(--text-muted); + font-family: var(--font); + font-size: 13px; + font-weight: 500; + cursor: pointer; + transition: all var(--transition); + line-height: 1; + white-space: nowrap; +} +.hub-user-btn:hover { + color: var(--accent); + border-color: var(--accent); + background: rgba(var(--accent-rgb), 0.06); +} +.hub-user-btn.logged-in { + border-color: rgba(var(--accent-rgb), 0.3); + color: var(--text-normal); +} +.hub-user-btn.admin { + border-color: #4ade80; + color: #4ade80; +} +.hub-user-avatar { + width: 24px; + height: 24px; + border-radius: 50%; + object-fit: cover; +} +.hub-user-icon { + font-size: 16px; + line-height: 1; +} +.hub-user-label { + line-height: 1; +} + +/* ════════════════════════════════════════════════════════════════════════════ + Login Modal + ════════════════════════════════════════════════════════════════════════════ */ +.hub-login-overlay { + position: fixed; + inset: 0; + z-index: 9999; + display: flex; + align-items: center; + justify-content: center; + background: rgba(0, 0, 0, 0.7); + backdrop-filter: blur(4px); +} +.hub-login-modal { + background: var(--bg-primary); + border: 1px solid var(--border); + border-radius: 16px; + width: 380px; + max-width: 92vw; + box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); + overflow: hidden; + animation: hub-modal-in 200ms ease; +} +.hub-login-modal-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 16px 20px; + border-bottom: 1px solid var(--border); + font-weight: 700; + font-size: 15px; +} +.hub-login-modal-close { + background: none; + border: none; + color: var(--text-muted); + cursor: pointer; + font-size: 16px; + padding: 4px; + border-radius: 4px; + transition: all var(--transition); +} +.hub-login-modal-close:hover { + color: var(--text-normal); + background: var(--bg-tertiary); +} +.hub-login-modal-body { + padding: 20px; +} +.hub-login-subtitle { + color: var(--text-muted); + font-size: 13px; + margin: 0 0 16px; + line-height: 1.4; +} + +/* Provider Buttons */ +.hub-login-providers { + display: flex; + flex-direction: column; + gap: 10px; +} +.hub-login-provider-btn { + display: flex; + align-items: center; + gap: 12px; + padding: 12px 16px; + border: 1px solid var(--border); + border-radius: var(--radius-lg); + background: var(--bg-secondary); + color: var(--text-normal); + font-family: var(--font); + font-size: 14px; + font-weight: 500; + cursor: pointer; + transition: all var(--transition); + text-decoration: none; + position: relative; +} +.hub-login-provider-btn:hover:not(:disabled) { + border-color: var(--accent); + background: rgba(var(--accent-rgb), 0.06); + transform: translateY(-1px); +} +.hub-login-provider-btn:active:not(:disabled) { + transform: translateY(0); +} +.hub-login-provider-btn:disabled { + opacity: 0.5; + cursor: not-allowed; +} +.hub-login-provider-btn.discord:hover:not(:disabled) { + border-color: #5865F2; + background: rgba(88, 101, 242, 0.08); +} +.hub-login-provider-btn.steam:hover:not(:disabled) { + border-color: #1b2838; + background: rgba(27, 40, 56, 0.15); +} +.hub-login-provider-btn.admin:hover { + border-color: var(--accent); +} +.hub-login-provider-icon { + flex-shrink: 0; + width: 22px; + height: 22px; +} +.hub-login-provider-icon-emoji { + font-size: 20px; + line-height: 1; + flex-shrink: 0; +} +.hub-login-soon { + position: absolute; + right: 12px; + font-size: 10px; + font-weight: 600; + text-transform: uppercase; + color: var(--text-faint); + background: var(--bg-tertiary); + padding: 2px 6px; + border-radius: 4px; + letter-spacing: 0.5px; +} +.hub-login-hint { + margin: 16px 0 0; + font-size: 12px; + color: var(--text-faint); + line-height: 1.4; +} +.hub-login-back { + background: none; + border: none; + color: var(--text-muted); + font-family: var(--font); + font-size: 13px; + cursor: pointer; + padding: 0; + margin-bottom: 16px; + transition: color var(--transition); +} +.hub-login-back:hover { + color: var(--accent); +} + +/* Admin form inside login modal */ +.hub-login-admin-form { + display: flex; + flex-direction: column; + gap: 12px; +} +.hub-login-admin-label { + font-size: 14px; + font-weight: 600; + color: var(--text-normal); +} +.hub-login-admin-input { + width: 100%; + padding: 10px 14px; + border: 1px solid var(--border); + border-radius: var(--radius); + background: var(--bg-secondary); + color: var(--text-normal); + font-size: 14px; + font-family: var(--font); + box-sizing: border-box; + transition: border-color var(--transition); +} +.hub-login-admin-input:focus { + outline: none; + border-color: var(--accent); +} +.hub-login-admin-error { + color: var(--danger); + font-size: 13px; + margin: 0; +} +.hub-login-admin-submit { + padding: 10px 16px; + background: var(--accent); + color: #fff; + border: none; + border-radius: var(--radius); + font-size: 14px; + font-weight: 600; + font-family: var(--font); + cursor: pointer; + transition: opacity var(--transition); +} +.hub-login-admin-submit:hover:not(:disabled) { + opacity: 0.9; +} +.hub-login-admin-submit:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +/* ════════════════════════════════════════════════════════════════════════════ + User Settings Panel + ════════════════════════════════════════════════════════════════════════════ */ +.hub-usettings-overlay { + position: fixed; + inset: 0; + z-index: 9999; + display: flex; + align-items: center; + justify-content: center; + background: rgba(0, 0, 0, 0.7); + backdrop-filter: blur(4px); +} +.hub-usettings-panel { + background: var(--bg-primary); + border: 1px solid var(--border); + border-radius: 16px; + width: 520px; + max-width: 95vw; + max-height: 85vh; + box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); + overflow: hidden; + display: flex; + flex-direction: column; + animation: hub-modal-in 200ms ease; +} + +/* Header */ +.hub-usettings-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 16px 20px; + border-bottom: 1px solid var(--border); + flex-shrink: 0; +} +.hub-usettings-user { + display: flex; + align-items: center; + gap: 12px; +} +.hub-usettings-avatar { + width: 40px; + height: 40px; + border-radius: 50%; + object-fit: cover; + border: 2px solid rgba(var(--accent-rgb), 0.3); +} +.hub-usettings-avatar-placeholder { + width: 40px; + height: 40px; + border-radius: 50%; + background: var(--accent); + color: #fff; + display: flex; + align-items: center; + justify-content: center; + font-size: 18px; + font-weight: 700; +} +.hub-usettings-user-info { + display: flex; + flex-direction: column; + gap: 2px; +} +.hub-usettings-username { + font-weight: 600; + font-size: 15px; + color: var(--text-normal); +} +.hub-usettings-discriminator { + font-size: 12px; + color: var(--text-muted); +} +.hub-usettings-header-actions { + display: flex; + align-items: center; + gap: 8px; +} +.hub-usettings-logout { + background: none; + border: 1px solid var(--border); + border-radius: var(--radius); + color: var(--text-muted); + font-size: 16px; + padding: 6px 8px; + cursor: pointer; + transition: all var(--transition); + line-height: 1; +} +.hub-usettings-logout:hover { + color: var(--danger); + border-color: var(--danger); +} +.hub-usettings-close { + background: none; + border: none; + color: var(--text-muted); + font-size: 16px; + cursor: pointer; + padding: 6px; + border-radius: 4px; + transition: all var(--transition); +} +.hub-usettings-close:hover { + color: var(--text-normal); + background: var(--bg-tertiary); +} + +/* Toast */ +.hub-usettings-toast { + padding: 8px 16px; + font-size: 13px; + text-align: center; + animation: hub-toast-in 300ms ease; +} +.hub-usettings-toast.success { + background: rgba(87, 210, 143, 0.1); + color: var(--success); +} +.hub-usettings-toast.error { + background: rgba(237, 66, 69, 0.1); + color: var(--danger); +} +@keyframes hub-toast-in { + from { opacity: 0; transform: translateY(-4px); } + to { opacity: 1; transform: translateY(0); } +} + +/* Loading */ +.hub-usettings-loading { + display: flex; + align-items: center; + justify-content: center; + gap: 10px; + padding: 40px; + color: var(--text-muted); + font-size: 14px; +} + +/* Content */ +.hub-usettings-content { + display: flex; + flex-direction: column; + overflow: hidden; + flex: 1; +} + +/* Section tabs */ +.hub-usettings-tabs { + display: flex; + gap: 4px; + padding: 12px 20px 0; + flex-shrink: 0; +} +.hub-usettings-tab { + flex: 1; + padding: 10px 12px; + border: none; + background: var(--bg-secondary); + color: var(--text-muted); + font-family: var(--font); + font-size: 13px; + font-weight: 500; + cursor: pointer; + border-radius: var(--radius) var(--radius) 0 0; + transition: all var(--transition); +} +.hub-usettings-tab:hover { + color: var(--text-normal); + background: var(--bg-tertiary); +} +.hub-usettings-tab.active { + color: var(--accent); + background: rgba(var(--accent-rgb), 0.1); + border-bottom: 2px solid var(--accent); +} + +/* Current sound */ +.hub-usettings-current { + padding: 12px 20px; + display: flex; + align-items: center; + gap: 8px; + flex-shrink: 0; + background: var(--bg-secondary); + margin: 0 20px; + border-radius: 0 0 var(--radius) var(--radius); + margin-bottom: 12px; +} +.hub-usettings-current-label { + font-size: 13px; + color: var(--text-muted); + flex-shrink: 0; +} +.hub-usettings-current-value { + display: flex; + align-items: center; + gap: 6px; + font-size: 13px; + font-weight: 500; + color: var(--accent); +} +.hub-usettings-current-none { + font-size: 13px; + color: var(--text-faint); + font-style: italic; +} +.hub-usettings-remove-btn { + background: none; + border: none; + color: var(--text-faint); + cursor: pointer; + font-size: 11px; + padding: 2px 4px; + border-radius: 4px; + transition: all var(--transition); +} +.hub-usettings-remove-btn:hover:not(:disabled) { + color: var(--danger); + background: rgba(237, 66, 69, 0.1); +} + +/* Search */ +.hub-usettings-search-wrap { + position: relative; + padding: 0 20px; + margin-bottom: 12px; + flex-shrink: 0; +} +.hub-usettings-search { + width: 100%; + padding: 8px 32px 8px 12px; + border: 1px solid var(--border); + border-radius: var(--radius); + background: var(--bg-secondary); + color: var(--text-normal); + font-size: 13px; + font-family: var(--font); + box-sizing: border-box; + transition: border-color var(--transition); +} +.hub-usettings-search:focus { + outline: none; + border-color: var(--accent); +} +.hub-usettings-search-clear { + position: absolute; + right: 28px; + top: 50%; + transform: translateY(-50%); + background: none; + border: none; + color: var(--text-faint); + cursor: pointer; + font-size: 12px; + padding: 4px; +} +.hub-usettings-search-clear:hover { + color: var(--text-normal); +} + +/* Sound list */ +.hub-usettings-sounds { + flex: 1; + overflow-y: auto; + padding: 0 20px 16px; + scrollbar-width: thin; + scrollbar-color: var(--bg-tertiary) transparent; +} +.hub-usettings-empty { + text-align: center; + padding: 32px; + color: var(--text-faint); + font-size: 14px; +} + +/* Folder */ +.hub-usettings-folder { + margin-bottom: 12px; +} +.hub-usettings-folder-name { + font-size: 12px; + font-weight: 600; + color: var(--text-muted); + text-transform: uppercase; + letter-spacing: 0.5px; + padding: 4px 0; + margin-bottom: 6px; + border-bottom: 1px solid var(--border); +} +.hub-usettings-folder-sounds { + display: flex; + flex-wrap: wrap; + gap: 6px; +} + +/* Sound button */ +.hub-usettings-sound-btn { + display: flex; + align-items: center; + gap: 4px; + padding: 5px 10px; + border: 1px solid var(--border); + border-radius: 6px; + background: var(--bg-secondary); + color: var(--text-normal); + font-family: var(--font); + font-size: 12px; + cursor: pointer; + transition: all var(--transition); + white-space: nowrap; +} +.hub-usettings-sound-btn:hover:not(:disabled) { + border-color: var(--accent); + background: rgba(var(--accent-rgb), 0.06); +} +.hub-usettings-sound-btn.selected { + border-color: var(--accent); + background: rgba(var(--accent-rgb), 0.12); + color: var(--accent); +} +.hub-usettings-sound-btn:disabled { + opacity: 0.5; + cursor: wait; +} +.hub-usettings-sound-icon { + font-size: 12px; + line-height: 1; +} +.hub-usettings-sound-name { + max-width: 180px; + overflow: hidden; + text-overflow: ellipsis; +} + +/* ── Mobile responsive for user settings ── */ +@media (max-width: 600px) { + .hub-usettings-panel { + width: 100%; + max-width: 100vw; + max-height: 100vh; + border-radius: 0; + } + .hub-user-label { + display: none; + } +} From 6224db68b3b71143d192afe070d5577fd92770c2 Mon Sep 17 00:00:00 2001 From: Forgejo CI Date: Tue, 10 Mar 2026 19:42:36 +0000 Subject: [PATCH 37/53] v1.8.11 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d9a03a9..267637b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.10 +1.8.11 From 81c73407a0811d112ab500eba9a9f63152298871 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 10 Mar 2026 22:02:15 +0100 Subject: [PATCH 38/53] ci: add Discord OAuth2 env vars to deploy step Pass DISCORD_CLIENT_ID and DISCORD_CLIENT_SECRET secrets to the container for Discord OAuth2 login support. Co-Authored-By: Claude Opus 4.6 --- .forgejo/workflows/build-deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/build-deploy.yml b/.forgejo/workflows/build-deploy.yml index 7aacbe3..d566afd 100644 --- a/.forgejo/workflows/build-deploy.yml +++ b/.forgejo/workflows/build-deploy.yml @@ -103,6 +103,8 @@ jobs: -e DISCORD_TOKEN_NOTIFICATIONS="${{ secrets.DISCORD_TOKEN_NOTIFICATIONS }}" \ -e PUBLIC_URL="${{ secrets.PUBLIC_URL }}" \ -e STEAM_API_KEY="${{ secrets.STEAM_API_KEY }}" \ + -e DISCORD_CLIENT_ID="${{ secrets.DISCORD_CLIENT_ID }}" \ + -e DISCORD_CLIENT_SECRET="${{ secrets.DISCORD_CLIENT_SECRET }}" \ -v /mnt/cache/appdata/gaming-hub/data:/data:rw \ -v /mnt/cache/appdata/dockge/container/jukebox/sounds/:/data/sounds:rw \ "$DEPLOY_IMAGE" From aa998c9b44d0bb28e085ed86d5c1b0f46fd9ca4e Mon Sep 17 00:00:00 2001 From: Forgejo CI Date: Tue, 10 Mar 2026 21:03:19 +0000 Subject: [PATCH 39/53] v1.8.12 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 267637b..7d2424c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.11 +1.8.12 From d135aab6dc887c56c5e12b7ebc5ba5cea0abc5d5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 10 Mar 2026 22:18:37 +0100 Subject: [PATCH 40/53] feat: add Steam OpenID login - Add Steam OpenID 2.0 authentication routes (login + callback) - Enable Steam button in LoginModal (was placeholder) - Unified user ID system: getUserId() supports Discord, Steam, Admin - Update soundboard user-sound endpoints for Steam users - UserSettings now works for both Discord and Steam providers - Steam hover uses brand color #66c0f4 Co-Authored-By: Claude Opus 4.6 --- server/src/core/discord-auth.ts | 118 ++++++++++++++++++++++++- server/src/plugins/soundboard/index.ts | 36 ++++---- web/src/App.tsx | 16 ++-- web/src/LoginModal.tsx | 17 ++-- web/src/UserSettings.tsx | 7 +- web/src/styles.css | 6 +- 6 files changed, 162 insertions(+), 38 deletions(-) diff --git a/server/src/core/discord-auth.ts b/server/src/core/discord-auth.ts index 253a10a..53e8679 100644 --- a/server/src/core/discord-auth.ts +++ b/server/src/core/discord-auth.ts @@ -1,5 +1,5 @@ // ────────────────────────────────────────────────────────────────────────────── -// Discord OAuth2 Authentication + Unified Session Management +// Unified Authentication: Discord OAuth2, Steam OpenID 2.0, Admin // ────────────────────────────────────────────────────────────────────────────── import crypto from 'node:crypto'; import type express from 'express'; @@ -10,6 +10,7 @@ const DISCORD_CLIENT_SECRET = process.env.DISCORD_CLIENT_SECRET ?? ''; const DISCORD_API = 'https://discord.com/api/v10'; const DISCORD_AUTH_URL = 'https://discord.com/oauth2/authorize'; const DISCORD_TOKEN_URL = `${DISCORD_API}/oauth2/token`; +const STEAM_API_KEY = process.env.STEAM_API_KEY ?? ''; const SESSION_MAX_AGE = 30 * 24 * 3600; // 30 days in seconds const ADMIN_MAX_AGE = 7 * 24 * 3600; // 7 days in seconds @@ -23,8 +24,9 @@ export interface DiscordUser { } export interface UserSession { - provider: 'discord' | 'admin'; + provider: 'discord' | 'steam' | 'admin'; discordId?: string; + steamId?: string; username?: string; avatar?: string | null; globalName?: string | null; @@ -32,6 +34,14 @@ export interface UserSession { exp: number; } +/** Returns the generic user ID regardless of provider (discordId, steam:steamId, or 'admin') */ +export function getUserId(session: UserSession): string | null { + if (session.discordId) return session.discordId; + if (session.steamId) return `steam:${session.steamId}`; + if (session.provider === 'admin') return 'admin'; + return null; +} + // ── Helpers ── function b64url(input: Buffer | string): string { return Buffer.from(input).toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_'); @@ -135,6 +145,55 @@ async function fetchDiscordUser(accessToken: string): Promise { return await res.json() as DiscordUser; } +// ── Steam OpenID 2.0 ── +export function isSteamConfigured(): boolean { + return !!STEAM_API_KEY; +} + +function getSteamReturnUrl(req: express.Request): string { + const publicUrl = process.env.PUBLIC_URL ?? ''; + if (publicUrl) return `${publicUrl.replace(/\/$/, '')}/api/auth/steam/callback`; + const proto = req.headers['x-forwarded-proto'] || req.protocol || 'http'; + const host = req.headers['x-forwarded-host'] || req.headers.host || 'localhost'; + return `${proto}://${host}/api/auth/steam/callback`; +} + +function getSteamRealm(req: express.Request): string { + const publicUrl = process.env.PUBLIC_URL ?? ''; + if (publicUrl) return publicUrl.replace(/\/$/, ''); + const proto = req.headers['x-forwarded-proto'] || req.protocol || 'http'; + const host = req.headers['x-forwarded-host'] || req.headers.host || 'localhost'; + return `${proto}://${host}`; +} + +async function verifySteamOpenId(query: Record): Promise { + const params = new URLSearchParams(); + for (const [key, value] of Object.entries(query)) { + params.set(key, String(value)); + } + params.set('openid.mode', 'check_authentication'); + + const resp = await fetch(`https://steamcommunity.com/openid/login?${params.toString()}`); + const text = await resp.text(); + if (!text.includes('is_valid:true')) return null; + + const claimedId = String(query['openid.claimed_id'] || ''); + const match = claimedId.match(/\/id\/(\d+)$/); + return match ? match[1] : null; +} + +async function fetchSteamProfile(steamId: string): Promise<{ personaName: string; avatarUrl: string }> { + const url = `https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=${STEAM_API_KEY}&steamids=${steamId}`; + const resp = await fetch(url); + if (!resp.ok) throw new Error(`Steam API error: ${resp.status}`); + const json = await resp.json() as any; + const player = json?.response?.players?.[0]; + return { + personaName: player?.personaname || steamId, + avatarUrl: player?.avatarfull || '', + }; +} + // ── Register Routes ── export function registerAuthRoutes(app: express.Application, adminPwd: string): void { @@ -142,7 +201,7 @@ export function registerAuthRoutes(app: express.Application, adminPwd: string): app.get('/api/auth/providers', (_req, res) => { res.json({ discord: isDiscordConfigured(), - steam: false, // Steam OpenID — planned + steam: isSteamConfigured(), admin: !!adminPwd, }); }); @@ -158,6 +217,7 @@ export function registerAuthRoutes(app: express.Application, adminPwd: string): authenticated: true, provider: session.provider, discordId: session.discordId ?? null, + steamId: session.steamId ?? null, username: session.username ?? null, avatar: session.avatar ?? null, globalName: session.globalName ?? null, @@ -211,6 +271,58 @@ export function registerAuthRoutes(app: express.Application, adminPwd: string): } }); + // Steam OpenID 2.0 — start + app.get('/api/auth/steam', (req, res) => { + if (!isSteamConfigured()) { + res.status(503).json({ error: 'Steam nicht konfiguriert (STEAM_API_KEY fehlt)' }); + return; + } + const realm = getSteamRealm(req); + const returnTo = getSteamReturnUrl(req); + + const params = new URLSearchParams({ + 'openid.ns': 'http://specs.openid.net/auth/2.0', + 'openid.mode': 'checkid_setup', + 'openid.return_to': returnTo, + 'openid.realm': realm, + 'openid.identity': 'http://specs.openid.net/auth/2.0/identifier_select', + 'openid.claimed_id': 'http://specs.openid.net/auth/2.0/identifier_select', + }); + + console.log(`[Auth] Steam OpenID redirect → ${returnTo}`); + res.redirect(`https://steamcommunity.com/openid/login?${params.toString()}`); + }); + + // Steam OpenID 2.0 — callback + app.get('/api/auth/steam/callback', async (req, res) => { + try { + const steamId = await verifySteamOpenId(req.query as Record); + if (!steamId) { + res.status(403).send('Steam-Verifizierung fehlgeschlagen.'); + return; + } + + const profile = await fetchSteamProfile(steamId); + + const session: UserSession = { + provider: 'steam', + steamId, + username: profile.personaName, + avatar: profile.avatarUrl || null, + iat: Date.now(), + exp: Date.now() + SESSION_MAX_AGE * 1000, + }; + + const token = signSession(session); + res.setHeader('Set-Cookie', `hub_session=${encodeURIComponent(token)}; HttpOnly; Path=/; Max-Age=${SESSION_MAX_AGE}; SameSite=Lax`); + console.log(`[Auth] Steam login: ${profile.personaName} (${steamId})`); + res.redirect('/'); + } catch (e) { + console.error('[Auth] Steam callback error:', e); + res.status(500).send('Steam Login fehlgeschlagen. Bitte erneut versuchen.'); + } + }); + // Admin login (via unified modal) app.post('/api/auth/admin', (req, res) => { if (!adminPwd) { res.status(503).json({ error: 'Admin nicht konfiguriert' }); return; } diff --git a/server/src/plugins/soundboard/index.ts b/server/src/plugins/soundboard/index.ts index ea050d7..bb9f855 100644 --- a/server/src/plugins/soundboard/index.ts +++ b/server/src/plugins/soundboard/index.ts @@ -17,7 +17,7 @@ import nacl from 'tweetnacl'; import { ChannelType, Events, type VoiceBasedChannel, type VoiceState, type Message } from 'discord.js'; import type { Plugin, PluginContext } from '../../core/plugin.js'; import { sseBroadcast } from '../../core/sse.js'; -import { getSession } from '../../core/discord-auth.js'; +import { getSession, getUserId } from '../../core/discord-auth.js'; // ── Config (env) ── const SOUNDS_DIR = process.env.SOUNDS_DIR ?? '/data/sounds'; @@ -1245,15 +1245,15 @@ const soundboardPlugin: Plugin = { }); }); - // ── User Sound Preferences (Discord-authenticated) ── + // ── User Sound Preferences (Discord / Steam authenticated) ── // Get current user's entrance/exit sounds app.get('/api/soundboard/user/sounds', (req, res) => { const session = getSession(req); - if (!session?.discordId) { + const userId = session ? getUserId(session) : null; + if (!userId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } - const userId = session.discordId; const entrance = persistedState.entranceSounds?.[userId] ?? null; const exit = persistedState.exitSounds?.[userId] ?? null; res.json({ entrance, exit }); @@ -1262,7 +1262,8 @@ const soundboardPlugin: Plugin = { // Set entrance sound app.post('/api/soundboard/user/entrance', (req, res) => { const session = getSession(req); - if (!session?.discordId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } + const userId = session ? getUserId(session) : null; + if (!userId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } const { fileName } = req.body ?? {}; if (!fileName || typeof fileName !== 'string') { res.status(400).json({ error: 'fileName erforderlich' }); return; } if (!/\.(mp3|wav)$/i.test(fileName)) { res.status(400).json({ error: 'Nur .mp3 oder .wav' }); return; } @@ -1279,16 +1280,17 @@ const soundboardPlugin: Plugin = { })(); if (!resolve) { res.status(404).json({ error: 'Datei nicht gefunden' }); return; } persistedState.entranceSounds = persistedState.entranceSounds ?? {}; - persistedState.entranceSounds[session.discordId] = resolve; + persistedState.entranceSounds[userId] = resolve; writeState(); - console.log(`[Soundboard] User ${session.username} (${session.discordId}) set entrance: ${resolve}`); + console.log(`[Soundboard] User ${session!.username} (${userId}) set entrance: ${resolve}`); res.json({ ok: true, entrance: resolve }); }); // Set exit sound app.post('/api/soundboard/user/exit', (req, res) => { const session = getSession(req); - if (!session?.discordId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } + const userId = session ? getUserId(session) : null; + if (!userId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } const { fileName } = req.body ?? {}; if (!fileName || typeof fileName !== 'string') { res.status(400).json({ error: 'fileName erforderlich' }); return; } if (!/\.(mp3|wav)$/i.test(fileName)) { res.status(400).json({ error: 'Nur .mp3 oder .wav' }); return; } @@ -1304,33 +1306,35 @@ const soundboardPlugin: Plugin = { })(); if (!resolve) { res.status(404).json({ error: 'Datei nicht gefunden' }); return; } persistedState.exitSounds = persistedState.exitSounds ?? {}; - persistedState.exitSounds[session.discordId] = resolve; + persistedState.exitSounds[userId] = resolve; writeState(); - console.log(`[Soundboard] User ${session.username} (${session.discordId}) set exit: ${resolve}`); + console.log(`[Soundboard] User ${session!.username} (${userId}) set exit: ${resolve}`); res.json({ ok: true, exit: resolve }); }); // Remove entrance sound app.delete('/api/soundboard/user/entrance', (req, res) => { const session = getSession(req); - if (!session?.discordId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } + const userId = session ? getUserId(session) : null; + if (!userId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } if (persistedState.entranceSounds) { - delete persistedState.entranceSounds[session.discordId]; + delete persistedState.entranceSounds[userId]; writeState(); } - console.log(`[Soundboard] User ${session.username} (${session.discordId}) removed entrance sound`); + console.log(`[Soundboard] User ${session!.username} (${userId}) removed entrance sound`); res.json({ ok: true }); }); // Remove exit sound app.delete('/api/soundboard/user/exit', (req, res) => { const session = getSession(req); - if (!session?.discordId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } + const userId = session ? getUserId(session) : null; + if (!userId) { res.status(401).json({ error: 'Nicht eingeloggt' }); return; } if (persistedState.exitSounds) { - delete persistedState.exitSounds[session.discordId]; + delete persistedState.exitSounds[userId]; writeState(); } - console.log(`[Soundboard] User ${session.username} (${session.discordId}) removed exit sound`); + console.log(`[Soundboard] User ${session!.username} (${userId}) removed exit sound`); res.json({ ok: true }); }); diff --git a/web/src/App.tsx b/web/src/App.tsx index 065dc9b..2347765 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -17,8 +17,9 @@ interface PluginInfo { interface AuthUser { authenticated: boolean; - provider?: 'discord' | 'admin'; + provider?: 'discord' | 'steam' | 'admin'; discordId?: string; + steamId?: string; username?: string; avatar?: string | null; globalName?: string | null; @@ -69,6 +70,8 @@ export default function App() { // Derived state const isAdmin = user.authenticated && (user.provider === 'admin' || user.isAdmin === true); const isDiscordUser = user.authenticated && user.provider === 'discord'; + const isSteamUser = user.authenticated && user.provider === 'steam'; + const isRegularUser = isDiscordUser || isSteamUser; // Electron auto-update state const isElectron = !!(window as any).electronAPI?.isElectron; @@ -239,7 +242,7 @@ export default function App() { setShowLoginModal(true); } else if (isAdmin) { setShowAdminPanel(true); - } else if (isDiscordUser) { + } else if (isRegularUser) { setShowUserSettings(true); } } @@ -294,7 +297,7 @@ export default function App() { } > {user.authenticated ? ( - isDiscordUser && user.avatar ? ( + isRegularUser && user.avatar ? ( ) : ( {isAdmin ? '\uD83D\uDD27' : '\uD83D\uDC64'} @@ -435,11 +438,12 @@ export default function App() { /> )} - {/* User Settings (Discord users) */} - {showUserSettings && isDiscordUser && user.discordId && ( + {/* User Settings (Discord + Steam users) */} + {showUserSettings && isRegularUser && ( )} - {/* Steam — placeholder */} - + {/* Steam */} + {providers.steam && ( + + + + + Mit Steam anmelden + + )} {/* Admin */} {providers.admin && ( diff --git a/web/src/UserSettings.tsx b/web/src/UserSettings.tsx index 1720c46..cb7ce65 100644 --- a/web/src/UserSettings.tsx +++ b/web/src/UserSettings.tsx @@ -1,7 +1,8 @@ import { useState, useEffect, useCallback } from 'react'; interface UserInfo { - discordId: string; + id: string; + provider: 'discord' | 'steam'; username: string; avatar: string | null; globalName: string | null; @@ -133,7 +134,9 @@ export default function UserSettings({ user, onClose, onLogout }: UserSettingsPr )}
{user.globalName || user.username} - @{user.username} + + {user.provider === 'steam' ? 'Steam' : `@${user.username}`} +
diff --git a/web/src/styles.css b/web/src/styles.css index 8acdfbc..3b1c050 100644 --- a/web/src/styles.css +++ b/web/src/styles.css @@ -2456,9 +2456,9 @@ html, body { border-color: #5865F2; background: rgba(88, 101, 242, 0.08); } -.hub-login-provider-btn.steam:hover:not(:disabled) { - border-color: #1b2838; - background: rgba(27, 40, 56, 0.15); +.hub-login-provider-btn.steam:hover { + border-color: #66c0f4; + background: rgba(102, 192, 244, 0.08); } .hub-login-provider-btn.admin:hover { border-color: var(--accent); From bf69827dbd8fddb64b46cc854220e05b1eddb6ec Mon Sep 17 00:00:00 2001 From: Forgejo CI Date: Tue, 10 Mar 2026 21:19:44 +0000 Subject: [PATCH 41/53] v1.8.13 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7d2424c..59009bc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.12 +1.8.13 From 24e8a6b3f77186f69ff37e4fcc33fe46179731ef Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 10 Mar 2026 22:28:27 +0100 Subject: [PATCH 42/53] ci: mirror Docker images to daddelolymp registry After building and pushing to adriahub, the CI pipeline now also tags and pushes images to forgejo.daddelolymp.de as a backup. Co-Authored-By: Claude Opus 4.6 --- .forgejo/workflows/build-deploy.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/build-deploy.yml b/.forgejo/workflows/build-deploy.yml index d566afd..9cd5b41 100644 --- a/.forgejo/workflows/build-deploy.yml +++ b/.forgejo/workflows/build-deploy.yml @@ -6,6 +6,7 @@ on: env: REGISTRY: forgejo.adriahub.de + REGISTRY_MIRROR: forgejo.daddelolymp.de IMAGE: root/gaming-hub jobs: @@ -58,7 +59,7 @@ jobs: ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest fi - - name: Push to registry + - name: Push to registry (adriahub) run: | echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u root --password-stdin docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} @@ -66,6 +67,18 @@ jobs: docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest fi + - name: Mirror to registry (daddelolymp) + run: | + echo "${{ secrets.REGISTRY_DADDELOLYMP_PASSWORD }}" | docker login ${{ env.REGISTRY_MIRROR }} -u root --password-stdin + docker tag ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} \ + ${{ env.REGISTRY_MIRROR }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} + docker push ${{ env.REGISTRY_MIRROR }}/${{ env.IMAGE }}:${{ steps.vars.outputs.tag }} + if [ "${GITHUB_REF_NAME}" = "main" ]; then + docker tag ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest \ + ${{ env.REGISTRY_MIRROR }}/${{ env.IMAGE }}:latest + docker push ${{ env.REGISTRY_MIRROR }}/${{ env.IMAGE }}:latest + fi + deploy: runs-on: ubuntu-latest needs: build From 7fe9a16cd8cfa062c9d4e80784c06e40dc01bad2 Mon Sep 17 00:00:00 2001 From: Forgejo CI Date: Tue, 10 Mar 2026 21:29:44 +0000 Subject: [PATCH 43/53] v1.8.14 [skip ci] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 59009bc..8e8ed1b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.13 +1.8.14 From b8e4139a91af44d62ec02af9d92b6ca18298bf36 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 10 Mar 2026 22:38:57 +0100 Subject: [PATCH 44/53] feat(electron): add audio toggle to screen picker The stream screen picker now shows a toggle switch to enable/disable system audio capture (loopback). Defaults to on. Previously audio was always included with no way to disable it. Co-Authored-By: Claude Opus 4.6 --- electron/main.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/electron/main.js b/electron/main.js index 21f33fb..0f8233d 100644 --- a/electron/main.js +++ b/electron/main.js @@ -155,16 +155,31 @@ h2{font-size:16px;margin-bottom:12px;color:#ccc} .item:hover{border-color:#7c5cff;transform:scale(1.03)} .item img{width:100%;height:120px;object-fit:cover;display:block;background:#111} .item .label{padding:8px 10px;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} -.cancel-row{text-align:center;margin-top:14px} +.bottom-row{display:flex;align-items:center;justify-content:space-between;margin-top:14px;padding:0 4px} +.audio-toggle{display:flex;align-items:center;gap:8px;cursor:pointer;user-select:none} +.audio-toggle input{display:none} +.switch{width:36px;height:20px;background:#3a3a4e;border-radius:10px;position:relative;transition:background .2s} +.switch::after{content:'';position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:#888;transition:transform .2s,background .2s} +.audio-toggle input:checked+.switch{background:#7c5cff} +.audio-toggle input:checked+.switch::after{transform:translateX(16px);background:#fff} +.audio-label{font-size:13px;color:#aaa} .cancel-btn{background:#3a3a4e;color:#e0e0e0;border:none;padding:8px 24px;border-radius:6px;cursor:pointer;font-size:14px} .cancel-btn:hover{background:#4a4a5e}

Bildschirm oder Fenster w\\u00e4hlen

-
+
+ + +